Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-04-12 15:48:02 +0400
committerGlenn L McGrath <bug1@ihug.co.nz>2001-04-12 15:48:02 +0400
commit6785b51280d6b0c00e964e1e9b24ff05d92f5bcc (patch)
treec9fbaf8bd615cb7871e16a5525f3223543fe69f5
parent359c1068719c295b25b2d8b81a6aded5aeb6e23d (diff)
dpkg-deb -c works now
-rw-r--r--archival/dpkg_deb.c15
-rw-r--r--dpkg_deb.c15
-rw-r--r--libbb/untar.c40
3 files changed, 36 insertions, 34 deletions
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index fbdb14e26..6653f2a7c 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -20,7 +20,7 @@
extern int dpkg_deb_main(int argc, char **argv)
{
- char *target_dir = NULL;
+ char *target_dir;
int opt = 0;
int optflag = 0;
@@ -50,9 +50,10 @@ extern int dpkg_deb_main(int argc, char **argv)
}
}
- if (((optind + 1 ) > argc) || (optflag == 0)) {
+ if (optind == argc) {
show_usage();
}
+
switch (optflag) {
case (extract_control):
case (extract_extract):
@@ -60,13 +61,15 @@ extern int dpkg_deb_main(int argc, char **argv)
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
+ } else {
+ target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1);
+ strcpy(target_dir, argv[optind + 1]);
}
break;
- default: {
- target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
- strcpy(target_dir, argv[optind + 1]);
- }
+ default:
+ target_dir = NULL;
}
+
deb_extract(argv[optind], optflag, target_dir);
/* else if (optflag & dpkg_deb_info) {
extract_flag = TRUE;
diff --git a/dpkg_deb.c b/dpkg_deb.c
index fbdb14e26..6653f2a7c 100644
--- a/dpkg_deb.c
+++ b/dpkg_deb.c
@@ -20,7 +20,7 @@
extern int dpkg_deb_main(int argc, char **argv)
{
- char *target_dir = NULL;
+ char *target_dir;
int opt = 0;
int optflag = 0;
@@ -50,9 +50,10 @@ extern int dpkg_deb_main(int argc, char **argv)
}
}
- if (((optind + 1 ) > argc) || (optflag == 0)) {
+ if (optind == argc) {
show_usage();
}
+
switch (optflag) {
case (extract_control):
case (extract_extract):
@@ -60,13 +61,15 @@ extern int dpkg_deb_main(int argc, char **argv)
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
+ } else {
+ target_dir = (char *) xmalloc(strlen(argv[optind + 1]) + 1);
+ strcpy(target_dir, argv[optind + 1]);
}
break;
- default: {
- target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
- strcpy(target_dir, argv[optind + 1]);
- }
+ default:
+ target_dir = NULL;
}
+
deb_extract(argv[optind], optflag, target_dir);
/* else if (optflag & dpkg_deb_info) {
extract_flag = TRUE;
diff --git a/libbb/untar.c b/libbb/untar.c
index cb312d597..9f7bd303c 100644
--- a/libbb/untar.c
+++ b/libbb/untar.c
@@ -52,18 +52,16 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
size_t size;
mode_t mode;
-// signal(SIGCHLD, child_died);
-
while (fread((char *) &raw_tar_header, 1, 512, src_tar_file) == 512) {
long sum = 0;
- char *dir;
+ char *dir = NULL;
uncompressed_count += 512;
/* Check header has valid magic */
if (strncmp(raw_tar_header.magic, "ustar", 5) != 0) {
/* Put this pack after TODO (check child still alive) is done */
-// error_msg("Invalid tar magic");
+ error_msg("Invalid tar magic");
break;
}
@@ -111,11 +109,16 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
}
*/
- /* extract files */
- dir = xmalloc(strlen(raw_tar_header.name) + strlen(base_path) + 2);
+ if (untar_function & (extract_verbose_extract | extract_contents)) {
+ printf("%s\n", raw_tar_header.name);
+ }
- sprintf(dir, "%s/%s", base_path, raw_tar_header.name);
- create_path(dir, 0777);
+ /* extract files */
+ if (base_path != NULL) {
+ dir = xmalloc(strlen(raw_tar_header.name) + strlen(base_path) + 2);
+ sprintf(dir, "%s/%s", base_path, raw_tar_header.name);
+ create_path(dir, 0777);
+ }
switch (raw_tar_header.typeflag ) {
case '0':
case '\0':
@@ -124,8 +127,6 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
*/
if (raw_tar_header.name[strlen(raw_tar_header.name)-1] != '/') {
switch (untar_function) {
- case (extract_verbose_extract):
- printf("%s\n", raw_tar_header.name);
case (extract_extract): {
FILE *dst_file = wfopen(dir, "w");
copy_file_chunk(src_tar_file, dst_file, size);
@@ -143,17 +144,12 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
break;
}
case '5':
- switch (untar_function) {
- case (extract_verbose_extract):
- printf("%s\n", raw_tar_header.name);
- case (extract_extract):
- if (create_path(dir, mode) != TRUE) {
- free(dir);
- perror_msg("%s: Cannot mkdir", raw_tar_header.name);
- return(EXIT_FAILURE);
- }
- break;
- default:
+ if (untar_function & (extract_extract | extract_verbose_extract)) {
+ if (create_path(dir, mode) != TRUE) {
+ free(dir);
+ perror_msg("%s: Cannot mkdir", raw_tar_header.name);
+ return(EXIT_FAILURE);
+ }
}
break;
case '1':
@@ -185,7 +181,7 @@ extern int untar(FILE *src_tar_file, int untar_function, char *base_path)
free(dir);
return(EXIT_FAILURE);
}
- free(dir);
+// free(dir);
}
return(EXIT_SUCCESS);
}