From a8fe22ca6ba1ef72e603611b6b72b65a701e1575 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 6 Jun 2003 00:56:03 +0000 Subject: [PATCH] doc/ 2003-06-06 Marcus Brinkmann * gpgme.texi (Crypto Operations): Rename gpgme_invalid_user_id_t to gpgme_invalid_key_t. gpgme/ 2003-06-06 Marcus Brinkmann * op-support.c (_gpgme_parse_inv_userid): Rename to _gpgme_parse_inv_recp and change to new datatype. * ops.h (_gpgme_parse_inv_key): Fix prototype. * gpgme.h (struct _gpgme_invalid_user_id): Rename to __gpgme_invalid_key. Rename field ID to KEY. (gpgme_invalid_user_id_t): Rename to gpgme_invalid_key_t. (struct _gpgme_op_encrypt_result): Here, too. (struct _gpgme_op_sign_result): Likewise. * encrypt.c (struct op_data): Likewise. (release_op_data): Likewise. * sign.c (struct op_data): Likewise. (release_op_data): Likewise. --- NEWS | 4 ++-- TODO | 1 - doc/ChangeLog | 5 +++++ doc/gpgme.texi | 24 ++++++++++---------- gpgme/ChangeLog | 13 +++++++++++ gpgme/encrypt.c | 11 +++++----- gpgme/gpgme.h | 17 +++++++------- gpgme/op-support.c | 45 +++++++++++++++++++------------------- gpgme/ops.h | 7 +++--- gpgme/sign.c | 13 ++++++----- tests/gpg/t-encrypt-sign.c | 4 ++-- tests/gpg/t-encrypt.c | 2 +- tests/gpg/t-sign.c | 2 +- tests/gpg/t-signers.c | 2 +- tests/gpg/t-support.h | 4 ++-- tests/gpgsm/t-encrypt.c | 2 +- tests/gpgsm/t-sign.c | 2 +- 17 files changed, 87 insertions(+), 71 deletions(-) diff --git a/NEWS b/NEWS index 5ad3e811..a6dc2179 100644 --- a/NEWS +++ b/NEWS @@ -198,7 +198,7 @@ Noteworthy changes in version 0.4.1 (unreleased) * The new gpgme_op_sign_result function provides detailed information about the result of a signing operation in gpgme_sign_result_t, - gpgme_invalid_user_id_t and gpgme_new_signature_t objects. + gpgme_invalid_key_t and gpgme_new_signature_t objects. * The new gpgme_op_encrypt_result function provides detailed information about the result of an encryption operation in @@ -352,7 +352,7 @@ gpgme_import_status_t NEW gpgme_import_result_t NEW gpgme_pubkey_algo_t NEW gpgme_hash_algo_t NEW -gpgme_invalid_user_id_t NEW +gpgme_invalid_key_t NEW gpgme_new_signature_t NEW gpgme_sign_result_t NEW gpgme_op_sign_result NEW diff --git a/TODO b/TODO index ae737f02..ad887da5 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ Hey Emacs, this is -*- outline -*- mode! * Before release: -** Change gpgme_invalid_user_id_t to gpgme_invalid_key_t. ** gpgme-config must include info about libgpg-error. * ABI's to break: diff --git a/doc/ChangeLog b/doc/ChangeLog index 5e239e76..dfd4f45e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2003-06-06 Marcus Brinkmann + + * gpgme.texi (Crypto Operations): Rename gpgme_invalid_user_id_t + to gpgme_invalid_key_t. + 2003-06-06 Marcus Brinkmann * gpgme.texi: Change error codes to GPG_ERR_* variants. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 39dfffb3..b516047b 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -3252,24 +3252,24 @@ The function @code{gpgme_trust_item_release} is an alias for @cindex cryptographic operation Sometimes, the result of a crypto operation returns a list of invalid -user IDs encountered in processing the request. The following -structure is used to hold information about such an user ID. +keys encountered in processing the request. The following structure +is used to hold information about such a key. -@deftp {Data type} {gpgme_invalid_user_id_t} +@deftp {Data type} {gpgme_invalid_key_t} This is a pointer to a structure used to store a part of the result of a crypto operation which takes user IDs as one input parameter. The structure contains the following members: @table @code -@item gpgme_invalid_user_id_t next -This is a pointer to the next invalid user ID structure in the linked +@item gpgme_invalid_key_t next +This is a pointer to the next invalid key structure in the linked list, or @code{NULL} if this is the last element. -@item char *id -The invalid user ID encountered. +@item char *fpr +The fingerprint or key ID of the invalid key encountered. @item gpgme_error_t reason -An error code describing the reason why the user ID was found invalid. +An error code describing the reason why the key was found invalid. @end table @end deftp @@ -3946,8 +3946,8 @@ signature, you can retrieve the pointer to the result with members: @table @code -@item gpgme_invalid_user_id_t invalid_signers -A linked list with information about all invalid user IDs for which a +@item gpgme_invalid_key_t invalid_signers +A linked list with information about all invalid keys for which a signature could not be created. @item gpgme_new_signature_t signatures @@ -4053,8 +4053,8 @@ data, you can retrieve the pointer to the result with members: @table @code -@item gpgme_invalid_user_id_t invalid_recipients -A linked list with information about all invalid user IDs for which +@item gpgme_invalid_key_t invalid_recipients +A linked list with information about all invalid keys for which the data could not be encrypted. @end table @end deftp diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index ae9cf580..da019673 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5 +1,18 @@ 2003-06-06 Marcus Brinkmann + * op-support.c (_gpgme_parse_inv_userid): Rename to + _gpgme_parse_inv_recp and change to new datatype. + * ops.h (_gpgme_parse_inv_key): Fix prototype. + * gpgme.h (struct _gpgme_invalid_user_id): Rename to + __gpgme_invalid_key. Rename field ID to KEY. + (gpgme_invalid_user_id_t): Rename to gpgme_invalid_key_t. + (struct _gpgme_op_encrypt_result): Here, too. + (struct _gpgme_op_sign_result): Likewise. + * encrypt.c (struct op_data): Likewise. + (release_op_data): Likewise. + * sign.c (struct op_data): Likewise. + (release_op_data): Likewise. + * posix-io.c (_gpgme_io_read): Save errno across debug calls. (_gpgme_io_write): Likewise. (_gpgme_io_pipe): Likewise. diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c index 50c13d98..61619ed9 100644 --- a/gpgme/encrypt.c +++ b/gpgme/encrypt.c @@ -37,7 +37,7 @@ typedef struct /* A pointer to the next pointer of the last invalid recipient in the list. This makes appending new invalid recipients painless while preserving the order. */ - gpgme_invalid_user_id_t *lastp; + gpgme_invalid_key_t *lastp; } *op_data_t; @@ -45,12 +45,13 @@ static void release_op_data (void *hook) { op_data_t opd = (op_data_t) hook; - gpgme_invalid_user_id_t invalid_recipient = opd->result.invalid_recipients; + gpgme_invalid_key_t invalid_recipient = opd->result.invalid_recipients; while (invalid_recipient) { - gpgme_invalid_user_id_t next = invalid_recipient->next; - free (invalid_recipient->id); + gpgme_invalid_key_t next = invalid_recipient->next; + if (invalid_recipient->fpr) + free (invalid_recipient->fpr); invalid_recipient = next; } } @@ -95,7 +96,7 @@ _gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code, break; case GPGME_STATUS_INV_RECP: - err = _gpgme_parse_inv_userid (args, opd->lastp); + err = _gpgme_parse_inv_recp (args, opd->lastp); if (err) return err; diff --git a/gpgme/gpgme.h b/gpgme/gpgme.h index c4612b87..6f81fdf4 100644 --- a/gpgme/gpgme.h +++ b/gpgme/gpgme.h @@ -142,11 +142,11 @@ int gpgme_err_code_to_errno (gpgme_err_code_t code); /* Return an error value with the error source SOURCE and the system error ERR. */ -gpgme_error_t gpgme_err_make_from_errno (gpg_err_source_t source, int err); +gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err); /* Return an error value with the system error ERR. */ -gpgme_err_code_t gpg_error_from_errno (int err); +gpgme_err_code_t gpgme_error_from_errno (int err); /* The possible encoding mode of gpgme_data_t objects. */ @@ -968,20 +968,20 @@ unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx, /* Crypto Operations. */ -struct _gpgme_invalid_user_id +struct _gpgme_invalid_key { - struct _gpgme_invalid_user_id *next; - char *id; + struct _gpgme_invalid_key *next; + char *fpr; gpgme_error_t reason; }; -typedef struct _gpgme_invalid_user_id *gpgme_invalid_user_id_t; +typedef struct _gpgme_invalid_key *gpgme_invalid_key_t; /* Encryption. */ struct _gpgme_op_encrypt_result { /* The list of invalid recipients. */ - gpgme_invalid_user_id_t invalid_recipients; + gpgme_invalid_key_t invalid_recipients; }; typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t; @@ -1059,7 +1059,7 @@ typedef struct _gpgme_new_signature *gpgme_new_signature_t; struct _gpgme_op_sign_result { /* The list of invalid signers. */ - gpgme_invalid_user_id_t invalid_signers; + gpgme_invalid_key_t invalid_signers; gpgme_new_signature_t signatures; }; typedef struct _gpgme_op_sign_result *gpgme_sign_result_t; @@ -1466,7 +1466,6 @@ typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED; typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED; typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED; #define GpgmeDataCbs gpgme_data_cbs -typedef gpgme_invalid_user_id_t GpgmeInvalidUserID _GPGME_DEPRECATED; typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED; typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED; typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED; diff --git a/gpgme/op-support.c b/gpgme/op-support.c index e0fe000c..68ac39c3 100644 --- a/gpgme/op-support.c +++ b/gpgme/op-support.c @@ -113,22 +113,22 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type) gpgme_error_t -_gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid) +_gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) { - gpgme_invalid_user_id_t inv_userid; + gpgme_invalid_key_t inv_key; char *tail; long int reason; - inv_userid = malloc (sizeof (*inv_userid)); - if (!inv_userid) + inv_key = malloc (sizeof (*inv_key)); + if (!inv_key) return gpg_error_from_errno (errno); - inv_userid->next = NULL; + inv_key->next = NULL; errno = 0; reason = strtol (args, &tail, 0); if (errno || args == tail || *tail != ' ') { /* The crypto backend does not behave. */ - free (inv_userid); + free (inv_key); return gpg_error (GPG_ERR_INV_ENGINE); } @@ -136,48 +136,47 @@ _gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid) { default: case 0: - inv_userid->reason = gpg_error (GPG_ERR_GENERAL); + inv_key->reason = gpg_error (GPG_ERR_GENERAL); break; case 1: - inv_userid->reason = gpg_error (GPG_ERR_NO_PUBKEY); + inv_key->reason = gpg_error (GPG_ERR_NO_PUBKEY); break; case 2: - /* FIXME: Ambiguous specification. */ - inv_userid->reason = gpg_error (GPG_ERR_AMBIGUOUS_NAME); + inv_key->reason = gpg_error (GPG_ERR_AMBIGUOUS_NAME); break; case 3: - inv_userid->reason = gpg_error (GPG_ERR_WRONG_KEY_USAGE); + inv_key->reason = gpg_error (GPG_ERR_WRONG_KEY_USAGE); break; case 4: - inv_userid->reason = gpg_error (GPG_ERR_CERT_REVOKED); + inv_key->reason = gpg_error (GPG_ERR_CERT_REVOKED); break; case 5: - inv_userid->reason = gpg_error (GPG_ERR_CERT_EXPIRED); + inv_key->reason = gpg_error (GPG_ERR_CERT_EXPIRED); break; case 6: - inv_userid->reason = gpg_error (GPG_ERR_NO_CRL_KNOWN); + inv_key->reason = gpg_error (GPG_ERR_NO_CRL_KNOWN); break; case 7: - inv_userid->reason = gpg_error (GPG_ERR_CRL_TOO_OLD); + inv_key->reason = gpg_error (GPG_ERR_CRL_TOO_OLD); break; case 8: - inv_userid->reason = gpg_error (GPG_ERR_NO_POLICY_MATCH); + inv_key->reason = gpg_error (GPG_ERR_NO_POLICY_MATCH); break; case 9: - inv_userid->reason = gpg_error (GPG_ERR_NO_SECKEY); + inv_key->reason = gpg_error (GPG_ERR_NO_SECKEY); break; case 10: - inv_userid->reason = gpg_error (GPG_ERR_PUBKEY_NOT_TRUSTED); + inv_key->reason = gpg_error (GPG_ERR_PUBKEY_NOT_TRUSTED); break; } @@ -185,17 +184,17 @@ _gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid) tail++; if (*tail) { - inv_userid->id = strdup (tail); - if (!inv_userid->id) + inv_key->fpr = strdup (tail); + if (!inv_key->fpr) { int saved_errno = errno; - free (inv_userid); + free (inv_key); return gpg_error_from_errno (saved_errno); } } else - inv_userid->id = NULL; + inv_key->fpr = NULL; - *userid = inv_userid; + *key = inv_key; return 0; } diff --git a/gpgme/ops.h b/gpgme/ops.h index e25fbd22..f01cc9a5 100644 --- a/gpgme/ops.h +++ b/gpgme/ops.h @@ -49,10 +49,9 @@ gpgme_error_t _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, /* Prepare a new operation on CTX. */ gpgme_error_t _gpgme_op_reset (gpgme_ctx_t ctx, int synchronous); -/* Parse the invalid user ID status line in ARGS and return the result - in USERID. */ -gpgme_error_t _gpgme_parse_inv_userid (char *args, - gpgme_invalid_user_id_t *userid); +/* Parse the INV_RECP status line in ARGS and return the result in + KEY. */ +gpgme_error_t _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key); /* From verify.c. */ diff --git a/gpgme/sign.c b/gpgme/sign.c index 1dc24bcc..af007890 100644 --- a/gpgme/sign.c +++ b/gpgme/sign.c @@ -37,7 +37,7 @@ typedef struct /* A pointer to the next pointer of the last invalid signer in the list. This makes appending new invalid signers painless while preserving the order. */ - gpgme_invalid_user_id_t *last_signer_p; + gpgme_invalid_key_t *last_signer_p; /* Likewise for signature information. */ gpgme_new_signature_t *last_sig_p; @@ -48,13 +48,14 @@ static void release_op_data (void *hook) { op_data_t opd = (op_data_t) hook; - gpgme_invalid_user_id_t invalid_signer = opd->result.invalid_signers; + gpgme_invalid_key_t invalid_signer = opd->result.invalid_signers; gpgme_new_signature_t sig = opd->result.signatures; while (invalid_signer) { - gpgme_invalid_user_id_t next = invalid_signer->next; - free (invalid_signer->id); + gpgme_invalid_key_t next = invalid_signer->next; + if (invalid_signer->fpr) + free (invalid_signer->fpr); free (invalid_signer); invalid_signer = next; } @@ -213,7 +214,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args) break; case GPGME_STATUS_INV_RECP: - err = _gpgme_parse_inv_userid (args, opd->last_signer_p); + err = _gpgme_parse_inv_recp (args, opd->last_signer_p); if (err) return err; @@ -222,7 +223,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args) case GPGME_STATUS_EOF: if (opd->result.invalid_signers) - return gpg_error (GPG_ERR_INV_USER_ID); + return gpg_error (GPG_ERR_UNUSABLE_SECKEY); break; default: diff --git a/tests/gpg/t-encrypt-sign.c b/tests/gpg/t-encrypt-sign.c index fc99d56c..96aebda0 100644 --- a/tests/gpg/t-encrypt-sign.c +++ b/tests/gpg/t-encrypt-sign.c @@ -34,7 +34,7 @@ check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) if (result->invalid_signers) { fprintf (stderr, "Invalid signer found: %s\n", - result->invalid_signers->id); + result->invalid_signers->fpr); exit (1); } if (!result->signatures || result->signatures->next) @@ -117,7 +117,7 @@ main (int argc, char **argv) if (result->invalid_recipients) { fprintf (stderr, "Invalid recipient encountered: %s\n", - result->invalid_recipients->id); + result->invalid_recipients->fpr); exit (1); } sign_result = gpgme_op_sign_result (ctx); diff --git a/tests/gpg/t-encrypt.c b/tests/gpg/t-encrypt.c index bebd9938..11ebf3f4 100644 --- a/tests/gpg/t-encrypt.c +++ b/tests/gpg/t-encrypt.c @@ -64,7 +64,7 @@ main (int argc, char *argv[]) if (result->invalid_recipients) { fprintf (stderr, "Invalid recipient encountered: %s\n", - result->invalid_recipients->id); + result->invalid_recipients->fpr); exit (1); } print_data (out); diff --git a/tests/gpg/t-sign.c b/tests/gpg/t-sign.c index ff40e7cd..85b94a7e 100644 --- a/tests/gpg/t-sign.c +++ b/tests/gpg/t-sign.c @@ -34,7 +34,7 @@ check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) if (result->invalid_signers) { fprintf (stderr, "Invalid signer found: %s\n", - result->invalid_signers->id); + result->invalid_signers->fpr); exit (1); } if (!result->signatures || result->signatures->next) diff --git a/tests/gpg/t-signers.c b/tests/gpg/t-signers.c index 12b0b083..1f2e48f9 100644 --- a/tests/gpg/t-signers.c +++ b/tests/gpg/t-signers.c @@ -36,7 +36,7 @@ check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) if (result->invalid_signers) { fprintf (stderr, "Invalid signer found: %s\n", - result->invalid_signers->id); + result->invalid_signers->fpr); exit (1); } if (!result->signatures || !result->signatures->next diff --git a/tests/gpg/t-support.h b/tests/gpg/t-support.h index 8f91838d..e9ea283d 100644 --- a/tests/gpg/t-support.h +++ b/tests/gpg/t-support.h @@ -46,11 +46,11 @@ print_data (gpgme_data_t dh) ret = gpgme_data_seek (dh, 0, SEEK_SET); if (ret) - fail_if_err (gpgme_error_from_errno (errno)); + fail_if_err (gpgme_err_code_from_errno (errno)); while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0) fwrite (buf, ret, 1, stdout); if (ret < 0) - fail_if_err (gpgme_error_from_errno (errno)); + fail_if_err (gpgme_err_code_from_errno (errno)); } diff --git a/tests/gpgsm/t-encrypt.c b/tests/gpgsm/t-encrypt.c index 247f1ca9..4da0f727 100644 --- a/tests/gpgsm/t-encrypt.c +++ b/tests/gpgsm/t-encrypt.c @@ -59,7 +59,7 @@ main (int argc, char **argv) if (result->invalid_recipients) { fprintf (stderr, "Invalid recipient encountered: %s\n", - result->invalid_recipients->id); + result->invalid_recipients->fpr); exit (1); } print_data (out); diff --git a/tests/gpgsm/t-sign.c b/tests/gpgsm/t-sign.c index fbd72f1a..d346b9e3 100644 --- a/tests/gpgsm/t-sign.c +++ b/tests/gpgsm/t-sign.c @@ -32,7 +32,7 @@ check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) if (result->invalid_signers) { fprintf (stderr, "Invalid signer found: %s\n", - result->invalid_signers->id); + result->invalid_signers->fpr); exit (1); } if (!result->signatures || result->signatures->next)