* debug.h (DEBUG_GLOBAL): New debug level.
* conversion.c (gnupg_errors, _gpgme_map_gnupg_error): Removed.
* data-user.c (gpgme_data_new_from_cbs): Add debug output.
* data-fd.c (gpgme_data_new_from_fd): Likewise.
* data-stream.c (gpgme_data_new_from_stream): Likewise.
* decrypt.c (gpgme_op_decrypt_result, gpgme_op_decrypt_start)
(gpgme_op_decrypt): Likewise.
* delete.c (gpgme_op_delete_start, gpgme_op_delete): Likewise.
* decrypt-verify.c (gpgme_op_decrypt_verify_start)
(gpgme_op_decrypt_verify): Likewise.
* sign.c (gpgme_op_sign_result): Fix debug message.
* data-mem.c (gpgme_data_new): Improve debug output.
* verify.c (parse_trust): Use atoi instead of
_gpgme_map_gnupg_error.
* decrypt.c (_gpgme_decrypt_status_handler): Likewise.
+2009-10-26 Marcus Brinkmann <marcus@g10code.de>
+
+ * debug.h (DEBUG_GLOBAL): New debug level.
+ * conversion.c (gnupg_errors, _gpgme_map_gnupg_error): Removed.
+ * data-user.c (gpgme_data_new_from_cbs): Add debug output.
+ * data-fd.c (gpgme_data_new_from_fd): Likewise.
+ * data-stream.c (gpgme_data_new_from_stream): Likewise.
+ * decrypt.c (gpgme_op_decrypt_result, gpgme_op_decrypt_start)
+ (gpgme_op_decrypt): Likewise.
+ * delete.c (gpgme_op_delete_start, gpgme_op_delete): Likewise.
+ * decrypt-verify.c (gpgme_op_decrypt_verify_start)
+ (gpgme_op_decrypt_verify): Likewise.
+ * sign.c (gpgme_op_sign_result): Fix debug message.
+ * data-mem.c (gpgme_data_new): Improve debug output.
+ * verify.c (parse_trust): Use atoi instead of
+ _gpgme_map_gnupg_error.
+ * decrypt.c (_gpgme_decrypt_status_handler): Likewise.
+
2009-10-22 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Remove @NETLIBS@ from LIBADDs.
else
return (time_t)strtoul (timestamp, endp, 10);
}
-
-
-
-\f
-static struct
-{
- char *name;
- gpgme_error_t err;
-} gnupg_errors[] =
- {
- { "EOF", GPG_ERR_EOF },
- { "No_Error", GPG_ERR_NO_ERROR },
- { "General_Error", GPG_ERR_GENERAL },
- { "Out_Of_Core", GPG_ERR_ENOMEM },
- { "Invalid_Value", GPG_ERR_INV_VALUE },
- { "IO_Error", GPG_ERR_GENERAL },
- { "Resource_Limit", GPG_ERR_RESOURCE_LIMIT },
- { "Internal_Error", GPG_ERR_INTERNAL },
- { "Bad_Certificate", GPG_ERR_BAD_CERT },
- { "Bad_Certificate_Chain", GPG_ERR_BAD_CERT_CHAIN},
- { "Missing_Certificate", GPG_ERR_MISSING_CERT },
- { "No_Data", GPG_ERR_NO_DATA },
- { "Bad_Signature", GPG_ERR_BAD_SIGNATURE },
- { "Not_Implemented", GPG_ERR_NOT_IMPLEMENTED },
- { "Conflict", GPG_ERR_CONFLICT },
- { "Bug", GPG_ERR_BUG },
- { "Read_Error", GPG_ERR_GENERAL },
- { "Write_Error", GPG_ERR_GENERAL },
- { "Invalid_Line", GPG_ERR_GENERAL },
- { "Incomplete_Line", GPG_ERR_INCOMPLETE_LINE },
- { "Invalid_Response", GPG_ERR_INV_RESPONSE },
- { "Agent_Error", GPG_ERR_AGENT },
- { "No_Public_Key", GPG_ERR_NO_PUBKEY },
- { "No_Secret_Key", GPG_ERR_NO_SECKEY },
- { "File_Open_Error", GPG_ERR_GENERAL },
- { "File_Create_Error", GPG_ERR_GENERAL },
- { "File_Error", GPG_ERR_GENERAL },
- { "Not_Supported", GPG_ERR_NOT_SUPPORTED },
- { "Invalid_Data", GPG_ERR_INV_DATA },
- { "Assuan_Server_Fault", GPG_ERR_ASSUAN_SERVER_FAULT },
- { "Assuan_Error", GPG_ERR_ASSUAN },
- { "Invalid_Session_Key", GPG_ERR_INV_SESSION_KEY },
- { "Invalid_Sexp", GPG_ERR_INV_SEXP },
- { "Unsupported_Algorithm", GPG_ERR_UNSUPPORTED_ALGORITHM },
- { "No_PIN_Entry", GPG_ERR_NO_PIN_ENTRY },
- { "PIN_Entry_Error", GPG_ERR_NO_PIN_ENTRY },
- { "Bad_PIN", GPG_ERR_BAD_PIN },
- { "Bad_Passphrase", GPG_ERR_BAD_PASSPHRASE },
- { "Invalid_Name", GPG_ERR_INV_NAME },
- { "Bad_Public_Key", GPG_ERR_BAD_PUBKEY },
- { "Bad_Secret_Key", GPG_ERR_BAD_SECKEY },
- { "Bad_Data", GPG_ERR_BAD_DATA },
- { "Invalid_Parameter", GPG_ERR_INV_PARAMETER },
- { "Tribute_to_D_A", GPG_ERR_TRIBUTE_TO_D_A },
- { "No_Dirmngr", GPG_ERR_NO_DIRMNGR },
- { "Dirmngr_Error", GPG_ERR_DIRMNGR },
- { "Certificate_Revoked", GPG_ERR_CERT_REVOKED },
- { "No_CRL_Known", GPG_ERR_NO_CRL_KNOWN },
- { "CRL_Too_Old", GPG_ERR_CRL_TOO_OLD },
- { "Line_Too_Long", GPG_ERR_LINE_TOO_LONG },
- { "Not_Trusted", GPG_ERR_NOT_TRUSTED },
- { "Canceled", GPG_ERR_CANCELED },
- { "Bad_CA_Certificate", GPG_ERR_BAD_CA_CERT },
- { "Certificate_Expired", GPG_ERR_CERT_EXPIRED },
- { "Certificate_Too_Young", GPG_ERR_CERT_TOO_YOUNG },
- { "Unsupported_Certificate", GPG_ERR_UNSUPPORTED_CERT },
- { "Unknown_Sexp", GPG_ERR_UNKNOWN_SEXP },
- { "Unsupported_Protection", GPG_ERR_UNSUPPORTED_PROTECTION },
- { "Corrupted_Protection", GPG_ERR_CORRUPTED_PROTECTION },
- { "Ambiguous_Name", GPG_ERR_AMBIGUOUS_NAME },
- { "Card_Error", GPG_ERR_CARD },
- { "Card_Reset", GPG_ERR_CARD_RESET },
- { "Card_Removed", GPG_ERR_CARD_REMOVED },
- { "Invalid_Card", GPG_ERR_INV_CARD },
- { "Card_Not_Present", GPG_ERR_CARD_NOT_PRESENT },
- { "No_PKCS15_App", GPG_ERR_NO_PKCS15_APP },
- { "Not_Confirmed", GPG_ERR_NOT_CONFIRMED },
- { "Configuration_Error", GPG_ERR_CONFIGURATION },
- { "No_Policy_Match", GPG_ERR_NO_POLICY_MATCH },
- { "Invalid_Index", GPG_ERR_INV_INDEX },
- { "Invalid_Id", GPG_ERR_INV_ID },
- { "No_Scdaemon", GPG_ERR_NO_SCDAEMON },
- { "Scdaemon_Error", GPG_ERR_SCDAEMON },
- { "Unsupported_Protocol", GPG_ERR_UNSUPPORTED_PROTOCOL },
- { "Bad_PIN_Method", GPG_ERR_BAD_PIN_METHOD },
- { "Card_Not_Initialized", GPG_ERR_CARD_NOT_INITIALIZED },
- { "Unsupported_Operation", GPG_ERR_UNSUPPORTED_OPERATION },
- { "Wrong_Key_Usage", GPG_ERR_WRONG_KEY_USAGE }
- };
-
-
-gpgme_error_t
-_gpgme_map_gnupg_error (char *errstr)
-{
- unsigned int i;
- gpgme_error_t err = gpg_err_make (GPG_ERR_SOURCE_GPG, GPG_ERR_GENERAL);
-
- /* Future version of GnuPG might return the error code directly, so
- we first test for a a numerical value and use that verbatim.
- Note that this numerical value might be followed by an
- underschore and the textual representation of the error code. */
- if (*errstr >= '0' && *errstr <= '9')
- return strtoul (errstr, NULL, 10);
-
- /* Well, this is a token, use the mapping table to get the error.
- The drawback is that we won't receive an error source and have to
- use GPG as source. */
- for (i = 0; i < DIM (gnupg_errors); i++)
- if (!strcmp (gnupg_errors[i].name, errstr))
- err = gpg_err_make (GPG_ERR_SOURCE_GPG, gnupg_errors[i].err);
-
- TRACE3 (DEBUG_CTX, "_gpgme_map_gnupg_error", 0,
- "mapped %s to %s <%s>", errstr, gpgme_strerror (err),
- gpgme_strsource (err));
- return err;
-}
#include <unistd.h>
#include <sys/types.h>
+#include "debug.h"
#include "data.h"
\f
\f
gpgme_error_t
-gpgme_data_new_from_fd (gpgme_data_t *dh, int fd)
+gpgme_data_new_from_fd (gpgme_data_t *r_dh, int fd)
{
- gpgme_error_t err = _gpgme_data_new (dh, &fd_cbs);
+ gpgme_error_t err;
+ TRACE_BEG1 (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=0x%x", fd);
+
+ err = _gpgme_data_new (r_dh, &fd_cbs);
if (err)
- return err;
+ return TRACE_ERR (err);
- (*dh)->data.fd = fd;
- return 0;
+ (*r_dh)->data.fd = fd;
+ return TRACE_SUC1 ("dh=%p", *r_dh);
}
if (err)
return TRACE_ERR (err);
- return TRACE_SUC1 ("r_dh=%p", *r_dh);
+ return TRACE_SUC1 ("dh=%p", *r_dh);
}
#include <stdio.h>
#include <sys/types.h>
+#include "debug.h"
#include "data.h"
\f
\f
gpgme_error_t
-gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream)
+gpgme_data_new_from_stream (gpgme_data_t *r_dh, FILE *stream)
{
- gpgme_error_t err = _gpgme_data_new (dh, &stream_cbs);
+ gpgme_error_t err;
+ TRACE_BEG1 (DEBUG_DATA, "gpgme_data_new_from_stream", r_dh, "stream=%p",
+ stream);
+
+ err = _gpgme_data_new (r_dh, &stream_cbs);
if (err)
- return err;
+ return TRACE_ERR (err);
- (*dh)->data.stream = stream;
- return 0;
+ (*r_dh)->data.stream = stream;
+ return TRACE_SUC1 ("dh=%p", *r_dh);
}
#include <sys/types.h>
#include <errno.h>
+#include "debug.h"
#include "data.h"
\f
\f
gpgme_error_t
-gpgme_data_new_from_cbs (gpgme_data_t *dh, gpgme_data_cbs_t cbs, void *handle)
+gpgme_data_new_from_cbs (gpgme_data_t *r_dh, gpgme_data_cbs_t cbs, void *handle)
{
- gpgme_error_t err = _gpgme_data_new (dh, &user_cbs);
+ gpgme_error_t err;
+ TRACE_BEG1 (DEBUG_DATA, "gpgme_data_new_from_cbs", r_dh, "handle=%p", handle);
+
+ err = _gpgme_data_new (r_dh, &user_cbs);
if (err)
- return err;
+ return TRACE_ERR (err);
- (*dh)->data.user.cbs = cbs;
- (*dh)->data.user.handle = handle;
- return 0;
+ (*r_dh)->data.user.cbs = cbs;
+ (*r_dh)->data.user.handle = handle;
+ return TRACE_SUC1 ("dh=%p", *r_dh);
}
/* The debug levels. */
#define DEBUG_INIT 1
-#define DEBUG_CTX 2
-#define DEBUG_ENGINE 3
-#define DEBUG_DATA 4
-#define DEBUG_ASSUAN 5
-#define DEBUG_SYSIO 6
+#define DEBUG_GLOBAL 2
+#define DEBUG_CTX 3
+#define DEBUG_ENGINE 4
+#define DEBUG_DATA 5
+#define DEBUG_ASSUAN 6
+#define DEBUG_SYSIO 7
\f
/* Remove path components from filenames (i.e. __FILE__) for cleaner
#include <config.h>
#endif
+#include "debug.h"
#include "gpgme.h"
#include "ops.h"
gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
gpgme_data_t plain)
{
- return decrypt_verify_start (ctx, 0, cipher, plain);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_verify_start", ctx,
+ "cipher=%p, plain=%p", cipher, plain);
+ return TRACE_ERR (decrypt_verify_start (ctx, 0, cipher, plain));
}
gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher,
gpgme_data_t plain)
{
- gpgme_error_t err = decrypt_verify_start (ctx, 1, cipher, plain);
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_verify", ctx,
+ "cipher=%p, plain=%p", cipher, plain);
+ err = decrypt_verify_start (ctx, 1, cipher, plain);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#include <string.h>
#include <errno.h>
+#include "debug.h"
#include "gpgme.h"
#include "util.h"
#include "context.h"
op_data_t opd;
gpgme_error_t err;
+ TRACE_BEG (DEBUG_CTX, "gpgme_op_decrypt_result", ctx);
+
err = _gpgme_op_data_lookup (ctx, OPDATA_DECRYPT, &hook, -1, NULL);
opd = hook;
if (err || !opd)
- return NULL;
+ {
+ TRACE_SUC0 ("result=(null)");
+ return NULL;
+ }
+
+ if (_gpgme_debug_trace ())
+ {
+ gpgme_recipient_t rcp;
+ int signatures = 0;
+
+ if (opd->result.unsupported_algorithm)
+ {
+ TRACE_LOG1 ("result: unsupported_algorithm: %s",
+ opd->result.unsupported_algorithm);
+ }
+ if (opd->result.wrong_key_usage)
+ {
+ TRACE_LOG ("result: wrong key usage");
+ }
+ rcp = opd->result.recipients;
+ while (rcp)
+ {
+ TRACE_LOG3 ("result: recipient: keyid=%s, pubkey_algo=%i, "
+ "status=%s", rcp->keyid, rcp->pubkey_algo,
+ gpg_strerror (rcp->status));
+ rcp = rcp->next;
+ }
+ if (opd->result.file_name)
+ {
+ TRACE_LOG1 ("result: original file name: %s", opd->result.file_name);
+ }
+ }
+ TRACE_SUC1 ("result=%p", &opd->result);
return &opd->result;
}
while (*args == ' ')
args++;
- if (gpg_err_code (_gpgme_map_gnupg_error (args))
- == GPG_ERR_UNSUPPORTED_ALGORITHM)
+ if (gpg_err_code (atoi (args)) == GPG_ERR_UNSUPPORTED_ALGORITHM)
{
char *end;
while (*args == ' ')
args++;
- err = _gpgme_map_gnupg_error (args);
- if (gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE)
+ if (gpg_err_code (atoi (args)) == GPG_ERR_WRONG_KEY_USAGE)
opd->result.wrong_key_usage = 1;
}
}
gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
gpgme_data_t plain)
{
- return decrypt_start (ctx, 0, cipher, plain);
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx,
+ "cipher=%p, plain=%p", cipher, plain);
+ return TRACE_ERR (decrypt_start (ctx, 0, cipher, plain));
}
gpgme_error_t
gpgme_op_decrypt (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain)
{
- gpgme_error_t err = decrypt_start (ctx, 1, cipher, plain);
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx,
+ "cipher=%p, plain=%p", cipher, plain);
+ err = decrypt_start (ctx, 1, cipher, plain);
if (!err)
err = _gpgme_wait_one (ctx);
- return err;
+ return TRACE_ERR (err);
}
#include <stdlib.h>
#include <errno.h>
+#include "debug.h"
#include "gpgme.h"
#include "context.h"
#include "ops.h"
gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key,
int allow_secret)
{
- return delete_start (ctx, 0, key, allow_secret);
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_delete", ctx,
+ "key=%p (%s), allow_secret=%i", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", allow_secret);
+ return TRACE_ERR (delete_start (ctx, 0, key, allow_secret));
}
gpgme_error_t
gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret)
{
- gpgme_error_t err = delete_start (ctx, 1, key, allow_secret);
+ gpgme_error_t err;
+
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_delete", ctx,
+ "key=%p (%s), allow_secret=%i", key,
+ (key->subkeys && !key->subkeys->fpr) ?
+ key->subkeys->fpr : "invalid", allow_secret);
+ err = delete_start (ctx, 1, key, allow_secret);
if (!err)
err = _gpgme_wait_one (ctx);
return err;
{
gpgme_error_t err;
- TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign_start", ctx,
+ TRACE_BEG3 (DEBUG_CTX, "gpgme_op_sign", ctx,
"plain=%p, sig=%p, mode=%i", plain, sig, mode);
err = sign_start (ctx, 1, plain, sig, mode);
if (!err)
sig->chain_model = 0;
if (*args)
{
- sig->validity_reason = _gpgme_map_gnupg_error (args);
+ sig->validity_reason = atoi (args);
while (*args && *args != ' ')
args++;
if (*args)
else
return gpg_error (GPG_ERR_INV_ENGINE);
- err = _gpgme_map_gnupg_error (which);
+ err = atoi (which);
if (!strcmp (where, "proc_pkt.plaintext")
&& gpg_err_code (err) == GPG_ERR_BAD_DATA)