From f25a44070ef842c4fa20eb9b077cc73e1cb0b4cd Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 30 Apr 2003 03:34:30 +0000 Subject: [PATCH] doc/ 2003-04-30 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Remove reference to gpgme_get_op_info. (Detailed Results): Subsection removed. gpgme/ 2003-04-30 Marcus Brinkmann * gpgme.h (gpgme_get_op_info): Remove prototype. * ops.h (_gpgme_set_op_info, _gpgme_data_release_and_return_string, _gpgme_data_get_as_string, _gpgme_data_append, _gpgme_data_append_string, _gpgme_data_append_string_for_xml, _gpgme_data_append_for_xml, _gpgme_data_append_percentstring_for_xml): Likewise. (_gpgme_progress_status_handler): Change first arg to void *. * progress.c (_gpgme_progress_status_handler): Likewise. * conversion.c: Do not include , , , and , but . (_gpgme_data_append): Remove function. (_gpgme_data_append_string): Likewise. (_gpgme_data_append_for_xml): Likewise. (_gpgme_data_append_string_for_xml): Likewise. (_gpgme_data_append_percentstring_for_xml): Likewise. * data-mem.c (_gpgme_data_get_as_string): Likewise. (_gpgme_data_release_and_return_string): Likewise. * gpgme.c (gpgme_get_op_info): Likewise. (_gpgme_set_op_info): Likewise. tests/ 2003-04-30 Marcus Brinkmann * gpg/t-eventloop.c (main): Do not call print_op_info. (print_op_info): Function removed. --- trunk/NEWS | 5 ++ trunk/doc/ChangeLog | 4 ++ trunk/doc/gpgme.texi | 38 +---------- trunk/gpgme/ChangeLog | 20 ++++++ trunk/gpgme/conversion.c | 119 +--------------------------------- trunk/gpgme/data-mem.c | 44 ------------- trunk/gpgme/gpgme.c | 58 ----------------- trunk/gpgme/gpgme.h | 6 +- trunk/gpgme/ops.h | 33 ++++------ trunk/gpgme/progress.c | 3 +- trunk/tests/ChangeLog | 3 + trunk/tests/gpg/t-eventloop.c | 16 ----- 12 files changed, 48 insertions(+), 301 deletions(-) diff --git a/trunk/NEWS b/trunk/NEWS index 98cee17..f401fc8 100644 --- a/trunk/NEWS +++ b/trunk/NEWS @@ -120,6 +120,10 @@ Noteworthy changes in version 0.4.1 (unreleased) information about the result of a key listing operation in a GpgmeKeyListResult object. + * Now that each function comes with its own result retrieval + interface, the generic gpgme_get_op_info interface is not useful + anymore and dropped. + * Interface changes relative to the 0.4.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeIOCb CHANGED: Return type from void to GpgmeError. @@ -188,6 +192,7 @@ gpgme_key_sig_get_ulong_attr DEPRECATED gpgme_key_get_as_xml REMOVED GpgmeKeyListResult NEW gpgme_op_keylist_result NEW +gpgme_get_op_info REMOVED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.0 (2002-12-23) diff --git a/trunk/doc/ChangeLog b/trunk/doc/ChangeLog index 94d8f19..fe3c608 100644 --- a/trunk/doc/ChangeLog +++ b/trunk/doc/ChangeLog @@ -1,5 +1,9 @@ 2003-04-30 Marcus Brinkmann + * gpgme.texi (Encrypting a Plaintext): Remove reference to + gpgme_get_op_info. + (Detailed Results): Subsection removed. + * gpgme.texi (Key Listing Mode): Add GPGME_KEYLIST_MODE_SIGS. (Manipulating Keys): Add obsoleteness note. (Key Signatures): Likewise. diff --git a/trunk/doc/gpgme.texi b/trunk/doc/gpgme.texi index 2107e84..19bc0fb 100644 --- a/trunk/doc/gpgme.texi +++ b/trunk/doc/gpgme.texi @@ -181,7 +181,6 @@ Crypto Operations * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. -* Detailed Results:: How to obtain more info about the operation. Sign @@ -3040,7 +3039,6 @@ An error code describing the reason why the user ID was found invalid. * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. -* Detailed Results:: How to obtain more info about the operation. @end menu @@ -3837,7 +3835,7 @@ If @code{GPGME_Invalid_UserID} is returned, some recipients in @var{rset} are invalid, but not all. In this case the plaintext is encrypted for all valid recipients and returned in @var{cipher}. More information about the invalid recipients is available with -@code{gpgme_get_op_info}. @xref{Detailed Results}. +@code{gpgme_op_encrypt_result}. If @var{recp} is @code{NULL}, symmetric rather than public key encryption is performed. Symmetrically encrypted cipher text can be @@ -3917,40 +3915,6 @@ recipients. @end deftypefun -@node Detailed Results -@subsection Detailed Results -@cindex cryptographic operation, detailed results - -@deftypefun {char *} gpgme_get_op_info (@w{GpgmeCtx @var{ctx}}, @w{int @var{reserved}}) -The function @code{gpgme_get_op_info} retrieves more information about -the last crypto operation. - -The function returns a string in the XML format. The user has to -release the string with @code{free}. - -Here is a sample of the information that might be returned: -@example - - - - 17 - 2 - pgp-sha1 - 01 - 9222222 - 121212121212121212 - - -@end example - -Currently, the only operations that return additional information are -encrypt, sign. @xref{Encrypt}, @xref{Sign}. - -The function returns a string or @code{NULL} if no such data is -available. -@end deftypefun - - @node Run Control @section Run Control @cindex run control diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 0d354f2..6479ebf 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,5 +1,25 @@ 2003-04-30 Marcus Brinkmann + * gpgme.h (gpgme_get_op_info): Remove prototype. + * ops.h (_gpgme_set_op_info, + _gpgme_data_release_and_return_string, _gpgme_data_get_as_string, + _gpgme_data_append, _gpgme_data_append_string, + _gpgme_data_append_string_for_xml, _gpgme_data_append_for_xml, + _gpgme_data_append_percentstring_for_xml): Likewise. + (_gpgme_progress_status_handler): Change first arg to void *. + * progress.c (_gpgme_progress_status_handler): Likewise. + * conversion.c: Do not include , , , + and , but . + (_gpgme_data_append): Remove function. + (_gpgme_data_append_string): Likewise. + (_gpgme_data_append_for_xml): Likewise. + (_gpgme_data_append_string_for_xml): Likewise. + (_gpgme_data_append_percentstring_for_xml): Likewise. + * data-mem.c (_gpgme_data_get_as_string): Likewise. + (_gpgme_data_release_and_return_string): Likewise. + * gpgme.c (gpgme_get_op_info): Likewise. + (_gpgme_set_op_info): Likewise. + * gpgme.h (struct _gpgme_key): New structure. (GpgmeKey): Define using _gpgme_key. (struct _gpgme_subkey): New structure. diff --git a/trunk/gpgme/conversion.c b/trunk/gpgme/conversion.c index 57e2f51..4082a32 100644 --- a/trunk/gpgme/conversion.c +++ b/trunk/gpgme/conversion.c @@ -22,11 +22,8 @@ #include #endif -#include -#include -#include -#include #include +#include #include "gpgme.h" #include "util.h" @@ -332,117 +329,3 @@ _gpgme_map_gnupg_error (char *err) return GPGME_General_Error; } - - -GpgmeError -_gpgme_data_append (GpgmeData dh, const char *buffer, size_t length) -{ - if (!dh || !buffer) - return GPGME_Invalid_Value; - - do - { - ssize_t amt = gpgme_data_write (dh, buffer, length); - if (amt == 0 || (amt < 0 && errno != EINTR)) - return GPGME_File_Error; - buffer += amt; - length -= amt; - } - while (length > 0); - - return 0; -} - - -GpgmeError -_gpgme_data_append_string (GpgmeData dh, const char *str) -{ - if (!str) - return 0; - - return _gpgme_data_append (dh, str, strlen (str)); -} - - -GpgmeError -_gpgme_data_append_for_xml (GpgmeData dh, const char *buffer, size_t len) -{ - const char *text, *str; - size_t count; - int err = 0; - - if (!dh || !buffer) - return GPGME_Invalid_Value; - - do - { - text = NULL; - str = buffer; - for (count = len; count && !text; str++, count--) - { - if (*str == '<') - text = "<"; - else if (*str == '>') - text = ">"; /* Not sure whether this is really needed. */ - else if (*str == '&') - text = "&"; - else if (!*str) - text = "�"; - } - if (text) - { - str--; - count++; - } - if (str != buffer) - err = _gpgme_data_append (dh, buffer, str - buffer); - if (!err && text) - { - err = _gpgme_data_append_string (dh, text); - str++; - count--; - } - buffer = str; - len = count; - } - while (!err && len); - return err; -} - - -/* Append a string to DATA and convert it so that the result will be - valid XML. */ -GpgmeError -_gpgme_data_append_string_for_xml (GpgmeData dh, const char *str) -{ - return _gpgme_data_append_for_xml (dh, str, strlen (str)); -} - - -/* Append a string with percent style (%XX) escape characters as - XML. */ -GpgmeError -_gpgme_data_append_percentstring_for_xml (GpgmeData dh, const char *str) -{ - const unsigned char *src; - unsigned char *buf, *dst; - int val; - GpgmeError err; - - buf = malloc (strlen (str)); - dst = buf; - for (src = str; *src; src++) - { - if (*src == '%' && (val = _gpgme_hextobyte (src + 1)) != -1) - { - *dst++ = val; - src += 2; - } - else - *dst++ = *src; - } - - err = _gpgme_data_append_for_xml (dh, buf, dst - buf); - free (buf); - return err; -} diff --git a/trunk/gpgme/data-mem.c b/trunk/gpgme/data-mem.c index 34de7e9..114d836 100644 --- a/trunk/gpgme/data-mem.c +++ b/trunk/gpgme/data-mem.c @@ -197,30 +197,6 @@ gpgme_data_new_from_mem (GpgmeData *dh, const char *buffer, } -/* This function does make sense when we know that it contains no nil - chars and if the underlying data object is memory based. */ -char * -_gpgme_data_get_as_string (GpgmeData dh) -{ - char *dst = NULL; - const char *src = NULL; - - assert (dh->cbs == &mem_cbs); - - src = dh->data.mem.buffer; - if (!src) - src = dh->data.mem.orig_buffer; - dst = malloc (dh->data.mem.length + 1); - if (dst) - { - if (src) - memcpy (dst, src, dh->data.mem.length); - dst[dh->data.mem.length] = '\0'; - } - return dst; -} - - char * gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len) { @@ -243,23 +219,3 @@ gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len) return str; } - - -/* This function does make sense when we know that it contains no nil - chars and if the underlying data object is memory based. */ -char * -_gpgme_data_release_and_return_string (GpgmeData dh) -{ - char *str = NULL; - - if (!dh) - return NULL; - - assert (dh->cbs == &mem_cbs); - if (gpgme_data_write (dh, "", 1) == 1) - str = gpgme_data_release_and_get_mem (dh, NULL); - else - gpgme_data_release (dh); - - return str; -} diff --git a/trunk/gpgme/gpgme.c b/trunk/gpgme/gpgme.c index 005d137..a729e40 100644 --- a/trunk/gpgme/gpgme.c +++ b/trunk/gpgme/gpgme.c @@ -87,64 +87,6 @@ _gpgme_release_result (GpgmeCtx ctx) data = next_data; } ctx->op_data = NULL; - _gpgme_set_op_info (ctx, NULL); -} - - -/** - * gpgme_get_op_info: - * @c: the context - * @reserved: - * - * Return information about the last operation. The caller has to - * free the string. NULL is returned if there is not previous - * operation available or the operation has not yet finished. - * - * Here is a sample information we return: - * - * - * - * - * 17 - * 2 - * pgp-sha1 - * 01 - * 9222222 - * 121212121212121212 - * - * - * ]]> - * - * Return value: NULL for no info available or an XML string - **/ -char * -gpgme_get_op_info (GpgmeCtx ctx, int reserved) -{ - if (!ctx || reserved || !ctx->op_info) - return NULL; /* Invalid value. */ - - return _gpgme_data_get_as_string (ctx->op_info); -} - - -/* Store the data object INFO with the operation info in the context - CTX. INFO is consumed. Subsequent calls append the data. */ -void -_gpgme_set_op_info (GpgmeCtx ctx, GpgmeData info) -{ - assert (ctx); - - if (!ctx->op_info) - ctx->op_info = info; - else - { - char *info_mem = 0; - size_t info_len; - - info_mem = gpgme_data_release_and_get_mem (info, &info_len); - _gpgme_data_append (ctx->op_info, info_mem, info_len); - } } diff --git a/trunk/gpgme/gpgme.h b/trunk/gpgme/gpgme.h index f9ff990..0fdd45b 100644 --- a/trunk/gpgme/gpgme.h +++ b/trunk/gpgme/gpgme.h @@ -699,11 +699,7 @@ const char *gpgme_get_sig_string_attr (GpgmeCtx c, int idx, R_KEY. */ GpgmeError gpgme_get_sig_key (GpgmeCtx ctx, int idx, GpgmeKey *r_key); -/* Return a string with more info about the last crypto operating in CTX. - RESERVED should be zero. The user has to free the string. */ -char *gpgme_get_op_info (GpgmeCtx ctx, int reserved); - - + /* Run control. */ /* The type of an I/O callback function. */ diff --git a/trunk/gpgme/ops.h b/trunk/gpgme/ops.h index 0159ebc..5c8dac9 100644 --- a/trunk/gpgme/ops.h +++ b/trunk/gpgme/ops.h @@ -24,32 +24,20 @@ #include "gpgme.h" #include "context.h" -/*-- gpgme.c --*/ + +/* From gpgme.c. */ void _gpgme_release_result (GpgmeCtx ctx); -void _gpgme_set_op_info (GpgmeCtx c, GpgmeData info); -/*-- wait.c --*/ + +/* From wait.c. */ GpgmeError _gpgme_wait_one (GpgmeCtx ctx); GpgmeError _gpgme_wait_on_condition (GpgmeCtx ctx, volatile int *cond); -/*-- recipient.c --*/ +/* From recipient.c. */ int _gpgme_recipients_all_valid ( const GpgmeRecipients rset ); - -/*-- data.c and conversion.c --*/ -char * _gpgme_data_release_and_return_string ( GpgmeData dh ); -char * _gpgme_data_get_as_string ( GpgmeData dh ); -GpgmeError _gpgme_data_append ( GpgmeData dh, - const char *buffer, size_t length ); -GpgmeError _gpgme_data_append_string ( GpgmeData dh, const char *s ); -GpgmeError _gpgme_data_append_string_for_xml ( GpgmeData dh, - const char *s); -GpgmeError _gpgme_data_append_for_xml ( GpgmeData dh, - const char *buffer, - size_t len ); -GpgmeError _gpgme_data_append_percentstring_for_xml ( GpgmeData dh, - const char *string ); - + +/* From data.c. */ GpgmeError _gpgme_data_inbound_handler (void *opaque, int fd); GpgmeError _gpgme_data_outbound_handler (void *opaque, int fd); @@ -103,15 +91,16 @@ GpgmeError _gpgme_encrypt_status_handler (void *priv, GpgmeStatusCode code, char *args); -/*-- passphrase.c --*/ +/* From passphrase.c. */ GpgmeError _gpgme_passphrase_status_handler (void *priv, GpgmeStatusCode code, char *args); GpgmeError _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, const char *key, const char **result); -/*-- progress.c --*/ -GpgmeError _gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, + +/* From progress.c. */ +GpgmeError _gpgme_progress_status_handler (void *priv, GpgmeStatusCode code, char *args); diff --git a/trunk/gpgme/progress.c b/trunk/gpgme/progress.c index a939fcd..d322052 100644 --- a/trunk/gpgme/progress.c +++ b/trunk/gpgme/progress.c @@ -29,8 +29,9 @@ GpgmeError -_gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) +_gpgme_progress_status_handler (void *priv, GpgmeStatusCode code, char *args) { + GpgmeCtx ctx = (GpgmeCtx) priv; char *p; char *args_cpy; int type = 0; diff --git a/trunk/tests/ChangeLog b/trunk/tests/ChangeLog index 2a44f23..8daf141 100644 --- a/trunk/tests/ChangeLog +++ b/trunk/tests/ChangeLog @@ -1,5 +1,8 @@ 2003-04-30 Marcus Brinkmann + * gpg/t-eventloop.c (main): Do not call print_op_info. + (print_op_info): Function removed. + * gpg/t-keylist.c: Rewritten. * gpgsm/t-keylist.c (main): Rewritten. * gpg/t-edit.c (main): Do not use gpgme_key_get_as_xml. Use diff --git a/trunk/tests/gpg/t-eventloop.c b/trunk/tests/gpg/t-eventloop.c index 71998bd..b168ef8 100644 --- a/trunk/tests/gpg/t-eventloop.c +++ b/trunk/tests/gpg/t-eventloop.c @@ -33,21 +33,6 @@ exit (1); } \ } while(0) -static void -print_op_info (GpgmeCtx ctx) -{ - char *str = gpgme_get_op_info (ctx, 0); - - if (!str) - puts (""); - else - { - puts (str); - free (str); - } -} - - static void print_data (GpgmeData dh) { @@ -233,7 +218,6 @@ main (int argc, char *argv[]) my_wait (); fail_if_err (op_result.err); - print_op_info (ctx); fail_if_err (err); fflush (NULL); -- 2.26.2