OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [iconv/] [lib/] [ucsconv.h] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3
 * Copyright (c) 1999,2000, Konstantin Chuguev. All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
#ifndef __ICONV_UCS_CONVERSION_H__
27
#define __ICONV_UCS_CONVERSION_H__
28
 
29
#include <_ansi.h>
30
#include <reent.h>
31
#include <sys/types.h>
32
#include <wchar.h>
33
#include "local.h"
34
 
35
/* No enough space in output buffer */
36
#define ICONV_CES_NOSPACE 0
37
/* Invalid input character */
38
#define ICONV_CES_INVALID_CHARACTER -1
39
/* No corespondent character in destination encoding */
40
#define ICONV_CES_BAD_SEQUENCE -2
41
/* All unknown characters are marked by this code */
42
#define DEFAULT_CHARACTER 0x3f /* ASCII '?' */
43
 
44
 
45
/*
46
 * iconv_to_ucs_ces_handlers_t - "to UCS" CES converter handlers.
47
 *
48
 * Structure contains function pointers which should be provided by
49
 * "to_ucs" CES converter.
50
 *
51
 * ============================================================================
52
 */
53
typedef struct
54
{
55
  /*
56
   * init - initialize CES converter.
57
   *
58
   * PARAMETERS:
59
   *   struct _reent *rptr   - reent structure of current thread/process;
60
   *   _CONST char *encoding - encoding name.
61
   *
62
   * DESCRIPTION:
63
   *  Initializes CES converter. CES converter may deal with a series of
64
   *  encodings, such as Table or EUC CES converters. 'encoding' parameter
65
   *  indicates which encoding CES converter should use.
66
   *
67
   * RETURN:
68
   *   Returns CES-specific data pointer if success. In case of error returns
69
   *   NULL and sets current thread's/process's errno.
70
   */
71
  _VOID_PTR _EXFNPTR(init, (struct _reent *rptr,
72
                          _CONST char *encoding));
73
 
74
  /*
75
   * close - close CES converter.
76
   *
77
   * PARAMETERS:
78
   *   struct _reent *rptr - reent structure of current thread/process;
79
   *   _VOID_PTR data      - CES converter-specific data.
80
   *
81
   * DESCRIPTION:
82
   *     Preforms CES converter closing.   *
83
   * RETURN:
84
   *   Returns (size_t)0 if success. In case of error returns (size_t)-1 and
85
   *   sets current thread's/process's errno.
86
   */
87
  size_t _EXFNPTR(close, (struct _reent *rptr,
88
                        _VOID_PTR data));
89
 
90
  /*
91
   * get_mb_cur_max - get maximum character length in bytes.
92
   *
93
   * PARAMETERS:
94
   *   _VOID_PTR data     - conversion-specific data;
95
   *
96
   * DESCRIPTION:
97
   *   Returns encoding's maximum character length.
98
   */
99
  int _EXFNPTR(get_mb_cur_max, (_VOID_PTR data));
100
 
101
  /*
102
   * get_state - get current shift state.
103
   *
104
   * PARAMETERS:
105
   *   _VOID_PTR data   - conversion-specific data;
106
   *   mbstate_t *state - mbstate_t object where shift state will be stored;
107
   *
108
   * DESCRIPTION:
109
   *   Returns encoding's current shift sequence.
110
   */
111
  _VOID _EXFNPTR(get_state, (_VOID_PTR data,
112
                           mbstate_t *state));
113
 
114
  /*
115
   * set_state - set shift state.
116
   *
117
   * PARAMETERS:
118
   *   _VOID_PTR data   - conversion-specific data;
119
   *   mbstate_t *state - mbstate_t value to which shift state will be set.
120
   *
121
   * DESCRIPTION:
122
   *   Sets encoding's current shift state to 'state'. if 'state'
123
   *   object is zero-object - reset current shift state.
124
   *   Returns 0 if '*state' object has right format, -1 else.
125
   */
126
  int _EXFNPTR(set_state, (_VOID_PTR data,
127
                         mbstate_t *state));
128
 
129
  /*
130
   * is_stateful - is encoding stateful state.
131
   *
132
   * PARAMETERS:
133
   *   _VOID_PTR data   - conversion-specific data;
134
   *
135
   * DESCRIPTION:
136
   *   Returns 0 if encoding is stateless, else returns 1.
137
   */
138
  int _EXFNPTR(is_stateful, (_VOID_PTR data));
139
 
140
  /*
141
   * convert_to_ucs - convert character to UCS.
142
   *
143
   * PARAMETERS:
144
   *   _VOID_PTR data               - CES converter-specific data;
145
   *   _CONST unsigned char **inbuf - buffer with input character byte sequence;
146
   *   size_t *inbytesleft          - output buffer bytes count.
147
   *
148
   * DESCRIPTION:
149
   *   Converts input characters into UCS encoding. 'inbuf' is
150
   *   incremented accordingly. 'bytesleft' is decremented accordingly. Should
151
   *   be provided by correspondent CES module.
152
   *
153
   * RETURN:
154
   *   Returns resulting UCS code if success. If input character is invalid,
155
   *   returns ICONV_CES_INVALID_CHARACTER. If invalid or incomplete bytes
156
   *   sequence was met, returns ICONV_CES_BAD_SEQUENCE.
157
   */
158
  ucs4_t _EXFNPTR(convert_to_ucs, (_VOID_PTR data,
159
                                 _CONST unsigned char **inbuf,
160
                                 size_t *inbytesleft));
161
} iconv_to_ucs_ces_handlers_t;
162
 
