|
Packit Service |
4684c1 |
/*
|
|
Packit Service |
4684c1 |
* Copyright (C) 2004-2012 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
* Author: Nikos Mavrogiannopoulos, Simon Josefsson
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* This file is part of GnuTLS.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is free software: you can redistribute it and/or modify
|
|
Packit Service |
4684c1 |
* it under the terms of the GNU General Public License as published by
|
|
Packit Service |
4684c1 |
* the Free Software Foundation, either version 3 of the License, or
|
|
Packit Service |
4684c1 |
* (at your option) any later version.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* GnuTLS is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
4684c1 |
* GNU General Public License for more details.
|
|
Packit Service |
4684c1 |
*
|
|
Packit Service |
4684c1 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
4684c1 |
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
4684c1 |
#include "config.h"
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <stdio.h>
|
|
Packit Service |
4684c1 |
#include <stdlib.h>
|
|
Packit Service |
4684c1 |
#include <string.h>
|
|
Packit Service |
4684c1 |
#include <gnutls/gnutls.h>
|
|
Packit Service |
4684c1 |
#include "common.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void main_latex(void);
|
|
Packit Service |
4684c1 |
static int main_texinfo(void);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define MAX_CODES 600
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
typedef struct {
|
|
Packit Service |
4684c1 |
char name[128];
|
|
Packit Service |
4684c1 |
int error_index;
|
|
Packit Service |
4684c1 |
} error_name;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int compar(const void *_n1, const void *_n2)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
const error_name *n1 = (const error_name *) _n1,
|
|
Packit Service |
4684c1 |
*n2 = (const error_name *) _n2;
|
|
Packit Service |
4684c1 |
return strcmp(n1->name, n2->name);
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static const char headers[] = "\\tablefirsthead{%\n"
|
|
Packit Service |
4684c1 |
"\\hline\n"
|
|
Packit Service |
4684c1 |
"\\multicolumn{1}{|c}{Code} &\n"
|
|
Packit Service |
4684c1 |
"\\multicolumn{1}{c}{Name} &\n"
|
|
Packit Service |
4684c1 |
"\\multicolumn{1}{c|}{Description} \\\\\n" "\\hline}\n"
|
|
Packit Service |
4684c1 |
#if 0
|
|
Packit Service |
4684c1 |
"\\tablehead{%\n"
|
|
Packit Service |
4684c1 |
"\\hline\n"
|
|
Packit Service |
4684c1 |
"\\multicolumn{3}{|l|}{\\small\\sl continued from previous page}\\\\\n"
|
|
Packit Service |
4684c1 |
"\\hline}\n"
|
|
Packit Service |
4684c1 |
"\\tabletail{%\n"
|
|
Packit Service |
4684c1 |
"\\hline\n"
|
|
Packit Service |
4684c1 |
"\\multicolumn{3}{|r|}{\\small\\sl continued on next page}\\\\\n"
|
|
Packit Service |
4684c1 |
"\\hline}\n"
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
"\\tablelasttail{\\hline}\n"
|
|
Packit Service |
4684c1 |
"\\bottomcaption{The error codes table}\n\n";
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
int main(int argc, char *argv[])
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
if (argc > 1)
|
|
Packit Service |
4684c1 |
main_latex();
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
main_texinfo();
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static int main_texinfo(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int i, j;
|
|
Packit Service |
4684c1 |
const char *desc;
|
|
Packit Service |
4684c1 |
const char *_name;
|
|
Packit Service |
4684c1 |
char buffer[500];
|
|
Packit Service |
4684c1 |
error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("@multitable @columnfractions .15 .40 .37\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
memset(names_to_sort, 0, sizeof(names_to_sort));
|
|
Packit Service |
4684c1 |
j = 0;
|
|
Packit Service |
4684c1 |
for (i = 0; i > -MAX_CODES; i--) {
|
|
Packit Service |
4684c1 |
_name = gnutls_strerror_name(i);
|
|
Packit Service |
4684c1 |
if (_name == NULL)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
desc = gnutls_strerror(i);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("@item %d @tab %s @tab %s\n", i,
|
|
Packit Service |
4684c1 |
escape_texi_string(_name, buffer, sizeof(buffer)),
|
|
Packit Service |
4684c1 |
desc);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
strcpy(names_to_sort[j].name, _name);
|
|
Packit Service |
4684c1 |
names_to_sort[j].error_index = i;
|
|
Packit Service |
4684c1 |
j++;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("@end multitable\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return 0;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
static void main_latex(void)
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int i, j;
|
|
Packit Service |
4684c1 |
static char buffer1[500];
|
|
Packit Service |
4684c1 |
static char buffer2[500];
|
|
Packit Service |
4684c1 |
const char *desc;
|
|
Packit Service |
4684c1 |
const char *_name;
|
|
Packit Service |
4684c1 |
error_name names_to_sort[MAX_CODES]; /* up to MAX_CODES names */
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
puts(headers);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf
|
|
Packit Service |
4684c1 |
("\\begin{supertabular}{|p{.05\\linewidth}|p{.40\\linewidth}|p{.45\\linewidth}|}\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
memset(names_to_sort, 0, sizeof(names_to_sort));
|
|
Packit Service |
4684c1 |
j = 0;
|
|
Packit Service |
4684c1 |
for (i = 0; i > -MAX_CODES; i--) {
|
|
Packit Service |
4684c1 |
_name = gnutls_strerror_name(i);
|
|
Packit Service |
4684c1 |
if (_name == NULL)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
strcpy(names_to_sort[j].name, _name);
|
|
Packit Service |
4684c1 |
names_to_sort[j].error_index = i;
|
|
Packit Service |
4684c1 |
j++;
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
//qsort( names_to_sort, j, sizeof(error_name), compar);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
for (i = 0; i < j; i++) {
|
|
Packit Service |
4684c1 |
_name = names_to_sort[i].name;
|
|
Packit Service |
4684c1 |
desc = gnutls_strerror(names_to_sort[i].error_index);
|
|
Packit Service |
4684c1 |
if (desc == NULL || _name == NULL)
|
|
Packit Service |
4684c1 |
continue;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("%d & {\\scriptsize{%s}} & %s",
|
|
Packit Service |
4684c1 |
names_to_sort[i].error_index, escape_string(_name,
|
|
Packit Service |
4684c1 |
buffer1,
|
|
Packit Service |
4684c1 |
sizeof
|
|
Packit Service |
4684c1 |
(buffer1)),
|
|
Packit Service |
4684c1 |
escape_string(desc, buffer2, sizeof(buffer2)));
|
|
Packit Service |
4684c1 |
printf("\\\\\n");
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
printf("\\end{supertabular}\n\n");
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
return;
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
}
|