| 1 |
148 |
jeremybenn |
/* Copyright (C) 1997, 1998, 1999, 2000, 2001 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 Lesser General Public
|
| 6 |
|
|
License as published by the Free Software Foundation; either
|
| 7 |
|
|
version 2.1 of the 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 |
|
|
Lesser General Public License for more details.
|
| 13 |
|
|
|
| 14 |
|
|
You should have received a copy of the GNU Lesser General Public
|
| 15 |
|
|
License along with the GNU C Library; if not, write to the Free
|
| 16 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
| 17 |
|
|
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 |
|
|
#define __need_mbstate_t
|
| 28 |
|
|
#include <wchar.h>
|
| 29 |
|
|
#define __need_size_t
|
| 30 |
|
|
#define __need_wchar_t
|
| 31 |
|
|
#include <stddef.h>
|
| 32 |
|
|
|
| 33 |
|
|
/* ISO 10646 value used to signal invalid value. */
|
| 34 |
|
|
#define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
|
| 35 |
|
|
|
| 36 |
|
|
/* Error codes for gconv functions. */
|
| 37 |
|
|
enum
|
| 38 |
|
|
{
|
| 39 |
|
|
__GCONV_OK = 0,
|
| 40 |
|
|
__GCONV_NOCONV,
|
| 41 |
|
|
__GCONV_NODB,
|
| 42 |
|
|
__GCONV_NOMEM,
|
| 43 |
|
|
|
| 44 |
|
|
__GCONV_EMPTY_INPUT,
|
| 45 |
|
|
__GCONV_FULL_OUTPUT,
|
| 46 |
|
|
__GCONV_ILLEGAL_INPUT,
|
| 47 |
|
|
__GCONV_INCOMPLETE_INPUT,
|
| 48 |
|
|
|
| 49 |
|
|
__GCONV_ILLEGAL_DESCRIPTOR,
|
| 50 |
|
|
__GCONV_INTERNAL_ERROR
|
| 51 |
|
|
};
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
/* Flags the `__gconv_open' function can set. */
|
| 55 |
|
|
enum
|
| 56 |
|
|
{
|
| 57 |
|
|
__GCONV_IS_LAST = 0x0001,
|
| 58 |
|
|
__GCONV_IGNORE_ERRORS = 0x0002
|
| 59 |
|
|
};
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
/* Forward declarations. */
|
| 63 |
|
|
struct __gconv_step;
|
| 64 |
|
|
struct __gconv_step_data;
|
| 65 |
|
|
struct __gconv_loaded_object;
|
| 66 |
|
|
struct __gconv_trans_data;
|
| 67 |
|
|
|
| 68 |
|
|
|
| 69 |
|
|
/* Type of a conversion function. */
|
| 70 |
|
|
typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *,
|
| 71 |
|
|
__const unsigned char **, __const unsigned char *,
|
| 72 |
|
|
unsigned char **, size_t *, int, int);
|
| 73 |
|
|
|
| 74 |
|
|
/* Constructor and destructor for local data for conversion step. */
|
| 75 |
|
|
typedef int (*__gconv_init_fct) (struct __gconv_step *);
|
| 76 |
|
|
typedef void (*__gconv_end_fct) (struct __gconv_step *);
|
| 77 |
|
|
|
| 78 |
|
|
|
| 79 |
|
|
/* Type of a transliteration/transscription function. */
|
| 80 |
|
|
typedef int (*__gconv_trans_fct) (struct __gconv_step *,
|
| 81 |
|
|
struct __gconv_step_data *, void *,
|
| 82 |
|
|
__const unsigned char *,
|
| 83 |
|
|
__const unsigned char **,
|
| 84 |
|
|
__const unsigned char *, unsigned char **,
|
| 85 |
|
|
size_t *);
|
| 86 |
|
|
|
| 87 |
|
|
/* Function to call to provide transliteration module with context. */
|
| 88 |
|
|
typedef int (*__gconv_trans_context_fct) (void *, __const unsigned char *,
|
| 89 |
|
|
__const unsigned char *,
|
| 90 |
|
|
unsigned char *, unsigned char *);
|
| 91 |
|
|
|
| 92 |
|
|
/* Function to query module about supported encoded character sets. */
|
| 93 |
|
|
typedef int (*__gconv_trans_query_fct) (__const char *, __const char ***,
|
| 94 |
|
|
size_t *);
|
| 95 |
|
|
|
| 96 |
|
|
/* Constructor and destructor for local data for transliteration. */
|
| 97 |
|
|
typedef int (*__gconv_trans_init_fct) (void **, const char *);
|
| 98 |
|
|
typedef void (*__gconv_trans_end_fct) (void *);
|
| 99 |
|
|
|
| 100 |
|
|
struct __gconv_trans_data
|
| 101 |
|
|
{
|
| 102 |
|
|
/* Transliteration/Transscription function. */
|
| 103 |
|
|
__gconv_trans_fct __trans_fct;
|
| 104 |
|
|
__gconv_trans_context_fct __trans_context_fct;
|
| 105 |
|
|
__gconv_trans_end_fct __trans_end_fct;
|
| 106 |
|
|
void *__data;
|
| 107 |
|
|
struct __gconv_trans_data *__next;
|
| 108 |
|
|
};
|
| 109 |
|
|
|
| 110 |
|
|
|
| 111 |
|
|
/* Description of a conversion step. */
|
| 112 |
|
|
struct __gconv_step
|
| 113 |
|
|
{
|
| 114 |
|
|
struct __gconv_loaded_object *__shlib_handle;
|
| 115 |
|
|
__const char *__modname;
|
| 116 |
|
|
|
| 117 |
|
|
int __counter;
|
| 118 |
|
|
|
| 119 |
|
|
char *__from_name;
|
| 120 |
|
|
char *__to_name;
|
| 121 |
|
|
|
| 122 |
|
|
__gconv_fct __fct;
|
| 123 |
|
|
__gconv_init_fct __init_fct;
|
| 124 |
|
|
__gconv_end_fct __end_fct;
|
| 125 |
|
|
|
| 126 |
|
|
/* Information about the number of bytes needed or produced in this
|
| 127 |
|
|
step. This helps optimizing the buffer sizes. */
|
| 128 |
|
|
int __min_needed_from;
|
| 129 |
|
|
int __max_needed_from;
|
| 130 |
|
|
int __min_needed_to;
|
| 131 |
|
|
int __max_needed_to;
|
| 132 |
|
|
|
| 133 |
|
|
/* Flag whether this is a stateful encoding or not. */
|
| 134 |
|
|
int __stateful;
|
| 135 |
|
|
|
| 136 |
|
|
void *__data; /* Pointer to step-local data. */
|
| 137 |
|
|
};
|
| 138 |
|
|
|
| 139 |
|
|
/* Additional data for steps in use of conversion descriptor. This is
|
| 140 |
|
|
allocated by the `init' function. */
|
| 141 |
|
|
struct __gconv_step_data
|
| 142 |
|
|
{
|
| 143 |
|
|
unsigned char *__outbuf; /* Output buffer for this step. */
|
| 144 |
|
|
unsigned char *__outbufend; /* Address of first byte after the output
|
| 145 |
|
|
buffer. */
|
| 146 |
|
|
|
| 147 |
|
|
/* Is this the last module in the chain. */
|
| 148 |
|
|
int __flags;
|
| 149 |
|
|
|
| 150 |
|
|
/* Counter for number of invocations of the module function for this
|
| 151 |
|
|
descriptor. */
|
| 152 |
|
|
int __invocation_counter;
|
| 153 |
|
|
|
| 154 |
|
|
/* Flag whether this is an internal use of the module (in the mb*towc*
|
| 155 |
|
|
and wc*tomb* functions) or regular with iconv(3). */
|
| 156 |
|
|
int __internal_use;
|
| 157 |
|
|
|
| 158 |
|
|
mbstate_t *__statep;
|
| 159 |
|
|
mbstate_t __state; /* This element must not be used directly by
|
| 160 |
|
|
any module; always use STATEP! */
|
| 161 |
|
|
|
| 162 |
|
|
/* Transliteration information. */
|
| 163 |
|
|
struct __gconv_trans_data *__trans;
|
| 164 |
|
|
};
|
| 165 |
|
|
|
| 166 |
|
|
|
| 167 |
|
|
/* Combine conversion step description with data. */
|
| 168 |
|
|
typedef struct __gconv_info
|
| 169 |
|
|
{
|
| 170 |
|
|
size_t __nsteps;
|
| 171 |
|
|
struct __gconv_step *__steps;
|
| 172 |
|
|
__extension__ struct __gconv_step_data __data __flexarr;
|
| 173 |
|
|
} *__gconv_t;
|
| 174 |
|
|
|
| 175 |
|
|
#endif /* gconv.h */
|