[git] GPG-ERROR - branch, master, updated. libgpg-error-1.18-8-g528ee70
by Werner Koch
cvs at cvs.gnupg.org
Thu Mar 19 09:27:45 CET 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".
The branch, master has been updated
via 528ee704f8f9d881ba370dcbfa9194d6704f9a2f (commit)
from dc95f1ea1ab902b9f49de651084f514535e4a3fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 528ee704f8f9d881ba370dcbfa9194d6704f9a2f
Author: Werner Koch <wk at gnupg.org>
Date: Thu Mar 19 09:26:23 2015 +0100
Add option --defines to gpg-error.
* src/gpg-error.c (main): Add option --help and --defines.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/src/gpg-error.c b/src/gpg-error.c
index 034a61b..672efe7 100644
--- a/src/gpg-error.c
+++ b/src/gpg-error.c
@@ -394,13 +394,27 @@ main (int argc, char *argv[])
fputs ("gpg-error (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stdout);
exit (0);
}
+ else if (argc == 2 && !strcmp (argv[1], "--help"))
+ {
+ fputs ("gpg-error (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stdout);
+ fputs ("Options:\n"
+ " --version Print version\n"
+ " --help Print this help\n"
+ " --list Print all error codes\n"
+ " --defines Print all error codes as #define lines\n", stdout);
+ exit (0);
+ }
else if (argc == 2 && !strcmp (argv[1], "--list"))
{
listmode = 1;
}
+ else if (argc == 2 && !strcmp (argv[1], "--defines"))
+ {
+ listmode = 2;
+ }
- if (listmode)
+ if (listmode == 1)
{
for (i=0; i < GPG_ERR_SOURCE_DIM; i++)
{
@@ -423,27 +437,71 @@ main (int argc, char *argv[])
err, gpg_err_code (err),
error_sym, gpg_strerror (err));
}
-
- i = argc; /* Don't run the usual stuff. */
}
- while (i < argc)
+ else if (listmode == 2)
{
- if (get_err_from_number (argv[i], &err)
- || get_err_from_symbol (argv[i], &err)
- || get_err_from_str (argv[i], &err))
- {
+ int n, nmax;
+
+ for (i=0, nmax=0; i < GPG_ERR_SOURCE_DIM; i++)
+ {
+ err = gpg_err_make (i, 1);
source_sym = gpg_strsource_sym (err);
+ if (source_sym)
+ {
+ n = strlen (source_sym);
+ if (n > nmax)
+ nmax = n;
+ }
+ }
+ for (i=0; i < GPG_ERR_SOURCE_DIM; i++)
+ {
+ err = gpg_err_make (i, 1);
+ source_sym = gpg_strsource_sym (err);
+ if (source_sym)
+ printf ("#define %-*s %3u\n", nmax,source_sym,gpg_err_source (err));
+ }
+
+
+ for (i=0, nmax = 0; i < GPG_ERR_CODE_DIM; i++)
+ {
+ err = gpg_err_make (GPG_ERR_SOURCE_UNKNOWN, i);
+ error_sym = gpg_strerror_sym (err);
+ if (error_sym)
+ {
+ n = strlen (error_sym);
+ if (n > nmax)
+ nmax = n;
+ }
+ }
+ for (i=0; i < GPG_ERR_CODE_DIM; i++)
+ {
+ err = gpg_err_make (GPG_ERR_SOURCE_UNKNOWN, i);
error_sym = gpg_strerror_sym (err);
+ if (error_sym)
+ printf ("#define %-*s %5u\n", nmax, error_sym, gpg_err_code (err));
+ }
+ }
+ else /* Standard mode. */
+ {
+ while (i < argc)
+ {
+ if (get_err_from_number (argv[i], &err)
+ || get_err_from_symbol (argv[i], &err)
+ || get_err_from_str (argv[i], &err))
+ {
+ source_sym = gpg_strsource_sym (err);
+ error_sym = gpg_strerror_sym (err);
- printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n",
- err, gpg_err_source (err), gpg_err_code (err),
- source_sym ? source_sym : "-", error_sym ? error_sym : "-",
- gpg_strsource (err), gpg_strerror (err));
- }
- else
- fprintf (stderr, _("%s: warning: could not recognize %s\n"),
- argv[0], argv[i]);
- i++;
+ printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n",
+ err, gpg_err_source (err), gpg_err_code (err),
+ source_sym ? source_sym : "-", error_sym ? error_sym:"-",
+ gpg_strsource (err), gpg_strerror (err));
+ }
+ else
+ fprintf (stderr, _("%s: warning: could not recognize %s\n"),
+ argv[0], argv[i]);
+ i++;
+ }
}
exit (0);
-----------------------------------------------------------------------
Summary of changes:
src/gpg-error.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 75 insertions(+), 17 deletions(-)
hooks/post-receive
--
Error codes used by GnuPG et al.
http://git.gnupg.org
More information about the Gnupg-commits
mailing list