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 |
/* $Id: boa_grammar.y,v 1.3 2002/09/25 06:42:34 nmav Exp $*/ |
24 |
|
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 |
#ifdef DEBUG |
36 |
#define DBG(x) x |
37 |
#else |
38 |
#define DBG(x) |
39 |
#endif |
40 |
|
41 |
char *arg1hold; |
42 |
char *arg2hold; |
43 |
char *arg3hold; |
44 |
char mime_type[256]; /* global to inherit */ |
45 |
|
46 |
%} |
47 |
|
48 |
%union { |
49 |
char * sval; |
50 |
int ival; |
51 |
struct ccommand * cval; |
52 |
}; |
53 |
|
54 |
/* boa.conf tokens */ |
55 |
%token <cval> STMT_NO_ARGS STMT_ONE_ARG STMT_TWO_ARGS STMT_THREE_ARGS STMT_FOUR_ARGS |
56 |
|
57 |
/* mime.type tokens */ |
58 |
%token <sval> MIMETYPE |
59 |
%token <sval> STRING |
60 |
%token <ival> INTEGER |
61 |
%token STRING_SEP ':' |
62 |
|
63 |
%start ConfigFiles |
64 |
|
65 |
%% |
66 |
|
67 |
ConfigFiles: BoaConfigStmts MimeTypeStmts |
68 |
; |
69 |
|
70 |
BoaConfigStmts: BoaConfigStmts BoaConfigStmt |
71 |
| /* empty */ |
72 |
; |
73 |
|
74 |
BoaConfigStmt: |
75 |
StmtNoArgs |
76 |
| StmtOneArg |
77 |
| StmtTwoArgs |
78 |
| StmtThreeArgs |
79 |
| StmtFourArgs |
80 |
; |
81 |
|
82 |
StmtNoArgs: STMT_NO_ARGS |
83 |
{ if ($1->action) { |
84 |
DBG(printf("StmtNoArgs: %s\n",$1->name);) |
85 |
$1->action(NULL, NULL, NULL,NULL,$1->object); |
86 |
} |
87 |
} |
88 |
; |
89 |
|
90 |
StmtOneArg: STMT_ONE_ARG STRING |
91 |
{ if ($1->action) { |
92 |
DBG(printf("StmtOneArg: %s %s\n",$1->name,$2);) |
93 |
$1->action($2,NULL, NULL, NULL,$1->object); |
94 |
} |
95 |
} |
96 |
; |
97 |
|
98 |
StmtTwoArgs: STMT_TWO_ARGS STRING |
99 |
{ arg1hold = strdup($2); } |
100 |
STRING |
101 |
{ if ($1->action) { |
102 |
DBG(printf("StmtTwoArgs: '%s' '%s' '%s'\n", |
103 |
$1->name,arg1hold,$4);) |
104 |
$1->action(arg1hold, $4,NULL, NULL, $1->object); |
105 |
} |
106 |
free(arg1hold); |
107 |
} |
108 |
; |
109 |
|
110 |
StmtThreeArgs: STMT_THREE_ARGS STRING |
111 |
{ arg1hold = strdup($2); } |
112 |
STRING |
113 |
{ arg2hold = strdup($4); } |
114 |
STRING |
115 |
{ if ($1->action) { |
116 |
DBG(printf("StmtThreeArgs: '%s' '%s' '%s' '%s'\n", |
117 |
$1->name,arg1hold, arg2hold, $6);) |
118 |
$1->action(arg1hold, arg2hold, $6, NULL, $1->object); |
119 |
} |
120 |
free(arg1hold); |
121 |
free(arg2hold); |
122 |
} |
123 |
; |
124 |
|
125 |
StmtFourArgs: STMT_FOUR_ARGS STRING |
126 |
{ arg1hold = strdup($2); } |
127 |
STRING |
128 |
{ arg2hold = strdup($4); } |
129 |
STRING |
130 |
{ arg3hold = strdup($6); } |
131 |
STRING |
132 |
{ if ($1->action) { |
133 |
DBG(printf("StmtFourArgs: '%s' '%s' '%s' '%s' '%s'\n", |
134 |
$1->name,arg1hold, arg2hold, arg3hold, $8);) |
135 |
$1->action(arg1hold, arg2hold, arg3hold, $8, $1->object); |
136 |
} |
137 |
free(arg1hold); |
138 |
free(arg2hold); |
139 |
free(arg3hold); |
140 |
} |
141 |
; |
142 |
|
143 |
/******************* mime.types **********************/ |
144 |
|
145 |
MimeTypeStmts: MimeTypeStmts MimeTypeStmt |
146 |
| /* empty */ |
147 |
; |
148 |
|
149 |
MimeTypeStmt: MIMETYPE |
150 |
{ strcpy(mime_type, $1); } |
151 |
ExtensionList |
152 |
; |
153 |
|
154 |
ExtensionList: ExtensionList Extension |
155 |
| /* empty */ |
156 |
; |
157 |
|
158 |
Extension: STRING |
159 |
{ add_mime_type($1, mime_type); } |
160 |
; |
161 |
|
162 |
%% |
163 |
|