aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpgme.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-02-07 19:51:29 +0000
committerWerner Koch <[email protected]>2013-02-07 19:51:29 +0000
commit29eced50687dd8a39dafe704102ae09ea8e8533a (patch)
treec8bb9b47232807d90ec0525bdf8afb3c6186c3ee /src/gpgme.c
parentUse gpg_error_from_syserror instead of directly accessing errno. (diff)
downloadgpgme-29eced50687dd8a39dafe704102ae09ea8e8533a.tar.gz
gpgme-29eced50687dd8a39dafe704102ae09ea8e8533a.zip
Add public function gpgme_io_writen.
* src/gpgme.c (gpgme_io_read): New. -- This is a writen style variant for gpgme_io_write. It is often easier to use this one in passphrase and edit callbacks.
Diffstat (limited to 'src/gpgme.c')
-rw-r--r--src/gpgme.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gpgme.c b/src/gpgme.c
index 86099d60..79895db2 100644
--- a/src/gpgme.c
+++ b/src/gpgme.c
@@ -634,6 +634,30 @@ gpgme_io_write (int fd, const void *buffer, size_t count)
return TRACE_SYSRES (ret);
}
+/* This function provides access to the internal write function. It
+ is to be used by user callbacks to return data to gpgme. See
+ gpgme_passphrase_cb_t and gpgme_edit_cb_t. Note that this is a
+ variant of gpgme_io_write which guarantees that all COUNT bytes are
+ written or an error is return. Returns: 0 on success or -1 on
+ error and the sets errno. */
+int
+gpgme_io_writen (int fd, const void *buffer, size_t count)
+{
+ int ret = 0;
+ TRACE_BEG2 (DEBUG_GLOBAL, "gpgme_io_writen", fd,
+ "buffer=%p, count=%u", buffer, count);
+ while (count)
+ {
+ ret = _gpgme_io_write (fd, buffer, count);
+ if (ret < 0)
+ break;
+ buffer += ret;
+ count -= ret;
+ ret = 0;
+ }
+ return TRACE_SYSRES (ret);
+}
+
/* This function returns the callback function for I/O. */
void