]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/at.c
streamline group attr specification/diagnostics
[openldap] / servers / slapd / at.c
index 2f5c57d700c946e03a96d2d76ecf85c775c75dd5..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;
 }
 
@@ -61,6 +77,9 @@ static Avlnode        *attr_cache = NULL;
 static LDAP_STAILQ_HEAD(ATList, slap_attribute_type) attr_list
        = LDAP_STAILQ_HEAD_INITIALIZER(attr_list);
 
+/* Last hardcoded attribute registered */
+AttributeType *at_sys_tail;
+
 int at_oc_cache;
 
 static int
@@ -229,7 +248,7 @@ at_delete_names( AttributeType *at )
 /* Mark the attribute as deleted, remove from list, and remove all its
  * names from the AVL tree. Leave the OID in the tree.
  */
-int
+void
 at_delete( AttributeType *at )
 {
        at->sat_flags |= SLAP_AT_DELETED;
@@ -237,8 +256,6 @@ at_delete( AttributeType *at )
        LDAP_STAILQ_REMOVE(&attr_list,at,slap_attribute_type,sat_next);
 
        at_delete_names( at );
-
-       return 0;
 }
 
 static void
@@ -527,6 +544,10 @@ at_insert(
                }
        }
 
+       if ( sat->sat_flags & SLAP_AT_HARDCODE ) {
+               prev = at_sys_tail;
+               at_sys_tail = sat;
+       }
        if ( prev ) {
                LDAP_STAILQ_INSERT_AFTER( &attr_list, prev, sat, sat_next );
        } else {
@@ -919,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;
        }
@@ -936,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;