blob: 24847ebc084897d5bb690e7918177325ea1cbc69 [file] [log] [blame] [raw]
/* A part of the Native C Library for Windows NT
Copyright 2007-2015 PC GO Ld.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
#ifndef _CTYPE_H
#define _CTYPE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
# define _ISbit(bit) (1 << (bit))
#else
# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
#endif
#define _ISupper _ISbit(0) /* UPPERCASE. */
#define _ISlower _ISbit(1) /* lowercase. */
#define _ISalpha _ISbit(2) /* Alphabetic. */
#define _ISdigit _ISbit(3) /* Numeric. */
#define _ISxdigit _ISbit(4) /* Hexadecimal numeric. */
#define _ISspace _ISbit(5) /* Whitespace. */
#define _ISprint _ISbit(6) /* Printing. */
#define _ISgraph _ISbit(7) /* Graphical. */
#define _ISblank _ISbit(8) /* Blank (usually SPC and TAB). */
#define _IScntrl _ISbit(9) /* Control character. */
#define _ISpunct _ISbit(10) /* Punctuation. */
#define _ISalnum _ISbit(11) /* Alphanumeric. */
//const unsigned short int **__ctype_b(void);
//#define __isctype(c, type) ({ int _c = (int)(c); _c < 0 ? 0 : ((*__ctype_b())[_c] & (unsigned short int)(type)); })
int __isctype(int, unsigned short int);
int isalnum(int);
int isalpha(int);
int isblank(int);
int iscntrl(int);
int isdigit(int);
int isgraph(int);
int islower(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int isxdigit(int);
int tolower(int);
int toupper(int);
#if !defined __NO_CTYPE && !defined __cplusplus
# define isalnum(c) __isctype((c), _ISalnum)
# define isalpha(c) __isctype((c), _ISalpha)
# define isblank(c) __isctype((c), _ISblank)
# define iscntrl(c) __isctype((c), _IScntrl)
# define isdigit(c) __isctype((c), _ISdigit)
# define islower(c) __isctype((c), _ISlower)
# define isgraph(c) __isctype((c), _ISgraph)
# define isprint(c) __isctype((c), _ISprint)
# define ispunct(c) __isctype((c), _ISpunct)
# define isspace(c) __isctype((c), _ISspace)
# define isupper(c) __isctype((c), _ISupper)
# define isxdigit(c) __isctype((c), _ISxdigit)
# define isascii(c) (((c) & ~0x7f) == 0)
# define tolower(c) ({ int _c = (c); (_c < -128 || _c > 255 || !isupper(_c)) ? _c : _c + ('a' - 'A'); })
# define toupper(c) ({ int _c = (c); (_c < -128 || _c > 255 || !islower(_c)) ? _c : _c - ('a' - 'A'); })
#endif
#ifdef __cplusplus
}
#endif
#endif