Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

my_sys.h

Go to the documentation of this file.
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 MAXMAPS         (4)     /* Number of error message maps */
00047 #define ERRMOD          (1000)  /* Max number of errors in a map */
00048 #define ERRMSGSIZE      (SC_MAXWIDTH)   /* Max length of a error message */
00049 #define NRERRBUFFS      (2)     /* Buffers for parameters */
00050 #define MY_FILE_ERROR   ((uint) ~0)
00051 
00052         /* General bitmaps for my_func's */
00053 #define MY_FFNF         1       /* Fatal if file not found */
00054 #define MY_FNABP        2       /* Fatal if not all bytes read/writen */
00055 #define MY_NABP         4       /* Error if not all bytes read/writen */
00056 #define MY_FAE          8       /* Fatal if any error */
00057 #define MY_WME          16      /* Write message on error */
00058 #define MY_WAIT_IF_FULL 32      /* Wait and try again if disk full error */
00059 #define MY_RAID         64      /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
00060 #define MY_FULL_IO     512      /* For my_read - loop intil I/O
00061                                    is complete
00062                                 */
00063 #define MY_DONT_CHECK_FILESIZE 128      /* Option to init_io_cache() */
00064 #define MY_LINK_WARNING 32      /* my_redel() gives warning if links */
00065 #define MY_COPYTIME     64      /* my_redel() copys time */
00066 #define MY_DELETE_OLD   256     /* my_create_with_symlink() */
00067 #define MY_RESOLVE_LINK 128     /* my_realpath(); Only resolve links */
00068 #define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
00069 #define MY_REDEL_MAKE_BACKUP 256
00070 #define MY_SEEK_NOT_DONE 32     /* my_lock may have to do a seek */
00071 #define MY_DONT_WAIT    64      /* my_lock() don't wait if can't lock */
00072 #define MY_ZEROFILL     32      /* my_malloc(), fill array with zero */
00073 #define MY_ALLOW_ZERO_PTR 64    /* my_realloc() ; zero ptr -> malloc */
00074 #define MY_FREE_ON_ERROR 128    /* my_realloc() ; Free old ptr on error */
00075 #define MY_HOLD_ON_ERROR 256    /* my_realloc() ; Return old ptr on error */
00076 #define MY_THREADSAFE   128     /* pread/pwrite:  Don't allow interrupts */
00077 #define MY_DONT_OVERWRITE_FILE 1024     /* my_copy; Don't overwrite file */
00078 
00079 #define MY_CHECK_ERROR  1       /* Params to my_end; Check open-close */
00080 #define MY_GIVE_INFO    2       /* Give time info about process*/
00081 
00082 #define ME_HIGHBYTE     8       /* Shift for colours */
00083 #define ME_NOCUR        1       /* Don't use curses message */
00084 #define ME_OLDWIN       2       /* Use old window */
00085 #define ME_BELL         4       /* Ring bell then printing message */
00086 #define ME_HOLDTANG     8       /* Don't delete last keys */
00087 #define ME_WAITTOT      16      /* Wait for errtime secs of for a action */
00088 #define ME_WAITTANG     32      /* Wait for a user action  */
00089 #define ME_NOREFRESH    64      /* Dont refresh screen */
00090 #define ME_NOINPUT      128     /* Dont use the input libary */
00091 #define ME_COLOUR1      ((1 << ME_HIGHBYTE))    /* Possibly error-colours */
00092 #define ME_COLOUR2      ((2 << ME_HIGHBYTE))
00093 #define ME_COLOUR3      ((3 << ME_HIGHBYTE))
00094 
00095         /* Bits in last argument to fn_format */
00096 #define MY_REPLACE_DIR          1       /* replace dir in name with 'dir' */
00097 #define MY_REPLACE_EXT          2       /* replace extension with 'ext' */
00098 #define MY_UNPACK_FILENAME      4       /* Unpack name (~ -> home) */
00099 #define MY_PACK_FILENAME        8       /* Pack name (home -> ~) */
00100 #define MY_RESOLVE_SYMLINKS     16      /* Resolve all symbolic links */
00101 #define MY_RETURN_REAL_PATH     32      /* return full path for file */
00102 #define MY_SAFE_PATH            64      /* Return NULL if too long path */
00103 #define MY_RELATIVE_PATH        128     /* name is relative to 'dir' */
00104 
00105         /* My seek flags */
00106 #define MY_SEEK_SET     0
00107 #define MY_SEEK_CUR     1
00108 #define MY_SEEK_END     2
00109 
00110         /* Some constants */
00111 #define MY_WAIT_FOR_USER_TO_FIX_PANIC   60      /* in seconds */
00112 #define MY_WAIT_GIVE_USER_A_MESSAGE     10      /* Every 10 times of prev */
00113 #define MIN_COMPRESS_LENGTH             50      /* Don't compress small bl. */
00114 #define DFLT_INIT_HITS  3
00115 
00116         /* root_alloc flags */
00117 #define MY_KEEP_PREALLOC        1
00118 #define MY_MARK_BLOCKS_FREE     2  /* move used to free list and reuse them */
00119 
00120         /* Internal error numbers (for assembler functions) */
00121 #define MY_ERRNO_EDOM           33
00122 #define MY_ERRNO_ERANGE         34
00123 
00124         /* defines when allocating data */
00125 #ifdef SAFEMALLOC
00126 #define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG )
00127 #define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG )
00128 #define my_realloc(PTR,SZ,FLAG) _myrealloc((PTR), (SZ), __FILE__, __LINE__, FLAG )
00129 #define my_checkmalloc() _sanity( __FILE__, __LINE__ )
00130 #define my_free(PTR,FLAG) _myfree((PTR), __FILE__, __LINE__,FLAG)
00131 #define my_memdup(A,B,C) _my_memdup((A),(B), __FILE__,__LINE__,C)
00132 #define my_strdup(A,C) _my_strdup((A), __FILE__,__LINE__,C)
00133 #define my_strdup_with_length(A,B,C) _my_strdup_with_length((A),(B),__FILE__,__LINE__,C)
00134 #define QUICK_SAFEMALLOC sf_malloc_quick=1
00135 #define NORMAL_SAFEMALLOC sf_malloc_quick=0
00136 extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
00137 extern ulonglong sf_malloc_mem_limit;
00138 
00139 #define CALLER_INFO_PROTO   , const char *sFile, uint uLine
00140 #define CALLER_INFO         , __FILE__, __LINE__
00141 #define ORIG_CALLER_INFO    , sFile, uLine
00142 #else
00143 #define my_checkmalloc()
00144 #undef TERMINATE
00145 #define TERMINATE(A) {}
00146 #define QUICK_SAFEMALLOC
00147 #define NORMAL_SAFEMALLOC
00148 extern gptr my_malloc(uint Size,myf MyFlags);
00149 #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
00150 extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
00151 extern void my_no_flags_free(gptr ptr);
00152 extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
00153 extern char *my_strdup(const char *from,myf MyFlags);
00154 extern char *my_strdup_with_length(const byte *from, uint length,
00155                                    myf MyFlags);
00156 #define my_free(PTR,FG) my_no_flags_free(PTR)
00157 #define CALLER_INFO_PROTO   /* nothing */
00158 #define CALLER_INFO         /* nothing */
00159 #define ORIG_CALLER_INFO    /* nothing */
00160 #endif
00161 
00162 #ifdef HAVE_ALLOCA
00163 #if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
00164 #pragma alloca
00165 #endif /* _AIX */
00166 #if defined(__MWERKS__)
00167 #undef alloca
00168 #define alloca __alloca
00169 #endif /* __MWERKS__ */
00170 #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && ! defined(alloca)
00171 #define alloca __builtin_alloca
00172 #endif /* GNUC */
00173 #define my_alloca(SZ) alloca((size_t) (SZ))
00174 #define my_afree(PTR) {}
00175 #else
00176 #define my_alloca(SZ) my_malloc(SZ,MYF(0))
00177 #define my_afree(PTR) my_free(PTR,MYF(MY_WME))
00178 #endif /* HAVE_ALLOCA */
00179 
00180 #ifdef MSDOS
00181 #ifdef __ZTC__
00182 void * __CDECL halloc(long count,size_t length);
00183 void   __CDECL hfree(void *ptr);
00184 #endif
00185 #if defined(USE_HALLOC)
00186 #if defined(_VCM_) || defined(M_IC80386)
00187 #undef USE_HALLOC
00188 #endif
00189 #endif
00190 #ifdef USE_HALLOC
00191 #define malloc(a) halloc((long) (a),1)
00192 #define free(a) hfree(a)
00193 #endif
00194 #endif /* MSDOS */
00195 
00196 #ifndef errno                           /* did we already get it? */
00197 #ifdef HAVE_ERRNO_AS_DEFINE
00198 #include <errno.h>                      /* errno is a define */
00199 #else
00200 extern int errno;                       /* declare errno */
00201 #endif
00202 #endif                                  /* #ifndef errno */
00203 extern const char ** NEAR my_errmsg[];
00204 extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
00205 extern char *home_dir;                  /* Home directory for user */
00206 extern char *my_progname;               /* program-name (printed in errors) */
00207 extern char NEAR curr_dir[];            /* Current directory for user */
00208 extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
00209 extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
00210                                        myf MyFlags);
00211 extern uint my_file_limit;
00212 
00213 /* charsets */
00214 extern CHARSET_INFO *default_charset_info;
00215 extern CHARSET_INFO *all_charsets[256];
00216 extern CHARSET_INFO compiled_charsets[];
00217 
00218 /* statistics */
00219 extern ulong    my_cache_w_requests, my_cache_write, my_cache_r_requests,
00220                 my_cache_read;
00221 extern ulong    my_blocks_used, my_blocks_changed;
00222 extern ulong    my_file_opened,my_stream_opened, my_tmp_file_created;
00223 extern uint     mysys_usage_id;
00224 extern my_bool  my_init_done;
00225 
00226                                         /* Point to current my_message() */
00227 extern void (*my_sigtstp_cleanup)(void),
00228                                         /* Executed before jump to shell */
00229             (*my_sigtstp_restart)(void),
00230             (*my_abort_hook)(int);
00231                                         /* Executed when comming from shell */
00232 extern int NEAR my_umask,               /* Default creation mask  */
00233            NEAR my_umask_dir,
00234            NEAR my_recived_signals,     /* Signals we have got */
00235            NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
00236            NEAR my_dont_interrupt;      /* call remember_intr when set */
00237 extern my_bool NEAR mysys_uses_curses, my_use_symdir;
00238 extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;
00239 
00240 extern ulong    my_default_record_cache_size;
00241 extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
00242                NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
00243 extern char     wild_many,wild_one,wild_prefix;
00244 extern const char *charsets_dir;
00245 extern char *defaults_extra_file;
00246 
00247 typedef struct wild_file_pack   /* Struct to hold info when selecting files */
00248 {
00249   uint          wilds;          /* How many wildcards */
00250   uint          not_pos;        /* Start of not-theese-files */
00251   my_string     *wild;          /* Pointer to wildcards */
00252 } WF_PACK;
00253 
00254 enum loglevel {
00255    ERROR_LEVEL,
00256    WARNING_LEVEL,
00257    INFORMATION_LEVEL
00258 };
00259 
00260 enum cache_type
00261 {
00262   READ_CACHE,WRITE_CACHE,
00263   SEQ_READ_APPEND               /* sequential read or append */,
00264   READ_FIFO, READ_NET,WRITE_NET};
00265 
00266 enum flush_type
00267 {
00268   FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE
00269 };
00270 
00271 typedef struct st_record_cache  /* Used when cacheing records */
00272 {
00273   File file;
00274   int   rc_seek,error,inited;
00275   uint  rc_length,read_length,reclength;
00276   my_off_t rc_record_pos,end_of_file;
00277   byte  *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
00278 #ifdef HAVE_AIOWAIT
00279   int   use_async_io;
00280   my_aio_result aio_result;
00281 #endif
00282   enum cache_type type;
00283 } RECORD_CACHE;
00284 
00285 enum file_type
00286 {
00287   UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
00288   FILE_BY_MKSTEMP, FILE_BY_DUP
00289 };
00290 
00291 struct st_my_file_info
00292 {
00293   my_string             name;
00294   enum file_type        type;
00295 #if defined(THREAD) && !defined(HAVE_PREAD)
00296   pthread_mutex_t       mutex;
00297 #endif
00298 };
00299 
00300 extern struct st_my_file_info *my_file_info;
00301 
00302 typedef struct st_my_tmpdir
00303 {
00304   char **list;
00305   uint cur, max;
00306 #ifdef THREAD
00307   pthread_mutex_t mutex;
00308 #endif
00309 } MY_TMPDIR;
00310 
00311 typedef struct st_dynamic_array
00312 {
00313   char *buffer;
00314   uint elements,max_element;
00315   uint alloc_increment;
00316   uint size_of_element;
00317 } DYNAMIC_ARRAY;
00318 
00319 typedef struct st_dynamic_string
00320 {
00321   char *str;
00322   uint length,max_length,alloc_increment;
00323 } DYNAMIC_STRING;
00324 
00325 struct st_io_cache;
00326 typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
00327 
00328 #ifdef THREAD
00329 typedef struct st_io_cache_share
00330 {
00331   /* to sync on reads into buffer */
00332   pthread_mutex_t mutex;
00333   pthread_cond_t  cond;
00334   int             count, total;
00335   /* actual IO_CACHE that filled the buffer */
00336   struct st_io_cache *active;
00337 #ifdef NOT_YET_IMPLEMENTED
00338   /* whether the structure should be free'd */
00339   my_bool alloced;
00340 #endif
00341 } IO_CACHE_SHARE;
00342 #endif
00343 
00344 typedef struct st_io_cache              /* Used when cacheing files */
00345 {
00346   /* Offset in file corresponding to the first byte of byte* buffer. */
00347   my_off_t pos_in_file;
00348   /*
00349     The offset of end of file for READ_CACHE and WRITE_CACHE.
00350     For SEQ_READ_APPEND it the maximum of the actual end of file and
00351     the position represented by read_end.
00352   */
00353   my_off_t end_of_file;
00354   /* Points to current read position in the buffer */
00355   byte  *read_pos;
00356   /* the non-inclusive boundary in the buffer for the currently valid read */
00357   byte  *read_end;
00358   byte  *buffer;                                /* The read buffer */
00359   /* Used in ASYNC_IO */
00360   byte  *request_pos;
00361 
00362   /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
00363   byte  *write_buffer;
00364   /*
00365     Only used in SEQ_READ_APPEND, and points to the current read position
00366     in the write buffer. Note that reads in SEQ_READ_APPEND caches can
00367     happen from both read buffer (byte* buffer) and write buffer
00368     (byte* write_buffer).
00369   */
00370   byte *append_read_pos;
00371   /* Points to current write position in the write buffer */
00372   byte *write_pos;
00373   /* The non-inclusive boundary of the valid write area */
00374   byte *write_end;
00375 
00376   /*
00377     Current_pos and current_end are convenience variables used by
00378     my_b_tell() and other routines that need to know the current offset
00379     current_pos points to &write_pos, and current_end to &write_end in a
00380     WRITE_CACHE, and &read_pos and &read_end respectively otherwise
00381   */
00382   byte  **current_pos, **current_end;
00383 #ifdef THREAD
00384   /*
00385     The lock is for append buffer used in SEQ_READ_APPEND cache
00386     need mutex copying from append buffer to read buffer.
00387   */
00388   pthread_mutex_t append_buffer_lock;
00389   /*
00390     The following is used when several threads are reading the
00391     same file in parallel. They are synchronized on disk
00392     accesses reading the cached part of the file asynchronously.
00393     It should be set to NULL to disable the feature.  Only
00394     READ_CACHE mode is supported.
00395   */
00396   IO_CACHE_SHARE *share;
00397 #endif
00398   /*
00399     A caller will use my_b_read() macro to read from the cache
00400     if the data is already in cache, it will be simply copied with
00401     memcpy() and internal variables will be accordinging updated with
00402     no functions invoked. However, if the data is not fully in the cache,
00403     my_b_read() will call read_function to fetch the data. read_function
00404     must never be invoked directly.
00405   */
00406   int (*read_function)(struct st_io_cache *,byte *,uint);
00407   /*
00408     Same idea as in the case of read_function, except my_b_write() needs to
00409     be replaced with my_b_append() for a SEQ_READ_APPEND cache
00410   */
00411   int (*write_function)(struct st_io_cache *,const byte *,uint);
00412   /*
00413     Specifies the type of the cache. Depending on the type of the cache
00414     certain operations might not be available and yield unpredicatable
00415     results. Details to be documented later
00416   */
00417   enum cache_type type;
00418   /*
00419     Callbacks when the actual read I/O happens. These were added and
00420     are currently used for binary logging of LOAD DATA INFILE - when a
00421     block is read from the file, we create a block create/append event, and
00422     when IO_CACHE is closed, we create an end event. These functions could,
00423     of course be used for other things
00424   */
00425   IO_CACHE_CALLBACK pre_read;
00426   IO_CACHE_CALLBACK post_read;
00427   IO_CACHE_CALLBACK pre_close;
00428   /*
00429     Counts the number of times, when we were forced to use disk. We use it to
00430     increase the binlog_cache_disk_use status variable.
00431   */
00432   ulong disk_writes;
00433   void* arg;                            /* for use by pre/post_read */
00434   char *file_name;                      /* if used with 'open_cached_file' */
00435   char *dir,*prefix;
00436   File file; /* file descriptor */
00437   /*
00438     seek_not_done is set by my_b_seek() to inform the upcoming read/write
00439     operation that a seek needs to be preformed prior to the actual I/O
00440     error is 0 if the cache operation was successful, -1 if there was a
00441     "hard" error, and the actual number of I/O-ed bytes if the read/write was
00442     partial.
00443   */
00444   int   seek_not_done,error;
00445   /* buffer_length is memory size allocated for buffer or write_buffer */
00446   uint  buffer_length;
00447   /* read_length is the same as buffer_length except when we use async io */
00448   uint  read_length;
00449   myf   myflags;                        /* Flags used to my_read/my_write */
00450   /*
00451     alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
00452     0 if it was supplied by the user.
00453     Currently READ_NET is the only one that will use a buffer allocated
00454     somewhere else
00455   */
00456   my_bool alloced_buffer;
00457 #ifdef HAVE_AIOWAIT
00458   /*
00459     As inidicated by ifdef, this is for async I/O, which is not currently
00460     used (because it's not reliable on all systems)
00461   */
00462   uint inited;
00463   my_off_t aio_read_pos;
00464   my_aio_result aio_result;
00465 #endif
00466 } IO_CACHE;
00467 
00468 typedef int (*qsort2_cmp)(const void *, const void *, const void *);
00469 
00470         /* defines for mf_iocache */
00471 
00472         /* Test if buffer is inited */
00473 #define my_b_clear(info) (info)->buffer=0
00474 #define my_b_inited(info) (info)->buffer
00475 #define my_b_EOF INT_MIN
00476 
00477 #define my_b_read(info,Buffer,Count) \
00478   ((info)->read_pos + (Count) <= (info)->read_end ?\
00479    (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
00480     ((info)->read_pos+=(Count)),0) :\
00481    (*(info)->read_function)((info),Buffer,Count))
00482 
00483 #define my_b_write(info,Buffer,Count) \
00484  ((info)->write_pos + (Count) <=(info)->write_end ?\
00485   (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
00486    ((info)->write_pos+=(Count)),0) : \
00487    (*(info)->write_function)((info),(Buffer),(Count)))
00488 
00489 #define my_b_get(info) \
00490   ((info)->read_pos != (info)->read_end ?\
00491    ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
00492    _my_b_get(info))
00493 
00494         /* my_b_write_byte dosn't have any err-check */
00495 #define my_b_write_byte(info,chr) \
00496   (((info)->write_pos < (info)->write_end) ?\
00497    ((*(info)->write_pos++)=(chr)) :\
00498    (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
00499 
00500 #define my_b_fill_cache(info) \
00501   (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
00502 
00503 #define my_b_tell(info) ((info)->pos_in_file + \
00504                          (uint) (*(info)->current_pos - (info)->request_pos))
00505 
00506 /* tell write offset in the SEQ_APPEND cache */
00507 my_off_t my_b_append_tell(IO_CACHE* info);
00508 
00509 #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
00510                                           *(info)->current_pos)
00511 
00512 typedef uint32 ha_checksum;
00513 
00514 #include <my_alloc.h>
00515 
00516         /* Prototypes for mysys and my_func functions */
00517 
00518 extern int my_copy(const char *from,const char *to,myf MyFlags);
00519 extern int my_append(const char *from,const char *to,myf MyFlags);
00520 extern int my_delete(const char *name,myf MyFlags);
00521 extern int my_getwd(my_string buf,uint size,myf MyFlags);
00522 extern int my_setwd(const char *dir,myf MyFlags);
00523 extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
00524 extern gptr my_once_alloc(uint Size,myf MyFlags);
00525 extern void my_once_free(void);
00526 extern char *my_once_strdup(const char *src,myf myflags);
00527 extern char *my_once_memdup(const char *src, uint len, myf myflags);
00528 extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
00529 extern File my_open(const char *FileName,int Flags,myf MyFlags);
00530 extern File my_register_filename(File fd, const char *FileName,
00531                                  enum file_type type_of_file,
00532                                  uint error_message_number, myf MyFlags);
00533 extern File my_create(const char *FileName,int CreateFlags,
00534                       int AccsesFlags, myf MyFlags);
00535 extern int my_close(File Filedes,myf MyFlags);
00536 extern File my_dup(File file, myf MyFlags);
00537 extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
00538 extern int my_readlink(char *to, const char *filename, myf MyFlags);
00539 extern int my_realpath(char *to, const char *filename, myf MyFlags);
00540 extern File my_create_with_symlink(const char *linkname, const char *filename,
00541                                    int createflags, int access_flags,
00542                                    myf MyFlags);
00543 extern int my_delete_with_symlink(const char *name, myf MyFlags);
00544 extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
00545 extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
00546 extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
00547 extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
00548                      myf MyFlags);
00549 extern int my_rename(const char *from,const char *to,myf MyFlags);
00550 extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
00551 extern my_off_t my_tell(File fd,myf MyFlags);
00552 extern uint my_write(File Filedes,const byte *Buffer,uint Count,
00553                      myf MyFlags);
00554 extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
00555                       my_off_t offset,myf MyFlags);
00556 extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
00557 extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
00558                       myf MyFlags);
00559 extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
00560 extern my_off_t my_ftell(FILE *stream,myf MyFlags);
00561 extern gptr _mymalloc(uint uSize,const char *sFile,
00562                       uint uLine, myf MyFlag);
00563 extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
00564                        uint uLine, myf MyFlag);
00565 extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
00566 extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
00567 extern int _sanity(const char *sFile,unsigned int uLine);
00568 extern gptr _my_memdup(const byte *from,uint length,
00569                        const char *sFile, uint uLine,myf MyFlag);
00570 extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
00571                             myf MyFlag);
00572 extern char *_my_strdup_with_length(const byte *from, uint length,
00573                                     const char *sFile, uint uLine,
00574                                     myf MyFlag);
00575 
00576 #ifdef __WIN__
00577 extern int my_access(const char *path, int amode);
00578 #else
00579 #define my_access access
00580 #endif
00581 extern int check_if_legal_filename(const char *path);
00582 
00583 #ifndef TERMINATE
00584 extern void TERMINATE(FILE *file);
00585 #endif
00586 extern void init_glob_errs(void);
00587 extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
00588 extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
00589 extern int my_fclose(FILE *fd,myf MyFlags);
00590 extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
00591 extern int my_sync(File fd, myf my_flags);
00592 extern int my_error _VARARGS((int nr,myf MyFlags, ...));
00593 extern int my_printf_error _VARARGS((uint my_err, const char *format,
00594                                      myf MyFlags, ...)
00595                                     __attribute__ ((format (printf, 2, 4))));
00596 extern int my_message(uint my_err, const char *str,myf MyFlags);
00597 extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
00598 extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
00599 extern my_bool my_init(void);
00600 extern void my_end(int infoflag);
00601 extern int my_redel(const char *from, const char *to, int MyFlags);
00602 extern int my_copystat(const char *from, const char *to, int MyFlags);
00603 extern my_string my_filename(File fd);
00604 
00605 #ifndef THREAD
00606 extern void dont_break(void);
00607 extern void allow_break(void);
00608 #else
00609 #define dont_break()
00610 #define allow_break()
00611 #endif
00612 
00613 extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
00614 extern char *my_tmpdir(MY_TMPDIR *tmpdir);
00615 extern void free_tmpdir(MY_TMPDIR *tmpdir);
00616 
00617 extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
00618 extern uint dirname_part(my_string to,const char *name);
00619 extern uint dirname_length(const char *name);
00620 #define base_name(A) (A+dirname_length(A))
00621 extern int test_if_hard_path(const char *dir_name);
00622 extern my_bool has_path(const char *name);
00623 extern char *convert_dirname(char *to, const char *from, const char *from_end);
00624 extern void to_unix_path(my_string name);
00625 extern my_string fn_ext(const char *name);
00626 extern my_string fn_same(my_string toname,const char *name,int flag);
00627 extern my_string fn_format(my_string to,const char *name,const char *dir,
00628                            const char *form, uint flag);
00629 extern size_s strlength(const char *str);
00630 extern void pack_dirname(my_string to,const char *from);
00631 extern uint unpack_dirname(my_string to,const char *from);
00632 extern uint cleanup_dirname(my_string to,const char *from);
00633 extern uint system_filename(my_string to,const char *from);
00634 extern uint unpack_filename(my_string to,const char *from);
00635 extern my_string intern_filename(my_string to,const char *from);
00636 extern my_string directory_file_name(my_string dst, const char *src);
00637 extern int pack_filename(my_string to, const char *name, size_s max_length);
00638 extern my_string my_path(my_string to,const char *progname,
00639                          const char *own_pathname_part);
00640 extern my_string my_load_path(my_string to, const char *path,
00641                               const char *own_path_prefix);
00642 extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
00643 extern WF_PACK *wf_comp(my_string str);
00644 extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
00645 extern void wf_end(struct wild_file_pack *buffer);
00646 extern size_s strip_sp(my_string str);
00647 extern void get_date(my_string to,int timeflag,time_t use_time);
00648 extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
00649 extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
00650                              uint reclength,enum cache_type type,
00651                              pbool use_async_io);
00652 extern int read_cache_record(RECORD_CACHE *info,byte *to);
00653 extern int end_record_cache(RECORD_CACHE *info);
00654 extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
00655                               const byte *record,uint length);
00656 extern int flush_write_cache(RECORD_CACHE *info);
00657 extern long my_clock(void);
00658 extern sig_handler sigtstp_handler(int signal_number);
00659 extern void handle_recived_signals(void);
00660 
00661 extern sig_handler my_set_alarm_variable(int signo);
00662 extern void my_string_ptr_sort(void *base,uint items,size_s size);
00663 extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
00664                                   size_s size_of_element,uchar *buffer[]);
00665 extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
00666                       qsort2_cmp cmp, void *cmp_argument);
00667 extern qsort2_cmp get_ptr_compare(uint);
00668 extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
00669                          enum cache_type type,my_off_t seek_offset,
00670                          pbool use_async_io, myf cache_myflags);
00671 extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
00672                                my_off_t seek_offset,pbool use_async_io,
00673                                pbool clear_cache);
00674 extern void setup_io_cache(IO_CACHE* info);
00675 extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
00676 #ifdef THREAD
00677 extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
00678 extern void init_io_cache_share(IO_CACHE *info,
00679                                 IO_CACHE_SHARE *s, uint num_threads);
00680 extern void remove_io_thread(IO_CACHE *info);
00681 #endif
00682 extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
00683 extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
00684 extern int _my_b_get(IO_CACHE *info);
00685 extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
00686 extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
00687 extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
00688 extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);
00689 
00690 extern int my_block_write(IO_CACHE *info, const byte *Buffer,
00691                           uint Count, my_off_t pos);
00692 extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
00693 
00694 #define flush_io_cache(info) my_b_flush_io_cache((info),1)
00695 
00696 extern int end_io_cache(IO_CACHE *info);
00697 extern uint my_b_fill(IO_CACHE *info);
00698 extern void my_b_seek(IO_CACHE *info,my_off_t pos);
00699 extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
00700 extern my_off_t my_b_filelength(IO_CACHE *info);
00701 extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
00702 extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
00703 extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
00704                                  const char *prefix, uint cache_size,
00705                                  myf cache_myflags);
00706 extern my_bool real_open_cached_file(IO_CACHE *cache);
00707 extern void close_cached_file(IO_CACHE *cache);
00708 File create_temp_file(char *to, const char *dir, const char *pfx,
00709                       int mode, myf MyFlags);
00710 #define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
00711 #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
00712 extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
00713           uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
00714 extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
00715 extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
00716 extern byte *pop_dynamic(DYNAMIC_ARRAY*);
00717 extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
00718 extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
00719 extern void delete_dynamic(DYNAMIC_ARRAY *array);
00720 extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
00721 extern void freeze_size(DYNAMIC_ARRAY *array);
00722 #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
00723 #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
00724 #define push_dynamic(A,B) insert_dynamic(A,B)
00725 #define reset_dynamic(array) ((array)->elements= 0)
00726 
00727 extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
00728                                    uint init_alloc,uint alloc_increment);
00729 extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
00730 my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
00731                           uint length);
00732 extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
00733 extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
00734 extern void dynstr_free(DYNAMIC_STRING *str);
00735 #ifdef HAVE_MLOCK
00736 extern byte *my_malloc_lock(uint length,myf flags);
00737 extern void my_free_lock(byte *ptr,myf flags);
00738 #else
00739 #define my_malloc_lock(A,B) my_malloc((A),(B))
00740 #define my_free_lock(A,B) my_free((A),(B))
00741 #endif
00742 #define alloc_root_inited(A) ((A)->min_malloc != 0)
00743 #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
00744 #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
00745 extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
00746                             uint pre_alloc_size);
00747 extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
00748 extern void free_root(MEM_ROOT *root, myf MyFLAGS);
00749 extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
00750 extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
00751                                 uint prealloc_size);
00752 extern char *strdup_root(MEM_ROOT *root,const char *str);
00753 extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
00754 extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
00755 extern void get_defaults_files(int argc, char **argv,
00756                                char **defaults, char **extra_defaults);
00757 extern int load_defaults(const char *conf_file, const char **groups,
00758                          int *argc, char ***argv);
00759 extern void free_defaults(char **argv);
00760 extern void print_defaults(const char *conf_file, const char **groups);
00761 extern my_bool my_compress(byte *, ulong *, ulong *);
00762 extern my_bool my_uncompress(byte *, ulong *, ulong *);
00763 extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
00764 extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
00765 extern uint my_bit_log2(ulong value);
00766 extern uint my_count_bits(ulonglong v);
00767 extern void my_sleep(ulong m_seconds);
00768 extern ulong crc32(ulong crc, const uchar *buf, uint len);
00769 extern uint my_set_max_open_files(uint files);
00770 void my_free_open_file_info(void);
00771 
00772 ulonglong my_getsystime(void);
00773 my_bool my_gethwaddr(uchar *to);
00774 
00775 /* character sets */
00776 extern uint get_charset_number(const char *cs_name, uint cs_flags);
00777 extern uint get_collation_number(const char *name);
00778 extern const char *get_charset_name(uint cs_number);
00779 
00780 extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
00781 extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
00782 extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
00783                                            uint cs_flags, myf my_flags);
00784 extern void free_charsets(void);
00785 extern char *get_charsets_dir(char *buf);
00786 extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
00787 extern my_bool init_compiled_charsets(myf flags);
00788 extern void add_compiled_collation(CHARSET_INFO *cs);
00789 extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
00790                                      const char *from, ulong length);
00791 
00792 #ifdef __WIN__
00793 extern my_bool have_tcpip;              /* Is set if tcpip is used */
00794 
00795 /* implemented in my_windac.c */
00796 
00797 int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
00798                             DWORD owner_rights, DWORD everybody_rights);
00799 
00800 void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
00801 
00802 #endif
00803 #ifdef __NETWARE__
00804 void netware_reg_user(const char *ip, const char *user,
00805                       const char *application);
00806 #endif
00807 
00808 C_MODE_END
00809 #include "raid.h"
00810 #endif /* _my_sys_h */

Generated on Sun May 14 14:51:19 2006 by  doxygen 1.4.2