163
 
164
/*
165
 * iconv_from_ucs_ces_handlers_t - "from UCS" CES converter handlers.
166
 *
167
 * Structure contains function pointers which should be provided by
168
 * "from_ucs" CES converter.
169
 *
170
 * ============================================================================
171
 */
172
typedef struct
173
{
174
  /* Same as in iconv_to_ucs_ces_handlers_t */
175
  _VOID_PTR _EXFNPTR(init, (struct _reent *rptr,
176
                          _CONST char *encoding));
177
 
178
  /* Same as in iconv_to_ucs_ces_handlers_t */
179
  size_t _EXFNPTR(close, (struct _reent *rptr,
180
                        _VOID_PTR data));
181
 
182
  /* Same as in iconv_to_ucs_ces_handlers_t */
183
  int _EXFNPTR(get_mb_cur_max, (_VOID_PTR data));
184
 
185
  /* Same as in iconv_to_ucs_ces_handlers_t */
186
  _VOID _EXFNPTR(get_state, (_VOID_PTR data,
187
                           mbstate_t *state));
188
 
189
  /* Same as in iconv_to_ucs_ces_handlers_t */
190
  int _EXFNPTR(set_state, (_VOID_PTR data,
191
                         mbstate_t *state));
192
 
193
  /* Same as in iconv_to_ucs_ces_handlers_t */
194
  int _EXFNPTR(is_stateful, (_VOID_PTR data));
195
 
196
  /*
197
   * convert_from_ucs - convert UCS character to destination encoding.
198
   *
199
   * PARAMETERS:
200
   *   _VOID_PTR data         - CES converter-specific data;
201
   *   ucs4_t in              - input UCS-4 character;
202
   *   unsigned char **outbuf - output buffer for the result;
203
   *   size_t *outbytesleft   - output buffer bytes count.
204
   *
205
   * DESCRIPTION:
206
   *   Converts input UCS characters to destination encoding and stores result
207
   *   in 'outbuf' if there is sufficient free space present. 'outbuf' is
208
   *   incremented accordingly. 'outbytesleft' is decremented accordingly. Should
209
   *   be provided by correspondent CES module.
210
   *   Output buffer always has at least 1 byte.
211
   *
212
   * RETURN:
213
   *   Returns number of bytes that was written into output buffer if success.
214
   *   If there is no enough space in output buffer, returns ICONV_CES_NOSPACE.
215
   *   If there is no corresponding character in destination encoding, returns
216
   *   ICONV_CES_INVALID_CHARACTER.
217
   */
218
  size_t _EXFNPTR(convert_from_ucs, (_VOID_PTR data,
219
                                   ucs4_t in,
220
                                   unsigned char **outbuf,
221
                                   size_t *outbytesleft));
222
} iconv_from_ucs_ces_handlers_t;
223
 
