/* ldapmodify.c - generic program to modify or add entries using LDAP */
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
+#include <ac/string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#ifndef VMS
#include <unistd.h>
#endif /* VMS */
+
#include <lber.h>
#include <ldap.h>
#include <ldif.h>
static char *prog;
static char *binddn = LDAPMODIFY_BINDDN;
-static char *passwd = NULL;
+static char *passwd = LDAPMODIFY_BIND_CRED;
static char *ldaphost = LDAPHOST;
static int ldapport = LDAP_PORT;
static int new, replace, not, verbose, contoper, force, valsfromfiles;
for ac_func in \
+ bcopy \
flock \
gethostname \
gettimeofday \
getdtablesize \
lockf \
memcpy \
+ memmove \
mktime \
select \
setpwfile \
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5728: checking for $ac_func" >&5
+echo "configure:5730: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5733 "configure"
+#line 5735 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:5756: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in strdup
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5784: checking for $ac_func" >&5
+echo "configure:5786: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5789 "configure"
+#line 5791 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:5812: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5814: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:5842: checking declaration of sys_errlist" >&5
+echo "configure:5844: checking declaration of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5848 "configure"
+#line 5850 "configure"
#include "confdefs.h"
#include <stdio.h>
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:5858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5860: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:5879: checking existence of sys_errlist" >&5
+echo "configure:5881: checking existence of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5885 "configure"
+#line 5887 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:5892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else
OL_ARG_ENABLE(cache,[ --enable-cache enable caching], yes)dnl
OL_ARG_ENABLE(dns,[ --enable-dns enable dns support], no)dnl
OL_ARG_ENABLE(referrals,[ --enable-referrals enable referrals], yes)dnl
-OL_ARG_ENABLE(cldap,[ --enable-clapd enable connectionless ldap], no)dnl
+OL_ARG_ENABLE(cldap,[ --enable-cldap enable connectionless ldap], no)dnl
dnl General "with" options
OL_ARG_WITH(kerberos,[ --with-kerberos use Kerberos],
AC_FUNC_WAIT3
AC_CHECK_FUNCS( \
+ bcopy \
flock \
gethostname \
gettimeofday \
getdtablesize \
lockf \
memcpy \
+ memmove \
mktime \
select \
setpwfile \
#define _AC_STRING_H
#if STDC_HEADERS
-# include <string.h>
+# include <string.h>
#else
-# ifndef HAVE_STRCHR
-# define strchr index
-# define strrchr rindex
-# endif
-char *strchr (), *strrchr ();
-# ifndef HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy ((s), (d), (n))
-# define memmove(d, s, n) bcopy ((s), (d), (n))
-# endif
+# ifndef HAVE_STRCHR
+# define strchr index
+# define strrchr rindex
+# endif
+ char *strchr (), *strrchr ();
+
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# define memmove(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#ifdef HAVE_MEMMOVE
+# define SAFEMEMCPY( d, s, n ) memmove((s), (d), (n))
+#else
+# ifdef HAVE_BCOPY
+# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
+# else
+# ifdef MACOS
+# define SAFEMEMCPY( d, s, n ) BlockMoveData((Ptr)(s), (Ptr)(d), (n))
+# else
+# define SAFEMEMCPY( d, s, n ) memmove((s), (d), (n))
+# endif
+# endif
#endif
#endif /* _AC_STRING_H */
#ifndef _AVL
#define _AVL
+#include <ldap_cdefs.h>
+
/*
* this structure represents a generic avl tree node.
*/
typedef struct avlnode {
caddr_t avl_data;
- char avl_bf;
+ signed char avl_bf;
struct avlnode *avl_left;
struct avlnode *avl_right;
} Avlnode;
#define RH 1
/* avl routines */
-#define avl_getone(x) (x == 0 ? 0 : (x)->avl_data)
-#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
-extern int avl_insert();
-extern caddr_t avl_delete();
-extern caddr_t avl_find();
-extern caddr_t avl_getfirst();
-extern caddr_t avl_getnext();
-extern int avl_dup_error();
-extern int avl_apply();
+#define avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data)
+#define avl_onenode(x) ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
+
+/* looks like this function pointer is not used consistently */
+/* typedef int (*IFP)LDAP_P((caddr_t, caddr_t)); */
+typedef int (*IFP)();
+
+LDAP_F int
+avl_insert LDAP_P((Avlnode **, caddr_t, IFP, IFP));
+
+LDAP_F caddr_t
+avl_delete LDAP_P((Avlnode **, caddr_t, IFP));
+
+LDAP_F caddr_t
+avl_find LDAP_P((Avlnode *, caddr_t, IFP));
+
+LDAP_F caddr_t
+avl_getfirst LDAP_P((Avlnode *));
+
+#ifdef AVL_REENTRANT
+LDAP_F caddr_t
+avl_getnext LDAP_P((Avlnode *, caddr_t ));
+#else
+LDAP_F caddr_t
+avl_getnext LDAP_P((void));
+#endif
+
+LDAP_F int
+avl_dup_error LDAP_P((void));
+
+LDAP_F int
+avl_apply LDAP_P((Avlnode *, IFP, caddr_t, int, int));
/* apply traversal types */
#define AVL_PREORDER 1
/* what apply returns if it ran out of nodes */
#define AVL_NOMORE -6
-typedef int (*IFP)();
-
#endif /* _AVL */
#ifndef _LBER_H
#define _LBER_H
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <ldap_cdefs.h>
-#if !defined( NEEDPROTOS ) && defined(__STDC__)
-#define NEEDPROTOS 1
-#endif
+LDAP_BEGIN_DECL
/* BER classes and mask */
#define LBER_CLASS_UNIVERSAL 0x00
#define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */
#define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */
-#ifdef NEEDPROTOS
-typedef int (*BERTranslateProc)( char **bufp, unsigned long *buflenp,
- int free_input );
-#else /* NEEDPROTOS */
-typedef int (*BERTranslateProc)();
-#endif /* NEEDPROTOS */
+typedef int (*BERTranslateProc) LDAP_P(( char **bufp,
+ unsigned long *buflenp,
+ int free_input ));
typedef struct berelement {
char *ber_buf;
char *bv_val;
};
-#ifndef NEEDPROTOS
-extern BerElement *ber_alloc();
-extern BerElement *der_alloc();
-extern BerElement *ber_alloc_t();
-extern BerElement *ber_dup();
+#ifdef LDAP_DEBUG
extern int lber_debug;
-extern void ber_bvfree();
-extern void ber_bvecfree();
-extern struct berval *ber_bvdup();
-extern void ber_dump();
-extern void ber_sos_dump();
-extern void lber_bprint();
-extern void ber_reset();
-extern void ber_init();
-#else /* NEEDPROTOS */
-#if defined(WINSOCK)
-#include "proto-lb.h"
+#endif
+
+/*
+ * in bprint.c:
+ */
+LDAP_F void lber_bprint LDAP_P(( char *data, int len ));
+
+/*
+ * in decode.c:
+ */
+LDAP_F unsigned long ber_get_tag LDAP_P(( BerElement *ber ));
+LDAP_F unsigned long ber_skip_tag LDAP_P(( BerElement *ber, unsigned long *len ));
+LDAP_F unsigned long ber_peek_tag LDAP_P(( BerElement *ber, unsigned long *len ));
+LDAP_F unsigned long ber_get_int LDAP_P(( BerElement *ber, long *num ));
+LDAP_F unsigned long ber_get_stringb LDAP_P(( BerElement *ber, char *buf,
+ unsigned long *len ));
+LDAP_F unsigned long ber_get_stringa LDAP_P(( BerElement *ber, char **buf ));
+LDAP_F unsigned long ber_get_stringal LDAP_P(( BerElement *ber, struct berval **bv ));
+LDAP_F unsigned long ber_get_bitstringa LDAP_P(( BerElement *ber, char **buf,
+ unsigned long *len ));
+LDAP_F unsigned long ber_get_null LDAP_P(( BerElement *ber ));
+LDAP_F unsigned long ber_get_boolean LDAP_P(( BerElement *ber, int *boolval ));
+LDAP_F unsigned long ber_first_element LDAP_P(( BerElement *ber, unsigned long *len,
+ char **last ));
+LDAP_F unsigned long ber_next_element LDAP_P(( BerElement *ber, unsigned long *len,
+ char *last ));
+LDAP_F unsigned long ber_scanf LDAP_P(( BerElement *ber, char *fmt, ... ));
+LDAP_F void ber_bvfree LDAP_P(( struct berval *bv ));
+LDAP_F void ber_bvecfree LDAP_P(( struct berval **bv ));
+LDAP_F struct berval *ber_bvdup LDAP_P(( struct berval *bv ));
+#ifdef STR_TRANSLATION
+LDAP_F void ber_set_string_translators LDAP_P(( BerElement *ber,
+ BERTranslateProc encode_proc, BERTranslateProc decode_proc ));
+#endif /* STR_TRANSLATION */
+
+/*
+ * in encode.c
+ */
+LDAP_F int ber_put_enum LDAP_P(( BerElement *ber, long num, unsigned long tag ));
+LDAP_F int ber_put_int LDAP_P(( BerElement *ber, long num, unsigned long tag ));
+LDAP_F int ber_put_ostring LDAP_P(( BerElement *ber, char *str, unsigned long len,
+ unsigned long tag ));
+LDAP_F int ber_put_string LDAP_P(( BerElement *ber, char *str, unsigned long tag ));
+LDAP_F int ber_put_bitstring LDAP_P(( BerElement *ber, char *str,
+ unsigned long bitlen, unsigned long tag ));
+LDAP_F int ber_put_null LDAP_P(( BerElement *ber, unsigned long tag ));
+LDAP_F int ber_put_boolean LDAP_P(( BerElement *ber, int boolval,
+ unsigned long tag ));
+LDAP_F int ber_start_seq LDAP_P(( BerElement *ber, unsigned long tag ));
+LDAP_F int ber_start_set LDAP_P(( BerElement *ber, unsigned long tag ));
+LDAP_F int ber_put_seq LDAP_P(( BerElement *ber ));
+LDAP_F int ber_put_set LDAP_P(( BerElement *ber ));
+
+#ifdef __STDC__
+LDAP_F int ber_printf LDAP_P(( BerElement *ber, char *fmt, ... ));
#else
-#include "proto-lber.h"
+LDAP_F int ber_printf ( );
#endif
-#endif /* NEEDPROTOS */
+
+/*
+ * in io.c:
+ */
+LDAP_F long ber_read LDAP_P(( BerElement *ber, char *buf, unsigned long len ));
+LDAP_F long ber_write LDAP_P(( BerElement *ber, char *buf, unsigned long len,
+ int nosos ));
+LDAP_F void ber_free LDAP_P(( BerElement *ber, int freebuf ));
+LDAP_F int ber_flush LDAP_P(( Sockbuf *sb, BerElement *ber, int freeit ));
+LDAP_F BerElement *ber_alloc LDAP_P(( void ));
+LDAP_F BerElement *der_alloc LDAP_P(( void ));
+LDAP_F BerElement *ber_alloc_t LDAP_P(( int options ));
+LDAP_F BerElement *ber_dup LDAP_P(( BerElement *ber ));
+LDAP_F void ber_dump LDAP_P(( BerElement *ber, int inout ));
+LDAP_F void ber_sos_dump LDAP_P(( Seqorset *sos ));
+LDAP_F unsigned long ber_get_next LDAP_P(( Sockbuf *sb, unsigned long *len,
+ BerElement *ber ));
+LDAP_F void ber_init LDAP_P(( BerElement *ber, int options ));
+LDAP_F void ber_reset LDAP_P(( BerElement *ber, int was_writing ));
#if !defined(__alpha) || defined(VMS)
| ntohl( ( (l) & 0xFFFFFFFF00000000 ) >> 32 ))
#endif /* __alpha */
+LDAP_END_DECL
-/*
- * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
- */
-#ifdef MACOS
-#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n )
-#else /* MACOS */
-#ifdef sunos4
-#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n )
-#else /* sunos4 */
-#define SAFEMEMCPY( d, s, n ) memmove( d, s, n )
-#endif /* sunos4 */
-#endif /* MACOS */
-
-
-#ifdef __cplusplus
-}
-#endif
#endif /* _LBER_H */
/* define this for phonetic support */
#undef SLAPD_PHONETIC
+/* Define if you have the bcopy function. */
+#undef HAVE_BCOPY
+
/* Define if you have the flock function. */
#undef HAVE_FLOCK
/* Define if you have the memcpy function. */
#undef HAVE_MEMCPY
+/* Define if you have the memmove function. */
+#undef HAVE_MEMMOVE
+
/* Define if you have the mktime function. */
#undef HAVE_MKTIME
#endif
#include "bridge.h"
+#include "ldap_cdefs.h"
#endif /* _LDAP_PORTABLE_H */
#include <sys/types.h>
#include <stdio.h>
+#include <stdlib.h>
#include "avl.h"
#define ROTATERIGHT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_left == NULL ) {\
+ if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
(void) printf("RR error\n"); exit(1); \
}\
- tmp = (*x)->avl_left;\
- (*x)->avl_left = tmp->avl_right;\
- tmp->avl_right = *x;\
- *x = tmp;\
+ tmp = (*(x))->avl_left;\
+ (*(x))->avl_left = tmp->avl_right;\
+ tmp->avl_right = *(x);\
+ *(x) = tmp;\
}
#define ROTATELEFT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_right == NULL ) {\
+ if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
(void) printf("RL error\n"); exit(1); \
}\
- tmp = (*x)->avl_right;\
- (*x)->avl_right = tmp->avl_left;\
+ tmp = (*(x))->avl_right;\
+ (*(x))->avl_right = tmp->avl_left;\
tmp->avl_left = *x;\
- *x = tmp;\
+ *(x) = tmp;\
}
/*
*/
static
-ravl_insert( iroot, data, taller, fcmp, fdup, depth )
+int ravl_insert( iroot, data, taller, fcmp, fdup, depth )
Avlnode **iroot;
caddr_t data;
int *taller;
* NOTE: this routine may malloc memory
*/
-avl_insert( root, data, fcmp, fdup )
+int avl_insert( root, data, fcmp, fdup )
Avlnode **root;
caddr_t data;
IFP fcmp;
* been shortened because of a deletion.
*/
-static
+static int
right_balance( root )
Avlnode **root;
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
*/
static
-left_balance( root )
+int left_balance( root )
Avlnode **root;
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
}
static
-avl_inapply( root, fn, arg, stopflag )
+int avl_inapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
}
static
-avl_postapply( root, fn, arg, stopflag )
+int avl_postapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
}
static
-avl_preapply( root, fn, arg, stopflag )
+int avl_preapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
* of nodes.
*/
-avl_apply( root, fn, arg, stopflag, type )
+int avl_apply( root, fn, arg, stopflag, type )
Avlnode *root;
IFP fn;
caddr_t arg;
* AVL_NOMORE is returned.
*/
-avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
+int avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
Avlnode *root;
caddr_t data;
IFP fmatch;
* number of items actually freed is returned.
*/
-avl_free( root, dfree )
+int avl_free( root, dfree )
Avlnode *root;
IFP dfree;
{
/* ARGSUSED */
static
-avl_buildlist( data, arg )
+int avl_buildlist( data, arg )
caddr_t data;
int arg;
{
return( avl_list[ avl_nextlist++ ] );
}
-avl_dup_error()
+int avl_dup_error()
{
return( -1 );
}
-avl_dup_ok()
+int avl_dup_ok()
{
return( 0 );
}
/* testavl.c - Test Tim Howes AVL code */
-#include <sys/types.h>
-#include <stdio.h>
-#include "avl.h"
-
-char *strdup( s )
-char *s;
-{
- char *new;
- if ( (new = (char *) malloc( strlen( s ) + 1 )) == NULL )
- return( NULL );
+#define DISABLE_BRIDGE
+#include "portable.h"
- strcpy( new, s );
+#include <stdio.h>
+#include <ac/string.h>
+#include <sys/types.h>
- return( new );
-}
+#include "avl.h"
main( argc, argv )
int argc;
case 't': /* traverse with first, next */
printf( "***\n" );
for ( p = (char * ) avl_getfirst( tree );
- p != NULL; p = (char *) avl_getnext( tree, p ) )
+ p != NULL; p = (char *) avl_getnext( /* tree, p */ ) )
printf( "%s\n", p );
printf( "***\n" );
break;
exit( 0 );
name[ strlen( name ) - 1 ] = '\0';
if ( avl_insert( &tree, strdup( name ), strcmp,
- avl_dup_error ) != OK )
+ avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" );
break;
case 'd': /* delete */
#include <stdio.h>
-#ifdef MACOS
+#ifdef STDC_HEADERS
#include <stdlib.h>
#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+#include <ac/string.h>
+
+#ifdef MACOS
#include "macos.h"
-#else /* MACOS */
+#endif /* MACOS */
-#if defined(NeXT) || defined(VMS) || defined(__FreeBSD__)
-#include <stdlib.h>
-#else /* next || vms || freebsd */
-#include <malloc.h>
-#endif /* next || vms || freebsd */
-#if defined(BC31) || defined(_WIN32)
-#include <stdarg.h>
-#else /* BC31 || _WIN32 */
-#include <varargs.h>
-#endif /* BC31 || _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+
#ifdef PCNFS
#include <tklib.h>
#endif /* PCNFS */
-#endif /* MACOS */
-
#if defined( DOS ) || defined( _WIN32 )
#include "msdos.h"
#endif /* DOS */
/* VARARGS */
unsigned long
-ber_scanf(
-#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 )
- BerElement *ber, char *fmt, ... )
+ber_scanf
+#ifdef STDC_HEADERS
+ ( BerElement *ber, char *fmt, ... )
#else
- va_alist )
+ ( va_alist )
va_dcl
#endif
{
va_list ap;
-#if !defined( MACOS ) && !defined( BC31 ) && !defined( _WIN32 )
+#ifndef STDC_HEADERS
BerElement *ber;
char *fmt;
#endif
long *l, rc, tag;
unsigned long len;
-#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 )
+#if STDC_HEADERS
va_start( ap, fmt );
#else
va_start( ap );
break;
default:
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
rc = LBER_DEFAULT;
break;
}
* is provided ``as is'' without express or implied warranty.
*/
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <stdarg.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
-#if defined( BC31 ) || defined( _WIN32 )
+#include <ac/string.h>
+
+#ifdef STDC_HEADERS
#include <stdarg.h>
-#else /* BC31 || _WIN32 */
+#else
#include <varargs.h>
-#endif /* BC31 || _WIN32 */
+#endif
+
+#ifdef MACOS
+#include "macos.h"
+#endif /* MACOS */
+
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+
#ifdef PCNFS
#include <tklib.h>
#endif /* PCNFS */
-#endif /* MACOS */
-#ifndef VMS
-#include <memory.h>
-#endif
-#include <string.h>
-#include "lber.h"
#if defined( DOS ) || defined( _WIN32 )
#include "msdos.h"
#endif /* DOS */
-#ifdef NEEDPROTOS
-static int ber_put_len( BerElement *ber, unsigned long len, int nosos );
-static int ber_start_seqorset( BerElement *ber, unsigned long tag );
-static int ber_put_seqorset( BerElement *ber );
-static int ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag );
-#endif /* NEEDPROTOS */
+#include "lber.h"
+
+static int ber_put_len LDAP_P(( BerElement *ber,
+ unsigned long len, int nosos ));
+
+static int ber_start_seqorset LDAP_P(( BerElement *ber,
+ unsigned long tag ));
+
+static int ber_put_seqorset LDAP_P(( BerElement *ber ));
+
+static int ber_put_int_or_enum LDAP_P(( BerElement *ber,
+ long num, unsigned long tag ));
static int
/* VARARGS */
int
-ber_printf(
-#if defined( MACOS ) || defined( _WIN32 ) || defined( BC31 )
- BerElement *ber, char *fmt, ... )
-#else /* MACOS || _WIN32 || BC31 */
- va_alist )
+ber_printf
+#ifdef STDC_HEADERS
+ ( BerElement *ber, char *fmt, ... )
+#else
+ ( va_alist )
va_dcl
-#endif /* MACOS || _WIN32 || BC31 */
+#endif
{
va_list ap;
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( BC31 )
+#ifndef STDC_HEADERS
BerElement *ber;
char *fmt;
-#endif /* !MACOS && !_WIN32 && !BC31 */
+#endif
char *s, **ss;
struct berval **bv;
int rc, i;
unsigned long len;
-#if defined( MACOS ) || defined( _WIN32 ) || defined( BC31 )
+#ifdef STDC_HEADERS
va_start( ap, fmt );
-#else /* MACOS || _WIN32 || BC31 */
+#else
va_start( ap );
ber = va_arg( ap, BerElement * );
fmt = va_arg( ap, char * );
-#endif /* MACOS || _WIN32 || BC31 */
+#endif
for ( rc = 0; *fmt && rc != -1; fmt++ ) {
switch ( *fmt ) {
break;
default:
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
rc = -1;
break;
}
* is provided ``as is'' without express or implied warranty.
*/
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/string.h>
#include <ctype.h>
+#include <unistd.h>
#if defined( DOS ) || defined( _WIN32 )
#include "msdos.h"
#endif /* DOS || _WIN32 */
#ifdef MACOS
-#include <stdlib.h>
#include "macos.h"
#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
-#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#endif /* PCNFS */
#endif /* MACOS */
-#ifndef VMS
-#include <memory.h>
-#endif
-#include <string.h>
-#include "lber.h"
-
#ifdef _WIN32
#include <winsock.h>
#include <io.h>
#endif /* _WIN32 */
-#ifdef NEEDPROTOS
-static int ber_realloc( BerElement *ber, unsigned long len );
-static int ber_filbuf( Sockbuf *sb, long len );
-static long BerRead( Sockbuf *sb, char *buf, long len );
+#include "lber.h"
+
+static int ber_realloc LDAP_P(( BerElement *ber, unsigned long len ));
+static int ber_filbuf LDAP_P(( Sockbuf *sb, long len ));
+static long BerRead LDAP_P(( Sockbuf *sb, char *buf, long len ));
#ifdef PCNFS
-static int BerWrite( Sockbuf *sb, char *buf, long len );
+static int BerWrite LDAP_P(( Sockbuf *sb, char *buf, long len ));
#endif /* PCNFS */
-#else
-int ber_filbuf();
-long BerRead();
-static int ber_realloc();
-#endif /* NEEDPROTOS */
#define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \
(unsigned char)*sb->sb_ber.ber_ptr++ : \
#ifdef LDAP_DEBUG
if ( lber_debug ) {
fprintf( stderr, "ber_flush: %ld bytes to sd %ld%s\n", towrite,
- sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
+ (long) sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
: "" );
if ( lber_debug > 1 )
lber_bprint( ber->ber_rwptr, towrite );
ber_dump( BerElement *ber, int inout )
{
fprintf( stderr, "ber_dump: buf 0x%lx, ptr 0x%lx, end 0x%lx\n",
- ber->ber_buf, ber->ber_ptr, ber->ber_end );
+ (long) ber->ber_buf,
+ (long) ber->ber_ptr,
+ (long) ber->ber_end );
if ( inout == 1 ) {
fprintf( stderr, " current len %ld, contents:\n",
- ber->ber_end - ber->ber_ptr );
+ (long) (ber->ber_end - ber->ber_ptr) );
lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
} else {
fprintf( stderr, " current len %ld, contents:\n",
- ber->ber_ptr - ber->ber_buf );
+ (long) (ber->ber_ptr - ber->ber_buf) );
lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
}
}
fprintf( stderr, "*** sos dump ***\n" );
while ( sos != NULLSEQORSET ) {
fprintf( stderr, "ber_sos_dump: clen %ld first 0x%lx ptr 0x%lx\n",
- sos->sos_clen, sos->sos_first, sos->sos_ptr );
+ (long) sos->sos_clen, (long) sos->sos_first, (long) sos->sos_ptr );
fprintf( stderr, " current len %ld contents:\n",
- sos->sos_ptr - sos->sos_first );
+ (long) (sos->sos_ptr - sos->sos_first) );
lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
sos = sos->sos_next;
unsigned long
ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
{
- unsigned long tag, netlen, toread;
+ unsigned long tag = 0, netlen, toread;
unsigned char lc;
long rc;
int noctets, diff;
* cache.c - local caching support for LDAP
*/
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#ifndef NO_CACHE
#ifndef lint
#endif
#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
+#include <ac/string.h>
#include <stdlib.h>
+
+#ifdef MACOS
#include <time.h>
#include "macos.h"
#else /* MACOS */
#include <sys/socket.h>
#endif /* DOS */
#endif /* MACOS */
+
#include "lber.h"
#include "ldap.h"
#include "ldap-int.h"
-#ifdef NEEDPROTOS
-static int cache_hash( BerElement *ber );
-static LDAPMessage *msg_dup( LDAPMessage *msg );
-static int request_cmp( BerElement *req1, BerElement *req2 );
-static int chain_contains_dn( LDAPMessage *msg, char *dn );
-static long msg_size( LDAPMessage *msg );
-static void check_cache_memused( LDAPCache *lc );
-static void uncache_entry_or_req( LDAP *ld, char *dn, int msgid );
-#else /* NEEDPROTOS */
-static int cache_hash();
-static LDAPMessage *msg_dup();
-static int request_cmp();
-static int chain_contains_dn();
-static long msg_size();
-static void check_cache_memused();
-static void uncache_entry_or_req();
-#endif /* NEEDPROTOS */
-
+static int cache_hash LDAP_P(( BerElement *ber ));
+static LDAPMessage *msg_dup LDAP_P(( LDAPMessage *msg ));
+static int request_cmp LDAP_P(( BerElement *req1, BerElement *req2 ));
+static int chain_contains_dn LDAP_P(( LDAPMessage *msg, char *dn ));
+static long msg_size LDAP_P(( LDAPMessage *msg ));
+static void check_cache_memused LDAP_P(( LDAPCache *lc ));
+static void uncache_entry_or_req LDAP_P(( LDAP *ld, char *dn, int msgid ));
int
ldap_enable_cache( LDAP *ld, long timeout, long maxmem )
void
ldap_uncache_request( LDAP *ld, int msgid )
{
- Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %x\n",
- msgid, ld->ld_cache, 0 );
+ Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n",
+ msgid, (long) ld->ld_cache, 0 );
uncache_entry_or_req( ld, NULL, msgid );
}
void
ldap_uncache_entry( LDAP *ld, char *dn )
{
- Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %x\n",
- dn, ld->ld_cache, 0 );
+ Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n",
+ dn, (long) ld->ld_cache, 0 );
uncache_entry_or_req( ld, dn, 0 );
}
LDAPMessage *m, *prev, *next;
Debug( LDAP_DEBUG_TRACE,
- "ldap_uncache_entry_or_req dn %s msgid %d ld_cache %x\n",
- dn, msgid, ld->ld_cache );
+ "ldap_uncache_entry_or_req dn %s msgid %d ld_cache %lx\n",
+ dn, msgid, (long) ld->ld_cache );
if ( ld->ld_cache == NULLLDCACHE ) {
return;
void
-add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_add_request_to_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
{
LDAPMessage *new;
long len;
- Debug( LDAP_DEBUG_TRACE, "add_request_to_cache\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 );
ld->ld_errno = LDAP_SUCCESS;
if ( ld->ld_cache == NULLLDCACHE ||
if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
!= NULL ) {
- if (( new->lm_ber = alloc_ber_with_options( ld )) == NULLBER ) {
+ if (( new->lm_ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
free( (char *)new );
return;
}
void
-add_result_to_cache( LDAP *ld, LDAPMessage *result )
+ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
{
LDAPMessage *m, **mp, *req, *new, *prev;
int err, keep;
- Debug( LDAP_DEBUG_TRACE, "add_result_to_cache: id %d, type %d\n",
+ Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %d, type %d\n",
result->lm_msgid, result->lm_msgtype, 0 );
if ( ld->ld_cache == NULLLDCACHE ||
* will find them.
*/
int
-check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
+ldap_check_cache( LDAP *ld, unsigned long msgtype, BerElement *request )
{
LDAPMessage *m, *new, *prev, *next;
BerElement reqber;
int first, hash;
unsigned long validtime;
- Debug( LDAP_DEBUG_TRACE, "check_cache\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 );
if ( ld->ld_cache == NULLLDCACHE ||
( ld->ld_cache->lc_enabled == 0 )) {
* cldap.c - synchronous, retrying interface to the cldap protocol
*/
+#define DISABLE_BRIDGE
+#include "portable.h"
#ifdef CLDAP
#endif
#include <stdio.h>
-#include <string.h>
+#include <ac/string.h>
#include <errno.h>
-#ifdef MACOS
#include <stdlib.h>
+
+#ifdef MACOS
#include "macos.h"
-#else /* MACOS */
+#endif /* MACOS */
#ifdef DOS
#include "msdos.h"
-#else /* DOS */
+#endif /* DOS */
+
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
-#endif /* DOS */
-#endif /* MACOS */
#include "lber.h"
#include "ldap.h"
if ( ld->ld_sb.sb_addrs == NULL
#ifdef LDAP_REFERRALS
- || ( ld->ld_defconn = new_connection( ld, NULL, 1,0,0 )) == NULL
+ || ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
#endif /* LDAP_REFERRALS */
) {
free( ld );
"cldap_result waiting up to %d seconds for a response\n",
tv.tv_sec, 0, 0 );
ber_init( &ber, 0 );
- set_ber_options( ld, &ber );
+ ldap_set_ber_options( ld, &ber );
if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) {
ret = ld->ld_errno;
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) {
if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage)))
- == NULL || ( ldm->lm_ber = alloc_ber_with_options( ld ))
+ == NULL || ( ldm->lm_ber = ldap_alloc_ber_with_options( ld ))
== NULLBER ) {
rc = LDAP_NO_MEMORY;
break; /* return w/error*/
#ifndef NO_CACHE
if ( ld->ld_cache != NULL ) {
- add_result_to_cache( ld, ldm );
+ ldap_add_result_to_cache( ld, ldm );
}
#endif /* NO_CACHE */
static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
+#include <ac/string.h>
#include <stdlib.h>
+
+#ifdef MACOS
#include "macos.h"
#else /* MACOS */
#if defined( DOS ) || defined( _WIN32 )
* getfilter.c -- optional add-on to libldap
*/
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
#include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
+#include <ac/string.h>
#include <ctype.h>
-#if defined(NeXT)
+#include <sys/types.h>
#include <regex.h>
-#endif
+
#ifdef MACOS
-#include <stdlib.h>
#include "macos.h"
#else /* MACOS */
#ifdef DOS
#else /* DOS */
#include <sys/types.h>
#include <sys/file.h>
-#include <stdlib.h>
#include <sys/errno.h>
#ifndef VMS
#include <unistd.h>
#include "lber.h"
#include "ldap.h"
-#include "regex.h"
-
-#ifdef NEEDPROTOS
-static int break_into_words( char *str, char *delims, char ***wordsp );
-int next_line_tokens( char **bufp, long *blenp, char ***toksp );
-void free_strarray( char **sap );
-#else /* NEEDPROTOS */
-static int break_into_words();
-int next_line_tokens();
-void free_strarray();
-#endif /* NEEDPROTOS */
-#if !defined( MACOS ) && !defined( DOS )
-extern int errno;
-extern char *re_comp();
-#endif
+static int break_into_words LDAP_P(( char *str, char *delims, char ***wordsp ));
+int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
+void free_strarray LDAP_P(( char **sap ));
#define FILT_MAX_LINE_LEN 1024
LDAPFiltDesc *lfdp;
LDAPFiltList *flp, *nextflp;
LDAPFiltInfo *fip, *nextfip;
- char *tag, **tok;
- int tokcnt, i;
+ char *tag, **tok;
+ int tokcnt, i;
+ int rc;
+ regex_t re;
if (( lfdp = (LDAPFiltDesc *)calloc( 1, sizeof( LDAPFiltDesc))) == NULL ) {
return( NULL );
}
nextflp->lfl_tag = strdup( tag );
nextflp->lfl_pattern = tok[ 0 ];
- if ( re_comp( nextflp->lfl_pattern ) != NULL ) {
+ if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) {
#ifndef NO_USERINTERFACE
+ char error[512];
+ regerror(rc, &re, error, sizeof(error));
ldap_getfilter_free( lfdp );
- fprintf( stderr, "bad regular expresssion %s\n",
- nextflp->lfl_pattern );
+ fprintf( stderr, "bad regular expresssion %s, %s\n",
+ nextflp->lfl_pattern, error );
#if !defined( MACOS ) && !defined( DOS )
errno = EINVAL;
#endif
free_strarray( tok );
return( NULL );
}
+ regfree(&re);
nextflp->lfl_delims = tok[ 1 ];
nextflp->lfl_ilist = NULL;
ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
{
LDAPFiltList *flp;
+ int rc;
+ regex_t re;
if ( lfdp->lfd_curvalcopy != NULL ) {
free( lfdp->lfd_curvalcopy );
lfdp->lfd_curval = value;
lfdp->lfd_curfip = NULL;
- for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
- if ( re_comp( tagpat ) == NULL && re_exec( flp->lfl_tag ) == 1
- && re_comp( flp->lfl_pattern ) == NULL
- && re_exec( lfdp->lfd_curval ) == 1 ) {
- lfdp->lfd_curfip = flp->lfl_ilist;
- break;
- }
+ for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
+ /* compile tagpat, continue if we fail */
+ if (regcomp(&re, tagpat, 0) != 0)
+ continue;
+
+ /* match tagpatern and tag, continue if we fail */
+ rc = regexec(&re, flp->lfl_tag, 0, NULL, 0);
+ regfree(&re);
+ if (rc != 0)
+ continue;
+
+ /* compile flp->ifl_pattern, continue if we fail */
+ if (regcomp(&re, flp->lfl_pattern, 0) != 0)
+ continue;
+
+ /* match ifl_pattern and lfd_curval, continue if we fail */
+ rc = regexec(&re, lfdp->lfd_curval, 0, NULL, 0);
+ regfree(&re);
+ if (rc != 0)
+ continue;
+
+ /* we successfully compiled both patterns and matched both values */
+ lfdp->lfd_curfip = flp->lfl_ilist;
+ break;
}
if ( lfdp->lfd_curfip == NULL ) {
static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
#endif
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
+#include <stdlib.h>
+#include <ac/string.h>
#include <errno.h>
#ifdef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <netdb.h>
+#include <unistd.h>
#endif /* _WIN32 */
#ifdef _AIX
#include <sys/select.h>
#ifdef VMS
#include "ucx_select.h"
#endif /* VMS */
+
#include "portable.h"
#include "lber.h"
#include "ldap.h"
#endif /* DOS */
#endif /* MACOS */
+#include "ldap-int.h"
int
-connect_to_host( Sockbuf *sb, char *host, unsigned long address,
+ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
int port, int async )
/*
* if host == NULL, connect using address
* XXX async is not used yet!
*/
{
- int rc, i, s, connected, use_hp;
+ int rc, i, s = 0;
+ int connected, use_hp;
struct sockaddr_in sin;
- struct hostent *hp;
+ struct hostent *hp = NULL;
#ifdef notyet
#ifdef LDAP_REFERRALS
int status; /* for ioctl call */
#endif /* LDAP_REFERRALS */
#endif /* notyet */
- Debug( LDAP_DEBUG_TRACE, "connect_to_host: %s:%d\n",
+ Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n",
( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 );
connected = use_hp = 0;
void
-close_connection( Sockbuf *sb )
+ldap_close_connection( Sockbuf *sb )
{
tcp_close( sb->sb_sd );
}
#ifdef KERBEROS
char *
-host_connected_to( Sockbuf *sb )
+ldap_host_connected_to( Sockbuf *sb )
{
struct hostent *hp;
char *p;
void
-mark_select_write( LDAP *ld, Sockbuf *sb )
+ldap_mark_select_write( LDAP *ld, Sockbuf *sb )
{
struct selectinfo *sip;
void
-mark_select_read( LDAP *ld, Sockbuf *sb )
+ldap_mark_select_read( LDAP *ld, Sockbuf *sb )
{
struct selectinfo *sip;
void
-mark_select_clear( LDAP *ld, Sockbuf *sb )
+ldap_mark_select_clear( LDAP *ld, Sockbuf *sb )
{
struct selectinfo *sip;
int
-is_write_ready( LDAP *ld, Sockbuf *sb )
+ldap_is_write_ready( LDAP *ld, Sockbuf *sb )
{
struct selectinfo *sip;
int
-is_read_ready( LDAP *ld, Sockbuf *sb )
+ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
{
struct selectinfo *sip;
void *
-new_select_info()
+ldap_new_select_info()
{
struct selectinfo *sip;
void
-free_select_info( void *sip )
+ldap_free_select_info( void *sip )
{
free( sip );
}
if ( tblsize == 0 ) {
#ifdef USE_SYSCONF
tblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
+#else /* !USE_SYSCONF */
tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
+#endif /* !USE_SYSCONF */
+
+#ifdef FD_SETSIZE
+ if( tblsize > FD_SETSIZE ) {
+ tblsize = FD_SETSIZE;
+ }
+#endif /* FD_SETSIZE*/
}
sip = (struct selectinfo *)ld->ld_selectinfo;
a->asi_names = charray_dup( argv );
argv[lasti] = save;
- switch ( avl_insert( &attr_syntaxes, a, attr_syntax_cmp,
+ switch ( avl_insert( &attr_syntaxes, (caddr_t) a, attr_syntax_cmp,
attr_syntax_dup ) ) {
case -1: /* duplicate - different syntaxes */
Debug( LDAP_DEBUG_ARGS, "%s: line %d: duplicate attribute\n",
a->ai_indexmask |= INDEX_FROMINIT;
}
- switch (avl_insert( &li->li_attrs, a, ainfo_cmp, ainfo_dup )) {
+ switch (avl_insert( &li->li_attrs, (caddr_t) a, ainfo_cmp, ainfo_dup )) {
case 1: /* duplicate - updating init version */
free( a->ai_type );
free( (char *) a );
/* set cache mutex */
pthread_mutex_lock( &cache->c_mutex );
- if ( avl_insert( &cache->c_dntree, e, cache_entrydn_cmp, avl_dup_error )
- != 0 ) {
+ if ( avl_insert( &cache->c_dntree, (caddr_t) e,
+ cache_entrydn_cmp, avl_dup_error ) != 0 )
+ {
Debug( LDAP_DEBUG_TRACE,
"entry %20s id %d already in dn cache\n", e->e_dn,
e->e_id, 0 );
}
/* id tree */
- if ( avl_insert( &cache->c_idtree, e, cache_entryid_cmp, avl_dup_error )
- != 0 ) {
+ if ( avl_insert( &cache->c_idtree, (caddr_t) e,
+ cache_entryid_cmp, avl_dup_error ) != 0 )
+ {
Debug( LDAP_DEBUG_ANY, "entry %20s id %d already in id cache\n",
e->e_dn, e->e_id, 0 );
/* delete from dn tree inserted above */
- if ( avl_delete( &cache->c_dntree, e, cache_entrydn_cmp )
- == NULL ) {
+ if ( avl_delete( &cache->c_dntree, (caddr_t) e,
+ cache_entrydn_cmp ) == NULL )
+ {
Debug( LDAP_DEBUG_ANY, "can't delete from dn cache\n",
0, 0, 0 );
}
pthread_mutex_lock( &cache->c_mutex );
e.e_dn = dn;
- if ( (ep = (Entry *) avl_find( cache->c_dntree, &e, cache_entrydn_cmp ))
- != NULL ) {
+ if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
+ cache_entrydn_cmp )) != NULL )
+ {
/*
* entry is deleted or not fully created yet
*/
pthread_mutex_lock( &cache->c_mutex );
e.e_id = id;
- if ( (ep = (Entry *) avl_find( cache->c_idtree, &e, cache_entryid_cmp ))
- != NULL ) {
+ if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
+ cache_entryid_cmp )) != NULL )
+ {
/*
* entry is deleted or not fully created yet
*/
)
{
/* dn tree */
- if ( avl_delete( &cache->c_dntree, e, cache_entrydn_cmp ) == NULL ) {
+ if ( avl_delete( &cache->c_dntree, (caddr_t) e, cache_entrydn_cmp )
+ == NULL )
+ {
return( -1 );
}
/* id tree */
- if ( avl_delete( &cache->c_idtree, e, cache_entryid_cmp ) == NULL ) {
+ if ( avl_delete( &cache->c_idtree, (caddr_t) e, cache_entryid_cmp )
+ == NULL )
+ {
return( -1 );
}
#include "back-ldbm.h"
#include "ldapconfig.h"
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
/* idl.c - ldap id list handling routines */
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
+#include <ac/string.h>
+
#include <sys/types.h>
+#ifdef CLDAP
#include <sys/socket.h>
+#endif
#include "slap.h"
#include "ldapconfig.h"
#include "back-ldbm.h"
char *kstr;
int i, nids;
+#ifdef LDBM_USE_DB2
+ memset( &k2, 0, sizeof( k2 ) );
+ memset( &data, 0, sizeof( data ) );
+#endif
+
/* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch_one\n", 0, 0, 0 ); */
data = ldbm_cache_fetch( db, key );
char *kstr;
int i, nids;
+#ifdef LDBM_USE_DB2
+ memset( &k2, 0, sizeof( k2 ) );
+ memset( &data, 0, sizeof( data ) );
+#endif
+
/* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch\n", 0, 0, 0 ); */
data = ldbm_cache_fetch( db, key );
IDList *idl
)
{
- int rc;
+ int rc, flags;
Datum data;
+ struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+
+#ifdef LDBM_USE_DB2
+ memset( &data, 0, sizeof( data ) );
+#endif
/* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */
data.dptr = (char *) idl;
data.dsize = (2 + idl->b_nmax) * sizeof(ID);
+
+#ifdef LDBM_DEBUG
+ Statslog( LDAP_DEBUG_STATS, "<= idl_store(): rc=%d\n",
+ rc, 0, 0, 0, 0 );
+#endif
- rc = ldbm_cache_store( db, key, data, LDBM_REPLACE );
+ flags = LDBM_REPLACE;
+ if( li->li_flush_wrt ) flags |= LDBM_SYNC;
+ rc = ldbm_cache_store( db, key, data, flags );
/* Debug( LDAP_DEBUG_TRACE, "<= idl_store %d\n", rc, 0, 0 ); */
return( rc );
char *kstr;
Datum k2;
+#ifdef LDBM_USE_DB2
+ memset( &k2, 0, sizeof( k2 ) );
+#endif
+
if ( (idl = idl_fetch_one( be, db, key )) == NULL ) {
+#ifdef LDBM_DEBUG
+ Statslog( LDAP_DEBUG_STATS, "=> idl_insert_key(): no key yet\n",
+ 0, 0, 0, 0, 0 );
+#endif
+
idl = idl_alloc( 1 );
idl->b_ids[idl->b_nids++] = id;
rc = idl_store( be, db, key, idl );
if ( a == NULL ) {
return( NULL );
}
- if ( b == NULL ) {
+ if ( b == NULL || ALLIDS( b )) {
return( idl_dup( a ) );
}
- if ( ALLIDS( b ) ) {
- return( NULL );
- }
if ( ALLIDS( a ) ) {
n = idl_alloc( SLAPD_LDBM_MIN_MAXIDS );
extern pthread_mutex_t ops_mutex;
extern pthread_t listener_tid;
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
extern Operation *op_add();
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
zero.tv_usec = 0;
Debug( LDAP_DEBUG_CONNS, "before select active_threads %d\n",
active_threads, 0, 0 );
-#if defined(PTHREAD_PREEMPTIVE) || defined(NO_THREADS)
+#if defined(THREAD_PREEMPTIVE) || defined(NO_THREADS)
tvp = NULL;
#else
tvp = active_threads ? &zero : NULL;
#include <signal.h>
#include "slap.h"
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
+#define DISABLE_BRIDGE
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
+#include <ac/string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <limits.h>
-#include "portable.h"
+
#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
int i;
extern char *optarg;
+#ifdef LDBM_USE_DB2
+ DBC *cursorp;
+#endif
+
tailorfile = SLAPD_DEFAULT_CONFIGFILE;
while ( (i = getopt( argc, argv, "d:f:" )) != EOF ) {
switch ( i ) {
}
savekey.dptr = NULL;
+#ifdef LDBM_USE_DB2
+ for ( key = ldbm_firstkey( dbc->dbc_db, &cursorp );
+ key.dptr != NULL;
+ key = ldbm_nextkey( dbc->dbc_db, key, cursorp ) )
+#else
for ( key = ldbm_firstkey( dbc->dbc_db );
key.dptr != NULL;
- key = ldbm_nextkey( dbc->dbc_db, key ) ) {
+ key = ldbm_nextkey( dbc->dbc_db, key ) )
+#endif
+ {
if ( savekey.dptr != NULL )
ldbm_datum_free( dbc->dbc_db, savekey );
savekey = key;
}
last.dptr = NULL;
+
+#ifdef LDBM_USE_DB2
+ for ( key = ldbm_firstkey( dbp, &cursorp );
+ key.dptr != NULL;
+ key = ldbm_nextkey( dbp, last, cursorp ) )
+#else
for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
- key = ldbm_nextkey( dbp, last ) ) {
+ key = ldbm_nextkey( dbp, last ) )
+#endif
+ {
if ( last.dptr != NULL ) {
ldbm_datum_free( dbp, last );
}
static void set_shutdown LDAP_P((void));
void do_nothing LDAP_P((void));
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */
/* External references */
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */
extern char *str_getline LDAP_P(( char **next ));
extern void ch_free LDAP_P(( char *p ));
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */
#include "slurp.h"
#include "globals.h"
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */
int file_nonempty LDAP_P(( char * ));
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif
/* externs */
extern void Re_dump LDAP_P(( Re *re ));
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */
#include "slurp.h"
#include "globals.h"
-#ifndef DECL_SYS_ERRLIST
+#ifdef DECL_SYS_ERRLIST
extern char *sys_errlist[];
#endif /* DECL_SYS_ERRLIST */