Subversion Repositories Tewi

Rev

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

Rev 16 Rev 17
Line 1... Line 1...
1
/* $Id: config.c 16 2024-09-13 15:09:52Z nishi $ */
1
/* $Id: config.c 17 2024-09-13 17:41:07Z 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
 
7
 
7
#include <stdio.h>
8
#include <stdio.h>
8
#include <stdint.h>
9
#include <stdint.h>
9
#include <stdlib.h>
10
#include <stdlib.h>
10
#include <string.h>
11
#include <string.h>
Line 35... Line 36...
35
		config.vhosts[i].sslcert = NULL;
36
		config.vhosts[i].sslcert = NULL;
36
	}
37
	}
37
	config.root.sslkey = NULL;
38
	config.root.sslkey = NULL;
38
	config.root.sslcert = NULL;
39
	config.root.sslcert = NULL;
39
	config.vhost_count = 0;
40
	config.vhost_count = 0;
-
 
41
	config.server_root = cm_strdup(PREFIX);
40
	gethostname(config.hostname, 1024);
42
	gethostname(config.hostname, 1024);
41
}
43
}
42
 
44
 
43
int tw_config_read(const char* path) {
45
int tw_config_read(const char* path) {
44
	cm_log("Config", "Reading %s", path);
46
	cm_log("Config", "Reading %s", path);
Line 123... Line 125...
123
							stop = 1;
125
							stop = 1;
124
						} else {
126
						} else {
125
							if(current->sslcert != NULL) free(current->sslcert);
127
							if(current->sslcert != NULL) free(current->sslcert);
126
							current->sslcert = cm_strdup(r[1]);
128
							current->sslcert = cm_strdup(r[1]);
127
						}
129
						}
-
 
130
					} else if(cm_strcaseequ(r[0], "ServerRoot")) {
-
 
131
						if(r[1] == NULL) {
-
 
132
							cm_log("Config", "Missing path at line %d", ln);
-
 
133
							stop = 1;
-
 
134
						} else {
-
 
135
							if(config.server_root != NULL) free(config.server_root);
-
 
136
							config.server_root = cm_strdup(r[1]);
-
 
137
						}
-
 
138
					} else if(cm_strcaseequ(r[0], "LoadModule")) {
-
 
139
						for(i = 1; r[i] != NULL; i++) {
-
 
140
							void* mod = tw_module_load(r[i]);
-
 
141
							if(mod != NULL) {
-
 
142
								if(tw_module_init(mod) != 0) {
-
 
143
									stop = 1;
-
 
144
									break;
-
 
145
								}
-
 
146
							} else {
-
 
147
								stop = 1;
-
 
148
								break;
-
 
149
							}
-
 
150
						}
128
					} else {
151
					} else {
129
						if(r[0] != NULL) {
152
						if(r[0] != NULL) {
130
							cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
153
							cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
131
						}
154
						}
132
						stop = 1;
155
						stop = 1;