blob: 7c30669a33635eb824eed9f89cbc9f5486ef0a10 [file] [log] [blame]
Paul Fox5139bd92006-03-29 19:54:02 +00001/* vi: set sw=4 ts=4: */
Rob Landleya8e27602006-03-30 02:01:48 +00002/* This file was released into the public domain by Paul Fox.
Paul Fox5139bd92006-03-29 19:54:02 +00003 */
Denis Vlasenkob6adbf12007-05-26 19:00:18 +00004#include "libbb.h"
Paul Fox79c142d2005-08-01 16:04:40 +00005#include "bbconfigopts.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +02006#if ENABLE_FEATURE_COMPRESS_BBCONFIG
Denys Vlasenko833d4e72010-11-03 02:38:31 +01007# include "archive.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +02008# include "bbconfigopts_bz2.h"
9#endif
Paul Fox79c142d2005-08-01 16:04:40 +000010
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000011int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000012int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
Paul Fox79c142d2005-08-01 16:04:40 +000013{
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020014#if ENABLE_FEATURE_COMPRESS_BBCONFIG
15 bunzip_data *bd;
16 int i = start_bunzip(&bd,
17 /* src_fd: */ -1,
Denys Vlasenkocaddfc82010-10-28 23:08:53 +020018 /* inbuf: */ bbconfig_config_bz2,
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020019 /* 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 Vlasenko729ecb82010-06-07 14:14:26 +020031 full_write1_str(bbconfig_config);
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020032#endif
Paul Fox79c142d2005-08-01 16:04:40 +000033 return 0;
34}