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.14 1999/10/12 14:49:07 jon 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 |
|
36 |
#ifdef DEBUG |
37 |
#define DBG(x) x |
38 |
#else |
39 |
#define DBG(x) |
40 |
#endif |
41 |
|
42 |
char *arg1hold; |
43 |
char mime_type[256]; /* global to inherit */ |
44 |
|
45 |
%} |
46 |
|
47 |
%union { |
48 |
char * sval; |
49 |
int ival; |
50 |
struct ccommand * cval; |
51 |
}; |
52 |
|
53 |
/* boa.conf tokens */ |
54 |
%token <cval> STMT_NO_ARGS STMT_ONE_ARG STMT_TWO_ARGS |
55 |
|
56 |
/* mime.type tokens */ |
57 |
%token <sval> MIMETYPE |
58 |
%token <sval> STRING |
59 |
%token <ival> INTEGER |
60 |
|
61 |
%start ConfigFiles |
62 |
|
63 |
%% |
64 |
|
65 |
ConfigFiles: BoaConfigStmts MimeTypeStmts |
66 |
; |
67 |
|
68 |
BoaConfigStmts: BoaConfigStmts BoaConfigStmt |
69 |
| /* empty */ |
70 |
; |
71 |
|
72 |
BoaConfigStmt: |
73 |
StmtNoArgs |
74 |
| StmtOneArg |
75 |
| StmtTwoArgs |
76 |
; |
77 |
|
78 |
StmtNoArgs: STMT_NO_ARGS |
79 |
{ if ($1->action) { |
80 |
DBG(printf("StmtNoArgs: %s\n",$1->name);) |
81 |
$1->action(NULL,NULL,$1->object); |
82 |
} |
83 |
} |
84 |
; |
85 |
|
86 |
StmtOneArg: STMT_ONE_ARG STRING |
87 |
{ if ($1->action) { |
88 |
DBG(printf("StmtOneArg: %s %s\n",$1->name,$2);) |
89 |
$1->action($2,NULL,$1->object); |
90 |
} |
91 |
} |
92 |
; |
93 |
|
94 |
StmtTwoArgs: STMT_TWO_ARGS STRING |
95 |
{ arg1hold = strdup($2); } |
96 |
STRING |
97 |
{ if ($1->action) { |
98 |
DBG(printf("StmtTwoArgs: '%s' '%s' '%s'\n", |
99 |
$1->name,arg1hold,$4);) |
100 |
$1->action($4,arg1hold,$1->object); |
101 |
} |
102 |
free(arg1hold); |
103 |
} |
104 |
; |
105 |
|
106 |
|
107 |
/******************* mime.types **********************/ |
108 |
|
109 |
MimeTypeStmts: MimeTypeStmts MimeTypeStmt |
110 |
| /* empty */ |
111 |
; |
112 |
|
113 |
MimeTypeStmt: MIMETYPE |
114 |
{ strcpy(mime_type, $1); } |
115 |
ExtensionList |
116 |
; |
117 |
|
118 |
ExtensionList: ExtensionList Extension |
119 |
| /* empty */ |
120 |
; |
121 |
|
122 |
Extension: STRING |
123 |
{ add_mime_type($1, mime_type); } |
124 |
; |
125 |
|
126 |
%% |
127 |
|