+/* $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
#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>
#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[] = {
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;
*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 );
}
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 );
}
}
LDAP_FREE( colp->ti_label );
}
if ( colp->ti_args != NULL ) {
- free_strarray( colp->ti_args );
+ LDAP_VFREE( colp->ti_args );
}
LDAP_FREE( colp );
}
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;
/*
* 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 ];
/*
* 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 );
}
/*
* 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 );
}
/*
* 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 );
}
}
}
}
- 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 );
}
/*
* 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 );
}
/*
* 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 );
}
/*
* 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 );
}
/*
* 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 ) {
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 );
}
* 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 );
}
}
}
if ( itemoptions[ i ] == NULL ) {
- free_strarray( toks );
+ LDAP_VFREE( toks );
free_disptmpl( tmpl );
return( LDAP_TMPL_ERR_SYNTAX );
}
}
}
if ( itemtypes[ i ] == NULL ) {
- free_strarray( toks );
+ LDAP_VFREE( toks );
free_disptmpl( tmpl );
return( LDAP_TMPL_ERR_SYNTAX );
}
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 );
}