2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation plus additions
11 that are listed in the file LICENSE.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
31 * Lexical scanning of configuration files, used by parsers.
42 /* Lex get_char() return values */
49 /* Tokens returned by get_token() */
53 #define T_IDENTIFIER 104
54 #define T_UNQUOTED_STRING 105
55 #define T_QUOTED_STRING 106
56 #define T_BOB 108 /* begin block */
57 #define T_EOB 109 /* end of block */
62 #define T_UNICODE_MARK 201
65 * The following will be returned only if
66 * the appropriate expect flag has been set
68 #define T_SKIP_EOL 113 /* scan through EOLs */
69 #define T_PINT32 114 /* positive integer */
70 #define T_PINT32_RANGE 115 /* positive integer range */
71 #define T_INT32 116 /* integer */
72 #define T_INT64 117 /* 64 bit integer */
73 #define T_NAME 118 /* name max 128 chars */
74 #define T_STRING 119 /* string */
76 #define T_ALL 0 /* no expectations */
91 /* Lex scan options */
92 #define LOPT_NO_IDENT 0x1 /* No Identifiers -- use string */
93 #define LOPT_STRING 0x2 /* Force scan for string */
95 class BPIPE; /* forward reference */
98 typedef struct s_lex_context {
99 struct s_lex_context *next; /* pointer to next lexical context */
100 int options; /* scan options */
101 char *fname; /* filename */
102 FILE *fd; /* file descriptor */
103 char line[MAXSTRING]; /* input line */
104 char str[MAXSTRING]; /* string being scanned */
105 int str_len; /* length of string */
106 int line_no; /* file line number */
107 int col_no; /* char position on line */
108 int begin_line_no; /* line no of beginning of string */
109 enum lex_state state; /* lex_state variable */
110 int ch; /* last char/L_VAL returned by get_char */
113 uint32_t pint32_val2;
116 void (*scan_error)(const char *file, int line, struct s_lex_context *lc, const char *msg, ...);
117 int err_type; /* message level for scan_error (M_..) */
118 void *caller_ctx; /* caller private data */
119 BPIPE *bpipe; /* set if we are piping */
122 typedef void (LEX_ERROR_HANDLER)(const char *file, int line, LEX *lc, const char *msg, ...);
124 /* Lexical scanning errors in parsing conf files */
125 #define scan_err0(lc, msg) lc->scan_error(__FILE__, __LINE__, lc, msg)
126 #define scan_err1(lc, msg, a1) lc->scan_error(__FILE__, __LINE__, lc, msg, a1)
127 #define scan_err2(lc, msg, a1, a2) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2)
128 #define scan_err3(lc, msg, a1, a2, a3) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3)
129 #define scan_err4(lc, msg, a1, a2, a3, a4) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4)
130 #define scan_err5(lc, msg, a1, a2, a3, a4, a5) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4, a5)
131 #define scan_err6(lc, msg, a1, a2, a3, a4, a5, a6) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4, a5, a6)
133 void scan_to_eol(LEX *lc);
134 int scan_to_next_not_eol(LEX * lc);