]> git.sur5r.net Git - openldap/blob - include/disptmpl.h
Use ldap_cdefs.h more. Use bridge.h less.
[openldap] / include / disptmpl.h
1 /*
2  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of Michigan at Ann Arbor. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  * disptmpl.h:  display template library defines
13  * 7 March 1994 by Mark C Smith
14  */
15
16 #ifndef _DISPTMPL_H
17 #define _DISPTMPL_H
18
19 #include <ldap_cdefs.h>
20
21 LDAP_BEGIN_DECL
22
23 #define LDAP_TEMPLATE_VERSION   1
24
25 /*
26  * general types of items (confined to most significant byte)
27  */
28 #define LDAP_SYN_TYPE_TEXT              0x01000000L
29 #define LDAP_SYN_TYPE_IMAGE             0x02000000L
30 #define LDAP_SYN_TYPE_BOOLEAN           0x04000000L
31 #define LDAP_SYN_TYPE_BUTTON            0x08000000L
32 #define LDAP_SYN_TYPE_ACTION            0x10000000L
33
34
35 /*
36  * syntax options (confined to second most significant byte)
37  */
38 #define LDAP_SYN_OPT_DEFER              0x00010000L
39
40
41 /* 
42  * display template item syntax ids (defined by common agreement)
43  * these are the valid values for the ti_syntaxid of the tmplitem
44  * struct (defined below).  A general type is encoded in the
45  * most-significant 8 bits, and some options are encoded in the next
46  * 8 bits.  The lower 16 bits are reserved for the distinct types.
47  */
48 #define LDAP_SYN_CASEIGNORESTR  ( 1 | LDAP_SYN_TYPE_TEXT )
49 #define LDAP_SYN_MULTILINESTR   ( 2 | LDAP_SYN_TYPE_TEXT )
50 #define LDAP_SYN_DN             ( 3 | LDAP_SYN_TYPE_TEXT )
51 #define LDAP_SYN_BOOLEAN        ( 4 | LDAP_SYN_TYPE_BOOLEAN )
52 #define LDAP_SYN_JPEGIMAGE      ( 5 | LDAP_SYN_TYPE_IMAGE )
53 #define LDAP_SYN_JPEGBUTTON     ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
54 #define LDAP_SYN_FAXIMAGE       ( 7 | LDAP_SYN_TYPE_IMAGE )
55 #define LDAP_SYN_FAXBUTTON      ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
56 #define LDAP_SYN_AUDIOBUTTON    ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
57 #define LDAP_SYN_TIME           ( 10 | LDAP_SYN_TYPE_TEXT )
58 #define LDAP_SYN_DATE           ( 11 | LDAP_SYN_TYPE_TEXT )
59 #define LDAP_SYN_LABELEDURL     ( 12 | LDAP_SYN_TYPE_TEXT )
60 #define LDAP_SYN_SEARCHACTION   ( 13 | LDAP_SYN_TYPE_ACTION )
61 #define LDAP_SYN_LINKACTION     ( 14 | LDAP_SYN_TYPE_ACTION )
62 #define LDAP_SYN_ADDDNACTION    ( 15 | LDAP_SYN_TYPE_ACTION )
63 #define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION )
64 #define LDAP_SYN_RFC822ADDR     ( 17 | LDAP_SYN_TYPE_TEXT )
65
66
67 /*
68  * handy macros
69  */
70 #define LDAP_GET_SYN_TYPE( syid )       ((syid) & 0xFF000000L )
71 #define LDAP_GET_SYN_OPTIONS( syid )    ((syid) & 0x00FF0000L )
72
73
74 /*
75  * display options for output routines (used by entry2text and friends)
76  */
77 /*
78  * use calculated label width (based on length of longest label in
79  * template) instead of contant width
80  */
81 #define LDAP_DISP_OPT_AUTOLABELWIDTH    0x00000001L
82 #define LDAP_DISP_OPT_HTMLBODYONLY      0x00000002L
83
84 /*
85  * perform search actions (applies to ldap_entry2text_search only) 
86  */
87 #define LDAP_DISP_OPT_DOSEARCHACTIONS   0x00000002L
88
89 /*
90  * include additional info. relevant to "non leaf" entries only
91  * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
92  * and "Move Up" HREFs
93  */
94 #define LDAP_DISP_OPT_NONLEAF           0x00000004L
95
96
97 /*
98  * display template item options (may not apply to all types)
99  * if this bit is set in ti_options, it applies.
100  */
101 #define LDAP_DITEM_OPT_READONLY         0x00000001L
102 #define LDAP_DITEM_OPT_SORTVALUES       0x00000002L
103 #define LDAP_DITEM_OPT_SINGLEVALUED     0x00000004L
104 #define LDAP_DITEM_OPT_HIDEIFEMPTY      0x00000008L
105 #define LDAP_DITEM_OPT_VALUEREQUIRED    0x00000010L
106 #define LDAP_DITEM_OPT_HIDEIFFALSE      0x00000020L     /* booleans only */
107
108
109
110 /*
111  * display template item structure
112  */
113 struct ldap_tmplitem {
114     unsigned long               ti_syntaxid;
115     unsigned long               ti_options;
116     char                        *ti_attrname;
117     char                        *ti_label;
118     char                        **ti_args;
119     struct ldap_tmplitem        *ti_next_in_row;
120     struct ldap_tmplitem        *ti_next_in_col;
121     void                        *ti_appdata;
122 };
123
124
125 #define NULLTMPLITEM    ((struct ldap_tmplitem *)0)
126
127 #define LDAP_SET_TMPLITEM_APPDATA( ti, datap )  \
128         (ti)->ti_appdata = (void *)(datap)
129
130 #define LDAP_GET_TMPLITEM_APPDATA( ti, type )   \
131         (type)((ti)->ti_appdata)
132
133 #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option )       \
134         (((ti)->ti_options & option ) != 0 )
135
136
137 /*
138  * object class array structure
139  */
140 struct ldap_oclist {
141     char                **oc_objclasses;
142     struct ldap_oclist  *oc_next;
143 };
144
145 #define NULLOCLIST      ((struct ldap_oclist *)0)
146
147
148 /*
149  * add defaults list
150  */
151 struct ldap_adddeflist {
152     int                 ad_source;
153 #define LDAP_ADSRC_CONSTANTVALUE        1
154 #define LDAP_ADSRC_ADDERSDN             2
155     char                *ad_attrname;
156     char                *ad_value;
157     struct ldap_adddeflist      *ad_next;
158 };
159
160 #define NULLADLIST      ((struct ldap_adddeflist *)0)
161
162
163 /*
164  * display template global options
165  * if this bit is set in dt_options, it applies.
166  */
167 /*
168  * users should be allowed to try to add objects of these entries
169  */
170 #define LDAP_DTMPL_OPT_ADDABLE          0x00000001L
171
172 /*
173  * users should be allowed to do "modify RDN" operation of these entries
174  */
175 #define LDAP_DTMPL_OPT_ALLOWMODRDN      0x00000002L
176
177 /*
178  * this template is an alternate view, not a primary view
179  */
180 #define LDAP_DTMPL_OPT_ALTVIEW          0x00000004L
181
182
183 /*
184  * display template structure
185  */
186 struct ldap_disptmpl {
187     char                        *dt_name;
188     char                        *dt_pluralname;
189     char                        *dt_iconname;
190     unsigned long               dt_options;
191     char                        *dt_authattrname;
192     char                        *dt_defrdnattrname;
193     char                        *dt_defaddlocation;
194     struct ldap_oclist          *dt_oclist;
195     struct ldap_adddeflist      *dt_adddeflist;
196     struct ldap_tmplitem        *dt_items;
197     void                        *dt_appdata;
198     struct ldap_disptmpl        *dt_next;
199 };
200
201 #define NULLDISPTMPL    ((struct ldap_disptmpl *)0)
202
203 #define LDAP_SET_DISPTMPL_APPDATA( dt, datap )  \
204         (dt)->dt_appdata = (void *)(datap)
205
206 #define LDAP_GET_DISPTMPL_APPDATA( dt, type )   \
207         (type)((dt)->dt_appdata)
208
209 #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option )       \
210         (((dt)->dt_options & option ) != 0 )
211
212 #define LDAP_TMPL_ERR_VERSION   1
213 #define LDAP_TMPL_ERR_MEM       2
214 #define LDAP_TMPL_ERR_SYNTAX    3
215 #define LDAP_TMPL_ERR_FILE      4
216
217 /*
218  * buffer size needed for entry2text and vals2text
219  */
220 #define LDAP_DTMPL_BUFSIZ       8192
221
222
223 typedef int (*writeptype) LDAP_P(( void *writeparm, char *p, int len ));
224
225 LDAP_F int
226 ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp ));
227
228 LDAP_F int
229 ldap_init_templates_buf LDAP_P(( char *buf,
230         long buflen,
231         struct ldap_disptmpl **tmpllistp ));
232
233 LDAP_F void
234 ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist ));
235
236 LDAP_F struct ldap_disptmpl *
237 ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist ));
238
239 LDAP_F struct ldap_disptmpl *
240 ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist,
241         struct ldap_disptmpl *tmpl ));
242
243 LDAP_F struct ldap_disptmpl *
244 ldap_name2template LDAP_P(( char *name,
245         struct ldap_disptmpl *tmpllist ));
246
247 LDAP_F struct ldap_disptmpl *
248 ldap_oc2template LDAP_P(( char **oclist,
249         struct ldap_disptmpl *tmpllist ));
250
251 LDAP_F char **
252 ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl,
253         char **includeattrs,
254         int exclude,
255         unsigned long syntaxmask ));
256
257 LDAP_F struct ldap_tmplitem *
258 ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl ));
259
260 LDAP_F struct ldap_tmplitem *
261 ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl,
262         struct ldap_tmplitem *row ));
263
264 LDAP_F struct ldap_tmplitem *
265 ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
266         struct ldap_tmplitem *row ));
267
268 LDAP_F struct ldap_tmplitem *
269 ldap_next_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
270         struct ldap_tmplitem *row,
271         struct ldap_tmplitem *col ));
272
273 LDAP_F int
274 ldap_entry2text LDAP_P(( LDAP *ld,
275         char *buf, LDAPMessage *entry,
276         struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
277         writeptype writeproc, void *writeparm, char *eol, int rdncount,
278         unsigned long opts ));
279
280 LDAP_F int
281 ldap_vals2text LDAP_P(( LDAP *ld,
282         char *buf, char **vals, char *label, int labelwidth,
283         unsigned long syntaxid, writeptype writeproc, void *writeparm,
284         char *eol, int rdncount ));
285
286 LDAP_F int
287 ldap_entry2text_search LDAP_P(( LDAP *ld,
288         char *dn, char *base, LDAPMessage *entry,
289         struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
290         writeptype writeproc, void *writeparm, char *eol, int rdncount,
291         unsigned long opts ));
292
293 LDAP_F int
294 ldap_entry2html LDAP_P(( LDAP *ld,
295         char *buf, LDAPMessage *entry,
296         struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
297         writeptype writeproc, void *writeparm, char *eol, int rdncount,
298         unsigned long opts, char *urlprefix, char *base ));
299
300 LDAP_F int
301 ldap_vals2html LDAP_P(( LDAP *ld,
302         char *buf, char **vals, char *label, int labelwidth,
303         unsigned long syntaxid, writeptype writeproc, void *writeparm,
304         char *eol, int rdncount, char *urlprefix ));
305
306 LDAP_F int
307 ldap_entry2html_search LDAP_P(( LDAP
308         *ld, char *dn, char *base, LDAPMessage *entry,
309         struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
310         writeptype writeproc, void *writeparm, char *eol, int rdncount,
311         unsigned long opts, char *urlprefix ));
312
313 LDAP_END_DECL
314 #endif /* _DISPTMPL_H */