From 1c292fcf7a4049e3c0c422106cb54f16337a4e95 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 30 Jan 2003 17:12:07 +0000 Subject: [PATCH] 2003-01-30 Marcus Brinkmann * util.h (return_if_fail, return_null_if_fail, return_val_if_fail): Remove macro. * gpgme.c (gpgme_cancel): Don't use return_if_fail. * key.c (gpgme_key_ref): Likewise. * signers.c (gpgme_signers_enum): Likewise. (gpgme_signers_clear): Likewise. --- trunk/gpgme/ChangeLog | 7 +++++++ trunk/gpgme/gpgme.c | 16 +++++++--------- trunk/gpgme/key.c | 11 +++-------- trunk/gpgme/signers.c | 44 +++++++++---------------------------------- trunk/gpgme/util.h | 31 +++++------------------------- 5 files changed, 31 insertions(+), 78 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index cdeec93..f6692e3 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,5 +1,12 @@ 2003-01-30 Marcus Brinkmann + * util.h (return_if_fail, return_null_if_fail, + return_val_if_fail): Remove macro. + * gpgme.c (gpgme_cancel): Don't use return_if_fail. + * key.c (gpgme_key_ref): Likewise. + * signers.c (gpgme_signers_enum): Likewise. + (gpgme_signers_clear): Likewise. + * engine-backend.h (struct engine_ops): Rename get_path to get_file_name. * gpgme.h (struct _gpgme_engine_info): Rename member path to diff --git a/trunk/gpgme/gpgme.c b/trunk/gpgme/gpgme.c index d7e0056..134089b 100644 --- a/trunk/gpgme/gpgme.c +++ b/trunk/gpgme/gpgme.c @@ -102,22 +102,20 @@ _gpgme_release_result (GpgmeCtx ctx) } -/** - * gpgme_cancel: - * @c: the context - * - * Cancel the current operation. It is not guaranteed that it will work for - * all kinds of operations. It is especially useful in a passphrase callback - * to stop the system from asking another time for the passphrase. - **/ +/* Cancel the current operation. It is not guaranteed that it will + work for all kinds of operations. It is especially useful in a + passphrase callback to stop the system from asking another time for + the passphrase. */ void gpgme_cancel (GpgmeCtx ctx) { - return_if_fail (ctx); + if (!ctx) + return; ctx->cancel = 1; } + /** * gpgme_get_notation: * @c: the context diff --git a/trunk/gpgme/key.c b/trunk/gpgme/key.c index b1dc0ce..1f8e011 100644 --- a/trunk/gpgme/key.c +++ b/trunk/gpgme/key.c @@ -356,17 +356,12 @@ _gpgme_key_new_secret (GpgmeKey *r_key) } -/** - * gpgme_key_ref: - * @key: Key object - * - * To safe memory the Key objects implements reference counting. - * Use this function to bump the reference counter. - **/ +/* Acquire a reference to KEY. */ void gpgme_key_ref (GpgmeKey key) { - return_if_fail (key); + if (!key) + return; LOCK (key_ref_lock); key->ref_count++; UNLOCK (key_ref_lock); diff --git a/trunk/gpgme/signers.c b/trunk/gpgme/signers.c index 648a82d..8d39a1e 100644 --- a/trunk/gpgme/signers.c +++ b/trunk/gpgme/signers.c @@ -1,4 +1,4 @@ -/* signers.c - maintain signer sets +/* signers.c - Maintain signer sets. Copyright (C) 2001 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003 g10 Code GmbH @@ -33,24 +33,15 @@ different to a recipient set. */ -/** - * gpgme_signers_clear: - * @c: context to clear from signers - * - * Remove the list of signers from the context and release the - * references to the signers keys. - * - * Return value: The version string or NULL - **/ +/* Delete all signers from CTX. */ void gpgme_signers_clear (GpgmeCtx ctx) { int i; - return_if_fail (ctx); - - if (!ctx->signers) + if (!ctx || !ctx->signers) return; + for (i = 0; i < ctx->signers_len; i++) { assert (ctx->signers[i]); @@ -60,16 +51,7 @@ gpgme_signers_clear (GpgmeCtx ctx) ctx->signers_len = 0; } -/** - * gpgme_signers_add: - * @c: context to add signer to - * @key: key to add - * - * Add the key as a signer to the context. Acquires a reference to - * the key. - * - * Return value: NULL on success, or an error code. - **/ +/* Add KEY to list of signers in CTX. */ GpgmeError gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key) { @@ -96,21 +78,13 @@ gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key) return 0; } -/** - * gpgme_signers_enum: - * @c: context to retrieve signer from - * @seq: index of key to retrieve - * - * Acquire a reference to the signers key with the specified index - * number in the context and return it to the caller. - * - * Return value: A GpgmeKey or NULL on failure. - **/ + +/* Return the SEQth signer's key in CTX with one reference. */ GpgmeKey gpgme_signers_enum (const GpgmeCtx ctx, int seq) { - return_null_if_fail (ctx); - return_null_if_fail (seq >= 0); + if (!ctx || seq < 0) + return NULL; if (seq >= ctx->signers_len) return NULL; diff --git a/trunk/gpgme/util.h b/trunk/gpgme/util.h index c862235..8f697de 100644 --- a/trunk/gpgme/util.h +++ b/trunk/gpgme/util.h @@ -24,41 +24,20 @@ #include "types.h" #include "debug.h" + #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) - -#ifndef HAVE_STPCPY -char *stpcpy (char *a, const char *b); -#endif - -#define return_if_fail(expr) do { \ - if (!(expr)) { \ - fprintf (stderr, "%s:%d: assertion `%s' failed", \ - __FILE__, __LINE__, #expr ); \ - return; \ - } } while (0) -#define return_null_if_fail(expr) do { \ - if (!(expr)) { \ - fprintf (stderr, "%s:%d: assertion `%s' failed", \ - __FILE__, __LINE__, #expr ); \ - return NULL; \ - } } while (0) -#define return_val_if_fail(expr,val) do { \ - if (!(expr)) { \ - fprintf (stderr, "%s:%d: assertion `%s' failed", \ - __FILE__, __LINE__, #expr ); \ - return (val); \ - } } while (0) - - - /*-- {posix,w32}-util.c --*/ const char *_gpgme_get_gpg_path (void); const char *_gpgme_get_gpgsm_path (void); /*-- replacement functions in .c --*/ #ifdef HAVE_CONFIG_H +#ifndef HAVE_STPCPY +char *stpcpy (char *a, const char *b); +#endif + #if !HAVE_VASPRINTF #include int vasprintf (char **result, const char *format, va_list args); -- 2.26.2