/*
 * Copyright (c) 2012 Nagy, Attila <bra@fsn.hu>
 * Copyright (c) 2014 Balabit
 * Copyright (c) 2013 Viktor Tusa <tusa@balabit.hu>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * As an additional exemption you are allowed to compile & link against the
 * OpenSSL libraries as published by the OpenSSL project. See the file
 * COPYING for details.
 *
 */

%code requires {

#include "afstomp-parser.h"

}

%code {

#include "cfg-parser.h"
#include "cfg-grammar-internal.h"
#include "plugin.h"
#include "value-pairs/value-pairs.h"

}

%define api.prefix {afstomp_}
%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {LogDriver **instance}
%parse-param {gpointer arg}


/* INCLUDE_DECLS */

%token KW_STOMP
%token KW_STOMP_DESTINATION
%token KW_PERSISTENT
%token KW_ACK
%token KW_BODY
%token KW_PASSWORD
%token KW_USERNAME

%%

start
        : LL_CONTEXT_DESTINATION KW_STOMP
          {
            last_driver = *instance = afstomp_dd_new(configuration);
          }
          '(' afstomp_options ')'		{ YYACCEPT; }
          ;

afstomp_options
        : afstomp_option afstomp_options
        |
        ;

afstomp_option
        : KW_HOST '(' string ')'		{ afstomp_dd_set_host(last_driver, $3); free($3); }
        | KW_PORT '(' positive_integer ')'		{ afstomp_dd_set_port(last_driver, $3); }
        | KW_STOMP_DESTINATION '(' string ')'	{ afstomp_dd_set_destination(last_driver, $3); free($3); }
        | KW_BODY '(' template_content ')'	{ afstomp_dd_set_body(last_driver, $3); }
        | KW_PERSISTENT '(' yesno ')'		{ afstomp_dd_set_persistent(last_driver, $3); }
        | KW_ACK '(' yesno ')'			{ afstomp_dd_set_ack(last_driver, $3); }
        | KW_USERNAME '(' string ')'		{ afstomp_dd_set_user(last_driver, $3); free($3); }
        | KW_PASSWORD '(' string ')'		{ afstomp_dd_set_password(last_driver, $3); free($3); }
        | value_pair_option			{ afstomp_dd_set_value_pairs(last_driver, $1); }
        | threaded_dest_driver_general_option
	| { last_template_options = afstomp_dd_get_template_options(last_driver); } template_option
        ;

/* INCLUDE_RULES */

%%
