46 #define CTL "\001\002\003\004\005\006\007" \ 47 "\010\011\012\013\014\015\016\017" \ 48 "\020\021\022\023\024\025\026\027" \ 49 "\030\031\032\033\034\035\036\037" "\177" "\0" 63 #define LWS SP HT CR LF 65 #define LOALPHA "abcdefghijklmnopqrstuvwxyz" 67 #define UPALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 69 #define ALPHA LOALPHA UPALPHA 71 #define DIGIT "0123456789" 74 #define ALPHANUM DIGIT ALPHA 75 #define HEX DIGIT "ABCDEF" "abcdef" 80 #define SIP_TOKEN ALPHANUM "-.!%*_+`'~" 82 #define SIP_SEPARATOR "()<>@,;:\\\"/[]?={}" SP HT 85 #define SIP_WORD "()<>:\\\"/[]?{}" 88 #define skip_ws(ss) (*(ss) += span_ws(*(ss))) 91 #define skip_lws(ss) (*(ss) += span_lws(*(ss))) 94 #define skip_alpha(ss) (*(ss) += span_alpha(*(ss))) 97 #define skip_digit(ss) (*(ss) += span_digit(*(ss))) 100 #define skip_alpha_digit_safe(ss) (*(ss) += span_alpha_digit_safe(*(ss))) 103 #define skip_token(ss) (*(ss) += span_token(*(ss))) 106 #define skip_param(ss) (*(ss) += span_param(*(ss))) 109 #define skip_word(ss) (*(ss) += span_word(*(ss))) 112 #define IS_CRLF(c) ((c) == '\r' || (c) == '\n') 114 #define IS_LWS(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') 117 #define IS_WS(c) ((c) == ' ' || (c) == '\t') 119 #define IS_NON_WS(c) (c && !IS_WS(c)) 122 #define IS_NON_LWS(c) (c && !IS_LWS(c)) 125 #define IS_DIGIT(c) ((c) >= '0' && (c) <= '9') 127 #define IS_ALPHA(c) (c && ((_bnf_table[(unsigned char)c] & bnf_alpha))) 129 #define IS_ALPHANUM(c) (c && (IS_DIGIT(c) || IS_ALPHA(c))) 131 #define IS_UNRESERVED(c) ((_bnf_table[(unsigned char)c] & bnf_unreserved)) 133 #define IS_RESERVED(c) (c && !(_bnf_table[(unsigned char)c] & bnf_unreserved)) 135 #define IS_TOKEN(c) ((_bnf_table[(unsigned char)c] & bnf_token)) 137 #define IS_PARAM(c) ((_bnf_table[(unsigned char)c] & (bnf_token|bnf_param))) 139 #define IS_HEX(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) 141 #define IS_TOKENLWS(c) ((_bnf_table[(unsigned char)c] & (bnf_token|bn_lws))) 163 #define span_non_crlf(s) strcspn(s, CR LF) 166 #define span_non_ws(s) strcspn(s, WS) 169 #define span_ws(s) strspn(s, WS) 172 #define span_non_lws(s) strcspn(s, LWS) 182 if (e[i] ==
'\r') i++;
183 if (e[i] ==
'\n') i++;
185 e += i + strspn(e + i,
WS);
220 while (*e >=
'0' && *e <=
'9')
279 s += strcspn(s,
"\\\"");
291 #define URL_RESERVED ";/?:=+$," 294 #define URL_MARK "-_.!~*'()" 297 #define URL_UNRESERVED ALPHANUM URL_MARK 300 #define URL_ESCAPED "%" 301 #define URL_DELIMS "<>#%\"" 302 #define URL_UNWISE "{}|\\^[]`" 303 #define URL_SCHEME ALPHANUM "+-." 306 #define span_url_scheme(s) strspn(s, URL_SCHEME) isize_t span_token_lws(char const *s)
Calculate span of a token or linear whitespace characters.
Definition: bnf.h:190
Whitespace character.
Definition: bnf.h:144
isize_t span_hexdigit(char const *s)
Calculate span of a hex.
Definition: bnf.h:226
isize_t span_lws(char const *s)
Calculate span of a linear whitespace.
Definition: bnf.h:177
isize_t span_word(char const *s)
Calculate span of a SIP word.
Definition: bnf.h:253
int scan_ip6_address(char **inout_host)
Scan and canonize valid IP6 address.
Definition: bnf.c:467
issize_t scan_host(char **inout_host)
Scan valid domain name or IP address.
Definition: bnf.c:680
Linear whitespace.
Definition: bnf.h:146
isize_t span_alpha_digit_safe(char const *s)
Calculate span of characters belonging to an RTSP token.
Definition: bnf.h:235
#define IS_WS(c)
Test if is normal whitespace.
Definition: bnf.h:117
isize_t span_token(char const *s)
Calculate span of a token characters.
Definition: bnf.h:199
Line end character.
Definition: bnf.h:145
isize_t span_host(char const *host)
Return length of a valid domain name or IP address.
Definition: bnf.c:662
int span_ip6_reference(char const *host)
Return length of valid IP6 reference.
Definition: bnf.c:491
unsigned char const _bnf_table[256]
Table for determining class of a character.
Definition: bnf.c:55
int scan_ip4_address(char **inout_host)
Scan and canonize a valid IP4 address.
Definition: bnf.c:213
#define IS_TOKEN(c)
Test if is valid in tokens.
Definition: bnf.h:135
int scan_ip_address(char **inout_host)
Scan valid IP4/IP6 address.
Definition: bnf.c:554
issize_t scan_domain(char **inout_host)
Scan valid domain name.
Definition: bnf.c:643
isize_t span_domain(char const *host)
Return length of a valid domain name.
Definition: bnf.c:637
#define WS
Whitespace.
Definition: bnf.h:61
int span_ip6_address(char const *host)
Return length of valid IP6 address.
Definition: bnf.c:453
URL mark.
Definition: bnf.h:149
SIP parameter, not token.
Definition: bnf.h:155
#define IS_UNRESERVED(c)
Test if is URL-unreserved.
Definition: bnf.h:131
int span_ip4_address(char const *host)
Return length of valid IP4 address.
Definition: bnf.c:207
Alphabetic.
Definition: bnf.h:147
#define IS_PARAM(c)
Test if is valid for SIP parameter value.
Definition: bnf.h:137
int span_ip_address(char const *host)
Return length of valid IP4 or IP6 address.
Definition: bnf.c:535
SIP/HTTP parameter.
Definition: bnf.h:156
int scan_ip6_reference(char **inout_host)
Scan valid IP6 reference.
Definition: bnf.c:505
SIP token.
Definition: bnf.h:154
SIP token, not alphabetic (0123456789-.
Definition: bnf.h:153
isize_t span_param(char const *s)
Calculate span of a characters valid in parameters.
Definition: bnf.h:244
SIP separator.
Definition: bnf.h:151
#define IS_HEX(c)
Test if is a hex digit.
Definition: bnf.h:139
isize_t span_digit(char const *s)
Calculate span of a digits.
Definition: bnf.h:217
isize_t span_unreserved(char const *s)
Calculate span of a unreserved characters.
Definition: bnf.h:262
isize_t span_quoted(char const *s)
Calculate span of a double quoted string (with escaped chars inside)
Definition: bnf.h:271
isize_t span_alpha(char const *s)
Calculate span of a alphabetic characters.
Definition: bnf.h:208
URL unreserved.
Definition: bnf.h:150
RTSP safe.
Definition: bnf.h:148
#define SIP_WORD
SIP Word characters (that are not token characters)
Definition: bnf.h:85