123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef _ttail_dateformats_h__
- #define _ttail_dateformats_h__
-
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <errno.h>
-
- #include "options.h"
- #include "config.h"
-
- #define TTAIL_NODATE_A 2
- #define TTAIL_NODATE_B 4
-
-
- #define TTAIL_FMTNAME_SZ 16
-
-
- typedef struct _ttail_datefmt_s ttail_datefmt;
-
- //<! Datetime format info
- typedef void* ttail_fmt_infos;
-
- /**@brief Dateformat detection function
- *@param const char* logline
- *@return Datetime format info or TTAIL_NODETECT if detection fails
- */
- typedef ttail_fmt_infos (*ttail_detect_f)(const char*);
-
- /**@brief Comparison results
- *
- * -1 if a < b, 1 if a > b, 0 if a == b, -2 if exception
- *
- * If an exception occur, exception flags are set with | on the result.
- * Exceptions flags are : TTAIL_NODATE_A and TTAIL_NODATE_B
- */
- typedef int ttail_cmp_res;
-
- /**@brief Loglines comparison function
- *@param ttail_fmt_infos datetime returned from a ttail_detect_f
- *@param const char* logline a
- *@param const char* logline b
- *@return -1 if a < b, 1 if a > b, 0 if a == b, -2 if exception
- *@see ttail_cmp_res
- */
- typedef ttail_cmp_res (*ttail_cmp_f)(ttail_fmt_infos, const char*, const char*);
-
- ///<! Date detection infos free function
- typedef void (*ttail_free_infos_f)(ttail_fmt_infos);
-
- ///<! ttail_datefmt cleanup function
- typedef void (*ttail_fmt_cleanup_f)(ttail_datefmt*);
-
- /**@brief ttail_datefmt initalisation function
- *@param ttail_options* options
- *@return NULL on error
- */
- typedef ttail_datefmt* (*ttail_fmt_init_f)(ttail_options*);
-
- /**@brief Stores a datetime format
- *
- * Represent a ttail dateformat.
- *
- * A dateformat provides functions for detection, sorting etc. of a date
- * and time in a logline
- */
- struct _ttail_datefmt_s
- {
- ///<! Format name
- char *name;
-
- ///<! format initalisation function
- ttail_fmt_init_f init;
- ///<! @brief Detection function
- ttail_detect_f detect;
- ///<! @brief Comparison function
- ttail_cmp_f cmp;
- ///<! @brief Datetime infos free function
- ttail_free_infos_f date_free_infos;
- ///<! cleanup function
- ttail_fmt_cleanup_f cleanup;
-
- ///<! internal format datas
- void *_blob;
- };
-
- /**@brief Given a name of date format load the shared library and
- *build the format list calling the formats init functions
- *
- *@param const char **fmt_name_l format name list
- *@param size_t fmt_sz format name list size
- *@param ttail_optionts* options ttail_runtime options
- *@return NULL on error else a NULL terminated ttail_datefmt list
- */
- ttail_datefmt** ttail_date_fmt_init(ttail_options* options);
-
- #ifdef TTAIL_FMT_REGEX
- extern ttail_datefmt* ttail_fmt_regex_init(ttail_options* options);
- #endif
-
- #endif
|