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.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. "%y/%m/%d",\
  52. "%Y/%m/%d",\
  53. "%y-%m-%d",\
  54. "%Y/%m/%d:%H:%M",NULL}
  55. struct _ttail_s
  56. {
  57. char **logfile_name; /*!< logfiles name */
  58. FILE **logfile; /*!< logfiles pointers */
  59. size_t logfile_sz; /*<! logfiles count */
  60. /*! A regex matching the datetime prefix in loglines */
  61. regex_t date_prefix;
  62. /*! An alternative to regex is to give a constant number of char
  63. to delete */
  64. int prefix_sz;
  65. /*! A strptime format matching datetime in logfile */
  66. char *fmt;
  67. /*! Date min set from cli */
  68. struct tm date_min;
  69. struct tm date_max;
  70. int verbose;
  71. /**@brief Status flag
  72. *
  73. *see TTAIL_FLAG_*
  74. */
  75. int flag;
  76. ttail_search_t *session;
  77. };
  78. #endif