2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/socket.h>
22 static void dump_tmpl ( struct ldap_disptmpl *tmpl );
23 static void dump_srchpref( struct ldap_searchobj *sp );
25 #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
28 main( int argc, char **argv )
30 struct ldap_disptmpl *templates, *dtp;
31 struct ldap_searchobj *so, *sop;
36 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
42 if (( err = ldap_init_templates( "ldaptemplates.conf", &templates ))
44 fprintf( stderr, "ldap_init_templates failed (%d)\n", err );
48 if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so ))
50 fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err );
55 printf( "*** Display Templates:\n" );
56 for ( dtp = ldap_first_disptmpl( templates ); dtp != NULLDISPTMPL;
57 dtp = ldap_next_disptmpl( templates, dtp )) {
62 printf( "\n\n*** Search Objects:\n" );
63 for ( sop = ldap_first_searchobj( so ); sop != NULLSEARCHOBJ;
64 sop = ldap_next_searchobj( so, sop )) {
70 if (( dtp = ldap_oc2template( ++argv, templates )) == NULL ) {
71 fprintf( stderr, "no matching template found\n" );
78 ldap_free_templates( templates );
79 ldap_free_searchprefs( so );
85 static char *syn_name[] = {
86 "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN",
87 "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT",
91 static char *syn_type[] = {
92 "?", "txt", "img", "?", "bool", "?", "?", "?", "btn",
93 "?", "?", "?", "?", "?", "?", "?",
97 static char *includeattrs[] = { "objectClass", "sn", NULL };
99 static char *item_opts[] = {
100 "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL
103 static unsigned long item_opt_vals[] = {
104 LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES,
105 LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY,
106 LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE,
111 dump_tmpl( struct ldap_disptmpl *tmpl )
113 struct ldap_tmplitem *rowp, *colp;
114 int i, rowcnt, colcnt;
116 struct ldap_oclist *ocp;
117 struct ldap_adddeflist *adp;
119 printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n",
120 NULLSTRINGIFNULL( tmpl->dt_name ),
121 NULLSTRINGIFNULL( tmpl->dt_pluralname ),
122 NULLSTRINGIFNULL( tmpl->dt_iconname ));
124 printf( "object class list:\n" );
125 for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = ocp->oc_next ) {
126 for ( i = 0; ocp->oc_objclasses[ i ] != NULL; ++i ) {
127 printf( "%s%s", i == 0 ? " " : " & ",
128 NULLSTRINGIFNULL( ocp->oc_objclasses[ i ] ));
134 printf( "template options: " );
135 if ( tmpl->dt_options == 0L ) {
138 printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl,
139 LDAP_DTMPL_OPT_ADDABLE ) ? "addable" : "",
140 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALLOWMODRDN )
142 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALTVIEW )
146 printf( "authenticate as attribute: %s\n", tmpl->dt_authattrname != NULL ?
147 tmpl->dt_authattrname : "<default>" );
149 printf( "default RDN attribute: %s\n", tmpl->dt_defrdnattrname != NULL ?
150 tmpl->dt_defrdnattrname : "NONE" );
152 printf( "default add location: %s\n", tmpl->dt_defaddlocation != NULL ?
153 tmpl->dt_defaddlocation : "NONE" );
155 printf( "\nnew entry value default rules:\n" );
156 for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = adp->ad_next ) {
157 if ( adp->ad_source == LDAP_ADSRC_CONSTANTVALUE ) {
158 printf( " attribute %s <-- constant value \"%s\"\n",
159 NULLSTRINGIFNULL( adp->ad_attrname),
160 NULLSTRINGIFNULL( adp->ad_value ));
162 printf( " attribute %s <-- adder's DN\n",
163 NULLSTRINGIFNULL( adp->ad_attrname ));
168 printf( "\nfetch attributes & values:\n" );
169 if (( fetchattrs = ldap_tmplattrs( tmpl, includeattrs, 1,
170 LDAP_SYN_OPT_DEFER )) == NULL ) {
171 printf( " <none>\n" );
173 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
174 printf( " %s\n", fetchattrs[ i ] );
175 free( fetchattrs[ i ] );
177 free( (char *)fetchattrs );
180 printf( "\nfetch attributes only:\n" );
181 if (( fetchattrs = ldap_tmplattrs( tmpl, NULL, 0,
182 LDAP_SYN_OPT_DEFER )) == NULL ) {
183 printf( " <none>\n" );
185 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
186 printf( " %s\n", fetchattrs[ i ] );
187 free( fetchattrs[ i ] );
189 free( (char *)fetchattrs );
192 printf( "\ntemplate items:\n" );
194 for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
195 rowp = ldap_next_tmplrow( tmpl, rowp )) {
198 for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
199 colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
201 printf( " %2d-%d: %s (%s%s", rowcnt, colcnt,
202 syn_name[ colp->ti_syntaxid & 0x0000FFFF ],
203 syn_type[ LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) >> 24 ],
204 (( LDAP_GET_SYN_OPTIONS( colp->ti_syntaxid ) &
205 LDAP_SYN_OPT_DEFER ) != 0 ) ? ",defer" : "" );
207 for ( i = 0; item_opts[ i ] != NULL; ++i ) {
208 if ( LDAP_IS_TMPLITEM_OPTION_SET( colp, item_opt_vals[ i ] )) {
209 printf( ",%s", NULLSTRINGIFNULL( item_opts[ i ] ));
213 printf( "), %s, %s", NULLSTRINGIFNULL( colp->ti_attrname ),
214 NULLSTRINGIFNULL( colp->ti_label ));
215 if ( colp->ti_args != NULL ) {
217 for ( i = 0; colp->ti_args[ i ] != NULL; ++i ) {
218 printf( "<%s>", NULLSTRINGIFNULL( colp->ti_args[ i ] ));
229 dump_srchpref( struct ldap_searchobj *so )
232 struct ldap_searchattr *sa;
233 struct ldap_searchmatch *sm;
235 printf( "Object type prompt: %s\n",
236 NULLSTRINGIFNULL( so->so_objtypeprompt ));
237 printf( "Options: %s\n",
238 LDAP_IS_SEARCHOBJ_OPTION_SET( so, LDAP_SEARCHOBJ_OPT_INTERNAL ) ?
239 "internal" : "NONE" );
240 printf( "Prompt: %s\n", NULLSTRINGIFNULL( so->so_prompt ));
242 switch ( so->so_defaultscope ) {
243 case LDAP_SCOPE_BASE:
244 printf( "LDAP_SCOPE_BASE" );
246 case LDAP_SCOPE_ONELEVEL:
247 printf( "LDAP_SCOPE_ONELEVEL" );
249 case LDAP_SCOPE_SUBTREE:
250 printf( "LDAP_SCOPE_SUBTREE" );
253 printf("*** unknown!" );
256 printf( "Filter prefix: %s\n",
257 NULLSTRINGIFNULL( so->so_filterprefix ));
258 printf( "Filter tag: %s\n",
259 NULLSTRINGIFNULL( so->so_filtertag ));
260 printf( "Default select attr: %s\n",
261 NULLSTRINGIFNULL( so->so_defaultselectattr ));
262 printf( "Default select text: %s\n",
263 NULLSTRINGIFNULL( so->so_defaultselecttext ));
264 printf( "Searchable attributes ---- \n" );
265 for ( sa = so->so_salist; sa != NULL; sa = sa->sa_next ) {
266 printf( " Label: %s\n", NULLSTRINGIFNULL( sa->sa_attrlabel ));
267 printf( " Attribute: %s\n", NULLSTRINGIFNULL( sa->sa_attr ));
268 printf( " Select attr: %s\n", NULLSTRINGIFNULL( sa->sa_selectattr ));
269 printf( " Select text: %s\n", NULLSTRINGIFNULL( sa->sa_selecttext ));
270 printf( " Match types ---- \n" );
271 for ( i = 0, sm = so->so_smlist; sm != NULL; i++, sm = sm->sm_next ) {
272 if (( sa->sa_matchtypebitmap >> i ) & 1 ) {
273 printf( " %s (%s)\n",
274 NULLSTRINGIFNULL( sm->sm_matchprompt ),
275 NULLSTRINGIFNULL( sm->sm_filter ));