Next: , Previous: Memory Based Data Buffers, Up: Creating Data Buffers


6.1.2 File Based Data Buffers

File based data objects operate directly on file descriptors or streams. Only a small amount of data is stored in core at any time, so the size of the data objects is not limited by GPGME.

— Function: gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd)

The function gpgme_data_new_from_fd creates a new gpgme_data_t object and uses the file descriptor fd to read from (if used as an input data object) and write to (if used as an output data object).

When using the data object as an input buffer, the function might read a bit more from the file descriptor than is actually needed by the crypto engine in the desired operation because of internal buffering.

The function returns the error code GPG_ERR_NO_ERROR if the data object was successfully created, and GPG_ERR_ENOMEM if not enough memory is available.

— Function: gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream)

The function gpgme_data_new_from_stream creates a new gpgme_data_t object and uses the I/O stream stream to read from (if used as an input data object) and write to (if used as an output data object).

When using the data object as an input buffer, the function might read a bit more from the stream than is actually needed by the crypto engine in the desired operation because of internal buffering.

The function returns the error code GPG_ERR_NO_ERROR if the data object was successfully created, and GPG_ERR_ENOMEM if not enough memory is available.