guile: Rename to `libguile-gnutls-v-2'.
[gnutls.git] / doc / printlist.c
blob3abea702aa8e9b395931edf330b254766cbb2a9b
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 char id[2];
49 gnutls_kx_algorithm_t kx;
50 gnutls_cipher_algorithm_t cipher;
51 gnutls_mac_algorithm_t mac;
52 gnutls_protocol_t version;
54 printf ("Available cipher suites:\n");
56 printf ("@multitable @columnfractions .60 .20 .20\n");
57 for (i = 0; (name = gnutls_cipher_suite_info
58 (i, id, &kx, &cipher, &mac, &version)); i++)
60 printf ("@item %s\n@tab 0x%02X 0x%02X\n@tab %s\n",
61 name,
62 (unsigned char) id[0], (unsigned char) id[1],
63 gnutls_protocol_get_name (version));
65 printf ("@end multitable\n");
70 const gnutls_certificate_type_t *p = gnutls_certificate_type_list ();
72 printf ("\n\nAvailable certificate types:\n@itemize\n");
73 for (; *p; p++)
75 printf ("@item %s\n", gnutls_certificate_type_get_name (*p));
77 printf ("@end itemize\n");
81 const gnutls_protocol_t *p = gnutls_protocol_list ();
83 printf ("\nAvailable protocols:\n@itemize\n");
84 for (; *p; p++)
86 printf ("@item %s\n", gnutls_protocol_get_name (*p));
88 printf ("@end itemize\n");
92 const gnutls_cipher_algorithm_t *p = gnutls_cipher_list ();
94 printf ("\nAvailable ciphers:\n@itemize\n");
95 for (; *p; p++)
97 printf ("@item %s\n", gnutls_cipher_get_name (*p));
99 printf ("@end itemize\n");
103 const gnutls_mac_algorithm_t *p = gnutls_mac_list ();
105 printf ("\nAvailable MAC algorithms:\n@itemize\n");
106 for (; *p; p++)
108 printf ("@item %s\n", gnutls_mac_get_name (*p));
110 printf ("@end itemize\n");
114 const gnutls_kx_algorithm_t *p = gnutls_kx_list ();
116 printf ("\nAvailable key exchange methods:\n@itemize\n");
117 for (; *p; p++)
119 printf ("@item %s\n", gnutls_kx_get_name (*p));
121 printf ("@end itemize\n");
125 const gnutls_pk_algorithm_t *p = gnutls_pk_list ();
127 printf ("\nAvailable public key algorithms:\n@itemize\n");
128 for (; *p; p++)
130 printf ("@item %s\n", gnutls_pk_get_name (*p));
132 printf ("@end itemize\n");
136 const gnutls_sign_algorithm_t *p = gnutls_sign_list ();
138 printf ("\nAvailable public key signature algorithms:\n@itemize\n");
139 for (; *p; p++)
141 printf ("@item %s\n", gnutls_sign_get_name (*p));
143 printf ("@end itemize\n");
147 const gnutls_compression_method_t *p = gnutls_compression_list ();
149 printf ("\nAvailable compression methods:\n@itemize\n");
150 for (; *p; p++)
152 printf ("@item %s\n", gnutls_compression_get_name (*p));
154 printf ("@end itemize\n");
158 static const char headers[] = "\\tablefirsthead{%\n"
159 "\\hline\n"
160 "Ciphersuite name & TLS ID & since\\\\\n"
161 "\\hline}\n"
162 "\\tablehead{%\n"
163 "\\hline\n"
164 "\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
165 "\\hline}\n"
166 "\\tabletail{%\n"
167 "\\hline\n"
168 "\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
169 "\\hline}\n"
170 "\\tablelasttail{\\hline}\n"
171 "\\bottomcaption{The ciphersuites table}\n\n";
173 static char* escape_string( const char* str)
175 static char buffer[500];
176 int i = 0, j = 0;
179 while( str[i] != 0 && j < sizeof(buffer) - 1) {
180 if (str[i]=='_') {
181 buffer[j++] = '\\';
182 buffer[j++] = '_';
183 } else {
184 buffer[j++] = str[i];
186 i++;
189 buffer[j] = 0;
191 return buffer;
195 static void main_latex(void)
197 int i, j;
198 const char* desc;
199 const char* _name;
201 puts( headers);
203 printf("\\begin{supertabular}{|p{.64\\linewidth}|p{.12\\linewidth}|p{.09\\linewidth}|}\n");
206 size_t i;
207 const char *name;
208 char id[2];
209 gnutls_kx_algorithm_t kx;
210 gnutls_cipher_algorithm_t cipher;
211 gnutls_mac_algorithm_t mac;
212 gnutls_protocol_t version;
214 for (i = 0; (name = gnutls_cipher_suite_info
215 (i, id, &kx, &cipher, &mac, &version)); i++)
217 printf ("{\\small{%s}} & \\code{0x%02X 0x%02X} & %s",
218 escape_string(name),
219 (unsigned char) id[0], (unsigned char) id[1],
220 gnutls_protocol_get_name (version));
221 printf( "\\\\\n");
223 printf("\\end{supertabular}\n\n");
227 return;