/src/opensips/parser/parser_f.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2001-2003 FhG Fokus |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | * |
20 | | * History |
21 | | * -------- |
22 | | * 2003-02-28 scratchpad compatibility abandoned (jiri) |
23 | | * 2003-03-24 find_not_quoted function added (janakj) |
24 | | */ |
25 | | |
26 | | |
27 | | #ifndef parser_f_h |
28 | | #define parser_f_h |
29 | | |
30 | | #include "../str.h" |
31 | | |
32 | | char* eat_line(char* buffer, unsigned int len); |
33 | | |
34 | | /* turn the most frequently called functions into inline functions */ |
35 | | |
36 | | inline static char* eat_space_end(const char* p, const char* pend) |
37 | 0 | { |
38 | 0 | for(;(p<pend)&&(*p==' ' || *p=='\t') ;p++); |
39 | 0 | return (char *)p; |
40 | 0 | } Unexecuted instantiation: dset.c:eat_space_end Unexecuted instantiation: msg_parser.c:eat_space_end Unexecuted instantiation: parse_fline.c:eat_space_end Unexecuted instantiation: sdp.c:eat_space_end Unexecuted instantiation: sdp_helpr_funcs.c:eat_space_end Unexecuted instantiation: parse_body.c:eat_space_end Unexecuted instantiation: parse_cseq.c:eat_space_end Unexecuted instantiation: parser_f.c:eat_space_end Unexecuted instantiation: parse_nameaddr.c:eat_space_end |
41 | 0 | #define SP(_c) ((_c)=='\t' || (_c)==' ') |
42 | | inline static char* eat_lws_end(const char* p, const char* pend) |
43 | 0 | { |
44 | 0 | while(p<pend) { |
45 | 0 | if (SP(*p)) p++; |
46 | | /* BTW--I really dislike line folding; -jiri */ |
47 | 0 | else if (*p=='\n' && p+1<pend && SP(*(p+1))) p+=2; |
48 | 0 | else if (*p=='\r' && p+2<pend && *(p+1)=='\n' |
49 | 0 | && SP(*(p+2))) p+=3; |
50 | 0 | else break; /* no whitespace encountered */ |
51 | 0 | } |
52 | 0 | return (char *)p; |
53 | 0 | } Unexecuted instantiation: dset.c:eat_lws_end Unexecuted instantiation: msg_parser.c:eat_lws_end Unexecuted instantiation: parse_fline.c:eat_lws_end Unexecuted instantiation: sdp.c:eat_lws_end Unexecuted instantiation: sdp_helpr_funcs.c:eat_lws_end Unexecuted instantiation: parse_body.c:eat_lws_end Unexecuted instantiation: parse_cseq.c:eat_lws_end Unexecuted instantiation: parser_f.c:eat_lws_end Unexecuted instantiation: parse_nameaddr.c:eat_lws_end |
54 | | |
55 | | |
56 | | |
57 | | inline static char* eat_token_end(const char* p, const char* pend) |
58 | 0 | { |
59 | 0 | for (;(p<pend)&&(*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r'); p++); |
60 | 0 | return (char *)p; |
61 | 0 | } Unexecuted instantiation: dset.c:eat_token_end Unexecuted instantiation: msg_parser.c:eat_token_end Unexecuted instantiation: parse_fline.c:eat_token_end Unexecuted instantiation: sdp.c:eat_token_end Unexecuted instantiation: sdp_helpr_funcs.c:eat_token_end Unexecuted instantiation: parse_body.c:eat_token_end Unexecuted instantiation: parse_cseq.c:eat_token_end Unexecuted instantiation: parser_f.c:eat_token_end Unexecuted instantiation: parse_nameaddr.c:eat_token_end |
62 | | |
63 | | |
64 | | |
65 | | inline static char* eat_token2_end(const char* p, const char* pend, char delim) |
66 | 0 | { |
67 | 0 | for (;(p<pend)&&(*p!=(delim))&&(*p!='\n')&&(*p!='\r'); p++); |
68 | 0 | return (char *)p; |
69 | 0 | } Unexecuted instantiation: dset.c:eat_token2_end Unexecuted instantiation: msg_parser.c:eat_token2_end Unexecuted instantiation: parse_fline.c:eat_token2_end Unexecuted instantiation: sdp.c:eat_token2_end Unexecuted instantiation: sdp_helpr_funcs.c:eat_token2_end Unexecuted instantiation: parse_body.c:eat_token2_end Unexecuted instantiation: parse_cseq.c:eat_token2_end Unexecuted instantiation: parser_f.c:eat_token2_end Unexecuted instantiation: parse_nameaddr.c:eat_token2_end |
70 | | |
71 | | |
72 | | |
73 | | inline static int is_empty_end(const char* p, const char* pend ) |
74 | 0 | { |
75 | 0 | p=eat_space_end(p, pend ); |
76 | 0 | return ((p<(pend )) && (*p=='\r' || *p=='\n')); |
77 | 0 | } Unexecuted instantiation: dset.c:is_empty_end Unexecuted instantiation: msg_parser.c:is_empty_end Unexecuted instantiation: parse_fline.c:is_empty_end Unexecuted instantiation: sdp.c:is_empty_end Unexecuted instantiation: sdp_helpr_funcs.c:is_empty_end Unexecuted instantiation: parse_body.c:is_empty_end Unexecuted instantiation: parse_cseq.c:is_empty_end Unexecuted instantiation: parser_f.c:is_empty_end Unexecuted instantiation: parse_nameaddr.c:is_empty_end |
78 | | |
79 | | |
80 | | /* |
81 | | * Find a character occurrence that is not quoted |
82 | | */ |
83 | | inline static char* find_not_quoted(str* _s, char _c) |
84 | 0 | { |
85 | 0 | int quoted = 0, i; |
86 | |
|
87 | 0 | for(i = 0; i < _s->len; i++) { |
88 | 0 | if (!quoted) { |
89 | 0 | if (_s->s[i] == '\"') quoted = 1; |
90 | 0 | else if (_s->s[i] == _c) return _s->s + i; |
91 | 0 | } else { |
92 | 0 | if ((_s->s[i] == '\"') && (_s->s[i - 1] != '\\')) quoted = 0; |
93 | 0 | } |
94 | 0 | } |
95 | 0 | return 0; |
96 | 0 | } Unexecuted instantiation: dset.c:find_not_quoted Unexecuted instantiation: msg_parser.c:find_not_quoted Unexecuted instantiation: parse_fline.c:find_not_quoted Unexecuted instantiation: sdp.c:find_not_quoted Unexecuted instantiation: sdp_helpr_funcs.c:find_not_quoted Unexecuted instantiation: parse_body.c:find_not_quoted Unexecuted instantiation: parse_cseq.c:find_not_quoted Unexecuted instantiation: parser_f.c:find_not_quoted Unexecuted instantiation: parse_nameaddr.c:find_not_quoted |
97 | | |
98 | | |
99 | | #endif /* parser_f_h */ |