libiproute: eliminate unused fields in struct filter_t's; style fixes
[oweals/busybox.git] / applets / usage_pod.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Copyright (C) 2009 Denys Vlasenko.
4  *
5  * Licensed under GPLv2, see file LICENSE in this tarball for details.
6  */
7 #include <unistd.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <stdio.h>
11
12 /* Just #include "autoconf.h" doesn't work for builds in separate
13  * object directory */
14 #include "autoconf.h"
15
16 #define SKIP_applet_main
17 #define ALIGN1 /* nothing, just to placate applet_tables.h */
18 #define ALIGN2 /* nothing, just to placate applet_tables.h */
19 #include "applet_tables.h"
20
21 /* Since we can't use platform.h, have to do this again by hand: */
22 #if ENABLE_NOMMU
23 # define BB_MMU 0
24 # define USE_FOR_NOMMU(...) __VA_ARGS__
25 # define USE_FOR_MMU(...)
26 #else
27 # define BB_MMU 1
28 # define USE_FOR_NOMMU(...)
29 # define USE_FOR_MMU(...) __VA_ARGS__
30 #endif
31
32 static const char usage_messages[] = ""
33 #define MAKE_USAGE
34 #include "usage.h"
35 #include "applets.h"
36 ;
37
38 int main(void)
39 {
40         const char *names;
41         const char *usage;
42         int col, len2;
43
44         col = 0;
45         names = applet_names;
46         while (*names) {
47                 len2 = strlen(names) + 2;
48                 if (col >= 76 - len2) {
49                         printf(",\n");
50                         col = 0;
51                 }
52                 if (col == 0) {
53                         col = 6;
54                         printf("\t");
55                 } else {
56                         printf(", ");
57                 }
58                 printf(names);
59                 col += len2;
60                 names += len2 - 1;
61         }
62         printf("\n\n");
63
64         printf("=head1 COMMAND DESCRIPTIONS\n\n");
65         printf("=over 4\n\n");
66
67         names = applet_names;
68         usage = usage_messages;
69         while (*names) {
70                 if (*names >= 'a' && *names <= 'z'
71                  && *usage != NOUSAGE_STR[0]
72                 ) {
73                         printf("=item B<%s>\n\n", names);
74                         if (*usage)
75                                 printf("%s %s\n\n", names, usage);
76                         else
77                                 printf("%s\n\n", names);
78                 }
79                 names += strlen(names) + 1;
80                 usage += strlen(usage) + 1;
81         }
82         return 0;
83 }
84
85 /* TODO: we used to make options bold with B<> and output an example too:
86
87 =item B<cat>
88
89 cat [B<-u>] [FILE]...
90
91 Concatenate FILE(s) and print them to stdout
92
93 Options:
94         -u      Use unbuffered i/o (ignored)
95
96 Example:
97         $ cat /proc/uptime
98         110716.72 17.67
99
100 */