Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

keyfilecode.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include "keyerr.h"
#include "keydef.h"
#include "keyprint.h"
#include "keyfile.h"
#include "fileio.h"

Classes

struct  shuffle_candidate

Defines

#define boolean   int
#define true   1
#define false   0
#define log_errors   true
#define trace_io   false
#define fn_log_f   printf
#define hash_value(b, limit)   ((((int)b.block) + b.segment) % limit)
#define buddy_window   32
#define mark_modified(f, bufix)   f->buffer_pool.buffer[bufix].modified = true
#define delete_threshold   1
#define feasible_move(a, b, c)   ( (a<=keyspace_lc) && (b<=keyspace_lc) && (c<=keyspace_lc) )
#define kf6_keyrec_lc(a)   version_err
#define kf6_set_bof(a)   version_err
#define kf6_set_eof(a)   version_err
#define kf6_get_ptr(a, b, c, d)   version_err
#define kf6_put_ptr(a, b, c, d)   version_err
#define kf6_delete_ptr(a, b, c)   version_err
#define kf6_next_ptr(a, b, c, d, e)   version_err
#define kf6_prev_ptr(a, b, c, d, e)   version_err
#define kf6_get_rec(a, b, c, d, e, f)   version_err
#define kf6_put_rec(a, b, c, d, e)   version_err
#define kf6_delete_rec(a, b, c)   version_err
#define kf6_next_rec(a, b, c, d, e, f, g)   version_err
#define kf6_prev_rec(a, b, c, d, e, f, g)   version_err
#define kf6_get_subrec(a, b, c, d, e, f, g)   version_err
#define kf6_open_key(a, b, c, d)   version_err
#define kf6_create_key(a, b, c)   version_err
#define kf6_create_key_ld(a, b, c, d)   version_err
#define kf6_close_key(a)   version_err

Functions

