6 |
*/ |
*/ |
7 |
#include <unistd.h> |
#include <unistd.h> |
8 |
#include <stdint.h> |
#include <stdint.h> |
9 |
|
#include <stdlib.h> |
10 |
#include <string.h> |
#include <string.h> |
11 |
#include <stdio.h> |
#include <stdio.h> |
12 |
|
|
|
/* Just #include "autoconf.h" doesn't work for builds in separate |
|
|
* object directory */ |
|
13 |
#include "autoconf.h" |
#include "autoconf.h" |
14 |
|
|
15 |
#define SKIP_applet_main |
#define SKIP_applet_main |
28 |
# define USE_FOR_MMU(...) __VA_ARGS__ |
# define USE_FOR_MMU(...) __VA_ARGS__ |
29 |
#endif |
#endif |
30 |
|
|
|
static const char usage_messages[] = "" |
|
|
#define MAKE_USAGE |
|
31 |
#include "usage.h" |
#include "usage.h" |
32 |
|
#define MAKE_USAGE(aname, usage) { aname, usage }, |
33 |
|
static struct usage_data { |
34 |
|
const char *aname; |
35 |
|
const char *usage; |
36 |
|
} usage_array[] = { |
37 |
#include "applets.h" |
#include "applets.h" |
38 |
; |
}; |
39 |
|
|
40 |
|
static int compare_func(const void *a, const void *b) |
41 |
|
{ |
42 |
|
const struct usage_data *ua = a; |
43 |
|
const struct usage_data *ub = b; |
44 |
|
return strcmp(ua->aname, ub->aname); |
45 |
|
} |
46 |
|
|
47 |
int main(void) |
int main(void) |
48 |
{ |
{ |
|
const char *names; |
|
|
const char *usage; |
|
49 |
int col, len2; |
int col, len2; |
50 |
|
|
51 |
|
int i; |
52 |
|
int num_messages = sizeof(usage_array) / sizeof(usage_array[0]); |
53 |
|
|
54 |
|
if (num_messages == 0) |
55 |
|
return 0; |
56 |
|
|
57 |
|
qsort(usage_array, |
58 |
|
num_messages, sizeof(usage_array[0]), |
59 |
|
compare_func); |
60 |
|
|
61 |
col = 0; |
col = 0; |
62 |
names = applet_names; |
for (i = 0; i < num_messages; i++) { |
63 |
while (*names) { |
len2 = strlen(usage_array[i].aname) + 2; |
|
len2 = strlen(names) + 2; |
|
64 |
if (col >= 76 - len2) { |
if (col >= 76 - len2) { |
65 |
printf(",\n"); |
printf(",\n"); |
66 |
col = 0; |
col = 0; |
71 |
} else { |
} else { |
72 |
printf(", "); |
printf(", "); |
73 |
} |
} |
74 |
printf(names); |
printf(usage_array[i].aname); |
75 |
col += len2; |
col += len2; |
|
names += len2 - 1; |
|
76 |
} |
} |
77 |
printf("\n\n"); |
printf("\n\n"); |
78 |
|
|
79 |
printf("=head1 COMMAND DESCRIPTIONS\n\n"); |
printf("=head1 COMMAND DESCRIPTIONS\n\n"); |
80 |
printf("=over 4\n\n"); |
printf("=over 4\n\n"); |
81 |
|
|
82 |
names = applet_names; |
for (i = 0; i < num_messages; i++) { |
83 |
usage = usage_messages; |
if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z' |
84 |
while (*names) { |
&& usage_array[i].usage[0] != NOUSAGE_STR[0] |
|
if (*names >= 'a' && *names <= 'z' |
|
|
&& *usage != NOUSAGE_STR[0] |
|
85 |
) { |
) { |
86 |
printf("=item B<%s>\n\n", names); |
printf("=item B<%s>\n\n", usage_array[i].aname); |
87 |
if (*usage) |
if (usage_array[i].usage[0]) |
88 |
printf("%s %s\n\n", names, usage); |
printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage); |
89 |
else |
else |
90 |
printf("%s\n\n", names); |
printf("%s\n\n", usage_array[i].aname); |
91 |
} |
} |
|
names += strlen(names) + 1; |
|
|
usage += strlen(usage) + 1; |
|
92 |
} |
} |
93 |
return 0; |
return 0; |
94 |
} |
} |