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

Last change on this file since 348 was 347, checked in by Nishi, on Oct 16, 2024 at 1:33:28 AM

does not really work

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