/[hydra]/hydra/src/boa_grammar.y
ViewVC logotype

Annotation of /hydra/src/boa_grammar.y

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Wed Sep 25 06:42:34 2002 UTC (19 years, 2 months ago) by nmav
Branch: MAIN
CVS Tags: hydra_0_0_8, hydra_0_0_2, hydra_0_0_3, hydra_0_0_6, hydra_0_0_7, hydra_0_0_4, hydra_0_0_5
Changes since 1.2: +21 -3 lines
Cleanups. Added support for 3 argument options in the grammar (I'll probably rewrite it soon). Changed the Alias, ScriptAlias and Redirect options, to use the virtual hosting stuff.

1 nmav 1.1 %{
2    
3     /*
4     * Boa, an http server
5     * Copyright (C) 1995 Paul Phillips <psp@well.com>
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 1, or (at your option)
10     * any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20     *
21     */
22    
23 nmav 1.3 /* $Id: boa_grammar.y,v 1.2 2002/09/24 17:12:47 nmav Exp $*/
24 nmav 1.1
25     #include <string.h>
26     #include <stdio.h>
27     #include <stdlib.h>
28     #include <unistd.h>
29     /* #include "boa.h" */
30     #include "parse.h"
31    
32     int yyerror(char * msg);
33    
34     /* yydebug = 1; */
35    
36     #ifdef DEBUG
37     #define DBG(x) x
38     #else
39     #define DBG(x)
40     #endif
41    
42     char *arg1hold;
43 nmav 1.2 char *arg2hold;
44     char *arg3hold;
45 nmav 1.1 char mime_type[256]; /* global to inherit */
46    
47     %}
48    
49     %union {
50     char * sval;
51     int ival;
52     struct ccommand * cval;
53     };
54    
55     /* boa.conf tokens */
56 nmav 1.3 %token <cval> STMT_NO_ARGS STMT_ONE_ARG STMT_TWO_ARGS STMT_THREE_ARGS STMT_FOUR_ARGS
57 nmav 1.1
58     /* mime.type tokens */
59     %token <sval> MIMETYPE
60     %token <sval> STRING
61     %token <ival> INTEGER
62 nmav 1.2 %token STRING_SEP ':'
63 nmav 1.1
64     %start ConfigFiles
65    
66     %%
67    
68     ConfigFiles: BoaConfigStmts MimeTypeStmts
69     ;
70    
71     BoaConfigStmts: BoaConfigStmts BoaConfigStmt
72     | /* empty */
73     ;
74    
75     BoaConfigStmt:
76     StmtNoArgs
77     | StmtOneArg
78     | StmtTwoArgs
79 nmav 1.3 | StmtThreeArgs
80 nmav 1.2 | StmtFourArgs
81 nmav 1.1 ;
82    
83     StmtNoArgs: STMT_NO_ARGS
84     { if ($1->action) {
85     DBG(printf("StmtNoArgs: %s\n",$1->name);)
86 nmav 1.2 $1->action(NULL, NULL, NULL,NULL,$1->object);
87 nmav 1.1 }
88     }
89     ;
90    
91     StmtOneArg: STMT_ONE_ARG STRING
92     { if ($1->action) {
93     DBG(printf("StmtOneArg: %s %s\n",$1->name,$2);)
94 nmav 1.2 $1->action($2,NULL, NULL, NULL,$1->object);
95 nmav 1.1 }
96     }
97     ;
98    
99     StmtTwoArgs: STMT_TWO_ARGS STRING
100     { arg1hold = strdup($2); }
101     STRING
102     { if ($1->action) {
103     DBG(printf("StmtTwoArgs: '%s' '%s' '%s'\n",
104     $1->name,arg1hold,$4);)
105 nmav 1.2 $1->action($4,arg1hold,NULL, NULL, $1->object);
106 nmav 1.1 }
107     free(arg1hold);
108     }
109 nmav 1.3 ;
110    
111     StmtThreeArgs: STMT_THREE_ARGS STRING
112     { arg1hold = strdup($2); }
113     STRING
114     { arg2hold = strdup($4); }
115     STRING
116     { if ($1->action) {
117     DBG(printf("StmtThreeArgs: '%s' '%s' '%s' '%s'\n",
118     $1->name,arg1hold, arg2hold, $6);)
119     $1->action(arg1hold, arg2hold, $6, NULL, $1->object);
120     }
121     free(arg1hold);
122     free(arg2hold);
123     }
124     ;
125    
126 nmav 1.2 StmtFourArgs: STMT_FOUR_ARGS STRING
127     { arg1hold = strdup($2); }
128     STRING
129     { arg2hold = strdup($4); }
130     STRING
131     { arg3hold = strdup($6); }
132     STRING
133     { if ($1->action) {
134 nmav 1.3 DBG(printf("StmtFourArgs: '%s' '%s' '%s' '%s' '%s'\n",
135 nmav 1.2 $1->name,arg1hold, arg2hold, arg3hold, $8);)
136     $1->action(arg1hold, arg2hold, arg3hold, $8, $1->object);
137     }
138     free(arg1hold);
139     free(arg2hold);
140     free(arg3hold);
141     }
142 nmav 1.1 ;
143    
144     /******************* mime.types **********************/
145    
146     MimeTypeStmts: MimeTypeStmts MimeTypeStmt
147     | /* empty */
148     ;
149    
150     MimeTypeStmt: MIMETYPE
151     { strcpy(mime_type, $1); }
152     ExtensionList
153     ;
154    
155     ExtensionList: ExtensionList Extension
156     | /* empty */
157     ;
158    
159     Extension: STRING
160     { add_mime_type($1, mime_type); }
161     ;
162    
163     %%
164    

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26