]> sourceware.org Git - lvm2.git/commitdiff
Move arg_* functions from toollib.c to lvmcmdline.c.
authorDave Wysochanski <dwysocha@redhat.com>
Wed, 17 Dec 2008 16:45:32 +0000 (16:45 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Wed, 17 Dec 2008 16:45:32 +0000 (16:45 +0000)
In preparation for removing cmd->args.
IMO, it makes more sense to put these accessor functions
in the same location as the static array _the_args.
Next patch will update arg_* functions to use _the_args[]
directly and remove cmd->args.

tools/lvmcmdline.c
tools/toollib.c

index e1e98261df2f6bc5bf71eec809b59834803f2584..45191f7c380fbb065ab7c248abf4d19eb0fced8e 100644 (file)
@@ -53,6 +53,62 @@ static struct arg _the_args[ARG_COUNT + 1] = {
 
 static struct cmdline_context _cmdline;
 
+/* Command line args */
+unsigned arg_count(const struct cmd_context *cmd, int a)
+{
+       return cmd->args[a].count;
+}
+
+const char *arg_value(struct cmd_context *cmd, int a)
+{
+       return cmd->args[a].value;
+}
+
+const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].value : def;
+}
+
+int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].i_value : def;
+}
+
+uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
+}
+
+int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
+}
+
+uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
+}
+
+const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].ptr : def;
+}
+
+sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].sign : def;
+}
+
+percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
+{
+       return arg_count(cmd, a) ? cmd->args[a].percent : def;
+}
+
+int arg_count_increment(struct cmd_context *cmd, int a)
+{
+       return cmd->args[a].count++;
+}
+
 int yes_no_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
 {
        a->sign = SIGN_NONE;
index ef4ee0e868ee5490add7e741ef8574f0d48aed57..511a93fb1c637e980e0b70b03e9a1cfcf76b011d 100644 (file)
 #include <sys/stat.h>
 #include <sys/wait.h>
 
-/* Command line args */
-unsigned arg_count(const struct cmd_context *cmd, int a)
-{
-       return cmd->args[a].count;
-}
-
-const char *arg_value(struct cmd_context *cmd, int a)
-{
-       return cmd->args[a].value;
-}
-
-const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].value : def;
-}
-
-int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].i_value : def;
-}
-
-uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
-}
-
-int64_t arg_int64_value(struct cmd_context *cmd, int a, const int64_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
-}
-
-uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
-}
-
-const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].ptr : def;
-}
-
-sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].sign : def;
-}
-
-percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
-{
-       return arg_count(cmd, a) ? cmd->args[a].percent : def;
-}
-
-int arg_count_increment(struct cmd_context *cmd, int a)
-{
-       return cmd->args[a].count++;
-}
-
 const char *command_name(struct cmd_context *cmd)
 {
        return cmd->command->name;
This page took 0.039989 seconds and 5 git commands to generate.