/* syntax.c - routines to manage syntax definitions */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
static int
syn_index_name_cmp(
- char *name,
+ const char *name,
struct sindexrec *sir
)
{
return( NULL );
}
+void
+syn_destroy( void )
+{
+ Syntax *s, *n;
+
+ avl_free(syn_index, ldap_memfree);
+ for (s=syn_list; s; s=n) {
+ n = s->ssyn_next;
+ ldap_syntax_free((LDAPSyntax *)s);
+ }
+}
+
static int
syn_insert(
Syntax *ssyn,
(AVL_DUP) avl_dup_error ) ) {
*err = ssyn->ssyn_oid;
ldap_memfree(sir);
- return SLAP_SCHERR_DUP_SYNTAX;
+ return SLAP_SCHERR_SYN_DUP;
}
/* FIX: temporal consistency check */
syn_find(sir->sir_name);
ssyn->ssyn_next = NULL;
+ ssyn->ssyn_oidlen = strlen(syn->syn_oid);
ssyn->ssyn_flags = flags;
ssyn->ssyn_validate = validate;
ssyn->ssyn_normalize = normalize;
int
register_syntax(
- char * desc,
+ const char * desc,
unsigned flags,
slap_syntax_validate_func *validate,
slap_syntax_transform_func *normalize,
int
syn_schema_info( Entry *e )
{
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
Syntax *syn;
AttributeDescription *ad_ldapSyntaxes = slap_schema.si_ad_ldapSyntaxes;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
for ( syn = syn_list; syn; syn = syn->ssyn_next ) {
if ( ! syn->ssyn_validate ) {
continue;
}
- val.bv_val = ldap_syntax2str( &syn->ssyn_syn );
- if ( val.bv_val == NULL ) {
+ if ( ldap_syntax2bv( &syn->ssyn_syn, vals ) == NULL ) {
return -1;
}
- val.bv_len = strlen( val.bv_val );
#if 0
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
"syn_schema_info: Merging syn [%ld] %s\n",
- (long)val.bv_len, val.bv_val ));
+ (long)vals[0].bv_len, vals[0].bv_val ));
#else
Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
+ (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
#endif
attr_merge( e, ad_ldapSyntaxes, vals );
- ldap_memfree( val.bv_val );
+ ldap_memfree( vals[0].bv_val );
}
return 0;
}