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 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2017 Yann Weber
  3. *
  4. * This file is part of Ttail.
  5. *
  6. * Ttail is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * Ttail is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Ttail. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _ttail_h__
  20. #define _ttail_h__
  21. #include <ctype.h>
  22. #include <errno.h>
  23. #include <getopt.h>
  24. #include <regex.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <sys/types.h>
  29. #include <time.h>
  30. #include <unistd.h>
  31. typedef struct _ttail_s ttail_t;
  32. #include "config.h"
  33. #include "ttail_search.h"
  34. #define TTAIL_FLAG_PREFIX 1
  35. #define TTAIL_FLAG_DATE_MIN 2
  36. #define TTAIL_FLAG_DATE_MAX 4
  37. #define TTAIL_FLAG_FORMAT 8
  38. #define TTAIL_FLAG_EXTENDED_RE 16
  39. #define TTAIL_FLAG_CI_RE 32
  40. #define TTAIL_DEFAULT_FORMATS {"%m",\
  41. "%A %B %d, %Y %H:%M:%S",\
  42. "%A",\
  43. "%B%n%d %H:%M:%S",\
  44. "%B%n%d %H:%M",\
  45. "%m/%d/%y %I %p",\
  46. "%d,%m,%Y %H:%M",\
  47. "at %A the %dst of %B in %Y",\
  48. "run job at %I %p,%B %dnd",\
  49. "%A den %d. %B %Y %H.%M Uhr",\
  50. "%c",\
  51. "%d/%B/%Y:%H:%M:%S",\
  52. "%d/%B/%Y:%H:%M",\
  53. "%d/%m/%Y:%H:%M:%S",\
  54. "%d/%m/%Y:%H:%M",\
  55. "%y/%m/%d",\
  56. "%Y/%m/%d",\
  57. "%y-%m-%d",\
  58. "%Y/%m/%d:%H:%M",NULL}
  59. struct _ttail_s
  60. {
  61. char **logfile_name; /*!< logfiles name */
  62. FILE **logfile; /*!< logfiles pointers */
  63. size_t logfile_sz; /*<! logfiles count */
  64. /*! A regex matching the datetime prefix in loglines */
  65. regex_t date_prefix;
  66. /*! An alternative to regex is to give a constant number of char
  67. to delete */
  68. int prefix_sz;
  69. /*! A strptime format matching datetime in logfile */
  70. char *fmt;
  71. /*! Date min set from cli */
  72. struct tm date_min;
  73. struct tm date_max;
  74. int verbose;
  75. /**@brief Status flag
  76. *
  77. *see TTAIL_FLAG_*
  78. */
  79. int flag;
  80. ttail_search_t *session;
  81. };
  82. #endif