The world's most popular open source database
00001 /* Copyright (C) 2000-2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #ifndef _my_sys_h 00018 #define _my_sys_h 00019 C_MODE_START 00020 00021 #ifdef HAVE_AIOWAIT 00022 #include <sys/asynch.h> /* Used by record-cache */ 00023 typedef struct my_aio_result { 00024 aio_result_t result; 00025 int pending; 00026 } my_aio_result; 00027 #endif 00028 00029 #ifndef THREAD 00030 extern int NEAR my_errno; /* Last error in mysys */ 00031 #else 00032 #include <my_pthread.h> 00033 #endif 00034 00035 #ifndef _m_ctype_h 00036 #include <m_ctype.h> /* for CHARSET_INFO */ 00037 #endif 00038 00039 #include <stdarg.h> 00040 #include <typelib.h> 00041 00042 #define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; } 00043 #define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} 00044 #define MY_INIT(name); { my_progname= name; my_init(); } 00045 00046 #define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ 00047 #define NRERRBUFFS (2) /* Buffers for parameters */ 00048 #define MY_FILE_ERROR ((uint) ~0) 00049 00050 /* General bitmaps for my_func's */ 00051 #define MY_FFNF 1 /* Fatal if file not found */ 00052 #define MY_FNABP 2 /* Fatal if not all bytes read/writen */ 00053 #define MY_NABP 4 /* Error if not all bytes read/writen */ 00054 #define MY_FAE 8 /* Fatal if any error */ 00055 #define MY_WME 16 /* Write message on error */ 00056 #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ 00057 #define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ 00058 #define MY_RAID 64 /* Support for RAID */ 00059 #define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ 00060 #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ 00061 #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ 00062 #define MY_COPYTIME 64 /* my_redel() copys time */ 00063 #define MY_DELETE_OLD 256 /* my_create_with_symlink() */ 00064 #define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */ 00065 #define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */ 00066 #define MY_REDEL_MAKE_BACKUP 256 00067 #define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */ 00068 #define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */ 00069 #define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */ 00070 #define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */ 00071 #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ 00072 #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ 00073 #define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ 00074 #define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ 00075 00076 #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ 00077 #define MY_GIVE_INFO 2 /* Give time info about process*/ 00078 #define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */ 00079 00080 #define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */ 00081 #define MY_REMOVE_OPTION 1 00082 #define MY_REMOVE_SECTION 2 00083 00084 #define ME_HIGHBYTE 8 /* Shift for colours */ 00085 #define ME_NOCUR 1 /* Don't use curses message */ 00086 #define ME_OLDWIN 2 /* Use old window */ 00087 #define ME_BELL 4 /* Ring bell then printing message */ 00088 #define ME_HOLDTANG 8 /* Don't delete last keys */ 00089 #define ME_WAITTOT 16 /* Wait for errtime secs of for a action */ 00090 #define ME_WAITTANG 32 /* Wait for a user action */ 00091 #define ME_NOREFRESH 64 /* Dont refresh screen */ 00092 #define ME_NOINPUT 128 /* Dont use the input libary */ 00093 #define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */ 00094 #define ME_COLOUR2 ((2 << ME_HIGHBYTE)) 00095 #define ME_COLOUR3 ((3 << ME_HIGHBYTE)) 00096 00097 /* Bits in last argument to fn_format */ 00098 #define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */ 00099 #define MY_REPLACE_EXT 2 /* replace extension with 'ext' */ 00100 #define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */ 00101 #define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */ 00102 #define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */ 00103 #define MY_RETURN_REAL_PATH 32 /* return full path for file */ 00104 #define MY_SAFE_PATH 64 /* Return NULL if too long path */ 00105 #define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */ 00106 #define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/ 00107 00108 00109 /* My seek flags */ 00110 #define MY_SEEK_SET 0 00111 #define MY_SEEK_CUR 1 00112 #define MY_SEEK_END 2 00113 00114 /* Some constants */ 00115 #define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */ 00116 #define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ 00117 #define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */ 00118 #define DFLT_INIT_HITS 3 00119 00120 /* root_alloc flags */ 00121 #define MY_KEEP_PREALLOC 1 00122 #define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ 00123 00124 /* Internal error numbers (for assembler functions) */ 00125 #define MY_ERRNO_EDOM 33 00126 #define MY_ERRNO_ERANGE 34 00127 00128 /* Bits for get_date timeflag */ 00129 #define GETDATE_DATE_TIME 1 00130 #define GETDATE_SHORT_DATE 2 00131 #define GETDATE_HHMMSSTIME 4 00132 #define GETDATE_GMT 8 00133 #define GETDATE_FIXEDLENGTH 16 00134 00135 /* defines when allocating data */ 00136 #ifdef SAFEMALLOC 00137 #define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) 00138 #define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG ) 00139 #define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG ) 00140 #define my_checkmalloc() _sanity( __FILE__, __LINE__ ) 00141 #define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG) 00142 #define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C) 00143 #define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C) 00144 #define my_strndup(A,B,C) _my_strndup((A),(B),__FILE__,__LINE__,C) 00145 #define TRASH(A,B) bfill(A, B, 0x8F) 00146 #define QUICK_SAFEMALLOC sf_malloc_quick=1 00147 #define NORMAL_SAFEMALLOC sf_malloc_quick=0 00148 extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; 00149 extern ulonglong sf_malloc_mem_limit; 00150 00151 #define CALLER_INFO_PROTO , const char *sFile, uint uLine 00152 #define CALLER_INFO , __FILE__, __LINE__ 00153 #define ORIG_CALLER_INFO , sFile, uLine 00154 #else 00155 #define my_checkmalloc() 00156 #undef TERMINATE 00157 #define TERMINATE(A) {} 00158 #define QUICK_SAFEMALLOC 00159 #define NORMAL_SAFEMALLOC 00160 extern gptr my_malloc(uint Size,myf MyFlags); 00161 #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) 00162 extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); 00163 extern void my_no_flags_free(gptr ptr); 00164 extern gptr my_memdup(const byte *from,uint length,myf MyFlags); 00165 extern char *my_strdup(const char *from,myf MyFlags); 00166 extern char *my_strndup(const char *from, uint length, 00167 myf MyFlags); 00168 /* we do use FG (as a no-op) in below so that a typo on FG is caught */ 00169 #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) 00170 #define CALLER_INFO_PROTO /* nothing */ 00171 #define CALLER_INFO /* nothing */ 00172 #define ORIG_CALLER_INFO /* nothing */ 00173 #define TRASH(A,B) /* nothing */ 00174 #endif 00175 00176 #ifdef HAVE_LARGE_PAGES 00177 extern uint my_get_large_page_size(void); 00178 extern gptr my_large_malloc(uint size, myf my_flags); 00179 extern void my_large_free(gptr ptr, myf my_flags); 00180 #else 00181 #define my_get_large_page_size() (0) 00182 #define my_large_malloc(A,B) my_malloc_lock((A),(B)) 00183 #define my_large_free(A,B) my_free_lock((A),(B)) 00184 #endif /* HAVE_LARGE_PAGES */ 00185 00186 #ifdef HAVE_ALLOCA 00187 #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) 00188 #pragma alloca 00189 #endif /* _AIX */ 00190 #if defined(__MWERKS__) 00191 #undef alloca 00192 #define alloca _alloca 00193 #endif /* __MWERKS__ */ 00194 #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca) 00195 #define alloca __builtin_alloca 00196 #endif /* GNUC */ 00197 #define my_alloca(SZ) alloca((size_t) (SZ)) 00198 #define my_afree(PTR) {} 00199 #else 00200 #define my_alloca(SZ) my_malloc(SZ,MYF(0)) 00201 #define my_afree(PTR) my_free(PTR,MYF(MY_WME)) 00202 #endif /* HAVE_ALLOCA */ 00203 00204 #ifndef errno /* did we already get it? */ 00205 #ifdef HAVE_ERRNO_AS_DEFINE 00206 #include <errno.h> /* errno is a define */ 00207 #else 00208 extern int errno; /* declare errno */ 00209 #endif 00210 #endif /* #ifndef errno */ 00211 extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE]; 00212 extern char *home_dir; /* Home directory for user */ 00213 extern const char *my_progname; /* program-name (printed in errors) */ 00214 extern char NEAR curr_dir[]; /* Current directory for user */ 00215 extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags); 00216 extern int (*fatal_error_handler_hook)(uint my_err, const char *str, 00217 myf MyFlags); 00218 extern uint my_file_limit; 00219 00220 #ifdef HAVE_LARGE_PAGES 00221 extern my_bool my_use_large_pages; 00222 extern uint my_large_page_size; 00223 #endif 00224 00225 /* charsets */ 00226 extern CHARSET_INFO *default_charset_info; 00227 extern CHARSET_INFO *all_charsets[256]; 00228 extern CHARSET_INFO compiled_charsets[]; 00229 00230 /* statistics */ 00231 extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; 00232 extern uint mysys_usage_id; 00233 extern my_bool my_init_done; 00234 00235 /* Point to current my_message() */ 00236 extern void (*my_sigtstp_cleanup)(void), 00237 /* Executed before jump to shell */ 00238 (*my_sigtstp_restart)(void), 00239 (*my_abort_hook)(int); 00240 /* Executed when comming from shell */ 00241 extern int NEAR my_umask, /* Default creation mask */ 00242 NEAR my_umask_dir, 00243 NEAR my_recived_signals, /* Signals we have got */ 00244 NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ 00245 NEAR my_dont_interrupt; /* call remember_intr when set */ 00246 extern my_bool NEAR mysys_uses_curses, my_use_symdir; 00247 extern ulong sf_malloc_cur_memory, sf_malloc_max_memory; 00248 00249 extern ulong my_default_record_cache_size; 00250 extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, 00251 NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks; 00252 extern char wild_many,wild_one,wild_prefix; 00253 extern const char *charsets_dir; 00254 extern char *defaults_extra_file; 00255 extern const char *defaults_group_suffix; 00256 extern const char *defaults_file; 00257 00258 extern my_bool timed_mutexes; 00259 00260 typedef struct wild_file_pack /* Struct to hold info when selecting files */ 00261 { 00262 uint wilds; /* How many wildcards */ 00263 uint not_pos; /* Start of not-theese-files */ 00264 my_string *wild; /* Pointer to wildcards */ 00265 } WF_PACK; 00266 00267 enum loglevel { 00268 ERROR_LEVEL, 00269 WARNING_LEVEL, 00270 INFORMATION_LEVEL 00271 }; 00272 00273 enum cache_type 00274 { 00275 TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE, 00276 SEQ_READ_APPEND /* sequential read or append */, 00277 READ_FIFO, READ_NET,WRITE_NET}; 00278 00279 enum flush_type 00280 { 00281 FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE 00282 }; 00283 00284 typedef struct st_record_cache /* Used when cacheing records */ 00285 { 00286 File file; 00287 int rc_seek,error,inited; 00288 uint rc_length,read_length,reclength; 00289 my_off_t rc_record_pos,end_of_file; 00290 byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; 00291 #ifdef HAVE_AIOWAIT 00292 int use_async_io; 00293 my_aio_result aio_result; 00294 #endif 00295 enum cache_type type; 00296 } RECORD_CACHE; 00297 00298 enum file_type 00299 { 00300 UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN, 00301 FILE_BY_MKSTEMP, FILE_BY_DUP 00302 }; 00303 00304 struct st_my_file_info 00305 { 00306 my_string name; 00307 enum file_type type; 00308 #if defined(THREAD) && !defined(HAVE_PREAD) 00309 pthread_mutex_t mutex; 00310 #endif 00311 }; 00312 00313 extern struct st_my_file_info *my_file_info; 00314 00315 typedef struct st_my_tmpdir 00316 { 00317 char **list; 00318 uint cur, max; 00319 #ifdef THREAD 00320 pthread_mutex_t mutex; 00321 #endif 00322 } MY_TMPDIR; 00323 00324 typedef struct st_dynamic_array 00325 { 00326 char *buffer; 00327 uint elements,max_element; 00328 uint alloc_increment; 00329 uint size_of_element; 00330 } DYNAMIC_ARRAY; 00331 00332 typedef struct st_dynamic_string 00333 { 00334 char *str; 00335 uint length,max_length,alloc_increment; 00336 } DYNAMIC_STRING; 00337 00338 struct st_io_cache; 00339 typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*); 00340 00341 #ifdef THREAD 00342 typedef struct st_io_cache_share 00343 { 00344 /* to sync on reads into buffer */ 00345 pthread_mutex_t mutex; 00346 pthread_cond_t cond; 00347 int count, total; 00348 /* actual IO_CACHE that filled the buffer */ 00349 struct st_io_cache *active; 00350 #ifdef NOT_YET_IMPLEMENTED 00351 /* whether the structure should be free'd */ 00352 my_bool alloced; 00353 #endif 00354 } IO_CACHE_SHARE; 00355 #endif 00356 00357 typedef struct st_io_cache /* Used when cacheing files */ 00358 { 00359 /* Offset in file corresponding to the first byte of byte* buffer. */ 00360 my_off_t pos_in_file; 00361 /* 00362 The offset of end of file for READ_CACHE and WRITE_CACHE. 00363 For SEQ_READ_APPEND it the maximum of the actual end of file and 00364 the position represented by read_end. 00365 */ 00366 my_off_t end_of_file; 00367 /* Points to current read position in the buffer */ 00368 byte *read_pos; 00369 /* the non-inclusive boundary in the buffer for the currently valid read */ 00370 byte *read_end; 00371 byte *buffer; /* The read buffer */ 00372 /* Used in ASYNC_IO */ 00373 byte *request_pos; 00374 00375 /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ 00376 byte *write_buffer; 00377 /* 00378 Only used in SEQ_READ_APPEND, and points to the current read position 00379 in the write buffer. Note that reads in SEQ_READ_APPEND caches can 00380 happen from both read buffer (byte* buffer) and write buffer 00381 (byte* write_buffer). 00382 */ 00383 byte *append_read_pos; 00384 /* Points to current write position in the write buffer */ 00385 byte *write_pos; 00386 /* The non-inclusive boundary of the valid write area */ 00387 byte *write_end; 00388 00389 /* 00390 Current_pos and current_end are convenience variables used by 00391 my_b_tell() and other routines that need to know the current offset 00392 current_pos points to &write_pos, and current_end to &write_end in a 00393 WRITE_CACHE, and &read_pos and &read_end respectively otherwise 00394 */ 00395 byte **current_pos, **current_end; 00396 #ifdef THREAD 00397 /* 00398 The lock is for append buffer used in SEQ_READ_APPEND cache 00399 need mutex copying from append buffer to read buffer. 00400 */ 00401 pthread_mutex_t append_buffer_lock; 00402 /* 00403 The following is used when several threads are reading the 00404 same file in parallel. They are synchronized on disk 00405 accesses reading the cached part of the file asynchronously. 00406 It should be set to NULL to disable the feature. Only 00407 READ_CACHE mode is supported. 00408 */ 00409 IO_CACHE_SHARE *share; 00410 #endif 00411 /* 00412 A caller will use my_b_read() macro to read from the cache 00413 if the data is already in cache, it will be simply copied with 00414 memcpy() and internal variables will be accordinging updated with 00415 no functions invoked. However, if the data is not fully in the cache, 00416 my_b_read() will call read_function to fetch the data. read_function 00417 must never be invoked directly. 00418 */ 00419 int (*read_function)(struct st_io_cache *,byte *,uint); 00420 /* 00421 Same idea as in the case of read_function, except my_b_write() needs to 00422 be replaced with my_b_append() for a SEQ_READ_APPEND cache 00423 */ 00424 int (*write_function)(struct st_io_cache *,const byte *,uint); 00425 /* 00426 Specifies the type of the cache. Depending on the type of the cache 00427 certain operations might not be available and yield unpredicatable 00428 results. Details to be documented later 00429 */ 00430 enum cache_type type; 00431 /* 00432 Callbacks when the actual read I/O happens. These were added and 00433 are currently used for binary logging of LOAD DATA INFILE - when a 00434 block is read from the file, we create a block create/append event, and 00435 when IO_CACHE is closed, we create an end event. These functions could, 00436 of course be used for other things 00437 */ 00438 IO_CACHE_CALLBACK pre_read; 00439 IO_CACHE_CALLBACK post_read; 00440 IO_CACHE_CALLBACK pre_close; 00441 /* 00442 Counts the number of times, when we were forced to use disk. We use it to 00443 increase the binlog_cache_disk_use status variable. 00444 */ 00445 ulong disk_writes; 00446 void* arg; /* for use by pre/post_read */ 00447 char *file_name; /* if used with 'open_cached_file' */ 00448 char *dir,*prefix; 00449 File file; /* file descriptor */ 00450 /* 00451 seek_not_done is set by my_b_seek() to inform the upcoming read/write 00452 operation that a seek needs to be preformed prior to the actual I/O 00453 error is 0 if the cache operation was successful, -1 if there was a 00454 "hard" error, and the actual number of I/O-ed bytes if the read/write was 00455 partial. 00456 */ 00457 int seek_not_done,error; 00458 /* buffer_length is memory size allocated for buffer or write_buffer */ 00459 uint buffer_length; 00460 /* read_length is the same as buffer_length except when we use async io */ 00461 uint read_length; 00462 myf myflags; /* Flags used to my_read/my_write */ 00463 /* 00464 alloced_buffer is 1 if the buffer was allocated by init_io_cache() and 00465 0 if it was supplied by the user. 00466 Currently READ_NET is the only one that will use a buffer allocated 00467 somewhere else 00468 */ 00469 my_bool alloced_buffer; 00470 #ifdef HAVE_AIOWAIT 00471 /* 00472 As inidicated by ifdef, this is for async I/O, which is not currently 00473 used (because it's not reliable on all systems) 00474 */ 00475 uint inited; 00476 my_off_t aio_read_pos; 00477 my_aio_result aio_result; 00478 #endif 00479 } IO_CACHE; 00480 00481 typedef int (*qsort2_cmp)(const void *, const void *, const void *); 00482 00483 /* defines for mf_iocache */ 00484 00485 /* Test if buffer is inited */ 00486 #define my_b_clear(info) (info)->buffer=0 00487 #define my_b_inited(info) (info)->buffer 00488 #define my_b_EOF INT_MIN 00489 00490 #define my_b_read(info,Buffer,Count) \ 00491 ((info)->read_pos + (Count) <= (info)->read_end ?\ 00492 (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \ 00493 ((info)->read_pos+=(Count)),0) :\ 00494 (*(info)->read_function)((info),Buffer,Count)) 00495 00496 #define my_b_write(info,Buffer,Count) \ 00497 ((info)->write_pos + (Count) <=(info)->write_end ?\ 00498 (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\ 00499 ((info)->write_pos+=(Count)),0) : \ 00500 (*(info)->write_function)((info),(Buffer),(Count))) 00501 00502 #define my_b_get(info) \ 00503 ((info)->read_pos != (info)->read_end ?\ 00504 ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\ 00505 _my_b_get(info)) 00506 00507 /* my_b_write_byte dosn't have any err-check */ 00508 #define my_b_write_byte(info,chr) \ 00509 (((info)->write_pos < (info)->write_end) ?\ 00510 ((*(info)->write_pos++)=(chr)) :\ 00511 (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr)))) 00512 00513 #define my_b_fill_cache(info) \ 00514 (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) 00515 00516 #define my_b_tell(info) ((info)->pos_in_file + \ 00517 (uint) (*(info)->current_pos - (info)->request_pos)) 00518 00519 /* tell write offset in the SEQ_APPEND cache */ 00520 my_off_t my_b_append_tell(IO_CACHE* info); 00521 my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ 00522 00523 #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ 00524 *(info)->current_pos) 00525 00526 typedef uint32 ha_checksum; 00527 00528 /* Define the type of function to be passed to process_default_option_files */ 00529 typedef int (*Process_option_func)(void *ctx, const char *group_name, 00530 const char *option); 00531 00532 #include <my_alloc.h> 00533 00534 00535 /* Prototypes for mysys and my_func functions */ 00536 00537 extern int my_copy(const char *from,const char *to,myf MyFlags); 00538 extern int my_append(const char *from,const char *to,myf MyFlags); 00539 extern int my_delete(const char *name,myf MyFlags); 00540 extern int my_getwd(my_string buf,uint size,myf MyFlags); 00541 extern int my_setwd(const char *dir,myf MyFlags); 00542 extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); 00543 extern gptr my_once_alloc(uint Size,myf MyFlags); 00544 extern void my_once_free(void); 00545 extern char *my_once_strdup(const char *src,myf myflags); 00546 extern char *my_once_memdup(const char *src, uint len, myf myflags); 00547 extern File my_open(const char *FileName,int Flags,myf MyFlags); 00548 extern File my_register_filename(File fd, const char *FileName, 00549 enum file_type type_of_file, 00550 uint error_message_number, myf MyFlags); 00551 extern File my_create(const char *FileName,int CreateFlags, 00552 int AccessFlags, myf MyFlags); 00553 extern int my_close(File Filedes,myf MyFlags); 00554 extern File my_dup(File file, myf MyFlags); 00555 extern int my_mkdir(const char *dir, int Flags, myf MyFlags); 00556 extern int my_readlink(char *to, const char *filename, myf MyFlags); 00557 extern int my_realpath(char *to, const char *filename, myf MyFlags); 00558 extern File my_create_with_symlink(const char *linkname, const char *filename, 00559 int createflags, int access_flags, 00560 myf MyFlags); 00561 extern int my_delete_with_symlink(const char *name, myf MyFlags); 00562 extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); 00563 extern int my_symlink(const char *content, const char *linkname, myf MyFlags); 00564 extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); 00565 extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, 00566 myf MyFlags); 00567 extern int my_rename(const char *from,const char *to,myf MyFlags); 00568 extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); 00569 extern my_off_t my_tell(File fd,myf MyFlags); 00570 extern uint my_write(File Filedes,const byte *Buffer,uint Count, 00571 myf MyFlags); 00572 extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, 00573 my_off_t offset,myf MyFlags); 00574 extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); 00575 extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, 00576 myf MyFlags); 00577 extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); 00578 extern my_off_t my_ftell(FILE *stream,myf MyFlags); 00579 extern gptr _mymalloc(uint uSize,const char *sFile, 00580 uint uLine, myf MyFlag); 00581 extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, 00582 uint uLine, myf MyFlag); 00583 extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); 00584 extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); 00585 extern int _sanity(const char *sFile,unsigned int uLine); 00586 extern gptr _my_memdup(const byte *from,uint length, 00587 const char *sFile, uint uLine,myf MyFlag); 00588 extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, 00589 myf MyFlag); 00590 extern char *_my_strndup(const char *from, uint length, 00591 const char *sFile, uint uLine, 00592 myf MyFlag); 00593 00594 /* implemented in my_memmem.c */ 00595 extern void *my_memmem(const void *haystack, size_t haystacklen, 00596 const void *needle, size_t needlelen); 00597 00598 00599 #ifdef __WIN__ 00600 extern int my_access(const char *path, int amode); 00601 extern File my_sopen(const char *path, int oflag, int shflag, int pmode); 00602 #else 00603 #define my_access access 00604 #endif 00605 extern int check_if_legal_filename(const char *path); 00606 extern int check_if_legal_tablename(const char *path); 00607 00608 #if defined(__WIN__) && defined(__NT__) 00609 extern int nt_share_delete(const char *name,myf MyFlags); 00610 #define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags)) 00611 #else 00612 #define my_delete_allow_opened(fname,flags) my_delete((fname),(flags)) 00613 #endif 00614 00615 #ifndef TERMINATE 00616 extern void TERMINATE(FILE *file); 00617 #endif 00618 extern void init_glob_errs(void); 00619 extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags); 00620 extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags); 00621 extern int my_fclose(FILE *fd,myf MyFlags); 00622 extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); 00623 extern int my_sync(File fd, myf my_flags); 00624 extern int my_error _VARARGS((int nr,myf MyFlags, ...)); 00625 extern int my_printf_error _VARARGS((uint my_err, const char *format, 00626 myf MyFlags, ...) 00627 __attribute__ ((format (printf, 2, 4)))); 00628 extern int my_error_register(const char **errmsgs, int first, int last); 00629 extern const char **my_error_unregister(int first, int last); 00630 extern int my_message(uint my_err, const char *str,myf MyFlags); 00631 extern int my_message_no_curses(

