]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/edb2ldif.c
Split out schema initialization of builtin syntax/matching rule
[openldap] / servers / slapd / tools / edb2ldif.c
index 9aad796369a0c46b5f58f5f5395296c5877a19e1..0ef3fb8edcab60c4532487aea4a42ab9577b33da 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1995 Regents of the University of Michigan.
  * All rights reserved.
@@ -13,7 +14,8 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/errno.h>
@@ -21,7 +23,6 @@
 #include <ac/string.h>
 #include <ac/unistd.h>
 
-#include <sys/types.h>
 #include <sys/stat.h>
 
 #include <quipu/config.h>
@@ -109,7 +110,7 @@ main( int argc, char **argv )
     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
@@ -137,7 +138,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 +162,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 +182,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 +195,7 @@ main( int argc, char **argv )
 
     if ( errflg ) {
        fprintf( stderr, usage, progname );
-       exit( 1 );
+       exit( EXIT_FAILURE );
     }
 
     if ( basedn == NULL ) {
@@ -213,7 +214,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 +243,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 );
 }
 
 
@@ -761,7 +762,7 @@ read_edbmap( char *mapfile, struct edbmap **edbmapp )
        }
 
        *filename++ = '\0';
-       while ( isspace( *filename )) { /* strip leading whitespace */
+       while ( isspace((unsigned char) *filename) ) { /* strip leading whitespace */
            ++filename;
        }
 
@@ -770,12 +771,12 @@ read_edbmap( char *mapfile, struct edbmap **edbmapp )
        }
 
        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;
        }
 
@@ -784,7 +785,7 @@ read_edbmap( char *mapfile, struct edbmap **edbmapp )
        }
 
        p = rdn + strlen( rdn ) - 1;
-       while ( isspace( *p )) {        /* strip trailing whitespace */
+       while ( isspace((unsigned char) *p)) { /* strip trailing whitespace */
            *p-- = '\0';
        }
 
@@ -863,7 +864,7 @@ print_err( char *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 ] );
     }