Skip to content
Snippets Groups Projects
Commit 388836d0 authored by Howard Chu's avatar Howard Chu
Browse files

ITS#5122 add ARG_UINT config type for unsigned ints

parent d8dd9896
No related branches found
No related tags found
No related merge requests found
...@@ -150,10 +150,10 @@ typedef struct bdb_cache { ...@@ -150,10 +150,10 @@ typedef struct bdb_cache {
EntryInfo *c_lruhead; /* lru - add accessed entries here */ EntryInfo *c_lruhead; /* lru - add accessed entries here */
EntryInfo *c_lrutail; /* lru - rem lru entries from here */ EntryInfo *c_lrutail; /* lru - rem lru entries from here */
EntryInfo c_dntree; EntryInfo c_dntree;
int c_maxsize; unsigned c_maxsize;
int c_cursize; int c_cursize;
int c_minfree; unsigned c_minfree;
int c_eimax; unsigned c_eimax;
int c_eiused; /* EntryInfo's in use */ int c_eiused; /* EntryInfo's in use */
int c_leaves; /* EntryInfo leaf nodes */ int c_leaves; /* EntryInfo leaf nodes */
int c_purging; int c_purging;
...@@ -220,7 +220,7 @@ struct bdb_info { ...@@ -220,7 +220,7 @@ struct bdb_info {
ID bi_lastid; ID bi_lastid;
ldap_pvt_thread_mutex_t bi_lastid_mutex; ldap_pvt_thread_mutex_t bi_lastid_mutex;
int bi_idl_cache_max_size; unsigned bi_idl_cache_max_size;
int bi_idl_cache_size; int bi_idl_cache_size;
Avlnode *bi_idl_tree; Avlnode *bi_idl_tree;
bdb_idl_cache_entry_t *bi_idl_lru_head; bdb_idl_cache_entry_t *bi_idl_lru_head;
......
...@@ -55,12 +55,12 @@ static ConfigTable bdbcfg[] = { ...@@ -55,12 +55,12 @@ static ConfigTable bdbcfg[] = {
"DESC 'Directory for database content' " "DESC 'Directory for database content' "
"EQUALITY caseIgnoreMatch " "EQUALITY caseIgnoreMatch "
"SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
{ "cachefree", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, { "cachefree", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET,
(void *)offsetof(struct bdb_info, bi_cache.c_minfree), (void *)offsetof(struct bdb_info, bi_cache.c_minfree),
"( OLcfgDbAt:1.11 NAME 'olcDbCacheFree' " "( OLcfgDbAt:1.11 NAME 'olcDbCacheFree' "
"DESC 'Number of extra entries to free when max is reached' " "DESC 'Number of extra entries to free when max is reached' "
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
{ "cachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, { "cachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET,
(void *)offsetof(struct bdb_info, bi_cache.c_maxsize), (void *)offsetof(struct bdb_info, bi_cache.c_maxsize),
"( OLcfgDbAt:1.1 NAME 'olcDbCacheSize' " "( OLcfgDbAt:1.1 NAME 'olcDbCacheSize' "
"DESC 'Entry cache size in entries' " "DESC 'Entry cache size in entries' "
...@@ -86,13 +86,13 @@ static ConfigTable bdbcfg[] = { ...@@ -86,13 +86,13 @@ static ConfigTable bdbcfg[] = {
"( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' " "( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' "
"DESC 'Allow reads of uncommitted data' " "DESC 'Allow reads of uncommitted data' "
"SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
{ "dncachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, { "dncachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET,
(void *)offsetof(struct bdb_info, bi_cache.c_eimax), (void *)offsetof(struct bdb_info, bi_cache.c_eimax),
"( OLcfgDbAt:1.12 NAME 'olcDbDNcacheSize' " "( OLcfgDbAt:1.12 NAME 'olcDbDNcacheSize' "
"DESC 'DN cache size' " "DESC 'DN cache size' "
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
{ "idlcachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, { "idlcachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET,
(void *)offsetof(struct bdb_info,bi_idl_cache_max_size), (void *)offsetof(struct bdb_info, bi_idl_cache_max_size),
"( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' " "( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' "
"DESC 'IDL cache size in IDLs' " "DESC 'IDL cache size in IDLs' "
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
...@@ -119,7 +119,7 @@ static ConfigTable bdbcfg[] = { ...@@ -119,7 +119,7 @@ static ConfigTable bdbcfg[] = {
bdb_cf_gen, "( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' " bdb_cf_gen, "( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' "
"DESC 'Depth of search stack in IDLs' " "DESC 'Depth of search stack in IDLs' "
"SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
{ "shm_key", "key", 2, 2, 0, ARG_INT|ARG_OFFSET, { "shm_key", "key", 2, 2, 0, ARG_LONG|ARG_OFFSET,
(void *)offsetof(struct bdb_info, bi_shm_key), (void *)offsetof(struct bdb_info, bi_shm_key),
"( OLcfgDbAt:1.10 NAME 'olcDbShmKey' " "( OLcfgDbAt:1.10 NAME 'olcDbShmKey' "
"DESC 'Key for shared memory region' " "DESC 'Key for shared memory region' "
......
...@@ -124,6 +124,7 @@ ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) { ...@@ -124,6 +124,7 @@ ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) {
int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
int rc, arg_user, arg_type, arg_syn, iarg; int rc, arg_user, arg_type, arg_syn, iarg;
unsigned uiarg;
long larg; long larg;
ber_len_t barg; ber_len_t barg;
...@@ -227,6 +228,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { ...@@ -227,6 +228,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
return(ARG_BAD_CONF); return(ARG_BAD_CONF);
} }
break; break;
case ARG_UINT:
if ( lutil_atoux( &uiarg, c->argv[1], 0 ) != 0 ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ),
"<%s> unable to parse \"%s\" as unsigned int",
c->argv[0], c->argv[1] );
Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n",
c->log, c->cr_msg, 0);
return(ARG_BAD_CONF);
}
break;
case ARG_LONG: case ARG_LONG:
if ( lutil_atolx( &larg, c->argv[1], 0 ) != 0 ) { if ( lutil_atolx( &larg, c->argv[1], 0 ) != 0 ) {
snprintf( c->cr_msg, sizeof( c->cr_msg ), snprintf( c->cr_msg, sizeof( c->cr_msg ),
...@@ -283,6 +294,7 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { ...@@ -283,6 +294,7 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) {
switch(arg_type) { switch(arg_type) {
case ARG_ON_OFF: case ARG_ON_OFF:
case ARG_INT: c->value_int = iarg; break; case ARG_INT: c->value_int = iarg; break;
case ARG_UINT: c->value_uint = uiarg; break;
case ARG_LONG: c->value_long = larg; break; case ARG_LONG: c->value_long = larg; break;
case ARG_BER_LEN_T: c->value_ber_t = barg; break; case ARG_BER_LEN_T: c->value_ber_t = barg; break;
} }
...@@ -333,6 +345,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) { ...@@ -333,6 +345,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) {
switch(arg_type & ARGS_TYPES) { switch(arg_type & ARGS_TYPES) {
case ARG_ON_OFF: case ARG_ON_OFF:
case ARG_INT: *(int*)ptr = c->value_int; break; case ARG_INT: *(int*)ptr = c->value_int; break;
case ARG_UINT: *(unsigned*)ptr = c->value_uint; break;
case ARG_LONG: *(long*)ptr = c->value_long; break; case ARG_LONG: *(long*)ptr = c->value_long; break;
case ARG_BER_LEN_T: *(ber_len_t*)ptr = c->value_ber_t; break; case ARG_BER_LEN_T: *(ber_len_t*)ptr = c->value_ber_t; break;
case ARG_STRING: { case ARG_STRING: {
...@@ -419,6 +432,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c) ...@@ -419,6 +432,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
switch(cf->arg_type & ARGS_TYPES) { switch(cf->arg_type & ARGS_TYPES) {
case ARG_ON_OFF: case ARG_ON_OFF:
case ARG_INT: c->value_int = *(int *)ptr; break; case ARG_INT: c->value_int = *(int *)ptr; break;
case ARG_UINT: c->value_uint = *(unsigned *)ptr; break;
case ARG_LONG: c->value_long = *(long *)ptr; break; case ARG_LONG: c->value_long = *(long *)ptr; break;
case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break; case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break;
case ARG_STRING: case ARG_STRING:
...@@ -434,6 +448,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c) ...@@ -434,6 +448,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
bv.bv_val = c->log; bv.bv_val = c->log;
switch(cf->arg_type & ARGS_TYPES) { switch(cf->arg_type & ARGS_TYPES) {
case ARG_INT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%d", c->value_int); break; case ARG_INT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%d", c->value_int); break;
case ARG_UINT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%u", c->value_uint); break;
case ARG_LONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_long); break; case ARG_LONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_long); break;
case ARG_BER_LEN_T: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_ber_t); break; case ARG_BER_LEN_T: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_ber_t); break;
case ARG_ON_OFF: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%s", case ARG_ON_OFF: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%s",
......
...@@ -55,6 +55,7 @@ typedef enum { ...@@ -55,6 +55,7 @@ typedef enum {
#define ARG_STRING 0x00005000 #define ARG_STRING 0x00005000
#define ARG_BERVAL 0x00006000 #define ARG_BERVAL 0x00006000
#define ARG_DN 0x00007000 #define ARG_DN 0x00007000
#define ARG_UINT 0x00008000
#define ARGS_SYNTAX 0xffff0000 #define ARGS_SYNTAX 0xffff0000
#define ARG_IGNORED 0x00080000 #define ARG_IGNORED 0x00080000
...@@ -128,6 +129,7 @@ typedef struct config_args_s { ...@@ -128,6 +129,7 @@ typedef struct config_args_s {
/* parsed first val for simple cases */ /* parsed first val for simple cases */
union { union {
int v_int; int v_int;
unsigned v_uint;
long v_long; long v_long;
ber_len_t v_ber_t; ber_len_t v_ber_t;
char *v_string; char *v_string;
...@@ -159,6 +161,7 @@ typedef struct config_args_s { ...@@ -159,6 +161,7 @@ typedef struct config_args_s {
#define CONFIG_ONLINE_ADD(ca) (!((ca)->lineno)) #define CONFIG_ONLINE_ADD(ca) (!((ca)->lineno))
#define value_int values.v_int #define value_int values.v_int
#define value_uint values.v_uint
#define value_long values.v_long #define value_long values.v_long
#define value_ber_t values.v_ber_t #define value_ber_t values.v_ber_t
#define value_string values.v_string #define value_string values.v_string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment