PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ctype.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __CTYPE_H__
17#define __CTYPE_H__
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23extern unsigned char look_ctype_table(char character);
24extern void *get_ctype_table();
25
26/* These functions are non-standardized (char instead of int) */
27extern char _toupper(char c);
28extern char _tolower(char c);
29
30#define isascii(c) ((unsigned int)(c) <= 127)
31#define toascii(c) ((unsigned char)(c) & 127)
32
33#define isblank(c) ((c == ' ') || (c == '\t'))
34
35#ifdef USE_IOP_CTYPE_MACRO
36
37#define islower(c) ((c >= 'a') && (c <= 'z'))
38#define isupper(c) ((c >= 'A') && (c <= 'Z'))
39#define isdigit(c) ((c >= '0') && (c <= '9'))
40#define iscntrl(c) ((c >= 0) && (c < 32))
41#define isprint(c) ((c >= 32) && (c <= 127))
42
43#define isspace(c) (isblank(c) || (c == '\f') || (c == '\n') || (c == '\r') || (c == '\v'))
44#define isxdigit(c) (isdigit(c) || ((c >= 'A') && (c <= 'F')))
45
46#define isalnum(c) (isalpha(c) || isdigit(c))
47#define isalpha(c) (isupper(c) || islower(c))
48#define isgraph(c) (isprint(c) && !isspace(c))
49#define ispunct(c) (isprint(c) && !(isspace(c) || isalnum(c)))
50
51#define toupper(c) ((unsigned char)(c) + ('a' - 'A'))
52#define tolower(c) ((unsigned char)(c) - ('a' - 'A'))
53
54#else
55
57#define _U 0x01
59#define _L 0x02
61#define _N 0x04
63#define _S 0x08
65#define _P 0x10
67#define _C 0x20
69#define _X 0x40
71#define _B 0x80
72
73#define isalpha(c) (look_ctype_table((unsigned int)(c)) & (_U|_L))
74#define isupper(c) (look_ctype_table((unsigned int)(c)) & (_U))
75#define islower(c) (look_ctype_table((unsigned int)(c)) & (_L))
76#define isdigit(c) (look_ctype_table((unsigned int)(c)) & (_N))
77#define isxdigit(c) (look_ctype_table((unsigned int)(c)) & (_X|_N))
78#define isspace(c) (look_ctype_table((unsigned int)(c)) & (_S))
79#define ispunct(c) (look_ctype_table((unsigned int)(c)) & (_P))
80#define isalnum(c) (look_ctype_table((unsigned int)(c)) & (_U|_L|_N))
81#define isprint(c) (look_ctype_table((unsigned int)(c)) & (_P|_U|_L|_N|_B))
82#define isgraph(c) (look_ctype_table((unsigned int)(c)) & (_P|_U|_L|_N))
83#define iscntrl(c) (look_ctype_table((unsigned int)(c)) & (_C))
84
85#if __GNUC__ > 3
86#undef toupper
87#endif
88#ifndef toupper
89#define toupper(c) _toupper(c)
90#endif
91
92#if __GNUC__ > 3
93#undef tolower
94#endif
95#ifndef tolower
96#define tolower(c) _tolower(c)
97#endif
98
99#endif
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* __CTYPE_H__ */