Mercurial > hg > octave-kai > gnulib-hg
annotate lib/uniconv.h @ 11639:b2e769838448
hash: fix memory leak in last patch
* lib/hash.c (hash_rehash): Avoid memory leak.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Thu, 18 Jun 2009 15:24:38 -0600 |
parents | 3ba5fff00fed |
children | e8d2c6fc33ad |
rev | line source |
---|---|
7945 | 1 /* Conversions between Unicode and legacy encodings. |
11452 | 2 Copyright (C) 2002, 2005, 2007, 2009 Free Software Foundation, Inc. |
7945 | 3 |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify it |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
5 under the terms of the GNU Lesser General Public License as published |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
6 by the Free Software Foundation; either version 3 of the License, or |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
7 (at your option) any later version. |
7945 | 8 |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
12 Lesser General Public License for more details. |
7945 | 13 |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
14 You should have received a copy of the GNU Lesser General Public License |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8959
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7945 | 16 |
17 #ifndef _UNICONV_H | |
18 #define _UNICONV_H | |
19 | |
20 /* Get size_t. */ | |
21 #include <stddef.h> | |
22 | |
23 #include "unitypes.h" | |
24 | |
25 /* Get enum iconv_ilseq_handler. */ | |
11476
d053b39f7091
New include file "iconveh.h".
Bruno Haible <bruno@clisp.org>
parents:
11475
diff
changeset
|
26 #include "iconveh.h" |
7945 | 27 |
11475 | 28 /* Get uniconv_register_autodetect() declaration. */ |
7945 | 29 #include "striconveha.h" |
30 | |
31 /* Get locale_charset() declaration. */ | |
32 #include "localcharset.h" | |
33 | |
34 | |
35 #ifdef __cplusplus | |
36 extern "C" { | |
37 #endif | |
38 | |
39 | |
40 /* Converts an entire string, possibly including NUL bytes, from one encoding | |
41 to a Unicode encoding. | |
42 Converts a memory region given in encoding FROMCODE. FROMCODE is as for | |
43 iconv_open(3). | |
44 The input is in the memory region between SRC (inclusive) and SRC + SRCLEN | |
45 (exclusive). | |
46 If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this | |
47 array is filled with offsets into the result, i.e. the character starting | |
48 at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]], | |
49 and other offsets are set to (size_t)(-1). | |
11513 | 50 RESULTBUF and *LENGTHP should initially be a scratch buffer and its size, |
51 or *RESULTBUF can be NULL. | |
11514 | 52 May erase the contents of the memory at RESULTBUF. |
11511
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
53 If successful: The resulting Unicode string (non-NULL) is returned and its |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
54 length stored in *LENGTHP. The resulting string is RESULTBUF if no dynamic |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
55 memory allocation was necessary, or a freshly allocated memory block |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
56 otherwise. |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
57 In case of error: NULL is returned and errno is set. Particular errno |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
58 values: EINVAL, EILSEQ, ENOMEM. */ |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
59 extern uint8_t * |
7945 | 60 u8_conv_from_encoding (const char *fromcode, |
61 enum iconv_ilseq_handler handler, | |
62 const char *src, size_t srclen, | |
63 size_t *offsets, | |
11511
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
64 uint8_t *resultbuf, size_t *lengthp); |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
65 extern uint16_t * |
7945 | 66 u16_conv_from_encoding (const char *fromcode, |
67 enum iconv_ilseq_handler handler, | |
68 const char *src, size_t srclen, | |
69 size_t *offsets, | |
11511
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
70 uint16_t *resultbuf, size_t *lengthp); |
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
71 extern uint32_t * |
7945 | 72 u32_conv_from_encoding (const char *fromcode, |
73 enum iconv_ilseq_handler handler, | |
74 const char *src, size_t srclen, | |
75 size_t *offsets, | |
11511
d604b921ed8d
Simplify calling convention of u*_conv_from_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
76 uint32_t *resultbuf, size_t *lengthp); |
7945 | 77 |
8959
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
78 /* Converts an entire Unicode string, possibly including NUL units, from a |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
79 Unicode encoding to a given encoding. |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
80 Converts a memory region to encoding TOCODE. TOCODE is as for |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
81 iconv_open(3). |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
82 The input is in the memory region between SRC (inclusive) and SRC + SRCLEN |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
83 (exclusive). |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
84 If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
85 array is filled with offsets into the result, i.e. the character starting |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
86 at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]], |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
87 and other offsets are set to (size_t)(-1). |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
88 RESULTBUF and *LENGTHP should initially be a scratch buffer and its size, |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
89 or RESULTBUF can be NULL. |
11514 | 90 May erase the contents of the memory at RESULTBUF. |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
91 If successful: The resulting string (non-NULL) is returned and its length |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
92 stored in *LENGTHP. The resulting string is RESULTBUF if no dynamic memory |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
93 allocation was necessary, or a freshly allocated memory block otherwise. |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
94 In case of error: NULL is returned and errno is set. Particular errno |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
95 values: EINVAL, EILSEQ, ENOMEM. */ |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
96 extern char * |
8959
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
97 u8_conv_to_encoding (const char *tocode, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
98 enum iconv_ilseq_handler handler, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
99 const uint8_t *src, size_t srclen, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
100 size_t *offsets, |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
101 char *resultbuf, size_t *lengthp); |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
102 extern char * |
8959
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
103 u16_conv_to_encoding (const char *tocode, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
104 enum iconv_ilseq_handler handler, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
105 const uint16_t *src, size_t srclen, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
106 size_t *offsets, |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
107 char *resultbuf, size_t *lengthp); |
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
108 extern char * |
8959
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
109 u32_conv_to_encoding (const char *tocode, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
110 enum iconv_ilseq_handler handler, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
111 const uint32_t *src, size_t srclen, |
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
112 size_t *offsets, |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
11476
diff
changeset
|
113 char *resultbuf, size_t *lengthp); |
8959
dd17470aa43e
New modules uniconv/u{8,16,32}-conv-to-enc.
Bruno Haible <bruno@clisp.org>
parents:
7945
diff
changeset
|
114 |
7945 | 115 /* Converts a NUL terminated string from a given encoding. |
116 The result is malloc allocated, or NULL (with errno set) in case of error. | |
117 Particular errno values: EILSEQ, ENOMEM. */ | |
118 extern uint8_t * | |
119 u8_strconv_from_encoding (const char *string, | |
120 const char *fromcode, | |
121 enum iconv_ilseq_handler handler); | |
122 extern uint16_t * | |
123 u16_strconv_from_encoding (const char *string, | |
124 const char *fromcode, | |
125 enum iconv_ilseq_handler handler); | |
126 extern uint32_t * | |
127 u32_strconv_from_encoding (const char *string, | |
128 const char *fromcode, | |
129 enum iconv_ilseq_handler handler); | |
130 | |
131 /* Converts a NUL terminated string to a given encoding. | |
132 The result is malloc allocated, or NULL (with errno set) in case of error. | |
133 Particular errno values: EILSEQ, ENOMEM. */ | |
134 extern char * | |
135 u8_strconv_to_encoding (const uint8_t *string, | |
136 const char *tocode, | |
137 enum iconv_ilseq_handler handler); | |
138 extern char * | |
139 u16_strconv_to_encoding (const uint16_t *string, | |
140 const char *tocode, | |
141 enum iconv_ilseq_handler handler); | |
142 extern char * | |
143 u32_strconv_to_encoding (const uint32_t *string, | |
144 const char *tocode, | |
145 enum iconv_ilseq_handler handler); | |
146 | |
147 /* Converts a NUL terminated string from the locale encoding. | |
148 The result is malloc allocated, or NULL (with errno set) in case of error. | |
149 Particular errno values: ENOMEM. */ | |
150 extern uint8_t * | |
151 u8_strconv_from_locale (const char *string); | |
152 extern uint16_t * | |
153 u16_strconv_from_locale (const char *string); | |
154 extern uint32_t * | |
155 u32_strconv_from_locale (const char *string); | |
156 | |
157 /* Converts a NUL terminated string to the locale encoding. | |
158 The result is malloc allocated, or NULL (with errno set) in case of error. | |
159 Particular errno values: ENOMEM. */ | |
160 extern char * | |
161 u8_strconv_to_locale (const uint8_t *string); | |
162 extern char * | |
163 u16_strconv_to_locale (const uint16_t *string); | |
164 extern char * | |
165 u32_strconv_to_locale (const uint32_t *string); | |
166 | |
167 | |
168 #ifdef __cplusplus | |
169 } | |
170 #endif | |
171 | |
172 #endif /* _UNICONV_H */ |