Deleted Added
full compact
fifolog_writer.c (219027) fifolog_writer.c (219095)
1/*-
2 * Copyright (c) 2005-2008 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

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
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2005-2008 Poul-Henning Kamp
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

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
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c 219027 2011-02-25 09:40:17Z phk $
26 * $FreeBSD: head/usr.sbin/fifolog/fifolog_writer/fifolog_writer.c 219095 2011-02-28 09:11:46Z phk $
27 */
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <sysexits.h>
32#include <err.h>
33#include <unistd.h>
34#include <ctype.h>
35#include <assert.h>
36#include <poll.h>
37#include <string.h>
38#include <zlib.h>
39
40#include "libfifolog.h"
41
42static void
43usage(void)
44{
27 */
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <sysexits.h>
32#include <err.h>
33#include <unistd.h>
34#include <ctype.h>
35#include <assert.h>
36#include <poll.h>
37#include <string.h>
38#include <zlib.h>
39
40#include "libfifolog.h"
41
42static void
43usage(void)
44{
45 fprintf(stderr, "Usage: fifolog_writer [-w write-rate] [-s sync-rate] "
45 fprintf(stderr,
46 "Usage: fifolog_writer [-w write-rate] [-s sync-rate] "
46 "[-z compression] file\n");
47 exit(EX_USAGE);
48}
49
50int
51main(int argc, char * const *argv)
52{
53 struct fifolog_writer *f;

--- 46 unchanged lines hidden (view full) ---

100 if (fgets(buf, sizeof buf, stdin) == NULL)
101 break;
102 p = strchr(buf, '\0');
103 assert(p != NULL);
104 while (p > buf && isspace(p[-1]))
105 p--;
106 *p = '\0';
107 if (*buf != '\0')
47 "[-z compression] file\n");
48 exit(EX_USAGE);
49}
50
51int
52main(int argc, char * const *argv)
53{
54 struct fifolog_writer *f;

--- 46 unchanged lines hidden (view full) ---

101 if (fgets(buf, sizeof buf, stdin) == NULL)
102 break;
103 p = strchr(buf, '\0');
104 assert(p != NULL);
105 while (p > buf && isspace(p[-1]))
106 p--;
107 *p = '\0';
108 if (*buf != '\0')
108 fifolog_write_bytes_poll(f, 0, 0, buf, 0);
109 fifolog_write_record_poll(f, 0, 0, buf, 0);
109 } else if (i == 0)
110 } else if (i == 0)
110 (void)fifolog_write_poll(f, 0);
111 fifolog_write_poll(f, 0);
111 }
112 }
112 (void)fifolog_write_flush(f);
113 fifolog_write_close(f);
113 return (0);
114}
114 return (0);
115}