~ubuntu-branches/ubuntu/trusty/libidn/trusty

« back to all changes in this revision

Viewing changes to lib/stringprep.h.in

  • Committer: Bazaar Package Importer
  • Author(s): Simon Josefsson, Simon Josefsson
  • Date: 2009-04-17 00:22:30 UTC
  • mfrom: (1.2.11 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090417002230-3on40qu1llxq7ybb
Tags: 1.14-3
[ Simon Josefsson ]
* Don't use autotools-dev, the config.* files in libidn
  are newer than what's in autotools-dev.
* Use more idiomatatic code to filter out platforms without gcj.
  Thanks to Adeodato Simó <dato@net.com.org.es>.
* Upload to unstable after testing in experimental.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* stringprep.h --- Header file for stringprep functions.             -*- c -*-
2
 
 * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007  Simon Josefsson
3
 
 *
4
 
 * This file is part of GNU Libidn.
5
 
 *
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.
10
 
 *
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.
15
 
 *
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
19
 
 *
20
 
 */
21
 
 
22
 
#ifndef _STRINGPREP_H
23
 
#define _STRINGPREP_H
24
 
 
25
 
#ifdef __cplusplus
26
 
extern "C"
27
 
{
28
 
#endif
29
 
 
30
 
#include <stddef.h>             /* size_t */
31
 
#include <unistd.h>             /* ssize_t */
32
 
#include <idn-int.h>            /* uint32_t */
33
 
 
34
 
  /* On Windows, variables that may be in a DLL must be marked
35
 
   * specially.  This is only active when not building libidn itself
36
 
   * (!LIBIDN_BUILDING).  It is only used for MinGW which declare
37
 
   * __DECLSPEC_SUPPORTED or MSVC (_MSC_VER && _DLL). */
38
 
#if !defined (LIBIDN_BUILDING) && (defined(__DECLSPEC_SUPPORTED) || (defined(_MSC_VER) && defined(_DLL)))
39
 
# define IDN_DLL_VAR __declspec (dllimport)
40
 
#else
41
 
# define IDN_DLL_VAR
42
 
#endif
43
 
 
44
 
#define STRINGPREP_VERSION "@PACKAGE_VERSION@"
45
 
 
46
 
/* Error codes. */
47
 
  typedef enum
48
 
  {
49
 
    STRINGPREP_OK = 0,
50
 
    /* Stringprep errors. */
51
 
    STRINGPREP_CONTAINS_UNASSIGNED = 1,
52
 
    STRINGPREP_CONTAINS_PROHIBITED = 2,
53
 
    STRINGPREP_BIDI_BOTH_L_AND_RAL = 3,
54
 
    STRINGPREP_BIDI_LEADTRAIL_NOT_RAL = 4,
55
 
    STRINGPREP_BIDI_CONTAINS_PROHIBITED = 5,
56
 
    /* Error in calling application. */
57
 
    STRINGPREP_TOO_SMALL_BUFFER = 100,
58
 
    STRINGPREP_PROFILE_ERROR = 101,
59
 
    STRINGPREP_FLAG_ERROR = 102,
60
 
    STRINGPREP_UNKNOWN_PROFILE = 103,
61
 
    /* Internal errors. */
62
 
    STRINGPREP_NFKC_FAILED = 200,
63
 
    STRINGPREP_MALLOC_ERROR = 201
64
 
  } Stringprep_rc;
65
 
 
66
 
/* Flags used when calling stringprep(). */
67
 
  typedef enum
68
 
  {
69
 
    STRINGPREP_NO_NFKC = 1,
70
 
    STRINGPREP_NO_BIDI = 2,
71
 
    STRINGPREP_NO_UNASSIGNED = 4
72
 
  } Stringprep_profile_flags;
73
 
 
74
 
/* Steps in a stringprep profile. */
75
 
  typedef enum
76
 
  {
77
 
    STRINGPREP_NFKC = 1,
78
 
    STRINGPREP_BIDI = 2,
79
 
    STRINGPREP_MAP_TABLE = 3,
80
 
    STRINGPREP_UNASSIGNED_TABLE = 4,
81
 
    STRINGPREP_PROHIBIT_TABLE = 5,
82
 
    STRINGPREP_BIDI_PROHIBIT_TABLE = 6,
83
 
    STRINGPREP_BIDI_RAL_TABLE = 7,
84
 
    STRINGPREP_BIDI_L_TABLE = 8
85
 
  } Stringprep_profile_steps;
86
 
 
87
 
#define STRINGPREP_MAX_MAP_CHARS 4
88
 
 
89
 
  struct Stringprep_table_element
90
 
  {
91
 
    uint32_t start;
92
 
    uint32_t end;               /* 0 if only one character */
93
 
    uint32_t map[STRINGPREP_MAX_MAP_CHARS];     /* NULL if end is not 0 */
94
 
  };
95
 
  typedef struct Stringprep_table_element Stringprep_table_element;
96
 
 
97
 
  struct Stringprep_table
98
 
  {
99
 
    Stringprep_profile_steps operation;
100
 
    Stringprep_profile_flags flags;
101
 
    const Stringprep_table_element *table;
102
 
  };
103
 
  typedef struct Stringprep_table Stringprep_profile;
104
 
 
105
 
  struct Stringprep_profiles
106
 
  {
107
 
    const char *name;
108
 
    const Stringprep_profile *tables;
109
 
  };
110
 
  typedef struct Stringprep_profiles Stringprep_profiles;
111
 
 
112
 
  extern IDN_DLL_VAR const Stringprep_profiles stringprep_profiles[];
113
 
 
114
 
/* Profiles */
115
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_A_1[];
116
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_B_1[];
117
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_B_2[];
118
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_B_3[];
119
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_1_1[];
120
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_1_2[];
121
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_2_1[];
122
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_2_2[];
123
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_3[];
124
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_4[];
125
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_5[];
126
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_6[];
127
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_7[];
128
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_8[];
129
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_C_9[];
130
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_D_1[];
131
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_rfc3454_D_2[];
132
 
 
133
 
  /* Nameprep */
134
 
 
135
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_nameprep[];
136
 
 
137
 
#define stringprep_nameprep(in, maxlen)                 \
138
 
  stringprep(in, maxlen, 0, stringprep_nameprep)
139
 
 
140
 
#define stringprep_nameprep_no_unassigned(in, maxlen)                   \
141
 
  stringprep(in, maxlen, STRINGPREP_NO_UNASSIGNED, stringprep_nameprep)
142
 
 
143
 
  /* SASL */
144
 
 
145
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_saslprep[];
146
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_plain[];
147
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_trace[];
148
 
 
149
 
#define stringprep_plain(in, maxlen)            \
150
 
  stringprep(in, maxlen, 0, stringprep_plain)
151
 
 
152
 
  /* Kerberos */
153
 
 
154
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_kerberos5[];
155
 
 
156
 
#define stringprep_kerberos5(in, maxlen)                \
157
 
  stringprep(in, maxlen, 0, stringprep_kerberos5)
158
 
 
159
 
  /* XMPP */
160
 
 
161
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_xmpp_nodeprep[];
162
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_xmpp_resourceprep[];
163
 
  extern IDN_DLL_VAR const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[];
164
 
 
165
 
#define stringprep_xmpp_nodeprep(in, maxlen)            \
166
 
  stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep)
167
 
#define stringprep_xmpp_resourceprep(in, maxlen)                \
168
 
  stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep)
169
 
 
170
 
  /* iSCSI */
171
 
 
172
 
  extern IDN_DLL_VAR const Stringprep_profile stringprep_iscsi[];
173
 
 
174
 
#define stringprep_iscsi(in, maxlen)            \
175
 
  stringprep(in, maxlen, 0, stringprep_iscsi)
176
 
 
177
 
  /* API */
178
 
 
179
 
  extern int stringprep_4i (uint32_t * ucs4, size_t * len, size_t maxucs4len,
180
 
                            Stringprep_profile_flags flags,
181
 
                            const Stringprep_profile * profile);
182
 
  extern int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
183
 
                             Stringprep_profile_flags flags,
184
 
                             const Stringprep_profile * profile);
185
 
  extern int stringprep (char *in, size_t maxlen,
186
 
                         Stringprep_profile_flags flags,
187
 
                         const Stringprep_profile * profile);
188
 
 
189
 
  extern int stringprep_profile (const char *in,
190
 
                                 char **out,
191
 
                                 const char *profile,
192
 
                                 Stringprep_profile_flags flags);
193
 
 
194
 
  extern const char *stringprep_strerror (Stringprep_rc rc);
195
 
 
196
 
  extern const char *stringprep_check_version (const char *req_version);
197
 
 
198
 
/* Utility */
199
 
 
200
 
  extern int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf);
201
 
  extern uint32_t stringprep_utf8_to_unichar (const char *p);
202
 
 
203
 
  extern uint32_t *stringprep_utf8_to_ucs4 (const char *str, ssize_t len,
204
 
                                            size_t * items_written);
205
 
  extern char *stringprep_ucs4_to_utf8 (const uint32_t * str, ssize_t len,
206
 
                                        size_t * items_read,
207
 
                                        size_t * items_written);
208
 
 
209
 
  extern char *stringprep_utf8_nfkc_normalize (const char *str, ssize_t len);
210
 
  extern uint32_t *stringprep_ucs4_nfkc_normalize (uint32_t * str,
211
 
                                                   ssize_t len);
212
 
 
213
 
  extern const char *stringprep_locale_charset (void);
214
 
  extern char *stringprep_convert (const char *str,
215
 
                                   const char *to_codeset,
216
 
                                   const char *from_codeset);
217
 
  extern char *stringprep_locale_to_utf8 (const char *str);
218
 
  extern char *stringprep_utf8_to_locale (const char *str);
219
 
 
220
 
#ifdef __cplusplus
221
 
}
222
 
#endif
223
 
#endif                          /* _STRINGPREP_H */