]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/dsparse.c
Update PF_INET6 and PF_UNIX detection, both default to auto
[openldap] / libraries / libldap / dsparse.c
index 9e1f1fbdcd855f6af2320e1695c809bbd6a1f6b2..8ec7116fd9f2af43b18bb7d7d116c27cc3742ef0 100644 (file)
@@ -1,5 +1,6 @@
+/* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*  Portions
@@ -22,7 +23,7 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
 
 #include "ldap-int.h"
 
-static int next_line LDAP_P(( char **bufp, long *blenp, char **linep ));
+static int next_line LDAP_P(( char **bufp, ber_len_t *blenp, char **linep ));
 static char *next_token LDAP_P(( char ** sp ));
 
 
-
 int
-next_line_tokens( char **bufp, long *blenp, char ***toksp )
+ldap_int_next_line_tokens( char **bufp, ber_len_t *blenp, char ***toksp )
 {
     char       *p, *line, *token, **toks;
     int                rc, tokcnt;
@@ -51,18 +51,18 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
        return( rc );
     }
 
-    if (( toks = (char **)calloc( 1, sizeof( char * ))) == NULL ) {
-       free( line );
+    if (( toks = (char **)LDAP_CALLOC( 1, sizeof( char * ))) == NULL ) {
+       LBER_FREE( line );
        return( -1 );
     }
     tokcnt = 0;
 
     p = line;
     while (( token = next_token( &p )) != NULL ) {
-       if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) *
+       if (( toks = (char **)LDAP_REALLOC( toks, ( tokcnt + 2 ) *
                sizeof( char * ))) == NULL ) {
-           free( (char *)toks );
-           free( line );
+           LBER_FREE( (char *)toks );
+           LBER_FREE( line );
            return( -1 );
        }
        toks[ tokcnt ] = token;
@@ -71,15 +71,15 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
 
     if ( tokcnt == 1 && strcasecmp( toks[ 0 ], "END" ) == 0 ) {
        tokcnt = 0;
-       free_strarray( toks );
+       LDAP_VFREE( toks );
        toks = NULL;
     }
 
-    free( line );
+    LBER_FREE( line );
 
     if ( tokcnt == 0 ) {
        if ( toks != NULL ) {
-           free( (char *)toks );
+           LBER_FREE( (char *)toks );
        }
     } else {
        *toksp = toks;
@@ -90,10 +90,10 @@ next_line_tokens( char **bufp, long *blenp, char ***toksp )
 
 
 static int
-next_line( char **bufp, long *blenp, char **linep )
+next_line( char **bufp, ber_len_t *blenp, char **linep )
 {
     char       *linestart, *line, *p;
-    long       plen;
+    ber_slen_t plen;
 
     linestart = *bufp;
     p = *bufp;
@@ -131,7 +131,7 @@ next_line( char **bufp, long *blenp, char **linep )
        return( 0 );    /* end of file */
     }
 
-    if (( line = malloc( p - linestart )) == NULL ) {
+    if (( line = LDAP_MALLOC( p - linestart )) == NULL ) {
        *linep = NULL;
        return( -1 );   /* fatal error */
     }
@@ -192,19 +192,5 @@ next_token( char **sp )
        return( NULL );
     }
 
-    return( strdup( tokstart ));
-}
-
-
-void
-free_strarray( char **sap )
-{
-    int                i;
-
-    if ( sap != NULL ) {
-       for ( i = 0; sap[ i ] != NULL; ++i ) {
-           free( sap[ i ] );
-       }
-       free( (char *)sap );
-    }
+    return( LDAP_STRDUP( tokstart ));
 }