diff --git a/build/main.dsw b/build/main.dsw
index e728552c96b0d24dd2771836159c04b24265e446..2b8c9582c28f20fb80bebb9a6fc896f6c9284721 100644
--- a/build/main.dsw
+++ b/build/main.dsw
@@ -338,6 +338,15 @@ Package=<4>
     Begin Project Dependency
     Project_Dep_Name liblber
     End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldif
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name libldap
+    End Project Dependency
+    Begin Project Dependency
+    Project_Dep_Name liblutil
+    End Project Dependency
 }}}
 
 ###############################################################################
diff --git a/clients/fax500/main.c b/clients/fax500/main.c
index 614fe416d36b4461d3d57ccd0f860472f09acdc1..5bc84f2fb8efed7a7f7afa7ab44f8040b994ef28 100644
--- a/clients/fax500/main.c
+++ b/clients/fax500/main.c
@@ -34,12 +34,10 @@
 #include <sys/resource.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #include "fax500.h"
-
-#include <ldap_defaults.h>
+#include "ldap_defaults.h"
 
 #define USER		0
 #define GROUP_ERRORS	1
diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c
index 3b93ea5943ec602b1f10665b778e9683b9473831..bc8032530575d8ef452d56413400ace44a332d1d 100644
--- a/clients/fax500/rp500.c
+++ b/clients/fax500/rp500.c
@@ -33,8 +33,7 @@
 #include <ldap.h>
 
 #include "fax500.h"
-
-#include <ldap_defaults.h>
+#include "ldap_defaults.h"
 
 #define DEFAULT_PORT		79
 #define DEFAULT_SIZELIMIT	50
