summaryrefslogtreecommitdiff
path: root/src/configfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/configfile.c')
-rw-r--r--src/configfile.c408
1 files changed, 204 insertions, 204 deletions
diff --git a/src/configfile.c b/src/configfile.c
index e5d1610a..1d3d532f 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -26,8 +26,8 @@ static int config_insert(server *srv) {
size_t i;
int ret = 0;
buffer *stat_cache_string;
-
- config_values_t cv[] = {
+
+ config_values_t cv[] = {
{ "server.bind", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 0 */
{ "server.errorlog", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 1 */
{ "server.errorfile-prefix", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 2 */
@@ -38,7 +38,7 @@ static int config_insert(server *srv) {
{ "server.tag", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 7 */
{ "server.use-ipv6", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 8 */
{ "server.modules", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_SERVER }, /* 9 */
-
+
{ "server.event-handler", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 10 */
{ "server.pid-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 11 */
{ "server.max-request-size", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 12 */
@@ -49,7 +49,7 @@ static int config_insert(server *srv) {
{ "server.max-keep-alive-requests", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 17 */
{ "server.name", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 18 */
{ "server.max-keep-alive-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 19 */
-
+
{ "server.max-read-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 20 */
{ "server.max-write-idle", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 21 */
{ "server.error-handler-404", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 22 */
@@ -67,19 +67,19 @@ static int config_insert(server *srv) {
{ "mimetype.use-xattr", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 27 */
{ "mimetype.assign", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 28 */
{ "ssl.pemfile", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 29 */
-
+
{ "ssl.engine", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 30 */
-
+
{ "debug.log-file-not-found", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 31 */
{ "debug.log-request-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 32 */
{ "debug.log-response-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 33 */
{ "debug.log-request-header", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 34 */
-
+
{ "server.protocol-http11", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 35 */
{ "debug.log-request-header-on-error", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 36 */
{ "debug.log-state-handling", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 37 */
{ "ssl.ca-file", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 38 */
-
+
{ "server.errorlog-use-syslog", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 39 */
{ "server.range-requests", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 40 */
{ "server.stat-cache-engine", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 41 */
@@ -89,7 +89,7 @@ static int config_insert(server *srv) {
{ "server.core-files", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 45 */
{ "ssl.cipher-list", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_SERVER }, /* 46 */
{ "ssl.use-sslv2", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 47 */
-
+
{ "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
@@ -99,11 +99,11 @@ static int config_insert(server *srv) {
{ "server.groupid", "use server.groupname instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.use-keep-alive", "use server.max-keep-alive-requests = 0 instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.force-lower-case-files", "use server.force-lowercase-filenames instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
-
+
{ NULL, NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
};
-
+
/* 0 */
cv[0].destination = srv->srvconf.bindhost;
cv[1].destination = srv->srvconf.errorlog_file;
@@ -111,33 +111,33 @@ static int config_insert(server *srv) {
cv[4].destination = srv->srvconf.username;
cv[5].destination = srv->srvconf.groupname;
cv[6].destination = &(srv->srvconf.port);
-
+
cv[9].destination = srv->srvconf.modules;
cv[10].destination = srv->srvconf.event_handler;
cv[11].destination = srv->srvconf.pid_file;
-
+
cv[13].destination = &(srv->srvconf.max_worker);
cv[23].destination = &(srv->srvconf.max_fds);
cv[36].destination = &(srv->srvconf.log_request_header_on_error);
cv[37].destination = &(srv->srvconf.log_state_handling);
-
+
cv[39].destination = &(srv->srvconf.errorlog_use_syslog);
-
+
stat_cache_string = buffer_init();
cv[41].destination = stat_cache_string;
cv[43].destination = srv->srvconf.network_backend;
cv[44].destination = srv->srvconf.upload_tempdirs;
cv[45].destination = &(srv->srvconf.enable_cores);
-
+
cv[42].destination = &(srv->srvconf.max_conns);
cv[12].destination = &(srv->srvconf.max_request_size);
srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
assert(srv->config_storage);
-
+
for (i = 0; i < srv->config_context->used; i++) {
specific_config *s;
-
+
s = calloc(1, sizeof(specific_config));
assert(s);
s->document_root = buffer_init();
@@ -167,13 +167,13 @@ static int config_insert(server *srv) {
s->global_kbytes_per_second = 0;
s->global_bytes_per_second_cnt = 0;
s->global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
-
+
cv[2].destination = s->errorfile_prefix;
-
+
cv[7].destination = s->server_tag;
cv[8].destination = &(s->use_ipv6);
-
-
+
+
/* 13 max-worker */
cv[14].destination = s->document_root;
cv[15].destination = &(s->force_lowercase_filenames);
@@ -194,26 +194,26 @@ static int config_insert(server *srv) {
cv[28].destination = s->mimetypes;
cv[29].destination = s->ssl_pemfile;
cv[30].destination = &(s->is_ssl);
-
+
cv[31].destination = &(s->log_file_not_found);
cv[32].destination = &(s->log_request_handling);
cv[33].destination = &(s->log_response_header);
cv[34].destination = &(s->log_request_header);
-
+
cv[35].destination = &(s->allow_http11);
cv[38].destination = s->ssl_ca_file;
cv[40].destination = &(s->range_requests);
-
+
cv[46].destination = s->ssl_cipher_list;
cv[47].destination = &(s->ssl_use_sslv2);
srv->config_storage[i] = s;
-
+
if (0 != (ret = config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv))) {
break;
}
}
-
+
if (buffer_is_empty(stat_cache_string)) {
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_SIMPLE;
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("simple"))) {
@@ -223,22 +223,22 @@ static int config_insert(server *srv) {
} else if (buffer_is_equal_string(stat_cache_string, CONST_STR_LEN("disable"))) {
srv->srvconf.stat_cache_engine = STAT_CACHE_ENGINE_NONE;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sb",
+ log_error_write(srv, __FILE__, __LINE__, "sb",
"server.stat-cache-engine can be one of \"disable\", \"simple\", \"fam\", but not:", stat_cache_string);
ret = HANDLER_ERROR;
}
-
+
buffer_free(stat_cache_string);
-
+
return ret;
-
+
}
#define PATCH(x) con->conf.x = s->x
int config_setup_connection(server *srv, connection *con) {
specific_config *s = srv->config_storage[0];
-
+
PATCH(allow_http11);
PATCH(mimetypes);
PATCH(document_root);
@@ -256,20 +256,20 @@ int config_setup_connection(server *srv, connection *con) {
PATCH(kbytes_per_second);
PATCH(global_kbytes_per_second);
PATCH(global_bytes_per_second_cnt);
-
+
con->conf.global_bytes_per_second_cnt_ptr = &s->global_bytes_per_second_cnt;
buffer_copy_string_buffer(con->server_name, s->server_name);
-
+
PATCH(log_request_header);
PATCH(log_response_header);
PATCH(log_request_handling);
PATCH(log_condition_handling);
PATCH(log_file_not_found);
-
+
PATCH(range_requests);
PATCH(force_lowercase_filenames);
PATCH(is_ssl);
-
+
PATCH(ssl_pemfile);
PATCH(ssl_ca_file);
PATCH(ssl_cipher_list);
@@ -281,22 +281,22 @@ int config_setup_connection(server *srv, connection *con) {
int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
size_t i, j;
-
+
/* skip the first, the global context */
for (i = 1; i < srv->config_context->used; i++) {
data_config *dc = (data_config *)srv->config_context->data[i];
specific_config *s = srv->config_storage[i];
-
+
/* not our stage */
if (comp != dc->comp) continue;
-
+
/* condition didn't match */
if (!config_check_cond(srv, con, dc)) continue;
-
+
/* merge config */
for (j = 0; j < dc->value->used; j++) {
data_unset *du = dc->value->data[j];
-
+
if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.document-root"))) {
PATCH(document_root);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.range-requests"))) {
@@ -349,7 +349,7 @@ int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
PATCH(log_file_not_found);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.protocol-http11"))) {
PATCH(allow_http11);
- } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.force-lowercase-filenames"))) {
+ } else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.force-lowercase-filenames"))) {
PATCH(force_lowercase_filenames);
} else if (buffer_is_equal_string(du->key, CONST_STR_LEN("server.kbytes-per-second"))) {
PATCH(global_kbytes_per_second);
@@ -358,7 +358,7 @@ int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
}
}
}
-
+
return 0;
}
#undef PATCH
@@ -366,15 +366,15 @@ int config_patch_connection(server *srv, connection *con, comp_key_t comp) {
typedef struct {
int foo;
int bar;
-
+
const buffer *source;
const char *input;
size_t offset;
size_t size;
-
+
int line_pos;
int line;
-
+
int in_key;
int in_brace;
int in_cond;
@@ -392,7 +392,7 @@ static int tokenizer_open(server *srv, tokenizer_t *t, buffer *basedir, const ch
}
if (0 != stream_open(&(t->s), t->file)) {
- log_error_write(srv, __FILE__, __LINE__, "sbss",
+ log_error_write(srv, __FILE__, __LINE__, "sbss",
"opening configfile ", t->file, "failed:", strerror(errno));
buffer_free(t->file);
return -1;
@@ -403,7 +403,7 @@ static int tokenizer_open(server *srv, tokenizer_t *t, buffer *basedir, const ch
t->size = t->s.size;
t->line = 1;
t->line_pos = 1;
-
+
t->in_key = 1;
t->in_brace = 0;
t->in_cond = 0;
@@ -431,7 +431,7 @@ static int config_skip_newline(tokenizer_t *t) {
static int config_skip_comment(tokenizer_t *t) {
int i;
assert(t->input[t->offset] == '#');
- for (i = 1; t->input[t->offset + i] &&
+ for (i = 1; t->input[t->offset + i] &&
(t->input[t->offset + i] != '\n' && t->input[t->offset + i] != '\r');
i++);
t->offset += i;
@@ -441,44 +441,44 @@ static int config_skip_comment(tokenizer_t *t) {
static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *token) {
int tid = 0;
size_t i;
-
+
for (tid = 0; tid == 0 && t->offset < t->size && t->input[t->offset] ; ) {
char c = t->input[t->offset];
const char *start = NULL;
-
+
switch (c) {
- case '=':
+ case '=':
if (t->in_brace) {
if (t->input[t->offset + 1] == '>') {
t->offset += 2;
-
+
buffer_copy_string(token, "=>");
-
+
tid = TK_ARRAY_ASSIGN;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"use => for assignments in arrays");
return -1;
}
} else if (t->in_cond) {
if (t->input[t->offset + 1] == '=') {
t->offset += 2;
-
+
buffer_copy_string(token, "==");
-
+
tid = TK_EQ;
} else if (t->input[t->offset + 1] == '~') {
t->offset += 2;
-
+
buffer_copy_string(token, "=~");
-
+
tid = TK_MATCH;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"only =~ and == are allowed in the condition");
return -1;
}
@@ -486,51 +486,51 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
t->in_cond = 0;
} else if (t->in_key) {
tid = TK_ASSIGN;
-
+
buffer_copy_string_len(token, t->input + t->offset, 1);
-
+
t->offset++;
t->line_pos++;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"unexpected equal-sign: =");
return -1;
}
-
+
break;
- case '!':
+ case '!':
if (t->in_cond) {
if (t->input[t->offset + 1] == '=') {
t->offset += 2;
-
+
buffer_copy_string(token, "!=");
-
+
tid = TK_NE;
} else if (t->input[t->offset + 1] == '~') {
t->offset += 2;
-
+
buffer_copy_string(token, "!~");
-
+
tid = TK_NOMATCH;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"only !~ and != are allowed in the condition");
return -1;
}
t->in_key = 1;
t->in_cond = 0;
} else {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"unexpected exclamation-marks: !");
return -1;
}
-
+
break;
case '\t':
case ' ':
@@ -576,10 +576,10 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
case ',':
if (t->in_brace > 0) {
tid = TK_COMMA;
-
+
buffer_copy_string(token, "(COMMA)");
}
-
+
t->offset++;
t->line_pos++;
break;
@@ -587,70 +587,70 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
/* search for the terminating " */
start = t->input + t->offset + 1;
buffer_copy_string(token, "");
-
+
for (i = 1; t->input[t->offset + i]; i++) {
if (t->input[t->offset + i] == '\\' &&
t->input[t->offset + i + 1] == '"') {
-
+
buffer_append_string_len(token, start, t->input + t->offset + i - start);
-
+
start = t->input + t->offset + i + 1;
-
+
/* skip the " */
i++;
continue;
}
-
-
+
+
if (t->input[t->offset + i] == '"') {
tid = TK_STRING;
-
+
buffer_append_string_len(token, start, t->input + t->offset + i - start);
-
+
break;
}
}
if (t->input[t->offset + i] == '\0') {
/* ERROR */
-
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"missing closing quote");
-
+
return -1;
}
-
+
t->offset += i + 1;
t->line_pos += i + 1;
-
+
break;
case '(':
t->offset++;
t->in_brace++;
-
+
tid = TK_LPARAN;
-
+
buffer_copy_string(token, "(");
break;
case ')':
t->offset++;
t->in_brace--;
-
+
tid = TK_RPARAN;
-
+
buffer_copy_string(token, ")");
break;
case '$':
t->offset++;
-
+
tid = TK_DOLLAR;
t->in_cond = 1;
t->in_key = 0;
-
+
buffer_copy_string(token, "$");
-
+
break;
case '+':
@@ -667,88 +667,88 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
case '{':
t->offset++;
-
+
tid = TK_LCURLY;
-
+
buffer_copy_string(token, "{");
-
+
break;
-
+
case '}':
t->offset++;
-
+
tid = TK_RCURLY;
-
+
buffer_copy_string(token, "}");
-
+
break;
case '[':
t->offset++;
-
+
tid = TK_LBRACKET;
-
+
buffer_copy_string(token, "[");
-
+
break;
-
+
case ']':
t->offset++;
-
+
tid = TK_RBRACKET;
-
+
buffer_copy_string(token, "]");
-
+
break;
case '#':
t->line_pos += config_skip_comment(t);
-
+
break;
default:
if (t->in_cond) {
- for (i = 0; t->input[t->offset + i] &&
+ for (i = 0; t->input[t->offset + i] &&
(isalpha((unsigned char)t->input[t->offset + i])
); i++);
-
+
if (i && t->input[t->offset + i]) {
tid = TK_SRVVARNAME;
buffer_copy_string_len(token, t->input + t->offset, i);
-
+
t->offset += i;
t->line_pos += i;
} else {
/* ERROR */
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"invalid character in condition");
return -1;
}
} else if (isdigit((unsigned char)c)) {
/* take all digits */
for (i = 0; t->input[t->offset + i] && isdigit((unsigned char)t->input[t->offset + i]); i++);
-
+
/* was there it least a digit ? */
if (i) {
tid = TK_INTEGER;
-
+
buffer_copy_string_len(token, t->input + t->offset, i);
-
+
t->offset += i;
t->line_pos += i;
}
} else {
/* the key might consist of [-.0-9a-z] */
- for (i = 0; t->input[t->offset + i] &&
- (isalnum((unsigned char)t->input[t->offset + i]) ||
+ for (i = 0; t->input[t->offset + i] &&
+ (isalnum((unsigned char)t->input[t->offset + i]) ||
t->input[t->offset + i] == '.' ||
t->input[t->offset + i] == '_' || /* for env.* */
t->input[t->offset + i] == '-'
); i++);
-
+
if (i && t->input[t->offset + i]) {
buffer_copy_string_len(token, t->input + t->offset, i);
-
+
if (strcmp(token->ptr, "include") == 0) {
tid = TK_INCLUDE;
} else if (strcmp(token->ptr, "include_shell") == 0) {
@@ -760,14 +760,14 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
} else {
tid = TK_LKEY;
}
-
+
t->offset += i;
t->line_pos += i;
} else {
/* ERROR */
- log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsds",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"invalid character in variable name");
return -1;
}
@@ -775,16 +775,16 @@ static int config_tokenizer(server *srv, tokenizer_t *t, int *token_id, buffer *
break;
}
}
-
+
if (tid) {
*token_id = tid;
#if 0
- log_error_write(srv, __FILE__, __LINE__, "sbsdsdbdd",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsdbdd",
"source:", t->source,
"line:", t->line, "pos:", t->line_pos,
token, token->used - 1, tid);
#endif
-
+
return 1;
} else if (t->offset < t->size) {
fprintf(stderr, "%s.%d: %d, %s\n",
@@ -806,7 +806,7 @@ static int config_parse(server *srv, config_t *context, tokenizer_t *t) {
while((1 == (ret = config_tokenizer(srv, t, &token_id, token))) && context->ok) {
buffer_copy_string_buffer(lasttoken, token);
configparser(pParser, token_id, token, context);
-
+
token = buffer_init();
}
buffer_free(token);
@@ -819,14 +819,14 @@ static int config_parse(server *srv, config_t *context, tokenizer_t *t) {
}
}
configparserFree(pParser, free);
-
+
if (ret == -1) {
- log_error_write(srv, __FILE__, __LINE__, "sb",
+ log_error_write(srv, __FILE__, __LINE__, "sb",
"configfile parser failed at:", lasttoken);
} else if (context->ok == 0) {
- log_error_write(srv, __FILE__, __LINE__, "sbsdsdsb",
+ log_error_write(srv, __FILE__, __LINE__, "sbsdsdsb",
"source:", t->source,
- "line:", t->line, "pos:", t->line_pos,
+ "line:", t->line, "pos:", t->line_pos,
"parser failed somehow near here:", lasttoken);
ret = -1;
}
@@ -843,7 +843,7 @@ static int tokenizer_init(tokenizer_t *t, const buffer *source, const char *inpu
t->offset = 0;
t->line = 1;
t->line_pos = 1;
-
+
t->in_key = 1;
t->in_brace = 0;
t->in_cond = 0;
@@ -866,7 +866,7 @@ int config_parse_file(server *srv, config_t *context, const char *fn) {
}
if (0 != stream_open(&s, filename)) {
- log_error_write(srv, __FILE__, __LINE__, "sbss",
+ log_error_write(srv, __FILE__, __LINE__, "sbss",
"opening configfile ", filename, "failed:", strerror(errno));
ret = -1;
} else {
@@ -888,7 +888,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
char oldpwd[PATH_MAX];
if (NULL == getcwd(oldpwd, sizeof(oldpwd))) {
- log_error_write(srv, __FILE__, __LINE__, "s",
+ log_error_write(srv, __FILE__, __LINE__, "s",
"cannot get cwd", strerror(errno));
return -1;
}
@@ -901,7 +901,7 @@ int config_parse_cmd(server *srv, config_t *context, const char *cmd) {
}
if (0 != proc_open_buffer(&proc, cmd, NULL, out, NULL)) {
- log_error_write(srv, __FILE__, __LINE__, "sbss",
+ log_error_write(srv, __FILE__, __LINE__, "sbss",
"opening", source, "failed:", strerror(errno));
ret = -1;
} else {
@@ -951,7 +951,7 @@ int config_read(server *srv, const char *fn) {
buffer_copy_string_len(context.basedir, fn, pos - fn + 1);
fn = pos + 1;
}
-
+
dc = data_config_init();
buffer_copy_string(dc->key, "global");
@@ -966,7 +966,7 @@ int config_read(server *srv, const char *fn) {
dpid->value = getpid();
buffer_copy_string(dpid->key, "var.PID");
array_insert_unique(srv->config, (data_unset *)dpid);
-
+
dcwd = data_string_init();
buffer_prepare_copy(dcwd->value, 1024);
if (NULL != getcwd(dcwd->value->ptr, dcwd->value->size - 1)) {
@@ -990,7 +990,7 @@ int config_read(server *srv, const char *fn) {
} else {
return -1;
}
-
+
if (NULL != (modules = (data_array *)array_get_element(srv->config, "server.modules"))) {
data_string *ds;
data_array *prepends;
@@ -1048,12 +1048,12 @@ int config_read(server *srv, const char *fn) {
buffer_copy_string(modules->key, "server.modules");
array_insert_unique(srv->config, (data_unset *)modules);
}
-
+
if (0 != config_insert(srv)) {
return -1;
}
-
+
return 0;
}
@@ -1061,9 +1061,9 @@ int config_set_defaults(server *srv) {
size_t i;
specific_config *s = srv->config_storage[0];
struct stat st1, st2;
-
- struct ev_map { fdevent_handler_t et; const char *name; } event_handlers[] =
- {
+
+ struct ev_map { fdevent_handler_t et; const char *name; } event_handlers[] =
+ {
/* - poll is most reliable
* - select works everywhere
* - linux-* are experimental
@@ -1089,20 +1089,20 @@ int config_set_defaults(server *srv) {
#endif
{ FDEVENT_HANDLER_UNSET, NULL }
};
-
-
- if (buffer_is_empty(s->document_root)) {
- log_error_write(srv, __FILE__, __LINE__, "s",
- "a default document-root has to be set");
-
- return -1;
- }
-
+
+
+ if (buffer_is_empty(s->document_root)) {
+ log_error_write(srv, __FILE__, __LINE__, "s",
+ "a default document-root has to be set");
+
+ return -1;
+ }
+
if (buffer_is_empty(srv->srvconf.changeroot)) {
- if (-1 == stat(s->document_root->ptr, &st1)) {
- log_error_write(srv, __FILE__, __LINE__, "sb",
+ if (-1 == stat(s->document_root->ptr, &st1)) {
+ log_error_write(srv, __FILE__, __LINE__, "sb",
"base-docroot doesn't exist:",
- s->document_root);
+ s->document_root);
return -1;
}
@@ -1110,18 +1110,18 @@ int config_set_defaults(server *srv) {
buffer_copy_string_buffer(srv->tmp_buf, srv->srvconf.changeroot);
buffer_append_string_buffer(srv->tmp_buf, s->document_root);
- if (-1 == stat(srv->tmp_buf->ptr, &st1)) {
- log_error_write(srv, __FILE__, __LINE__, "sb",
+ if (-1 == stat(srv->tmp_buf->ptr, &st1)) {
+ log_error_write(srv, __FILE__, __LINE__, "sb",
"base-docroot doesn't exist:",
- srv->tmp_buf);
+ srv->tmp_buf);
return -1;
}
-
+
}
-
- buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
- buffer_to_lower(srv->tmp_buf);
+ buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
+
+ buffer_to_lower(srv->tmp_buf);
if (0 == stat(srv->tmp_buf->ptr, &st1)) {
int is_lower = 0;
@@ -1129,68 +1129,68 @@ int config_set_defaults(server *srv) {
is_lower = buffer_is_equal(srv->tmp_buf, s->document_root);
/* lower-case existed, check upper-case */
- buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
+ buffer_copy_string_buffer(srv->tmp_buf, s->document_root);
- buffer_to_upper(srv->tmp_buf);
+ buffer_to_upper(srv->tmp_buf);
/* we have to handle the special case that upper and lower-casing results in the same filename
* as in server.document-root = "/" or "/12345/" */
if (is_lower && buffer_is_equal(srv->tmp_buf, s->document_root)) {
- /* lower-casing and upper-casing didn't result in
- * an other filename, no need to stat(),
+ /* lower-casing and upper-casing didn't result in
+ * an other filename, no need to stat(),
* just assume it is case-sensitive. */
s->force_lowercase_filenames = 0;
- } else if (0 == stat(srv->tmp_buf->ptr, &st2)) {
-
- /* upper case exists too, doesn't the FS handle this ? */
-
- /* upper and lower have the same inode -> case-insensitve FS */
-
- if (st1.st_ino == st2.st_ino) {
- /* upper and lower have the same inode -> case-insensitve FS */
-
- s->force_lowercase_filenames = 1;
- }
- }
- }
-
+ } else if (0 == stat(srv->tmp_buf->ptr, &st2)) {
+
+ /* upper case exists too, doesn't the FS handle this ? */
+
+ /* upper and lower have the same inode -> case-insensitve FS */
+
+ if (st1.st_ino == st2.st_ino) {
+ /* upper and lower have the same inode -> case-insensitve FS */
+
+ s->force_lowercase_filenames = 1;
+ }
+ }
+ }
+
if (srv->srvconf.port == 0) {
srv->srvconf.port = s->is_ssl ? 443 : 80;
}
-
+
if (srv->srvconf.event_handler->used == 0) {
/* choose a good default
- *
- * the event_handler list is sorted by 'goodness'
+ *
+ * the event_handler list is sorted by 'goodness'
* taking the first available should be the best solution
*/
srv->event_handler = event_handlers[0].et;
-
+
if (FDEVENT_HANDLER_UNSET == srv->event_handler) {
- log_error_write(srv, __FILE__, __LINE__, "s",
+ log_error_write(srv, __FILE__, __LINE__, "s",
"sorry, there is no event handler for this system");
-
+
return -1;
}
} else {
/*
* User override
*/
-
+
for (i = 0; event_handlers[i].name; i++) {
if (0 == strcmp(event_handlers[i].name, srv->srvconf.event_handler->ptr)) {
srv->event_handler = event_handlers[i].et;
break;
}
}
-
+
if (FDEVENT_HANDLER_UNSET == srv->event_handler) {
- log_error_write(srv, __FILE__, __LINE__, "sb",
- "the selected event-handler in unknown or not supported:",
+ log_error_write(srv, __FILE__, __LINE__, "sb",
+ "the selected event-handler in unknown or not supported:",
srv->srvconf.event_handler );
-
+
return -1;
}
}
@@ -1198,19 +1198,19 @@ int config_set_defaults(server *srv) {
if (s->is_ssl) {
if (buffer_is_empty(s->ssl_pemfile)) {
/* PEM file is require */
-
- log_error_write(srv, __FILE__, __LINE__, "s",
+
+ log_error_write(srv, __FILE__, __LINE__, "s",
"ssl.pemfile has to be set");
return -1;
}
-
+
#ifndef USE_OPENSSL
- log_error_write(srv, __FILE__, __LINE__, "s",
+ log_error_write(srv, __FILE__, __LINE__, "s",
"ssl support is missing, recompile with --with-openssl");
-
+
return -1;
#endif
}
-
+
return 0;
}