Introduce run_select_query().
authorAndre Noll <maan@systemlinux.org>
Mon, 23 Jun 2008 12:47:22 +0000 (14:47 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 23 Jun 2008 12:47:22 +0000 (14:47 +0200)
This is just the part of com_select() that will be called from
the run command of interactive.c.

adu.h
select.c

diff --git a/adu.h b/adu.h
index 60966921219462236bb6109da2172c60590ced6d..2a15457b4b335bda8d28f219c8f100acfc6c5740 100644 (file)
--- a/adu.h
+++ b/adu.h
@@ -194,6 +194,7 @@ int for_each_admissible_user(int (*func)(struct user_info *, void *),
 void sort_hash_table(int (*comp)(const void *, const void *));
 
 /* select.c */
 void sort_hash_table(int (*comp)(const void *, const void *));
 
 /* select.c */
+int run_select_query(struct uid_range *admissible_uids);
 int com_select(void);
 
 /* create.h */
 int com_select(void);
 
 /* create.h */
index e3d97b11ef7893f09ba89008aa1994b30318fc39..4795de453adc095bdd0bf80134c5d4478dc40343 100644 (file)
--- a/select.c
+++ b/select.c
@@ -584,27 +584,9 @@ out:
        return ret;
 }
 
        return ret;
 }
 
-int com_select(void)
+int run_select_query(struct uid_range *admissible_uids)
 {
        int ret;
 {
        int ret;
-       struct uid_range *admissible_uids = NULL;
-
-       if (conf.select_options_given) {
-               struct select_cmdline_parser_params params = {
-                       .override = 1,
-                       .initialize = 1,
-                       .check_required = 1,
-                       .check_ambiguity = 1,
-                       .print_errors = 1
-               };
-
-               if (select_cmdline_parser_string_ext(conf.select_options_arg,
-                       &select_conf, "select", &params))
-                       return -E_SYNTAX;
-               ret = parse_uid_arg(select_conf.uid_arg, &admissible_uids);
-               if (ret < 0)
-                       return ret;
-       }
 
        if (select_conf.count_unit_arg != count_unit_arg_h)
                count_unit_buf[1] = count_unit_abbrevs[select_conf.count_unit_arg];
 
        if (select_conf.count_unit_arg != count_unit_arg_h)
                count_unit_buf[1] = count_unit_abbrevs[select_conf.count_unit_arg];
@@ -627,3 +609,27 @@ int com_select(void)
        close_all_tables();
        return ret;
 }
        close_all_tables();
        return ret;
 }
+
+int com_select(void)
+{
+       int ret;
+       struct uid_range *admissible_uids = NULL;
+
+       if (conf.select_options_given) {
+               struct select_cmdline_parser_params params = {
+                       .override = 1,
+                       .initialize = 1,
+                       .check_required = 1,
+                       .check_ambiguity = 1,
+                       .print_errors = 1
+               };
+
+               if (select_cmdline_parser_string_ext(conf.select_options_arg,
+                       &select_conf, "select", &params))
+                       return -E_SYNTAX;
+               ret = parse_uid_arg(select_conf.uid_arg, &admissible_uids);
+               if (ret < 0)
+                       return ret;
+       }
+       return run_select_query(admissible_uids);
+}