2
* collectd - src/utils_tail.h
3
* Copyright (C) 2007-2008 C-Ware, Inc.
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License as published by the
7
* Free Software Foundation; only version 2 of the License is applicable.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Luke Heberling <lukeh at c-ware.com>
22
* Facilitates reading information that is appended to a file, taking into
23
* account that the file may be rotated and a new file created under the
28
#define UTILS_TAIL_H 1
31
typedef struct cu_tail_s cu_tail_t;
33
typedef int tailfunc_t(void *data, char *buf, int buflen);
40
* Allocates a new tail object..
43
* `file' The name of the file to be tailed.
45
cu_tail_t *cu_tail_create (const char *file);
50
* Takes a tail object returned by `cu_tail_create' and destroys it, freeing
51
* all internal memory.
53
* Returns 0 when successful and non-zero otherwise.
55
int cu_tail_destroy (cu_tail_t *obj);
60
* Reads from the file until `buflen' characters are read, a newline
61
* character is read, or an eof condition is encountered. `buf' is
62
* always null-terminated on successful return and isn't touched when non-zero
65
* You can check if the EOF condition is reached by looking at the buffer: If
66
* the length of the string stored in the buffer is zero, EOF occurred.
67
* Otherwise at least the newline character will be in the buffer.
69
* Returns 0 when successful and non-zero otherwise.
71
int cu_tail_readline (cu_tail_t *obj, char *buf, int buflen);
76
* Reads from the file until eof condition or an error is encountered.
78
* Returns 0 when successful and non-zero otherwise.
80
int cu_tail_read (cu_tail_t *obj, char *buf, int buflen, tailfunc_t *callback,
83
#endif /* UTILS_TAIL_H */