summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/Config.src14
-rw-r--r--miscutils/bbconfig.c22
2 files changed, 36 insertions, 0 deletions
diff --git a/miscutils/Config.src b/miscutils/Config.src
index cadaabb..151f61b 100644
--- a/miscutils/Config.src
+++ b/miscutils/Config.src
@@ -22,6 +22,20 @@ config BBCONFIG
The bbconfig applet will print the config file with which
busybox was built.
+config FEATURE_COMPRESS_BBCONFIG
+ bool "Compress bbconfig data"
+ default y
+ depends on BBCONFIG
+ help
+ Store bbconfig data in compressed form, uncompress them on-the-fly
+ before output.
+
+ If you have a really tiny busybox with few applets enabled (and
+ bunzip2 isn't one of them), the overhead of the decompressor might
+ be noticeable. Also, if you run executables directly from ROM
+ and have very little memory, this might not be a win. Otherwise,
+ you probably want this.
+
config BEEP
bool "beep"
default y
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c
index 0d649b4..2860771 100644
--- a/miscutils/bbconfig.c
+++ b/miscutils/bbconfig.c
@@ -3,10 +3,32 @@
*/
#include "libbb.h"
#include "bbconfigopts.h"
+#if ENABLE_FEATURE_COMPRESS_BBCONFIG
+# include "unarchive.h"
+# include "bbconfigopts_bz2.h"
+#endif
int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
+#if ENABLE_FEATURE_COMPRESS_BBCONFIG
+ bunzip_data *bd;
+ int i = start_bunzip(&bd,
+ /* src_fd: */ -1,
+ /* inbuf: */ (void *)bbconfig_config_bz2,
+ /* len: */ sizeof(bbconfig_config_bz2));
+ /* read_bunzip can longjmp to start_bunzip, and ultimately
+ * end up here with i != 0 on read data errors! Not trivial */
+ if (!i) {
+ /* Cannot use xmalloc: will leak bd in NOFORK case! */
+ char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
+ if (outbuf) {
+ read_bunzip(bd, outbuf, sizeof(bbconfig_config));
+ full_write1_str(outbuf);
+ }
+ }
+#else
full_write1_str(bbconfig_config);
+#endif
return 0;
}