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

Last change on this file since 159 was 156, checked in by Nishi, on Sep 25, 2024 at 9:28:10 PM

release 1.07

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