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 * New operation gpgme_op_decrypt_verify() to decrypt and verify
signatures simultaneously. signatures simultaneously.

8
TODO
View File

@ -24,9 +24,6 @@
*** Test gpgme_data_rewind for invalid types. *** Test gpgme_data_rewind for invalid types.
*** Test gpgme_data_read's readable feature. *** Test gpgme_data_read's readable feature.
* Changes breaking the ABI
** GpgmeKey's main userID is not index == 0.
Bugs reported by Stephane Corthesy: Bugs reported by Stephane Corthesy:
> - When returning a GpgmeKey GPGME_ATTR_COMMENT attribute, characters > - When returning a GpgmeKey GPGME_ATTR_COMMENT attribute, characters
> like ":" are not un-escaped, they are returned as \x3a > like ":" are not un-escaped, they are returned as \x3a
@ -48,8 +45,3 @@ Bugs reported by Stephane Corthesy:
> the > the
> callback has become invalid; if I use a brand new one, the callback > callback has become invalid; if I use a brand new one, the callback
> is called recursively, when I ask to enumerate keys. > 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> 2001-12-17 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New

View File

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