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