blob: e5f4eb379f0d2d9410e792dc4bb968ec078f77fc [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 */
Pere Orga5bc8c002011-04-11 03:29:49 +02004
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 Vlasenkob6adbf12007-05-26 19:00:18 +000010#include "libbb.h"
Paul Fox79c142d2005-08-01 16:04:40 +000011#include "bbconfigopts.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020012#if ENABLE_FEATURE_COMPRESS_BBCONFIG
Denys Vlasenkod184a722011-09-22 12:45:14 +020013# include "bb_archive.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020014# include "bbconfigopts_bz2.h"
15#endif
Paul Fox79c142d2005-08-01 16:04:40 +000016
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000017int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000018int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
Paul Fox79c142d2005-08-01 16:04:40 +000019{
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020020#if ENABLE_FEATURE_COMPRESS_BBCONFIG
21 bunzip_data *bd;
22 int i = start_bunzip(&bd,
23 /* src_fd: */ -1,
Denys Vlasenkocaddfc82010-10-28 23:08:53 +020024 /* inbuf: */ bbconfig_config_bz2,
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020025 /* 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 Vlasenko729ecb82010-06-07 14:14:26 +020037 full_write1_str(bbconfig_config);
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020038#endif
Paul Fox79c142d2005-08-01 16:04:40 +000039 return 0;
40}