dbtype.h

来自「db.* (pronounced dee-be star) is an adva」· C头文件 代码 · 共 672 行 · 第 1/2 页

H
672
字号
    short st_memtot;     /* total number of members of set */    short st_flags;      /* 0x0001 is set if record is timestamped */} SET_ENTRY;typedef struct MEMBER_ENTRY_S{    short mt_record;           /* record table entry for this member */    short mt_mem_ptr;          /* offset to member ptrs in record */    short mt_sort_fld;         /* sort table entry of first sort field */    short mt_totsf;            /* total number of sort fields */} MEMBER_ENTRY;typedef struct SORT_ENTRY_S{    short se_fld;              /* field table entry of sort field */    short se_set;              /* set table entry of sorted set */}  SORT_ENTRY;/* kinds of keys */#define NOKEY      'n'#define DUPLICATES 'd'#define UNIQUE     'u'/* kinds of fields */#define FLOAT      'f'#define DOUBLE     'F'#define CHARACTER  'c'#define WIDECHAR   'C'#define SHORTINT   's'#define REGINT     'i'#define LONGINT    'l'#define DBADDR     'd'#define GROUPED    'g'#define COMKEY     'k'typedef struct FIELD_ENTRY_S{    char  fd_key;           /* see the #defines just above */    unsigned char fd_type;  /* see the #defines just above */    short fd_len;           /* length of field in bytes */    short fd_dim[MAXDIMS];  /* size of each array dimension */    short fd_keyfile;       /* task->file_table entry for key file */    short fd_keyno;         /* key prefix number */    short fd_ptr;           /* offset to field in record or 1st compound key field in task->key_table */    short fd_rec;           /* record table entry of record containing field */    short fd_flags;         /* see the #defines at the top of the file */} FIELD_ENTRY;/* compound key table entry declaration */typedef struct KEY_ENTRY_S{    short kt_key;              /* compound key field number */    short kt_field;            /* field number of included field */    short kt_ptr;              /* offset to start of field data in key */    short kt_sort;             /* 'a' = ascending, 'd' = descending */} KEY_ENTRY;/* database table entry declaration */typedef struct DB_ENTRY_S{    /* NOTE: db_name, db_path and ft_offset defined in TASK if ONE_DB */    short Size_ft;             /* size of this db's task->file_table */    short ft_offset;           /* offset to this db's task->file_table entries */    short Size_rt;             /* size of this db's task->record_table */    short rt_offset;           /* offset to this db's task->record_table entries */    short Size_fd;             /* size of this db's task->field_table */    short fd_offset;           /* offset to this db's task->field_table entries */    short Size_st;             /* size of this db's task->set_table */    short st_offset;           /* offset to this db's task->set_table entries */    short Size_mt;             /* size of this db's task->member_table */    short mt_offset;           /* offset to this db's task->member_table entries */    short Size_srt;            /* size of this db's task->sort_table */    short srt_offset;          /* offset to this db's task->sort_table entries */    short Size_kt;             /* size of this db's task->key_table */    short kt_offset;           /* offset to this db's key table entries */    short key_offset;          /* key prefix offset for this db */    DB_ADDR  sysdba;           /* database address of system record */    DB_ADDR  curr_dbt_rec;     /* this db's current record */    DB_ULONG curr_dbt_ts;      /* this db's current record timestamp */    short Page_size;           /* size of this db's page */    DB_TCHAR *Objnames;        /* buffer for rec, fld & set names */    DB_TCHAR db_path[DB_PATHLEN]; /* name of path to this database */    DB_TCHAR db_name[DBNMLEN];    /* name of this database */    short db_ver;              /* version of dbd file */} DB_ENTRY;/* Structure containing current record type & address for    recfrst/set/next.. NOTE: rn_type and rd_dba defined in TASK when ONE_DB.*/typedef struct RN_ENTRY_S{    short rn_type;    /* Last record type supplied to recfrst/recset */    DB_ADDR  rn_dba;     /* Last db addr computed by recfrst/recset/recnext */} RN_ENTRY;#define  DB_REF(item)            (task->curr_db_table->item)#define  RN_REF(item)            (task->curr_rn_table->item)#define  NUM2INT(num, offset)    ((num) + task->curr_db_table->offset)#define  NUM2EXT(num, offset)    ((num) - task->curr_db_table->offset)#define  ORIGIN(offset)          (task->curr_db_table->offset)#ifndef INTERNAL_H#define  TABLE_SIZE(size)        DB_REF(size)#endif /* INTERNAL_H *//* Country code table definition */typedef struct CNTRY_TBL_S{    unsigned char out_chr;    unsigned char sort_as1;    unsigned char sort_as2;    unsigned char sub_sort;} CNTRY_TBL;#ifndef INTERNAL_H#define DB_CLOSE  close#define DB_READ   read#define DB_WRITE  write#define DB_LSEEK lseek#define DB_TELL(fd)   DB_LSEEK(fd, 0, SEEK_CUR)/* File stream functions used in dbedit */#define DB_FTELL ftell#define DB_FSEEK fseek#endif /* INTERNAL_H */struct sk{    char *sk_val;    short sk_fld;};/* node key search path stack entry: one per level per key field */typedef struct NODE_PATH_S{    F_ADDR node;          /* node (page) number  */    short slot;           /* slot number of key */} NODE_PATH;/* index key information: one entry per key field */typedef struct KEY_INFO_S{    short level;          /* current level # in node path */    short max_lvls;       /* maximum possible levels for key */    short lstat;          /* last key function status */    short fldno;          /* field number of key */    FILE_NO keyfile;      /* key file containing this key */    DB_ADDR dba;          /* db address of last key */    char *keyval;         /* ptr to last key value */    NODE_PATH *node_path; /* stack of node #s in search path */} KEY_INFO;/* index file node structure */typedef struct{    time_t   last_chgd;   /* date/time of last change of this node */    short used_slots;     /* current # of used slots in node */    char     slots[1];    /* start of slot area */}  NODE;/* key slot structure */typedef struct key_slot{    F_ADDR child;         /* child node pointer */    short keyno;          /* key number */    char data[1];         /* start of key data */} KEY_SLOT;typedef union key_type{    char kd[MAXKEYSIZE];  /* This makes KEY_TYPE the correct size */    struct key_slot   ks;} KEY_TYPE;/* file rename table entry declarations */typedef struct ren_entry{    DB_TCHAR *file_name;    DB_TCHAR *ren_db_name;    FILE_NO   file_no;} REN_ENTRY;#ifndef INTERNAL_Htypedef struct{    DB_TCHAR *strbuf;    size_t    buflen;    size_t    strlen;} DB_STRING;DB_TCHAR *STRinit(DB_STRING *, DB_TCHAR *, size_t);DB_TCHAR *STRcpy(DB_STRING *, DB_TCHAR *);DB_TCHAR *STRcat(DB_STRING *, DB_TCHAR *);DB_TCHAR *STRccat(DB_STRING *, int);size_t    STRavail(DB_STRING *);#ifdef DB_TRACE#define API_ENTER(fn)   {if (task->db_trace & TRACE_API) api_enter(fn, task);}#define API_RETURN(c)   return((task->db_trace & TRACE_API) ? api_exit(task) : 0, (c))#define API_EXIT()      {if (task->db_trace & TRACE_API) api_exit(task);}#define FN_ENTER(fn)    {if (task->db_trace & TRACE_API) fn_enter(fn , task);}#define FN_RETURN(c)    return((task->db_trace & TRACE_API) ? fn_exit(task) : 0, (c))#define FN_EXIT()       {if (task->db_trace & TRACE_API) fn_exit(task);}#else  /* DB_TRACE */#define API_ENTER(fn)   /**/#define API_RETURN(c)   return(c)#define API_EXIT()      /**/#define FN_ENTER(fn)    /**/#define FN_RETURN(c)    return(c)#define FN_EXIT()       /**/#endif /* DB_TRACE */#define ENCODE_DBA(file, slot, dba) (*(dba)=(((F_ADDR)(file)&FILEMASK)<<FILESHIFT)|\                                    ((F_ADDR)(slot)&ADDRMASK))#define DECODE_DBA(dba, file, slot) {*(file)=(short)(((F_ADDR)(dba)>>FILESHIFT)&FILEMASK);\                                    *(slot)=(F_ADDR)(dba)&ADDRMASK;}#endif /* INTERNAL_H */#define DB_TIMEOUT     10     /* lock request wait 10 seconds in queue */#define NET_TIMEOUT    3      /* how long to wait for connection *//* record/set lock descriptor */typedef struct lock_descr{    DB_TCHAR        fl_type;       /* 'r'ead, 'w'rite, e'x'clusive, 'f'ree */    DB_TCHAR        fl_prev;       /* previous lock type */    FILE_NO        *fl_list;       /* array of files used by record/set */    int             fl_cnt;        /* Number of elements in fl_list */    DB_BOOLEAN      fl_kept;       /* Is lock kept after transaction? */} LOCK_DESCR;/*    Maximum number of transactions which can commit at a time. For    non-Unicode implementations, keep the TAF file size under 512    bytes. For Unicode this won't be enough - make it 1024 or 2048    bytes. On Win32, a wchar_t is 2 bytes, on Unix it's 4 bytes.    TAFLIMIT = (512 * sizeof(wchar_t) - 3 * sizeof(short) -               ((LOCKMGRLEN + LMCTYPELEN) * sizeof(wchar_t))) /               (LOGFILELEN * sizeof(wchar_t)    This will yield a file size of 512 * sizeof(wchar_t) or smaller*/#define TAFLIMIT 9/* structure to read TAF data into - size must be same for Unicode and ANSI */typedef struct TAFFILE_S{    short    user_count;    short    cnt;    short    unicode;    DB_TCHAR lmc_type[LMCTYPELEN];    DB_TCHAR lockmgrn[LOCKMGRLEN];    DB_TCHAR files[TAFLIMIT][LOGFILELEN];}  TAFFILE;typedef struct ll_elem{    struct ll_elem *next;    char           *data;}  ll_elem;#define LL_ELEM_INIT()  { NULL, NULL }typedef struct{    ll_elem *head;    ll_elem *tail;    ll_elem *curr;}  llist;#define LLIST_INIT()    { NULL, NULL, NULL }#define NO_SEEK      ((off_t)-1)#ifdef DBSTAT#include "dbstat.h"     /* must be before dbxtrn.h */#endif#include "trxlog.h"#ifndef MSGVER#define MSGVER  0x500#endif#include "dblock.h"     /* must be before dbxtrn.h */#if defined(TASK_DEFN)#include "dbxtrn.h"#ifndef INTERNAL_H#include "proto.h"#endif /* INTERNAL_H */#endif#include "apidefs.h"#ifdef QNX#define LOCK_FCN   LK_LOCK#define UNLOCK_FCN LK_UNLCK#else /* QNX */#define UNLOCK_FCN 0#define LOCK_FCN   1#endif /* QNX */#define READ_FCN   0#define WRITE_FCN  1#endif /* DBTYPE_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?