xref: /illumos-gate/usr/src/lib/libnisdb/ldap_util.h (revision 8d0852b7)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <stdarg.h>
287c478bd9Sstevel@tonic-gate #include <syslog.h>
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include "ldap_structs.h"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef	_LDAP_UTIL_H
337c478bd9Sstevel@tonic-gate #define	_LDAP_UTIL_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	T	1
407c478bd9Sstevel@tonic-gate #define	F	0
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	NIL(s)	(((s) != 0) ? (s) : "<nil>")
437c478bd9Sstevel@tonic-gate #define	MAX(a, b)	(((a) > (b)) ? (a) : (b))
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /* Message types */
467c478bd9Sstevel@tonic-gate #define	MSG_ALWAYS		-1
477c478bd9Sstevel@tonic-gate #define	MSG_NOTIMECHECK		0
487c478bd9Sstevel@tonic-gate #define	MSG_NOMEM		1
497c478bd9Sstevel@tonic-gate #define	MSG_MEMPARAM		2
507c478bd9Sstevel@tonic-gate #define	MSG_TSDERR		3
517c478bd9Sstevel@tonic-gate #define	MSG_BER			4
527c478bd9Sstevel@tonic-gate #define	MSG_INVALIDDELDISP	5
537c478bd9Sstevel@tonic-gate #define	MSG_NORULEVALUE		6
547c478bd9Sstevel@tonic-gate #define	MSG_NONPCOLDSTART	7
557c478bd9Sstevel@tonic-gate #define	MSG_VLV_INSUFF_ACC	8
567c478bd9Sstevel@tonic-gate #define	MSG_LASTMSG		9
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /* Error numbers (NPL is NisPlusLdap) */
597c478bd9Sstevel@tonic-gate #define	NPL_NOERROR	0
607c478bd9Sstevel@tonic-gate #define	NPL_NOMEM	1
617c478bd9Sstevel@tonic-gate #define	NPL_TSDERR	2
627c478bd9Sstevel@tonic-gate #define	NPL_BERENCODE	3
637c478bd9Sstevel@tonic-gate #define	NPL_BERDECODE	4
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /* Structure used to maintain a buffer with a length */
667c478bd9Sstevel@tonic-gate typedef struct {
677c478bd9Sstevel@tonic-gate 	char	*buf;
687c478bd9Sstevel@tonic-gate 	int	len;
697c478bd9Sstevel@tonic-gate } __nis_buffer_t;
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /* Generic print buffer */
727c478bd9Sstevel@tonic-gate extern __nis_buffer_t	pb;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* Deferred error reporting buffer (TSD) */
757c478bd9Sstevel@tonic-gate typedef struct {
767c478bd9Sstevel@tonic-gate 	int		error;
777c478bd9Sstevel@tonic-gate 	char		*message;
787c478bd9Sstevel@tonic-gate }  __nis_deferred_error_t;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* Exported symbols */
817c478bd9Sstevel@tonic-gate extern unsigned long	numMisaligned;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* Exported functions */
84*8d0852b7SRichard Lowe void	logmsg(int msgtype, int priority, const char *fmt, ...);
857c478bd9Sstevel@tonic-gate void	reportError(int error, char *fmt, ...);
867c478bd9Sstevel@tonic-gate int	getError(char **message);
877c478bd9Sstevel@tonic-gate void	clearError(void);
887c478bd9Sstevel@tonic-gate void	logError(int priority);
89*8d0852b7SRichard Lowe void	*am(const char *msg, int size);
90*8d0852b7SRichard Lowe int	slen(const char *str);
91*8d0852b7SRichard Lowe char	*sdup(const char *msg, int allocate, char *str);
92*8d0852b7SRichard Lowe char	*scat(const char *msg, int deallocate, char *s1, char *s2);
937c478bd9Sstevel@tonic-gate void	sfree(void *ptr);
947c478bd9Sstevel@tonic-gate char	lastChar(__nis_single_value_t *v);
957c478bd9Sstevel@tonic-gate void	*appendString2SingleVal(char *str, __nis_single_value_t *v,
967c478bd9Sstevel@tonic-gate 		int *newLen);
977c478bd9Sstevel@tonic-gate int	scmp(char *s, __nis_single_value_t *v);
987c478bd9Sstevel@tonic-gate int	scasecmp(char *s, __nis_single_value_t *v);
99*8d0852b7SRichard Lowe int	vp2buf(const char *msg, char **buf, int buflen, const char *fmt,
100*8d0852b7SRichard Lowe     va_list ap);
1017c478bd9Sstevel@tonic-gate void	p2buf(char *msg, char *fmt, ...);
102*8d0852b7SRichard Lowe void	bp2buf(const char *msg, __nis_buffer_t *b, const char *fmt, ...);
103*8d0852b7SRichard Lowe void	bc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b);
104*8d0852b7SRichard Lowe void	sbc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b);
1057c478bd9Sstevel@tonic-gate void	c2buf(char *msg, void *buf, int len);
1067c478bd9Sstevel@tonic-gate void	sc2buf(char *msg, void *buf, int len);
1077c478bd9Sstevel@tonic-gate void	printbuf(void);
1087c478bd9Sstevel@tonic-gate void	*extendArray(void *array, int newsize);
1097c478bd9Sstevel@tonic-gate int	checkIPaddress(char *addr, int len, char **newaddr);
1107c478bd9Sstevel@tonic-gate int	sstrncmp(const char *s1, const char *s2, int n);
1117c478bd9Sstevel@tonic-gate char	*trimWhiteSpaces(char *str, int *len, int deallocate);
1127c478bd9Sstevel@tonic-gate int	escapeSpecialChars(__nis_value_t *val);
1137c478bd9Sstevel@tonic-gate void	removeEscapeChars(__nis_value_t *val);
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate #endif	/* __cplusplus */
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #endif	/* _LDAP_UTIL_H */
121