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" 64 #define LWS SP HT _CR LF 66 #define LOALPHA "abcdefghijklmnopqrstuvwxyz" 68 #define UPALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 70 #define ALPHA LOALPHA UPALPHA 72 #define DIGIT "0123456789" 75 #define ALPHANUM DIGIT ALPHA 76 #define HEX DIGIT "ABCDEF" "abcdef" 81 #define SIP_TOKEN ALPHANUM "-.!%*_+`'~" 83 #define SIP_SEPARATOR "()<>@,;:\\\"/[]?={}" SP HT 86 #define SIP_WORD "()<>:\\\"/[]?{}" 89 #define skip_ws(ss) (*(ss) += span_ws(*(ss))) 92 #define skip_lws(ss) (*(ss) += span_lws(*(ss))) 95 #define skip_alpha(ss) (*(ss) += span_alpha(*(ss))) 98 #define skip_digit(ss) (*(ss) += span_digit(*(ss))) 101 #define skip_alpha_digit_safe(ss) (*(ss) += span_alpha_digit_safe(*(ss))) 104 #define skip_token(ss) (*(ss) += span_token(*(ss))) 107 #define skip_param(ss) (*(ss) += span_param(*(ss))) 110 #define skip_word(ss) (*(ss) += span_word(*(ss))) 113 #define IS_CRLF(c) ((c) == '\r' || (c) == '\n') 115 #define IS_LWS(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') 118 #define IS_WS(c) ((c) == ' ' || (c) == '\t') 120 #define IS_NON_WS(c) (c && !IS_WS(c)) 123 #define IS_NON_LWS(c) (c && !IS_LWS(c)) 126 #define IS_DIGIT(c) ((c) >= '0' && (c) <= '9') 128 #define IS_ALPHA(c) (c && ((_bnf_table[(unsigned char)c] & bnf_alpha))) 130 #define IS_ALPHANUM(c) (c && (IS_DIGIT(c) || IS_ALPHA(c))) 132 #define IS_UNRESERVED(c) ((_bnf_table[(unsigned char)c] & bnf_unreserved)) 134 #define IS_RESERVED(c) (c && !(_bnf_table[(unsigned char)c] & bnf_unreserved)) 136 #define IS_TOKEN(c) ((_bnf_table[(unsigned char)c] & bnf_token)) 138 #define IS_PARAM(c) ((_bnf_table[(unsigned char)c] & (bnf_token|bnf_param))) 140 #define IS_HEX(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) 142 #define IS_TOKENLWS(c) ((_bnf_table[(unsigned char)c] & (bnf_token|bn_lws))) 164 #define span_non_crlf(s) strcspn(s, _CR LF) 167 #define span_non_ws(s) strcspn(s, WS) 170 #define span_ws(s) strspn(s, WS) 173 #define span_non_lws(s) strcspn(s, LWS) 183 if (e[i] ==
'\r') i++;
184 if (e[i] ==
'\n') i++;
186 e += i + strspn(e + i,
WS);
221 while (*e >=
'0' && *e <=
'9')
280 s += strcspn(s,
"\\\"");
292 #define URL_RESERVED ";/?:=+$," 295 #define URL_MARK "-_.!~*'()" 298 #define URL_UNRESERVED ALPHANUM URL_MARK 301 #define URL_ESCAPED "%" 302 #define URL_DELIMS "<>#%\"" 303 #define URL_UNWISE "{}|\\^[]`" 304 #define URL_SCHEME ALPHANUM "+-." 307 #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:191
Whitespace character.
Definition: bnf.h:145
isize_t span_hexdigit(char const *s)
Calculate span of a hex.
Definition: bnf.h:227
isize_t span_lws(char const *s)
Calculate span of a linear whitespace.
Definition: bnf.h:178
isize_t span_word(char const *s)
Calculate span of a SIP word.
Definition: bnf.h:254
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:147
isize_t span_alpha_digit_safe(char const *s)
Calculate span of characters belonging to an RTSP token.
Definition: bnf.h:236
#define IS_WS(c)
Test if is normal whitespace.
Definition: bnf.h:118
isize_t span_token(char const *s)
Calculate span of a token characters.
Definition: bnf.h:200
Line end character.
Definition: bnf.h:146
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:136
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:62
int span_ip6_address(char const *host)
Return length of valid IP6 address.
Definition: bnf.c:453
URL mark.
Definition: bnf.h:150
SIP parameter, not token.
Definition: bnf.h:156
#define IS_UNRESERVED(c)
Test if is URL-unreserved.
Definition: bnf.h:132
int span_ip4_address(char const *host)
Return length of valid IP4 address.
Definition: bnf.c:207
Alphabetic.
Definition: bnf.h:148
#define IS_PARAM(c)
Test if is valid for SIP parameter value.
Definition: bnf.h:138
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:157
int scan_ip6_reference(char **inout_host)
Scan valid IP6 reference.
Definition: bnf.c:505
SIP token.
Definition: bnf.h:155
SIP token, not alphabetic (0123456789-.
Definition: bnf.h:154
isize_t span_param(char const *s)
Calculate span of a characters valid in parameters.
Definition: bnf.h:245
SIP separator.
Definition: bnf.h:152
#define IS_HEX(c)
Test if is a hex digit.
Definition: bnf.h:140
isize_t span_digit(char const *s)
Calculate span of a digits.
Definition: bnf.h:218
isize_t span_unreserved(char const *s)
Calculate span of a unreserved characters.
Definition: bnf.h:263
isize_t span_quoted(char const *s)
Calculate span of a double quoted string (with escaped chars inside)
Definition: bnf.h:272
isize_t span_alpha(char const *s)
Calculate span of a alphabetic characters.
Definition: bnf.h:209
URL unreserved.
Definition: bnf.h:151
RTSP safe.
Definition: bnf.h:149
#define SIP_WORD
SIP Word characters (that are not token characters)
Definition: bnf.h:86