Coverage Report

Created: 2024-02-25 06:34

/src/kamailio/src/core/parser/parser_f.h
Line
Count
Source
1
/*
2
 * Copyright (C) 2001-2003 FhG Fokus
3
 *
4
 * This file is part of Kamailio, a free SIP server.
5
 *
6
 * Kamailio 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
 * Kamailio 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
 */
21
22
/*! \file
23
 * \brief Parser :: Parser helper functions
24
 *
25
 * turn the most frequently called functions into inline functions
26
 *
27
 * \ingroup parser
28
 */
29
30
31
#ifndef parser_f_h
32
#define parser_f_h
33
34
#include "../comp_defs.h"
35
#include "../str.h"
36
37
char *eat_line(char *buffer, unsigned int len);
38
39
/* turn the most frequently called functions into inline functions */
40
41
inline static char *eat_space_end(const char *p, const char *pend)
42
52.2k
{
43
88.5k
  for(; (p < pend) && (*p == ' ' || *p == '\t'); p++)
44
36.2k
    ;
45
52.2k
  return (char *)p;
46
52.2k
}
Unexecuted instantiation: msg_parser.c:eat_space_end
parse_cseq.c:eat_space_end
Line
Count
Source
42
16.5k
{
43
33.6k
  for(; (p < pend) && (*p == ' ' || *p == '\t'); p++)
44
17.1k
    ;
45
16.5k
  return (char *)p;
46
16.5k
}
parse_fline.c:eat_space_end
Line
Count
Source
42
35.7k
{
43
54.9k
  for(; (p < pend) && (*p == ' ' || *p == '\t'); p++)
44
19.1k
    ;
45
35.7k
  return (char *)p;
46
35.7k
}
Unexecuted instantiation: parse_identityinfo.c:eat_space_end
Unexecuted instantiation: parse_retry_after.c:eat_space_end
Unexecuted instantiation: parser_f.c:eat_space_end
Unexecuted instantiation: sdp.c:eat_space_end
Unexecuted instantiation: sdp_helpr_funcs.c:eat_space_end
Unexecuted instantiation: select_core.c:eat_space_end
Unexecuted instantiation: dset.c:eat_space_end
Unexecuted instantiation: parse_body.c:eat_space_end
Unexecuted instantiation: parse_date.c:eat_space_end
Unexecuted instantiation: parse_identity.c:eat_space_end
Unexecuted instantiation: parse_nameaddr.c:eat_space_end
Unexecuted instantiation: parse_subscription_state.c:eat_space_end
47
289k
#define SP(_c) ((_c) == '\t' || (_c) == ' ')
48
inline static char *eat_lws_end(const char *p, const char *pend)
49
240k
{
50
251k
  while(p < pend) {
51
249k
    if(SP(*p))
52
7.99k
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
241k
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
2.19k
      p += 2;
56
239k
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
1.28k
      p += 3;
58
237k
    else
59
237k
      break; /* no whitespace encountered */
60
249k
  }
61
240k
  return (char *)p;
62
240k
}
msg_parser.c:eat_lws_end
Line
Count
Source
49
218k
{
50
222k
  while(p < pend) {
51
221k
    if(SP(*p))
52
2.66k
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
219k
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
657
      p += 2;
56
218k
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
249
      p += 3;
58
218k
    else
59
218k
      break; /* no whitespace encountered */
60
221k
  }
61
218k
  return (char *)p;
62
218k
}
parse_cseq.c:eat_lws_end
Line
Count
Source
49
16.2k
{
50
21.0k
  while(p < pend) {
51
19.0k
    if(SP(*p))
52
3.79k
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
15.2k
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
551
      p += 2;
56
14.6k
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
429
      p += 3;
58
14.2k
    else
59
14.2k
      break; /* no whitespace encountered */
60
19.0k
  }
61
16.2k
  return (char *)p;
62
16.2k
}
Unexecuted instantiation: parse_fline.c:eat_lws_end
parse_identityinfo.c:eat_lws_end
Line
Count
Source
49
75
{
50
1.88k
  while(p < pend) {
51
1.88k
    if(SP(*p))
52
1.10k
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
783
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
512
      p += 2;
56
271
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
196
      p += 3;
58
75
    else
59
75
      break; /* no whitespace encountered */
60
1.88k
  }
61
75
  return (char *)p;
62
75
}
parse_retry_after.c:eat_lws_end
Line
Count
Source
49
2.21k
{
50
2.21k
  while(p < pend) {
51
2.21k
    if(SP(*p))
52
0
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
2.21k
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
0
      p += 2;
56
2.21k
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
0
      p += 3;
58
2.21k
    else
59
2.21k
      break; /* no whitespace encountered */
60
2.21k
  }
61
2.21k
  return (char *)p;
62
2.21k
}
Unexecuted instantiation: parser_f.c:eat_lws_end
Unexecuted instantiation: sdp.c:eat_lws_end
sdp_helpr_funcs.c:eat_lws_end
Line
Count
Source
49
3.13k
{
50
4.45k
  while(p < pend) {
51
4.41k
    if(SP(*p))
52
431
      p++;
53
    /* BTW--I really dislike line folding; -jiri */
54
3.98k
    else if(*p == '\n' && p + 1 < pend && SP(*(p + 1)))
55
475
      p += 2;
56
3.51k
    else if(*p == '\r' && p + 2 < pend && *(p + 1) == '\n' && SP(*(p + 2)))
57
414
      p += 3;
58
3.09k
    else
59
3.09k
      break; /* no whitespace encountered */
60
4.41k
  }
61
3.13k
  return (char *)p;
62
3.13k
}
Unexecuted instantiation: select_core.c:eat_lws_end
Unexecuted instantiation: dset.c:eat_lws_end
Unexecuted instantiation: parse_body.c:eat_lws_end
Unexecuted instantiation: parse_date.c:eat_lws_end
Unexecuted instantiation: parse_identity.c:eat_lws_end
Unexecuted instantiation: parse_nameaddr.c:eat_lws_end
Unexecuted instantiation: parse_subscription_state.c:eat_lws_end
63
64
65
inline static char *eat_token_end(const char *p, const char *pend)
66
87.5k
{
67
8.01M
  for(; (p < pend) && (*p != ' ') && (*p != '\t') && (*p != '\n')
68
8.01M
      && (*p != '\r');
69
7.93M
      p++)
70
7.93M
    ;
71
87.5k
  return (char *)p;
72
87.5k
}
Unexecuted instantiation: msg_parser.c:eat_token_end
parse_cseq.c:eat_token_end
Line
Count
Source
66
33.1k
{
67
6.79M
  for(; (p < pend) && (*p != ' ') && (*p != '\t') && (*p != '\n')
68
6.79M
      && (*p != '\r');
69
6.75M
      p++)
70
6.75M
    ;
71
33.1k
  return (char *)p;
72
33.1k
}
parse_fline.c:eat_token_end
Line
Count
Source
66
54.4k
{
67
1.22M
  for(; (p < pend) && (*p != ' ') && (*p != '\t') && (*p != '\n')
68
1.22M
      && (*p != '\r');
69
1.17M
      p++)
70
1.17M
    ;
71
54.4k
  return (char *)p;
72
54.4k
}
Unexecuted instantiation: parse_identityinfo.c:eat_token_end
Unexecuted instantiation: parse_retry_after.c:eat_token_end
Unexecuted instantiation: parser_f.c:eat_token_end
Unexecuted instantiation: sdp.c:eat_token_end
Unexecuted instantiation: sdp_helpr_funcs.c:eat_token_end
Unexecuted instantiation: select_core.c:eat_token_end
Unexecuted instantiation: dset.c:eat_token_end
Unexecuted instantiation: parse_body.c:eat_token_end
Unexecuted instantiation: parse_date.c:eat_token_end
Unexecuted instantiation: parse_identity.c:eat_token_end
Unexecuted instantiation: parse_nameaddr.c:eat_token_end
Unexecuted instantiation: parse_subscription_state.c:eat_token_end
73
74
75
inline static char *eat_token2_end(const char *p, const char *pend, char delim)
76
65
{
77
320
  for(; (p < pend) && (*p != (delim)) && (*p != '\n') && (*p != '\r'); p++)
78
255
    ;
79
65
  return (char *)p;
80
65
}
Unexecuted instantiation: msg_parser.c:eat_token2_end
Unexecuted instantiation: parse_cseq.c:eat_token2_end
parse_fline.c:eat_token2_end
Line
Count
Source
76
65
{
77
320
  for(; (p < pend) && (*p != (delim)) && (*p != '\n') && (*p != '\r'); p++)
78
255
    ;
79
65
  return (char *)p;
80
65
}
Unexecuted instantiation: parse_identityinfo.c:eat_token2_end
Unexecuted instantiation: parse_retry_after.c:eat_token2_end
Unexecuted instantiation: parser_f.c:eat_token2_end
Unexecuted instantiation: sdp.c:eat_token2_end
Unexecuted instantiation: sdp_helpr_funcs.c:eat_token2_end
Unexecuted instantiation: select_core.c:eat_token2_end
Unexecuted instantiation: dset.c:eat_token2_end
Unexecuted instantiation: parse_body.c:eat_token2_end
Unexecuted instantiation: parse_date.c:eat_token2_end
Unexecuted instantiation: parse_identity.c:eat_token2_end
Unexecuted instantiation: parse_nameaddr.c:eat_token2_end
Unexecuted instantiation: parse_subscription_state.c:eat_token2_end
81
82
83
inline static int is_empty_end(const char *p, const char *pend)
84
17.7k
{
85
17.7k
  p = eat_space_end(p, pend);
86
17.7k
  return ((p < (pend)) && (*p == '\r' || *p == '\n'));
87
17.7k
}
Unexecuted instantiation: msg_parser.c:is_empty_end
Unexecuted instantiation: parse_cseq.c:is_empty_end
parse_fline.c:is_empty_end
Line
Count
Source
84
17.7k
{
85
17.7k
  p = eat_space_end(p, pend);
86
17.7k
  return ((p < (pend)) && (*p == '\r' || *p == '\n'));
87
17.7k
}
Unexecuted instantiation: parse_identityinfo.c:is_empty_end
Unexecuted instantiation: parse_retry_after.c:is_empty_end
Unexecuted instantiation: parser_f.c:is_empty_end
Unexecuted instantiation: sdp.c:is_empty_end
Unexecuted instantiation: sdp_helpr_funcs.c:is_empty_end
Unexecuted instantiation: select_core.c:is_empty_end
Unexecuted instantiation: dset.c:is_empty_end
Unexecuted instantiation: parse_body.c:is_empty_end
Unexecuted instantiation: parse_date.c:is_empty_end
Unexecuted instantiation: parse_identity.c:is_empty_end
Unexecuted instantiation: parse_nameaddr.c:is_empty_end
Unexecuted instantiation: parse_subscription_state.c:is_empty_end
88
89
90
/*
91
 * Find a character occurrence that is not quoted
92
 */
