diff options
| author | Marcus Brinkmann <[email protected]> | 2001-12-18 19:54:00 +0000 | 
|---|---|---|
| committer | Marcus Brinkmann <[email protected]> | 2001-12-18 19:54:00 +0000 | 
| commit | 247eecaab9d36e3f0a25b5462747d4b96c486640 (patch) | |
| tree | 1aab1b2861fda62f112efa07120f327755efeb67 | |
| parent | * acinclude.m4 (GNUPG_FIX_HDR_VERSION): Fixed for new automake. (diff) | |
| download | gpgme-247eecaab9d36e3f0a25b5462747d4b96c486640.tar.gz gpgme-247eecaab9d36e3f0a25b5462747d4b96c486640.zip  | |
2001-12-18  Marcus Brinkmann  <[email protected]>
	* 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.
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | TODO | 8 | ||||
| -rw-r--r-- | gpgme/ChangeLog | 6 | ||||
| -rw-r--r-- | gpgme/key.c | 158 | 
4 files changed, 94 insertions, 81 deletions
@@ -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. @@ -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/gpgme/ChangeLog b/gpgme/ChangeLog index 8e1e6caf..62d1aaa4 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2001-12-18  Marcus Brinkmann  <[email protected]> + +	* 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  <[email protected]>  	* engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New diff --git a/gpgme/key.c b/gpgme/key.c index 9e43bef4..3bd3b56e 100644 --- a/gpgme/key.c +++ b/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, "  </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) { -        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 ) {  | 
