aboutsummaryrefslogtreecommitdiff
path: root/rpmunpack.c
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2001-01-23 22:30:04 +0000
committerMark Whitley <markw@lineo.com>2001-01-23 22:30:04 +0000
commit59ab025363d884deb2013dcaae6c968585a6ec72 (patch)
tree852d97bdc34c44dbcf29cc8b5cd9257a8c90f7b3 /rpmunpack.c
parent2b8d07c590249991fae975652aae86f5fca91f81 (diff)
downloadbusybox-w32-59ab025363d884deb2013dcaae6c968585a6ec72.tar.gz
busybox-w32-59ab025363d884deb2013dcaae6c968585a6ec72.tar.bz2
busybox-w32-59ab025363d884deb2013dcaae6c968585a6ec72.zip
#define -> static const int. Also got rid of some big static buffers.
Diffstat (limited to 'rpmunpack.c')
-rw-r--r--rpmunpack.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/rpmunpack.c b/rpmunpack.c
index 249d223c0..512d63839 100644
--- a/rpmunpack.c
+++ b/rpmunpack.c
@@ -19,7 +19,7 @@
19/* 19/*
20 * Some general definitions 20 * Some general definitions
21 */ 21 */
22#define BUFSIZE 512 22
23#define RPM_MAGIC "\355\253\356\333" 23#define RPM_MAGIC "\355\253\356\333"
24#define GZ_MAGIC_1 '\037' 24#define GZ_MAGIC_1 '\037'
25#define GZ_MAGIC_2 '\213' 25#define GZ_MAGIC_2 '\213'
@@ -27,14 +27,13 @@
27/* 27/*
28 * Global variables 28 * Global variables
29 */ 29 */
30static char buffer[BUFSIZE];
31static char *progname; 30static char *progname;
32static int infile, outfile; 31static int infile, outfile;
33 32
34/* 33/*
35 * Read a specified number of bytes from input file 34 * Read a specified number of bytes from input file
36 */ 35 */
37static void myread(int num) 36static void myread(int num, char *buffer)
38{ 37{
39 int err; 38 int err;
40 39
@@ -52,6 +51,7 @@ static void myread(int num)
52int rpmunpack_main(int argc, char **argv) 51int rpmunpack_main(int argc, char **argv)
53{ 52{
54 int len, status = 0; 53 int len, status = 0;
54 char buffer[BUFSIZ];
55 55
56 /* Get our own program name */ 56 /* Get our own program name */
57 if ((progname = strrchr(argv[0], '/')) == NULL) 57 if ((progname = strrchr(argv[0], '/')) == NULL)
@@ -71,13 +71,13 @@ int rpmunpack_main(int argc, char **argv)
71 perror_msg_and_die("%s", argv[1]); 71 perror_msg_and_die("%s", argv[1]);
72 72
73 /* Read magic ID and output filename */ 73 /* Read magic ID and output filename */
74 myread(4); 74 myread(4, buffer);
75 if (strncmp(buffer, RPM_MAGIC, 4)) { 75 if (strncmp(buffer, RPM_MAGIC, 4)) {
76 fprintf(stderr, "Input file is not in RPM format!\n"); 76 fprintf(stderr, "Input file is not in RPM format!\n");
77 exit(1); 77 exit(1);
78 } 78 }
79 myread(6); /* Skip flags */ 79 myread(6, buffer); /* Skip flags */
80 myread(64); 80 myread(64, buffer);
81 buffer[64] = '\0'; 81 buffer[64] = '\0';
82 82
83 /* Open output file */ 83 /* Open output file */
@@ -97,9 +97,9 @@ int rpmunpack_main(int argc, char **argv)
97 * never appears before offset 0x200, so we skip these first couple of 97 * never appears before offset 0x200, so we skip these first couple of
98 * bytes to make the signature scan a little more reliable. 98 * bytes to make the signature scan a little more reliable.
99 */ 99 */
100 myread(0x200 - 74); 100 myread(0x200 - 74, buffer);
101 while (status < 2) { 101 while (status < 2) {
102 myread(1); 102 myread(1, buffer);
103 if (status == 0 && buffer[0] == GZ_MAGIC_1) 103 if (status == 0 && buffer[0] == GZ_MAGIC_1)
104 status++; 104 status++;
105 else if (status == 1 && buffer[0] == GZ_MAGIC_2) 105 else if (status == 1 && buffer[0] == GZ_MAGIC_2)
@@ -113,7 +113,7 @@ int rpmunpack_main(int argc, char **argv)
113 perror_msg_and_die("write"); 113 perror_msg_and_die("write");
114 114
115 /* Now simply copy the GZIP archive into the output file */ 115 /* Now simply copy the GZIP archive into the output file */
116 while ((len = read(infile, buffer, BUFSIZE)) > 0) { 116 while ((len = read(infile, buffer, BUFSIZ)) > 0) {
117 if (write(outfile, buffer, len) < 0) 117 if (write(outfile, buffer, len) < 0)
118 perror_msg_and_die("write"); 118 perror_msg_and_die("write");
119 } 119 }