]> git.tuebingen.mpg.de Git - adu.git/blobdiff - select.c
Make --uid take a comma-separated list of uids and move it to select.ggo.
[adu.git] / select.c
index 4c2f12cbc7ab7e6f7f69bfbd7809daf866f4959a..ab958461da82e2d2e50fa582b2d37c3a3b656b76 100644 (file)
--- a/select.c
+++ b/select.c
@@ -14,6 +14,7 @@
 #include "string.h"
 #include "error.h"
 #include "portable_io.h"
+#include "select.cmdline.h"
 
 /** Global dir count. */
 static uint64_t num_dirs;
@@ -76,6 +77,8 @@ static const uint64_t count_unit_divisors[] = {
 
 static const char size_unit_abbrevs[] = " BKMGT";
 static const char count_unit_abbrevs[] = "  kmgt";
+struct select_args_info select_conf;
+static struct uid_range *admissible_uids;
 
 static enum enum_size_unit format_size_value(enum enum_size_unit unit,
                uint64_t value, int print_unit, char *result)
@@ -575,7 +578,7 @@ static int read_uid_file(void)
        create_hash_table(bits);
        for (n = 0; n < num_uids; n++) {
                uint32_t uid = read_u32(map + n * sizeof(uid));
-               ret = search_uid(uid, OPEN_USER_TABLE, NULL);
+               ret = search_uid(uid, admissible_uids, OPEN_USER_TABLE, NULL);
                if (ret < 0)
                        goto out;
        }
@@ -587,6 +590,22 @@ out:
 int com_select(void)
 {
        int ret;
+       struct select_cmdline_parser_params params = {
+               .override = 1,
+               .initialize = 1,
+               .check_required = 1,
+               .check_ambiguity = 1,
+               .print_errors = 1
+       };
+
+       if (conf.select_options_given) {
+               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 (conf.count_unit_arg != count_unit_arg_h)
                count_unit_buf[1] = count_unit_abbrevs[conf.count_unit_arg];