12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #ifndef _ttail_search_files_h__
- #define _ttail_search_files_h__
-
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <regex.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
-
- typedef struct _ttail_search_file_s ttail_search_file_t;
-
-
- /*<! Private search session for logfiles */
- struct _ttail_search_file_s
- {
- /*<! logfile sizes */
- off_t *file_sz;
- #ifdef TTAIL_HUGE_FILE
- /*<! Shift width to apply on size to compute stuff */
- short sz_div;
- #endif
- /*<! Computed files start size */
- off_t *vfile;
- /*<! Computed file sizes sum */
- off_t vsz;
- /*<! Computed position */
- off_t vpos;
-
- char *buf;
- size_t buf_sz;
- };
-
- #include "config.h"
- #include "ttail.h"
- #include "ttail_search.h"
-
- /**@brief Convenient wrapper for getline
- *@param ttail_t* TTAIL
- *@param size_t ID file id
- *@return @ref getline()
- */
- #define ttail_getline(TTAIL, ID) (getline(\
- &(TTAIL->session->file.buf), &(TTAIL->session->file.buf_sz),\
- TTAIL->logfile[ID]))
- /*<!Accessor to getline wrapper buffer */
- #define ttail_getline_buf(TTAIL) (TTAIL->session->file.buf)
-
- /**@brief @ref ttail_search_closest() implementation for logfiles
- *@param ttail_t*
- *@return 0 if ok -1 if fatal error 1 if not found
- */
- int _ttail_search_closest_files(ttail_t*);
- int _ttail_search_closest_files_init(ttail_t*);
- int _ttail_search_closest_files_set_fsizes(ttail_t*);
-
- /**@brief Test if files are sorted
- *
- *If not sorted attempt to sort them
- *@param ttail_t*
- *@return -1 not sorted 0 sorted
- */
- int _ttail_search_file_sorted(ttail_t*);
-
- /**@brief Attempt to reopen a file
- *@param ttail_t* ttail
- *@param size_t id file id in ttail
- *@return 0 on success, -1 on failure and errno is set
- *@throw EINVAL if id is too big
- */
- int _ttail_file_reopen(ttail_t*, size_t);
-
- /**@brief Search next line
- *
- *Set f pos to next line begining and return the position
- *@param FILE* f
- *@return -1 on error 0 on EOF else return the next line position
- */
- long _ttail_file_next_line(FILE*);
-
- /**@brief Search line start
- *
- *Set f pos to line begining and return the position
- *@param FILE* f
- *@return -1 on error else return the next line position
- */
- long _ttail_file_start_line(FILE*);
-
- /**@brief Free the ttail_search_file_t session
- *@param ttail_t* ttail
- */
- void _ttail_search_file_free(ttail_t*);
- #endif
|