The world's most popular open source database
00001 /* -*- C++ -*- */ 00002 /* Copyright (C) 2004 MySQL AB 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00017 00018 #ifndef _PARSE_FILE_H_ 00019 #define _PARSE_FILE_H_ 00020 00021 #define PARSE_FILE_TIMESTAMPLENGTH 19 00022 00023 enum file_opt_type { 00024 FILE_OPTIONS_STRING, /* String (LEX_STRING) */ 00025 FILE_OPTIONS_ESTRING, /* Escaped string (LEX_STRING) */ 00026 FILE_OPTIONS_ULONGLONG, /* ulonglong parameter (ulonglong) */ 00027 FILE_OPTIONS_REV, /* Revision version number (ulonglong) */ 00028 FILE_OPTIONS_TIMESTAMP, /* timestamp (LEX_STRING have to be 00029 allocated with length 20 (19+1) */ 00030 FILE_OPTIONS_STRLIST, /* list of escaped strings 00031 (List<LEX_STRING>) */ 00032 FILE_OPTIONS_ULLLIST /* list of ulonglong values 00033 (List<ulonglong>) */ 00034 }; 00035 00036 struct File_option 00037 { 00038 LEX_STRING name; /* Name of the option */ 00039 int offset; /* offset to base address of value */ 00040 file_opt_type type; /* Option type */ 00041 }; 00042 00043 00044 /* 00045 This hook used to catch no longer supported keys and process them for 00046 backward compatibility. 00047 */ 00048 00049 class Unknown_key_hook 00050 { 00051 public: 00052 Unknown_key_hook() {} /* Remove gcc warning */ 00053 virtual ~Unknown_key_hook() {} /* Remove gcc warning */ 00054 virtual bool process_unknown_string(char *&unknown_key, gptr base, 00055 MEM_ROOT *mem_root, char *end)= 0; 00056 }; 00057 00058 00059 /* Dummy hook for parsers which do not need hook for unknown keys */ 00060 00061 class File_parser_dummy_hook: public Unknown_key_hook 00062 { 00063 public: 00064 File_parser_dummy_hook() {} /* Remove gcc warning */ 00065 virtual bool process_unknown_string(char *&unknown_key, gptr base, 00066 MEM_ROOT *mem_root, char *end); 00067 }; 00068 00069 extern File_parser_dummy_hook file_parser_dummy_hook; 00070 00071 bool get_file_options_ulllist(char *&ptr, char *end, char *line, 00072 gptr base, File_option *parameter, 00073 MEM_ROOT *mem_root); 00074 00075 char * 00076 parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str); 00077 00078 class File_parser; 00079 File_parser *sql_parse_prepare(const LEX_STRING *file_name, 00080 MEM_ROOT *mem_root, bool bad_format_errors); 00081 00082 my_bool 00083 sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, 00084 const LEX_STRING *type, 00085 gptr base, File_option *parameters, uint versions); 00086 my_bool rename_in_schema_file(const char *schema, const char *old_name, 00087 const char *new_name, ulonglong revision, 00088 uint num_view_backups); 00089 00090 class File_parser: public Sql_alloc 00091 { 00092 char *buff, *start, *end; 00093 LEX_STRING file_type; 00094 my_bool content_ok; 00095 public: 00096 File_parser() :buff(0), start(0), end(0), content_ok(0) 00097 { file_type.str= 0; file_type.length= 0; } 00098 00099 my_bool ok() { return content_ok; } 00100 LEX_STRING *type() { return &file_type; } 00101 my_bool parse(gptr base, MEM_ROOT *mem_root, 00102 struct File_option *parameters, uint required, 00103 Unknown_key_hook *hook); 00104 00105 friend File_parser *sql_parse_prepare(const LEX_STRING *file_name, 00106 MEM_ROOT *mem_root, 00107 bool bad_format_errors); 00108 }; 00109 00110 #endif /* _PARSE_FILE_H_ */
1.4.7

