Rev | Line | |
---|
[4] | 1 | /* $Id: tw_config.h 21 2024-09-14 12:39:39Z 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>
|
---|
| 16 | #endif
|
---|
[6] | 17 |
|
---|
[21] | 18 | #ifdef NO_IPV6
|
---|
| 19 | #define SOCKADDR struct sockaddr_in
|
---|
| 20 | #else
|
---|
| 21 | #define SOCKADDR struct sockaddr_in6
|
---|
| 22 | #endif
|
---|
| 23 |
|
---|
| 24 | #define MAX_PORTS 1024
|
---|
| 25 | #define MAX_VHOSTS 1024
|
---|
| 26 | #define MAX_MODULES 1024
|
---|
| 27 | #define MAX_DIRS 1024
|
---|
| 28 | #define MAX_MIME 1024
|
---|
| 29 |
|
---|
| 30 | enum TW_DIR_TYPE {
|
---|
| 31 | TW_DIR_ALLOW = 0,
|
---|
| 32 | TW_DIR_DENY
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | struct tw_dir_entry {
|
---|
| 36 | char* name;
|
---|
| 37 | char* dir;
|
---|
| 38 | int type;
|
---|
| 39 | };
|
---|
| 40 |
|
---|
| 41 | struct tw_mime_entry {
|
---|
| 42 | char* ext;
|
---|
| 43 | char* mime;
|
---|
| 44 | };
|
---|
| 45 |
|
---|
[12] | 46 | struct tw_config_entry {
|
---|
| 47 | char* name;
|
---|
| 48 | int port;
|
---|
| 49 | char* sslkey;
|
---|
| 50 | char* sslcert;
|
---|
[19] | 51 | char* root;
|
---|
[21] | 52 | struct tw_dir_entry dirs[MAX_DIRS];
|
---|
| 53 | int dir_count;
|
---|
| 54 | struct tw_mime_entry mimes[MAX_DIRS];
|
---|
| 55 | int mime_count;
|
---|
[12] | 56 | };
|
---|
| 57 |
|
---|
[6] | 58 | struct tw_config {
|
---|
[7] | 59 | uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */
|
---|
[12] | 60 | char hostname[1025];
|
---|
[6] | 61 | struct tw_config_entry root;
|
---|
[12] | 62 | struct tw_config_entry vhosts[MAX_VHOSTS];
|
---|
[18] | 63 | void* modules[MAX_MODULES];
|
---|
| 64 | int module_count;
|
---|
[12] | 65 | int vhost_count;
|
---|
[17] | 66 | char* server_root;
|
---|
[18] | 67 | char* extension;
|
---|
[6] | 68 | };
|
---|
| 69 |
|
---|
| 70 | void tw_config_init(void);
|
---|
[4] | 71 | int tw_config_read(const char* path);
|
---|
[12] | 72 | struct tw_config_entry* tw_vhost_match(const char* name, int port);
|
---|
[21] | 73 | bool tw_permission_allowed(const char* path, SOCKADDR addr, struct tw_http_request req, struct tw_config_entry* vhost);
|
---|
[4] | 74 |
|
---|
| 75 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.