]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/lex.c
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / lib / lex.c
index 095ce50d37102c99acdbb9e4dc9f49fc7d677211..a337757742ba20b9548c1f0d5f31053fb4902d48 100644 (file)
@@ -1,36 +1,34 @@
 /*
- * Lexical scanner for Bacula configuration file
- *
- *   Kern Sibbald, 2000
- *
- *   Version $Id$
- *
- */
+   Bacula(R) - The Network Backup Solution
 
-/*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2015 Kern Sibbald
+   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
 
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
 
+   Bacula(R) is a registered trademark of Kern Sibbald.
+*/
+/*
+ * Lexical scanner for Bacula configuration file
+ *
+ *   Kern Sibbald, 2000
+ *
  */
 
 #include "bacula.h"
 #include "lex.h"
 
-extern int debug_level;
+/* Debug level for this source file */
+static const int dbglvl = 5000;
 
 /*
  * Scan to "logical" end of line. I.e. end of line,
@@ -40,12 +38,15 @@ extern int debug_level;
 void scan_to_eol(LEX *lc)
 {
    int token;
-   Dmsg0(2000, "start scan to eof\n");
+   Dmsg0(dbglvl, "start scan to eol\n");
    while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
       if (token == T_EOB) {
          lex_unget_char(lc);
          return;
       }
+      if (token == T_EOF) {
+         return;
+      }
    }
 }
 
@@ -61,11 +62,10 @@ int scan_to_next_not_eol(LEX * lc)
    return token;
 }
 
-
 /*
  * Format a scanner error message
  */
-void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
+static void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
 {
    va_list arg_ptr;
    char buf[MAXSTRING];
@@ -75,21 +75,40 @@ void s_err(const char *file, int line, LEX *lc, const char *msg, ...)
    bvsnprintf(buf, sizeof(buf), msg, arg_ptr);
    va_end(arg_ptr);
 
+   if (lc->err_type == 0) {     /* M_ERROR_TERM by default */
+      lc->err_type = M_ERROR_TERM;
+   }
+
    if (lc->line_no > lc->begin_line_no) {
       bsnprintf(more, sizeof(more),
                 _("Problem probably begins at line %d.\n"), lc->begin_line_no);
    } else {
       more[0] = 0;
-   }  
+   }
    if (lc->line_no > 0) {
-      e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"
+      e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"
 "            : line %d, col %d of file %s\n%s\n%s"),
          buf, lc->line_no, lc->col_no, lc->fname, lc->line, more);
    } else {
-      e_msg(file, line, M_ERROR_TERM, 0, _("Config error: %s\n"), buf);
+      e_msg(file, line, lc->err_type, 0, _("Config error: %s\n"), buf);
    }
 }
 
+void lex_set_default_error_handler(LEX *lf)
+{
+   lf->scan_error = s_err;
+}
+
+/*
+ * Set err_type used in error_handler
+ * return the old value
+ */
+int lex_set_error_handler_error_type(LEX *lf, int err_type)
+{
+   int old = lf->err_type;
+   lf->err_type = err_type;
+   return old;
+}
 
 /*
  * Free the current file, and retrieve the contents
@@ -99,23 +118,87 @@ LEX *lex_close_file(LEX *lf)
 {
    LEX *of;
 
-   Dmsg1(2000, "Close lex file: %s\n", lf->fname);
    if (lf == NULL) {
-      Emsg0(M_ABORT, 0, "Close of NULL file\n");
+      Emsg0(M_ABORT, 0, _("Close of NULL file\n"));
    }
+   Dmsg1(dbglvl, "Close lex file: %s\n", lf->fname);
+
    of = lf->next;
-   fclose(lf->fd);
-   Dmsg1(2000, "Close cfg file %s\n", lf->fname);
-   free(lf->fname);
+   if (lf->bpipe) {
+      close_bpipe(lf->bpipe);
+      lf->bpipe = NULL;
+   } else if (lf->fd) {
+      fclose(lf->fd);
+   }
+   Dmsg1(dbglvl, "Close cfg file %s\n", lf->fname);
+   if (lf->fname) {
+      free(lf->fname);
+   }
+   free_memory(lf->line);
+   lf->line = NULL;
+   free_memory(lf->str);
+   lf->str = NULL;
    if (of) {
       of->options = lf->options;      /* preserve options */
       memcpy(lf, of, sizeof(LEX));
