]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/at.c
streamline group attr specification/diagnostics
[openldap] / servers / slapd / at.c
index e02acf90a026cf63d6fb2bb3252f32e0ac4c2023..f242491d11d909ac34a5310e633d9699481a0e4a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "slap.h"
 
 
-int is_at_syntax(
-       AttributeType *at,
-       const char *oid )
+const char *
+at_syntax(
+       AttributeType   *at )
 {
-       for( ; at != NULL; at = at->sat_sup ) {
-               if( at->sat_syntax_oid ) {
-                       return ( strcmp( at->sat_syntax_oid, oid ) == 0 );
+       for ( ; at != NULL; at = at->sat_sup ) {
+               if ( at->sat_syntax_oid ) {
+                       return at->sat_syntax_oid;
                }
        }
 
+       assert( 0 );
+
+       return NULL;
+}
+
+int
+is_at_syntax(
+       AttributeType   *at,
+       const char      *oid )
+{
+       const char *syn_oid = at_syntax( at );
+
+       if ( syn_oid ) {
+               return strcmp( syn_oid, oid ) == 0;
+       }
+
        return 0;
 }
 
@@ -62,7 +78,7 @@ static LDAP_STAILQ_HEAD(ATList, slap_attribute_type) attr_list
        = LDAP_STAILQ_HEAD_INITIALIZER(attr_list);
 
 /* Last hardcoded attribute registered */
-static AttributeType *attr_sys_tail;
+AttributeType *at_sys_tail;
 
 int at_oc_cache;
 
@@ -529,8 +545,8 @@ at_insert(
        }
 
        if ( sat->sat_flags & SLAP_AT_HARDCODE ) {
-               prev = attr_sys_tail;
-               attr_sys_tail = sat;
+               prev = at_sys_tail;
+               at_sys_tail = sat;
        }
        if ( prev ) {
                LDAP_STAILQ_INSERT_AFTER( &attr_list, prev, sat, sat_next );
@@ -924,7 +940,7 @@ at_unparse( BerVarray *res, AttributeType *start, AttributeType *end, int sys )
        /* count the result size */
        i = 0;
        for ( at=start; at; at=LDAP_STAILQ_NEXT(at, sat_next)) {
-               if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) continue;
+               if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) break;
                i++;
                if ( at == end ) break;
        }
@@ -941,7 +957,7 @@ at_unparse( BerVarray *res, AttributeType *start, AttributeType *end, int sys )
        i = 0;
        for ( at=start; at; at=LDAP_STAILQ_NEXT(at, sat_next)) {
                LDAPAttributeType lat, *latp;
-               if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) continue;
+               if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) break;
                if ( at->sat_oidmacro ) {
                        lat = at->sat_atype;
                        lat.at_oid = at->sat_oidmacro;