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 |
21 | extern "C" { |
22 | #endif |
23 | |
24 | #ifdef HAVE_AIOWAIT |
25 | #include <sys/asynch.h> /* Used by record-cache */ |
26 | typedef 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__ |
139 | void * __CDECL halloc(long count,size_t length); |
140 | void __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 |
157 | extern int errno; /* declare errno */ |
158 | #endif |
159 | #endif |
160 | extern const char ** NEAR my_errmsg[]; |
161 | extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; |
162 | /* tbr |
163 | extern int (*ma_error_handler_hook)(uint my_err, const char *str,myf MyFlags); |
164 | extern int (*fatal_ma_error_handler_hook)(uint my_err, const char *str, |
165 | myf MyFlags); |
166 | */ |
167 | |
168 | /* charsets */ |
169 | /* tbr |
170 | extern uint get_charset_number(const char *cs_name); |
171 | extern const char *get_charset_name(uint cs_number); |
172 | extern my_bool set_default_charset(uint cs, myf flags); |
173 | extern my_bool set_default_charset_by_name(const char *cs_name, myf flags); |
174 | extern void free_charsets(void); |
175 | extern char *list_charsets(myf want_flags); |
176 | extern char *get_charsets_dir(char *buf); |
177 | */ |
178 | extern MARIADB_CHARSET_INFO *get_charset(uint cs_number, myf flags); |
179 | extern MARIADB_CHARSET_INFO *get_charset_by_name(const char *cs_name); |
180 | extern MARIADB_CHARSET_INFO *get_charset_by_nr(uint cs_number); |
181 | |
182 | /* string functions */ |
183 | char *ma_strmake(register char *dst, register const char *src, size_t length); |
184 | |
185 | /* statistics */ |
186 | #ifdef TBR |
187 | extern ulong _my_cache_w_requests,_my_cache_write,_my_cache_r_requests, |
188 | _my_cache_read; |
189 | extern ulong _my_blocks_used,_my_blocks_changed; |
190 | extern ulong ma_file_opened,ma_stream_opened, ma_tmp_file_created; |
191 | extern my_bool key_cache_inited; |
192 | |
193 | /* Point to current ma_message() */ |
194 | extern 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 */ |
199 | extern 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 */ |
204 | extern my_bool NEAR mysys_uses_curses, ma_use_symdir; |
205 | extern size_t lCurMemory,lMaxMemory; /* from safemalloc */ |
206 | |
207 | extern ulong ma_default_record_cache_size; |
208 | extern my_bool NEAR ma_disable_locking,NEAR ma_disable_async_io, |
209 | NEAR ma_disable_flush_key_blocks, NEAR ma_disable_symlinks; |
210 | extern char wild_many,wild_one,wild_prefix; |
211 | extern const char *charsets_dir; |
212 | extern char *defaults_extra_file; |
213 | typedef 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 | |
220 | struct my_rnd_struct { |
221 | unsigned long seed1,seed2,max_value; |
222 | double max_value_dbl; |
223 | }; |
224 | |
225 | #endif |
226 | typedef 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 | |
232 | enum cache_type {READ_CACHE,WRITE_CACHE,READ_FIFO,READ_NET,WRITE_NET}; |
233 | enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, |
234 | FLUSH_FORCE_WRITE}; |
235 | |
236 | typedef 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 | /* |
251 | enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, |
252 | STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP }; |
253 | |
254 | extern struct ma_file_info |
255 | { |
256 | my_string name; |
257 | enum file_type type; |
258 | #if defined(THREAD) && !defined(HAVE_PREAD) |
259 | pthread_mutex_t mutex; |
260 | #endif |
261 | } ma_file_info[MY_NFILE]; |
262 | */ |
263 | |
264 | typedef struct st_dynamic_array { |
265 | char *buffer; |
266 | uint elements,max_element; |
267 | uint alloc_increment; |
268 | uint size_of_element; |
269 | } DYNAMIC_ARRAY; |
270 | |
271 | typedef struct st_dynamic_string { |
272 | char *str; |
273 | size_t length,max_length,alloc_increment; |
274 | } DYNAMIC_STRING; |
275 | |
276 | |
277 | typedef struct st_io_cache /* Used when caching files */ |
278 | { |
279 | my_off_t pos_in_file,end_of_file; |
280 | unsigned char *rc_pos,*rc_end,*buffer,*rc_request_pos; |
281 | int (*read_function)(struct st_io_cache *,unsigned char *,uint); |
282 | char *file_name; /* if used with 'open_cached_file' */ |
283 | char *dir,*prefix; |
284 | File file; |
285 | int seek_not_done,error; |
286 | uint buffer_length,read_length; |
287 | myf myflags; /* Flags used to my_read/my_write */ |
288 | enum cache_type type; |
289 | #ifdef HAVE_AIOWAIT |
290 | uint inited; |
291 | my_off_t aio_read_pos; |
292 | my_aio_result aio_result; |
293 | #endif |
294 | } IO_CACHE; |
295 | |
296 | typedef int (*qsort2_cmp)(const void *, const void *, const void *); |
297 | |
298 | /* defines for mf_iocache */ |
299 | |
300 | /* Test if buffer is inited */ |
301 | #define my_b_clear(info) (info)->buffer=0 |
302 | #define my_b_inited(info) (info)->buffer |
303 | #define my_b_EOF INT_MIN |
304 | |
305 | #define my_b_read(info,Buffer,Count) \ |
306 | ((info)->rc_pos + (Count) <= (info)->rc_end ?\ |
307 | (memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \ |
308 | ((info)->rc_pos+=(Count)),0) :\ |
309 | (*(info)->read_function)((info),Buffer,Count)) |
310 | |
311 | #define my_b_get(info) \ |
312 | ((info)->rc_pos != (info)->rc_end ?\ |
313 | ((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\ |
314 | _my_b_get(info)) |
315 | |
316 | #define my_b_write(info,Buffer,Count) \ |
317 | ((info)->rc_pos + (Count) <= (info)->rc_end ?\ |
318 | (memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \ |
319 | ((info)->rc_pos+=(Count)),0) :\ |
320 | _my_b_write(info,Buffer,Count)) |
321 | |
322 | /* my_b_write_byte doesn't have any err-check */ |
323 | #define my_b_write_byte(info,chr) \ |
324 | (((info)->rc_pos < (info)->rc_end) ?\ |
325 | ((*(info)->rc_pos++)=(chr)) :\ |
326 | (_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr)))) |
327 | |
328 | #define my_b_fill_cache(info) \ |
329 | (((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0)) |
330 | |
331 | #define my_b_tell(info) ((info)->pos_in_file + \ |
332 | ((info)->rc_pos - (info)->rc_request_pos)) |
333 | |
334 | #define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos)) |
335 | |
336 | typedef struct st_changeable_var { |
337 | const char *name; /* Name of variable */ |
338 | long *varptr; /* Pointer to variable */ |
339 | long def_value, /* Default value */ |
340 | min_value, /* Min allowed value */ |
341 | max_value, /* Max allowed value */ |
342 | sub_size, /* Subtract this from given value */ |
343 | block_size; /* Value should be a mult. of this */ |
344 | } CHANGEABLE_VAR; |
345 | |
346 | |
347 | /* structs for ma_alloc_root */ |
348 | |
349 | #ifndef ST_MA_USED_MEM_DEFINED |
350 | #define ST_MA_USED_MEM_DEFINED |
351 | typedef struct st_ma_used_mem { /* struct for once_alloc */ |
352 | struct st_ma_used_mem *next; /* Next block in use */ |
353 | size_t left; /* memory left in block */ |
354 | size_t size; /* Size of block */ |
355 | } MA_USED_MEM; |
356 | |
357 | typedef struct st_ma_mem_root { |
358 | MA_USED_MEM *free; |
359 | MA_USED_MEM *used; |
360 | MA_USED_MEM *pre_alloc; |
361 | size_t min_malloc; |
362 | size_t block_size; |
363 | unsigned int block_num; |
364 | unsigned int first_block_usage; |
365 | void (*error_handler)(void); |
366 | } MA_MEM_ROOT; |
367 | #endif |
368 | |
369 | /* Prototypes for mysys and my_func functions */ |
370 | |
371 | extern void * _mymalloc(size_t uSize,const char *sFile, |
372 | uint uLine, myf MyFlag); |
373 | extern void * _myrealloc(void * pPtr,size_t uSize,const char *sFile, |
374 | uint uLine, myf MyFlag); |
375 | extern void *ma_multi_malloc(myf MyFlags, ...); |
376 | extern void _myfree(void * pPtr,const char *sFile,uint uLine, myf MyFlag); |
377 | extern int _sanity(const char *sFile,unsigned int uLine); |
378 | #ifndef TERMINATE |
379 | extern void TERMINATE(FILE *file); |
380 | #endif |
381 | extern void ma_init_glob_errs(void); |
382 | extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); |
383 | extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); |
384 | extern int my_fclose(FILE *fd,myf MyFlags); |
385 | extern int my_chsize(File fd,my_off_t newlength,myf MyFlags); |
386 | extern int ma_error _VARARGS((int nr,myf MyFlags, ...)); |
387 | extern int ma_printf_error _VARARGS((uint my_err, const char *format, |
388 | myf MyFlags, ...) |
389 | __attribute__ ((format (printf, 2, 4)))); |
390 | extern int ma_vsnprintf( char *str, size_t n, |
391 | const char *format, va_list ap ); |
392 | extern int ma_snprintf(char* to, size_t n, const char* fmt, ...); |
393 | extern int ma_message(uint my_err, const char *str,myf MyFlags); |
394 | extern int _mariadb_stderr_out(unsigned int error, const char *errmsg, myf MyFlags); |
395 | |
396 | extern void ma_init(void); |
397 | extern void ma_end(int infoflag); |
398 | extern int my_redel(const char *from, const char *to, int MyFlags); |
399 | extern int my_copystat(const char *from, const char *to, int MyFlags); |
400 | extern my_string my_filename(File fd); |
401 | |
402 | #ifndef THREAD |
403 | extern void dont_break(void); |
404 | extern void allow_break(void); |
405 | #else |
406 | #define dont_break() |
407 | #define allow_break() |
408 | #endif |
409 | |
410 | extern void caseup(my_string str,uint length); |
411 | extern void casedn(my_string str,uint length); |
412 | extern void caseup_str(my_string str); |
413 | extern void casedn_str(my_string str); |
414 | extern void case_sort(my_string str,uint length); |
415 | extern uint ma_dirname_part(my_string to,const char *name); |
416 | extern uint ma_dirname_length(const char *name); |
417 | #define base_name(A) (A+dirname_length(A)) |
418 | extern int test_if_hard_path(const char *dir_name); |
419 | extern char *ma_convert_dirname(my_string name); |
420 | extern void to_unix_path(my_string name); |
421 | extern my_string ma_fn_ext(const char *name); |
422 | extern my_string fn_same(my_string toname,const char *name,int flag); |
423 | extern my_string ma_fn_format(my_string to,const char *name,const char *dsk, |
424 | const char *form,int flag); |
425 | extern size_s ma_strlength(const char *str); |
426 | extern void ma_pack_dirname(my_string to,const char *from); |
427 | extern uint unma_pack_dirname(my_string to,const char *from); |
428 | extern uint ma_cleanup_dirname(my_string to,const char *from); |
429 | extern uint ma_system_filename(my_string to,const char *from); |
430 | extern my_string ma_unpack_filename(my_string to,const char *from); |
431 | extern my_string ma_intern_filename(my_string to,const char *from); |
432 | extern my_string directory_file_name(my_string dst, const char *src); |
433 | extern int pack_filename(my_string to, const char *name, size_s max_length); |
434 | extern my_string my_path(my_string to,const char *progname, |
435 | const char *own_pathname_part); |
436 | extern my_string my_load_path(my_string to, const char *path, |
437 | const char *own_path_prefix); |
438 | extern int wild_compare(const char *str,const char *wildstr); |
439 | extern my_string my_strcasestr(const char *src,const char *suffix); |
440 | extern int my_strcasecmp(const char *s,const char *t); |
441 | extern int my_strsortcmp(const char *s,const char *t); |
442 | extern int my_casecmp(const char *s,const char *t,uint length); |
443 | extern int my_sortcmp(const char *s,const char *t,uint length); |
444 | extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len); |
445 | #ifdef TBR |
446 | extern WF_PACK *wf_comp(my_string str); |
447 | extern int wf_test(struct wild_file_pack *wf_pack,const char *name); |
448 | extern void wf_end(struct wild_file_pack *buffer); |
449 | extern size_s strip_sp(my_string str); |
450 | extern void get_date(my_string to,int timeflag,time_t use_time); |
451 | extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage); |
452 | extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, |
453 | uint reclength,enum cache_type type, |
454 | pbool use_async_io); |
455 | extern int read_cache_record(RECORD_CACHE *info,unsigned char *to); |
456 | extern int end_record_cache(RECORD_CACHE *info); |
457 | extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, |
458 | const unsigned char *record,uint length); |
459 | extern int flush_write_cache(RECORD_CACHE *info); |
460 | extern long my_clock(void); |
461 | extern sig_handler sigtstp_handler(int signal_number); |
462 | extern void handle_recived_signals(void); |
463 | extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem); |
464 | extern unsigned char *key_cache_read(File file,my_off_t filepos,unsigned char* buff,uint length, |
465 | uint block_length,int return_buffer); |
466 | extern int key_cache_write(File file,my_off_t filepos,unsigned char* buff,uint length, |
467 | uint block_length,int force_write); |
468 | extern int flush_key_blocks(int file, enum flush_type type); |
469 | extern void end_key_cache(void); |
470 | extern sig_handler my_set_alarm_variable(int signo); |
471 | extern void my_string_ptr_sort(void *base,uint items,size_s size); |
472 | extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, |
473 | size_s size_of_element,uchar *buffer[]); |
474 | extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, |
475 | qsort2_cmp cmp, void *cmp_argument); |
476 | extern qsort2_cmp get_ptr_compare(uint); |
477 | extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, |
478 | enum cache_type type,my_off_t seek_offset, |
479 | pbool use_async_io, myf cache_myflags); |
480 | extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, |
481 | my_off_t seek_offset,pbool use_async_io, |
482 | pbool clear_cache); |
483 | extern int _my_b_read(IO_CACHE *info,unsigned char *Buffer,uint Count); |
484 | extern int _my_b_net_read(IO_CACHE *info,unsigned char *Buffer,uint Count); |
485 | extern int _my_b_get(IO_CACHE *info); |
486 | extern int _my_b_async_read(IO_CACHE *info,unsigned char *Buffer,uint Count); |
487 | extern int _my_b_write(IO_CACHE *info,const unsigned char *Buffer,uint Count); |
488 | extern int my_block_write(IO_CACHE *info, const unsigned char *Buffer, |
489 | uint Count, my_off_t pos); |
490 | extern int flush_io_cache(IO_CACHE *info); |
491 | extern int end_io_cache(IO_CACHE *info); |
492 | extern uint my_b_fill(IO_CACHE *info); |
493 | extern void my_b_seek(IO_CACHE *info,my_off_t pos); |
494 | extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); |
495 | extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); |
496 | extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); |
497 | extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, |
498 | const char *prefix, uint cache_size, |
499 | myf cache_myflags); |
500 | extern my_bool real_open_cached_file(IO_CACHE *cache); |
501 | extern void close_cached_file(IO_CACHE *cache); |
502 | File create_temp_file(char *to, const char *dir, const char *pfx, |
503 | int mode, myf MyFlags); |
504 | #define ma_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) |
505 | #endif |
506 | extern my_bool ma_init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, |
507 | uint init_alloc,uint alloc_increment CALLER_INFO_PROTO); |
508 | #define ma_init_dynamic_array_ci(A,B,C,D) ma_init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) |
509 | extern my_bool ma_insert_dynamic(DYNAMIC_ARRAY *array,void * element); |
510 | extern unsigned char *ma_alloc_dynamic(DYNAMIC_ARRAY *array); |
511 | extern unsigned char *ma_pop_dynamic(DYNAMIC_ARRAY*); |
512 | extern my_bool ma_set_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index); |
513 | extern void ma_get_dynamic(DYNAMIC_ARRAY *array,void * element,uint array_index); |
514 | extern void ma_delete_dynamic(DYNAMIC_ARRAY *array); |
515 | extern void ma_delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); |
516 | extern void ma_freeze_size(DYNAMIC_ARRAY *array); |
517 | #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) |
518 | #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) |
519 | #define push_dynamic(A,B) ma_insert_dynamic(A,B) |
520 | |
521 | extern int ma_find_type(my_string x,TYPELIB *typelib,uint full_name); |
522 | extern void ma_make_type(my_string to,uint nr,TYPELIB *typelib); |
523 | extern const char *ma_get_type(TYPELIB *typelib,uint nr); |
524 | extern my_bool ma_init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, |
525 | size_t init_alloc, size_t alloc_increment); |
526 | extern my_bool ma_dynstr_append(DYNAMIC_STRING *str, const char *append); |
527 | my_bool ma_dynstr_append_mem(DYNAMIC_STRING *str, const char *append, |
528 | size_t length); |
529 | extern my_bool ma_dynstr_set(DYNAMIC_STRING *str, const char *init_str); |
530 | extern my_bool ma_dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); |
531 | extern void ma_dynstr_free(DYNAMIC_STRING *str); |
532 | void set_all_changeable_vars(CHANGEABLE_VAR *vars); |
533 | my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars); |
534 | my_bool set_changeable_varval(const char *var, ulong val, |
535 | CHANGEABLE_VAR *vars); |
536 | #ifdef HAVE_MLOCK |
537 | extern unsigned char *ma_malloc_lock(size_t length,myf flags); |
538 | extern void ma_free_lock(unsigned char *ptr,myf flags); |
539 | #else |
540 | #define ma_malloc_lock(A,B) ma_malloc((A),(B)) |
541 | #define ma_free_lock(A,B) ma_free((A),(B)) |
542 | #endif |
543 | #define ma_alloc_root_inited(A) ((A)->min_malloc != 0) |
544 | void ma_init_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size); |
545 | void *ma_alloc_root(MA_MEM_ROOT *mem_root, size_t Size); |
546 | void ma_free_root(MA_MEM_ROOT *root, myf MyFLAGS); |
547 | char *ma_strdup_root(MA_MEM_ROOT *root,const char *str); |
548 | char *ma_memdup_root(MA_MEM_ROOT *root,const char *str, size_t len); |
549 | void ma_free_defaults(char **argv); |
550 | void ma_print_defaults(const char *conf_file, const char **groups); |
551 | my_bool _mariadb_compress(unsigned char *, size_t *, size_t *); |
552 | my_bool _mariadb_uncompress(unsigned char *, size_t *, size_t *); |
553 | unsigned char *_mariadb_compress_alloc(const unsigned char *packet, size_t *len, size_t *complen); |
554 | ulong checksum(const unsigned char *mem, uint count); |
555 | |
556 | #if defined(_MSC_VER) && !defined(_WIN32) |
557 | extern void sleep(int sec); |
558 | #endif |
559 | |
560 | #ifdef __cplusplus |
561 | } |
562 | #endif |
563 | #endif /* _my_sys_h */ |
564 | |