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