ekg2
|
00001 /* $Id: strings.h 4412 2008-08-17 12:28:15Z peres $ */ 00002 00003 #ifndef __EKG_STRINGS_H 00004 #define __EKG_STRINGS_H 00005 00006 /* 00007 * (C) Copyright 2003-2006 Maciej Pietrzak <maciej@hell.org.pl> 00008 * Jakub Zawadzki <darkjames@darkjames.ath.cx> 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License Version 2 as 00012 * published by the Free Software Foundation. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00022 */ 00023 00024 #include "ekg2-config.h" 00025 00026 00027 #if USE_UNICODE 00028 00029 #include <wchar.h> /* wchar_t stuff */ 00030 00031 extern int config_use_unicode; /* not everyone want to include stuff.h */ 00032 00033 #define CHAR_T wchar_t 00034 #define TEXT(x) (wchar_t *) L##x 00035 #define CHAR(x) (wchar_t) L##x 00036 #define STRING_FORMAT "%ls" 00037 #define CHAR_FORMAT "%lc" 00038 00039 extern size_t xwcslen(const CHAR_T *str); 00040 extern size_t xmbslen(const char *str); 00041 extern CHAR_T *xwcscpy(CHAR_T *dst, CHAR_T *src); 00042 extern CHAR_T *xwcsdup(CHAR_T *str); 00043 extern CHAR_T *xwcscat(CHAR_T *dst, const CHAR_T *src); 00044 extern int xwcscmp(const CHAR_T *s1, const CHAR_T *s2); 00045 extern CHAR_T *xwcschr(const CHAR_T *s, CHAR_T c); 00046 extern char *wcs_to_normal(const CHAR_T *str); 00047 extern CHAR_T *normal_to_wcs(const char *str); 00048 extern CHAR_T **wcs_array_make(const CHAR_T *string, const CHAR_T *sep, int max, int trim, int quotes); 00049 extern CHAR_T *wcs_array_join(CHAR_T **array, const CHAR_T *sep); 00050 extern size_t xwcslcpy(CHAR_T *dst, const CHAR_T *src, size_t size); 00051 00052 #define free_utf(x) xfree(x) 00053 00054 #else /* USE_UNICODE */ 00055 00056 #include "xmalloc.h" 00057 00058 #define CHAR_T unsigned char 00059 #define TEXT(x) x 00060 #define CHAR(x) x 00061 #define STRING_FORMAT "%s" 00062 #define CHAR_FORMAT "%c" 00063 00064 #define xwcslen(str) xstrlen((char *) str) 00065 #define xmbslen(str) xstrlen(str) 00066 #define xwcscpy(dst, str) xstrcpy((char *) dst, (char *) str) 00067 #define xwcsdup(str) (CHAR_T *) xstrdup((char *) str) 00068 #define xwcscat(dst, src) xstrcat((char *) dst, (char *) src) 00069 #define xwcscmp(s1, s2) xstrcmp((char *) s1, (char *) s2) 00070 #define xwcschr(s, c) xstrchr((char *) s, c) 00071 #define wcs_to_normal(x) (char *) x 00072 #define wcs_array_make(str, sep, max, trim, quotes) (CHAR_T **) array_make((char *) str, sep, max, trim, quotes) 00073 #define wcs_array_join(arr, sep) (CHAR_T *) array_join((char **) arr, sep) 00074 #define xwcslcpy(dst, src, size) strlcpy((char *) dst, (char *) src, size) 00075 #define free_utf(x) 00076 00077 #endif /* USE_UNICODE */ 00078 00079 00080 #endif /* __EKG_STRINGS_H */