Add.
[libidn.git] / lib / strerror-punycode.c
blob713d6ca5e130a3a737f54091d8dee84b43d3fbe8
1 /* strerror-punycode.c --- Convert punycode 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 "punycode.h"
28 #include "gettext.h"
29 #define _(String) dgettext (PACKAGE, String)
31 /**
32 * punycode_strerror - return string describing punycode error code
33 * @rc: an #Punycode_status 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 * PUNYCODE_SUCCESS: Successful operation. This value is guaranteed
39 * to always be zero, the remaining ones are only guaranteed to hold
40 * non-zero values, for logical comparison purposes.
41 * PUNYCODE_BAD_INPUT: Input is invalid.
42 * PUNYCODE_BIG_OUTPUT: Output would exceed the space provided.
43 * PUNYCODE_OVERFLOW: Input needs wider integers to process.
45 * Return value: Returns a pointer to a statically allocated string
46 * containing a description of the error with the return code @rc.
47 **/
48 const char *
49 punycode_strerror (Punycode_status rc)
51 const char *p;
53 bindtextdomain (PACKAGE, LOCALEDIR);
55 switch (rc)
57 case PUNYCODE_SUCCESS:
58 p = _("Success");
59 break;
61 case PUNYCODE_BAD_INPUT:
62 p = _("Invalid input");
63 break;
65 case PUNYCODE_BIG_OUTPUT:
66 p = _("Output would exceed the buffer space provided");
67 break;
69 case PUNYCODE_OVERFLOW:
70 p = _("String size limit exceeded");
71 break;
73 default:
74 p = _("Unknown error");
75 break;
78 return p;