2003-04-30  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Encrypting a Plaintext): Remove reference to
	gpgme_get_op_info.
	(Detailed Results): Subsection removed.

gpgme/
2003-04-30  Marcus Brinkmann  <marcus@g10code.de>

	* 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 <string.h>, <errno.h>, <ctype.h>,
	and <sys/types.h>, but <string.h>.
	(_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  <marcus@g10code.de>

	* gpg/t-eventloop.c (main): Do not call print_op_info.
	(print_op_info): Function removed.
This commit is contained in:
Marcus Brinkmann 2003-04-30 03:34:30 +00:00
parent 473288524e
commit 102e973a9b
12 changed files with 48 additions and 301 deletions

5
NEWS
View File

@ -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)

View File

@ -1,5 +1,9 @@
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* 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.

View File

@ -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
<GnupgOperationInfo>
<signature>
<detached/> <!-- or cleartext or standard -->
<algo>17</algo>
<hashalgo>2</hashalgo>
<micalg>pgp-sha1</micalg>
<sigclass>01</sigclass>
<created>9222222</created>
<fpr>121212121212121212</fpr>
</signature>
</GnupgOperationInfo>
@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

View File

@ -1,5 +1,25 @@
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* 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 <string.h>, <errno.h>, <ctype.h>,
and <sys/types.h>, but <string.h>.
(_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.

View File

@ -22,11 +22,8 @@
#include <config.h>
#endif
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#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 = "&lt;";
else if (*str == '>')
text = "&gt;"; /* Not sure whether this is really needed. */
else if (*str == '&')
text = "&amp;";
else if (!*str)
text = "&#00;";
}
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;
}

View File

@ -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;
}

View File

@ -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:
* <literal>
* <![CDATA[
* <GnupgOperationInfo>
* <signature>
* <detached/> <!-- or cleartext or standard -->
* <algo>17</algo>
* <hashalgo>2</hashalgo>
* <micalg>pgp-sha1</micalg>
* <sigclass>01</sigclass>
* <created>9222222</created>
* <fpr>121212121212121212</fpr>
* </signature>
* </GnupgOperationInfo>
* ]]>
* </literal>
* 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);
}
}

View File

@ -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. */

View File

@ -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);

View File

@ -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;

View File

@ -1,5 +1,8 @@
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* 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

View File

@ -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 ("<!-- no operation info available -->");
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);