Creating a Blob Control Structure

From InterBase

Go Up to Writing a Blob UDF


A Blob control structure is a C structure, declared within a UDF module as a
typedef. Programmers must provide the control structure definition, which should be defined as follows:

typedef struct blob {
    short	(*blob_get_segment)(isc_blob_handle, byte *, ISC_USHORT, ISC_USHORT *);
    isc_blob_handle  *blob_handle;
    ISC_LONG	number_segments;
    ISC_LONG	max_seglen;
    ISC_LONG	total_size;
    void	(*blob_put_segment)(isc_blob_handle, byte *, ISC_USHORT);
    ISC_LONG	(*blob_seek)(isc_blob_handle, ISC_USHORT, ISC_LONG);  /* reserved for future use */
} *Blob;
Fields in the Blob struct
Field Description

blob_get_segment

Points to a function that is called to read a segment from a Blob if one is passed; the function takes four arguments: a Blob handle, the address of a buffer into which to place Blob a segment of data that is read, the size (unsigned short integer) of that buffer, and the address of the variable that stores the size of the segment (address of unsigned short integer) that is read.

If Blob data is not read by the UDF, set blob_get_segment to NULL.

The function returns a signed short integer type with the following possible values:
short (*blob_get_segment) (isc_blob_handle, byte *, ISC_USHORT, ISC_USHORT *)

1	-- Complete segment has been returned
0	-- End of blob (no data returned)
-1	-- Current segment is incomplete

blob_handle

  • Required Uniquely identifies a Blob passed to a UDF or returned by it.

number_segments

Specifies the total number of segments in the Blob. Set this value to NULL if Blob data is not passed to a UDF.

max_seglen

Specifies the size, in bytes, of the largest single segment passed. Set this value to NULL if Blob data is not passed to a UDF.

total_size

Specifies the actual size, in bytes, of the Blob as a single unit. Set this value to NULL if Blob data is not passed to a UDF.

blob_put_segment

Points to a function that writes a segment to a Blob if one is being returned by the UDF. The function takes three arguments: a Blob handle, the address of a buffer containing the data to write into the Blob, and the size (unsigned short integer), in bytes, of the data to write. If Blob data is not read by the UDF, set blob_put_segment to NULL. The function has no return type (void)

Advance To: