From 359c1068719c295b25b2d8b81a6aded5aeb6e23d Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Thu, 12 Apr 2001 10:19:08 +0000 Subject: Fix dpkg-deb, enum's are cool --- libbb/deb_extract.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'libbb/deb_extract.c') diff --git a/libbb/deb_extract.c b/libbb/deb_extract.c index 35ff99671..e982c14bb 100644 --- a/libbb/deb_extract.c +++ b/libbb/deb_extract.c @@ -29,25 +29,27 @@ #include #include "libbb.h" -const int dpkg_deb_contents = 1; -const int dpkg_deb_control = 2; -const int dpkg_deb_info = 4; -const int dpkg_deb_extract = 8; -const int dpkg_deb_verbose_extract = 16; -const int dpkg_deb_list = 32; - -extern int deb_extract(const char *package_filename, const int function, char *target_dir) +extern int deb_extract(const char *package_filename, int function, char *target_dir) { FILE *deb_file, *uncompressed_file; ar_headers_t *headers = NULL; - char *ared_file; + char *ared_file = NULL; int gunzip_pid; - if ((function == dpkg_deb_info) || (function == dpkg_deb_control)) { - ared_file = xstrdup("control.tar.gz"); - } else { - ared_file = xstrdup("data.tar.gz"); + switch (function) { + case (extract_info): + case (extract_control): + ared_file = xstrdup("control.tar.gz"); + break; + case (extract_contents): + case (extract_extract): + case (extract_verbose_extract): + case (extract_list): + ared_file = xstrdup("data.tar.gz"); + break; + default: + error_msg("Unknown extraction function"); } /* open the debian package to be worked on */ @@ -70,12 +72,14 @@ extern int deb_extract(const char *package_filename, const int function, char *t uncompressed_file = fdopen(gz_open(deb_file, &gunzip_pid), "r"); /* get a list of all tar headers inside the .gz file */ - untar(uncompressed_file, dpkg_deb_extract, target_dir); + untar(uncompressed_file, function, target_dir); /* we are deliberately terminating the child so we can safely ignore this */ - signal(SIGTERM, SIG_IGN); gz_close(gunzip_pid); + fclose(deb_file); fclose(uncompressed_file); + free(ared_file); + return(EXIT_SUCCESS); } \ No newline at end of file -- cgit v1.2.3