/*
 * Copyright (c) 2002-2012 Balabit
 * Copyright (c) 1998-2012 Balázs Scheidler
 *
 * 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.
 *
 */

#include "driver.h"
#include "cfg-parser.h"
#include "affile-grammar.h"

extern int affile_debug;

int affile_parse(CfgLexer *lexer, LogDriver **instance, gpointer arg);

static CfgLexerKeyword affile_keywords[] =
{
  { "file",               KW_FILE },
  { "fifo",               KW_PIPE },
  { "pipe",               KW_PIPE },
  { "stdin",              KW_STDIN },
  { "stdout",             KW_STDOUT },

  { "wildcard_file",      KW_WILDCARD_FILE },
  { "base_dir",           KW_BASE_DIR },
  { "filename_pattern",   KW_FILENAME_PATTERN },
  { "exclude_pattern",    KW_EXCLUDE_PATTERN },
  { "recursive",          KW_RECURSIVE },
  { "max_files",          KW_MAX_FILES },
  { "monitor_method",     KW_MONITOR_METHOD },
  { "force_directory_polling", KW_FORCE_DIRECTORY_POLLING, KWS_OBSOLETE, "Use wildcard-file(monitor-method())" },

  { "fsync",              KW_FSYNC },
  { "remove_if_older",    KW_OVERWRITE_IF_OLDER, KWS_OBSOLETE, "overwrite_if_older" },
  { "overwrite_if_older", KW_OVERWRITE_IF_OLDER },
  { "symlink_as",         KW_SYMLINK_AS },
  { "follow_always_reads", KW_FOLLOW_ALWAYS_READS },
  { "follow_freq",        KW_FOLLOW_FREQ },
  { "follow_method",      KW_FOLLOW_METHOD },
  { "monitor_freq",       KW_MONITOR_FREQ },
  { "multi_line_timeout", KW_MULTI_LINE_TIMEOUT },
  { "time_reap",          KW_TIME_REAP },
  { "logrotate",          KW_LOGROTATE },
  { "enable",             KW_LOGROTATE_ENABLE },
  { "size",               KW_LOGROTATE_SIZE },
  { "rotations",          KW_LOGROTATE_ROTATIONS},
  { NULL }
};

CfgParser affile_parser =
{
#if SYSLOG_NG_ENABLE_DEBUG
  .debug_flag = &affile_debug,
#endif
  .name = "affile",
  .keywords = affile_keywords,
  .parse = (gint (*)(CfgLexer *, gpointer *, gpointer)) affile_parse,
  .cleanup = (void (*)(gpointer)) log_pipe_unref,
};

CFG_PARSER_IMPLEMENT_LEXER_BINDING(affile_, AFFILE_, LogDriver **)
