xref: /haiku/src/system/libroot/posix/glibc/wcsmbs/wcsmbsload.c (revision 23d878482ed22e55dad6d1fca1df7bea42eb157c)
1 /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19 
20 #include <limits.h>
21 
22 #include <locale/localeinfo.h>
23 #include <wcsmbsload.h>
24 #include <iconv/gconv_int.h>
25 
26 
27 /* These are the descriptions for the default conversion functions.  */
28 static struct __gconv_step to_wc =
29 {
30   .__shlib_handle = NULL,
31   .__modname = NULL,
32   .__counter = INT_MAX,
33   .__from_name = (char *) "MULTIBYTE",
34   .__to_name = (char *) "WCHAR",
35   .__fct = __gconv_transform_multibyte_wchar,
36   .__init_fct = NULL,
37   .__end_fct = NULL,
38   .__min_needed_from = 1,
39   .__max_needed_from = MB_LEN_MAX,
40   .__min_needed_to = 4,
41   .__max_needed_to = 4,
42   .__stateful = 0,
43   .__data = NULL
44 };
45 
46 static struct __gconv_step to_mb =
47 {
48   .__shlib_handle = NULL,
49   .__modname = NULL,
50   .__counter = INT_MAX,
51   .__from_name = (char *) "WCHAR",
52   .__to_name = (char *) "MULTIBYTE",
53   .__fct = __gconv_transform_wchar_multibyte,
54   .__init_fct = NULL,
55   .__end_fct = NULL,
56   .__min_needed_from = 4,
57   .__max_needed_from = 4,
58   .__min_needed_to = 1,
59   .__max_needed_to = MB_LEN_MAX,
60   .__stateful = 0,
61   .__data = NULL
62 };
63 
64 
65 /* For the default locale we only have to handle ANSI_X3.4-1968.  */
66 struct gconv_fcts __wcsmbs_gconv_fcts =
67 {
68   .towc = &to_wc,
69   .towc_nsteps = 1,
70   .tomb = &to_mb,
71   .tomb_nsteps = 1
72 };
73 
74 
75 /* Clone the current conversion function set.  */
76 void
77 internal_function
78 __wcsmbs_clone_conv (struct gconv_fcts *copy)
79 {
80   /* Copy the data.  */
81   *copy = __wcsmbs_gconv_fcts;
82 }
83