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_search_std.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_search_std_h__
  20. #define _ttail_search_std_h__
  21. #include <errno.h>
  22. #include <string.h>
  23. #include <stdlib.h>
  24. typedef struct _ttail_search_stdin_s ttail_search_stdin_t;
  25. /*<! Private search session for stdin */
  26. struct _ttail_search_stdin_s
  27. {
  28. char *buff;
  29. size_t buff_sz;
  30. };
  31. #include "config.h"
  32. #include "ttail.h"
  33. #include "ttail_search.h"
  34. /**@brief Convenient wrapper for getline
  35. *@param ttail_t* TTAIL
  36. *@param size_t ID file id
  37. *@return @ref getline()
  38. */
  39. #define ttail_std_getline(TTAIL) (getline(\
  40. &(TTAIL->session->std.buff), &(TTAIL->session->std.buff_sz), stdin))
  41. /*<!Accessor to getline wrapper buffer */
  42. #define ttail_std_getline_buff(TTAIL) (TTAIL->session->std.buff)
  43. /**@brief init private session members
  44. *@patam ttail_t* t
  45. *@return -1 on error else 0
  46. *@todo checks
  47. */
  48. int _ttail_search_closest_std_init(ttail_t* t);
  49. /**@brief @ref ttail_search_closest() implementation for stdin
  50. *@note when returns ttail->session->std.buff contains the first
  51. *line to print
  52. *@param ttail_t*
  53. *@param struct tm* tmin
  54. *@return 0 if ok -1 if fatal error 1 if not found
  55. *@todo checks
  56. */
  57. int _ttail_search_closest_stdin(ttail_t*);
  58. /**@brief Output result loglines to stdout
  59. *@param ttail_t*
  60. *@param int fd
  61. *@todo checks
  62. */
  63. void _ttail_search_print_stdin(ttail_t*, int);
  64. /**@brief free private session members
  65. *@patam ttail_t* t
  66. */
  67. void _ttail_search_stdin_free(ttail_t* t);
  68. #endif