03_all_arpwatch-2.1a15-getopt.patch 2.85 KB
Newer Older
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
Patch from debian. Just reorders usage output and getopt options to ease adding new features.


diff -Naru arpwatch-2.1a15.orig/arpsnmp.8 arpwatch-2.1a15/arpsnmp.8
--- arpwatch-2.1a15.orig/arpsnmp.8	2006-09-22 17:18:02.000000000 +0400
+++ arpwatch-2.1a15/arpsnmp.8	2006-09-22 18:17:44.000000000 +0400
@@ -27,10 +27,15 @@
 .B arpsnmp
 [
 .B -d
-] [
+]
+.br
+.ti +8
+[
 .B -f
 .I datafile
 ]
+.br
+.ti +8
 .I file
 [
 .I ...
diff -Naru arpwatch-2.1a15.orig/arpsnmp.c arpwatch-2.1a15/arpsnmp.c
--- arpwatch-2.1a15.orig/arpsnmp.c	2004-01-23 01:25:17.000000000 +0300
+++ arpwatch-2.1a15/arpsnmp.c	2006-09-22 18:17:15.000000000 +0400
@@ -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);
 }
diff -Naru arpwatch-2.1a15.orig/arpwatch.8 arpwatch-2.1a15/arpwatch.8
--- arpwatch-2.1a15.orig/arpwatch.8	2006-09-22 17:18:02.000000000 +0400
+++ arpwatch-2.1a15/arpwatch.8	2006-09-22 18:19:20.000000000 +0400
@@ -28,10 +28,16 @@
 .B arpwatch
 [
 .B -dN
-] [
+]
+.br
+.ti +8
+[
 .B -f
 .I datafile
-] [
+]
+.br
+.ti +8
+[
 .B -i
 .I interface
 ]
@@ -40,7 +46,10 @@
 [
 .B -n
 .IR net [/ width
-]] [
+]]
+.br
+.ti +8
+[
 .B -r
 .I file
 ]
diff -Naru arpwatch-2.1a15.orig/arpwatch.c arpwatch-2.1a15/arpwatch.c
--- arpwatch-2.1a15.orig/arpwatch.c	2004-01-23 01:18:20.000000000 +0300
+++ arpwatch-2.1a15/arpwatch.c	2006-09-22 18:22:35.000000000 +0400
@@ -153,6 +153,14 @@
 	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 +178,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 +209,6 @@
 		case 'r':
 			rfilename = optarg;
 			break;
-
 		default:
 			usage();
 		}
@@ -748,9 +755,16 @@
 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);
 }