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