diff options
author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/libidn/strerror-punycode.c |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/libidn/strerror-punycode.c')
-rw-r--r-- | contrib/libs/libidn/strerror-punycode.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/contrib/libs/libidn/strerror-punycode.c b/contrib/libs/libidn/strerror-punycode.c new file mode 100644 index 00000000000..80486999563 --- /dev/null +++ b/contrib/libs/libidn/strerror-punycode.c @@ -0,0 +1,79 @@ +/* strerror-punycode.c --- Convert punycode errors into text. + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Simon Josefsson + * + * This file is part of GNU Libidn. + * + * GNU Libidn is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * GNU Libidn is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GNU Libidn; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#ifdef HAVE_CONFIG_H +# include "idn_config.h" +#endif + +#include "punycode.h" + +#include "gettext.h" +#define _(String) dgettext (PACKAGE, String) + +/** + * punycode_strerror - return string describing punycode error code + * @rc: an #Punycode_status return code. + * + * Convert a return code integer to a text string. This string can be + * used to output a diagnostic message to the user. + * + * PUNYCODE_SUCCESS: Successful operation. This value is guaranteed + * to always be zero, the remaining ones are only guaranteed to hold + * non-zero values, for logical comparison purposes. + * PUNYCODE_BAD_INPUT: Input is invalid. + * PUNYCODE_BIG_OUTPUT: Output would exceed the space provided. + * PUNYCODE_OVERFLOW: Input needs wider integers to process. + * + * Return value: Returns a pointer to a statically allocated string + * containing a description of the error with the return code @rc. + **/ +const char * +punycode_strerror (Punycode_status rc) +{ + const char *p; + + bindtextdomain (PACKAGE, LOCALEDIR); + + switch (rc) + { + case PUNYCODE_SUCCESS: + p = _("Success"); + break; + + case PUNYCODE_BAD_INPUT: + p = _("Invalid input"); + break; + + case PUNYCODE_BIG_OUTPUT: + p = _("Output would exceed the buffer space provided"); + break; + + case PUNYCODE_OVERFLOW: + p = _("String size limit exceeded"); + break; + + default: + p = _("Unknown error"); + break; + } + + return p; +} |