aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2004-12-17 05:23:36 +0000
committerRob Landley <rob@landley.net>2004-12-17 05:23:36 +0000
commitec4f3d95e7f0150f92e046bf65d4d63fbeffb528 (patch)
tree595038501d778a2b4bb51093521479cb94de67ca
parent861f0145d3f04547bb15fde1718b949996094fba (diff)
downloadbusybox-w32-ec4f3d95e7f0150f92e046bf65d4d63fbeffb528.tar.gz
busybox-w32-ec4f3d95e7f0150f92e046bf65d4d63fbeffb528.tar.bz2
busybox-w32-ec4f3d95e7f0150f92e046bf65d4d63fbeffb528.zip
Minor in-passing crapectomy.
-rw-r--r--archival/gzip.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index d494aa30e..e539c2a46 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -51,12 +51,6 @@
51#include <time.h> 51#include <time.h>
52#include "busybox.h" 52#include "busybox.h"
53 53
54#define memzero(s, n) memset ((void *)(s), 0, (n))
55
56#ifndef RETSIGTYPE
57# define RETSIGTYPE void
58#endif
59
60typedef unsigned char uch; 54typedef unsigned char uch;
61typedef unsigned short ush; 55typedef unsigned short ush;
62typedef unsigned long ulg; 56typedef unsigned long ulg;
@@ -214,9 +208,6 @@ typedef int file_t; /* Do not use stdio */
214static int zip(int in, int out); 208static int zip(int in, int out);
215static int file_read(char *buf, unsigned size); 209static int file_read(char *buf, unsigned size);
216 210
217 /* from gzip.c */
218static RETSIGTYPE abort_gzip(void);
219
220 /* from deflate.c */ 211 /* from deflate.c */
221static void lm_init(ush * flags); 212static void lm_init(ush * flags);
222static ulg deflate(void); 213static ulg deflate(void);
@@ -335,7 +326,7 @@ static void put_short(ush w)
335/* ======================================================================== 326/* ========================================================================
336 * Signal and error handler. 327 * Signal and error handler.
337 */ 328 */
338static void abort_gzip() 329static void abort_gzip(int ignored)
339{ 330{
340 exit(ERROR); 331 exit(ERROR);
341} 332}
@@ -350,13 +341,6 @@ static void clear_bufs(void)
350 bytes_in = 0L; 341 bytes_in = 0L;
351} 342}
352 343
353static void write_bb_error_msg(void)
354{
355 fputc('\n', stderr);
356 bb_perror_nomsg();
357 abort_gzip();
358}
359
360/* =========================================================================== 344/* ===========================================================================
361 * Does the same as write(), but also handles partial pipe writes and checks 345 * Does the same as write(), but also handles partial pipe writes and checks
362 * for error return. 346 * for error return.
@@ -366,9 +350,7 @@ static void write_buf(int fd, void *buf, unsigned cnt)
366 unsigned n; 350 unsigned n;
367 351
368 while ((n = write(fd, buf, cnt)) != cnt) { 352 while ((n = write(fd, buf, cnt)) != cnt) {
369 if (n == (unsigned) (-1)) { 353 if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write");
370 write_bb_error_msg();
371 }
372 cnt -= n; 354 cnt -= n;
373 buf = (void *) ((char *) buf + n); 355 buf = (void *) ((char *) buf + n);
374 } 356 }
@@ -846,7 +828,7 @@ static void lm_init(ush * flags)
846 register unsigned j; 828 register unsigned j;
847 829
848 /* Initialize the hash table. */ 830 /* Initialize the hash table. */
849 memzero((char *) head, HASH_SIZE * sizeof(*head)); 831 memset(head, 0, HASH_SIZE * sizeof(*head));
850 /* prev will be initialized on the fly */ 832 /* prev will be initialized on the fly */
851 833
852 *flags |= SLOW; 834 *flags |= SLOW;
@@ -1188,8 +1170,6 @@ static ulg deflate()
1188 1170
1189typedef struct dirent dir_type; 1171typedef struct dirent dir_type;
1190 1172
1191typedef RETSIGTYPE(*sig_type) (int);
1192
1193/* ======================================================================== */ 1173/* ======================================================================== */
1194int gzip_main(int argc, char **argv) 1174int gzip_main(int argc, char **argv)
1195{ 1175{
@@ -1235,16 +1215,16 @@ int gzip_main(int argc, char **argv)
1235 1215
1236 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; 1216 foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
1237 if (foreground) { 1217 if (foreground) {
1238 (void) signal(SIGINT, (sig_type) abort_gzip); 1218 (void) signal(SIGINT, abort_gzip);
1239 } 1219 }
1240#ifdef SIGTERM 1220#ifdef SIGTERM
1241 if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { 1221 if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
1242 (void) signal(SIGTERM, (sig_type) abort_gzip); 1222 (void) signal(SIGTERM, abort_gzip);
1243 } 1223 }
1244#endif 1224#endif
1245#ifdef SIGHUP 1225#ifdef SIGHUP
1246 if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { 1226 if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
1247 (void) signal(SIGHUP, (sig_type) abort_gzip); 1227 (void) signal(SIGHUP, abort_gzip);
1248 } 1228 }
1249#endif 1229#endif
1250 1230