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/miniws.c File Reference


Detailed Description

Mini Web Server [Sec. 8.4.4].

Definition in file miniws.c.

Go to the source code of this file.

Defines

#define HEADER
#define CONTENT_TEXT   "Content-Type: text/html\r\n\r\n"
#define CONTENT_JPEG   "Content-Type: image/jpeg\r\n\r\n"
#define HTML_NOTFOUND
#define DEFAULT_DOC   "index.html"
#define WEB_ROOT   "/aup/webroot/"
#define PORT   ":8000"

Functions

void send_header (SSI *ssip, const char *msg, off_t len, const char *path, int fd)
bool handle_request (SSI *ssip, char *s, int fd)
int main (void)


Define Documentation

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

Definition at line 34 of file miniws.c.

Referenced by send_header(), and send_header_OK().

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

Definition at line 31 of file miniws.c.

Referenced by send_header(), and send_header_OK().

#define DEFAULT_DOC   "index.html"
 

Definition at line 64 of file miniws.c.

Referenced by handle_request().

#define HEADER
 

Value:

"HTTP/1.0 %s\r\n"\
    "Server: AUP-ws\r\n"\
    "Content-Length: %ld\r\n"

Definition at line 26 of file miniws.c.

Referenced by send_header().

#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 document</h2>"\
    "</body></html>\r\n"

Definition at line 37 of file miniws.c.

Referenced by handle_request(), and send_header_notfound().

#define PORT   ":8000"
 

Definition at line 114 of file miniws.c.

Referenced by main().

#define WEB_ROOT   "/aup/webroot/"
 

Definition at line 65 of file miniws.c.

Referenced by handle_request().


Function Documentation

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

Definition at line 67 of file miniws.c.

References DEFAULT_DOC, EC_CLEANUP_BGN, EC_CLEANUP_END, ec_eof, EC_FLUSH, ec_neg1, HTML_NOTFOUND, send_header(), stat::st_mode, stat::st_size, stat(), WEB_ROOT, and writeall().

int main void   ) 
 

Definition at line 116 of file miniws.c.

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

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

Definition at line 44 of file miniws.c.

References CONTENT_JPEG, CONTENT_TEXT, EC_CLEANUP_BGN, EC_CLEANUP_END, EC_FLUSH, ec_neg1, HEADER, and writeall().

Referenced by handle_request().


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