timed tail for logfiles. Display loglines given a minimum date and/or a maximum date.
c
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ttail.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _ttail_h__
  2. #define _ttail_h__
  3. #include <ctype.h>
  4. #include <errno.h>
  5. #include <getopt.h>
  6. #include <regex.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <sys/types.h>
  11. #include <time.h>
  12. #include <unistd.h>
  13. typedef struct _ttail_s ttail_t;
  14. #include "config.h"
  15. #include "ttail_search.h"
  16. #define TTAIL_FLAG_PREFIX 1
  17. #define TTAIL_FLAG_DATE_MIN 2
  18. #define TTAIL_FLAG_DATE_MAX 4
  19. #define TTAIL_FLAG_FORMAT 8
  20. #define TTAIL_FLAG_EXTENDED_RE 16
  21. #define TTAIL_FLAG_EXTENDED_CI 32
  22. #define TTAIL_DEFAULT_FORMATS {"%m",\
  23. "%A %B %d, %Y %H:%M:%S",\
  24. "%A",\
  25. "%B%n%d %H:%M:%S",\
  26. "%B%n%d %H:%M",\
  27. "%m/%d/%y %I %p",\
  28. "%d,%m,%Y %H:%M",\
  29. "at %A the %dst of %B in %Y",\
  30. "run job at %I %p,%B %dnd",\
  31. "%A den %d. %B %Y %H.%M Uhr",\
  32. "%c",\
  33. "%y/%m/%d",\
  34. "%Y/%m/%d",\
  35. "%y-%m-%d",\
  36. "%Y/%m/%d:%H:%M",NULL}
  37. struct _ttail_s
  38. {
  39. char **logfile_name; /*!< logfiles name */
  40. FILE **logfile; /*!< logfiles pointers */
  41. size_t logfile_sz; /*<! logfiles count */
  42. /*! A regex matching the datetime prefix in loglines */
  43. regex_t date_prefix;
  44. /*! An alternative to regex is to give a constant number of char
  45. to delete */
  46. int prefix_sz;
  47. /*! A strptime format matching datetime in logfile */
  48. char *fmt;
  49. /*! Date min set from cli */
  50. struct tm date_min;
  51. struct tm date_max;
  52. int verbose;
  53. /**@brief Status flag
  54. *
  55. *see TTAIL_FLAG_*
  56. */
  57. int flag;
  58. ttail_search_t *session;
  59. };
  60. #endif