lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* This file was released into the public domain by Paul Fox. |
| 3 | */ |
| 4 | |
| 5 | //usage:#define bbconfig_trivial_usage |
| 6 | //usage: "" |
| 7 | //usage:#define bbconfig_full_usage "\n\n" |
| 8 | //usage: "Print the config file used by busybox build" |
| 9 | |
| 10 | #include "libbb.h" |
| 11 | #include "bbconfigopts.h" |
| 12 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
| 13 | # include "bb_archive.h" |
| 14 | # include "bbconfigopts_bz2.h" |
| 15 | #endif |
| 16 | |
| 17 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 18 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
| 19 | { |
| 20 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
| 21 | bunzip_data *bd; |
| 22 | int i = start_bunzip(&bd, |
| 23 | /* src_fd: */ -1, |
| 24 | /* inbuf: */ bbconfig_config_bz2, |
| 25 | /* len: */ sizeof(bbconfig_config_bz2)); |
| 26 | /* read_bunzip can longjmp to start_bunzip, and ultimately |
| 27 | * end up here with i != 0 on read data errors! Not trivial */ |
| 28 | if (!i) { |
| 29 | /* Cannot use xmalloc: will leak bd in NOFORK case! */ |
| 30 | char *outbuf = malloc_or_warn(sizeof(bbconfig_config)); |
| 31 | if (outbuf) { |
| 32 | read_bunzip(bd, outbuf, sizeof(bbconfig_config)); |
| 33 | full_write1_str(outbuf); |
| 34 | } |
| 35 | } |
| 36 | #else |
| 37 | full_write1_str(bbconfig_config); |
| 38 | #endif |
| 39 | return 0; |
| 40 | } |