1/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2 Copyright (c) 2017, MariaDB Corporation.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16
17
18#ifndef _typelib_h
19#define _typelib_h
20
21#include "my_alloc.h"
22
23typedef struct st_typelib { /* Different types saved here */
24 unsigned int count; /* How many types */
25 const char *name; /* Name of typelib */
26 const char **type_names;
27 unsigned int *type_lengths;
28} TYPELIB;
29
30extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
31extern int find_type_with_warning(const char *x, TYPELIB *typelib,
32 const char *option);
33#define FIND_TYPE_BASIC 0
34/** makes @c find_type() require the whole name, no prefix */
35#define FIND_TYPE_NO_PREFIX (1U << 0)
36/** always implicitly on, so unused, but old code may pass it */
37#define FIND_TYPE_NO_OVERWRITE 0
38/** makes @c find_type() accept a number. Not used either */
39#define FIND_TYPE_ALLOW_NUMBER 0
40/** makes @c find_type() treat ',' and '=' as terminators */
41#define FIND_TYPE_COMMA_TERM (1U << 3)
42
43extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
44extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
45extern const char *get_type(TYPELIB *typelib,unsigned int nr);
46extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
47
48extern TYPELIB sql_protocol_typelib;
49
50my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name,
51 my_ulonglong cur_set, my_ulonglong default_set,
52 const char *str, unsigned int length,
53 char **err_pos, unsigned int *err_len);
54
55#endif /* _typelib_h */
56