From: Kurt Zeilenga Date: Tue, 3 Aug 1999 18:14:24 +0000 (+0000) Subject: s/exit(1)/exit(EXIT_FAILURE)/ X-Git-Tag: TWEB_OL_BASE~311 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=df8f7cbb9b79be3be9205d116d1dd0b263d6861a;p=openldap s/exit(1)/exit(EXIT_FAILURE)/ s/exit(0)/exit(EXIT_SUCCESS)/ add where needed and other minor header adjustments --- diff --git a/build/main.dsw b/build/main.dsw index e728552c96..2b8c9582c2 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 614fe416d3..5bc84f2fb8 100644 --- a/clients/fax500/main.c +++ b/clients/fax500/main.c @@ -34,12 +34,10 @@ #include #endif -#include "lber.h" -#include "ldap.h" +#include #include "fax500.h" - -#include +#include "ldap_defaults.h" #define USER 0 #define GROUP_ERRORS 1 diff --git a/clients/fax500/rp500.c b/clients/fax500/rp500.c index 3b93ea5943..bc80325305 100644 --- a/clients/fax500/rp500.c +++ b/clients/fax500/rp500.c @@ -33,8 +33,7 @@ #include #include "fax500.h" - -#include +#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 19e72277df..63b77e9a4b 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -29,10 +29,8 @@ #include #endif -#include "lber.h" -#include "ldap.h" - -#include "disptmpl.h" +#include +#include #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 3d95f4d6f3..234d908691 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -35,16 +35,16 @@ #include #endif +#include +#include + #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 4ee45391c7..c68b3522ef 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -36,15 +36,14 @@ #endif -#include "lber.h" -#include "ldap.h" +#include +#include #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 67da27b8e1..678663805d 100644 --- a/clients/mail500/main.c +++ b/clients/mail500/main.c @@ -39,8 +39,7 @@ #include #endif -#include "lber.h" -#include "ldap.h" +#include #include "ldap_defaults.h" diff --git a/clients/rcpt500/main.c b/clients/rcpt500/main.c index 9a37edae75..74fe9d088d 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 53b55729d6..dac5f15fc9 100644 --- a/clients/rcpt500/query.c +++ b/clients/rcpt500/query.c @@ -8,8 +8,6 @@ #include "portable.h" -#include - #include #include @@ -17,10 +15,10 @@ #include #include -#include "lber.h" -#include "ldap.h" +#include -#include "disptmpl.h" +#include +#include #include "rcpt500.h" #include "ldap_defaults.h" diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index ddd80e399b..c38e034e5c 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 351ca5e37c..52c8f52aca 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -26,9 +26,9 @@ #include #include -#include -#include +#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 c8186761c3..7c38c08844 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 3d48a2d2c5..dfbd12c491 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 2a8f8822e2..0476b198f8 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -10,8 +10,8 @@ #include #include -#include +#include "ldif.h" #include "ldap_defaults.h" #define DEFSEP "=" diff --git a/clients/ud/auth.c b/clients/ud/auth.c index e3968a04ef..89580347bb 100644 --- a/clients/ud/auth.c +++ b/clients/ud/auth.c @@ -28,8 +28,8 @@ #include #include -#include +#include "ldap_defaults.h" #include "ud.h" #ifdef HAVE_KERBEROS diff --git a/clients/ud/edit.c b/clients/ud/edit.c index 3cc1530d9b..997926c23d 100644 --- a/clients/ud/edit.c +++ b/clients/ud/edit.c @@ -32,7 +32,8 @@ #include #include -#include + +#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 e8ef8b48fd..3b7a87fb1c 100644 --- a/clients/ud/group.c +++ b/clients/ud/group.c @@ -26,7 +26,8 @@ #include #include -#include + +#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 ef8e1ae21a..48df356768 100644 --- a/clients/ud/main.c +++ b/clients/ud/main.c @@ -46,7 +46,7 @@ #include #include -#include +#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 70a6c54ee9..2efd2895d6 100644 --- a/clients/ud/util.c +++ b/clients/ud/util.c @@ -26,8 +26,8 @@ #include #include -#include +#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 d99d3e558d..a49a3bf896 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 0be574aec2..8747269551 100644 --- a/contrib/web_ldap/web_ldap.c +++ b/contrib/web_ldap/web_ldap.c @@ -19,7 +19,7 @@ #include #include -#include +#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("

