1 /* schemaparse.c - routines to parse config file objectclass definitions */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
18 static LDAP_SLIST_HEAD(OidMacroList, slap_oid_macro) om_list
19 = LDAP_SLIST_HEAD_INITIALIZER(om_list);
21 /* Replace an OID Macro invocation with its full numeric OID.
22 * If the macro is used with "macroname:suffix" append ".suffix"
30 /* OID macros must start alpha */
31 if ( OID_LEADCHAR( *oid ) ) {
35 LDAP_SLIST_FOREACH( om, &om_list, som_next ) {
36 char **names = om->som_names;
42 for( ; *names != NULL ; names++ ) {
43 int pos = dscompare(*names, oid, ':');
46 int suflen = strlen(oid + pos);
47 char *tmp = SLAP_MALLOC( om->som_oid.bv_len
51 LDAP_LOG( OPERATION, ERR,
52 "oidm_find: SLAP_MALLOC failed", 0, 0, 0 );
54 Debug( LDAP_DEBUG_ANY,
55 "oidm_find: SLAP_MALLOC failed", 0, 0, 0 );
59 strcpy(tmp, om->som_oid.bv_val);
61 suflen = om->som_oid.bv_len;
63 strcpy(tmp+suflen, oid+pos+1);
77 /* FIXME: this causes a malloc debug error */
80 while( !LDAP_SLIST_EMPTY( &om_list )) {
81 om = LDAP_SLIST_FIRST( &om_list );
83 ldap_charray_free(om->som_names);
84 free(om->som_oid.bv_val);
87 LDAP_SLIST_REMOVE_HEAD( &om_list, som_next );
103 fprintf( stderr, "%s: line %d: too many arguments\n",
105 usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
109 oid = oidm_find( argv[1] );
113 "ObjectIdentifier \"%s\" previously defined \"%s\"",
114 fname, lineno, argv[1], oid );
118 om = (OidMacro *) SLAP_MALLOC( sizeof(OidMacro) );
121 LDAP_LOG( OPERATION, ERR, "parse_oidm: SLAP_MALLOC failed", 0, 0, 0 );
123 Debug( LDAP_DEBUG_ANY, "parse_oidm: SLAP_MALLOC failed", 0, 0, 0 );
128 LDAP_SLIST_NEXT( om, som_next ) = NULL;
129 om->som_names = NULL;
130 ldap_charray_add( &om->som_names, argv[1] );
131 om->som_oid.bv_val = oidm_find( argv[2] );
133 if (!om->som_oid.bv_val) {
134 fprintf( stderr, "%s: line %d: OID %s not recognized\n",
135 fname, lineno, argv[2] );
139 if (om->som_oid.bv_val == argv[2]) {
140 om->som_oid.bv_val = ch_strdup( argv[2] );
143 om->som_oid.bv_len = strlen( om->som_oid.bv_val );
145 LDAP_SLIST_INSERT_HEAD( &om_list, om, som_next );