bbconfig.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* vi: set sw=4 ts=4: */
  2. /* This file was released into the public domain by Paul Fox.
  3. */
  4. //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.
  24. //applet:IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP))
  25. //kbuild:lib-$(CONFIG_BBCONFIG) += bbconfig.o
  26. //usage:#define bbconfig_trivial_usage
  27. //usage: ""
  28. //usage:#define bbconfig_full_usage "\n\n"
  29. //usage: "Print the config file used by busybox build"
  30. #include "libbb.h"
  31. #include "bbconfigopts.h"
  32. #if ENABLE_FEATURE_COMPRESS_BBCONFIG
  33. # include "bb_archive.h"
  34. # include "bbconfigopts_bz2.h"
  35. #endif
  36. int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  37. int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
  38. {
  39. #if ENABLE_FEATURE_COMPRESS_BBCONFIG
  40. bunzip_data *bd;
  41. int i = start_bunzip(&bd,
  42. /* src_fd: */ -1,
  43. /* inbuf: */ bbconfig_config_bz2,
  44. /* len: */ sizeof(bbconfig_config_bz2));
  45. /* read_bunzip can longjmp to start_bunzip, and ultimately
  46. * end up here with i != 0 on read data errors! Not trivial */
  47. if (!i) {
  48. /* Cannot use xmalloc: will leak bd in NOFORK case! */
  49. char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
  50. if (outbuf) {
  51. read_bunzip(bd, outbuf, sizeof(bbconfig_config));
  52. full_write1_str(outbuf);
  53. }
  54. }
  55. #else
  56. full_write1_str(bbconfig_config);
  57. #endif
  58. return 0;
  59. }