Add.
[libidn.git] / lib / strerror-stringprep.c
blobe1c80ddc966d9ae02d60414ea435c63e613fe8d9
1 /* strerror-stringprep.c --- Convert stringprep 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "stringprep.h"
24 #include "gettext.h"
25 #define _(String) dgettext (PACKAGE, String)
27 /**
28 * stringprep_strerror:
29 * @rc: a #Stringprep_rc return code.
31 * Convert a return code integer to a text string. This string can be
32 * used to output a diagnostic message to the user.
34 * STRINGPREP_OK: Successful operation. This value is guaranteed to
35 * always be zero, the remaining ones are only guaranteed to hold
36 * non-zero values, for logical comparison purposes.
37 * STRINGPREP_CONTAINS_UNASSIGNED: String contain unassigned Unicode
38 * code points, which is forbidden by the profile.
39 * STRINGPREP_CONTAINS_PROHIBITED: String contain code points
40 * prohibited by the profile.
41 * STRINGPREP_BIDI_BOTH_L_AND_RAL: String contain code points with
42 * conflicting bidirection category.
43 * STRINGPREP_BIDI_LEADTRAIL_NOT_RAL: Leading and trailing character
44 * in string not of proper bidirectional category.
45 * STRINGPREP_BIDI_CONTAINS_PROHIBITED: Contains prohibited code
46 * points detected by bidirectional code.
47 * STRINGPREP_TOO_SMALL_BUFFER: Buffer handed to function was too
48 * small. This usually indicate a problem in the calling
49 * application.
50 * STRINGPREP_PROFILE_ERROR: The stringprep profile was inconsistent.
51 * This usually indicate an internal error in the library.
52 * STRINGPREP_FLAG_ERROR: The supplied flag conflicted with profile.
53 * This usually indicate a problem in the calling application.
54 * STRINGPREP_UNKNOWN_PROFILE: The supplied profile name was not
55 * known to the library.
56 * STRINGPREP_NFKC_FAILED: The Unicode NFKC operation failed. This
57 * usually indicate an internal error in the library.
58 * STRINGPREP_MALLOC_ERROR: The malloc() was out of memory. This is
59 * usually a fatal error.
61 * Return value: Returns a pointer to a statically allocated string
62 * containing a description of the error with the return code @rc.
63 **/
64 const char *
65 stringprep_strerror (Stringprep_rc rc)
67 const char *p;
69 bindtextdomain (PACKAGE, LOCALEDIR);
71 switch (rc)
73 case STRINGPREP_OK:
74 p = _("Success");
75 break;
77 case STRINGPREP_CONTAINS_UNASSIGNED:
78 p = _("Forbidden unassigned code points in input");
79 break;
81 case STRINGPREP_CONTAINS_PROHIBITED:
82 p = _("Prohibited code points in input");
83 break;
85 case STRINGPREP_BIDI_BOTH_L_AND_RAL:
86 p = _("Conflicting bidirectional properties in input");
87 break;
89 case STRINGPREP_BIDI_LEADTRAIL_NOT_RAL:
90 p = _("Malformed bidirectional string");
91 break;
93 case STRINGPREP_BIDI_CONTAINS_PROHIBITED:
94 p = _("Prohibited bidirectional code points in input");
95 break;
97 case STRINGPREP_TOO_SMALL_BUFFER:
98 p = _("Output would exceed the buffer space provided");
99 break;
101 case STRINGPREP_PROFILE_ERROR:
102 p = _("Error in stringprep profile definition");
103 break;
105 case STRINGPREP_FLAG_ERROR:
106 p = _("Flag conflict with profile");
107 break;
109 case STRINGPREP_UNKNOWN_PROFILE:
110 p = _("Unknown profile");
111 break;
113 case STRINGPREP_NFKC_FAILED:
114 p = _("Unicode normalization failed (internal error)");
115 break;
117 case STRINGPREP_MALLOC_ERROR:
118 p = _("Cannot allocate memory");
119 break;
121 default:
122 p = _("Unknown error");
123 break;
126 return p;