xref: /titanic_44/usr/src/lib/libnisdb/ldap_util.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <stdarg.h>
30*7c478bd9Sstevel@tonic-gate #include <syslog.h>
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include "ldap_structs.h"
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifndef	_LDAP_UTIL_H
35*7c478bd9Sstevel@tonic-gate #define	_LDAP_UTIL_H
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
38*7c478bd9Sstevel@tonic-gate extern "C" {
39*7c478bd9Sstevel@tonic-gate #endif
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #define	T	1
42*7c478bd9Sstevel@tonic-gate #define	F	0
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #define	NIL(s)	(((s) != 0) ? (s) : "<nil>")
45*7c478bd9Sstevel@tonic-gate #define	MAX(a, b)	(((a) > (b)) ? (a) : (b))
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /* Message types */
48*7c478bd9Sstevel@tonic-gate #define	MSG_ALWAYS		-1
49*7c478bd9Sstevel@tonic-gate #define	MSG_NOTIMECHECK		0
50*7c478bd9Sstevel@tonic-gate #define	MSG_NOMEM		1
51*7c478bd9Sstevel@tonic-gate #define	MSG_MEMPARAM		2
52*7c478bd9Sstevel@tonic-gate #define	MSG_TSDERR		3
53*7c478bd9Sstevel@tonic-gate #define	MSG_BER			4
54*7c478bd9Sstevel@tonic-gate #define	MSG_INVALIDDELDISP	5
55*7c478bd9Sstevel@tonic-gate #define	MSG_NORULEVALUE		6
56*7c478bd9Sstevel@tonic-gate #define	MSG_NONPCOLDSTART	7
57*7c478bd9Sstevel@tonic-gate #define	MSG_VLV_INSUFF_ACC	8
58*7c478bd9Sstevel@tonic-gate #define	MSG_LASTMSG		9
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate /* Error numbers (NPL is NisPlusLdap) */
61*7c478bd9Sstevel@tonic-gate #define	NPL_NOERROR	0
62*7c478bd9Sstevel@tonic-gate #define	NPL_NOMEM	1
63*7c478bd9Sstevel@tonic-gate #define	NPL_TSDERR	2
64*7c478bd9Sstevel@tonic-gate #define	NPL_BERENCODE	3
65*7c478bd9Sstevel@tonic-gate #define	NPL_BERDECODE	4
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /* Structure used to maintain a buffer with a length */
68*7c478bd9Sstevel@tonic-gate typedef struct {
69*7c478bd9Sstevel@tonic-gate 	char	*buf;
70*7c478bd9Sstevel@tonic-gate 	int	len;
71*7c478bd9Sstevel@tonic-gate } __nis_buffer_t;
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /* Generic print buffer */
74*7c478bd9Sstevel@tonic-gate extern __nis_buffer_t	pb;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /* Deferred error reporting buffer (TSD) */
77*7c478bd9Sstevel@tonic-gate typedef struct {
78*7c478bd9Sstevel@tonic-gate 	int		error;
79*7c478bd9Sstevel@tonic-gate 	char		*message;
80*7c478bd9Sstevel@tonic-gate }  __nis_deferred_error_t;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /* Exported symbols */
83*7c478bd9Sstevel@tonic-gate extern unsigned long	numMisaligned;
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /* Exported functions */
86*7c478bd9Sstevel@tonic-gate void	logmsg(int msgtype, int priority, char *fmt, ...);
87*7c478bd9Sstevel@tonic-gate void	reportError(int error, char *fmt, ...);
88*7c478bd9Sstevel@tonic-gate int	getError(char **message);
89*7c478bd9Sstevel@tonic-gate void	clearError(void);
90*7c478bd9Sstevel@tonic-gate void	logError(int priority);
91*7c478bd9Sstevel@tonic-gate void	*am(char *msg, int size);
92*7c478bd9Sstevel@tonic-gate int	slen(char *str);
93*7c478bd9Sstevel@tonic-gate char	*sdup(char *msg, int allocate, char *str);
94*7c478bd9Sstevel@tonic-gate char	*scat(char *msg, int deallocate, char *s1, char *s2);
95*7c478bd9Sstevel@tonic-gate void	sfree(void *ptr);
96*7c478bd9Sstevel@tonic-gate char	lastChar(__nis_single_value_t *v);
97*7c478bd9Sstevel@tonic-gate void	*appendString2SingleVal(char *str, __nis_single_value_t *v,
98*7c478bd9Sstevel@tonic-gate 		int *newLen);
99*7c478bd9Sstevel@tonic-gate int	scmp(char *s, __nis_single_value_t *v);
100*7c478bd9Sstevel@tonic-gate int	scasecmp(char *s, __nis_single_value_t *v);
101*7c478bd9Sstevel@tonic-gate int	vp2buf(char *msg, char **buf, int buflen, char *fmt, va_list ap);
102*7c478bd9Sstevel@tonic-gate void	p2buf(char *msg, char *fmt, ...);
103*7c478bd9Sstevel@tonic-gate void	bp2buf(char *msg, __nis_buffer_t *b, char *fmt, ...);
104*7c478bd9Sstevel@tonic-gate void	bc2buf(char *msg, void *buf, int len, __nis_buffer_t *b);
105*7c478bd9Sstevel@tonic-gate void	sbc2buf(char *msg, void *buf, int len, __nis_buffer_t *b);
106*7c478bd9Sstevel@tonic-gate void	c2buf(char *msg, void *buf, int len);
107*7c478bd9Sstevel@tonic-gate void	sc2buf(char *msg, void *buf, int len);
108*7c478bd9Sstevel@tonic-gate void	printbuf(void);
109*7c478bd9Sstevel@tonic-gate void	*extendArray(void *array, int newsize);
110*7c478bd9Sstevel@tonic-gate int	checkIPaddress(char *addr, int len, char **newaddr);
111*7c478bd9Sstevel@tonic-gate int	sstrncmp(const char *s1, const char *s2, int n);
112*7c478bd9Sstevel@tonic-gate char	*trimWhiteSpaces(char *str, int *len, int deallocate);
113*7c478bd9Sstevel@tonic-gate int	escapeSpecialChars(__nis_value_t *val);
114*7c478bd9Sstevel@tonic-gate void	removeEscapeChars(__nis_value_t *val);
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
118*7c478bd9Sstevel@tonic-gate }
119*7c478bd9Sstevel@tonic-gate #endif	/* __cplusplus */
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #endif	/* _LDAP_UTIL_H */
122