#include "../back-monitor/back-monitor.h"
+#include "config.h"
+
static ObjectClass *oc_olmBDBDatabase;
static AttributeDescription *ad_olmBDBEntryCache,
bdb_monitor_initialize( void )
{
int i, code;
+ ConfigArgs c;
+ char *argv[ 3 ];
static int bdb_monitor_initialized = 0;
/* register schema here */
+ argv[ 0 ] = "back-bdb/back-hdb monitor";
+ c.argv = argv;
+ c.argc = 3;
+ c.fname = argv[0];
+
for ( i = 0; s_oid[ i ].name; i++ ) {
- char *argv[ 3 ];
-
- argv[ 0 ] = "back-bdb/back-hdb monitor";
+ c.lineno = i;
argv[ 1 ] = s_oid[ i ].name;
argv[ 2 ] = s_oid[ i ].oid;
- if ( parse_oidm( argv[ 0 ], i, 3, argv, 0, NULL ) != 0 ) {
+ if ( parse_oidm( &c, 0, NULL ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"bdb_monitor_initialize: unable to add "
"objectIdentifier \"%s=%s\"\n",
#include "lutil.h"
#include "back-ldap.h"
+#include "config.h"
+
static ObjectClass *oc_olmLDAPDatabase;
static AttributeDescription *ad_olmDbURIList;
{
int i, code;
const char *err;
+ ConfigArgs c;
+ char *argv[ 3 ];
static int ldap_back_monitor_initialized = 0;
return -1;
}
+ argv[ 0 ] = "back-ldap monitor";
+ c.argv = argv;
+ c.argc = 3;
+ c.fname = argv[0];
for ( i = 0; s_oid[ i ].name; i++ ) {
- char *argv[ 3 ];
- argv[ 0 ] = "back-ldap monitor";
argv[ 1 ] = s_oid[ i ].name;
argv[ 2 ] = s_oid[ i ].oid;
- if ( parse_oidm( argv[ 0 ], i, 3, argv, 0, NULL ) != 0 ) {
+ if ( parse_oidm( &c, 0, NULL ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"ldap_back_monitor_initialize: unable to add "
"objectIdentifier \"%s=%s\"\n",
#include "lber_pvt.h"
#include "back-monitor.h"
+#include "config.h"
+
#undef INTEGRATE_CORE_SCHEMA
/*
int i, rc;
const char *text;
monitor_info_t *mi = &monitor_info;
+ ConfigArgs c;
+ char *argv[ 3 ];
+
+ argv[ 0 ] = "monitor";
+ c.argv = argv;
+ c.argc = 3;
+ c.fname = argv[0];
for ( i = 0; s_oid[ i ].name; i++ ) {
- char *argv[ 3 ];
-
- argv[ 0 ] = "monitor";
argv[ 1 ] = s_oid[ i ].name;
argv[ 2 ] = s_oid[ i ].oid;
- if ( parse_oidm( argv[ 0 ], i, 3, argv, 0, NULL ) != 0 ) {
+ if ( parse_oidm( &c, 0, NULL ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"monitor_back_initialize: unable to add "
"objectIdentifier \"%s=%s\"\n",
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )",
NULL, NULL },
- { "objectidentifier", NULL, 0, 0, 0, ARG_MAGIC|CFG_OID,
+ { "objectidentifier", "name> <oid", 3, 3, 0, ARG_MAGIC|CFG_OID,
&config_generic, "( OLcfgGlAt:33 NAME 'olcObjectIdentifier' "
"EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL },
static int
config_generic(ConfigArgs *c) {
- char *p;
int i;
if ( c->op == SLAP_CONFIG_EMIT ) {
return rc;
}
- p = strchr(c->line,'(' /*')'*/);
-
switch(c->type) {
case CFG_BACKEND:
if(!(c->bi = backend_info(c->argv[1]))) {
if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
cfn = c->private;
- if(parse_oidm(c->fname, c->lineno, c->argc, c->argv, 1, &om))
+ if(parse_oidm(c, 1, &om))
return(1);
if (!cfn->c_om_head) cfn->c_om_head = om;
cfn->c_om_tail = om;
}
/* else prev is NULL, append to end of global list */
}
- if(parse_oc(c->fname, c->lineno, p, c->argv, &oc, prev)) return(1);
+ if(parse_oc(c, &oc, prev)) return(1);
if (!cfn->c_oc_head) cfn->c_oc_head = oc;
if (cfn->c_oc_tail == prev) cfn->c_oc_tail = oc;
}
}
/* else prev is NULL, append to end of global list */
}
- if(parse_at(c->fname, c->lineno, p, c->argv, &at, prev)) return(1);
+ if(parse_at(c, &at, prev)) return(1);
if (!cfn->c_at_head) cfn->c_at_head = at;
if (cfn->c_at_tail == prev) cfn->c_at_tail = at;
}
if ( c->op == LDAP_MOD_ADD && c->private && cfn != c->private )
cfn = c->private;
- if(parse_cr(c->fname, c->lineno, p, c->argv, &cr)) return(1);
+ if(parse_cr(c, &cr)) return(1);
if (!cfn->c_cr_head) cfn->c_cr_head = cr;
cfn->c_cr_tail = cr;
}
config_back_initialize( BackendInfo *bi )
{
ConfigTable *ct = config_back_cf_table;
+ ConfigArgs ca;
char *argv[4];
int i;
AttributeDescription *ad = NULL;
bi->bi_tool_entry_get = config_tool_entry_get;
bi->bi_tool_entry_put = config_tool_entry_put;
+ ca.argv = argv;
+ argv[ 0 ] = "slapd";
+ ca.argv = argv;
+ ca.argc = 3;
+ ca.fname = argv[0];
+
argv[3] = NULL;
for (i=0; OidMacros[i].name; i++ ) {
argv[1] = OidMacros[i].name;
argv[2] = OidMacros[i].oid;
- parse_oidm( "slapd", i, 3, argv, 0, NULL );
+ parse_oidm( &ca, 0, NULL );
}
bi->bi_cf_ocs = cf_ocs;
#include "slap.h"
#include "lutil.h"
+#include "config.h"
static LDAP_STAILQ_HEAD(OidMacroList, slap_oid_macro) om_list
= LDAP_STAILQ_HEAD_INITIALIZER(om_list);
int
parse_oidm(
- const char *fname,
- int lineno,
- int argc,
- char **argv,
+ struct config_args_s *c,
int user,
OidMacro **rom)
{
OidMacro *om = NULL;
struct berval bv;
- if (argc != 3) {
- fprintf( stderr, "%s: line %d: too many arguments\n",
- fname, lineno );
-usage: fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
- if (om) SLAP_FREE( om );
- return 1;
- }
-
- oid = oidm_find( argv[1] );
+ oid = oidm_find( c->argv[1] );
if( oid != NULL ) {
- fprintf( stderr,
- "%s: line %d: "
- "ObjectIdentifier \"%s\" previously defined \"%s\"",
- fname, lineno, argv[1], oid );
+ snprintf( c->msg, sizeof( c->msg ),
+ "%s: \"%s\" previously defined \"%s\"",
+ c->argv[0], c->argv[1], oid );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
SLAP_FREE( oid );
return 1;
}
om = (OidMacro *) SLAP_CALLOC( sizeof(OidMacro), 1 );
if( om == NULL ) {
- Debug( LDAP_DEBUG_ANY, "parse_oidm: SLAP_CALLOC failed", 0, 0, 0 );
+ snprintf( c->msg, sizeof( c->msg ),
+ "%s: SLAP_CALLOC failed", c->argv[0] );
+ Debug( LDAP_DEBUG_ANY,
+ "%s %s\n", c->log, c->msg, 0 );
return 1;
}
om->som_names = NULL;
om->som_subs = NULL;
- ber_str2bv( argv[1], 0, 1, &bv );
+ ber_str2bv( c->argv[1], 0, 1, &bv );
ber_bvarray_add( &om->som_names, &bv );
- ber_str2bv( argv[2], 0, 1, &bv );
+ ber_str2bv( c->argv[2], 0, 1, &bv );
ber_bvarray_add( &om->som_subs, &bv );
- om->som_oid.bv_val = oidm_find( argv[2] );
+ om->som_oid.bv_val = oidm_find( c->argv[2] );
if (!om->som_oid.bv_val) {
- fprintf( stderr, "%s: line %d: OID %s not recognized\n",
- fname, lineno, argv[2] );
- goto usage;
+ snprintf( c->msg, sizeof( c->msg ),
+ "%s: OID %s not recognized",
+ c->argv[0], c->argv[2] );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
+ SLAP_FREE( om );
+ return 1;
}
- if (om->som_oid.bv_val == argv[2]) {
- om->som_oid.bv_val = ch_strdup( argv[2] );
+ if (om->som_oid.bv_val == c->argv[2]) {
+ om->som_oid.bv_val = ch_strdup( c->argv[2] );
}
om->som_oid.bv_len = strlen( om->som_oid.bv_val );
LDAP_BEGIN_DECL
+struct config_args_s; /* config.h */
+
/*
* aci.c
*/
LDAP_SLAPD_F (void) oidm_unparse LDAP_P((
BerVarray *bva, OidMacro *start, OidMacro *end, int system ));
LDAP_SLAPD_F (int) parse_oidm LDAP_P((
- const char *fname, int lineno, int argc, char **argv, int user,
- OidMacro **om ));
+ struct config_args_s *ca, int user, OidMacro **om ));
/*
* operation.c
LDAP_SLAPD_F( int ) slap_valid_descr( const char * );
LDAP_SLAPD_F (int) parse_cr LDAP_P((
- const char *fname, int lineno, char *line, char **argv,
- ContentRule **scr ));
+ struct config_args_s *ca, ContentRule **scr ));
LDAP_SLAPD_F (int) parse_oc LDAP_P((
- const char *fname, int lineno, char *line, char **argv,
- ObjectClass **soc, ObjectClass *prev ));
+ struct config_args_s *ca, ObjectClass **soc, ObjectClass *prev ));
LDAP_SLAPD_F (int) parse_at LDAP_P((
- const char *fname, int lineno, char *line, char **argv,
- AttributeType **sat, AttributeType *prev ));
+ struct config_args_s *ca, AttributeType **sat, AttributeType *prev ));
LDAP_SLAPD_F (char *) scherr2str LDAP_P((int code)) LDAP_GCCATTR((const));
LDAP_SLAPD_F (int) dscompare LDAP_P(( const char *s1, const char *s2del,
char delim ));
#include "slap.h"
#include "ldap_schema.h"
+#include "config.h"
static void oc_usage(void);
static void at_usage(void);
int
parse_cr(
- const char *fname,
- int lineno,
- char *line,
- char **argv,
+ 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 ) {
- fprintf( stderr, "%s: line %d: %s before %s\n",
- fname, lineno, ldap_scherr2str(code), err );
+ snprintf( c->msg, sizeof( c->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->msg, 0 );
cr_usage();
return 1;
}
if ( cr->cr_oid == NULL ) {
- fprintf( stderr,
- "%s: line %d: Content rule has no OID\n",
- fname, lineno );
+ snprintf( c->msg, sizeof( c->msg ), "%s: OID is missing",
+ c->argv[0] );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
cr_usage();
code = 1;
goto done;
code = cr_add( cr, 1, scr, &err );
if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str( code ), err );
+ snprintf( c->msg, sizeof( c->msg ), "%s: %s: \"%s\"",
+ c->argv[0], scherr2str(code), err);
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
code = 1;
goto done;
}
int
parse_oc(
- const char *fname,
- int lineno,
- char *line,
- char **argv,
+ struct config_args_s *c,
ObjectClass **soc,
ObjectClass *prev )
{
LDAPObjectClass *oc;
int code;
const char *err;
+ char *line = strchr( c->line, '(' );
oc = ldap_str2objectclass(line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
if ( !oc ) {
- fprintf( stderr, "%s: line %d: %s before %s\n",
- fname, lineno, ldap_scherr2str( code ), err );
+ snprintf( c->msg, sizeof( c->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->msg, 0 );
oc_usage();
return 1;
}
if ( oc->oc_oid == NULL ) {
- fprintf( stderr,
- "%s: line %d: objectclass has no OID\n",
- fname, lineno );
+ snprintf( c->msg, sizeof( c->msg ), "%s: OID is missing",
+ c->argv[0] );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
oc_usage();
code = 1;
goto done;
code = oc_add( oc, 1, soc, prev, &err );
if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str( code ), err );
+ snprintf( c->msg, sizeof( c->msg ), "%s: %s: \"%s\"",
+ c->argv[0], scherr2str(code), err);
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
code = 1;
goto done;
}
int
parse_at(
- const char *fname,
- int lineno,
- char *line,
- char **argv,
+ struct config_args_s *c,
AttributeType **sat,
AttributeType *prev )
{
LDAPAttributeType *at;
int code;
const char *err;
+ char *line = strchr( c->line, '(' );
at = ldap_str2attributetype( line, &code, &err, LDAP_SCHEMA_ALLOW_ALL );
if ( !at ) {
- fprintf( stderr, "%s: line %d: %s before %s\n",
- fname, lineno, ldap_scherr2str(code), err );
+ snprintf( c->msg, sizeof( c->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->msg, 0 );
at_usage();
return 1;
}
if ( at->at_oid == NULL ) {
- fprintf( stderr,
- "%s: line %d: attributeType has no OID\n",
- fname, lineno );
+ snprintf( c->msg, sizeof( c->msg ), "%s: OID is missing",
+ c->argv[0] );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
at_usage();
code = 1;
goto done;
/* operational attributes should be defined internally */
if ( at->at_usage ) {
- fprintf( stderr, "%s: line %d: attribute type \"%s\" is operational\n",
- fname, lineno, at->at_oid );
+ snprintf( c->msg, sizeof( c->msg ), "%s: \"%s\" is operational",
+ c->argv[0], at->at_oid );
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
code = 1;
goto done;
}
code = at_add( at, 1, sat, prev, &err);
if ( code ) {
- fprintf( stderr, "%s: line %d: %s: \"%s\"\n",
- fname, lineno, scherr2str(code), err);
+ snprintf( c->msg, sizeof( c->msg ), "%s: %s: \"%s\"",
+ c->argv[0], scherr2str(code), err);
+ Debug( LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE,
+ "%s %s\n", c->log, c->msg, 0 );
code = 1;
goto done;
}