Subversion Repositories Tewi

Rev

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

Rev 19 Rev 21
Line 1... Line 1...
1
/* $Id: tw_config.h 19 2024-09-14 00:51:41Z nishi $ */
1
/* $Id: tw_config.h 21 2024-09-14 12:39:39Z nishi $ */
2
 
2
 
3
#ifndef __TW_CONFIG_H__
3
#ifndef __TW_CONFIG_H__
4
#define __TW_CONFIG_H__
4
#define __TW_CONFIG_H__
5
 
5
 
-
 
6
#include "tw_http.h"
-
 
7
 
6
#include <stdint.h>
8
#include <stdint.h>
-
 
9
#include <stdbool.h>
-
 
10
 
-
 
11
#ifdef __MINGW32__
-
 
12
#include <winsock2.h>
-
 
13
#define NO_IPV6
-
 
14
#else
-
 
15
#include <netinet/in.h>
-
 
16
#endif
7
 
17
 
-
 
18
#ifdef NO_IPV6
-
 
19
#define SOCKADDR struct sockaddr_in
-
 
20
#else
-
 
21
#define SOCKADDR struct sockaddr_in6
-
 
22
#endif
-
 
23
 
8
#define MAX_PORTS 1024
24
#define MAX_PORTS	1024
9
#define MAX_VHOSTS 1024
25
#define MAX_VHOSTS	1024
10
#define MAX_MODULES 1024
26
#define MAX_MODULES	1024
-
 
27
#define MAX_DIRS 	1024
-
 
28
#define MAX_MIME 	1024
-
 
29
 
-
 
30
enum TW_DIR_TYPE {
-
 
31
	TW_DIR_ALLOW = 0,
-
 
32
	TW_DIR_DENY
-
 
33
};
-
 
34
 
-
 
35
struct tw_dir_entry {
-
 
36
	char* name;
-
 
37
	char* dir;
-
 
38
	int type;
-
 
39
};
-
 
40
 
-
 
41
struct tw_mime_entry {
-
 
42
	char* ext;
-
 
43
	char* mime;
-
 
44
};
11
 
45
 
12
struct tw_config_entry {
46
struct tw_config_entry {
13
	char* name;
47
	char* name;
14
	int port;
48
	int port;
15
	char* sslkey;
49
	char* sslkey;
16
	char* sslcert;
50
	char* sslcert;
17
	char* root;
51
	char* root;
-
 
52
	struct tw_dir_entry dirs[MAX_DIRS];
-
 
53
	int dir_count;
-
 
54
	struct tw_mime_entry mimes[MAX_DIRS];
-
 
55
	int mime_count;
18
};
56
};
19
 
57
 
20
struct tw_config {
58
struct tw_config {
21
	uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
59
	uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
22
	char hostname[1025];
60
	char hostname[1025];
Line 30... Line 68...
30
};
68
};
31
 
69
 
32
void tw_config_init(void);
70
void tw_config_init(void);
33
int tw_config_read(const char* path);
71
int tw_config_read(const char* path);
34
struct tw_config_entry* tw_vhost_match(const char* name, int port);
72
struct tw_config_entry* tw_vhost_match(const char* name, int port);
-
 
73
bool tw_permission_allowed(const char* path, SOCKADDR addr, struct tw_http_request req, struct tw_config_entry* vhost);
35
 
74
 
36
#endif
75
#endif