/* schemaparse.c - routines to parse config file objectclass definitions */
+/* $OpenLDAP$ */
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
#include <stdio.h>
+#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "ldap_schema.h"
-static Avlnode *object_classes = NULL;
-
int global_schemacheck = 1; /* schemacheck on is default */
-static void oc_usage_old(void);
-static void oc_usage(void);
+static void oc_usage_old(void) LDAP_GCCATTR((noreturn));
+static void oc_usage(void) LDAP_GCCATTR((noreturn));
+static void at_usage(void) LDAP_GCCATTR((noreturn));
-static char *err2text[] = {
+static char *const err2text[] = {
"",
"Out of memory",
"Objectclass not found",
void
parse_oc_old(
Backend *be,
- char *fname,
+ const char *fname,
int lineno,
int argc,
char **argv
* matched, otherwise return length matched.
*/
int
-dscompare(char *s1, char *s2, char delim)
+dscompare(const char *s1, const char *s2, char delim)
{
- char *orig = s1;
+ const char *orig = s1;
while (*s1++ == *s2++)
if (!s1[-1]) break;
--s1;
void
parse_oidm(
- char *fname,
+ const char *fname,
int lineno,
int argc,
char **argv
void
parse_oc(
- char *fname,
+ const char *fname,
int lineno,
char *line,
char **argv
const char *err;
char *oid = NULL;
- /* Kludge for OIDmacros. If the numericOid field starts nonnumeric
- * look for and expand a macro. The macro's place in the input line
- * will be replaced with a field of '0's to keep ldap_str2objectclass
- * happy. The actual oid will be swapped into place afterward.
- */
- if ( !isdigit( *argv[2] ))
- {
- oid = find_oidm(argv[2]);
- if (!oid)
- {
- fprintf(stderr, "%s: line %d: OID %s not recognized\n",
- fname, lineno, argv[2]);
- exit( EXIT_FAILURE );
- }
- if (oid != argv[2])
- memset(strstr(line, argv[2]), '0', strlen(argv[2]));
- else
- oid = NULL;
- }
oc = ldap_str2objectclass(line,&code,&err);
if ( !oc ) {
fprintf( stderr, "%s: line %d: %s before %s\n",
fname, lineno, ldap_scherr2str(code), err );
oc_usage();
}
- if (oid)
- {
- ldap_memfree(oc->oc_oid);
- oc->oc_oid = oid;
+ if ( oc->oc_oid ) {
+ if ( !isdigit( oc->oc_oid[0] )) {
+ /* Expand OID macros */
+ oid = find_oidm( oc->oc_oid );
+ if ( !oid ) {
+ fprintf(stderr,
+ "%s: line %d: OID %s not recognized\n",
+ fname, lineno, oc->oc_oid);
+ exit( EXIT_FAILURE );
+ }
+ if ( oid != oc->oc_oid ) {
+ ldap_memfree( oc->oc_oid );
+ oc->oc_oid = oid;
+ }
+ }
}
+ /* oc->oc_oid == NULL will be an error someday */
code = oc_add(oc,&err);
if ( code ) {
fprintf( stderr, "%s: line %d: %s %s\n",
void
parse_at(
- char *fname,
+ const char *fname,
int lineno,
char *line,
char **argv
char *oid = NULL;
char *soid = NULL;
- /* Kludge for OIDmacros. If the numericOid field starts nonnumeric
- * look for and expand a macro. The macro's place in the input line
- * will be replaced with a field of '0's to keep ldap_str2attr
- * happy. The actual oid will be swapped into place afterward.
- */
- if ( !isdigit( *argv[2] ))
- {
- oid = find_oidm(argv[2]);
- if (!oid)
- {
- fprintf(stderr, "%s: line %d: OID %s not recognized\n",
- fname, lineno, argv[2]);
- exit( EXIT_FAILURE );
- }
- if (oid != argv[2])
- memset(strstr(line, argv[2]), '0', strlen(argv[2]));
- else
- oid = NULL;
- }
+ /* Kludge for OIDmacros for syntaxes. If the syntax field starts
+ * nonnumeric, look for and expand a macro. The macro's place in
+ * the input line will be replaced with a field of '0's to keep
+ * ldap_str2attributetype happy. The actual oid will be swapped
+ * into place afterwards.
+ */
for (; argv[3]; argv++)
{
if (!strcasecmp(argv[3], "syntax") &&
fname, lineno, ldap_scherr2str(code), err );
at_usage();
}
- if (oid)
- {
- ldap_memfree(at->at_oid);
- at->at_oid = oid;
+ if ( at->at_oid ) {
+ if ( !isdigit( at->at_oid[0] )) {
+ /* Expand OID macros */
+ oid = find_oidm( at->at_oid );
+ if ( !oid ) {
+ fprintf(stderr,
+ "%s: line %d: OID %s not recognized\n",
+ fname, lineno, at->at_oid);
+ exit( EXIT_FAILURE );
+ }
+ if ( oid != at->at_oid ) {
+ ldap_memfree( at->at_oid );
+ at->at_oid = oid;
+ }
+ }
}
+ /* at->at_oid == NULL will be an error someday */
if (soid)
{
ldap_memfree(at->at_syntax_oid);