|
|
1 /*
2 * The basic data type is a line buffer, in which blocks of lines are
3 * allocated. The line buffer can be made inactive, to make it use as little
4 * system resources as possible.
5 * Blocks can be created, deleted, queried for their size, split in two, or
6 * concatenated. Blocks are never actually deleted in a line buffer, but a
7 * fake delete operation is added for the sake of completeness.
8 */
9 typedef Int block;
10
11 typedef struct _btbuf_ {
12 long offset; /* offset in tmpfile */
13 struct _btbuf_ *prev; /* prev in linked list */
14 struct _btbuf_ *next; /* next in linked list */
15 char *buf; /* buffer with blocks and text */
16 } btbuf;
17
18 typedef struct {
19 char *file; /* tmpfile name */
20 int fd; /* tmpfile fd */
21 char *buf; /* current low-level buffer */
22 int blksz; /* block size in write buffer */
23 int txtsz; /* text size in write buffer */
24 void (*putline) P((char*, char*)); /* output line function */
25 char *context; /* context for putline */
26 bool reverse; /* for bk_put() */
27 btbuf *wb; /* write buffer */
28 btbuf bt[NR_EDBUFS]; /* read & write buffers */
29 } linebuf;
30
31 extern linebuf *lb_new P((linebuf*, char*));
32 extern void lb_del P((linebuf*));
33 extern void lb_inact P((linebuf*));
34
35 extern block bk_new P((linebuf*, char*(*)(char*), char*));
36 # define bk_del(linebuf, block) /* nothing */
37 extern Int bk_size P((linebuf*, block));
38 extern void bk_split P((linebuf*, block, Int, block*, block*));
39 extern block bk_cat P((linebuf*, block, block));
40 extern void bk_put P((linebuf*, block, Int, Int, void(*)(char*, char*),
41 char*, int));
42
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.