| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: irdaattach.c,v 1.8 2009/04/16 02:11:44 lukem Exp $ */ | | 1 | /* $NetBSD: irdaattach.c,v 1.9 2011/08/30 19:07:07 joerg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson (lennart@augustsson.net). | | 8 | * by Lennart Augustsson (lennart@augustsson.net). |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -36,28 +36,27 @@ | | | @@ -36,28 +36,27 @@ |
36 | #include <dev/ir/irdaio.h> | | 36 | #include <dev/ir/irdaio.h> |
37 | | | 37 | |
38 | #include <err.h> | | 38 | #include <err.h> |
39 | #include <fcntl.h> | | 39 | #include <fcntl.h> |
40 | #include <paths.h> | | 40 | #include <paths.h> |
41 | #include <signal.h> | | 41 | #include <signal.h> |
42 | #include <stdio.h> | | 42 | #include <stdio.h> |
43 | #include <stdlib.h> | | 43 | #include <stdlib.h> |
44 | #include <string.h> | | 44 | #include <string.h> |
45 | #include <termios.h> | | 45 | #include <termios.h> |
46 | #include <unistd.h> | | 46 | #include <unistd.h> |
47 | #include <util.h> | | 47 | #include <util.h> |
48 | | | 48 | |
49 | int main(int, char **); | | 49 | __dead static void usage(void); |
50 | void usage(void); | | | |
51 | | | 50 | |
52 | int | | 51 | int |
53 | main(int argc, char **argv) | | 52 | main(int argc, char **argv) |
54 | { | | 53 | { |
55 | int fd; | | 54 | int fd; |
56 | char *dev, devbuf[100]; | | 55 | char *dev, devbuf[100]; |
57 | const char *donglename = "none"; | | 56 | const char *donglename = "none"; |
58 | struct termios tty; | | 57 | struct termios tty; |
59 | tcflag_t cflag = HUPCL; | | 58 | tcflag_t cflag = HUPCL; |
60 | int ch; | | 59 | int ch; |
61 | sigset_t nsigset; | | 60 | sigset_t nsigset; |
62 | int opt_detach = 1; | | 61 | int opt_detach = 1; |
63 | int pr_pid = 0; | | 62 | int pr_pid = 0; |
| @@ -147,21 +146,21 @@ main(int argc, char **argv) | | | @@ -147,21 +146,21 @@ main(int argc, char **argv) |
147 | if (ioctl(fd, IRFRAMETTY_SET_DONGLE, &dongle) < 0) | | 146 | if (ioctl(fd, IRFRAMETTY_SET_DONGLE, &dongle) < 0) |
148 | err(1, "IRFRAMETTY_SET_DONGLE"); | | 147 | err(1, "IRFRAMETTY_SET_DONGLE"); |
149 | | | 148 | |
150 | fflush(stdout); | | 149 | fflush(stdout); |
151 | if (opt_detach && daemon(0, 0) != 0) | | 150 | if (opt_detach && daemon(0, 0) != 0) |
152 | err(1, "couldn't detach"); | | 151 | err(1, "couldn't detach"); |
153 | if (pr_pid) | | 152 | if (pr_pid) |
154 | pidfile(NULL); | | 153 | pidfile(NULL); |
155 | sigemptyset(&nsigset); | | 154 | sigemptyset(&nsigset); |
156 | for (;;) | | 155 | for (;;) |
157 | sigsuspend(&nsigset); | | 156 | sigsuspend(&nsigset); |
158 | } | | 157 | } |
159 | | | 158 | |
160 | void | | 159 | static void |
161 | usage() | | 160 | usage(void) |
162 | { | | 161 | { |
163 | | | 162 | |
164 | fprintf(stderr, "usage: %s [-d donglename] [-fhHlmnp] ttyname\n", | | 163 | fprintf(stderr, "usage: %s [-d donglename] [-fhHlmnp] ttyname\n", |
165 | getprogname()); | | 164 | getprogname()); |
166 | exit(1); | | 165 | exit(1); |
167 | } | | 166 | } |