2005-04-28 10:26:44 +02:00
|
|
|
%{
|
|
|
|
/*
|
|
|
|
* $Id: lex.l,v 1.23 2005/04/12 19:34:35 nohar Exp $
|
|
|
|
*
|
|
|
|
* This file is part of the bip proproject
|
|
|
|
* Copyright (C) 2004 Arnaud Cornet
|
|
|
|
*
|
|
|
|
* 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 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
* See the file "COPYING" for the exact licensing terms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "conf.h"
|
|
|
|
int linec = 0;
|
|
|
|
#define YY_NO_UNPUT
|
|
|
|
#include "util.h"
|
|
|
|
extern int conf_error;
|
|
|
|
extern list_t *root_list;
|
|
|
|
void yyparse(void);
|
|
|
|
void free_conf(list_t*);
|
|
|
|
|
2005-08-01 13:43:17 +02:00
|
|
|
#if 0
|
2005-08-01 13:41:14 +02:00
|
|
|
/* SPANK ME WITH A SHOVEL */
|
|
|
|
static void yyunput(int c, char *buf);
|
|
|
|
void dummy_lex_FFS(void)
|
|
|
|
{
|
|
|
|
yyunput(0, NULL);
|
|
|
|
}
|
2005-08-01 13:43:17 +02:00
|
|
|
#endif
|
2005-08-01 13:41:14 +02:00
|
|
|
|
2005-04-28 10:26:44 +02:00
|
|
|
list_t *parse_conf(FILE *file)
|
|
|
|
{
|
|
|
|
YY_BUFFER_STATE in = yy_create_buffer(file, YY_BUF_SIZE);
|
|
|
|
yy_switch_to_buffer(in);
|
|
|
|
yyparse();
|
|
|
|
if (conf_error) {
|
|
|
|
free_conf(root_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return root_list;
|
2005-10-09 14:40:38 +02:00
|
|
|
}
|
2005-04-28 10:26:44 +02:00
|
|
|
%}
|
|
|
|
%%
|
|
|
|
(" "|\t)+
|
|
|
|
\n { linec++; }
|
|
|
|
"#"[^\n]*$
|
|
|
|
[0-9]+ {
|
|
|
|
yylval.number = atoi(yytext);
|
|
|
|
return LEX_INT;
|
|
|
|
}
|
|
|
|
("true"|"false") {
|
|
|
|
yylval.number = strcmp(yytext, "true")
|
|
|
|
== 0 ? 1 : 0;
|
|
|
|
return LEX_BOOL;
|
|
|
|
}
|
|
|
|
"ip" { return LEX_IP; }
|
|
|
|
"port" { return LEX_PORT; }
|
|
|
|
"client_side_ssl" { return LEX_CSS; }
|
|
|
|
"server" { return LEX_SERVER; }
|
|
|
|
"network" { return LEX_NETWORK; }
|
|
|
|
"host" { return LEX_HOST; }
|
|
|
|
"name" { return LEX_NAME; }
|
|
|
|
"user" { return LEX_USER; }
|
|
|
|
"connection" { return LEX_CONNECTION; }
|
|
|
|
"nick" { return LEX_NICK; }
|
|
|
|
"realname" { return LEX_REALNAME; }
|
2005-07-09 14:55:01 +02:00
|
|
|
"default_nick" { return LEX_DEFAULT_NICK; }
|
|
|
|
"default_user" { return LEX_DEFAULT_USER; }
|
|
|
|
"default_realname" { return LEX_DEFAULT_REALNAME; }
|
2005-04-28 10:26:44 +02:00
|
|
|
"source_port" { return LEX_SOURCE_PORT; }
|
|
|
|
"vhost" { return LEX_VHOST; }
|
|
|
|
"password" { return LEX_PASSWORD; }
|
|
|
|
"ssl" { return LEX_SSL; }
|
2005-06-04 13:05:54 +02:00
|
|
|
"ssl_check_mode" { return LEX_SSL_CHECK_MODE; }
|
|
|
|
"ssl_check_store" { return LEX_SSL_CHECK_STORE; }
|
2005-04-28 10:26:44 +02:00
|
|
|
"key" { return LEX_KEY; }
|
|
|
|
"channel" { return LEX_CHANNEL; }
|
|
|
|
"log_level" { return LEX_LOG_LEVEL; }
|
|
|
|
"log_root" { return LEX_LOG_ROOT; }
|
|
|
|
"log_format" { return LEX_LOG_FORMAT; }
|
|
|
|
"backlog_lines" { return LEX_BACKLOG_LINES; }
|
2007-01-12 19:49:14 +01:00
|
|
|
"backlog_no_timestamp" { return LEX_BACKLOG_NO_TIMESTAMP; }
|
2005-05-19 22:55:11 +02:00
|
|
|
"backlog" { return LEX_BACKLOG; }
|
2006-10-21 14:06:31 +02:00
|
|
|
"bl_msg_only" { return LEX_BL_MSG_ONLY; }
|
2005-05-19 22:55:11 +02:00
|
|
|
"log" { return LEX_LOG; }
|
2005-04-28 10:26:44 +02:00
|
|
|
"always_backlog" { return LEX_ALWAYS_BACKLOG; }
|
|
|
|
"log_sync_interval" { return LEX_LOG_SYNC_INTERVAL; }
|
|
|
|
"follow_nick" { return LEX_FOLLOW_NICK; }
|
|
|
|
"ignore_first_nick" { return LEX_IGN_FIRST_NICK; }
|
|
|
|
"away_nick" { return LEX_AWAY_NICK; }
|
|
|
|
"on_connect_send" { return LEX_ON_CONNECT_SEND; }
|
2006-09-18 18:06:23 +02:00
|
|
|
"no_client_away_msg" { return LEX_NO_CLIENT_AWAY_MSG; }
|
2005-04-28 10:26:44 +02:00
|
|
|
"pid_file" { return LEX_PID_FILE; }
|
2005-05-30 20:01:00 +02:00
|
|
|
"blreset_on_talk" { return LEX_BLRESET_ON_TALK; }
|
2005-04-28 10:26:44 +02:00
|
|
|
\"[^"]*\" {
|
|
|
|
size_t len = strlen(yytext) - 2;
|
|
|
|
yylval.string = malloc(len + 1);
|
|
|
|
if (!yylval.string)
|
|
|
|
fatal("malloc");
|
|
|
|
memcpy(yylval.string, yytext + 1, len);
|
|
|
|
yylval.string[len] = 0;
|
|
|
|
return LEX_STRING;
|
|
|
|
}
|
|
|
|
"=" { return LEX_EQ; }
|
|
|
|
"{" { return LEX_LBRA; }
|
|
|
|
"}" { return LEX_RBRA; }
|
|
|
|
";" { return LEX_SEMICOLON; }
|
|
|
|
. { printf("Parse error line %d, unknown character '%s'\n", linec + 1, yytext);
|
|
|
|
return LEX_BUNCH; }
|
|
|
|
%%
|