2 * Copyright (C) 2012 Free Software Foundation
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of libdane.
8 * libdane is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
24 #include <gnutls/dane.h>
26 /* I18n of error codes. */
28 #define _(String) dgettext (PACKAGE, String)
29 #define N_(String) gettext_noop (String)
31 #define ERROR_ENTRY(desc, name) \
40 typedef struct error_entry error_entry
;
42 static const error_entry error_algorithms
[] = {
43 ERROR_ENTRY (N_("Success."), DANE_E_SUCCESS
),
44 ERROR_ENTRY (N_("There was error initializing the DNS query."),
45 DANE_E_INITIALIZATION_ERROR
),
46 ERROR_ENTRY (N_("There was an error while resolving."),
47 DANE_E_RESOLVING_ERROR
),
48 ERROR_ENTRY (N_("No DANE data were found."),
50 ERROR_ENTRY (N_("No DNSSEC signature was found."),
51 DANE_E_NO_DNSSEC_SIG
),
52 ERROR_ENTRY (N_("Received corrupt data."),
53 DANE_E_RECEIVED_CORRUPT_DATA
),
54 ERROR_ENTRY (N_("The DNSSEC signature is invalid."),
55 DANE_E_INVALID_DNSSEC_SIG
),
56 ERROR_ENTRY (N_("There was a memory error."),
58 ERROR_ENTRY (N_("There requested data are not available."),
59 DANE_E_REQUESTED_DATA_NOT_AVAILABLE
),
60 ERROR_ENTRY (N_("There request is invalid."),
61 DANE_E_INVALID_REQUEST
),
62 ERROR_ENTRY (N_("There was an error in the public key."),
64 ERROR_ENTRY (N_("No certificate was found."),
71 * @error: is a DANE error code, a negative error code
73 * This function is similar to strerror. The difference is that it
74 * accepts an error number returned by a gnutls function; In case of
75 * an unknown error a descriptive string is sent instead of %NULL.
77 * Error codes are always a negative error code.
79 * Returns: A string explaining the DANE error message.
82 dane_strerror (int error
)
84 const char *ret
= NULL
;
87 for (p
= error_algorithms
; p
->desc
!= NULL
; p
++)
89 if (p
->number
== error
)
98 return _("(unknown error code)");