Mercurial > hg > freeDiameter
comparison extensions/app_sip/diamsip.l @ 392:8e260030f32c
Added configuration file for app_sip and test_sip
author | Alexandre Westfahl <awestfahl@freediameter.net> |
---|---|
date | Tue, 06 Jul 2010 19:50:52 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
391:1042347401cc | 392:8e260030f32c |
---|---|
1 /********************************************************************************************************* | |
2 * Software License Agreement (BSD License) * | |
3 * Author: Alexandre Westfahl <awestfahl@freediameter.net> * | |
4 * * | |
5 * Copyright (c) 2010, Alexandre Westfahl, Teraoka Laboratory (Keio University), and the WIDE Project. * | |
6 * * | |
7 * All rights reserved. * | |
8 * Based on ta_conf.l (Sebastien Decugis <sdecugis@nict.go.jp>) * | |
9 * * | |
10 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
11 * permitted provided that the following conditions are met: * | |
12 * * | |
13 * * Redistributions of source code must retain the above * | |
14 * copyright notice, this list of conditions and the * | |
15 * following disclaimer. * | |
16 * * | |
17 * * Redistributions in binary form must reproduce the above * | |
18 * copyright notice, this list of conditions and the * | |
19 * following disclaimer in the documentation and/or other * | |
20 * materials provided with the distribution. * | |
21 * * | |
22 * * Neither the name of the Teraoka Laboratory nor the * | |
23 * names of its contributors may be used to endorse or * | |
24 * promote products derived from this software without * | |
25 * specific prior written permission of Teraoka Laboratory * | |
26 * * | |
27 * * | |
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
30 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
31 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
36 *********************************************************************************************************/ | |
37 | |
38 | |
39 | |
40 %{ | |
41 #include "diamsip.h" | |
42 /* Include yacc tokens definitions */ | |
43 #include "diamsip.tab.h" | |
44 | |
45 /* Update the column information */ | |
46 #define YY_USER_ACTION { \ | |
47 yylloc->first_column = yylloc->last_column + 1; \ | |
48 yylloc->last_column = yylloc->first_column + yyleng - 1; \ | |
49 } | |
50 | |
51 /* Avoid warning with newer flex */ | |
52 #define YY_NO_INPUT | |
53 | |
54 %} | |
55 | |
56 %option bison-bridge bison-locations | |
57 %option noyywrap | |
58 %option nounput | |
59 | |
60 %% | |
61 | |
62 /* Update the line count */ | |
63 \n { | |
64 yylloc->first_line++; | |
65 yylloc->last_line++; | |
66 yylloc->last_column=0; | |
67 } | |
68 | |
69 /* Eat all spaces but not new lines */ | |
70 ([[:space:]]{-}[\n])+ ; | |
71 /* Eat all comments */ | |
72 #.*$ ; | |
73 | |
74 /* Recognize any integer */ | |
75 [-]?[[:digit:]]+ { | |
76 /* Convert this to an integer value */ | |
77 int ret=0; | |
78 ret = sscanf(yytext, "%i", &yylval->integer); | |
79 if (ret != 1) { | |
80 /* No matching: an error occurred */ | |
81 fd_log_debug("Unable to convert the value '%s' to a valid number: %s\n", yytext, strerror(errno)); | |
82 return LEX_ERROR; /* trig an error in yacc parser */ | |
83 /* Maybe we could REJECT instead of failing here? */ | |
84 } | |
85 return INTEGER; | |
86 } | |
87 | |
88 /* Recognize quoted strings -- we do not support escaped \" in the string currently. */ | |
89 \"[^\"]+\" { | |
90 /* Match a quoted string. Let's be very permissive. */ | |
91 yylval->string = strdup(yytext+1); | |
92 if (!yylval->string) { | |
93 fd_log_debug("Unable to copy the string '%s': %s\n", yytext, strerror(errno)); | |
94 TRACE_DEBUG(INFO, "strdup failed"); | |
95 return LEX_ERROR; /* trig an error in yacc parser */ | |
96 } | |
97 yylval->string[strlen(yytext) - 2] = '\0'; | |
98 return QSTRING; | |
99 } | |
100 | |
101 | |
102 | |
103 /* Recognize the tokens */ | |
104 (?i:"mysql_login") { | |
105 return ASMYSQL_LOGIN; | |
106 } | |
107 | |
108 (?i:"mysql_password") { | |
109 return ASMYSQL_PASSWORD; | |
110 } | |
111 | |
112 (?i:"mysql_database") { | |
113 return ASMYSQL_DATABASE; | |
114 } | |
115 | |
116 (?i:"mysql_server") { | |
117 return ASMYSQL_SERVER; | |
118 } | |
119 | |
120 (?i:"mysql_port") { | |
121 return ASMYSQL_PORT; | |
122 } | |
123 | |
124 (?i:"mode") { | |
125 return MODE; | |
126 } | |
127 | |
128 (?i:"datasource") { | |
129 return DATASOURCE; | |
130 } | |
131 | |
132 (?i:"mysql") { | |
133 yylval->integer = ASMYSQL; | |
134 return INTEGER; | |
135 } | |
136 (?i:"dsserver") { | |
137 yylval->integer = MODE_DSSERVER; | |
138 return INTEGER; | |
139 } | |
140 | |
141 (?i:"sl") { | |
142 yylval->integer = MODE_SL; | |
143 return INTEGER; | |
144 } | |
145 | |
146 | |
147 | |
148 /* Valid single characters for yyparse */ | |
149 [=;] { return yytext[0]; } | |
150 | |
151 /* Unrecognized sequence, if it did not match any previous pattern */ | |
152 [^[:space:]"*=>;\n]+ { | |
153 fd_log_debug("Unrecognized text on line %d col %d: '%s'.\n", yylloc->first_line, yylloc->first_column, yytext); | |
154 return LEX_ERROR; | |
155 } | |
156 | |
157 %% |