]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_input.c
kes Update copyright date in program files, and for the most part
[bacula/bacula] / bacula / src / dird / ua_input.c
index e4ecafd2a9aa544a338c58e353fd661ad35f3282..9472af92713d14bb89de706b94d1b2626e1ec4bf 100644 (file)
@@ -79,17 +79,17 @@ bool get_pint(UAContext *ua, const char *prompt)
          return false;
       }
       /* Kludge for slots blank line => 0 */
-      if (ua->cmd[0] == 0 && strncmp(prompt, "Enter slot", 10) == 0) {
+      if (ua->cmd[0] == 0 && strncmp(prompt, _("Enter slot"), strlen(_("Enter slot"))) == 0) {
          return true;
       }
       if (!is_a_number(ua->cmd)) {
-         bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
+         bsendmsg(ua, _("Expected a positive integer, got: %s\n"), ua->cmd);
          continue;
       }
       errno = 0;
       dval = strtod(ua->cmd, NULL);
       if (errno != 0 || dval < 0) {
-         bsendmsg(ua, "Expected a positive integer, got: %s\n", ua->cmd);
+         bsendmsg(ua, _("Expected a positive integer, got: %s\n"), ua->cmd);
          continue;
       }
       ua->pint32_val = (uint32_t)dval;
@@ -98,6 +98,30 @@ bool get_pint(UAContext *ua, const char *prompt)
    }
 }
 
+/*
+ * Test a yes or no response
+ *  Returns:  false if failure
+ *            true  if success => ret == 1 for yes
+ *                                ret == 0 for no
+ */
+bool is_yesno(char *val, int *ret)
+{
+   *ret = 0;
+   if ((strcasecmp(val,   _("yes")) == 0) ||
+       (strcasecmp(val, NT_("yes")) == 0))
+   {
+      *ret = 1;
+   } else if ((strcasecmp(val,   _("no")) == 0) ||
+              (strcasecmp(val, NT_("no")) == 0))
+   {
+      *ret = 0;
+   } else {
+      return false;
+   }
+
+   return true;
+}
+
 /*
  * Gets a yes or no response
  *  Returns:  false if failure
@@ -107,7 +131,7 @@ bool get_pint(UAContext *ua, const char *prompt)
 bool get_yesno(UAContext *ua, const char *prompt)
 {
    int len;
-
+   int ret;
    ua->pint32_val = 0;
    for (;;) {
       if (!get_cmd(ua, prompt)) {
@@ -117,18 +141,14 @@ bool get_yesno(UAContext *ua, const char *prompt)
       if (len < 1 || len > 3) {
          continue;
       }
-      if (strncasecmp(ua->cmd, _("yes"), len) == 0) {
-         ua->pint32_val = 1;
-         return true;
-      }
-      if (strncasecmp(ua->cmd, _("no"), len) == 0) {
+      if (is_yesno(ua->cmd, &ret)) {
+         ua->pint32_val = ret;
          return true;
       }
       bsendmsg(ua, _("Invalid response. You must answer yes or no.\n"));
    }
 }
 
-
 void parse_ua_args(UAContext *ua)
 {
    parse_args(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS);