]> git.sur5r.net Git - openldap/blobdiff - tests/progs/slapd-addel.c
Add cn=monitor, cn=config, cn=schema to namingContexts.
[openldap] / tests / progs / slapd-addel.c
index e99fbf00fe9bf1a3d49e70be3abda5112c9b97f5..7f4a403c7ee7b300ae4dfc89ac67946fa6cc91ed 100644 (file)
@@ -2,13 +2,17 @@
 
 #include <stdio.h>
 
-#include <ac/string.h>
+#include <ac/stdlib.h>
+
 #include <ac/ctype.h>
 #include <ac/socket.h>
+#include <ac/string.h>
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 
 #include "lber.h"
 #include "ldap.h"
@@ -33,7 +37,7 @@ usage( char *name )
 int
 main( int argc, char **argv )
 {
-       int             i, j;
+       int             i;
        char        *host = "localhost";
        int                     port = -1;
        char            *manager = NULL;
@@ -102,10 +106,6 @@ main( int argc, char **argv )
 }
 
 
-#define safe_realloc( ptr, size )   ( ptr == NULL ? malloc( size ) : \
-                               realloc( ptr, size ))
-
-
 static void
 addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
 {
@@ -127,9 +127,9 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
     }
 
     if ( pmods == NULL || pmods[ i ] == NULL ) {
-               if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) *
+               if (( pmods = (LDAPMod **)realloc( pmods, (i + 2) *
                        sizeof( LDAPMod * ))) == NULL ) {
-                       perror( "safe_realloc" );
+                       perror( "realloc" );
                        exit( 1 );
                }
                *pmodsp = pmods;
@@ -154,13 +154,13 @@ addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
                }
                }
                if (( pmods[ i ]->mod_bvalues =
-                       (struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
+                       (struct berval **)ber_memrealloc( pmods[ i ]->mod_bvalues,
                        (j + 2) * sizeof( struct berval * ))) == NULL ) {
-                       perror( "safe_realloc" );
+                       perror( "ber_realloc" );
                        exit( 1 );
                }
                pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
-               if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
+               if (( bvp = (struct berval *)ber_memalloc( sizeof( struct berval )))
                        == NULL ) {
                        perror( "malloc" );
                        exit( 1 );
@@ -184,7 +184,7 @@ get_add_entry( char *filename, LDAPMod ***mods )
        FILE    *fp;
        char    *entry = NULL;
 
-       if ( fp = fopen( filename, "r" )) {
+       if ( (fp = fopen( filename, "r" )) != NULL ) {
                char  line[BUFSIZ];
 
                if ( fgets( line, BUFSIZ, fp )) {
@@ -207,7 +207,8 @@ get_add_entry( char *filename, LDAPMod ***mods )
                        if ( !( value = strchr( line, ':' ))) break;
 
                        *value++ = '\0'; 
-                       while ( *value && isspace( *value )) value++;
+                       while ( *value && isspace( (unsigned char) *value ))
+                               value++;
 
                        addmodifyop( mods, LDAP_MOD_ADD, line, value, strlen( value ));
 
@@ -247,7 +248,7 @@ do_addel(
 
 
        fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
-                                       pid, maxloop, entry );
+                                       (long) pid, maxloop, entry );
 
        for ( i = 0; i < maxloop; i++ ) {
 
@@ -272,7 +273,7 @@ do_addel(
 
        }
 
-       fprintf( stderr, " PID=%ld - Add/Delete done.\n", pid );
+       fprintf( stderr, " PID=%ld - Add/Delete done.\n", (long) pid );
 
        ldap_unbind( ld );
 }