/* WB-tree File Based Associative String Data Base System. * Copyright (c) 1991, 1992, 1993, 2000, 2003 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA * 02111, USA. * * As a special exception, the Free Software Foundation gives permission * for additional uses of the text contained in its release of GUILE. * * The exception is that, if you link the GUILE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public License. * Your use of that executable is in no way restricted on account of * linking the GUILE library code into it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the GNU General Public License. * * This exception applies only to the code released by the * Free Software Foundation under the name GUILE. If you copy * code from other Free Software Foundation releases into a copy of * GUILE, as the General Public License permits, the exception does * not apply to the code that you add in this way. To avoid misleading * anyone as to the status of such modified files, you must delete * this exception notice from them. * * If you write modifications of your own for GUILE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ #ifdef __STDC__ #define STDC_INCLUDES #endif #ifdef __TURBOC__ #define MSDOS #endif #ifdef MSDOS #define STDC_INCLUDES #endif #ifdef VMS #define STDC_INCLUDES #endif #ifdef STDC_INCLUDES #include #include #else unsigned char *malloc(); unsigned char *realloc(); #endif #ifdef MSDOS #include #include #include #include # define open_input_file(name) (open(name,O_BINARY | O_RDONLY)) # define open_output_file(name) (open(name,O_BINARY | O_WRONLY | O_CREAT, S_IWRITE | S_IREAD)) # define open_io_file(name) (open(name,O_BINARY | O_RDWR)) #else /* MSDOS */ /* #include */ # define max(a,b) (ab ? b : a) extern int errno; # define open_input_file(name) (open(name,0)) # define open_output_file(name) (creat(name, 0666)) /* was S_IWRITE | S_IREAD */ # define open_io_file(name) (open(name,2)) #endif #include #define substring_move_left(src,start,end,dst,dstart) (memmove(&dst[dstart],&src[start],(end)-(start))) #define substring_move_right substring_move_left #define substring_move(src,start,end,dst,dstart) (memcpy(&dst[dstart],&src[start],(end)-(start))) /* these are only used in blkio.scm, but are here for their SCM equivalents. */ #define file_position(fildes) (tell(fildes)) #define file_set_position(fildes,offset) (lseek(fildes,offset,0)) #define substring_write(buf,start,end,fildes) (write(fildes,&((char *)buf)[start],end-start)) #define substring_read(buf,start,end,fildes) (read(fildes,&((char *)buf)[start],end-start)) #define close_port(fildes) (close(fildes)) #define output_port_P(fildes) ((fildes)>=0) #define input_port_P(fildes) ((fildes)>=0) typedef struct slck { struct slck *NEXT; int FLG; int NAME; } LCK; extern LCK *last_lck; LCK *make_lck(); int try_lck(); void lck(); void unlck(); void check_lcks(); typedef struct entry { struct entry *NEXT; long ID; unsigned char *BLK; int TAG, AGE, DTY, PUS, ACC, REF, SEG; } ENTRY; ENTRY *make_ent(); typedef int (*int_function)(); #define ent_tag(ent) ((ent)->TAG) #define ent_next(ent) ((ent)->NEXT) #define ent_seg(ent) ((ent)->SEG) #define ent_id(ent) ((ent)->ID) #define ent_blk(ent) ((ent)->BLK) #define ent_age(ent) ((ent)->AGE) #define ent_dty_P(ent) ((ent)->DTY) #define ent_pus(ent) ((ent->PUS)) #define ent_acc(ent) ((ent)->ACC) #define ent_ref(ent) ((ent)->REF) #define ent_set_tag(ent, tag) {(ent)->TAG = tag;} #define ent_set_next(ent, next) {(ent)->NEXT = next;} #define ent_set_seg(ent, seg) {(ent)->SEG = seg;} #define ent_set_id(ent, num) {(ent)->ID = num;} #define ent_set_age(ent, age) {(ent)->AGE = age;} #define ent_set_dty(ent, dty) {(ent)->DTY = dty;} #define ent_set_pus(ent, pus) {(ent)->PUS = pus;} #define ent_set_acc(ent, acc) {(ent)->ACC = acc;} #define ent_set_ref(ent, ref) {(ent)->REF = ref;} typedef struct { int SEG, TYP; long ID, LAST; int WCB, SPARE; } HAND; HAND *make_han(); #define han_id(han) (((HAND *)(han))->ID) #define han_seg(han) (((HAND *)(han))->SEG) #define han_typ(han) (((HAND *)(han))->TYP) #define han_last(han) (((HAND *)(han))->LAST) #define han_wcb(han) (((HAND *)(han))->WCB) #define han_set_num(han,num) {((HAND *)(han))->ID = num;} #define han_set_seg(han,seg) {((HAND *)(han))->SEG = seg;} #define han_set_typ(han,typ) {((HAND *)(han))->TYP = typ;} #define han_set_last(han,last) {((HAND *)(han))->LAST = last;} #define han_set_wcb(han,wcb) {((HAND *)(han))->WCB = wcb;} typedef struct { int PORT, BSIZ; long USED; unsigned char *STRN; HAND RT_HAN, FL_HAN; LCK FLCK; LCK FFCK; int FLC_LEN; long *FLC; } SEGD; extern SEGD segd_tab[]; #define segd_port(segd) ((segd).PORT) #define segd_bsiz(segd) ((segd).BSIZ) #define segd_used(segd) ((segd).USED) #define segd_str(segd) ((segd).STRN) #define segd_rt_han(segd) (&((segd).RT_HAN)) #define segd_fl_han(segd) (&((segd).FL_HAN)) #define segd_lck(segd) (&((segd).FLCK)) #define segd_fck(segd) (&((segd).FFCK)) #define segd_flc_len(segd) ((segd).FLC_LEN) #define segd_flc(segd) ((segd).FLC) #define segd_set_port(segd,port) {(segd).PORT = port;} #define segd_set_bsiz(segd,bsiz) {(segd).BSIZ = bsiz;} #define segd_set_used(segd,used) {(segd).USED = used;} #define segd_set_str(segd,strn) {(segd).STRN = strn;} #define segd_set_flc_len(segd,len) {(segd).FLC_LEN = len;} #define segd_set_flc(segd,flc) {(segd).FLC = flc;} #include extern FILE *diagout; #define dprintf(DaRgS) (fprintf DaRgS) #include "wbdefs.h" #include "ent.h" #include "blink.h" #include "handle.h" #include "prev.h" #include "del.h" #include "stats.h" #include "blkio.h" #include "scan.h" /* BLK predicates */ #define root_P(blk) (*(long *)&blk[blk_id_pos] == *(long *)&blk[blk_top_id_pos]) #define end_of_chain_P(blk) (*(long *)&blk[blk_nxt_id_pos] == 0L)