Subversion Repositories Tewi

Rev

Rev 156 | Rev 174 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 161
Line 1... Line 1...
1
/* $Id: config.c 156 2024-09-25 12:28:10Z nishi $ */
1
/* $Id: config.c 161 2024-09-25 13:35:04Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "tw_config.h"
5
#include "tw_config.h"
6
#include "tw_module.h"
6
#include "tw_module.h"
Line 100... Line 100...
100
	config.extension = NULL;
100
	config.extension = NULL;
101
	config.server_root = cm_strdup(PREFIX);
101
	config.server_root = cm_strdup(PREFIX);
102
	config.server_admin = cm_strdup(SERVER_ADMIN);
102
	config.server_admin = cm_strdup(SERVER_ADMIN);
103
	config.defined[0] = NULL;
103
	config.defined[0] = NULL;
104
	gethostname(config.hostname, 1024);
104
	gethostname(config.hostname, 1024);
-
 
105
#ifdef HAS_CHROOT
-
 
106
	tw_add_define("HAS_CHROOT");
-
 
107
#endif
105
}
108
}
106
 
109
 
107
int tw_config_read(const char* path) {
110
int tw_config_read(const char* path) {
108
	cm_log("Config", "Reading %s", path);
111
	cm_log("Config", "Reading %s", path);
109
	char cbuf[2];
112
	char cbuf[2];
Line 271... Line 274...
271
						} else {
274
						} else {
272
							if(current->sslcert != NULL) free(current->sslcert);
275
							if(current->sslcert != NULL) free(current->sslcert);
273
							current->sslcert = cm_strdup(r[1]);
276
							current->sslcert = cm_strdup(r[1]);
274
						}
277
						}
275
#endif
278
#endif
-
 
279
#ifdef HAS_CHROOT
-
 
280
					} else if(cm_strcaseequ(r[0], "ChrootDirectory")) {
-
 
281
						if(r[1] == NULL) {
-
 
282
							cm_log("Config", "Missing path at line %d", ln);
-
 
283
							stop = 1;
-
 
284
						} else {
-
 
285
							if(current->chroot_path != NULL) free(current->chroot_path);
-
 
286
							current->chroot_path = cm_strdup(r[1]);
-
 
287
						}
-
 
288
#endif
276
					} else if(cm_strcaseequ(r[0], "ForceLog")) {
289
					} else if(cm_strcaseequ(r[0], "ForceLog")) {
277
						if(r[1] == NULL) {
290
						if(r[1] == NULL) {
278
							cm_log("Config", "Missing log at line %d", ln);
291
							cm_log("Config", "Missing log at line %d", ln);
279
							stop = 1;
292
							stop = 1;
280
						} else {
293
						} else {
Line 344... Line 357...
344
							stop = 1;
357
							stop = 1;
345
						} else {
358
						} else {
346
							if(current->root != NULL) free(current->root);
359
							if(current->root != NULL) free(current->root);
347
							current->root = cm_strdup(strcmp(r[1], "/") == 0 ? "" : r[1]);
360
							current->root = cm_strdup(strcmp(r[1], "/") == 0 ? "" : r[1]);
348
						}
361
						}
349
					} else if(cm_strcaseequ(r[0], "ServerRoot")) {
-
 
350
						if(r[1] == NULL) {
-
 
351
							cm_log("Config", "Missing path at line %d", ln);
-
 
352
							stop = 1;
-
 
353
						} else {
-
 
354
							if(config.server_root != NULL) free(config.server_root);
-
 
355
							config.server_root = cm_strdup(r[1]);
-
 
356
						}
-
 
357
					} else if(cm_strcaseequ(r[0], "MIMEType")) {
362
					} else if(cm_strcaseequ(r[0], "MIMEType")) {
358
						if(r[1] == NULL) {
363
						if(r[1] == NULL) {
359
							cm_log("Config", "Missing extension at line %d", ln);
364
							cm_log("Config", "Missing extension at line %d", ln);
360
							stop = 1;
365
							stop = 1;
361
						} else if(r[2] == NULL) {
366
						} else if(r[2] == NULL) {