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