2 * Copyright (c) 2005-2008 Poul-Henning Kamp
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 #include "libfifolog.h"
46 "Usage: fifolog_writer [-w write-rate] [-s sync-rate] "
47 "[-z compression] file\n");
52 main(int argc, char * const *argv)
54 struct fifolog_writer *f;
61 unsigned z_opt = Z_BEST_COMPRESSION;
63 while ((c = getopt(argc, argv, "w:s:z:")) != -1) {
66 w_opt = strtoul(optarg, NULL, 0);
69 s_opt = strtoul(optarg, NULL, 0);
72 z_opt = strtoul(optarg, NULL, 0);
89 f = fifolog_write_new();
92 es = fifolog_write_open(f, argv[0], w_opt, s_opt, z_opt);
94 err(1, "Error: %s", es);
98 pfd[0].events = POLLIN;
99 i = poll(pfd, 1, 1000);
101 if (fgets(buf, sizeof buf, stdin) == NULL)
103 p = strchr(buf, '\0');
105 while (p > buf && isspace(p[-1]))
109 fifolog_write_record_poll(f, 0, 0, buf, 0);
111 fifolog_write_poll(f, 0);
113 fifolog_write_close(f);