|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* @file samples.h
|
|
Packit |
1422b7 |
* @brief Object to process log samples.
|
|
Packit |
1422b7 |
* @author Rainer Gerhards
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* This object handles log samples, and in actual log sample files.
|
|
Packit |
1422b7 |
* It co-operates with the ptree object to build the actual parser tree.
|
|
Packit |
1422b7 |
*//*
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* liblognorm - a fast samples-based log normalization library
|
|
Packit |
1422b7 |
* Copyright 2010 by Rainer Gerhards and Adiscon GmbH.
|
|
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_V1_SAMPLES_H_INCLUDED
|
|
Packit |
1422b7 |
#define LIBLOGNORM_V1_SAMPLES_H_INCLUDED
|
|
Packit |
1422b7 |
#include <stdio.h> /* we need es_size_t */
|
|
Packit |
1422b7 |
#include <libestr.h>
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* A single log sample.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
struct ln_v1_samp {
|
|
Packit |
1422b7 |
es_str_t *msg;
|
|
Packit |
1422b7 |
};
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* Reads a sample stored in buffer buf and creates a new ln_v1_samp object
|
|
Packit |
1422b7 |
* out of it.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* @note
|
|
Packit |
1422b7 |
* It is the caller's responsibility to delete the newly
|
|
Packit |
1422b7 |
* created ln_v1_samp object if it is no longer needed.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* @param[ctx] ctx current library context
|
|
Packit |
1422b7 |
* @param[buf] cstr buffer containing the string contents of the sample
|
|
Packit |
1422b7 |
* @param[lenBuf] length of the sample contained within buf
|
|
Packit |
1422b7 |
* @return Newly create object or NULL if an error occured.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
struct ln_v1_samp *
|
|
Packit |
1422b7 |
ln_v1_processSamp(ln_ctx ctx, const char *buf, es_size_t lenBuf);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* Read a sample from repository (sequentially).
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* Reads a sample starting with the current file position and
|
|
Packit |
1422b7 |
* creates a new ln_v1_samp object out of it.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* @note
|
|
Packit |
1422b7 |
* It is the caller's responsibility to delete the newly
|
|
Packit |
1422b7 |
* created ln_v1_samp object if it is no longer needed.
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* @param[in] ctx current library context
|
|
Packit |
1422b7 |
* @param[in] repo repository descriptor
|
|
Packit |
1422b7 |
* @param[out] isEof must be set to 0 on entry and is switched to 1 if EOF occured.
|
|
Packit |
1422b7 |
* @return Newly create object or NULL if an error or EOF occured.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
struct ln_v1_samp *
|
|
Packit |
1422b7 |
ln_v1_sampRead(ln_ctx ctx, FILE *repo, int *isEof);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* Free ln_v1_samp object.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
void
|
|
Packit |
1422b7 |
ln_v1_sampFree(ln_ctx ctx, struct ln_v1_samp *samp);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
/**
|
|
Packit |
1422b7 |
* Parse a given sample
|
|
Packit |
1422b7 |
*
|
|
Packit |
1422b7 |
* @param[in] ctx current library context
|
|
Packit |
1422b7 |
* @param[in] rule string (with prefix and suffix '%' markers)
|
|
Packit |
1422b7 |
* @param[in] offset in rule-string to start at (it should be pointed to
|
|
Packit |
1422b7 |
* starting character: '%')
|
|
Packit |
1422b7 |
* @param[in] temp string buffer(working space),
|
|
Packit |
1422b7 |
* externalized for efficiency reasons
|
|
Packit |
1422b7 |
* @param[out] return code (0 means success)
|
|
Packit |
1422b7 |
* @return newly created node, which can be added to sample tree.
|
|
Packit |
1422b7 |
*/
|
|
Packit |
1422b7 |
ln_fieldList_t*
|
|
Packit |
1422b7 |
ln_v1_parseFieldDescr(ln_ctx ctx, es_str_t *rule, es_size_t *bufOffs,
|
|
Packit |
1422b7 |
es_str_t **str, int* ret);
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#endif /* #ifndef LIBLOGNORM_V1_SAMPLES_H_INCLUDED */
|