123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #ifndef _ttail_h__
- #define _ttail_h__
-
- #include <ctype.h>
- #include <errno.h>
- #include <getopt.h>
- #include <regex.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/types.h>
- #include <time.h>
- #include <unistd.h>
-
- #define TTAIL_FLAG_PREFIX 1
- #define TTAIL_FLAG_DATE_MIN 2
- #define TTAIL_FLAG_DATE_MAX 4
- #define TTAIL_FLAG_FORMAT 8
- #define TTAIL_DEFAULT_FORMATS {"%m", "%A %B %d, %Y %H:%M:%S", "%A", "%B", \
- "%m/%d/%y %I %p", "%d,%m,%Y %H:%M", "at %A the %dst of %B in %Y",\
- "run job at %I %p,%B %dnd", "%A den %d. %B %Y %H.%M Uhr",\
- "%c", "%y/%m/%d", "%Y/%m/%d", "%y-%m-%d", "%Y/%m/%d:%H:%M",NULL}
-
- struct _ttail_s
- {
- char **logfile_name; /*!< logfiles name */
- FILE **logfile; /*!< logfiles pointers */
- size_t logfile_sz; /*<! logfiles count */
-
- /*! A regex matching the datetime prefix in loglines */
- regex_t date_prefix;
-
- /*! A strptime format matching datetime in logfile */
- char *fmt;
-
- struct tm date_min;
- struct tm date_max;
-
- int verbose;
- int flag;
- };
- typedef struct _ttail_s ttail_t;
-
-
- /**@brief Parse cli arguments and return a ttail_t
- *@param int argc
- *@param char** argv
- *@return NULL on error
- */
- ttail_t *ttail_init(int argc, char **argv);
-
- /**@brief Checks that init lead to a valid runtime
- *@param ttail_t* t
- *@return 0 if no error -1 if fatal error
- */
- int ttail_init_check(ttail_t*);
-
- /**@brief Add a logfile
- *@param ttail_t*
- *@param const char * filename
- *@return 0 if no errors 1 if unable to open file -1 if fatal error
- */
- int ttail_add_logfile(ttail_t*, const char*);
-
- /**@brief Set a date prefix regex
- *@param ttail_t*
- *@param const char * regex
- *@return 0 if no errors 1 if allready set -1 if compilation fails
- */
- int ttail_set_prefix(ttail_t*, const char*);
-
- /**@brief Set dates min/max
- *
- *After the call dates are free and set to NULL except if error
- *@param ttail_t ttail instance
- *@param char*[2] dates {min,max} both can be NULL
- *@return -1 if error 0 else
- */
- int ttail_set_dates(ttail_t*, char*[2]);
-
- /**@brief Attempt to guess a dateformat
- *@param ttail_t* ttail if manage to guess set the ttail_t.fmt
- *@param const char* date as a dtring
- *@param struct tm* if non NULL will be set to detected date
- *@return -1 if no guess -2 if fmt already set else id in TTAIL_DEFAULT_FORMATS
- */
- int ttail_format_guess(ttail_t*, const char*, struct tm*);
-
-
- void ttail_free(ttail_t*);
-
-
- #endif
|