93
inline static char *find_not_quoted(str *_s, char _c)
94
15.1k
{
95
15.1k
  int quoted = 0, i;
96
97
851k
  for(i = 0; i < _s->len; i++) {
98
851k
    if(!quoted) {
99
637k
      if(_s->s[i] == '\"')
100
2.61k
        quoted = 1;
101
634k
      else if(_s->s[i] == _c)
102
14.9k
        return _s->s + i;
103
637k
    } else {
104
213k
      if((_s->s[i] == '\"') && (_s->s[i - 1] != '\\'))
105
2.56k
        quoted = 0;
106
213k
    }
107
851k
  }
108
203
  return 0;
109
15.1k
}
Unexecuted instantiation: msg_parser.c:find_not_quoted
Unexecuted instantiation: parse_cseq.c:find_not_quoted
Unexecuted instantiation: parse_fline.c:find_not_quoted
Unexecuted instantiation: parse_identityinfo.c:find_not_quoted
Unexecuted instantiation: parse_retry_after.c:find_not_quoted
Unexecuted instantiation: parser_f.c:find_not_quoted
Unexecuted instantiation: sdp.c:find_not_quoted
Unexecuted instantiation: sdp_helpr_funcs.c:find_not_quoted
Unexecuted instantiation: select_core.c:find_not_quoted
Unexecuted instantiation: dset.c:find_not_quoted
Unexecuted instantiation: parse_body.c:find_not_quoted
Unexecuted instantiation: parse_date.c:find_not_quoted
Unexecuted instantiation: parse_identity.c:find_not_quoted
parse_nameaddr.c:find_not_quoted
Line
Count
Source
94
15.1k
{
95
15.1k
  int quoted = 0, i;
96
97
851k
  for(i = 0; i < _s->len; i++) {
98
851k
    if(!quoted) {
99
637k
      if(_s->s[i] == '\"')
100
2.61k
        quoted = 1;
101
634k
      else if(_s->s[i] == _c)
102
14.9k
        return _s->s + i;
103
637k
    } else {
104
213k
      if((_s->s[i] == '\"') && (_s->s[i - 1] != '\\'))
105
2.56k
        quoted = 0;
106
213k
    }
107
851k
  }
108
203
  return 0;
109
15.1k
}
Unexecuted instantiation: parse_subscription_state.c:find_not_quoted
110
111
112
#endif /* parser_f_h */