2 * Copyright (c) 1993, 1994 Regents of the University of Michigan.
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.
12 * disptmpl.h: display template library defines
13 * 7 March 1994 by Mark C Smith
19 #include <ldap_cdefs.h>
23 #define LDAP_TEMPLATE_VERSION 1
26 * general types of items (confined to most significant byte)
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
36 * syntax options (confined to second most significant byte)
38 #define LDAP_SYN_OPT_DEFER 0x00010000L
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.
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 )
70 #define LDAP_GET_SYN_TYPE( syid ) ((syid) & 0xFF000000L )
71 #define LDAP_GET_SYN_OPTIONS( syid ) ((syid) & 0x00FF0000L )
75 * display options for output routines (used by entry2text and friends)
78 * use calculated label width (based on length of longest label in
79 * template) instead of contant width
81 #define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L
82 #define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L
85 * perform search actions (applies to ldap_entry2text_search only)
87 #define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L
90 * include additional info. relevant to "non leaf" entries only
91 * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
94 #define LDAP_DISP_OPT_NONLEAF 0x00000004L
98 * display template item options (may not apply to all types)
99 * if this bit is set in ti_options, it applies.
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 */
111 * display template item structure
113 struct ldap_tmplitem {
114 unsigned long ti_syntaxid;
115 unsigned long ti_options;
119 struct ldap_tmplitem *ti_next_in_row;
120 struct ldap_tmplitem *ti_next_in_col;
125 #define NULLTMPLITEM ((struct ldap_tmplitem *)0)
127 #define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \
128 ( (ti)->ti_appdata = (void *)(datap) )
130 #define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \
131 ( (type)((ti)->ti_appdata) )
133 #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \
134 ( ((ti)->ti_options & (option) ) != 0 )
138 * object class array structure
141 char **oc_objclasses;
142 struct ldap_oclist *oc_next;
145 #define NULLOCLIST ((struct ldap_oclist *)0)
151 struct ldap_adddeflist {
153 #define LDAP_ADSRC_CONSTANTVALUE 1
154 #define LDAP_ADSRC_ADDERSDN 2
157 struct ldap_adddeflist *ad_next;
160 #define NULLADLIST ((struct ldap_adddeflist *)0)
164 * display template global options
165 * if this bit is set in dt_options, it applies.
168 * users should be allowed to try to add objects of these entries
170 #define LDAP_DTMPL_OPT_ADDABLE 0x00000001L
173 * users should be allowed to do "modify RDN" operation of these entries
175 #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
178 * this template is an alternate view, not a primary view
180 #define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L
184 * display template structure
186 struct ldap_disptmpl {
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;
198 struct ldap_disptmpl *dt_next;
201 #define NULLDISPTMPL ((struct ldap_disptmpl *)0)
203 #define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \
204 ( (dt)->dt_appdata = (void *)(datap) )
206 #define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \
207 ( (type)((dt)->dt_appdata) )
209 #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \
210 ( ((dt)->dt_options & (option) ) != 0 )
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
218 * buffer size needed for entry2text and vals2text
220 #define LDAP_DTMPL_BUFSIZ 8192
223 typedef int (*writeptype) LDAP_P(( void *writeparm, char *p, int len ));
226 ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp ));
229 ldap_init_templates_buf LDAP_P(( char *buf,
231 struct ldap_disptmpl **tmpllistp ));
234 ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist ));
236 LDAP_F struct ldap_disptmpl *
237 ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist ));
239 LDAP_F struct ldap_disptmpl *
240 ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist,
241 struct ldap_disptmpl *tmpl ));
243 LDAP_F struct ldap_disptmpl *
244 ldap_name2template LDAP_P(( char *name,
245 struct ldap_disptmpl *tmpllist ));
247 LDAP_F struct ldap_disptmpl *
248 ldap_oc2template LDAP_P(( char **oclist,
249 struct ldap_disptmpl *tmpllist ));
252 ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl,
255 unsigned long syntaxmask ));
257 LDAP_F struct ldap_tmplitem *
258 ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl ));
260 LDAP_F struct ldap_tmplitem *
261 ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl,
262 struct ldap_tmplitem *row ));
264 LDAP_F struct ldap_tmplitem *
265 ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
266 struct ldap_tmplitem *row ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
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 ));
314 #endif /* _DISPTMPL_H */