build: add cmake build system
[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
28         if (argc < 2) {
29                 fprintf(stderr, "syntax: %s <opkg file> [<file_to_extract>]\n",
30                         argv[0]);
31                 exit(0);
32         }
33
34         if (argc < 3) {
35                 filename = NULL;
36         } else {
37                 filename = argv[2];
38         }
39
40         returned = deb_extract(argv[1], stdout, dowhat, NULL, filename);
41
42         if (returned)
43                 fprintf(stderr, "returned %s\n", returned);
44         else
45                 fprintf(stderr, "extract returned nuthin'\n");
46
47         return 0;
48 }