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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [iconv/] [ces/] [table-pcs.c] - Blame information for rev 301

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3
 * modification, are permitted provided that the following conditions
4
 * are met:
5
 * 1. Redistributions of source code must retain the above copyright
6
 *    notice, this list of conditions and the following disclaimer.
7
 * 2. Redistributions in binary form must reproduce the above copyright
8
 *    notice, this list of conditions and the following disclaimer in the
9
 *    documentation and/or other materials provided with the distribution.
10
 *
11
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
12
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
16
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
17
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
19
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
20
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21
 * SUCH DAMAGE.
22
 */
23
 
24
/*
25
 * This CES converter is just an simple extension of table CES converter.
26
 * This CES converter is used for 16 bit CCSes which include 7bit
27
 * Portable Characters Set (PCS) (equivalent to ASCII) (example: BIG5).
28
 */
29
 
30
#include "cesbi.h"
31
 
32
#if defined (ICONV_TO_UCS_CES_TABLE_PCS) \
33
 || defined (ICONV_FROM_UCS_CES_TABLE_PCS)
34
 
35
#include <_ansi.h>
36
#include <reent.h>
37
#include <sys/types.h>
38
#include "../lib/local.h"
39
#include "../lib/ucsconv.h"
40
 
41
#if defined (ICONV_FROM_UCS_CES_TABLE_PCS)
42
static size_t
43
_DEFUN(table_pcs_convert_from_ucs, (data, in, outbuf, outbytesleft),
44
                               _VOID_PTR data         _AND
45
                               ucs4_t in              _AND
46
                               unsigned char **outbuf _AND
47
                               size_t *outbytesleft)
48
{
49
  if (*outbytesleft < 1)
50
    return (size_t)ICONV_CES_NOSPACE;
51
 
52
  if (in  < 0x80)
53
    {
54
      **outbuf = (unsigned char)in;
55
      *outbuf += 1;
56
      *outbytesleft -= 1;
57
      return 1;
58
    }
59
 
60
  return _iconv_from_ucs_ces_handlers_table.convert_from_ucs (
61
                                                    data,
62
                                                    in,
63
                                                    outbuf,
64
                                                    outbytesleft);
65
}
66
 
67
static _VOID_PTR
68
_DEFUN(table_pcs_from_ucs_init, (rptr, encoding),
69
                                struct _reent *rptr _AND
70
                                _CONST char *encoding)
71
{
72
  return _iconv_from_ucs_ces_handlers_table.init (rptr, encoding);
73
}
74
 
75
static size_t
76
_DEFUN(table_pcs_from_ucs_close, (rptr, data),
77
                                 struct _reent *rptr _AND
78
                                 _VOID_PTR data)
79
{
80
  return _iconv_from_ucs_ces_handlers_table.close (rptr, data);
81
}
82
 
83
static int
84
_DEFUN(table_pcs_from_ucs_get_mb_cur_max, (data),
85
                                           _VOID_PTR data)
86
{
87
  return _iconv_from_ucs_ces_handlers_table.get_mb_cur_max (data);
88
}
89
 
90
#endif /* ICONV_FROM_UCS_CES_TABLE_PCS */
91
 
92
#if defined (ICONV_TO_UCS_CES_TABLE_PCS)
93
static ucs4_t
94
_DEFUN(table_pcs_convert_to_ucs, (data, inbuf, inbytesleft),
95
                             _VOID_PTR data               _AND
96
                             _CONST unsigned char **inbuf _AND
97
                             size_t *inbytesleft)
98
{
99
  if (*inbytesleft < 1)
100
    return (ucs4_t)ICONV_CES_BAD_SEQUENCE;
101
 
102
  if (**inbuf < 0x80)
103
    {
104
      *inbytesleft -= 1;
105
      *inbuf += 1;
106
      return (ucs4_t)(*(*inbuf - 1));
107
    }
108
 
109
  return _iconv_to_ucs_ces_handlers_table.convert_to_ucs (
110
                                                             data,
111
                                                             inbuf,
112
                                                             inbytesleft);
113
}
114
 
115
static _VOID_PTR
116
_DEFUN(table_pcs_to_ucs_init, (rptr, encoding),
117
                              struct _reent *rptr _AND
118
                              _CONST char *encoding)
119
{
120
  return _iconv_to_ucs_ces_handlers_table.init (rptr, encoding);
121
}
122
 
123
static size_t
124
_DEFUN(table_pcs_to_ucs_close, (rptr, data),
125
                               struct _reent *rptr _AND
126
                               _VOID_PTR data)
127
{
128
  return _iconv_to_ucs_ces_handlers_table.close (rptr, data);
129
}
130
 
131
static int
132
_DEFUN(table_pcs_to_ucs_get_mb_cur_max, (data),
133
                                         _VOID_PTR data)
134
{
135
  return _iconv_to_ucs_ces_handlers_table.get_mb_cur_max (data);
136
}
137
 
138
#endif /* ICONV_TO_UCS_CES_TABLE_PCS */
139
 
140
#if defined (ICONV_FROM_UCS_CES_TABLE_PCS)
141
_CONST iconv_from_ucs_ces_handlers_t
142
_iconv_from_ucs_ces_handlers_table_pcs =
143
{
144
  table_pcs_from_ucs_init,
145
  table_pcs_from_ucs_close,
146
  table_pcs_from_ucs_get_mb_cur_max,
147
  NULL,
148
  NULL,
149
  NULL,
150
  table_pcs_convert_from_ucs
151
};
152
#endif
153
 
154
#if defined (ICONV_TO_UCS_CES_TABLE_PCS)
155
_CONST iconv_to_ucs_ces_handlers_t
156
_iconv_to_ucs_ces_handlers_table_pcs =
157
{
158
  table_pcs_to_ucs_init,
159
  table_pcs_to_ucs_close,
160
  table_pcs_to_ucs_get_mb_cur_max,
161
  NULL,
162
  NULL,
163
  NULL,
164
  table_pcs_convert_to_ucs
165
};
166
#endif
167
 
168
#endif /* ICONV_TO_UCS_CES_TABLE_PCS || ICONV_FROM_UCS_CES_TABLE_PCS */
169
 

powered by: WebSVN 2.1.0

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