boolean allocate_rec ()
void replace_max_key ()
void deallocate_rec ()
void check_ix_block_compression ()
void update_index ()
void index_delete ()
void split_block ()
FILE * file_index ()
void print_index_type (FILE *list, int index_type)
int compressed_int_lc (unsigned char buf[])
int uncompress_key_lc (UINT16 *key_lc, unsigned char p[])
int uncompress_UINT16 (UINT16 *i, unsigned char p[])
int uncompress_UINT32 (UINT32 *i, unsigned char p[])
int uncompress_UINT64 (UINT64 *i, unsigned char p[])
int compress_UINT32 (UINT32 i, unsigned char *ptr)
int compress_UINT64 (UINT64 i, unsigned char *ptr)
int UINT32_lc_if_compressed (UINT32 i)
int UINT64_lc_if_compressed (UINT64 i)
unsigned allocation_lc (unsigned lc, unsigned unit)
unsigned rec_allocation_lc (unsigned lc)
boolean error_is_fatal (UINT32 error_code)
void set_err (struct fcb *f, UINT32 err)
void set_error (struct fcb *f, int err, char caption[])
void set_error1 (struct fcb *f, int err, char caption[], int code)
void set_error2 (struct fcb *f, int err, char caption[], int code1, int code2)
boolean check_fcb (struct fcb *f)
boolean set_up (struct fcb *f, unsigned char key[], unsigned key_lc, struct key *k)
boolean gt_n_pntr (struct leveln_pntr p1, struct leveln_pntr p2)
int pntr_sc (struct ix_block *b, int ix)
int pack0_ptr (struct fcb *f, struct ix_block *b, level0_pntr *p)
int unpack0_lc (struct fcb *f, struct ix_block *b, int ix)
int unpack0_ptr (struct fcb *f, struct ix_block *b, int ix, level0_pntr *p)
int unpack0_ptr_and_rec (struct fcb *f, buffer_t *buf, int ix, level0_pntr *p, unsigned char rec[], unsigned *rec_lc, unsigned max_rec_lc)
int level0_pntr_lc (struct fcb *f, level0_pntr *p)
int leveln_pntr_lc (struct leveln_pntr *p)
int levelx_pntr_lc (struct fcb *f, levelx_pntr *p, int level)
int packn_ptr (struct ix_block *b, struct leveln_pntr *p)
int unpackn_lc (struct ix_block *b, int ix)
int unpackn_ptr (struct ix_block *b, int ix, struct leveln_pntr *p)
int nth_pntr_lc (struct fcb *f, struct ix_block *b, int ix)
int copy_ptr (struct fcb *f, struct ix_block *b, int ix, struct ix_block *b1)
boolean eq_key (struct key *k1, struct key *k2)
void copy_key (struct key *from, struct key *to)
int key_entry_lc (struct ix_block *b, int ix)
int get_nth_key (struct ix_block *b, struct key *k, int n)
int get_nth_key_and_pntr (struct fcb *f, struct ix_block *b, struct key *k, int n, levelx_pntr *p)
void get_max_key (struct ix_block *b, struct key *k)
void init_file_name (struct fcb *f, char id[])
void build_segment_name (struct fcb *f, unsigned segment, char name[])
void byte_swap_UINT16s (unsigned char s[], int cnt)
void byte_swap_UINT32 (unsigned char n[])
void byte_swap_UINT64 (unsigned char n[])
unsigned char read_byte (struct fcb *f, FILE *file)
UINT16 read_UINT16 (struct fcb *f, FILE *file)
UINT32 read_UINT32 (struct fcb *f, FILE *file)
UINT64 read_UINT64 (struct fcb *f, FILE *file)
boolean read_fib (struct fcb *f, char id[], boolean byte_swapping_required, boolean read_only)
void write_UINT16 (struct fcb *f, FILE *file, UINT16 *i)
void write_UINT16s (struct fcb *f, FILE *file, unsigned char s[], unsigned int cnt)
void write_UINT32 (struct fcb *f, FILE *file, UINT32 i)
void write_UINT64 (struct fcb *f, FILE *file, UINT64 i)
void write_fib (struct fcb *f)
void read_page (struct fcb *f, struct leveln_pntr p, block_type_t *buf)
void get_page (struct fcb *f, struct leveln_pntr blk, block_type_t *buf)
void write_page (struct fcb *f, struct leveln_pntr p, block_type_t *buf)
int vacate_file_index (struct fcb *f)
void open_segment (struct fcb *f, unsigned segment, int ix)
int file_ix (struct fcb *f, unsigned segment)
FILE * file_index (struct fcb *f, unsigned segment)
void set_position (struct fcb *f, int index, struct leveln_pntr b, int ix)
void reset_ages (struct fcb *f)
int search_hash_chain (struct fcb *f, struct leveln_pntr block)
void hash_chain_insert (struct fcb *f, int bufix)
void hash_chain_remove (struct fcb *f, int bufix)
void make_buffer_youngest (struct fcb *f, int bufix)
void init_buffer_hash_fields (struct fcb *f, int i, struct leveln_pntr *b)
void initialize_buffer (struct fcb *f, int bufix, struct leveln_pntr *contents)
int write_block_and_buddies (struct fcb *f, int bufix)
int vacate_oldest_buffer (struct fcb *f, struct leveln_pntr *b)
void copy_index_block (struct ix_block *b1, struct ix_block *b2)
void set_empty_block_prefix (struct ix_block *b, struct key *prefix, unsigned prefix_lc)
void initialize_index_block (struct ix_block *b, int index, unsigned lvl, struct key *prefix, unsigned prefix_lc)
int get_index (struct fcb *f, struct leveln_pntr b)
int find_prefix_lc (struct key *k1, struct key *k2)
int block_prefix_lc (struct ix_block *b)
unsigned ix_pool_lc (struct ix_block *b)
unsigned ix_entry_lc (struct fcb *f, struct key *k, levelx_pntr *p, unsigned prefix_lc, int level)
unsigned ix_entries_lc (struct fcb *f, struct ix_block *b, int start, int cnt, unsigned prefix_lc)
unsigned new_chars_in_use (struct ix_block *b, int prefix_lc)
int ix_pool_lc_after_insert (struct fcb *f, struct ix_block *b, struct key *k, levelx_pntr *p, int ix, unsigned *new_prefix_lc)
int ix_pool_lc_after_replace (struct fcb *f, struct ix_block *b, struct key *k, levelx_pntr *p, int ix, unsigned *new_prefix_lc)
int ix_pool_lc_after_change (struct fcb *f, struct ix_block *b, struct key *k, levelx_pntr *p, int ix, unsigned *new_prefix_lc, boolean insert)
int compare_key (unsigned char k[], UINT32 klc, struct ix_block *b, int ix)
int search_block (struct fcb *f, int bufix, struct key *k, boolean *found)
leveln_pntr search_index (struct fcb *f, int index, UINT32 stop_lvl, struct key *k)
leveln_pntr parent_block (struct fcb *f, int bufix, struct key *k)
void set_block_shift (struct fcb *f)
boolean machine_is_little_endian ()
void init_key (struct fcb *f, char id[], int lc)
void insert_rec (struct fcb *f, char r[], level0_pntr *p)
void lock_buffer (f, bufix) struct fcb *f

