pbms_get_data_range_cb
Description
pbms_bool pbms_get_data_range_cb ( PBMS pbms ,const char * blob_ref ,size_t first_byte ,size_t last_byte ,PBMS_WRITE_CALLBACK_FUNC callback ,void * caller_data )
Streams a portion of the BLOB data, via a callback function, back from the PBMS BLOB streaming daemon.
Parameters
pbms
A valid PBMS connection handle.
blob_ref
A BLOB reference for the data to be received.
first_byte
The offset of the first byte in the range of data to return.
last_byte
The offset of the last byte in the range of data to return.
callback
The callback function through which the data is streamed back from the daemon.
caller_data
A pointer to user defined data passed into the callback function.
Return Values

Returns TRUE on success.

Returns FALSE on failure. Use pbms_errno() and pbms_error() to retrieve error details.

Example
/*
 * This is an example of a callback to stream a file from the PBMS daemon.
 * In this case the caller_data is a pointer to a file handle.
 */
size_t file_callback(void *caller_data, const char *buffer, size_t size, pbms_bool reset)
{
	int *fh = (int*) caller_data;

	if (reset) {
		lseek(fh, 0, SEEK_SET);
	}
	if (size) {
		size = write(fh, buffer, size);
	}
	return size;
}

main ()
{
	PBMS pbms;
	int fh;

	pbms_library_init(false);

	pbms = pbms_connect("localhost", 8080, "aDatabase");

	// Fetch the BLOB back, 'name' is a LONGBLOB column.
	mysql_query(mysql, "select name from bobtest where id = 1");
	results = mysql_store_result(mysql);
			
	record = mysql_fetch_row(result);
	
	 // Open a file into which the BLOB will be streamed.
	fh = open("myblob.jpg", O_WRONLY | O_CREAT | O_TRUNC, 0000777);

	// Get back the second K of data.
	pbms_get_data_range_cb(pbms, record[0], 1024, 2047, file_callback, &fh));

	pbms_close(pbms);
	pbms_library_end();
}
		
Related functions
pbms_get_data() pbms_get_data_range() pbms_get_data_cb() pbms_get_info() pbms_put_data() pbms_put_data_cb()