ekg2
ekg/strings.h
Idź do dokumentacji tego pliku.
00001 /* $Id$ */
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 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 extern int config_use_unicode;  /* not everyone want to include stuff.h */
00036 
00037 #define CHAR_T wchar_t  
00038 #define TEXT(x) (wchar_t *) L##x
00039 #define CHAR(x) (wchar_t)   L##x
00040 #define STRING_FORMAT "%ls"
00041 #define CHAR_FORMAT "%lc"
00042 
00043 extern size_t xwcslen(const CHAR_T *str);
00044 extern size_t xmbslen(const char *str);
00045 extern CHAR_T *xwcscpy(CHAR_T *dst, CHAR_T *src);
00046 extern CHAR_T *xwcsdup(CHAR_T *str);
00047 extern CHAR_T *xwcscat(CHAR_T *dst, const CHAR_T *src);
00048 extern int xwcscmp(const CHAR_T *s1, const CHAR_T *s2);
00049 extern CHAR_T *xwcschr(const CHAR_T *s, CHAR_T c);
00050 extern char *wcs_to_normal(const CHAR_T *str);
00051 extern CHAR_T *normal_to_wcs(const char *str);
00052 extern CHAR_T **wcs_array_make(const CHAR_T *string, const CHAR_T *sep, int max, int trim, int quotes);
00053 extern CHAR_T *wcs_array_join(CHAR_T **array, const CHAR_T *sep);
00054 extern size_t xwcslcpy(CHAR_T *dst, const CHAR_T *src, size_t size);
00055 
00056 #define free_utf(x) xfree(x)
00057 
00058 #else   /* USE_UNICODE */
00059 
00060 #include <ekg/xmalloc.h>
00061 
00062 #ifdef __cplusplus
00063 extern "C" {
00064 #endif
00065 
00066 #define CHAR_T unsigned char
00067 #define TEXT(x) x
00068 #define CHAR(x) x
00069 #define STRING_FORMAT "%s"
00070 #define CHAR_FORMAT "%c"
00071 
00072 #define xwcslen(str) xstrlen((char *) str)
00073 #define xmbslen(str) xstrlen(str)
00074 #define xwcscpy(dst, str) xstrcpy((char *) dst, (char *) str)
00075 #define xwcsdup(str) (CHAR_T *) xstrdup((char *) str)
00076 #define xwcscat(dst, src) xstrcat((char *) dst, (char *) src)
00077 #define xwcscmp(s1, s2) xstrcmp((char *) s1, (char *) s2)
00078 #define xwcschr(s, c) xstrchr((char *) s, c)
00079 #define wcs_to_normal(x) (char *) x
00080 #define wcs_array_make(str, sep, max, trim, quotes) (CHAR_T **) array_make((char *) str, sep, max, trim, quotes)
00081 #define wcs_array_join(arr, sep) (CHAR_T *) array_join((char **) arr, sep)
00082 #define xwcslcpy(dst, src, size) strlcpy((char *) dst, (char *) src, size)
00083 #define free_utf(x)
00084 
00085 #endif  /* USE_UNICODE */
00086 
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090 
00091 #endif /* __EKG_STRINGS_H */
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje