mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-24 16:43:28 +02:00
gpg: Add debug flag "recsel".
* g10/gpg.c: Include recsel.h. (debug_flags): New flag "recsel". (set_debug): Set it. * g10/options.h (DBG_RECSEL_VALUE, DBG_RECSEL): New. * g10/import.c (impex_filter_getval): Add debug diagnostics. * g10/keylist.c (parse_and_set_list_filter): Dump the record filter. * common/recsel.c (recsel_debug): New variable. (recsel_set_debug): New function. (recsel_select): Add debug output if requested.
This commit is contained in:
parent
28591a9f3a
commit
a9445bbb1d
@ -71,6 +71,10 @@ struct recsel_expr_s
|
||||
};
|
||||
|
||||
|
||||
/* Global debug variable. */
|
||||
static int recsel_debug;
|
||||
|
||||
|
||||
/* Helper */
|
||||
static inline gpg_error_t
|
||||
my_error_from_syserror (void)
|
||||
@ -460,6 +464,15 @@ recsel_release (recsel_expr_t a)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
recsel_set_debug (int value)
|
||||
{
|
||||
int old = recsel_debug;
|
||||
recsel_debug = value;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
recsel_dump (recsel_expr_t selector)
|
||||
{
|
||||
@ -511,6 +524,8 @@ recsel_select (recsel_expr_t selector,
|
||||
while (se)
|
||||
{
|
||||
value = getval? getval (cookie, se->name) : NULL;
|
||||
if (recsel_debug)
|
||||
log_debug ("%s: name=%s got value '%s'\n", __func__, se->name, value);
|
||||
if (!value)
|
||||
value = "";
|
||||
|
||||
@ -616,5 +631,7 @@ recsel_select (recsel_expr_t selector,
|
||||
}
|
||||
}
|
||||
|
||||
if (recsel_debug)
|
||||
log_debug ("%s: result=%d\n", __func__, result);
|
||||
return result;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ typedef struct recsel_expr_s *recsel_expr_t;
|
||||
|
||||
gpg_error_t recsel_parse_expr (recsel_expr_t *selector, const char *expr);
|
||||
void recsel_release (recsel_expr_t a);
|
||||
int recsel_set_debug (int value);
|
||||
void recsel_dump (recsel_expr_t selector);
|
||||
int recsel_select (recsel_expr_t selector,
|
||||
const char *(*getval)(void *cookie, const char *propname),
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "../common/init.h"
|
||||
#include "../common/mbox-util.h"
|
||||
#include "../common/zb32.h"
|
||||
#include "../common/recsel.h"
|
||||
#include "../common/shareddefs.h"
|
||||
#include "../common/compliance.h"
|
||||
#include "../common/comopt.h"
|
||||
@ -1043,6 +1044,7 @@ static struct debug_flags_s debug_flags [] =
|
||||
{ DBG_TRUST_VALUE , "trust" },
|
||||
{ DBG_HASHING_VALUE, "hashing" },
|
||||
{ DBG_IPC_VALUE , "ipc" },
|
||||
{ DBG_RECSEL_VALUE , "recsel" },
|
||||
{ DBG_CLOCK_VALUE , "clock" },
|
||||
{ DBG_LOOKUP_VALUE , "lookup" },
|
||||
{ DBG_EXTPROG_VALUE, "extprog" },
|
||||
@ -1413,6 +1415,9 @@ set_debug (const char *level)
|
||||
if (opt.debug && opt.quiet)
|
||||
opt.quiet = 0;
|
||||
|
||||
/* Pass debug flags to the record selection module. */
|
||||
recsel_set_debug (!!DBG_RECSEL);
|
||||
|
||||
if (opt_set_iobuf_size || opt_set_iobuf_size_used)
|
||||
log_debug ("iobuf buffer size is %uk\n",
|
||||
iobuf_set_buffer_size (opt_set_iobuf_size));
|
||||
|
@ -1464,6 +1464,8 @@ impex_filter_getval (void *cookie, const char *propname)
|
||||
/* We allow a prefix delimited by a slash to limit the scope of the
|
||||
* keyword. Note that "pub" also includes "sec" and "sub" includes
|
||||
* "ssb". */
|
||||
if (DBG_RECSEL) /* Printing the packet type is useful. */
|
||||
log_debug ("%s: pkttype=%s\n", __func__, pkttype_str (node->pkt->pkttype));
|
||||
if ((s=strchr (propname, '/')) && s != propname)
|
||||
{
|
||||
size_t n = s - propname;
|
||||
|
@ -132,6 +132,8 @@ parse_and_set_list_filter (const char *string)
|
||||
err = recsel_parse_expr (&list_filter.selkey, string+7);
|
||||
else
|
||||
err = gpg_error (GPG_ERR_INV_NAME);
|
||||
if (!err && DBG_RECSEL)
|
||||
recsel_dump (list_filter.selkey);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -368,6 +368,7 @@ struct {
|
||||
#define DBG_TRUST_VALUE 256 /* debug the trustdb */
|
||||
#define DBG_HASHING_VALUE 512 /* debug hashing operations */
|
||||
#define DBG_IPC_VALUE 1024 /* debug assuan communication */
|
||||
#define DBG_RECSEL_VALUE 2048 /* Debug the record selection */
|
||||
#define DBG_CLOCK_VALUE 4096
|
||||
#define DBG_LOOKUP_VALUE 8192 /* debug the key lookup */
|
||||
#define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
|
||||
@ -382,6 +383,7 @@ struct {
|
||||
#define DBG_TRUST (opt.debug & DBG_TRUST_VALUE)
|
||||
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
|
||||
#define DBG_IPC (opt.debug & DBG_IPC_VALUE)
|
||||
#define DBG_RECSEL (opt.debug & DBG_RECSEL_VALUE)
|
||||
#define DBG_CLOCK (opt.debug & DBG_CLOCK_VALUE)
|
||||
#define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
|
||||
#define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user