1 /* stringprep.h --- Header file for stringprep functions. -*- c -*-
2 * Copyright (C) 2002, 2003, 2004, 2005 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
30 #include <stddef.h> /* size_t */
36 #define uint32_t SilcUInt32
42 #define uint16_t SilcUInt16
45 #define int16_t SilcInt16
48 #define STRINGPREP_VERSION "0.5.9"
54 /* Stringprep errors. */
55 STRINGPREP_CONTAINS_UNASSIGNED = 1,
56 STRINGPREP_CONTAINS_PROHIBITED = 2,
57 STRINGPREP_BIDI_BOTH_L_AND_RAL = 3,
58 STRINGPREP_BIDI_LEADTRAIL_NOT_RAL = 4,
59 STRINGPREP_BIDI_CONTAINS_PROHIBITED = 5,
60 /* Error in calling application. */
61 STRINGPREP_TOO_SMALL_BUFFER = 100,
62 STRINGPREP_PROFILE_ERROR = 101,
63 STRINGPREP_FLAG_ERROR = 102,
64 STRINGPREP_UNKNOWN_PROFILE = 103,
65 /* Internal errors. */
66 STRINGPREP_NFKC_FAILED = 200,
67 STRINGPREP_MALLOC_ERROR = 201
70 /* Flags used when calling stringprep(). */
73 STRINGPREP_NO_NFKC = 1,
74 STRINGPREP_NO_BIDI = 2,
75 STRINGPREP_NO_UNASSIGNED = 4
76 } Stringprep_profile_flags;
78 /* Steps in a stringprep profile. */
83 STRINGPREP_MAP_TABLE = 3,
84 STRINGPREP_UNASSIGNED_TABLE = 4,
85 STRINGPREP_PROHIBIT_TABLE = 5,
86 STRINGPREP_BIDI_PROHIBIT_TABLE = 6,
87 STRINGPREP_BIDI_RAL_TABLE = 7,
88 STRINGPREP_BIDI_L_TABLE = 8
89 } Stringprep_profile_steps;
91 #define STRINGPREP_MAX_MAP_CHARS 4
93 struct Stringprep_table_element
96 uint32_t end; /* 0 if only one character */
97 uint32_t map[STRINGPREP_MAX_MAP_CHARS]; /* NULL if end is not 0 */
99 typedef struct Stringprep_table_element Stringprep_table_element;
101 struct Stringprep_table
103 Stringprep_profile_steps operation;
104 Stringprep_profile_flags flags;
105 const Stringprep_table_element *table;
107 typedef struct Stringprep_table Stringprep_profile;
109 struct Stringprep_profiles
112 const Stringprep_profile *tables;
114 typedef struct Stringprep_profiles Stringprep_profiles;
116 extern const Stringprep_profiles stringprep_profiles[];
119 extern const Stringprep_table_element stringprep_rfc3454_A_1[];
120 extern const Stringprep_table_element stringprep_rfc3454_B_1[];
121 extern const Stringprep_table_element stringprep_rfc3454_B_2[];
122 extern const Stringprep_table_element stringprep_rfc3454_B_3[];
123 extern const Stringprep_table_element stringprep_rfc3454_C_1_1[];
124 extern const Stringprep_table_element stringprep_rfc3454_C_1_2[];
125 extern const Stringprep_table_element stringprep_rfc3454_C_2_1[];
126 extern const Stringprep_table_element stringprep_rfc3454_C_2_2[];
127 extern const Stringprep_table_element stringprep_rfc3454_C_3[];
128 extern const Stringprep_table_element stringprep_rfc3454_C_4[];
129 extern const Stringprep_table_element stringprep_rfc3454_C_5[];
130 extern const Stringprep_table_element stringprep_rfc3454_C_6[];
131 extern const Stringprep_table_element stringprep_rfc3454_C_7[];
132 extern const Stringprep_table_element stringprep_rfc3454_C_8[];
133 extern const Stringprep_table_element stringprep_rfc3454_C_9[];
134 extern const Stringprep_table_element stringprep_rfc3454_D_1[];
135 extern const Stringprep_table_element stringprep_rfc3454_D_2[];
137 extern int stringprep_4i (uint32_t * ucs4, size_t * len, size_t maxucs4len,
138 Stringprep_profile_flags flags,
139 const Stringprep_profile * profile);
140 extern int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
141 Stringprep_profile_flags flags,
142 const Stringprep_profile * profile);
143 extern int stringprep (char *in, size_t maxlen,
144 Stringprep_profile_flags flags,
145 const Stringprep_profile * profile);
147 extern int stringprep_profile (const char *in,
150 Stringprep_profile_flags flags);
152 extern const char *stringprep_strerror (Stringprep_rc rc);
154 extern const char *stringprep_check_version (const char *req_version);
158 extern int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf);
159 extern uint32_t stringprep_utf8_to_unichar (const char *p);
161 extern uint32_t *stringprep_utf8_to_ucs4 (const char *str, int len,
162 size_t * items_written);
163 extern char *stringprep_ucs4_to_utf8 (const uint32_t * str, int len,
165 size_t * items_written);
167 extern char *stringprep_utf8_nfkc_normalize (const char *str, int len);
168 extern uint32_t *stringprep_ucs4_nfkc_normalize (uint32_t * str,
171 extern const char *stringprep_locale_charset (void);
172 extern char *stringprep_convert (const char *str,
173 const char *to_codeset,
174 const char *from_codeset);
175 extern char *stringprep_locale_to_utf8 (const char *str);
176 extern char *stringprep_utf8_to_locale (const char *str);
181 #endif /* _STRINGPREP_H */