xref: /freebsd-src/usr.sbin/fifolog/lib/libfifolog.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1662cb04cSPoul-Henning Kamp /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
4662cb04cSPoul-Henning Kamp  * Copyright (c) 2005-2008 Poul-Henning Kamp
5662cb04cSPoul-Henning Kamp  * All rights reserved.
6662cb04cSPoul-Henning Kamp  *
7662cb04cSPoul-Henning Kamp  * Redistribution and use in source and binary forms, with or without
8662cb04cSPoul-Henning Kamp  * modification, are permitted provided that the following conditions
9662cb04cSPoul-Henning Kamp  * are met:
10662cb04cSPoul-Henning Kamp  * 1. Redistributions of source code must retain the above copyright
11662cb04cSPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer.
12662cb04cSPoul-Henning Kamp  * 2. Redistributions in binary form must reproduce the above copyright
13662cb04cSPoul-Henning Kamp  *    notice, this list of conditions and the following disclaimer in the
14662cb04cSPoul-Henning Kamp  *    documentation and/or other materials provided with the distribution.
15662cb04cSPoul-Henning Kamp  *
16662cb04cSPoul-Henning Kamp  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17662cb04cSPoul-Henning Kamp  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18662cb04cSPoul-Henning Kamp  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19662cb04cSPoul-Henning Kamp  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20662cb04cSPoul-Henning Kamp  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21662cb04cSPoul-Henning Kamp  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22662cb04cSPoul-Henning Kamp  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23662cb04cSPoul-Henning Kamp  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24662cb04cSPoul-Henning Kamp  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25662cb04cSPoul-Henning Kamp  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26662cb04cSPoul-Henning Kamp  * SUCH DAMAGE.
27662cb04cSPoul-Henning Kamp  */
28662cb04cSPoul-Henning Kamp 
29662cb04cSPoul-Henning Kamp #include <sys/stdint.h>
30662cb04cSPoul-Henning Kamp 
31662cb04cSPoul-Henning Kamp /* CREATORS */
326e482ac5SPoul-Henning Kamp const char *fifolog_create(const char *fn, off_t size, ssize_t recsize);
33662cb04cSPoul-Henning Kamp 
34662cb04cSPoul-Henning Kamp /* WRITERS */
35662cb04cSPoul-Henning Kamp 
366e482ac5SPoul-Henning Kamp #include "fifolog_write.h"
37662cb04cSPoul-Henning Kamp 
38662cb04cSPoul-Henning Kamp /* READERS */
39662cb04cSPoul-Henning Kamp 
40662cb04cSPoul-Henning Kamp typedef void fifolog_reader_render_t(void *priv, time_t when, unsigned flag, const unsigned char *p, unsigned l);
41662cb04cSPoul-Henning Kamp struct fifolog_reader;
42662cb04cSPoul-Henning Kamp struct fifolog_reader *fifolog_reader_open(const char *fname);
43662cb04cSPoul-Henning Kamp off_t fifolog_reader_seek(const struct fifolog_reader *fl, time_t t0);
44662cb04cSPoul-Henning Kamp void fifolog_reader_process(struct fifolog_reader *fl, off_t from, fifolog_reader_render_t *func, void *priv, time_t end);
45662cb04cSPoul-Henning Kamp 
46662cb04cSPoul-Henning Kamp /* UTILS */
47662cb04cSPoul-Henning Kamp time_t get_date(char *p);
48