857 |
if (!inf) |
if (!inf) |
858 |
return; |
return; |
859 |
list = inf->list; |
list = inf->list; |
860 |
while (list) |
while (list) { |
|
{ |
|
861 |
i = list->next; |
i = list->next; |
862 |
if (list->name) |
if (list->name) { |
|
{ |
|
863 |
safe_free (list->name); |
safe_free (list->name); |
864 |
list->name = NULL; |
list->name = NULL; |
865 |
} |
} |
866 |
if (list->prefs) |
if (list->prefs) { |
|
{ |
|
867 |
safe_free (list->prefs); |
safe_free (list->prefs); |
868 |
list->prefs = NULL; |
list->prefs = NULL; |
869 |
} |
} |
878 |
{ |
{ |
879 |
char *p, *pend; |
char *p, *pend; |
880 |
int field = 0, len = 0; |
int field = 0, len = 0; |
881 |
struct user_id_info_s *i; |
struct user_id_info_s *i, *t; |
882 |
|
|
883 |
if (!line || strlen (line) < 3 || strncmp (line, "uid", 3)) |
if (!line || strlen (line) < 3 || strncmp (line, "uid", 3)) |
884 |
return; |
return; |
885 |
|
|
886 |
i = calloc( 1, sizeof *i ); |
i = calloc (1, sizeof *i); |
887 |
if( i == NULL ) |
if (!i) |
888 |
return; |
return; |
889 |
i->next = inf->list; |
if (!inf->list) |
890 |
inf->list = i; |
inf->list = i; |
891 |
|
else { |
892 |
|
for (t=inf->list; t->next; t=t->next) |
893 |
|
; |
894 |
|
t->next = i; |
895 |
|
} |
896 |
|
|
897 |
p = strdup( line ); |
p = strdup (line); |
898 |
if( p == NULL ) |
if (!p) |
899 |
return; |
return; |
900 |
while( 1 ) { |
while (1) { |
901 |
field++; |
field++; |
902 |
pend = strsep (&p, ":"); |
pend = strsep (&p, ":"); |
903 |
if (pend == NULL) |
if (pend == NULL) |
904 |
break; |
break; |
905 |
|
|
906 |
switch (field) |
switch (field) { |
|
{ |
|
907 |
case 2: /* trust info */ |
case 2: /* trust info */ |
908 |
break; |
break; |
909 |
|
|
911 |
i->name = calloc (1, strlen (pend)+1); |
i->name = calloc (1, strlen (pend)+1); |
912 |
if (!i->name) |
if (!i->name) |
913 |
return; |
return; |
914 |
_gpgme_decode_c_string (pend, &i->name, strlen (pend)+ 1); |
_gpgme_decode_c_string (pend, &i->name, strlen (pend)+ 1); |
915 |
|
if (strchr (pend, '<') != NULL) { |
916 |
|
int pos = strchr (i->name, '<')- i->name + 1; |
917 |
|
int end = strchr (i->name, '>') - i->name; |
918 |
|
i->email = calloc (1, end-pos+2); |
919 |
|
if (!i->email) |
920 |
|
return; |
921 |
|
memcpy (i->email, i->name+pos, (end-pos)); |
922 |
|
} |
923 |
break; |
break; |
924 |
|
|
925 |
case 13: /* preferences */ |
case 13: /* preferences */ |
926 |
if (strstr (pend, "mdc")) |
if (strstr (pend, "mdc")) { |
|
{ |
|
927 |
len = strlen (pend) - 4; /* ,mdc */ |
len = strlen (pend) - 4; /* ,mdc */ |
928 |
if (strstr (pend, "no-ks-modify")) |
if (strstr (pend, "no-ks-modify")) { |
|
{ |
|
929 |
i->flags.no_ks_modify = 1; |
i->flags.no_ks_modify = 1; |
930 |
len -= 13; /* ,no-ks-modify */ |
len -= 13; /* ,no-ks-modify */ |
931 |
} |
} |
940 |
i->prefs = strdup (pend); |
i->prefs = strdup (pend); |
941 |
if (!i->prefs) |
if (!i->prefs) |
942 |
return; |
return; |
943 |
i->flags.mdc = 0; |
i->flags.mdc = 0; |
944 |
} |
} |
945 |
break; |
break; |
946 |
|
|
947 |
case 14: /* idx/flags */ |
case 14: /* idx/flags */ |
948 |
i->idx = atol( pend ); |
i->idx = atol (pend); |
949 |
if( strchr( pend, 'r' ) ) |
if (strchr (pend, 'r')) |
950 |
i->flags.revoked = 1; |
i->flags.revoked = 1; |
951 |
if( strchr( pend, 'p' ) ) |
if (strchr( pend, 'p')) |
952 |
i->flags.primary = 1; |
i->flags.primary = 1; |
953 |
break; |
break; |
954 |
} |
} |
955 |
} |
} |
956 |
safe_free( p ); |
safe_free (p); |
957 |
} /* edit_key_colon_handler */ |
} /* edit_key_colon_handler */ |
958 |
|
|
959 |
|
|
960 |
static gpgme_error_t |
static gpgme_error_t |
961 |
editkey_get_info_start( gpgme_ctx_t ctx, const char *keyid, gpgme_data_t out ) |
editkey_get_info_start (gpgme_ctx_t ctx, const char *keyid, gpgme_data_t out) |
962 |
{ |
{ |
963 |
gpgme_error_t rc; |
gpgme_error_t rc; |
964 |
|
|
1008 |
return err; |
return err; |
1009 |
|
|
1010 |
err = editkey_get_info_start( ctx, keyid, out ); |
err = editkey_get_info_start( ctx, keyid, out ); |
1011 |
if( !err ) |
if (!err) { |
1012 |
{ |
gpgme_wait (ctx, 1); |
|
gpgme_wait( ctx, 1 ); |
|
1013 |
ctx->pending = 0; |
ctx->pending = 0; |
1014 |
} |
} |
1015 |
if (err) |
if (err) |
1016 |
return err; |
return err; |
1017 |
|
|
1018 |
err = gpgme_uid_info_new( &inf ); |
err = gpgme_uid_info_new (&inf); |
1019 |
if (err) |
if (err) |
1020 |
return err; |
return err; |
1021 |
|
|
1094 |
|
|
1095 |
|
|
1096 |
const char* |
const char* |
1097 |
gpgme_editkey_get_string_attr( gpgme_uidinfo_t inf, int what, int idx ) |
gpgme_editkey_get_string_attr (gpgme_uidinfo_t inf, int what, int idx) |
1098 |
{ |
{ |
1099 |
const char *val; |
const char *val=NULL; |
1100 |
struct user_id_info_s *i; |
struct user_id_info_s *i; |
1101 |
|
|
1102 |
if( !inf ) |
if( !inf ) |
1104 |
|
|
1105 |
switch( what ) { |
switch( what ) { |
1106 |
case GPGME_ATTR_NAME: |
case GPGME_ATTR_NAME: |
1107 |
for( i = inf->list; i && idx; i = i->next, idx-- ) |
for (i = inf->list; i && idx; i = i->next, idx--) |
1108 |
; |
; |
1109 |
if( i ) |
if (i) |
1110 |
val = i->name; |
val = i->name; |
1111 |
break; |
break; |
1112 |
|
|
1113 |
|
case GPGME_ATTR_EMAIL: |
1114 |
|
for (i=inf->list; i && idx; i = i->next, idx--) |
1115 |
|
; |
1116 |
|
if (i) |
1117 |
|
val = i->email; |
1118 |
|
break; |
1119 |
|
|
1120 |
case GPGME_ATTR_UID_PREFS: |
case GPGME_ATTR_UID_PREFS: |
1121 |
for( i = inf->list; i && idx; i = i->next, idx-- ) |
for (i = inf->list; i && idx; i = i->next, idx--) |
1122 |
; |
; |
1123 |
if( i ) |
if (i) |
1124 |
val = i->prefs; |
val = i->prefs; |
1125 |
break; |
break; |
1126 |
|
|