]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/config.c
Kill lber_debug
[openldap] / servers / slurpd / config.c
index 617943cbacee19d82be6715c1961ab218e64b105..e9b5d7e7c1600fd75602cdc0c7973e64a35520db 100644 (file)
 #include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/stdlib.h>
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/ctype.h>
 
 #include <lber.h>
 #include <ldap.h>
 #define MAXARGS        100
 
 /* Forward declarations */
-#ifdef NEEDPROTOS
-static void    add_replica( char **, int );
-static int     parse_replica_line( char **, int, Ri *);
-static void    parse_line( char *, int *, char ** );
-static char    *getline( FILE * );
-static char    *strtok_quote( char *, char * );
-#else /* NEEDPROTOS */
-static void    add_replica();
-static int     parse_replica_line();
-static void    parse_line();
-static char    *getline();
-static char    *strtok_quote();
-#endif /* NEEDPROTOS */
+static void    add_replica LDAP_P(( char **, int ));
+static int     parse_replica_line LDAP_P(( char **, int, Ri *));
+static void    parse_line LDAP_P(( char *, int *, char ** ));
+static char    *getline LDAP_P(( FILE * ));
+static char    *strtok_quote LDAP_P(( char *, char * ));
 
 /* current config file line # */
 static int     lineno;
@@ -61,8 +55,7 @@ slurpd_read_config(
 )
 {
     FILE       *fp;
-    char       buf[BUFSIZ];
-    char       *line, *p;
+    char       *line;
     int                cargc;
     char       *cargv[MAXARGS];
 
@@ -180,11 +173,13 @@ strtok_quote(
            } else {
                inquote = 1;
            }
-           strcpy( next, next + 1 );
+           SAFEMEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
            break;
 
        case '\\':
-           strcpy( next, next + 1 );
+           if ( next[1] )
+               SAFEMEMCPY( next, next + 1, strlen( next + 1 ) + 1 );
+           next++;             /* dont parse the escaped character */
            break;
 
        default:
@@ -235,7 +230,7 @@ getline(
            *p = '\0';
        }
        lineno++;
-       if ( ! isspace( buf[0] ) ) {
+       if ( ! isspace( (unsigned char) buf[0] ) ) {
            return( line );
        }
 
@@ -346,7 +341,7 @@ parse_replica_line(
                ri->ri_port = atoi( hp );
            }
            if ( ri->ri_port <= 0 ) {
-               ri->ri_port = LDAP_PORT;
+               ri->ri_port = 0;
            }
            ri->ri_hostname = strdup( val );
            gots |= GOT_HOST;
@@ -359,13 +354,13 @@ parse_replica_line(
                strlen( BINDMETHSTR ))) {
            val = cargv[ i ] + strlen( BINDMETHSTR ) + 1;
            if ( !strcasecmp( val, KERBEROSSTR )) {
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
                ri->ri_bind_method = AUTH_KERBEROS;
                if ( ri->ri_srvtab == NULL ) {
                    ri->ri_srvtab = strdup( sglob->default_srvtab );
                }
                gots |= GOT_METHOD;
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
            fprintf( stderr, "Error: a bind method of \"kerberos\" was\n" );
            fprintf( stderr, "specified in the slapd configuration file,\n" );
            fprintf( stderr, "but slurpd was not built with kerberos.\n" );
@@ -373,7 +368,7 @@ parse_replica_line(
            fprintf( stderr, "kerberos support if you wish to use\n" );
            fprintf( stderr, "bindmethod=kerberos\n" );
            exit( 1 );
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
            } else if ( !strcasecmp( val, SIMPLESTR )) {
                ri->ri_bind_method = AUTH_SIMPLE;
                gots |= GOT_METHOD;