summaryrefslogtreecommitdiff
path: root/include/libc/ctype.h
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:45:02 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2023-02-01 18:50:25 -0400
commit9fa0a7f1da1b70bee995f53c6c96c43189018772 (patch)
tree114548896790eaff23cdca84a025281de86bbb51 /include/libc/ctype.h
parent2ba3289286bbfcf9fcc13fd135d976058d8b6c2e (diff)
global: Import Dolphin SDK
This version comes from the Metroid Prime decompilation project. https://github.com/PrimeDecomp/prime
Diffstat (limited to 'include/libc/ctype.h')
-rw-r--r--include/libc/ctype.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/libc/ctype.h b/include/libc/ctype.h
new file mode 100644
index 0000000..b8f6067
--- /dev/null
+++ b/include/libc/ctype.h
@@ -0,0 +1,69 @@
+#ifndef _CTYPE_H_
+#define _CTYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// eof.h
+#define EOF -1L
+
+extern unsigned char __ctype_map[];
+extern unsigned char __lower_map[];
+extern unsigned char __upper_map[];
+
+#define __control_char 0x01
+#define __motion_char 0x02
+#define __space_char 0x04
+#define __punctuation 0x08
+#define __digit 0x10
+#define __hex_digit 0x20
+#define __lower_case 0x40
+#define __upper_case 0x80
+
+#define __letter (__lower_case | __upper_case)
+#define __alphanumeric (__letter | __digit)
+#define __graphic (__alphanumeric | __punctuation)
+#define __printable (__graphic | __space_char)
+#define __whitespace (__motion_char | __space_char)
+#define __control (__motion_char | __control_char)
+#define __zero_fill(c) ((int)(unsigned char)(c))
+
+#ifndef _CTYPE_INLINE
+#define _CTYPE_INLINE static inline
+#endif
+
+_CTYPE_INLINE
+int isalnum(int c) { return __ctype_map[__zero_fill(c)] & __alphanumeric; }
+_CTYPE_INLINE
+int isalpha(int c) { return __ctype_map[__zero_fill(c)] & __letter; }
+_CTYPE_INLINE
+int iscntrl(int c) { return __ctype_map[__zero_fill(c)] & __control; }
+_CTYPE_INLINE
+int isdigit(int c) { return __ctype_map[__zero_fill(c)] & __digit; }
+_CTYPE_INLINE
+int isgraph(int c) { return __ctype_map[__zero_fill(c)] & __graphic; }
+_CTYPE_INLINE
+int islower(int c) { return __ctype_map[__zero_fill(c)] & __lower_case; }
+_CTYPE_INLINE
+int isprint(int c) { return __ctype_map[__zero_fill(c)] & __printable; }
+_CTYPE_INLINE
+int ispunct(int c) { return __ctype_map[__zero_fill(c)] & __punctuation; }
+_CTYPE_INLINE
+int isspace(int c) { return __ctype_map[__zero_fill(c)] & __whitespace; }
+_CTYPE_INLINE
+int isupper(int c) { return __ctype_map[__zero_fill(c)] & __upper_case; }
+_CTYPE_INLINE
+int isxdigit(int c) { return __ctype_map[__zero_fill(c)] & __hex_digit; }
+_CTYPE_INLINE
+int tolower(int c) { return ((c == EOF) ? EOF : ((int)__lower_map[__zero_fill(c)])); }
+_CTYPE_INLINE
+int toupper(int c) { return ((c == EOF) ? EOF : ((int)__upper_map[__zero_fill(c)])); }
+_CTYPE_INLINE
+int iswblank(int c) { return ((c == (int)L' ') || (c == (int)L'\t')); }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif