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