]> git.decadent.org.uk Git - ion3.git/blob - ioncore/dummywc.h
6d1a4913ad8fcd3680554091974249ccfb7d2bfe
[ion3.git] / ioncore / dummywc.h
1 /*
2  * ion/ioncore/dummywc.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 /* This file contains dummy implementations of multibyte/widechar routines
13  * used by Ion for retarded platforms.
14  */
15
16 #ifndef ION_IONCORE_DUMMYWC_H
17 #define ION_IONCORE_DUMMYWC_H
18
19 #include <string.h>
20 #include <ctype.h>
21
22 #define wchar_t int
23 #define mbstate_t int
24
25 #define iswalnum isalnum
26 #define iswprint isprint
27 #define iswspace isspace
28
29 #define mbrlen dummywc_mbrlen
30 #define mbtowc dummywc_mbtowc
31 #define mbrtowc dummywc_mbrtowc
32
33 static size_t dummywc_mbrlen(const char *s, size_t n, mbstate_t *ps)
34 {
35     if(*s=='\0')
36         return 0;
37     return 1;
38 }
39
40 static int dummywc_mbtowc(wchar_t *pwc, const char *s, size_t n)
41 {
42     if(n>0 && *s!='\0'){
43         *pwc=*s;
44         return 1;
45     }
46     return 0;
47 }
48
49 static size_t dummywc_mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
50 {
51     return mbtowc(pwc, s, n);
52 }
53
54 #endif /* ION_IONCORE_DUMMYWC_H */
55