blob: 94520ff66fa581e94e48e8fc2c77836e61b425f4 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Denis Vlasenkodb12d1d2008-12-07 00:52:58 +00002/*
3 * Copyright (C) 2008 Denys Vlasenko.
4 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenkodb12d1d2008-12-07 00:52:58 +00006 */
Rob Landley7e21d5f2006-04-27 23:34:46 +00007#include <unistd.h>
Denys Vlasenko0e5ba082010-06-05 23:11:07 +02008#include <stdlib.h>
9#include <string.h>
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000010
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +020011#include "autoconf.h"
Rob Landley7e21d5f2006-04-27 23:34:46 +000012
Denis Vlasenko21765fa2008-06-13 20:44:05 +000013/* Since we can't use platform.h, have to do this again by hand: */
14#if ENABLE_NOMMU
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +020015# define BB_MMU 0
16# define USE_FOR_NOMMU(...) __VA_ARGS__
17# define USE_FOR_MMU(...)
Denis Vlasenko21765fa2008-06-13 20:44:05 +000018#else
Denys Vlasenkoacabf8f2009-10-02 01:10:32 +020019# define BB_MMU 1
20# define USE_FOR_NOMMU(...)
21# define USE_FOR_MMU(...) __VA_ARGS__
Denis Vlasenko21765fa2008-06-13 20:44:05 +000022#endif
23
Denis Vlasenkofdc10172006-10-19 22:10:07 +000024#include "usage.h"
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020025#define MAKE_USAGE(aname, usage) { aname, usage },
26static struct usage_data {
27 const char *aname;
28 const char *usage;
29} usage_array[] = {
Denis Vlasenkofdc10172006-10-19 22:10:07 +000030#include "applets.h"
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020031};
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}
Rob Landley7e21d5f2006-04-27 23:34:46 +000039
40int main(void)
41{
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020042 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
Rob Landley7e21d5f2006-04-27 23:34:46 +000054 return 0;
55}