]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ad.c
Remove lint
[openldap] / servers / slapd / ad.c
index ff076944fc1053f55c8d86ed206d7280cb452a1c..e2a028c90df5b96331e94331de6a4f2249685592 100644 (file)
@@ -18,7 +18,6 @@
 #include "ldap_pvt.h"
 #include "slap.h"
 
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
 AttributeDescription *ad_dup(
        AttributeDescription *desc )
 {
@@ -77,7 +76,7 @@ static int ad_keystring(
 int slap_str2ad(
        const char *str,
        AttributeDescription **ad,
-       char **text )
+       const char **text )
 {
        struct berval bv;
        bv.bv_val = (char *) str;
@@ -89,7 +88,7 @@ int slap_str2ad(
 int slap_bv2ad(
        struct berval *bv,
        AttributeDescription **ad,
-       char **text )
+       const char **text )
 {
        int rtn = LDAP_UNDEFINED_TYPE;
        int i;
@@ -98,7 +97,6 @@ int slap_bv2ad(
 
        assert( ad != NULL );
        assert( *ad == NULL ); /* temporary */
-       assert( *text != NULL );
 
        if( bv == NULL || bv->bv_len == 0 ) {
                *text = "empty attribute description";
@@ -130,14 +128,12 @@ int slap_bv2ad(
 
        for( i=1; tokens[i] != NULL; i++ ) {
                if( strcasecmp( tokens[i], "binary" ) == 0 ) {
-                       if( desc.ad_flags & SLAP_DESC_BINARY ) {
+                       if( slap_ad_is_binary( &desc ) ) {
                                *text = "option \"binary\" specified multiple times";
                                goto done;
                        }
 
-                       if(!( desc.ad_type->sat_syntax->ssyn_flags
-                               & SLAP_SYNTAX_BINARY ))
-                       {
+                       if( !slap_syntax_is_binary( desc.ad_type->sat_syntax )) {
                                /* not stored in binary, disallow option */
                                *text = "option \"binary\" with type not supported";
                                goto done;
@@ -152,7 +148,8 @@ int slap_bv2ad(
                                *text = "multiple language tag options specified";
                                goto done;
                        }
-                       desc.ad_lang = tokens[i];
+
+                       desc.ad_lang = ch_strdup( tokens[i] );
 
                        /* normalize to all lower case, it's easy */
                        ldap_pvt_str2lower( desc.ad_lang );
@@ -166,7 +163,7 @@ int slap_bv2ad(
        desc.ad_cname = ch_malloc( sizeof( struct berval ) );
 
        desc.ad_cname->bv_len = strlen( desc.ad_type->sat_cname );
-       if( desc.ad_flags & SLAP_DESC_BINARY ) {
+       if( slap_ad_is_binary( &desc ) ) {
                desc.ad_cname->bv_len += sizeof("binary");
        }
        if( desc.ad_lang != NULL ) {
@@ -176,7 +173,7 @@ int slap_bv2ad(
        desc.ad_cname->bv_val = ch_malloc( desc.ad_cname->bv_len + 1 );
 
        strcpy( desc.ad_cname->bv_val, desc.ad_type->sat_cname );
-       if( desc.ad_flags & SLAP_DESC_BINARY ) {
+       if( slap_ad_is_binary( &desc ) ) {
                strcat( desc.ad_cname->bv_val, ";binary" );
        }
 
@@ -207,7 +204,7 @@ int is_ad_subtype(
                return 0;
        }
 
-       if( super->ad_flags && ( super->ad_flags == sub->ad_flags )) {
+       if( super->ad_flags && ( super->ad_flags != sub->ad_flags )) {
                return 0;
        }
 
@@ -228,7 +225,7 @@ int ad_inlist(
        int i;
        for( i=0; attrs[i] != NULL; i++ ) {
                AttributeDescription *ad = NULL;
-               char *text;
+               const char *text;
                int rc;
                
                rc = slap_str2ad( attrs[i], &ad, &text );
@@ -245,5 +242,55 @@ int ad_inlist(
        return 0;
 }
 
-#endif
+
+int slap_str2undef_ad(
+       const char *str,
+       AttributeDescription **ad,
+       const char **text )
+{
+       struct berval bv;
+       bv.bv_val = (char *) str;
+       bv.bv_len = strlen( str );
+
+       return slap_bv2undef_ad( &bv, ad, text );
+}
+
+int slap_bv2undef_ad(
+       struct berval *bv,
+       AttributeDescription **ad,
+       const char **text )
+{
+       AttributeDescription desc;
+
+       assert( ad != NULL );
+       assert( *ad == NULL ); /* temporary */
+
+       if( bv == NULL || bv->bv_len == 0 ) {
+               *text = "empty attribute description";
+               return LDAP_UNDEFINED_TYPE;
+       }
+
+       /* make sure description is IA5 */
+       if( ad_keystring( bv ) ) {
+               *text = "attribute description contains inappropriate characters";
+               return LDAP_UNDEFINED_TYPE;
+       }
+
+       desc.ad_type = slap_schema.si_at_undefined;
+       desc.ad_flags = SLAP_DESC_NONE;
+       desc.ad_lang = NULL;
+
+       desc.ad_cname = ber_bvdup( bv );
+
+       /* canoncial to upper case */
+       ldap_pvt_str2upper( bv->bv_val );
+
+       if( *ad == NULL ) {
+               *ad = ch_malloc( sizeof( AttributeDescription ) );
+       }
+
+       **ad = desc;
+
+       return LDAP_SUCCESS;
+}