]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/edit.c
Use the command line utility dropdb instead of the psql command
[bacula/bacula] / bacula / src / lib / edit.c
index 7d490c04577be860b32b0d8f24719195cae69e5c..23360905e04fa6b85f096c8081589d6f85e6f1ef 100644 (file)
@@ -308,6 +308,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.