mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-24 13:24:56 +08:00
add infrastructure to register verbmasks; allow to register loglevels programmatically; cleanup glue protos
This commit is contained in:
parent
d2b863fa24
commit
4c1339cf22
@ -1854,11 +1854,12 @@ config_requires(ConfigArgs *c) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
static slap_verbmasks *loglevel_ops;
|
||||
|
||||
static int
|
||||
config_loglevel(ConfigArgs *c) {
|
||||
int i;
|
||||
char *next;
|
||||
slap_verbmasks loglevel_ops[] = {
|
||||
loglevel_init( void )
|
||||
{
|
||||
slap_verbmasks lo[] = {
|
||||
{ BER_BVC("Any"), -1 },
|
||||
{ BER_BVC("Trace"), LDAP_DEBUG_TRACE },
|
||||
{ BER_BVC("Packets"), LDAP_DEBUG_PACKETS },
|
||||
@ -1878,6 +1879,39 @@ config_loglevel(ConfigArgs *c) {
|
||||
{ BER_BVNULL, 0 }
|
||||
};
|
||||
|
||||
return slap_verbmasks_init( &loglevel_ops, lo );
|
||||
}
|
||||
|
||||
static slap_mask_t loglevel_ignore[] = { -1, 0 };
|
||||
|
||||
int
|
||||
slap_loglevel_register( slap_mask_t m, struct berval *s )
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ( loglevel_ops == NULL ) {
|
||||
loglevel_init();
|
||||
}
|
||||
|
||||
rc = slap_verbmasks_append( &loglevel_ops, m, s, loglevel_ignore );
|
||||
|
||||
if ( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_loglevel_register(%d, \"%s\") failed\n",
|
||||
m, s->bv_val, 0 );
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
config_loglevel(ConfigArgs *c) {
|
||||
int i;
|
||||
char *next;
|
||||
|
||||
if ( loglevel_ops == NULL ) {
|
||||
loglevel_init();
|
||||
}
|
||||
|
||||
if (c->op == SLAP_CONFIG_EMIT) {
|
||||
return mask_to_verbs( loglevel_ops, ldap_syslog, &c->rvalue_vals );
|
||||
} else if ( c->op == LDAP_MOD_DELETE ) {
|
||||
|
@ -802,6 +802,94 @@ mask_to_verbs(slap_verbmasks *v, slap_mask_t m, BerVarray *bva) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
slap_verbmasks_init( slap_verbmasks **vp, slap_verbmasks *v )
|
||||
{
|
||||
int i;
|
||||
|
||||
assert( *vp == NULL );
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ )
|
||||
;
|
||||
|
||||
*vp = ch_calloc( i + 1, sizeof( slap_verbmasks ) );
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
|
||||
ber_dupbv( &(*vp)[ i ].word, &v[ i ].word );
|
||||
*((slap_mask_t *)&(*vp)[ i ].mask) = v[ i ].mask;
|
||||
}
|
||||
|
||||
BER_BVZERO( &(*vp)[ i ].word );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
slap_verbmasks_destroy( slap_verbmasks *v )
|
||||
{
|
||||
int i;
|
||||
|
||||
assert( v != NULL );
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &v[ i ].word ); i++ ) {
|
||||
ch_free( v[ i ].word.bv_val );
|
||||
}
|
||||
|
||||
ch_free( v );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
slap_verbmasks_append(
|
||||
slap_verbmasks **vp,
|
||||
slap_mask_t m,
|
||||
struct berval *v,
|
||||
slap_mask_t *ignore )
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( !m ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for ( i = 0; !BER_BVISNULL( &(*vp)[ i ].word ); i++ ) {
|
||||
if ( !(*vp)[ i ].mask ) continue;
|
||||
|
||||
if ( ignore != NULL ) {
|
||||
int j;
|
||||
|
||||
for ( j = 0; ignore[ j ] != 0; j++ ) {
|
||||
if ( (*vp)[ i ].mask == ignore[ j ] ) {
|
||||
goto check_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( m & (*vp)[ i ].mask ) == (*vp)[ i ].mask ) {
|
||||
if ( ber_bvstrcasecmp( v, &(*vp)[ i ].word ) == 0 ) {
|
||||
/* already set; ignore */
|
||||
return 0;
|
||||
}
|
||||
/* conflicts */
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( m & (*vp)[ i ].mask ) {
|
||||
/* conflicts */
|
||||
return 1;
|
||||
}
|
||||
check_next:;
|
||||
}
|
||||
|
||||
*vp = ch_realloc( *vp, sizeof( slap_verbmasks ) * ( i + 2 ) );
|
||||
ber_dupbv( &(*vp)[ i ].word, v );
|
||||
*((slap_mask_t *)&(*vp)[ i ].mask) = m;
|
||||
BER_BVZERO( &(*vp)[ i + 1 ].word );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
enum_to_verb(slap_verbmasks *v, slap_mask_t m, struct berval *bv) {
|
||||
int i;
|
||||
|
@ -342,17 +342,9 @@ LDAP_SLAPD_F (int) backend_operational LDAP_P((
|
||||
|
||||
LDAP_SLAPD_V(BackendInfo) slap_binfo[];
|
||||
|
||||
/*
|
||||
* backglue.c
|
||||
*/
|
||||
|
||||
LDAP_SLAPD_F (int) glue_back_initialize( BackendInfo *bi );
|
||||
LDAP_SLAPD_F (int) glue_sub_init( void );
|
||||
|
||||
/*
|
||||
* backover.c
|
||||
*/
|
||||
|
||||
LDAP_SLAPD_F (int) overlay_register LDAP_P(( slap_overinst *on ));
|
||||
LDAP_SLAPD_F (int) overlay_config LDAP_P(( BackendDB *be, const char *ov ));
|
||||
LDAP_SLAPD_F (void) overlay_destroy_one LDAP_P((
|
||||
@ -372,6 +364,11 @@ LDAP_SLAPD_F (int) overlay_op_walk LDAP_P((
|
||||
slap_overinfo *oi,
|
||||
slap_overinst *on ));
|
||||
|
||||
/*
|
||||
* bconfig.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) slap_loglevel_register LDAP_P (( slap_mask_t m, struct berval *s ));
|
||||
|
||||
/*
|
||||
* ch_malloc.c
|
||||
*/
|
||||
@ -537,6 +534,10 @@ LDAP_SLAPD_F (int) mask_to_verbs LDAP_P((
|
||||
slap_verbmasks *v, slap_mask_t m, BerVarray *bva ));
|
||||
LDAP_SLAPD_F (int) enum_to_verb LDAP_P((
|
||||
slap_verbmasks *v, slap_mask_t m, struct berval *bv ));
|
||||
LDAP_SLAPD_F (int) slap_verbmasks_init LDAP_P(( slap_verbmasks **vp, slap_verbmasks *v ));
|
||||
LDAP_SLAPD_F (int) slap_verbmasks_destroy LDAP_P(( slap_verbmasks *v ));
|
||||
LDAP_SLAPD_F (int) slap_verbmasks_append LDAP_P(( slap_verbmasks **vp,
|
||||
slap_mask_t m, struct berval *v, slap_mask_t *ignore ));
|
||||
LDAP_SLAPD_F (int) bindconf_parse LDAP_P((
|
||||
const char *word, slap_bindconf *bc ));
|
||||
LDAP_SLAPD_F (int) bindconf_unparse LDAP_P((
|
||||
|
Loading…
Reference in New Issue
Block a user