1 | /* Copyright (C) 2000-2003 MySQL AB |
---|
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 as published by |
---|
5 | the Free Software Foundation; either version 2 of the License, or |
---|
6 | (at your option) any later version. |
---|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
---|
16 | |
---|
17 | #ifndef _my_sys_h |
---|
18 | #define _my_sys_h |
---|
19 | C_MODE_START |
---|
20 | |
---|
21 | #ifdef HAVE_AIOWAIT |
---|
22 | #include <sys/asynch.h> /* Used by record-cache */ |
---|
23 | typedef struct my_aio_result { |
---|
24 | aio_result_t result; |
---|
25 | int pending; |
---|
26 | } my_aio_result; |
---|
27 | #endif |
---|
28 | |
---|
29 | #ifndef THREAD |
---|
30 | extern int NEAR my_errno; /* Last error in mysys */ |
---|
31 | #else |
---|
32 | #include <my_pthread.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #ifndef _m_ctype_h |
---|
36 | #include <m_ctype.h> /* for CHARSET_INFO */ |
---|
37 | #endif |
---|
38 | |
---|
39 | #include <stdarg.h> |
---|
40 | #include <typelib.h> |
---|
41 | |
---|
42 | #define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; } |
---|
43 | #define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} |
---|
44 | #define MY_INIT(name); { my_progname= name; my_init(); } |
---|
45 | |
---|
46 | #define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ |
---|
47 | #define NRERRBUFFS (2) /* Buffers for parameters */ |
---|
48 | #define MY_FILE_ERROR ((uint) ~0) |
---|
49 | |
---|
50 | /* General bitmaps for my_func's */ |
---|
51 | #define MY_FFNF 1 /* Fatal if file not found */ |
---|
52 | #define MY_FNABP 2 /* Fatal if not all bytes read/writen */ |
---|
53 | #define MY_NABP 4 /* Error if not all bytes read/writen */ |
---|
54 | #define MY_FAE 8 /* Fatal if any error */ |
---|
55 | #define MY_WME 16 /* Write message on error */ |
---|
56 | #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ |
---|
57 | #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ |
---|
58 | #define MY_RAID 64 /* Support for RAID */ |
---|
59 | #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ |
---|
60 | #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ |
---|
61 | #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ |
---|
62 | #define MY_COPYTIME 64 /* my_redel() copys time */ |
---|
63 | #define MY_DELETE_OLD 256 /* my_create_with_symlink() */ |
---|
64 | #define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ |
---|
65 | #define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ |
---|
66 | #define MY_REDEL_MAKE_BACKUP 256 |
---|
67 | #define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ |
---|
68 | #define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ |
---|
69 | #define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ |
---|
70 | #define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ |
---|
71 | #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ |
---|
72 | #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ |
---|
73 | #define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ |
---|
74 | #define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ |
---|
75 | |
---|
76 | #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ |
---|
77 | #define MY_GIVE_INFO 2 /* Give time info about process*/ |
---|
78 | |
---|
79 | #define ME_HIGHBYTE 8 /* Shift for colours */ |
---|
80 | #define ME_NOCUR 1 /* Don't use curses message */ |
---|
81 | #define ME_OLDWIN 2 /* Use old window */ |
---|
82 | #define ME_BELL 4 /* Ring bell then printing message */ |
---|
83 | #define ME_HOLDTANG 8 /* Don't delete last keys */ |
---|
84 | #define ME_WAITTOT 16 /* Wait for errtime secs of for a action */ |
---|
85 | #define ME_WAITTANG 32 /* Wait for a user action */ |
---|
86 | #define ME_NOREFRESH 64 /* Dont refresh screen */ |
---|
87 | #define ME_NOINPUT 128 /* Dont use the input libary */ |
---|
88 | #define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ |
---|
89 | #define ME_COLOUR2 ((2 << ME_HIGHBYTE)) |
---|
90 | #define ME_COLOUR3 ((3 << ME_HIGHBYTE)) |
---|
91 | |
---|
92 | /* Bits in last argument to fn_format */ |
---|
93 | #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ |
---|
94 | #define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ |
---|
95 | #define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ |
---|
96 | #define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ |
---|
97 | #define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ |
---|
98 | #define MY_RETURN_REAL_PATH 32 /* return full path for file */ |
---|
99 | #define MY_SAFE_PATH 64 /* Return NULL if too long path */ |
---|
100 | #define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ |
---|
101 | |
---|
102 | /* My seek flags */ |
---|
103 | #define MY_SEEK_SET 0 |
---|
104 | #define MY_SEEK_CUR 1 |
---|
105 | #define MY_SEEK_END 2 |
---|
106 | |
---|
107 | /* Some constants */ |
---|
108 | #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ |
---|
109 | #define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ |
---|
110 | #define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ |
---|
111 | #define DFLT_INIT_HITS 3 |
---|
112 | |
---|
113 | /* root_alloc flags */ |
---|
114 | #define MY_KEEP_PREALLOC 1 |
---|
115 | #define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ |
---|
116 | |
---|
117 | /* Internal error numbers (for assembler functions) */ |
---|
118 | #define MY_ERRNO_EDOM 33 |
---|
119 | #define MY_ERRNO_ERANGE 34 |
---|
120 | |
---|
121 | /* Bits for get_date timeflag */ |
---|
122 | #define GETDATE_DATE_TIME 1 |
---|
123 | #define GETDATE_SHORT_DATE 2 |
---|
124 | #define GETDATE_HHMMSSTIME 4 |
---|
125 | #define GETDATE_GMT 8 |
---|
126 | #define GETDATE_FIXEDLENGTH 16 |
---|
127 | |
---|
128 | /* defines when allocating data */ |
---|
129 | #ifdef SAFEMALLOC |
---|
130 | #define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) |
---|
131 | #define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG ) |
---|
132 | #define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG ) |
---|
133 | #define my_checkmalloc() _sanity( __FILE__, __LINE__ ) |
---|
134 | #define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG) |
---|
135 | #define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C) |
---|
136 | #define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C) |
---|
137 | #define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C) |
---|
138 | #define TRASH(A,B) bfill(A, B, 0x8F) |
---|
139 | #define QUICK_SAFEMALLOC sf_malloc_quick=1 |
---|
140 | #define NORMAL_SAFEMALLOC sf_malloc_quick=0 |
---|
141 | extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; |
---|
142 | extern ulonglong sf_malloc_mem_limit; |
---|
143 | |
---|
144 | #define CALLER_INFO_PROTO , const char *sFile, uint uLine |
---|
145 | #define CALLER_INFO , __FILE__, __LINE__ |
---|
146 | #define ORIG_CALLER_INFO , sFile, uLine |
---|
147 | #else |
---|
148 | #define my_checkmalloc() |
---|
149 | #undef TERMINATE |
---|
150 | #define TERMINATE(A) {} |
---|
151 | #define QUICK_SAFEMALLOC |
---|
152 | #define NORMAL_SAFEMALLOC |
---|
153 | extern gptr my_malloc(uint Size,myf MyFlags); |
---|
154 | #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) |
---|
155 | extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); |
---|
156 | extern void my_no_flags_free(gptr ptr); |
---|
157 | extern gptr my_memdup(const byte *from,uint length,myf MyFlags); |
---|
158 | extern char *my_strdup(const char *from,myf MyFlags); |
---|
159 | extern char *my_strdup_with_length(const byte *from, uint length, |
---|
160 | myf MyFlags); |
---|
161 | /* we do use FG (as a no-op) in below so that a typo on FG is caught */ |
---|
162 | #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) |
---|
163 | #define CALLER_INFO_PROTO /* nothing */ |
---|
164 | #define CALLER_INFO /* nothing */ |
---|
165 | #define ORIG_CALLER_INFO /* nothing */ |
---|
166 | #define TRASH(A,B) /* nothing */ |
---|
167 | #endif |
---|
168 | |
---|
169 | #ifdef HAVE_LARGE_PAGES |
---|
170 | extern uint my_get_large_page_size(void); |
---|
171 | extern gptr my_large_malloc(uint size, myf my_flags); |
---|
172 | extern void my_large_free(gptr ptr, myf my_flags); |
---|
173 | #else |
---|
174 | #define my_get_large_page_size() (0) |
---|
175 | #define my_large_malloc(A,B) my_malloc_lock((A),(B)) |
---|
176 | #define my_large_free(A,B) my_free_lock((A),(B)) |
---|
177 | #endif /* HAVE_LARGE_PAGES */ |
---|
178 | |
---|
179 | #ifdef HAVE_ALLOCA |
---|
180 | #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) |
---|
181 | #pragma alloca |
---|
182 | #endif /* _AIX */ |
---|
183 | #if defined(__MWERKS__) |
---|
184 | #undef alloca |
---|
185 | #define alloca _alloca |
---|
186 | #endif /* __MWERKS__ */ |
---|
187 | #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca) |
---|
188 | #define alloca __builtin_alloca |
---|
189 | #endif /* GNUC */ |
---|
190 | #define my_alloca(SZ) alloca((size_t) (SZ)) |
---|
191 | #define my_afree(PTR) {} |
---|
192 | #else |
---|
193 | #define my_alloca(SZ) my_malloc(SZ,MYF(0)) |
---|
194 | #define my_afree(PTR) my_free(PTR,MYF(MY_WME)) |
---|
195 | #endif /* HAVE_ALLOCA */ |
---|
196 | |
---|
197 | #ifdef MSDOS |
---|
198 | #ifdef __ZTC__ |
---|
199 | void * __CDECL halloc(long count,size_t length); |
---|
200 | void __CDECL hfree(void *ptr); |
---|
201 | #endif |
---|
202 | #if defined(USE_HALLOC) |
---|
203 | #if defined(_VCM_) || defined(M_IC80386) |
---|
204 | #undef USE_HALLOC |
---|
205 | #endif |
---|
206 | #endif |
---|
207 | #ifdef USE_HALLOC |
---|
208 | #define malloc(a) halloc((long) (a),1) |
---|
209 | #define free(a) hfree(a) |
---|
210 | #endif |
---|
211 | #endif /* MSDOS */ |
---|
212 | |
---|
213 | #ifndef errno /* did we already get it? */ |
---|
214 | #ifdef HAVE_ERRNO_AS_DEFINE |
---|
215 | #include <errno.h> /* errno is a define */ |
---|
216 | #else |
---|
217 | extern int errno; /* declare errno */ |
---|
218 | #endif |
---|
219 | #endif /* #ifndef errno */ |
---|
220 | extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; |
---|
221 | extern char *home_dir; /* Home directory for user */ |
---|
222 | extern const char *my_progname; /* program-name (printed in errors) */ |
---|
223 | extern char NEAR curr_dir[]; /* Current directory for user */ |
---|
224 | extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); |
---|
225 | extern int (*fatal_error_handler_hook)(uint my_err, const char *str, |
---|
226 | myf MyFlags); |
---|
227 | extern uint my_file_limit; |
---|
228 | |
---|
229 | #ifdef HAVE_LARGE_PAGES |
---|
230 | extern my_bool my_use_large_pages; |
---|
231 | extern uint my_large_page_size; |
---|
232 | #endif |
---|
233 | |
---|
234 | /* charsets */ |
---|
235 | extern CHARSET_INFO *default_charset_info; |
---|
236 | extern CHARSET_INFO *all_charsets[256]; |
---|
237 | extern CHARSET_INFO compiled_charsets[]; |
---|
238 | |
---|
239 | /* statistics */ |
---|
240 | extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; |
---|
241 | extern uint mysys_usage_id; |
---|
242 | extern my_bool my_init_done; |
---|
243 | |
---|
244 | /* Point to current my_message() */ |
---|
245 | extern void (*my_sigtstp_cleanup)(void), |
---|
246 | /* Executed before jump to shell */ |
---|
247 | (*my_sigtstp_restart)(void), |
---|
248 | (*my_abort_hook)(int); |
---|
249 | /* Executed when comming from shell */ |
---|
250 | extern int NEAR my_umask, /* Default creation mask */ |
---|
251 | NEAR my_umask_dir, |
---|
252 | NEAR my_recived_signals, /* Signals we have got */ |
---|
253 | NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ |
---|
254 | NEAR my_dont_interrupt; /* call remember_intr when set */ |
---|
255 | extern my_bool NEAR mysys_uses_curses, my_use_symdir; |
---|
256 | extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; |
---|
257 | |
---|
258 | extern ulong my_default_record_cache_size; |
---|
259 | extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, |
---|
260 | NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; |
---|
261 | extern char wild_many,wild_one,wild_prefix; |
---|
262 | extern const char *charsets_dir; |
---|
263 | extern char *defaults_extra_file; |
---|
264 | extern const char *defaults_group_suffix; |
---|
265 | extern const char *defaults_file; |
---|
266 | |
---|
267 | extern my_bool timed_mutexes; |
---|
268 | |
---|
269 | typedef struct wild_file_pack /* Struct to hold info when selecting files */ |
---|
270 | { |
---|
271 | uint wilds; /* How many wildcards */ |
---|
272 | uint not_pos; /* Start of not-theese-files */ |
---|
273 | my_string *wild; /* Pointer to wildcards */ |
---|
274 | } WF_PACK; |
---|
275 | |
---|
276 | enum loglevel { |
---|
277 | ERROR_LEVEL, |
---|
278 | WARNING_LEVEL, |
---|
279 | INFORMATION_LEVEL |
---|
280 | }; |
---|
281 | |
---|
282 | enum cache_type |
---|
283 | { |
---|
284 | TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE, |
---|
285 | SEQ_READ_APPEND /* sequential read or append */, |
---|
286 | READ_FIFO, READ_NET,WRITE_NET}; |
---|
287 | |
---|
288 | enum flush_type |
---|
289 | { |
---|
290 | FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE |
---|
291 | }; |
---|
292 | |
---|
293 | typedef struct st_record_cache /* Used when cacheing records */ |
---|
294 | { |
---|
295 | File file; |
---|
296 | int rc_seek,error,inited; |
---|
297 | uint rc_length,read_length,reclength; |
---|
298 | my_off_t rc_record_pos,end_of_file; |
---|
299 | byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; |
---|
300 | #ifdef HAVE_AIOWAIT |
---|
301 | int use_async_io; |
---|
302 | my_aio_result aio_result; |
---|
303 | #endif |
---|
304 | enum cache_type type; |
---|
305 | } RECORD_CACHE; |
---|
306 | |
---|
307 | enum file_type |
---|
308 | { |
---|
309 | UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, |
---|
310 | FILE_BY_MKSTEMP, FILE_BY_DUP |
---|
311 | }; |
---|
312 | |
---|
313 | struct st_my_file_info |
---|
314 | { |
---|
315 | my_string name; |
---|
316 | enum file_type type; |
---|
317 | #if defined(THREAD) && !defined(HAVE_PREAD) |
---|
318 | pthread_mutex_t mutex; |
---|
319 | #endif |
---|
320 | }; |
---|
321 | |
---|
322 | extern struct st_my_file_info *my_file_info; |
---|
323 | |
---|
324 | typedef struct st_my_tmpdir |
---|
325 | { |
---|
326 | char **list; |
---|
327 | uint cur, max; |
---|
328 | #ifdef THREAD |
---|
329 | pthread_mutex_t mutex; |
---|
330 | #endif |
---|
331 | } MY_TMPDIR; |
---|
332 | |
---|
333 | typedef struct st_dynamic_array |
---|
334 | { |
---|
335 | char *buffer; |
---|
336 | uint elements,max_element; |
---|
337 | uint alloc_increment; |
---|
338 | uint size_of_element; |
---|
339 | } DYNAMIC_ARRAY; |
---|
340 | |
---|
341 | typedef struct st_dynamic_string |
---|
342 | { |
---|
343 | char *str; |
---|
344 | uint length,max_length,alloc_increment; |
---|
345 | } DYNAMIC_STRING; |
---|
346 | |
---|
347 | struct st_io_cache; |
---|
348 | typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); |
---|
349 | |
---|
350 | #ifdef THREAD |
---|
351 | typedef struct st_io_cache_share |
---|
352 | { |
---|
353 | /* to sync on reads into buffer */ |
---|
354 | pthread_mutex_t mutex; |
---|
355 | pthread_cond_t cond; |
---|
356 | int count, total; |
---|
357 | /* actual IO_CACHE that filled the buffer */ |
---|
358 | struct st_io_cache *active; |
---|
359 | #ifdef NOT_YET_IMPLEMENTED |
---|
360 | /* whether the structure should be free'd */ |
---|
361 | my_bool alloced; |
---|
362 | #endif |
---|
363 | } IO_CACHE_SHARE; |
---|
364 | #endif |
---|
365 | |
---|
366 | typedef struct st_io_cache /* Used when cacheing files */ |
---|
367 | { |
---|
368 | /* Offset in file corresponding to the first byte of byte* buffer. */ |
---|
369 | my_off_t pos_in_file; |
---|
370 | /* |
---|
371 | The offset of end of file for READ_CACHE and WRITE_CACHE. |
---|
372 | For SEQ_READ_APPEND it the maximum of the actual end of file and |
---|
373 | the position represented by read_end. |
---|
374 | */ |
---|
375 | my_off_t end_of_file; |
---|
376 | /* Points to current read position in the buffer */ |
---|
377 | byte *read_pos; |
---|
378 | /* the non-inclusive boundary in the buffer for the currently valid read */ |
---|
379 | byte *read_end; |
---|
380 | byte *buffer; /* The read buffer */ |
---|
381 | /* Used in ASYNC_IO */ |
---|
382 | byte *request_pos; |
---|
383 | |
---|
384 | /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ |
---|
385 | byte *write_buffer; |
---|
386 | /* |
---|
387 | Only used in SEQ_READ_APPEND, and points to the current read position |
---|
388 | in the write buffer. Note that reads in SEQ_READ_APPEND caches can |
---|
389 | happen from both read buffer (byte* buffer) and write buffer |
---|
390 | (byte* write_buffer). |
---|
391 | */ |
---|
392 | byte *append_read_pos; |
---|
393 | /* Points to current write position in the write buffer */ |
---|
394 | byte *write_pos; |
---|
395 | /* The non-inclusive boundary of the valid write area */ |
---|
396 | byte *write_end; |
---|
397 | |
---|
398 | /* |
---|
399 | Current_pos and current_end are convenience variables used by |
---|
400 | my_b_tell() and other routines that need to know the current offset |
---|
401 | current_pos points to &write_pos, and current_end to &write_end in a |
---|
402 | WRITE_CACHE, and &read_pos and &read_end respectively otherwise |
---|
403 | */ |
---|
404 | byte **current_pos, **current_end; |
---|
405 | #ifdef THREAD |
---|
406 | /* |
---|
407 | The lock is for append buffer used in SEQ_READ_APPEND cache |
---|
408 | need mutex copying from append buffer to read buffer. |
---|
409 | */ |
---|
410 | pthread_mutex_t append_buffer_lock; |
---|
411 | /* |
---|
412 | The following is used when several threads are reading the |
---|
413 | same file in parallel. They are synchronized on disk |
---|
414 | accesses reading the cached part of the file asynchronously. |
---|
415 | It should be set to NULL to disable the feature. Only |
---|
416 | READ_CACHE mode is supported. |
---|
417 | */ |
---|
418 | IO_CACHE_SHARE *share; |
---|
419 | #endif |
---|
420 | /* |
---|
421 | A caller will use my_b_read() macro to read from the cache |
---|
422 | if the data is already in cache, it will be simply copied with |
---|
423 | memcpy() and internal variables will be accordinging updated with |
---|
424 | no functions invoked. However, if the data is not fully in the cache, |
---|
425 | my_b_read() will call read_function to fetch the data. read_function |
---|
426 | must never be invoked directly. |
---|
427 | */ |
---|
428 | int (*read_function)(struct st_io_cache *,byte *,uint); |
---|
429 | /* |
---|
430 | Same idea as in the case of read_function, except my_b_write() needs to |
---|
431 | be replaced with my_b_append() for a SEQ_READ_APPEND cache |
---|
432 | */ |
---|
433 | int (*write_function)(struct st_io_cache *,const byte *,uint); |
---|
434 | /* |
---|
435 | Specifies the type of the cache. Depending on the type of the cache |
---|
436 | certain operations might not be available and yield unpredicatable |
---|
437 | results. Details to be documented later |
---|
438 | */ |
---|
439 | enum cache_type type; |
---|
440 | /* |
---|
441 | Callbacks when the actual read I/O happens. These were added and |
---|
442 | are currently used for binary logging of LOAD DATA INFILE - when a |
---|
443 | block is read from the file, we create a block create/append event, and |
---|
444 | when IO_CACHE is closed, we create an end event. These functions could, |
---|
445 | of course be used for other things |
---|
446 | */ |
---|
447 | IO_CACHE_CALLBACK pre_read; |
---|
448 | IO_CACHE_CALLBACK post_read; |
---|
449 | IO_CACHE_CALLBACK pre_close; |
---|
450 | /* |
---|
451 | Counts the number of times, when we were forced to use disk. We use it to |
---|
452 | increase the binlog_cache_disk_use status variable. |
---|
453 | */ |
---|
454 | ulong disk_writes; |
---|
455 | void* arg; /* for use by pre/post_read */ |
---|
456 | char *file_name; /* if used with 'open_cached_file' */ |
---|
457 | char *dir,*prefix; |
---|
458 | File file; /* file descriptor */ |
---|
459 | /* |
---|
460 | seek_not_done is set by my_b_seek() to inform the upcoming read/write |
---|
461 | operation that a seek needs to be preformed prior to the actual I/O |
---|
462 | error is 0 if the cache operation was successful, -1 if there was a |
---|
463 | "hard" error, and the actual number of I/O-ed bytes if the read/write was |
---|
464 | partial. |
---|
465 | */ |
---|
466 | int seek_not_done,error; |
---|
467 | /* buffer_length is memory size allocated for buffer or write_buffer */ |
---|
468 | uint buffer_length; |
---|
469 | /* read_length is the same as buffer_length except when we use async io */ |
---|
470 | uint read_length; |
---|
471 | myf myflags; /* Flags used to my_read/my_write */ |
---|
472 | /* |
---|
473 | alloced_buffer is 1 if the buffer was allocated by init_io_cache() and |
---|
474 | 0 if it was supplied by the user. |
---|
475 | Currently READ_NET is the only one that will use a buffer allocated |
---|
476 | somewhere else |
---|
477 | */ |
---|
478 | my_bool alloced_buffer; |
---|
479 | #ifdef HAVE_AIOWAIT |
---|
480 | /* |
---|
481 | As inidicated by ifdef, this is for async I/O, which is not currently |
---|
482 | used (because it's not reliable on all systems) |
---|
483 | */ |
---|
484 | uint inited; |
---|
485 | my_off_t aio_read_pos; |
---|
486 | my_aio_result aio_result; |
---|
487 | #endif |
---|
488 | } IO_CACHE; |
---|
489 | |
---|
490 | typedef int (*qsort2_cmp)(const void *, const void *, const void *); |
---|
491 | |
---|
492 | /* defines for mf_iocache */ |
---|
493 | |
---|
494 | /* Test if buffer is inited */ |
---|
495 | #define my_b_clear(info) (info)->buffer=0 |
---|
496 | #define my_b_inited(info) (info)->buffer |
---|
497 | #define my_b_EOF INT_MIN |
---|
498 | |
---|
499 | #define my_b_read(info,Buffer,Count) \ |
---|
500 | ((info)->read_pos + (Count) <= (info)->read_end ?\ |
---|
501 | (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \ |
---|
502 | ((info)->read_pos+=(Count)),0) :\ |
---|
503 | (*(info)->read_function)((info),Buffer,Count)) |
---|
504 | |
---|
505 | #define my_b_write(info,Buffer,Count) \ |
---|
506 | ((info)->write_pos + (Count) <=(info)->write_end ?\ |
---|
507 | (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ |
---|
508 | ((info)->write_pos+=(Count)),0) : \ |
---|
509 | (*(info)->write_function)((info),(Buffer),(Count))) |
---|
510 | |
---|
511 | #define my_b_get(info) \ |
---|
512 | ((info)->read_pos != (info)->read_end ?\ |
---|
513 | ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\ |
---|
514 | _my_b_get(info)) |
---|
515 | |
---|
516 | /* my_b_write_byte dosn't have any err-check */ |
---|
517 | #define my_b_write_byte(info,chr) \ |
---|
518 | (((info)->write_pos < (info)->write_end) ?\ |
---|
519 | ((*(info)->write_pos++)=(chr)) :\ |
---|
520 | (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr)))) |
---|
521 | |
---|
522 | #define my_b_fill_cache(info) \ |
---|
523 | (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) |
---|
524 | |
---|
525 | #define my_b_tell(info) ((info)->pos_in_file + \ |
---|
526 | (uint) (*(info)->current_pos - (info)->request_pos)) |
---|
527 | |
---|
528 | /* tell write offset in the SEQ_APPEND cache */ |
---|
529 | my_off_t my_b_append_tell(IO_CACHE* info); |
---|
530 | my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ |
---|
531 | |
---|
532 | #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ |
---|
533 | *(info)->current_pos) |
---|
534 | |
---|
535 | typedef uint32 ha_checksum; |
---|
536 | |
---|
537 | /* Define the type of function to be passed to process_default_option_files */ |
---|
538 | typedef int (*Process_option_func)(void *ctx, const char *group_name, |
---|
539 | const char *option); |
---|
540 | |
---|
541 | #include <my_alloc.h> |
---|
542 | |
---|
543 | /* Prototypes for mysys and my_func functions */ |
---|
544 | |
---|
545 | extern int my_copy(const char *from,const char *to,myf MyFlags); |
---|
546 | extern int my_append(const char *from,const char *to,myf MyFlags); |
---|
547 | extern int my_delete(const char *name,myf MyFlags); |
---|
548 | extern int my_getwd(my_string buf,uint size,myf MyFlags); |
---|
549 | extern int my_setwd(const char *dir,myf MyFlags); |
---|
550 | extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); |
---|
551 | extern gptr my_once_alloc(uint Size,myf MyFlags); |
---|
552 | extern void my_once_free(void); |
---|
553 | extern char *my_once_strdup(const char *src,myf myflags); |
---|
554 | extern char *my_once_memdup(const char *src, uint len, myf myflags); |
---|
555 | extern File my_open(const char *FileName,int Flags,myf MyFlags); |
---|
556 | extern File my_register_filename(File fd, const char *FileName, |
---|
557 | enum file_type type_of_file, |
---|
558 | uint error_message_number, myf MyFlags); |
---|
559 | extern File my_create(const char *FileName,int CreateFlags, |
---|
560 | int AccsesFlags, myf MyFlags); |
---|
561 | extern int my_close(File Filedes,myf MyFlags); |
---|
562 | extern File my_dup(File file, myf MyFlags); |
---|
563 | extern int my_mkdir(const char *dir, int Flags, myf MyFlags); |
---|
564 | extern int my_readlink(char *to, const char *filename, myf MyFlags); |
---|
565 | extern int my_realpath(char *to, const char *filename, myf MyFlags); |
---|
566 | extern File my_create_with_symlink(const char *linkname, const char *filename, |
---|
567 | int createflags, int access_flags, |
---|
568 | myf MyFlags); |
---|
569 | extern int my_delete_with_symlink(const char *name, myf MyFlags); |
---|
570 | extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); |
---|
571 | extern int my_symlink(const char *content, const char *linkname, myf MyFlags); |
---|
572 | extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); |
---|
573 | extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, |
---|
574 | myf MyFlags); |
---|
575 | extern int my_rename(const char *from,const char *to,myf MyFlags); |
---|
576 | extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); |
---|
577 | extern my_off_t my_tell(File fd,myf MyFlags); |
---|
578 | extern uint my_write(File Filedes,const byte *Buffer,uint Count, |
---|
579 | myf MyFlags); |
---|
580 | extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, |
---|
581 | my_off_t offset,myf MyFlags); |
---|
582 | extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); |
---|
583 | extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, |
---|
584 | myf MyFlags); |
---|
585 | extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); |
---|
586 | extern my_off_t my_ftell(FILE *stream,myf MyFlags); |
---|
587 | extern gptr _mymalloc(uint uSize,const char *sFile, |
---|
588 | uint uLine, myf MyFlag); |
---|
589 | extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, |
---|
590 | uint uLine, myf MyFlag); |
---|
591 | extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); |
---|
592 | extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); |
---|
593 | extern int _sanity(const char *sFile,unsigned int uLine); |
---|
594 | extern gptr _my_memdup(const byte *from,uint length, |
---|
595 | const char *sFile, uint uLine,myf MyFlag); |
---|
596 | extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, |
---|
597 | myf MyFlag); |
---|
598 | extern char *_my_strdup_with_length(const byte *from, uint length, |
---|
599 | const char *sFile, uint uLine, |
---|
600 | myf MyFlag); |
---|
601 | |
---|
602 | #ifdef __WIN__ |
---|
603 | extern int my_access(const char *path, int amode); |
---|
604 | extern File my_sopen(const char *path, int oflag, int shflag, int pmode); |
---|
605 | #else |
---|
606 | #define my_access access |
---|
607 | #endif |
---|
608 | extern int check_if_legal_filename(const char *path); |
---|
609 | |
---|
610 | #ifndef TERMINATE |
---|
611 | extern void TERMINATE(FILE *file); |
---|
612 | #endif |
---|
613 | extern void init_glob_errs(void); |
---|
614 | extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); |
---|
615 | extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); |
---|
616 | extern int my_fclose(FILE *fd,myf MyFlags); |
---|
617 | extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); |
---|
618 | extern int my_sync(File fd, myf my_flags); |
---|
619 | extern int my_error _VARARGS((int nr,myf MyFlags, ...)); |
---|
620 | extern int my_printf_error _VARARGS((uint my_err, const char *format, |
---|
621 | myf MyFlags, ...) |
---|
622 | __attribute__ ((format (printf, 2, 4)))); |
---|
623 | extern int my_error_register(const char **errmsgs, int first, int last); |
---|
624 | extern const char **my_error_unregister(int first, int last); |
---|
625 | extern int my_message(uint my_err, const char *str,myf MyFlags); |
---|
626 | extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags); |
---|
627 | extern int my_message_curses(uint my_err, const char *str,myf MyFlags); |
---|
628 | extern my_bool my_init(void); |
---|
629 | extern void my_end(int infoflag); |
---|
630 | extern int my_redel(const char *from, const char *to, int MyFlags); |
---|
631 | extern int my_copystat(const char *from, const char *to, int MyFlags); |
---|
632 | extern my_string my_filename(File fd); |
---|
633 | |
---|
634 | #ifndef THREAD |
---|
635 | extern void dont_break(void); |
---|
636 | extern void allow_break(void); |
---|
637 | #else |
---|
638 | #define dont_break() |
---|
639 | #define allow_break() |
---|
640 | #endif |
---|
641 | |
---|
642 | extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); |
---|
643 | extern char *my_tmpdir(MY_TMPDIR *tmpdir); |
---|
644 | extern void free_tmpdir(MY_TMPDIR *tmpdir); |
---|
645 | |
---|
646 | extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); |
---|
647 | extern uint dirname_part(my_string to,const char *name); |
---|
648 | extern uint dirname_length(const char *name); |
---|
649 | #define base_name(A) (A+dirname_length(A)) |
---|
650 | extern int test_if_hard_path(const char *dir_name); |
---|
651 | extern my_bool has_path(const char *name); |
---|
652 | extern char *convert_dirname(char *to, const char *from, const char *from_end); |
---|
653 | extern void to_unix_path(my_string name); |
---|
654 | extern my_string fn_ext(const char *name); |
---|
655 | extern my_string fn_same(my_string toname,const char *name,int flag); |
---|
656 | extern my_string fn_format(my_string to,const char *name,const char *dir, |
---|
657 | const char *form, uint flag); |
---|
658 | extern size_s strlength(const char *str); |
---|
659 | extern void pack_dirname(my_string to,const char *from); |
---|
660 | extern uint unpack_dirname(my_string to,const char *from); |
---|
661 | extern uint cleanup_dirname(my_string to,const char *from); |
---|
662 | extern uint system_filename(my_string to,const char *from); |
---|
663 | extern uint unpack_filename(my_string to,const char *from); |
---|
664 | extern my_string intern_filename(my_string to,const char *from); |
---|
665 | extern my_string directory_file_name(my_string dst, const char *src); |
---|
666 | extern int pack_filename(my_string to, const char *name, size_s max_length); |
---|
667 | extern my_string my_path(my_string to,const char *progname, |
---|
668 | const char *own_pathname_part); |
---|
669 | extern my_string my_load_path(my_string to, const char *path, |
---|
670 | const char *own_path_prefix); |
---|
671 | extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern); |
---|
672 | extern WF_PACK *wf_comp(my_string str); |
---|
673 | extern int wf_test(struct wild_file_pack *wf_pack,const char *name); |
---|
674 | extern void wf_end(struct wild_file_pack *buffer); |
---|
675 | extern size_s strip_sp(my_string str); |
---|
676 | extern void get_date(my_string to,int timeflag,time_t use_time); |
---|
677 | extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage); |
---|
678 | extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, |
---|
679 | uint reclength,enum cache_type type, |
---|
680 | pbool use_async_io); |
---|
681 | extern int read_cache_record(RECORD_CACHE *info,byte *to); |
---|
682 | extern int end_record_cache(RECORD_CACHE *info); |
---|
683 | extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, |
---|
684 | const byte *record,uint length); |
---|
685 | extern int flush_write_cache(RECORD_CACHE *info); |
---|
686 | extern long my_clock(void); |
---|
687 | extern sig_handler sigtstp_handler(int signal_number); |
---|
688 | extern void handle_recived_signals(void); |
---|
689 | |
---|
690 | extern sig_handler my_set_alarm_variable(int signo); |
---|
691 | extern void my_string_ptr_sort(void *base,uint items,size_s size); |
---|
692 | extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, |
---|
693 | size_s size_of_element,uchar *buffer[]); |
---|
694 | extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, |
---|
695 | qsort2_cmp cmp, void *cmp_argument); |
---|
696 | extern qsort2_cmp get_ptr_compare(uint); |
---|
697 | void my_store_ptr(byte *buff, uint pack_length, my_off_t pos); |
---|
698 | my_off_t my_get_ptr(byte *ptr, uint pack_length); |
---|
699 | extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, |
---|
700 | enum cache_type type,my_off_t seek_offset, |
---|
701 | pbool use_async_io, myf cache_myflags); |
---|
702 | extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, |
---|
703 | my_off_t seek_offset,pbool use_async_io, |
---|
704 | pbool clear_cache); |
---|
705 | extern void setup_io_cache(IO_CACHE* info); |
---|
706 | extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count); |
---|
707 | #ifdef THREAD |
---|
708 | extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); |
---|
709 | extern void init_io_cache_share(IO_CACHE *info, |
---|
710 | IO_CACHE_SHARE *s, uint num_threads); |
---|
711 | extern void remove_io_thread(IO_CACHE *info); |
---|
712 | #endif |
---|
713 | extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count); |
---|
714 | extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count); |
---|
715 | extern int _my_b_get(IO_CACHE *info); |
---|
716 | extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); |
---|
717 | extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); |
---|
718 | extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); |
---|
719 | extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); |
---|
720 | |
---|
721 | extern int my_block_write(IO_CACHE *info, const byte *Buffer, |
---|
722 | uint Count, my_off_t pos); |
---|
723 | extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); |
---|
724 | |
---|
725 | #define flush_io_cache(info) my_b_flush_io_cache((info),1) |
---|
726 | |
---|
727 | extern int end_io_cache(IO_CACHE *info); |
---|
728 | extern uint my_b_fill(IO_CACHE *info); |
---|
729 | extern void my_b_seek(IO_CACHE *info,my_off_t pos); |
---|
730 | extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); |
---|
731 | extern my_off_t my_b_filelength(IO_CACHE *info); |
---|
732 | extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); |
---|
733 | extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); |
---|
734 | extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, |
---|
735 | const char *prefix, uint cache_size, |
---|
736 | myf cache_myflags); |
---|
737 | extern my_bool real_open_cached_file(IO_CACHE *cache); |
---|
738 | extern void close_cached_file(IO_CACHE *cache); |
---|
739 | File create_temp_file(char *to, const char *dir, const char *pfx, |
---|
740 | int mode, myf MyFlags); |
---|
741 | #define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO) |
---|
742 | #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO) |
---|
743 | extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, |
---|
744 | uint init_alloc,uint alloc_increment |
---|
745 | CALLER_INFO_PROTO); |
---|
746 | extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); |
---|
747 | extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); |
---|
748 | extern byte *pop_dynamic(DYNAMIC_ARRAY*); |
---|
749 | extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); |
---|
750 | extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); |
---|
751 | extern void delete_dynamic(DYNAMIC_ARRAY *array); |
---|
752 | extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); |
---|
753 | extern void freeze_size(DYNAMIC_ARRAY *array); |
---|
754 | #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) |
---|
755 | #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) |
---|
756 | #define push_dynamic(A,B) insert_dynamic(A,B) |
---|
757 | #define reset_dynamic(array) ((array)->elements= 0) |
---|
758 | |
---|
759 | extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, |
---|
760 | uint init_alloc,uint alloc_increment); |
---|
761 | extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); |
---|
762 | my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, |
---|
763 | uint length); |
---|
764 | extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); |
---|
765 | extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); |
---|
766 | extern void dynstr_free(DYNAMIC_STRING *str); |
---|
767 | #ifdef HAVE_MLOCK |
---|
768 | extern byte *my_malloc_lock(uint length,myf flags); |
---|
769 | extern void my_free_lock(byte *ptr,myf flags); |
---|
770 | #else |
---|
771 | #define my_malloc_lock(A,B) my_malloc((A),(B)) |
---|
772 | #define my_free_lock(A,B) my_free((A),(B)) |
---|
773 | #endif |
---|
774 | #define alloc_root_inited(A) ((A)->min_malloc != 0) |
---|
775 | #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) |
---|
776 | #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) |
---|
777 | extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, |
---|
778 | uint pre_alloc_size); |
---|
779 | extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); |
---|
780 | extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...); |
---|
781 | extern void free_root(MEM_ROOT *root, myf MyFLAGS); |
---|
782 | extern void set_prealloc_root(MEM_ROOT *root, char *ptr); |
---|
783 | extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, |
---|
784 | uint prealloc_size); |
---|
785 | extern char *strdup_root(MEM_ROOT *root,const char *str); |
---|
786 | extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); |
---|
787 | extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); |
---|
788 | extern int get_defaults_options(int argc, char **argv, |
---|
789 | char **defaults, char **extra_defaults, |
---|
790 | char **group_suffix); |
---|
791 | extern int load_defaults(const char *conf_file, const char **groups, |
---|
792 | int *argc, char ***argv); |
---|
793 | extern int modify_defaults_file(const char *file_location, const char *option, |
---|
794 | const char *option_value, |
---|
795 | const char *section_name, int remove_option); |
---|
796 | extern int my_search_option_files(const char *conf_file, int *argc, |
---|
797 | char ***argv, uint *args_used, |
---|
798 | Process_option_func func, void *func_ctx); |
---|
799 | extern void free_defaults(char **argv); |
---|
800 | extern void my_print_default_files(const char *conf_file); |
---|
801 | extern void print_defaults(const char *conf_file, const char **groups); |
---|
802 | extern my_bool my_compress(byte *, ulong *, ulong *); |
---|
803 | extern my_bool my_uncompress(byte *, ulong *, ulong *); |
---|
804 | extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); |
---|
805 | extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); |
---|
806 | extern uint my_bit_log2(ulong value); |
---|
807 | extern uint my_count_bits(ulonglong v); |
---|
808 | extern uint my_count_bits_ushort(ushort v); |
---|
809 | extern void my_sleep(ulong m_seconds); |
---|
810 | extern ulong crc32(ulong crc, const uchar *buf, uint len); |
---|
811 | extern uint my_set_max_open_files(uint files); |
---|
812 | void my_free_open_file_info(void); |
---|
813 | |
---|
814 | ulonglong my_getsystime(void); |
---|
815 | my_bool my_gethwaddr(uchar *to); |
---|
816 | |
---|
817 | #ifdef HAVE_SYS_MMAN_H |
---|
818 | #include <sys/mman.h> |
---|
819 | |
---|
820 | #ifndef MAP_NOSYNC |
---|
821 | #define MAP_NOSYNC 0 |
---|
822 | #endif |
---|
823 | |
---|
824 | #define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) |
---|
825 | #ifdef HAVE_GETPAGESIZE |
---|
826 | #define my_getpagesize() getpagesize() |
---|
827 | #else |
---|
828 | /* qnx ? */ |
---|
829 | #define my_getpagesize() 8192 |
---|
830 | #endif |
---|
831 | #define my_munmap(a,b) munmap((a),(b)) |
---|
832 | |
---|
833 | #else |
---|
834 | /* not a complete set of mmap() flags, but only those that nesessary */ |
---|
835 | #define PROT_READ 1 |
---|
836 | #define PROT_WRITE 2 |
---|
837 | #define MAP_SHARED 0x0001 |
---|
838 | #define MAP_NOSYNC 0x0800 |
---|
839 | #define MAP_FAILED ((void *)-1) |
---|
840 | #define MS_SYNC 0x0000 |
---|
841 | |
---|
842 | #ifndef __NETWARE__ |
---|
843 | #define HAVE_MMAP |
---|
844 | #endif |
---|
845 | |
---|
846 | int my_getpagesize(void); |
---|
847 | void *my_mmap(void *, size_t, int, int, int, my_off_t); |
---|
848 | int my_munmap(void *, size_t); |
---|
849 | #endif |
---|
850 | |
---|
851 | int my_msync(int, void *, size_t, int); |
---|
852 | |
---|
853 | /* character sets */ |
---|
854 | extern uint get_charset_number(const char *cs_name, uint cs_flags); |
---|
855 | extern uint get_collation_number(const char *name); |
---|
856 | extern const char *get_charset_name(uint cs_number); |
---|
857 | |
---|
858 | extern CHARSET_INFO *get_charset(uint cs_number, myf flags); |
---|
859 | extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); |
---|
860 | extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, |
---|
861 | uint cs_flags, myf my_flags); |
---|
862 | extern void free_charsets(void); |
---|
863 | extern char *get_charsets_dir(char *buf); |
---|
864 | extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); |
---|
865 | extern my_bool init_compiled_charsets(myf flags); |
---|
866 | extern void add_compiled_collation(CHARSET_INFO *cs); |
---|
867 | extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, |
---|
868 | char *to, ulong to_length, |
---|
869 | const char *from, ulong length); |
---|
870 | #ifdef __WIN__ |
---|
871 | #define BACKSLASH_MBTAIL |
---|
872 | /* File system character set */ |
---|
873 | extern CHARSET_INFO *fs_character_set(void); |
---|
874 | #endif |
---|
875 | extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, |
---|
876 | char *to, ulong to_length, |
---|
877 | const char *from, ulong length); |
---|
878 | |
---|
879 | extern void thd_increment_bytes_sent(ulong length); |
---|
880 | extern void thd_increment_bytes_received(ulong length); |
---|
881 | extern void thd_increment_net_big_packet_count(ulong length); |
---|
882 | |
---|
883 | #ifdef __WIN__ |
---|
884 | extern my_bool have_tcpip; /* Is set if tcpip is used */ |
---|
885 | |
---|
886 | /* implemented in my_windac.c */ |
---|
887 | |
---|
888 | int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, |
---|
889 | DWORD owner_rights, DWORD everybody_rights); |
---|
890 | |
---|
891 | void my_security_attr_free(SECURITY_ATTRIBUTES *sa); |
---|
892 | |
---|
893 | /* implemented in my_conio.c */ |
---|
894 | char* my_cgets(char *string, unsigned long clen, unsigned long* plen); |
---|
895 | |
---|
896 | #endif |
---|
897 | #ifdef __NETWARE__ |
---|
898 | void netware_reg_user(const char *ip, const char *user, |
---|
899 | const char *application); |
---|
900 | #endif |
---|
901 | |
---|
902 | C_MODE_END |
---|
903 | #include "raid.h" |
---|
904 | #endif /* _my_sys_h */ |
---|