Update.
[glibc.git] / iconv / gconv.h
blob3f787c5e1c622125f8a36eb018f3feba5ed3dacd
1 /* Copyright (C) 1997, 1998 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 #include <wchar.h>
28 #define __need_size_t
29 #include <stddef.h>
31 /* ISO 10646 value used to signal invalid value. */
32 #define UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
34 /* Error codes for gconv functions. */
35 enum
37 GCONV_OK = 0,
38 GCONV_NOCONV,
39 GCONV_NODB,
40 GCONV_NOMEM,
42 GCONV_EMPTY_INPUT,
43 GCONV_FULL_OUTPUT,
44 GCONV_ILLEGAL_INPUT,
45 GCONV_INCOMPLETE_INPUT,
47 GCONV_ILLEGAL_DESCRIPTOR,
48 GCONV_INTERNAL_ERROR
52 /* Forward declarations. */
53 struct gconv_step;
54 struct gconv_step_data;
55 struct gconv_loaded_object;
58 /* Type of a conversion function. */
59 typedef int (*gconv_fct) __PMT ((struct gconv_step *,
60 struct gconv_step_data *, __const char **,
61 __const char *, size_t *, int));
63 /* Constructor and destructor for local data for conversion step. */
64 typedef int (*gconv_init_fct) __PMT ((struct gconv_step *));
65 typedef void (*gconv_end_fct) __PMT ((struct gconv_step *));
68 /* Description of a conversion step. */
69 struct gconv_step
71 struct gconv_loaded_object *shlib_handle;
72 const char *modname;
74 int counter;
76 __const char *from_name;
77 __const char *to_name;
79 gconv_fct fct;
80 gconv_init_fct init_fct;
81 gconv_end_fct end_fct;
83 /* Information about the number of bytes needed or produced in this
84 step. This helps optimizing the buffer sizes. */
85 int min_needed_from;
86 int max_needed_from;
87 int min_needed_to;
88 int max_needed_to;
90 /* Flag whether this is a stateful encoding or not. */
91 int stateful;
93 void *data; /* Pointer to step-local data. */
96 /* Additional data for steps in use of conversion descriptor. This is
97 allocated by the `init' function. */
98 struct gconv_step_data
100 char *outbuf; /* Output buffer for this step. */
101 char *outbufend; /* Address of first byte after the output buffer. */
103 /* Is this the last module in the chain. */
104 int is_last;
106 /* Counter for number of invocations of the module function for this
107 desriptor. */
108 int invocation_counter;
110 /* Flag whether this is an internal use of the module (in the mb*towc*
111 and wc*tomb* functions) or regular with iconv(3). */
112 int internal_use;
114 mbstate_t *statep;
115 mbstate_t __state; /* This element should not be used directly by
116 any module; always use STATEP! */
120 /* Combine conversion step description with data. */
121 typedef struct gconv_info
123 size_t nsteps;
124 struct gconv_step *steps;
125 struct gconv_step_data *data;
126 } *gconv_t;
128 #endif /* gconv.h */