]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/disptmpl.c
cleanup
[openldap] / libraries / libldap / disptmpl.c
index 0fb3e20163304d70fafd77d2d7efa67a3d155ae3..f1cf4117ce83b6844b895e7f8aec6ec22df7586c 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
@@ -20,9 +21,9 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
 
-#include <ac/ctype.h>
+#include <ac/stdlib.h>
+
 #include <ac/string.h>
 #include <ac/time.h>
 #include <ac/unistd.h>
@@ -35,7 +36,7 @@
 #include "disptmpl.h"
 
 static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl ));
-static int read_next_tmpl LDAP_P(( char **bufp, long *blenp,
+static int read_next_tmpl LDAP_P(( char **bufp, ber_len_t *blenp,
        struct ldap_disptmpl **tmplp, int dtversion ));
 
 static const char *const       tmploptions[] = {
@@ -138,7 +139,7 @@ ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
 
 
 int
-ldap_init_templates_buf( char *buf, long buflen,
+ldap_init_templates_buf( char *buf, ber_len_t buflen,
        struct ldap_disptmpl **tmpllistp )
 {
     int                                rc=-1, version;
@@ -147,13 +148,13 @@ ldap_init_templates_buf( char *buf, long buflen,
 
     *tmpllistp = prevtmpl = NULL;
 
-    if ( next_line_tokens( &buf, &buflen, &toks ) != 2 ||
+    if ( ldap_int_next_line_tokens( &buf, &buflen, &toks ) != 2 ||
            strcasecmp( toks[ 0 ], "version" ) != 0 ) {
-       free_strarray( toks );
+       LDAP_VFREE( toks );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
     version = atoi( toks[ 1 ] );
-    free_strarray( toks );
+    LDAP_VFREE( toks );
     if ( version != LDAP_TEMPLATE_VERSION ) {
        return( LDAP_TMPL_ERR_VERSION );
     }
@@ -224,7 +225,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
 
            for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) {
                nextocp = ocp->oc_next;
-               free_strarray( ocp->oc_objclasses );
+               LDAP_VFREE( ocp->oc_objclasses );
                LDAP_FREE( ocp );
            }
        }
@@ -258,7 +259,7 @@ free_disptmpl( struct ldap_disptmpl *tmpl )
                        LDAP_FREE( colp->ti_label );
                    }
                    if ( colp->ti_args != NULL ) {
-                       free_strarray( colp->ti_args );
+                       LDAP_VFREE( colp->ti_args );
                    }
                    LDAP_FREE( colp );
                }
@@ -440,7 +441,7 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
 
 
 static int
-read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
+read_next_tmpl( char **bufp, ber_len_t *blenp, struct ldap_disptmpl **tmplp,
        int dtversion )
 {
     int                                i, j, tokcnt, samerow, adsource;
@@ -455,14 +456,14 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * template name comes first
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX );
     }
 
     if (( tmpl = (struct ldap_disptmpl *)LDAP_CALLOC( 1,
            sizeof( struct ldap_disptmpl ))) == NULL ) {
-       free_strarray( toks );
+       LDAP_VFREE( toks );
        return(  LDAP_TMPL_ERR_MEM );
     }
     tmpl->dt_name = toks[ 0 ];
@@ -471,8 +472,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * template plural name comes next
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -482,8 +483,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * template icon name is next
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -493,8 +494,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * template options come next
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) < 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) < 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -505,15 +506,15 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
            }
        }
     }
-    free_strarray( toks );
+    LDAP_VFREE( toks );
 
     /*
      * object class list is next
      */
-    while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
+    while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) {
        if (( ocp = (struct ldap_oclist *)LDAP_CALLOC( 1,
                sizeof( struct ldap_oclist ))) == NULL ) {
-           free_strarray( toks );
+           LDAP_VFREE( toks );
            free_disptmpl( tmpl );
            return( LDAP_TMPL_ERR_MEM );
        }
@@ -533,8 +534,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * read name of attribute to authenticate as
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -548,8 +549,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * read default attribute to use for RDN
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -559,8 +560,8 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * read default location for new entries
      */
-    if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
-       free_strarray( toks );
+    if (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) != 1 ) {
+       LDAP_VFREE( toks );
        free_disptmpl( tmpl );
        return( LDAP_TMPL_ERR_SYNTAX );
     }
@@ -574,7 +575,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
     /*
      * read list of rules used to define default values for new entries
      */
-    while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
+    while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) {
        if ( strcasecmp( ADDEF_CONSTANT, toks[ 0 ] ) == 0 ) {
            adsource = LDAP_ADSRC_CONSTANTVALUE;
        } else if ( strcasecmp( ADDEF_ADDERSDN, toks[ 0 ] ) == 0 ) {
@@ -585,14 +586,14 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
        if ( adsource == 0 || tokcnt < 2 ||
                ( adsource == LDAP_ADSRC_CONSTANTVALUE && tokcnt != 3 ) ||
                ( adsource == LDAP_ADSRC_ADDERSDN && tokcnt != 2 )) {
-           free_strarray( toks );
+           LDAP_VFREE( toks );
            free_disptmpl( tmpl );
            return( LDAP_TMPL_ERR_SYNTAX );
        }
                
        if (( adp = (struct ldap_adddeflist *)LDAP_CALLOC( 1,
                sizeof( struct ldap_adddeflist ))) == NULL ) {
-           free_strarray( toks );
+           LDAP_VFREE( toks );
            free_disptmpl( tmpl );
            return( LDAP_TMPL_ERR_MEM );
        }
@@ -616,17 +617,17 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
      * item list is next
      */
     samerow = 0;
-    while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
+    while (( tokcnt = ldap_int_next_line_tokens( bufp, blenp, &toks )) > 0 ) {
        if ( strcasecmp( toks[ 0 ], "item" ) == 0 ) {
            if ( tokcnt < 4 ) {
-               free_strarray( toks );
+               LDAP_VFREE( toks );
                free_disptmpl( tmpl );
                return( LDAP_TMPL_ERR_SYNTAX );
            }
 
            if (( ip = (struct ldap_tmplitem *)LDAP_CALLOC( 1,
                    sizeof( struct ldap_tmplitem ))) == NULL ) {
-               free_strarray( toks );
+               LDAP_VFREE( toks );
                free_disptmpl( tmpl );
                return( LDAP_TMPL_ERR_MEM );
            }
@@ -642,7 +643,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                    }
                }
                if ( itemoptions[ i ] == NULL ) {
-                   free_strarray( toks );
+                   LDAP_VFREE( toks );
                    free_disptmpl( tmpl );
                    return( LDAP_TMPL_ERR_SYNTAX );
                }
@@ -655,7 +656,7 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
                }
            }
            if ( itemtypes[ i ] == NULL ) {
-               free_strarray( toks );
+               LDAP_VFREE( toks );
                free_disptmpl( tmpl );
                return( LDAP_TMPL_ERR_SYNTAX );
            }
@@ -696,10 +697,10 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp,
            previp = ip;
            samerow = 0;
        } else if ( strcasecmp( toks[ 0 ], "samerow" ) == 0 ) {
-           free_strarray( toks );
+           LDAP_VFREE( toks );
            samerow = 1;
        } else {
-           free_strarray( toks );
+           LDAP_VFREE( toks );
            free_disptmpl( tmpl );
            return( LDAP_TMPL_ERR_SYNTAX );
        }