MySQL 9.0.0
Source Code Documentation
parse_file.h
Go to the documentation of this file.
1/* Copyright (c) 2004, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef _PARSE_FILE_H_
25#define _PARSE_FILE_H_
26
27#include <stddef.h>
28#include <sys/types.h>
29
30#include "lex_string.h"
31#include "my_inttypes.h"
32
33struct MEM_ROOT;
34
35#define PARSE_FILE_TIMESTAMPLENGTH 19
36
38 FILE_OPTIONS_STRING, /**< String (LEX_STRING) */
39 FILE_OPTIONS_ESTRING, /**< Escaped string (LEX_STRING) */
40 FILE_OPTIONS_ULONGLONG, /**< ulonglong parameter (ulonglong) */
41 FILE_OPTIONS_TIMESTAMP, /**< timestamp (LEX_STRING have to be
42 allocated with length 20 (19+1) */
43 FILE_OPTIONS_STRLIST, /**< list of escaped strings
44 (List<LEX_STRING>) */
45 FILE_OPTIONS_ULLLIST /**< list of ulonglong values
46 (List<ulonglong>) */
47};
48
50 LEX_CSTRING name; /**< Name of the option */
51 size_t offset; /**< offset to base address of value */
52 file_opt_type type; /**< Option type */
53};
54
55/**
56 This hook used to catch no longer supported keys and process them for
57 backward compatibility.
58*/
59
61 public:
62 virtual ~Unknown_key_hook() = default;
63 virtual bool process_unknown_string(const char *&unknown_key, uchar *base,
64 MEM_ROOT *mem_root, const char *end) = 0;
65};
66
67/**
68 Dummy hook for parsers which do not need hook for unknown keys.
69*/
71 public:
72 bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *,
73 const char *) override;
74};
75
77
78bool get_file_options_ulllist(const char *&ptr, const char *end,
79 const char *line, uchar *base,
80 File_option *parameter, MEM_ROOT *mem_root);
81
82class File_parser;
83
85 bool bad_format_errors);
86
88 const char *start, *end;
91
92 public:
94 file_type.str = nullptr;
95 file_type.length = 0;
96 }
97
98 bool ok() { return content_ok; }
99 const LEX_CSTRING &type() const { return file_type; }
100 bool parse(uchar *base, MEM_ROOT *mem_root, struct File_option *parameters,
101 uint required, Unknown_key_hook *hook) const;
102
105 bool bad_format_errors);
106};
107#endif /* _PARSE_FILE_H_ */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Dummy hook for parsers which do not need hook for unknown keys.
Definition: parse_file.h:70
bool process_unknown_string(const char *&unknown_key, uchar *, MEM_ROOT *, const char *) override
Dummy unknown key hook.
Definition: parse_file.cc:521
Definition: parse_file.h:87
bool content_ok
Definition: parse_file.h:90
LEX_CSTRING file_type
Definition: parse_file.h:89
bool ok()
Definition: parse_file.h:98
friend File_parser * sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, bool bad_format_errors)
Prepare frm to parse (read to memory).
Definition: parse_file.cc:62
const LEX_CSTRING & type() const
Definition: parse_file.h:99
File_parser()
Definition: parse_file.h:93
const char * end
Definition: parse_file.h:88
const char * start
Definition: parse_file.h:88
bool parse(uchar *base, MEM_ROOT *mem_root, struct File_option *parameters, uint required, Unknown_key_hook *hook) const
parse parameters.
Definition: parse_file.cc:345
This hook used to catch no longer supported keys and process them for backward compatibility.
Definition: parse_file.h:60
virtual bool process_unknown_string(const char *&unknown_key, uchar *base, MEM_ROOT *mem_root, const char *end)=0
virtual ~Unknown_key_hook()=default
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
File_parser * sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, bool bad_format_errors)
Prepare frm to parse (read to memory).
Definition: parse_file.cc:62
file_opt_type
Definition: parse_file.h:37
@ FILE_OPTIONS_STRING
String (LEX_STRING)
Definition: parse_file.h:38
@ FILE_OPTIONS_ULONGLONG
ulonglong parameter (ulonglong)
Definition: parse_file.h:40
@ FILE_OPTIONS_ESTRING
Escaped string (LEX_STRING)
Definition: parse_file.h:39
@ FILE_OPTIONS_ULLLIST
list of ulonglong values (List<ulonglong>)
Definition: parse_file.h:45
@ FILE_OPTIONS_TIMESTAMP
timestamp (LEX_STRING have to be allocated with length 20 (19+1)
Definition: parse_file.h:41
@ FILE_OPTIONS_STRLIST
list of escaped strings (List<LEX_STRING>)
Definition: parse_file.h:43
bool get_file_options_ulllist(const char *&ptr, const char *end, const char *line, uchar *base, File_option *parameter, MEM_ROOT *mem_root)
Parser for FILE_OPTIONS_ULLLIST type value.
Definition: parse_file.cc:289
File_parser_dummy_hook file_parser_dummy_hook
Definition: parse_file.cc:44
Definition: parse_file.h:49
file_opt_type type
Option type.
Definition: parse_file.h:52
size_t offset
offset to base address of value
Definition: parse_file.h:51
LEX_CSTRING name
Name of the option.
Definition: parse_file.h:50
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35