Back to index

lightning-sunbird  0.9+nobinonly
disptmpl.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla Communicator client code, released
00015  * March 31, 1998.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039  * Copyright (c) 1993, 1994 Regents of the University of Michigan.
00040  * All rights reserved.
00041  *
00042  * Redistribution and use in source and binary forms are permitted
00043  * provided that this notice is preserved and that due credit is given
00044  * to the University of Michigan at Ann Arbor. The name of the University
00045  * may not be used to endorse or promote products derived from this
00046  * software without specific prior written permission. This software
00047  * is provided ``as is'' without express or implied warranty.
00048  *
00049  * disptmpl.h:  display template library defines
00050  */
00051 
00052 #ifndef _DISPTMPL_H
00053 #define _DISPTMPL_H
00054 
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058 
00059 /* calling conventions used by library */
00060 #ifndef LDAP_CALL
00061 #if defined( _WINDOWS ) || defined( _WIN32 )
00062 #define LDAP_C __cdecl
00063 #ifndef _WIN32 
00064 #define __stdcall _far _pascal
00065 #define LDAP_CALLBACK _loadds
00066 #else
00067 #define LDAP_CALLBACK
00068 #endif /* _WIN32 */
00069 #define LDAP_PASCAL __stdcall
00070 #define LDAP_CALL LDAP_PASCAL
00071 #else /* _WINDOWS */
00072 #define LDAP_C
00073 #define LDAP_CALLBACK
00074 #define LDAP_PASCAL
00075 #define LDAP_CALL
00076 #endif /* _WINDOWS */
00077 #endif /* LDAP_CALL */
00078 
00079 #define LDAP_TEMPLATE_VERSION      1
00080 
00081 /*
00082  * general types of items (confined to most significant byte)
00083  */
00084 #define LDAP_SYN_TYPE_TEXT         0x01000000L
00085 #define LDAP_SYN_TYPE_IMAGE        0x02000000L
00086 #define LDAP_SYN_TYPE_BOOLEAN             0x04000000L
00087 #define LDAP_SYN_TYPE_BUTTON              0x08000000L
00088 #define LDAP_SYN_TYPE_ACTION              0x10000000L
00089 
00090 
00091 /*
00092  * syntax options (confined to second most significant byte)
00093  */
00094 #define LDAP_SYN_OPT_DEFER         0x00010000L
00095 
00096 
00097 /* 
00098  * display template item syntax ids (defined by common agreement)
00099  * these are the valid values for the ti_syntaxid of the tmplitem
00100  * struct (defined below).  A general type is encoded in the
00101  * most-significant 8 bits, and some options are encoded in the next
00102  * 8 bits.  The lower 16 bits are reserved for the distinct types.
00103  */
00104 #define LDAP_SYN_CASEIGNORESTR     ( 1 | LDAP_SYN_TYPE_TEXT )
00105 #define LDAP_SYN_MULTILINESTR      ( 2 | LDAP_SYN_TYPE_TEXT )
00106 #define LDAP_SYN_DN         ( 3 | LDAP_SYN_TYPE_TEXT )
00107 #define LDAP_SYN_BOOLEAN    ( 4 | LDAP_SYN_TYPE_BOOLEAN )
00108 #define LDAP_SYN_JPEGIMAGE  ( 5 | LDAP_SYN_TYPE_IMAGE )
00109 #define LDAP_SYN_JPEGBUTTON ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
00110 #define LDAP_SYN_FAXIMAGE   ( 7 | LDAP_SYN_TYPE_IMAGE )
00111 #define LDAP_SYN_FAXBUTTON  ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
00112 #define LDAP_SYN_AUDIOBUTTON       ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
00113 #define LDAP_SYN_TIME              ( 10 | LDAP_SYN_TYPE_TEXT )
00114 #define LDAP_SYN_DATE              ( 11 | LDAP_SYN_TYPE_TEXT )
00115 #define LDAP_SYN_LABELEDURL ( 12 | LDAP_SYN_TYPE_TEXT )
00116 #define LDAP_SYN_SEARCHACTION      ( 13 | LDAP_SYN_TYPE_ACTION )
00117 #define LDAP_SYN_LINKACTION ( 14 | LDAP_SYN_TYPE_ACTION )
00118 #define LDAP_SYN_ADDDNACTION       ( 15 | LDAP_SYN_TYPE_ACTION )
00119 #define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION )
00120 #define LDAP_SYN_RFC822ADDR ( 17 | LDAP_SYN_TYPE_TEXT )
00121 
00122 
00123 /*
00124  * handy macros
00125  */
00126 #define LDAP_GET_SYN_TYPE( syid )  ((syid) & 0xFF000000UL )
00127 #define LDAP_GET_SYN_OPTIONS( syid )      ((syid) & 0x00FF0000UL )
00128 
00129 
00130 /*
00131  * display options for output routines (used by entry2text and friends)
00132  */
00133 /*
00134  * use calculated label width (based on length of longest label in
00135  * template) instead of contant width
00136  */
00137 #define LDAP_DISP_OPT_AUTOLABELWIDTH      0x00000001L
00138 #define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L
00139 
00140 /*
00141  * perform search actions (applies to ldap_entry2text_search only) 
00142  */
00143 #define LDAP_DISP_OPT_DOSEARCHACTIONS     0x00000002L
00144 
00145 /*
00146  * include additional info. relevant to "non leaf" entries only
00147  * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
00148  * and "Move Up" HREFs
00149  */
00150 #define LDAP_DISP_OPT_NONLEAF             0x00000004L
00151 
00152 
00153 /*
00154  * display template item options (may not apply to all types)
00155  * if this bit is set in ti_options, it applies.
00156  */
00157 #define LDAP_DITEM_OPT_READONLY           0x00000001L
00158 #define LDAP_DITEM_OPT_SORTVALUES  0x00000002L
00159 #define LDAP_DITEM_OPT_SINGLEVALUED       0x00000004L
00160 #define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L
00161 #define LDAP_DITEM_OPT_VALUEREQUIRED      0x00000010L
00162 #define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L   /* booleans only */
00163 
00164 
00165 
00166 /*
00167  * display template item structure
00168  */
00169 struct ldap_tmplitem {
00170     unsigned long           ti_syntaxid;
00171     unsigned long           ti_options;
00172     char                    *ti_attrname;
00173     char                    *ti_label;
00174     char                    **ti_args;
00175     struct ldap_tmplitem    *ti_next_in_row;
00176     struct ldap_tmplitem    *ti_next_in_col;
00177     void                    *ti_appdata;
00178 };
00179 
00180 
00181 #define NULLTMPLITEM ((struct ldap_tmplitem *)0)
00182 
00183 #define LDAP_SET_TMPLITEM_APPDATA( ti, datap )   \
00184        (ti)->ti_appdata = (void *)(datap)
00185 
00186 #define LDAP_GET_TMPLITEM_APPDATA( ti, type )    \
00187        (type)((ti)->ti_appdata)
00188 
00189 #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option )       \
00190        (((ti)->ti_options & option ) != 0 )
00191 
00192 
00193 /*
00194  * object class array structure
00195  */
00196 struct ldap_oclist {
00197     char             **oc_objclasses;
00198     struct ldap_oclist      *oc_next;
00199 };
00200 
00201 #define NULLOCLIST   ((struct ldap_oclist *)0)
00202 
00203 
00204 /*
00205  * add defaults list
00206  */
00207 struct ldap_adddeflist {
00208     int                     ad_source;
00209 #define LDAP_ADSRC_CONSTANTVALUE   1
00210 #define LDAP_ADSRC_ADDERSDN        2
00211     char             *ad_attrname;
00212     char             *ad_value;
00213     struct ldap_adddeflist  *ad_next;
00214 };
00215 
00216 #define NULLADLIST   ((struct ldap_adddeflist *)0)
00217 
00218 
00219 /*
00220  * display template global options
00221  * if this bit is set in dt_options, it applies.
00222  */
00223 /*
00224  * users should be allowed to try to add objects of these entries
00225  */
00226 #define LDAP_DTMPL_OPT_ADDABLE            0x00000001L
00227 
00228 /*
00229  * users should be allowed to do "modify RDN" operation of these entries
00230  */
00231 #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
00232 
00233 /*
00234  * this template is an alternate view, not a primary view
00235  */
00236 #define LDAP_DTMPL_OPT_ALTVIEW            0x00000004L
00237 
00238 
00239 /*
00240  * display template structure
00241  */
00242 struct ldap_disptmpl {
00243     char                    *dt_name;
00244     char                    *dt_pluralname;
00245     char                    *dt_iconname;
00246     unsigned long           dt_options;
00247     char                    *dt_authattrname;
00248     char                    *dt_defrdnattrname;
00249     char                    *dt_defaddlocation;
00250     struct ldap_oclist             *dt_oclist;
00251     struct ldap_adddeflist  *dt_adddeflist;
00252     struct ldap_tmplitem    *dt_items;
00253     void                    *dt_appdata;
00254     struct ldap_disptmpl    *dt_next;
00255 };
00256 
00257 #define NULLDISPTMPL ((struct ldap_disptmpl *)0)
00258 
00259 #define LDAP_SET_DISPTMPL_APPDATA( dt, datap )   \
00260        (dt)->dt_appdata = (void *)(datap)
00261 
00262 #define LDAP_GET_DISPTMPL_APPDATA( dt, type )    \
00263        (type)((dt)->dt_appdata)
00264 
00265 #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option )       \
00266        (((dt)->dt_options & option ) != 0 )
00267 
00268 #define LDAP_TMPL_ERR_VERSION      1
00269 #define LDAP_TMPL_ERR_MEM   2
00270 #define LDAP_TMPL_ERR_SYNTAX       3
00271 #define LDAP_TMPL_ERR_FILE  4
00272 
00273 /*
00274  * buffer size needed for entry2text and vals2text
00275  */
00276 #define LDAP_DTMPL_BUFSIZ   8192
00277 
00278 typedef int (*writeptype)( void *writeparm, char *p, int len );
00279 
00280 LDAP_API(int)
00281 LDAP_CALL
00282 ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
00283 
00284 LDAP_API(int)
00285 LDAP_CALL
00286 ldap_init_templates_buf( char *buf, long buflen,
00287        struct ldap_disptmpl **tmpllistp );
00288 
00289 LDAP_API(void)
00290 LDAP_CALL
00291 ldap_free_templates( struct ldap_disptmpl *tmpllist );
00292 
00293 LDAP_API(struct ldap_disptmpl *)
00294 LDAP_CALL
00295 ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
00296 
00297 LDAP_API(struct ldap_disptmpl *)
00298 LDAP_CALL
00299 ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
00300        struct ldap_disptmpl *tmpl );
00301 
00302 LDAP_API(struct ldap_disptmpl *)
00303 LDAP_CALL
00304 ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
00305 
00306 LDAP_API(struct ldap_disptmpl *)
00307 LDAP_CALL
00308 ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
00309 
00310 LDAP_API(char **)
00311 LDAP_CALL
00312 ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
00313         unsigned long syntaxmask );
00314 
00315 LDAP_API(struct ldap_tmplitem *)
00316 LDAP_CALL
00317 ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
00318 
00319 LDAP_API(struct ldap_tmplitem *)
00320 LDAP_CALL
00321 ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
00322 
00323 LDAP_API(struct ldap_tmplitem *)
00324 LDAP_CALL
00325 ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
00326 
00327 LDAP_API(struct ldap_tmplitem *)
00328 LDAP_CALL
00329 ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
00330        struct ldap_tmplitem *col );
00331 
00332 LDAP_API(int)
00333 LDAP_CALL
00334 ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
00335        struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
00336        writeptype writeproc, void *writeparm, char *eol, int rdncount,
00337        unsigned long opts );
00338 
00339 LDAP_API(int)
00340 LDAP_CALL
00341 ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
00342        unsigned long syntaxid, writeptype writeproc, void *writeparm,
00343        char *eol, int rdncount );
00344 
00345 LDAP_API(int)
00346 LDAP_CALL
00347 ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
00348        struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
00349        writeptype writeproc, void *writeparm, char *eol, int rdncount,
00350        unsigned long opts );
00351 
00352 LDAP_API(int)
00353 LDAP_CALL
00354 ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
00355        struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
00356        writeptype writeproc, void *writeparm, char *eol, int rdncount,
00357        unsigned long opts, char *urlprefix, char *base );
00358 
00359 LDAP_API(int)
00360 LDAP_CALL
00361 ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
00362        unsigned long syntaxid, writeptype writeproc, void *writeparm,
00363        char *eol, int rdncount, char *urlprefix );
00364 
00365 LDAP_API(int)
00366 LDAP_CALL
00367 ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
00368        struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
00369        writeptype writeproc, void *writeparm, char *eol, int rdncount,
00370        unsigned long opts, char *urlprefix );
00371 
00372 LDAP_API(char *)
00373 LDAP_CALL
00374 ldap_tmplerr2string( int err );
00375 
00376 #ifdef __cplusplus
00377 }
00378 #endif
00379 #endif /* _DISPTMPL_H */