#include "postgres.h" #include "fmgr.h" /* MIMETYPES */ #define IMAGE_UNKNOWN 0x00 #define IMAGE_JPG 0x01 #define IMAGE_PNG 0x02 /* IMAGE datatype */ struct pg_image { int32 length; /* VARLENA header */ uint8 imgtype; /* image type (IMAGE_JPG or IMAGE_PNG) */ int width; /* image width, in pixels */ int height; /* image height, in pixels */ int datasz; /* image filesize, in bytes */ char data[]; /* image data */ }; #define DatumGetImageP(X) ((struct pg_image *) PG_DETOAST_DATUM(X)) #define ImagePGetDatum(X) PointerGetDatum(X) #define PG_GETARG_IMAGE_P(n) DatumGetImageP(PG_GETARG_DATUM(n)) #define PG_RETURN_IMAGE_P(x) return ImagePGetDatum(x) Datum pg_image_in(PG_FUNCTION_ARGS); Datum pg_image_out(PG_FUNCTION_ARGS); Datum pg_image_in_text(PG_FUNCTION_ARGS); Datum pg_image_out_text(PG_FUNCTION_ARGS); Datum pg_image_from_bytea(PG_FUNCTION_ARGS); Datum pg_image_width(PG_FUNCTION_ARGS); Datum pg_image_height(PG_FUNCTION_ARGS); Datum pg_image_filesize(PG_FUNCTION_ARGS); Datum pg_image_mimetype(PG_FUNCTION_ARGS); Datum pg_image_imagedata(PG_FUNCTION_ARGS); Datum pg_image_eq(PG_FUNCTION_ARGS); Datum pg_image_ne(PG_FUNCTION_ARGS); Datum pg_image_hash(PG_FUNCTION_ARGS);