1 /* $MirOS: src/lib/libc/i18n/mbrlen.c,v 1.5 2014/02/09 22:35:52 tg Exp $ */
2
3 /*-
4 * Copyright (c) 2006
5 * Thorsten Glaser <tg@mirbsd.de>
6 *
7 * Provided that these terms and disclaimer and all copyright notices
8 * are retained or reproduced in an accompanying document, permission
9 * is granted to deal in this work without restriction, including un-
10 * limited rights to use, publicly perform, distribute, sell, modify,
11 * merge, give away, or sublicence.
12 *
13 * Advertising materials mentioning features or use of this work must
14 * display the following acknowledgement:
15 * This product includes material provided by Thorsten Glaser.
16 *
17 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
18 * the utmost extent permitted by applicable law, neither express nor
19 * implied; without malicious intent or gross negligence. In no event
20 * may a licensor, author or contributor be held liable for indirect,
21 * direct, other damage, loss, or other issues arising in any way out
22 * of dealing in the work, even if advised of the possibility of such
23 * damage or existence of a defect, except proven that it results out
24 * of said person's immediate fault when using the work as intended.
25 */
26
27 #include <wchar.h>
28
29 __RCSID("$MirOS: src/lib/libc/i18n/mbrlen.c,v 1.5 2014/02/09 22:35:52 tg Exp $");
30
31 size_t
mbrlen(const char * s,size_t n,mbstate_t * ps)32 mbrlen(const char *s, size_t n, mbstate_t *ps)
33 {
34 static mbstate_t internal = { 0, 0 };
35
36 return (mbrtowc(NULL, s, n, (ps == NULL) ? &internal : ps));
37 }
38