1 /* Copyright (c) 2000, 2021, 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 also distributed 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 included with MySQL.
13 
14    Without limiting anything contained in the foregoing, this file,
15    which is part of C Driver for MySQL (Connector/C), is also subject to the
16    Universal FOSS Exception, version 1.0, a copy of which can be found at
17    http://oss.oracle.com/licenses/universal-foss-exception.
18 
19    This program is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    GNU General Public License, version 2.0, for more details.
23 
24    You should have received a copy of the GNU General Public License
25    along with this program; if not, write to the Free Software
26    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
27 
28 
29 #ifndef _typelib_h
30 #define _typelib_h
31 
32 #include "my_alloc.h"
33 
34 typedef struct st_typelib {	/* Different types saved here */
35   unsigned int count;		/* How many types */
36   const char *name;		/* Name of typelib */
37   const char **type_names;
38   unsigned int *type_lengths;
39 } TYPELIB;
40 
41 extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
42 extern int find_type_or_exit(const char *x, TYPELIB *typelib,
43                              const char *option);
44 #define FIND_TYPE_BASIC           0
45 /** makes @c find_type() require the whole name, no prefix */
46 #define FIND_TYPE_NO_PREFIX      (1 << 0)
47 /** always implicitely on, so unused, but old code may pass it */
48 #define FIND_TYPE_NO_OVERWRITE   (1 << 1)
49 /** makes @c find_type() accept a number */
50 #define FIND_TYPE_ALLOW_NUMBER   (1 << 2)
51 /** makes @c find_type() treat ',' as terminator */
52 #define FIND_TYPE_COMMA_TERM     (1 << 3)
53 
54 extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
55 extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
56 extern const char *get_type(TYPELIB *typelib,unsigned int nr);
57 extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from);
58 
59 extern TYPELIB sql_protocol_typelib;
60 
61 my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name,
62                               my_ulonglong cur_set, my_ulonglong default_set,
63                               const char *str, unsigned int length,
64                               char **err_pos, unsigned int *err_len);
65 
66 #endif /* _typelib_h */
67