Subversion Repositories Tewi

Rev

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

Rev 12 Rev 13
Line 1... Line 1...
1
/* $Id: config.c 12 2024-09-13 13:36:03Z nishi $ */
1
/* $Id: config.c 13 2024-09-13 13:38:57Z 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 <stdint.h>
Line 14... Line 14...
14
struct tw_config config;
14
struct tw_config config;
15
 
15
 
16
struct tw_config_entry* tw_vhost_match(const char* name, int port) {
16
struct tw_config_entry* tw_vhost_match(const char* name, int port) {
17
	int i;
17
	int i;
18
	for(i = 0; i < config.vhost_count; i++) {
18
	for(i = 0; i < config.vhost_count; i++) {
19
		if(strcmp(config.vhosts[i].name, name) == 0 && config.vhosts[i].port == port) {
19
		if(strcmp(config.vhosts[i].name, name) == 0 && (config.vhosts[i].port == -1 ? 1 : config.vhosts[i].port == port)) {
20
			return &config.vhosts[i];
20
			return &config.vhosts[i];
21
		}
21
		}
22
	}
22
	}
23
	return &config.root;
23
	return &config.root;
24
}
24
}
Line 76... Line 76...
76
							} else {
76
							} else {
77
								vhost = cm_strdup(r[1]);
77
								vhost = cm_strdup(r[1]);
78
								current = &config.vhosts[config.vhost_count++];
78
								current = &config.vhosts[config.vhost_count++];
79
								int i;
79
								int i;
80
								current->name = cm_strdup(vhost);
80
								current->name = cm_strdup(vhost);
81
								current->port = 80;
81
								current->port = -1;
82
								for(i = 0; vhost[i] != 0; i++) {
82
								for(i = 0; vhost[i] != 0; i++) {
83
									if(vhost[i] == ':') {
83
									if(vhost[i] == ':') {
84
										current->name[i] = 0;
84
										current->name[i] = 0;
85
										current->port = atoi(current->name + i + 1);
85
										current->port = atoi(current->name + i + 1);
86
										break;
86
										break;