@@ -219,7 +218,7 @@ main( int argc, char **argv )
 
 		if ( fgets( buf, sizeof(buf), stdin ) == NULL
 		    || buf[0] == '\n' ) {
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 		i = atoi( buf ) - 1;
 		e = ldap_first_entry( ld, result );
@@ -228,13 +227,13 @@ main( int argc, char **argv )
 		}
 		if ( e == NULL ) {
 			fprintf( stderr, "Invalid choice!\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		print_entry( ld, e );
 	} else if ( matches == 0 ) {
 		fprintf( stderr, "No matches found for \"%s\"\n", key );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else {
 		fprintf( stderr, "Error return from ldap_count_entries\n" );
 		exit( -1 );
@@ -260,7 +259,7 @@ print_entry( LDAP *ld, LDAPMessage *e )
 	if ( (fax = ldap_get_values( ld, e, "facsimileTelephoneNumber" ))
 	    == NULL ) {
 		fprintf( stderr, "Entry \"%s\" has no fax number.\n", dn );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	faxmail = faxtotpc( fax[0], NULL );
 	title = ldap_get_values( ld, e, "title" );
diff --git a/clients/finger/main.c b/clients/finger/main.c
index 19e72277df6949e02b7e7d44f7594dcb46357a40..63b77e9a4bf2fb8aae55d833db4da5f24daf5608 100644
--- a/clients/finger/main.c
+++ b/clients/finger/main.c
@@ -29,10 +29,8 @@
 #include <sys/resource.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
-
-#include "disptmpl.h"
+#include <ldap.h>
+#include <disptmpl.h>
 
 #include "ldap_defaults.h"
 
@@ -54,7 +52,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -108,7 +106,7 @@ main( int argc, char **argv )
 		if ( getpeername( 0, (struct sockaddr *)&peername,
 		    &peernamelen ) != 0 ) {
 			perror( "getpeername" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -161,7 +159,7 @@ do_query( void )
 	if ( (ld = ldap_init( ldaphost, ldapport )) == NULL ) {
 		fprintf( stderr, FINGER_UNAVAILABLE );
 		perror( "ldap_init" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	{
@@ -175,7 +173,7 @@ do_query( void )
 	{
 		fprintf( stderr, FINGER_UNAVAILABLE );
 		ldap_perror( ld, "ldap_simple_bind_s" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 #ifdef HAVE_SYSCONF
@@ -202,11 +200,11 @@ do_query( void )
 			perror( "select" );
 		else
 			fprintf( stderr, "connection timed out on input\r\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( fgets( buf, sizeof(buf), stdin ) == NULL )
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	len = strlen( buf );
 
@@ -279,7 +277,7 @@ do_search( LDAP *ld, char *buf )
 		    != LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
 			fprintf( stderr, FINGER_UNAVAILABLE );
 			ldap_perror( ld, "ldap_search_st" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		matches = ldap_count_entries( ld, result );
@@ -290,7 +288,7 @@ do_search( LDAP *ld, char *buf )
 		    == NULL ) {
 			fprintf( stderr, "Cannot open filter file (%s)\n",
 			    filterfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		for ( fi = ldap_getfirstfilter( fd, "finger", buf );
@@ -306,7 +304,7 @@ do_search( LDAP *ld, char *buf )
 			{
 				fprintf( stderr, FINGER_UNAVAILABLE );
 				ldap_perror( ld, "ldap_search_st" );
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 
 			if ( (matches = ldap_count_entries( ld, result )) != 0 )
@@ -330,7 +328,7 @@ do_search( LDAP *ld, char *buf )
 		fflush( stdout );
 	} else if ( matches < 0 ) {
 		fprintf( stderr, "error return from ldap_count_entries\r\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( matches <= FINGER_LISTLIMIT ) {
 		printf( "%d %s match%s found for \"%s\":\r\n", matches,
 		    ufn ? "UFN" : fi->lfi_desc, matches > 1 ? "es" : "", buf );
@@ -431,7 +429,7 @@ do_read( LDAP *ld, LDAPMessage *e )
 	    defvals, entry2textwrite, (void *)stdout, "\r\n", rdncount,
 	    LDAP_DISP_OPT_DOSEARCHACTIONS ) != LDAP_SUCCESS ) {
 		ldap_perror( ld, "ldap_entry2text_search" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( tmpllist != NULL ) {
diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c
index 3d95f4d6f3ab505d141d9b44d442f330f6696975..234d908691a381466da3285c115f2ae56801d18f 100644
--- a/clients/gopher/go500.c
+++ b/clients/gopher/go500.c
@@ -35,16 +35,16 @@
 #include <sys/resource.h>
 #endif
 
+#include <ldap.h>
+#include <disptmpl.h>
+
 #include "ldap_defaults.h"
-#include "lber.h"
-#include "ldap.h"
 
 #define ldap_debug debug
 #include "ldap_log.h"
 
 #include "lutil.h"
 
-#include "disptmpl.h"
 
 int	debug;
 int	dosyslog;
@@ -74,7 +74,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-d debuglevel] [-f filterfile] [-t templatefile]\r\n\t[-a] [-l] [-p port] [-x ldaphost] [-b searchbase] [-c rdncount]\r\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -144,7 +144,7 @@ main( int argc, char **argv )
 	if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost) )
 	    == -1 ) {
 		perror( "gethostname" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 #endif
 
@@ -222,7 +222,7 @@ main( int argc, char **argv )
 
 		do_queries( 0 );
 
-		exit( 0 );
+		exit( EXIT_SUCCESS );
 	}
 
 	for ( ;; ) {
@@ -243,7 +243,7 @@ main( int argc, char **argv )
 		if ( (ns = accept( s, (struct sockaddr *) &from, &fromlen ))
 		    == -1 ) {
 			if ( debug ) perror( "accept" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
@@ -287,7 +287,7 @@ set_socket( int port )
 
 	if ( (s = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) {
                 perror( "socket" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         /* set option so clients can't keep us from coming back up */
@@ -295,7 +295,7 @@ set_socket( int port )
         if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
 	    sizeof(one) ) < 0 ) {
                 perror( "setsockopt" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         /* bind to a name */
@@ -304,13 +304,13 @@ set_socket( int port )
         addr.sin_port = htons( port );
         if ( bind( s, (struct sockaddr *) &addr, sizeof(addr) ) ) {
                 perror( "bind" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
 	/* listen for connections */
         if ( listen( s, 5 ) == -1 ) {
                 perror( "listen" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         if ( debug ) printf("tcp socket allocated, bound, and listening\n");
@@ -350,7 +350,7 @@ do_queries( int s )
 	LDAP		*ld;
 
 	if ( (fp = fdopen( s, "a+")) == NULL ) {
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	timeout.tv_sec = GO500_TIMEOUT;
@@ -359,10 +359,10 @@ do_queries( int s )
 	FD_SET( fileno( fp ), &readfds );
 
 	if ( (rc = select( dtblsize, &readfds, 0, 0, &timeout )) <= 0 )
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	if ( fgets( buf, sizeof(buf), fp ) == NULL )
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	len = strlen( buf );
 	if ( debug ) {
@@ -398,7 +398,7 @@ do_queries( int s )
 			LDAP_SERVER_DOWN, myhost, myport );
 		fprintf( fp, ".\r\n" );
 		rewind(fp);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else {
 		int deref = GO500_DEREF;
 		ldap_set_option(ld, LDAP_OPT_DEREF, &deref);
@@ -410,7 +410,7 @@ do_queries( int s )
 			    rc, myhost, myport );
 			fprintf( fp, ".\r\n" );
 			rewind(fp);
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -443,7 +443,7 @@ do_queries( int s )
 		ldap_unbind( ld );
 	}
 
-	exit( 1 );
+	exit( EXIT_FAILURE );
 	/* NOT REACHED */
 }
 
@@ -493,7 +493,7 @@ do_search( LDAP *ld, FILE *fp, char *buf )
 		if ( (filtd = ldap_init_getfilter( filterfile )) == NULL ) {
 			fprintf( stderr, "Cannot open filter file (%s)\n",
 			    filterfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		tv.tv_sec = GO500_TIMEOUT;
@@ -585,7 +585,7 @@ do_read( LDAP *ld, FILE *fp, char *dn )
 	    entry2textwrite, (void *) fp, "\r\n", rdncount,
 	    LDAP_DISP_OPT_DOSEARCHACTIONS ) != LDAP_SUCCESS ) {
 		ldap_perror( ld, "ldap_entry2text_search" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( tmpllist != NULL ) {
diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c
index 4ee45391c706b63a5a989085e31ef3057e82ac58..c68b3522ef6344b56bfa0d4a158a055a4f1262e2 100644
--- a/clients/gopher/go500gw.c
+++ b/clients/gopher/go500gw.c
@@ -36,15 +36,14 @@
 #endif
 
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
+#include <disptmpl.h>
 
 #define ldap_debug debug
 #include "ldap_log.h"
 
 #include "lutil.h"
 
-#include "disptmpl.h"
 
 #include "ldap_defaults.h"
 
@@ -88,7 +87,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-d debuglevel] [-I] [-p port] [-P ldapport] [-l]\r\n\t[-x ldaphost] [-a] [-h helpfile] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -182,7 +181,7 @@ main (int  argc, char **argv )
 	if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost) )
 	    == -1 ) {
 		perror( "gethostname" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 #endif
 
@@ -248,7 +247,7 @@ main (int  argc, char **argv )
 
 		tcp_close( 0 );
 
-		exit( 0 );
+		exit( EXIT_SUCCESS );
 	}
 
 	for ( ;; ) {
@@ -269,7 +268,7 @@ main (int  argc, char **argv )
 		if ( (ns = accept( s, (struct sockaddr *) &from, &fromlen ))
 		    == -1 ) {
 			if ( debug ) perror( "accept" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
@@ -313,7 +312,7 @@ set_socket( int port )
 
 	if ( (s = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) {
                 perror( "socket" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         /* set option so clients can't keep us from coming back up */
@@ -321,7 +320,7 @@ set_socket( int port )
         if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
 	    sizeof(one) ) < 0 ) {
                 perror( "setsockopt" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         /* bind to a name */
@@ -330,13 +329,13 @@ set_socket( int port )
         addr.sin_port = htons( port );
         if ( bind( s, (struct sockaddr *) &addr, sizeof(addr) ) ) {
                 perror( "bind" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
 	/* listen for connections */
         if ( listen( s, 5 ) == -1 ) {
                 perror( "listen" );
-                exit( 1 );
+                exit( EXIT_FAILURE );
         }
 
         if ( debug )
@@ -379,7 +378,7 @@ do_queries( int s )
 
 	if ( (fp = fdopen( s, "a+")) == NULL ) {
 		perror( "fdopen" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	timeout.tv_sec = GO500GW_TIMEOUT;
@@ -388,10 +387,10 @@ do_queries( int s )
 	FD_SET( fileno( fp ), &readfds );
 
 	if ( (rc = select( dtblsize, &readfds, 0, 0, &timeout )) <= 0 )
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	if ( fgets( buf, sizeof(buf), fp ) == NULL )
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	len = strlen( buf );
 	if ( debug ) {
@@ -437,7 +436,7 @@ do_queries( int s )
 		fprintf( fp, ".\r\n" );
 		rewind(fp);
 
-		exit( 0 );
+		exit( EXIT_SUCCESS );
 		/* NOT REACHED */
 	}
 
@@ -447,7 +446,7 @@ do_queries( int s )
 		    LDAP_SERVER_DOWN, myhost, myport );
 		fprintf( fp, ".\r\n" );
 		rewind(fp);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	deref = LDAP_DEREF_ALWAYS;
@@ -463,7 +462,7 @@ do_queries( int s )
 		    rc, myhost, myport );
 		fprintf( fp, ".\r\n" );
 		rewind(fp);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	switch ( *query++ ) {
@@ -487,7 +486,7 @@ do_queries( int s )
 	fprintf( fp, ".\r\n" );
 	rewind(fp);
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 	/* NOT REACHED */
 }
 
@@ -729,7 +728,7 @@ do_search( LDAP *ld, FILE *fp, char *query )
 
 	if ( (filter = strchr( query, '\t' )) == NULL ) {
 		fprintf( fp, "3Missing filter!\r\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	*filter++ = '\0';
 	base = query;
@@ -757,7 +756,7 @@ do_search( LDAP *ld, FILE *fp, char *query )
 #endif
 		if ( (scope = make_scope( ld, base )) == -1 ) {
 			fprintf( fp, "3Bad scope\r\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		filtertype = (scope == LDAP_SCOPE_ONELEVEL ?
@@ -771,7 +770,7 @@ do_search( LDAP *ld, FILE *fp, char *query )
 		if ( (filtd = ldap_init_getfilter( filterfile )) == NULL ) {
 			fprintf( stderr, "Cannot open filter file (%s)\n",
 			    filterfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 
 		count = 0;
diff --git a/clients/mail500/main.c b/clients/mail500/main.c
index 67da27b8e14ce531afbe724b4a943c43f3e27075..678663805d2714196c757b66697e80a88ba053a7 100644
--- a/clients/mail500/main.c
+++ b/clients/mail500/main.c
@@ -39,8 +39,7 @@
 #include <sys/resource.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #include "ldap_defaults.h"
 
diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c
index 9a37edae751195bd4bb18e08aa1d460668934899..74fe9d088d56c7cb70549ba37ba3c58c58a7ce1b 100644
--- a/clients/rcpt500/main.c
+++ b/clients/rcpt500/main.c
@@ -112,7 +112,7 @@ main( int argc, char **argv )
     }
     if ( errflg || optind < argc ) {
 	fprintf( stderr, usage, prog );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
 #ifdef SIGPIPE
@@ -243,7 +243,7 @@ read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
 	if ( dosyslog ) {
 	    syslog( LOG_ERR, "strdup: %m" );
 	}
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     while ( 1 ) {
@@ -257,7 +257,7 @@ read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
 	    if ( dosyslog ) {
 		syslog( LOG_ERR, "realloc: %m" );
 	    }
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	strcat( hdr, "\n" );
 	strcat( hdr, *linep );
diff --git a/clients/rcpt500/query.c b/clients/rcpt500/query.c
index 53b55729d629939fd288e3c4ae43e96abf56b972..dac5f15fc92f2435b0be5aed35915443b89774e2 100644
--- a/clients/rcpt500/query.c
+++ b/clients/rcpt500/query.c
@@ -8,8 +8,6 @@
 
 #include "portable.h"
 
-#include <stdio.h>
-
 #include <ac/stdlib.h>
 
 #include <ac/ctype.h>
@@ -17,10 +15,10 @@
 #include <ac/syslog.h>
 #include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <stdio.h>
 
-#include "disptmpl.h"
+#include <ldap.h>
+#include <disptmpl.h>
 
 #include "rcpt500.h"
 #include "ldap_defaults.h"
diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c
index ddd80e399b72ce524dbf729a9fb00ba6684a102b..c38e034e5c176b51c1f7093183159b0a322647e9 100644
--- a/clients/tools/ldapdelete.c
+++ b/clients/tools/ldapdelete.c
@@ -81,7 +81,7 @@ main( int argc, char **argv )
 	case 'f':	/* read DNs from a file */
 	    if (( fp = fopen( optarg, "r" )) == NULL ) {
 		perror( optarg );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	    break;
 	case 'd':
diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c
index 351ca5e37c89dfbb56829631ee1b71500cfb235a..52c8f52aca74a667c0f0d9260fc89eace07b6950 100644
--- a/clients/tools/ldapmodify.c
+++ b/clients/tools/ldapmodify.c
@@ -26,9 +26,9 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldif.h>
 
-#include <ldap_defaults.h>
+#include "ldif.h"
+#include "ldap_defaults.h"
 
 static char	*prog;
 static char	*binddn = NULL;
@@ -405,7 +405,7 @@ process_ldif_rec( char *rbuf, int count )
 	    } else if ( strcasecmp( type, T_DN_STR ) == 0 ) {
 		if (( dn = strdup( value )) == NULL ) {
 		    perror( "strdup" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		}
 		expect_ct = 1;
 	    }
@@ -471,7 +471,7 @@ process_ldif_rec( char *rbuf, int count )
 	    if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
 		if (( newrdn = strdup( value )) == NULL ) {
 		    perror( "strdup" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		}
 		expect_deleteoldrdn = 1;
 		expect_newrdn = 0;
@@ -495,7 +495,7 @@ process_ldif_rec( char *rbuf, int count )
 	    if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
 		if (( newsup = strdup( value )) == NULL ) {
 		    perror( "strdup" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		}
 		expect_newsup = 0;
 	    } else {
@@ -579,7 +579,7 @@ process_ldapmod_rec( char *rbuf )
 	if ( dn == NULL ) {	/* first line contains DN */
 	    if (( dn = strdup( line )) == NULL ) {
 		perror( "strdup" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	} else {
 	    if (( p = strchr( line, '=' )) == NULL ) {
@@ -682,19 +682,19 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
 	if (( pmods = (LDAPMod **)ber_memrealloc( pmods, (i + 2) *
 		sizeof( LDAPMod * ))) == NULL ) {
 	    perror( "realloc" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	*pmodsp = pmods;
 	pmods[ i + 1 ] = NULL;
 	if (( pmods[ i ] = (LDAPMod *)ber_memcalloc( 1, sizeof( LDAPMod )))
 		== NULL ) {
 	    perror( "calloc" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	pmods[ i ]->mod_op = modop;
 	if (( pmods[ i ]->mod_type = ber_strdup( attr )) == NULL ) {
 	    perror( "strdup" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
     }
 
@@ -709,25 +709,25 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
 		(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
 		(j + 2) * sizeof( struct berval * ))) == NULL ) {
 	    perror( "ber_realloc" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
 	if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
 		== NULL ) {
 	    perror( "ber_memalloc" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	pmods[ i ]->mod_bvalues[ j ] = bvp;
 
 	if ( valsfromfiles && *value == '/' ) {	/* get value from file */
 	    if ( fromfile( value, bvp ) < 0 ) {
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	} else {
 	    bvp->bv_len = vlen;
 	    if (( bvp->bv_val = (char *)ber_memalloc( vlen + 1 )) == NULL ) {
 		perror( "malloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	    SAFEMEMCPY( bvp->bv_val, value, vlen );
 	    bvp->bv_val[ vlen ] = '\0';
@@ -926,7 +926,7 @@ read_one_record( FILE *fp )
 
 			if (( buf = (char *)realloc( buf, lmax )) == NULL ) {
 				perror( "realloc" );
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 		}
 
diff --git a/clients/tools/ldapmodify.dsw b/clients/tools/ldapmodify.dsw
index c8186761c36bd3cffd47274c45525df8c389e58a..7c38c08844983b6f2608b2288db1ca4c66f1b152 100644
--- a/clients/tools/ldapmodify.dsw
+++ b/clients/tools/ldapmodify.dsw
@@ -78,6 +78,18 @@ Package=<4>
 
 ###############################################################################
 
+Project: "setup"=..\..\include\setup.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
 Global:
 
 Package=<5>
diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c
index 3d48a2d2c5eebfd64104a0ffb81f57bacb371a6e..dfbd12c491f0bc1ff4cbde250d2e228edd0371c1 100644
--- a/clients/tools/ldappasswd.c
+++ b/clients/tools/ldappasswd.c
@@ -351,7 +351,7 @@ usage (char *s)
 	fprintf (stderr, "  -Y saltlen\tsalt length to use\n");
 /*      fprintf (stderr, "  -y salt\tsalt to use\n"); */
 	fprintf (stderr, "  -z size\tsize limit\n");
-	exit (1);
+	exit( EXIT_FAILURE );
 }
 
 int
diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c
index 2a8f8822e28ded8fb7e0381dd6430b6c1a0bbfa6..0476b198f8ab5f0bba4dc415e54d2fd53203d0be 100644
--- a/clients/tools/ldapsearch.c
+++ b/clients/tools/ldapsearch.c
@@ -10,8 +10,8 @@
 #include <ac/unistd.h>
 
 #include <ldap.h>
-#include <ldif.h>
 
+#include "ldif.h"
 #include "ldap_defaults.h"
 
 #define DEFSEP		"="
diff --git a/clients/ud/auth.c b/clients/ud/auth.c
index e3968a04ef0de40c27368f10ca8069a4f9d89c9d..89580347bbd3656722bce8cbe8749305db098de0 100644
--- a/clients/ud/auth.c
+++ b/clients/ud/auth.c
@@ -28,8 +28,8 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
 
+#include "ldap_defaults.h"
 #include "ud.h"
 
 #ifdef HAVE_KERBEROS
diff --git a/clients/ud/edit.c b/clients/ud/edit.c
index 3cc1530d9bdebc507f90bba09d27036f834d8662..997926c23d1f9a3977d380b5127b45fd1b368acb 100644
--- a/clients/ud/edit.c
+++ b/clients/ud/edit.c
@@ -32,7 +32,8 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
+
+#include "ldap_defaults.h"
 #include "ud.h"
 
 static int  load_editor( void );
diff --git a/clients/ud/group.c b/clients/ud/group.c
index e8ef8b48fdf944f2b3bb419ec2bb289f97b5c541..3b7a87fb1c3143b81ed2879df79e15b337bac1aa 100644
--- a/clients/ud/group.c
+++ b/clients/ud/group.c
@@ -26,7 +26,8 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
+
+#include "ldap_defaults.h"
 #include "ud.h"
 
 static char * bind_and_fetch(char *name);
diff --git a/clients/ud/main.c b/clients/ud/main.c
index ef8e1ae21aea31ebab7b10e2c26de2654b10c0bf..48df35676809c117deb7f4c7828746b870711336 100644
--- a/clients/ud/main.c
+++ b/clients/ud/main.c
@@ -46,7 +46,7 @@
 #include <lber.h>
 #include <ldap.h>
 
-#include <ldap_defaults.h>
+#include "ldap_defaults.h"
 #include "ud.h"
 
 /*
@@ -139,10 +139,10 @@ main( int argc, char **argv )
 			printf("   64  authentication information\n");
 			printf("  128  initialization information\n\n");
 			format("These are masks, and may be added to form multiple debug levels.  For example, '-d 35' would perform a function trace, print out information about the find() function, and would print out information about the output routines too.", 75, 2);
-			exit(0);
+			exit( EXIT_SUCCESS );
 		default:
 			fprintf(stderr, "Usage: %s [-c filter-config-file] [-d debug-level] [-l ldap-debug-level] [-s server] [-p port] [-V]\n", argv[0]);
-			exit(-1);
+			exit( EXIT_FAILURE);
 			/* NOTREACHED */
 		}
 	}
@@ -282,7 +282,7 @@ do_commands( void )
 #ifdef HAVE_KERBEROS
 	destroy_tickets();
 #endif
-	exit(0);
+	exit( EXIT_SUCCESS );
 	/* NOTREACHED */
 }
 
@@ -650,7 +650,7 @@ initialize_client( void )
 	 */
 	if ((ld = ldap_init(server, ldap_port)) == NULL) {
 		fprintf(stderr, "  Initialization of LDAP session failed.\n");
-		exit(0);
+		exit( EXIT_FAILURE );
 		/* NOTREACHED */
 	}
 	if (ldap_bind_s(ld, (char *) default_bind_object, NULL,
@@ -661,7 +661,7 @@ initialize_client( void )
 		fprintf(stderr, "  The LDAP Directory is temporarily unavailable.  Please try again later.\n");
 		if (ld_errno != LDAP_UNAVAILABLE)
 			ldap_perror(ld, "  ldap_bind_s");
-		exit(0);
+		exit( EXIT_FAILURE );
 		/* NOTREACHED */
 	}
 	{
diff --git a/clients/ud/util.c b/clients/ud/util.c
index 70a6c54ee91996a1a8d229693064ef11f3592b48..2efd2895d666f7ca457662f9d2eb638d78b14ef3 100644
--- a/clients/ud/util.c
+++ b/clients/ud/util.c
@@ -26,8 +26,8 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
 
+#include "ldap_defaults.h"
 #include "ud.h"
 
 void
@@ -102,7 +102,7 @@ fatal( char *s )
 #ifdef HAVE_KERBEROS
 	destroy_tickets();
 #endif
-	exit(-1);
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -451,7 +451,7 @@ Malloc( unsigned int size )
 	void_ptr = (void *) malloc(size);
 	if (void_ptr == NULL) {
 		perror("malloc");
-		exit(-1);
+		exit( EXIT_FAILURE );
 		/*NOTREACHED*/
 	}
 	return(void_ptr);
diff --git a/contrib/saucer/main.c b/contrib/saucer/main.c
index d99d3e558dc3e807db6732171d82e3bd69a7dcee..a49a3bf896a84cdb3b7f6132807550603e26f586 100644
--- a/contrib/saucer/main.c
+++ b/contrib/saucer/main.c
@@ -634,7 +634,7 @@ int main(int argc, char **argv)
 	if (error_flag) {
 		fprintf(stderr, "usage: %s [-h host] [-p portnumber] [-u X500UserName]\n\t[-c credentials] [-d debug-level]\n",
 				progname);
-		exit(2);
+		exit( EXIT_FAILURE );
 	}
 
 	rc = user_tailor();
@@ -642,7 +642,7 @@ int main(int argc, char **argv)
 	if (!(ld = ldap_init(hostname, portnum))) {
 		fprintf(stderr, "%s: unable to initialize LDAP session (%s:%d)\n",
 				progname, hostname, portnum);
-		exit(2);
+		exit( EXIT_FAILURE );
 	}
 
 	if (!bind_user())
diff --git a/contrib/web_ldap/web_ldap.c b/contrib/web_ldap/web_ldap.c
index 0be574aec27ba3f75b9324780e617ff72abd9a74..8747269551827ee6b1cd5bceb1ae115c51b28dfe 100644
--- a/contrib/web_ldap/web_ldap.c
+++ b/contrib/web_ldap/web_ldap.c
@@ -19,7 +19,7 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldif.h> 
+#include "ldif.h"
 #include "maint_form.h" /* for HTML Form manipulations */
 
 /* default values */
@@ -178,12 +178,12 @@ main(int argc, char ** argv) {
       if (strcompare(getenv("REQUEST_METHOD"),"POST"))
 	{
 	   printf("<p>++ Error - This script should be referenced with a METHOD of POST.\n");
-	   exit(1);
+	   exit( EXIT_FAILURE );
 	}
       if (strcompare(getenv("CONTENT_TYPE"),"application/x-www-form-urlencoded"))
 	{
 	   printf("<p>++ Error - This script can only be used to decode form results. \n");
-	   exit(1);
+	   exit( EXIT_FAILURE );
 	}
       cl = atoi(getenv("CONTENT_LENGTH"));
       
@@ -209,7 +209,7 @@ main(int argc, char ** argv) {
 	   printf("%s%s%s", "This script expected a 'FORM' value returned ",
 		  "and did not get one.  Make sure the HTML used for this ",
 		  "script is correct.");
-	   exit(1);
+	   exit( EXIT_FAILURE );
 	} 
       
       /* Looking for:
@@ -341,7 +341,7 @@ main(int argc, char ** argv) {
 	   }
 	}
 	printf("</body>\n</html>\n");
-	exit(1);
+	exit( EXIT_FAILURE );
      }
    
    /*authenticate as nobody */
@@ -373,7 +373,7 @@ main(int argc, char ** argv) {
 	   }
 	}
 	printf("</body>\n</html>\n");
-	exit(1);
+	exit( EXIT_FAILURE );
      }
    
    printf("<b>Directory Lookup Results</b>\n<pre>\n");
diff --git a/contrib/whois++/whois++.h b/contrib/whois++/whois++.h
index 6d148526e9a1831d8f6332ab6980360e3afdb148..bf77fceab5a6d8806a3d92d916fe740f767c9168 100644
--- a/contrib/whois++/whois++.h
+++ b/contrib/whois++/whois++.h
@@ -41,8 +41,7 @@
 #include <sys/time.h>
 #include <netinet/in.h>
 #include "syslog.h"
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #define	EQ(x,y)		(strcasecmp(x,y) == 0)
 
diff --git a/include/ac/stdlib.h b/include/ac/stdlib.h
index 505b30b5cf36bca486230f391c2ea40b102923ec..d642b459101a5549b891f4e062336e3efc45a501 100644
--- a/include/ac/stdlib.h
+++ b/include/ac/stdlib.h
@@ -12,16 +12,16 @@
 #ifndef _AC_STDLIB_H
 #define _AC_STDLIB_H
 
-#	include <stdlib.h>
+#include <stdlib.h>
 
-	/* Not sure if !STDC_HEADERS is needed */
-#	if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#		include <malloc.h>
-#	endif
+/* Ignore malloc.h if we have STDC_HEADERS */
+#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
+#	include <malloc.h>
+#endif
 
-#	ifndef EXIT_SUCCESS
-#		define EXIT_SUCCESS 0
-#		define EXIT_FAILURE 1
-#	endif
+#ifndef EXIT_SUCCESS
+#	define EXIT_SUCCESS 0
+#	define EXIT_FAILURE 1
+#endif
 
 #endif /* _AC_STDLIB_H */
diff --git a/include/ldap_pvt.h b/include/ldap_pvt.h
index 3bede83b2a3ca29cf15cccfd829160ed6b5d38db..3014e217ee0c32a7c8dcea437c358ba3cfc6a26d 100644
--- a/include/ldap_pvt.h
+++ b/include/ldap_pvt.h
@@ -73,6 +73,10 @@ ldap_str2charray LDAP_P((
 	char *str,
 	char *brkstr ));
 
+/* url.c */
+void ldap_pvt_hex_unescape LDAP_P(( char *s ));
+int ldap_pvt_unhex( int c );
+
 LDAP_END_DECL
 
 #endif
diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c
index 27678616ee33db1bbed29ff642379264dee0ec3e..de0870bc6c0b367ff219c66ea4c11710deaf230f 100644
--- a/libraries/libavl/avl.c
+++ b/libraries/libavl/avl.c
@@ -27,7 +27,7 @@ static char avl_version[] = "AVL library version 1.0\n";
 #define ROTATERIGHT(x)	{ \
 	Avlnode *tmp;\
 	if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
-		(void) fputs("RR error\n", stderr); exit(1); \
+		(void) fputs("RR error\n", stderr); exit( EXIT_FAILURE ); \
 	}\
 	tmp = (*(x))->avl_left;\
 	(*(x))->avl_left = tmp->avl_right;\
@@ -37,7 +37,7 @@ static char avl_version[] = "AVL library version 1.0\n";
 #define ROTATELEFT(x)	{ \
 	Avlnode *tmp;\
 	if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
-		(void) fputs("RL error\n", stderr); exit(1); \
+		(void) fputs("RL error\n", stderr); exit( EXIT_FAILURE ); \
 	}\
 	tmp = (*(x))->avl_right;\
 	(*(x))->avl_right = tmp->avl_left;\
diff --git a/libraries/libavl/testavl.c b/libraries/libavl/testavl.c
index 3328933ecace62fc79c92f46ea3ef6a9ddb6384f..bd6d35bf01edd5e1ea3e03be6ff0b610d06affdc 100644
--- a/libraries/libavl/testavl.c
+++ b/libraries/libavl/testavl.c
@@ -47,7 +47,7 @@ main( int argc, char **argv )
 		case 'f':	/* find */
 			printf( "data? " );
 			if ( fgets( name, sizeof( name ), stdin ) == NULL )
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			name[ strlen( name ) - 1 ] = '\0';
 			if ( (p = (char *) avl_find( tree, name, (AVL_CMP) strcmp ))
 			    == NULL )
@@ -58,7 +58,7 @@ main( int argc, char **argv )
 		case 'i':	/* insert */
 			printf( "data? " );
 			if ( fgets( name, sizeof( name ), stdin ) == NULL )
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			name[ strlen( name ) - 1 ] = '\0';
 			if ( avl_insert( &tree, strdup( name ), (AVL_CMP) strcmp, 
 			    avl_dup_error ) != 0 )
@@ -67,13 +67,13 @@ main( int argc, char **argv )
 		case 'd':	/* delete */
 			printf( "data? " );
 			if ( fgets( name, sizeof( name ), stdin ) == NULL )
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			name[ strlen( name ) - 1 ] = '\0';
 			if ( avl_delete( &tree, name, (AVL_CMP) strcmp ) == NULL )
 				printf( "\nNot found!\n" );
 			break;
 		case 'q':	/* quit */
-			exit( 0 );
+			exit( EXIT_SUCCESS );
 			break;
 		case '\n':
 			break;
diff --git a/libraries/liblber/idtest.c b/libraries/liblber/idtest.c
index 7f6723c1c26461b5342eb56f311c2d689b252a07..83d8ec7ace3d1aa665a12abe5e2e9019c1208f4b 100644
--- a/libraries/liblber/idtest.c
+++ b/libraries/liblber/idtest.c
@@ -36,29 +36,29 @@ main( int argc, char **argv )
 	/* read the pe from standard in */
 	if ( (psin = ps_alloc( std_open )) == NULLPS ) {
 		perror( "ps_alloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	if ( std_setup( psin, stdin ) == NOTOK ) {
 		perror( "std_setup" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	/* write the pe to standard out */
 	if ( (psout = ps_alloc( std_open )) == NULLPS ) {
 		perror( "ps_alloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	if ( std_setup( psout, stdout ) == NOTOK ) {
 		perror( "std_setup" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	/* pretty print it to standard error */
 	if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
 		perror( "ps_alloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	if ( std_setup( pserr, stderr ) == NOTOK ) {
 		perror( "std_setup" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	while ( (pe = ps2pe( psin )) != NULLPE ) {
@@ -66,7 +66,7 @@ main( int argc, char **argv )
 		pe2ps( psout, pe );
 	}
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 #else
 	fprintf(stderr, "requires ISODE X.500 distribution.\n");
 	return( EXIT_FAILURE );
diff --git a/libraries/libldap/apitest.c b/libraries/libldap/apitest.c
index f3a181aed8b1dbe5f2d105c79e984f33ad403b30..043729b7f6db89444f23d94e5789c8f9ad37ef6f 100644
--- a/libraries/libldap/apitest.c
+++ b/libraries/libldap/apitest.c
@@ -12,12 +12,11 @@
  */
 #include "portable.h"
 
-#include <stdio.h>
-
 #include <ac/stdlib.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <stdio.h>
+
+#include <ldap.h>
 
 int
 main(int argc, char **argv)
diff --git a/libraries/libldap/digest.c b/libraries/libldap/digest.c
index a0ca3a7a2aa4605fcab8cd33202b009b1605ded8..96035612a25e209196b6b90c6820aaf115a55acf 100644
--- a/libraries/libldap/digest.c
+++ b/libraries/libldap/digest.c
@@ -6,14 +6,14 @@
  *	DIGEST-MD5 routines
  */
 
-#include <portable.h>
+#include "portable.h"
 
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/time.h>
 
 #include "ldap-int.h"
-#include <ldap_pvt.h>
+#include "ldap_pvt.h"
 
 #define TK_NOENDQUOTE	-2
 #define TK_OUTOFMEM	-1
diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c
index be679a597356cac6c53c1bf64e670a0f026e8cfe..0ea3e5e1e8dfc8a35ac496aaac506786d4a8410c 100644
--- a/libraries/libldap/test.c
+++ b/libraries/libldap/test.c
@@ -343,7 +343,7 @@ main( int argc, char **argv )
 
 	if ( errflg || optind < argc - 1 ) {
 		fprintf( stderr, usage, argv[ 0 ] );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	
 	printf( "%s( %s, %d )\n",
@@ -360,14 +360,14 @@ main( int argc, char **argv )
 
 	if ( ld == NULL ) {
 		perror( cldapflg ? "cldap_open" : "ldap_init" );
-		exit(1);
+		exit( EXIT_FAILURE );
 	}
 
 	if ( copyfname != NULL ) {
 		if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
 		    0600 ))  == -1 ) {
 			perror( copyfname );
-			exit ( 1 );
+			exit ( EXIT_FAILURE );
 		}
 		ld->ld_sb.sb_options = copyoptions;
 	}
@@ -549,7 +549,7 @@ main( int argc, char **argv )
 			if ( !cldapflg ) {
 				ldap_unbind( ld );
 			}
-			exit( 0 );
+			exit( EXIT_SUCCESS );
 			break;
 
 		case 'r':	/* result or remove */
diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c
index ead67ea0751709dcab010712edc38597ae5d1724..06c8fe33cdeb711e6deb63670c4d42dcb5bb3889 100644
--- a/libraries/libldap/tmplout.c
+++ b/libraries/libldap/tmplout.c
@@ -21,11 +21,10 @@
 #include <sys/file.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
+#include <disptmpl.h>
 
 #include "ldap_log.h"
-#include "disptmpl.h"
 
 #include "ldap-int.h"
 #include "ldap_defaults.h"
diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c
index a12643a152a099fc1b75360bea4e94a92207fc15..b7969334888eb524c325229faa48174dd89b1ae9 100644
--- a/libraries/libldap/tmpltest.c
+++ b/libraries/libldap/tmpltest.c
@@ -13,12 +13,11 @@
 
 #ifdef HAVE_CONSOLE_H
 #include <console.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
 
-#include "lber.h"
-#include "ldap.h"
-#include "disptmpl.h"
-#include "srchpref.h"
+#include <ldap.h>
+#include <disptmpl.h>
+#include <srchpref.h>
 
 static void dump_tmpl	 ( struct ldap_disptmpl *tmpl );
 static void dump_srchpref( struct ldap_searchobj *sp );
@@ -43,13 +42,13 @@ main( int argc, char **argv )
     if (( err = ldap_init_templates( "ldaptemplates.conf", &templates ))
 	    != 0 ) {
 	fprintf( stderr, "ldap_init_templates failed (%d)\n", err );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     if (( err = ldap_init_searchprefs( "ldapsearchprefs.conf", &so ))
 	    != 0 ) {
 	fprintf( stderr, "ldap_init_searchprefs failed (%d)\n", err );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     if ( argc == 1 ) {
@@ -79,7 +78,7 @@ main( int argc, char **argv )
     ldap_free_templates( templates );
     ldap_free_searchprefs( so );
 
-    exit( 0 );
+    exit( EXIT_SUCCESS );
 }
 
 
diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c
index 57c4391c806f125c1c29e32e9ca92c0de1171e92..d85f4e790ae34e567b26fe50fbec168ccee4c80f 100644
--- a/libraries/libldap/url.c
+++ b/libraries/libldap/url.c
@@ -40,8 +40,6 @@ static const char* skip_url_prefix LDAP_P((
 	const char *url,
 	int *enclosedp,
 	int *ldaps ));
-static void hex_unescape LDAP_P(( char *s ));
-static int unhex( char c );
 
 
 int
@@ -229,7 +227,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 
 	if (( q = strchr( url, ':' )) != NULL ) {
 		*q++ = '\0';
-		hex_unescape( q );
+		ldap_pvt_hex_unescape( q );
 
 		if( *q == '\0' ) {
 			LDAP_FREE( url );
@@ -240,7 +238,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 		ludp->lud_port = atoi( q );
 	}
 
-	hex_unescape( url );
+	ldap_pvt_hex_unescape( url );
 	ludp->lud_host = LDAP_STRDUP( url );
 
 	if( ludp->lud_host == NULL ) {
@@ -265,7 +263,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 
 	if( *p != '\0' ) {
 		/* parse dn part */
-		hex_unescape( p );
+		ldap_pvt_hex_unescape( p );
 		ludp->lud_dn = LDAP_STRDUP( p );
 	} else {
 		ludp->lud_dn = LDAP_STRDUP( "" );
@@ -295,7 +293,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 
 	if( *p != '\0' ) {
 		/* parse attributes */
-		hex_unescape( p );
+		ldap_pvt_hex_unescape( p );
 		ludp->lud_attrs = ldap_str2charray( p, "," );
 
 		if( ludp->lud_attrs == NULL ) {
@@ -323,7 +321,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 
 	if( *p != '\0' ) {
 		/* parse the scope */
-		hex_unescape( p );
+		ldap_pvt_hex_unescape( p );
 		ludp->lud_scope = str2scope( p );
 
 		if( ludp->lud_scope == -1 ) {
@@ -351,7 +349,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 
 	if( *p != '\0' ) {
 		/* parse the filter */
-		hex_unescape( p );
+		ldap_pvt_hex_unescape( p );
 
 		if( ! *p ) {
 			/* missing filter */
@@ -398,7 +396,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
 	}
 
 	for( i=0; ludp->lud_exts[i] != NULL; i++ ) {
-		hex_unescape( ludp->lud_exts[i] );
+		ldap_pvt_hex_unescape( ludp->lud_exts[i] );
 	}
 
 	if( i == 0 ) {
@@ -544,8 +542,8 @@ ldap_url_search_s(
 }
 
 
-static void
-hex_unescape( char *s )
+void
+ldap_pvt_hex_unescape( char *s )
 {
 /*
  * Remove URL hex escapes from s... done in place.  The basic concept for
@@ -556,10 +554,10 @@ hex_unescape( char *s )
 	for ( p = s; *s != '\0'; ++s ) {
 		if ( *s == '%' ) {
 			if ( *++s != '\0' ) {
-				*p = unhex( *s ) << 4;
+				*p = ldap_pvt_unhex( *s ) << 4;
 			}
 			if ( *++s != '\0' ) {
-				*p++ += unhex( *s );
+				*p++ += ldap_pvt_unhex( *s );
 			}
 		} else {
 			*p++ = *s;
@@ -570,8 +568,8 @@ hex_unescape( char *s )
 }
 
 
-static int
-unhex( char c )
+int
+ldap_pvt_unhex( int c )
 {
 	return( c >= '0' && c <= '9' ? c - '0'
 	    : c >= 'A' && c <= 'F' ? c - 'A' + 10
diff --git a/libraries/libldif/fetch.c b/libraries/libldif/fetch.c
index 3ccd80e76493a908458bf9964713ab624fdb5c63..3f1ccf18a2430634b3b5a715e368ad52de5c2eb2 100644
--- a/libraries/libldif/fetch.c
+++ b/libraries/libldif/fetch.c
@@ -16,6 +16,7 @@
 
 #include "ldap_log.h"
 #include "lber_pvt.h"
+#include "ldap_pvt.h"
 #include "ldif.h"
 
 int
@@ -25,13 +26,40 @@ ldif_fetch_url(
     ber_len_t *vlenp
 )
 {
-#ifdef HAVE_FETCH
-	FILE *url = fetchGetURL( (char*) urlstr, "" );
+	FILE *url;
 	char buffer[1024];
 	char *p = NULL;
 	size_t total;
 	size_t bytes;
 
+	*valuep = NULL;
+	*vlenp = 0;
+
+#ifdef HAVE_FETCH
+	url = fetchGetURL( (char*) urlstr, "" );
+
+#else
+	if( strncasecmp( "file://", urlstr, sizeof("file://")-1 ) == 0 ) {
+		p = strchr( &urlstr[sizeof("file://")-1], '/' );
+		if( p == NULL ) {
+			return -1;
+		}
+
+		if( *p != *LDAP_DIRSEP ) {
+			/* skip over false root */
+			p++;
+		}
+
+		p = ber_strdup( p );
+		ldap_pvt_hex_unescape( p );
+
+		url = fopen( p, "r" );
+
+	} else {
+		return -1;
+	}
+#endif
+
 	if( url == NULL ) {
 		return -1;
 	}
@@ -56,11 +84,5 @@ ldif_fetch_url(
 	*vlenp = total;
 
 	return 0;
-
-#else
-	*valuep = NULL;
-	*vlenp = 0;
-	return -1;
-#endif
 }
 
diff --git a/libraries/libldif/libldif.dsp b/libraries/libldif/libldif.dsp
index 2574238b9cd85cc0999ddda54fc98e1d540f343c..f72025a24141eb2c00c711bea568fe2cfe8ffd59 100644
--- a/libraries/libldif/libldif.dsp
+++ b/libraries/libldif/libldif.dsp
@@ -123,6 +123,10 @@ LIB32=link.exe -lib
 # Name "libldif - Win32 Single Release"
 # Begin Source File
 
+SOURCE=.\fetch.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\include\ldif.h
 # End Source File
 # Begin Source File
diff --git a/libraries/liblutil/detach.c b/libraries/liblutil/detach.c
index 682410d42191a5caab45efdb44b02ee62e83ef2b..cd9f0e0f3ab9de1e845d9d0a728475a57f295107 100644
--- a/libraries/liblutil/detach.c
+++ b/libraries/liblutil/detach.c
@@ -65,7 +65,7 @@ lutil_detach( int debug, int do_close )
 				break;
 
 			default:
-				_exit( 0 );
+				_exit( EXIT_SUCCESS );
 			}
 			break;
 		}
@@ -78,7 +78,7 @@ lutil_detach( int debug, int do_close )
 
 		if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
 			perror( "/dev/null" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 		for ( i = 0;  i < 3;  i++ )
 			if ( sd != i && isatty( i ) )
diff --git a/libraries/liblutil/getpass.c b/libraries/liblutil/getpass.c
index 865c7d1885f7d6657cc0242179adcdc982406350..30c632d56249d32fb0022aab52c35f61b7c00297 100644
--- a/libraries/liblutil/getpass.c
+++ b/libraries/liblutil/getpass.c
@@ -35,7 +35,8 @@
 
 #include <lber.h>
 #include <ldap.h>
-#include <ldap_defaults.h>
+
+#include "ldap_defaults.h"
 
 char *
 getpass( const char *prompt )
diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c
index 03777b15d29848fa73604671f132e01f3593c831..9fbf7e2755962ff04d6f2d2f18a5e47eed845874 100644
--- a/libraries/liblutil/md5.c
+++ b/libraries/liblutil/md5.c
@@ -299,7 +299,7 @@ main (int  argc, char **argv )
 	if (argc < 2)
 	{
 		fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
-		exit (1);
+		return EXIT_FAILURE;
 	}
 	for (j = 1; j < argc; ++j)
 	{
@@ -313,6 +313,6 @@ main (int  argc, char **argv )
 		}
 		printf ("\n");
 	}
-	return 0;
+	return EXIT_SUCCESS;
 }
 #endif /* TEST */
diff --git a/libraries/liblutil/ntservice.c b/libraries/liblutil/ntservice.c
index f07fb7cb2093e19187a7075dbf514cc020bfc98b..f287a647cb13674cc41cc286797ba45289efcd8e 100644
--- a/libraries/liblutil/ntservice.c
+++ b/libraries/liblutil/ntservice.c
@@ -9,7 +9,7 @@
 #include <windows.h>
 #include <winsvc.h>
 
-#include "ldap.h"
+#include <ldap.h>
 
 #define ldap_debug slap_debug
 extern int slap_debug;
diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c
index 6a291fd2b127bf6cd308c3bb6e8c8704e5627ba6..d12508f6b531b5ae2a1aae0c2231af7d7adeecb5 100644
--- a/servers/slapd/aclparse.c
+++ b/servers/slapd/aclparse.c
@@ -439,7 +439,7 @@ acl_usage( void )
 			"\t[domain=<regex>] [sockurl=<regex>]\n"
 		"<access> ::= [self]{none|auth|compare|search|read|write}\n"
 		);
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 static void
diff --git a/servers/slapd/add.c b/servers/slapd/add.c
index 196a3189d5fd7b90d85bb7d14f347d0605e45481..fe7c7b607512eee5e72ec9aef2832dd0e51e7aeb 100644
--- a/servers/slapd/add.c
+++ b/servers/slapd/add.c
@@ -195,7 +195,6 @@ add_created_attrs( Operation *op, Entry *e )
 	struct berval	bv;
 	struct berval	*bvals[2];
 	Attribute	*a;
-	Attribute	*tmp;
 	struct tm	*ltm;
 	time_t		currenttime;
 
diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c
index 59cd1452c795f9e5e80ccd037680e97b4abff852..589291b943629a0b3637776316e87f750ca4f07a 100644
--- a/servers/slapd/attr.c
+++ b/servers/slapd/attr.c
@@ -324,7 +324,7 @@ attr_syntax_config(
 	if ( code ) {
 		fprintf( stderr, "%s: line %d: %s %s\n",
 			 fname, lineno, scherr2str(code), err);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	ldap_memfree(at);
 }
diff --git a/servers/slapd/back-bdb2/txn.c b/servers/slapd/back-bdb2/txn.c
index b2e2b0721f5ef9e0767931e65a68a0c2a2431240..4cf75de346d511e4c6f22be0e1f480837cb57fbb 100644
--- a/servers/slapd/back-bdb2/txn.c
+++ b/servers/slapd/back-bdb2/txn.c
@@ -128,7 +128,7 @@ bdb2i_txn_attr_config(
 				if ( open ) {
 					pthread_kill( pthread_self(), LDAP_SIGUSR1 );
 				} else {
-					exit( 1 );
+					exit( EXIT_FAILURE );
 				}
 			}
 
diff --git a/servers/slapd/back-ldbm/startup.c b/servers/slapd/back-ldbm/startup.c
index c9e8703d1f2f9162920c38354322791eb7d49264..8464876287a54206a143d366fac2a43676bef74d 100644
--- a/servers/slapd/back-ldbm/startup.c
+++ b/servers/slapd/back-ldbm/startup.c
@@ -79,7 +79,7 @@ ldbm_back_startup(
 		fprintf( stderr,
 				"ldbm_back_startup(): FATAL error in db_appinit() : %s\n",
 				error );
-	 	exit( 1 );
+	 	exit( EXIT_FAILURE );
 
 	}
 #endif
diff --git a/servers/slapd/back-perl/config.c b/servers/slapd/back-perl/config.c
index 41f36a9a2473ae88a565a62e93d0db13a6133e57..83067e5c241c0732f30bdaa323759679ae8668a0 100644
--- a/servers/slapd/back-perl/config.c
+++ b/servers/slapd/back-perl/config.c
@@ -125,7 +125,7 @@ perl_back_db_config(
 		if ( return_code != 0 ) {
 			fprintf( stderr,
 				 "Unknown perl backeng config: %s\n", argv[0]);
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
diff --git a/servers/slapd/back-shell/fork.c b/servers/slapd/back-shell/fork.c
index 7619c367457656ad9856aaeaa38a4ad288c8ea67..1f08097b1a41aaed8604eb7849782d61c0a5dfad 100644
--- a/servers/slapd/back-shell/fork.c
+++ b/servers/slapd/back-shell/fork.c
@@ -50,13 +50,13 @@ forkandexec(
 		close( c2p[0] );
 		if ( dup2( p2c[0], 0 ) == -1 || dup2( c2p[1], 1 ) == -1 ) {
 			Debug( LDAP_DEBUG_ANY, "dup2 failed\n", 0, 0, 0 );
-			exit( -1 );
+			exit( EXIT_FAILURE );
 		}
 
 		execv( args[0], args );
 
 		Debug( LDAP_DEBUG_ANY, "execv failed\n", 0, 0, 0 );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 
 	case -1:	/* trouble */
 		Debug( LDAP_DEBUG_ANY, "fork failed\n", 0, 0, 0 );
diff --git a/servers/slapd/ch_malloc.c b/servers/slapd/ch_malloc.c
index 724b93581f2f448bb115f351c9af6f85a80778b3..8fa9ce33d1bbb5111c1f656af60de169ae3e942c 100644
--- a/servers/slapd/ch_malloc.c
+++ b/servers/slapd/ch_malloc.c
@@ -21,7 +21,7 @@ ch_malloc(
 	if ( (new = (void *) ber_memalloc( size )) == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "ch_malloc of %lu bytes failed\n",
 			(long) size, 0, 0 );
-		exit( 1 );
+		exit( EXIT_SUCCESS );
 	}
 
 	return( new );
@@ -46,7 +46,7 @@ ch_realloc(
 	if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n",
 			(long) size, 0, 0 );
-		exit( 1 );
+		exit( EXIT_SUCCESS );
 	}
 
 	return( new );
@@ -63,7 +63,7 @@ ch_calloc(
 	if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "ch_calloc of %lu elems of %lu bytes failed\n",
 		  (long) nelem, (long) size, 0 );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	return( new );
@@ -78,7 +78,7 @@ ch_strdup(
 
 	if ( (new = ber_strdup( string )) == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "ch_strdup(%s) failed\n", string, 0, 0 );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	return( new );
diff --git a/servers/slapd/config.c b/servers/slapd/config.c
index 6017101f636415dd5a6a4a6fefb0270ee524fc0a..ac03893698bef56f6a9bf7412471abd6fc1a4d06 100644
--- a/servers/slapd/config.c
+++ b/servers/slapd/config.c
@@ -655,13 +655,13 @@ read_config( char *fname )
                       Debug( LDAP_DEBUG_ANY,
                              "%s: line %d: missing filename in \"loadmodule <filename>\" line\n",
                              fname, lineno, 0 );
-                      exit( 1 );
+                      exit( EXIT_FAILURE );
                    }
                    if (!load_module(cargv[1], cargc - 2, (cargc > 2) ? cargv + 2 : NULL)) {
                       Debug( LDAP_DEBUG_ANY,
                              "%s: line %d: failed to load or initialize module %s\n",
                              fname, lineno, cargv[1]);
-                      exit( 1 );
+                      exit( EXIT_FAILURE );
                    }
 		   
 #endif /*SLAPD_MODULES*/
diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c
index 4ea6664a77cab6ccd24b43aacee28312f0e8234b..548bbf3d12c885f657f27818483532ade1f7650d 100644
--- a/servers/slapd/daemon.c
+++ b/servers/slapd/daemon.c
@@ -856,7 +856,6 @@ slapd_daemon_task(
 		{
 			ber_socket_t rd;
 			int is_listener = 0;
-			int rc;
 
 #ifdef HAVE_WINSOCK
 			rd = readfds.fd_array[i];
diff --git a/servers/slapd/main.c b/servers/slapd/main.c
index 0cbdab394aaed6cd4bf19ff9db028dcc61ba8a9a..148f1a8731b0b843458df0acf210ef5c4cabebf2 100644
--- a/servers/slapd/main.c
+++ b/servers/slapd/main.c
@@ -273,7 +273,7 @@ int main( int argc, char **argv )
 		case 'c':	/* do connectionless (udp) */
 			/* udp = 1; */
 			fprintf( stderr, "connectionless support not supported");
-			exit( -1 );
+			exit( EXIT_FAILURE );
 			break;
 #endif
 
diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c
index b2cf4fc1f45a7fd435b71683c44d25c51a218122..d1b195f4590b27e4802794fd860778346473dd82 100644
--- a/servers/slapd/sasl.c
+++ b/servers/slapd/sasl.c
@@ -2,6 +2,7 @@
 
 #ifdef HAVE_CYRUS_SASL
 
+#include <ac/stdlib.h>
 #include <stdio.h>
 
 #include "slap.h"
@@ -32,7 +33,7 @@ int sasl_init( void )
 	if( rc != SASL_OK ) {
 		Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n",
 			0, 0, 0 );
-		exit(-1);
+		return EXIT_FAILURE;
 	}
 
 	rc = sasl_server_new( "ldap", NULL, NULL, NULL,
@@ -42,7 +43,7 @@ int sasl_init( void )
 	if( rc != SASL_OK ) {
 		Debug( LDAP_DEBUG_ANY, "sasl_server_new failed\n",
 			0, 0, 0 );
-		exit(-1);
+		return EXIT_FAILURE;
 	}
 
 	memset(&secprops, 0, sizeof(secprops));
@@ -55,7 +56,7 @@ int sasl_init( void )
 	if( rc != SASL_OK ) {
 		Debug( LDAP_DEBUG_ANY, "sasl_setprop failed\n",
 			0, 0, 0 );
-		exit(-1);
+		return EXIT_FAILURE;
 	}
 
 	rc = sasl_listmech( server, NULL, NULL, ",", NULL,
@@ -64,13 +65,13 @@ int sasl_init( void )
 	if( rc != SASL_OK ) {
 		Debug( LDAP_DEBUG_ANY, "sasl_listmech failed: %d\n",
 			rc, 0, 0 );
-		exit(-1);
+		return EXIT_FAILURE;
 	}
 
 	Debug( LDAP_DEBUG_TRACE, "SASL mechanisms: %s\n",
 		data, 0, 0 );
 
-	return 0;
+	return EXIT_SUCCESS;
 }
 
 int sasl_destory( void )
diff --git a/servers/slapd/schema.c b/servers/slapd/schema.c
index c7bafd9b8a51b2e5f068915c6b5c2d4901ca7f54..577fbfcbf0dfe3e964ff5c64acb175c4882845ed 100644
--- a/servers/slapd/schema.c
+++ b/servers/slapd/schema.c
@@ -1006,7 +1006,7 @@ schema_init( void )
 		if ( res ) {
 			fprintf( stderr, "schema_init: Error registering syntax %s\n",
 				 syntax_defs[i].sd_desc );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 	for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
@@ -1018,7 +1018,7 @@ schema_init( void )
 		if ( res ) {
 			fprintf( stderr, "schema_init: Error registering matching rule %s\n",
 				 mrule_defs[i].mrd_desc );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 	schema_init_done = 1;
diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c
index 4e4ea442168d9b0fd9a7a79ac348b772cc5d86e6..42aa19d83557391bd6efd384a09beaa513ab68a0 100644
--- a/servers/slapd/schemaparse.c
+++ b/servers/slapd/schemaparse.c
@@ -113,7 +113,7 @@ parse_oc_old(
 			if ( code ) {
 				fprintf( stderr, "%s: line %d: %s %s\n",
 					 fname, lineno, scherr2str(code), *namep);
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 			namep++;
 		}
@@ -125,7 +125,7 @@ parse_oc_old(
 			if ( code ) {
 				fprintf( stderr, "%s: line %d: %s %s\n",
 					 fname, lineno, scherr2str(code), *namep);
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 			namep++;
 		}
@@ -135,7 +135,7 @@ parse_oc_old(
 	if ( code ) {
 		fprintf( stderr, "%s: line %d: %s %s\n",
 			 fname, lineno, scherr2str(code), err);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	ldap_memfree(oc);
 }
@@ -161,7 +161,7 @@ parse_oc(
 	if ( code ) {
 		fprintf( stderr, "%s: line %d: %s %s\n",
 			 fname, lineno, scherr2str(code), err);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	ldap_memfree(oc);
 }
@@ -180,7 +180,7 @@ oc_usage( void )
 	fprintf( stderr, "  [ \"MUST\" oids ]      ; AttributeTypes\n");
 	fprintf( stderr, "  [ \"MAY\" oids ]       ; AttributeTypes\n");
 	fprintf( stderr, "whsp \")\"\n");
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 static void
@@ -189,7 +189,7 @@ oc_usage_old( void )
 	fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
 	fprintf( stderr, "                [ requires <attrlist> ]\n" );
 	fprintf( stderr, "                [ allows <attrlist> ]\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 static void
@@ -215,7 +215,7 @@ at_usage( void )
 	fprintf( stderr, "                                 ; distributedOperation\n");
 	fprintf( stderr, "                                 ; dSAOperation\n");
 	fprintf( stderr, "whsp \")\"\n");
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 void
@@ -239,7 +239,7 @@ parse_at(
 	if ( code ) {
 		fprintf( stderr, "%s: line %d: %s %s\n",
 			 fname, lineno, scherr2str(code), err);
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	ldap_memfree(at);
 }
diff --git a/servers/slapd/shell-backends/passwd-shell.c b/servers/slapd/shell-backends/passwd-shell.c
index 0a8d19fdbed6f976556bd398822448e2bf8b83cc..c62b5d058f88305881df1beeed883065251f3d90 100644
--- a/servers/slapd/shell-backends/passwd-shell.c
+++ b/servers/slapd/shell-backends/passwd-shell.c
@@ -68,7 +68,7 @@ main( int argc, char **argv )
 
     if ( errflg || optind < argc ) {
 	fprintf( stderr, "usage: %s [-d]\n", progname );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     debug_printf( "started\n" );
@@ -76,13 +76,13 @@ main( int argc, char **argv )
     (void) memset( (char *)&op, '\0', sizeof( op ));
 
     if ( parse_input( stdin, stdout, &op ) < 0 ) {
-	exit( 0 );
+	exit( EXIT_SUCCESS );
     }
 
     if ( op.ldop_op != LDOP_SEARCH ) {
 	write_result( stdout, LDAP_UNWILLING_TO_PERFORM, NULL,
 		"Command Not Implemented" );
-	exit( 0 );
+	exit( EXIT_SUCCESS );
     }
 
 #ifdef LDAP_DEBUG
@@ -91,7 +91,7 @@ main( int argc, char **argv )
 
     pwdfile_search( &op, stdout );
 
-    exit( 0 );
+    exit( EXIT_SUCCESS );
 }
 
 
diff --git a/servers/slapd/shell-backends/shellutil.c b/servers/slapd/shell-backends/shellutil.c
index 5c9e2a267c9eee4238695adbe532f1ea69ad6d59..4ba1213fa2fa11e833df5abb1671ce401de9b4d4 100644
--- a/servers/slapd/shell-backends/shellutil.c
+++ b/servers/slapd/shell-backends/shellutil.c
@@ -275,7 +275,7 @@ estrdup( char *s )
 
     if (( p = strdup( s )) == NULL ) {
 	debug_printf( "strdup failed\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     return( p );
@@ -295,7 +295,7 @@ erealloc( void *s, unsigned size )
 
     if ( p == NULL ) {
 	debug_printf( "realloc( p, %d ) failed\n", size );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     return( p );
@@ -309,7 +309,7 @@ ecalloc( unsigned nelem, unsigned elsize )
 
     if (( p = calloc( nelem, elsize )) == NULL ) {
 	debug_printf( "calloc( %d, %d ) failed\n", nelem, elsize );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     return( p );
diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h
index 57dbbd9eb2b1610b5198df495cafd7e1fbc63806..d114732e487a5553656c9b61675e4c6065cfa0a2 100644
--- a/servers/slapd/slap.h
+++ b/servers/slapd/slap.h
@@ -20,10 +20,8 @@
 
 #include "ldap_log.h"
 
-#include "lber.h"
-#include "ldap.h"
-
-#include "ldap_schema.h"
+#include <ldap.h>
+#include <ldap_schema.h>
 
 #include "ldap_pvt_thread.h"
 #include "ldif.h"
diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c
index f3b36d72f3697e63890e1cf5e7265b7d22698e39..e0927ccc1a9d42d435f1a876abc8f52101ca2d85 100644
--- a/servers/slapd/tools/centipede.c
+++ b/servers/slapd/tools/centipede.c
@@ -167,7 +167,7 @@ main( int argc, char **argv )
 			} else {
 				fprintf( stderr, "%s: unknown auth method\n", optarg );
 				fputs( "expecting \"simple\" or \"kerberos\"\n", stderr );
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 			break;
 
@@ -179,7 +179,7 @@ main( int argc, char **argv )
 			} else {
 				fprintf( stderr, "%s: unknown auth method\n", optarg );
 				fputs( "expecting \"simple\" or \"kerberos\"\n", stderr );
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 			break;
 
@@ -197,12 +197,12 @@ main( int argc, char **argv )
 
 		default:
 			usage( argv[0] );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 	if ( optind == argc || ldapsrcurl == NULL || ldapdesturl == NULL ) {
 		usage( argv[0] );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 	attrs = &argv[optind];
 
@@ -213,12 +213,12 @@ main( int argc, char **argv )
 
 	if ( (ld = start_ldap_search( ldapsrcurl, ldapfilter, attrs )) == NULL ) {
 		fprintf( stderr, "could not initiate ldap search\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( create_tmp_files( attrs, &tmpfile, &ldbm ) != 0 ) {
 		fprintf( stderr, "could not create temp files\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	/*
@@ -229,10 +229,10 @@ main( int argc, char **argv )
 	if ( (count = generate_new_centroids( ld, attrs, ldbm )) < 1 ) {
 		if ( count == 0 ) {
 		    fprintf( stderr, "no entries matched\n" );
-		    exit( 0 );
+		    exit( EXIT_SUCCESS );
 		} else {
 		    fprintf( stderr, "could not generate new centroid\n" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		}
 	}
 
@@ -246,7 +246,7 @@ main( int argc, char **argv )
 	if ( (ld = bind_to_destination_ldap( ldapsrcurl, ldapdesturl )) == NULL ) {
 		fprintf( stderr,
 		  "could not bind to index server, or could not create index entry\n" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	for ( i = 0; ldbm[i] != NULL; i++ ) {
@@ -338,7 +338,7 @@ main( int argc, char **argv )
 	free( ldbm );
 	free( tmpfile );
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 /*
@@ -591,7 +591,7 @@ diff_centroids(
 		 (vals[0] = (char *) malloc( 20 )) == NULL )
 	{
 		perror( "malloc" );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 	}
 	/* add values in mods[0] */
 	mods[0]->mod_op = LDAP_MOD_ADD;
@@ -855,7 +855,7 @@ full_centroid(
 	     (vals[0] = (char *) malloc( 20 )) == NULL )
 	{
 		perror( "malloc" );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 	}
 	mods[0]->mod_op = LDAP_MOD_REPLACE;
 	mods[0]->mod_type = attr;
diff --git a/servers/slapd/tools/chlog2replog.c b/servers/slapd/tools/chlog2replog.c
index 58ae5aa6e53202e14d9df5d81b6ae50dd2639260..ec31ed457fdc521e6c656045e40d0a55d0143a04 100644
--- a/servers/slapd/tools/chlog2replog.c
+++ b/servers/slapd/tools/chlog2replog.c
@@ -473,13 +473,13 @@ main( int argc, char **argv )
 	    break;
 	default:
 	    usage( progname );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
     }
 
     if (( dn_suffix == NULL ) || ( nreplicas == 0 )) {
 	usage( progname );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     if ( ofile == NULL ) {
@@ -494,12 +494,12 @@ main( int argc, char **argv )
     if (( std_ps = ps_alloc( std_open )) == NULLPS ||
 	    std_setup( std_ps, ofp ) != OK ) {
 	fprintf( stderr, "std_ps setup failed - help!\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
     if (( rps = ps_alloc( str_open )) == NULLPS ||
 	    str_setup( rps, NULLCP, 0, 0 ) != OK ) {
 	fprintf( stderr, "rps setup failed - help!\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
 
@@ -569,7 +569,7 @@ main( int argc, char **argv )
 	    if ( ofile != NULL ) {
 		if (( ofp = lock_fopen( ofile, "a", &lfp )) == NULL ) {
 		    perror( "open" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		}
 	    }
 	    /*
@@ -697,5 +697,5 @@ main( int argc, char **argv )
 	sprintf( nbuf, "%s.lock", ofile );
 	(void) unlink( nbuf );
     }
-    exit( 0 );
+    exit( EXIT_SUCCESS );
 }
diff --git a/servers/slapd/tools/edb2ldif.c b/servers/slapd/tools/edb2ldif.c
index 85454dca1b19f614c2b78efd25c47aea0edae558..345a5e89383ec1f01474b1bf2977d6314f480450 100644
--- a/servers/slapd/tools/edb2ldif.c
+++ b/servers/slapd/tools/edb2ldif.c
@@ -137,7 +137,7 @@ main( int argc, char **argv )
 	    } else if (( always_addvals = read_file( optarg, &always_addlen ))
 		    == NULL ) {
 		print_err( optarg );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	    break;
 
@@ -161,7 +161,7 @@ main( int argc, char **argv )
 	    }
 	    if ( file_attr_directory == NULL ) {
 		print_err( "malloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 #else /* HAVE_FILE_ATTR_DIR */
 	    fprintf( stderr, "Ignoring -f:  this option requires a newer version of ISODE.\n" );
@@ -181,7 +181,7 @@ main( int argc, char **argv )
 	    }
 	    if ( ignore_attr == NULL ) {
 		print_err( "malloc/realloc" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	    ignore_attr[ ignore_count ] = optarg;
 	    ignore_attr[ ++ignore_count ] = NULL;
@@ -194,7 +194,7 @@ main( int argc, char **argv )
 
     if ( errflg ) {
 	fprintf( stderr, usage, progname );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     if ( basedn == NULL ) {
@@ -213,7 +213,7 @@ main( int argc, char **argv )
     if ( init_syntaxes() < 0 ) {
 	fprintf( stderr, "%s: init_syntaxes failed -- check your oid tables \n",
 	    progname );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
 
@@ -242,7 +242,7 @@ main( int argc, char **argv )
     fprintf( stderr, "edb2ldif: exit( %d )\n", ( rc < 0 ) ? 1 : 0 );
 #endif
 
-    exit( ( rc < 0 ) ? 1 : 0 );
+    exit( ( rc < 0 ) ? EXIT_FAILURE : EXIT_SUCCESS );
 }
 
 
diff --git a/servers/slapd/tools/ldapsyntax.c b/servers/slapd/tools/ldapsyntax.c
index a8fd9fab3a9d8858123f9560720453e0fe1aecfc..5de70187f29f8fcff786aeae44dd47e7864c25da 100644
--- a/servers/slapd/tools/ldapsyntax.c
+++ b/servers/slapd/tools/ldapsyntax.c
@@ -24,8 +24,8 @@
 /* #include <quipu/dap2.h> */
 #include <quipu/dua.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
+
 #include "ldif.h"
 #include "ldapsyntax.h"
 
diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c
index b41d8ba8d19d41a46bda18a774ac108d6a8ee534..94df7d390176eee341a549052c0c3f2ef9d2e3db 100644
--- a/servers/slapd/tools/ldbmtest.c
+++ b/servers/slapd/tools/ldbmtest.c
@@ -77,8 +77,7 @@ main( int argc, char **argv )
 			fprintf( stderr,
 			    "usage: %s [-d level] [-f slapdconfigfile]\n",
 			    argv[0] );
-			exit( -1 );
-			break;
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -294,7 +293,7 @@ main( int argc, char **argv )
 			printf( "suffix: " );
 			fflush( stdout );
 			if ( fgets( buf, sizeof(buf), stdin ) == NULL ) {
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			} else {
 				buf[strlen( buf ) - 1] = '\0';
 			}
@@ -542,7 +541,7 @@ edit_entry( char c, Datum *data )
 		}
 		execl( editor, editor, tmpname, NULL );
 		perror( "execl" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	fclose( fp );
@@ -579,12 +578,12 @@ openfile( char *name, int namesiz, int mode, int verbose, char c )
 		if ( c == 'f' ) {
 			printf( "  file: " );
 			if ( fgets( name, namesiz, stdin ) == NULL )
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			name[strlen( name ) - 1] = '\0';
 		} else {
 			printf( "  attr: " );
 			if ( fgets( name, namesiz, stdin ) == NULL )
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			name[strlen( name ) - 1] = '\0';
 		}
 	}
@@ -744,7 +743,7 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
 			if ( tty )
 				printf( "  dn: " );
 			if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			}
 			kbuf[strlen( kbuf ) - 1] = '\0';
 			key->dptr = strdup( kbuf );
@@ -755,7 +754,7 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
 			if ( tty )
 				printf( "  dnid: " );
 			if ( fgets( dbuf, sizeof(dbuf), fp ) == NULL ) {
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			}
 			n = atol( dbuf );
 			data->dptr = (char *) malloc( sizeof(n) );
@@ -769,7 +768,7 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
 			if ( tty )
 				printf( "  dnid: " );
 			if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			}
 			n = atol( kbuf );
 			key->dptr = (char *) malloc( sizeof(n) );
@@ -788,7 +787,7 @@ get_keydata( FILE *fp, char c, Datum *key, Datum *data )
 			if ( tty )
 				printf( "  key: " );
 			if ( fgets( kbuf, sizeof(kbuf), fp ) == NULL ) {
-				exit( 0 );
+				exit( EXIT_SUCCESS );
 			}
 			kbuf[strlen( kbuf ) - 1] = '\0';
 			key->dptr = strdup( kbuf );
diff --git a/servers/slapd/tools/ldif.c b/servers/slapd/tools/ldif.c
index 94381c62028ddf655b357a2f854b9de06f876380..f157bf021bd69938ae74138cf55d21ff2b8f0c25 100644
--- a/servers/slapd/tools/ldif.c
+++ b/servers/slapd/tools/ldif.c
@@ -12,15 +12,15 @@
 #include <io.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
+
 #include "ldif.h"
 
 static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -54,7 +54,7 @@ main( int argc, char **argv )
 
 		if (( val = (char *) malloc( BUFSIZ )) == NULL ) {
 			perror( "malloc" );
-			exit( 1 );
+			return EXIT_FAILURE;
 		}
 		max = BUFSIZ;
 		cur = 0;
@@ -64,7 +64,7 @@ main( int argc, char **argv )
 				if (( val = (char *) realloc( val, max )) ==
 				    NULL ) {
 					perror( "realloc" );
-					exit( 1 );
+					return EXIT_FAILURE;
 				}
 			}
 			memcpy( val + cur, buf, nread );
@@ -72,14 +72,14 @@ main( int argc, char **argv )
 		}
 
 		if (( out = ldif_put( LDIF_PUT_BINARY, type, val, cur )) == NULL ) {
-		    	perror( "ldif_type_and_value" );
-			exit( 1 );
+		    perror( "ldif_type_and_value" );
+			return EXIT_FAILURE;
 		}
 
 		fputs( out, stdout );
 		ber_memfree( out );
 		free( val );
-		exit( 0 );
+		return EXIT_SUCCESS;
 	}
 
 	/* not binary:  one value per line... */
@@ -89,12 +89,11 @@ main( int argc, char **argv )
 		if (( out = ldif_put( LDIF_PUT_VALUE, type, buf, strlen( buf ) ))
 		    == NULL ) {
 		    	perror( "ldif_type_and_value" );
-			exit( 1 );
+			return EXIT_FAILURE;
 		}
 		fputs( out, stdout );
 		ber_memfree( out );
 	}
 
-	exit( 0 );
-	return( 0 ); /* NOT REACHED */
+	return EXIT_SUCCESS;
 }
diff --git a/servers/slapd/tools/ldif.dsp b/servers/slapd/tools/ldif.dsp
index 28cee71c44f7d7c878cb4a380bc43809579d1b01..31928665b0eb8632d46c40aba722c85f51f42527 100644
--- a/servers/slapd/tools/ldif.dsp
+++ b/servers/slapd/tools/ldif.dsp
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 oldif32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
 
 !ELSEIF  "$(CFG)" == "ldif - Win32 Debug"
 
@@ -77,7 +77,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 oldif32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
+# ADD LINK32 hs_regex.lib libdb.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
 
 !ELSEIF  "$(CFG)" == "ldif - Win32 Single Debug"
 
@@ -102,7 +102,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 oldif32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
-# ADD LINK32 oldif32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libraries\Debug"
 
 !ELSEIF  "$(CFG)" == "ldif - Win32 Single Release"
 
@@ -127,7 +127,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 oldif32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
-# ADD LINK32 oldif32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
+# ADD LINK32 hs_regex.lib libdbs.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\libraries\Release"
 
 !ENDIF 
 
diff --git a/servers/slapd/tools/ldif2id2children-bdb2.c b/servers/slapd/tools/ldif2id2children-bdb2.c
index b70c8aeff4dfbbbe410d38aac5d59dbc79d38a71..aa1652dfa6dc27c4a3ea3286c8a55b662b5f4db0 100644
--- a/servers/slapd/tools/ldif2id2children-bdb2.c
+++ b/servers/slapd/tools/ldif2id2children-bdb2.c
@@ -24,7 +24,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber]\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -73,7 +73,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -93,15 +93,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No bdb2 database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "bdb2" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an bdb2 database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -118,7 +118,7 @@ main( int argc, char **argv )
 	if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX, LDBM_NEWDB ))
 	    == NULL ) {
 		perror( "dn2id file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	id = 0;
@@ -185,7 +185,7 @@ main( int argc, char **argv )
 					if ( ldbm_store( db->dbc_db, key, data,
 					    LDBM_REPLACE ) != 0 ) {
 						perror( "dn2id ldbm_store..." );
-						exit( 1 );
+						exit( EXIT_FAILURE );
 					}
 				}
 			}
@@ -204,7 +204,7 @@ main( int argc, char **argv )
 	if ( (db2 = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
 	    LDBM_NEWDB )) == NULL ) {
 		perror( "id2children file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	rewind( stdin );
@@ -297,7 +297,7 @@ main( int argc, char **argv )
 					if ( bdb2i_idl_insert_key( be, db2, key, id )
 					    != 0 ) {
 						perror( "bdb2i_idl_insert_key" );
-						exit( 1 );
+						exit( EXIT_FAILURE );
 					}
 				}
 			}
@@ -315,5 +315,5 @@ main( int argc, char **argv )
 	slap_shutdown(dbnum);
 	slap_destroy();
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
diff --git a/servers/slapd/tools/ldif2id2children.c b/servers/slapd/tools/ldif2id2children.c
index 1a72b1f17fa21854d5de243cc10741a57ec5f5e3..97587c23fe4532b98aa94cd8d97c1a3712e60ef8 100644
--- a/servers/slapd/tools/ldif2id2children.c
+++ b/servers/slapd/tools/ldif2id2children.c
@@ -24,7 +24,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber]\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -75,7 +75,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -95,15 +95,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No ldbm database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "ldbm" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an ldbm database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -120,7 +120,7 @@ main( int argc, char **argv )
 	if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_NEWDB ))
 	    == NULL ) {
 		perror( "dn2id file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	id = 0;
@@ -187,7 +187,7 @@ main( int argc, char **argv )
 					if ( ldbm_store( db->dbc_db, key, data,
 					    LDBM_REPLACE ) != 0 ) {
 						perror( "dn2id ldbm_store" );
-						exit( 1 );
+						exit( EXIT_FAILURE );
 					}
 				}
 			}
@@ -206,7 +206,7 @@ main( int argc, char **argv )
 	if ( (db2 = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
 	    LDBM_NEWDB )) == NULL ) {
 		perror( "id2children file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	rewind( stdin );
@@ -299,7 +299,7 @@ main( int argc, char **argv )
 					if ( idl_insert_key( be, db2, key, id )
 					    != 0 ) {
 						perror( "idl_insert_key" );
-						exit( 1 );
+						exit( EXIT_FAILURE );
 					}
 				}
 			}
diff --git a/servers/slapd/tools/ldif2id2entry-bdb2.c b/servers/slapd/tools/ldif2id2entry-bdb2.c
index bc055976bfe8254352d35c3e57d13582e0b7cf90..5e86e79712313ffbbca772abc5dadd1e0ce5429b 100644
--- a/servers/slapd/tools/ldif2id2entry-bdb2.c
+++ b/servers/slapd/tools/ldif2id2entry-bdb2.c
@@ -22,7 +22,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber]\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -72,7 +72,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -92,15 +92,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No bdb2 database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "bdb2" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an bdb2 database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -114,7 +114,7 @@ main( int argc, char **argv )
 	if ( (db = bdb2i_cache_open( be, "id2entry", BDB2_SUFFIX, LDBM_NEWDB ))
 	    == NULL ) {
 		perror( "id2entry file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	id = 0;
@@ -178,7 +178,7 @@ main( int argc, char **argv )
 				    LDBM_INSERT ) != 0 ) {
 					fputs("id2entry ldbm_store failed\n",
 					      stderr);
-					exit( 1 );
+					exit( EXIT_FAILURE );
 				}
 			}
 			*buf = '\0';
@@ -198,5 +198,5 @@ main( int argc, char **argv )
 
 	slap_destroy();
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c
index 0e886427b53f9dff1b93159f9763fa35c96c6d87..aa90d138bcf9d964a89d378fea9884b8124bcfe6 100644
--- a/servers/slapd/tools/ldif2id2entry.c
+++ b/servers/slapd/tools/ldif2id2entry.c
@@ -22,7 +22,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber]\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -74,7 +74,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -94,15 +94,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No ldbm database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "ldbm" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an ldbm database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -116,7 +116,7 @@ main( int argc, char **argv )
 	if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_NEWDB ))
 	    == NULL ) {
 		perror( "id2entry file" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	id = 0;
@@ -180,7 +180,7 @@ main( int argc, char **argv )
 				    LDBM_INSERT ) != 0 ) {
 					fputs("id2entry ldbm_store failed\n",
 					      stderr);
-					exit( 1 );
+					exit( EXIT_FAILURE );
 				}
 			}
 			*buf = '\0';
diff --git a/servers/slapd/tools/ldif2index-bdb2.c b/servers/slapd/tools/ldif2index-bdb2.c
index 53fabcc2abf584c458554c1591a874acdc269c00..04f9f4baa681a583c734f1b5da0032aa0f8843db 100644
--- a/servers/slapd/tools/ldif2index-bdb2.c
+++ b/servers/slapd/tools/ldif2index-bdb2.c
@@ -21,7 +21,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber] attr\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -72,7 +72,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -88,15 +88,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No bdb2 database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "bdb2" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an bdb2 database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -109,7 +109,7 @@ main( int argc, char **argv )
 
 	bdb2i_attr_masks( be->be_private, attr, &indexmask, &syntaxmask );
 	if ( indexmask == 0 ) {
-		exit( 0 );
+		exit( EXIT_SUCCESS );
 	}
 
 	id = 0;
@@ -172,5 +172,5 @@ main( int argc, char **argv )
 	slap_shutdown(dbnum);
 	slap_destroy();
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
diff --git a/servers/slapd/tools/ldif2index.c b/servers/slapd/tools/ldif2index.c
index f654baaa08afe44fd5353c9a5db3036f88bef4ae..84d86d3f57c928e81ce65fe9fdafe8aaed4cee06 100644
--- a/servers/slapd/tools/ldif2index.c
+++ b/servers/slapd/tools/ldif2index.c
@@ -21,7 +21,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-n databasenumber] attr\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -74,7 +74,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -90,15 +90,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No ldbm database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "ldbm" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an ldbm database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -111,7 +111,7 @@ main( int argc, char **argv )
 
 	attr_masks( be->be_private, attr, &indexmask, &syntaxmask );
 	if ( indexmask == 0 ) {
-		exit( 0 );
+		exit( EXIT_SUCCESS );
 	}
 
 	id = 0;
diff --git a/servers/slapd/tools/ldif2ldbm-bdb2.c b/servers/slapd/tools/ldif2ldbm-bdb2.c
index e1471f92a40b1b070d237f8a19f826348f519c9b..f2cb07e5aaebed73e16d204376ed3ae8233d1084 100644
--- a/servers/slapd/tools/ldif2ldbm-bdb2.c
+++ b/servers/slapd/tools/ldif2ldbm-bdb2.c
@@ -32,7 +32,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-j #jobs] [-n databasenumber] [-s sbindir]\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -95,7 +95,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -106,7 +106,7 @@ main( int argc, char **argv )
 	rc = slap_init(SLAP_TOOL_MODE, "ldif2ldbm");
 	if (rc != 0 ) {
 		fprintf( stderr, "ldif2ldbm: slap_init failed!\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	read_config( tailorfile );
@@ -120,15 +120,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No bdb2 database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "bdb2" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an bdb2 database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -272,7 +272,7 @@ main( int argc, char **argv )
 
 	slap_destroy();
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 static void
@@ -287,7 +287,7 @@ fork_child( char *prog, char *args[] )
 		execvp( prog, args );
 		fprintf( stderr, "%s: ", prog );
 		perror( "execv" );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 		break;
 
 	case -1:	/* trouble */
diff --git a/servers/slapd/tools/ldif2ldbm.c b/servers/slapd/tools/ldif2ldbm.c
index e95c5dddb282969bd3afaa653899c126d061155d..cff24fd6a9690610c9bbd0745689d234cbf8b9f8 100644
--- a/servers/slapd/tools/ldif2ldbm.c
+++ b/servers/slapd/tools/ldif2ldbm.c
@@ -35,7 +35,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s -i inputfile [-d debuglevel] [-f configfile] [-j #jobs] [-n databasenumber] [-s sbindir]\n", name );
-    exit( 1 );
+    exit( EXIT_FAILURE );
 }
 
 int
@@ -101,7 +101,7 @@ main( int argc, char **argv )
 	} else {
 		if ( freopen( inputfile, "r", stdin ) == NULL ) {
 			perror( inputfile );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	}
 
@@ -112,7 +112,7 @@ main( int argc, char **argv )
 	rc = slap_init(SLAP_TOOL_MODE, "ldif2ldbm");
 	if (rc != 0 ) {
 		fprintf( stderr, "ldif2ldbm: slap_init failed!\n");
-		exit(1);
+		exit(EXIT_FAILURE);
 	}
 
 	read_config( tailorfile );
@@ -126,15 +126,15 @@ main( int argc, char **argv )
 		}
 		if ( dbnum == nbackends ) {
 			fprintf( stderr, "No ldbm database found in config file\n" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 		}
 	} else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
 		fprintf( stderr, "Database number selected via -n is out of range\n" );
 		fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	} else if ( strcasecmp( backends[dbnum].be_type, "ldbm" ) != 0 ) {
 		fprintf( stderr, "Database number %d selected via -n is not an ldbm database\n", dbnum );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	slap_startup(dbnum);
@@ -315,7 +315,7 @@ fork_child( char *prog, char *args[] )
     {
         fprintf( stderr, "Could not create %s: ", prog );
         perror( "CreateProcess" );
-        exit (-1);
+        exit (EXIT_FAILURE);
     }
 
     processes[nkids] = proc_info.hProcess;
@@ -357,7 +357,7 @@ fork_child( char *prog, char *args[] )
 		execvp( prog, args );
 		fprintf( stderr, "%s: ", prog );
 		perror( "execv" );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 		break;
 
 	case -1:	/* trouble */
diff --git a/servers/slapd/tools/sizecount.c b/servers/slapd/tools/sizecount.c
index 9d49474b3cb8fc739bed5bd211e00bb26444f62c..74e96fc4a1b8f117258f4ae86ec8ce8ddba9a373 100644
--- a/servers/slapd/tools/sizecount.c
+++ b/servers/slapd/tools/sizecount.c
@@ -48,13 +48,13 @@ main( int argc, char **argv )
 */
 	if ( (ld = ldap_init( "vertigo:5555", 0 )) == NULL ) {
 		perror( "ldap_init" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( ldap_search( ld, "cn=index", LDAP_SCOPE_ONELEVEL, "(objectclass=*)",
 	  attrs, 0 ) == -1 ) {
 		ldap_perror( ld, "ldap_search" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	printf( "attr\tdn\tnentries\tvcount\tvsize\twcount\twsize\tpcount\tpsize\tscount\tssize\n" );
@@ -82,7 +82,7 @@ main( int argc, char **argv )
 			  DB_FLAGS, MODE, CACHE_SIZE )) == NULL || (sldbm = ldbm_open(
 			  "scount.ldbm", DB_FLAGS, MODE, CACHE_SIZE )) == NULL ) {
 				perror( "ldbm_open" );
-				exit( 1 );
+				exit( EXIT_FAILURE );
 			}
 			vcount = 0; vsize = 0;
 			wcount = 0; wsize = 0;
@@ -164,7 +164,7 @@ main( int argc, char **argv )
 	(void) unlink( "pcount.ldbm" );
 	(void) unlink( "scount.ldbm" );
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 static void
diff --git a/servers/slapd/user.c b/servers/slapd/user.c
index d79325bfdd75882ef03fe3ce84399f2a6e3d4e00..acac1ad1637762946fe5282ad50b877a5b8de89d 100644
--- a/servers/slapd/user.c
+++ b/servers/slapd/user.c
@@ -60,7 +60,7 @@ slap_init_user( char *user, char *group )
 	    if ( pwd == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "No passwd entry for user %s\n",
 		       user, 0, 0 );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	    if ( got_uid ) {
 		free( user );
@@ -93,7 +93,7 @@ slap_init_user( char *user, char *group )
 	    if ( grp == NULL ) {
 		Debug( LDAP_DEBUG_ANY, "No group entry for group %s\n",
 		       group, 0, 0 );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	    }
 	}
 	free( group );
@@ -104,7 +104,7 @@ slap_init_user( char *user, char *group )
 	if ( getuid() == 0 && initgroups( user, gid ) != 0 ) {
 	    Debug( LDAP_DEBUG_ANY,
 		   "Could not set the group access (gid) list\n", 0, 0, 0 );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 	free( user );
     }
@@ -117,13 +117,13 @@ slap_init_user( char *user, char *group )
 	if ( setgid( gid ) != 0 ) {
 	    Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n",
 		   gid, 0, 0 );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 #ifdef HAVE_SETEGID
 	if ( setegid( gid ) != 0 ) {
 	    Debug( LDAP_DEBUG_ANY, "Could not set effective group id to %d\n",
 		   gid, 0, 0 );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 #endif
     }
@@ -132,13 +132,13 @@ slap_init_user( char *user, char *group )
 	if ( setuid( uid ) != 0 ) {
 	    Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n",
 		   uid, 0, 0 );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 #ifdef HAVE_SETEUID
 	if ( seteuid( uid ) != 0 ) {
 	    Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n",
 		   uid, 0, 0 );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
 #endif
     }
diff --git a/servers/slurpd/ch_malloc.c b/servers/slurpd/ch_malloc.c
index 9f119825fa8cd0774c119c79d320de6e826b65c8..54d54c3aaa750d6574bccc5c60d121153facb0f2 100644
--- a/servers/slurpd/ch_malloc.c
+++ b/servers/slurpd/ch_malloc.c
@@ -39,7 +39,7 @@ ch_malloc(
 	if ( (new = (void *) ber_memalloc( size )) == NULL ) {
 		fprintf( stderr, "malloc of %lu bytes failed\n",
 			(long) size );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	return( new );
@@ -71,7 +71,7 @@ ch_realloc(
 	if ( (new = (void *) ber_memrealloc( block, size )) == NULL ) {
 		fprintf( stderr, "realloc of %lu bytes failed\n",
 			(long) size );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	return( new );
@@ -95,7 +95,7 @@ ch_calloc(
 	if ( (new = (void *) ber_memcalloc( nelem, size )) == NULL ) {
 		fprintf( stderr, "calloc of %lu elems of %lu bytes failed\n",
 		    (long) nelem, (long) size );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	return( new );
diff --git a/servers/slurpd/config.c b/servers/slurpd/config.c
index e9b5d7e7c1600fd75602cdc0c7973e64a35520db..38802e4422f797b15b2ade857214ac453cc24b24 100644
--- a/servers/slurpd/config.c
+++ b/servers/slurpd/config.c
@@ -64,7 +64,7 @@ slurpd_read_config(
 
     if ( (fp = fopen( fname, "r" )) == NULL ) {
 	perror( fname );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     lineno = 0;
@@ -96,7 +96,7 @@ slurpd_read_config(
 			"line %d: missing filename in \"replogfile ",
 			lineno );
 		    fprintf( stderr, "<filename>\" line\n" );
-		    exit( 1 );
+		    exit( EXIT_FAILURE );
 		} else if ( cargc > 2 && *cargv[2] != '#' ) {
 		    fprintf( stderr,
 			"line %d: extra cruft at the end of \"replogfile %s\"",
@@ -258,13 +258,13 @@ add_replica(
 	    ( nr + 1 )  * sizeof( Re * ));
     if ( sglob->replicas == NULL ) {
 	fprintf( stderr, "out of memory, add_replica\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
     sglob->replicas[ nr ] = NULL; 
 
     if ( Ri_init( &(sglob->replicas[ nr - 1 ])) < 0 ) {
 	fprintf( stderr, "out of memory, Ri_init\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
     if ( parse_replica_line( cargv, cargc,
 	    sglob->replicas[ nr - 1] ) < 0 ) {
@@ -287,7 +287,7 @@ add_replica(
 		sglob->replicas[ nr - 1 ] );
 	if ( sglob->replicas[ nr - 1]->ri_stel == NULL ) {
 	    fprintf( stderr, "Failed to add status element structure\n" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 	}
     }
 }
@@ -367,7 +367,7 @@ parse_replica_line(
 	    fprintf( stderr, "You must rebuild the LDAP release with\n" );
 	    fprintf( stderr, "kerberos support if you wish to use\n" );
 	    fprintf( stderr, "bindmethod=kerberos\n" );
-	    exit( 1 );
+	    exit( EXIT_FAILURE );
 #endif /* HAVE_KERBEROS */
 	    } else if ( !strcasecmp( val, SIMPLESTR )) {
 		ri->ri_bind_method = AUTH_SIMPLE;
diff --git a/servers/slurpd/globals.c b/servers/slurpd/globals.c
index b90a4570d4f34f78ed828b19fe9cc872133543fa..1871085b668f53db4bd085bd51334e3b97c3fe20 100644
--- a/servers/slurpd/globals.c
+++ b/servers/slurpd/globals.c
@@ -59,12 +59,12 @@ init_globals( void )
     g->srpos = 0L;
     if ( St_init( &(g->st)) < 0 ) {
 	fprintf( stderr, "Cannot initialize status data\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
     ldap_pvt_thread_mutex_init( &(g->rej_mutex) );
     if ( Rq_init( &(g->rq)) < 0 ) {
 	fprintf( stderr, "Cannot initialize queue\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 #ifdef HAVE_KERBEROS
     g->default_srvtab = SRVTAB;
diff --git a/servers/slurpd/main.c b/servers/slurpd/main.c
index 9ba0a6c8be9798de800a0568226d2ee14c0130fe..afe0889e66519f3b40d58eaceaf31dfc267a0d0b 100644
--- a/servers/slurpd/main.c
+++ b/servers/slurpd/main.c
@@ -47,14 +47,14 @@ main(
      */
     if (( sglob = init_globals()) == NULL ) {
 	fprintf( stderr, "Out of memory initializing globals\n" );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     /*
      * Process command-line args and fill in globals.
      */
     if ( doargs( argc, argv, sglob ) < 0 ) {
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     /*
@@ -64,7 +64,7 @@ main(
 	fprintf( stderr,
 		"Errors encountered while processing config file \"%s\"\n",
 		sglob->slapd_configfile );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     /*
@@ -73,7 +73,7 @@ main(
     if ( sglob->st->st_read( sglob->st )) {
 	fprintf( stderr, "Malformed slurpd status file \"%s\"\n",
 		sglob->slurpd_status_file, 0, 0 );
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     /*
@@ -81,7 +81,7 @@ main(
      * Check for any fatal error conditions before we get started
      */
      if ( sanity() < 0 ) {
-	exit( 1 );
+	exit( EXIT_FAILURE );
     }
 
     /*
@@ -110,7 +110,7 @@ main(
 	{
 	Debug( LDAP_DEBUG_ANY, "file manager ldap_pvt_thread_create failed\n",
 		0, 0, 0 );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 
     }
 
diff --git a/servers/slurpd/slurp.h b/servers/slurpd/slurp.h
index 5dcce03befc8b784d61daffb2437a716378d8172..274f1517d8511ed9f5f9989f57602b17a2383ed1 100644
--- a/servers/slurpd/slurp.h
+++ b/servers/slurpd/slurp.h
@@ -29,8 +29,7 @@
 #endif
 #include <sys/types.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #define ldap_debug slurp_debug
 #include "ldap_log.h"
diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c
index 7f4a403c7ee7b300ae4dfc89ac67946fa6cc91ed..b5a2a2177e733e30f257197b2be0a9404099f55f 100644
--- a/tests/progs/slapd-addel.c
+++ b/tests/progs/slapd-addel.c
@@ -14,8 +14,7 @@
 #include <sys/param.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #define LOOPS	100
 
@@ -31,7 +30,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -f <addfile> [-l <loops>]\n",
 			name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -88,7 +87,7 @@ main( int argc, char **argv )
 
 		fprintf( stderr, "%s: invalid entry DN in file \"%s\".\n",
 				argv[0], filename );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	}
 
@@ -96,13 +95,13 @@ main( int argc, char **argv )
 
 		fprintf( stderr, "%s: invalid attrs in file \"%s\".\n",
 				argv[0], filename );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	}
 
 	do_addel( host, port, manager, passwd, entry, attrs, loops );
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 
@@ -130,19 +129,19 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
 		if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
 			sizeof( LDAPMod * ))) == NULL ) {
 	    		perror( "realloc" );
-	    		exit( 1 );
+	    		exit( EXIT_FAILURE );
 		}
 		*pmodsp = pmods;
 		pmods[ i + 1 ] = NULL;
 		if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
 			== NULL ) {
 	    		perror( "calloc" );
-	    		exit( 1 );
+	    		exit( EXIT_FAILURE );
 		}
 		pmods[ i ]->mod_op = modop;
 		if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
 	    	perror( "strdup" );
-	    	exit( 1 );
+	    	exit( EXIT_FAILURE );
 		}
     }
 
@@ -157,20 +156,20 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
 			(struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
 			(j + 2) * sizeof( struct berval * ))) == NULL ) {
 	    		perror( "ber_realloc" );
-	    		exit( 1 );
+	    		exit( EXIT_FAILURE );
 		}
 		pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
 		if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
 			== NULL ) {
 	    		perror( "malloc" );
-	    		exit( 1 );
+	    		exit( EXIT_FAILURE );
 		}
 		pmods[ i ]->mod_bvalues[ j ] = bvp;
 
 	    bvp->bv_len = vlen;
 	    if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
 			perror( "malloc" );
-			exit( 1 );
+			exit( EXIT_FAILURE );
 	    }
 	    SAFEMEMCPY( bvp->bv_val, value, vlen );
 	    bvp->bv_val[ vlen ] = '\0';
@@ -237,13 +236,13 @@ do_addel(
 
 	if (( ld = ldap_init( host, port )) == NULL ) {
 		perror( "ldap_init" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE )
 				!= LDAP_SUCCESS ) {
 		ldap_perror( ld, "ldap_bind" );
-		 exit( 1 );
+		 exit( EXIT_FAILURE );
 	}
 
 
diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c
index 287a4973ea83371593e0a6b0d0a66aaef8498ce0..124eea6c887b4470c57bd3d6b3273fde5fe8ca4f 100644
--- a/tests/progs/slapd-read.c
+++ b/tests/progs/slapd-read.c
@@ -14,8 +14,7 @@
 #include <sys/param.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #define LOOPS	100
 
@@ -27,7 +26,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h <host>] -p port -e <entry> [-l <loops>]\n",
 			name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -70,13 +69,13 @@ main( int argc, char **argv )
 
 		fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
 				argv[0] );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	}
 
 	do_read( host, port, entry, ( 4 * loops ));
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 
@@ -91,12 +90,12 @@ do_read( char *host, int port, char *entry, int maxloop )
 
 	if (( ld = ldap_init( host, port )) == NULL ) {
 		perror( "ldap_init" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
 		ldap_perror( ld, "ldap_bind" );
-		 exit( 1 );
+		 exit( EXIT_FAILURE );
 	}
 
 
diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c
index 1799f639be7b9e16706f22e73a919934a94b6af1..fd0a533896e994bd486d622989057ac526def6ac 100644
--- a/tests/progs/slapd-search.c
+++ b/tests/progs/slapd-search.c
@@ -14,8 +14,7 @@
 #include <sys/param.h>
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 #define LOOPS	100
 
@@ -27,7 +26,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h <host>] -p port -b <searchbase> -f <searchfiter> [-l <loops>]\n",
 			name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -75,13 +74,13 @@ main( int argc, char **argv )
 
 		fprintf( stderr, "%s: invalid EMPTY search filter.\n",
 				argv[0] );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	}
 
 	do_search( host, port, sbase, filter, ( 4 * loops ));
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 
@@ -95,12 +94,12 @@ do_search( char *host, int port, char *sbase, char *filter, int maxloop )
 
 	if (( ld = ldap_init( host, port )) == NULL ) {
 		perror( "ldap_init" );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 	}
 
 	if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
 		ldap_perror( ld, "ldap_bind" );
-		 exit( 1 );
+		 exit( EXIT_FAILURE );
 	}
 
 
diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c
index 902b2953544c1bbb9452c17e5e3cbcf7ff03e5f8..cadd3df89dec75d8d95f8bca4a29ec55e645a274 100644
--- a/tests/progs/slapd-tester.c
+++ b/tests/progs/slapd-tester.c
@@ -42,7 +42,7 @@ static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h <host>] -p <port> -D <manager> -w <passwd> -d <datadir> -b <baseDN> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
-	exit( 1 );
+	exit( EXIT_FAILURE );
 }
 
 int
@@ -130,7 +130,7 @@ main( int argc, char **argv )
 
 		fprintf( stderr, "%s: couldn't open data directory \"%s\".\n",
 					argv[0], dirname );
-		exit( 1 );
+		exit( EXIT_FAILURE );
 
 	}
 
@@ -246,7 +246,7 @@ main( int argc, char **argv )
 
 	wait4kids( -1 );
 
-	exit( 0 );
+	exit( EXIT_SUCCESS );
 }
 
 static char *
@@ -319,7 +319,7 @@ fork_child( char *prog, char *args[] )
 		execvp( prog, args );
 		fprintf( stderr, "%s: ", prog );
 		perror( "execv" );
-		exit( -1 );
+		exit( EXIT_FAILURE );
 		break;
 
 	case -1:	/* trouble */