More enum docs.
[gnutls.git] / doc / errcodes.c
blob2c3f255e2b6a262a8916f2ea4a6cf023502a4be5
1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 * Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos, Simon Josefsson
6 * This file is part of GNUTLS.
8 * GNUTLS is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * GNUTLS is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #endif
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <gnutls/gnutls.h>
31 typedef struct
33 char name[128];
34 int error_index;
35 } error_name;
38 static int
39 compar (const void *_n1, const void *_n2)
41 const error_name *n1 = (const error_name *) _n1,
42 *n2 = (const error_name *) _n2;
43 return strcmp (n1->name, n2->name);
46 int
47 main (int argc, char *argv[])
49 int i, j;
50 const char *desc;
51 const char *_name;
52 error_name names_to_sort[400]; /* up to 400 names */
54 printf ("@table @code\n");
56 memset (names_to_sort, 0, sizeof (names_to_sort));
57 j = 0;
58 for (i = 0; i > -400; i--)
60 _name = gnutls_strerror_name (i);
61 if (_name == NULL)
62 continue;
64 strcpy (names_to_sort[j].name, _name);
65 names_to_sort[j].error_index = i;
66 j++;
69 qsort (names_to_sort, j, sizeof (error_name), compar);
71 for (i = 0; i < j; i++)
73 _name = names_to_sort[i].name;
74 desc = gnutls_strerror (names_to_sort[i].error_index);
75 if (desc == NULL || _name == NULL)
76 continue;
78 printf ("@item %s:\n%s\n\n", _name, desc);
81 printf ("@end table\n");
83 return 0;