2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c8/ws.c File Reference


Detailed Description

More-complete Web Server [Sec. 8.4.4 (not in book)].

Definition in file ws.c.

Go to the source code of this file.

Defines

#define WEB_ROOT   "/aup/webroot/"
#define NOTFOUND_PAGE   "/aup/notfound.htm"
#define HEADER_OK
#define CONTENT_TEXT   "Content-Type: text/html\r\n\r\n"
#define CONTENT_JPEG   "Content-Type: image/jpeg\r\n\r\n"
#define HEADER_NOTFOUND
#define HTML_NOTFOUND

Functions

void send_header_OK (SSI *ssip, off_t len, const char *path, int fd)
void send_header_notfound (SSI *ssip, const char *path, int fd)
bool handle_request (SSI *ssip, const char *s, int fd)
int main (int argc, char *argv[])


Define Documentation

#define CONTENT_JPEG   "Content-Type: image/jpeg\r\n\r\n"
 

Definition at line 39 of file ws.c.

#define CONTENT_TEXT   "Content-Type: text/html\r\n\r\n"
 

Definition at line 36 of file ws.c.

#define HEADER_NOTFOUND
 

Value:

"HTTP/1.1 404 Not Found\r\n"\
    "Server: AUP-ws\r\n"\
    "Transfer-Encoding: chunked\r\n"\
    "Content-Type: text/html\r\n\r\n"

Definition at line 42 of file ws.c.

Referenced by send_header_notfound().

#define HEADER_OK
 

Value:

"HTTP/1.1 200 OK\r\n"\
    "Server: AUP-ws\r\n"\
    "Content-Length: %ld\r\n"

Definition at line 31 of file ws.c.

Referenced by send_header_OK().

#define HTML_NOTFOUND
 

Value:

"<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"\
    "<html><head><title>Error 404</title>\n"\
    "</head><body>\n"\
    "<h2>AUP-ws server can't find page %s</h2>"\
    "</body></html>\r\n"

Definition at line 48 of file ws.c.

#define NOTFOUND_PAGE   "/aup/notfound.htm"
 

Definition at line 29 of file ws.c.

#define WEB_ROOT   "/aup/webroot/"
 

Definition at line 28 of file ws.c.


Function Documentation

bool handle_request SSI ssip,
const char *  s,
int  fd
[static]
 

Definition at line 99 of file ws.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, EC_FLUSH, ec_neg1, send_header_notfound(), send_header_OK(), stat::st_mode, stat::st_size, stat(), WEB_ROOT, and writeall().

Referenced by main().

int main int  argc,
char *  argv[]
 

Definition at line 145 of file ws.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, ec_false, ec_neg1, ec_null, errno, exit(), gethostname(), handle_request(), read(), ssi_close(), ssi_open(), ssi_wait_server(), and syserr_print().

void send_header_notfound SSI ssip,
const char *  path,
int  fd
[static]
 

Definition at line 83 of file ws.c.

References EC_CLEANUP_BGN, EC_CLEANUP_END, EC_FLUSH, ec_neg1, HEADER_NOTFOUND, HTML_NOTFOUND, and writeall().

Referenced by handle_request().

void send_header_OK SSI ssip,
off_t  len,
const char *  path,
int  fd
[static]
 

Definition at line 56 of file ws.c.

References CONTENT_JPEG, CONTENT_TEXT, ctime(), EC_CLEANUP_BGN, EC_CLEANUP_END, EC_FLUSH, ec_neg1, HEADER_OK, time(), and writeall().

Referenced by handle_request().


Generated on Fri Apr 23 10:57:10 2004 for AUP2 Example Source by doxygen 1.3.1