📄 my_sys.h
字号:
/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */#ifndef _my_sys_h#define _my_sys_h#ifdef __cplusplusextern "C" {#endif#ifdef HAVE_AIOWAIT#include <sys/asynch.h> /* Used by record-cache */typedef struct my_aio_result { aio_result_t result; int pending;} my_aio_result;#endif#ifdef THREADextern int *_my_errno(void) __attribute__ ((const));#define my_errno (*_my_errno())#elseextern int NEAR my_errno; /* Last error in mysys */#endif#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}#define MY_INIT(name); { my_progname= name; my_init(); }#define MAXMAPS (4) /* Number of error message maps */#define ERRMOD (1000) /* Max number of errors in a map */#define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */#define NRERRBUFFS (2) /* Buffers for parameters */#define MY_FILE_ERROR ((uint) ~0) /* General bitmaps for my_func's */#define MY_FFNF 1 /* Fatal if file not found */#define MY_FNABP 2 /* Fatal if not all bytes read/writen */#define MY_NABP 4 /* Error if not all bytes read/writen */#define MY_FAE 8 /* Fatal if any error */#define MY_WME 16 /* Write message on error */#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */#define MY_COPYTIME 64 /* my_redel() copys time */#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */#define MY_GIVE_INFO 2 /* Give time info about process*/#define ME_HIGHBYTE 8 /* Shift for colours */#define ME_NOCUR 1 /* Don't use curses message */#define ME_OLDWIN 2 /* Use old window */#define ME_BELL 4 /* Ring bell then printing message */#define ME_HOLDTANG 8 /* Don't delete last keys */#define ME_WAITTOT 16 /* Wait for errtime secs of for a action */#define ME_WAITTANG 32 /* Wait for a user action */#define ME_NOREFRESH 64 /* Dont refresh screen */#define ME_NOINPUT 128 /* Dont use the input libary */#define ME_COLOUR1 ((1 << ME_HIGHBYTE)) /* Possibly error-colours */#define ME_COLOUR2 ((2 << ME_HIGHBYTE))#define ME_COLOUR3 ((3 << ME_HIGHBYTE)) /* My seek flags */#define MY_SEEK_SET 0#define MY_SEEK_CUR 1#define MY_SEEK_END 2 /* Some constants */#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */ /* defines when allocating data */#ifdef SAFEMALLOC#define my_malloc(SZ,FLAG) _mymalloc( SZ, __FILE__, __LINE__, FLAG )#define my_realloc(PTR,SZ,FLAG) _myrealloc( PTR, SZ, __FILE__, __LINE__, FLAG )#define my_checkmalloc() _sanity( __FILE__, __LINE__ )#define my_free(PTR,FLAG) _myfree( PTR, __FILE__, __LINE__,FLAG)#define my_memdup(A,B,C) _my_memdup(A,B,__FILE__,__LINE__,C)#define my_strdup(A,C) _my_strdup(A,__FILE__,__LINE__,C)#define QUICK_SAFEMALLOC sf_malloc_quick=1#define NORMAL_SAFEMALLOC sf_malloc_quick=0extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;#else#define my_checkmalloc() (0)#define TERMINATE(A) {}#define QUICK_SAFEMALLOC#define NORMAL_SAFEMALLOCextern gptr my_malloc(uint Size,myf MyFlags);extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);extern void my_no_flags_free(gptr ptr);extern gptr my_memdup(const byte *from,uint length,myf MyFlags);extern string my_strdup(const char *from,myf MyFlags);#define my_free(PTR,FG) my_no_flags_free(PTR)#endif#ifdef HAVE_ALLOCA#define my_alloca(SZ) alloca((size_t) (SZ))#define my_afree(PTR) {}#else#define my_alloca(SZ) my_malloc(SZ,MYF(0))#define my_afree(PTR) my_free(PTR,MYF(MY_WME))#endif /* HAVE_ALLOCA */#ifdef MSDOS#ifdef __ZTC__void * __CDECL halloc(long count,size_t length);void __CDECL hfree(void *ptr);#endif#if defined(USE_HALLOC)#if defined(_VCM_) || defined(M_IC80386)#undef USE_HALLOC#endif#endif#ifdef USE_HALLOC#define malloc(a) halloc((long) (a),1)#define free(a) hfree(a)#endif#endif /* MSDOS */#ifdef HAVE_ERRNO_AS_DEFINE#include <errno.h> /* errno is a define */#elseextern int errno; /* declare errno */#endifextern char ** NEAR errmsg[];extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];extern char *home_dir; /* Home directory for user */extern char *my_progname; /* program-name (printed in errors) */extern char NEAR curr_dir[]; /* Current directory for user */extern int (*error_handler_hook)(uint my_error, const char *str,myf MyFlags);extern int (*fatal_error_handler_hook)(uint my_error, const char *str, myf MyFlags); /* Point to current my_message() */extern void (*my_sigtstp_cleanup)(void), /* Executed before jump to shell */ (*my_sigtstp_restart)(void), (*my_abort_hook)(int); /* Executed when comming from shell */extern int NEAR my_umask, /* Default creation mask */ NEAR my_recived_signals, /* Signals we have got */ NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ NEAR my_dont_interrupt, /* call remember_intr when set */ NEAR mysys_uses_curses;extern long lCurMemory,lMaxMemory; /* from safemalloc */extern ulong my_default_record_cache_size;extern int NEAR my_disable_locking,NEAR my_disable_async_io;extern char wild_many,wild_one,wild_prefix;typedef struct wild_file_pack /* Struct to hold info when selecting files */{ uint wilds; /* How many wildcards */ uint not_pos; /* Start of not-theese-files */ string *wild; /* Pointer to wildcards */} WF_PACK;typedef struct st_typelib { /* Different types saved here */ uint count; /* How many types */ string name; /* Name of typelib */ string *type_names;} TYPELIB;enum cache_type {READ_CACHE,WRITE_CACHE};typedef struct st_record_cache /* Used when cacheing records */{ File file; int rc_seek,error,inited; uint rc_length,read_length,reclength; my_off_t rc_record_pos,end_of_file; byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;#ifdef HAVE_AIOWAIT int use_async_io; my_aio_result aio_result;#endif enum cache_type type;} RECORD_CACHE;enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN };extern struct my_file_info{ string name; enum file_type type;} my_file_info[MY_NFILE];typedef struct st_dynamic_array { char *buffer; uint elements,max_element; uint alloc_increment; uint size_of_element;} DYNAMIC_ARRAY;typedef struct st_dynamic_string { char *str; uint length,max_length,alloc_increment;} DYNAMIC_STRING;typedef struct st_io_cache /* Used when cacheing files */{ byte *rc_pos,*rc_end,*buffer,*rc_request_pos; File file; int seek_not_done,error; uint buffer_length,read_length; my_off_t pos_in_file,end_of_file; myf myflags; /* Flags used to my_read/my_write */#ifdef HAVE_AIOWAIT uint inited; my_off_t aio_read_pos; my_aio_result aio_result;#endif enum cache_type type; int (*read_function)(struct st_io_cache *,byte *,uint); char *file_name; /* if used with 'open_cacheed_file' */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -