/*
* Copyright 2017 Yann Weber
*
* This file is part of Ttail.
*
* Ttail 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 3 of the License, or
* any later version.
*
* Ttail 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 Ttail. If not, see .
*/
#ifndef _ttail_init_h__
#define _ttail_init_h__
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "ttail.h"
/**@todo set logfiles as "leadings" option */
#define TTAIL_LONG_OPT {\
{"verbose", no_argument, 0, 'v'},\
{"re-prefix", required_argument, 0, 'r'},\
{"re-extended", no_argument, 0, 'E'},\
{"re-ignore-case", no_argument, 0, 'i'},\
{"prefix-len", required_argument, 0, 'p'},\
{"date-format", required_argument, 0, 'f'},\
{"date-min", required_argument, 0, 'd'},\
{"date-max", required_argument, 0, 'm'},\
{"help", no_argument, 0, 'h'},\
{0, 0, 0, 0 }\
}
#define TTAIL_SHORT_OPT "vr:Eip:f:d:l:m:h"
#define TTAIL_OPT_HELP {\
{"Augment the verbosity level",NULL},\
{"Matched part of logline will be stripped","REGEX"},\
{"Interpret REGEX as an extended regular expression (specified by \
POSIX) ",NULL},\
{"Ignore case distinctions (specified by POSIX)",NULL},\
{"Indicate to strip a fixed len prefix","CHAR_COUNT"},\
{"Set the date format (see man strptime for supported date formats"\
,"FORMAT"},\
{"Start to output loglines starting from this date","DATE"},\
{"Stop to output loglines before this date","DATE"},\
{"Print this help and exit",NULL},\
{"",NULL}\
}
#define TTAIL_HELP_TEXT "\tLOGFILES\n\t\tLogfiles, can take '-' as value to \
tell ttail to read from stdin instead of files\n\n\
Date formats\n\n\
\tTwo date formats are allowed for dates arguments (-d , -m) :\n\
\t- the same than in the logfile\n\
\t- relative from now prefixing the argument with '#-' and given a unit\n\
\t\t- y : year\n\
\t\t- M : Month\n\
\t\t- d : day\n\
\t\t- h : hour\n\
\t\t- m : min\n\
\t\t- s : sec\n\
"
#define TTAIL_NORMDATE(ttail,tm,FIELD) {\
if(ttail->flag & TTAIL_FLAG_DATE_MIN && (tm)->FIELD == -1)\
{ ttail->date_min.FIELD = -1; }\
if(ttail->flag & TTAIL_FLAG_DATE_MAX && (tm)->FIELD == -1)\
{ ttail->date_max.FIELD = -1; }\
}
/**