Paul Fox | 5139bd9 | 2006-03-29 19:54:02 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Rob Landley | a8e2760 | 2006-03-30 02:01:48 +0000 | [diff] [blame] | 2 | /* This file was released into the public domain by Paul Fox. |
Paul Fox | 5139bd9 | 2006-03-29 19:54:02 +0000 | [diff] [blame] | 3 | */ |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 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 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 10 | #include "libbb.h" |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 11 | #include "bbconfigopts.h" |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 12 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
Denys Vlasenko | d184a72 | 2011-09-22 12:45:14 +0200 | [diff] [blame^] | 13 | # include "bb_archive.h" |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 14 | # include "bbconfigopts_bz2.h" |
| 15 | #endif |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 16 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 17 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 18 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 19 | { |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 20 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
| 21 | bunzip_data *bd; |
| 22 | int i = start_bunzip(&bd, |
| 23 | /* src_fd: */ -1, |
Denys Vlasenko | caddfc8 | 2010-10-28 23:08:53 +0200 | [diff] [blame] | 24 | /* inbuf: */ bbconfig_config_bz2, |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 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 |
Denys Vlasenko | 729ecb8 | 2010-06-07 14:14:26 +0200 | [diff] [blame] | 37 | full_write1_str(bbconfig_config); |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 38 | #endif |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 39 | return 0; |
| 40 | } |