source: Main/trunk/Server/tw_config.h@ 213

Last change on this file since 213 was 212, checked in by Nishi, on Oct 3, 2024 at 2:44:55 AM

compiles on vc6

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