aboutsummaryrefslogtreecommitdiff
path: root/libbb/deb_extract.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/deb_extract.c')
-rw-r--r--libbb/deb_extract.c34
1 files changed, 19 insertions, 15 deletions
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 @@
29#include <signal.h> 29#include <signal.h>
30#include "libbb.h" 30#include "libbb.h"
31 31
32const int dpkg_deb_contents = 1; 32extern int deb_extract(const char *package_filename, int function, char *target_dir)
33const int dpkg_deb_control = 2;
34const int dpkg_deb_info = 4;
35const int dpkg_deb_extract = 8;
36const int dpkg_deb_verbose_extract = 16;
37const int dpkg_deb_list = 32;
38
39extern int deb_extract(const char *package_filename, const int function, char *target_dir)
40{ 33{
41 34
42 FILE *deb_file, *uncompressed_file; 35 FILE *deb_file, *uncompressed_file;
43 ar_headers_t *headers = NULL; 36 ar_headers_t *headers = NULL;
44 char *ared_file; 37 char *ared_file = NULL;
45 int gunzip_pid; 38 int gunzip_pid;
46 39
47 if ((function == dpkg_deb_info) || (function == dpkg_deb_control)) { 40 switch (function) {
48 ared_file = xstrdup("control.tar.gz"); 41 case (extract_info):
49 } else { 42 case (extract_control):
50 ared_file = xstrdup("data.tar.gz"); 43 ared_file = xstrdup("control.tar.gz");
44 break;
45 case (extract_contents):
46 case (extract_extract):
47 case (extract_verbose_extract):
48 case (extract_list):
49 ared_file = xstrdup("data.tar.gz");
50 break;
51 default:
52 error_msg("Unknown extraction function");
51 } 53 }
52 54
53 /* open the debian package to be worked on */ 55 /* 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
70 uncompressed_file = fdopen(gz_open(deb_file, &gunzip_pid), "r"); 72 uncompressed_file = fdopen(gz_open(deb_file, &gunzip_pid), "r");
71 73
72 /* get a list of all tar headers inside the .gz file */ 74 /* get a list of all tar headers inside the .gz file */
73 untar(uncompressed_file, dpkg_deb_extract, target_dir); 75 untar(uncompressed_file, function, target_dir);
74 76
75 /* we are deliberately terminating the child so we can safely ignore this */ 77 /* we are deliberately terminating the child so we can safely ignore this */
76 signal(SIGTERM, SIG_IGN);
77 gz_close(gunzip_pid); 78 gz_close(gunzip_pid);
79
78 fclose(deb_file); 80 fclose(deb_file);
79 fclose(uncompressed_file); 81 fclose(uncompressed_file);
82 free(ared_file);
83
80 return(EXIT_SUCCESS); 84 return(EXIT_SUCCESS);
81} \ No newline at end of file 85} \ No newline at end of file