guile: Rename to `libguile-gnutls-v-2'.
[gnutls.git] / doc / alert-printlist.c
blob4d7ad38de45af89235117e3e27fc06586461bf8f
1 /*
2 * Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3 * Author: Nikos Mavrogiannopoulos
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/>.
21 #include <config.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <gnutls/gnutls.h>
26 #include <gnutls/x509.h>
27 #include <gnutls/openpgp.h>
29 static void main_texinfo (void);
30 static void main_latex(void);
32 int
33 main (int argc, char *argv[])
35 if (argc > 1)
36 main_latex();
37 else
38 main_texinfo();
40 return 0;
43 static void main_texinfo (void)
46 size_t i;
47 const char *name;
48 gnutls_kx_algorithm_t kx;
49 gnutls_cipher_algorithm_t cipher;
50 gnutls_mac_algorithm_t mac;
51 gnutls_protocol_t version;
53 printf ("Available alert messages:\n");
55 printf ("@multitable @columnfractions .55 .10 .30\n@anchor{tab:alerts}\n");
56 for (i = 0; i<256;i++)
58 if (gnutls_alert_get_strname(i)==NULL) continue;
59 printf ("@item %s\n@tab %d\n@tab %s\n",
60 gnutls_alert_get_strname(i),
61 (unsigned int) i, gnutls_alert_get_name (i));
63 printf ("@end multitable\n");
68 static const char headers[] = "\\tablefirsthead{%\n"
69 "\\hline\n"
70 "Alert & ID & Description\\\\\n"
71 "\\hline}\n"
72 "\\tablehead{%\n"
73 "\\hline\n"
74 "\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
75 "\\hline}\n"
76 "\\tabletail{%\n"
77 "\\hline\n"
78 "\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
79 "\\hline}\n"
80 "\\tablelasttail{\\hline}\n"
81 "\\bottomcaption{The TLS alert table}\n\n";
83 static char* escape_string( const char* str)
85 static char buffer[500];
86 int i = 0, j = 0;
89 while( str[i] != 0 && j < sizeof(buffer) - 1) {
90 if (str[i]=='_') {
91 buffer[j++] = '\\';
92 buffer[j++] = '_';
93 } else {
94 buffer[j++] = str[i];
96 i++;
99 buffer[j] = 0;
101 return buffer;
105 static void main_latex(void)
107 int i, j;
108 const char* desc;
109 const char* _name;
111 puts( headers);
113 printf("\\begin{supertabular}{|p{.50\\linewidth}|p{.07\\linewidth}|p{.34\\linewidth}|}\n\\label{tab:alerts}\n");
116 size_t i;
117 const char *name;
118 gnutls_kx_algorithm_t kx;
119 gnutls_cipher_algorithm_t cipher;
120 gnutls_mac_algorithm_t mac;
121 gnutls_protocol_t version;
123 for (i = 0; i<256;i++)
125 if (gnutls_alert_get_strname(i)==NULL) continue;
126 printf ("{\\small{%s}} & \\code{%d} & %s",
127 escape_string(gnutls_alert_get_strname(i)),
128 (unsigned int) i, gnutls_alert_get_name (i));
129 printf( "\\\\\n");
132 printf("\\end{supertabular}\n\n");
136 return;