]> mj.ucw.cz Git - libucw.git/blob - lib/index.h
Added a useful macro for value clamping.
[libucw.git] / lib / index.h
1 /*
2  *      Sherlock Gatherer: Data structures used in indices
3  *
4  *      (c) 2001 Martin Mares <mj@ucw.cz>
5  */
6
7 #define CLAMP(x,min,max) ({ int _t=x; (_t < min) ? min : (_t > max) ? max : _t; })
8
9 /* Words */
10
11 #define MAX_WORD_LEN            64
12
13 /* Word types */
14
15 enum word_type {
16   WT_RESERVED,                          /* Reserved word type */
17   WT_TEXT,                              /* Ordinary text */
18   WT_EMPH,                              /* Emphasized text */
19   WT_SMALL,                             /* Small font */
20   WT_TITLE,                             /* Document title */
21   WT_SMALL_HEADING,                     /* Heading */
22   WT_BIG_HEADING,                       /* Larger heading */
23   WT_KEYWORD,                           /* Explicitly marked keyword */
24   WT_META,                              /* Various meta-information */
25   WT_ALT                                /* Alternate texts for graphical elements */
26 };
27
28 /* Index card attributes */
29
30 struct card_attr {
31   u32 card;                             /* Reference to card description (either oid or filepos) */
32   u32 site_id;
33   byte weight;
34   byte flags;
35   byte rfu[2];
36 };
37
38 enum card_flag {
39   CARD_FLAG_EMPTY = 1,                  /* Empty document (redirect, robot file etc.) [scanner] */
40   CARD_FLAG_ACCENTED = 2,               /* Document contains accented characters [scanner] */
41   CARD_FLAG_DUP = 4,                    /* Removed as a duplicate [merger] */
42   CARD_FLAG_MERGED = 8,                 /* Destination of a merge [merger] */
43 };
44
45 /* String fingerprints */
46
47 struct fingerprint {
48   byte hash[12];
49 };
50
51 void fingerprint(byte *string, struct fingerprint *fp);