xref: /titanic_44/usr/src/cmd/ldap/ns_ldap/printResult.c (revision 587032cf0967234b39ccb50adca936a367841063)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <stdio.h>
29 #include "../../../lib/libsldap/common/ns_sldap.h"
30 
31 void
32 _printEntry(ns_ldap_entry_t *entry) {
33 	int	j, k;
34 	char	*cp;
35 	for (j = 0; j < entry->attr_count; j++) {
36 		cp = entry->attr_pair[j]->attrname;
37 		if (j == 0) {
38 			(void) fprintf(stdout, "%s: %s\n", cp,
39 				entry->attr_pair[j]->attrvalue[0]);
40 		} else {
41 			for (k = 0; (k < entry->attr_pair[j]->value_count) &&
42 			    (entry->attr_pair[j]->attrvalue[k]); k++)
43 				(void) fprintf(stdout, "\t%s: %s\n", cp,
44 					entry->attr_pair[j]->attrvalue[k]);
45 		}
46 	}
47 }
48 
49 
50 void
51 _printResult(ns_ldap_result_t *result) {
52 	ns_ldap_entry_t *curEntry;
53 	int	i;
54 
55 	if (result == NULL) {
56 		return;
57 	}
58 	curEntry = result->entry;
59 	for (i = 0; i < result->entries_count; i++) {
60 		if (i != 0)
61 			(void) fprintf(stdout, "\n");
62 		_printEntry(curEntry);
63 		curEntry = curEntry->next;
64 	}
65 }
66