2 * Copyright (C) 2004-2012 Free Software Foundation, Inc.
3 * Author: Nikos Mavrogiannopoulos, Simon Josefsson
5 * This file is part of GnuTLS.
7 * GnuTLS is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * GnuTLS is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include <gnutls/gnutls.h>
31 static void main_latex(void);
32 static int main_texinfo (void);
44 compar (const void *_n1, const void *_n2)
46 const error_name *n1 = (const error_name *) _n1,
47 *n2 = (const error_name *) _n2;
48 return strcmp (n1->name, n2->name);
51 static const char headers[] = "\\tablefirsthead{%\n"
53 "\\multicolumn{1}{|c}{Code} &\n"
54 "\\multicolumn{1}{c}{Name} &\n"
55 "\\multicolumn{1}{c|}{Description} \\\\\n"
60 "\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
64 "\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
67 "\\tablelasttail{\\hline}\n"
68 "\\bottomcaption{The error codes table}\n\n";
71 main (int argc, char *argv[])
81 static int main_texinfo (void)
87 error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
89 printf ("@multitable @columnfractions .15 .40 .37\n");
91 memset (names_to_sort, 0, sizeof (names_to_sort));
93 for (i = 0; i > -MAX_CODES; i--)
95 _name = gnutls_strerror_name (i);
99 desc = gnutls_strerror (i);
101 printf ("@item %d @tab %s @tab %s\n", i, escape_texi_string(_name, buffer,sizeof(buffer)), desc);
103 strcpy (names_to_sort[j].name, _name);
104 names_to_sort[j].error_index = i;
108 printf ("@end multitable\n");
113 static void main_latex(void)
116 static char buffer1[500];
117 static char buffer2[500];
120 error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
124 printf("\\begin{supertabular}{|p{.05\\linewidth}|p{.40\\linewidth}|p{.45\\linewidth}|}\n");
126 memset( names_to_sort, 0, sizeof(names_to_sort));
128 for (i=0;i>-MAX_CODES;i--)
130 _name = gnutls_strerror_name(i);
131 if ( _name == NULL) continue;
133 strcpy( names_to_sort[j].name, _name);
134 names_to_sort[j].error_index = i;
138 //qsort( names_to_sort, j, sizeof(error_name), compar);
142 _name = names_to_sort[i].name;
143 desc = gnutls_strerror( names_to_sort[i].error_index);
144 if (desc == NULL || _name == NULL) continue;
146 printf( "%d & {\\scriptsize{%s}} & %s", names_to_sort[i].error_index, escape_string(_name, buffer1, sizeof(buffer1)), escape_string(desc, buffer2, sizeof(buffer2)));
150 printf("\\end{supertabular}\n\n");