]> mj.ucw.cz Git - libucw.git/blob - lib/custom.h
Replaced enums by #define's in definitions of word, meta and string types.
[libucw.git] / lib / custom.h
1 /*
2  *      Sherlock: Custom Parts of Configuration
3  *
4  *      (c) 2001--2003 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 /* Word types (at most 7 of them + WT_RESERVED and WT_MAX) */
11
12 #define WT_RESERVED             0       /* Reserved word type */
13 #define WT_TEXT                 1       /* Ordinary text */
14 #define WT_EMPH                 2       /* Emphasized text */
15 #define WT_SMALL                3       /* Small font */
16 #define WT_SMALL_HEADING        4       /* Heading */
17 #define WT_BIG_HEADING          5       /* Larger heading */
18 #define WT_ALT                  6       /* Alternate texts for graphical elements */
19 #define WT_LINK                 7       /* Link text */
20 #define WT_MAX                  8
21
22 /* Descriptive names used for user output */
23 #define WORD_TYPE_USER_NAMES                                                    \
24    "reserved", "text", "emph", "small", "hdr1", "hdr2", "alt", "link"
25
26 /* Keywords for word type names */
27 #define WORD_TYPE_NAMES                         \
28         T(WORD, ~(1 << WT_LINK))                \
29         T(TEXT, 1 << WT_TEXT)                   \
30         T(EMPH, 1 << WT_EMPH)                   \
31         T(SMALL, 1 << WT_SMALL)                 \
32         T(HDR, (1 << WT_SMALL_HEADING) | (1 << WT_BIG_HEADING))  \
33         T(HDR1, 1 << WT_SMALL_HEADING)          \
34         T(HDR2, 1 << WT_BIG_HEADING)            \
35         T(ALT, 1 << WT_ALT)                     \
36         T(LINK, 1 << WT_LINK)
37
38 /* These types are always matched without accents if accent mode is set to "auto" */
39 #define WORD_TYPES_NO_AUTO_ACCENT 0
40
41 /* These types belong to all languages */
42 #define WORD_TYPES_ALL_LANGS (1 << WT_LINK)
43
44 /* Meta information types (at most 16 of them + MT_MAX) */
45
46 #define MT_TITLE                0       /* Document title */
47 #define MT_KEYWORD              1       /* Keyword from the document */
48 #define MT_MISC                 2       /* Unclassified metas */
49 #define MT_MAX                  3
50
51 #define META_TYPE_USER_NAMES                    \
52    "title", "keywd", "misc"
53
54 /* Keywords for meta type names */
55 #define META_TYPE_NAMES                         \
56         T(TITLE, 1 << MT_TITLE)                 \
57         T(KEYWD, 1 << MT_KEYWORD)               \
58         T(META, 1 << MT_MISC)
59
60 #define META_TYPES_NO_AUTO_ACCENT 0
61 #define META_TYPES_ALL_LANGS 0
62
63 /* String types */
64
65 #define ST_RESERVED             0       /* Reserved string type */
66 #define ST_URL                  1       /* URL of the document */
67 #define ST_HOST                 2       /* Host name */
68 #define ST_DOMAIN               3       /* Domain name */
69 #define ST_REF                  4       /* URL reference */
70 #define ST_MAX                  5
71
72 #define STRING_TYPE_USER_NAMES                                                  \
73    "URL", "host", "domain", "ref", "type4", "type5", "type6", "type7",  \
74    "type8", "type9", "type10", "type11", "type12", "type13", "type14", "type15"
75
76 #define STRING_TYPE_NAMES                       \
77         T(URL, 1 << ST_URL)                     \
78         T(HOST, 1 << ST_HOST)                   \
79         T(DOMAIN, 1 << ST_DOMAIN)               \
80         T(REF, 1 << ST_REF)
81
82 #define STRING_TYPES_URL ((1 << ST_URL) | (1 << ST_REF))
83 /* These must be indexed in lowercase form */
84 #define STRING_TYPES_CASE_INSENSITIVE ((1 << ST_HOST) | (1 << ST_DOMAIN))
85
86 /*
87  *  Definitions of custom attributes:
88  *
89  *  First of all, you need to define your own card_attr fields which will
90  *  contain your attributes: CUSTOM_CARD_ATTRS lists them.
91  *  Please order the attributes by decreasing size to get optimum padding.
92  *
93  *  Then define custom_create_attrs() which will get the object description
94  *  and set your card_attr fields accordingly.
95  *
96  *  Finally, you have to define CUSTOM_ATTRS with matching rules:
97  *
98  *  INT_ATTR(id, keyword, get_func, parse_func) -- unsigned integer attribute
99  *
100  *  id          C identifier of the attribute
101  *  keywd       search server keyword for the attribute
102  *  int get_func(struct card_attr *ca)
103  *              get attribute value from the card_attr
104  *  byte *parse_func(u32 *dest, byte *value, uns intval)
105  *              parse value in query (returns error message or NULL)
106  *              for KEYWD = "string", it gets value="string", intval=0
107  *              for KEYWD = num, it gets value=NULL, intval=num.
108  *
109  *  SMALL_SET_ATTR(id, keyword, get_func, parse_func)
110  *    -- integers 0..31 with set matching
111  *
112  *  A good place for definitions of the functions is lib/custom.c.
113  */
114
115 struct card_attr;
116 struct odes;
117
118 /* No custom attributes defined yet */
119
120 #define CUSTOM_CARD_ATTRS
121 #define CUSTOM_ATTRS
122 static inline void custom_create_attrs(struct odes *odes UNUSED, struct card_attr *ca UNUSED) { }