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