aboutsummaryrefslogtreecommitdiff
path: root/archival/gunzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/gunzip.c')
-rw-r--r--archival/gunzip.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c
index e9963a8d2..3350da052 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -82,7 +82,7 @@ extern int gunzip_main(int argc, char **argv)
82 int opt; 82 int opt;
83 83
84 /* if called as zcat */ 84 /* if called as zcat */
85 if (strcmp(applet_name, "zcat") == 0) { 85 if (strcmp(bb_applet_name, "zcat") == 0) {
86 flags |= gunzip_to_stdout; 86 flags |= gunzip_to_stdout;
87 } 87 }
88 88
@@ -100,7 +100,7 @@ extern int gunzip_main(int argc, char **argv)
100 case 'd': /* Used to convert gzip to gunzip. */ 100 case 'd': /* Used to convert gzip to gunzip. */
101 break; 101 break;
102 default: 102 default:
103 show_usage(); /* exit's inside usage */ 103 bb_show_usage(); /* exit's inside usage */
104 } 104 }
105 } 105 }
106 106
@@ -118,29 +118,29 @@ extern int gunzip_main(int argc, char **argv)
118 src_fd = fileno(stdin); 118 src_fd = fileno(stdin);
119 flags |= gunzip_to_stdout; 119 flags |= gunzip_to_stdout;
120 } else { 120 } else {
121 src_fd = xopen(old_path, O_RDONLY); 121 src_fd = bb_xopen(old_path, O_RDONLY);
122 122
123 /* Get the time stamp on the input file. */ 123 /* Get the time stamp on the input file. */
124 if (stat(old_path, &stat_buf) < 0) { 124 if (stat(old_path, &stat_buf) < 0) {
125 error_msg_and_die("Couldn't stat file %s", old_path); 125 bb_error_msg_and_die("Couldn't stat file %s", old_path);
126 } 126 }
127 } 127 }
128 128
129 /* Check that the input is sane. */ 129 /* Check that the input is sane. */
130 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) { 130 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) {
131 error_msg_and_die 131 bb_error_msg_and_die
132 ("compressed data not read from terminal. Use -f to force it."); 132 ("compressed data not read from terminal. Use -f to force it.");
133 } 133 }
134 134
135 /* Set output filename and number */ 135 /* Set output filename and number */
136 if (flags & gunzip_test) { 136 if (flags & gunzip_test) {
137 dst_fd = xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */ 137 dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
138 } else if (flags & gunzip_to_stdout) { 138 } else if (flags & gunzip_to_stdout) {
139 dst_fd = fileno(stdout); 139 dst_fd = fileno(stdout);
140 } else { 140 } else {
141 char *extension; 141 char *extension;
142 142
143 new_path = xstrdup(old_path); 143 new_path = bb_xstrdup(old_path);
144 144
145 extension = strrchr(new_path, '.'); 145 extension = strrchr(new_path, '.');
146#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS 146#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
@@ -154,11 +154,11 @@ extern int gunzip_main(int argc, char **argv)
154 extension[2] = 'a'; 154 extension[2] = 'a';
155 extension[3] = 'r'; 155 extension[3] = 'r';
156 } else { 156 } else {
157 error_msg_and_die("Invalid extension"); 157 bb_error_msg_and_die("Invalid extension");
158 } 158 }
159 159
160 /* Open output file */ 160 /* Open output file */
161 dst_fd = xopen(new_path, O_WRONLY | O_CREAT); 161 dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
162 162
163 /* Set permissions on the file */ 163 /* Set permissions on the file */
164 chmod(new_path, stat_buf.st_mode); 164 chmod(new_path, stat_buf.st_mode);
@@ -168,10 +168,10 @@ extern int gunzip_main(int argc, char **argv)
168 } 168 }
169 169
170 /* do the decompression, and cleanup */ 170 /* do the decompression, and cleanup */
171 if (xread_char(src_fd) == 0x1f) { 171 if (bb_xread_char(src_fd) == 0x1f) {
172 unsigned char magic2; 172 unsigned char magic2;
173 173
174 magic2 = xread_char(src_fd); 174 magic2 = bb_xread_char(src_fd);
175#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS 175#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
176 if (magic2 == 0x9d) { 176 if (magic2 == 0x9d) {
177 status = uncompress(src_fd, dst_fd); 177 status = uncompress(src_fd, dst_fd);
@@ -181,14 +181,14 @@ extern int gunzip_main(int argc, char **argv)
181 check_header_gzip(src_fd); 181 check_header_gzip(src_fd);
182 status = inflate(src_fd, dst_fd); 182 status = inflate(src_fd, dst_fd);
183 if (status != 0) { 183 if (status != 0) {
184 error_msg_and_die("Error inflating"); 184 bb_error_msg_and_die("Error inflating");
185 } 185 }
186 check_trailer_gzip(src_fd); 186 check_trailer_gzip(src_fd);
187 } else { 187 } else {
188 error_msg_and_die("Invalid magic"); 188 bb_error_msg_and_die("Invalid magic");
189 } 189 }
190 } else { 190 } else {
191 error_msg_and_die("Invalid magic"); 191 bb_error_msg_and_die("Invalid magic");
192 } 192 }
193 193
194 if ((status != EXIT_SUCCESS) && (new_path)) { 194 if ((status != EXIT_SUCCESS) && (new_path)) {
@@ -205,7 +205,7 @@ extern int gunzip_main(int argc, char **argv)
205 205
206 /* delete_path will be NULL if in test mode or from stdin */ 206 /* delete_path will be NULL if in test mode or from stdin */
207 if (delete_path && (unlink(delete_path) == -1)) { 207 if (delete_path && (unlink(delete_path) == -1)) {
208 error_msg_and_die("Couldn't remove %s", delete_path); 208 bb_error_msg_and_die("Couldn't remove %s", delete_path);
209 } 209 }
210 210
211 free(new_path); 211 free(new_path);