1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef _ttail_search_h__
- #define _ttail_search_h__
-
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <regex.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
-
- typedef union _ttail_search_u ttail_search_t;
- typedef struct _ttail_search_stdin_s ttail_search_stdin_t;
- #include "ttail.h"
- typedef char* (*ttail_search_subst_f)(ttail_t*, 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;
-
-
- #include "config.h"
- #include "ttail_search_files.h"
-
- /*<! Private search session for stdin */
- struct _ttail_search_stdin_s
- {
- char *buff;
- size_t buff_sz;
- };
-
- /**@brief Search session is an union depending in the search method
- * employed
- */
- union _ttail_search_u
- {
- ttail_search_file_t file;
- ttail_search_stdin_t std;
- };
-
- /**@brief Begin a search session placing it in a ready to print situation
- *@param ttail_t*
- *@param struct tm* tmin
- *@return 0 if ok -1 if fatal error 1 if not found
- */
- int ttail_search_closest(ttail_t*, const struct tm*);
-
- /**@brief @ref ttail_search_closest() implementation for stdin
- *@param ttail_t*
- *@param struct tm* tmin
- *@return 0 if ok -1 if fatal error 1 if not found
- */
- int _ttail_search_closest_stdin(ttail_t*, const struct tm*);
-
- /**@brief Loglines comparison function
- *@param ttail_t* ttail
- *@param const char* logline a
- *@param const char* logline b
- *@return @ref ttail_cmp_res
- */
- ttail_cmp_res ttail_cmp_loglines(ttail_t*, const char*, const char*);
-
- /**@brief compare a logline to a date
- *@param ttail_t* ttail
- *@param const char* logline
- *@param struct tm* @see time.h
- *@return @ref ttail_cmp_res
- */
- ttail_cmp_res ttail_cmp_logline(ttail_t*, const char*, struct tm*);
-
- /**@brief Fetch a date from a logline
- *@param ttail_t* ttail
- *@param const char* logline
- *@param struct tm* tm will be set to extracted date if not NULL
- *@return 0 if ok, -1 if error 1 if no prefix found 2 if no date found
- */
- int ttail_logline2date(ttail_t*, const char*, struct tm*);
-
- /**@brief Apply the choosen substitution to the logline
- *@param ttail_t* ttail
- *@param const char* logline
- *@return a pointer on the end of the subst string or NULL if subst fails
- */
- const char* ttail_logline_subst(ttail_t*, const char*);
-
- /**@brief Compare two struct tm
- *@param a struct tm*
- *@param b struct tm*
- *@return <0 if a<b, >0 if a>b and 0 if a == b
- *@todo checks
- */
- int ttail_tm_cmp(const struct tm*, const struct tm*);
-
- #endif
|