|
|
1.1 root 1: /* websrvr.h */
2:
3: /* Synchronet Web Server */
4:
5: /* $Id: websrvr.h,v 1.39 2006/09/15 21:12:53 rswindell Exp $ */
6:
7: /****************************************************************************
8: * @format.tab-size 4 (Plain Text/Source Code File Header) *
9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
10: * *
11: * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
12: * *
13: * This program is free software; you can redistribute it and/or *
14: * modify it under the terms of the GNU General Public License *
15: * as published by the Free Software Foundation; either version 2 *
16: * of the License, or (at your option) any later version. *
17: * See the GNU General Public License for more details: gpl.txt or *
18: * http://www.fsf.org/copyleft/gpl.html *
19: * *
20: * Anonymous FTP access to the most recent released source is available at *
21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
22: * *
23: * Anonymous CVS access to the development source and modification history *
24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
26: * (just hit return, no password is necessary) *
27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
28: * *
29: * For Synchronet coding style and modification guidelines, see *
30: * http://www.synchro.net/source.html *
31: * *
32: * You are encouraged to submit any modifications (preferably in Unix diff *
33: * format) via e-mail to [email protected] *
34: * *
35: * Note: If this box doesn't appear square, then you need to fix your tabs. *
36: ****************************************************************************/
37:
38: #ifndef _WEBSRVR_H_
39: #define _WEBSRVR_H_
40:
41: #include "client.h" /* client_t */
42: #include "startup.h" /* BBS_OPT_* */
43: #include "semwrap.h" /* sem_t */
44:
45: typedef struct {
46: DWORD size; /* sizeof(web_startup_t) */
47: WORD port;
48: WORD max_clients;
49: WORD max_inactivity;
50: WORD max_cgi_inactivity;
51: WORD sem_chk_freq; /* semaphore file checking frequency (in seconds) */
52: DWORD interface_addr;
53: DWORD options;
54:
55: void* cbdata; /* Private data passed to callbacks */
56:
57: /* Callbacks (NULL if unused) */
58: int (*lputs)(void*, int, char*);
59: void (*status)(void*, char*);
60: void (*started)(void*);
61: void (*recycle)(void*);
62: void (*terminated)(void*, int code);
63: void (*clients)(void*, int active);
64: void (*thread_up)(void*, BOOL up, BOOL setuid);
65: void (*socket_open)(void*, BOOL open);
66: void (*client_on)(void*, BOOL on, int sock, client_t*, BOOL update);
67: BOOL (*seteuid)(BOOL user);
68: BOOL (*setuid)(BOOL);
69:
70: /* Paths */
71: char ssjs_ext[16]; /* Server-Side JavaScript file extension */
72: char js_ext[16]; /* Embedded JavaScript file extension */
73: char** cgi_ext; /* CGI Extensions */
74: char cgi_dir[128]; /* relative to root_dir (all files executable) */
75: char ctrl_dir[128];
76: char root_dir[128]; /* HTML root directory */
77: char error_dir[128]; /* relative to root_dir */
78: char temp_dir[128];
79: char** index_file_name; /* Index filenames */
80: char logfile_base[128]; /* Logfile base name (date is appended) */
81: char answer_sound[128];
82: char hangup_sound[128];
83: char hack_sound[128];
84:
85: /* Misc */
86: char host_name[128];
87: BOOL recycle_now;
88: BOOL shutdown_now;
89: int log_level;
90: uint bind_retry_count; /* Number of times to retry bind() calls */
91: uint bind_retry_delay; /* Time to wait between each bind() retry */
92: char default_cgi_content[128];
93: WORD outbuf_highwater_mark; /* output block size control */
94: WORD outbuf_drain_timeout;
95:
96: /* JavaScript operating parameters */
97: js_startup_t js;
98:
99: } web_startup_t;
100:
101: #if defined(STARTUP_INIT_FIELD_TABLES)
102: /* startup options that requires re-initialization/recycle when changed */
103: static struct init_field web_init_fields[] = {
104: OFFSET_AND_SIZE(web_startup_t,port)
105: ,OFFSET_AND_SIZE(web_startup_t,interface_addr)
106: ,OFFSET_AND_SIZE(web_startup_t,ctrl_dir)
107: ,OFFSET_AND_SIZE(web_startup_t,root_dir)
108: ,OFFSET_AND_SIZE(web_startup_t,error_dir)
109: ,OFFSET_AND_SIZE(web_startup_t,cgi_dir)
110: ,OFFSET_AND_SIZE(web_startup_t,logfile_base)
111: ,{ 0,0 } /* terminator */
112: };
113: #endif
114:
115: #define WEB_OPT_DEBUG_RX (1<<0) /* Log all received requests */
116: #define WEB_OPT_DEBUG_TX (1<<1) /* Log all transmitted responses */
117: #define WEB_OPT_DEBUG_SSJS (1<<2) /* Don't delete sbbs_ssjs.*.html */
118: #define WEB_OPT_VIRTUAL_HOSTS (1<<4) /* Use virutal host html subdirs */
119: #define WEB_OPT_NO_CGI (1<<5) /* Disable CGI support */
120: #define WEB_OPT_HTTP_LOGGING (1<<6) /* Create/write-to HttpLogFile */
121:
122: /* web_startup_t.options bits that require re-init/recycle when changed */
123: #define WEB_INIT_OPTS (BBS_OPT_LOCAL_TIMEZONE|WEB_OPT_HTTP_LOGGING)
124:
125: #if defined(STARTUP_INI_BITDESC_TABLES)
126: static ini_bitdesc_t web_options[] = {
127:
128: { WEB_OPT_DEBUG_RX ,"DEBUG_RX" },
129: { WEB_OPT_DEBUG_TX ,"DEBUG_TX" },
130: { WEB_OPT_DEBUG_SSJS ,"DEBUG_SSJS" },
131: { WEB_OPT_VIRTUAL_HOSTS ,"VIRTUAL_HOSTS" },
132: { WEB_OPT_NO_CGI ,"NO_CGI" },
133: { WEB_OPT_HTTP_LOGGING ,"HTTP_LOGGING" },
134:
135: /* shared bits */
136: { BBS_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" },
137: { BBS_OPT_NO_RECYCLE ,"NO_RECYCLE" },
138: { BBS_OPT_GET_IDENT ,"GET_IDENT" },
139: { BBS_OPT_NO_JAVASCRIPT ,"NO_JAVASCRIPT" },
140: { BBS_OPT_LOCAL_TIMEZONE ,"LOCAL_TIMEZONE" },
141: { BBS_OPT_MUTE ,"MUTE" },
142:
143: /* terminator */
144: { 0 ,NULL }
145: };
146: #endif
147:
148: #define WEB_DEFAULT_ROOT_DIR "../web/root"
149: #define WEB_DEFAULT_ERROR_DIR "error"
150: #define WEB_DEFAULT_CGI_DIR "cgi-bin"
151: #define WEB_DEFAULT_CGI_CONTENT "text/plain"
152:
153: #ifdef DLLEXPORT
154: #undef DLLEXPORT
155: #endif
156: #ifdef DLLCALL
157: #undef DLLCALL
158: #endif
159:
160: #ifdef _WIN32
161: #ifdef WEBSRVR_EXPORTS
162: #define DLLEXPORT __declspec(dllexport)
163: #else
164: #define DLLEXPORT __declspec(dllimport)
165: #endif
166: #ifdef __BORLANDC__
167: #define DLLCALL __stdcall
168: #else
169: #define DLLCALL
170: #endif
171: #else
172: #define DLLEXPORT
173: #define DLLCALL
174: #endif
175:
176: #ifdef __cplusplus
177: extern "C" {
178: #endif
179: DLLEXPORT void DLLCALL web_server(void* arg);
180: DLLEXPORT void DLLCALL web_terminate(void);
181: DLLEXPORT const char* DLLCALL web_ver(void);
182: #ifdef __cplusplus
183: }
184: #endif
185:
186: #endif /* Don't add anything after this line */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.