|
Packit |
1422b7 |
/*
|
|
Packit |
1422b7 |
* liblognorm - a fast samples-based log normalization library
|
|
Packit |
1422b7 |
* Copyright 2010-2015 by Rainer Gerhards and Adiscon GmbH.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* Modified by Pavel Levshin (pavel@levshin.spb.ru) in 2013
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* This file is part of liblognorm.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
1422b7 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
1422b7 |
* License as published by the Free Software Foundation; either
|
|
Packit |
1422b7 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
1422b7 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
1422b7 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
1422b7 |
* Lesser General Public License for more details.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
1422b7 |
* License along with this library; if not, write to the Free Software
|
|
Packit |
1422b7 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* A copy of the LGPL v2.1 can be found in the file "COPYING" in this distribution.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
#ifndef LIBLOGNORM_PARSER_H_INCLUDED
|
|
Packit |
1422b7 |
#define LIBLOGNORM_PARSER_H_INCLUDED
|
|
Packit |
1422b7 |
#include "pdag.h"
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* Parser interface
|
|
Packit |
1422b7 |
* @param[in] str the to-be-parsed string
|
|
Packit |
1422b7 |
* @param[in] strLen length of the to-be-parsed string
|
|
Packit |
1422b7 |
* @param[in] offs an offset into the string
|
|
Packit |
1422b7 |
* @param[out] parsed bytes
|
|
Packit |
1422b7 |
* @param[out] ptr to json object containing parsed data (can be unused)
|
|
Packit |
1422b7 |
* if NULL on input, object is NOT persisted
|
|
Packit |
1422b7 |
* @return 0 on success, something else otherwise
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
// TODO #warning check how to handle "value" - does it need to be set to NULL?
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#define PARSERDEF_NO_DATA(parser) \
|
|
Packit |
1422b7 |
int ln_v2_parse##parser(npb_t *npb, size_t *offs, void *const, size_t *parsed, struct json_object **value)
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#define PARSERDEF(parser) \
|
|
Packit |
1422b7 |
int ln_construct##parser(ln_ctx ctx, json_object *const json, void **pdata); \
|
|
Packit |
1422b7 |
int ln_v2_parse##parser(npb_t *npb, size_t *offs, void *const, size_t *parsed, struct json_object **value); \
|
|
Packit |
1422b7 |
void ln_destruct##parser(ln_ctx ctx, void *const pdata)
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
PARSERDEF(RFC5424Date);
|
|
Packit |
1422b7 |
PARSERDEF(RFC3164Date);
|
|
Packit |
1422b7 |
PARSERDEF(Number);
|
|
Packit |
1422b7 |
PARSERDEF(Float);
|
|
Packit |
1422b7 |
PARSERDEF(HexNumber);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(KernelTimestamp);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Whitespace);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Word);
|
|
Packit |
1422b7 |
PARSERDEF(StringTo);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Alpha);
|
|
Packit |
1422b7 |
PARSERDEF(Literal);
|
|
Packit |
1422b7 |
PARSERDEF(CharTo);
|
|
Packit |
1422b7 |
PARSERDEF(CharSeparated);
|
|
Packit |
1422b7 |
PARSERDEF(Repeat);
|
|
Packit |
1422b7 |
PARSERDEF(String);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Rest);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(OpQuotedString);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(QuotedString);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(ISODate);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Time12hr);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Time24hr);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(Duration);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(IPv4);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(IPv6);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(JSON);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(CEESyslog);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(v2IPTables);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(CiscoInterfaceSpec);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(MAC48);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(CEF);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(CheckpointLEA);
|
|
Packit |
1422b7 |
PARSERDEF_NO_DATA(NameValue);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#undef PARSERDEF_NO_DATA
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/* utility functions */
|
|
Packit |
1422b7 |
int ln_combineData_Literal(void *const org, void *const add);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/* definitions for friends */
|
|
Packit |
1422b7 |
struct data_Repeat {
|
|
Packit |
1422b7 |
ln_pdag *parser;
|
|
Packit |
1422b7 |
ln_pdag *while_cond;
|
|
Packit |
1422b7 |
int permitMismatchInParser;
|
|
Packit |
1422b7 |
};
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#endif /* #ifndef LIBLOGNORM_PARSER_H_INCLUDED */
|