]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/lex.c
Working directory pane in restore. Will get this into the stack next.
[bacula/bacula] / bacula / src / lib / lex.c
index 11b9af015639f7bda9f64e1c82df3dda8feb6baa..e7fcc559e521bac84fe5bc05c97ea0728118bdd0 100644 (file)
@@ -1,3 +1,30 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   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 should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  * Lexical scanner for Bacula configuration file
  *
@@ -6,21 +33,6 @@
  *   Version $Id$
  *
  */
-/*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   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 
-   the file LICENSE for additional details.
-
- */
-
 
 #include "bacula.h"
 #include "lex.h"
@@ -155,7 +167,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
    char *fname = bstrdup(filename);
 
 
-   if ((fd = fopen(fname, "r")) == NULL) {
+   if ((fd = fopen(fname, "rb")) == NULL) {
       return NULL;
    }
    Dmsg1(400, "Open config file: %s\n", fname);
@@ -324,6 +336,7 @@ lex_get_token(LEX *lf, int expect)
    int ch;
    int token = T_NONE;
    bool esc_next = false;
+   int unicode_count = 0;
 
    Dmsg0(dbglvl, "enter lex_get_token\n");
    while (token == T_NONE) {
@@ -395,6 +408,16 @@ lex_get_token(LEX *lf, int expect)
             lf->state = lex_include;
             begin_str(lf, 0);
             break;
+         case 0xEF:
+            if (lf->line_no != 1 || lf->col_no != 1)
+            {
+               lf->state = lex_string;
+               begin_str(lf, ch);
+               break;
+            }
+            lf->state = lex_unicode_mark;
+            unicode_count = 1;
+            break;
          default:
             lf->state = lex_string;
             begin_str(lf, ch);
@@ -526,6 +549,27 @@ lex_get_token(LEX *lf, int expect)
          }
          add_str(lf, ch);
          break;
+      case lex_unicode_mark:
+         if (ch == L_EOF) {
+            token = T_ERROR;
+            break;
+         }
+         unicode_count++;
+         if (unicode_count == 2) {
+            if (ch != 0xBB) {
+               token = T_ERROR;
+               break;
+            }
+         } else if (unicode_count == 3) {
+            if (ch != 0xBF) {
+               token = T_ERROR;
+               break;
+            }
+            token = T_UNICODE_MARK;
+            lf->state = lex_none;
+            break;
+         }
+         break;
       }
       Dmsg4(dbglvl, "ch=%d state=%s token=%s %c\n", ch, lex_state_to_str(lf->state),
         lex_tok_to_str(token), ch);