-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathbstuff.h
65 lines (57 loc) · 2.42 KB
/
bstuff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
/* Copyright (C) 2001-03 by Frank Mitchell */
/* Under Enclosed Free-Use License */
/* bstuff.h Version 0.55 (Second Release) */
/* Contact: [email protected] */
#define ZLEN 25 /* Data String Length */
#define FNAMLEN 32 /* Max Filename Length */
#define MESGFIL "MESSAGE.DAT" /* Error Messages */
#define SPECFIL "SPECFIL.DAT" /* User Config Spec */
#define DATAFIL "WEIRD.DAT" /* Data File */
#define BTREEFIL "BUSHY.DAT" /* Bushy Tree File */
#define CHECKFIL "CHECKORD.DAT" /* Sorted Data Check */
typedef struct {
char StrkBfil[FNAMLEN]; /* String Key B-Tree Filename */
char NumkBfil[FNAMLEN]; /* Numeric Key B-Tree Filename */
} DATAHR; /* Data File Header */
typedef struct {
unsigned Flags; /* Record Attributes */
long RecNum; /* Record # */
char StrDatK[ZLEN]; /* ASCII String Key */
long NumDatK; /* Long Integer Key */
} RECORD; /* Data File Record */
typedef struct {
fpos_t RootQ; /* Root Node Posn */
size_t RootLev; /* Root Node Level # */
size_t FullNode; /* # Keys in Disk Node */
size_t LenK; /* Key Length In Bytes */
fpos_t VacQ; /* Vacant B-Tree End Posn */
} TREEHR; /* Bushy Tree Header */
typedef struct {
size_t KeyTot; /* Node Key Total */
int Lev; /* Node Level, Leaf=0 */
} NODEHR; /* Node Header */
typedef struct {
fpos_t NodeQ; /* File Position Of Node */
int NodeE; /* End Element # (=Total-1) */
int SelJ; /* Node Body Index Selected */
char*SelKP; /* Node Body Key Selected */
fpos_t*BodQP; /* Node Body File Posn Store */
char*BodKP; /* Node Body Key Store */
} BRANCH; /* Branch Tracking At Each Level */
int DATINIT(void); /* Data File Prep */
long KNURAN(long*,long*); /* Knuth Virtuous Random #s */
int MAKSTR(char*,int,long*,long*); /* Random String Keys */
int BTRINIT(void); /* Initialize Bushy Tree */
int BUSH(char*,fpos_t); /* Bushy Tree Build */
char*CHOPDOWN(char*,fpos_t,size_t*,FILE*,TREEHR*,BRANCH*); /* Node Chop */
int STICKIN(char*,fpos_t*,size_t); /* Insert Node Elements */
int NEWROOT(char*,fpos_t,size_t); /* Create New B-Tree Root */
int COLX7F(char*,char*,size_t); /* Custom ASCII Collation */
int TREESCAN(void); /* Check Bushy Tree */
int NODETREK(void); /* Scan Node Hierarchy */
int SCANZERO(char*,fpos_t); /* Scan Level-0 For Keys */