Subversion Repositories Tewi

Rev

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

Rev 6 Rev 7
Line 1... Line 1...
1
/* $Id: config.c 6 2024-09-13 10:28:20Z nishi $ */
1
/* $Id: config.c 7 2024-09-13 10:40:53Z nishi $ */
2
 
2
 
3
#include "tw_config.h"
3
#include "tw_config.h"
4
 
4
 
5
#include <stdio.h>
5
#include <stdio.h>
-
 
6
#include <stdint.h>
6
#include <stdlib.h>
7
#include <stdlib.h>
7
#include <string.h>
8
#include <string.h>
8
 
9
 
9
#include <cm_string.h>
10
#include <cm_string.h>
10
#include <cm_log.h>
11
#include <cm_log.h>
11
 
12
 
12
struct tw_config config;
13
struct tw_config config;
13
 
14
 
14
void tw_config_init(void) {}
15
void tw_config_init(void) {
-
 
16
	int i;
-
 
17
	for(i = 0; i < MAX_PORTS + 1; i++) {
-
 
18
		config.ports[i] = -1;
-
 
19
	}
-
 
20
}
15
 
21
 
16
int tw_config_read(const char* path) {
22
int tw_config_read(const char* path) {
17
	cm_log("Config", "Reading %s", path);
23
	cm_log("Config", "Reading %s", path);
18
	char cbuf[2];
24
	char cbuf[2];
19
	cbuf[1] = 0;
25
	cbuf[1] = 0;
Line 57... Line 63...
57
							stop = 1;
63
							stop = 1;
58
						} else {
64
						} else {
59
							free(vhost);
65
							free(vhost);
60
							vhost = NULL;
66
							vhost = NULL;
61
						}
67
						}
-
 
68
					} else if(cm_strcaseequ(r[0], "Listen") || cm_strcaseequ(r[0], "ListenSSL")) {
-
 
69
						for(i = 1; r[i] != NULL; i++) {
-
 
70
							uint64_t port = atoi(r[i]);
-
 
71
							cm_log("Config", "Going to listen at port %d%s", (int)port, cm_strcaseequ(r[0], "ListenSSL") ? " with SSL" : "");
-
 
72
							if(cm_strcaseequ(r[0], "ListenSSL")) port |= (1ULL << 32);
-
 
73
							int j;
-
 
74
							for(j = 0; config.ports[j] != -1; j++)
-
 
75
								;
-
 
76
							config.ports[j] = port;
-
 
77
						}
62
					} else {
78
					} else {
63
						if(r[0] != NULL) {
79
						if(r[0] != NULL) {
64
							cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
80
							cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln);
65
						}
81
						}
66
						stop = 1;
82
						stop = 1;