3
0

usage.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2008 Denys Vlasenko.
  4. *
  5. * Licensed under GPLv2, see file LICENSE in this source tree.
  6. */
  7. #include <unistd.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "autoconf.h"
  11. /* Since we can't use platform.h, have to do this again by hand: */
  12. #if ENABLE_NOMMU
  13. # define BB_MMU 0
  14. # define USE_FOR_NOMMU(...) __VA_ARGS__
  15. # define USE_FOR_MMU(...)
  16. #else
  17. # define BB_MMU 1
  18. # define USE_FOR_NOMMU(...)
  19. # define USE_FOR_MMU(...) __VA_ARGS__
  20. #endif
  21. #include "usage.h"
  22. #define MAKE_USAGE(aname, usage) { aname, usage },
  23. static struct usage_data {
  24. const char *aname;
  25. const char *usage;
  26. } usage_array[] = {
  27. #include "applets.h"
  28. };
  29. static int compare_func(const void *a, const void *b)
  30. {
  31. const struct usage_data *ua = a;
  32. const struct usage_data *ub = b;
  33. return strcmp(ua->aname, ub->aname);
  34. }
  35. int main(void)
  36. {
  37. int i;
  38. int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
  39. if (num_messages == 0)
  40. return 0;
  41. qsort(usage_array,
  42. num_messages, sizeof(usage_array[0]),
  43. compare_func);
  44. for (i = 0; i < num_messages; i++)
  45. write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
  46. return 0;
  47. }