opkg: add a download progress callback hook to libopkg
[oweals/opkg-lede.git] / opkg_extract_test.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "libbb/libbb.h"
4
5 /*
6  * build thus: 
7
8  * gcc -o opkg_extract_test opkg_extract_test.c -I./busybox-0.60.2/libbb -L./busybox-0.60.2 -lbb
9  *
10  */
11 const char * applet_name;
12
13 int main(int argc, char * argv[])
14 {
15   /*
16    * see libbb.h and let your imagination run wild
17    * or, set the last item below to extract_one_to_buffer, and you get the control file in 
18    * "returned"
19    * or, set the last one to extract_all_to_fs, and, well, guess what happens
20    */
21
22     /* enum extract_functions_e dowhat = extract_control_tar_gz | extract_unconditional | extract_one_to_buffer; */
23     enum extract_functions_e dowhat = extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
24   char * returned;
25   char * filename;
26   
27   if(argc < 2){
28     fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n", argv[0]);
29     exit(0);
30   }
31   
32   if (argc < 3){
33     filename=NULL;
34   } else {
35     filename = argv[2];
36   }
37
38   returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
39   
40   if(returned)
41     fprintf(stderr, "returned %s\n", returned);
42   else
43     fprintf(stderr, "extract returned nuthin'\n");
44
45   return 0;
46 }