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.
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.
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]
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
29 #include "ns_internal.h"
36 static mutex_t ns_error_lock
= DEFAULTMUTEX
;
37 static boolean_t error_inited
= B_FALSE
;
39 static struct ns_ldaperror ns_ldap_errlist
[] = {
40 {NS_LDAP_SUCCESS
, NULL
},
41 {NS_LDAP_OP_FAILED
, NULL
},
42 {NS_LDAP_NOTFOUND
, NULL
},
43 {NS_LDAP_MEMORY
, NULL
},
44 {NS_LDAP_CONFIG
, NULL
},
45 {NS_LDAP_PARTIAL
, NULL
},
46 {NS_LDAP_INTERNAL
, NULL
},
47 {NS_LDAP_INVALID_PARAM
, NULL
},
57 (void) mutex_lock(&ns_error_lock
);
59 ns_ldap_errlist
[i
++].e_reason
= gettext("Success");
60 ns_ldap_errlist
[i
++].e_reason
= gettext("Operation failed");
61 ns_ldap_errlist
[i
++].e_reason
= gettext("Object not found");
62 ns_ldap_errlist
[i
++].e_reason
= gettext("Memory failure");
63 ns_ldap_errlist
[i
++].e_reason
=
64 gettext("LDAP configuration problem");
65 ns_ldap_errlist
[i
++].e_reason
= gettext("Partial result");
66 ns_ldap_errlist
[i
++].e_reason
= gettext("LDAP error");
67 ns_ldap_errlist
[i
++].e_reason
= gettext("Invalid parameter");
68 ns_ldap_errlist
[i
++].e_reason
= gettext("Unknown error");
69 error_inited
= B_TRUE
;
71 (void) mutex_unlock(&ns_error_lock
);
76 __ns_ldap_err2str(int err
, char **strmsg
)
83 for (i
= 0; (ns_ldap_errlist
[i
].e_code
!= err
) &&
84 (ns_ldap_errlist
[i
].e_code
!= -1); i
++) {
87 *strmsg
= ns_ldap_errlist
[i
].e_reason
;
88 return (NS_LDAP_SUCCESS
);
93 __ns_ldap_freeError(ns_ldap_error_t
**errorp
)
97 if (errorp
== NULL
|| *errorp
== NULL
)
98 return (NS_LDAP_SUCCESS
);
105 return (NS_LDAP_SUCCESS
);