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 #include <stdio.h>
27 #include "../../../lib/libsldap/common/ns_sldap.h"
28
29 void
_printEntry(ns_ldap_entry_t * entry)30 _printEntry(ns_ldap_entry_t *entry) {
31 int j, k;
32 char *cp;
33 for (j = 0; j < entry->attr_count; j++) {
34 cp = entry->attr_pair[j]->attrname;
35 if (j == 0) {
36 (void) fprintf(stdout, "%s: %s\n", cp,
37 entry->attr_pair[j]->attrvalue[0]);
38 } else {
39 for (k = 0; (k < entry->attr_pair[j]->value_count) &&
40 (entry->attr_pair[j]->attrvalue[k]); k++)
41 (void) fprintf(stdout, "\t%s: %s\n", cp,
42 entry->attr_pair[j]->attrvalue[k]);
43 }
44 }
45 }
46
47
48 void
_printResult(ns_ldap_result_t * result)49 _printResult(ns_ldap_result_t *result) {
50 ns_ldap_entry_t *curEntry;
51 int i;
52
53 if (result == NULL) {
54 return;
55 }
56 curEntry = result->entry;
57 for (i = 0; i < result->entries_count; i++) {
58 if (i != 0)
59 (void) fprintf(stdout, "\n");
60 _printEntry(curEntry);
61 curEntry = curEntry->next;
62 }
63 }
64