]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/edit.c
Apply win32 fixes + add tapetest.c
[bacula/bacula] / bacula / src / lib / edit.c
index 7d490c04577be860b32b0d8f24719195cae69e5c..11a2e329247165701563ced33ba34a8d4ff16e79 100644 (file)
@@ -262,9 +262,16 @@ int size_to_uint64(char *str, int str_len, uint64_t *rtn_value)
    if (errno != 0 || value < 0) {
       return 0;
    }
+#if defined(HAVE_WIN32)
+   /* work around microsofts non handling of uint64 to double cvt*/
+   *rtn_value = (uint64_t)(value * (__int64)mult[i]);
+   Dmsg2(400, "Full value = %lf %" lld "\n", value * (__int64)mult[i],  
+        (uint64_t)(value * (__int64)mult[i]));
+#else
    *rtn_value = (uint64_t)(value * mult[i]);
    Dmsg2(400, "Full value = %lf %" lld "\n", value * mult[i],  
       (uint64_t)(value * mult[i]));
+#endif
    return 1;
 }
 
@@ -308,6 +315,48 @@ int is_an_integer(const char *n)
    return digit_seen && *n==0;
 }
 
+/*
+ * Check if Bacula Resoure Name is valid
+ */
+/* 
+ * Check if the Volume name has legal characters
+ * If ua is non-NULL send the message
+ */
+bool is_name_valid(char *name, POOLMEM **msg)
+{
+   int len;
+   char *p;
+   /* Special characters to accept */
+   const char *accept = ":.-_ ";
+
+   /* Restrict the characters permitted in the Volume name */
+   for (p=name; *p; p++) {
+      if (B_ISALPHA(*p) || B_ISDIGIT(*p) || strchr(accept, (int)(*p))) {
+        continue;
+      }
+      if (msg) {
+         Mmsg(msg, _("Illegal character \"%c\" in name.\n"), *p);
+      }
+      return false;
+   }
+   len = strlen(name);
+   if (len >= MAX_NAME_LENGTH) {
+      if (msg) {
+         Mmsg(msg, _("Name too long.\n"));
+      }
+      return false;
+   }
+   if (len == 0) {
+      if (msg) {
+         Mmsg(msg,  _("Volume name must be at least one character long.\n"));
+      }
+      return false;
+   }
+   return true;
+}
+
+
+
 /*
  * Add commas to a string, which is presumably
  * a number.