]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/schema.c
Add ber_bvstr and ber_bvstrdup string to berval allocators.
[openldap] / libraries / libldap / schema.c
index 0871386060167c9ae233f1614bde05176d017061..78fbe8a3fa25079f7ee5a5e89017a1076b53a066 100644 (file)
@@ -1,7 +1,9 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- *
+ */
+/*
  * schema.c:  parsing routines used by servers and clients to process
  *     schema definitions
  */
 
 #include <ldap_schema.h>
 
+
+static LDAP_CONST char *
+choose_name( char *names[], LDAP_CONST char *fallback )
+{
+       return( (names != NULL && names[0] != NULL) ? names[0] : fallback );
+}
+
+LDAP_CONST char *
+ldap_syntax2name( LDAP_SYNTAX * syn )
+{
+       return( syn->syn_oid );
+}
+
+LDAP_CONST char *
+ldap_matchingrule2name( LDAP_MATCHING_RULE * mr )
+{
+       return( choose_name( mr->mr_names, mr->mr_oid ) );
+}
+
+LDAP_CONST char *
+ldap_attributetype2name( LDAP_ATTRIBUTE_TYPE * at )
+{
+       return( choose_name( at->at_names, at->at_oid ) );
+}
+
+LDAP_CONST char *
+ldap_objectclass2name( LDAP_OBJECT_CLASS * oc )
+{
+       return( choose_name( oc->oc_names, oc->oc_oid ) );
+}
+
+
 /*
  * When pretty printing the entities we will be appending to a buffer.
  * Since checking for overflow, realloc'ing and checking if no error
@@ -1227,9 +1261,6 @@ ldap_str2attributetype( const char * s, int * code, const char ** errp )
        int seen_substr = 0;
        int seen_syntax = 0;
        int seen_usage = 0;
-       int seen_kind = 0;
-       int seen_must = 0;
-       int seen_may = 0;
        LDAP_ATTRIBUTE_TYPE * at;
        char ** ssdummy;
        const char * savepos;
@@ -1804,7 +1835,7 @@ ldap_str2objectclass( const char * s, int * code, const char ** errp )
        }
 }
 
-static char *err2text[] = {
+static char *const err2text[] = {
        "",
        "Out of memory",
        "Unexpected token",