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