*** empty log message ***
[libidn.git] / lib / strerror-tld.c
blob0c7d0bc8e282aea2d152d4993e4b8fdfcba57353
1 /* strerror-tld.c --- Convert TLD errors into text.
2 * Copyright (C) 2004 Simon Josefsson
4 * This file is part of GNU Libidn.
6 * GNU Libidn is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * GNU Libidn is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with GNU Libidn; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
26 #include "tld.h"
28 #include "gettext.h"
29 #define _(String) dgettext (PACKAGE, String)
31 /**
32 * tld_strerror - return string describing tld error code
33 * @rc: tld return code
35 * Convert a return code integer to a text string. This string can be
36 * used to output a diagnostic message to the user.
38 * TLD_SUCCESS: Successful operation. This value is guaranteed to
39 * always be zero, the remaining ones are only guaranteed to hold
40 * non-zero values, for logical comparison purposes.
41 * TLD_INVALID: Invalid character found.
42 * TLD_NODATA: No input data was provided.
43 * TLD_MALLOC_ERROR: Error during memory allocation.
44 * TLD_ICONV_ERROR: Error during iconv string conversion.
45 * TLD_NO_TLD: No top-level domain found in domain string.
47 * Return value: Returns a pointer to a statically allocated string
48 * containing a description of the error with the return code @rc.
49 **/
50 const char *
51 tld_strerror (Tld_rc rc)
53 const char *p;
55 bindtextdomain (PACKAGE, LOCALEDIR);
57 switch (rc)
59 case TLD_SUCCESS:
60 p = _("Success");
61 break;
63 case TLD_INVALID:
64 p = _("Code points prohibited by top-level domain");
65 break;
67 case TLD_NODATA:
68 p = _("Missing input");
69 break;
71 case TLD_MALLOC_ERROR:
72 p = _("Cannot allocate memory");
73 break;
75 case TLD_ICONV_ERROR:
76 p = _("System iconv failed");
77 break;
79 case TLD_NO_TLD:
80 p = _("No top-level domain found in input");
81 break;
83 default:
84 p = _("Unknown error");
85 break;
88 return p;