18 static void dump_tmpl ( struct ldap_disptmpl *tmpl );
19 static void dump_srchpref( struct ldap_searchobj *sp );
21 #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
24 main( int argc, char **argv )
26 struct ldap_disptmpl *templates, *dtp;
27 struct ldap_searchobj *so, *sop;
32 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
38 if (( err = ldap_init_templates( "ldaptemplates.conf", &templates ))
40 fprintf( stderr, "ldap_init_templates failed (%d)\n", err );
44 if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so ))
46 fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err );
51 printf( "*** Display Templates:\n" );
52 for ( dtp = ldap_first_disptmpl( templates ); dtp != NULLDISPTMPL;
53 dtp = ldap_next_disptmpl( templates, dtp )) {
58 printf( "\n\n*** Search Objects:\n" );
59 for ( sop = ldap_first_searchobj( so ); sop != NULLSEARCHOBJ;
60 sop = ldap_next_searchobj( so, sop )) {
66 if (( dtp = ldap_oc2template( ++argv, templates )) == NULL ) {
67 fprintf( stderr, "no matching template found\n" );
74 ldap_free_templates( templates );
75 ldap_free_searchprefs( so );
81 static char *syn_name[] = {
82 "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN",
83 "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT",
87 static char *syn_type[] = {
88 "?", "txt", "img", "?", "bool", "?", "?", "?", "btn",
89 "?", "?", "?", "?", "?", "?", "?",
93 static char *includeattrs[] = { "objectClass", "sn", NULL };
95 static char *item_opts[] = {
96 "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL
99 static unsigned long item_opt_vals[] = {
100 LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES,
101 LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY,
102 LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE,
107 dump_tmpl( struct ldap_disptmpl *tmpl )
109 struct ldap_tmplitem *rowp, *colp;
110 int i, rowcnt, colcnt;
112 struct ldap_oclist *ocp;
113 struct ldap_adddeflist *adp;
115 printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n",
116 NULLSTRINGIFNULL( tmpl->dt_name ),
117 NULLSTRINGIFNULL( tmpl->dt_pluralname ),
118 NULLSTRINGIFNULL( tmpl->dt_iconname ));
120 printf( "object class list:\n" );
121 for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = ocp->oc_next ) {
122 for ( i = 0; ocp->oc_objclasses[ i ] != NULL; ++i ) {
123 printf( "%s%s", i == 0 ? " " : " & ",
124 NULLSTRINGIFNULL( ocp->oc_objclasses[ i ] ));
130 printf( "template options: " );
131 if ( tmpl->dt_options == 0L ) {
134 printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl,
135 LDAP_DTMPL_OPT_ADDABLE ) ? "addable" : "",
136 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALLOWMODRDN )
138 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALTVIEW )
142 printf( "authenticate as attribute: %s\n", tmpl->dt_authattrname != NULL ?
143 tmpl->dt_authattrname : "<default>" );
145 printf( "default RDN attribute: %s\n", tmpl->dt_defrdnattrname != NULL ?
146 tmpl->dt_defrdnattrname : "NONE" );
148 printf( "default add location: %s\n", tmpl->dt_defaddlocation != NULL ?
149 tmpl->dt_defaddlocation : "NONE" );
151 printf( "\nnew entry value default rules:\n" );
152 for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = adp->ad_next ) {
153 if ( adp->ad_source == LDAP_ADSRC_CONSTANTVALUE ) {
154 printf( " attribute %s <-- constant value \"%s\"\n",
155 NULLSTRINGIFNULL( adp->ad_attrname),
156 NULLSTRINGIFNULL( adp->ad_value ));
158 printf( " attribute %s <-- adder's DN\n",
159 NULLSTRINGIFNULL( adp->ad_attrname ));
164 printf( "\nfetch attributes & values:\n" );
165 if (( fetchattrs = ldap_tmplattrs( tmpl, includeattrs, 1,
166 LDAP_SYN_OPT_DEFER )) == NULL ) {
167 printf( " <none>\n" );
169 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
170 printf( " %s\n", fetchattrs[ i ] );
171 free( fetchattrs[ i ] );
173 free( (char *)fetchattrs );
176 printf( "\nfetch attributes only:\n" );
177 if (( fetchattrs = ldap_tmplattrs( tmpl, NULL, 0,
178 LDAP_SYN_OPT_DEFER )) == NULL ) {
179 printf( " <none>\n" );
181 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
182 printf( " %s\n", fetchattrs[ i ] );
183 free( fetchattrs[ i ] );
185 free( (char *)fetchattrs );
188 printf( "\ntemplate items:\n" );
190 for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
191 rowp = ldap_next_tmplrow( tmpl, rowp )) {
194 for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
195 colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
197 printf( " %2d-%d: %s (%s%s", rowcnt, colcnt,
198 syn_name[ colp->ti_syntaxid & 0x0000FFFF ],
199 syn_type[ LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) >> 24 ],
200 (( LDAP_GET_SYN_OPTIONS( colp->ti_syntaxid ) &
201 LDAP_SYN_OPT_DEFER ) != 0 ) ? ",defer" : "" );
203 for ( i = 0; item_opts[ i ] != NULL; ++i ) {
204 if ( LDAP_IS_TMPLITEM_OPTION_SET( colp, item_opt_vals[ i ] )) {
205 printf( ",%s", NULLSTRINGIFNULL( item_opts[ i ] ));
209 printf( "), %s, %s", NULLSTRINGIFNULL( colp->ti_attrname ),
210 NULLSTRINGIFNULL( colp->ti_label ));
211 if ( colp->ti_args != NULL ) {
213 for ( i = 0; colp->ti_args[ i ] != NULL; ++i ) {
214 printf( "<%s>", NULLSTRINGIFNULL( colp->ti_args[ i ] ));
225 dump_srchpref( struct ldap_searchobj *so )
228 struct ldap_searchattr *sa;
229 struct ldap_searchmatch *sm;
231 printf( "Object type prompt: %s\n",
232 NULLSTRINGIFNULL( so->so_objtypeprompt ));
233 printf( "Options: %s\n",
234 LDAP_IS_SEARCHOBJ_OPTION_SET( so, LDAP_SEARCHOBJ_OPT_INTERNAL ) ?
235 "internal" : "NONE" );
236 printf( "Prompt: %s\n", NULLSTRINGIFNULL( so->so_prompt ));
238 switch ( so->so_defaultscope ) {
239 case LDAP_SCOPE_BASE:
240 printf( "LDAP_SCOPE_BASE" );
242 case LDAP_SCOPE_ONELEVEL:
243 printf( "LDAP_SCOPE_ONELEVEL" );
245 case LDAP_SCOPE_SUBTREE:
246 printf( "LDAP_SCOPE_SUBTREE" );
249 printf("*** unknown!" );
252 printf( "Filter prefix: %s\n",
253 NULLSTRINGIFNULL( so->so_filterprefix ));
254 printf( "Filter tag: %s\n",
255 NULLSTRINGIFNULL( so->so_filtertag ));
256 printf( "Default select attr: %s\n",
257 NULLSTRINGIFNULL( so->so_defaultselectattr ));
258 printf( "Default select text: %s\n",
259 NULLSTRINGIFNULL( so->so_defaultselecttext ));
260 printf( "Searchable attributes ---- \n" );
261 for ( sa = so->so_salist; sa != NULL; sa = sa->sa_next ) {
262 printf( " Label: %s\n", NULLSTRINGIFNULL( sa->sa_attrlabel ));
263 printf( " Attribute: %s\n", NULLSTRINGIFNULL( sa->sa_attr ));
264 printf( " Select attr: %s\n", NULLSTRINGIFNULL( sa->sa_selectattr ));
265 printf( " Select text: %s\n", NULLSTRINGIFNULL( sa->sa_selecttext ));
266 printf( " Match types ---- \n" );
267 for ( i = 0, sm = so->so_smlist; sm != NULL; i++, sm = sm->sm_next ) {
268 if (( sa->sa_matchtypebitmap >> i ) & 1 ) {
269 printf( " %s (%s)\n",
270 NULLSTRINGIFNULL( sm->sm_matchprompt ),
271 NULLSTRINGIFNULL( sm->sm_filter ));