; index.inc
;
;

;------------------------------------------------------------------------------
;	  data:	Equates for the HEADER portion of the INDEX file
;
;------------------------------------------------------------------------------

ind_root	equ	0
 ind_root_type	equ	0
 ind_root_num	equ	2
 ind_root_prev	equ	4
 ind_root_next	equ	8

ind_marker	equ	nh_header_len		;BYTEs	unique string for a
						;	FORCE header

 ind_force_str	equ	'FORCEIIIFDX '
 ind_marker_len	equ	12

ind_write_count equ nh_header_len + 12

ind_record_len	equ	nh_header_len + 14	;WORD	index record length
						;	this includes the
						;	DWORD record number

ind_records	equ	nh_header_len + 16	;WORD	number of records in
						;	the database

ind_unique	equ	nh_header_len + 20	;WORD	If TRUE, then the index
						;	is indexed unique

ind_rec_node	equ	nh_header_len + 22	;WORD	number of records we
						;	can stuff into one node

ind_root_size	equ	nh_header_len + 24

ind_data	equ	ind_root_size

ind_handle	equ	ind_data	;WORD	FDX file handle DOS

ind_idf_handle	equ	ind_data + 2	;WORD	memory handle for
					;	buffer containing index
					; 	records

ind_memory	equ	ind_data + 4	;WORD	memory handle for this
					; 	buffer (i.e. FHB for
					;	the index file)

ind_position	equ	ind_data + 6	;WORD	integer from 0 to
					;	"ind_rec_node" to 
					;	indicate what "node"
					;	position we're at

ind_leaf_addr	equ	ind_data + 8	;DWORD	r/w address of the current
					;	leaf in memory in the
					;	index file

ind_branch_addr	equ	ind_data + 12	;DWORD	r/w address of the current
					;	branch in memory within
					;	the index file

ind_b_position	equ	ind_data + 16	;WORD	what branch position
					;	are we at?

ind_alias	equ	ind_data + 18	;dword 	seg:offset of the alias block.

ind_pre_comm	equ	ind_data + 22	;word	TRUE if PRECOMMIT was called
					;	FALSE if APPCOMMIT was called
					;		prior to a commit call.

ind_dirty		equ ind_data + 24	; WORD	TRUE if index has been written to

ind_shared		equ ind_data + 26	; WORD	TRUE if index is shared

ind_previous	equ	ind_data + 28	;word	pointer(near) into ind_prev_tbl
ind_prev_tbl	equ	ind_data + 30	;dword	table of "previous" node. 1st
					;	entry = -1.(root). 2nd element
					;	= previous file offset of 3rd
					;	level node in memory
 ind_prev_ele	equ	8		;7 levels+root

ind_table_len	equ	ind_data + 32 + (4 * ind_prev_ele )
ind_table_para	equ	(ind_table_len+15)/16
ind_allowed	equ	7		;number of index files that can
					; be associated with a DBF file

;------------------------------------------------------------------------------
;	  data:	equates for the an INDEX FILE RECORD
;
;------------------------------------------------------------------------------

ir_record	equ	0		;0-3	DWORD record number
ir_key		equ	4		;4-???	buffer containing index KEY

;------------------------------------------------------------------------------
;	  data:	NODE EQUATES
;
;------------------------------------------------------------------------------

nh_type		equ	0		; WORD	The TYPE of the node, either a
					;	 LEAF or a BRANCH.
 nh_branch	equ	1
 nh_leaf	equ	2
 nh_root	equ	3
nh_number	equ	2		; WORD	Number of records inside of
					; 	 this node.
				
nh_previous	equ	4		;DWORD	Number of the previous node.
					;	 If this is -1, then this is the
					;	 1st node in the file following
					; 	 the ROOT node

nh_next		equ	8		;DWORD	Number of the next node. If this
					; 	 is -1 then this is the LAST
					;	 node in the file

nh_header_len	equ	12		;length of the header portion inside
					; of each node

	;===WARNING: DON'T ARBITRARILY CHANGE! Always keep values
	;	multiples of 2 (i.e., we use rep movsw!)

nh_node_size	equ	4096		;number of bytes for each node.

nh_node_space	equ	nh_node_size-nh_header_len ;(nh_node_size * 3) / 4

nh_nodes_in_16k	equ	16343 / nh_node_size

;------------------------------------------------------------------------------
;	  data:	Equates for the INDEX COMPILER RECORD table. This table 
;		contains all information necessary for a call to the 
;		_INDEX library routine. (i.e., information for CD_INDEX 
;		in the compiler)
;
;------------------------------------------------------------------------------

ir_ind_exp_off	equ	0		;offset of the index expression
ir_ind_exp_seg	equ	2		;segment of index expression else extrn
					; index if secondary

ir_ind_var_off	equ	4		;offset of index variable. NOTE: This
					; will contains the offset of the
					; field variable if we're using method
					; #3.
ir_ind_var_seg	equ	6		;segment of index variable else extrn
					; index if secondary
ir_ind_var_size	equ	8
ir_ind_var_type	equ	10

ir_ind_fn_off	equ	12		;offset of filename
ir_ind_fn_seg	equ	14		;segment of filename else extrn index

ir_ind_cf_off	equ	16		;offset of character field
ir_ind_cf_seg	equ	18

ir_ind_cex_off	equ	20		;this expression is used for
					; a SEEK
ir_ind_cex_seg	equ	22

ir_table_len	equ	20
ir_number_files	equ	70

;------------------------------------------------------------------------------
;	  data:	Structure for file buffers for merge index
;
;------------------------------------------------------------------------------

mf_num_files	equ	50		;number of files we support during
					; a merge
mf_buffer	equ	0		;pointer to beginning of buffer
mf_pointer	equ	4		;pointer to current record within
					; block
mf_open		equ	8		;TRUE | FALSE whether the file is
					; open or not
mf_handle	equ	10		;DOS file handle
mf_filename	equ	12		;full pathname here...
mf_active	equ	100		;if FALSE, then this area is no longer
					; used
mf_records	equ	102		;number of records in memory
mf_read		equ	106		;if FALSE, then do NOT read any more
					; from tmp file and set active to FALSE
mf_rw_ptr	equ	108		;rw pointer for tmp file for reread
mf_table_len	equ	112
