]> git.ipfire.org Git - thirdparty/glibc.git/blob - iconv/gconv.h
Update.
[thirdparty/glibc.git] / iconv / gconv.h
1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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. */
18
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. */
22
23 #ifndef _GCONV_H
24 #define _GCONV_H 1
25
26 #include <features.h>
27 #include <wchar.h>
28 #define __need_size_t
29 #include <stddef.h>
30
31 /* ISO 10646 value used to signal invalid value. */
32 #define UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
33
34 /* Error codes for gconv functions. */
35 enum
36 {
37 GCONV_OK = 0,
38 GCONV_NOCONV,
39 GCONV_NODB,
40 GCONV_NOMEM,
41
42 GCONV_EMPTY_INPUT,
43 GCONV_FULL_OUTPUT,
44 GCONV_ILLEGAL_INPUT,
45 GCONV_INCOMPLETE_INPUT,
46
47 GCONV_ILLEGAL_DESCRIPTOR,
48 GCONV_INTERNAL_ERROR
49 };
50
51
52 /* Forward declarations. */
53 struct gconv_step;
54 struct gconv_step_data;
55 struct gconv_loaded_object;
56
57
58 /* Type of a conversion function. */
59 typedef int (*gconv_fct) __P ((struct gconv_step *,
60 struct gconv_step_data *, __const char **,
61 __const char *, size_t *, int));
62
63 /* Constructor and destructor for local data for conversion step. */
64 typedef int (*gconv_init_fct) __P ((struct gconv_step *));
65 typedef void (*gconv_end_fct) __P ((struct gconv_step *));
66
67
68 /* Description of a conversion step. */
69 struct gconv_step
70 {
71 struct gconv_loaded_object *shlib_handle;
72 const char *modname;
73
74 int counter;
75
76 __const char *from_name;
77 __const char *to_name;
78
79 gconv_fct fct;
80 gconv_init_fct init_fct;
81 gconv_end_fct end_fct;
82
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;
89
90 /* Flag whether this is a stateful encoding or not. */
91 int stateful;
92
93 void *data; /* Pointer to step-local data. */
94 };
95
96 /* Additional data for steps in use of conversion descriptor. This is
97 allocated by the `init' function. */
98 struct gconv_step_data
99 {
100 char *outbuf; /* Output buffer for this step. */
101 char *outbufend; /* Address of first byte after the output buffer. */
102
103 int is_last;
104
105 mbstate_t *statep;
106 mbstate_t __state; /* This element should not be used directly by
107 any module; always use STATEP! */
108 };
109
110
111 /* Combine conversion step description with data. */
112 typedef struct gconv_info
113 {
114 size_t nsteps;
115 struct gconv_step *steps;
116 struct gconv_step_data *data;
117 } *gconv_t;
118
119 #endif /* gconv.h */