############################################################################ # # Name: initfile.icn # # Title: initialize entry for file in filestats table # # Author: Richard L. Goerwitz # # Version: 2.2 # ############################################################################ # # This file contains initfile(filename), which creates a set of stats # for the indexed database contained in filename. Uses several global # structures, primarily for speed. Beware. # ############################################################################ # # See also: retrieve.icn, bmp2text.icn, retrops.icn # ############################################################################ # Used to store stats for each filename. record Fs(ind_filename, bmp_filename, lim_filename, unt_filename, IS, ofs_table) # IS is declared in indexutl.icn. # global IS global filestats procedure initfile(filename) # Messy procedure which creates and stores the names of several # files that will be repeatedly used with "filename." Reads in # the stats for filename from that file's .IS file. Also reads in # the bitmap->offset (.OFS file) table, and puts it into # filestats[filename].ofs_table for later (re-)use. The bitmap-> # offset table contains pointers into the .UNT file for filename, # which lists all the main text divisions, with pointers into the # main text file (i.e. filename) for each division. The scheme # is: .OFS file (locates larger divisions) -> .UNT file (contains # the offsets for smaller divisions in filename) -> filename (the # actual compressed text). local IS_filename, in_IS, upto_field, stored_bitmap_length, ofs_filename, intext, cut_down_bitmap, block_size, offset # global filestats initial { filestats := table() # OS-specific parameters are initialized here. initialize_os_params() # in indexutl.icn } # Check for sloppy programming. Did we do this one already?? if not (/filestats[filename] := Fs(,,,,,table())) then fail filestats[filename].ind_filename := dir_name(filename)||create_fname(filename, "IND") filestats[filename].bmp_filename := dir_name(filename)||create_fname(filename, "BMP") filestats[filename].lim_filename := dir_name(filename)||create_fname(filename, "LIM") filestats[filename].unt_filename := dir_name(filename)||create_fname(filename, "UNT") # Decode stored IS record for filename. IS_filename := dir_name(filename)||create_fname(filename, "IS") in_IS := open(IS_filename) | abort("bitmap_2_text", "Can't open "||IS_filename||". Did you forget to index?", 24) filestats[filename].IS := decode(!in_IS) close(in_IS) # Having decoded IS, we can now determine the length of the cut- # down bitmaps stored in the .OFS file for filename. upto_field := 1 < (filestats[filename].IS.no * 2) / 3 | 1 stored_bitmap_length := ((filestats[filename].IS.len * upto_field) <= seq(0,8)) # open .OFS file ofs_filename := dir_name(filename)||create_fname(filename, "OFS") intext := open(ofs_filename) | abort("bitmap_2_text", "can't open "||ofs_filename, 23) # read in blocks from .OFS file, breaking them into their # constituent parts while block_size := read_int(intext, 8) * 8 do { cut_down_bitmap := read_int(intext, stored_bitmap_length) offset := read_int(intext, block_size - stored_bitmap_length) insert(filestats[filename].ofs_table, cut_down_bitmap, offset) } close(intext) return *filestats[filename].ofs_table end