From 0d8c6accd772fc2bf5b596b9418fc850188a7788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sun, 21 Jun 2009 17:25:24 +0000 Subject: [PATCH] Add T_CONFIG_INT for bigger integers from the config (needed for #1966) git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2546 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 2 +- src/base.h | 1 + src/configfile-glue.c | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 34334fa5..a9848ab2 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,7 @@ NEWS ==== - 1.4.24 - - * + * Add T_CONFIG_INT for bigger integers from the config (needed for #1966) - 1.4.23 - 2009-06-19 * Added some extra warning options in cmake and fix the resulting warnings (unused/static functions) diff --git a/src/base.h b/src/base.h index bcb2325c..d5285e61 100644 --- a/src/base.h +++ b/src/base.h @@ -84,6 +84,7 @@ typedef int socklen_t; typedef enum { T_CONFIG_UNSET, T_CONFIG_STRING, T_CONFIG_SHORT, + T_CONFIG_INT, T_CONFIG_BOOLEAN, T_CONFIG_ARRAY, T_CONFIG_LOCAL, diff --git a/src/configfile-glue.c b/src/configfile-glue.c index 0fa665c4..0a67c8f6 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -103,7 +103,6 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t if (e != ds->value->ptr && !*e && l >=0 && l <= 65535) { *((unsigned short *)(cv[i].destination)) = l; break; - } } @@ -112,7 +111,37 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t 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"); + log_error_write(srv, __FILE__, __LINE__, "ssds", "unexpected type for key:", cv[i].key, du->type, "expected a short integer, range 0 ... 65535"); + 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 (ds->value->ptr && *ds->value->ptr) { + char *e; + long l = strtol(ds->value->ptr, &e, 10); + if (e != ds->value->ptr && !*e && l >= 0) { + *((unsigned int *)(cv[i].destination)) = l; + break; + } + } + + + log_error_write(srv, __FILE__, __LINE__, "ssb", "got a string but expected an integer:", 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 an integer, range 0 ... 4294967295"); return -1; } break;