224
 
225
/*
226
 * iconv_to_ucs_ces_desc_t - "to UCS" CES converter definition structure for
227
 * usage in iconv_ucs_conversion_t conversion description structure.
228
 *
229
 * ============================================================================
230
 */
231
typedef struct
232
{
233
  /* CES converter handlers */
234
  _CONST iconv_to_ucs_ces_handlers_t *handlers;
235
 
236
  /* "to_ucs" CES converter-specific data. */
237
  _VOID_PTR data;
238
} iconv_to_ucs_ces_desc_t;
239
 
240
 
241
/*
242
 * iconv_from_ucs_ces_desc_t - "from UCS" CES converter definition structure for
243
 * usage in iconv_ucs_conversion_t conversion description structure.
244
 *
245
 * ============================================================================
246
 */
247
typedef struct
248
{
249
  /* CES converter handlers */
250
  _CONST iconv_from_ucs_ces_handlers_t *handlers;
251
 
252
  /* "from_ucs" CES converter-specific data. */
253
  _VOID_PTR data;
254
} iconv_from_ucs_ces_desc_t;
255
 
256
 
257
/*
258
 * iconv_ucs_conversion_t - UCS-based conversion definition structure.
259
 *
260
 * Defines special type of conversion where every character is first
261
 * converted into UCS-4 (UCS-2 for table-driven), and after this the
262
 * resulting UCS character is converted to destination encoding.
263
 * UCS-based conversion is composed of two *converters*, defined by
264
 * iconv_ces_t structure. The iconv_ucs_conversion_t object is referred
265
 * from iconv_conversion_t object using 'data' field.
266
 *
267
 * Structure contains two objects - 'to_ucs' and 'from_ucs' which define
268
 * "source encoding to UCS" and "UCS to destination encoding" converters.
269
 *
270
 * ============================================================================
271
 */
272
typedef struct
273
{
274
  /* Source encoding -> CES converter. */
275
  iconv_to_ucs_ces_desc_t to_ucs;
276
 
277
  /* UCS -> destination encoding CES converter. */
278
  iconv_from_ucs_ces_desc_t from_ucs;
279
} iconv_ucs_conversion_t;
280
 
281
 
282
/*
283
 * iconv_to_ucs_ces_t - defines "to UCS" CES converter.
284
 *
285
 * ============================================================================
286
 */
287
typedef struct
288
{
289
  /*
290
   * An array of encodings names, supported by CES converter.
291
   * The end of array should be marked by NULL pointer.
292
   */
293
  _CONST char **names;
294
 
295
  /* CES converter description structure */
296
  _CONST iconv_to_ucs_ces_handlers_t *handlers;
297
} iconv_to_ucs_ces_t;
298
 
299
 
300
/*
301
 * iconv_from_ucs_ces_t - defines "from UCS" CES converter.
302
 *
303
 * ============================================================================
304
 */
305
typedef struct
306
{
307
  /*
308
   * An array of encodings names, supported by CES converter.
309
   * The end of array should be marked by NULL pointer.
310
   */
311
  _CONST char **names;
312
 
313
  /* CES converter description structure */
314
  _CONST iconv_from_ucs_ces_handlers_t *handlers;
315
} iconv_from_ucs_ces_t;
316
 
317
 
318
/* List of "to UCS" linked-in CES converters. */
319
extern _CONST iconv_to_ucs_ces_t
320
_iconv_to_ucs_ces[];
321
 
322
/* List of "from UCS" linked-in CES converters. */
323
extern _CONST iconv_from_ucs_ces_t
324
_iconv_from_ucs_ces[];
325
 
326
#endif /* !__ICONV_UCS_CONVERSION_H__ */
327
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.