diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-01 15:55:11 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-01 15:55:11 +0000 |
commit | 97a8dd3857aea9730382e2975a2ee2000fd23ebb (patch) | |
tree | 608f73898f3ed5f466dff68189625fa9328a15be | |
parent | f8aa109a9f7c67b291f240fb3ed91da90f26359b (diff) | |
download | busybox-w32-97a8dd3857aea9730382e2975a2ee2000fd23ebb.tar.gz busybox-w32-97a8dd3857aea9730382e2975a2ee2000fd23ebb.tar.bz2 busybox-w32-97a8dd3857aea9730382e2975a2ee2000fd23ebb.zip |
g[un]zip: add support for -v (verbose).
Add CONFIG_DESKTOP, almost all bloat from this change
is hidden under that.
-rw-r--r-- | Config.in | 8 | ||||
-rw-r--r-- | archival/bunzip2.c | 5 | ||||
-rw-r--r-- | archival/gunzip.c | 56 | ||||
-rw-r--r-- | archival/gzip.c | 7 | ||||
-rw-r--r-- | archival/libunarchive/decompress_bunzip2.c | 22 | ||||
-rw-r--r-- | archival/libunarchive/decompress_uncompress.c | 18 | ||||
-rw-r--r-- | archival/libunarchive/decompress_unlzma.c | 16 | ||||
-rw-r--r-- | archival/libunarchive/decompress_unzip.c | 15 | ||||
-rw-r--r-- | archival/libunarchive/get_header_tar_gz.c | 2 | ||||
-rw-r--r-- | archival/libunarchive/open_transformer.c | 6 | ||||
-rw-r--r-- | archival/rpm2cpio.c | 8 | ||||
-rw-r--r-- | archival/unlzma.c | 12 | ||||
-rw-r--r-- | coreutils/od.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | include/unarchive.h | 11 |
15 files changed, 122 insertions, 72 deletions
@@ -29,6 +29,14 @@ config CONFIG_NITPICK | |||
29 | 29 | ||
30 | You have been warned. | 30 | You have been warned. |
31 | 31 | ||
32 | config CONFIG_DESKTOP | ||
33 | bool "Enable options for full-blown desktop systems." | ||
34 | default n | ||
35 | help | ||
36 | Enable options and features which are not essential. | ||
37 | Select this only if you plan to use busybox on full-blown | ||
38 | desktop machine with common Linux distro, not on an ebmbedded box. | ||
39 | |||
32 | choice | 40 | choice |
33 | prompt "Buffer allocation policy" | 41 | prompt "Buffer allocation policy" |
34 | default CONFIG_FEATURE_BUFFERS_USE_MALLOC | 42 | default CONFIG_FEATURE_BUFFERS_USE_MALLOC |
diff --git a/archival/bunzip2.c b/archival/bunzip2.c index 62f28582c..9d62366c3 100644 --- a/archival/bunzip2.c +++ b/archival/bunzip2.c | |||
@@ -14,9 +14,10 @@ | |||
14 | 14 | ||
15 | int bunzip2_main(int argc, char **argv) | 15 | int bunzip2_main(int argc, char **argv) |
16 | { | 16 | { |
17 | USE_DESKTOP(long long) int status; | ||
17 | char *filename; | 18 | char *filename; |
18 | unsigned long opt; | 19 | unsigned long opt; |
19 | int status, src_fd, dst_fd; | 20 | int src_fd, dst_fd; |
20 | 21 | ||
21 | opt = bb_getopt_ulflags(argc, argv, "cf"); | 22 | opt = bb_getopt_ulflags(argc, argv, "cf"); |
22 | 23 | ||
@@ -55,7 +56,7 @@ int bunzip2_main(int argc, char **argv) | |||
55 | } else dst_fd = STDOUT_FILENO; | 56 | } else dst_fd = STDOUT_FILENO; |
56 | status = uncompressStream(src_fd, dst_fd); | 57 | status = uncompressStream(src_fd, dst_fd); |
57 | if (filename) { | 58 | if (filename) { |
58 | if (!status) filename[strlen(filename)] = '.'; | 59 | if (status >= 0) filename[strlen(filename)] = '.'; |
59 | if (unlink(filename) < 0) { | 60 | if (unlink(filename) < 0) { |
60 | bb_error_msg_and_die("cannot remove %s", filename); | 61 | bb_error_msg_and_die("cannot remove %s", filename); |
61 | } | 62 | } |
diff --git a/archival/gunzip.c b/archival/gunzip.c index 9a68e62e4..1b4968628 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -34,13 +34,15 @@ | |||
34 | #define GUNZIP_OPT_FORCE 2 | 34 | #define GUNZIP_OPT_FORCE 2 |
35 | #define GUNZIP_OPT_TEST 4 | 35 | #define GUNZIP_OPT_TEST 4 |
36 | #define GUNZIP_OPT_DECOMPRESS 8 | 36 | #define GUNZIP_OPT_DECOMPRESS 8 |
37 | #define GUNZIP_OPT_VERBOSE 0x10 | ||
37 | 38 | ||
38 | int gunzip_main(int argc, char **argv) | 39 | int gunzip_main(int argc, char **argv) |
39 | { | 40 | { |
40 | char status = EXIT_SUCCESS; | 41 | USE_DESKTOP(long long) int status; |
42 | int exitcode = 0; | ||
41 | unsigned long opt; | 43 | unsigned long opt; |
42 | 44 | ||
43 | opt = bb_getopt_ulflags(argc, argv, "cftd"); | 45 | opt = bb_getopt_ulflags(argc, argv, "cftdv"); |
44 | /* if called as zcat */ | 46 | /* if called as zcat */ |
45 | if (strcmp(bb_applet_name, "zcat") == 0) { | 47 | if (strcmp(bb_applet_name, "zcat") == 0) { |
46 | opt |= GUNZIP_OPT_STDOUT; | 48 | opt |= GUNZIP_OPT_STDOUT; |
@@ -59,6 +61,8 @@ int gunzip_main(int argc, char **argv) | |||
59 | if (old_path == NULL || strcmp(old_path, "-") == 0) { | 61 | if (old_path == NULL || strcmp(old_path, "-") == 0) { |
60 | src_fd = STDIN_FILENO; | 62 | src_fd = STDIN_FILENO; |
61 | opt |= GUNZIP_OPT_STDOUT; | 63 | opt |= GUNZIP_OPT_STDOUT; |
64 | USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;) | ||
65 | optind = argc; /* we don't handle "gunzip - a.gz b.gz" */ | ||
62 | } else { | 66 | } else { |
63 | src_fd = xopen(old_path, O_RDONLY); | 67 | src_fd = xopen(old_path, O_RDONLY); |
64 | 68 | ||
@@ -67,9 +71,9 @@ int gunzip_main(int argc, char **argv) | |||
67 | } | 71 | } |
68 | 72 | ||
69 | /* Check that the input is sane. */ | 73 | /* Check that the input is sane. */ |
70 | if (isatty(src_fd) && ((opt & GUNZIP_OPT_FORCE) == 0)) { | 74 | if (isatty(src_fd) && !(opt & GUNZIP_OPT_FORCE)) { |
71 | bb_error_msg_and_die | 75 | bb_error_msg_and_die |
72 | ("compressed data not read from terminal. Use -f to force it."); | 76 | ("compressed data not read from terminal, use -f to force it"); |
73 | } | 77 | } |
74 | 78 | ||
75 | /* Set output filename and number */ | 79 | /* Set output filename and number */ |
@@ -94,7 +98,8 @@ int gunzip_main(int argc, char **argv) | |||
94 | extension[2] = 'a'; | 98 | extension[2] = 'a'; |
95 | extension[3] = 'r'; | 99 | extension[3] = 'r'; |
96 | } else { | 100 | } else { |
97 | bb_error_msg_and_die("Invalid extension"); | 101 | // FIXME: should we die or just skip to next? |
102 | bb_error_msg_and_die("invalid extension"); | ||
98 | } | 103 | } |
99 | 104 | ||
100 | /* Open output file (with correct permissions) */ | 105 | /* Open output file (with correct permissions) */ |
@@ -105,30 +110,34 @@ int gunzip_main(int argc, char **argv) | |||
105 | delete_path = old_path; | 110 | delete_path = old_path; |
106 | } | 111 | } |
107 | 112 | ||
113 | status = -1; | ||
108 | /* do the decompression, and cleanup */ | 114 | /* do the decompression, and cleanup */ |
109 | if (xread_char(src_fd) == 0x1f) { | 115 | if (xread_char(src_fd) == 0x1f) { |
110 | unsigned char magic2; | 116 | unsigned char magic2; |
111 | 117 | ||
112 | magic2 = xread_char(src_fd); | 118 | magic2 = xread_char(src_fd); |
113 | #ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS | 119 | if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) { |
114 | if (magic2 == 0x9d) { | ||
115 | status = uncompress(src_fd, dst_fd); | 120 | status = uncompress(src_fd, dst_fd); |
116 | } else | 121 | } else if (magic2 == 0x8b) { |
117 | #endif | 122 | check_header_gzip(src_fd); // FIXME: xfunc? _or_die? |
118 | if (magic2 == 0x8b) { | 123 | status = inflate_gunzip(src_fd, dst_fd); |
119 | check_header_gzip(src_fd); | 124 | } else { |
120 | status = inflate_gunzip(src_fd, dst_fd); | 125 | bb_error_msg("invalid magic"); |
121 | if (status != 0) { | 126 | exitcode = 1; |
122 | bb_error_msg_and_die("error inflating"); | 127 | } |
123 | } | 128 | if (status < 0) { |
124 | } else { | 129 | bb_error_msg("error inflating"); |
125 | bb_error_msg_and_die("invalid magic"); | 130 | exitcode = 1; |
126 | } | 131 | } |
132 | else if (ENABLE_DESKTOP && (opt & GUNZIP_OPT_VERBOSE)) { | ||
133 | fprintf(stderr, "%s: %u%% - replaced with %s\n", | ||
134 | // TODO: LARGEFILE support for stat_buf.st_size? | ||
135 | old_path, (unsigned)(stat_buf.st_size*100 / (status+1)), new_path); | ||
136 | } | ||
127 | } else { | 137 | } else { |
128 | bb_error_msg_and_die("invalid magic"); | 138 | bb_error_msg("invalid magic"); exitcode = 1; |
129 | } | 139 | } |
130 | 140 | if (status < 0 && new_path) { | |
131 | if ((status != EXIT_SUCCESS) && (new_path)) { | ||
132 | /* Unzip failed, remove new path instead of old path */ | 141 | /* Unzip failed, remove new path instead of old path */ |
133 | delete_path = new_path; | 142 | delete_path = new_path; |
134 | } | 143 | } |
@@ -142,12 +151,13 @@ int gunzip_main(int argc, char **argv) | |||
142 | 151 | ||
143 | /* delete_path will be NULL if in test mode or from stdin */ | 152 | /* delete_path will be NULL if in test mode or from stdin */ |
144 | if (delete_path && (unlink(delete_path) == -1)) { | 153 | if (delete_path && (unlink(delete_path) == -1)) { |
145 | bb_error_msg_and_die("cannot remove %s", delete_path); | 154 | bb_error_msg("cannot remove %s", delete_path); |
155 | exitcode = 1; | ||
146 | } | 156 | } |
147 | 157 | ||
148 | free(new_path); | 158 | free(new_path); |
149 | 159 | ||
150 | } while (optind < argc); | 160 | } while (optind < argc); |
151 | 161 | ||
152 | return status; | 162 | return exitcode; |
153 | } | 163 | } |
diff --git a/archival/gzip.c b/archival/gzip.c index 05f6cb582..bb58158f4 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 16 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | // TODO: full support for -v for DESKTOP | ||
20 | |||
19 | #define SMALL_MEM | 21 | #define SMALL_MEM |
20 | 22 | ||
21 | #include <stdlib.h> | 23 | #include <stdlib.h> |
@@ -1134,7 +1136,7 @@ int gzip_main(int argc, char **argv) | |||
1134 | struct stat statBuf; | 1136 | struct stat statBuf; |
1135 | char *delFileName; | 1137 | char *delFileName; |
1136 | 1138 | ||
1137 | opt = bb_getopt_ulflags(argc, argv, "cf123456789q" USE_GUNZIP("d")); | 1139 | opt = bb_getopt_ulflags(argc, argv, "cf123456789qv" USE_GUNZIP("d")); |
1138 | //if (opt & 0x1) // -c | 1140 | //if (opt & 0x1) // -c |
1139 | //if (opt & 0x2) // -f | 1141 | //if (opt & 0x2) // -f |
1140 | /* Ignore 1-9 (compression level) options */ | 1142 | /* Ignore 1-9 (compression level) options */ |
@@ -1148,7 +1150,8 @@ int gzip_main(int argc, char **argv) | |||
1148 | //if (opt & 0x200) // -8 | 1150 | //if (opt & 0x200) // -8 |
1149 | //if (opt & 0x400) // -9 | 1151 | //if (opt & 0x400) // -9 |
1150 | //if (opt & 0x800) // -q | 1152 | //if (opt & 0x800) // -q |
1151 | if (ENABLE_GUNZIP && (opt & 0x1000)) { // -d | 1153 | //if (opt & 0x1000) // -v |
1154 | if (ENABLE_GUNZIP && (opt & 0x2000)) { // -d | ||
1152 | /* FIXME: bb_getopt_ulflags should not depend on optind */ | 1155 | /* FIXME: bb_getopt_ulflags should not depend on optind */ |
1153 | optind = 1; | 1156 | optind = 1; |
1154 | return gunzip_main(argc, argv); | 1157 | return gunzip_main(argc, argv); |
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c index 657d4ab01..d0a4ecb5e 100644 --- a/archival/libunarchive/decompress_bunzip2.c +++ b/archival/libunarchive/decompress_bunzip2.c | |||
@@ -671,20 +671,24 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf, | |||
671 | /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data, | 671 | /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data, |
672 | not end of file.) */ | 672 | not end of file.) */ |
673 | 673 | ||
674 | int uncompressStream(int src_fd, int dst_fd) | 674 | USE_DESKTOP(long long) int |
675 | uncompressStream(int src_fd, int dst_fd) | ||
675 | { | 676 | { |
677 | USE_DESKTOP(long long total_written = 0;) | ||
676 | char *outbuf; | 678 | char *outbuf; |
677 | bunzip_data *bd; | 679 | bunzip_data *bd; |
678 | int i; | 680 | int i; |
679 | 681 | ||
680 | outbuf=xmalloc(IOBUF_SIZE); | 682 | outbuf=xmalloc(IOBUF_SIZE); |
681 | if(!(i=start_bunzip(&bd,src_fd,0,0))) { | 683 | i=start_bunzip(&bd,src_fd,0,0); |
684 | if(!i) { | ||
682 | for(;;) { | 685 | for(;;) { |
683 | if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break; | 686 | if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break; |
684 | if(i!=write(dst_fd,outbuf,i)) { | 687 | if(i!=write(dst_fd,outbuf,i)) { |
685 | i=RETVAL_UNEXPECTED_OUTPUT_EOF; | 688 | i=RETVAL_UNEXPECTED_OUTPUT_EOF; |
686 | break; | 689 | break; |
687 | } | 690 | } |
691 | USE_DESKTOP(total_written += i;) | ||
688 | } | 692 | } |
689 | } | 693 | } |
690 | 694 | ||
@@ -692,27 +696,27 @@ int uncompressStream(int src_fd, int dst_fd) | |||
692 | 696 | ||
693 | if(i==RETVAL_LAST_BLOCK) { | 697 | if(i==RETVAL_LAST_BLOCK) { |
694 | if (bd->headerCRC!=bd->totalCRC) { | 698 | if (bd->headerCRC!=bd->totalCRC) { |
695 | bb_error_msg("Data integrity error when decompressing."); | 699 | bb_error_msg("data integrity error when decompressing"); |
696 | } else { | 700 | } else { |
697 | i=RETVAL_OK; | 701 | i=RETVAL_OK; |
698 | } | 702 | } |
699 | } else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) { | 703 | } else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) { |
700 | bb_error_msg("Compressed file ends unexpectedly"); | 704 | bb_error_msg("compressed file ends unexpectedly"); |
701 | } else { | 705 | } else { |
702 | bb_error_msg("Decompression failed"); | 706 | bb_error_msg("decompression failed"); |
703 | } | 707 | } |
704 | free(bd->dbuf); | 708 | free(bd->dbuf); |
705 | free(bd); | 709 | free(bd); |
706 | free(outbuf); | 710 | free(outbuf); |
707 | 711 | ||
708 | return i; | 712 | return i ? i : USE_DESKTOP(total_written) + 0; |
709 | } | 713 | } |
710 | 714 | ||
711 | #ifdef TESTING | 715 | #ifdef TESTING |
712 | 716 | ||
713 | static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data", | 717 | static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data", |
714 | "Unexpected input EOF","Unexpected output EOF","Data error", | 718 | "Unexpected input EOF","Unexpected output EOF","Data error", |
715 | "Out of memory","Obsolete (pre 0.9.5) bzip format not supported."}; | 719 | "Out of memory","Obsolete (pre 0.9.5) bzip format not supported."}; |
716 | 720 | ||
717 | /* Dumb little test thing, decompress stdin to stdout */ | 721 | /* Dumb little test thing, decompress stdin to stdout */ |
718 | int main(int argc, char *argv[]) | 722 | int main(int argc, char *argv[]) |
@@ -720,8 +724,8 @@ int main(int argc, char *argv[]) | |||
720 | int i=uncompressStream(0,1); | 724 | int i=uncompressStream(0,1); |
721 | char c; | 725 | char c; |
722 | 726 | ||
723 | if(i) fprintf(stderr,"%s\n", bunzip_errors[-i]); | 727 | if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]); |
724 | else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n"); | 728 | else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n"); |
725 | return -i; | 729 | return -i; |
726 | } | 730 | } |
727 | #endif | 731 | #endif |
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c index e2941438c..ff98254ff 100644 --- a/archival/libunarchive/decompress_uncompress.c +++ b/archival/libunarchive/decompress_uncompress.c | |||
@@ -86,8 +86,10 @@ static int maxbits = BITS; | |||
86 | * with those of the compress() routine. See the definitions above. | 86 | * with those of the compress() routine. See the definitions above. |
87 | */ | 87 | */ |
88 | 88 | ||
89 | int uncompress(int fd_in, int fd_out) | 89 | USE_DESKTOP(long long) int |
90 | uncompress(int fd_in, int fd_out) | ||
90 | { | 91 | { |
92 | USE_DESKTOP(long long total_written = 0;) | ||
91 | unsigned char *stackp; | 93 | unsigned char *stackp; |
92 | long int code; | 94 | long int code; |
93 | int finchar; | 95 | int finchar; |
@@ -182,16 +184,16 @@ int uncompress(int fd_in, int fd_out) | |||
182 | { | 184 | { |
183 | unsigned char *p = &inbuf[posbits >> 3]; | 185 | unsigned char *p = &inbuf[posbits >> 3]; |
184 | 186 | ||
185 | code = | 187 | code = ((((long) (p[0])) | ((long) (p[1]) << 8) | |
186 | ((((long) (p[0])) | ((long) (p[1]) << 8) | | 188 | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; |
187 | ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask; | ||
188 | } | 189 | } |
189 | posbits += n_bits; | 190 | posbits += n_bits; |
190 | 191 | ||
191 | 192 | ||
192 | if (oldcode == -1) { | 193 | if (oldcode == -1) { |
193 | outbuf[outpos++] = (unsigned char) (finchar = | 194 | oldcode = code; |
194 | (int) (oldcode = code)); | 195 | finchar = (int) oldcode; |
196 | outbuf[outpos++] = (unsigned char) finchar; | ||
195 | continue; | 197 | continue; |
196 | } | 198 | } |
197 | 199 | ||
@@ -255,6 +257,7 @@ int uncompress(int fd_in, int fd_out) | |||
255 | 257 | ||
256 | if (outpos >= OBUFSIZ) { | 258 | if (outpos >= OBUFSIZ) { |
257 | write(fd_out, outbuf, outpos); | 259 | write(fd_out, outbuf, outpos); |
260 | USE_DESKTOP(total_written += outpos;) | ||
258 | outpos = 0; | 261 | outpos = 0; |
259 | } | 262 | } |
260 | stackp += i; | 263 | stackp += i; |
@@ -280,9 +283,10 @@ int uncompress(int fd_in, int fd_out) | |||
280 | 283 | ||
281 | if (outpos > 0) { | 284 | if (outpos > 0) { |
282 | write(fd_out, outbuf, outpos); | 285 | write(fd_out, outbuf, outpos); |
286 | USE_DESKTOP(total_written += outpos;) | ||
283 | } | 287 | } |
284 | 288 | ||
285 | RELEASE_CONFIG_BUFFER(inbuf); | 289 | RELEASE_CONFIG_BUFFER(inbuf); |
286 | RELEASE_CONFIG_BUFFER(outbuf); | 290 | RELEASE_CONFIG_BUFFER(outbuf); |
287 | return 0; | 291 | return USE_DESKTOP(total_written) + 0; |
288 | } | 292 | } |
diff --git a/archival/libunarchive/decompress_unlzma.c b/archival/libunarchive/decompress_unlzma.c index 0fb1249cb..a6902807b 100644 --- a/archival/libunarchive/decompress_unlzma.c +++ b/archival/libunarchive/decompress_unlzma.c | |||
@@ -211,9 +211,10 @@ typedef struct { | |||
211 | #define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS) | 211 | #define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS) |
212 | #define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS) | 212 | #define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS) |
213 | 213 | ||
214 | 214 | USE_DESKTOP(long long) int | |
215 | int unlzma(int src_fd, int dst_fd) | 215 | unlzma(int src_fd, int dst_fd) |
216 | { | 216 | { |
217 | USE_DESKTOP(long long total_written = 0;) | ||
217 | lzma_header_t header; | 218 | lzma_header_t header; |
218 | int lc, pb, lp; | 219 | int lc, pb, lp; |
219 | uint32_t pos_state_mask; | 220 | uint32_t pos_state_mask; |
@@ -305,7 +306,9 @@ int unlzma(int src_fd, int dst_fd) | |||
305 | if (buffer_pos == header.dict_size) { | 306 | if (buffer_pos == header.dict_size) { |
306 | buffer_pos = 0; | 307 | buffer_pos = 0; |
307 | global_pos += header.dict_size; | 308 | global_pos += header.dict_size; |
309 | // FIXME: error check | ||
308 | write(dst_fd, buffer, header.dict_size); | 310 | write(dst_fd, buffer, header.dict_size); |
311 | USE_DESKTOP(total_written += header.dict_size;) | ||
309 | } | 312 | } |
310 | if (state < 4) | 313 | if (state < 4) |
311 | state = 0; | 314 | state = 0; |
@@ -345,7 +348,9 @@ int unlzma(int src_fd, int dst_fd) | |||
345 | if (buffer_pos == header.dict_size) { | 348 | if (buffer_pos == header.dict_size) { |
346 | buffer_pos = 0; | 349 | buffer_pos = 0; |
347 | global_pos += header.dict_size; | 350 | global_pos += header.dict_size; |
351 | // FIXME: error check | ||
348 | write(dst_fd, buffer, header.dict_size); | 352 | write(dst_fd, buffer, header.dict_size); |
353 | USE_DESKTOP(total_written += header.dict_size;) | ||
349 | } | 354 | } |
350 | continue; | 355 | continue; |
351 | } else { | 356 | } else { |
@@ -456,15 +461,18 @@ int unlzma(int src_fd, int dst_fd) | |||
456 | if (buffer_pos == header.dict_size) { | 461 | if (buffer_pos == header.dict_size) { |
457 | buffer_pos = 0; | 462 | buffer_pos = 0; |
458 | global_pos += header.dict_size; | 463 | global_pos += header.dict_size; |
464 | // FIXME: error check | ||
459 | write(dst_fd, buffer, header.dict_size); | 465 | write(dst_fd, buffer, header.dict_size); |
466 | USE_DESKTOP(total_written += header.dict_size;) | ||
460 | } | 467 | } |
461 | len--; | 468 | len--; |
462 | } while (len != 0 && buffer_pos < header.dst_size); | 469 | } while (len != 0 && buffer_pos < header.dst_size); |
463 | } | 470 | } |
464 | } | 471 | } |
465 | 472 | ||
473 | // FIXME: error check | ||
466 | write(dst_fd, buffer, buffer_pos); | 474 | write(dst_fd, buffer, buffer_pos); |
475 | USE_DESKTOP(total_written += buffer_pos;) | ||
467 | rc_free(&rc); | 476 | rc_free(&rc); |
468 | return 0; | 477 | return USE_DESKTOP(total_written) + 0; |
469 | } | 478 | } |
470 | |||
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c index 989ac4fd8..27b4ddbcf 100644 --- a/archival/libunarchive/decompress_unzip.c +++ b/archival/libunarchive/decompress_unzip.c | |||
@@ -835,8 +835,10 @@ void inflate_cleanup(void) | |||
835 | free(bytebuffer); | 835 | free(bytebuffer); |
836 | } | 836 | } |
837 | 837 | ||
838 | int inflate_unzip(int in, int out) | 838 | USE_DESKTOP(long long) int |
839 | inflate_unzip(int in, int out) | ||
839 | { | 840 | { |
841 | USE_DESKTOP(long long total = 0;) | ||
840 | ssize_t nwrote; | 842 | ssize_t nwrote; |
841 | typedef void (*sig_type) (int); | 843 | typedef void (*sig_type) (int); |
842 | 844 | ||
@@ -864,6 +866,7 @@ int inflate_unzip(int in, int out) | |||
864 | bb_perror_msg("write"); | 866 | bb_perror_msg("write"); |
865 | return -1; | 867 | return -1; |
866 | } | 868 | } |
869 | USE_DESKTOP(total += nwrote;) | ||
867 | if (ret == 0) break; | 870 | if (ret == 0) break; |
868 | } | 871 | } |
869 | 872 | ||
@@ -880,15 +883,17 @@ int inflate_unzip(int in, int out) | |||
880 | gunzip_bb >>= 8; | 883 | gunzip_bb >>= 8; |
881 | gunzip_bk -= 8; | 884 | gunzip_bk -= 8; |
882 | } | 885 | } |
883 | return 0; | 886 | return USE_DESKTOP(total) + 0; |
884 | } | 887 | } |
885 | 888 | ||
886 | int inflate_gunzip(int in, int out) | 889 | USE_DESKTOP(long long) int |
890 | inflate_gunzip(int in, int out) | ||
887 | { | 891 | { |
888 | uint32_t stored_crc = 0; | 892 | uint32_t stored_crc = 0; |
889 | unsigned int count; | 893 | unsigned int count; |
894 | USE_DESKTOP(long long total = )inflate_unzip(in, out); | ||
890 | 895 | ||
891 | inflate_unzip(in, out); | 896 | USE_DESKTOP(if (total < 0) return total;) |
892 | 897 | ||
893 | /* top up the input buffer with the rest of the trailer */ | 898 | /* top up the input buffer with the rest of the trailer */ |
894 | count = bytebuffer_size - bytebuffer_offset; | 899 | count = bytebuffer_size - bytebuffer_offset; |
@@ -915,5 +920,5 @@ int inflate_gunzip(int in, int out) | |||
915 | return -1; | 920 | return -1; |
916 | } | 921 | } |
917 | 922 | ||
918 | return 0; | 923 | return USE_DESKTOP(total) + 0; |
919 | } | 924 | } |
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c index ad26f465a..24e4f9c9f 100644 --- a/archival/libunarchive/get_header_tar_gz.c +++ b/archival/libunarchive/get_header_tar_gz.c | |||
@@ -17,7 +17,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle) | |||
17 | 17 | ||
18 | xread(archive_handle->src_fd, &magic, 2); | 18 | xread(archive_handle->src_fd, &magic, 2); |
19 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 19 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
20 | bb_error_msg_and_die("Invalid gzip magic"); | 20 | bb_error_msg_and_die("invalid gzip magic"); |
21 | } | 21 | } |
22 | 22 | ||
23 | check_header_gzip(archive_handle->src_fd); | 23 | check_header_gzip(archive_handle->src_fd); |
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c index 578b92963..99e71ec2e 100644 --- a/archival/libunarchive/open_transformer.c +++ b/archival/libunarchive/open_transformer.c | |||
@@ -11,7 +11,8 @@ | |||
11 | #include "unarchive.h" | 11 | #include "unarchive.h" |
12 | 12 | ||
13 | /* transformer(), more than meets the eye */ | 13 | /* transformer(), more than meets the eye */ |
14 | int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)) | 14 | int open_transformer(int src_fd, |
15 | USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)) | ||
15 | { | 16 | { |
16 | int fd_pipe[2]; | 17 | int fd_pipe[2]; |
17 | int pid; | 18 | int pid; |
@@ -28,6 +29,7 @@ int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)) | |||
28 | if (pid == 0) { | 29 | if (pid == 0) { |
29 | /* child process */ | 30 | /* child process */ |
30 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ | 31 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ |
32 | // FIXME: error check? | ||
31 | transformer(src_fd, fd_pipe[1]); | 33 | transformer(src_fd, fd_pipe[1]); |
32 | close(fd_pipe[1]); /* Send EOF */ | 34 | close(fd_pipe[1]); /* Send EOF */ |
33 | close(src_fd); | 35 | close(src_fd); |
@@ -38,5 +40,5 @@ int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)) | |||
38 | /* parent process */ | 40 | /* parent process */ |
39 | close(fd_pipe[1]); /* Don't want to write to the child */ | 41 | close(fd_pipe[1]); /* Don't want to write to the child */ |
40 | 42 | ||
41 | return(fd_pipe[0]); | 43 | return fd_pipe[0]; |
42 | } | 44 | } |
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c index 3ae8458dd..c00c6be65 100644 --- a/archival/rpm2cpio.c +++ b/archival/rpm2cpio.c | |||
@@ -63,7 +63,7 @@ int rpm2cpio_main(int argc, char **argv) | |||
63 | 63 | ||
64 | xread(rpm_fd, &lead, sizeof(struct rpm_lead)); | 64 | xread(rpm_fd, &lead, sizeof(struct rpm_lead)); |
65 | if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { | 65 | if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { |
66 | bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ | 66 | bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ |
67 | } | 67 | } |
68 | 68 | ||
69 | /* Skip the signature header */ | 69 | /* Skip the signature header */ |
@@ -75,12 +75,12 @@ int rpm2cpio_main(int argc, char **argv) | |||
75 | 75 | ||
76 | xread(rpm_fd, &magic, 2); | 76 | xread(rpm_fd, &magic, 2); |
77 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { | 77 | if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { |
78 | bb_error_msg_and_die("Invalid gzip magic"); | 78 | bb_error_msg_and_die("invalid gzip magic"); |
79 | } | 79 | } |
80 | 80 | ||
81 | check_header_gzip(rpm_fd); | 81 | check_header_gzip(rpm_fd); |
82 | if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) { | 82 | if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) { |
83 | bb_error_msg("Error inflating"); | 83 | bb_error_msg("error inflating"); |
84 | } | 84 | } |
85 | 85 | ||
86 | close(rpm_fd); | 86 | close(rpm_fd); |
diff --git a/archival/unlzma.c b/archival/unlzma.c index fe542b6ac..b87a3fe79 100644 --- a/archival/unlzma.c +++ b/archival/unlzma.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * Licensed under GPL v2, see file LICENSE in this tarball for details. | 8 | * Licensed under GPL v2, see file LICENSE in this tarball for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | /* Why our g[un]zip/bunzip2 are so ugly compared to this beauty? */ | ||
12 | |||
11 | #include "busybox.h" | 13 | #include "busybox.h" |
12 | #include "unarchive.h" | 14 | #include "unarchive.h" |
13 | 15 | ||
@@ -15,15 +17,16 @@ | |||
15 | 17 | ||
16 | int unlzma_main(int argc, char **argv) | 18 | int unlzma_main(int argc, char **argv) |
17 | { | 19 | { |
20 | USE_DESKTOP(long long) int status; | ||
18 | char *filename; | 21 | char *filename; |
19 | unsigned long opt; | 22 | unsigned long opt; |
20 | int status, src_fd, dst_fd; | 23 | int src_fd, dst_fd; |
21 | 24 | ||
22 | opt = bb_getopt_ulflags(argc, argv, "c"); | 25 | opt = bb_getopt_ulflags(argc, argv, "c"); |
23 | 26 | ||
24 | /* Set input filename and number */ | 27 | /* Set input filename and number */ |
25 | filename = argv[optind]; | 28 | filename = argv[optind]; |
26 | if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) { | 29 | if (filename && (filename[0] != '-') && (filename[1] != '\0')) { |
27 | /* Open input file */ | 30 | /* Open input file */ |
28 | src_fd = xopen(filename, O_RDONLY); | 31 | src_fd = xopen(filename, O_RDONLY); |
29 | } else { | 32 | } else { |
@@ -50,13 +53,12 @@ int unlzma_main(int argc, char **argv) | |||
50 | dst_fd = STDOUT_FILENO; | 53 | dst_fd = STDOUT_FILENO; |
51 | status = unlzma(src_fd, dst_fd); | 54 | status = unlzma(src_fd, dst_fd); |
52 | if (filename) { | 55 | if (filename) { |
53 | if (!status) | 56 | if (status >= 0) /* if success delete src, else delete dst */ |
54 | filename[strlen(filename)] = '.'; | 57 | filename[strlen(filename)] = '.'; |
55 | if (unlink(filename) < 0) { | 58 | if (unlink(filename) < 0) { |
56 | bb_error_msg_and_die("cannot remove %s", filename); | 59 | bb_error_msg_and_die("cannot remove %s", filename); |
57 | } | 60 | } |
58 | } | 61 | } |
59 | 62 | ||
60 | return status; | 63 | return (status < 0); |
61 | } | 64 | } |
62 | |||
diff --git a/coreutils/od.c b/coreutils/od.c index 1149ef148..df06dd3ec 100644 --- a/coreutils/od.c +++ b/coreutils/od.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * Original copyright notice is retained at the end of this file. | 11 | * Original copyright notice is retained at the end of this file. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | // TODO: -t. busybox's own build script needs it | ||
15 | |||
14 | #include <ctype.h> | 16 | #include <ctype.h> |
15 | #include <string.h> | 17 | #include <string.h> |
16 | #include <getopt.h> | 18 | #include <getopt.h> |
diff --git a/include/libbb.h b/include/libbb.h index 67cf4939c..b4516e99a 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -339,7 +339,7 @@ char *last_char_is(const char *s, int c); | |||
339 | 339 | ||
340 | char *fgets_str(FILE *file, const char *terminating_string); | 340 | char *fgets_str(FILE *file, const char *terminating_string); |
341 | 341 | ||
342 | extern int uncompress(int fd_in, int fd_out); | 342 | extern USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); |
343 | extern int inflate(int in, int out); | 343 | extern int inflate(int in, int out); |
344 | 344 | ||
345 | extern struct hostent *xgethostbyname(const char *name); | 345 | extern struct hostent *xgethostbyname(const char *name); |
@@ -353,9 +353,9 @@ extern void bb_lookup_host(struct sockaddr_in *s_in, const char *host); | |||
353 | // This is declared here rather than #including <libgen.h> in order to avoid | 353 | // This is declared here rather than #including <libgen.h> in order to avoid |
354 | // confusing the two versions of basename. See the dirname/basename man page | 354 | // confusing the two versions of basename. See the dirname/basename man page |
355 | // for details. | 355 | // for details. |
356 | char *dirname (char *path); | 356 | char *dirname(char *path); |
357 | 357 | ||
358 | int bb_make_directory (char *path, long mode, int flags); | 358 | int bb_make_directory(char *path, long mode, int flags); |
359 | 359 | ||
360 | int get_signum(const char *name); | 360 | int get_signum(const char *name); |
361 | const char *get_signame(int number); | 361 | const char *get_signame(int number); |
diff --git a/include/unarchive.h b/include/unarchive.h index 653cff80f..82a70aed6 100644 --- a/include/unarchive.h +++ b/include/unarchive.h | |||
@@ -100,14 +100,15 @@ extern void data_align(archive_handle_t *archive_handle, const unsigned short bo | |||
100 | extern const llist_t *find_list_entry(const llist_t *list, const char *filename); | 100 | extern const llist_t *find_list_entry(const llist_t *list, const char *filename); |
101 | extern const llist_t *find_list_entry2(const llist_t *list, const char *filename); | 101 | extern const llist_t *find_list_entry2(const llist_t *list, const char *filename); |
102 | 102 | ||
103 | extern int uncompressStream(int src_fd, int dst_fd); | 103 | extern USE_DESKTOP(long long) int uncompressStream(int src_fd, int dst_fd); |
104 | extern void inflate_init(unsigned int bufsize); | 104 | extern void inflate_init(unsigned int bufsize); |
105 | extern void inflate_cleanup(void); | 105 | extern void inflate_cleanup(void); |
106 | extern int inflate_unzip(int in, int out); | 106 | extern USE_DESKTOP(long long) int inflate_unzip(int in, int out); |
107 | extern int inflate_gunzip(int in, int out); | 107 | extern USE_DESKTOP(long long) int inflate_gunzip(int in, int out); |
108 | extern int unlzma(int src_fd, int dst_fd); | 108 | extern USE_DESKTOP(long long) int unlzma(int src_fd, int dst_fd); |
109 | 109 | ||
110 | extern int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd)); | 110 | extern int open_transformer(int src_fd, |
111 | USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)); | ||
111 | 112 | ||
112 | 113 | ||
113 | #endif | 114 | #endif |