Subversion Repositories Tewi

Rev

Rev 311 | Rev 315 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 nishi 1
/* $Id: tw_config.h 312 2024-10-13 18:17:37Z nishi $ */
2
 
3
#ifndef __TW_CONFIG_H__
4
#define __TW_CONFIG_H__
5
 
140 nishi 6
#ifdef __cplusplus
7
extern "C" {
8
#endif
9
 
156 nishi 10
#include "../config.h"
11
 
21 nishi 12
#include "tw_http.h"
13
 
7 nishi 14
#include <stdint.h>
21 nishi 15
#include <stdbool.h>
7 nishi 16
 
311 nishi 17
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
240 nishi 18
#ifdef USE_WINSOCK1
19
#include <winsock.h>
20
#else
21 nishi 21
#include <winsock2.h>
240 nishi 22
#endif
21 nishi 23
#define NO_IPV6
24
#else
187 nishi 25
#ifdef __PPU__
26
#include <net/net.h>
27
#endif
312 nishi 28
#if !defined(__OS2__)
21 nishi 29
#include <netinet/in.h>
312 nishi 30
#endif
81 nishi 31
#ifdef __HAIKU__
32
#define NO_IPV6
21 nishi 33
#endif
81 nishi 34
#endif
6 nishi 35
 
312 nishi 36
#if defined(NO_IPV6)
21 nishi 37
#define SOCKADDR struct sockaddr_in
38
#else
39
#define SOCKADDR struct sockaddr_in6
40
#endif
41
 
22 nishi 42
#define MAX_PORTS 1024
43
#define MAX_VHOSTS 1024
44
#define MAX_MODULES 1024
45
#define MAX_DIRS 1024
257 nishi 46
#define MAX_MIME 4096
22 nishi 47
#define MAX_ICON 1024
258 nishi 48
#define MAX_INDEX 32
33 nishi 49
#define MAX_README 8
21 nishi 50
 
215 nishi 51
#if defined(_MSC_VER) || defined(__BORLANDC__)
212 nishi 52
#define NUM1024 1024UL
53
#else
54
#define NUM1024 1024ULL
55
#endif
56
 
21 nishi 57
enum TW_DIR_TYPE {
58
	TW_DIR_ALLOW = 0,
59
	TW_DIR_DENY
60
};
61
 
62
struct tw_dir_entry {
63
	char* name;
64
	char* dir;
65
	int type;
66
};
67
 
68
struct tw_mime_entry {
69
	char* ext;
70
	char* mime;
71
};
72
 
22 nishi 73
struct tw_icon_entry {
74
	char* mime;
75
	char* icon;
76
};
77
 
12 nishi 78
struct tw_config_entry {
79
	char* name;
80
	int port;
156 nishi 81
#ifndef NO_SSL
12 nishi 82
	char* sslkey;
83
	char* sslcert;
156 nishi 84
#endif
19 nishi 85
	char* root;
123 nishi 86
	int hideport;
21 nishi 87
	struct tw_dir_entry dirs[MAX_DIRS];
88
	int dir_count;
257 nishi 89
	struct tw_mime_entry mimes[MAX_MIME];
21 nishi 90
	int mime_count;
257 nishi 91
	struct tw_icon_entry icons[MAX_ICON];
22 nishi 92
	int icon_count;
24 nishi 93
	char* indexes[MAX_INDEX];
94
	int index_count;
33 nishi 95
	char* readmes[MAX_README];
96
	int readme_count;
156 nishi 97
#ifdef HAS_CHROOT
98
	char* chroot_path;
99
#endif
12 nishi 100
};
101
 
6 nishi 102
struct tw_config {
215 nishi 103
#if defined(_MSC_VER) || defined(__BORLANDC__)
212 nishi 104
	uint32_t ports[MAX_PORTS + 1];
105
#else
7 nishi 106
	uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
212 nishi 107
#endif
12 nishi 108
	char hostname[1025];
156 nishi 109
	char* defined[1025];
6 nishi 110
	struct tw_config_entry root;
12 nishi 111
	struct tw_config_entry vhosts[MAX_VHOSTS];
18 nishi 112
	void* modules[MAX_MODULES];
113
	int module_count;
12 nishi 114
	int vhost_count;
128 nishi 115
	char* server_admin;
17 nishi 116
	char* server_root;
18 nishi 117
	char* extension;
6 nishi 118
};
119
 
120
void tw_config_init(void);
4 nishi 121
int tw_config_read(const char* path);
12 nishi 122
struct tw_config_entry* tw_vhost_match(const char* name, int port);
21 nishi 123
bool tw_permission_allowed(const char* path, SOCKADDR addr, struct tw_http_request req, struct tw_config_entry* vhost);
4 nishi 124
 
140 nishi 125
#ifdef __cplusplus
126
}
4 nishi 127
#endif
140 nishi 128
 
129
#endif