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