Commit df8f7cbb authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

s/exit(1)/exit(EXIT_FAILURE)/

s/exit(0)/exit(EXIT_SUCCESS)/
add <ac/stdlib.h> where needed and other minor header adjustments
parent 32ba884d
......@@ -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
}}}
###############################################################################
......
......@@ -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
......
......@@ -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" );
......
......@@ -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 ) {
......
......@@ -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 ) {
......
......@@ -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;
......
......@@ -39,8 +39,7 @@
#include <sys/resource.h>
#endif
#include "lber.h"
#include "ldap.h"
#include <ldap.h>
#include "ldap_defaults.h"
......
......@@ -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 );
......
......@@ -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"
......
......@@ -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':
......
......@@ -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,