summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-26 10:42:51 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-26 10:42:51 +0000
commitbf0a201008671f81c107de72c026b1b84967561d (patch)
treeaf74820b70fa27929fe218c95822c20651b60637 /archival
parent5dd7ef0f37373e397a7160cb431a32ae57f9f7d9 (diff)
downloadbusybox-w32-bf0a201008671f81c107de72c026b1b84967561d.tar.gz
busybox-w32-bf0a201008671f81c107de72c026b1b84967561d.tar.bz2
busybox-w32-bf0a201008671f81c107de72c026b1b84967561d.zip
style fixes
last xcalloc replaced by xzalloc
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/check_header_gzip.c4
-rw-r--r--archival/libunarchive/decompress_bunzip2.c68
-rw-r--r--archival/libunarchive/decompress_unzip.c4
-rw-r--r--archival/unzip.c4
4 files changed, 40 insertions, 40 deletions
diff --git a/archival/libunarchive/check_header_gzip.c b/archival/libunarchive/check_header_gzip.c
index 3e42035b9..0cfa94454 100644
--- a/archival/libunarchive/check_header_gzip.c
+++ b/archival/libunarchive/check_header_gzip.c
@@ -43,13 +43,13 @@ void check_header_gzip(int src_fd)
43 /* Discard original name if any */ 43 /* Discard original name if any */
44 if (header.formatted.flags & 0x08) { 44 if (header.formatted.flags & 0x08) {
45 /* bit 3 set: original file name present */ 45 /* bit 3 set: original file name present */
46 while(xread_char(src_fd) != 0); 46 while (xread_char(src_fd) != 0);
47 } 47 }
48 48
49 /* Discard file comment if any */ 49 /* Discard file comment if any */
50 if (header.formatted.flags & 0x10) { 50 if (header.formatted.flags & 0x10) {
51 /* bit 4 set: file comment present */ 51 /* bit 4 set: file comment present */
52 while(xread_char(src_fd) != 0); 52 while (xread_char(src_fd) != 0);
53 } 53 }
54 54
55 /* Read the header checksum */ 55 /* Read the header checksum */
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c
index d0a4ecb5e..ff7d64d83 100644
--- a/archival/libunarchive/decompress_bunzip2.c
+++ b/archival/libunarchive/decompress_bunzip2.c
@@ -32,25 +32,25 @@
32#include "unarchive.h" 32#include "unarchive.h"
33 33
34/* Constants for Huffman coding */ 34/* Constants for Huffman coding */
35#define MAX_GROUPS 6 35#define MAX_GROUPS 6
36#define GROUP_SIZE 50 /* 64 would have been more efficient */ 36#define GROUP_SIZE 50 /* 64 would have been more efficient */
37#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */ 37#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
38#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */ 38#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
39#define SYMBOL_RUNA 0 39#define SYMBOL_RUNA 0
40#define SYMBOL_RUNB 1 40#define SYMBOL_RUNB 1
41 41
42/* Status return values */ 42/* Status return values */
43#define RETVAL_OK 0 43#define RETVAL_OK 0
44#define RETVAL_LAST_BLOCK (-1) 44#define RETVAL_LAST_BLOCK (-1)
45#define RETVAL_NOT_BZIP_DATA (-2) 45#define RETVAL_NOT_BZIP_DATA (-2)
46#define RETVAL_UNEXPECTED_INPUT_EOF (-3) 46#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
47#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4) 47#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
48#define RETVAL_DATA_ERROR (-5) 48#define RETVAL_DATA_ERROR (-5)
49#define RETVAL_OUT_OF_MEMORY (-6) 49#define RETVAL_OUT_OF_MEMORY (-6)
50#define RETVAL_OBSOLETE_INPUT (-7) 50#define RETVAL_OBSOLETE_INPUT (-7)
51 51
52/* Other housekeeping constants */ 52/* Other housekeeping constants */
53#define IOBUF_SIZE 4096 53#define IOBUF_SIZE 4096
54 54
55/* This is what we know about each Huffman coding group */ 55/* This is what we know about each Huffman coding group */
56struct group_data { 56struct group_data {
@@ -151,7 +151,7 @@ static int get_next_block(bunzip_data *bd)
151 /* Reset longjmp I/O error handling */ 151 /* Reset longjmp I/O error handling */
152 152
153 i=setjmp(bd->jmpbuf); 153 i=setjmp(bd->jmpbuf);
154 if(i) return i; 154 if (i) return i;
155 155
156 /* Read in header signature and CRC, then validate signature. 156 /* Read in header signature and CRC, then validate signature.
157 (last block signature means CRC is for whole file, return now) */ 157 (last block signature means CRC is for whole file, return now) */
@@ -166,8 +166,8 @@ static int get_next_block(bunzip_data *bd)
166 some code for this in busybox 1.0.0-pre3, but nobody ever noticed that 166 some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
167 it didn't actually work. */ 167 it didn't actually work. */
168 168
169 if(get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT; 169 if (get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
170 if((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR; 170 if ((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
171 171
172 /* mapping table: if some byte values are never used (encoding things 172 /* mapping table: if some byte values are never used (encoding things
173 like ascii text), the compression code removes the gaps to have fewer 173 like ascii text), the compression code removes the gaps to have fewer
@@ -180,7 +180,7 @@ static int get_next_block(bunzip_data *bd)
180 for (i=0;i<16;i++) { 180 for (i=0;i<16;i++) {
181 if(t&(1<<(15-i))) { 181 if(t&(1<<(15-i))) {
182 k=get_bits(bd,16); 182 k=get_bits(bd,16);
183 for(j=0;j<16;j++) 183 for (j=0;j<16;j++)
184 if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j; 184 if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
185 } 185 }
186 } 186 }
@@ -196,17 +196,17 @@ static int get_next_block(bunzip_data *bd)
196 start of the list.) */ 196 start of the list.) */
197 197
198 if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR; 198 if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
199 for(i=0; i<groupCount; i++) mtfSymbol[i] = i; 199 for (i=0; i<groupCount; i++) mtfSymbol[i] = i;
200 for(i=0; i<nSelectors; i++) { 200 for (i=0; i<nSelectors; i++) {
201 201
202 /* Get next value */ 202 /* Get next value */
203 203
204 for(j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR; 204 for (j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
205 205
206 /* Decode MTF to get the next selector */ 206 /* Decode MTF to get the next selector */
207 207
208 uc = mtfSymbol[j]; 208 uc = mtfSymbol[j];
209 for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1]; 209 for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
210 mtfSymbol[0]=selectors[i]=uc; 210 mtfSymbol[0]=selectors[i]=uc;
211 } 211 }
212 212
@@ -227,7 +227,7 @@ static int get_next_block(bunzip_data *bd)
227 227
228 t=get_bits(bd, 5)-1; 228 t=get_bits(bd, 5)-1;
229 for (i = 0; i < symCount; i++) { 229 for (i = 0; i < symCount; i++) {
230 for(;;) { 230 for (;;) {
231 if (((unsigned)t) > (MAX_HUFCODE_BITS-1)) 231 if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
232 return RETVAL_DATA_ERROR; 232 return RETVAL_DATA_ERROR;
233 233
@@ -254,7 +254,7 @@ static int get_next_block(bunzip_data *bd)
254 /* Find largest and smallest lengths in this group */ 254 /* Find largest and smallest lengths in this group */
255 255
256 minLen=maxLen=length[0]; 256 minLen=maxLen=length[0];
257 for(i = 1; i < symCount; i++) { 257 for (i = 1; i < symCount; i++) {
258 if(length[i] > maxLen) maxLen = length[i]; 258 if(length[i] > maxLen) maxLen = length[i];
259 else if(length[i] < minLen) minLen = length[i]; 259 else if(length[i] < minLen) minLen = length[i];
260 } 260 }
@@ -284,9 +284,9 @@ static int get_next_block(bunzip_data *bd)
284 /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */ 284 /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
285 285
286 pp=0; 286 pp=0;
287 for(i=minLen;i<=maxLen;i++) { 287 for (i=minLen;i<=maxLen;i++) {
288 temp[i]=limit[i]=0; 288 temp[i]=limit[i]=0;
289 for(t=0;t<symCount;t++) 289 for (t=0;t<symCount;t++)
290 if(length[t]==i) hufGroup->permute[pp++] = t; 290 if(length[t]==i) hufGroup->permute[pp++] = t;
291 } 291 }
292 292
@@ -325,7 +325,7 @@ static int get_next_block(bunzip_data *bd)
325 325
326 /* Initialize symbol occurrence counters and symbol Move To Front table */ 326 /* Initialize symbol occurrence counters and symbol Move To Front table */
327 327
328 for(i=0;i<256;i++) { 328 for (i=0;i<256;i++) {
329 byteCount[i] = 0; 329 byteCount[i] = 0;
330 mtfSymbol[i]=(unsigned char)i; 330 mtfSymbol[i]=(unsigned char)i;
331 } 331 }
@@ -333,7 +333,7 @@ static int get_next_block(bunzip_data *bd)
333 /* Loop through compressed symbols. */ 333 /* Loop through compressed symbols. */
334 334
335 runPos=dbufCount=selector=0; 335 runPos=dbufCount=selector=0;
336 for(;;) { 336 for (;;) {
337 337
338 /* fetch next Huffman coding group from list. */ 338 /* fetch next Huffman coding group from list. */
339 339
@@ -372,7 +372,7 @@ got_huff_bits:
372 /* Figure how how many bits are in next symbol and unget extras */ 372 /* Figure how how many bits are in next symbol and unget extras */
373 373
374 i=hufGroup->minLen; 374 i=hufGroup->minLen;
375 while(j>limit[i]) ++i; 375 while (j>limit[i]) ++i;
376 bd->inbufBitCount += (hufGroup->maxLen - i); 376 bd->inbufBitCount += (hufGroup->maxLen - i);
377 377
378 /* Huffman decode value to get nextSym (with bounds checking) */ 378 /* Huffman decode value to get nextSym (with bounds checking) */
@@ -421,7 +421,7 @@ got_huff_bits:
421 421
422 uc = symToByte[mtfSymbol[0]]; 422 uc = symToByte[mtfSymbol[0]];
423 byteCount[uc] += t; 423 byteCount[uc] += t;
424 while(t--) dbuf[dbufCount++]=uc; 424 while (t--) dbuf[dbufCount++]=uc;
425 } 425 }
426 426
427 /* Is this the terminating symbol? */ 427 /* Is this the terminating symbol? */
@@ -473,7 +473,7 @@ end_of_huffman_loop:
473 /* Turn byteCount into cumulative occurrence counts of 0 to n-1. */ 473 /* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
474 474
475 j=0; 475 j=0;
476 for(i=0;i<256;i++) { 476 for (i=0;i<256;i++) {
477 k=j+byteCount[i]; 477 k=j+byteCount[i];
478 byteCount[i] = j; 478 byteCount[i] = j;
479 j=k; 479 j=k;
@@ -535,7 +535,7 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
535 535
536 /* Loop outputting bytes */ 536 /* Loop outputting bytes */
537 537
538 for(;;) { 538 for (;;) {
539 539
540 /* If the output buffer is full, snapshot state and return */ 540 /* If the output buffer is full, snapshot state and return */
541 541
@@ -682,7 +682,7 @@ uncompressStream(int src_fd, int dst_fd)
682 outbuf=xmalloc(IOBUF_SIZE); 682 outbuf=xmalloc(IOBUF_SIZE);
683 i=start_bunzip(&bd,src_fd,0,0); 683 i=start_bunzip(&bd,src_fd,0,0);
684 if(!i) { 684 if(!i) {
685 for(;;) { 685 for (;;) {
686 if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break; 686 if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
687 if(i!=write(dst_fd,outbuf,i)) { 687 if(i!=write(dst_fd,outbuf,i)) {
688 i=RETVAL_UNEXPECTED_OUTPUT_EOF; 688 i=RETVAL_UNEXPECTED_OUTPUT_EOF;
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 38262608d..09f89e25c 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -791,7 +791,7 @@ static int inflate_get_next_window(void)
791 791
792 gunzip_outbuf_count = 0; 792 gunzip_outbuf_count = 0;
793 793
794 while(1) { 794 while (1) {
795 int ret; 795 int ret;
796 796
797 if (needAnotherBlock) { 797 if (needAnotherBlock) {
@@ -859,7 +859,7 @@ inflate_unzip(int in, int out)
859 /* Allocate space for buffer */ 859 /* Allocate space for buffer */
860 bytebuffer = xmalloc(bytebuffer_max); 860 bytebuffer = xmalloc(bytebuffer_max);
861 861
862 while(1) { 862 while (1) {
863 int ret = inflate_get_next_window(); 863 int ret = inflate_get_next_window();
864 nwrote = full_write(out, gunzip_window, gunzip_outbuf_count); 864 nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
865 if (nwrote == -1) { 865 if (nwrote == -1) {
diff --git a/archival/unzip.c b/archival/unzip.c
index 1c03a4c47..570789427 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -112,7 +112,7 @@ int unzip_main(int argc, char **argv)
112 char key_buf[512]; 112 char key_buf[512];
113 struct stat stat_buf; 113 struct stat stat_buf;
114 114
115 while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) { 115 while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
116 switch (opt_range) { 116 switch (opt_range) {
117 case 0: /* Options */ 117 case 0: /* Options */
118 switch (opt) { 118 switch (opt) {
@@ -192,7 +192,7 @@ int unzip_main(int argc, char **argv)
192 } else { 192 } else {
193 static const char *const extn[] = {"", ".zip", ".ZIP"}; 193 static const char *const extn[] = {"", ".zip", ".ZIP"};
194 int orig_src_fn_len = strlen(src_fn); 194 int orig_src_fn_len = strlen(src_fn);
195 for(i = 0; (i < 3) && (src_fd == -1); i++) { 195 for (i = 0; (i < 3) && (src_fd == -1); i++) {
196 strcpy(src_fn + orig_src_fn_len, extn[i]); 196 strcpy(src_fn + orig_src_fn_len, extn[i]);
197 src_fd = open(src_fn, O_RDONLY); 197 src_fd = open(src_fn, O_RDONLY);
198 } 198 }