+2009-10-27 Marcus Brinkmann <marcus@g10code.de>
+
+ * edit.c (gpgme_op_edit_start, gpgme_op_edit)
+ (gpgme_op_card_edit_start, gpgme_op_card_edit): Add debug output.
+ * encrypt-sign.c (gpgme_op_encrypt_sign_start)
+ (gpgme_op_encrypt_sign): Likewise.
+ * encrypt.c (gpgme_op_encrypt_start, gpgme_op_encrypt)
+ (gpgme_op_encrypt_result): Likewise.
+ * export.c (gpgme_op_export_start, gpgme_op_export)
+ (gpgme_op_export_ext_start, gpgme_op_export_ext)
+ (gpgme_op_export_keys_start, gpgme_op_export_keys): Likewise.
+ * genkey.c (gpgme_op_genkey_start, gpgme_op_genkey)
+ (gpgme_op_genkey_result): Likewise.
+ * getauditlog.c (gpgme_op_getauditlog_start)
+ (gpgme_op_getauditlog): Likewise.
+ * import.c (gpgme_op_import_result, gpgme_op_import_start)
+ (gpgme_op_import): Likewise.
+ * keylist.c (gpgme_op_keylist_result, keylist_colon_handler)
+ (gpgme_op_keylist_start, gpgme_op_keylist_ext_start)
+ (gpgme_op_keylist_next, gpgme_op_keylist_end, gpgme_get_key): Likewise.
+ * opassuan.c (gpgme_op_assuan_transact_start)
+ (gpgme_op_assuan_transact_ext, gpgme_op_assuan_result)
+ (gpgme_op_assuan_transact): Likewise.
+ * signers.c (gpgme_signers_add, gpgme_signers_clear): Likewise.
+ * trustlist.c (gpgme_op_trustlist_start)
+ (gpgme_op_trustlist_next, gpgme_op_trustlist_end): Likewise.
+ * verify.c (gpgme_op_verify_start, gpgme_op_verify)
+ (gpgme_op_verify_result): Likewise.
+
2009-10-26 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h.in (struct gpgme_io_event_done_data)
_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4), 0
+#define TRACE_BEG5(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5) \
+ _TRACE (lvl, name, tag); \
+ _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \
+ _gpgme_trace_func, _gpgme_trace_tagname, \
+ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0
+#define TRACE_BEG7(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \
+ arg5, arg6, arg7) \
+ _TRACE (lvl, name, tag); \
+ _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \
+ _gpgme_trace_func, _gpgme_trace_tagname, \
+ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \
+ arg6, arg7), 0
+#define TRACE_BEG8(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, \
+ arg5, arg6, arg7, arg8) \
+ _TRACE (lvl, name, tag); \
+ _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): enter: " fmt "\n", \
+ _gpgme_trace_func, _gpgme_trace_tagname, \
+ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5, \
+ arg6, arg7, arg8), 0
#define TRACE(lvl, name, tag) \
_gpgme_debug (lvl, "%s (%s=%p): call\n", \
_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
_gpgme_trace_tag, arg1, arg2, arg3, arg4), 0
+#define TRACE_LOG5(fmt, arg1, arg2, arg3, arg4, arg5) \
+ _gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \
+ _gpgme_trace_func, _gpgme_trace_tagname, \
+ _gpgme_trace_tag, arg1, arg2, arg3, arg4, arg5), 0
#define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
_gpgme_debug (_gpgme_trace_level, "%s (%s=%p): check: " fmt "\n", \
_gpgme_trace_func, _gpgme_trace_tagname, \
{
gpgme_error_t err;
- TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx,
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt", ctx,
"cipher=%p, plain=%p", cipher, plain);
err = decrypt_start (ctx, 1, cipher, plain);
if (!err)
#include <stdlib.h>
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key,
gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out)
{
- return edit_start (ctx, 0, 0, key, fnc, fnc_value, out);
+ TRACE_BEG5 (DEBUG_CTX, "gpgme_op_edit_start", ctx,
+ "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", fnc, fnc_value, out);
+ return TRACE_ERR (edit_start (ctx, 0, 0, key, fnc, fnc_value, out));
}
gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key,
gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out)
{
- gpgme_error_t err = edit_start (ctx, 1, 0, key, fnc, fnc_value, out);
+ gpgme_error_t err;
+
+ TRACE_BEG5 (DEBUG_CTX, "gpgme_op_edit", ctx,
+ "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", fnc, fnc_value, out);
+
+ err = edit_start (ctx, 1, 0, key, fnc, fnc_value, out);
+
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
\f
gpgme_edit_cb_t fnc, void *fnc_value,
gpgme_data_t out)
{
- return edit_start (ctx, 0, 1, key, fnc, fnc_value, out);
+ TRACE_BEG5 (DEBUG_CTX, "gpgme_op_card_edit_start", ctx,
+ "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", fnc, fnc_value, out);
+ return TRACE_ERR (edit_start (ctx, 0, 1, key, fnc, fnc_value, out));
}
gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key,
gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out)
{
- gpgme_error_t err = edit_start (ctx, 1, 1, key, fnc, fnc_value, out);
+ gpgme_error_t err;
+
+ TRACE_BEG5 (DEBUG_CTX, "gpgme_op_card_edit", ctx,
+ "key=%p (%s), fnc=%p fnc_value=%p, out=%p", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", fnc, fnc_value, out);
+ err = edit_start (ctx, 1, 1, key, fnc, fnc_value, out);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#endif
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- return encrypt_sign_start (ctx, 0, recp, flags, plain, cipher);
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_sign_start", ctx,
+ "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher);
+
+ if (_gpgme_debug_trace () && recp)
+ {
+ int i = 0;
+
+ while (recp[i])
+ {
+ TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i],
+ (recp[i]->subkeys && !recp[i]->subkeys->fpr) ?
+ recp[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ return TRACE_ERR (encrypt_sign_start (ctx, 0, recp, flags, plain, cipher));
}
gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- gpgme_error_t err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher);
+ gpgme_error_t err;
+
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_sign", ctx,
+ "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher);
+
+ if (_gpgme_debug_trace () && recp)
+ {
+ int i = 0;
+
+ while (recp[i])
+ {
+ TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i],
+ (recp[i]->subkeys && !recp[i]->subkeys->fpr) ?
+ recp[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#include <errno.h>
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_encrypt_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+ if (_gpgme_debug_trace ())
+ {
+ gpgme_invalid_key_t invkeys = opd->result.invalid_recipients;
+ int i = 0;
+
+ while (invkeys)
+ {
+ TRACE_LOG3 ("invalid_recipients[%i] = %s (%s)",
+ i, invkeys->fpr ? invkeys->fpr : "(null)",
+ gpg_strerror (invkeys->reason));
+ invkeys = invkeys->next;
+ i++;
+ }
+ }
+
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- return encrypt_start (ctx, 0, recp, flags, plain, cipher);
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt_start", ctx,
+ "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher);
+
+ if (_gpgme_debug_trace () && recp)
+ {
+ int i = 0;
+
+ while (recp[i])
+ {
+ TRACE_LOG3 ("recipient[%i] = %p (%s)", i,recp[i],
+ (recp[i]->subkeys && !recp[i]->subkeys->fpr) ?
+ recp[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ return TRACE_ERR (encrypt_start (ctx, 0, recp, flags, plain, cipher));
}
gpgme_encrypt_flags_t flags,
gpgme_data_t plain, gpgme_data_t cipher)
{
- gpgme_error_t err = encrypt_start (ctx, 1, recp, flags, plain, cipher);
+ gpgme_error_t err;
+
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_encrypt", ctx,
+ "flags=0x%x, plain=%p, cipher=%p", flags, plain, cipher);
+
+ if (_gpgme_debug_trace () && recp)
+ {
+ int i = 0;
+
+ while (recp[i])
+ {
+ TRACE_LOG3 ("recipient[%i] = %p (%s)", i, recp[i],
+ (recp[i]->subkeys && !recp[i]->subkeys->fpr) ?
+ recp[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ err = encrypt_start (ctx, 1, recp, flags, plain, cipher);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#include <string.h>
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern,
gpgme_export_mode_t mode, gpgme_data_t keydata)
{
- return export_start (ctx, 0, pattern, mode, keydata);
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_export_start", ctx,
+ "pattern=%s, mode=0x%x, keydata=%p", pattern, mode, keydata);
+ return TRACE_ERR (export_start (ctx, 0, pattern, mode, keydata));
}
gpgme_op_export (gpgme_ctx_t ctx, const char *pattern,
gpgme_export_mode_t mode, gpgme_data_t keydata)
{
- gpgme_error_t err = export_start (ctx, 1, pattern, mode, keydata);
+ gpgme_error_t err;
+
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_export", ctx,
+ "pattern=%s, mode=0x%x, keydata=%p", pattern, mode, keydata);
+
+ err = export_start (ctx, 1, pattern, mode, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
gpgme_op_export_ext_start (gpgme_ctx_t ctx, const char *pattern[],
gpgme_export_mode_t mode, gpgme_data_t keydata)
{
- return export_ext_start (ctx, 0, pattern, mode, keydata);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_ext_start", ctx,
+ "mode=0x%x, keydata=%p", mode, keydata);
+
+ if (_gpgme_debug_trace () && pattern)
+ {
+ int i = 0;
+
+ while (pattern[i])
+ {
+ TRACE_LOG2 ("pattern[%i] = %s", i, pattern[i]);
+ i++;
+ }
+ }
+
+ return TRACE_ERR (export_ext_start (ctx, 0, pattern, mode, keydata));
}
gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[],
gpgme_export_mode_t mode, gpgme_data_t keydata)
{
- gpgme_error_t err = export_ext_start (ctx, 1, pattern, mode, keydata);
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_ext_start", ctx,
+ "mode=0x%x, keydata=%p", mode, keydata);
+
+ if (_gpgme_debug_trace () && pattern)
+ {
+ int i = 0;
+
+ while (pattern[i])
+ {
+ TRACE_LOG2 ("pattern[%i] = %s", i, pattern[i]);
+ i++;
+ }
+ }
+
+ err = export_ext_start (ctx, 1, pattern, mode, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
gpgme_export_mode_t mode,
gpgme_data_t keydata)
{
- return export_keys_start (ctx, 0, keys, mode, keydata);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_keys_start", ctx,
+ "mode=0x%x, keydata=%p", mode, keydata);
+
+ if (_gpgme_debug_trace () && keys)
+ {
+ int i = 0;
+
+ while (keys[i])
+ {
+ TRACE_LOG3 ("keys[%i] = %p (%s)", i,keys[i],
+ (keys[i]->subkeys && !keys[i]->subkeys->fpr) ?
+ keys[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ return TRACE_ERR (export_keys_start (ctx, 0, keys, mode, keydata));
}
gpgme_error_t
gpgme_export_mode_t mode,
gpgme_data_t keydata)
{
- gpgme_error_t err = export_keys_start (ctx, 1, keys, mode, keydata);
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_export_keys", ctx,
+ "mode=0x%x, keydata=%p", mode, keydata);
+
+ if (_gpgme_debug_trace () && keys)
+ {
+ int i = 0;
+
+ while (keys[i])
+ {
+ TRACE_LOG3 ("keys[%i] = %p (%s)", i,keys[i],
+ (keys[i]->subkeys && !keys[i]->subkeys->fpr) ?
+ keys[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ err = export_keys_start (ctx, 1, keys, mode, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
#include <errno.h>
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_genkey_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+ TRACE_LOG3 ("fpr = %s, %s, %s", opd->result.fpr,
+ opd->result.primary ? "primary" : "no primary",
+ opd->result.sub ? "sub" : "no sub");
+
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms,
gpgme_data_t pubkey, gpgme_data_t seckey)
{
- return genkey_start (ctx, 0, parms, pubkey, seckey);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey_start", ctx,
+ "pubkey=%p, seckey=%p", pubkey, seckey);
+ TRACE_LOGBUF (parms, strlen (parms));
+ return TRACE_ERR (genkey_start (ctx, 0, parms, pubkey, seckey));
}
{
gpgme_error_t err;
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_genkey", ctx,
+ "pubkey=%p, seckey=%p", pubkey, seckey);
+ TRACE_LOGBUF (parms, strlen (parms));
+
err = genkey_start (ctx, 1, parms, pubkey, seckey);
if (!err)
err = _gpgme_wait_one (ctx);
#endif
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
gpgme_op_getauditlog_start (gpgme_ctx_t ctx,
gpgme_data_t output, unsigned int flags)
{
- return getauditlog_start (ctx, 0, output, flags);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog_start", ctx,
+ "output=%p, flags=0x%x", output, flags);
+ return TRACE_ERR (getauditlog_start (ctx, 0, output, flags));
}
gpgme_error_t
gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, unsigned int flags)
{
- gpgme_error_t err = getauditlog_start (ctx, 1, output, flags);
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_getauditlog", ctx,
+ "output=%p, flags=0x%x", output, flags);
+
+ err = getauditlog_start (ctx, 1, output, flags);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#include <string.h>
#include "gpgme.h"
+#include "debug.h"
#include "context.h"
#include "ops.h"
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_import_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_IMPORT, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+
+
+ if (_gpgme_debug_trace ())
+ {
+ gpgme_import_status_t impstat;
+ int i;
+
+ TRACE_LOG5 ("%i considered, %i no UID, %i imported, %i imported RSA, "
+ "%i unchanged", opd->result.considered,
+ opd->result.no_user_id, opd->result.imported,
+ opd->result.imported_rsa, opd->result.unchanged);
+ TRACE_LOG4 ("%i new UIDs, %i new sub keys, %i new signatures, "
+ "%i new revocations", opd->result.new_user_ids,
+ opd->result.new_sub_keys, opd->result.new_signatures,
+ opd->result.new_revocations);
+ TRACE_LOG3 ("%i secret keys, %i imported, %i unchanged",
+ opd->result.secret_read, opd->result.secret_imported,
+ opd->result.secret_unchanged);
+ TRACE_LOG2 ("%i skipped new keys, %i not imported",
+ opd->result.skipped_new_keys, opd->result.not_imported);
+
+ impstat = opd->result.imports;
+ i = 0;
+ while (impstat)
+ {
+ TRACE_LOG4 ("import[%i] for %s = 0x%x (%s)",
+ i, impstat->fpr, impstat->status, impstat->result);
+ impstat = impstat->next;
+ i++;
+ }
+ }
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
gpgme_error_t
gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata)
{
- return _gpgme_op_import_start (ctx, 0, keydata);
+ TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import_start", ctx,
+ "keydata=%p", keydata);
+
+ return TRACE_ERR (_gpgme_op_import_start (ctx, 0, keydata));
}
gpgme_error_t
gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata)
{
- gpgme_error_t err = _gpgme_op_import_start (ctx, 1, keydata);
+ gpgme_error_t err;
+
+ TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import", ctx,
+ "keydata=%p", keydata);
+
+ err = _gpgme_op_import_start (ctx, 1, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
gpgme_error_t
gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t *keys)
{
- return _gpgme_op_import_keys_start (ctx, 0, keys);
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys_start", ctx);
+ if (_gpgme_debug_trace () && keys)
+ {
+ int i = 0;
+
+ while (keys[i])
+ {
+ TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i],
+ (keys[i]->subkeys && !keys[i]->subkeys->fpr) ?
+ keys[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ return TRACE_ERR (_gpgme_op_import_keys_start (ctx, 0, keys));
}
gpgme_error_t
gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t *keys)
{
- gpgme_error_t err = _gpgme_op_import_keys_start (ctx, 1, keys);
+ gpgme_error_t err;
+
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys", ctx);
+ if (_gpgme_debug_trace () && keys)
+ {
+ int i = 0;
+
+ while (keys[i])
+ {
+ TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i],
+ (keys[i]->subkeys && !keys[i]->subkeys->fpr) ?
+ keys[i]->subkeys->fpr : "invalid");
+ i++;
+ }
+ }
+
+ err = _gpgme_op_import_keys_start (ctx, 1, keys);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_keylist_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+
+ TRACE_LOG1 ("truncated = %i", opd->result.truncated);
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
void *hook;
op_data_t opd;
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_start", ctx,
+ "pattern=%s, secret_only=%i", pattern, secret_only);
+
err = _gpgme_op_reset (ctx, 2);
if (err)
- return err;
+ return TRACE_ERR (err);
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook,
sizeof (*opd), release_op_data);
opd = hook;
if (err)
- return err;
+ return TRACE_ERR (err);
_gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx);
err = _gpgme_engine_set_colon_line_handler (ctx->engine,
keylist_colon_handler, ctx);
if (err)
- return err;
+ return TRACE_ERR (err);
- return _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only,
- ctx->keylist_mode);
+ err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only,
+ ctx->keylist_mode);
+ return TRACE_ERR (err);
}
void *hook;
op_data_t opd;
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_keylist_ext_start", ctx,
+ "secret_only=%i, reserved=0x%x", secret_only, reserved);
+
err = _gpgme_op_reset (ctx, 2);
if (err)
- return err;
+ return TRACE_ERR (err);
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook,
sizeof (*opd), release_op_data);
opd = hook;
if (err)
- return err;
+ return TRACE_ERR (err);
_gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx);
err = _gpgme_engine_set_colon_line_handler (ctx->engine,
keylist_colon_handler, ctx);
if (err)
- return err;
+ return TRACE_ERR (err);
- return _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only,
- reserved, ctx->keylist_mode);
+ err = _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only,
+ reserved, ctx->keylist_mode);
+ return TRACE_ERR (err);
}
void *hook;
op_data_t opd;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_keylist_next", ctx);
+
if (!ctx || !r_key)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
*r_key = NULL;
if (!ctx)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL);
opd = hook;
if (err)
- return err;
+ return TRACE_ERR (err);
if (opd == NULL)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (!opd->key_queue)
{
err = _gpgme_wait_on_condition (ctx, &opd->key_cond, NULL);
if (err)
- return err;
+ return TRACE_ERR (err);
if (!opd->key_cond)
- return gpg_error (GPG_ERR_EOF);
+ return TRACE_ERR (gpg_error (GPG_ERR_EOF));
opd->key_cond = 0;
assert (opd->key_queue);
*r_key = queue_item->key;
free (queue_item);
- return 0;
+
+ return TRACE_SUC2 ("key=%p (%s)", *r_key,
+ ((*r_key)->subkeys && !(*r_key)->subkeys->fpr) ?
+ (*r_key)->subkeys->fpr : "invalid");
}
gpgme_error_t
gpgme_op_keylist_end (gpgme_ctx_t ctx)
{
+ TRACE (DEBUG_CTX, "gpgme_op_keylist_end", ctx);
+
if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE);
gpgme_error_t err;
gpgme_key_t key;
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_get_key", ctx,
+ "fpr=%s, secret=%i", fpr, secret);
+
if (!ctx || !r_key || !fpr)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (strlen (fpr) < 8) /* We have at least a key ID. */
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
/* FIXME: We use our own context because we have to avoid the user's
I/O callback handlers. */
err = gpgme_new (&listctx);
if (err)
- return err;
+ return TRACE_ERR (err);
{
gpgme_protocol_t proto;
gpgme_engine_info_t info;
}
}
gpgme_release (listctx);
- return err;
+ if (! err)
+ {
+ TRACE_LOG2 ("key=%p (%s)", *r_key,
+ ((*r_key)->subkeys && !(*r_key)->subkeys->fpr) ?
+ (*r_key)->subkeys->fpr : "invalid");
+ }
+ return TRACE_ERR (err);
}
#include <config.h>
#endif
+/* Suppress warning for accessing deprecated member "err". */
+#define _GPGME_IN_GPGME 1
#include "gpgme.h"
#include "context.h"
#include "ops.h"
#include "util.h"
+#include "debug.h"
static gpgme_error_t
opassuan_start (gpgme_ctx_t ctx, int synchronous,
gpgme_assuan_status_cb_t status_cb,
void *status_cb_value)
{
- return opassuan_start (ctx, 0, command,
- data_cb, data_cb_value,
- inq_cb, inq_cb_value,
- status_cb, status_cb_value);
+ TRACE_BEG7 (DEBUG_CTX, "gpgme_op_assuan_transact_start", ctx,
+ "command=%s, data_cb=%p/%p, inq_cb=%p/%p, status_cb=%p/%p",
+ command, data_cb, data_cb_value, inq_cb, inq_cb_value,
+ status_cb, status_cb_value);
+
+ return TRACE_ERR (opassuan_start (ctx, 0, command,
+ data_cb, data_cb_value,
+ inq_cb, inq_cb_value,
+ status_cb, status_cb_value));
}
void *inq_cb_value,
gpgme_assuan_status_cb_t status_cb,
void *status_cb_value,
- gpgme_error_t *op_err)
+ gpgme_error_t *op_err_p)
{
gpgme_error_t err;
+ gpgme_error_t op_err;
+
+ TRACE_BEG8 (DEBUG_CTX, "gpgme_op_assuan_transact", ctx,
+ "command=%s, data_cb=%p/%p, inq_cb=%p/%p, status_cb=%p/%p, "
+ "op_err=%p",
+ command, data_cb, data_cb_value, inq_cb, inq_cb_value,
+ status_cb, status_cb_value, op_err_p);
err = opassuan_start (ctx, 1, command,
data_cb, data_cb_value,
inq_cb, inq_cb_value,
status_cb, status_cb_value);
if (!err)
- err = _gpgme_wait_one_ext (ctx, op_err);
- return err;
+ err = _gpgme_wait_one_ext (ctx, &op_err);
+
+ if (op_err)
+ {
+ TRACE_LOG2 ("op_err = %s <%s>", gpgme_strerror (op_err),
+ gpgme_strsource (op_err));
+ if (! op_err_p)
+ {
+ TRACE_LOG ("warning: operational error ignored by user");
+ }
+ }
+ if (op_err_p)
+ *op_err_p = op_err;
+
+ return TRACE_ERR (err);
}
void *hook;
op_data_t opd;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_assuan_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_ASSUAN, &hook, -1, NULL);
opd = hook;
/* Check in case this function is used without having run a command
before. */
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
/* All of this is a hack for the old style interface. The new style
interface returns op errors directly. */
opd->result.err = _gpgme_engine_assuan_last_op_err (ctx->engine->engine);
-
+ if (opd->result.err)
+ {
+ TRACE_LOG1 ("err = %s", gpg_strerror (0));
+ }
+ else
+ {
+ TRACE_LOG2 ("err = %s <%s>", gpg_strerror (opd->result.err),
+ gpg_strsource (opd->result.err));
+ }
+
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
gpgme_assuan_status_cb_t status_cb,
void *status_cb_value)
{
- gpgme_error_t op_err;
gpgme_error_t err;
+ TRACE (DEBUG_CTX, "gpgme_op_assuan_transact", ctx);
+
/* Users of the old-style session based interfaces need to look at
the result structure. */
gpgme_op_assuan_transact_ext (ctx, command, data_cb, data_cb_value,
inq_cb, inq_cb_value,
- status_cb, status_cb_value, &op_err);
+ status_cb, status_cb_value, NULL);
return err;
}
#include <assert.h>
#include <errno.h>
+#include "gpgme.h"
#include "util.h"
#include "context.h"
+#include "debug.h"
\f
/* Delete all signers from CTX. */
{
unsigned int i;
+ TRACE (DEBUG_CTX, "gpgme_signers_clear", ctx);
+
if (!ctx || !ctx->signers)
return;
gpgme_error_t
gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key)
{
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_signers_add", ctx,
+ "key=%p (%s)", key, (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid");
+
if (!ctx || !key)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (ctx->signers_len == ctx->signers_size)
{
newarr = realloc (ctx->signers, n * sizeof (*newarr));
if (!newarr)
- return gpg_error_from_errno (errno);
+ return TRACE_ERR (gpg_error_from_errno (errno));
for (j = ctx->signers_size; j < n; j++)
newarr[j] = NULL;
ctx->signers = newarr;
gpgme_key_ref (key);
ctx->signers[ctx->signers_len++] = key;
- return 0;
+ return TRACE_SUC ();
}
#include <errno.h>
#include "gpgme.h"
+#include "debug.h"
#include "util.h"
#include "context.h"
#include "ops.h"
void *hook;
op_data_t opd;
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_trustlist_start", ctx,
+ "pattern=%s, max_level=%i", pattern, max_level);
+
if (!pattern || !*pattern)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
err = _gpgme_op_reset (ctx, 2);
if (err)
- return err;
+ return TRACE_ERR (err);
err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook,
sizeof (*opd), NULL);
opd = hook;
if (err)
- return err;
+ return TRACE_ERR (err);
_gpgme_engine_set_status_handler (ctx->engine,
trustlist_status_handler, ctx);
err = _gpgme_engine_set_colon_line_handler (ctx->engine,
trustlist_colon_handler, ctx);
if (err)
- return err;
+ return TRACE_ERR (err);
- return _gpgme_engine_op_trustlist (ctx->engine, pattern);
+ err = _gpgme_engine_op_trustlist (ctx->engine, pattern);
+ return TRACE_ERR (err);
}
op_data_t opd;
struct trust_queue_item_s *q;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_trustlist_next", ctx);
+
if (!r_item)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
*r_item = NULL;
if (!ctx)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL);
opd = hook;
if (err)
- return err;
+ return TRACE_ERR (err);
if (opd == NULL)
- return gpg_error (GPG_ERR_INV_VALUE);
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
if (!opd->trust_queue)
{
err = _gpgme_wait_on_condition (ctx, &opd->trust_cond, NULL);
if (err)
- return err;
+ return TRACE_ERR (err);
if (!opd->trust_cond)
- return gpg_error (GPG_ERR_EOF);
+ return TRACE_ERR (gpg_error (GPG_ERR_EOF));
opd->trust_cond = 0;
assert (opd->trust_queue);
}
*r_item = q->item;
free (q);
+ if ((*r_item)->type == 1)
+ {
+ TRACE_SUC5 ("trust_item=%p: %s: owner trust %s with level %i "
+ "and validity 0x%x", *r_item, (*r_item)->keyid,
+ (*r_item)->owner_trust, (*r_item)->level,
+ (*r_item)->validity);
+ }
+ else if ((*r_item)->type == 2)
+ {
+ TRACE_SUC5 ("trust_item=%p: %s: UID %s with level %i "
+ "and validity 0x%x", *r_item, (*r_item)->keyid,
+ (*r_item)->name, (*r_item)->level, (*r_item)->validity);
+ }
+ else
+ {
+ TRACE_SUC5 ("trust_item=%p: %s: unknown type %i with level %i "
+ "and validity 0x%x", *r_item, (*r_item)->keyid,
+ (*r_item)->type, (*r_item)->level, (*r_item)->validity);
+ }
return 0;
}
gpgme_error_t
gpgme_op_trustlist_end (gpgme_ctx_t ctx)
{
+ TRACE (DEBUG_CTX, "gpgme_op_trustlist_end", ctx);
+
if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE);
#include <assert.h>
#include "gpgme.h"
+#include "debug.h"
#include "util.h"
#include "context.h"
#include "ops.h"
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_verify_result", ctx);
err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+
+ if (_gpgme_debug_trace ())
+ {
+ gpgme_signature_t sig = opd->result.signatures;
+ int i = 0;
+
+ while (sig)
+ {
+ TRACE_LOG4 ("sig[%i] = fpr %s, summary 0x%x, status %s",
+ i, sig->fpr, sig->summary, gpg_strerror (sig->status));
+ TRACE_LOG6 ("sig[%i] = timestamps 0x%x/0x%x flags:%s%s%s",
+ i, sig->timestamp, sig->exp_timestamp,
+ sig->wrong_key_usage ? "wrong key usage" : "",
+ sig->pka_trust == 1 ? "pka bad"
+ : (sig->pka_trust == 2 ? "pka_okay" : "pka RFU"),
+ sig->chain_model ? "chain model" : "");
+ TRACE_LOG5 ("sig[%i] = validity 0x%x (%s), algos %s/%s",
+ i, sig->validity, gpg_strerror (sig->validity_reason),
+ gpgme_pubkey_algo_name (sig->pubkey_algo),
+ gpgme_hash_algo_name (sig->hash_algo));
+ if (sig->pka_address)
+ {
+ TRACE_LOG2 ("sig[%i] = PKA address %s", i, sig->pka_address);
+ }
+ if (sig->notations)
+ {
+ TRACE_LOG1 ("sig[%i] = has notations (not shown)", i);
+ }
+ sig = sig->next;
+ i++;
+ }
+ }
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig,
gpgme_data_t signed_text, gpgme_data_t plaintext)
{
- return verify_start (ctx, 0, sig, signed_text, plaintext);
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_verify_start", ctx,
+ "sig=%p, signed_text=%p, plaintext=%p",
+ sig, signed_text, plaintext);
+ return TRACE_ERR (verify_start (ctx, 0, sig, signed_text, plaintext));
}
{
gpgme_error_t err;
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_verify", ctx,
+ "sig=%p, signed_text=%p, plaintext=%p",
+ sig, signed_text, plaintext);
+
err = verify_start (ctx, 1, sig, signed_text, plaintext);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
\f
gpgme_error_t err = 0;
int hang = 1;
+ if (op_err_p)
+ *op_err_p = 0;
+
do
{
int nr = _gpgme_io_select (ctx->fdt.fds, ctx->fdt.size, 0);
err = gpg_error_from_errno (errno);
_gpgme_cancel_with_err (ctx, err, 0);
- if (op_err_p)
- *op_err_p = 0;
return err;
}
and signal it. */
_gpgme_cancel_with_err (ctx, err, 0);
- if (op_err_p)
- *op_err_p = 0;
return err;
}
else if (op_err)
}
while (hang);
- if (op_err_p)
- *op_err_p = 0;
return 0;
}