libidn  1.25
strerror-tld.c
Go to the documentation of this file.
00001 /* strerror-tld.c --- Convert TLD errors into text.
00002    Copyright (C) 2004-2012 Simon Josefsson
00003 
00004    This file is part of GNU Libidn.
00005 
00006    GNU Libidn is free software: you can redistribute it and/or
00007    modify it under the terms of either:
00008 
00009      * the GNU Lesser General Public License as published by the Free
00010        Software Foundation; either version 3 of the License, or (at
00011        your option) any later version.
00012 
00013    or
00014 
00015      * the GNU General Public License as published by the Free
00016        Software Foundation; either version 2 of the License, or (at
00017        your option) any later version.
00018 
00019    or both in parallel, as here.
00020 
00021    GNU Libidn is distributed in the hope that it will be useful,
00022    but WITHOUT ANY WARRANTY; without even the implied warranty of
00023    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024    General Public License for more details.
00025 
00026    You should have received copies of the GNU General Public License and
00027    the GNU Lesser General Public License along with this program.  If
00028    not, see <http://www.gnu.org/licenses/>. */
00029 
00030 #ifdef HAVE_CONFIG_H
00031 # include "config.h"
00032 #endif
00033 
00034 #include "tld.h"
00035 
00036 #include "gettext.h"
00037 #define _(String) dgettext (PACKAGE, String)
00038 
00058 const char *
00059 tld_strerror (Tld_rc rc)
00060 {
00061   const char *p;
00062 
00063   bindtextdomain (PACKAGE, LOCALEDIR);
00064 
00065   switch (rc)
00066     {
00067     case TLD_SUCCESS:
00068       p = _("Success");
00069       break;
00070 
00071     case TLD_INVALID:
00072       p = _("Code points prohibited by top-level domain");
00073       break;
00074 
00075     case TLD_NODATA:
00076       p = _("Missing input");
00077       break;
00078 
00079     case TLD_MALLOC_ERROR:
00080       p = _("Cannot allocate memory");
00081       break;
00082 
00083     case TLD_ICONV_ERROR:
00084       p = _("System iconv failed");
00085       break;
00086 
00087     case TLD_NO_TLD:
00088       p = _("No top-level domain found in input");
00089       break;
00090 
00091     default:
00092       p = _("Unknown error");
00093       break;
00094     }
00095 
00096   return p;
00097 }