1 | /* locatedb.h -- declarations for the locate database
|
---|
2 | Copyright (C) 1994 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2, or (at your option)
|
---|
7 | any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
---|
17 | USA.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef _LOCATEDB_H
|
---|
21 | #define _LOCATEDB_H 1
|
---|
22 |
|
---|
23 | /* The magic string at the start of a locate database, to make sure
|
---|
24 | it's in the right format. The 02 is the database format version number.
|
---|
25 | This string has the same format as a database entry, but you can't
|
---|
26 | concatenate databases even if you remove it, since the differential count
|
---|
27 | in the first entry of the second database will be wrong. */
|
---|
28 | #define LOCATEDB_MAGIC "\0LOCATE02"
|
---|
29 |
|
---|
30 | /* Common-prefix length differences in the ranges
|
---|
31 | 0..127, -127..-1 (0x00..0x7f, 0x81..0xff) fit into one byte.
|
---|
32 | This value (which is -128) indicates that the difference is
|
---|
33 | too large to fit into one byte, and a two-byte integer follows. */
|
---|
34 | #define LOCATEDB_ESCAPE 0x80
|
---|
35 | #define LOCATEDB_ONEBYTE_MAX (127)
|
---|
36 | #define LOCATEDB_ONEBYTE_MIN (-127)
|
---|
37 |
|
---|
38 |
|
---|
39 | /* If it is ever possible to try to encode LOCATEDB_MAGIC as a
|
---|
40 | * single-byte offset, then an unfortunate length of common prefix
|
---|
41 | * will produce a spurious escape character, desynchronising the data
|
---|
42 | * stream. We use a compile-time check in the preprocessor to prevent
|
---|
43 | * this.
|
---|
44 | */
|
---|
45 | #if LOCATEDB_ESCAPE <= LOCATEDB_ONEBYTE_MAX
|
---|
46 | #error "You have a bad combination of LOCATEDB_ESCAPE and LOCATEDB_ONEBYTE_MAX, see above"
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | /* These are used for old, bigram-encoded databases: */
|
---|
50 |
|
---|
51 | /* Means the differential count follows in a 2-byte int instead. */
|
---|
52 | #define LOCATEDB_OLD_ESCAPE 30
|
---|
53 |
|
---|
54 | /* Offset added to differential counts to encode them as positive numbers. */
|
---|
55 | #define LOCATEDB_OLD_OFFSET 14
|
---|
56 |
|
---|
57 | # ifndef PARAMS
|
---|
58 | # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
---|
59 | # define PARAMS(Args) Args
|
---|
60 | # else
|
---|
61 | # define PARAMS(Args) ()
|
---|
62 | # endif
|
---|
63 | # endif
|
---|
64 |
|
---|
65 |
|
---|
66 | #define SLOCATE_DB_MAGIC_LEN 2
|
---|
67 |
|
---|
68 | #endif /* !_LOCATEDB_H */
|
---|