str_list_push: remove unused function
[oweals/opkg-lede.git] / tests / 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 =
24             extract_control_tar_gz | extract_all_to_fs | extract_preserve_date;
25         char *returned;
26         char *filename;
27         int err;
28
29         if (argc < 2) {
30                 fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n",
31                         argv[0]);
32                 exit(0);
33         }
34
35         if (argc < 3) {
36                 filename = NULL;
37         } else {
38                 filename = argv[2];
39         }
40
41         returned = deb_extract(argv[1], stdout, dowhat, NULL, filename, &err);
42
43         if (returned)
44                 fprintf(stderr, "returned %s\n", returned);
45         else
46                 fprintf(stderr, "extract returned nuthin'\n");
47
48         return 0;
49 }