1stMUD/corefiles/
1stMUD/gods/
1stMUD/notes/
1stMUD/player/
1stMUD/win32/
1stMUD/win32/ROM/
/*	
 *	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)
 */
#if !defined(WIN32)
#include <arpa/inet.h>
#else
#include "../win32/winstuff.h"
#endif

#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 SECURE_URL      "staffarea"	/* The secure URL. http://mud.is.here:<port>/SECURE_URL */

#define AUTH_DOMAIN     "Staff Area - Username and Password are CASE SENSITIVE."	/* Secure Area Description (tell me where this is used) */
#define MAXDATA         1024

#define DEFAULT_URL     "http://localhost/"	// CHANGE THIS TO YOUR SERVER ADDRESS
											// Important that it has a trailing '/'
#define WEBSERVERPORT   (port + 5)	// port the web server will run on

#define MUD_NAME        "1stMUD"	// You mud's name here

extern bool WebUP;
extern int port;

/* HTTP Basic Auth req. Base64 encoded/decode */
void Base64Decode(char *bufcoded, unsigned char *bufplain, int outbufsize);

typedef struct web_descriptor WEB_DESCRIPTOR;

struct web_descriptor
{
	WEB_DESCRIPTOR *next;
	WEB_DESCRIPTOR *prev;
	int fd;
	char request[MAXDATA * 2];
	struct sockaddr_in their_addr;
	unsigned int sin_size;
	bool valid;
	bool keepalive;
};

/* FUNCTION DEFS */
int send_buf(int fd, const char *fmt, ...)
	__attribute__ ((format(printf, 2, 3)));
void handle_web_request(WEB_DESCRIPTOR * wdesc);

bool init_web_server(void);
void update_web_server(void);
void shutdown_web_server(void);