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