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