From: Marcus Brinkmann Date: Tue, 18 Dec 2001 19:54:00 +0000 (+0000) Subject: 2001-12-18 Marcus Brinkmann X-Git-Tag: gpgme-1.2.0@1385~1186 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8855a72d57f0d9e6e08c8de013acb434ba1ca831;p=gpgme.git 2001-12-18 Marcus Brinkmann * 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. --- diff --git a/trunk/NEWS b/trunk/NEWS index 8e6d27e..dcf2a55 100644 --- a/trunk/NEWS +++ b/trunk/NEWS @@ -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. diff --git a/trunk/TODO b/trunk/TODO index f222324..6fd791c 100644 --- a/trunk/TODO +++ b/trunk/TODO @@ -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. - - - - - diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 8e1e6ca..62d1aaa 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2001-12-18 Marcus Brinkmann + + * 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 * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New diff --git a/trunk/gpgme/key.c b/trunk/gpgme/key.c index 9e43bef..3bd3b56 100644 --- a/trunk/gpgme/key.c +++ b/trunk/gpgme/key.c @@ -483,81 +483,100 @@ 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 ) - return mk_error (Out_Of_Core); - uid->revoked = 0; - uid->invalid = 0; - uid->validity = 0; - uid->name_part = NULL; - uid->email_part = NULL; - uid->comment_part = NULL; - d = uid->name; - - while ( *s ) { - if ( *s != '\\' ) - *d++ = *s++; - else if ( s[1] == '\\' ) { - s++; - *d++ = *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) + return mk_error (Out_Of_Core); + uid->revoked = 0; + uid->invalid = 0; + uid->validity = 0; + uid->name_part = NULL; + uid->email_part = NULL; + uid->comment_part = NULL; + uid->next = NULL; + d = uid->name; + + while (*s) + { + if (*s != '\\') + *d++ = *s++; + else if (s[1] == '\\') + { + s++; + *d++ = *s++; } - else if ( s[1] == 'n' ) { - s += 2; - *d++ = '\n'; + else if (s[1] == 'n') + { + s += 2; + *d++ = '\n'; } - else if ( s[1] == 'r' ) { - s += 2; - *d++ = '\r'; + else if (s[1] == 'r') + { + s += 2; + *d++ = '\r'; } - else if ( s[1] == 'v' ) { - s += 2; - *d++ = '\v'; + else if (s[1] == 'v') + { + s += 2; + *d++ = '\v'; } - else if ( s[1] == 'b' ) { - s += 2; - *d++ = '\b'; + else if (s[1] == 'b') + { + s += 2; + *d++ = '\b'; } - else if ( s[1] == '0' ) { - /* Hmmm: no way to express this */ - s += 2; - *d++ = '\\'; - *d++ = '\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]) ) { - unsigned int val = (s[2]-'0')*16 + (s[3]-'0'); - if ( !val ) { - *d++ = '\\'; - *d++ = '\0'; + 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) + { + *d++ = '\\'; + *d++ = '\0'; } - else - *(byte*)d++ = val; - s += 3; + else + *(byte*)d++ = val; + s += 3; } - else { /* should not happen */ - s++; - *d++ = '\\'; - *d++ = *s++; + else + { + /* should not happen */ + s++; + *d++ = '\\'; + *d++ = *s++; } } - *d++ = 0; - if (key->x509) - parse_x509_user_id (uid, d); - else - parse_user_id (uid, d); - - uid->next = key->uids; + *d++ = 0; + if (key->x509) + parse_x509_user_id (uid, d); + else + parse_user_id (uid, d); + + 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; + + 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, " \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) { - one_uid_as_xml (d,u); - for ( u = key->uids; u && u->next; u = u->next ) { - one_uid_as_xml (d,u); - } - } + /* Now the user IDs. */ + for (u = key->uids; u; u = u->next) + one_uid_as_xml (d,u); /* and now the subkeys */ for (k=key->keys.next; k; k = k->next ) {