mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg: Use a common filter_getval for import and export.
* g10/import.c (filter_getval): Rename to ... (impex_filter_getval): this. Make global. (apply_keep_uid_filter, apply_drop_sig_filter): Adjust. * g10/export.c (filter_getval): Remove. (apply_drop_sig_filter): Use impex_filter_getval. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
f9e49c80e7
commit
c8e0d37f41
33
g10/export.c
33
g10/export.c
@ -1293,37 +1293,6 @@ write_keyblock_to_output (kbnode_t keyblock, int with_armor,
|
||||
}
|
||||
|
||||
|
||||
/* Helper for apply_keep_uid_filter. */
|
||||
static const char *
|
||||
filter_getval (void *cookie, const char *propname)
|
||||
{
|
||||
kbnode_t node = cookie;
|
||||
const char *result;
|
||||
|
||||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
if (!strcmp (propname, "uid"))
|
||||
result = node->pkt->pkt.user_id->name;
|
||||
else if (!strcmp (propname, "mbox"))
|
||||
{
|
||||
if (!node->pkt->pkt.user_id->mbox)
|
||||
{
|
||||
node->pkt->pkt.user_id->mbox
|
||||
= mailbox_from_userid (node->pkt->pkt.user_id->name);
|
||||
}
|
||||
return node->pkt->pkt.user_id->mbox;
|
||||
}
|
||||
else if (!strcmp (propname, "primary"))
|
||||
result = node->pkt->pkt.user_id->is_primary? "1":"0";
|
||||
else
|
||||
result = NULL;
|
||||
}
|
||||
else
|
||||
result = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply the keep-uid filter to the keyblock. The deleted nodes are
|
||||
* marked and thus the caller should call commit_kbnode afterwards.
|
||||
@ -1338,7 +1307,7 @@ apply_keep_uid_filter (kbnode_t keyblock, recsel_expr_t selector)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
if (!recsel_select (selector, filter_getval, node))
|
||||
if (!recsel_select (selector, impex_filter_getval, node))
|
||||
{
|
||||
/* log_debug ("keep-uid: deleting '%s'\n", */
|
||||
/* node->pkt->pkt.user_id->name); */
|
||||
|
10
g10/import.c
10
g10/import.c
@ -1103,9 +1103,9 @@ check_prefs (ctrl_t ctrl, kbnode_t keyblock)
|
||||
}
|
||||
|
||||
|
||||
/* Helper for apply_keep_uid_filter and apply_drop_sig_filter. */
|
||||
static const char *
|
||||
filter_getval (void *cookie, const char *propname)
|
||||
/* Helper for apply_*_filter in im,port.c and export.c. */
|
||||
const char *
|
||||
impex_filter_getval (void *cookie, const char *propname)
|
||||
{
|
||||
/* FIXME: Malloc our static buffers and access them via the cookie. */
|
||||
kbnode_t node = cookie;
|
||||
@ -1178,7 +1178,7 @@ apply_keep_uid_filter (kbnode_t keyblock, recsel_expr_t selector)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
if (!recsel_select (selector, filter_getval, node))
|
||||
if (!recsel_select (selector, impex_filter_getval, node))
|
||||
{
|
||||
|
||||
/* log_debug ("keep-uid: deleting '%s'\n", */
|
||||
@ -1237,7 +1237,7 @@ apply_drop_sig_filter (kbnode_t keyblock, recsel_expr_t selector)
|
||||
|
||||
if (IS_UID_SIG(sig) || IS_UID_REV(sig))
|
||||
{
|
||||
if (recsel_select (selector, filter_getval, node))
|
||||
if (recsel_select (selector, impex_filter_getval, node))
|
||||
delete_kbnode (node);
|
||||
}
|
||||
}
|
||||
|
@ -368,6 +368,7 @@ gpg_error_t import_old_secring (ctrl_t ctrl, const char *fname);
|
||||
import_stats_t import_new_stats_handle (void);
|
||||
void import_release_stats_handle (import_stats_t hd);
|
||||
void import_print_stats (import_stats_t hd);
|
||||
const char *impex_filter_getval (void *cookie, const char *propname);
|
||||
gpg_error_t transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats,
|
||||
kbnode_t sec_keyblock, int batch, int force);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user