Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
     22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 #ifndef _WCHAR_H_
     29 #define _WCHAR_H_
     30 
     31 #include <limits.h>
     32 #include <sys/cdefs.h>
     33 #include <stdio.h>
     34 
     35 /* wchar_t is required in stdlib.h according to POSIX */
     36 #define __need___wchar_t
     37 #include <stddef.h>
     38 
     39 #include <stdarg.h>
     40 #include <time.h>
     41 #include <malloc.h>
     42 
     43 #include <stddef.h>
     44 
     45 /* IMPORTANT: Any code that relies on wide character support is essentially
     46  *            non-portable and/or broken. the only reason this header exist
     47  *            is because I'm really a nice guy. However, I'm not nice enough
     48  *            to provide you with a real implementation. instead wchar_t == char
     49  *            and all wc functions are stubs to their "normal" equivalent...
     50  */
     51 
     52 __BEGIN_DECLS
     53 
     54 typedef int                     wint_t;
     55 typedef struct { int  dummy; }  mbstate_t;
     56 
     57 typedef enum {
     58     WC_TYPE_INVALID = 0,
     59     WC_TYPE_ALNUM,
     60     WC_TYPE_ALPHA,
     61     WC_TYPE_BLANK,
     62     WC_TYPE_CNTRL,
     63     WC_TYPE_DIGIT,
     64     WC_TYPE_GRAPH,
     65     WC_TYPE_LOWER,
     66     WC_TYPE_PRINT,
     67     WC_TYPE_PUNCT,
     68     WC_TYPE_SPACE,
     69     WC_TYPE_UPPER,
     70     WC_TYPE_XDIGIT,
     71     WC_TYPE_MAX
     72 } wctype_t;
     73 
     74 #define  WCHAR_MAX   INT_MAX
     75 #define  WCHAR_MIN   INT_MIN
     76 #define  WEOF        ((wint_t)(-1))
     77 
     78 extern wint_t            btowc(int);
     79 extern int               fwprintf(FILE *, const wchar_t *, ...);
     80 extern int               fwscanf(FILE *, const wchar_t *, ...);
     81 extern int               iswalnum(wint_t);
     82 extern int               iswalpha(wint_t);
     83 extern int               iswcntrl(wint_t);
     84 extern int               iswdigit(wint_t);
     85 extern int               iswgraph(wint_t);
     86 extern int               iswlower(wint_t);
     87 extern int               iswprint(wint_t);
     88 extern int               iswpunct(wint_t);
     89 extern int               iswspace(wint_t);
     90 extern int               iswupper(wint_t);
     91 extern int               iswxdigit(wint_t);
     92 extern int               iswctype(wint_t, wctype_t);
     93 extern wint_t            fgetwc(FILE *);
     94 extern wchar_t          *fgetws(wchar_t *, int, FILE *);
     95 extern wint_t            fputwc(wchar_t, FILE *);
     96 extern int               fputws(const wchar_t *, FILE *);
     97 extern int               fwide(FILE *, int);
     98 extern wint_t            getwc(FILE *);
     99 extern wint_t            getwchar(void);
    100 extern int               mbsinit(const mbstate_t *);
    101 extern size_t            mbrlen(const char *, size_t, mbstate_t *);
    102 extern size_t            mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
    103 extern size_t            mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
    104 extern size_t            mbstowcs(wchar_t *, const char *, size_t);
    105 extern wint_t            putwc(wchar_t, FILE *);
    106 extern wint_t            putwchar(wchar_t);
    107 extern int               swprintf(wchar_t *, size_t, const wchar_t *, ...);
    108 extern int               swscanf(const wchar_t *, const wchar_t *, ...);
    109 extern wint_t            towlower(wint_t);
    110 extern wint_t            towupper(wint_t);
    111 extern wint_t            ungetwc(wint_t, FILE *);
    112 extern int               vfwprintf(FILE *, const wchar_t *, va_list);
    113 extern int               vwprintf(const wchar_t *, va_list);
    114 extern int               vswprintf(wchar_t *, size_t, const wchar_t *, va_list);
    115 extern size_t            wcrtomb(char *, wchar_t, mbstate_t *);
    116 extern wchar_t          *wcscat(wchar_t *, const wchar_t *);
    117 extern wchar_t          *wcschr(const wchar_t *, wchar_t);
    118 extern int               wcscmp(const wchar_t *, const wchar_t *);
    119 extern int               wcscoll(const wchar_t *, const wchar_t *);
    120 extern wchar_t          *wcscpy(wchar_t *, const wchar_t *);
    121 extern size_t            wcscspn(const wchar_t *, const wchar_t *);
    122 extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
    123 extern size_t            wcslen(const wchar_t *);
    124 extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
    125 extern int               wcsncmp(const wchar_t *, const wchar_t *, size_t);
    126 extern wchar_t          *wcsncpy(wchar_t *, const wchar_t *, size_t);
    127 extern wchar_t          *wcspbrk(const wchar_t *, const wchar_t *);
    128 extern wchar_t          *wcsrchr(const wchar_t *, wchar_t);
    129 extern size_t            wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
    130 extern size_t            wcsspn(const wchar_t *, const wchar_t *);
    131 extern wchar_t          *wcsstr(const wchar_t *, const wchar_t *);
    132 extern double            wcstod(const wchar_t *, wchar_t **);
    133 extern wchar_t          *wcstok(wchar_t *, const wchar_t *, wchar_t **);
    134 extern long int          wcstol(const wchar_t *, wchar_t **, int);
    135 extern size_t            wcstombs(char *, const wchar_t *, size_t);
    136 extern unsigned long int wcstoul(const wchar_t *, wchar_t **, int);
    137 extern wchar_t          *wcswcs(const wchar_t *, const wchar_t *);
    138 extern int               wcswidth(const wchar_t *, size_t);
    139 extern size_t            wcsxfrm(wchar_t *, const wchar_t *, size_t);
    140 extern int               wctob(wint_t);
    141 extern wctype_t          wctype(const char *);
    142 extern int               wcwidth(wchar_t);
    143 extern wchar_t          *wmemchr(const wchar_t *, wchar_t, size_t);
    144 extern int               wmemcmp(const wchar_t *, const wchar_t *, size_t);
    145 extern wchar_t          *wmemcpy(wchar_t *, const wchar_t *, size_t);
    146 extern wchar_t          *wmemmove(wchar_t *, const wchar_t *, size_t);
    147 extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
    148 extern int               wprintf(const wchar_t *, ...);
    149 extern int               wscanf(const wchar_t *, ...);
    150 
    151 /* No really supported.  These are just for making libstdc++-v3 happy.  */
    152 typedef void *wctrans_t;
    153 extern wint_t		 towctrans(wint_t, wctrans_t);
    154 extern wctrans_t	 wctrans (const char *);
    155 
    156 __END_DECLS
    157 
    158 #endif /* _WCHAR_H_ */
    159