Added copying conditions.
[libidn.git] / stringprep.h.in
blob40b1fa6d3120e83e79bbefc087b1ca9351e252eb
1 /* stringprep.h header file for libstringprep -*- c -*-
2 * Copyright (C) 2002 Simon Josefsson
4 * This file is part of Libstringprep.
6 * Libstringprep 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 * Libstringprep 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 Libstringprep; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _STRINGPREP_H
23 #define _STRINGPREP_H
25 #ifdef __cplusplus
26 extern "C"
28 #if 0 /* keep Emacsens's auto-indent happy */
30 #endif
31 #endif
33 #define STRINGPREP_VERSION "@PACKAGE_VERSION@"
35 /* Error codes */
36 enum {
37 STRINGPREP_OK = 0,
38 STRINGPREP_NFKC_FAILED,
39 STRINGPREP_TOO_SMALL_BUFFER,
40 STRINGPREP_MALLOC_ERROR,
41 STRINGPREP_BIDI_NOT_IN_PROFILE,
42 STRINGPREP_BIDI_BOTH_L_AND_RAL,
43 STRINGPREP_BIDI_LEADTRAIL_NOT_RAL,
44 STRINGPREP_UTF8_TOO_LARGE
47 enum {
48 /* Flags in API */
49 STRINGPREP_NO_NFKC = (1<<1),
50 STRINGPREP_NO_BIDI = (1<<2),
51 /* Internal flags */
52 STRINGPREP_BIDI_PROHIBITED = (1<<27),
53 STRINGPREP_BIDI_RAL = (1<<28),
54 STRINGPREP_BIDI_L = (1<<29),
55 STRINGPREP_INVERT_MAGIC = (1<<30)
58 #define STRINGPREP_BIDI_PROHIBITED_MASK (~STRINGPREP_NO_BIDI & \
59 STRINGPREP_BIDI_PROHIBITED)
60 #define STRINGPREP_BIDI_RAL_MASK (~STRINGPREP_NO_BIDI & \
61 STRINGPREP_BIDI_RAL)
62 #define STRINGPREP_BIDI_L_MASK (~STRINGPREP_NO_BIDI & \
63 STRINGPREP_BIDI_L)
65 #define MAX_MAP_CHARS 5
67 struct stringprep_table_element
69 long start;
70 long end; /* 0 if only one character */
71 long map[MAX_MAP_CHARS]; /* Always NULL if end is non-0 */
74 struct stringprep_table
76 int flags;
77 struct stringprep_table_element *table;
80 typedef struct stringprep_table stringprep_profile;
82 /* API */
84 extern int stringprep (char *in, int maxlen, int flags,
85 stringprep_profile * profile);
87 extern const char *stringprep_check_version (const char *req_version);
89 /* Utility */
91 extern int stringprep_unichar_to_utf8 (long c, char *outbuf);
92 extern long stringprep_utf8_to_unichar (const char *p);
94 extern long *stringprep_utf8_to_ucs4 (const char *str, int len,
95 int *items_written);
96 extern char *stringprep_ucs4_to_utf8 (const long * str, int len,
97 int * items_read, int * items_written);
99 extern char *stringprep_utf8_nfkc_normalize (const char *str, int len);
100 extern long *stringprep_ucs4_nfkc_normalize (long *str, int len);
102 extern const char *stringprep_locale_charset ();
103 extern char *stringprep_convert (const char *str,
104 const char *to_codeset,
105 const char *from_codeset);
106 extern char *stringprep_locale_to_utf8 (const char *str);
108 #ifdef __cplusplus
110 #endif
111 #endif /* _STRINGPREP_H */