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

Last change on this file since 315 was 315, checked in by Nishi, on Oct 14, 2024 at 7:01:02 PM

wip

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