Variables

int read_cnt
level0_pntr null0_ptr
leveln_pntr nulln_ptr = {max_segment,0}
int power_of_two [20]
int bufix

Define Documentation

#define boolean   int
 

#define buddy_window   32
 

#define delete_threshold   1
 

#define false   0
 

#define feasible_move a,
b,
 )     ( (a<=keyspace_lc) && (b<=keyspace_lc) && (c<=keyspace_lc) )
 

#define fn_log_f   printf
 

#define hash_value b,
limit   )     ((((int)b.block) + b.segment) % limit)
 

#define kf6_close_key  )     version_err
 

#define kf6_create_key a,
b,
 )     version_err
 

#define kf6_create_key_ld a,
b,
c,
 )     version_err
 

#define kf6_delete_ptr a,
b,
 )     version_err
 

#define kf6_delete_rec a,
b,
 )     version_err
 

#define kf6_get_ptr a,
b,
c,
 )     version_err
 

#define kf6_get_rec a,
b,
c,
d,
e,
 )     version_err
 

#define kf6_get_subrec a,
b,
c,
d,
e,
f,
 )     version_err
 

#define kf6_keyrec_lc  )     version_err
 

#define kf6_next_ptr a,
b,
c,
d,
 )     version_err
 

#define kf6_next_rec a,
b,
c,
d,
e,
f,
 )     version_err
 

#define kf6_open_key a,
b,
c,
 )     version_err
 

#define kf6_prev_ptr a,
b,
c,
d,
 )     version_err
 

#define kf6_prev_rec a,
b,
c,
d,
e,
f,
 )     version_err
 

#define kf6_put_ptr a,
b,
c,
 )     version_err
 

#define kf6_put_rec a,
b,
c,
d,
 )     version_err
 

#define kf6_set_bof  )     version_err
 

#define kf6_set_eof  )     version_err
 

#define log_errors   true
 

#define mark_modified f,
bufix   )     f->buffer_pool.buffer[bufix].modified = true
 

#define trace_io   false
 

#define true   1
 


Function Documentation

boolean allocate_rec  )  [static]
 

unsigned allocation_lc unsigned  lc,
unsigned  unit
[static]
 

int block_prefix_lc struct ix_block b  )  [static]
 

void build_segment_name struct fcb f,
unsigned  segment,
char  name[]
[static]
 

void byte_swap_UINT16s unsigned char  s[],
int  cnt
[static]
 

void byte_swap_UINT32 unsigned char  n[]  )  [static]
 

void byte_swap_UINT64 unsigned char  n[]  )  [static]
 

boolean check_fcb struct fcb f  )  [static]
 

void check_ix_block_compression  )  [static]
 

int compare_key unsigned char  k[],
UINT32  klc,
struct ix_block b,
int  ix
[static]
 

int compress_UINT32 UINT32  i,
unsigned char *  ptr
[static]
 

int compress_UINT64 UINT64  i,
unsigned char *  ptr
[static]
 

int compressed_int_lc unsigned char  buf[]  )  [static]
 

void copy_index_block struct ix_block b1,
struct ix_block b2
[static]
 

void copy_key struct key from,
struct key to
[static]
 

