(parse_opt): Rewrite parsing of -i parameter value using table.
authordrepper <drepper>
Sun, 14 Jan 2007 05:23:52 +0000 (05:23 +0000)
committerdrepper <drepper>
Sun, 14 Jan 2007 05:23:52 +0000 (05:23 +0000)
nscd/nscd.c

index b68ae2f..d0c34eb 100644 (file)
@@ -332,15 +332,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
            exit (EXIT_FAILURE);
 
          request_header req;
            exit (EXIT_FAILURE);
 
          request_header req;
-         if (strcmp (arg, "passwd") == 0)
-           req.key_len = sizeof "passwd";
-         else if (strcmp (arg, "group") == 0)
-           req.key_len = sizeof "group";
-         else if (strcmp (arg, "hosts") == 0)
-           req.key_len = sizeof "hosts";
-         else
+         dbtype cnt;
+         for (cnt = pwddb; cnt < lastdb; ++cnt)
+           if (strcmp (arg, dbnames[cnt]) == 0)
+             break;
+
+         if (cnt == lastdb)
            return ARGP_ERR_UNKNOWN;
 
            return ARGP_ERR_UNKNOWN;
 
+         req.key_len = strlen (arg) + 1;
          req.version = NSCD_VERSION;
          req.type = INVALIDATE;
 
          req.version = NSCD_VERSION;
          req.type = INVALIDATE;