2001-12-18 Marcus Brinkmann <marcus@g10code.de>

* key.c (_gpgme_key_append_name): Append, not prepend, the uid.
	Initialize the next field of the uid structure.
	(gpgme_key_get_as_xml): Do not list last uid first.
This commit is contained in:
Marcus Brinkmann 2001-12-18 19:54:00 +00:00
parent ac53a44dfa
commit 247eecaab9
4 changed files with 91 additions and 78 deletions

3
NEWS
View File

@ -1,4 +1,7 @@
* GpgmeKey lists the user ids in the order as they are returned by
GnuPG, first the primary key with index 0, then the sub-user ids.
* New operation gpgme_op_decrypt_verify() to decrypt and verify
signatures simultaneously.

8
TODO
View File

@ -24,9 +24,6 @@
*** Test gpgme_data_rewind for invalid types.
*** Test gpgme_data_read's readable feature.
* Changes breaking the ABI
** GpgmeKey's main userID is not index == 0.
Bugs reported by Stephane Corthesy:
> - When returning a GpgmeKey GPGME_ATTR_COMMENT attribute, characters
> like ":" are not un-escaped, they are returned as \x3a
@ -48,8 +45,3 @@ Bugs reported by Stephane Corthesy:
> the
> callback has become invalid; if I use a brand new one, the callback
> is called recursively, when I ask to enumerate keys.

View File

@ -1,3 +1,9 @@
2001-12-18 Marcus Brinkmann <marcus@g10code.de>
* key.c (_gpgme_key_append_name): Append, not prepend, the uid.
Initialize the next field of the uid structure.
(gpgme_key_get_as_xml): Do not list last uid first.
2001-12-17 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New

View File

@ -483,18 +483,17 @@ parse_x509_user_id ( struct user_id_s *uid, char *tail )
* sequences and put it into the list of UIDs
*/
GpgmeError
_gpgme_key_append_name ( GpgmeKey key, const char *s )
_gpgme_key_append_name (GpgmeKey key, const char *s)
{
struct user_id_s *uid;
char *d;
assert (key);
/* we can malloc a buffer of the same length, because the
* converted string will never be larger. Actually we allocate it
* twice the size, so that we are able to store the parsed stuff
* there too */
uid = xtrymalloc ( sizeof *uid + 2*strlen (s)+3 );
if ( !uid )
/* We can malloc a buffer of the same length, because the converted
string will never be larger. Actually we allocate it twice the
size, so that we are able to store the parsed stuff there too. */
uid = xtrymalloc ( sizeof *uid + 2*strlen (s)+3);
if (!uid)
return mk_error (Out_Of_Core);
uid->revoked = 0;
uid->invalid = 0;
@ -502,40 +501,50 @@ _gpgme_key_append_name ( GpgmeKey key, const char *s )
uid->name_part = NULL;
uid->email_part = NULL;
uid->comment_part = NULL;
uid->next = NULL;
d = uid->name;
while ( *s ) {
if ( *s != '\\' )
while (*s)
{
if (*s != '\\')
*d++ = *s++;
else if ( s[1] == '\\' ) {
else if (s[1] == '\\')
{
s++;
*d++ = *s++;
}
else if ( s[1] == 'n' ) {
else if (s[1] == 'n')
{
s += 2;
*d++ = '\n';
}
else if ( s[1] == 'r' ) {
else if (s[1] == 'r')
{
s += 2;
*d++ = '\r';
}
else if ( s[1] == 'v' ) {
else if (s[1] == 'v')
{
s += 2;
*d++ = '\v';
}
else if ( s[1] == 'b' ) {
else if (s[1] == 'b')
{
s += 2;
*d++ = '\b';
}
else if ( s[1] == '0' ) {
else if (s[1] == '0')
{
/* Hmmm: no way to express this */
s += 2;
*d++ = '\\';
*d++ = '\0';
}
else if ( s[1] == 'x' && my_isdigit (s[2]) && my_isdigit (s[3]) ) {
else if (s[1] == 'x' && my_isdigit (s[2]) && my_isdigit (s[3]))
{
unsigned int val = (s[2]-'0')*16 + (s[3]-'0');
if ( !val ) {
if (!val)
{
*d++ = '\\';
*d++ = '\0';
}
@ -543,7 +552,9 @@ _gpgme_key_append_name ( GpgmeKey key, const char *s )
*(byte*)d++ = val;
s += 3;
}
else { /* should not happen */
else
{
/* should not happen */
s++;
*d++ = '\\';
*d++ = *s++;
@ -555,8 +566,16 @@ _gpgme_key_append_name ( GpgmeKey key, const char *s )
else
parse_user_id (uid, d);
uid->next = key->uids;
if (key->uids)
{
struct user_id_s *u = key->uids;
while (u->next)
u = u->next;
u->next = uid;
}
else
key->uids = uid;
return 0;
}
@ -667,16 +686,9 @@ gpgme_key_get_as_xml ( GpgmeKey key )
/*add_tag_and_time (d, "expires", key->expires );*/
_gpgme_data_append_string (d, " </mainkey>\n");
/* Now the user IDs. We are listing the last one first because this is
* the primary one. */
for (u = key->uids; u && u->next; u = u->next )
;
if (u) {
/* Now the user IDs. */
for (u = key->uids; u; u = u->next)
one_uid_as_xml (d,u);
for ( u = key->uids; u && u->next; u = u->next ) {
one_uid_as_xml (d,u);
}
}
/* and now the subkeys */
for (k=key->keys.next; k; k = k->next ) {