示例#1
0
static int dsaschema_parse_cr(const char *fname, int lineno, char *line, char **argv)
{
	LDAPContentRule *cr;
	int code;
	const char *err;

	cr = ldap_str2contentrule(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL);
	if (!cr) {
		fprintf(stderr, "%s: line %d: %s before %s\n",
			fname, lineno, ldap_scherr2str(code), err);
		return 1;
	}

	if (cr->cr_oid == NULL) {
		fprintf(stderr,
			"%s: line %d: objectclass has no OID\n",
			fname, lineno);
		return 1;
	}

	code = cr_add(cr, 0, NULL, &err);
	if (code) {
		fprintf(stderr, "%s: line %d: %s: \"%s\"\n",
			fname, lineno, ldap_scherr2str(code), err);
		return 1;
	}

	ldap_memfree(cr);
	return 0;
}
示例#2
0
int
parse_cr(
	struct config_args_s *c,
	ContentRule	**scr )
{
	LDAPContentRule *cr;
	int		code;
	const char	*err;
	char *line = strchr( c->line, '(' );

	cr = ldap_str2contentrule( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
	if ( !cr ) {
		snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: %s before %s",
			c->argv[0], ldap_scherr2str( code ), err );
		Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
			"%s %s\n", c->log, c->cr_msg );
		cr_usage();
		return 1;
	}

	if ( cr->cr_oid == NULL ) {
		snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: OID is missing",
			c->argv[0] );
		Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
			"%s %s\n", c->log, c->cr_msg );
		cr_usage();
		code = 1;
		goto done;
	}

	code = cr_add( cr, 1, scr, &err );
	if ( code ) {
		snprintf( c->cr_msg, sizeof( c->cr_msg ), "%s: %s: \"%s\"",
			c->argv[0], scherr2str(code), err);
		Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
			"%s %s\n", c->log, c->cr_msg );
		code = 1;
		goto done;
	}

done:;
	if ( code ) {
		ldap_contentrule_free( cr );

	} else {
		ldap_memfree( cr );
	}

	return code;
}