1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /*
- * Copyright 2017 Yann Weber
- *
- * This file is part of Ttail.
- *
- * Ttail is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Ttail is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ttail. If not, see <http://www.gnu.org/licenses/>.
- */
- #ifndef _ttail_search_std_h__
- #define _ttail_search_std_h__
-
- #include <errno.h>
- #include <string.h>
- #include <stdlib.h>
-
- typedef struct _ttail_search_stdin_s ttail_search_stdin_t;
- /*<! Private search session for stdin */
- struct _ttail_search_stdin_s
- {
- /**@brief ttail_std_getline buffer
- *@note buffer is used by format detection
- */
- char *buff;
- /**@brief buffer size */
- size_t buff_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_std_getline(TTAIL) (getline(\
- &(TTAIL->session->std.buff), &(TTAIL->session->std.buff_sz), stdin))
- /*<!Accessor to getline wrapper buffer */
- #define ttail_std_getline_buff(TTAIL) (TTAIL->session->std.buff)
-
- /**@brief init private session members
- *@patam ttail_t* t
- *@return -1 on error else 0
- *@todo checks
- */
- int ttail_search_std_init(ttail_t* t);
-
- /**@brief Date format initialisation using logfiles
- *
- *If no format set yet attempt to guess it from logfiles
- *@param ttail_t*
- *@return 0 on success -1 on failure 1 if format was allready set
- *@see _ttail_search_files_fmt_guess()
- */
- int _ttail_search_std_fmt_init(ttail_t*);
-
- /**@brief @ref ttail_search_closest() implementation for stdin
- *@warning Expect that ttail_search_closest_std_init() has been called
- *@note when returns ttail->session->std.buff contains the first
- *line to print
- *@param ttail_t*
- *@param struct tm* tmin
- *@return 0 if ok -1 if fatal error 1 if not found
- *@todo checks
- */
- int _ttail_search_closest_stdin(ttail_t*);
-
- /**@brief Output result loglines to stdout
- *@param ttail_t*
- *@param int fd
- *@todo checks
- */
- void _ttail_search_print_stdin(ttail_t*, int);
-
- /**@brief free private session members
- *@patam ttail_t* t
- */
- void _ttail_search_stdin_free(ttail_t* t);
-
- #endif
|