blob: 5ea9ac32d05c13fcb387fdd50e4b6e4d5d196169 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
Copyright (C) 2005-2009 Michel de Boer <michel@twinklephone.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
%{
#include <string>
#include "sdp_parse_ctrl.h"
#include "sdp_parser.h"
#include "audits/memman.h"
using namespace std;
%}
%option noyywrap
%option stack
DIGIT [0-9]
ALPHA [a-zA-Z]
ALNUM [a-zA-Z0-9]
TOKEN_SYM [[:alnum:]\-\.!%\*_\+\'~]
SAFE_SYM [[:alnum:]'`\-\.\/:\?\"#\$&\*;=@\[\]\^_\{|\}\+~\"]
%x C_NUM
%x C_LINE
%x C_SAFE
%%
switch (t_sdp_parser::context) {
case t_sdp_parser::X_NUM: BEGIN(C_NUM); break;
case t_sdp_parser::X_LINE: BEGIN(C_LINE); break;
case t_sdp_parser::X_SAFE: BEGIN(C_SAFE); break;
default: BEGIN(INITIAL);
}
/* SDP lines */
^v= { return T_LINE_VERSION; }
^o= { return T_LINE_ORIGIN; }
^s= { return T_LINE_SESSION_NAME; }
^c= { return T_LINE_CONNECTION; }
^a= { return T_LINE_ATTRIBUTE; }
^m= { return T_LINE_MEDIA; }
^{ALPHA}= { return T_LINE_UNKNOWN; }
/* Token as define in RFC 3261 */
{TOKEN_SYM}+ { yysdplval.yysdpt_str = new string(yysdptext);
MEMMAN_NEW(yysdplval.yysdpt_str);
return T_TOKEN; }
/* End of line */
\r\n { return T_CRLF; }
\n { return T_CRLF; }
[[:blank:]] /* Skip white space */
/* Single character token */
. { return yysdptext[0]; }
/* Number */
<C_NUM>{DIGIT}+ { yysdplval.yysdpt_int = atoi(yysdptext);
return T_NUM; }
<C_NUM>[[:blank:]] /* Skip white space */
<C_NUM>. { return yysdptext[0]; }
<C_NUM>\r\n { return T_CRLF; }
<C_NUM>\n { return T_CRLF; }
/* Safe */
<C_SAFE>{SAFE_SYM}+ { yysdplval.yysdpt_str = new string(yysdptext);
MEMMAN_NEW(yysdplval.yysdpt_str);
return T_SAFE; }
<C_SAFE>[[:blank:]] /* Skip white space */
<C_SAFE>. { return yysdptext[0]; }
<C_SAFE>\r\n { return T_CRLF; }
<C_SAFE>\n { return T_CRLF; }
/* Get all text till end of line */
<C_LINE>[^\r\n]+ { yysdplval.yysdpt_str = new string(yysdptext);
MEMMAN_NEW(yysdplval.yysdpt_str);
return T_LINE; }
<C_LINE>\r\n { return T_CRLF; }
<C_LINE>\n { return T_CRLF; }
<C_LINE>\r { return T_CRLF; }
|