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

Last change on this file since 33 was 33, checked in by Nishi, on Sep 16, 2024 at 9:52:47 PM

can show readme on index now

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/* $Id: tw_config.h 33 2024-09-16 12:52:47Z 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#define MAX_README 8
32
33enum TW_DIR_TYPE {
34 TW_DIR_ALLOW = 0,
35 TW_DIR_DENY
36};
37
38struct tw_dir_entry {
39 char* name;
40 char* dir;
41 int type;
42};
43
44struct tw_mime_entry {
45 char* ext;
46 char* mime;
47};
48
49struct tw_icon_entry {
50 char* mime;
51 char* icon;
52};
53
54struct tw_config_entry {
55 char* name;
56 int port;
57 char* sslkey;
58 char* sslcert;
59 char* root;
60 struct tw_dir_entry dirs[MAX_DIRS];
61 int dir_count;
62 struct tw_mime_entry mimes[MAX_DIRS];
63 int mime_count;
64 struct tw_icon_entry icons[MAX_DIRS];
65 int icon_count;
66 char* indexes[MAX_INDEX];
67 int index_count;
68 char* readmes[MAX_README];
69 int readme_count;
70};
71
72struct tw_config {
73 uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
74 char hostname[1025];
75 struct tw_config_entry root;
76 struct tw_config_entry vhosts[MAX_VHOSTS];
77 void* modules[MAX_MODULES];
78 int module_count;
79 int vhost_count;
80 char* server_root;
81 char* extension;
82};
83
84void tw_config_init(void);
85int tw_config_read(const char* path);
86struct tw_config_entry* tw_vhost_match(const char* name, int port);
87bool tw_permission_allowed(const char* path, SOCKADDR addr, struct tw_http_request req, struct tw_config_entry* vhost);
88
89#endif
Note: See TracBrowser for help on using the repository browser.