-void
-parse_oc_old(
- Backend *be,
- char *fname,
- int lineno,
- int argc,
- char **argv
-)
-{
- int i;
- char last;
- LDAP_OBJECT_CLASS *oc;
- int code;
- const char *err;
- char **namep;
-
- oc = (LDAP_OBJECT_CLASS *) ch_calloc( 1, sizeof(LDAP_OBJECT_CLASS) );
- oc->oc_names = ch_calloc( 2, sizeof(char *) );
- oc->oc_names[0] = ch_strdup( argv[1] );
- oc->oc_names[1] = NULL;
- if ( strcasecmp( oc->oc_names[0], "top" ) ) {
- oc->oc_kind = LDAP_SCHEMA_STRUCTURAL;
- }
- for ( i = 2; i < argc; i++ ) {
- /* required attributes */
- if ( strcasecmp( argv[i], "requires" ) == 0 ) {
- do {
- i++;
- if ( i < argc ) {
- char **s = str2charray( argv[i], "," );
- last = argv[i][strlen( argv[i] ) - 1];
- charray_merge( &oc->oc_at_oids_must, s );
- charray_free( s );
- }
- } while ( i < argc && last == ',' );
-
- /* optional attributes */
- } else if ( strcasecmp( argv[i], "allows" ) == 0 ) {
- do {
- i++;
- if ( i < argc ) {
- char **s = str2charray( argv[i], "," );
- last = argv[i][strlen( argv[i] ) - 1];
-
- charray_merge( &oc->oc_at_oids_may, s );
- charray_free( s );
- }
- } while ( i < argc && last == ',' );
-
- } else {
- fprintf( stderr,
- "%s: line %d: expecting \"requires\" or \"allows\" got \"%s\"\n",
- fname, lineno, argv[i] );
- oc_usage_old();
- }
- }
-
- /*
- * There was no requirement in the old schema that all attributes
- * types were defined before use and they would just default to
- * SYNTAX_CIS. To support this, we need to make attribute types
- * out of thin air.
- */
- if ( oc->oc_at_oids_must ) {
- namep = oc->oc_at_oids_must;
- while ( *namep ) {
- code = at_fake_if_needed( *namep );
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s %s\n",
- fname, lineno, scherr2str(code), *namep);
- exit( EXIT_FAILURE );
- }
- namep++;
- }
- }
- if ( oc->oc_at_oids_may ) {
- namep = oc->oc_at_oids_may;
- while ( *namep ) {
- code = at_fake_if_needed( *namep );
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s %s\n",
- fname, lineno, scherr2str(code), *namep);
- exit( EXIT_FAILURE );
- }
- namep++;
- }
- }
-
- code = oc_add(oc,&err);
- if ( code ) {
- fprintf( stderr, "%s: line %d: %s %s\n",
- fname, lineno, scherr2str(code), err);
- exit( EXIT_FAILURE );
- }
- ldap_memfree(oc);
-}