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

Last change on this file since 312 was 312, checked in by Nishi, on Oct 14, 2024 at 3:17:37 AM

works on os2

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