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