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