Subversion Repositories Tewi

Rev

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