-      Dmsg1(2000, "Restart scan of cfg file %s\n", of->fname);
+      Dmsg1(dbglvl, "Restart scan of cfg file %s\n", of->fname);
    } else {
       of = lf;
       lf = NULL;
    }
-   free(of);
+   if (of) {
+      free(of);
+   }
+   return lf;
+}
+
+/*
+ * Open a configuration in memory buffer. We push the
+ * state of the current file (lf) so that we
+ * can do includes.  This is a bit of a hammer.
+ * Instead of passing back the pointer to the
+ * new packet, I simply replace the contents
+ * of the caller's packet with the new packet,
+ * and link the contents of the old packet into
+ * the next field.
+ *
+ */
+LEX *lex_open_buf(LEX *lf, const char *buffer, LEX_ERROR_HANDLER *scan_error)
+
+{
+   LEX *nf;
+
+   Dmsg0(400, "Open config buffer\n");
+   nf = (LEX *)malloc(sizeof(LEX));
+   if (lf) {
+      memcpy(nf, lf, sizeof(LEX));
+      memset(lf, 0, sizeof(LEX));
+      lf->next = nf;                  /* if have lf, push it behind new one */
+      lf->options = nf->options;      /* preserve user options */
+      /*
+       * preserve err_type to prevent bacula exiting on 'reload'
+       * if config is invalid. Fixes bug #877
+       */
+      lf->err_type = nf->err_type;
+   } else {
+      lf = nf;                        /* start new packet */
+      memset(lf, 0, sizeof(LEX));
+      lex_set_error_handler_error_type(lf, M_ERROR_TERM);
+   }
+   if (scan_error) {
+      lf->scan_error = scan_error;
+   } else {
+      lex_set_default_error_handler(lf);
+   }
+   lf->fd = NULL;
+   lf->bpipe = NULL;
+   lf->fname = NULL;
+   lf->line = get_memory(5000);
+   pm_strcpy(lf->line, buffer);
+   pm_strcat(lf->line, "");
+   lf->state = lex_none;
+   lf->ch = 0;
+   lf->str = get_memory(5000);
    return lf;
 }
 
