Add ATDESC config arg type for AttributeDescriptions

This commit is contained in:
Howard Chu 2009-04-20 00:31:33 +00:00
parent d70afbe6d1
commit 615082b0d0
2 changed files with 25 additions and 0 deletions

View File

@ -216,6 +216,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
ch_free( c->value_ndn.bv_val );
ch_free( c->value_dn.bv_val );
}
} else if(arg_type == ARG_ATDESC) {
const char *text = NULL;
c->value_ad = NULL;
rc = slap_str2ad( c->argv[1], &c->value_ad, &text );
if ( rc != LDAP_SUCCESS ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> invalid AttributeDescription %d (%s)",
c->argv[0], rc, text );
Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n" , c->log, c->cr_msg, 0);
return(ARG_BAD_CONF);
}
} else { /* all numeric */
int j;
iarg = 0; larg = 0; barg = 0;
@ -366,6 +376,9 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
case ARG_BERVAL:
*(struct berval *)ptr = c->value_bv;
break;
case ARG_ATDESC:
*(AttributeDescription **)ptr = c->value_ad;
break;
}
return(0);
}
@ -443,6 +456,8 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
break;
case ARG_BERVAL:
ber_dupbv( &c->value_bv, (struct berval *)ptr ); break;
case ARG_ATDESC:
c->value_ad = *(AttributeDescription **)ptr; break;
}
}
if ( cf->arg_type & ARGS_TYPES) {
@ -469,6 +484,13 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
return 1;
}
break;
case ARG_ATDESC:
if ( c->value_ad ) {
bv = c->value_ad->ad_cname;
} else {
return 1;
}
break;
default:
bv.bv_val = NULL;
break;

View File

@ -58,6 +58,7 @@ typedef enum {
#define ARG_BERVAL 0x00006000
#define ARG_DN 0x00007000
#define ARG_UINT 0x00008000
#define ARG_ATDESC 0x00009000
#define ARGS_SYNTAX 0xffff0000
#define ARG_IGNORED 0x00080000
@ -140,6 +141,7 @@ typedef struct config_args_s {
struct berval vdn_dn;
struct berval vdn_ndn;
} v_dn;
AttributeDescription *v_ad;
} values;
/* return values for emit mode */
BerVarray rvalue_vals;
@ -170,6 +172,7 @@ typedef struct config_args_s {
#define value_bv values.v_bv
#define value_dn values.v_dn.vdn_dn
#define value_ndn values.v_dn.vdn_ndn
#define value_ad values.v_ad
int config_fp_parse_line(ConfigArgs *c);