annotate extensions/rt_ereg/rtereg_conf.y @ 740:4a9f08d6b6ba

Updated my mail address
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 24 Mar 2011 15:00:18 +0900
parents ecfa089bd29a
children d59decafe9c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
525
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 525
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
525
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
5 * Copyright (c) 2010, WIDE Project and NICT *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 /* Yacc extension's configuration parser.
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37 */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 /* For development only : */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 %debug
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41 %error-verbose
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
42
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
43 /* The parser receives the configuration file filename as parameter */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44 %parse-param {char * conffile}
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 /* Keep track of location */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 %locations
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 %pure-parser
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 %{
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 #include "rtereg.h"
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 #include "rtereg_conf.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54 /* Forward declaration */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 int yyparse(char * conffile);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 /* Parse the configuration file */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 int rtereg_conf_handle(char * conffile)
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 extern FILE * rtereg_confin;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 int ret;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 TRACE_ENTRY("%p", conffile);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 TRACE_DEBUG (FULL, "Parsing configuration file: %s...", conffile);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67 rtereg_confin = fopen(conffile, "r");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 if (rtereg_confin == NULL) {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69 ret = errno;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 fd_log_debug("Unable to open extension configuration file %s for reading: %s\n", conffile, strerror(ret));
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71 TRACE_DEBUG (INFO, "Error occurred, message logged -- configuration file.");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72 return ret;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
73 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75 ret = yyparse(conffile);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77 fclose(rtereg_confin);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 if (ret != 0) {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
80 TRACE_DEBUG (INFO, "Unable to parse the configuration file.");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
81 return EINVAL;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 } else {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83 TRACE_DEBUG(FULL, "[rt-ereg] Added %d rules successfully.", rtereg_conf.rules_nb);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
86 return 0;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
87 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 /* The Lex parser prototype */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 int rtereg_conflex(YYSTYPE *lvalp, YYLTYPE *llocp);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 /* Function to report the errors */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 void yyerror (YYLTYPE *ploc, char * conffile, char const *s)
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 TRACE_DEBUG(INFO, "Error in configuration parsing");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 if (ploc->first_line != ploc->last_line)
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98 fd_log_debug("%s:%d.%d-%d.%d : %s\n", conffile, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 else if (ploc->first_column != ploc->last_column)
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 fd_log_debug("%s:%d.%d-%d : %s\n", conffile, ploc->first_line, ploc->first_column, ploc->last_column, s);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 else
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102 fd_log_debug("%s:%d.%d : %s\n", conffile, ploc->first_line, ploc->first_column, s);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
105 %}
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107 /* Values returned by lex for token */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
108 %union {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
109 char *string; /* The string is allocated by strdup in lex.*/
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110 int integer;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 /* In case of error in the lexical analysis */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 %token LEX_ERROR
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116 /* A (de)quoted string (malloc'd in lex parser; it must be freed after use) */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 %token <string> QSTRING
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118 %token <integer> INTEGER
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
119
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
120 /* Tokens */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121 %token AVP
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 /* -------------------------------------- */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 %%
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
127 /* The grammar definition */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 conffile: rules avp rules
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129 ;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 /* a server entry */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132 avp: AVP '=' QSTRING ';'
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 if (rtereg_conf.avp != NULL) {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135 yyerror(&yylloc, conffile, "Only one AVP can be specified");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 YYERROR;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
137 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139 CHECK_FCT_DO( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, $3, &rtereg_conf.avp, ENOENT ),
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 TRACE_DEBUG(INFO, "Unable to find '%s' AVP in the loaded dictionaries.", $3);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 yyerror (&yylloc, conffile, "Invalid AVP value.");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 YYERROR;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 } );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 /* Now check the type */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 struct dict_avp_data data;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 CHECK_FCT( fd_dict_getval( rtereg_conf.avp, &data) );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 CHECK_PARAMS_DO (data.avp_basetype == AVP_TYPE_OCTETSTRING,
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 TRACE_DEBUG(INFO, "'%s' AVP in not an OCTETSTRING AVP (%d).", $3, data.avp_basetype);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 yyerror (&yylloc, conffile, "AVP in not an OCTETSTRING type.");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 YYERROR;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 } );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
157 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158 ;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160 rules: /* empty OK */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161 | rules rule
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 ;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
163
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 rule: QSTRING ':' QSTRING '+' '=' INTEGER ';'
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 struct rtereg_rule * new;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 int err;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 /* Add new rule in the array */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 rtereg_conf.rules_nb += 1;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 CHECK_MALLOC_DO(rtereg_conf.rules = realloc(rtereg_conf.rules, rtereg_conf.rules_nb * sizeof(struct rtereg_rule)),
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 yyerror (&yylloc, conffile, "Not enough memory to store the configuration...");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 YYERROR;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175 } );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177 new = &rtereg_conf.rules[rtereg_conf.rules_nb - 1];
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
178
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
179 new->pattern = $1;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
180 new->server = $3;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181 new->score = $6;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
182
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
183 /* Attempt to compile the regex */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
184 CHECK_FCT_DO( err=regcomp(&new->preg, new->pattern, REG_EXTENDED | REG_NOSUB),
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185 {
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186 char * buf;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
187 size_t bl;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
188
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
189 /* Error while compiling the regex */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
190 TRACE_DEBUG(INFO, "Error while compiling the regular expression '%s':", new->pattern);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
191
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
192 /* Get the error message size */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
193 bl = regerror(err, &new->preg, NULL, 0);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
194
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
195 /* Alloc the buffer for error message */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
196 CHECK_MALLOC( buf = malloc(bl) );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
197
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
198 /* Get the error message content */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
199 regerror(err, &new->preg, buf, bl);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200 TRACE_DEBUG(INFO, "\t%s", buf);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
201
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 /* Free the buffer, return the error */
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
203 free(buf);
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
204
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
205 yyerror (&yylloc, conffile, "Invalid regular expression.");
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206 YYERROR;
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207 } );
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
208 }
ecfa089bd29a Forgot new files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
209 ;
"Welcome to our mercurial repository"