int copy_ptr struct fcb f,
struct ix_block b,
int  ix,
struct ix_block b1
[static]
 

void deallocate_rec  )  [static]
 

boolean eq_key struct key k1,
struct key k2
[static]
 

boolean error_is_fatal UINT32  error_code  )  [static]
 

FILE* file_index struct fcb f,
unsigned  segment
[static]
 

FILE* file_index  )  [static]
 

int file_ix struct fcb f,
unsigned  segment
[static]
 

int find_prefix_lc struct key k1,
struct key k2
[static]
 

int get_index struct fcb f,
struct leveln_pntr  b
[static]
 

void get_max_key struct ix_block b,
struct key k
[static]
 

int get_nth_key struct ix_block b,
struct key k,
int  n
 

int get_nth_key_and_pntr struct fcb f,
struct ix_block b,
struct key k,
int  n,
levelx_pntr p
 

void get_page struct fcb f,
struct leveln_pntr  blk,
block_type_t buf
 

boolean gt_n_pntr struct leveln_pntr  p1,
struct leveln_pntr  p2
[static]
 

void hash_chain_insert struct fcb f,
int  bufix
[static]
 

void hash_chain_remove struct fcb f,
int  bufix
[static]
 

void index_delete  )  [static]
 

void init_buffer_hash_fields struct fcb f,
int  i,
struct leveln_pntr b
[static]
 

void init_file_name struct fcb f,
char  id[]
[static]
 

void init_key struct fcb f,
char  id[],
int  lc
[static]
 

void initialize_buffer struct fcb f,
int  bufix,
struct leveln_pntr contents
[static]
 

void initialize_index_block struct ix_block b,
int  index,
unsigned  lvl,
struct key prefix,
unsigned  prefix_lc
[static]
 

void insert_rec struct fcb f,
char  r[],
level0_pntr p
[static]
 

unsigned ix_entries_lc struct fcb f,
struct ix_block b,
int  start,
int  cnt,
unsigned  prefix_lc
[static]
 

unsigned ix_entry_lc struct fcb f,
struct key k,
levelx_pntr p,
unsigned  prefix_lc,
int  level
[static]
 

unsigned ix_pool_lc struct ix_block b  )  [static]
 

int ix_pool_lc_after_change struct fcb f,
struct ix_block b,
struct key k,
levelx_pntr p,
int  ix,
unsigned *  new_prefix_lc,
boolean  insert
[static]
 

int ix_pool_lc_after_insert struct fcb f,
struct ix_block b,
struct key k,
levelx_pntr p,
int  ix,
unsigned *  new_prefix_lc
[static]
 

int ix_pool_lc_after_replace struct fcb f,
struct ix_block b,
struct key k,
levelx_pntr p,
int  ix,
unsigned *  new_prefix_lc
[static]
 

int key_entry_lc struct ix_block b,
int  ix
[static]
 

int level0_pntr_lc struct fcb f,
level0_pntr p
[static]
 

int leveln_pntr_lc struct leveln_pntr p  )  [static]
 

int levelx_pntr_lc struct fcb f,
levelx_pntr p,
int  level
[static]
 

void lock_buffer ,
bufix 
[static]
 

boolean machine_is_little_endian  )  [static]
 

void make_buffer_youngest struct fcb f,
int  bufix
[static]
 

unsigned new_chars_in_use struct ix_block b,
int  prefix_lc
[static]
 

int nth_pntr_lc struct fcb f,
struct ix_block b,
int  ix
[static]
 

void open_segment struct fcb f,
unsigned  segment,
int  ix
[static]
 

int pack0_ptr struct fcb f,
struct ix_block b,
level0_pntr p
 

int packn_ptr struct ix_block b,
struct leveln_pntr p
 

struct leveln_pntr parent_block struct fcb f,
int  bufix,
struct key k
[static]
 

int pntr_sc struct ix_block b,
int  ix
[static]
 

void print_index_type FILE *  list,
int  index_type
[static]
 

unsigned char read_byte struct fcb f,
FILE *  file
[static]
 

boolean read_fib struct fcb f,
char  id[],
boolean  byte_swapping_required,
boolean  read_only
[static]
 

