blob: 4781a42763d0483fe64be15fd46afabb9e7649b9 [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 */
Denys Vlasenkofb4da162016-11-22 23:14:24 +01004//config:config BBCONFIG
5//config: bool "bbconfig"
6//config: default n
7//config: help
8//config: The bbconfig applet will print the config file with which
9//config: busybox was built.
10//config:
11//config:config FEATURE_COMPRESS_BBCONFIG
12//config: bool "Compress bbconfig data"
13//config: default y
14//config: depends on BBCONFIG
15//config: help
16//config: Store bbconfig data in compressed form, uncompress them on-the-fly
17//config: before output.
18//config:
19//config: If you have a really tiny busybox with few applets enabled (and
20//config: bunzip2 isn't one of them), the overhead of the decompressor might
21//config: be noticeable. Also, if you run executables directly from ROM
22//config: and have very little memory, this might not be a win. Otherwise,
23//config: you probably want this.
Pere Orga5bc8c002011-04-11 03:29:49 +020024
Denys Vlasenkof88e3bf2016-11-22 23:54:17 +010025//applet:IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP))
26
27//kbuild:lib-$(CONFIG_BBCONFIG) += bbconfig.o
28
Pere Orga5bc8c002011-04-11 03:29:49 +020029//usage:#define bbconfig_trivial_usage
30//usage: ""
31//usage:#define bbconfig_full_usage "\n\n"
32//usage: "Print the config file used by busybox build"
33
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000034#include "libbb.h"
Paul Fox79c142d2005-08-01 16:04:40 +000035#include "bbconfigopts.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020036#if ENABLE_FEATURE_COMPRESS_BBCONFIG
Denys Vlasenkod184a722011-09-22 12:45:14 +020037# include "bb_archive.h"
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020038# include "bbconfigopts_bz2.h"
39#endif
Paul Fox79c142d2005-08-01 16:04:40 +000040
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000041int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +000042int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
Paul Fox79c142d2005-08-01 16:04:40 +000043{
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020044#if ENABLE_FEATURE_COMPRESS_BBCONFIG
45 bunzip_data *bd;
46 int i = start_bunzip(&bd,
47 /* src_fd: */ -1,
Denys Vlasenkocaddfc82010-10-28 23:08:53 +020048 /* inbuf: */ bbconfig_config_bz2,
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020049 /* len: */ sizeof(bbconfig_config_bz2));
50 /* read_bunzip can longjmp to start_bunzip, and ultimately
51 * end up here with i != 0 on read data errors! Not trivial */
52 if (!i) {
53 /* Cannot use xmalloc: will leak bd in NOFORK case! */
54 char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
55 if (outbuf) {
56 read_bunzip(bd, outbuf, sizeof(bbconfig_config));
57 full_write1_str(outbuf);
58 }
59 }
60#else
Denys Vlasenko729ecb82010-06-07 14:14:26 +020061 full_write1_str(bbconfig_config);
Denys Vlasenko9ce07e72010-08-29 14:36:11 +020062#endif
Paul Fox79c142d2005-08-01 16:04:40 +000063 return 0;
64}