summaryrefslogtreecommitdiff
path: root/miscutils/bbconfig.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-08-29 14:36:11 +0200
committerDenys Vlasenko2010-08-29 14:36:11 +0200
commit9ce07e778f05719115f354d4907f51295fb3fd1a (patch)
tree1f204121b58c0a86904e376d2fc6b08f9c3ce881 /miscutils/bbconfig.c
parent7715b48c36a453b41f4555ee57c2f936e25f06f1 (diff)
downloadbusybox-9ce07e778f05719115f354d4907f51295fb3fd1a.zip
busybox-9ce07e778f05719115f354d4907f51295fb3fd1a.tar.gz
bbconfig: add COMPRESS_BBCONFIG option
function old new delta bbconfig_config_bz2 - 4905 +4905 bbconfig_main 13 70 +57 bbconfig_config 21811 - -21811 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 1/0 up/down: 4962/-21811) Total: -16849 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bbconfig.c')
-rw-r--r--miscutils/bbconfig.c22
1 files changed, 22 insertions, 0 deletions
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;
}