]> git.sur5r.net Git - bacula/bacula/commitdiff
Modify scan code so that in most places scanning will
authorKern Sibbald <kern@sibbald.com>
Tue, 7 Sep 2004 17:17:11 +0000 (17:17 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 7 Sep 2004 17:17:11 +0000 (17:17 +0000)
  continue across the end of a line.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1588 91ce42f0-d328-0410-95d8-f526ca767f89

12 files changed:
bacula/.cvsignore
bacula/kernstodo
bacula/src/cats/sql_find.c
bacula/src/console/console_conf.c
bacula/src/dird/dird_conf.c
bacula/src/dird/inc_conf.c
bacula/src/lib/address_conf.c
bacula/src/lib/lex.c
bacula/src/lib/lex.h
bacula/src/lib/parse_conf.c
bacula/src/stored/stored_conf.c
bacula/src/version.h

index 2856eb45bccc8f709f1ad33f8a25ccf7fb3a3385..c24ed44804e53c2b1dc93739cde5ba19bafb116a 100644 (file)
@@ -1,5 +1,6 @@
 1
 2
+text
 set-gnome2
 set-gnome1.4
 kerns-gprof-config
index b3c6033169e580908c198476da9b58d67afa6d4d..09b22fd96c79d526a4a8f3779eaab76c861d98c7 100644 (file)
@@ -1,5 +1,5 @@
-                 Kern's ToDo List
-                   06 Septermber 2004
+                    Kern's ToDo List
+                   07 Septermber 2004
 
 Major development:      
 Project                     Developer
@@ -11,61 +11,15 @@ Version 1.35                Kern (see below)
 ========================================================
 
 1.35 Items to do for release:
-- Fix silly restriction requiring Include { Options { xxx } } to be
-  on separate lines.
-- Improve error message if old/new FileSet syntax mixed.
 - Restore c: with a prefix into /prefix/c/ to prevent c: and d:
   files with the same name from overwritting each other.
 - Add new DCR calling sequences everywhere in SD. This will permit 
   simultaneous use of multiple devices by a single job.
 
-
 - Document a get out of jail procedure if everything breaks if 
   you lost/broke the Catalog -- do the same for "I know my
   file is there how do I get it back?".
 
-- New IP address specification is used as follows:
-    [sdaddresses|diraddresses|fdaddresses] = { [[ip|ipv4|ipv6] = { 
-           [[addr|port] = [^ ]+[\n;]+] }] }
-
-  so it could look for example like this:
-     SDaddresses  = { ip = {
-            addr = 1.2.3.4; port = 1205; }
-        ipv4 = {
-            addr = 1.2.3.4; port = http; }
-        ipv6 = {
-            addr = 1.2.3.4;
-            port = 1205;
-        }
-        ip = {
-            addr = 1.2.3.4
-            port = 1205
-        }
-        ip = {
-            addr = 1.2.3.4
-        }
-        ip = {
-            addr = 201:220:222::2
-        }
-        ip = {
-            addr = bluedot.thun.net
-        }
-     }
-  as a consequence, you can now specify multiple IP addresses and
-  ports to be used. In the case of a server, it will listen on
-  all those that you specify. In the case of connecting to the server,
-  Bacula will attempt connecting to one at a time until it succeeds.
-  And, in a few other special cases, Bacula will use only the first
-  address specified.
-
-  The default port numbers are still the same and the services and hosts 
-  are also resolved by name. So now  you could use the real names for the 
-  port numbers.
-
-  An ip section will allow resolution to either an ipv4 or an ipv6 address.
-  An ipv4 section forces the resolution to be only ipv4, and an ipv6 section
-  forces the resolution to be only ipv6.
-
    
 Maybe for 1.35:
 - Look at patches/bacula_db.b2z postgresql that loops during restore.
@@ -74,7 +28,7 @@ Maybe for 1.35:
 - Add bscan to four-concurrent-jobs regression.
 - Add IPv6 to regression
 - Perhaps add read/write programs and/or plugins to FileSets.
-
+- How to handle backing up portables ...
 
 Documentation to do: (any release a little bit at a time)
 - Alternative to static linking "ldd prog" save all binaries listed,
@@ -1405,4 +1359,48 @@ Block Position: 0
 - Document that console commands can be abbreviated.
 - Doc update AllFromVol
 - Doc -p option in stored
+- New IP address specification is used as follows:
+    [sdaddresses|diraddresses|fdaddresses] = { [[ip|ipv4|ipv6] = { 
+           [[addr|port] = [^ ]+[\n;]+] }] }
+
+  so it could look for example like this:
+     SDaddresses  = { ip = {
+            addr = 1.2.3.4; port = 1205; }
+        ipv4 = {
+            addr = 1.2.3.4; port = http; }
+        ipv6 = {
+            addr = 1.2.3.4;
+            port = 1205;
+        }
+        ip = {
+            addr = 1.2.3.4
+            port = 1205
+        }
+        ip = {
+            addr = 1.2.3.4
+        }
+        ip = {
+            addr = 201:220:222::2
+        }
+        ip = {
+            addr = bluedot.thun.net
+        }
+     }
+  as a consequence, you can now specify multiple IP addresses and
+  ports to be used. In the case of a server, it will listen on
+  all those that you specify. In the case of connecting to the server,
+  Bacula will attempt connecting to one at a time until it succeeds.
+  And, in a few other special cases, Bacula will use only the first
+  address specified.
+
+  The default port numbers are still the same and the services and hosts 
+  are also resolved by name. So now  you could use the real names for the 
+  port numbers.
+
+  An ip section will allow resolution to either an ipv4 or an ipv6 address.
+  An ipv4 section forces the resolution to be only ipv4, and an ipv6 section
+  forces the resolution to be only ipv6.
+- Fix silly restriction requiring Include { Options { xxx } } to be
+  on separate lines.
+
  
index 74a1e4039bc7e81098feac421016f3fded274724..dc47ba69248da5b2951adc3a00543a4ab2aa9f15 100644 (file)
@@ -128,7 +128,8 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
    }
 
    if ((row = sql_fetch_row(mdb)) == NULL) {
-      Mmsg1(&mdb->errmsg, _("No Job record found: ERR=%s\n"), sql_strerror(mdb));
+      Mmsg2(&mdb->errmsg, _("No Job record found: ERR=%s\nCMD=%s\n"),
+        sql_strerror(mdb),  mdb->cmd);
       sql_free_result(mdb);
       db_unlock(mdb);
       return 0;
index 4a377dfa661d4610da59acddfbd24d160330a8f5..83d0f227916450e1be39e20e4eec1da5ce3547e6 100644 (file)
@@ -122,16 +122,16 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
       recurse = false;
    }
    switch (type) {
-      case R_CONSOLE:
-         printf("Console: name=%s rcfile=%s histfile=%s\n", reshdr->name,
-               res->res_cons.rc_file, res->res_cons.hist_file);
-        break;
-      case R_DIRECTOR:
-         printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, 
-                res->res_dir.address, res->res_dir.DIRport);
-        break;
-      default:
-         printf("Unknown resource type %d\n", type);
+   case R_CONSOLE:
+      printf("Console: name=%s rcfile=%s histfile=%s\n", reshdr->name,
+            res->res_cons.rc_file, res->res_cons.hist_file);
+      break;
+   case R_DIRECTOR:
+      printf("Director: name=%s address=%s DIRport=%d\n", reshdr->name, 
+             res->res_dir.address, res->res_dir.DIRport);
+      break;
+   default:
+      printf("Unknown resource type %d\n", type);
    }
    if (recurse && res->res_dir.hdr.next) {
       dump_resource(type, res->res_dir.hdr.next, sendit, sock);
@@ -163,19 +163,19 @@ void free_resource(RES *sres, int type)
    }
 
    switch (type) {
-      case R_CONSOLE:
-        if (res->res_cons.rc_file) {
-           free(res->res_cons.rc_file);
-        }
-        if (res->res_cons.hist_file) {
-           free(res->res_cons.hist_file);
-        }
-      case R_DIRECTOR:
-        if (res->res_dir.address)
-           free(res->res_dir.address);
-        break;
-      default:
-         printf("Unknown resource type %d\n", type);
+   case R_CONSOLE:
+      if (res->res_cons.rc_file) {
+        free(res->res_cons.rc_file);
+      }
+      if (res->res_cons.hist_file) {
+        free(res->res_cons.hist_file);
+      }
+   case R_DIRECTOR:
+      if (res->res_dir.address)
+        free(res->res_dir.address);
+      break;
+   default:
+      printf("Unknown resource type %d\n", type);
    }
    /* Common stuff again -- free the resource, recurse to next one */
    free(res);
