File: 10getopt_patchable

package info (click to toggle)
arpwatch 2.1a15-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,988 kB
  • sloc: sh: 3,047; ansic: 2,811; makefile: 90; awk: 90; perl: 15
file content (297 lines) | stat: -rw-r--r-- 4,451 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
Description: prepare for the simple addition of options through patches
Author: KELEMEN Péter <fuji@debian.org>
Author: Axel Beckert <abe@debian.org>
Last-Update: 2015-06-13

--- a/arpsnmp.8
+++ b/arpsnmp.8
@@ -27,10 +27,19 @@
 .B arpsnmp
 [
 .B \-d
-] [
+]
+.\" **
+.\" **
+.br
+.ti +8
+[
 .B \-f
 .I datafile
 ]
+.\" **
+.\" **
+.br
+.ti +8
 .I file
 [
 .I ...
@@ -42,18 +51,24 @@
 .B Arpsnmp
 reads information from a file (usually generated by
 .BR snmpwalk (8)).
+.\" **
+.\" **
 .LP
 The
 .B \-d
 flag is used enable debugging. This also inhibits mailing the reports.
 Instead, they are sent to
 .IR stderr .
+.\" **
+.\" **
 .LP
 The
 .B \-f
 flag is used to set the ethernet/ip address database filename.
 The default is
 .IR arp.dat .
+.\" **
+.\" **
 .LP
 Note that an empty
 .I arp.dat
--- a/arpsnmp.c
+++ b/arpsnmp.c
@@ -78,6 +78,10 @@
 	register char *cp;
 	register int op, i;
 	char errbuf[256];
+	char options[] =
+		"d"
+		"f:"
+	;
 
 	if ((cp = strrchr(argv[0], '/')) != NULL)
 		prog = cp + 1;
@@ -90,7 +94,7 @@
 	}
 
 	opterr = 0;
-	while ((op = getopt(argc, argv, "df:")) != EOF)
+	while ((op = getopt(argc, argv, options)) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -182,9 +186,14 @@
 usage(void)
 {
 	extern char version[];
+	char usage[] =
+		"[-d] "
+		"[-f datafile] "
+		"file [...]\n"
+	;
 
 	(void)fprintf(stderr, "Version %s\n", version);
 	(void)fprintf(stderr,
-	    "usage: %s [-d] [-f datafile] file [...]\n", prog);
+	    "usage: %s %s", prog, usage);
 	exit(1);
 }
--- a/arpwatch.8
+++ b/arpwatch.8
@@ -26,12 +26,24 @@
 .SH SYNOPSIS
 .na
 .B arpwatch
+.\" **
+.\" **
 [
 .B \-dN
-] [
+]
+.\" **
+.\" **
+.br
+.ti +8
+[
 .B \-f
 .I datafile
-] [
+]
+.\" **
+.\" **
+.br
+.ti +8
+[
 .B \-i
 .I interface
 ]
@@ -40,10 +52,17 @@
 [
 .B -n
 .IR net [/ width
-]] [
+]]
+.\" **
+.\" **
+.br
+.ti +8
+[
 .B \-r
 .I file
 ]
+.\" **
+.\" **
 .ad
 .SH DESCRIPTION
 .B Arpwatch
@@ -53,22 +72,30 @@
 uses
 .BR pcap (3)
 to listen for arp packets on a local ethernet interface.
+.\" **
+.\" **
 .LP
 The
 .B \-d
 flag is used enable debugging. This also inhibits forking into the
 background and emailing the reports. Instead, they are sent to
 .IR stderr .
+.\" **
+.\" **
 .LP
 The
 .B \-f
 flag is used to set the ethernet/ip address database filename.
 The default is
 .IR arp.dat .
+.\" **
+.\" **
 .LP
 The
 .B \-i
 flag is used to override the default interface.
+.\" **
+.\" **
 .LP
 The
 .B \-n
@@ -77,10 +104,14 @@
 on the same wire. If the optional
 .I width
 is not specified, the default netmask for the network's class is used.
+.\" **
+.\" **
 .LP
 The
 .B \-N
 flag disables reporting any bogons.
+.\" **
+.\" **
 .LP
 The
 .B \-r
@@ -93,11 +124,15 @@
 of reading from the network. In this case,
 .B arpwatch
 does not fork.
+.\" **
+.\" **
 .LP
 Note that an empty
 .I arp.dat
 file must be created before the first time you run
 .BR arpwatch .
+.\" **
+.\" **
 .LP
 .SH "REPORT MESSAGES"
 Here's a quick list of the report messages generated by
--- a/arpwatch.c
+++ b/arpwatch.c
@@ -153,6 +153,26 @@
 	register char *interface, *rfilename;
 	struct bpf_program code;
 	char errbuf[PCAP_ERRBUF_SIZE];
+	char options[] =
+		"d"
+		/**/
+		/**/
+		"f:"
+		/**/
+		/**/
+		"i:"
+		/**/
+		/**/
+		"n:"
+		/**/
+		/**/
+		"N"
+		/**/
+		/**/
+		"r:"
+		/**/
+		/**/
+	;
 
 	if (argv[0] == NULL)
 		prog = "arpwatch";
@@ -170,7 +190,7 @@
 	interface = NULL;
 	rfilename = NULL;
 	pd = NULL;
-	while ((op = getopt(argc, argv, "df:i:n:Nr:")) != EOF)
+	while ((op = getopt(argc, argv, options)) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -201,7 +221,8 @@
 		case 'r':
 			rfilename = optarg;
 			break;
-
+		/**/
+		/**/
 		default:
 			usage();
 		}
@@ -748,9 +769,26 @@
 usage(void)
 {
 	extern char version[];
+	char usage[] =
+		"[-dN] "
+		/**/
+		/**/
+		"[-f datafile] "
+		/**/
+		/**/
+		"[-i interface] "
+		/**/
+		/**/
+		"[-n net[/width]] "
+		/**/
+		/**/
+		"[-r file] "
+		/**/
+		/**/
+		"\n"
+	;
 
 	(void)fprintf(stderr, "Version %s\n", version);
-	(void)fprintf(stderr, "usage: %s [-dN] [-f datafile] [-i interface]"
-	    " [-n net[/width]] [-r file]\n", prog);
+	(void)fprintf(stderr, "usage: %s %s", prog, usage);
 	exit(1);
 }
--- a/util.c
+++ b/util.c
@@ -61,6 +61,8 @@
 
 int debug = 0;
 int initializing = 1;			/* true if initializing */
+/**/
+/**/
 
 /* syslog() helper routine */
 void
--- a/util.h
+++ b/util.h
@@ -17,3 +17,5 @@
 
 extern int debug;
 extern int initializing;
+/**/
+/**/