@@ -135,33 +218,49 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
 {
    LEX *nf;
    FILE *fd;
+   BPIPE *bpipe = NULL;
    char *fname = bstrdup(filename);
 
-
-   if ((fd = fopen(fname, "r")) == NULL) {
+   if (fname[0] == '|') {
+      if ((bpipe = open_bpipe(fname+1, 0, "rb")) == NULL) {
+         free(fname);
+         return NULL;
+      }
+      fd = bpipe->rfd;
+   } else if ((fd = fopen(fname, "rb")) == NULL) {
+      free(fname);
       return NULL;
    }
-   Dmsg1(2000, "Open config file: %s\n", fname);
+   Dmsg1(400, "Open config file: %s\n", fname);
    nf = (LEX *)malloc(sizeof(LEX));
    if (lf) {
       memcpy(nf, lf, sizeof(LEX));
       memset(lf, 0, sizeof(LEX));
       lf->next = nf;                  /* if have lf, push it behind new one */
       lf->options = nf->options;      /* preserve user options */
+      /*
+       * preserve err_type to prevent bacula exiting on 'reload'
+       * if config is invalid. Fixes bug #877
+       */
+      lf->err_type = nf->err_type;
    } else {
       lf = nf;                        /* start new packet */
       memset(lf, 0, sizeof(LEX));
+      lex_set_error_handler_error_type(lf, M_ERROR_TERM);
    }
-   lf->fd = fd;
-   lf->fname = fname;
-   lf->state = lex_none;
-   lf->ch = L_EOL;
    if (scan_error) {
       lf->scan_error = scan_error;
    } else {
-      lf->scan_error = s_err;
+      lex_set_default_error_handler(lf);
    }
-   Dmsg1(2000, "Return lex=%x\n", lf);
+   lf->fd = fd;
+   lf->bpipe = bpipe;
+   lf->fname = fname;
+   lf->line = get_memory(5000);
+   lf->state = lex_none;
+   lf->ch = L_EOL;
+   lf->str = get_memory(5000);
+   Dmsg1(dbglvl, "Return lex=%x\n", lf);
    return lf;
 }
 
@@ -174,10 +273,11 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
 int lex_get_char(LEX *lf)
 {
    if (lf->ch == L_EOF) {
-      Emsg0(M_ABORT, 0, "get_char: called after EOF\n");
+      Emsg0(M_ABORT, 0, _("get_char: called after EOF."
+         " You may have a open double quote without the closing double quote.\n"));
    }
-   if (lf->ch == L_EOL) {
-      if (bfgets(lf->line, MAXSTRING, lf->fd) == NULL) {
+   if (lf->fd && lf->ch == L_EOL) {
+      if (bfgets(lf->line, lf->fd) == NULL) {
          lf->ch = L_EOF;
          if (lf->next) {
             lex_close_file(lf);
@@ -186,22 +286,43 @@ int lex_get_char(LEX *lf)
       }
       lf->line_no++;
       lf->col_no = 0;
+      Dmsg2(1000, "fget line=%d %s", lf->line_no, lf->line);
+   } else if (lf->ch == L_EOL) {
+      lf->line_no++;
+      lf->col_no++;
    }
    lf->ch = (uint8_t)lf->line[lf->col_no];
-   if (lf->ch == 0) {
-      lf->ch = L_EOL;
+   if (lf->fd) {
+      if (lf->ch == 0) {
+         lf->ch = L_EOL;           /* reached end of line, force bfgets */
+      } else {
+         lf->col_no++;
+      }
    } else {
-      lf->col_no++;
+      if (lf->ch == 0) {           /* End of buffer, stop scan */
+         lf->ch = L_EOF;
+         if (lf->next) {
+            lex_close_file(lf);
+         }
+         return lf->ch;
+      } else if (lf->ch == '\n') {  /* End of line */
+         Dmsg0(dbglvl, "Found newline return L_EOL\n");
+         lf->ch = L_EOL;
+      } else {
+         lf->col_no++;
+      }
    }
-   Dmsg2(2000, "lex_get_char: %c %d\n", lf->ch, lf->ch);
+   Dmsg3(dbglvl, "lex_get_char: %c %d col=%d\n", lf->ch, lf->ch, lf->col_no);
    return lf->ch;
 }
 
 void lex_unget_char(LEX *lf)
 {
-   lf->col_no--;
-   if (lf->ch == L_EOL)
-      lf->ch = 0;
+   if (lf->ch == L_EOL) {
+      lf->ch = 0;                     /* End of line, force read of next one */
+   } else {
+      lf->col_no--;                   /* Backup to re-read char */
+   }
 }
 
 
@@ -210,7 +331,7 @@ void lex_unget_char(LEX *lf)
  */
 static void add_str(LEX *lf, int ch)
 {
-   if (lf->str_len >= MAXSTRING-3) {
+   if (lf->str_len >= sizeof_pool_memory(lf->str)) {
       Emsg3(M_ERROR_TERM, 0, _(
            _("Config token too long, file: %s, line %d, begins at line %d\n")),
              lf->fname, lf->line_no, lf->begin_line_no);
@@ -236,13 +357,17 @@ static void begin_str(LEX *lf, int ch)
 static const char *lex_state_to_str(int state)
 {
    switch (state) {
-   case lex_none:          return "none";
-   case lex_comment:       return "comment";
-   case lex_number:        return "number";
-   case lex_ip_addr:       return "ip_addr";
-   case lex_identifier:    return "identifier";
-   case lex_string:        return "string";
-   case lex_quoted_string: return "quoted_string";
+   case lex_none:          return _("none");
+   case lex_comment:       return _("comment");
+   case lex_number:        return _("number");
+   case lex_ip_addr:       return _("ip_addr");
+   case lex_identifier:    return _("identifier");
+   case lex_string:        return _("string");
+   case lex_quoted_string: return _("quoted_string");
+   case lex_include:       return _("include");
+   case lex_include_quoted_string: return _("include_quoted_string");
+   case lex_utf8_bom:      return _("UTF-8 Byte Order Mark");
+   case lex_utf16_le_bom:  return _("UTF-16le Byte Order Mark");
    default:                return "??????";
    }
 }
@@ -270,6 +395,8 @@ const char *lex_tok_to_str(int token)
    case T_EOF:             return "T_EOF";
    case T_COMMA:           return "T_COMMA";
    case T_EOL:             return "T_EOL";
+   case T_UTF8_BOM:        return "T_UTF8_BOM";
+   case T_UTF16_BOM:       return "T_UTF16_BOM";
    default:                return "??????";
    }
 }
@@ -284,13 +411,30 @@ static uint32_t scan_pint(LEX *lf, char *str)
       errno = 0;
       val = str_to_int64(str);
       if (errno != 0 || val < 0) {
-         scan_err1(lf, _("expected a postive integer number, got: %s"), str);
+         scan_err1(lf, _("expected a positive integer number, got: %s"), str);
          /* NOT REACHED */
       }
    }
    return (uint32_t)val;
 }
 
+static uint64_t scan_pint64(LEX *lf, char *str)
+{
+   uint64_t val = 0;
+   if (!is_a_number(str)) {
+      scan_err1(lf, _("expected a positive integer number, got: %s"), str);
+      /* NOT REACHED */
+   } else {
+      errno = 0;
+      val = str_to_uint64(str);
+      if (errno != 0) {
+         scan_err1(lf, _("expected a positive integer number, got: %s"), str);
+         /* NOT REACHED */
+      }
+   }
+   return val;
+}
+
 /*
  *
  * Get the next token from the input
@@ -302,13 +446,20 @@ lex_get_token(LEX *lf, int expect)
    int ch;
    int token = T_NONE;
    bool esc_next = false;
-
-   Dmsg0(2000, "enter lex_get_token\n");
+   /* Unicode files, especially on Win32, may begin with a "Byte Order Mark"
+      to indicate which transmission format the file is in. The codepoint for
+      this mark is U+FEFF and is represented as the octets EF-BB-BF in UTF-8
+      and as FF-FE in UTF-16le(little endian) and  FE-FF in UTF-16(big endian).
+      We use a distinct state for UTF-8 and UTF-16le, and use bom_bytes_seen
+      to tell which byte we are expecting. */
+   int bom_bytes_seen = 0;
+
+   Dmsg1(dbglvl, "enter lex_get_token state=%s\n", lex_state_to_str(lf->state));
    while (token == T_NONE) {
       ch = lex_get_char(lf);
       switch (lf->state) {
       case lex_none:
-         Dmsg2(2000, "Lex state lex_none ch=%d,%x\n", ch, ch);
+         Dmsg2(dbglvl, "Lex state lex_none ch=%c,%d\n", ch, ch);
          if (B_ISSPACE(ch))
             break;
          if (B_ISALPHA(ch)) {
@@ -329,11 +480,11 @@ lex_get_token(LEX *lf, int expect)
             begin_str(lf, ch);
             break;
          }
-         Dmsg0(2000, "Enter lex_none switch\n");
+         Dmsg0(dbglvl, "Enter lex_none switch\n");
          switch (ch) {
          case L_EOF:
             token = T_EOF;
-            Dmsg0(2000, "got L_EOF set token=T_EOF\n");
+            Dmsg0(dbglvl, "got L_EOF set token=T_EOF\n");
             break;
          case '#':
             lf->state = lex_comment;
@@ -364,14 +515,40 @@ lex_get_token(LEX *lf, int expect)
             }
             break;
          case L_EOL:
-            Dmsg0(2000, "got L_EOL set token=T_EOL\n");
+            Dmsg0(dbglvl, "got L_EOL set token=T_EOL\n");
             if (expect != T_SKIP_EOL) {
                token = T_EOL;
             }
             break;
          case '@':
-            lf->state = lex_include;
-            begin_str(lf, 0);
+            /* In NO_EXTERN mode, @ is part of a string */
+            if (lf->options & LOPT_NO_EXTERN) {
+               lf->state = lex_string;
+               begin_str(lf, ch);
+            } else {
+               lf->state = lex_include;
+               begin_str(lf, 0);
+            }
+            break;
+         case 0xEF: /* probably a UTF-8 BOM */
+         case 0xFF: /* probably a UTF-16le BOM */
+         case 0xFE: /* probably a UTF-16be BOM (error)*/
+            if (lf->line_no != 1 || lf->col_no != 1)
+            {
+               lf->state = lex_string;
+               begin_str(lf, ch);
+            } else {
+               bom_bytes_seen = 1;
+               if (ch == 0xEF) {
+                  lf->state = lex_utf8_bom;
+               } else if (ch == 0xFF) {
+                  lf->state = lex_utf16_le_bom;
+               } else {
+                  scan_err0(lf, _("This config file appears to be in an "
+                     "unsupported Unicode format (UTF-16be). Please resave as UTF-8\n"));
+                  return T_ERROR;
+               }
+            }
             break;
          default:
             lf->state = lex_string;
@@ -380,7 +557,7 @@ lex_get_token(LEX *lf, int expect)
          }
          break;
       case lex_comment:
-         Dmsg1(2000, "Lex state lex_comment ch=%x\n", ch);
+         Dmsg1(dbglvl, "Lex state lex_comment ch=%x\n", ch);
          if (ch == L_EOL) {
             lf->state = lex_none;
             if (expect != T_SKIP_EOL) {
@@ -391,7 +568,7 @@ lex_get_token(LEX *lf, int expect)
          }
          break;
       case lex_number:
-         Dmsg2(2000, "Lex state lex_number ch=%x %c\n", ch, ch);
+         Dmsg2(dbglvl, "Lex state lex_number ch=%x %c\n", ch, ch);
          if (ch == L_EOF) {
             token = T_ERROR;
             break;
@@ -416,10 +593,10 @@ lex_get_token(LEX *lf, int expect)
             token = T_ERROR;
             break;
          }
-         Dmsg1(2000, "Lex state lex_ip_addr ch=%x\n", ch);
+         Dmsg1(dbglvl, "Lex state lex_ip_addr ch=%x\n", ch);
          break;
       case lex_string:
-         Dmsg1(2000, "Lex state lex_string ch=%x\n", ch);
+         Dmsg1(dbglvl, "Lex state lex_string ch=%x\n", ch);
          if (ch == L_EOF) {
             token = T_ERROR;
             break;
@@ -434,7 +611,7 @@ lex_get_token(LEX *lf, int expect)
          add_str(lf, ch);
          break;
       case lex_identifier:
-         Dmsg2(2000, "Lex state lex_identifier ch=%x %c\n", ch, ch);
+         Dmsg2(dbglvl, "Lex state lex_identifier ch=%x %c\n", ch, ch);
          if (B_ISALPHA(ch)) {
             add_str(lf, ch);
             break;
@@ -457,7 +634,7 @@ lex_get_token(LEX *lf, int expect)
          add_str(lf, ch);
          break;
       case lex_quoted_string:
-         Dmsg2(2000, "Lex state lex_quoted_string ch=%x %c\n", ch, ch);
+         Dmsg2(dbglvl, "Lex state lex_quoted_string ch=%x %c\n", ch, ch);
          if (ch == L_EOF) {
             token = T_ERROR;
             break;
@@ -477,38 +654,107 @@ lex_get_token(LEX *lf, int expect)
          }
          if (ch == '"') {
             token = T_QUOTED_STRING;
+            /*
+             * Since we may be scanning a quoted list of names,
+             *  we get the next character (a comma indicates another
+             *  one), then we put it back for rescanning.
+             */
+            lex_get_char(lf);
+            lex_unget_char(lf);
             lf->state = lex_none;
             break;
          }
          add_str(lf, ch);
          break;
+      case lex_include_quoted_string:
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
+         if (esc_next) {
+            add_str(lf, ch);
+            esc_next = false;
+            break;
+         }
+         if (ch == '\\') {
+            esc_next = true;
+            break;
+         }
+         if (ch == '"') {
+            /* Keep the original LEX so we can print an error if the included file can't be opened. */
+            LEX* lfori = lf;
+            /* Skip the double quote when restarting parsing */
+            lex_get_char(lf);
+
+            lf->state = lex_none;
+            lf = lex_open_file(lf, lf->str, lf->scan_error);
+            if (lf == NULL) {
+               berrno be;
+               scan_err2(lfori, _("Cannot open included config file %s: %s\n"),
+                  lfori->str, be.bstrerror());
+               return T_ERROR;
+            }
+            break;
+         }
+         add_str(lf, ch);
+         break;
       case lex_include:            /* scanning a filename */
          if (ch == L_EOF) {
             token = T_ERROR;
             break;
          }
+         if (ch == '"') {
+            lf->state = lex_include_quoted_string;
+            break;
+         }
+
+
          if (B_ISSPACE(ch) || ch == '\n' || ch == L_EOL || ch == '}' || ch == '{' ||
              ch == ';' || ch == ','   || ch == '"' || ch == '#') {
             /* Keep the original LEX so we can print an error if the included file can't be opened. */
             LEX* lfori = lf;
-            
+
             lf->state = lex_none;
-            lf = lex_open_file(lf, lf->str, NULL);
+            lf = lex_open_file(lf, lf->str, lf->scan_error);
             if (lf == NULL) {
                berrno be;
                scan_err2(lfori, _("Cannot open included config file %s: %s\n"),
-                  lfori->str, be.strerror());
+                  lfori->str, be.bstrerror());
                return T_ERROR;
             }
             break;
          }
          add_str(lf, ch);
          break;
+      case lex_utf8_bom:
+         /* we only end up in this state if we have read an 0xEF
+            as the first byte of the file, indicating we are probably
+            reading a UTF-8 file */
+         if (ch == 0xBB && bom_bytes_seen == 1) {
+            bom_bytes_seen++;
+         } else if (ch == 0xBF && bom_bytes_seen == 2) {
+            token = T_UTF8_BOM;
+            lf->state = lex_none;
+         } else {
+            token = T_ERROR;
+         }
+         break;
+      case lex_utf16_le_bom:
+         /* we only end up in this state if we have read an 0xFF
+            as the first byte of the file -- indicating that we are
+            probably dealing with an Intel based (little endian) UTF-16 file*/
+         if (ch == 0xFE) {
+            token = T_UTF16_BOM;
+            lf->state = lex_none;
+         } else {
+            token = T_ERROR;
+         }
+         break;
       }
-      Dmsg4(2000, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state),
+      Dmsg4(dbglvl, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state),
         lex_tok_to_str(token), ch);
    }
-   Dmsg2(2000, "lex returning: line %d token: %s\n", lf->line_no, lex_tok_to_str(token));
+   Dmsg2(dbglvl, "lex returning: line %d token: %s\n", lf->line_no, lex_tok_to_str(token));
    lf->token = token;
 
    /*
@@ -562,7 +808,7 @@ lex_get_token(LEX *lf, int expect)
       break;
 
    case T_INT64:
-      Dmsg2(2000, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL));
+      Dmsg2(dbglvl, "int64=:%s: %f\n", lf->str, strtod(lf->str, NULL));
       if (token != T_NUMBER || !is_a_number(lf->str)) {
          scan_err2(lf, _("expected an integer number, got %s: %s"),
                lex_tok_to_str(token), lf->str);
@@ -580,6 +826,26 @@ lex_get_token(LEX *lf, int expect)
       }
       break;
 
+   case T_PINT64_RANGE:
+      if (token == T_NUMBER) {
+         lf->pint64_val = scan_pint64(lf, lf->str);
+         lf->pint64_val2 = lf->pint64_val;
+         token = T_PINT64;
+      } else {
+         char *p = strchr(lf->str, '-');
+         if (!p) {
+            scan_err2(lf, _("expected an integer or a range, got %s: %s"),
+               lex_tok_to_str(token), lf->str);
+            token = T_ERROR;
+            break;
+         }
+         *p++ = 0;                       /* terminate first half of range */
+         lf->pint64_val  = scan_pint64(lf, lf->str);
+         lf->pint64_val2 = scan_pint64(lf, p);
+         token = T_PINT64_RANGE;
+      }
+      break;
+
    case T_NAME:
       if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
          scan_err2(lf, _("expected a name, got %s: %s"),