+/* $OpenLDAP$ */
/*
* Copyright (c) 1995 Regents of the University of Michigan.
* All rights reserved.
#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
#include <ac/ctype.h>
+#include <ac/errno.h>
#include <ac/dirent.h>
#include <ac/string.h>
+#include <ac/unistd.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <quipu/config.h>
char *usage = "usage: %s [-d] [-o] [-r] [-v] [-b basedn] [-a addvalsfile] [-f fileattrdir] [-i ignoreattr...] [edbfile...]\n";
char edbfile[ MAXNAMLEN ], *basedn;
int c, rc, errflg, ignore_count, recurse;
- extern int optind;
- extern char *optarg;
extern char dsa_mode;
#ifdef HAVE_FILE_ATTR_DIR
extern char *file_attr_directory;
always_addvals = NULL;
basedn = NULL;
- while (( c = getopt( argc, argv, "dorva:b:f:h:i:" )) != -1 ) {
+ while (( c = getopt( argc, argv, "dorva:b:f:h:i:" )) != EOF ) {
switch( c ) {
case 'd':
#ifdef LDAP_DEBUG
} else if (( always_addvals = read_file( optarg, &always_addlen ))
== NULL ) {
print_err( optarg );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
break;
}
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" );
}
if ( ignore_attr == NULL ) {
print_err( "malloc/realloc" );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
ignore_attr[ ignore_count ] = optarg;
ignore_attr[ ++ignore_count ] = NULL;
if ( errflg ) {
fprintf( stderr, usage, progname );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
if ( basedn == NULL ) {
if ( init_syntaxes() < 0 ) {
fprintf( stderr, "%s: init_syntaxes failed -- check your oid tables \n",
progname );
- exit( 1 );
+ exit( EXIT_FAILURE );
}
fprintf( stderr, "edb2ldif: exit( %d )\n", ( rc < 0 ) ? 1 : 0 );
#endif
- exit( ( rc < 0 ) ? 1 : 0 );
+ exit( ( rc < 0 ) ? EXIT_FAILURE : EXIT_SUCCESS );
}
}
*filename++ = '\0';
- while ( isspace( *filename )) { /* strip leading whitespace */
+ while ( isspace((unsigned char) *filename) ) { /* strip leading whitespace */
++filename;
}
}
p = filename + strlen( filename ) - 1;
- while ( isspace( *p )) { /* strip trailing whitespace */
+ while ( isspace((unsigned char) *p) ) { /* strip trailing whitespace */
*p-- = '\0';
}
rdn = line;
- while ( isspace( *rdn )) { /* strip leading whitespace */
+ while ( isspace((unsigned char) *rdn)) { /* strip leading whitespace */
++rdn;
}
}
p = rdn + strlen( rdn ) - 1;
- while ( isspace( *p )) { /* strip trailing whitespace */
+ while ( isspace((unsigned char) *p)) { /* strip trailing whitespace */
*p-- = '\0';
}
static void
print_err( char *msg )
{
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
-
#ifdef LDAP_DEBUG
if ( debugflg ) {
fprintf( stderr, "print_err( \"%s\" )\n", msg );
#endif
if ( errno > sys_nerr ) {
- fprintf( stderr, "%s: %s: error %d\n", progname, msg, errno );
+ fprintf( stderr, "%s: %s: errno=%d\n", progname, msg, errno );
} else {
fprintf( stderr, "%s: %s: %s\n", progname, msg, sys_errlist[ errno ] );
}