3 Copyright (c) 2004-2007 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
4 Use is subject to license terms.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _PARSE_FILE_H_
21 #define _PARSE_FILE_H_
23 #define PARSE_FILE_TIMESTAMPLENGTH 19
26 FILE_OPTIONS_STRING
, /**< String (LEX_STRING) */
27 FILE_OPTIONS_ESTRING
, /**< Escaped string (LEX_STRING) */
28 FILE_OPTIONS_ULONGLONG
, /**< ulonglong parameter (ulonglong) */
29 FILE_OPTIONS_TIMESTAMP
, /**< timestamp (LEX_STRING have to be
30 allocated with length 20 (19+1) */
31 FILE_OPTIONS_STRLIST
, /**< list of escaped strings
33 FILE_OPTIONS_ULLLIST
/**< list of ulonglong values
39 LEX_STRING name
; /**< Name of the option */
40 int offset
; /**< offset to base address of value */
41 file_opt_type type
; /**< Option type */
46 This hook used to catch no longer supported keys and process them for
47 backward compatibility.
50 class Unknown_key_hook
53 Unknown_key_hook() {} /* Remove gcc warning */
54 virtual ~Unknown_key_hook() {} /* Remove gcc warning */
55 virtual bool process_unknown_string(char *&unknown_key
, uchar
* base
,
56 MEM_ROOT
*mem_root
, char *end
)= 0;
60 /** Dummy hook for parsers which do not need hook for unknown keys. */
62 class File_parser_dummy_hook
: public Unknown_key_hook
65 File_parser_dummy_hook() {} /* Remove gcc warning */
66 virtual bool process_unknown_string(char *&unknown_key
, uchar
* base
,
67 MEM_ROOT
*mem_root
, char *end
);
70 extern File_parser_dummy_hook file_parser_dummy_hook
;
72 bool get_file_options_ulllist(char *&ptr
, char *end
, char *line
,
73 uchar
* base
, File_option
*parameter
,
77 parse_escaped_string(char *ptr
, char *end
, MEM_ROOT
*mem_root
, LEX_STRING
*str
);
80 File_parser
*sql_parse_prepare(const LEX_STRING
*file_name
,
81 MEM_ROOT
*mem_root
, bool bad_format_errors
);
84 sql_create_definition_file(const LEX_STRING
*dir
, const LEX_STRING
*file_name
,
85 const LEX_STRING
*type
,
86 uchar
* base
, File_option
*parameters
);
87 my_bool
rename_in_schema_file(THD
*thd
,
88 const char *schema
, const char *old_name
,
89 const char *new_db
, const char *new_name
);
91 class File_parser
: public Sql_alloc
93 char *buff
, *start
, *end
;
97 File_parser() :buff(0), start(0), end(0), content_ok(0)
98 { file_type
.str
= 0; file_type
.length
= 0; }
100 my_bool
ok() { return content_ok
; }
101 LEX_STRING
*type() { return &file_type
; }
102 my_bool
parse(uchar
* base
, MEM_ROOT
*mem_root
,
103 struct File_option
*parameters
, uint required
,
104 Unknown_key_hook
*hook
);
106 friend File_parser
*sql_parse_prepare(const LEX_STRING
*file_name
,
108 bool bad_format_errors
);
110 #endif /* _PARSE_FILE_H_ */