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