bbconfig.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* vi: set sw=4 ts=4: */
  2. /* This file was released into the public domain by Paul Fox.
  3. */
  4. //usage:#define bbconfig_trivial_usage
  5. //usage: ""
  6. //usage:#define bbconfig_full_usage "\n\n"
  7. //usage: "Print the config file used by busybox build"
  8. #include "libbb.h"
  9. #include "bbconfigopts.h"
  10. #if ENABLE_FEATURE_COMPRESS_BBCONFIG
  11. # include "bb_archive.h"
  12. # include "bbconfigopts_bz2.h"
  13. #endif
  14. int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  15. int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
  16. {
  17. #if ENABLE_FEATURE_COMPRESS_BBCONFIG
  18. bunzip_data *bd;
  19. int i = start_bunzip(&bd,
  20. /* src_fd: */ -1,
  21. /* inbuf: */ bbconfig_config_bz2,
  22. /* len: */ sizeof(bbconfig_config_bz2));
  23. /* read_bunzip can longjmp to start_bunzip, and ultimately
  24. * end up here with i != 0 on read data errors! Not trivial */
  25. if (!i) {
  26. /* Cannot use xmalloc: will leak bd in NOFORK case! */
  27. char *outbuf = malloc_or_warn(sizeof(bbconfig_config));
  28. if (outbuf) {
  29. read_bunzip(bd, outbuf, sizeof(bbconfig_config));
  30. full_write1_str(outbuf);
  31. }
  32. }
  33. #else
  34. full_write1_str(bbconfig_config);
  35. #endif
  36. return 0;
  37. }