Description
size_t pbms_put_callback (
void * caller_data
,char * buffer
,size_t size
,pbms_bool reset
)
This is the prototype for a user defined callback function of type
PBMS_READ_CALLBACK_FUNC
which is passed
into the
pbms_put_data_cb() function. The callback is called repeatedly by
pbms_put_data_cb() to get BLOB data to send to the PBMS daemon.
Parameters
- caller_data
- The caller_data parameter passed into the pbms_put_data_cb()
function which is a pointer to a user defined data structure.
- buffer
- The buffer into which the user writes the next block of BLOB data to be sent.
- size
- The size of the buffer.
- reset
- A flag to indicate that the data transfer has been restarted from the beginning.
Return Values
The length of the data written into the buffer.
Zero is returned when there is no more data to be transfered.
Example
/*
* This is an example of a callback to stream a file to the PBMS daemon.
* In this case the caller_data is a pointer to a file handle.
*/
size_t file_callback(void *caller_data, char *buffer, size_t size, pbms_bool reset)
{
int *fh = (int*) caller_data;
if (reset) {
lseek(fh, 0, SEEK_SET);
}
if (size) {
size = read(fh, buffer, size);
}
return size;
}