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.
This commit is contained in:
parent
0052a72f89
commit
dae3073aaa
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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__);
|
||||
|
@ -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),
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user