Subversion Repositories Tewi

Rev

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