From: Marcus Brinkmann Date: Wed, 8 Feb 2012 14:26:17 +0000 (+0100) Subject: Use gpgme interface for error handling to avoid linking with gpg-error. X-Git-Tag: gpgme-1.3.2~14 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dae3073aaa8b7feb1c844fdaf711f79141b9cc65;p=gpgme.git Use gpgme interface for error handling to avoid linking with gpg-error. * tests/t-data.c, tests/run-export.c, tests/run-keylist.c, tests/run-support.h, tests/run-verify.c, tests/gpg/t-decrypt-verify.c, tests/gpg/t-edit.c, tests/gpg/t-eventloop.c, tests/gpg/t-keylist-sig.c, tests/gpg/t-keylist.c, tests/gpg/t-support.h, tests/gpg/t-trustlist.c, tests/gpg/t-verify.c, tests/gpg/t-wait.c, tests/gpgsm/cms-decrypt.c, tests/gpgsm/cms-keylist.c, tests/gpgsm/t-keylist.c, tests/gpgsm/t-support.h, tests/gpgsm/t-verify.c, tests/opassuan/t-command.c: Use gpgme interface for gpg-error functions. --- diff --git a/tests/gpg/t-decrypt-verify.c b/tests/gpg/t-decrypt-verify.c index 697d383..113aec1 100644 --- a/tests/gpg/t-decrypt-verify.c +++ b/tests/gpg/t-decrypt-verify.c @@ -61,7 +61,7 @@ check_verify_result (gpgme_verify_result_t result, unsigned int summary, __FILE__, __LINE__, sig->fpr); exit (1); } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); @@ -85,7 +85,7 @@ check_verify_result (gpgme_verify_result_t result, unsigned int summary, __FILE__, __LINE__, sig->validity); exit (1); } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); diff --git a/tests/gpg/t-edit.c b/tests/gpg/t-edit.c index 394379d..545db73 100644 --- a/tests/gpg/t-edit.c +++ b/tests/gpg/t-edit.c @@ -46,11 +46,11 @@ flush_data (gpgme_data_t dh) ret = gpgme_data_seek (dh, 0, SEEK_SET); if (ret) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); while ((ret = gpgme_data_read (dh, buf, 100)) > 0) fwrite (buf, ret, 1, stdout); if (ret < 0) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); } diff --git a/tests/gpg/t-eventloop.c b/tests/gpg/t-eventloop.c index bf1ab4e..cb1e57c 100644 --- a/tests/gpg/t-eventloop.c +++ b/tests/gpg/t-eventloop.c @@ -78,7 +78,7 @@ add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, } } if (i == FDLIST_MAX) - return gpg_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL); + return gpgme_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL); *r_tag = &fds[i]; return 0; } diff --git a/tests/gpg/t-keylist-sig.c b/tests/gpg/t-keylist-sig.c index b89ba33..9482c74 100644 --- a/tests/gpg/t-keylist-sig.c +++ b/tests/gpg/t-keylist-sig.c @@ -605,14 +605,10 @@ main (int argc, char **argv) exit (1); } - - - - gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpg/t-keylist.c b/tests/gpg/t-keylist.c index 2c04935..67844cb 100644 --- a/tests/gpg/t-keylist.c +++ b/tests/gpg/t-keylist.c @@ -551,7 +551,7 @@ main (int argc, char **argv) gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpg/t-support.h b/tests/gpg/t-support.h index 6e282a3..6a18b5c 100644 --- a/tests/gpg/t-support.h +++ b/tests/gpg/t-support.h @@ -143,7 +143,7 @@ print_import_result (gpgme_import_result_t r) for (st=r->imports; st; st = st->next) { printf (" fpr: %s err: %d (%s) status:", nonnull (st->fpr), - st->result, gpg_strerror (st->result)); + st->result, gpgme_strerror (st->result)); if (st->status & GPGME_IMPORT_NEW) fputs (" new", stdout); if (st->status & GPGME_IMPORT_UID) diff --git a/tests/gpg/t-trustlist.c b/tests/gpg/t-trustlist.c index 7707639..5d24518 100644 --- a/tests/gpg/t-trustlist.c +++ b/tests/gpg/t-trustlist.c @@ -56,7 +56,7 @@ main (int argc, char *argv[]) item->validity, item->name); gpgme_trust_item_unref (item); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); gpgme_release (ctx); diff --git a/tests/gpg/t-verify.c b/tests/gpg/t-verify.c index 0efd06f..dceabac 100644 --- a/tests/gpg/t-verify.c +++ b/tests/gpg/t-verify.c @@ -117,10 +117,10 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, __FILE__, __LINE__, sig->fpr); exit (1); } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", - __FILE__, __LINE__, gpg_strerror (sig->status)); + __FILE__, __LINE__, gpgme_strerror (sig->status)); exit (1); } if (notation) @@ -192,7 +192,7 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, __FILE__, __LINE__, sig->validity); exit (1); } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); @@ -259,7 +259,7 @@ main (int argc, char *argv[]) err = gpgme_data_new (&text); fail_if_err (err); err = gpgme_op_verify (ctx, sig, NULL, text); - if (gpg_err_code (err) != GPG_ERR_BAD_DATA) + if (gpgme_err_code (err) != GPG_ERR_BAD_DATA) { fprintf (stderr, "%s:%i: Double plaintext message not detected\n", __FILE__, __LINE__); diff --git a/tests/gpg/t-wait.c b/tests/gpg/t-wait.c index eec4d96..e58adad 100644 --- a/tests/gpg/t-wait.c +++ b/tests/gpg/t-wait.c @@ -61,7 +61,7 @@ main (int argc, char *argv[]) while (gpgme_wait (ctx, &err, 0) == NULL && err == 0) sleep(1); - if (gpg_err_code (err) != GPG_ERR_NO_DATA) + if (gpgme_err_code (err) != GPG_ERR_NO_DATA) { fprintf (stderr, "%s:%d: %s: %s\n", __FILE__, __LINE__, gpgme_strsource (err), diff --git a/tests/gpgsm/cms-decrypt.c b/tests/gpgsm/cms-decrypt.c index 767f87b..580832d 100644 --- a/tests/gpgsm/cms-decrypt.c +++ b/tests/gpgsm/cms-decrypt.c @@ -73,7 +73,7 @@ main (int argc, char **argv) err = gpgme_op_decrypt (ctx, in, out); printf ("gpgme_op_decrypt: %s <%s> (%u)\n", - gpg_strerror (err), gpg_strsource (err), err); + gpgme_strerror (err), gpgme_strsource (err), err); result = gpgme_op_decrypt_result (ctx); if (!result) { @@ -88,7 +88,7 @@ main (int argc, char **argv) for (recp = result->recipients; recp; recp = recp->next) { printf ("recipient.status: %s <%s> (%u)\n", - gpg_strerror (recp->status), gpg_strsource (recp->status), + gpgme_strerror (recp->status), gpgme_strsource (recp->status), recp->status); printf ("recipient.pkalgo: %d\n", recp->pubkey_algo); printf ("recipient.keyid : %s\n", nonnull (recp->keyid)); diff --git a/tests/gpgsm/cms-keylist.c b/tests/gpgsm/cms-keylist.c index 698a9d8..7ed3a4e 100644 --- a/tests/gpgsm/cms-keylist.c +++ b/tests/gpgsm/cms-keylist.c @@ -108,7 +108,7 @@ main (int argc, char **argv) gpgme_key_unref (key); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpgsm/t-keylist.c b/tests/gpgsm/t-keylist.c index 0f1cf33..bebd9d6 100644 --- a/tests/gpgsm/t-keylist.c +++ b/tests/gpgsm/t-keylist.c @@ -366,7 +366,7 @@ main (int argc, char **argv) gpgme_key_unref (key); i++; } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h index 6dc1456..cc1a7db 100644 --- a/tests/gpgsm/t-support.h +++ b/tests/gpgsm/t-support.h @@ -32,9 +32,9 @@ if (err) \ { \ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \ - __FILE__, __LINE__, gpg_strsource (err), \ - gpg_strerror (err), \ - gpg_err_source (err), gpg_err_code (err)); \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err), \ + gpgme_err_source (err), gpgme_err_code (err)); \ exit (1); \ } \ } \ @@ -50,11 +50,11 @@ print_data (gpgme_data_t dh) ret = gpgme_data_seek (dh, 0, SEEK_SET); if (ret) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0) fwrite (buf, ret, 1, stdout); if (ret < 0) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); } diff --git a/tests/gpgsm/t-verify.c b/tests/gpgsm/t-verify.c index d39487e..062c5a1 100644 --- a/tests/gpgsm/t-verify.c +++ b/tests/gpgsm/t-verify.c @@ -77,7 +77,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr, __FILE__, __LINE__, sig->fpr); got_errors = 1; } - if (gpg_err_code (sig->status) != status) + if (gpgme_err_code (sig->status) != status) { fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->status)); @@ -101,7 +101,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr, __FILE__, __LINE__, sig->validity); got_errors = 1; } - if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) { fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); @@ -123,7 +123,7 @@ show_auditlog (gpgme_ctx_t ctx) { fprintf (stderr, "%s:%i: Can't get audit log: %s\n", __FILE__, __LINE__, gpgme_strerror (err)); - if (gpg_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD) + if (gpgme_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD) got_errors = 1; } print_data (data); diff --git a/tests/opassuan/t-command.c b/tests/opassuan/t-command.c index aa5f34c..87f8202 100644 --- a/tests/opassuan/t-command.c +++ b/tests/opassuan/t-command.c @@ -34,16 +34,16 @@ if (err) \ { \ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \ - __FILE__, __LINE__, gpg_strsource (err), \ - gpg_strerror (err), \ - gpg_err_source (err), gpg_err_code (err)); \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err), \ + gpgme_err_source (err), gpgme_err_code (err)); \ exit (1); \ } \ } \ while (0) -static gpg_error_t +static gpgme_error_t data_cb (void *opaque, const void *data, size_t datalen) { printf ("DATA_CB: datalen=%d\n", (int)datalen); @@ -51,12 +51,12 @@ data_cb (void *opaque, const void *data, size_t datalen) } -static gpg_error_t +static gpgme_error_t inq_cb (void *opaque, const char *name, const char *args, gpgme_data_t *r_data) { gpgme_data_t data; - gpg_error_t err; + gpgme_error_t err; if (name) { @@ -81,14 +81,14 @@ inq_cb (void *opaque, const char *name, const char *args, /* Uncomment the next lines and send a "SCD LEARN" to test sending cancel from in inquiry. */ /* if (name && !strcmp (name, "KNOWNCARDP")) */ - /* return gpg_error (GPG_ERR_ASS_CANCELED); */ + /* return gpgme_error (GPG_ERR_ASS_CANCELED); */ return 0; } -static gpg_error_t +static gpgme_error_t status_cb (void *opaque, const char *status, const char *args) { printf ("STATUS_CB: status=`%s' args=`%s'\n", status, args); diff --git a/tests/run-export.c b/tests/run-export.c index 8dddb5b..b70ed91 100644 --- a/tests/run-export.c +++ b/tests/run-export.c @@ -117,7 +117,7 @@ main (int argc, char **argv) gpgme_key_unref (key); } } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/run-keylist.c b/tests/run-keylist.c index 8dd28b8..0f2154a 100644 --- a/tests/run-keylist.c +++ b/tests/run-keylist.c @@ -201,7 +201,7 @@ main (int argc, char **argv) else gpgme_key_unref (key); } - if (gpg_err_code (err) != GPG_ERR_EOF) + if (gpgme_err_code (err) != GPG_ERR_EOF) fail_if_err (err); err = gpgme_op_keylist_end (ctx); fail_if_err (err); diff --git a/tests/run-support.h b/tests/run-support.h index d7f0923..db7b7d5 100644 --- a/tests/run-support.h +++ b/tests/run-support.h @@ -142,7 +142,7 @@ print_import_result (gpgme_import_result_t r) for (st=r->imports; st; st = st->next) { printf (" fpr: %s err: %d (%s) status:", nonnull (st->fpr), - st->result, gpg_strerror (st->result)); + st->result, gpgme_strerror (st->result)); if (st->status & GPGME_IMPORT_NEW) fputs (" new", stdout); if (st->status & GPGME_IMPORT_UID) diff --git a/tests/run-verify.c b/tests/run-verify.c index 0dde815..4837d9c 100644 --- a/tests/run-verify.c +++ b/tests/run-verify.c @@ -94,14 +94,14 @@ print_result (gpgme_verify_result_t result) for (sig = result->signatures; sig; sig = sig->next) { printf ("Signature %d\n", count++); - printf (" status ....: %s\n", gpg_strerror (sig->status)); + printf (" status ....: %s\n", gpgme_strerror (sig->status)); printf (" summary ...:"); print_summary (sig->summary); putchar ('\n'); printf (" fingerprint: %s\n", nonnull (sig->fpr)); printf (" created ...: %lu\n", sig->timestamp); printf (" expires ...: %lu\n", sig->exp_timestamp); printf (" validity ..: "); print_validity (sig->validity); putchar ('\n'); - printf (" val.reason : %s\n", gpg_strerror (sig->status)); + printf (" val.reason : %s\n", gpgme_strerror (sig->status)); printf (" pubkey algo: %d\n", sig->pubkey_algo); printf (" digest algo: %d\n", sig->hash_algo); printf (" pka address: %s\n", nonnull (sig->pka_address)); @@ -185,9 +185,9 @@ main (int argc, char **argv) fp_sig = fopen (argv[0], "rb"); if (!fp_sig) { - err = gpg_error_from_syserror (); + err = gpgme_error_from_syserror (); fprintf (stderr, PGM ": can't open `%s': %s\n", - argv[0], gpg_strerror (err)); + argv[0], gpgme_strerror (err)); exit (1); } if (argc > 1) @@ -195,9 +195,9 @@ main (int argc, char **argv) fp_msg = fopen (argv[1], "rb"); if (!fp_msg) { - err = gpg_error_from_syserror (); + err = gpgme_error_from_syserror (); fprintf (stderr, PGM ": can't open `%s': %s\n", - argv[1], gpg_strerror (err)); + argv[1], gpgme_strerror (err)); exit (1); } } @@ -212,7 +212,7 @@ main (int argc, char **argv) if (err) { fprintf (stderr, PGM ": error allocating data object: %s\n", - gpg_strerror (err)); + gpgme_strerror (err)); exit (1); } if (fp_msg) @@ -221,7 +221,7 @@ main (int argc, char **argv) if (err) { fprintf (stderr, PGM ": error allocating data object: %s\n", - gpg_strerror (err)); + gpgme_strerror (err)); exit (1); } } @@ -232,7 +232,7 @@ main (int argc, char **argv) print_result (result); if (err) { - fprintf (stderr, PGM ": signing failed: %s\n", gpg_strerror (err)); + fprintf (stderr, PGM ": signing failed: %s\n", gpgme_strerror (err)); exit (1); } diff --git a/tests/t-data.c b/tests/t-data.c index 713da0a..a319484 100644 --- a/tests/t-data.c +++ b/tests/t-data.c @@ -163,7 +163,7 @@ write_test (round_t round, gpgme_data_t data) amt = gpgme_data_write (data, text, strlen (text)); if (amt != strlen (text)) - fail_if_err (gpg_error_from_errno (errno)); + fail_if_err (gpgme_error_from_errno (errno)); gpgme_data_seek (data, 0, SEEK_SET); @@ -237,8 +237,8 @@ main (int argc, char **argv) case TEST_INOUT_MEM_FROM_FILE_NO_COPY: err = gpgme_data_new_from_file (&data, text_filename, 0); /* This is not implemented yet. */ - if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED - || gpg_err_code (err) == GPG_ERR_INV_VALUE) + if (gpgme_err_code (err) == GPG_ERR_NOT_IMPLEMENTED + || gpgme_err_code (err) == GPG_ERR_INV_VALUE) continue; break; case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME: