summaryrefslogtreecommitdiff
path: root/tools/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/tools.h')
-rw-r--r--tools/tools.h56
1 files changed, 33 insertions, 23 deletions
diff --git a/tools/tools.h b/tools/tools.h
index f6d224fb1..4ef94e1ed 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -50,20 +50,27 @@
#define CMD_LEN 256
#define MAX_ARGS 64
-/* command functions */
-typedef int (*command_fn) (struct cmd_context * cmd, int argc, char **argv);
-
-#define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
-#include "commands.h"
-#undef xx
+/* define the enums for the values accepted by command line --options */
+enum {
+#define val(a, b, c, d) a ,
+#include "vals.h"
+#undef val
+};
-/* define the enums for the command line switches */
+/* define the enums for the command line --options */
enum {
#define arg(a, b, c, d, e, f) a ,
#include "args.h"
#undef arg
};
+/* command functions */
+#define xx(a, b...) int a(struct cmd_context *cmd, int argc, char **argv);
+#include "commands.h"
+#undef xx
+
+#include "command.h"
+
#define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */
#define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */
@@ -79,13 +86,13 @@ struct arg_values {
/* void *ptr; // Currently not used. */
};
-/* a global table of possible arguments */
+/* a global table of possible --option's */
struct arg_props {
+ int arg_enum; /* foo_ARG from args.h */
const char short_arg;
char _padding[7];
const char *long_arg;
-
- int (*fn) (struct cmd_context *cmd, struct arg_values *av);
+ int val_enum; /* foo_VAL from vals.h */
uint32_t flags;
uint32_t prio;
};
@@ -96,6 +103,14 @@ struct arg_value_group_list {
uint32_t prio;
};
+/* a global table of possible --option values */
+struct val_props {
+ int val_enum; /* foo_VAL from vals.h */
+ int (*fn) (struct cmd_context *cmd, struct arg_values *av);
+ const char *name;
+ const char *usage;
+};
+
#define CACHE_VGMETADATA 0x00000001
#define PERMITTED_READ_ONLY 0x00000002
/* Process all VGs if none specified on the command line. */
@@ -118,19 +133,6 @@ struct arg_value_group_list {
#define ENABLE_DUPLICATE_DEVS 0x00000400
/* Command does not accept tags as args. */
#define DISALLOW_TAG_ARGS 0x00000800
-
-/* a register of the lvm commands */
-struct command {
- const char *name;
- const char *desc;
- const char *usage;
- command_fn fn;
-
- unsigned flags;
-
- int num_args;
- int *valid_args;
-};
void usage(const char *name);
@@ -157,7 +159,15 @@ int segtype_arg(struct cmd_context *cmd, struct arg_values *av);
int alloc_arg(struct cmd_context *cmd, struct arg_values *av);
int locktype_arg(struct cmd_context *cmd, struct arg_values *av);
int readahead_arg(struct cmd_context *cmd, struct arg_values *av);
+int vgmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int pvmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
int metadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int polloperation_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int writemostly_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int syncaction_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int reportformat_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int configreport_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
+int configtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
/* we use the enums to access the switches */
unsigned arg_count(const struct cmd_context *cmd, int a);