]> mj.ucw.cz Git - libucw.git/blob - lib/index.h
Defined which string classes contain URL's and which ones case insensitive
[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 /* String types */
29
30 enum string_type {
31   ST_RESERVED,                          /* Reserved string type */
32   ST_URL,                               /* URL of the document */
33   ST_HOST,                              /* Host name */
34   ST_DOMAIN,                            /* Domain name */
35   ST_REF,                               /* URL reference */
36   ST_BACKREF,                           /* Back-reference (frame or redirect source) */
37 };
38
39 #define STRING_TYPES_URL ((1 << ST_URL) | (1 << ST_REF) | (1 << ST_BACKREF))
40 #define STRING_TYPES_CASE_INSENSITIVE ((1 << ST_HOST) | (1 << ST_DOMAIN))
41
42 /* Index card attributes */
43
44 struct card_attr {
45   u32 card;                             /* Reference to card description (either oid or filepos) */
46   u32 site_id;
47   byte weight;
48   byte flags;
49   byte rfu[2];
50 };
51
52 enum card_flag {
53   CARD_FLAG_EMPTY = 1,                  /* Empty document (redirect, robot file etc.) [scanner] */
54   CARD_FLAG_ACCENTED = 2,               /* Document contains accented characters [scanner] */
55   CARD_FLAG_DUP = 4,                    /* Removed as a duplicate [merger] */
56   CARD_FLAG_MERGED = 8,                 /* Destination of a merge [merger] */
57 };
58
59 #define CARD_POS_SHIFT 5                /* Card positions are shifted this # of bytes to the right */
60
61 /* String fingerprints */
62
63 struct fingerprint {
64   byte hash[12];
65 };
66
67 void fingerprint(byte *string, struct fingerprint *fp);
68
69 /* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */
70
71 #define GET_TAGGED_CHAR(p,u) do {                               \
72   u = *p;                                                       \
73   if (u >= 0xc0)                                                \
74     GET_UTF8(p,u);                                              \
75   else if (u >= 0x80)                                           \
76     {                                                           \
77       p++;                                                      \
78       if (u >= 0xb0)                                            \
79         u += 0x80020000;                                        \
80       else if (u >= 0xa0)                                       \
81         u = 0x80010000 + ((u & 0x0f) << 6) + (*p++ & 0x3f);     \
82       else                                                      \
83         u += 0x80000000;                                        \
84     }                                                           \
85   else                                                          \
86     p++;                                                        \
87 } while (0)