Update.
[glibc.git] / iconv / gconv.h
blob4d7022feb5aafd43c061c0778be2430af6ae318f
1 /* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library 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
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 /* This header provides no interface for a user to the internals of
20 the gconv implementation in the libc. Therefore there is no use
21 for these definitions beside for writing additional gconv modules. */
23 #ifndef _GCONV_H
24 #define _GCONV_H 1
26 #include <features.h>
27 #define __need_mbstate_t
28 #include <wchar.h>
29 #define __need_size_t
30 #include <stddef.h>
32 /* ISO 10646 value used to signal invalid value. */
33 #define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
35 /* Error codes for gconv functions. */
36 enum
38 __GCONV_OK = 0,
39 __GCONV_NOCONV,
40 __GCONV_NODB,
41 __GCONV_NOMEM,
43 __GCONV_EMPTY_INPUT,
44 __GCONV_FULL_OUTPUT,
45 __GCONV_ILLEGAL_INPUT,
46 __GCONV_INCOMPLETE_INPUT,
48 __GCONV_ILLEGAL_DESCRIPTOR,
49 __GCONV_INTERNAL_ERROR
53 /* Forward declarations. */
54 struct __gconv_step;
55 struct __gconv_step_data;
56 struct __gconv_loaded_object;
59 /* Type of a conversion function. */
60 typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
61 __const unsigned char **, __const unsigned char *,
62 size_t *, int);
64 /* Constructor and destructor for local data for conversion step. */
65 typedef int (*__gconv_init_fct) (struct __gconv_step *);
66 typedef void (*__gconv_end_fct) (struct __gconv_step *);
69 /* Description of a conversion step. */
70 struct __gconv_step
72 struct __gconv_loaded_object *__shlib_handle;
73 __const char *__modname;
75 int __counter;
77 __const char *__from_name;
78 __const char *__to_name;
80 __gconv_fct __fct;
81 __gconv_init_fct __init_fct;
82 __gconv_end_fct __end_fct;
84 /* Information about the number of bytes needed or produced in this
85 step. This helps optimizing the buffer sizes. */
86 int __min_needed_from;
87 int __max_needed_from;
88 int __min_needed_to;
89 int __max_needed_to;
91 /* Flag whether this is a stateful encoding or not. */
92 int __stateful;
94 void *__data; /* Pointer to step-local data. */
97 /* Additional data for steps in use of conversion descriptor. This is
98 allocated by the `init' function. */
99 struct __gconv_step_data
101 unsigned char *__outbuf; /* Output buffer for this step. */
102 unsigned char *__outbufend; /* Address of first byte after the output
103 buffer.*/
105 /* Is this the last module in the chain. */
106 int __is_last;
108 /* Counter for number of invocations of the module function for this
109 descriptor. */
110 int __invocation_counter;
112 /* Flag whether this is an internal use of the module (in the mb*towc*
113 and wc*tomb* functions) or regular with iconv(3). */
114 int __internal_use;
116 __mbstate_t *__statep;
117 __mbstate_t __state; /* This element should not be used directly by
118 any module; always use STATEP! */
122 /* Combine conversion step description with data. */
123 typedef struct __gconv_info
125 size_t __nsteps;
126 struct __gconv_step *__steps;
127 struct __gconv_step_data __data[0];
128 } *__gconv_t;
130 #endif /* gconv.h */