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

Last change on this file since 328 was 328, checked in by Nishi, on Oct 15, 2024 at 2:54:06 AM

trying to add nextstep support

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