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