aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/https/minitasn1/errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/https/minitasn1/errors.c')
-rw-r--r--src/daemon/https/minitasn1/errors.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/daemon/https/minitasn1/errors.c b/src/daemon/https/minitasn1/errors.c
deleted file mode 100644
index 72b61938..00000000
--- a/src/daemon/https/minitasn1/errors.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * Copyright (C) 2006 Free Software Foundation, Inc.
3 * Copyright (C) 2002, 2005 Fabio Fiorina
4 *
5 * This file is part of LIBTASN1.
6 *
7 * The LIBTASN1 library is free software; you can redistribute it
8 * and/or modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA
21 */
22
23#include <int.h>
24#include "errors.h"
25#ifdef STDC_HEADERS
26# include <stdarg.h>
27#endif
28
29
30#define LIBTASN1_ERROR_ENTRY(name) \
31 { #name, name }
32
33struct MHD__libtasn1_error_entry
34{
35 const char *name;
36 int number;
37};
38typedef struct MHD__libtasn1_error_entry MHD__libtasn1_error_entry;
39
40static const MHD__libtasn1_error_entry error_algorithms[] = {
41 LIBTASN1_ERROR_ENTRY (ASN1_SUCCESS),
42 LIBTASN1_ERROR_ENTRY (ASN1_FILE_NOT_FOUND),
43 LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_FOUND),
44 LIBTASN1_ERROR_ENTRY (ASN1_IDENTIFIER_NOT_FOUND),
45 LIBTASN1_ERROR_ENTRY (ASN1_DER_ERROR),
46 LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_FOUND),
47 LIBTASN1_ERROR_ENTRY (ASN1_GENERIC_ERROR),
48 LIBTASN1_ERROR_ENTRY (ASN1_VALUE_NOT_VALID),
49 LIBTASN1_ERROR_ENTRY (ASN1_TAG_ERROR),
50 LIBTASN1_ERROR_ENTRY (ASN1_TAG_IMPLICIT),
51 LIBTASN1_ERROR_ENTRY (ASN1_ERROR_TYPE_ANY),
52 LIBTASN1_ERROR_ENTRY (ASN1_SYNTAX_ERROR),
53 LIBTASN1_ERROR_ENTRY (ASN1_MEM_ERROR),
54 LIBTASN1_ERROR_ENTRY (ASN1_MEM_ALLOC_ERROR),
55 LIBTASN1_ERROR_ENTRY (ASN1_DER_OVERFLOW),
56 LIBTASN1_ERROR_ENTRY (ASN1_NAME_TOO_LONG),
57 LIBTASN1_ERROR_ENTRY (ASN1_ARRAY_ERROR),
58 LIBTASN1_ERROR_ENTRY (ASN1_ELEMENT_NOT_EMPTY),
59 {0}
60};
61
62#define LIBTASN1_ERROR_LOOP(b) \
63 const MHD__libtasn1_error_entry *p; \
64 for(p = error_algorithms; p->name != NULL; p++) { b ; }
65
66#define LIBTASN1_ERROR_ALG_LOOP(a) \
67 LIBTASN1_ERROR_LOOP( if(p->number == error) { a; break; } )
68
69
70
71/**
72 * MHD__libtasn1_perror - prints a string to stderr with a description of an error
73 * @error: is an error returned by a libtasn1 function.
74 *
75 * This function is like perror(). The only difference is that it
76 * accepts an error returned by a libtasn1 function.
77 **/
78void
79MHD__libtasn1_perror (MHD__asn1_retCode error)
80{
81 const char *ret = NULL;
82
83 /* avoid prefix */
84 LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1);
85
86 fprintf (stderr, "LIBTASN1 ERROR: %s\n", ret);
87
88}
89
90
91/**
92 * MHD__libtasn1_strerror - Returns a string with a description of an error
93 * @error: is an error returned by a libtasn1 function.
94 *
95 * This function is similar to strerror(). The only difference is
96 * that it accepts an error (number) returned by a libtasn1 function.
97 *
98 * Returns: Pointer to static zero-terminated string describing error
99 * code.
100 **/
101const char *
102MHD__libtasn1_strerror (MHD__asn1_retCode error)
103{
104 const char *ret = NULL;
105
106 /* avoid prefix */
107 LIBTASN1_ERROR_ALG_LOOP (ret = p->name + sizeof ("ASN1_") - 1);
108
109 return ret;
110}
111
112/* this function will output a message.
113 */
114#ifdef LIBTASN1_DEBUG
115void
116MHD__libtasn1_log (const char *fmt, ...)
117{
118 va_list args;
119 char str[MAX_LOG_SIZE];
120
121 va_start (args, fmt);
122 vsprintf (str, fmt, args); /* Flawfinder: ignore */
123 va_end (args);
124
125 fprintf (stderr, str);
126
127 return;
128}
129#else /* not DEBUG */
130void
131MHD__libtasn1_log (const char *fmt, ...)
132{
133 return;
134}
135#endif /* DEBUG */