Add gpgme_io_write and gpgme_io_read.

Minor cleanups.
This commit is contained in:
Werner Koch 2009-06-09 16:01:02 +00:00
parent 621ffc14ae
commit caf36ce1ce
11 changed files with 71 additions and 7 deletions

6
NEWS
View File

@ -8,6 +8,10 @@ Noteworthy changes in version 1.1.9
selftest failed (for example, if -mms-bitfields was not used on
MingW32 targets).
* New functions gpgme_io_read and gpgme_io_write for use with
gpgme_passphrase_cb_t and gpgme_edit_cb_t functions.
* Interface changes relative to the 1.1.7 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GPGME_KEYLIST_MODE_EPHEMERAL NEW.
@ -22,6 +26,8 @@ Noteworthy changes in version 1.1.9
GPGME_ENCRYPT_NO_ENCRYPT_TO NEW.
gpgme_check_version CHANGED: Is now a macro.
gpgme_new EXTENDED: More failure codes.
gpgme_io_read NEW.
gpgme_io_write NEW.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,5 +1,12 @@
2009-06-09 Werner Koch <wk@g10code.com>
* version.c (gpgme_check_version_internal): Make result const.
* gpgme.c: Include priv-io.h.
(gpgme_io_read, gpgme_io_write): New.
* libgpgme.vers (GPGME_1.1): Add them.
* gpgme.def: Ditto.
* Makefile.am (main_sources): Remove gpgme.h.
(include_HEADERS): Rename to nodist_include_HEADERS so that a
VPATH build won't use the distributed one.

View File

@ -34,6 +34,7 @@
#include "ops.h"
#include "wait.h"
#include "debug.h"
#include "priv-io.h"
/* The default locale. */
@ -428,6 +429,33 @@ gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
}
/* This function provides access to the internal read function; it is
normally not used. */
ssize_t
gpgme_io_read (int fd, void *buffer, size_t count)
{
int ret;
ret = _gpgme_io_read (fd, buffer, count);
return 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. */
ssize_t
gpgme_io_write (int fd, const void *buffer, size_t count)
{
int ret;
ret = _gpgme_io_write (fd, buffer, count);
return ret;
}
/* This function returns the callback function for I/O. */
void
gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)

View File

@ -173,6 +173,10 @@ EXPORTS
gpgme_op_assuan_transact @134
gpgme_check_version_internal @135
gpgme_io_read @136
gpgme_io_write @137
; END

View File

@ -961,6 +961,11 @@ void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
/* Get the current I/O callback functions. */
void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs);
/* Wrappers around the internal I/O functions for use with
gpgme_passphrase_cb_t and gpgme_edit_cb_t. */
ssize_t gpgme_io_read (int fd, void *buffer, size_t count);
ssize_t gpgme_io_write (int fd, const void *buffer, size_t count);
/* Process the pending operation and, if HANG is non-zero, wait for
the pending operation to finish. */
gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang);

View File

@ -53,6 +53,10 @@ GPGME_1.1 {
gpgme_op_assuan_transact_start;
gpgme_check_version_internal;
gpgme_io_read;
gpgme_io_write;
};

View File

@ -213,7 +213,7 @@ const char *
gpgme_check_version_internal (const char *req_version,
size_t offset_sig_validity)
{
char *result;
const char *result;
TRACE2 (DEBUG_INIT, "gpgme_check_version_internal: ", 0,
"req_version=%s, offset_sig_validity=%i",

View File

@ -1,3 +1,12 @@
2009-06-09 Werner Koch <wk@g10code.com>
* gpg/Makefile.am (./pubring.gpg): Ignore errors in case of
already imported keys. Add --no-permission-warning and remove
obsolete --allow-secret-key-import.
* gpg/mkdemodirs.in (GPG): Add --no-permission-warning.
* gpg/t-edit.c (edit_fnc): Use gpgme_io_write.
2009-04-19 Moritz <moritz@gnu.org>
* gpg/Makefile.am (EXTRA_DIST): Replaced mkdemodirs with mkdemodirs.in.

View File

@ -63,8 +63,9 @@ clean-local:
all-local: ./pubring.gpg ./gpg.conf ./gpg-agent.conf
./pubring.gpg: $(srcdir)/pubdemo.asc ./Alpha/Secret.gpg
$(GPG) --homedir . --import $(srcdir)/pubdemo.asc
$(GPG) --homedir . --allow-secret-key-import \
-$(GPG) --homedir . --no-permission-warning \
--import $(srcdir)/pubdemo.asc
-$(GPG) --homedir . --no-permission-warning \
--import Alpha/Secret.gpg Zulu/Secret.gpg
./Alpha/Secret.gpg: mkdemodirs secdemo.asc

View File

@ -19,7 +19,7 @@
set -e
GPG="@GPG@ --batch --quiet --no-secmem-warning"
GPG="@GPG@ --batch --quiet --no-secmem-warning --no-permission-warning"
NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India
Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo
Sierra Tango Uniform Victor Whisky XRay Yankee Zulu'
@ -45,7 +45,7 @@ for name in $NAMES; do
[ -d $name ] && rm -r $name
mkdir $name
$GPGDEMO --export-secret-key -o - $name > $name/Secret.gpg
$GPG --homedir $name --allow-secret-key-import --import $name/Secret.gpg
$GPG --homedir $name --import $name/Secret.gpg
$GPGDEMO --export -o - $name > $name/Public.gpg
$GPG --homedir $name --import $name/Public.gpg
[ -f $name/pubring.gpg~ ] && rm $name/pubring.gpg~

View File

@ -103,8 +103,8 @@ edit_fnc (void *opaque, gpgme_status_code_t status, const char *args, int fd)
if (result)
{
write (fd, result, strlen (result));
write (fd, "\n", 1);
gpgme_io_write (fd, result, strlen (result));
gpgme_io_write (fd, "\n", 1);
}
return 0;
}