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