14 void dump_tmpl( struct ldap_disptmpl *tmpl );
15 void dump_srchpref( struct ldap_searchobj *sp );
16 #else /* NEEDPROTOS */
19 #endif /* NEEDPROTOS */
22 #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
26 main( int argc, char **argv )
28 struct ldap_disptmpl *templates, *dtp;
29 struct ldap_searchobj *so, *sop;
34 for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
40 if (( err = ldap_init_templates( "ldaptemplates.conf", &templates ))
42 fprintf( stderr, "ldap_init_templates failed (%d)\n", err );
46 if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so ))
48 fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err );
53 printf( "*** Display Templates:\n" );
54 for ( dtp = ldap_first_disptmpl( templates ); dtp != NULLDISPTMPL;
55 dtp = ldap_next_disptmpl( templates, dtp )) {
60 printf( "\n\n*** Search Objects:\n" );
61 for ( sop = ldap_first_searchobj( so ); sop != NULLSEARCHOBJ;
62 sop = ldap_next_searchobj( so, sop )) {
68 if (( dtp = ldap_oc2template( ++argv, templates )) == NULL ) {
69 fprintf( stderr, "no matching template found\n" );
76 ldap_free_templates( templates );
77 ldap_free_searchprefs( so );
83 static char *syn_name[] = {
84 "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN",
85 "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT",
89 static char *syn_type[] = {
90 "?", "txt", "img", "?", "bool", "?", "?", "?", "btn",
91 "?", "?", "?", "?", "?", "?", "?",
95 static char *includeattrs[] = { "objectClass", "sn", NULL };
97 static char *item_opts[] = {
98 "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL
101 static unsigned long item_opt_vals[] = {
102 LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES,
103 LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY,
104 LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE,
109 dump_tmpl( struct ldap_disptmpl *tmpl )
111 struct ldap_tmplitem *rowp, *colp;
112 int i, rowcnt, colcnt;
114 struct ldap_oclist *ocp;
115 struct ldap_adddeflist *adp;
117 printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n",
118 NULLSTRINGIFNULL( tmpl->dt_name ),
119 NULLSTRINGIFNULL( tmpl->dt_pluralname ),
120 NULLSTRINGIFNULL( tmpl->dt_iconname ));
122 printf( "object class list:\n" );
123 for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = ocp->oc_next ) {
124 for ( i = 0; ocp->oc_objclasses[ i ] != NULL; ++i ) {
125 printf( "%s%s", i == 0 ? " " : " & ",
126 NULLSTRINGIFNULL( ocp->oc_objclasses[ i ] ));
132 printf( "template options: " );
133 if ( tmpl->dt_options == 0L ) {
136 printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl,
137 LDAP_DTMPL_OPT_ADDABLE ) ? "addable" : "",
138 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALLOWMODRDN )
140 LDAP_IS_DISPTMPL_OPTION_SET( tmpl, LDAP_DTMPL_OPT_ALTVIEW )
144 printf( "authenticate as attribute: %s\n", tmpl->dt_authattrname != NULL ?
145 tmpl->dt_authattrname : "<default>" );
147 printf( "default RDN attribute: %s\n", tmpl->dt_defrdnattrname != NULL ?
148 tmpl->dt_defrdnattrname : "NONE" );
150 printf( "default add location: %s\n", tmpl->dt_defaddlocation != NULL ?
151 tmpl->dt_defaddlocation : "NONE" );
153 printf( "\nnew entry value default rules:\n" );
154 for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = adp->ad_next ) {
155 if ( adp->ad_source == LDAP_ADSRC_CONSTANTVALUE ) {
156 printf( " attribute %s <-- constant value \"%s\"\n",
157 NULLSTRINGIFNULL( adp->ad_attrname),
158 NULLSTRINGIFNULL( adp->ad_value ));
160 printf( " attribute %s <-- adder's DN\n",
161 NULLSTRINGIFNULL( adp->ad_attrname ));
166 printf( "\nfetch attributes & values:\n" );
167 if (( fetchattrs = ldap_tmplattrs( tmpl, includeattrs, 1,
168 LDAP_SYN_OPT_DEFER )) == NULL ) {
169 printf( " <none>\n" );
171 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
172 printf( " %s\n", fetchattrs[ i ] );
173 free( fetchattrs[ i ] );
175 free( (char *)fetchattrs );
178 printf( "\nfetch attributes only:\n" );
179 if (( fetchattrs = ldap_tmplattrs( tmpl, NULL, 0,
180 LDAP_SYN_OPT_DEFER )) == NULL ) {
181 printf( " <none>\n" );
183 for ( i = 0; fetchattrs[ i ] != NULL; ++i ) {
184 printf( " %s\n", fetchattrs[ i ] );
185 free( fetchattrs[ i ] );
187 free( (char *)fetchattrs );
190 printf( "\ntemplate items:\n" );
192 for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
193 rowp = ldap_next_tmplrow( tmpl, rowp )) {
196 for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
197 colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
199 printf( " %2d-%d: %s (%s%s", rowcnt, colcnt,
200 syn_name[ colp->ti_syntaxid & 0x0000FFFF ],
201 syn_type[ LDAP_GET_SYN_TYPE( colp->ti_syntaxid ) >> 24 ],
202 (( LDAP_GET_SYN_OPTIONS( colp->ti_syntaxid ) &
203 LDAP_SYN_OPT_DEFER ) != 0 ) ? ",defer" : "" );
205 for ( i = 0; item_opts[ i ] != NULL; ++i ) {
206 if ( LDAP_IS_TMPLITEM_OPTION_SET( colp, item_opt_vals[ i ] )) {
207 printf( ",%s", NULLSTRINGIFNULL( item_opts[ i ] ));
211 printf( "), %s, %s", NULLSTRINGIFNULL( colp->ti_attrname ),
212 NULLSTRINGIFNULL( colp->ti_label ));
213 if ( colp->ti_args != NULL ) {
215 for ( i = 0; colp->ti_args[ i ] != NULL; ++i ) {
216 printf( "<%s>", NULLSTRINGIFNULL( colp->ti_args[ i ] ));
227 dump_srchpref( struct ldap_searchobj *so )
230 struct ldap_searchattr *sa;
231 struct ldap_searchmatch *sm;
233 printf( "Object type prompt: %s\n",
234 NULLSTRINGIFNULL( so->so_objtypeprompt ));
235 printf( "Options: %s\n",
236 LDAP_IS_SEARCHOBJ_OPTION_SET( so, LDAP_SEARCHOBJ_OPT_INTERNAL ) ?
237 "internal" : "NONE" );
238 printf( "Prompt: %s\n", NULLSTRINGIFNULL( so->so_prompt ));
240 switch ( so->so_defaultscope ) {
241 case LDAP_SCOPE_BASE:
242 printf( "LDAP_SCOPE_BASE" );
244 case LDAP_SCOPE_ONELEVEL:
245 printf( "LDAP_SCOPE_ONELEVEL" );
247 case LDAP_SCOPE_SUBTREE:
248 printf( "LDAP_SCOPE_SUBTREE" );
251 printf("*** unknown!" );
254 printf( "Filter prefix: %s\n",
255 NULLSTRINGIFNULL( so->so_filterprefix ));
256 printf( "Filter tag: %s\n",
257 NULLSTRINGIFNULL( so->so_filtertag ));
258 printf( "Default select attr: %s\n",
259 NULLSTRINGIFNULL( so->so_defaultselectattr ));
260 printf( "Default select text: %s\n",
261 NULLSTRINGIFNULL( so->so_defaultselecttext ));
262 printf( "Searchable attributes ---- \n" );
263 for ( sa = so->so_salist; sa != NULL; sa = sa->sa_next ) {
264 printf( " Label: %s\n", NULLSTRINGIFNULL( sa->sa_attrlabel ));
265 printf( " Attribute: %s\n", NULLSTRINGIFNULL( sa->sa_attr ));
266 printf( " Select attr: %s\n", NULLSTRINGIFNULL( sa->sa_selectattr ));
267 printf( " Select text: %s\n", NULLSTRINGIFNULL( sa->sa_selecttext ));
268 printf( " Match types ---- \n" );
269 for ( i = 0, sm = so->so_smlist; sm != NULL; i++, sm = sm->sm_next ) {
270 if (( sa->sa_matchtypebitmap >> i ) & 1 ) {
271 printf( " %s (%s)\n",
272 NULLSTRINGIFNULL( sm->sm_matchprompt ),
273 NULLSTRINGIFNULL( sm->sm_filter ));