1998-08-09 08:43:13 +08:00
|
|
|
/* schemaparse.c - routines to parse config file objectclass definitions */
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slap.h"
|
|
|
|
|
|
|
|
struct objclass *global_oc;
|
|
|
|
int global_schemacheck;
|
|
|
|
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
static void oc_usage(void);
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
parse_oc(
|
|
|
|
Backend *be,
|
|
|
|
char *fname,
|
|
|
|
int lineno,
|
|
|
|
int argc,
|
|
|
|
char **argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char last;
|
|
|
|
struct objclass *oc;
|
|
|
|
struct objclass **ocp;
|
|
|
|
|
|
|
|
oc = (struct objclass *) ch_calloc( 1, sizeof(struct objclass) );
|
1998-11-28 04:21:54 +08:00
|
|
|
oc->oc_name = ch_strdup( argv[1] );
|
1998-08-09 08:43:13 +08:00
|
|
|
for ( i = 2; i < argc; i++ ) {
|
|
|
|
/* required attributes */
|
|
|
|
if ( strcasecmp( argv[i], "requires" ) == 0 ) {
|
|
|
|
do {
|
|
|
|
i++;
|
|
|
|
if ( i < argc ) {
|
1998-11-23 12:35:26 +08:00
|
|
|
char **s = str2charray( argv[i], "," );
|
1998-08-09 08:43:13 +08:00
|
|
|
last = argv[i][strlen( argv[i] ) - 1];
|
1998-11-23 12:35:26 +08:00
|
|
|
charray_merge( &oc->oc_required, s );
|
|
|
|
charray_free( s );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
} while ( i < argc && last == ',' );
|
|
|
|
|
|
|
|
/* optional attributes */
|
|
|
|
} else if ( strcasecmp( argv[i], "allows" ) == 0 ) {
|
|
|
|
do {
|
|
|
|
i++;
|
|
|
|
if ( i < argc ) {
|
1998-11-23 12:35:26 +08:00
|
|
|
char **s = str2charray( argv[i], "," );
|
1998-08-09 08:43:13 +08:00
|
|
|
last = argv[i][strlen( argv[i] ) - 1];
|
1998-11-23 12:35:26 +08:00
|
|
|
|
|
|
|
charray_merge( &oc->oc_allowed, s );
|
|
|
|
charray_free( s );
|
1998-08-09 08:43:13 +08:00
|
|
|
}
|
|
|
|
} while ( i < argc && last == ',' );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fprintf( stderr,
|
|
|
|
"%s: line %d: expecting \"requires\" or \"allows\" got \"%s\"\n",
|
|
|
|
fname, lineno, argv[i] );
|
|
|
|
oc_usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ocp = &global_oc;
|
|
|
|
while ( *ocp != NULL ) {
|
|
|
|
ocp = &(*ocp)->oc_next;
|
|
|
|
}
|
|
|
|
*ocp = oc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
oc_usage( void )
|
1998-08-09 08:43:13 +08:00
|
|
|
{
|
|
|
|
fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
|
|
|
|
fprintf( stderr, " [ requires <attrlist> ]\n" );
|
|
|
|
fprintf( stderr, " [ allows <attrlist> ]\n" );
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
|