X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fschema_init.c;h=e0a0600542be8973823c6bc0019f161ea7dde35e;hb=08fe5e7026a6ea7ab301f6ab9bd383b85f1e2149;hp=d31257113917b6a9f67be998d0b378dc94db6c0d;hpb=439af9ec109e3a11b9ef4add968214a6875896ca;p=openldap diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index d312571139..e0a0600542 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -2187,6 +2187,56 @@ UUIDValidate( return LDAP_SUCCESS; } +static int +UUIDPretty( + Syntax *syntax, + struct berval *in, + struct berval *out, + void *ctx ) +{ + int i; + int rc=LDAP_INVALID_SYNTAX; + + assert( in != NULL ); + assert( out != NULL ); + + if( in->bv_len != 36 ) return LDAP_INVALID_SYNTAX; + + out->bv_len = 36; + out->bv_val = slap_sl_malloc( out->bv_len + 1, ctx ); + + for( i=0; i<36; i++ ) { + switch(i) { + case 8: + case 13: + case 18: + case 23: + if( in->bv_val[i] != '-' ) { + goto handle_error; + } + out->bv_val[i] = '-'; + break; + + default: + if( !ASCII_HEX( in->bv_val[i]) ) { + goto handle_error; + } + out->bv_val[i] = TOLOWER( in->bv_val[i] ); + } + } + + rc = LDAP_SUCCESS; + out->bv_val[ out->bv_len ] = '\0'; + + if( 0 ) { +handle_error: + slap_sl_free( out->bv_val, ctx ); + out->bv_val = NULL; + } + + return rc; +} + int UUIDNormalize( slap_mask_t usage, @@ -3448,7 +3498,7 @@ static slap_syntax_defs_rec syntax_defs[] = { #endif {"( 1.3.6.1.1.16.1 DESC 'UUID' )", - 0, UUIDValidate, NULL}, + 0, UUIDValidate, UUIDPretty}, {"( 1.3.6.1.4.1.4203.666.11.2.1 DESC 'CSN' )", SLAP_SYNTAX_HIDE, csnValidate, NULL},