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) \
39 typedef struct error_entry error_entry;
41 static const error_entry error_algorithms[] = {
42 ERROR_ENTRY(N_("Success."), DANE_E_SUCCESS),
43 ERROR_ENTRY(N_("There was error initializing the DNS query."),
44 DANE_E_INITIALIZATION_ERROR),
45 ERROR_ENTRY(N_("There was an error while resolving."),
46 DANE_E_RESOLVING_ERROR),
47 ERROR_ENTRY(N_("No DANE data were found."),
49 ERROR_ENTRY(N_("Unknown DANE data were found."),
50 DANE_E_UNKNOWN_DANE_DATA),
51 ERROR_ENTRY(N_("No DNSSEC signature was found."),
52 DANE_E_NO_DNSSEC_SIG),
53 ERROR_ENTRY(N_("Received corrupt data."),
54 DANE_E_RECEIVED_CORRUPT_DATA),
55 ERROR_ENTRY(N_("The DNSSEC signature is invalid."),
56 DANE_E_INVALID_DNSSEC_SIG),
57 ERROR_ENTRY(N_("There was a memory error."),
59 ERROR_ENTRY(N_("The requested data are not available."),
60 DANE_E_REQUESTED_DATA_NOT_AVAILABLE),
61 ERROR_ENTRY(N_("The request is invalid."),
62 DANE_E_INVALID_REQUEST),
63 ERROR_ENTRY(N_("There was an error in the certificate."),
65 ERROR_ENTRY(N_("There was an error in the public key."),
67 ERROR_ENTRY(N_("No certificate was found."),
69 ERROR_ENTRY(N_("Error in file."),
76 * @error: is a DANE error code, a negative error code
78 * This function is similar to strerror. The difference is that it
79 * accepts an error number returned by a gnutls function; In case of
80 * an unknown error a descriptive string is sent instead of %NULL.
82 * Error codes are always a negative error code.
84 * Returns: A string explaining the DANE error message.
86 const char *dane_strerror(int error)
88 const char *ret = NULL;
91 for (p = error_algorithms; p->desc != NULL; p++) {
92 if (p->number == error) {
100 return _("(unknown error code)");