ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
strings.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 #ifndef __EKG_STRINGS_H
4 #define __EKG_STRINGS_H
5 
6 /*
7  * (C) Copyright 2003-2006 Maciej Pietrzak <maciej@hell.org.pl>
8  * Jakub Zawadzki <darkjames@darkjames.ath.cx>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License Version 2 as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23 
24 #include "ekg2-config.h"
25 
26 
27 #if USE_UNICODE
28 
29 #include <wchar.h> /* wchar_t stuff */
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 extern int config_use_unicode; /* not everyone want to include stuff.h */
36 
37 #define CHAR_T wchar_t
38 #define TEXT(x) (wchar_t *) L##x
39 #define CHAR(x) (wchar_t) L##x
40 #define STRING_FORMAT "%ls"
41 #define CHAR_FORMAT "%lc"
42 
43 extern size_t xwcslen(const CHAR_T *str);
44 extern size_t xmbslen(const char *str);
45 extern CHAR_T *xwcscpy(CHAR_T *dst, CHAR_T *src);
46 extern CHAR_T *xwcsdup(CHAR_T *str);
47 extern CHAR_T *xwcscat(CHAR_T *dst, const CHAR_T *src);
48 extern int xwcscmp(const CHAR_T *s1, const CHAR_T *s2);
49 extern CHAR_T *xwcschr(const CHAR_T *s, CHAR_T c);
50 extern char *wcs_to_normal(const CHAR_T *str);
51 extern CHAR_T *normal_to_wcs(const char *str);
52 extern CHAR_T **wcs_array_make(const CHAR_T *string, const CHAR_T *sep, int max, int trim, int quotes);
53 extern CHAR_T *wcs_array_join(CHAR_T **array, const CHAR_T *sep);
54 extern size_t xwcslcpy(CHAR_T *dst, const CHAR_T *src, size_t size);
55 
56 #define free_utf(x) xfree(x)
57 
58 #else /* USE_UNICODE */
59 
60 #include <ekg/xmalloc.h>
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 #define CHAR_T unsigned char
67 #define TEXT(x) x
68 #define CHAR(x) x
69 #define STRING_FORMAT "%s"
70 #define CHAR_FORMAT "%c"
71 
72 #define xwcslen(str) xstrlen((char *) str)
73 #define xmbslen(str) xstrlen(str)
74 #define xwcscpy(dst, str) xstrcpy((char *) dst, (char *) str)
75 #define xwcsdup(str) (CHAR_T *) xstrdup((char *) str)
76 #define xwcscat(dst, src) xstrcat((char *) dst, (char *) src)
77 #define xwcscmp(s1, s2) xstrcmp((char *) s1, (char *) s2)
78 #define xwcschr(s, c) xstrchr((char *) s, c)
79 #define wcs_to_normal(x) (char *) x
80 #define wcs_array_make(str, sep, max, trim, quotes) (CHAR_T **) array_make((char *) str, sep, max, trim, quotes)
81 #define wcs_array_join(arr, sep) (CHAR_T *) array_join((char **) arr, sep)
82 #define xwcslcpy(dst, src, size) strlcpy((char *) dst, (char *) src, size)
83 #define free_utf(x)
84 
85 #endif /* USE_UNICODE */
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* __EKG_STRINGS_H */