Revert "Merge branch 'upstream' into tizen"
[platform/upstream/gnutls.git] / doc / alert-printlist.c
1 /*
2  * Copyright (C) 2008-2012 Free Software Foundation, Inc.
3  * Author: Nikos Mavrogiannopoulos
4  *
5  * This file is part of GnuTLS.
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
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>
28 #include "common.h"
29
30 static void main_texinfo(void);
31 static void main_latex(void);
32
33 char buffer[1024];
34
35 int main(int argc, char *argv[])
36 {
37         if (argc > 1)
38                 main_latex();
39         else
40                 main_texinfo();
41
42         return 0;
43 }
44
45 static void main_texinfo(void)
46 {
47         {
48                 size_t i;
49                 const char *name;
50                 gnutls_kx_algorithm_t kx;
51                 gnutls_cipher_algorithm_t cipher;
52                 gnutls_mac_algorithm_t mac;
53                 gnutls_protocol_t version;
54
55                 printf
56                     ("@multitable @columnfractions .55 .10 .30\n@anchor{tab:alerts}\n");
57                 printf("@headitem Alert @tab ID @tab Description\n");
58                 for (i = 0; i < 256; i++) {
59                         if (gnutls_alert_get_strname(i) == NULL)
60                                 continue;
61                         printf("@item %s\n@tab %d\n@tab %s\n",
62                                escape_texi_string(gnutls_alert_get_strname
63                                                   (i), buffer,
64                                                   sizeof(buffer)),
65                                (unsigned int) i, gnutls_alert_get_name(i));
66                 }
67                 printf("@end multitable\n");
68
69         }
70 }
71
72 static const char headers[] = "\\tablefirsthead{%\n"
73     "\\hline\n" "Alert & ID & Description\\\\\n" "\\hline}\n"
74 #if 0
75     "\\tablehead{%\n"
76     "\\hline\n"
77     "\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
78     "\\hline}\n"
79     "\\tabletail{%\n"
80     "\\hline\n"
81     "\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
82     "\\hline}\n"
83 #endif
84     "\\tablelasttail{\\hline}\n"
85     "\\bottomcaption{The TLS alert table}\n\n";
86
87 static void main_latex(void)
88 {
89         int i, j;
90         const char *desc;
91         const char *_name;
92
93         puts(headers);
94
95         printf
96             ("\\begin{supertabular}{|p{.50\\linewidth}|p{.07\\linewidth}|p{.34\\linewidth}|}\n\\label{tab:alerts}\n");
97
98         {
99                 size_t i;
100                 const char *name;
101                 gnutls_kx_algorithm_t kx;
102                 gnutls_cipher_algorithm_t cipher;
103                 gnutls_mac_algorithm_t mac;
104                 gnutls_protocol_t version;
105
106                 for (i = 0; i < 256; i++) {
107                         if (gnutls_alert_get_strname(i) == NULL)
108                                 continue;
109                         printf("{\\small{%s}} & \\code{%d} & %s",
110                                escape_string(gnutls_alert_get_strname(i),
111                                              buffer, sizeof(buffer)),
112                                (unsigned int) i, gnutls_alert_get_name(i));
113                         printf("\\\\\n");
114                 }
115
116                 printf("\\end{supertabular}\n\n");
117
118         }
119
120         return;
121
122 }