void read_page struct fcb f,
struct leveln_pntr  p,
block_type_t buf
[static]
 

UINT16 read_UINT16 struct fcb f,
FILE *  file
[static]
 

UINT32 read_UINT32 struct fcb f,
FILE *  file
[static]
 

UINT64 read_UINT64 struct fcb f,
FILE *  file
[static]
 

unsigned rec_allocation_lc unsigned  lc  )  [static]
 

void replace_max_key  )  [static]
 

void reset_ages struct fcb f  )  [static]
 

int search_block struct fcb f,
int  bufix,
struct key k,
boolean *  found
[static]
 

int search_hash_chain struct fcb f,
struct leveln_pntr  block
[static]
 

struct leveln_pntr search_index struct fcb f,
int  index,
UINT32  stop_lvl,
struct key k
[static]
 

void set_block_shift struct fcb f  )  [static]
 

void set_empty_block_prefix struct ix_block b,
struct key prefix,
unsigned  prefix_lc
[static]
 

void set_err struct fcb f,
UINT32  err
[static]
 

void set_error struct fcb f,
int  err,
char  caption[]
[static]
 

void set_error1 struct fcb f,
int  err,
char  caption[],
int  code
[static]
 

void set_error2 struct fcb f,
int  err,
char  caption[],
int  code1,
int  code2
[static]
 

void set_position struct fcb f,
int  index,
struct leveln_pntr  b,
int  ix
[static]
 

boolean set_up struct fcb f,
unsigned char  key[],
unsigned  key_lc,
struct key k
[static]
 

void split_block  )  [static]
 

int UINT32_lc_if_compressed UINT32  i  )  [static]
 

int UINT64_lc_if_compressed UINT64  i  )  [static]
 

int uncompress_key_lc UINT16 key_lc,
unsigned char  p[]
[static]
 

int uncompress_UINT16 UINT16 i,
unsigned char  p[]
[static]
 

int uncompress_UINT32 UINT32 i,
unsigned char  p[]
[static]
 

int uncompress_UINT64 UINT64 i,
unsigned char  p[]
[static]
 

int unpack0_lc struct fcb f,
struct ix_block b,
int  ix
[static]
 

int unpack0_ptr struct fcb f,
struct ix_block b,
int  ix,
level0_pntr p
 

int unpack0_ptr_and_rec struct fcb f,
buffer_t buf,
int  ix,
level0_pntr p,
unsigned char  rec[],
unsigned *  rec_lc,
unsigned  max_rec_lc
[static]
 

int unpackn_lc struct ix_block b,
int  ix
[static]
 

int unpackn_ptr struct ix_block b,
int  ix,
struct leveln_pntr p
 

void update_index  )  [static]
 

int vacate_file_index struct fcb f  )  [static]
 

int vacate_oldest_buffer struct fcb f,
struct leveln_pntr b
[static]
 

int write_block_and_buddies struct fcb f,
int  bufix
[static]
 

void write_fib struct fcb f  )  [static]
 

void write_page struct fcb f,
struct leveln_pntr  p,
block_type_t buf
[static]
 

void write_UINT16 struct fcb f,
FILE *  file,
UINT16 i
[static]
 

void write_UINT16s struct fcb f,
FILE *  file,
unsigned char  s[],
unsigned int  cnt
[static]
 

void write_UINT32 struct fcb f,
FILE *  file,
UINT32  i
[static]
 

void write_UINT64 struct fcb f,
FILE *  file,
UINT64  i
[static]
 


Variable Documentation

int bufix
 

level0_pntr null0_ptr [static]
 

Initial value:

 {max_segment,0,0}
  dummy_ptr = {0,0,0}

struct leveln_pntr nulln_ptr = {max_segment,0} [static]
 

int power_of_two[20] [static]
 

int read_cnt [static]
 

Initial value:

0
  write_cnt=0
  shuffle_cnt
  shuffle_lt_zero_cnt=0
  shuffle_rt_zero_cnt=0


Generated on Tue Jun 15 11:02:57 2010 for Lemur by doxygen 1.3.4