local-to-global.h 1.54 KB
Newer Older
inge's avatar
inge committed
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
/*
 * File: local_to_global.h
 *
 * Copyright 1996 Inge Wallin, Per Cederqvist
 */


#ifndef LOCAL2GLOBAL__H
#define LOCAL2GLOBAL__H

#include "kom-types.h"


#define  L2G_BLOCKSIZE   10	     /* Doesn't seem to matter much. */


typedef struct block_info {
    int              first_free;     /* Insert new texts here. */
    int              zeroes;	     /* Used as optimization for compacting. */

    Local_text_no    start;	     /* First local text no in this block. */
    Local_text_no  * key_block;
    Text_no        * value_block;
} L2g_block_info;


typedef struct local_to_global {
    int 	      num_blocks;
    L2g_block_info  * blocks;
} Local_to_global;



void             l2g_destruct(Local_to_global *l2g);

void             l2g_init    (Local_to_global *l2g);
void             l2g_clear   (Local_to_global *l2g);
void             l2g_copy    (Local_to_global *from, Local_to_global *to);

void             l2g_append  (Local_to_global *l2g, Local_text_no lno, 
			                            Text_no       tno);
void             l2g_delete  (Local_to_global *l2g, Local_text_no lno);
Text_no          l2g_lookup  (Local_to_global *l2g, Local_text_no lno);
Local_text_no    l2g_next_key(Local_to_global *l2g, Local_text_no lno);
void             l2g_compact (Local_to_global *l2g);

/* Text file representation, e.g. for the database. */
void             l2g_dump    (Local_to_global *l2g, FILE *file);
void             l2g_read    (Local_to_global *l2g, FILE *file);
void             l2g_print   (Local_to_global *l2g, FILE *file);

#endif /* LOCAL2GLOBAL__H */