aboutsummaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
Diffstat (limited to 'applets')
-rw-r--r--applets/Kbuild.src (renamed from applets/Kbuild)6
-rw-r--r--applets/usage.c33
-rwxr-xr-xapplets/usage_compressed22
-rw-r--r--applets/usage_pod.c57
4 files changed, 78 insertions, 40 deletions
diff --git a/applets/Kbuild b/applets/Kbuild.src
index a6b0cf6fb..e3bac9681 100644
--- a/applets/Kbuild
+++ b/applets/Kbuild.src
@@ -27,9 +27,9 @@ HOSTCFLAGS_usage_pod.o = -I$(srctree_slash)include -Iinclude
27 27
28applets/applets.o: include/usage_compressed.h include/applet_tables.h 28applets/applets.o: include/usage_compressed.h include/applet_tables.h
29 29
30applets/applet_tables: .config $(srctree_slash)include/applets.h 30applets/applet_tables: .config include/applets.h
31applets/usage: .config $(srctree_slash)include/applets.h 31applets/usage: .config include/applets.h
32applets/usage_pod: .config include/applet_tables.h $(srctree_slash)include/applets.h 32applets/usage_pod: .config include/applet_tables.h include/applets.h
33 33
34quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h 34quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
35 cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets 35 cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
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}
diff --git a/applets/usage_compressed b/applets/usage_compressed
index 8d343529d..bfd5aa873 100755
--- a/applets/usage_compressed
+++ b/applets/usage_compressed
@@ -9,12 +9,19 @@ test -x "$loc/usage" || exit 1
9test "$SED" || SED=sed 9test "$SED" || SED=sed
10test "$DD" || DD=dd 10test "$DD" || DD=dd
11 11
12sz=`"$loc/usage" | wc -c` || exit 1
13
14exec >"$target" 12exec >"$target"
15 13
16echo 'static const char packed_usage[] ALIGN1 = {' 14echo '#define UNPACKED_USAGE "" \'
15"$loc/usage" | od -v -t x1 \
16| $SED -e 's/^[^ ]*//' \
17 -e 's/ //g' \
18 -e '/^$/d' \
19 -e 's/\(..\)/\\x\1/g' \
20 -e 's/^/"/' \
21 -e 's/$/" \\/'
22echo ''
17 23
24echo '#define PACKED_USAGE \'
18## Breaks on big-endian systems! 25## Breaks on big-endian systems!
19## # Extra effort to avoid using "od -t x1": -t is not available 26## # Extra effort to avoid using "od -t x1": -t is not available
20## # in non-CONFIG_DESKTOPed busybox od 27## # in non-CONFIG_DESKTOPed busybox od
@@ -24,12 +31,11 @@ echo 'static const char packed_usage[] ALIGN1 = {'
24## -e 's/ //g' \ 31## -e 's/ //g' \
25## -e '/^$/d' \ 32## -e '/^$/d' \
26## -e 's/\(..\)\(..\)/0x\2,0x\1,/g' 33## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
27 34## -e 's/$/ \\/'
28"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \ 35"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
29| $SED -e 's/^[^ ]*//' \ 36| $SED -e 's/^[^ ]*//' \
30 -e 's/ //g' \ 37 -e 's/ //g' \
31 -e '/^$/d' \ 38 -e '/^$/d' \
32 -e 's/\(..\)/0x\1,/g' 39 -e 's/\(..\)/0x\1,/g' \
33 40 -e 's/$/ \\/'
34echo '};' 41echo ''
35echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
diff --git a/applets/usage_pod.c b/applets/usage_pod.c
index ee3729d7b..85a2a8ec4 100644
--- a/applets/usage_pod.c
+++ b/applets/usage_pod.c
@@ -6,11 +6,10 @@
6 */ 6 */
7#include <unistd.h> 7#include <unistd.h>
8#include <stdint.h> 8#include <stdint.h>
9#include <stdlib.h>
9#include <string.h> 10#include <string.h>
10#include <stdio.h> 11#include <stdio.h>
11 12
12/* Just #include "autoconf.h" doesn't work for builds in separate
13 * object directory */
14#include "autoconf.h" 13#include "autoconf.h"
15 14
16#define SKIP_applet_main 15#define SKIP_applet_main
@@ -29,22 +28,39 @@
29# define USE_FOR_MMU(...) __VA_ARGS__ 28# define USE_FOR_MMU(...) __VA_ARGS__
30#endif 29#endif
31 30
32static const char usage_messages[] = ""
33#define MAKE_USAGE
34#include "usage.h" 31#include "usage.h"
32#define MAKE_USAGE(aname, usage) { aname, usage },
33static struct usage_data {
34 const char *aname;
35 const char *usage;
36} usage_array[] = {
35#include "applets.h" 37#include "applets.h"
36; 38};
39
40static 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}
37 46
38int main(void) 47int main(void)
39{ 48{
40 const char *names;
41 const char *usage;
42 int col, len2; 49 int col, len2;
43 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
44 col = 0; 61 col = 0;
45 names = applet_names; 62 for (i = 0; i < num_messages; i++) {
46 while (*names) { 63 len2 = strlen(usage_array[i].aname) + 2;
47 len2 = strlen(names) + 2;
48 if (col >= 76 - len2) { 64 if (col >= 76 - len2) {
49 printf(",\n"); 65 printf(",\n");
50 col = 0; 66 col = 0;
@@ -55,29 +71,24 @@ int main(void)
55 } else { 71 } else {
56 printf(", "); 72 printf(", ");
57 } 73 }
58 printf(names); 74 printf(usage_array[i].aname);
59 col += len2; 75 col += len2;
60 names += len2 - 1;
61 } 76 }
62 printf("\n\n"); 77 printf("\n\n");
63 78
64 printf("=head1 COMMAND DESCRIPTIONS\n\n"); 79 printf("=head1 COMMAND DESCRIPTIONS\n\n");
65 printf("=over 4\n\n"); 80 printf("=over 4\n\n");
66 81
67 names = applet_names; 82 for (i = 0; i < num_messages; i++) {
68 usage = usage_messages; 83 if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z'
69 while (*names) { 84 && usage_array[i].usage[0] != NOUSAGE_STR[0]
70 if (*names >= 'a' && *names <= 'z'
71 && *usage != NOUSAGE_STR[0]
72 ) { 85 ) {
73 printf("=item B<%s>\n\n", names); 86 printf("=item B<%s>\n\n", usage_array[i].aname);
74 if (*usage) 87 if (usage_array[i].usage[0])
75 printf("%s %s\n\n", names, usage); 88 printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage);
76 else 89 else
77 printf("%s\n\n", names); 90 printf("%s\n\n", usage_array[i].aname);
78 } 91 }
79 names += strlen(names) + 1;
80 usage += strlen(usage) + 1;
81 } 92 }
82 return 0; 93 return 0;
83} 94}