source: Main/trunk/Server/tw_config.h@ 315

Last change on this file since 315 was 315, checked in by Nishi, on Oct 14, 2024 at 7:01:02 PM

wip

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