cow_parse.hrl 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. %% Copyright (c) 2015-2023, Loïc Hoguin <essen@ninenines.eu>
  2. %%
  3. %% Permission to use, copy, modify, and/or distribute this software for any
  4. %% purpose with or without fee is hereby granted, provided that the above
  5. %% copyright notice and this permission notice appear in all copies.
  6. %%
  7. %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. -ifndef(COW_PARSE_HRL).
  15. -define(COW_PARSE_HRL, 1).
  16. -define(IS_ALPHA(C),
  17. (C =:= $a) or (C =:= $b) or (C =:= $c) or (C =:= $d) or (C =:= $e) or
  18. (C =:= $f) or (C =:= $g) or (C =:= $h) or (C =:= $i) or (C =:= $j) or
  19. (C =:= $k) or (C =:= $l) or (C =:= $m) or (C =:= $n) or (C =:= $o) or
  20. (C =:= $p) or (C =:= $q) or (C =:= $r) or (C =:= $s) or (C =:= $t) or
  21. (C =:= $u) or (C =:= $v) or (C =:= $w) or (C =:= $x) or (C =:= $y) or
  22. (C =:= $z) or
  23. (C =:= $A) or (C =:= $B) or (C =:= $C) or (C =:= $D) or (C =:= $E) or
  24. (C =:= $F) or (C =:= $G) or (C =:= $H) or (C =:= $I) or (C =:= $J) or
  25. (C =:= $K) or (C =:= $L) or (C =:= $M) or (C =:= $N) or (C =:= $O) or
  26. (C =:= $P) or (C =:= $Q) or (C =:= $R) or (C =:= $S) or (C =:= $T) or
  27. (C =:= $U) or (C =:= $V) or (C =:= $W) or (C =:= $X) or (C =:= $Y) or
  28. (C =:= $Z)
  29. ).
  30. -define(IS_ALPHANUM(C), ?IS_ALPHA(C) or ?IS_DIGIT(C)).
  31. -define(IS_CHAR(C), C > 0, C < 128).
  32. -define(IS_DIGIT(C),
  33. (C =:= $0) or (C =:= $1) or (C =:= $2) or (C =:= $3) or (C =:= $4) or
  34. (C =:= $5) or (C =:= $6) or (C =:= $7) or (C =:= $8) or (C =:= $9)).
  35. -define(IS_ETAGC(C), C =:= 16#21; C >= 16#23, C =/= 16#7f).
  36. -define(IS_HEX(C),
  37. ?IS_DIGIT(C) or
  38. (C =:= $a) or (C =:= $b) or (C =:= $c) or
  39. (C =:= $d) or (C =:= $e) or (C =:= $f) or
  40. (C =:= $A) or (C =:= $B) or (C =:= $C) or
  41. (C =:= $D) or (C =:= $E) or (C =:= $F)).
  42. -define(IS_LHEX(C),
  43. ?IS_DIGIT(C) or
  44. (C =:= $a) or (C =:= $b) or (C =:= $c) or
  45. (C =:= $d) or (C =:= $e) or (C =:= $f)).
  46. -define(IS_TOKEN(C),
  47. ?IS_ALPHA(C) or ?IS_DIGIT(C) or
  48. (C =:= $!) or (C =:= $#) or (C =:= $$) or (C =:= $%) or (C =:= $&) or
  49. (C =:= $') or (C =:= $*) or (C =:= $+) or (C =:= $-) or (C =:= $.) or
  50. (C =:= $^) or (C =:= $_) or (C =:= $`) or (C =:= $|) or (C =:= $~)).
  51. -define(IS_TOKEN68(C),
  52. ?IS_ALPHA(C) or ?IS_DIGIT(C) or
  53. (C =:= $-) or (C =:= $.) or (C =:= $_) or
  54. (C =:= $~) or (C =:= $+) or (C =:= $/)).
  55. -define(IS_URI_UNRESERVED(C),
  56. ?IS_ALPHA(C) or ?IS_DIGIT(C) or
  57. (C =:= $-) or (C =:= $.) or (C =:= $_) or (C =:= $~)).
  58. -define(IS_URI_GEN_DELIMS(C),
  59. (C =:= $:) or (C =:= $/) or (C =:= $?) or (C =:= $#) or
  60. (C =:= $[) or (C =:= $]) or (C =:= $@)).
  61. -define(IS_URI_SUB_DELIMS(C),
  62. (C =:= $!) or (C =:= $$) or (C =:= $&) or (C =:= $') or
  63. (C =:= $() or (C =:= $)) or (C =:= $*) or (C =:= $+) or
  64. (C =:= $,) or (C =:= $;) or (C =:= $=)).
  65. -define(IS_VCHAR(C), C =:= $\t; C > 31, C < 127).
  66. -define(IS_VCHAR_OBS(C), C =:= $\t; C > 31, C =/= 127).
  67. -define(IS_WS(C), (C =:= $\s) or (C =:= $\t)).
  68. -define(IS_WS_COMMA(C), ?IS_WS(C) or (C =:= $,)).
  69. -endif.