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);
42 static int compar(const void *_n1, const void *_n2)
44 const error_name *n1 = (const error_name *) _n1,
45 *n2 = (const error_name *) _n2;
46 return strcmp(n1->name, n2->name);
49 static const char headers[] = "\\tablefirsthead{%\n"
51 "\\multicolumn{1}{|c}{Code} &\n"
52 "\\multicolumn{1}{c}{Name} &\n"
53 "\\multicolumn{1}{c|}{Description} \\\\\n" "\\hline}\n"
57 "\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
61 "\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
64 "\\tablelasttail{\\hline}\n"
65 "\\bottomcaption{The error codes table}\n\n";
67 int main(int argc, char *argv[])
77 static int main_texinfo(void)
83 error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
85 printf("@multitable @columnfractions .15 .40 .37\n");
87 memset(names_to_sort, 0, sizeof(names_to_sort));
89 for (i = 0; i > -MAX_CODES; i--) {
90 _name = gnutls_strerror_name(i);
94 desc = gnutls_strerror(i);
96 printf("@item %d @tab %s @tab %s\n", i,
97 escape_texi_string(_name, buffer, sizeof(buffer)),
100 strcpy(names_to_sort[j].name, _name);
101 names_to_sort[j].error_index = i;
105 printf("@end multitable\n");
110 static void main_latex(void)
113 static char buffer1[500];
114 static char buffer2[500];
117 error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
122 ("\\begin{supertabular}{|p{.05\\linewidth}|p{.40\\linewidth}|p{.45\\linewidth}|}\n");
124 memset(names_to_sort, 0, sizeof(names_to_sort));
126 for (i = 0; i > -MAX_CODES; i--) {
127 _name = gnutls_strerror_name(i);
131 strcpy(names_to_sort[j].name, _name);
132 names_to_sort[j].error_index = i;
136 //qsort( names_to_sort, j, sizeof(error_name), compar);
138 for (i = 0; i < j; i++) {
139 _name = names_to_sort[i].name;
140 desc = gnutls_strerror(names_to_sort[i].error_index);
141 if (desc == NULL || _name == NULL)
144 printf("%d & {\\scriptsize{%s}} & %s",
145 names_to_sort[i].error_index, escape_string(_name,
149 escape_string(desc, buffer2, sizeof(buffer2)));
153 printf("\\end{supertabular}\n\n");