summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2004-08-05 02:04:15 +0000
committerSimon Josefsson <simon@josefsson.org>2004-08-05 02:04:15 +0000
commit432bb43ba97dfc459d3843125376427a3686e258 (patch)
tree725f8c8af596ef083ec62d4ff607bfb9978e1bc2 /src
parentecb0adcca370ad2e05497d7aaf18a6af5240d436 (diff)
downloadgnutls-432bb43ba97dfc459d3843125376427a3686e258.tar.gz
(errcodes): Add, same as retcodes, but for texinfo.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/errcodes.c59
2 files changed, 62 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 388d832ddd..6009dc838b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,9 +18,11 @@ gnutls_cli_debug_SOURCES = tls_test-gaa.c tls_test.c tests.c common.c
gnutls_cli_debug_LDADD = ../lib/libgnutls.la ../libextra/libgnutls-extra.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS) $(LIBOPENCDK_LIBS) $(SERV_LIBS)
-noinst_PROGRAMS = retcodes
+noinst_PROGRAMS = retcodes errcodes
retcodes_SOURCES = retcodes.c
retcodes_LDADD = ../lib/libgnutls.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS)
+errcodes_SOURCES = errcodes.c
+errcodes_LDADD = ../lib/libgnutls.la $(LIBGCRYPT_LIBS) $(LIBTASN1_LIBS)
if HAVE_LIBCFG
certtool_SOURCES = certtool-gaa.c certtool.c prime.c getpass.c certtool-cfg.c
diff --git a/src/errcodes.c b/src/errcodes.c
new file mode 100644
index 0000000000..0797207ff3
--- /dev/null
+++ b/src/errcodes.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gnutls/gnutls.h>
+
+const char *_gnutls_strerror(int);
+
+typedef struct {
+ char name[128];
+ int error_index;
+} error_name;
+
+
+static int compar(const void *_n1, const void *_n2)
+{
+ const error_name *n1 = (const error_name *) _n1,
+ *n2 = (const error_name *) _n2;
+ return strcmp(n1->name, n2->name);
+}
+
+int main()
+{
+ int i, j;
+ const char *desc;
+ const char *_name;
+ error_name names_to_sort[400]; /* up to 400 names */
+
+ printf("@chapter Error codes and descriptions\n");
+ printf("@cindex Error codes\n");
+ printf("\n");
+ printf("@itemize\n");
+
+ memset(names_to_sort, 0, sizeof(names_to_sort));
+ j = 0;
+ for (i = 0; i > -400; i--) {
+ _name = _gnutls_strerror(i);
+ if (_name == NULL)
+ continue;
+
+ strcpy(names_to_sort[j].name, _name);
+ names_to_sort[j].error_index = i;
+ j++;
+ }
+
+ qsort(names_to_sort, j, sizeof(error_name), compar);
+
+ for (i = 0; i < j; i++) {
+ _name = names_to_sort[i].name;
+ desc = gnutls_strerror(names_to_sort[i].error_index);
+ if (desc == NULL || _name == NULL)
+ continue;
+
+ printf("@item @code{%s}:\n%s\n\n", _name, desc);
+ }
+
+ printf("@end itemize\n");
+
+ return 0;
+}