1 /* $NetBSD: src/lib/libc/locale/multibyte_amd1.c,v 1.5 2003/03/05 20:18:16 tshiozak Exp $ */
2 /* $DragonFly: src/lib/libc/locale/multibyte_amd1.c,v 1.1 2005/03/16 06:54:41 joerg Exp $ */
5 * Copyright (c)2002 Citrus Project,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/types.h>
34 #include "../citrus/citrus_module.h"
35 #include "../citrus/citrus_ctype.h"
37 #include "multibyte.h"
40 mbrlen(const char *s
, size_t n
, mbstate_t *ps
)
45 _fixup_ps(_CurrentRuneLocale
, ps
, s
== NULL
);
47 err0
= _citrus_ctype_mbrlen(_ps_to_ctype(ps
), s
, n
,
48 _ps_to_private(ps
), &ret
);
56 mbsinit(const mbstate_t *ps
)
65 if (_ps_to_runelocale(ps
) == NULL
)
66 rl
= _CurrentRuneLocale
;
68 rl
= _ps_to_runelocale(ps
);
70 /* mbsinit should cause no error... */
71 err0
= _citrus_ctype_mbsinit(rl
->rl_citrus_ctype
,
72 _ps_to_private_const(ps
), &ret
);
80 mbrtowc(wchar_t *pwc
, const char *s
, size_t n
, mbstate_t *ps
)
85 _fixup_ps(_CurrentRuneLocale
, ps
, s
==NULL
);
87 err0
= _citrus_ctype_mbrtowc(_ps_to_ctype(ps
), pwc
, s
, n
,
88 _ps_to_private(ps
), &ret
);
96 mbsrtowcs(wchar_t *pwcs
, const char **s
, size_t n
, mbstate_t *ps
)
101 _fixup_ps(_CurrentRuneLocale
, ps
, s
==NULL
);
103 err0
= _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps
), pwcs
, s
, n
,
104 _ps_to_private(ps
), &ret
);
112 wcrtomb(char *s
, wchar_t wc
, mbstate_t *ps
)
117 _fixup_ps(_CurrentRuneLocale
, ps
, s
==NULL
);
119 err0
= _citrus_ctype_wcrtomb(_ps_to_ctype(ps
), s
, wc
,
120 _ps_to_private(ps
), &ret
);
128 wcsrtombs(char *s
, const wchar_t **ppwcs
, size_t n
, mbstate_t *ps
)
133 _fixup_ps(_CurrentRuneLocale
, ps
, s
==NULL
);
135 err0
= _citrus_ctype_wcsrtombs(_ps_to_ctype(ps
), s
, ppwcs
, n
,
136 _ps_to_private(ps
), &ret
);
149 err0
= _citrus_ctype_btowc(_to_cur_ctype(), c
, &ret
);
162 err0
= _citrus_ctype_wctob(_to_cur_ctype(), wc
, &ret
);