1 /* schemaparse.c - routines to parse config file objectclass definitions */
4 * Copyright 1998-2002 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 OidMacro *om_list = NULL;
20 /* Replace an OID Macro invocation with its full numeric OID.
21 * If the macro is used with "macroname:suffix" append ".suffix"
29 /* OID macros must start alpha */
30 if ( OID_LEADCHAR( *oid ) ) {
34 for (om = om_list; om; om=om->som_next) {
35 char **names = om->som_names;
41 for( ; *names != NULL ; names++ ) {
42 int pos = dscompare(*names, oid, ':');
45 int suflen = strlen(oid + pos);
46 char *tmp = ch_malloc( om->som_oid.bv_len
48 strcpy(tmp, om->som_oid.bv_val);
50 suflen = om->som_oid.bv_len;
52 strcpy(tmp+suflen, oid+pos+1);
66 for (om = om_list; om; om = n) {
68 ldap_charray_free(om->som_names);
69 free(om->som_oid.bv_val);
86 fprintf( stderr, "%s: line %d: too many arguments\n",
88 usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
92 oid = oidm_find( argv[1] );
96 "ObjectIdentifier \"%s\" previously defined \"%s\"",
97 fname, lineno, argv[1], oid );
101 om = (OidMacro *) ch_malloc( sizeof(OidMacro) );
103 om->som_names = NULL;
104 ldap_charray_add( &om->som_names, argv[1] );
105 om->som_oid.bv_val = oidm_find( argv[2] );
107 if (!om->som_oid.bv_val) {
108 fprintf( stderr, "%s: line %d: OID %s not recognized\n",
109 fname, lineno, argv[2] );
113 if (om->som_oid.bv_val == argv[2]) {
114 om->som_oid.bv_val = ch_strdup( argv[2] );
117 om->som_oid.bv_len = strlen( om->som_oid.bv_val );
118 om->som_next = om_list;