| 1 |
%{ |
|---|
| 2 |
/* ====================================================================== |
|---|
| 3 |
* Copyright (c) 2000 Theo Schlossnagle |
|---|
| 4 |
* All rights reserved. |
|---|
| 5 |
* The following code was written by Theo Schlossnagle <jesus@omniti.com> |
|---|
| 6 |
* This code was written to facilitate clustered logging via Spread. |
|---|
| 7 |
* More information on Spread can be found at http://www.spread.org/ |
|---|
| 8 |
* Please refer to the LICENSE file before using this software. |
|---|
| 9 |
* ====================================================================== |
|---|
| 10 |
*/ |
|---|
| 11 |
|
|---|
| 12 |
#include "config.h" |
|---|
| 13 |
|
|---|
| 14 |
extern int line_num, semantic_errors; |
|---|
| 15 |
extern int buffsize; |
|---|
| 16 |
extern char *yytext; |
|---|
| 17 |
|
|---|
| 18 |
static SpreadConfiguration *current_sc = NULL; |
|---|
| 19 |
static LogFacility *current_lf = NULL; |
|---|
| 20 |
|
|---|
| 21 |
int yyerror(char *str); |
|---|
| 22 |
|
|---|
| 23 |
#define NEW_SC_IFNEEDED if(!current_sc) current_sc=config_new_spread_conf(); |
|---|
| 24 |
|
|---|
| 25 |
#define NEW_LF_IFNEEDED if(!current_sc) current_sc=config_new_spread_conf(); \ |
|---|
| 26 |
if(!current_lf) current_lf=config_new_logfacility(); |
|---|
| 27 |
%} |
|---|
| 28 |
%start Config |
|---|
| 29 |
%token BUFFERSIZE SPREAD PORT HOST LOG GROUP FILENAME MATCH VHOSTGROUP VHOSTDIR |
|---|
| 30 |
%token OPENBRACE CLOSEBRACE EQUALS STRING CLF REWRITETIMES |
|---|
| 31 |
%% |
|---|
| 32 |
Config : Globals SpreadConfs |
|---|
| 33 |
{ config_start(); } |
|---|
| 34 |
|
|---|
| 35 |
Globals : GlobalParam Globals |
|---|
| 36 |
| |
|---|
| 37 |
; |
|---|
| 38 |
|
|---|
| 39 |
GlobalParam : BUFFERSIZE EQUALS STRING |
|---|
| 40 |
{ if(buffsize<0) { |
|---|
| 41 |
buffsize = atoi($3); |
|---|
| 42 |
} |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
SpreadConfs : SpreadConf SpreadConfs |
|---|
| 46 |
| SpreadConf |
|---|
| 47 |
; |
|---|
| 48 |
|
|---|
| 49 |
SpreadConf : SPREAD OPENBRACE SPparams LogStructs CLOSEBRACE |
|---|
| 50 |
{ config_add_spreadconf(current_sc); |
|---|
| 51 |
current_sc = NULL; } |
|---|
| 52 |
; |
|---|
| 53 |
|
|---|
| 54 |
SPparams : SPparam SPparams |
|---|
| 55 |
| |
|---|
| 56 |
; |
|---|
| 57 |
|
|---|
| 58 |
SPparam : PORT EQUALS STRING |
|---|
| 59 |
{ NEW_SC_IFNEEDED; |
|---|
| 60 |
config_set_spread_port(current_sc, $3); } |
|---|
| 61 |
| HOST EQUALS STRING |
|---|
| 62 |
{ NEW_SC_IFNEEDED; |
|---|
| 63 |
config_set_spread_host(current_sc, $3); } |
|---|
| 64 |
; |
|---|
| 65 |
|
|---|
| 66 |
LogStructs : LogStruct LogStructs |
|---|
| 67 |
| |
|---|
| 68 |
; |
|---|
| 69 |
|
|---|
| 70 |
LogStruct : LOG OPENBRACE Logparams CLOSEBRACE |
|---|
| 71 |
{ config_add_logfacility(current_sc, current_lf); |
|---|
| 72 |
current_lf = NULL; } |
|---|
| 73 |
; |
|---|
| 74 |
|
|---|
| 75 |
Logparams : Logparams Logparam |
|---|
| 76 |
| |
|---|
| 77 |
; |
|---|
| 78 |
|
|---|
| 79 |
Logparam : GROUP EQUALS STRING |
|---|
| 80 |
{ NEW_LF_IFNEEDED; |
|---|
| 81 |
config_set_logfacility_group(current_lf, $3); } |
|---|
| 82 |
| FILENAME EQUALS STRING |
|---|
| 83 |
{ NEW_LF_IFNEEDED; |
|---|
| 84 |
config_set_logfacility_filename(current_lf, $3); } |
|---|
| 85 |
| MATCH EQUALS STRING |
|---|
| 86 |
{ NEW_LF_IFNEEDED; |
|---|
| 87 |
config_add_logfacility_match(current_lf, $3); } |
|---|
| 88 |
| VHOSTDIR EQUALS STRING |
|---|
| 89 |
{ NEW_LF_IFNEEDED; |
|---|
| 90 |
config_set_logfacility_vhostdir(current_lf, $3); } |
|---|
| 91 |
| REWRITETIMES EQUALS CLF |
|---|
| 92 |
{ NEW_LF_IFNEEDED; |
|---|
| 93 |
fprintf(stderr, "Setting logfacility to force local times in CLF\n"); |
|---|
| 94 |
config_set_logfaclity_rewritetimes_clf(current_lf); } |
|---|
| 95 |
| REWRITETIMES EQUALS STRING |
|---|
| 96 |
{ NEW_LF_IFNEEDED; |
|---|
| 97 |
config_set_logfaclity_rewritetimes_user(current_lf, |
|---|
| 98 |
$3); } |
|---|
| 99 |
; |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
%% |
|---|
| 103 |
int yyerror(char *str) { |
|---|
| 104 |
fprintf(stderr, "Parser error on or before line %d\n", line_num); |
|---|
| 105 |
fprintf(stderr, "Offending token: %s\n", yytext); |
|---|
| 106 |
return -1; |
|---|
| 107 |
} |
|---|