Commit 0c3b8a35 authored by Ondřej Kuzník's avatar Ondřej Kuzník Committed by Quanah Gibson-Mount
Browse files

ITS#9363 Store defaults in ArgConf

parent 356715fd
......@@ -482,22 +482,30 @@ config_del_vals(ConfigTable *cf, ConfigArgs *c)
if ( cf->arg_type & ARGS_TYPES )
switch ( cf->arg_type & ARGS_TYPES ) {
case ARG_ON_OFF:
case ARG_INT: *(int *)ptr = 0; break;
case ARG_UINT: *(unsigned *)ptr = 0; break;
case ARG_LONG: *(long *)ptr = 0; break;
case ARG_ULONG: *(size_t *)ptr = 0; break;
case ARG_BER_LEN_T: *(ber_len_t *)ptr = 0; break;
case ARG_INT: *(int *)ptr = cf->arg_default.v_int; break;
case ARG_UINT: *(unsigned *)ptr = cf->arg_default.v_uint; break;
case ARG_LONG: *(long *)ptr = cf->arg_default.v_long; break;
case ARG_ULONG: *(size_t *)ptr = cf->arg_default.v_ulong; break;
case ARG_BER_LEN_T: *(ber_len_t *)ptr = cf->arg_default.v_ber_t; break;
case ARG_STRING:
ch_free( *(char**)ptr );
*(char **)ptr = NULL;
if ( cf->arg_default.v_string ) {
*(char **)ptr = ch_strdup( cf->arg_default.v_string );
} else {
*(char **)ptr = NULL;
}
break;
case ARG_BERVAL:
case ARG_BINARY:
ch_free( ((struct berval *)ptr)->bv_val );
BER_BVZERO( (struct berval *)ptr );
if ( !BER_BVISNULL( &cf->arg_default.v_bv ) ) {
ber_dupbv( (struct berval *)ptr, &cf->arg_default.v_bv );
} else {
BER_BVZERO( (struct berval *)ptr );
}
break;
case ARG_ATDESC:
*(AttributeDescription **)ptr = NULL;
*(AttributeDescription **)ptr = cf->arg_default.v_ad;
break;
}
return rc;
......
......@@ -21,6 +21,23 @@
LDAP_BEGIN_DECL
typedef union config_values_u {
/* Drop-in to make existing "notify" initialisers quietly work */
void *dummy;
int v_int;
unsigned v_uint;
long v_long;
size_t v_ulong;
ber_len_t v_ber_t;
char *v_string;
struct berval v_bv;
struct {
struct berval vdn_dn;
struct berval vdn_ndn;
} v_dn;
AttributeDescription *v_ad;
} ConfigValues;
typedef struct ConfigTable {
const char *name;
const char *what;
......@@ -31,7 +48,7 @@ typedef struct ConfigTable {
void *arg_item;
const char *attribute;
AttributeDescription *ad;
void *notify;
ConfigValues arg_default;
} ConfigTable;
/* search entries are returned according to this order */
......@@ -142,20 +159,7 @@ typedef struct config_args_s {
int depth;
int valx; /* multi-valued value index */
/* parsed first val for simple cases */
union {
int v_int;
unsigned v_uint;
long v_long;
size_t v_ulong;
ber_len_t v_ber_t;
char *v_string;
struct berval v_bv;
struct {
struct berval vdn_dn;
struct berval vdn_ndn;
} v_dn;
AttributeDescription *v_ad;
} values;
ConfigValues values;
/* return values for emit mode */
BerVarray rvalue_vals;
BerVarray rvalue_nvals;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment