main.c (0d3e72861810e434c4f79b7a74e5268eac06b3fe) main.c (e1b4d8d0746069292d84708b0e11b17a7e1ef5e0)
1
2/*
3 * main.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

151 buf, sizeof(buf), NULL)) < 0)
152 err(EX_OSERR, "read(hook)");
153 if (rl == 0)
154 errx(EX_OSERR, "read EOF from hook?!");
155
156 /* Write packet to stdout */
157 if (asciiFlag)
158 WriteAscii((u_char *) buf, rl);
1
2/*
3 * main.c
4 *
5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
6 * All rights reserved.
7 *
8 * Subject to the following obligations and disclaimer of warranty, use and

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

151 buf, sizeof(buf), NULL)) < 0)
152 err(EX_OSERR, "read(hook)");
153 if (rl == 0)
154 errx(EX_OSERR, "read EOF from hook?!");
155
156 /* Write packet to stdout */
157 if (asciiFlag)
158 WriteAscii((u_char *) buf, rl);
159 else if ((wl = write(1, buf, rl)) != rl) {
159 else if ((wl = write(STDOUT_FILENO, buf, rl)) != rl) {
160 if (wl < 0) {
161 err(EX_OSERR, "write(stdout)");
162 } else {
163 errx(EX_OSERR,
164 "stdout: read %d, wrote %d",
165 rl, wl);
166 }
167 }

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

216 buf[count + k] : '.';
217 snprintf(sbuf + strlen(sbuf),
218 sizeof(sbuf) - strlen(sbuf), "%c", ch);
219 } else
220 snprintf(sbuf + strlen(sbuf),
221 sizeof(sbuf) - strlen(sbuf), " ");
222 snprintf(sbuf + strlen(sbuf),
223 sizeof(sbuf) - strlen(sbuf), "\n");
160 if (wl < 0) {
161 err(EX_OSERR, "write(stdout)");
162 } else {
163 errx(EX_OSERR,
164 "stdout: read %d, wrote %d",
165 rl, wl);
166 }
167 }

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

216 buf[count + k] : '.';
217 snprintf(sbuf + strlen(sbuf),
218 sizeof(sbuf) - strlen(sbuf), "%c", ch);
219 } else
220 snprintf(sbuf + strlen(sbuf),
221 sizeof(sbuf) - strlen(sbuf), " ");
222 snprintf(sbuf + strlen(sbuf),
223 sizeof(sbuf) - strlen(sbuf), "\n");
224 (void) write(1, sbuf, strlen(sbuf));
224 (void) write(STDOUT_FILENO, sbuf, strlen(sbuf));
225 }
226 ch = '\n';
227 write(1, &ch, 1);
228}
229
230/*
231 * Display usage and exit
232 */
233static void
234Usage(void)
235{
236 errx(EX_USAGE, "usage: nghook [-adln] path [hookname]");
237}
238
225 }
226 ch = '\n';
227 write(1, &ch, 1);
228}
229
230/*
231 * Display usage and exit
232 */
233static void
234Usage(void)
235{
236 errx(EX_USAGE, "usage: nghook [-adln] path [hookname]");
237}
238