aboutsummaryrefslogtreecommitdiff
path: root/applets/usage.c
diff options
context:
space:
mode:
Diffstat (limited to 'applets/usage.c')
-rw-r--r--applets/usage.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/applets/usage.c b/applets/usage.c
index d4fd12f9b..46adbf475 100644
--- a/applets/usage.c
+++ b/applets/usage.c
@@ -5,9 +5,9 @@
5 * Licensed under GPLv2, see file LICENSE in this tarball for details. 5 * Licensed under GPLv2, see file LICENSE in this tarball for details.
6 */ 6 */
7#include <unistd.h> 7#include <unistd.h>
8#include <stdlib.h>
9#include <string.h>
8 10
9/* Just #include "autoconf.h" doesn't work for builds in separate
10 * object directory */
11#include "autoconf.h" 11#include "autoconf.h"
12 12
13/* Since we can't use platform.h, have to do this again by hand: */ 13/* Since we can't use platform.h, have to do this again by hand: */
@@ -21,14 +21,35 @@
21# define USE_FOR_MMU(...) __VA_ARGS__ 21# define USE_FOR_MMU(...) __VA_ARGS__
22#endif 22#endif
23 23
24static const char usage_messages[] = ""
25#define MAKE_USAGE
26#include "usage.h" 24#include "usage.h"
25#define MAKE_USAGE(aname, usage) { aname, usage },
26static struct usage_data {
27 const char *aname;
28 const char *usage;
29} usage_array[] = {
27#include "applets.h" 30#include "applets.h"
28; 31};
32
33static int compare_func(const void *a, const void *b)
34{
35 const struct usage_data *ua = a;
36 const struct usage_data *ub = b;
37 return strcmp(ua->aname, ub->aname);
38}
29 39
30int main(void) 40int main(void)
31{ 41{
32 write(STDOUT_FILENO, usage_messages, sizeof(usage_messages)); 42 int i;
43 int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
44
45 if (num_messages == 0)
46 return 0;
47
48 qsort(usage_array,
49 num_messages, sizeof(usage_array[0]),
50 compare_func);
51 for (i = 0; i < num_messages; i++)
52 write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
53
33 return 0; 54 return 0;
34} 55}