libidn 1.43

strerror-idna.c
Go to the documentation of this file.
1/* strerror-idna.c --- Convert IDNA errors into text.
2 Copyright (C) 2004-2025 Simon Josefsson
3
4 This file is part of GNU Libidn.
5
6 GNU Libidn is free software: you can redistribute it and/or
7 modify it under the terms of either:
8
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version.
12
13 or
14
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version.
18
19 or both in parallel, as here.
20
21 GNU Libidn is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <https://www.gnu.org/licenses/>. */
29
30#ifdef HAVE_CONFIG_H
31# include "config.h"
32#endif
33
34#include "idna.h"
35
36#include "gettext.h"
37#define _(String) dgettext (PACKAGE, String)
38
72 const char *
73 idna_strerror (Idna_rc rc)
74{
75 const char *p;
76
77 bindtextdomain (PACKAGE, LOCALEDIR);
78
79 switch (rc)
80 {
81 case IDNA_SUCCESS:
82 p = _("Success");
83 break;
84
85 case IDNA_STRINGPREP_ERROR:
86 p = _("String preparation failed");
87 break;
88
89 case IDNA_PUNYCODE_ERROR:
90 p = _("Punycode failed");
91 break;
92
93 case IDNA_CONTAINS_NON_LDH:
94 p = _("Non-digit/letter/hyphen in input");
95 break;
96
97 case IDNA_CONTAINS_MINUS:
98 p = _("Forbidden leading or trailing minus sign ('-')");
99 break;
100
101 case IDNA_INVALID_LENGTH:
102 p = _("Output would be too large or too small");
103 break;
104
105 case IDNA_NO_ACE_PREFIX:
106 p = _("Input does not start with ACE prefix ('xn--')");
107 break;
108
109 case IDNA_ROUNDTRIP_VERIFY_ERROR:
110 p = _("String not idempotent under ToASCII");
111 break;
112
113 case IDNA_CONTAINS_ACE_PREFIX:
114 p = _("Input already contain ACE prefix ('xn--')");
115 break;
116
117 case IDNA_ICONV_ERROR:
118 p = _("Character encoding conversion error");
119 break;
120
121 case IDNA_MALLOC_ERROR:
122 p = _("Cannot allocate memory");
123 break;
124
125 case IDNA_DLOPEN_ERROR:
126 p = _("System dlopen failed");
127 break;
128
129 default:
130 p = _("Unknown error");
131 break;
132 }
133
134 return p;
135}
idna.h
Idna_rc
Idna_rc
Definition idna.h:73
IDNA_ROUNDTRIP_VERIFY_ERROR
@ IDNA_ROUNDTRIP_VERIFY_ERROR
Definition idna.h:83
IDNA_PUNYCODE_ERROR
@ IDNA_PUNYCODE_ERROR
Definition idna.h:76
IDNA_SUCCESS
@ IDNA_SUCCESS
Definition idna.h:74
IDNA_NO_ACE_PREFIX
@ IDNA_NO_ACE_PREFIX
Definition idna.h:82
IDNA_CONTAINS_MINUS
@ IDNA_CONTAINS_MINUS
Definition idna.h:80
IDNA_ICONV_ERROR
@ IDNA_ICONV_ERROR
Definition idna.h:85
IDNA_STRINGPREP_ERROR
@ IDNA_STRINGPREP_ERROR
Definition idna.h:75
IDNA_CONTAINS_ACE_PREFIX
@ IDNA_CONTAINS_ACE_PREFIX
Definition idna.h:84
IDNA_CONTAINS_NON_LDH
@ IDNA_CONTAINS_NON_LDH
Definition idna.h:77
IDNA_INVALID_LENGTH
@ IDNA_INVALID_LENGTH
Definition idna.h:81
IDNA_MALLOC_ERROR
@ IDNA_MALLOC_ERROR
Definition idna.h:87
IDNA_DLOPEN_ERROR
@ IDNA_DLOPEN_ERROR
Definition idna.h:88
_
#define _(String)
Definition strerror-idna.c:37
idna_strerror
const char * idna_strerror(Idna_rc rc)
Definition strerror-idna.c:73