usage_pod.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2009 Denys Vlasenko.
  4. *
  5. * Licensed under GPLv2, see file LICENSE in this tarball for details.
  6. */
  7. #include <unistd.h>
  8. #include <stdint.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11. /* Just #include "autoconf.h" doesn't work for builds in separate
  12. * object directory */
  13. #include "autoconf.h"
  14. #define SKIP_applet_main
  15. #define ALIGN1 /* nothing, just to placate applet_tables.h */
  16. #define ALIGN2 /* nothing, just to placate applet_tables.h */
  17. #include "applet_tables.h"
  18. /* Since we can't use platform.h, have to do this again by hand: */
  19. #if ENABLE_NOMMU
  20. # define BB_MMU 0
  21. # define USE_FOR_NOMMU(...) __VA_ARGS__
  22. # define USE_FOR_MMU(...)
  23. #else
  24. # define BB_MMU 1
  25. # define USE_FOR_NOMMU(...)
  26. # define USE_FOR_MMU(...) __VA_ARGS__
  27. #endif
  28. static const char usage_messages[] = ""
  29. #define MAKE_USAGE
  30. #include "usage.h"
  31. #include "applets.h"
  32. ;
  33. int main(void)
  34. {
  35. const char *names;
  36. const char *usage;
  37. int col, len2;
  38. col = 0;
  39. names = applet_names;
  40. while (*names) {
  41. len2 = strlen(names) + 2;
  42. if (col >= 76 - len2) {
  43. printf(",\n");
  44. col = 0;
  45. }
  46. if (col == 0) {
  47. col = 6;
  48. printf("\t");
  49. } else {
  50. printf(", ");
  51. }
  52. printf(names);
  53. col += len2;
  54. names += len2 - 1;
  55. }
  56. printf("\n\n");
  57. printf("=head1 COMMAND DESCRIPTIONS\n\n");
  58. printf("=over 4\n\n");
  59. names = applet_names;
  60. usage = usage_messages;
  61. while (*names) {
  62. if (*names >= 'a' && *names <= 'z'
  63. && *usage != NOUSAGE_STR[0]
  64. ) {
  65. printf("=item B<%s>\n\n", names);
  66. if (*usage)
  67. printf("%s %s\n\n", names, usage);
  68. else
  69. printf("%s\n\n", names);
  70. }
  71. names += strlen(names) + 1;
  72. usage += strlen(usage) + 1;
  73. }
  74. return 0;
  75. }
  76. /* TODO: we used to make options bold with B<> and output an example too:
  77. =item B<cat>
  78. cat [B<-u>] [FILE]...
  79. Concatenate FILE(s) and print them to stdout
  80. Options:
  81. -u Use unbuffered i/o (ignored)
  82. Example:
  83. $ cat /proc/uptime
  84. 110716.72 17.67
  85. */