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

Last change on this file since 140 was 140, checked in by Nishi, on Sep 23, 2024 at 8:31:18 PM

adding cplusplus thing

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