@@ -240,17 +240,17 @@ void save_resource(int type, RES_ITEM *items, int pass)
 
    /* The following code is only executed during pass 1 */
    switch (type) {
-      case R_CONSOLE:
-        size = sizeof(CONRES);
-        break;
-      case R_DIRECTOR:
-        size = sizeof(DIRRES);
-        break;
-      default:
-         printf("Unknown resource type %d\n", type);
-        error = 1;
-        size = 1;
-        break;
+   case R_CONSOLE:
+      size = sizeof(CONRES);
+      break;
+   case R_DIRECTOR:
+      size = sizeof(DIRRES);
+      break;
+   default:
+      printf("Unknown resource type %d\n", type);
+      error = 1;
+      size = 1;
+      break;
    }
    /* Common */
    if (!error) {
index 148f9ff54a090c6bb23331113229dfa693f50f01..09d6c0924bb03ec5b9cba91fcd0087772519d947 100644 (file)
@@ -1223,202 +1223,3 @@ void store_acl(LEX *lc, RES_ITEM *item, int index, int pass)
    set_bit(index, res_all.hdr.item_present);
 }
 
-
-#ifdef old_deprecated_code
-/* 
- * Store backup/verify info for Job record 
- *
- * Note, this code is used for both BACKUP and VERIFY jobs
- *
- *    Backup = Client=<client-name> FileSet=<FileSet-name> Level=<level>
- */
-static void store_backup(LEX *lc, RES_ITEM *item, int index, int pass)
-{
-   int token, i;
-   RES *res;
-   int options = lc->options;
-
-   lc->options |= LOPT_NO_IDENT;      /* make spaces significant */
-
-   
-   ((JOB *)(item->value))->JobType = item->code;
-   while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
-      bool found = false;
-
-      Dmsg1(900, "store_backup got token=%s\n", lex_tok_to_str(token));
-      
-      if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
-         scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
-      }
-      Dmsg1(900, "Got keyword: %s\n", lc->str);
-      for (i=0; BakVerFields[i].name; i++) {
-        if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
-           found = true;
-           if (lex_get_token(lc, T_ALL) != T_EQUALS) {
-               scan_err1(lc, "Expected an equals, got: %s", lc->str);
-           }
-           token = lex_get_token(lc, T_NAME);
-            Dmsg1(900, "Got value: %s\n", lc->str);
-           switch (BakVerFields[i].token) {
-            case 'C':
-              /* Find Client Resource */
-              if (pass == 2) {
-                 res = GetResWithName(R_CLIENT, lc->str);
-                 if (res == NULL) {
-                     scan_err1(lc, "Could not find specified Client Resource: %s",
-                               lc->str);
-                 }
-                 res_all.res_job.client = (CLIENT *)res;
-              }
-              break;
-            case 'F':
-              /* Find FileSet Resource */
-              if (pass == 2) {
-                 res = GetResWithName(R_FILESET, lc->str);
-                 if (res == NULL) {
-                     scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
-                                lc->str);
-                 }
-                 res_all.res_job.fileset = (FILESET *)res;
-              }
-              break;
-            case 'L':
-              /* Get level */
-              for (i=0; joblevels[i].level_name; i++) {
-                 if (joblevels[i].job_type == item->code && 
-                      strcasecmp(lc->str, joblevels[i].level_name) == 0) {
-                    ((JOB *)(item->value))->level = joblevels[i].level;
-                    i = 0;
-                    break;
-                 }
-              }
-              if (i != 0) {
-                  scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
-              }
-              break;
-           } /* end switch */
-           break;
-        } /* end if strcmp() */
-      } /* end for */
-      if (!found) {
-         scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
-      }
-   } /* end while */
-   lc->options = options;            /* reset original options */
-   set_bit(index, res_all.hdr.item_present);
-}
-
-/* 
- * Store restore info for Job record 
- *
- *    Restore = JobId=<job-id> Where=<root-directory> Replace=<options> Bootstrap=<file>
- *
- */
-static void store_restore(LEX *lc, RES_ITEM *item, int index, int pass)
-{
-   int token, i;
-   RES *res;
-   int options = lc->options;
-
-   lc->options |= LOPT_NO_IDENT;      /* make spaces significant */
-
-   Dmsg0(900, "Enter store_restore()\n");
-   
-   ((JOB *)(item->value))->JobType = item->code;
-   while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
-      bool found = false;
-
-      if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
-         scan_err1(lc, "expected a name, got: %s", lc->str);
-      }
-      for (i=0; RestoreFields[i].name; i++) {
-         Dmsg1(900, "Restore kw=%s\n", lc->str);
-        if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
-           found = true;
-           if (lex_get_token(lc, T_ALL) != T_EQUALS) {
-               scan_err1(lc, "Expected an equals, got: %s", lc->str);
-           }
-           token = lex_get_token(lc, T_ALL);
-            Dmsg1(900, "Restore value=%s\n", lc->str);
-           switch (RestoreFields[i].token) {
-            case 'B':
-              /* Bootstrap */
-              if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
-                  scan_err1(lc, "Expected a Restore bootstrap file, got: %s", lc->str);
-              }
-              if (pass == 1) {
-                 res_all.res_job.RestoreBootstrap = bstrdup(lc->str);
-              }
-              break;
-            case 'C':
-              /* Find Client Resource */
-              if (pass == 2) {
-                 res = GetResWithName(R_CLIENT, lc->str);
-                 if (res == NULL) {
-                     scan_err1(lc, "Could not find specified Client Resource: %s",
-                               lc->str);
-                 }
-                 res_all.res_job.client = (CLIENT *)res;
-              }
-              break;
-            case 'F':
-              /* Find FileSet Resource */
-              if (pass == 2) {
-                 res = GetResWithName(R_FILESET, lc->str);
-                 if (res == NULL) {
-                     scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
-                                lc->str);
-                 }
-                 res_all.res_job.fileset = (FILESET *)res;
-              }
-              break;
-            case 'J':
-              /* JobId */
-              if (token != T_NUMBER) {
-                  scan_err1(lc, "expected an integer number, got: %s", lc->str);
-              }
-              errno = 0;
-              res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
-               Dmsg1(900, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
-              if (errno != 0) {
-                  scan_err1(lc, "expected an integer number, got: %s", lc->str);
-              }
-              break;
-            case 'W':
-              /* Where */
-              if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
-                  scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
-              }
-              if (pass == 1) {
-                 res_all.res_job.RestoreWhere = bstrdup(lc->str);
-              }
-              break;
-            case 'R':
-              /* Replacement options */
-              if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
-                  scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
-              }
-              /* Fix to scan Replacement options */
-              for (i=0; ReplaceOptions[i].name; i++) {
-                 if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
-                     ((JOB *)(item->value))->replace = ReplaceOptions[i].token;
-                    i = 0;
-                    break;
-                 }
-              }
-              if (i != 0) {
-                  scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
-              }
-              break;
-           } /* end switch */
-           break;
-        } /* end if strcmp() */
-      } /* end for */
-      if (!found) {
-         scan_err1(lc, "%s not a valid Restore keyword", lc->str);
-      }
-   } /* end while */
-   lc->options = options;            /* reset original options */
-   set_bit(index, res_all.hdr.item_present);
-}
-#endif
index 815b82483262978b7496508825b7a6b9fca5e2c6..c3a01f4ef3ade4cd22719dbb80e08bee90e6c5ae 100644 (file)
@@ -243,6 +243,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
 /* 
  * 
  * Store FileSet Include/Exclude info  
+ *  NEW style includes are handled in store_newinc()
  */
 void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
 {
@@ -257,11 +258,14 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
     *  new Include is followed immediately by open brace, whereas the
     *  old include has options following the Include.
     */
-   token = lex_get_token(lc, T_ALL);           
+   token = lex_get_token(lc, T_SKIP_EOL);           
    if (token == T_BOB) {
       store_newinc(lc, item, index, pass);
       return;
    }
+
+   /* What follows is scanning for the OLD style Include/Exclude */
+
    if (token != T_EQUALS) {
       scan_err1(lc, _("Expecting an equals sign, got: %s\n"), lc->str);
    }
@@ -270,7 +274,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
 
    /* Get include options */
    inc_opts[0] = 0;
-   while ((token=lex_get_token(lc, T_ALL)) != T_BOB) {
+   while ((token=lex_get_token(lc, T_SKIP_EOL)) != T_BOB) {
         
       keyword = INC_KW_NONE;
       for (i=0; FS_option_kw[i].name; i++) {
@@ -283,7 +287,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
          scan_err1(lc, _("Expected a FileSet keyword, got: %s"), lc->str);
       }
       /* Option keyword should be following by = <option> */
-      if ((token=lex_get_token(lc, T_ALL)) != T_EQUALS) {
+      if ((token=lex_get_token(lc, T_SKIP_EOL)) != T_EQUALS) {
          scan_err1(lc, _("expected an = following keyword, got: %s"), lc->str);
       } else {
         /* Scan right hand side of option */
@@ -337,10 +341,9 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
       /* Pickup include/exclude names. They are stored in INCEXE
        *  structures which contains the options and the name.
        */
-      while ((token = lex_get_token(lc, T_ALL)) != T_EOB) {
+      while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOB) {
         switch (token) {
         case T_COMMA:
-        case T_EOL:
            continue;
 
         case T_IDENTIFIER:
@@ -371,7 +374,8 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass)
 
 
 /*
- * Store FileSet FInclude/FExclude info   
+ * Store NEW style FileSet FInclude/FExclude info   
+ *
  *  Note, when this routine is called, we are inside a FileSet
  *  resource.  We treat the Include/Execlude like a sort of
  *  mini-resource within the FileSet resource.
@@ -384,14 +388,11 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass)
 
    if (!res_all.res_fs.have_MD5) {
       MD5Init(&res_all.res_fs.md5c);
-      res_all.res_fs.have_MD5 = TRUE;
+      res_all.res_fs.have_MD5 = true;
    }
    memset(&res_incexe, 0, sizeof(INCEXE));
    res_all.res_fs.new_include = true;
-   while ((token = lex_get_token(lc, T_ALL)) != T_EOF) {
-      if (token == T_EOL) {
-        continue;
-      }
+   while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOF) {
       if (token == T_EOB) {
         break;
       }
@@ -402,7 +403,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass)
          options = strcasecmp(lc->str, "options") == 0;
         if (strcasecmp(newinc_items[i].name, lc->str) == 0) {
            if (!options) {
-              token = lex_get_token(lc, T_ALL);
+              token = lex_get_token(lc, T_SKIP_EOL);
               if (token != T_EQUALS) {
                   scan_err1(lc, "expected an equals, got: %s", lc->str);
               }
@@ -453,10 +454,10 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
    regex_t preg;
    char prbuf[500];
 
+   token = lex_get_token(lc, T_SKIP_EOL);           
    if (pass == 1) {
       /* Pickup regex string
        */
-      token = lex_get_token(lc, T_ALL);           
       switch (token) {
       case T_IDENTIFIER:
       case T_UNQUOTED_STRING:
@@ -476,8 +477,6 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
       default:
          scan_err1(lc, _("Expected a regex string, got: %s\n"), lc->str);
       }                                
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -487,14 +486,12 @@ static void store_base(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
+   token = lex_get_token(lc, T_NAME);          
    if (pass == 1) {
       /*
        * Pickup Base Job Name
        */
-      token = lex_get_token(lc, T_NAME);          
       res_incexe.current_opts->base.append(bstrdup(lc->str));
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -504,14 +501,12 @@ static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
+   token = lex_get_token(lc, T_NAME);          
    if (pass == 1) {
       /*
        * Pickup reader command
        */
-      token = lex_get_token(lc, T_NAME);          
       res_incexe.current_opts->reader = bstrdup(lc->str); 
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -521,14 +516,12 @@ static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
+   token = lex_get_token(lc, T_NAME);          
    if (pass == 1) {
       /*
        * Pickup writer command
        */
-      token = lex_get_token(lc, T_NAME);          
       res_incexe.current_opts->writer = bstrdup(lc->str);
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -540,11 +533,11 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token;
 
+   token = lex_get_token(lc, T_SKIP_EOL);           
    if (pass == 1) {
       /*
        * Pickup Wild-card string
        */
-      token = lex_get_token(lc, T_ALL);           
       switch (token) {
       case T_IDENTIFIER:
       case T_UNQUOTED_STRING:
@@ -556,8 +549,6 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass)
       default:
          scan_err1(lc, _("Expected a wild-card string, got: %s\n"), lc->str);
       }                                
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -573,10 +564,10 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass)
    int token;
    INCEXE *incexe;
 
+   token = lex_get_token(lc, T_SKIP_EOL);           
    if (pass == 1) {
       /* Pickup Filename string
        */
-      token = lex_get_token(lc, T_ALL);           
       switch (token) {
         case T_IDENTIFIER:
         case T_UNQUOTED_STRING:
@@ -594,8 +585,6 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass)
         default:
             scan_err1(lc, _("Expected a filename, got: %s"), lc->str);
       }                                
-   } else { /* pass 2 */
-      lex_get_token(lc, T_ALL);         
    }
    scan_to_eol(lc);
 }
@@ -607,7 +596,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass)
 {
    int token, i;
 
-   token = lex_get_token(lc, T_ALL);           
+   token = lex_get_token(lc, T_SKIP_EOL);           
    if (token != T_BOB) {
       scan_err1(lc, "Expecting open brace. Got %s", lc->str);
    }
@@ -628,7 +617,7 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass)
       }
       for (i=0; options_items[i].name; i++) {
         if (strcasecmp(options_items[i].name, lc->str) == 0) {
-           token = lex_get_token(lc, T_ALL);
+           token = lex_get_token(lc, T_SKIP_EOL);
            if (token != T_EQUALS) {
                scan_err1(lc, "expected an equals, got: %s", lc->str);
            }
@@ -642,7 +631,6 @@ static void options_res(LEX *lc, RES_ITEM *item, int index, int pass)
          scan_err1(lc, "Keyword %s not permitted in this resource", lc->str);
       }
    }
-   scan_to_eol(lc);
 }
 
 
index 8c03b774d8fc9b89a0059adc1994d59ca4fb0d4c..49629b3579fdda53c97708bbfd51df6d0c2cecd7 100644 (file)
@@ -191,7 +191,7 @@ const char *IPADDR::build_address_str(char *buf, int blen)
 
 const char *build_addresses_str(dlist *addrs, char *buf, int blen) 
 {
-   if (!addrs->size()) {
+   if (addrs->size() == 0) {
       bstrncpy(buf, "", blen);
       return buf;
    }
@@ -223,17 +223,6 @@ int get_first_port_host_order(dlist * addrs)
    return ((IPADDR *)(addrs->first()))->get_port_host_order();                           
 }
 
-static int skip_to_next_not_eol(LEX * lc)
-{
-   int token;
-
-   do {
-      token = lex_get_token(lc, T_ALL);
-   } while (token == T_EOL);
-   return token;
-}
-
-
 void init_default_addresses(dlist **out, int port)
 {
    char *errstr;
@@ -269,7 +258,7 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
         } else if (iaddr->get_type() != type) {
            *errstr = (char *)malloc(1024);
            bsnprintf(*errstr, 1023,
-                      "the old style addresses could mixed with new style");
+                      "the old style addresses cannot be mixed with new style");
            return 0;
         }
       }
@@ -348,6 +337,37 @@ static int add_address(dlist **out, IPADDR::i_type type, unsigned short defaultp
    return 1;
 }
 
+/*
+ *   my tests
+ *   positiv
+ *   = { ip = { addr = 1.2.3.4; port = 1205; } ipv4 = { addr = 1.2.3.4; port = http; } }
+ *   = { ip = { 
+ *        addr = 1.2.3.4; port = 1205; } 
+ *     ipv4 = { 
+ *        addr = 1.2.3.4; port = http; } 
+ *     ipv6 = { 
+ *      addr = 1.2.3.4; 
+ *      port = 1205;
+ *     } 
+ *     ip = {
+ *      addr = 1.2.3.4
+ *      port = 1205
+ *     } 
+ *     ip = {
+ *      addr = 1.2.3.4
+ *     } 
+ *     ip = {
+ *      addr = 2001:220:222::2
+ *     } 
+ *     ip = {
+ *      addr = bluedot.thun.net
+ (     } 
+ *   }
+ *   negativ
+ *   = { ip = { } }
+ *   = { ipv4 { addr = doof.nowaytoheavenxyz.uhu; } }
+ *   = { ipv4 { port = 4711 } }
+ */
 void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
 {
    int token;
@@ -357,47 +377,13 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
    char port_str[128];
    int family = 0;
 
-    
-
-   /*
-    *   =  { [[ip|ipv4|ipv6] = { [[addr|port] = [^ ]+[\n;]+] }]+ }
-    *  or my tests
-    *  positiv
-    *  = { ip = { addr = 1.2.3.4; port = 1205; } ipv4 = { addr = 1.2.3.4; port = http; } }
-    *  = { ip = { 
-    *        addr = 1.2.3.4; port = 1205; } 
-    *    ipv4 = { 
-    *        addr = 1.2.3.4; port = http; } 
-    *    ipv6 = { 
-    *      addr = 1.2.3.4; 
-    *      port = 1205;
-    *    } 
-    *    ip = {
-    *      addr = 1.2.3.4
-    *      port = 1205
-    *    } 
-    *    ip = {
-    *      addr = 1.2.3.4
-    *    } 
-    *    ip = {
-    *      addr = 2001:220:222::2
-    *    } 
-    *    ip = {
-    *      addr = bluedot.thun.net
-    (    } 
-    *  }
-    *  negativ
-    *  = { ip = { } }
-    *  = { ipv4 { addr = doof.nowaytoheavenxyz.uhu; } }
-    *  = { ipv4 { port = 4711 } }
-    */
-
-   token = skip_to_next_not_eol(lc);
+
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (token != T_BOB) {
       scan_err1(lc, _("Expected a block begin { , got: %s"), lc->str);
    }
 
-   token = skip_to_next_not_eol(lc);
+   token = lex_get_token(lc, T_SKIP_EOL);
    if (token == T_EOB) {
       scan_err0(lc, _("Empty addr block is not allowed"));
    }
@@ -405,39 +391,42 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
       if (!(token == T_UNQUOTED_STRING || token == T_IDENTIFIER)) {
          scan_err1(lc, _("Expected a string, got: %s"), lc->str);
       }
-      if (!strcmp("ip", lc->str) || !strcmp("ipv4", lc->str)) {
+      if (strcmp("ip", lc->str) == 0 || strcmp("ipv4", lc->str) == 0) {
         family = AF_INET;
       }
 #ifdef HAVE_IPV6
-      else if (!strcmp("ipv6", lc->str)) {
+      else if (strcmp("ipv6", lc->str) == 0) {
         family = AF_INET6;
+      } else {
+         scan_err1(lc, _("Expected a string [ip|ipv4|ipv6], got: %s"), lc->str);
       }
-#endif
+#else
       else {
-         scan_err1(lc, _("Expected a string [ip|ipv4|ipv6], got: %s"), lc->str);
+         scan_err1(lc, _("Expected a string [ip|ipv4], got: %s"), lc->str);
       }
-      token = skip_to_next_not_eol(lc);
+#endif
+      token = lex_get_token(lc, T_SKIP_EOL);
       if (token != T_EQUALS) {
          scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
       }
-      token = skip_to_next_not_eol(lc);
+      token = lex_get_token(lc, T_SKIP_EOL);
       if (token != T_BOB) {
          scan_err1(lc, _("Expected a block beginn { , got: %s"), lc->str);
       }
-      token = skip_to_next_not_eol(lc);
+      token = lex_get_token(lc, T_SKIP_EOL);
       exist = EMPTYLINE;
       port_str[0] = hostname_str[0] = '\0';
       do {
         if (token != T_IDENTIFIER) {
             scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
         }
-         if (!strcmp("port", lc->str)) {
+         if (strcmp("port", lc->str) == 0) {
            next_line = PORTLINE;
            if (exist & PORTLINE) {
                scan_err0(lc, _("Only one port per address block"));
            }
            exist |= PORTLINE;
-         } else if (!strcmp("addr", lc->str)) {
+         } else if (strcmp("addr", lc->str) == 0) {
            next_line = ADDRLINE;
            if (exist & ADDRLINE) {
                scan_err0(lc, _("Only one addr per address block"));
@@ -446,11 +435,11 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
         } else {
             scan_err1(lc, _("Expected a identifier [addr|port], got: %s"), lc->str);
         }
-        token = lex_get_token(lc, T_ALL);
+        token = lex_get_token(lc, T_SKIP_EOL);
         if (token != T_EQUALS) {
             scan_err1(lc, _("Expected a equal =, got: %s"), lc->str);
         }
-        token = lex_get_token(lc, T_ALL);
+        token = lex_get_token(lc, T_SKIP_EOL);
         switch (next_line) {
         case PORTLINE:
            if (!
@@ -462,16 +451,16 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
            break;
         case ADDRLINE:
            if (!(token == T_UNQUOTED_STRING || token == T_IDENTIFIER)) {
-               scan_err1(lc, _("Expected a ipnumber or a hostname, got: %s"),
+               scan_err1(lc, _("Expected an IP number or a hostname, got: %s"),
                         lc->str);
            }
            bstrncpy(hostname_str, lc->str, sizeof(hostname_str));
            break;
         case EMPTYLINE:
-            scan_err0(lc, _("Statemachine missmatch"));
+            scan_err0(lc, _("State machine missmatch"));
            break;
         }
-        token = skip_to_next_not_eol(lc);
+        token = lex_get_token(lc, T_SKIP_EOL);
       } while (token == T_IDENTIFIER);
       if (token != T_EOB) {
          scan_err1(lc, _("Expected a end of block }, got: %s"), lc->str);
@@ -484,7 +473,7 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
                   hostname_str, port_str, errstr);
           free(errstr);
        }
-      token = skip_to_next_not_eol(lc);
+      token = scan_to_next_not_eol(lc);
    } while ((token == T_IDENTIFIER || token == T_UNQUOTED_STRING));
    if (token != T_EOB) {
       scan_err1(lc, _("Expected a end of block }, got: %s"), lc->str);
@@ -494,9 +483,9 @@ void store_addresses(LEX * lc, RES_ITEM * item, int index, int pass)
 void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass)
 {
 
-   int token = lex_get_token(lc, T_ALL);
+   int token = lex_get_token(lc, T_SKIP_EOL);
    if (!(token == T_UNQUOTED_STRING || token == T_NUMBER || token == T_IDENTIFIER)) {
-      scan_err1(lc, _("Expected a hostname or ipnummer, got: %s"), lc->str);
+      scan_err1(lc, _("Expected a hostname or IP nummer, got: %s"), lc->str);
    }
    char *errstr;
    if (pass == 1 && !add_address((dlist **) (item->value), IPADDR::R_SINGLE_ADDR,
@@ -508,9 +497,9 @@ void store_addresses_address(LEX * lc, RES_ITEM * item, int index, int pass)
 
 void store_addresses_port(LEX * lc, RES_ITEM * item, int index, int pass)
 {
-   int token = lex_get_token(lc, T_ALL);
+   int token = lex_get_token(lc, T_SKIP_EOL);
    if (!(token == T_UNQUOTED_STRING || token == T_NUMBER || token == T_IDENTIFIER)) {
-      scan_err1(lc, _("Expected a port nummer or string, got: %s"), lc->str);
+      scan_err1(lc, _("Expected a port number or string, got: %s"), lc->str);
    }
    char *errstr;
    if (pass == 1 && !add_address((dlist **)(item->value), IPADDR::R_SINGLE_PORT,
index d2a47e2eb2cbace8b6f8e8639db9a0718652cc4f..afaaf98633b29f788b96f3b4367ba0dd6d690df6 100644 (file)
@@ -34,14 +34,31 @@ extern int debug_level;
 
 /*
  * Scan to "logical" end of line. I.e. end of line,
- * or semicolon.
+ *   or semicolon, but stop on T_EOB (same as end of
+ *   line except it is not eaten).
  */
 void scan_to_eol(LEX *lc)
 {
+   int token;
    Dmsg0(2000, "start scan to eof\n");
-   while (lex_get_token(lc, T_ALL) != T_EOL)
-      { }
-   Dmsg0(2000, "done scan to eof\n");
+   while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
+      if (token == T_EOB) {
+        lex_unget_char(lc);
+        return;
+      }
+   }
+}
+
+/*
+ * Get next token, but skip EOL
+ */
+int scan_to_next_not_eol(LEX * lc)
+{
+   int token;
+   do {
+      token = lex_get_token(lc, T_ALL);
+   } while (token == T_EOL);
+   return token;
 }
 
    
@@ -282,7 +299,7 @@ lex_get_token(LEX *lf, int expect)
 {
    int ch;
    int token = T_NONE;
-   int esc_next = FALSE;
+   bool esc_next = false;
 
    Dmsg0(2000, "enter lex_get_token\n");
    while (token == T_NONE) {
@@ -335,11 +352,15 @@ lex_get_token(LEX *lf, int expect)
            begin_str(lf, ch);
            break;
          case ';':
-           token = T_EOL;      /* treat ; like EOL */
+           if (expect != T_SKIP_EOL) {
+              token = T_EOL;      /* treat ; like EOL */
+           }
            break;
         case L_EOL:
             Dmsg0(2000, "got L_EOL set token=T_EOL\n");
-           token = T_EOL;
+           if (expect != T_SKIP_EOL) {
+              token = T_EOL;
+           }
            break;
          case '@':
            lf->state = lex_include;
@@ -355,7 +376,9 @@ lex_get_token(LEX *lf, int expect)
          Dmsg1(2000, "Lex state lex_comment ch=%x\n", ch);
         if (ch == L_EOL) {
            lf->state = lex_none;
-           token = T_EOL;
+           if (expect != T_SKIP_EOL) {
+              token = T_EOL;
+           }
         } else if (ch == L_EOF) {
            token = T_ERROR;
         }
@@ -433,16 +456,16 @@ lex_get_token(LEX *lf, int expect)
            break;
         }
         if (ch == L_EOL) {
-           esc_next = FALSE;
+           esc_next = false;
            break;
         }
         if (esc_next) {
            add_str(lf, ch);
-           esc_next = FALSE;
+           esc_next = false;
            break;
         }
          if (ch == '\\') {
-           esc_next = TRUE;
+           esc_next = true;
            break;
         }
          if (ch == '"') {
index 199d34c1106baccc36624b66a7901a38b94e0ae2..49274ed93a0e01065700da2595f57b54aa936ca0 100644 (file)
 #define T_EQUALS                      110
 #define T_COMMA                       111
 #define T_EOL                         112
-#define T_SEMI                        113
 #define T_ERROR                       200
 /*
  * The following will be returned only if
  * the appropriate expect flag has been set   
  */
+#define T_SKIP_EOL                    113  /* scan through EOLs */
 #define T_PINT32                      114  /* positive integer */
 #define T_PINT32_RANGE                115  /* positive integer range */
 #define T_INT32                       116  /* integer */
@@ -115,5 +115,6 @@ typedef void (LEX_ERROR_HANDLER)(const char *file, int line, LEX *lc, const char
 #define scan_err6(lc, msg, a1, a2, a3, a4, a5, a6) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4, a5, a6)
 
 void scan_to_eol(LEX *lc);
+int scan_to_next_not_eol(LEX * lc);
 
 #endif /* _LEX_H */
index 527b724149f4f011eeaf9b6c8d57f8a722c67d74..273be9c122ac0ef48f0755ca6240d54f092cac2e 100755 (executable)
@@ -234,13 +234,13 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
            token = lex_get_token(lc, T_NAME);   /* scan destination */
            dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2);
            if (dest[0] != 0) {
-               pm_strcat(&dest, " ");  /* separate multiple destinations with space */
+               pm_strcat(dest, " ");  /* separate multiple destinations with space */
               dest_len++;
            }
-           pm_strcat(&dest, lc->str);
+           pm_strcat(dest, lc->str);
            dest_len += lc->str_len;
             Dmsg2(900, "store_msgs newdest=%s: dest=%s:\n", lc->str, NPRT(dest));
-           token = lex_get_token(lc, T_ALL);
+           token = lex_get_token(lc, T_SKIP_EOL);
            if (token == T_COMMA) { 
               continue;           /* get another destination */
            }
@@ -259,9 +259,9 @@ void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass)
         dest = get_pool_memory(PM_MESSAGE);
         /* Pick up a single destination */
         token = lex_get_token(lc, T_NAME);   /* scan destination */
-        pm_strcpy(&dest, lc->str);
+        pm_strcpy(dest, lc->str);
         dest_len = lc->str_len;
-        token = lex_get_token(lc, T_ALL);
+        token = lex_get_token(lc, T_SKIP_EOL);
          Dmsg1(900, "store_msgs dest=%s:\n", NPRT(dest));
         if (token != T_EQUALS) {
             scan_err1(lc, _("expected an =, got: %s"), lc->str); 
@@ -527,7 +527,7 @@ void store_size(LEX *lc, RES_ITEM *item, int index, int pass)
    uint64_t uvalue;
 
    Dmsg0(900, "Enter store_size\n");
-   token = lex_get_token(lc, T_ALL);
+   token = lex_get_token(lc, T_SKIP_EOL);
    errno = 0;
    switch (token) {
    case T_NUMBER:
@@ -555,7 +555,7 @@ void store_time(LEX *lc, RES_ITEM *item, int index, int pass)
    utime_t utime;
    char period[500];
 
-   token = lex_get_token(lc, T_ALL);
+   token = lex_get_token(lc, T_SKIP_EOL);
    errno = 0;
    switch (token) {
    case T_NUMBER:
@@ -754,7 +754,7 @@ parse_config(const char *cf, int exit_on_error)
                     /* If the ITEM_NO_EQUALS flag is set we do NOT              
                      *   scan for = after the keyword  */
                     if (!(items[i].flags & ITEM_NO_EQUALS)) {
-                       token = lex_get_token(lc, T_ALL);
+                       token = lex_get_token(lc, T_SKIP_EOL);
                         Dmsg1 (900, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
                        if (token != T_EQUALS) {
                            scan_err1(lc, _("expected an equals, got: %s"), lc->str);
index 25edf24b743ca2b3a447c18efa38ff77f46effb2..16a370405db79066a80ad728adfe31c97e3f349f 100644 (file)
@@ -59,7 +59,6 @@ static RES_ITEM store_items[] = {
    {"sdaddresses",           store_addresses,  ITEM(res_store.sdaddrs), 0, ITEM_DEFAULT, 9103},
    {"messages",              store_res,  ITEM(res_store.messages),   0, R_MSGS, 0},
    {"sdport",                store_addresses_port,  ITEM(res_store.sdaddrs),     0, ITEM_DEFAULT, 9103},
-   {"sddport",               store_addresses_port,  ITEM(res_store.sddaddrs),    0, 0, 0}, /* deprecated */
    {"workingdirectory",      store_dir,  ITEM(res_store.working_directory), 0, ITEM_REQUIRED, 0},
    {"piddirectory",          store_dir,  ITEM(res_store.pid_directory), 0, ITEM_REQUIRED, 0},
    {"subsysdirectory",       store_dir,  ITEM(res_store.subsys_directory), 0, 0, 0},
index fbc1fe30db35c576fd8be074dd7682e73d439d8a..fb79addbf2b9f746472e4194f4148a97a997d133 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
 #define VERSION "1.35.3"
-#define BDATE   "06 September 2004"
-#define LSMDATE "06Sep04"
+#define BDATE   "07 September 2004"
+#define LSMDATE "07Sep04"
 
 /* Debug flags */
 #undef  DEBUG