From 6a685cf7023d7fc0fbaafae8ca075278e01e52dc Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Wed, 14 Nov 2007 17:31:45 -0500 Subject: [PATCH] Updated to use new pwmd error codes which reuses more GPG error codes. --- libpwmd.c | 26 ++++++-------------------- libpwmd.h | 33 ++++++++++++++------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/libpwmd.c b/libpwmd.c index f4af28ca..4e659304 100644 --- a/libpwmd.c +++ b/libpwmd.c @@ -71,9 +71,9 @@ static gpg_error_t pinentry_command(pwm_t *pwm, char **result, const char *cmd); static gpg_error_t global_error; -const char *pwmd_strerror(gpg_error_t error) +const char *pwmd_strerror(gpg_error_t e) { - gpg_err_code_t code = gpg_err_code(error); + gpg_err_code_t code = gpg_err_code(e); if (code >= GPG_ERR_USER_1 && code < gpg_err_code(EPWMD_MAX)) { switch (code) { @@ -83,31 +83,17 @@ const char *pwmd_strerror(gpg_error_t error) case GPG_ERR_USER_2: return N_("No cache slots available"); case GPG_ERR_USER_3: - return N_("Element not found"); - case GPG_ERR_USER_4: return N_("Recursion loop"); - case GPG_ERR_USER_5: - return N_("Invalid character in element"); - case GPG_ERR_USER_6: - return N_("Empty"); - case GPG_ERR_USER_7: - return N_("Will not overwrite existing account"); - case GPG_ERR_USER_8: + case GPG_ERR_USER_4: return N_("No file is open"); - case GPG_ERR_USER_9: + case GPG_ERR_USER_5: return N_("General LibXML error"); - case GPG_ERR_USER_10: - return N_("File not found in cache"); - case GPG_ERR_USER_11: - return N_("Attribute not found"); - case GPG_ERR_USER_12: - return N_("Invalid filename or link"); - case GPG_ERR_USER_13: + case GPG_ERR_USER_6: return N_("File modified"); } } - return gpg_strerror(error); + return gpg_strerror(e); } gpg_error_t pwmd_init() diff --git a/libpwmd.h b/libpwmd.h index aaa73f1c..4fb407ee 100644 --- a/libpwmd.h +++ b/libpwmd.h @@ -247,29 +247,24 @@ gpg_error_t pwmd_setopt(pwm_t *pwm, pwmd_option_t opt, ...) __attribute__ ((warn /* * Protocol error codes. */ -#define EPWMD_ERROR GPG_ERR_USER_1 -#define EPWMD_MAX_SLOTS GPG_ERR_USER_2 -#define EPWMD_ELEMENT_NOT_FOUND GPG_ERR_USER_3 -#define EPWMD_LOOP GPG_ERR_USER_4 -#define EPWMD_INVALID_ELEMENT GPG_ERR_USER_5 -#define EPWMD_EMPTY_ELEMENT GPG_ERR_USER_6 -#define EPWMD_ACCOUNT_EXISTS GPG_ERR_USER_7 -#define EPWMD_NO_FILE GPG_ERR_USER_8 -#define EPWMD_LIBXML_ERROR GPG_ERR_USER_9 -#define EPWMD_CACHE_NOT_FOUND GPG_ERR_USER_10 -#define EPWMD_ATTR_NOT_FOUND GPG_ERR_USER_11 -#define EPWMD_INVALID_FILENAME GPG_ERR_USER_12 -#define EPWMD_FILE_MODIFIED GPG_ERR_USER_13 -#define EPWMD_MAX GPG_ERR_USER_14 - -/* - * Try to reuse GPG error codes when possible. There's only 16 user-defined - * codes available. - */ #define EPWMD_KEY GPG_ERR_WRONG_KEY_USAGE #define EPWMD_BADKEY GPG_ERR_INV_PASSPHRASE #define EPWMD_COMMAND_SYNTAX GPG_ERR_SYNTAX +#define EPWMD_ELEMENT_NOT_FOUND GPG_ERR_NOT_FOUND +#define EPWMD_ACCOUNT_EXISTS GPG_ERR_AMBIGUOUS_NAME +#define EPWMD_CACHE_NOT_FOUND GPG_ERR_NOT_FOUND #define EPWMD_ATTR_SYNTAX GPG_ERR_SYNTAX +#define EPWMD_ATTR_NOT_FOUND GPG_ERR_NOT_FOUND +#define EPWMD_INVALID_FILENAME GPG_ERR_INV_NAME +#define EPWMD_EMPTY_ELEMENT GPG_ERR_NO_VALUE +#define EPWMD_INVALID_ELEMENT GPG_ERR_INV_VALUE +#define EPWMD_ERROR GPG_ERR_USER_1 +#define EPWMD_MAX_SLOTS GPG_ERR_USER_2 +#define EPWMD_LOOP GPG_ERR_USER_3 +#define EPWMD_NO_FILE GPG_ERR_USER_4 +#define EPWMD_LIBXML_ERROR GPG_ERR_USER_5 +#define EPWMD_FILE_MODIFIED GPG_ERR_USER_6 +#define EPWMD_MAX GPG_ERR_USER_7 /* * Return a string describing a pwmd protocol error code. -- 2.11.4.GIT