1 /* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #define _GCONV_INT_H 1
29 /* Type to represent search path. */
36 /* Variable with search path for `gconv' implementation. */
37 extern const struct path_elem
*__gconv_path_elem
;
38 /* Maximum length of a single path element. */
39 extern size_t __gconv_max_path_elem_len
;
42 /* Structure for alias definition. Simply to strings. */
50 /* How many character should be conveted in one call? */
51 #define GCONV_NCHAR_GOAL 8160
54 /* Structure describing one loaded shared object. This normally are
55 objects to perform conversation but as a special case the db shared
56 object is also handled. */
57 struct __gconv_loaded_object
59 /* Name of the object. */
62 /* Reference counter for the db functionality. If no conversion is
63 needed we unload the db library. */
66 /* The handle for the shared object. */
69 /* Pointer to the functions the module defines. */
71 __gconv_init_fct init_fct
;
72 __gconv_end_fct end_fct
;
76 /* Description for an available conversion module. */
79 const char *from_pattern
;
80 const char *from_constpfx
;
81 size_t from_constpfx_len
;
82 const regex_t
*from_regex
;
83 regex_t from_regex_mem
;
85 const char *to_string
;
90 const char *module_name
;
92 struct gconv_module
*left
; /* Prefix smaller. */
93 struct gconv_module
*same
; /* List of entries with identical prefix. */
94 struct gconv_module
*matching
;/* Next node with more specific prefix. */
95 struct gconv_module
*right
; /* Prefix larger. */
99 /* Internal data structure to represent transliteration module. */
103 struct trans_struct
*next
;
105 const char **csnames
;
107 __gconv_trans_fct trans_fct
;
108 __gconv_trans_context_fct trans_context_fct
;
109 __gconv_trans_init_fct trans_init_fct
;
110 __gconv_trans_end_fct trans_end_fct
;
114 /* Flags for `gconv_open'. */
117 GCONV_AVOID_NOCONV
= 1 << 0
121 /* Global variables. */
123 /* Database of alias names. */
124 extern void *__gconv_alias_db
;
126 /* Array with available modules. */
127 extern size_t __gconv_nmodules
;
128 extern struct gconv_module
*__gconv_modules_db
;
131 /* The gconv functions expects the name to be in upper case and complete,
132 including the trailing slashes if necessary. */
133 #define norm_add_slashes(str,suffix) \
135 const char *cp = (str); \
139 size_t suffix_len = suffix == NULL ? 0 : strlen (suffix); \
141 while (*cp != '\0') \
145 tmp = result = alloca (cp - (str) + 3 + suffix_len); \
147 while (*cp != '\0') \
148 *tmp++ = _toupper (*cp++); \
155 if (suffix != NULL) \
156 tmp = __mempcpy (tmp, suffix, suffix_len); \
164 /* Return in *HANDLE decriptor for transformation from FROMSET to TOSET. */
165 extern int __gconv_open (const char *toset
, const char *fromset
,
166 __gconv_t
*handle
, int flags
)
169 /* Free resources associated with transformation descriptor CD. */
170 extern int __gconv_close (__gconv_t cd
)
173 /* Transform at most *INBYTESLEFT bytes from buffer starting at *INBUF
174 according to rules described by CD and place up to *OUTBYTESLEFT
175 bytes in buffer starting at *OUTBUF. Return number of non-identical
176 conversions in *IRREVERSIBLE if this pointer is not null. */
177 extern int __gconv (__gconv_t cd
, const unsigned char **inbuf
,
178 const unsigned char *inbufend
, unsigned char **outbuf
,
179 unsigned char *outbufend
, size_t *irreversible
)
182 /* Return in *HANDLE a pointer to an array with *NSTEPS elements describing
183 the single steps necessary for transformation from FROMSET to TOSET. */
184 extern int __gconv_find_transform (const char *toset
, const char *fromset
,
185 struct __gconv_step
**handle
,
186 size_t *nsteps
, int flags
)
189 /* Read all the configuration data and cache it. */
190 extern void __gconv_read_conf (void);
192 /* Determine the directories we are looking in. */
193 extern void __gconv_get_path (void);
195 /* Comparison function to search alias. */
196 extern int __gconv_alias_compare (const void *p1
, const void *p2
);
198 /* Clear reference to transformation step implementations which might
199 cause the code to be unloaded. */
200 extern int __gconv_close_transform (struct __gconv_step
*steps
,
204 /* Load shared object named by NAME. If already loaded increment reference
206 extern struct __gconv_loaded_object
*__gconv_find_shlib (const char *name
)
209 /* Release shared object. If no further reference is available unload
211 extern int __gconv_release_shlib (struct __gconv_loaded_object
*handle
)
214 /* Fill STEP with information about builtin module with NAME. */
215 extern void __gconv_get_builtin_trans (const char *name
,
216 struct __gconv_step
*step
)
219 /* Try to load transliteration step module. */
220 extern int __gconv_translit_find (struct trans_struct
*trans
)
223 /* Transliteration using the locale's data. */
224 extern int __gconv_transliterate (struct __gconv_step
*step
,
225 struct __gconv_step_data
*step_data
,
227 __const
unsigned char *inbufstart
,
228 __const
unsigned char **inbufp
,
229 __const
unsigned char *inbufend
,
230 unsigned char **outbufstart
,
231 size_t *irreversible
);
234 /* Builtin transformations. */
236 # define __BUILTIN_TRANS(Name) \
237 extern int Name (struct __gconv_step *step, \
238 struct __gconv_step_data *data, \
239 const unsigned char **inbuf, \
240 const unsigned char *inbufend, \
241 unsigned char **outbufstart, size_t *irreversible, \
242 int do_flush, int consume_incomplete)
244 __BUILTIN_TRANS (__gconv_transform_ascii_internal
);
245 __BUILTIN_TRANS (__gconv_transform_internal_ascii
);
246 __BUILTIN_TRANS (__gconv_transform_utf8_internal
);
247 __BUILTIN_TRANS (__gconv_transform_internal_utf8
);
248 __BUILTIN_TRANS (__gconv_transform_ucs2_internal
);
249 __BUILTIN_TRANS (__gconv_transform_internal_ucs2
);
250 __BUILTIN_TRANS (__gconv_transform_ucs2reverse_internal
);
251 __BUILTIN_TRANS (__gconv_transform_internal_ucs2reverse
);
252 __BUILTIN_TRANS (__gconv_transform_internal_ucs4
);
253 __BUILTIN_TRANS (__gconv_transform_ucs4_internal
);
254 __BUILTIN_TRANS (__gconv_transform_internal_ucs4le
);
255 __BUILTIN_TRANS (__gconv_transform_ucs4le_internal
);
256 __BUILTIN_TRANS (__gconv_transform_internal_utf16
);
257 __BUILTIN_TRANS (__gconv_transform_utf16_internal
);
258 # undef __BUITLIN_TRANS
264 #endif /* gconv_int.h */