3 * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
4 * Use is subject to license terms.
7 #pragma ident "%Z%%M% %I% %E% SMI"
21 void dump_tmpl( struct ldap_disptmpl
*tmpl
);
22 void dump_srchpref( struct ldap_searchobj
*sp
);
23 #else /* NEEDPROTOS */
26 #endif /* NEEDPROTOS */
29 #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
33 main( int argc
, char **argv
)
35 struct ldap_disptmpl
*templates
, *dtp
;
36 struct ldap_searchobj
*so
, *sop
;
41 for ( argc
= 0; argv
[ argc
] != NULL
; ++argc
) {
47 if (( err
= ldap_init_templates( "ldaptemplates.conf", &templates
))
49 fprintf( stderr
, "ldap_init_templates failed (%d)\n", err
);
53 if (( err
= ldap_init_searchprefs( "ldapsearchprefs.conf", &so
))
55 fprintf( stderr
, "ldap_init_searchprefs failed (%d)\n", err
);
60 printf( "*** Display Templates:\n" );
61 for ( dtp
= ldap_first_disptmpl( templates
); dtp
!= NULLDISPTMPL
;
62 dtp
= ldap_next_disptmpl( templates
, dtp
)) {
67 printf( "\n\n*** Search Objects:\n" );
68 for ( sop
= ldap_first_searchobj( so
); sop
!= NULLSEARCHOBJ
;
69 sop
= ldap_next_searchobj( so
, sop
)) {
75 if (( dtp
= ldap_oc2template( ++argv
, templates
)) == NULL
) {
76 fprintf( stderr
, "no matching template found\n" );
83 ldap_free_templates( templates
);
84 ldap_free_searchprefs( so
);
90 static char *syn_name
[] = {
91 "?", "CIS", "MLS", "DN", "BOOL", "JPEG", "JPEGBTN", "FAX", "FAXBTN",
92 "AUDIOBTN", "TIME", "DATE", "URL", "SEARCHACT", "LINKACT", "ADDDNACT",
96 static char *syn_type
[] = {
97 "?", "txt", "img", "?", "bool", "?", "?", "?", "btn",
98 "?", "?", "?", "?", "?", "?", "?",
102 static char *includeattrs
[] = { "objectClass", "sn", NULL
};
104 static char *item_opts
[] = {
105 "ro", "sort", "1val", "hide", "required", "hideiffalse", NULL
108 static unsigned long item_opt_vals
[] = {
109 LDAP_DITEM_OPT_READONLY
, LDAP_DITEM_OPT_SORTVALUES
,
110 LDAP_DITEM_OPT_SINGLEVALUED
, LDAP_DITEM_OPT_HIDEIFEMPTY
,
111 LDAP_DITEM_OPT_VALUEREQUIRED
, LDAP_DITEM_OPT_HIDEIFFALSE
,
116 dump_tmpl( struct ldap_disptmpl
*tmpl
)
118 struct ldap_tmplitem
*rowp
, *colp
;
119 int i
, rowcnt
, colcnt
;
121 struct ldap_oclist
*ocp
;
122 struct ldap_adddeflist
*adp
;
124 printf( "** Template \"%s\" (plural \"%s\", icon \"%s\")\n",
125 NULLSTRINGIFNULL( tmpl
->dt_name
),
126 NULLSTRINGIFNULL( tmpl
->dt_pluralname
),
127 NULLSTRINGIFNULL( tmpl
->dt_iconname
));
129 printf( "object class list:\n" );
130 for ( ocp
= tmpl
->dt_oclist
; ocp
!= NULL
; ocp
= ocp
->oc_next
) {
131 for ( i
= 0; ocp
->oc_objclasses
[ i
] != NULL
; ++i
) {
132 printf( "%s%s", i
== 0 ? " " : " & ",
133 NULLSTRINGIFNULL( ocp
->oc_objclasses
[ i
] ));
139 printf( "template options: " );
140 if ( tmpl
->dt_options
== 0L ) {
143 printf( "%s %s %s\n", LDAP_IS_DISPTMPL_OPTION_SET( tmpl
,
144 LDAP_DTMPL_OPT_ADDABLE
) ? "addable" : "",
145 LDAP_IS_DISPTMPL_OPTION_SET( tmpl
, LDAP_DTMPL_OPT_ALLOWMODRDN
)
147 LDAP_IS_DISPTMPL_OPTION_SET( tmpl
, LDAP_DTMPL_OPT_ALTVIEW
)
151 printf( "authenticate as attribute: %s\n", tmpl
->dt_authattrname
!= NULL
?
152 tmpl
->dt_authattrname
: "<default>" );
154 printf( "default RDN attribute: %s\n", tmpl
->dt_defrdnattrname
!= NULL
?
155 tmpl
->dt_defrdnattrname
: "NONE" );
157 printf( "default add location: %s\n", tmpl
->dt_defaddlocation
!= NULL
?
158 tmpl
->dt_defaddlocation
: "NONE" );
160 printf( "\nnew entry value default rules:\n" );
161 for ( adp
= tmpl
->dt_adddeflist
; adp
!= NULL
; adp
= adp
->ad_next
) {
162 if ( adp
->ad_source
== LDAP_ADSRC_CONSTANTVALUE
) {
163 printf( " attribute %s <-- constant value \"%s\"\n",
164 NULLSTRINGIFNULL( adp
->ad_attrname
),
165 NULLSTRINGIFNULL( adp
->ad_value
));
167 printf( " attribute %s <-- adder's DN\n",
168 NULLSTRINGIFNULL( adp
->ad_attrname
));
173 printf( "\nfetch attributes & values:\n" );
174 if (( fetchattrs
= ldap_tmplattrs( tmpl
, includeattrs
, 1,
175 LDAP_SYN_OPT_DEFER
)) == NULL
) {
176 printf( " <none>\n" );
178 for ( i
= 0; fetchattrs
[ i
] != NULL
; ++i
) {
179 printf( " %s\n", fetchattrs
[ i
] );
180 free( fetchattrs
[ i
] );
182 free( (char *)fetchattrs
);
185 printf( "\nfetch attributes only:\n" );
186 if (( fetchattrs
= ldap_tmplattrs( tmpl
, NULL
, 0,
187 LDAP_SYN_OPT_DEFER
)) == NULL
) {
188 printf( " <none>\n" );
190 for ( i
= 0; fetchattrs
[ i
] != NULL
; ++i
) {
191 printf( " %s\n", fetchattrs
[ i
] );
192 free( fetchattrs
[ i
] );
194 free( (char *)fetchattrs
);
197 printf( "\ntemplate items:\n" );
199 for ( rowp
= ldap_first_tmplrow( tmpl
); rowp
!= NULLTMPLITEM
;
200 rowp
= ldap_next_tmplrow( tmpl
, rowp
)) {
203 for ( colp
= ldap_first_tmplcol( tmpl
, rowp
); colp
!= NULLTMPLITEM
;
204 colp
= ldap_next_tmplcol( tmpl
, rowp
, colp
)) {
206 printf( " %2d-%d: %s (%s%s", rowcnt
, colcnt
,
207 syn_name
[ colp
->ti_syntaxid
& 0x0000FFFF ],
208 syn_type
[ LDAP_GET_SYN_TYPE( colp
->ti_syntaxid
) >> 24 ],
209 (( LDAP_GET_SYN_OPTIONS( colp
->ti_syntaxid
) &
210 LDAP_SYN_OPT_DEFER
) != 0 ) ? ",defer" : "" );
212 for ( i
= 0; item_opts
[ i
] != NULL
; ++i
) {
213 if ( LDAP_IS_TMPLITEM_OPTION_SET( colp
, item_opt_vals
[ i
] )) {
214 printf( ",%s", NULLSTRINGIFNULL( item_opts
[ i
] ));
218 printf( "), %s, %s", NULLSTRINGIFNULL( colp
->ti_attrname
),
219 NULLSTRINGIFNULL( colp
->ti_label
));
220 if ( colp
->ti_args
!= NULL
) {
222 for ( i
= 0; colp
->ti_args
[ i
] != NULL
; ++i
) {
223 printf( "<%s>", NULLSTRINGIFNULL( colp
->ti_args
[ i
] ));
234 dump_srchpref( struct ldap_searchobj
*so
)
237 struct ldap_searchattr
*sa
;
238 struct ldap_searchmatch
*sm
;
240 printf( "Object type prompt: %s\n",
241 NULLSTRINGIFNULL( so
->so_objtypeprompt
));
242 printf( "Options: %s\n",
243 LDAP_IS_SEARCHOBJ_OPTION_SET( so
, LDAP_SEARCHOBJ_OPT_INTERNAL
) ?
244 "internal" : "NONE" );
245 printf( "Prompt: %s\n", NULLSTRINGIFNULL( so
->so_prompt
));
247 switch ( so
->so_defaultscope
) {
248 case LDAP_SCOPE_BASE
:
249 printf( "LDAP_SCOPE_BASE" );
251 case LDAP_SCOPE_ONELEVEL
:
252 printf( "LDAP_SCOPE_ONELEVEL" );
254 case LDAP_SCOPE_SUBTREE
:
255 printf( "LDAP_SCOPE_SUBTREE" );
258 printf("*** unknown!" );
261 printf( "Filter prefix: %s\n",
262 NULLSTRINGIFNULL( so
->so_filterprefix
));
263 printf( "Filter tag: %s\n",
264 NULLSTRINGIFNULL( so
->so_filtertag
));
265 printf( "Default select attr: %s\n",
266 NULLSTRINGIFNULL( so
->so_defaultselectattr
));
267 printf( "Default select text: %s\n",
268 NULLSTRINGIFNULL( so
->so_defaultselecttext
));
269 printf( "Searchable attributes ---- \n" );
270 for ( sa
= so
->so_salist
; sa
!= NULL
; sa
= sa
->sa_next
) {
271 printf( " Label: %s\n", NULLSTRINGIFNULL( sa
->sa_attrlabel
));
272 printf( " Attribute: %s\n", NULLSTRINGIFNULL( sa
->sa_attr
));
273 printf( " Select attr: %s\n", NULLSTRINGIFNULL( sa
->sa_selectattr
));
274 printf( " Select text: %s\n", NULLSTRINGIFNULL( sa
->sa_selecttext
));
275 printf( " Match types ---- \n" );
276 for ( i
= 0, sm
= so
->so_smlist
; sm
!= NULL
; i
++, sm
= sm
->sm_next
) {
277 if (( sa
->sa_matchtypebitmap
>> i
) & 1 ) {
278 printf( " %s (%s)\n",
279 NULLSTRINGIFNULL( sm
->sm_matchprompt
),
280 NULLSTRINGIFNULL( sm
->sm_filter
));