1 #define SEARCHSZ        41              /* max size of search string */
2 #define MAXTEMP         2048            /* max of temp file size (in cells) */
3 #define TEMPSZ          ((MAXTEMP+7)/8) /* temp table size (in bytes) */
4 #define POOLSZ          50              /* number of lines in cache */
5 
6 #define XTEMP           1               /* line is in tmp file */
7 #define XNOEOLN         2               /* no end of line */
8 
9 struct index {                          /* out of core line descriptor */
10 	long            seek;           /* seek in file */
11 	short           len;            /* length of line */
12 	unsigned        poolindex :8;   /* index in pool or NOINDEX */
13 	unsigned        flags :8;       /* is in tmp file */
14 };
15 
16 struct map {                            /* pool cell descriptor */
17 	short           busy;           /* cell busy */
18 	int             index;          /* index in lindex */
19 	long            time;           /* time of last access */
20 };
21 
22 typedef struct {                        /* in core line descriptor */
23 	char            *ptr;           /* pointer to string */
24 	short           len;            /* length of string */
25 	short           oldlen;         /* length before mod */
26 	unsigned        mod :8;         /* line is modified */
27 	unsigned        noeoln :8;      /* no end of line */
28 } LINE;
29 
30 typedef struct {
31 	struct index    *lindex;        /* out of core line descriptors */
32 	struct map      map [POOLSZ];   /* line pool */
33 	LINE            pool [POOLSZ];  /* in core line descriptors */
34 	char            tmap [TEMPSZ];  /* temp file map */
35 	long            nindex;         /* number of indexes malloc'ed */
36 	long            size;           /* length of file in bytes */
37 	short           fd;             /* file descriptor */
38 	short           bakfd;          /* bak file descriptor */
39 	short           tfd;            /* temp file descriptor */
40 	int             len;            /* length of file in lines */
41 	short           broken;         /* there are broken lines */
42 } REC;
43 
44 REC *RecOpen (int fd, int wmode);
45 void RecClose (REC *r);
46 int RecSave (REC *r, char *filename);
47 void RecBreak (REC *r);
48 LINE *RecGet (REC *r, int n);
49 void RecPut (LINE *p, int newlen);
50 void RecDelChar (REC *r, int line, int off);
51 void RecInsChar (REC *r, int line, int off, int sym);
52 void RecInsLine (REC *r, int n);
53 void RecDelLine (REC *r, int n);
54