#ifdef MAN_PAGE_GENERATOR
-struct command_name command_names[MAX_COMMAND_NAMES] = {
+struct command_name command_names[] = {
#define xx(a, b, c...) { # a, b, c },
#include "commands.h"
#undef xx
+ { .name = NULL }
};
struct command commands[COMMAND_COUNT];
#else /* MAN_PAGE_GENERATOR */
-struct command_name command_names[MAX_COMMAND_NAMES] = {
+struct command_name command_names[] = {
#define xx(a, b, c...) { # a, b, c, a},
#include "commands.h"
#undef xx
+ { .name = NULL }
};
extern struct command commands[COMMAND_COUNT]; /* defined in lvmcmdline.c */
if (!islower(name[0]))
return NULL; /* Commands starts with lower-case */
- for (i = 0; i < MAX_COMMAND_NAMES; i++) {
- if (!command_names[i].name)
- break;
+ for (i = 0; command_names[i].name; i++)
if (!strcmp(command_names[i].name, name))
return &command_names[i];
- }
return NULL;
}
int cn, opt_enum, ci, oo, ro, found;
struct command *cmd;
- for (cn = 0; cn < MAX_COMMAND_NAMES; cn++) {
- if (!command_names[cn].name)
- break;
-
+ for (cn = 0; command_names[cn].name; cn++) {
/* already factored */
if (command_names[cn].variants)
continue;
/*
* Table of command names
*/
-extern struct command_name command_names[MAX_COMMAND_NAMES];
+extern struct command_name command_names[];
/*
* Table of commands (as defined in command-lines.in)
static struct command_name *_find_command_name(const char *name)
{
int i;
-
- for (i = 0; i < MAX_COMMAND_NAMES; i++) {
- if (!command_names[i].name)
- break;
+
+ for (i = 0; command_names[i].name; i++)
if (!strcmp(command_names[i].name, name))
return &command_names[i];
- }
+
return NULL;
}
}
}
- _cmdline.command_names = command_names;
- _cmdline.num_command_names = 0;
+ /* Check how many command entries we have */
+ for (i = 0; command_names[i].name; i++)
+ ;
- for (i = 0; i < MAX_COMMAND_NAMES; i++) {
- if (!command_names[i].name)
- break;
- _cmdline.num_command_names++;
- }
+ _cmdline.num_command_names = i;
+ _cmdline.command_names = command_names;
for (i = 0; i < _cmdline.num_command_names; i++)
_set_valid_args_for_command_name(i);
{
int i;
- for (i = 0; i < MAX_COMMAND_NAMES; i++) {
- if (!command_names[i].name)
- break;
+ for (i = 0; command_names[i].name; i++)
_usage(command_names[i].name, 1, 1);
- }
print_usage_notes(NULL);
}