2009-10-02 04:40:32 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 Denys Vlasenko.
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2009-10-02 04:40:32 +05:30
|
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
2010-06-06 02:41:07 +05:30
|
|
|
#include <stdlib.h>
|
2009-10-02 04:40:32 +05:30
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "autoconf.h"
|
|
|
|
|
|
|
|
#define SKIP_applet_main
|
|
|
|
#define ALIGN1 /* nothing, just to placate applet_tables.h */
|
|
|
|
#define ALIGN2 /* nothing, just to placate applet_tables.h */
|
|
|
|
#include "applet_tables.h"
|
|
|
|
|
|
|
|
/* Since we can't use platform.h, have to do this again by hand: */
|
|
|
|
#if ENABLE_NOMMU
|
|
|
|
# define BB_MMU 0
|
|
|
|
# define USE_FOR_NOMMU(...) __VA_ARGS__
|
|
|
|
# define USE_FOR_MMU(...)
|
|
|
|
#else
|
|
|
|
# define BB_MMU 1
|
|
|
|
# define USE_FOR_NOMMU(...)
|
|
|
|
# define USE_FOR_MMU(...) __VA_ARGS__
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "usage.h"
|
2010-06-06 02:41:07 +05:30
|
|
|
#define MAKE_USAGE(aname, usage) { aname, usage },
|
|
|
|
static struct usage_data {
|
2011-02-03 04:35:48 +05:30
|
|
|
const char *aname;
|
|
|
|
const char *usage;
|
2010-06-06 02:41:07 +05:30
|
|
|
} usage_array[] = {
|
2009-10-02 04:40:32 +05:30
|
|
|
#include "applets.h"
|
2010-06-06 02:41:07 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static int compare_func(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const struct usage_data *ua = a;
|
|
|
|
const struct usage_data *ub = b;
|
|
|
|
return strcmp(ua->aname, ub->aname);
|
|
|
|
}
|
2009-10-02 04:40:32 +05:30
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int col, len2;
|
|
|
|
|
2010-06-06 02:41:07 +05:30
|
|
|
int i;
|
|
|
|
int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
|
|
|
|
|
|
|
|
if (num_messages == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
qsort(usage_array,
|
|
|
|
num_messages, sizeof(usage_array[0]),
|
|
|
|
compare_func);
|
|
|
|
|
2009-10-02 04:40:32 +05:30
|
|
|
col = 0;
|
2010-06-06 02:41:07 +05:30
|
|
|
for (i = 0; i < num_messages; i++) {
|
|
|
|
len2 = strlen(usage_array[i].aname) + 2;
|
2009-10-02 04:40:32 +05:30
|
|
|
if (col >= 76 - len2) {
|
|
|
|
printf(",\n");
|
|
|
|
col = 0;
|
|
|
|
}
|
|
|
|
if (col == 0) {
|
|
|
|
col = 6;
|
|
|
|
printf("\t");
|
|
|
|
} else {
|
|
|
|
printf(", ");
|
|
|
|
}
|
2010-06-06 02:41:07 +05:30
|
|
|
printf(usage_array[i].aname);
|
2009-10-02 04:40:32 +05:30
|
|
|
col += len2;
|
|
|
|
}
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
printf("=head1 COMMAND DESCRIPTIONS\n\n");
|
|
|
|
printf("=over 4\n\n");
|
|
|
|
|
2010-06-06 02:41:07 +05:30
|
|
|
for (i = 0; i < num_messages; i++) {
|
|
|
|
if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z'
|
|
|
|
&& usage_array[i].usage[0] != NOUSAGE_STR[0]
|
2009-10-02 04:40:32 +05:30
|
|
|
) {
|
2010-06-06 02:41:07 +05:30
|
|
|
printf("=item B<%s>\n\n", usage_array[i].aname);
|
|
|
|
if (usage_array[i].usage[0])
|
|
|
|
printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage);
|
2009-10-02 04:51:31 +05:30
|
|
|
else
|
2010-06-06 02:41:07 +05:30
|
|
|
printf("%s\n\n", usage_array[i].aname);
|
2009-10-02 04:40:32 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: we used to make options bold with B<> and output an example too:
|
|
|
|
|
|
|
|
=item B<cat>
|
|
|
|
|
|
|
|
cat [B<-u>] [FILE]...
|
|
|
|
|
|
|
|
Concatenate FILE(s) and print them to stdout
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-u Use unbuffered i/o (ignored)
|
|
|
|
|
|
|
|
Example:
|
|
|
|
$ cat /proc/uptime
|
|
|
|
110716.72 17.67
|
|
|
|
|
|
|
|
*/
|