2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
19 * Lexical scanning of configuration files, used by parsers.
28 /* Lex get_char() return values */
35 /* Tokens returned by get_token() */
39 #define T_IDENTIFIER 104
40 #define T_UNQUOTED_STRING 105
41 #define T_QUOTED_STRING 106
42 #define T_BOB 108 /* begin block */
43 #define T_EOB 109 /* end of block */
48 #define T_UTF8_BOM 201 /* File starts with a UTF-8 BOM*/
49 #define T_UTF16_BOM 202 /* File starts with a UTF-16LE BOM*/
52 * The following will be returned only if
53 * the appropriate expect flag has been set
55 #define T_SKIP_EOL 113 /* scan through EOLs */
56 #define T_PINT32 114 /* positive integer */
57 #define T_PINT32_RANGE 115 /* positive integer range */
58 #define T_INT32 116 /* integer */
59 #define T_INT64 117 /* 64 bit integer */
60 #define T_NAME 118 /* name max 128 chars */
61 #define T_STRING 119 /* string */
62 #define T_PINT64_RANGE 120 /* positive integer range */
63 #define T_PINT64 121 /* positive integer range */
65 #define T_ALL 0 /* no expectations */
76 lex_include_quoted_string,
78 lex_utf8_bom, /* we are parsing out a utf8 byte order mark */
79 lex_utf16_le_bom /* we are parsing out a utf-16 (little endian) byte order mark */
82 /* Lex scan options */
83 #define LOPT_NO_IDENT 0x1 /* No Identifiers -- use string */
84 #define LOPT_STRING 0x2 /* Force scan for string */
85 #define LOPT_NO_EXTERN 0x4 /* Don't follow @ command */
87 class BPIPE; /* forward reference */
90 typedef struct s_lex_context {
91 struct s_lex_context *next; /* pointer to next lexical context */
92 int options; /* scan options */
93 char *fname; /* filename */
94 FILE *fd; /* file descriptor */
95 POOLMEM *line; /* input line */
96 char str[MAXSTRING]; /* string being scanned */
97 int str_len; /* length of string */
98 int line_no; /* file line number */
99 int col_no; /* char position on line */
100 int begin_line_no; /* line no of beginning of string */
101 enum lex_state state; /* lex_state variable */
102 int ch; /* last char/L_VAL returned by get_char */
105 uint32_t pint32_val2;
109 uint64_t pint64_val2;
110 void (*scan_error)(const char *file, int line, struct s_lex_context *lc, const char *msg, ...);
111 int err_type; /* message level for scan_error (M_..) */
112 void *caller_ctx; /* caller private data */
113 BPIPE *bpipe; /* set if we are piping */
116 typedef void (LEX_ERROR_HANDLER)(const char *file, int line, LEX *lc, const char *msg, ...);
118 /* Lexical scanning errors in parsing conf files */
119 #define scan_err0(lc, msg) lc->scan_error(__FILE__, __LINE__, lc, msg)
120 #define scan_err1(lc, msg, a1) lc->scan_error(__FILE__, __LINE__, lc, msg, a1)
121 #define scan_err2(lc, msg, a1, a2) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2)
122 #define scan_err3(lc, msg, a1, a2, a3) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3)
123 #define scan_err4(lc, msg, a1, a2, a3, a4) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4)
124 #define scan_err5(lc, msg, a1, a2, a3, a4, a5) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4, a5)
125 #define scan_err6(lc, msg, a1, a2, a3, a4, a5, a6) lc->scan_error(__FILE__, __LINE__, lc, msg, a1, a2, a3, a4, a5, a6)
127 void scan_to_eol(LEX *lc);
128 int scan_to_next_not_eol(LEX * lc);