Update.
[glibc.git] / iconv / gconv_int.h
blobe4202f68ea0e52bc4a3bc6a8345ecce827543d23
1 /* Copyright (C) 1997, 1998 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. */
20 #ifndef _GCONV_INT_H
21 #define _GCONV_INT_H 1
23 #include "gconv.h"
24 #include <regex.h>
26 __BEGIN_DECLS
29 /* Structure for alias definition. Simply to strings. */
30 struct gconv_alias
32 const char *fromname;
33 const char *toname;
37 /* How many character should be conveted in one call? */
38 #define GCONV_NCHAR_GOAL 8160
41 /* Structure describing one loaded shared object. This normally are
42 objects to perform conversation but as a special case the db shared
43 object is also handled. */
44 struct gconv_loaded_object
46 /* Name of the object. */
47 const char *name;
49 /* Reference counter for the db functionality. If no conversion is
50 needed we unload the db library. */
51 int counter;
53 /* The handle for the shared object. */
54 struct link_map *handle;
56 /* Pointer to the functions the module defines. */
57 gconv_fct fct;
58 gconv_init_fct init_fct;
59 gconv_end_fct end_fct;
63 /* Description for an available conversion module. */
64 struct gconv_module
66 const char *from_pattern;
67 const char *from_constpfx;
68 size_t from_constpfx_len;
69 const regex_t *from_regex;
71 const char *to_string;
73 int cost_hi;
74 int cost_lo;
76 const char *module_name;
80 /* Global variables. */
82 /* Database of alias names. */
83 extern void *__gconv_alias_db;
85 /* Array with available modules. */
86 extern size_t __gconv_nmodules;
87 extern struct gconv_module **__gconv_modules_db;
90 /* Return in *HANDLE decriptor for transformation from FROMSET to TOSET. */
91 extern int __gconv_open (const char *__toset, const char *__fromset,
92 gconv_t *__handle)
93 internal_function;
95 /* Free resources associated with transformation descriptor CD. */
96 extern int __gconv_close (gconv_t cd)
97 internal_function;
99 /* Transform at most *INBYTESLEFT bytes from buffer starting at *INBUF
100 according to rules described by CD and place up to *OUTBYTESLEFT
101 bytes in buffer starting at *OUTBUF. Return number of written
102 characters in *CONVERTED if this pointer is not null. */
103 extern int __gconv (gconv_t __cd, const char **__inbuf, const char *inbufend,
104 char **__outbuf, char *outbufend, size_t *__converted)
105 internal_function;
107 /* Return in *HANDLE a pointer to an array with *NSTEPS elements describing
108 the single steps necessary for transformation from FROMSET to TOSET. */
109 extern int __gconv_find_transform (const char *__toset, const char *__fromset,
110 struct gconv_step **__handle,
111 size_t *__nsteps)
112 internal_function;
114 /* Read all the configuration data and cache it. */
115 extern void __gconv_read_conf (void)
116 internal_function;
118 /* Comparison function to search alias. */
119 extern int __gconv_alias_compare (const void *__p1, const void *__p2);
121 /* Clear reference to transformation step implementations which might
122 cause the code to be unloaded. */
123 extern int __gconv_close_transform (struct gconv_step *__steps,
124 size_t __nsteps)
125 internal_function;
127 /* Load shared object named by NAME. If already loaded increment reference
128 count. */
129 extern struct gconv_loaded_object *__gconv_find_shlib (const char *__name)
130 internal_function;
132 /* Find function named NAME in shared object referenced by HANDLE. */
133 void *__gconv_find_func (void *handle, const char *name)
134 internal_function;
136 /* Release shared object. If no further reference is available unload
137 the object. */
138 extern int __gconv_release_shlib (struct gconv_loaded_object *__handle)
139 internal_function;
141 /* Fill STEP with information about builtin module with NAME. */
142 extern void __gconv_get_builtin_trans (const char *__name,
143 struct gconv_step *__step)
144 internal_function;
148 /* Builtin transformations. */
149 #ifdef _LIBC
150 # define __BUILTIN_TRANS(Name) \
151 extern int Name (struct gconv_step *__step, struct gconv_step_data *__data, \
152 const char **__inbuf, const char *__inbufend, \
153 size_t *__written, int __do_flush)
155 __BUILTIN_TRANS (__gconv_transform_dummy);
156 __BUILTIN_TRANS (__gconv_transform_ascii_internal);
157 __BUILTIN_TRANS (__gconv_transform_internal_ascii);
158 __BUILTIN_TRANS (__gconv_transform_utf8_internal);
159 __BUILTIN_TRANS (__gconv_transform_internal_utf8);
160 __BUILTIN_TRANS (__gconv_transform_ucs2_internal);
161 __BUILTIN_TRANS (__gconv_transform_internal_ucs2);
162 __BUILTIN_TRANS (__gconv_transform_ucs2little_internal);
163 __BUILTIN_TRANS (__gconv_transform_internal_ucs2little);
164 __BUILTIN_TRANS (__gconv_transform_internal_ucs4);
165 # undef __BUITLIN_TRANS
167 #endif
169 __END_DECLS
171 #endif /* gconv_int.h */