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

Last change on this file since 311 was 311, checked in by Nishi, on Oct 13, 2024 at 10:23:22 AM

attempting to add os/2

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