Feature #1966 » lighttpd-1.4.x-add-T_CONFIG_INT.patch
src/configfile-glue.c (working copy) | ||
---|---|---|
return -1;
|
||
}
|
||
break;
|
||
case T_CONFIG_INT:
|
||
switch(du->type) {
|
||
case TYPE_INTEGER: {
|
||
data_integer *di = (data_integer *)du;
|
||
*((unsigned int *)(cv[i].destination)) = di->value;
|
||
break;
|
||
}
|
||
case TYPE_STRING: {
|
||
data_string *ds = (data_string *)du;
|
||
/* If the value came from an environment variable, then it is a
|
||
* data_string, although it may contain a number in ASCII
|
||
* decimal format. We try to interpret the string as a decimal
|
||
* int before giving up, in order to support setting numeric
|
||
* values with environment variables (eg, port number).
|
||
*/
|
||
if (ds->value->ptr && *ds->value->ptr) {
|
||
char *e;
|
||
long l = strtol(ds->value->ptr, &e, 10);
|
||
if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) {
|
||
*((unsigned int *)(cv[i].destination)) = l;
|
||
break;
|
||
}
|
||
}
|
||
log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an int:", cv[i].key, ds->value);
|
||
return -1;
|
||
}
|
||
default:
|
||
log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected a integer, range 0 ... 65535");
|
||
return -1;
|
||
}
|
||
break;
|
||
case T_CONFIG_BOOLEAN:
|
||
if (du->type == TYPE_STRING) {
|
||
data_string *ds = (data_string *)du;
|
src/base.h (working copy) | ||
---|---|---|
typedef enum { T_CONFIG_UNSET,
|
||
T_CONFIG_STRING,
|
||
T_CONFIG_SHORT,
|
||
T_CONFIG_INT,
|
||
T_CONFIG_BOOLEAN,
|
||
T_CONFIG_ARRAY,
|
||
T_CONFIG_LOCAL,
|