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

Last change on this file since 24 was 24, checked in by Nishi, on Sep 14, 2024 at 11:09:58 PM

redirects properly now

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