Eneboo - Documentación para desarrolladores
src/libmysql_macosx/include/my_sys.h
Ir a la documentación de este archivo.
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_file_opened,my_stream_opened, my_tmp_file_created;
00220 extern uint     mysys_usage_id;
00221 extern my_bool  my_init_done;
00222 
00223                                         /* Point to current my_message() */
00224 extern void (*my_sigtstp_cleanup)(void),
00225                                         /* Executed before jump to shell */
00226             (*my_sigtstp_restart)(void),
00227             (*my_abort_hook)(int);
00228                                         /* Executed when comming from shell */
00229 extern int NEAR my_umask,               /* Default creation mask  */
00230            NEAR my_umask_dir,
00231            NEAR my_recived_signals,     /* Signals we have got */
00232            NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
00233            NEAR my_dont_interrupt;      /* call remember_intr when set */
00234 extern my_bool NEAR mysys_uses_curses, my_use_symdir;
00235 extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;
00236 
00237 extern ulong    my_default_record_cache_size;
00238 extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
00239                NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
00240 extern char     wild_many,wild_one,wild_prefix;
00241 extern const char *charsets_dir;
00242 extern char *defaults_extra_file;
00243 
00244 typedef struct wild_file_pack   /* Struct to hold info when selecting files */
00245 {
00246   uint          wilds;          /* How many wildcards */
00247   uint          not_pos;        /* Start of not-theese-files */
00248   my_string     *wild;          /* Pointer to wildcards */
00249 } WF_PACK;
00250 
00251 enum loglevel {
00252    ERROR_LEVEL,
00253    WARNING_LEVEL,
00254    INFORMATION_LEVEL
00255 };
00256 
00257 enum cache_type
00258 {
00259   READ_CACHE,WRITE_CACHE,
00260   SEQ_READ_APPEND               /* sequential read or append */,
00261   READ_FIFO, READ_NET,WRITE_NET};
00262 
00263 enum flush_type
00264 {
00265   FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED, FLUSH_FORCE_WRITE
00266 };
00267 
00268 typedef struct st_record_cache  /* Used when cacheing records */
00269 {
00270   File file;
00271   int   rc_seek,error,inited;
00272   uint  rc_length,read_length,reclength;
00273   my_off_t rc_record_pos,end_of_file;
00274   byte  *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
00275 #ifdef HAVE_AIOWAIT
00276   int   use_async_io;
00277   my_aio_result aio_result;
00278 #endif
00279   enum cache_type type;
00280 } RECORD_CACHE;
00281 
00282 enum file_type
00283 {
00284   UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
00285   FILE_BY_MKSTEMP, FILE_BY_DUP
00286 };
00287 
00288 struct st_my_file_info
00289 {
00290   my_string             name;
00291   enum file_type        type;
00292 #if defined(THREAD) && !defined(HAVE_PREAD)
00293   pthread_mutex_t       mutex;
00294 #endif
00295 };
00296 
00297 extern struct st_my_file_info *my_file_info;
00298 
00299 typedef struct st_my_tmpdir
00300 {
00301   char **list;
00302   uint cur, max;
00303 #ifdef THREAD
00304   pthread_mutex_t mutex;
00305 #endif
00306 } MY_TMPDIR;
00307 
00308 typedef struct st_dynamic_array
00309 {
00310   char *buffer;
00311   uint elements,max_element;
00312   uint alloc_increment;
00313   uint size_of_element;
00314 } DYNAMIC_ARRAY;
00315 
00316 typedef struct st_dynamic_string
00317 {
00318   char *str;
00319   uint length,max_length,alloc_increment;
00320 } DYNAMIC_STRING;
00321 
00322 struct st_io_cache;
00323 typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
00324 
00325 #ifdef THREAD
00326 typedef struct st_io_cache_share
00327 {
00328   /* to sync on reads into buffer */
00329   pthread_mutex_t mutex;
00330   pthread_cond_t  cond;
00331   int             count, total;
00332   /* actual IO_CACHE that filled the buffer */
00333   struct st_io_cache *active;
00334 #ifdef NOT_YET_IMPLEMENTED
00335   /* whether the structure should be free'd */
00336   my_bool alloced;
00337 #endif
00338 } IO_CACHE_SHARE;
00339 #endif
00340 
00341 typedef struct st_io_cache              /* Used when cacheing files */
00342 {
00343   /* Offset in file corresponding to the first byte of byte* buffer. */
00344   my_off_t pos_in_file;
00345   /*
00346     The offset of end of file for READ_CACHE and WRITE_CACHE.
00347     For SEQ_READ_APPEND it the maximum of the actual end of file and
00348     the position represented by read_end.
00349   */
00350   my_off_t end_of_file;
00351   /* Points to current read position in the buffer */
00352   byte  *read_pos;
00353   /* the non-inclusive boundary in the buffer for the currently valid read */
00354   byte  *read_end;
00355   byte  *buffer;                                /* The read buffer */
00356   /* Used in ASYNC_IO */
00357   byte  *request_pos;
00358 
00359   /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
00360   byte  *write_buffer;
00361   /*
00362     Only used in SEQ_READ_APPEND, and points to the current read position
00363     in the write buffer. Note that reads in SEQ_READ_APPEND caches can
00364     happen from both read buffer (byte* buffer) and write buffer
00365     (byte* write_buffer).
00366   */
00367   byte *append_read_pos;
00368   /* Points to current write position in the write buffer */
00369   byte *write_pos;
00370   /* The non-inclusive boundary of the valid write area */
00371   byte *write_end;
00372 
00373   /*
00374     Current_pos and current_end are convenience variables used by
00375     my_b_tell() and other routines that need to know the current offset
00376     current_pos points to &write_pos, and current_end to &write_end in a
00377     WRITE_CACHE, and &read_pos and &read_end respectively otherwise
00378   */
00379   byte  **current_pos, **current_end;
00380 #ifdef THREAD
00381   /*
00382     The lock is for append buffer used in SEQ_READ_APPEND cache
00383     need mutex copying from append buffer to read buffer.
00384   */
00385   pthread_mutex_t append_buffer_lock;
00386   /*
00387     The following is used when several threads are reading the
00388     same file in parallel. They are synchronized on disk
00389     accesses reading the cached part of the file asynchronously.
00390     It should be set to NULL to disable the feature.  Only
00391     READ_CACHE mode is supported.
00392   */
00393   IO_CACHE_SHARE *share;
00394 #endif
00395   /*
00396     A caller will use my_b_read() macro to read from the cache
00397     if the data is already in cache, it will be simply copied with
00398     memcpy() and internal variables will be accordinging updated with
00399     no functions invoked. However, if the data is not fully in the cache,
00400     my_b_read() will call read_function to fetch the data. read_function
00401     must never be invoked directly.
00402   */
00403   int (*read_function)(struct st_io_cache *,byte *,uint);
00404   /*
00405     Same idea as in the case of read_function, except my_b_write() needs to
00406     be replaced with my_b_append() for a SEQ_READ_APPEND cache
00407   */
00408   int (*write_function)(struct st_io_cache *,const byte *,uint);
00409   /*
00410     Specifies the type of the cache. Depending on the type of the cache
00411     certain operations might not be available and yield unpredicatable
00412     results. Details to be documented later
00413   */
00414   enum cache_type type;
00415   /*
00416     Callbacks when the actual read I/O happens. These were added and
00417     are currently used for binary logging of LOAD DATA INFILE - when a
00418     block is read from the file, we create a block create/append event, and
00419     when IO_CACHE is closed, we create an end event. These functions could,
00420     of course be used for other things
00421   */
00422   IO_CACHE_CALLBACK pre_read;
00423   IO_CACHE_CALLBACK post_read;
00424   IO_CACHE_CALLBACK pre_close;
00425   /*
00426     Counts the number of times, when we were forced to use disk. We use it to
00427     increase the binlog_cache_disk_use status variable.
00428   */
00429   ulong disk_writes;
00430   void* arg;                            /* for use by pre/post_read */
00431   char *file_name;                      /* if used with 'open_cached_file' */
00432   char *dir,*prefix;
00433   File file; /* file descriptor */
00434   /*
00435     seek_not_done is set by my_b_seek() to inform the upcoming read/write
00436     operation that a seek needs to be preformed prior to the actual I/O
00437     error is 0 if the cache operation was successful, -1 if there was a
00438     "hard" error, and the actual number of I/O-ed bytes if the read/write was
00439     partial.
00440   */
00441   int   seek_not_done,error;
00442   /* buffer_length is memory size allocated for buffer or write_buffer */
00443   uint  buffer_length;
00444   /* read_length is the same as buffer_length except when we use async io */
00445   uint  read_length;
00446   myf   myflags;                        /* Flags used to my_read/my_write */
00447   /*
00448     alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
00449     0 if it was supplied by the user.
00450     Currently READ_NET is the only one that will use a buffer allocated
00451     somewhere else
00452   */
00453   my_bool alloced_buffer;
00454 #ifdef HAVE_AIOWAIT
00455   /*
00456     As inidicated by ifdef, this is for async I/O, which is not currently
00457     used (because it's not reliable on all systems)
00458   */
00459   uint inited;
00460   my_off_t aio_read_pos;
00461   my_aio_result aio_result;
00462 #endif
00463 } IO_CACHE;
00464 
00465 typedef int (*qsort2_cmp)(const void *, const void *, const void *);
00466 
00467         /* defines for mf_iocache */
00468 
00469         /* Test if buffer is inited */
00470 #define my_b_clear(info) (info)->buffer=0
00471 #define my_b_inited(info) (info)->buffer
00472 #define my_b_EOF INT_MIN
00473 
00474 #define my_b_read(info,Buffer,Count) \
00475   ((info)->read_pos + (Count) <= (info)->read_end ?\
00476    (memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
00477     ((info)->read_pos+=(Count)),0) :\
00478    (*(info)->read_function)((info),Buffer,Count))
00479 
00480 #define my_b_write(info,Buffer,Count) \
00481  ((info)->write_pos + (Count) <=(info)->write_end ?\
00482   (memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
00483    ((info)->write_pos+=(Count)),0) : \
00484    (*(info)->write_function)((info),(Buffer),(Count)))
00485 
00486 #define my_b_get(info) \
00487   ((info)->read_pos != (info)->read_end ?\
00488    ((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
00489    _my_b_get(info))
00490 
00491         /* my_b_write_byte dosn't have any err-check */
00492 #define my_b_write_byte(info,chr) \
00493   (((info)->write_pos < (info)->write_end) ?\
00494    ((*(info)->write_pos++)=(chr)) :\
00495    (_my_b_write(info,0,0) , ((*(info)->write_pos++)=(chr))))
00496 
00497 #define my_b_fill_cache(info) \
00498   (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0))
00499 
00500 #define my_b_tell(info) ((info)->pos_in_file + \
00501                          (uint) (*(info)->current_pos - (info)->request_pos))
00502 
00503 /* tell write offset in the SEQ_APPEND cache */
00504 my_off_t my_b_append_tell(IO_CACHE* info);
00505 
00506 #define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \
00507                                           *(info)->current_pos)
00508 
00509 typedef uint32 ha_checksum;
00510 
00511 #include <my_alloc.h>
00512 
00513         /* Prototypes for mysys and my_func functions */
00514 
00515 extern int my_copy(const char *from,const char *to,myf MyFlags);
00516 extern int my_append(const char *from,const char *to,myf MyFlags);
00517 extern int my_delete(const char *name,myf MyFlags);
00518 extern int my_getwd(my_string buf,uint size,myf MyFlags);
00519 extern int my_setwd(const char *dir,myf MyFlags);
00520 extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
00521 extern gptr my_once_alloc(uint Size,myf MyFlags);
00522 extern void my_once_free(void);
00523 extern char *my_once_strdup(const char *src,myf myflags);
00524 extern char *my_once_memdup(const char *src, uint len, myf myflags);
00525 extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
00526 extern File my_open(const char *FileName,int Flags,myf MyFlags);
00527 extern File my_register_filename(File fd, const char *FileName,
00528                                  enum file_type type_of_file,
00529                                  uint error_message_number, myf MyFlags);
00530 extern File my_create(const char *FileName,int CreateFlags,
00531                       int AccsesFlags, myf MyFlags);
00532 extern int my_close(File Filedes,myf MyFlags);
00533 extern File my_dup(File file, myf MyFlags);
00534 extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
00535 extern int my_readlink(char *to, const char *filename, myf MyFlags);
00536 extern int my_realpath(char *to, const char *filename, myf MyFlags);
00537 extern File my_create_with_symlink(const char *linkname, const char *filename,
00538                                    int createflags, int access_flags,
00539                                    myf MyFlags);
00540 extern int my_delete_with_symlink(const char *name, myf MyFlags);
00541 extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
00542 extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
00543 extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
00544 extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
00545                      myf MyFlags);
00546 extern int my_rename(const char *from,const char *to,myf MyFlags);
00547 extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
00548 extern my_off_t my_tell(File fd,myf MyFlags);
00549 extern uint my_write(File Filedes,const byte *Buffer,uint Count,
00550                      myf MyFlags);
00551 extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
00552                       my_off_t offset,myf MyFlags);
00553 extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
00554 extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
00555                       myf MyFlags);
00556 extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
00557 extern my_off_t my_ftell(FILE *stream,myf MyFlags);
00558 extern gptr _mymalloc(uint uSize,const char *sFile,
00559                       uint uLine, myf MyFlag);
00560 extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
00561                        uint uLine, myf MyFlag);
00562 extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
00563 extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
00564 extern int _sanity(const char *sFile,unsigned int uLine);
00565 extern gptr _my_memdup(const byte *from,uint length,
00566                        const char *sFile, uint uLine,myf MyFlag);
00567 extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
00568                             myf MyFlag);
00569 extern char *_my_strdup_with_length(const byte *from, uint length,
00570                                     const char *sFile, uint uLine,
00571                                     myf MyFlag);
00572 
00573 #ifdef __WIN__
00574 extern int my_access(const char *path, int amode);
00575 #else
00576 #define my_access access
00577 #endif
00578 extern int check_if_legal_filename(const char *path);
00579 
00580 #ifndef TERMINATE
00581 extern void TERMINATE(FILE *file);
00582 #endif
00583 extern void init_glob_errs(void);
00584 extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
00585 extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
00586 extern int my_fclose(FILE *fd,myf MyFlags);
00587 extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
00588 extern int my_sync(File fd, myf my_flags);
00589 extern int my_error _VARARGS((int nr,myf MyFlags, ...));
00590 extern int my_printf_error _VARARGS((uint my_err, const char *format,
00591                                      myf MyFlags, ...)
00592                                     __attribute__ ((format (printf, 2, 4))));
00593 extern int my_message(uint my_err, const char *str,myf MyFlags);
00594 extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
00595 extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
00596 extern my_bool my_init(void);
00597 extern void my_end(int infoflag);
00598 extern int my_redel(const char *from, const char *to, int MyFlags);
00599 extern int my_copystat(const char *from, const char *to, int MyFlags);
00600 extern my_string my_filename(File fd);
00601 
00602 #ifndef THREAD
00603 extern void dont_break(void);
00604 extern void allow_break(void);
00605 #else
00606 #define dont_break()
00607 #define allow_break()
00608 #endif
00609 
00610 extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
00611 extern char *my_tmpdir(MY_TMPDIR *tmpdir);
00612 extern void free_tmpdir(MY_TMPDIR *tmpdir);
00613 
00614 extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
00615 extern uint dirname_part(my_string to,const char *name);
00616 extern uint dirname_length(const char *name);
00617 #define base_name(A) (A+dirname_length(A))
00618 extern int test_if_hard_path(const char *dir_name);
00619 extern my_bool has_path(const char *name);
00620 extern char *convert_dirname(char *to, const char *from, const char *from_end);
00621 extern void to_unix_path(my_string name);
00622 extern my_string fn_ext(const char *name);
00623 extern my_string fn_same(my_string toname,const char *name,int flag);
00624 extern my_string fn_format(my_string to,const char *name,const char *dir,
00625                            const char *form, uint flag);
00626 extern size_s strlength(const char *str);
00627 extern void pack_dirname(my_string to,const char *from);
00628 extern uint unpack_dirname(my_string to,const char *from);
00629 extern uint cleanup_dirname(my_string to,const char *from);
00630 extern uint system_filename(my_string to,const char *from);
00631 extern uint unpack_filename(my_string to,const char *from);
00632 extern my_string intern_filename(my_string to,const char *from);
00633 extern my_string directory_file_name(my_string dst, const char *src);
00634 extern int pack_filename(my_string to, const char *name, size_s max_length);
00635 extern my_string my_path(my_string to,const char *progname,
00636                          const char *own_pathname_part);
00637 extern my_string my_load_path(my_string to, const char *path,
00638                               const char *own_path_prefix);
00639 extern int wild_compare(const char *str,const char *wildstr,pbool str_is_pattern);
00640 extern WF_PACK *wf_comp(my_string str);
00641 extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
00642 extern void wf_end(struct wild_file_pack *buffer);
00643 extern size_s strip_sp(my_string str);
00644 extern void get_date(my_string to,int timeflag,time_t use_time);
00645 extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
00646 extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
00647                              uint reclength,enum cache_type type,
00648                              pbool use_async_io);
00649 extern int read_cache_record(RECORD_CACHE *info,byte *to);
00650 extern int end_record_cache(RECORD_CACHE *info);
00651 extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
00652                               const byte *record,uint length);
00653 extern int flush_write_cache(RECORD_CACHE *info);
00654 extern long my_clock(void);
00655 extern sig_handler sigtstp_handler(int signal_number);
00656 extern void handle_recived_signals(void);
00657 
00658 extern sig_handler my_set_alarm_variable(int signo);
00659 extern void my_string_ptr_sort(void *base,uint items,size_s size);
00660 extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
00661                                   size_s size_of_element,uchar *buffer[]);
00662 extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
00663                       qsort2_cmp cmp, void *cmp_argument);
00664 extern qsort2_cmp get_ptr_compare(uint);
00665 extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
00666                          enum cache_type type,my_off_t seek_offset,
00667                          pbool use_async_io, myf cache_myflags);
00668 extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
00669                                my_off_t seek_offset,pbool use_async_io,
00670                                pbool clear_cache);
00671 extern void setup_io_cache(IO_CACHE* info);
00672 extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
00673 #ifdef THREAD
00674 extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count);
00675 extern void init_io_cache_share(IO_CACHE *info,
00676                                 IO_CACHE_SHARE *s, uint num_threads);
00677 extern void remove_io_thread(IO_CACHE *info);
00678 #endif
00679 extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count);
00680 extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
00681 extern int _my_b_get(IO_CACHE *info);
00682 extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
00683 extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
00684 extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count);
00685 extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count);
00686 
00687 extern int my_block_write(IO_CACHE *info, const byte *Buffer,
00688                           uint Count, my_off_t pos);
00689 extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
00690 
00691 #define flush_io_cache(info) my_b_flush_io_cache((info),1)
00692 
00693 extern int end_io_cache(IO_CACHE *info);
00694 extern uint my_b_fill(IO_CACHE *info);
00695 extern void my_b_seek(IO_CACHE *info,my_off_t pos);
00696 extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
00697 extern my_off_t my_b_filelength(IO_CACHE *info);
00698 extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
00699 extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
00700 extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
00701                                  const char *prefix, uint cache_size,
00702                                  myf cache_myflags);
00703 extern my_bool real_open_cached_file(IO_CACHE *cache);
00704 extern void close_cached_file(IO_CACHE *cache);
00705 File create_temp_file(char *to, const char *dir, const char *pfx,
00706                       int mode, myf MyFlags);
00707 #define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
00708 #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
00709 extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
00710           uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
00711 extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
00712 extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
00713 extern byte *pop_dynamic(DYNAMIC_ARRAY*);
00714 extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
00715 extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
00716 extern void delete_dynamic(DYNAMIC_ARRAY *array);
00717 extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
00718 extern void freeze_size(DYNAMIC_ARRAY *array);
00719 #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
00720 #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
00721 #define push_dynamic(A,B) insert_dynamic(A,B)
00722 #define reset_dynamic(array) ((array)->elements= 0)
00723 
00724 extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
00725                                    uint init_alloc,uint alloc_increment);
00726 extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
00727 my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
00728                           uint length);
00729 extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
00730 extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
00731 extern void dynstr_free(DYNAMIC_STRING *str);
00732 #ifdef HAVE_MLOCK
00733 extern byte *my_malloc_lock(uint length,myf flags);
00734 extern void my_free_lock(byte *ptr,myf flags);
00735 #else
00736 #define my_malloc_lock(A,B) my_malloc((A),(B))
00737 #define my_free_lock(A,B) my_free((A),(B))
00738 #endif
00739 #define alloc_root_inited(A) ((A)->min_malloc != 0)
00740 #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
00741 #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
00742 extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
00743                             uint pre_alloc_size);
00744 extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
00745 extern void free_root(MEM_ROOT *root, myf MyFLAGS);
00746 extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
00747 extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
00748                                 uint prealloc_size);
00749 extern char *strdup_root(MEM_ROOT *root,const char *str);
00750 extern char *strmake_root(MEM_ROOT *root,const char *str,uint len);
00751 extern char *memdup_root(MEM_ROOT *root,const char *str,uint len);
00752 extern void get_defaults_files(int argc, char **argv,
00753                                char **defaults, char **extra_defaults);
00754 extern int load_defaults(const char *conf_file, const char **groups,
00755                          int *argc, char ***argv);
00756 extern void free_defaults(char **argv);
00757 extern void print_defaults(const char *conf_file, const char **groups);
00758 extern my_bool my_compress(byte *, ulong *, ulong *);
00759 extern my_bool my_uncompress(byte *, ulong *, ulong *);
00760 extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
00761 extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
00762 extern uint my_bit_log2(ulong value);
00763 extern uint my_count_bits(ulonglong v);
00764 extern void my_sleep(ulong m_seconds);
00765 extern ulong crc32(ulong crc, const uchar *buf, uint len);
00766 extern uint my_set_max_open_files(uint files);
00767 void my_free_open_file_info(void);
00768 
00769 ulonglong my_getsystime(void);
00770 my_bool my_gethwaddr(uchar *to);
00771 
00772 /* character sets */
00773 extern uint get_charset_number(const char *cs_name, uint cs_flags);
00774 extern uint get_collation_number(const char *name);
00775 extern const char *get_charset_name(uint cs_number);
00776 
00777 extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
00778 extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
00779 extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
00780                                            uint cs_flags, myf my_flags);
00781 extern void free_charsets(void);
00782 extern char *get_charsets_dir(char *buf);
00783 extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
00784 extern my_bool init_compiled_charsets(myf flags);
00785 extern void add_compiled_collation(CHARSET_INFO *cs);
00786 extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, char *to,
00787                                      const char *from, ulong length);
00788 #ifdef __WIN__
00789 #define BACKSLASH_MBTAIL
00790 /* File system character set */
00791 extern CHARSET_INFO *fs_character_set(void);
00792 #endif
00793 
00794 #ifdef __WIN__
00795 extern my_bool have_tcpip;              /* Is set if tcpip is used */
00796 
00797 /* implemented in my_windac.c */
00798 
00799 int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
00800                             DWORD owner_rights, DWORD everybody_rights);
00801 
00802 void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
00803 
00804 /* implemented in my_conio.c */
00805 char* my_cgets(char *string, unsigned long clen, unsigned long* plen);
00806 
00807 #endif
00808 #ifdef __NETWARE__
00809 void netware_reg_user(const char *ip, const char *user,
00810                       const char *application);
00811 #endif
00812 
00813 C_MODE_END
00814 #include "raid.h"
00815 #endif /* _my_sys_h */
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'