Mercurial > lcfOS
comparison cos/kernel/snprintf.c @ 13:d07d4701a103
Cleanup of header files
author | windel |
---|---|
date | Mon, 14 Nov 2011 21:44:35 +0100 |
parents | fcdae30b2782 |
children | f3e3e0e9c4bc |
comparison
equal
deleted
inserted
replaced
12:fcdae30b2782 | 13:d07d4701a103 |
---|---|
1 /* | 1 /* |
2 * snprintf.c | 2 * snprintf.c |
3 */ | 3 */ |
4 #include "kernel.h" | 4 #include "kernel.h" |
5 | 5 |
6 #include "ctype.h" | 6 /* |
7 * NOTE! This ctype does not handle EOF like the standard C | |
8 * library is required to. | |
9 */ | |
10 | |
11 #define _U 0x01 /* upper */ | |
12 #define _L 0x02 /* lower */ | |
13 #define _D 0x04 /* digit */ | |
14 #define _C 0x08 /* cntrl */ | |
15 #define _P 0x10 /* punct */ | |
16 #define _S 0x20 /* white space (space/lf/tab) */ | |
17 #define _X 0x40 /* hex digit */ | |
18 #define _SP 0x80 /* hard space (0x20) */ | |
19 | |
7 | 20 |
8 unsigned char _ctype[] = { | 21 unsigned char _ctype[] = { |
9 _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ | 22 _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ |
10 _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ | 23 _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ |
11 _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ | 24 _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ |
29 _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ | 42 _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ |
30 _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ | 43 _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ |
31 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ | 44 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ |
32 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ | 45 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ |
33 | 46 |
47 #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) | |
48 | |
49 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) | |
50 #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) | |
51 #define iscntrl(c) ((__ismask(c)&(_C)) != 0) | |
52 #define isdigit(c) ((__ismask(c)&(_D)) != 0) | |
53 #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) | |
54 #define islower(c) ((__ismask(c)&(_L)) != 0) | |
55 #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) | |
56 #define ispunct(c) ((__ismask(c)&(_P)) != 0) | |
57 #define isspace(c) ((__ismask(c)&(_S)) != 0) | |
58 #define isupper(c) ((__ismask(c)&(_U)) != 0) | |
59 #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) | |
60 | |
61 #define isascii(c) (((unsigned char)(c))<=0x7f) | |
62 #define toascii(c) (((unsigned char)(c))&0x7f) | |
63 | |
64 static inline unsigned char tolower(unsigned char c) | |
65 { | |
66 if (isupper(c)) | |
67 c -= 'A'-'a'; | |
68 return c; | |
69 } | |
70 | |
71 static inline unsigned char toupper(unsigned char c) | |
72 { | |
73 if (islower(c)) | |
74 c -= 'a'-'A'; | |
75 return c; | |
76 } | |
34 | 77 |
35 #define MORE_THAN_YOU_WANT 1<<30 | 78 #define MORE_THAN_YOU_WANT 1<<30 |
36 #define MAX_STDOUT_CHARS 255 | 79 #define MAX_STDOUT_CHARS 255 |
37 | 80 |
38 static char hexmap[] = { | 81 static char hexmap[] = { |