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