1/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2
3 This library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
7
8 This library 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 GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public
14 License along with this library; if not, write to the Free
15 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 MA 02111-1301, USA */
17
18#ifndef _my_sys_h
19#define _my_sys_h
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#ifdef HAVE_AIOWAIT
25#include <sys/asynch.h> /* Used by record-cache */
26typedef struct my_aio_result {
27 aio_result_t result;
28 int pending;
29} my_aio_result;
30#endif
31
32#ifndef _mariadb_ctype_h
33#include <mariadb_ctype.h> /* for MARIADB_CHARSET_INFO */
34#endif
35
36#include <stdarg.h>
37
38#define MYSYS_PROGRAM_USES_CURSES() { ma_error_handler_hook = ma_message_curses; mysys_uses_curses=1; }
39#define MYSYS_PROGRAM_DONT_USE_CURSES() { ma_error_handler_hook = ma_message_no_curses; mysys_uses_curses=0;}
40#define MY_INIT(name); { ma_progname= name; ma_init(); }
41
42#define MAXMAPS (4) /* Number of error message maps */
43#define ERRMOD (1000) /* Max number of errors in a map */
44#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */
45#define NRERRBUFFS (2) /* Buffers for parameters */
46#define MY_FILE_ERROR ((uint) ~0)
47
48 /* General bitmaps for my_func's */
49#define MY_FFNF 1 /* Fatal if file not found */
50#define MY_FNABP 2 /* Fatal if not all bytes read/written */
51#define MY_NABP 4 /* Error if not all bytes read/written */
52#define MY_FAE 8 /* Fatal if any error */
53#define MY_WME 16 /* Write message on error */
54#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
55#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
56#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
57#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
58#define MY_COPYTIME 64 /* my_redel() copies time */
59#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
60#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
61#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
62#define MY_REDEL_MAKE_BACKUP 256
63#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
64#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
65#define MY_ZEROFILL 32 /* ma_malloc(), fill array with zero */
66#define MY_ALLOW_ZERO_PTR 64 /* ma_realloc() ; zero ptr -> malloc */
67#define MY_FREE_ON_ERROR 128 /* ma_realloc() ; Free old ptr on error */
68#define MY_HOLD_ON_ERROR 256 /* ma_realloc() ; Return old ptr on error */
69#define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */
70#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */
71
72#define MY_CHECK_ERROR 1 /* Params to ma_end; Check open-close */
73#define MY_GIVE_INFO 2 /* Give time info about process*/
74
75#define ME_HIGHBYTE 8 /* Shift for colours */
76#define ME_NOCUR 1 /* Don't use curses message */
77#define ME_OLDWIN 2 /* Use old window */
78#define ME_BELL 4 /* Ring bell then printing message */
79#define ME_HOLDTANG 8 /* Don't delete last keys */
80#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */
81#define ME_WAITTANG 32 /* Wait for a user action */
82#define ME_NOREFRESH 64 /* Don't refresh screen */
83#define ME_NOINPUT 128 /* Don't use the input library */
84#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */
85#define ME_COLOUR2 ((2 << ME_HIGHBYTE))
86#define ME_COLOUR3 ((3 << ME_HIGHBYTE))
87
88 /* My seek flags */
89#define MY_SEEK_SET 0
90#define MY_SEEK_CUR 1
91#define MY_SEEK_END 2
92
93 /* My charsets_list flags */
94#define MY_NO_SETS 0
95#define MY_COMPILED_SETS 1 /* show compiled-in sets */
96#define MY_CONFIG_SETS 2 /* sets that have a *.conf file */
97#define MY_INDEX_SETS 4 /* all sets listed in the Index file */
98#define MY_LOADED_SETS 8 /* the sets that are currently loaded */
99
100 /* Some constants */
101#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
102#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
103#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
104#define KEYCACHE_BLOCK_SIZE 1024
105
106 /* root_alloc flags */
107#define MY_KEEP_PREALLOC 1
108
109 /* defines when allocating data */
110
111#define my_checkmalloc() (0)
112#undef TERMINATE
113#define TERMINATE(A) {}
114#define QUICK_SAFEMALLOC
115#define NORMAL_SAFEMALLOC
116#define ma_malloc_ci(SZ,FLAG) ma_malloc( SZ, FLAG )
117#define CALLER_INFO_PROTO /* nothing */
118#define CALLER_INFO /* nothing */
119#define ORIG_CALLER_INFO /* nothing */
120
121#ifdef HAVE_ALLOCA
122#if defined(_AIX) && !defined(__GNUC__)
123#pragma alloca
124#endif /* _AIX */
125#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
126#ifndef alloca
127#define alloca __builtin_alloca
128#endif
129#endif /* GNUC */
130#define my_alloca(SZ) alloca((size_t) (SZ))
131#define my_afree(PTR) {}
132#else
133#define my_alloca(SZ) ma_malloc(SZ,MYF(0))
134#define my_afree(PTR) ma_free(PTR)
135#endif /* HAVE_ALLOCA */
136
137#ifdef MSDOS
138#ifdef __ZTC__
139void * __CDECL halloc(long count,size_t length);
140void __CDECL hfree(void *ptr);
141#endif
142#if defined(USE_HALLOC)
143#if defined(_VCM_) || defined(M_IC80386)
144#undef USE_HALLOC
145#endif
146#endif
147#ifdef USE_HALLOC
148#define malloc(a) halloc((long) (a),1)
149#define free(a) hfree(a)
150#endif
151#endif /* MSDOS */
152
153#ifndef errno
154#ifdef HAVE_ERRNO_AS_DEFINE
155#include <errno.h> /* errno is a define */
156#else
157extern int errno; /* declare errno */
158#endif
159#endif
160extern const char ** NEAR my_errmsg[];
161extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
162/* tbr
163extern int (*ma_error_handler_hook)(uint my_err, const char *str,myf MyFlags);
164extern int (*fatal_ma_error_handler_hook)(uint my_err, const char *str,
165 myf MyFlags);
166*/
167
168/* charsets */
169/* tbr
170extern uint get_charset_number(const char *cs_name);
171extern const char *get_charset_name(uint cs_number);
172extern my_bool set_default_charset(uint cs, myf flags);
173extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
174extern void free_charsets(void);
175extern char *list_charsets(myf want_flags);
176extern char *get_charsets_dir(char *buf);
177*/
178extern MARIADB_CHARSET_INFO *get_charset(uint cs_number, myf flags);
179extern MARIADB_CHARSET_INFO *get_charset_by_name(const char *cs_name);
180extern MARIADB_CHARSET_INFO *get_charset_by_nr(uint cs_number);
181
182/* string functions */
183char *ma_strmake(register char *dst, register const char *src, size_t length);
184
185/* statistics */
186#ifdef TBR
187extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
188 _my_cache_read;
189extern ulong _my_blocks_used,_my_blocks_changed;
190extern ulong ma_file_opened,ma_stream_opened, ma_tmp_file_created;
191extern my_bool key_cache_inited;
192
193 /* Point to current ma_message() */
194extern void (*my_sigtstp_cleanup)(void),
195 /* Executed before jump to shell */
196 (*my_sigtstp_restart)(void),
197 (*my_abort_hook)(int);
198 /* Executed when coming from shell */
199extern int NEAR ma_umask, /* Default creation mask */
200 NEAR ma_umask_dir,
201 NEAR my_recived_signals, /* Signals we have got */
202 NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
203 NEAR ma_dont_interrupt; /* call remember_intr when set */
204extern my_bool NEAR mysys_uses_curses, ma_use_symdir;
205extern size_t lCurMemory,lMaxMemory; /* from safemalloc */
206
207extern ulong ma_default_record_cache_size;
208extern my_bool NEAR ma_disable_locking,NEAR ma_disable_async_io,
209 NEAR ma_disable_flush_key_blocks, NEAR ma_disable_symlinks;
210extern char wild_many,wild_one,wild_prefix;
211extern const char *charsets_dir;
212extern char *defaults_extra_file;
213typedef struct wild_file_pack /* Struct to hold info when selecting files */
214{
215 uint wilds; /* How many wildcards */
216 uint not_pos; /* Start of not-theese-files */
217 my_string *wild; /* Pointer to wildcards */
218} WF_PACK;
219
220struct my_rnd_struct {
221 unsigned long seed1,seed2,max_value;
222 double max_value_dbl;
223};
224
225#endif
226typedef struct st_typelib { /* Different types saved here */
227 uint count; /* How many types */
228 const char *name; /* Name of typelib */
229 const char **type_names;
230} TYPELIB;
231
232enum cache_type {READ_CACHE,WRITE_CACHE,READ_FIFO,READ_NET,WRITE_NET};
233enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED,
234 FLUSH_FORCE_WRITE};
235
236typedef struct st_record_cache /* Used when caching records */
237{
238 File file;
239 int rc_seek,error,inited;
240 uint rc_length,read_length,reclength;
241 my_off_t rc_record_pos,end_of_file;
242 unsigned char *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
243#ifdef HAVE_AIOWAIT
244 int use_async_io;
245 my_aio_result aio_result;
246#endif
247 enum cache_type type;
248} RECORD_CACHE;
249
250
251typedef struct st_dynamic_array {
252 char *buffer;
253 uint elements,max_element;
254 uint alloc_increment;
255 uint size_of_element;
256} DYNAMIC_ARRAY;
257
258typedef struct st_dynamic_string {
259 char *str;
260 size_t length,max_length,alloc_increment;
261} DYNAMIC_STRING;
262
263
264typedef struct st_io_cache /* Used when caching files */
265{
266 my_off_t pos_in_file,end_of_file;
267 unsigned char *rc_pos,*rc_end,*buffer,*rc_request_pos;
268 int (*read_function)(struct st_io_cache *,unsigned char *,uint);
269 char *file_name; /* if used with 'open_cached_file' */
270 char *dir,*prefix;
271 File file;
272 int seek_not_done,error;
273 uint buffer_length,read_length;
274 myf myflags; /* Flags used to my_read/my_write */
275 enum cache_type type;
276#ifdef HAVE_AIOWAIT
277 uint inited;
278 my_off_t aio_read_pos;
279 my_aio_result aio_result;
280#endif
281} IO_CACHE;
282
283typedef int (*qsort2_cmp)(const void *, const void *, const void *);
284
285 /* defines for mf_iocache */
286
287 /* Test if buffer is inited */
288#define my_b_clear(info) (info)->buffer=0
289#define my_b_inited(info) (info)->buffer
290#define my_b_EOF INT_MIN
291
292#define my_b_read(info,Buffer,Count) \
293 ((info)->rc_pos + (Count) <= (info)->rc_end ?\
294 (memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \
295 ((info)->rc_pos+=(Count)),0) :\
296 (*(info)->read_function)((info),Buffer,Count))
297
298#define my_b_get(info) \
299 ((info)->rc_pos != (info)->rc_end ?\
300 ((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
301 _my_b_get(info))
302
303#define my_b_write(info,Buffer,Count) \
304 ((info)->rc_pos + (Count) <= (info)->rc_end ?\
305 (memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
306 ((info)->rc_pos+=(Count)),0) :\
307 _my_b_write(info,Buffer,Count))
308
309 /* my_b_write_byte doesn't have any err-check */
310#define my_b_write_byte(info,chr) \
311 (((info)->rc_pos < (info)->rc_end) ?\
312 ((*(info)->rc_pos++)=(chr)) :\
313 (_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr))))
314
315#define my_b_fill_cache(info) \
316 (((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0))
317
318#define my_b_tell(info) ((info)->pos_in_file + \
319 ((info)->rc_pos - (info)->rc_request_pos))
320
321#define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos))
322
323typedef struct st_changeable_var {
324 const char *name; /* Name of variable */
325 long *varptr; /* Pointer to variable */
326 long def_value, /* Default value */
327 min_value, /* Min allowed value */
328 max_value, /* Max allowed value */
329 sub_size, /* Subtract this from given value */
330 block_size; /* Value should be a mult. of this */
331} CHANGEABLE_VAR;
332
333
334/* structs for ma_alloc_root */
335
336#ifndef ST_MA_USED_MEM_DEFINED
337#define ST_MA_USED_MEM_DEFINED
338typedef struct st_ma_used_mem { /* struct for once_alloc */
339 struct st_ma_used_mem *next; /* Next block in use */
340 size_t left; /* memory left in block */
341 size_t size; /* Size of block */
342} MA_USED_MEM;
343
344typedef struct st_ma_mem_root {
345 MA_USED_MEM *free;
346 MA_USED_MEM *used;
347 MA_USED_MEM *pre_alloc;
348 size_t min_malloc;
349 size_t block_size;
350 unsigned int block_num;
351 unsigned int first_block_usage;
352 void (*error_handler)(void);
353} MA_MEM_ROOT;
354#endif
355
356 /* Prototypes for mysys and my_func functions */
357
358extern void * _mymalloc(size_t uSize,const char *sFile,
359 uint uLine, myf MyFlag);
360extern void * _myrealloc(void * pPtr,size_t uSize,const char *sFile,
361 uint uLine, myf MyFlag);
362extern void *ma_multi_malloc(myf MyFlags, ...);
363extern void _myfree(void * pPtr,const char *sFile,uint uLine, myf MyFlag);
364extern int _sanity(const char *sFile,unsigned int uLine);
365#ifndef TERMINATE
366extern void TERMINATE(FILE *file);
367#endif
368extern void ma_init_glob_errs(void);
369extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
370extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
371extern int my_fclose(FILE *fd,myf MyFlags);
372extern int my_chsize(File fd,my_off_t newlength,myf MyFlags);
373extern int ma_error _VARARGS((int nr,myf MyFlags, ...));
374extern int ma_printf_error _VARARGS((uint my_err, const char *format,
375 myf MyFlags, ...)
376 __attribute__ ((format (printf, 2, 4))));
377extern int ma_vsnprintf( char *str, size_t n,
378 const char *format, va_list ap );
379extern int ma_snprintf(char* to, size_t n, const char* fmt, ...);
380extern int ma_message(uint my_err, const char *str,myf MyFlags);
381extern int _mariadb_stderr_out(unsigned int error, const char *errmsg, myf MyFlags);
382
383extern void ma_init(void);
384extern void ma_end(int infoflag);
385extern int my_redel(const char *from, const char *to, int MyFlags);
386extern int my_copystat(const char *from, const char *to, int MyFlags);
387extern my_string my_filename(File fd);
388
389#ifndef THREAD
390extern void dont_break(void);
391extern void allow_break(void);
392#else
393#define dont_break()
394#define allow_break()
395#endif
396
397extern void caseup(my_string str,uint length);
398extern void casedn(my_string str,uint length);
399extern void caseup_str(my_string str);
400extern void casedn_str(my_string str);
401extern void case_sort(my_string str,uint length);
402extern uint ma_dirname_part(my_string to,const char *name);
403extern uint ma_dirname_length(const char *name);
404#define base_name(A) (A+dirname_length(A))
405extern int test_if_hard_path(const char *dir_name);
406extern char *ma_convert_dirname(my_string name);
407extern void to_unix_path(my_string name);
408extern my_string ma_fn_ext(const char *name);
409extern my_string fn_same(my_string toname,const char *name,int flag);
410extern my_string ma_fn_format(my_string to,const char *name,const char *dsk,
411 const char *form,int flag);
412extern size_s ma_strlength(const char *str);
413extern void ma_pack_dirname(my_string to,const char *from);
414extern uint unma_pack_dirname(my_string to,const char *from);
415extern uint ma_cleanup_dirname(my_string to,const char *from);
416extern uint ma_system_filename(my_string to,const char *from);
417extern my_string ma_unpack_filename(my_string to,const char *from);
418extern my_string ma_intern_filename(my_string to,const char *from);
419extern my_string directory_file_name(my_string dst, const char *src);
420extern int pack_filename(my_string to, const char *name, size_s max_length);
421extern my_string my_path(my_string to,const char *progname,
422 const char *own_pathname_part);
423extern my_string my_load_path(my_string to, const char *path,
424 const char *own_path_prefix);
425extern int wild_compare(const char *str,const char *wildstr);
426extern my_string my_strcasestr(const char *src,const char *suffix);
427extern int my_strcasecmp(const char *s,const char *t);
428extern int my_strsortcmp(const char *s,const char *t);
429extern int my_casecmp(const char *s,const char *t,uint length);
430extern int my_sortcmp(const char *s,const char *t,uint length);
431extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
432#ifdef TBR
433extern WF_PACK *wf_comp(my_string str);
434extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
435extern void wf_end(struct wild_file_pack *buffer);
436extern size_s strip_sp(my_string str);
437extern void get_date(my_string to,int timeflag,time_t use_time);
438extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
439extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
440 uint reclength,enum cache_type type,
441 pbool use_async_io);
442extern int read_cache_record(RECORD_CACHE *info,unsigned char *to);
443extern int end_record_cache(RECORD_CACHE *info);
444extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
445 const unsigned char *record,uint length);
446extern int flush_write_cache(RECORD_CACHE *info);
447extern long my_clock(void);
448extern sig_handler sigtstp_handler(int signal_number);
449extern void handle_recived_signals(void);
450extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
451extern unsigned char *key_cache_read(File file,my_off_t filepos,unsigned char* buff,uint length,
452 uint block_length,int return_buffer);
453extern int key_cache_write(File file,my_off_t filepos,unsigned char* buff,uint length,
454 uint block_length,int force_write);
455extern int flush_key_blocks(int file, enum flush_type type);
456extern void end_key_cache(void);
457extern sig_handler my_set_alarm_variable(int signo);
458extern void my_string_ptr_sort(void *base,uint items,size_s size);
459extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
460 size_s size_of_element,uchar *buffer[]);
461extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
462 qsort2_cmp cmp, void *cmp_argument);
463extern qsort2_cmp get_ptr_compare(uint);
464extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
465 enum cache_type type,my_off_t seek_offset,
466 pbool use_async_io, myf cache_myflags);
467extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
468 my_off_t seek_offset,pbool use_async_io,
469 pbool clear_cache);
470extern int _my_b_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
471extern int _my_b_net_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
472extern int _my_b_get(IO_CACHE *info);
473extern int _my_b_async_read(IO_CACHE *info,unsigned char *Buffer,uint Count);
474extern int _my_b_write(IO_CACHE *info,const unsigned char *Buffer,uint Count);
475extern int my_block_write(IO_CACHE *info, const unsigned char *Buffer,
476 uint Count, my_off_t pos);
477extern int flush_io_cache(IO_CACHE *info);
478extern int end_io_cache(IO_CACHE *info);
479extern uint my_b_fill(IO_CACHE *info);
480extern void my_b_seek(IO_CACHE *info,my_off_t pos);
481extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
482extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
483extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
484extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
485 const char *prefix, uint cache_size,
486 myf cache_myflags);
487extern my_bool real_open_cached_file(IO_CACHE *cache);
488extern void close_cached_file(IO_CACHE *cache);
489File create_temp_file(char *to, const char *dir, const char *pfx,
490 int mode, myf MyFlags);
491#define ma_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
492#endif
493extern my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
494 uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
495#define ma_init_dynamic_array_ci(A,B,C,D) ma_init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
496extern my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array,void * element);
497extern unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array);
498extern unsigned char *ma_pop_dynamic(DYNAMIC_ARRAY*);
499extern my_bool ma_set_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index);
500extern void ma_get_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index);
501extern void ma_delete_dynamic(DYNAMIC_ARRAY *array);
502extern void ma_delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
503extern void ma_freeze_size(DYNAMIC_ARRAY *array);
504#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
505#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
506#define push_dynamic(A,B) ma_insert_dynamic(A,B)
507
508extern int ma_find_type(my_string x,TYPELIB *typelib,uint full_name);
509extern void ma_make_type(my_string to,uint nr,TYPELIB *typelib);
510extern const char *ma_get_type(TYPELIB *typelib,uint nr);
511extern my_bool ma_init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
512 size_t init_alloc, size_t alloc_increment);
513extern my_bool ma_dynstr_append(DYNAMIC_STRING *str, const char *append);
514extern my_bool ma_dynstr_append_quoted(DYNAMIC_STRING *str,
515 const char *append, size_t len,
516 char quote);
517my_bool ma_dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
518 size_t length);
519extern my_bool ma_dynstr_set(DYNAMIC_STRING *str, const char *init_str);
520extern my_bool ma_dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
521extern void ma_dynstr_free(DYNAMIC_STRING *str);
522void set_all_changeable_vars(CHANGEABLE_VAR *vars);
523my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
524my_bool set_changeable_varval(const char *var, ulong val,
525 CHANGEABLE_VAR *vars);
526#define ma_alloc_root_inited(A) ((A)->min_malloc != 0)
527void ma_init_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size);
528void *ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size);
529void ma_free_root(MA_MEM_ROOT *root, myf MyFLAGS);
530char *ma_strdup_root(MA_MEM_ROOT *root,const char *str);
531char *ma_memdup_root(MA_MEM_ROOT *root,const char *str, size_t len);
532void ma_free_defaults(char **argv);
533void ma_print_defaults(const char *conf_file, const char **groups);
534my_bool _mariadb_compress(unsigned char *, size_t *, size_t *);
535my_bool _mariadb_uncompress(unsigned char *, size_t *, size_t *);
536unsigned char *_mariadb_compress_alloc(const unsigned char *packet, size_t *len, size_t *complen);
537ulong checksum(const unsigned char *mem, uint count);
538
539#if defined(_MSC_VER) && !defined(_WIN32)
540extern void sleep(int sec);
541#endif
542
543#ifdef __cplusplus
544}
545#endif
546#endif /* _my_sys_h */
547