++ 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("

++ 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("\n\n"); - exit(1); + exit( EXIT_FAILURE ); } /*authenticate as nobody */ @@ -373,7 +373,7 @@ main(int argc, char ** argv) { } } printf("\n\n"); - exit(1); + exit( EXIT_FAILURE ); } printf("Directory Lookup Results\n

\n");
diff --git a/contrib/whois++/whois++.h b/contrib/whois++/whois++.h
index 6d148526e9..bf77fceab5 100644
--- a/contrib/whois++/whois++.h
+++ b/contrib/whois++/whois++.h
@@ -41,8 +41,7 @@
 #include 
 #include 
 #include "syslog.h"
-#include "lber.h"
-#include "ldap.h"
+#include 
 
 #define	EQ(x,y)		(strcasecmp(x,y) == 0)
 
diff --git a/include/ac/stdlib.h b/include/ac/stdlib.h
index 505b30b5cf..d642b45910 100644
--- a/include/ac/stdlib.h
+++ b/include/ac/stdlib.h
@@ -12,16 +12,16 @@
 #ifndef _AC_STDLIB_H
 #define _AC_STDLIB_H
 
-#	include 
+#include 
 
-	/* Not sure if !STDC_HEADERS is needed */
-#	if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
-#		include 
-#	endif
+/* Ignore malloc.h if we have STDC_HEADERS */
+#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
+#	include 
+#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 3bede83b2a..3014e217ee 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 27678616ee..de0870bc6c 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 3328933eca..bd6d35bf01 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 7f6723c1c2..83d8ec7ace 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 f3a181aed8..043729b7f6 100644
--- a/libraries/libldap/apitest.c
+++ b/libraries/libldap/apitest.c
@@ -12,12 +12,11 @@
  */
 #include "portable.h"
 
-#include 
-
 #include 
 
-#include "lber.h"
-#include "ldap.h"
+#include 
+
+#include 
 
 int
 main(int argc, char **argv)
diff --git a/libraries/libldap/digest.c b/libraries/libldap/digest.c
index a0ca3a7a2a..96035612a2 100644
--- a/libraries/libldap/digest.c
+++ b/libraries/libldap/digest.c
@@ -6,14 +6,14 @@
  *	DIGEST-MD5 routines
  */
 
-#include 
+#include "portable.h"
 
 #include 
 #include 
 #include 
 
 #include "ldap-int.h"
-#include 
+#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 be679a5973..0ea3e5e1e8 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 ead67ea075..06c8fe33cd 100644
--- a/libraries/libldap/tmplout.c
+++ b/libraries/libldap/tmplout.c
@@ -21,11 +21,10 @@
 #include 
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include 
+#include 
 
 #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 a12643a152..b796933488 100644
--- a/libraries/libldap/tmpltest.c
+++ b/libraries/libldap/tmpltest.c
@@ -13,12 +13,11 @@
 
 #ifdef HAVE_CONSOLE_H
 #include 
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
 
-#include "lber.h"
-#include "ldap.h"
-#include "disptmpl.h"
-#include "srchpref.h"
+#include 
+#include 
+#include 
 
 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 57c4391c80..d85f4e790a 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 3ccd80e764..3f1ccf18a2 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 2574238b9c..f72025a241 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 682410d421..cd9f0e0f3a 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 865c7d1885..30c632d562 100644
--- a/libraries/liblutil/getpass.c
+++ b/libraries/liblutil/getpass.c
@@ -35,7 +35,8 @@
 
 #include 
 #include 
-#include 
+
+#include "ldap_defaults.h"
 
 char *
 getpass( const char *prompt )
diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c
index 03777b15d2..9fbf7e2755 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 f07fb7cb20..f287a647cb 100644
--- a/libraries/liblutil/ntservice.c
+++ b/libraries/liblutil/ntservice.c
@@ -9,7 +9,7 @@
 #include 
 #include 
 
-#include "ldap.h"
+#include 
 
 #define ldap_debug slap_debug
 extern int slap_debug;
diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c
index 6a291fd2b1..d12508f6b5 100644
--- a/servers/slapd/aclparse.c
+++ b/servers/slapd/aclparse.c
@@ -439,7 +439,7 @@ acl_usage( void )
 			"\t[domain=] [sockurl=]\n"
 		" ::= [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 196a3189d5..fe7c7b6075 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 59cd1452c7..589291b943 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 b2e2b0721f..4cf75de346 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 c9e8703d1f..8464876287 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 41f36a9a24..83067e5c24 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 7619c36745..1f08097b1a 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 724b93581f..8fa9ce33d1 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 6017101f63..ac03893698 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 \" 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 4ea6664a77..548bbf3d12 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 0cbdab394a..148f1a8731 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 b2cf4fc1f4..d1b195f459 100644
--- a/servers/slapd/sasl.c
+++ b/servers/slapd/sasl.c
@@ -2,6 +2,7 @@
 
 #ifdef HAVE_CYRUS_SASL
 
+#include 
 #include 
 
 #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 c7bafd9b8a..577fbfcbf0 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 4e4ea44216..42aa19d835 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, " ::= objectclass \n" );
 	fprintf( stderr, "                [ requires  ]\n" );
 	fprintf( stderr, "                [ allows  ]\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 0a8d19fdbe..c62b5d058f 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 5c9e2a267c..4ba1213fa2 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 57dbbd9eb2..d114732e48 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 
+#include 
 
 #include "ldap_pvt_thread.h"
 #include "ldif.h"
diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c
index f3b36d72f3..e0927ccc1a 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 58ae5aa6e5..ec31ed457f 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 85454dca1b..345a5e8938 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 a8fd9fab3a..5de70187f2 100644
--- a/servers/slapd/tools/ldapsyntax.c
+++ b/servers/slapd/tools/ldapsyntax.c
@@ -24,8 +24,8 @@
 /* #include  */
 #include 
 
-#include "lber.h"
-#include "ldap.h"
+#include 
+
 #include "ldif.h"
 #include "ldapsyntax.h"
 
diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c
index b41d8ba8d1..94df7d3901 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 94381c6202..f157bf021b 100644
--- a/servers/slapd/tools/ldif.c
+++ b/servers/slapd/tools/ldif.c
@@ -12,15 +12,15 @@
 #include 
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include 
+
 #include "ldif.h"
 
 static void
 usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-b] \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 28cee71c44..31928665b0 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 b70c8aeff4..aa1652dfa6 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 1a72b1f17f..97587c23fe 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 bc055976bf..5e86e79712 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 0e886427b5..aa90d138bc 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 53fabcc2ab..04f9f4baa6 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 f654baaa08..84d86d3f57 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 e1471f92a4..f2cb07e5aa 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 e95c5dddb2..cff24fd6a9 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 9d49474b3c..74e96fc4a1 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 d79325bfdd..acac1ad163 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 9f119825fa..54d54c3aaa 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 e9b5d7e7c1..38802e4422 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, "\" 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 b90a4570d4..1871085b66 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 9ba0a6c8be..afe0889e66 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 5dcce03bef..274f1517d8 100644
--- a/servers/slurpd/slurp.h
+++ b/servers/slurpd/slurp.h
@@ -29,8 +29,7 @@
 #endif
 #include 
 
-#include "lber.h"
-#include "ldap.h"
+#include 
 
 #define ldap_debug slurp_debug
 #include "ldap_log.h"
diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c
index 7f4a403c7e..b5a2a2177e 100644
--- a/tests/progs/slapd-addel.c
+++ b/tests/progs/slapd-addel.c
@@ -14,8 +14,7 @@
 #include 
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include 
 
 #define LOOPS	100
 
@@ -31,7 +30,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h ] -p port -D  -w  -f  [-l ]\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 287a4973ea..124eea6c88 100644
--- a/tests/progs/slapd-read.c
+++ b/tests/progs/slapd-read.c
@@ -14,8 +14,7 @@
 #include 
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include 
 
 #define LOOPS	100
 
@@ -27,7 +26,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h ] -p port -e  [-l ]\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 1799f639be..fd0a533896 100644
--- a/tests/progs/slapd-search.c
+++ b/tests/progs/slapd-search.c
@@ -14,8 +14,7 @@
 #include 
 #endif
 
-#include "lber.h"
-#include "ldap.h"
+#include 
 
 #define LOOPS	100
 
@@ -27,7 +26,7 @@ usage( char *name )
 {
 	fprintf( stderr, "usage: %s [-h ] -p port -b  -f  [-l ]\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 902b295354..cadd3df89d 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 ] -p  -D  -w  -d  -b  [-j ] [-l ] -P \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 */