2002-04-03 01:17:30 +08:00
|
|
|
/* $Id: grammar.y,v 1.7 2002-04-02 17:17:30 rjkaes Exp $
|
2000-09-12 08:12:52 +08:00
|
|
|
*
|
|
|
|
* This is the grammar for tinyproxy's configuration file. It needs to be
|
|
|
|
* in sync with scanner.l. If you know more about yacc and lex than I do
|
|
|
|
* please update these files.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Robert James Kaes (rjkaes@flarenet.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
#include "tinyproxy.h"
|
|
|
|
|
|
|
|
#include "acl.h"
|
|
|
|
#include "anonymous.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "thread.h"
|
|
|
|
|
|
|
|
void yyerror(char *s);
|
|
|
|
int yylex(void);
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
unsigned int num;
|
|
|
|
char *cptr;
|
|
|
|
void *ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* statements */
|
|
|
|
%token KW_PORT KW_LISTEN
|
|
|
|
%token KW_LOGFILE KW_PIDFILE KW_SYSLOG
|
|
|
|
%token KW_MAXCLIENTS KW_MAXSPARESERVERS KW_MINSPARESERVERS KW_STARTSERVERS
|
|
|
|
%token KW_MAXREQUESTSPERCHILD
|
|
|
|
%token KW_TIMEOUT
|
|
|
|
%token KW_USER KW_GROUP
|
2001-09-17 04:08:24 +08:00
|
|
|
%token KW_ANONYMOUS KW_FILTER KW_XTINYPROXY
|
|
|
|
%token KW_TUNNEL KW_UPSTREAM
|
2000-09-12 08:12:52 +08:00
|
|
|
%token KW_ALLOW KW_DENY
|
|
|
|
|
|
|
|
/* yes/no switches */
|
|
|
|
%token KW_YES KW_NO
|
|
|
|
|
2001-06-02 11:10:09 +08:00
|
|
|
/* settings for loglevel */
|
|
|
|
%token KW_LOGLEVEL
|
2001-08-27 05:10:04 +08:00
|
|
|
%token KW_LOG_CRITICAL KW_LOG_ERROR KW_LOG_WARNING KW_LOG_NOTICE KW_LOG_CONNECT KW_LOG_INFO
|
2001-06-02 11:10:09 +08:00
|
|
|
|
2000-09-12 08:12:52 +08:00
|
|
|
%token <cptr> IDENTIFIER
|
|
|
|
%token <num> NUMBER
|
|
|
|
%token <cptr> STRING
|
|
|
|
%token <cptr> NUMERIC_ADDRESS
|
|
|
|
%token <cptr> STRING_ADDRESS
|
|
|
|
%token <cptr> NETMASK_ADDRESS
|
|
|
|
|
|
|
|
%type <num> yesno
|
|
|
|
%type <cptr> string
|
|
|
|
%type <cptr> network_address
|
|
|
|
%type <cptr> unique_address
|
2001-06-02 11:10:09 +08:00
|
|
|
%type <num> loglevels
|
2000-09-12 08:12:52 +08:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
start
|
|
|
|
: /* empty */
|
|
|
|
| start line
|
|
|
|
;
|
|
|
|
|
|
|
|
line
|
|
|
|
: '\n'
|
|
|
|
| statement '\n'
|
|
|
|
;
|
|
|
|
|
|
|
|
statement
|
|
|
|
: KW_PORT NUMBER { config.port = $2; }
|
|
|
|
| KW_TIMEOUT NUMBER { config.idletimeout = $2; }
|
|
|
|
| KW_SYSLOG yesno
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
config.syslog = $2;
|
|
|
|
#else
|
2001-05-27 10:25:21 +08:00
|
|
|
log_message(LOG_WARNING, "Syslog support was not compiled in.");
|
2000-09-12 08:12:52 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
| KW_MAXCLIENTS NUMBER { thread_configure(THREAD_MAXCLIENTS, $2); }
|
|
|
|
| KW_MAXSPARESERVERS NUMBER { thread_configure(THREAD_MAXSPARESERVERS, $2); }
|
|
|
|
| KW_MINSPARESERVERS NUMBER { thread_configure(THREAD_MINSPARESERVERS, $2); }
|
|
|
|
| KW_STARTSERVERS NUMBER { thread_configure(THREAD_STARTSERVERS, $2); }
|
|
|
|
| KW_MAXREQUESTSPERCHILD NUMBER { thread_configure(THREAD_MAXREQUESTSPERCHILD, $2); }
|
|
|
|
| KW_LOGFILE string
|
|
|
|
{
|
|
|
|
config.logf_name = $2;
|
|
|
|
if (!config.logf_name) {
|
|
|
|
fprintf(stderr, "bad log file\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| KW_PIDFILE string { config.pidpath = $2; }
|
|
|
|
| KW_USER string { config.username = $2; }
|
|
|
|
| KW_GROUP string { config.group = $2; }
|
2001-08-27 05:10:04 +08:00
|
|
|
| KW_ANONYMOUS string { anonymous_insert($2); }
|
2000-09-12 08:12:52 +08:00
|
|
|
| KW_FILTER string
|
|
|
|
{
|
|
|
|
#ifdef FILTER_ENABLE
|
|
|
|
config.filter = $2;
|
|
|
|
#else
|
2001-05-27 10:25:21 +08:00
|
|
|
log_message(LOG_WARNING, "Filter support was not compiled in.");
|
2000-09-12 08:12:52 +08:00
|
|
|
#endif
|
|
|
|
}
|
2002-04-03 01:17:30 +08:00
|
|
|
| KW_XTINYPROXY network_address
|
|
|
|
{
|
|
|
|
#ifdef XTINYPROXY_ENABLE
|
|
|
|
config.my_domain = $2;
|
|
|
|
#else
|
|
|
|
log_message(LOG_WARNING, "X-Tinyproxy header support was not compiled in.");
|
|
|
|
#endif
|
|
|
|
}
|
2000-09-12 08:12:52 +08:00
|
|
|
| KW_TUNNEL unique_address ':' NUMBER
|
|
|
|
{
|
|
|
|
#ifdef TUNNEL_SUPPORT
|
|
|
|
config.tunnel_name = $2;
|
|
|
|
config.tunnel_port = $4;
|
|
|
|
#else
|
2001-05-27 10:25:21 +08:00
|
|
|
log_message(LOG_WARNING, "Tunnel support was not compiled in.");
|
2000-09-12 08:12:52 +08:00
|
|
|
#endif
|
|
|
|
}
|
2001-09-17 04:08:24 +08:00
|
|
|
| KW_UPSTREAM unique_address ':' NUMBER
|
|
|
|
{
|
|
|
|
#ifdef UPSTREAM_SUPPORT
|
|
|
|
config.upstream_name = $2;
|
|
|
|
config.upstream_port = $4;
|
|
|
|
#else
|
|
|
|
log_message(LOG_WARNING, "Upstream proxy support was not compiled in.");
|
|
|
|
#endif
|
|
|
|
}
|
2000-09-12 08:12:52 +08:00
|
|
|
| KW_LISTEN NUMERIC_ADDRESS { config.ipAddr = $2; }
|
|
|
|
| KW_ALLOW network_address { insert_acl($2, ACL_ALLOW); }
|
|
|
|
| KW_DENY network_address { insert_acl($2, ACL_DENY); }
|
2001-06-02 11:10:09 +08:00
|
|
|
| KW_LOGLEVEL loglevels { set_log_level($2); }
|
2000-09-12 08:12:52 +08:00
|
|
|
;
|
|
|
|
|
2001-06-02 11:10:09 +08:00
|
|
|
loglevels
|
|
|
|
: KW_LOG_CRITICAL { $$ = LOG_CRIT; }
|
|
|
|
| KW_LOG_ERROR { $$ = LOG_ERR; }
|
|
|
|
| KW_LOG_WARNING { $$ = LOG_WARNING; }
|
|
|
|
| KW_LOG_NOTICE { $$ = LOG_NOTICE; }
|
2001-08-27 05:10:04 +08:00
|
|
|
| KW_LOG_CONNECT { $$ = LOG_CONN; }
|
2001-06-02 11:10:09 +08:00
|
|
|
| KW_LOG_INFO { $$ = LOG_INFO; }
|
|
|
|
;
|
|
|
|
|
2000-09-12 08:12:52 +08:00
|
|
|
network_address
|
|
|
|
: unique_address
|
|
|
|
| NETMASK_ADDRESS
|
|
|
|
;
|
|
|
|
|
|
|
|
unique_address
|
|
|
|
: STRING_ADDRESS
|
|
|
|
| NUMERIC_ADDRESS
|
|
|
|
;
|
|
|
|
|
|
|
|
yesno
|
|
|
|
: KW_YES { $$ = 1; }
|
|
|
|
| KW_NO { $$ = 0; }
|
|
|
|
| NUMBER { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
string
|
|
|
|
: IDENTIFIER
|
|
|
|
| STRING
|
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
extern unsigned int yylineno;
|
|
|
|
|
2001-11-25 10:20:54 +08:00
|
|
|
void
|
|
|
|
yyerror(char *s)
|
2000-09-12 08:12:52 +08:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Line %d: %s\n", yylineno, s);
|
|
|
|
}
|