diff options
author | Ali Fardan <raiz@stellarbound.space> | 2020-11-22 17:02:51 +0300 |
---|---|---|
committer | Ali Fardan <raiz@stellarbound.space> | 2020-11-22 17:02:51 +0300 |
commit | 5a66aa1bbace4775025cd99a8ab0a8a18487dfe9 (patch) | |
tree | a40b9c727001661fb2200f06b87155a9e5a8db98 /types.h | |
parent | 7ea4eb3fe07564f605731b4b4eef09a47c0bfb08 (diff) | |
download | libyuri-5a66aa1bbace4775025cd99a8ab0a8a18487dfe9.tar.gz |
- implement percent encoding in encode.c
- move syntax macros from decode.c to separate types.h header - fix normalizer (sorta, needs testing) - TODO: more testing...
Diffstat (limited to 'types.h')
-rw-r--r-- | types.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/types.h b/types.h new file mode 100644 index 0000000..03208d4 --- /dev/null +++ b/types.h @@ -0,0 +1,113 @@ +#define _is_alpha(c)\ + ((c == 'A') ||\ + (c == 'B') ||\ + (c == 'C') ||\ + (c == 'D') ||\ + (c == 'E') ||\ + (c == 'F') ||\ + (c == 'G') ||\ + (c == 'H') ||\ + (c == 'I') ||\ + (c == 'J') ||\ + (c == 'K') ||\ + (c == 'L') ||\ + (c == 'M') ||\ + (c == 'N') ||\ + (c == 'O') ||\ + (c == 'P') ||\ + (c == 'Q') ||\ + (c == 'R') ||\ + (c == 'S') ||\ + (c == 'T') ||\ + (c == 'U') ||\ + (c == 'V') ||\ + (c == 'W') ||\ + (c == 'X') ||\ + (c == 'Y') ||\ + (c == 'Z') ||\ + (c == 'a') ||\ + (c == 'b') ||\ + (c == 'c') ||\ + (c == 'd') ||\ + (c == 'e') ||\ + (c == 'f') ||\ + (c == 'g') ||\ + (c == 'h') ||\ + (c == 'i') ||\ + (c == 'j') ||\ + (c == 'k') ||\ + (c == 'l') ||\ + (c == 'm') ||\ + (c == 'n') ||\ + (c == 'o') ||\ + (c == 'p') ||\ + (c == 'q') ||\ + (c == 'r') ||\ + (c == 's') ||\ + (c == 't') ||\ + (c == 'u') ||\ + (c == 'v') ||\ + (c == 'w') ||\ + (c == 'x') ||\ + (c == 'y') ||\ + (c == 'z')) + +#define _is_digit(c)\ + ((c == '0') ||\ + (c == '1') ||\ + (c == '2') ||\ + (c == '3') ||\ + (c == '4') ||\ + (c == '5') ||\ + (c == '6') ||\ + (c == '7') ||\ + (c == '8') ||\ + (c == '9')) + +#define _is_gen_delim(c)\ + ((c == ':') ||\ + (c == '/') ||\ + (c == '?') ||\ + (c == '#') ||\ + (c == '[') ||\ + (c == ']') ||\ + (c == '@')) + +#define _is_sub_delim(c)\ + ((c == '!') ||\ + (c == '$') ||\ + (c == '&') ||\ + (c == '\'') ||\ + (c == '(') ||\ + (c == ')') ||\ + (c == '*') ||\ + (c == '+') ||\ + (c == ',') ||\ + (c == ';') ||\ + (c == '=')) + +#define _is_unreserved(c)\ + (_is_alpha(c) ||\ + _is_digit(c) ||\ + (c == '-') ||\ + (c == '.') ||\ + (c == '_') ||\ + (c == '~')) + +#define _is_reserved(c)\ + (_is_gen_delim(c) ||\ + _is_sub_delim(c)) + +#define _is_pchar(c)\ + (_is_unreserved(c) ||\ + _is_sub_delim(c) ||\ + (c == ':') ||\ + (c == '@')) + +#define _is_segment(c)\ + _is_pchar(c) + +#define _is_segment_nc(c)\ + (_is_unreserved(c) ||\ + _is_sub_delim(c) ||\ + (c == '@')) |