/*
* Web.h was made because some webmasters don't know the first thing
* about code. So I saw it as a chance to dip my quill into a little
* more coding.
*
* What this is for is use with 'show_web_file' in websvr.c, it will
* do about the exact same as 'show_file' but for the WWW. What this
* will do is show HTML files from a directory rather from code.
*
* The file types go like this:
*
* *.ti These are files that are just one solid page with no code
* before or after it. Such as an index page or error page.
*
* *.tih This will be a header (Telnet Interface Header), that will
* start out a HTML file with tags or what not, before the code.
* Placing graphics for headers is not uncommon and leave a nice touch.
*
* *.tif This will be a footer (Telnet Interface Footer), it will clean
* up the mess made by the code, and finish the HTML, providing links
* and so on and so forth. This is your interface, be creative :)
*
* This should make those rudy poo webmasters happy, somewhat :)
* Just explain that they will have to account for the middle of the html
* to be code generated and to format accordingly before and after.
*
* -- Christopher Aaron Haslage (Yakkov) 6/3/99 (No Help)
***************************************************************************
* 1stMUD ROM Derivative (c) 2001-2003 by Ryan Jennings *
* http://1stmud.dlmud.com/ <r-jenn@shaw.ca> *
***************************************************************************/
/* Modded for 1stMUD by Markanth 14/05/2003 */
#if !defined(WEBSERVER_H)
#define WEBSERVER_H
#if !defined(NO_WEB)
#define DOCTYPE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
/*
* Added: 21 April 2001 (Trax)
* Moved to a .h file as some of this info is gonna be useful elsewhere
* (and I don't like bloating merc.h/mud.h, its bad enough as it is)
*
* Define various places where web pages will reside for the server to serve
* as well as any other misc files req.
*/
#define AUTH_DOMAIN "Staff Area - Username and Password are CASE SENSITIVE." /* Secure Area Description */
#define MAXDATA MAX_STRING_LENGTH
#define DEFAULT_URL "http://%s:%d/"
#define TELNET_URL "telnet://%s:%d/"
#define WEBSERVERPORT (port + 5) // port the web server will run on
/* HTTP Basic Auth req. Base64 encoded/decode */
PROTOTYPE(void Base64Decode, (char *, unsigned char *, int));
typedef struct web_descriptor WEB_DESCRIPTOR;
struct web_descriptor
{
WEB_DESCRIPTOR *next;
WEB_DESCRIPTOR *prev;
int fd;
char request[MAXDATA];
struct sockaddr_in their_addr;
bool valid;
bool keepalive;
};
typedef bool WEB_FUN(WEB_DESCRIPTOR * wdesc, char *path, const char *stuff);
#define HANDLE_URL(fun) bool fun (WEB_DESCRIPTOR *wdesc, char *path, const char *stuff)
struct request_type
{
char *req;
char *name;
WEB_FUN *fun;
bool secure;
};
EXTERN const struct request_type request_table[];
/* FUNCTION DEFS */
PROTOTYPEF(int send_buf, (int, const char *, ...), 2, 3);
PROTOTYPE(void handle_web_request, (WEB_DESCRIPTOR *));
PROTOTYPE(bool init_web_server, (void));
PROTOTYPE(void update_web_server, (void));
PROTOTYPE(void shutdown_web_server, (void));
#endif
#endif