aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/get-passphrase.c13
-rw-r--r--common/membuf.c14
-rw-r--r--common/membuf.h1
3 files changed, 16 insertions, 12 deletions
diff --git a/common/get-passphrase.c b/common/get-passphrase.c
index 53ce7d136..f1517fbfa 100644
--- a/common/get-passphrase.c
+++ b/common/get-passphrase.c
@@ -130,17 +130,6 @@ default_inq_cb (void *opaque, const char *line)
}
-static gpg_error_t
-membuf_data_cb (void *opaque, const void *buffer, size_t length)
-{
- membuf_t *data = opaque;
-
- if (buffer)
- put_membuf (data, buffer, length);
- return 0;
-}
-
-
/* Ask for a passphrase via gpg-agent. On success the caller needs to
free the string stored at R_PASSPHRASE. On error NULL will be
stored at R_PASSPHRASE and an appropriate gpg error code is
@@ -214,7 +203,7 @@ gnupg_get_passphrase (const char *cache_id,
else
init_membuf (&data, 64);
err = assuan_transact (agent_ctx, line,
- membuf_data_cb, &data,
+ put_membuf_cb, &data,
default_inq_cb, NULL, NULL, NULL);
/* Older Pinentries return the old assuan error code for canceled
diff --git a/common/membuf.c b/common/membuf.c
index f4430a972..fde24f615 100644
--- a/common/membuf.c
+++ b/common/membuf.c
@@ -116,6 +116,20 @@ put_membuf (membuf_t *mb, const void *buf, size_t len)
}
+/* A variant of put_membuf accepting a void * and returning a
+ gpg_error_t (which will always return 0) to be used as a generic
+ callback handler. This function also allows buffer to be NULL. */
+gpg_error_t
+put_membuf_cb (void *opaque, const void *buf, size_t len)
+{
+ membuf_t *data = opaque;
+
+ if (buf)
+ put_membuf (data, buf, len);
+ return 0;
+}
+
+
void
put_membuf_str (membuf_t *mb, const char *string)
{
diff --git a/common/membuf.h b/common/membuf.h
index eb7d5650a..a1610b6c8 100644
--- a/common/membuf.h
+++ b/common/membuf.h
@@ -53,6 +53,7 @@ void init_membuf (membuf_t *mb, int initiallen);
void init_membuf_secure (membuf_t *mb, int initiallen);
void clear_membuf (membuf_t *mb, size_t amount);
void put_membuf (membuf_t *mb, const void *buf, size_t len);
+gpg_error_t put_membuf_cb (void *opaque, const void *buf, size_t len);
void put_membuf_str (membuf_t *mb, const char *string);
void put_membuf_printf (membuf_t *mb, const char *format,
...) GPGRT_ATTR_PRINTF(2,3);