summaryrefslogtreecommitdiff
path: root/misc/parchive/patches/patch-ab
blob: 3acd84703f9c9c15eb9f95aaf28dab5a8bd8c4b1 (plain)
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
$NetBSD: patch-ab,v 1.2 2003/08/25 20:23:08 fredb Exp $

--- main.c.orig	Sat Nov 17 13:29:48 2001
+++ main.c
@@ -21,6 +21,7 @@
 #include "interface.h"
 
 struct cmdline cmd;
+char* progname;
 
 /*\
 |*| Print usage
@@ -30,12 +31,13 @@ usage(void)
 {
 	printf(
 "Usage:\n"
-"   par c(heck)   [options] <par file>         : Check parity archive\n"
-"   par r(ecover) [options] <par file>         : Restore missing volumes\n"
-"   par a(dd)     [options] <par file> [files] : Add files to parity archive\n"
+"   %s c(heck)   [options] <par file>         : Check parity archive\n"
+"   %s r(ecover) [options] <par file>         : Restore missing volumes\n"
+"   %s a(dd)     [options] <par file> [files] : Add files to parity archive\n"
+"   %s t(able)   [options] <par file>         : List contents of parity archive\n"
 " Advanced:\n"
-"   par m(ix)     [options] : Try to restore from all parity files at once\n"
-"   par i(nteractive) [<par files>] : Interactive mode (very bare-bones)\n"
+"   %s m(ix)     [options] : Try to restore from all parity files at once\n"
+"   %s i(nteractive) [<par files>] : Interactive mode (very bare-bones)\n"
 "\n"
 "Options: (Can be turned off with '+')\n"
 "    -m   : Move existing files out of the way\n"
@@ -52,8 +54,8 @@ usage(void)
 "    -v,+v: Increase or decrease verbosity\n"
 "    -h,-?: Display this help\n"
 "    --   : Always treat following arguments as files\n"
-"\n"
-	);
+"\n",
+	progname, progname, progname, progname, progname, progname);
 	return 0;
 }
 
@@ -97,6 +99,8 @@ main(int argc, char *argv[])
 	if (check_sizes())
 		return -1;
 
+	progname = argv[0];
+
 	/*\ Some defaults \*/
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.volumes = 10;
@@ -207,6 +211,10 @@ main(int argc, char *argv[])
 			case 'I':
 				cmd.action = ACTION_TEXT_UI;
 				break;
+			case 't':
+			case 'T':
+				cmd.action = ACTION_CONTENTS;
+				break;
 			default:
 				fprintf(stderr, "Unknown command: '%s'\n",
 						argv[1]);
@@ -244,6 +252,17 @@ main(int argc, char *argv[])
 			break;
 		case ACTION_TEXT_UI:
 			par_load(unist(argv[1]));
+			break;
+		case ACTION_CONTENTS:
+			fprintf(stderr, "Reading %s\n", argv[1]);
+			par = read_par_header(unist(argv[1]), 0, 0, 0);
+			if (!par) {
+				fail = 2;
+				continue;
+			}
+			dump_par(par);
+			free_par(par);
+			par=0;
 			break;
 		}
 	}