gda-blob

gda-blob — Management of BLOBs (Binary Large OBjects)

Functions

gint gda_blob_open ()
gint gda_blob_read ()
gint gda_blob_write ()
gint gda_blob_lseek ()
gint gda_blob_close ()
gint gda_blob_remove ()
void gda_blob_free_data ()

Types and Values

enum GdaBlobMode
struct GdaBlob

Description

Functions

gda_blob_open ()

gint
gda_blob_open (GdaBlob *blob,
               GdaBlobMode mode);

Opens an existing BLOB. The BLOB must be initialized by gda_connection_create_blob or obtained from a GdaValue.

Parameters

blob

a GdaBlob structure obtained from a GdaValue or allocated by the user when he/she wants to create a new GdaBlob.

 

mode

see GdaBlobMode.

 

Returns

0 if everything's ok. In case of error, -1 is returned and the provider should have added an error to the connection.


gda_blob_read ()

gint
gda_blob_read (GdaBlob *blob,
               gpointer buf,
               gint size,
               gint *bytes_read);

Reads a chunk of bytes from the BLOB into a user-provided location.

Parameters

blob

a GdaBlob which is opened with the flag GDA_BLOB_MODE_READ set.

 

buf

buffer to read the data into.

 

size

maximum number of bytes to read.

 

bytes_read

on return it will point to the number of bytes actually read.

 

Returns

0 if everything's ok. In case of error, -1 is returned and the provider should have added an error to the connection.


gda_blob_write ()

gint
gda_blob_write (GdaBlob *blob,
                gpointer buf,
                gint size,
                gint *bytes_written);

Writes a chunk of bytes from a user-provided location to the BLOB.

Parameters

blob

a GdaBlob which is opened with the flag GDA_BLOB_MODE_WRITE set.

 

buf

buffer to write the data from.

 

size

maximum number of bytes to read.

 

bytes_written

on return it will point to the number of bytes actually written.

 

Returns

0 if everything's ok. In case of error, -1 is returned and the provider should have added an error to the connection.


gda_blob_lseek ()

gint
gda_blob_lseek (GdaBlob *blob,
                gint offset,
                gint whence);

Sets the blob read/write position.

Parameters

blob

a opened GdaBlob.

 

offset

offset added to the position specified by whence .

 

whence

SEEK_SET, SEEK_CUR or SEEK_END with the same meaning as in fseek(3).

 

Returns

the current position in the blob or < 0 in case of error. In case of error the provider should have added an error to the connection.


gda_blob_close ()

gint
gda_blob_close (GdaBlob *blob);

Closes the BLOB. After calling this function, blob should no longer be used.

Parameters

blob

a opened GdaBlob.

 

Returns

0 if everything's ok. In case of error, -1 is returned and the provider should have added an error to the connection.


gda_blob_remove ()

gint
gda_blob_remove (GdaBlob *blob);

Removes the BLOB from the database. After calling this function, blob should no longer be used.

Parameters

blob

a valid GdaBlob.

 

Returns

0 if everything's ok. In case of error, -1 is returned and the provider should have added an error to the connection.


gda_blob_free_data ()

void
gda_blob_free_data (GdaBlob *blob);

Let the provider free any internal data stored in blob . The user is still responsible for deallocating blob itself.

Parameters

blob

a valid GdaBlob.

 

Types and Values

enum GdaBlobMode

Members

GDA_BLOB_MODE_READ

   

GDA_BLOB_MODE_WRITE

   

GDA_BLOB_MODE_RDWR

   

struct GdaBlob

struct GdaBlob {
	/* Private */
	gint (* open) (GdaBlob *blob, GdaBlobMode mode);

	gint (* read) (GdaBlob *blob, gpointer buf, gint size,
			gint *bytes_read);

	gint (* write) (GdaBlob *blob, gpointer buf, gint size,
			gint *bytes_written);

	gint (* lseek) (GdaBlob *blob, gint offset, gint whence);

	gint (* close) (GdaBlob *blob);

	gint (* remove) (GdaBlob *blob);

	gchar * (* stringify) (GdaBlob *blob);

	void (* free_data) (GdaBlob *blob);

	gpointer priv_data;
	/* */

	/* Public */
	gpointer user_data;
};