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 | */ |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 4 | #include "libbb.h" |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 5 | #include "bbconfigopts.h" |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 6 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
| 7 | # include "unarchive.h" |
| 8 | # include "bbconfigopts_bz2.h" |
| 9 | #endif |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 10 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 11 | int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 12 | int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 13 | { |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 14 | #if ENABLE_FEATURE_COMPRESS_BBCONFIG |
| 15 | bunzip_data *bd; |
| 16 | int i = start_bunzip(&bd, |
| 17 | /* src_fd: */ -1, |
Denys Vlasenko | caddfc8 | 2010-10-28 23:08:53 +0200 | [diff] [blame] | 18 | /* inbuf: */ bbconfig_config_bz2, |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 19 | /* len: */ sizeof(bbconfig_config_bz2)); |
| 20 | /* read_bunzip can longjmp to start_bunzip, and ultimately |
| 21 | * end up here with i != 0 on read data errors! Not trivial */ |
| 22 | if (!i) { |
| 23 | /* Cannot use xmalloc: will leak bd in NOFORK case! */ |
| 24 | char *outbuf = malloc_or_warn(sizeof(bbconfig_config)); |
| 25 | if (outbuf) { |
| 26 | read_bunzip(bd, outbuf, sizeof(bbconfig_config)); |
| 27 | full_write1_str(outbuf); |
| 28 | } |
| 29 | } |
| 30 | #else |
Denys Vlasenko | 729ecb8 | 2010-06-07 14:14:26 +0200 | [diff] [blame] | 31 | full_write1_str(bbconfig_config); |
Denys Vlasenko | 9ce07e7 | 2010-08-29 14:36:11 +0200 | [diff] [blame] | 32 | #endif |
Paul Fox | 79c142d | 2005-08-01 16:04:40 +0000 | [diff] [blame] | 33 | return 0; |
| 34 | } |