timed tail for logfiles. Display loglines given a minimum date and/or a maximum date.
c
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ttail_search_files.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _ttail_search_files_h__
  2. #define _ttail_search_files_h__
  3. #include <errno.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <regex.h>
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <unistd.h>
  10. typedef struct _ttail_search_file_s ttail_search_file_t;
  11. /*<! Private search session for logfiles */
  12. struct _ttail_search_file_s
  13. {
  14. /*<! logfile sizes */
  15. off_t *file_sz;
  16. #ifdef TTAIL_HUGE_FILE
  17. /*<! Shift width to apply on size to compute stuff */
  18. short sz_div;
  19. #endif
  20. /*<! Computed files start size */
  21. off_t *vfile;
  22. /*<! Computed file sizes sum */
  23. off_t vsz;
  24. /*<! Computed position */
  25. off_t vpos;
  26. char *buf;
  27. size_t buf_sz;
  28. };
  29. #include "config.h"
  30. #include "ttail.h"
  31. #include "ttail_search.h"
  32. /**@brief Convenient wrapper for getline
  33. *@param ttail_t* TTAIL
  34. *@param size_t ID file id
  35. *@return @ref getline()
  36. */
  37. #define ttail_getline(TTAIL, ID) (getline(\
  38. &(TTAIL->session->file.buf), &(TTAIL->session->file.buf_sz),\
  39. TTAIL->logfile[ID]))
  40. /*<!Accessor to getline wrapper buffer */
  41. #define ttail_getline_buf(TTAIL) (TTAIL->session->file.buf)
  42. /**@brief @ref ttail_search_closest() implementation for logfiles
  43. *@param ttail_t*
  44. *@return 0 if ok -1 if fatal error 1 if not found
  45. */
  46. int _ttail_search_closest_files(ttail_t*);
  47. int _ttail_search_closest_files_init(ttail_t*);
  48. int _ttail_search_closest_files_set_fsizes(ttail_t*);
  49. /**@brief Test if files are sorted
  50. *
  51. *If not sorted attempt to sort them
  52. *@param ttail_t*
  53. *@return -1 not sorted 0 sorted
  54. */
  55. int _ttail_search_file_sorted(ttail_t*);
  56. /**@brief Attempt to reopen a file
  57. *@param ttail_t* ttail
  58. *@param size_t id file id in ttail
  59. *@return 0 on success, -1 on failure and errno is set
  60. *@throw EINVAL if id is too big
  61. */
  62. int _ttail_file_reopen(ttail_t*, size_t);
  63. /**@brief Search next line
  64. *
  65. *Set f pos to next line begining and return the position
  66. *@param FILE* f
  67. *@return -1 on error 0 on EOF else return the next line position
  68. */
  69. long _ttail_file_next_line(FILE*);
  70. /**@brief Search line start
  71. *
  72. *Set f pos to line begining and return the position
  73. *@param FILE* f
  74. *@return -1 on error else return the next line position
  75. */
  76. long _ttail_file_start_line(FILE*);
  77. /**@brief Free the ttail_search_file_t session
  78. *@param ttail_t* ttail
  79. */
  80. void _ttail_search_file_free(ttail_t*);
  81. #endif