summaryrefslogtreecommitdiff
blob: 860c866eeab30d97e443832e17215732639a2a21 (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
81
diff -ur rzip-2.1/main.c rzip-2.1-patched/main.c
--- rzip-2.1/main.c	2006-02-14 01:38:23.000000000 +0100
+++ rzip-2.1-patched/main.c	2008-07-30 19:29:49.426926726 +0200
@@ -35,6 +35,7 @@
 	printf("     -k            keep existing files\n");
 	printf("     -P            show compression progress\n");
 	printf("     -L level      set compression level\n");
+	printf("     -l nr         set higher bits of the expected file length to nr\n");
 	printf("     -V            show version\n");
 #if 0
 	/* damn, this will be quite hard to do */
@@ -172,6 +173,13 @@
 
 	
 	read_magic(fd_in, fd_out, &expected_size);
+
+#ifdef HAVE_LARGE_FILES
+	if (control->nr) {
+		expected_size = ( ((off_t)(control->nr))<<32) | (expected_size & 0xFFFFFFFF);
+	}
+#endif
+
 	runzip_fd(fd_in, fd_out, fd_hist, expected_size);	
 	
 	if ((control->flags & FLAG_TEST_ONLY) == 0) {
@@ -267,7 +275,7 @@
 		control.flags |= FLAG_DECOMPRESS;
 	}
 
-	while ((c = getopt(argc, argv, "h0123456789dS:tVvkfPo:L:")) != -1) {
+	while ((c = getopt(argc, argv, "h0123456789dS:tVvkl:fPo:L:")) != -1) {
 		if (isdigit(c)) {
 			control.compression_level = c - '0';
 			continue;
@@ -295,6 +303,12 @@
 		case 'k':
 			control.flags |= FLAG_KEEP_FILES;
 			break;
+		case 'l':
+#ifndef HAVE_LARGE_FILES
+			fatal("You used the -l option, but this rzip doesn't support large files.");
+#endif
+			control.nr = atoi(optarg);
+			break;
 		case 'v':
 			control.verbosity++;
 			break;
diff -ur rzip-2.1/runzip.c rzip-2.1-patched/runzip.c
--- rzip-2.1/runzip.c	2003-10-08 00:08:28.000000000 +0200
+++ rzip-2.1-patched/runzip.c	2008-07-30 19:34:03.803564086 +0200
@@ -179,10 +179,16 @@
  */
 off_t runzip_fd(int fd_in, int fd_out, int fd_hist, off_t expected_size)
 {
-	off_t total = 0;
-	while (total < expected_size) {
-		total += runzip_chunk(fd_in, fd_out, fd_hist);
+	off_t total = 0, fin=1;
+	while (fin && total < expected_size) {
+		fin = runzip_chunk(fd_in, fd_out, fd_hist);
+		total += fin;
 	}
+
+	if (total < expected_size) {
+		fprintf(stderr, "Warning: The uncompressed size does not equal the expected file size.\nHowever if you used the -l option, this may be okay.\n");
+	}
+
 	return total;
 }
 
diff -ur rzip-2.1/rzip.h rzip-2.1-patched/rzip.h
--- rzip-2.1/rzip.h	2006-02-14 01:38:23.000000000 +0100
+++ rzip-2.1-patched/rzip.h	2008-07-30 19:29:49.426926726 +0200
@@ -113,6 +113,7 @@
 	unsigned compression_level;
 	unsigned flags;
 	unsigned verbosity;
+	unsigned nr;
 };
 
 void fatal(const char *format, ...);