diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-07 10:51:17 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-04-07 10:51:17 +0000 |
commit | efccb9b98f848247a659e1115f9f94cf1a43f35d (patch) | |
tree | b7c89de36a8fab99f284b5d29c1f80c136b3ecb2 /apps/JAWS/server | |
parent | 74d53a81e16bd718f059d83d7457b5558ed59125 (diff) | |
download | ATCD-efccb9b98f848247a659e1115f9f94cf1a43f35d.tar.gz |
*** empty log message ***
Diffstat (limited to 'apps/JAWS/server')
-rw-r--r-- | apps/JAWS/server/HTTP_Handler.cpp | 275 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Handler.h | 211 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Helpers.cpp | 64 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Helpers.h | 47 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Request.cpp | 222 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Request.h | 59 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Server.cpp | 259 | ||||
-rw-r--r-- | apps/JAWS/server/HTTP_Server.h | 150 | ||||
-rw-r--r-- | apps/JAWS/server/IO.cpp | 357 | ||||
-rw-r--r-- | apps/JAWS/server/IO.h | 107 | ||||
-rw-r--r-- | apps/JAWS/server/JXH_List.h | 132 | ||||
-rw-r--r-- | apps/JAWS/server/JXH_String.h | 44 | ||||
-rw-r--r-- | apps/JAWS/server/Makefile | 219 | ||||
-rw-r--r-- | apps/JAWS/server/VFS.cpp | 364 | ||||
-rw-r--r-- | apps/JAWS/server/VFS.h | 119 | ||||
-rw-r--r-- | apps/JAWS/server/jaws.mak | 972 | ||||
-rw-r--r-- | apps/JAWS/server/jaws.mdp | bin | 0 -> 50176 bytes | |||
-rw-r--r-- | apps/JAWS/server/main.cpp | 21 | ||||
-rw-r--r-- | apps/JAWS/server/svc.conf | 10 | ||||
-rw-r--r-- | apps/JAWS/server/test_HTTP_Request.cpp | 52 |
20 files changed, 3684 insertions, 0 deletions
diff --git a/apps/JAWS/server/HTTP_Handler.cpp b/apps/JAWS/server/HTTP_Handler.cpp new file mode 100644 index 00000000000..907ff5aec9f --- /dev/null +++ b/apps/JAWS/server/HTTP_Handler.cpp @@ -0,0 +1,275 @@ +// HTTP_Service.cpp -- simple implementation of the HTTP protocol + +#include "ace/Message_Block.h" + +#include "JAWS/server/HTTP_Handler.h" +#include "JAWS/server/HTTP_Helpers.h" +#include "JAWS/server/IO.h" + +HTTP_Handler::HTTP_Handler (JAWS_IO &io, + HTTP_Handler_Factory &factory) + : io_ (io), + handle_ (ACE_INVALID_HANDLE), + request_data_ (0), + factory_ (factory) +{ + this->io_.handler (this); +} + +HTTP_Handler::~HTTP_Handler (void) +{ + this->request_data_->release (); + this->request_data_ = 0; +} + +void +HTTP_Handler::open (ACE_HANDLE handle, + ACE_Message_Block &initial_data) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) New connection \n")); + + this->handle_ = handle; + this->io_.handle (this->handle_); + + this->request_data_ = initial_data.duplicate (); + this->client_data (initial_data); +} + +void +HTTP_Handler::client_data (ACE_Message_Block &message_block) +{ + message_block.rd_ptr ()[message_block.length ()] = '\0'; + + if (this->enough_data ()) + { + this->parse_request (); + return; + } + + int next_read_size = HTTP_Handler::MAX_REQUEST_SIZE - this->request_data_->length (); + if (next_read_size == 0) + { + this->request_too_long (); + return; + } + + this->io_.read (*this->request_data_, next_read_size); +} + +int +HTTP_Handler::enough_data (void) +{ + char *data = this->request_data_->rd_ptr (); + if (ACE_OS::strstr (data, "\r\n\r\n") != NULL || + ACE_OS::strstr (data, "\n\n") != NULL) + return 1; + else + return 0; +} + +void +HTTP_Handler::parse_request (void) +{ + request_.init (request_data_->rd_ptr (), request_data_->length ()); + + if (request_.status () != HTTP_Request::OK) + this->invalid_request (HTTP_Status_Code::STATUS_BAD_REQUEST); + else + { + switch (request_.type ()) + { + case HTTP_Request::GET : + this->io_.transmit_file (request_.filename (), "\r\n\r\n", 2); + break; + + case HTTP_Request::PUT : + this->io_.receive_file (request_.filename (), + request_.data (), + request_.data_length (), + request_.content_length ()); + break; + + default : + this->invalid_request (HTTP_Status_Code::STATUS_NOT_IMPLEMENTED); + } + } +} + +void +HTTP_Handler::serve_error (int status_code) +{ + static char const errormessage[] = + "HTTP/1.0 %d %s\r\n" + "Content-type: text/html\r\n" + "\r\n" + "<html>\n" + "<head><title>Error message</title></head>\n" + "<body>\n" + "<h1>Error %d: %s</h1>" + "Could not access file: %s.\n" + "</body>\n" + "</html>\n" + ; + + char buffer[2 * MAXPATHLEN]; + int length = sprintf (buffer, + errormessage, + status_code, HTTP_Status_Code::instance()[status_code], + status_code, HTTP_Status_Code::instance()[status_code], + request_.filename ()); + + this->io_.send_error_message (buffer, length); +} + +void +HTTP_Handler::serve_directory (void) +{ + // We'll just forbid it for now. + this->serve_error(403); +} + +void +HTTP_Handler::receive_file_complete (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s received successfully\n", request_.filename ())); + char buffer[BUFSIZ]; + ACE_OS::sprintf (buffer, + "%s %d %s", + "HTTP/1.0", + HTTP_Status_Code::STATUS_OK, + "Successful"); + this->io_.send_confirmation_message (buffer, ACE_OS::strlen (buffer)); +} + +void +HTTP_Handler::receive_file_error (int result) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s error in receiving file\n", request_.filename ())); + char buffer[BUFSIZ]; + ACE_OS::sprintf (buffer, + "%s %d %s", + "HTTP/1.0", + result, + "Failed"); + this->io_.send_confirmation_message (buffer, ACE_OS::strlen (buffer)); +} + +void +HTTP_Handler::confirmation_message_complete (void) +{ + this->done (); +} + +void +HTTP_Handler::error_message_complete (void) +{ + this->done (); +} + +void +HTTP_Handler::transmit_file_complete (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s transmitted successfully\n", request_.filename ())); + this->done (); +} + +void +HTTP_Handler::transmit_file_error (int result) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s error in transmitting file\n", request_.filename ())); + this->serve_error (result); +} + +void +HTTP_Handler::read_error (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) error in reading request\n")); + this->done (); +} + +void +HTTP_Handler::write_error (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s error in writing response\n", request_.filename ())); + this->done (); +} + +void +HTTP_Handler::timeout (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) %s error in reading request\n", request_.filename ())); + this->serve_error (HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR); +} + +void +HTTP_Handler::request_too_long (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) request too long\n")); + this->serve_error (HTTP_Status_Code::STATUS_BAD_REQUEST); +} + +void +HTTP_Handler::invalid_request (int error) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) invalid request\n")); + this->serve_error (error); +} + +void +HTTP_Handler::done (void) +{ + this->factory_.destroy_http_handler (*this, this->io_); +} + +HTTP_Handler_Factory::~HTTP_Handler_Factory (void) +{ +} + +HTTP_Handler * +Synch_HTTP_Handler_Factory::create_http_handler (void) +{ + JAWS_Synch_IO *io; + ACE_NEW_RETURN (io, JAWS_Synch_IO, 0); + HTTP_Handler *handler; + ACE_NEW_RETURN (handler, HTTP_Handler (*io, *this), 0); + return handler; +} + +void +Synch_HTTP_Handler_Factory::destroy_http_handler (HTTP_Handler &handler, + JAWS_IO &io) +{ + delete &handler; + delete &io; +} + + +// This only works on Win32 +#if defined (ACE_WIN32) +void +Asynch_HTTP_Handler_Factory::open (ACE_HANDLE handle, + ACE_Message_Block &mb) +{ + JAWS_Asynch_IO *io; + ACE_NEW (io, JAWS_Asynch_IO); + HTTP_Handler *handler; + ACE_NEW (handler, HTTP_Handler (*io, *this)); + handler->open (handle, mb); +} + +void +Asynch_HTTP_Handler_Factory::destroy_http_handler (HTTP_Handler &handler, + JAWS_IO &io) +{ + delete &handler; + delete &io; + delete this; +} + +HTTP_Handler * +Asynch_HTTP_Handler_Factory::create_http_handler (void) +{ + return 0; +} + +#endif /* ACE_WIN32 */ diff --git a/apps/JAWS/server/HTTP_Handler.h b/apps/JAWS/server/HTTP_Handler.h new file mode 100644 index 00000000000..a6327a5a346 --- /dev/null +++ b/apps/JAWS/server/HTTP_Handler.h @@ -0,0 +1,211 @@ +#if !defined (HTTP_HANDLER_H) +#define HTTP_HANDLER_H + +// Forward declarations +class JAWS_IO; +class Message_Block; +class HTTP_Handler_Factory; + +#include "ace/Asynch_IO.h" +#include "JAWS/server/HTTP_Request.h" + +class HTTP_Handler + // + // = TITLE + // + // This class is used to implement the HTTP protocol + // + // = DESCRIPTION + // + // The HTTP_Handler class is a state based implementation of the + // HTTP protocol. Therefore, it can be used synchronously and + // asynchronously. It uses an abstract IO class to move between + // different HTTP protocol states. It is up to the IO class to + // decide on synchronous or asynchronous I/O. + +{ + // Friend I/O classes. Can call protected methods. + friend class JAWS_Synch_IO; + friend class JAWS_Asynch_IO; + + // Factories + friend class Asynch_HTTP_Handler_Factory; + friend class Synch_HTTP_Handler_Factory; + +public: + virtual void open (ACE_HANDLE handle, + ACE_Message_Block &initial_data); + // The handler is initialized with a connection <handle> of a new + // client and any <initial_data> that came across. The + // <initial_data> block will be of MAX_REQUEST_SIZE and the number + // of bytes in <initial_data> can be found from + // <initial_data>.length () + +protected: + HTTP_Handler (JAWS_IO &io, + HTTP_Handler_Factory &factory); + // The constructor is passed the factory that created <this> and the + // IO mechanism that the handler should use. + + ~HTTP_Handler (void); + // Destructor + + virtual void done (void); + // This is the termination state of the handler. After successful or + // unsuccessful completions, the handler will end up in this state + // (method). + + virtual void client_data (ACE_Message_Block &data); + // This method is called by the IO class when new client data shows + // up. + + virtual void read_error (void); + // This method is called by the IO class when there was an error in + // reading new data from the client. + + virtual void transmit_file_complete (void); + // This method is called by the IO class when the requested file has + // been successfully transmitted to the client. + + virtual void transmit_file_error (int result); + // This method is called by the IO class when there was an error in + // transmitting the requested file to the client. + + virtual void receive_file_complete (void); + // This method is called by the IO class when the requested file has + // been successfully received from the client. + + virtual void receive_file_error (int result); + // This method is called by the IO class when there was an error in + // receiving the requested file from the client. + + virtual void write_error (void); + // This method is called by the IO class when there was an error in + // writing data to the client. + + virtual void timeout (void); + // This method is called by the framework when there is a timeout. + + virtual int enough_data (void); + // Has the header of the client request been read yet? + + virtual void confirmation_message_complete (void); + // This method is called by the IO class when the confirmation + // message has been delivered to the client. + + virtual void error_message_complete (void); + // This method is called by the IO class when the error message has + // been delivered to the client. + + virtual void parse_request (void); + // Parse the client request + + virtual void invalid_request (int result); + // Invalid request. + + virtual void request_too_long (void); + // Request too long. + + virtual void serve_error (int status_code); + // Send the <status_code> error to the client. + + virtual void serve_directory (void); + // The client has asked for a directory listing. + + HTTP_Handler_Factory &factory_; + // Reference to the creating factory. + +public: + enum + { + MAX_REQUEST_SIZE = 1024, + METHODSIZ = 10, + VERSIONSIZ = 10 + }; + +private: + ACE_Message_Block *request_data_; + // This points to the request sent by the client + + ACE_HANDLE handle_; + // I/O handle to the client + + HTTP_Request request_; + + JAWS_IO &io_; + // IO class used by the handler +}; + +class HTTP_Handler_Factory + // + // = TITLE + // + // This class is used to create new HTTP handlers + // + // = DESCRIPTION + // + // This is an abstract factory for creating new HTTP handlers +{ +public: + virtual ~HTTP_Handler_Factory (void); + // Destructor + + virtual HTTP_Handler *create_http_handler (void) = 0; + // This creates a new HTTP_Handler + + virtual void destroy_http_handler (HTTP_Handler &handler, + JAWS_IO &io) = 0; + // The HTTP handler will call this method from HTTP_Handler::done to + // tell the factory to reap up the handler as it is now done with + // the protocol +}; + +class Synch_HTTP_Handler_Factory : public HTTP_Handler_Factory + // + // = TITLE + // + // This class is used to create new HTTP handlers that will use + // Synch IO + // + // = DESCRIPTION + // +{ +public: + HTTP_Handler *create_http_handler (void); + // This creates a new HTTP_Handler + + void destroy_http_handler (HTTP_Handler &handler, + JAWS_IO &io); + // The HTTP handler will call this method from HTTP_Handler::done to + // tell the factory to reap up the handler as it is now done with + // the protocol +}; + +// This only works on Win32 +#if defined (ACE_WIN32) +class Asynch_HTTP_Handler_Factory : public HTTP_Handler_Factory, public ACE_Service_Handler +{ +public: + void destroy_http_handler (HTTP_Handler &handler, + JAWS_IO &io); + // The HTTP handler will call this method from HTTP_Handler::done to + // tell the factory to reap up the handler as it is now done with + // the protocol + + void open (ACE_HANDLE handle, + ACE_Message_Block &message_block); + // <open> is called by ACE_Asynch_Acceptor to initialize a new + // instance of ACE_Service_Handler that has been created after the a + // new connection is accepted. + // + // This will act as a creation point for new handlers + +private: + HTTP_Handler *create_http_handler (void); + // This method is private as users are not allowed to create new + // handlers. New handlers can only be created by the framework when + // new client connections arrive. +}; +#endif /* ACE_WIN32 */ + +#endif /* HTTP_HANDLER_H */ diff --git a/apps/JAWS/server/HTTP_Helpers.cpp b/apps/JAWS/server/HTTP_Helpers.cpp new file mode 100644 index 00000000000..53f871b4701 --- /dev/null +++ b/apps/JAWS/server/HTTP_Helpers.cpp @@ -0,0 +1,64 @@ +// HTTP_Helpers.cpp -- Helper utilities for both server and client + +#include "JAWS/server/HTTP_Helpers.h" + +ACE_Thread_Mutex HTTP_Status_Code::lock_; +int HTTP_Status_Code::instance_ = 0; +const char * HTTP_Status_Code::Reason[HTTP_Status_Code::MAX_STATUS_CODE+1]; + +char const * const * const +HTTP_Status_Code::instance (void) +{ + if (HTTP_Status_Code::instance_ == 0) + { + ACE_Guard<ACE_Thread_Mutex> g(lock_); + + if (HTTP_Status_Code::instance_ == 0) + { + for (int i = 0; i < HTTP_Status_Code::MAX_STATUS_CODE+1; i++) + { + switch (i) + { + case STATUS_OK: + HTTP_Status_Code::Reason[i] = "OK"; break; + case STATUS_CREATED: + HTTP_Status_Code::Reason[i] = "Created"; break; + case STATUS_ACCEPTED: + HTTP_Status_Code::Reason[i] = "Accepted"; break; + case STATUS_NO_CONTENT: + HTTP_Status_Code::Reason[i] = "No Content"; break; + case STATUS_MOVED_PERMANENTLY: + HTTP_Status_Code::Reason[i] = "Moved Permanently"; break; + case STATUS_MOVED_TEMPORARILY: + HTTP_Status_Code::Reason[i] = "Moved Temporarily"; break; + case STATUS_NOT_MODIFIED: + HTTP_Status_Code::Reason[i] = "Not Modified"; break; + case STATUS_BAD_REQUEST: + HTTP_Status_Code::Reason[i] = "Bad Request"; break; + case STATUS_UNAUTHORIZED: + HTTP_Status_Code::Reason[i] = "Unauthorized"; break; + case STATUS_FORBIDDEN: + HTTP_Status_Code::Reason[i] = "Forbidden"; break; + case STATUS_NOT_FOUND: + HTTP_Status_Code::Reason[i] = "Not Found"; break; + case STATUS_INTERNAL_SERVER_ERROR: + HTTP_Status_Code::Reason[i] = "Internal Server Error"; break; + case STATUS_NOT_IMPLEMENTED: + HTTP_Status_Code::Reason[i] = "Not Implemented"; break; + case STATUS_BAD_GATEWAY: + HTTP_Status_Code::Reason[i] = "Bad Gateway"; break; + case STATUS_SERVICE_UNAVAILABLE: + HTTP_Status_Code::Reason[i] = "Service Unavailable"; break; + default: + HTTP_Status_Code::Reason[i] = "Unknown"; + } + } + + HTTP_Status_Code::instance_ = 1; + } + + // GUARD released + } + + return HTTP_Status_Code::Reason; +} diff --git a/apps/JAWS/server/HTTP_Helpers.h b/apps/JAWS/server/HTTP_Helpers.h new file mode 100644 index 00000000000..389eaf079d0 --- /dev/null +++ b/apps/JAWS/server/HTTP_Helpers.h @@ -0,0 +1,47 @@ +// HTTP_Helpers.h + +// Design around the Singleton pattern +// Simplify interface to HTTP_types: +// -> type(path) returns the type of the path matched by extension. +// -> app(path) returns the app for the path matched by extension. + +#if !defined (HTTP_HELPERS_H) +#define HTTP_HELPERS_H + +#include "ace/Synch.h" + +class HTTP_Status_Code +{ +public: + static char const * const * const instance(void); + + enum STATUS_CODE { + STATUS_OK = 200, + STATUS_CREATED = 201, + STATUS_ACCEPTED = 202, + STATUS_NO_CONTENT = 204, + STATUS_MOVED_PERMANENTLY = 301, + STATUS_MOVED_TEMPORARILY = 302, + STATUS_NOT_MODIFIED = 304, + STATUS_BAD_REQUEST = 400, + STATUS_UNAUTHORIZED = 401, + STATUS_FORBIDDEN = 403, + STATUS_NOT_FOUND = 404, + STATUS_INTERNAL_SERVER_ERROR = 500, + STATUS_NOT_IMPLEMENTED = 501, + STATUS_BAD_GATEWAY = 502, + STATUS_SERVICE_UNAVAILABLE = 503, + STATUS_INSUFFICIENT_DATA = 399 + }; + + enum {MAX_STATUS_CODE=599}; + +private: + static const char * Reason[MAX_STATUS_CODE+1]; + static int instance_; + static ACE_Thread_Mutex lock_; + +}; + +#endif /* HTTP_HELPERS_H */ + diff --git a/apps/JAWS/server/HTTP_Request.cpp b/apps/JAWS/server/HTTP_Request.cpp new file mode 100644 index 00000000000..f165485dae5 --- /dev/null +++ b/apps/JAWS/server/HTTP_Request.cpp @@ -0,0 +1,222 @@ +#include "JAWS/server/HTTP_Request.h" + +// for reasons of efficiency, this class expects buffer to be null-terminated, +// and buflen does NOT include the \0 +HTTP_Request::HTTP_Request (void) +{ +} + +void +HTTP_Request::init (const char *buffer, int buflen) +{ + // Initialize these every time. + content_length_ = 0; + filename_ = "no filename"; + status_ = OK; + type_ = NO_TYPE; + + // Extract the data pointer. + data_ = NULL; + datalen_ = 0; + + if ((data_ = ACE_OS::strstr (buffer,"\r\n\r\n")) != NULL) + data_ += 4; + else if ((data_ = ACE_OS::strstr (buffer, "\n\n")) != NULL) + data_ += 2; + else + // Keep going even without a header? + status_ = NO_HEADER; + + // set the datalen + if (data_ != NULL) + datalen_ = (buffer + buflen) - data_; + else + datalen_ = 0; + + char *lasts; // for strtok_r + + // Get the request type. + char *token = ACE_OS::strtok_r ((char *) buffer, " \t", &lasts); + + // Delegate according to the request type. + if (ACE_OS::strcmp (token, "PUT") == 0) + this->parse_PUT (lasts); + else if (ACE_OS::strcmp (token, "GET") == 0) + this->parse_GET (lasts); + else + { + status_ = NO_FILENAME; + return; + } +} + +static void +HTTP_fix_path (char *path) +{ + // fix the path if it needs fixing/is fixable + + // replace the percentcodes with the actual character + int i,j; + char percentcode[3]; + + for (i = j = 0; path[i] != '\0'; i++,j++) { + if (path[i] == '%') { + percentcode[0] = path[++i]; + percentcode[1] = path[++i]; + percentcode[2] = '\0'; + path[j] = ACE_OS::strtol(percentcode, (char **)0, 16); + } + else path[j] = path[i]; + } + path[j] = path[i]; +} + +void +HTTP_Request::parse_GET (char *lasts) +{ + type_ = GET; + + // next look for filename + filename_ = ACE_OS::strtok_r (NULL, " \t", &lasts); + if (filename_ == NULL) + { + status_ = NO_FILENAME; + return; + } + + HTTP_fix_path (filename_); + + // Ok, I'm punting here, screw the rest of the request. I've got + // what I want. +} + +void +HTTP_Request::parse_PUT (char *lasts) +{ + type_ = PUT; + + // next look for filename + filename_ = ACE_OS::strtok_r (NULL, " \t", &lasts); + if (filename_ == NULL) + { + status_ = NO_FILENAME; + return; + } + + HTTP_fix_path (filename_); + + // now loop, looking for Content-length: + + char *token = ACE_OS::strtok_r (NULL, "\n\r:", &lasts); + while (token) + { + if (ACE_OS::strcmp (token, "Content-length") == 0) + { + token = ACE_OS::strtok_r (NULL, " \t\r\n", &lasts); + content_length_ = ACE_OS::atoi (token); + break; + } + token = ACE_OS::strtok_r (NULL, "\n\r:", &lasts); + } + + if (content_length_ == 0) + { + status_ = NO_CONTENT_LENGTH; + return; + } +} + +u_long +HTTP_Request::type (void) +{ + return type_; +} + +char * +HTTP_Request::data (void) +{ + return data_; +} + +int +HTTP_Request::data_length (void) +{ + return datalen_; +} + +char * +HTTP_Request::filename (void) +{ + return filename_; +} + +int +HTTP_Request::content_length (void) +{ + return content_length_; +} + +int +HTTP_Request::status (void) +{ + return status_; +} + +char * +HTTP_Request::status_string (void) +{ + switch (status_) + { + case OK: + return "All is well"; + case NO_CONTENT_LENGTH: + return "Content-length: field missing in the header"; + case NO_FILENAME: + return "Filename missing in the header"; + case NO_HEADER: + default: + return "No header"; + } +} + +void +HTTP_Request::dump (void) +{ + switch (this->type ()) + { + case GET : + ACE_DEBUG ((LM_DEBUG, "GET command.\n" + "filename is %s," + " length of the file is %d," + " data string is %s," + " datalen is %d," + " status is %d, which is %s\n\n", + this->filename() ? this->filename() : "EMPTY", + this->content_length(), + this->data() ? this->data() : "EMPTY", + this->data_length(), + this->status(), + this->status_string())); + break; + + case PUT : + ACE_DEBUG ((LM_DEBUG, "PUT command.\n" + "filename is %s," + " length of the file is %d," + " data string is %s," + " datalen is %d," + " status is %d, which is %s\n\n", + this->filename() ? this->filename() : "EMPTY", + this->content_length(), + this->data() ? this->data() : "EMPTY", + this->data_length(), + this->status(), + this->status_string())); + break; + + case NO_TYPE : + default: + break; + } +} + diff --git a/apps/JAWS/server/HTTP_Request.h b/apps/JAWS/server/HTTP_Request.h new file mode 100644 index 00000000000..b5fe6a39645 --- /dev/null +++ b/apps/JAWS/server/HTTP_Request.h @@ -0,0 +1,59 @@ +#if !defined (HTTP_REQUEST_H) +#define HTTP_REQUEST_H + +#include "ace/OS.h" + +class HTTP_Request +{ +public: + HTTP_Request (void); + // Default construction. + + void init (const char *buffer, int buflen); + // Initialize the request object with the buffer. This will parse + // the buffer and prepare for the accessors. + + u_long type (void); + // GET or PUT. + + char *data (void); + + int data_length (void); + + int content_length (void); + + char *filename (void); + + int status (void); + + char *status_string (void); + + void dump (void); + // Dump the state of the request. + + enum + { + OK = 1, + NO_FILENAME, + NO_CONTENT_LENGTH, + NO_HEADER, + // ************** + NO_TYPE, + GET, + PUT + }; + +protected: + void parse_GET (char *lasts); + void parse_PUT (char *lasts); + +private: + char *data_; + int datalen_; + int content_length_; + char *filename_; + int status_; + u_long type_; +}; + +#endif /* HTTP_REQUEST_H */ diff --git a/apps/JAWS/server/HTTP_Server.cpp b/apps/JAWS/server/HTTP_Server.cpp new file mode 100644 index 00000000000..3d5c1f3ebd1 --- /dev/null +++ b/apps/JAWS/server/HTTP_Server.cpp @@ -0,0 +1,259 @@ +// HTTP_Server.cpp + +#include "ace/Get_Opt.h" +#include "ace/Asynch_Acceptor.h" +#include "ace/Proactor.h" + +#include "JAWS/server/IO.h" +#include "JAWS/server/HTTP_Server.h" + +template <class LOCK> int +LOCK_SOCK_Acceptor<LOCK>::accept (ACE_SOCK_Stream &ns, + ACE_Addr *ra, + ACE_Time_Value *to, + int r) const +{ + ACE_Guard<LOCK> m ((LOCK &)this->lock_); + + return ACE_SOCK_Acceptor::accept (ns, ra, to, r); +} + +void +HTTP_Server::parse_args (int argc, char *argv[]) +{ + int c; + char *prog = argc > 0 ? argv[0] : "Sock_Server"; + + // Set some defaults + this->port_ = 0; + this->threads_ = 0; + + ACE_Get_Opt get_opt(argc, argv, "p:n:s:"); + while ((c = get_opt()) != -1) + switch (c) + { + case 'p': + this->port_ = ACE_OS::atoi(get_opt.optarg); + break; + case 'n': + this->threads_ = ACE_OS::atoi(get_opt.optarg); + break; + case 's': + // 0 -> synch thread pool + // 1 -> thread per request + // 2 -> asynch thread pool + this->strategy_ = ACE_OS::atoi(get_opt.optarg); + break; + default: + break; + } + + if (this->port_ == 0) this->port_ = 5432; + if (this->threads_ == 0) this->threads_ = 5; + + ACE_DEBUG ((LM_DEBUG, "in HTTP_Server::init, %s port = %d, number of threads = %d\n", + prog, this->port_, this->threads_)); + +} + +int +HTTP_Server::init (int argc, char *argv[]) +{ + this->parse_args (argc, argv); + + if (this->acceptor_.open (ACE_INET_Addr (this->port_), 1) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::open"), -1); + + switch (this->strategy_) + { + case 2: + return this->asynch_thread_pool (); + break; + + case 1: + return this->thread_per_request (); + break; + + case 0: + default: + return this->synch_thread_pool (); + break; + } + return 0; +} + +int +HTTP_Server::fini (void) +{ + this->tm_.close(); + return 0; +} + +int +HTTP_Server::synch_thread_pool (void) +{ + for (int i = 0; i < this->threads_; i++) + { + Synch_Thread_Pool_Task *t; + ACE_NEW_RETURN (t, Synch_Thread_Pool_Task (this->acceptor_, this->tm_), -1); + if (t->open () != 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Pool_Task::open"), -1); + } + this->tm_.wait(); + return 0; +} + +Synch_Thread_Pool_Task::Synch_Thread_Pool_Task (HTTP_Acceptor &acceptor, ACE_Thread_Manager &tm) + : ACE_Task<ACE_NULL_SYNCH>(&tm), acceptor_(acceptor) +{ +} + +int +Synch_Thread_Pool_Task::open (void *args) +{ + if (this->activate () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Synch_Thread_Pool_Task::open"), -1); + + return 0; +} + +int +Synch_Thread_Pool_Task::svc (void) +{ + Synch_HTTP_Handler_Factory factory; + for (;;) + { + ACE_SOCK_Stream stream; + if (this->acceptor_.accept (stream) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::accept"), -1); + ACE_Message_Block *mb; + ACE_NEW_RETURN (mb, ACE_Message_Block (HTTP_Handler::MAX_REQUEST_SIZE + 1), -1); + HTTP_Handler *handler = factory.create_http_handler (); + handler->open (stream.get_handle (), *mb); + mb->release (); + ACE_DEBUG ((LM_DEBUG, "(%t) in Synch_Thread_Pool_Task::svc, recycling\n")); + } + + return 0; +} + +int +HTTP_Server::thread_per_request (void) +{ + // thread per request + for (;;) + { + ACE_SOCK_Stream stream; + if (this->acceptor_.accept (stream) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "HTTP_Acceptor::accept"), -1); + Thread_Per_Request_Task *t; + ACE_NEW_RETURN (t, Thread_Per_Request_Task (stream.get_handle (), this->tm_), -1); + if (t->open () != 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Per_Request_Task::open"), -1); + } + return 0; +} + +Thread_Per_Request_Task::Thread_Per_Request_Task (ACE_HANDLE handle, + ACE_Thread_Manager &tm) + : ACE_Task<ACE_NULL_SYNCH>(&tm), + handle_ (handle) +{ +} + +int +Thread_Per_Request_Task::open (void *args) +{ + if (this->activate () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Per_Request_Task::open"), -1); + + return 0; +} + +int +Thread_Per_Request_Task::svc (void) +{ + ACE_Message_Block *mb; + ACE_NEW_RETURN (mb, ACE_Message_Block (HTTP_Handler::MAX_REQUEST_SIZE + 1), -1); + Synch_HTTP_Handler_Factory factory; + HTTP_Handler *handler = factory.create_http_handler (); + handler->open (this->handle_, *mb); + mb->release (); + return 0; +} + +int +Thread_Per_Request_Task::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) Thread_Per_Request_Task::svc, dying\n")); + delete this; + return 0; +} + + +int +HTTP_Server::asynch_thread_pool (void) +{ +// This only works on Win32 +#if defined (ACE_WIN32) + ACE_Asynch_Acceptor<Asynch_HTTP_Handler_Factory> acceptor; + if (acceptor.open (ACE_INET_Addr (this->port_), + HTTP_Handler::MAX_REQUEST_SIZE + 1) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Acceptor::open"), -1); + + for (int i = 0; i < this->threads_; i++) + { + Asynch_Thread_Pool_Task *t; + ACE_NEW_RETURN (t, Asynch_Thread_Pool_Task (*ACE_Service_Config::proactor(), this->tm_), -1); + if (t->open () != 0) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Thread_Pool_Task::open"), -1); + } + return this->tm_.wait(); +#endif /* ACE_WIN32 */ + return -1; +} + +// This only works on Win32 +#if defined (ACE_WIN32) + +Asynch_Thread_Pool_Task::Asynch_Thread_Pool_Task (ACE_Proactor &proactor, ACE_Thread_Manager &tm) + : ACE_Task<ACE_NULL_SYNCH> (&tm), proactor_ (proactor) +{ +} + +int +Asynch_Thread_Pool_Task::open (void *args) +{ + if (this->activate () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Asynch_Thread_Pool_Task::open"), -1); + + return 0; +} + +int +Asynch_Thread_Pool_Task::svc (void) +{ + for (;;) + { + if (this->proactor_.handle_events () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Proactor::handle_events"), -1); + } + return 0; +} + +#endif /* ACE_WIN32 */ + +// Define the factory function. +ACE_SVC_FACTORY_DEFINE (HTTP_Server) + +// Define the object that describes the service. +ACE_STATIC_SVC_DEFINE (HTTP_Server, "HTTP_Server", ACE_SVC_OBJ_T, + &ACE_SVC_NAME (HTTP_Server), + ACE_Service_Type::DELETE_THIS + | ACE_Service_Type::DELETE_OBJ, 0) + +// This is necessary for gcc to work with templates +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class LOCK_SOCK_Acceptor<ACE_Thread_Mutex>; +template class ACE_Oneshot_Acceptor<HTTP_Handler, ONESHOT_SOCK_ACCEPTOR>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/apps/JAWS/server/HTTP_Server.h b/apps/JAWS/server/HTTP_Server.h new file mode 100644 index 00000000000..7a746b6014d --- /dev/null +++ b/apps/JAWS/server/HTTP_Server.h @@ -0,0 +1,150 @@ +// -*- C++ -*- +// HTTP_Server.h + +#if !defined (HTTP_SERVER_H) +#define HTTP_SERVER_H + +class ACE_Proactor; + +#include "ace/Service_Object.h" +#include "ace/Thread_Manager.h" +#include "ace/Acceptor.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/Task.h" +#include "ace/Asynch_IO.h" + +#include "JAWS/server/HTTP_Handler.h" + +// Specialize ACE_SOCK_Acceptor to lock around accept(); +template <class LOCK> +class LOCK_SOCK_Acceptor : public ACE_SOCK_Acceptor +{ +public: + int accept (ACE_SOCK_Stream &new_stream, + ACE_Addr *remote_addr = 0, + ACE_Time_Value *timeout = 0, + int restart = 1) const; + +private: + LOCK lock_; +}; + +#if defined (ACE_HAS_TEMPLATE_TYPEDEFS) +#define ONESHOT_SOCK_ACCEPTOR HTTP_SOCK_Acceptor +#else /* TEMPLATES are broken */ +#define ONESHOT_SOCK_ACCEPTOR HTTP_SOCK_Acceptor, HTTP_SOCK_Acceptor::PEER_ADDR +#endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ + +#if defined (ACE_WIN32) +typedef LOCK_SOCK_Acceptor<ACE_Null_Mutex> HTTP_SOCK_Acceptor; +#else +typedef LOCK_SOCK_Acceptor<ACE_Thread_Mutex> HTTP_SOCK_Acceptor; +#endif /* ACE_WIN32 */ + +//typedef ACE_Oneshot_Acceptor <HTTP_Handler, ONESHOT_SOCK_ACCEPTOR> HTTP_Acceptor; +typedef HTTP_SOCK_Acceptor HTTP_Acceptor; + +class HTTP_Server : public ACE_Service_Object + // + // = TITLE + // + // This server is used to create HTTP Handlers for the Web + // server + // + // = DESCRIPTION + // + // +{ +public: + virtual int init (int argc, char *argv[]); + // Initialization + + virtual int fini (void); + // Exit hooks + +protected: + virtual int thread_per_request (); + // Thread Per Request implementation + + virtual int asynch_thread_pool (); + // Asynch Thread Pool implementation + + virtual int synch_thread_pool (); + // Synch Thread Pool implementation + + void setup_signal_handler (void); + +private: + void parse_args (int argc, char **argv); + int port_; + int threads_; + int strategy_; + ACE_Thread_Manager tm_; + HTTP_Acceptor acceptor_; +}; + +class Synch_Thread_Pool_Task : public ACE_Task<ACE_NULL_SYNCH> + // + // = TITLE + // + // Used to implement Synch Thread Pool + // + // = DESCRIPTION + // + // +{ +public: + Synch_Thread_Pool_Task (HTTP_Acceptor &acceptor, ACE_Thread_Manager &tm); + virtual int open (void *args = 0); + virtual int svc (void); + +private: + HTTP_Acceptor &acceptor_; +}; + +class Thread_Per_Request_Task : public ACE_Task<ACE_NULL_SYNCH> + // + // = TITLE + // + // Used to implement Thread Per Request + // + // = DESCRIPTION + // + // +{ +public: + Thread_Per_Request_Task (ACE_HANDLE handle, ACE_Thread_Manager &tm); + virtual int open (void *args = 0); + virtual int close (u_long); + virtual int svc (void); + +private: + ACE_HANDLE handle_; +}; + +// This only works on Win32 +#if defined (ACE_WIN32) +class Asynch_Thread_Pool_Task : public ACE_Task<ACE_NULL_SYNCH> + // + // = TITLE + // + // Used to implement Asynch Thread Pool + // + // = DESCRIPTION + // + // +{ +public: + Asynch_Thread_Pool_Task (ACE_Proactor &proactor, ACE_Thread_Manager &tm); + virtual int open (void *args = 0); + virtual int svc (void); + +private: + ACE_Proactor &proactor_; +}; +#endif /* ACE_WIN32 */ + +ACE_STATIC_SVC_DECLARE (HTTP_Server) + +#endif /* HTTP_SERVER_H */ + diff --git a/apps/JAWS/server/IO.cpp b/apps/JAWS/server/IO.cpp new file mode 100644 index 00000000000..099cf062076 --- /dev/null +++ b/apps/JAWS/server/IO.cpp @@ -0,0 +1,357 @@ +#include "JAWS/server/IO.h" +#include "JAWS/server/HTTP_Handler.h" +#include "JAWS/server/HTTP_Helpers.h" +#include "JAWS/server/VFS.h" +#include "ace/Message_Block.h" +#include "ace/SOCK_Stream.h" + +JAWS_IO::JAWS_IO (void) + : handle_ (ACE_INVALID_HANDLE), + handler_ (0) +{ +} + +JAWS_IO::~JAWS_IO (void) +{ +} + +ACE_HANDLE +JAWS_IO::handle (void) +{ + return this->handle_; +} + +void +JAWS_IO::handle (ACE_HANDLE handle) +{ + this->handle_ = handle; +} + +void +JAWS_IO::handler (HTTP_Handler *handler) +{ + this->handler_ = handler; +} + +JAWS_Synch_IO::JAWS_Synch_IO (void) + : JAWS_IO () +{ +} + +JAWS_Synch_IO::~JAWS_Synch_IO (void) +{ + ACE_OS::closesocket (this->handle_); +} + +void +JAWS_Synch_IO::read (ACE_Message_Block& mb, int size) +{ + ACE_SOCK_Stream stream; + stream.set_handle (this->handle_); + int result = stream.recv (mb.wr_ptr (), size); + if (result <= 0) + this->handler_->read_error (); + else + { + mb.wr_ptr (result); + this->handler_->client_data (mb); + } +} + +void +JAWS_Synch_IO::receive_file (char *filename, + void *initial_data, + int initial_data_length, + int entire_length) +{ + JAWS_VFS_Node *vf = 0; + VFS::instance ()->open (filename, vf); + + vf->map_write (entire_length); + + int result = vf->status (); + + if (result == HTTP_Status_Code::STATUS_OK) + { + ACE_SOCK_Stream stream; + stream.set_handle (this->handle_); + + ACE_OS::memcpy (vf->addr (), initial_data, initial_data_length); + + int bytes_to_read = entire_length - initial_data_length; + + int bytes = stream.recv_n ((char *) vf->addr () + initial_data_length, + bytes_to_read); + if (bytes == bytes_to_read) + this->handler_->receive_file_complete (); + else + result = HTTP_Status_Code::STATUS_INSUFFICIENT_DATA; + } + + if (result != HTTP_Status_Code::STATUS_OK) + this->handler_->receive_file_error (result); + + VFS::instance ()->close (vf); +} + +void +JAWS_Synch_IO::transmit_file (char *filename, + const char *header, + int header_size) +{ + JAWS_VFS_Node *vf = 0; + VFS::instance ()->open (filename, vf); + + vf->map_read (); + + int result = vf->status (); + + if (result == HTTP_Status_Code::STATUS_OK) + { + ACE_SOCK_Stream stream; + stream.set_handle (this->handle_); + + int bytes = stream.send_n (header, header_size); + if (bytes == header_size) + { + int bytes = stream.send_n (vf->addr (), vf->size ()); + if (bytes == vf->size ()) + this->handler_->transmit_file_complete (); + else + result = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + } + else + result = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + } + if (result != HTTP_Status_Code::STATUS_OK) + this->handler_->transmit_file_error (result); + VFS::instance ()->close (vf); +} + +void +JAWS_Synch_IO::send_confirmation_message (const char *buffer, + int length) +{ + this->send_message (buffer, length); + this->handler_->confirmation_message_complete (); +} + +void +JAWS_Synch_IO::send_error_message (const char *buffer, + int length) +{ + this->send_message (buffer, length); + this->handler_->error_message_complete (); +} + +void +JAWS_Synch_IO::send_message (const char *buffer, + int length) +{ + ACE_SOCK_Stream stream; + stream.set_handle (this->handle_); + stream.send_n (buffer, length); +} + +// This only works on Win32 +#if defined (ACE_WIN32) + +JAWS_Asynch_IO::JAWS_Asynch_IO (void) + : JAWS_IO () +{ +} + +JAWS_Asynch_IO::~JAWS_Asynch_IO (void) +{ + ACE_OS::closesocket (this->handle_); +} + +void +JAWS_Asynch_IO::read (ACE_Message_Block& mb, int size) +{ + ACE_Asynch_Read_Stream ar; + if (ar.open (*this, this->handle_) == -1 || + ar.read (mb, size) == -1) + this->handler_->read_error (); +} + +// This method will be called when an asynchronous read completes on a stream. +void +JAWS_Asynch_IO::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) +{ + if (result.act () != 0) + // This callback is for this->receive_file() + { + int code = 0; + if (result.success ()) + { + if (result.message_block ().length () == result.message_block ().size ()) + code = HTTP_Status_Code::STATUS_OK; + else + { + ACE_Asynch_Read_Stream ar; + if (ar.open (*this, this->handle_) == -1 || + ar.read (result.message_block (), + result.message_block ().size () - result.message_block ().length (), + result.act ()) == -1) + code = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + else + return; + } + if (code == HTTP_Status_Code::STATUS_OK) + this->handler_->receive_file_complete (); + else + this->handler_->receive_file_error (code); + + delete &result.message_block (); + JAWS_VFS_Node *vf = (JAWS_VFS_Node *) result.act (); + VFS::instance ()->close (vf); + } + } + else + { + // This callback is for this->read() + if (result.success ()) + this->handler_->client_data (result.message_block ()); + else + this->handler_->read_error (); + } +} + +void +JAWS_Asynch_IO::receive_file (char *filename, + void *initial_data, + int initial_data_length, + int entire_length) +{ + ACE_Message_Block *mb = 0; + JAWS_VFS_Node *vf = 0; + VFS::instance ()->open (filename, vf); + + vf->map_write (entire_length); + + int result = vf->status (); + + if (result == HTTP_Status_Code::STATUS_OK) + { + ACE_OS::memcpy (vf->addr (), initial_data, initial_data_length); + + int bytes_to_read = entire_length - initial_data_length; + mb = new ACE_Message_Block ((char *) vf->addr () + initial_data_length, + bytes_to_read); + ACE_Asynch_Read_Stream ar; + if (ar.open (*this, this->handle_) == -1 || + ar.read (*mb, + mb->size () - mb->length (), + vf) == -1) + result = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + } + + if (result != HTTP_Status_Code::STATUS_OK) + { + this->handler_->receive_file_error (result); + delete mb; + VFS::instance ()->close (vf); + } +} + +void +JAWS_Asynch_IO::transmit_file (char *filename, + const char *header, + int header_size) +{ + ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer = 0; + JAWS_VFS_Node *vf; + + VFS::instance ()->open (filename, vf); + + vf->open (); + + int result = vf->status (); + + if (result == HTTP_Status_Code::STATUS_OK) + { + ACE_Message_Block header_mb (header, header_size); + header_and_trailer = new ACE_Asynch_Transmit_File::Header_And_Trailer (&header_mb, + header_size); + ACE_Asynch_Transmit_File tf; + if (tf.open (*this, this->handle_) == -1 || + tf.transmit_file (vf->get_handle (), // file handle + header_and_trailer, // header and trailer data + 0, // bytes_to_write + 0, // offset + 0, // offset_high + 0, // bytes_per_send + 0, // flags + vf // act + ) == -1) + result = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + } + + if (result != HTTP_Status_Code::STATUS_OK) + { + this->handler_->transmit_file_error (result); + delete header_and_trailer; + VFS::instance ()->close (vf); + } +} + + +// This method will be called when an asynchronous transmit file completes. +void +JAWS_Asynch_IO::handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result) +{ + if (result.success ()) + this->handler_->transmit_file_complete (); + else + this->handler_->transmit_file_error (HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR); + + delete result.header_and_trailer (); + JAWS_VFS_Node *vf = (JAWS_VFS_Node *) result.act (); + VFS::instance ()->close (vf); +} + +void +JAWS_Asynch_IO::send_confirmation_message (const char *buffer, + int length) +{ + this->send_message (buffer, length, CONFORMATION); +} + +void +JAWS_Asynch_IO::send_error_message (const char *buffer, + int length) +{ + this->send_message (buffer, length, ERROR_MESSAGE); +} + +void +JAWS_Asynch_IO::send_message (const char *buffer, + int length, + int act) +{ + ACE_Message_Block *mb = new ACE_Message_Block (buffer, length); + ACE_Asynch_Write_Stream aw; + if (aw.open (*this, this->handle_) == -1 || + aw.write (*mb, length, (void *) act) == -1) + { + mb->release (); + if (act == CONFORMATION) + this->handler_->confirmation_message_complete (); + else + this->handler_->error_message_complete (); + } +} + +void +JAWS_Asynch_IO::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) +{ + result.message_block ().release (); + if (result.act () == (void *) CONFORMATION) + this->handler_->confirmation_message_complete (); + else + this->handler_->error_message_complete (); +} + +#endif /* ACE_WIN32 */ + diff --git a/apps/JAWS/server/IO.h b/apps/JAWS/server/IO.h new file mode 100644 index 00000000000..96ceeec3909 --- /dev/null +++ b/apps/JAWS/server/IO.h @@ -0,0 +1,107 @@ +#ifndef JAWS_IO_H +#define JAWS_IO_H + +class ACE_Message_Block; +class HTTP_Handler; + +#include "ace/ACE.h" +#include "ace/Asynch_IO.h" + +class JAWS_IO + // + // = TITLE + // + // This class defines the abstract interface for an I/O class in + // the context of Web-likes servers + // + // = DESCRIPTION + // + // An I/O class should have the following interface. Derived + // classes will define the exactly how the I/O will take place + // (Asynchronous, Synchronous, Reactive) +{ +public: + JAWS_IO (void); + virtual ~JAWS_IO (void); + void handler (HTTP_Handler *handler); + void handle (ACE_HANDLE h); + ACE_HANDLE handle (void); + + virtual void read (ACE_Message_Block& mb, int size) = 0; + virtual void transmit_file (char *filename, + const char *header, + int header_size) = 0; + virtual void receive_file (char *filename, + void *initial_data, + int initial_data_length, + int entire_length) = 0; + virtual void send_confirmation_message (const char *buffer, int length) = 0; + virtual void send_error_message (const char *buffer, int length) = 0; + +protected: + ACE_HANDLE handle_; + HTTP_Handler *handler_; +}; + +class JAWS_Synch_IO : public JAWS_IO +{ +public: + JAWS_Synch_IO (void); + ~JAWS_Synch_IO (void); + void read (ACE_Message_Block& mb, int size); + void transmit_file (char *filename, + const char *header, + int header_size); + void receive_file (char *filename, + void *initial_data, + int initial_data_length, + int entire_length); + void send_confirmation_message (const char *buffer, int length); + void send_error_message (const char *buffer, int length); + +protected: + virtual void send_message (const char *buffer, int length); +}; + +// This only works on Win32 +#if defined (ACE_WIN32) + +class JAWS_Asynch_IO : public JAWS_IO, public ACE_Handler +{ +public: + JAWS_Asynch_IO (void); + ~JAWS_Asynch_IO (void); + void read (ACE_Message_Block& mb, int size); + void transmit_file (char *filename, + const char *header, + int header_size); + void receive_file (char *filename, + void *initial_data, + int initial_data_length, + int entire_length); + void send_confirmation_message (const char *buffer, int length); + void send_error_message (const char *buffer, int length); + +protected: + enum Message_Types + { + CONFORMATION, + ERROR_MESSAGE + }; + + virtual void send_message (const char *buffer, int length, int act); + + virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); + // This method will be called when an asynchronous read completes on a stream. + + virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); + // This method will be called when an asynchronous write completes on a stream. + + virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result); + // This method will be called when an asynchronous transmit file completes. + +}; +#endif /* ACE_WIN32 */ + +#endif /* JAWS_IO_H */ + diff --git a/apps/JAWS/server/JXH_List.h b/apps/JAWS/server/JXH_List.h new file mode 100644 index 00000000000..0ea083e7988 --- /dev/null +++ b/apps/JAWS/server/JXH_List.h @@ -0,0 +1,132 @@ +/* -*- C++ -*- */ +// JXH_List.h + +#ifndef JXH_LIST_H +#define JXH_LIST_H + +#include <iostream.h> + +template <class ItemType> +class JXH_List + // = TITLE + // JXH_List Template Class + // + // = DESCRIPTION + // Yet another implementation of a list. + // Comletely unordered. Elements inserted at tail, but may + // be moved about by other operations. Must use linear + // search to find. + // + // What's different: + // (1) If you are creating a list of pointers, it will return + // the same pointers you gave it. + // (2) If you are creating a list of objects, your objects must + // have a copy constructor. The List will create its own + // local copy of the object. + // +{ +public: + // = Public Interfaces + // + + JXH_List() : current_(0), count_(0), size_(256) + { theList_ = new JXH_ListItem *[size_]; } + + // JXH_List(long size) : current_(0), count_(0), size_(size) + // { theList_ = new JXH_ListItem *[size_]; } + + JXH_List(unsigned long size) : current_(0), count_(0), size_(size) + { theList_ = new JXH_ListItem *[size_]; } + + ~JXH_List() + { for (int i = 0; i < count_; i++) delete theList_[i]; + delete [] theList_; } + + int Insert(const ItemType & item) + { if (IsFull()) { + JXH_ListItem ** alist = new JXH_ListItem *[2*size_]; + if (alist == 0) return 0; + for (int i = 0; i < count_; i++) alist[i] = theList_[i]; + delete [] theList_; + theList_ = alist; + size_ = 2*size_; + } + current_ = count_++; + theList_[current_] = new JXH_ListItem(item); + return 1; } + + int Delete() + { if (IsEmpty()) return 0; + delete theList_[current_]; + theList_[current_] = theList_[--count_]; + theList_[count_] = 0; + return 1; } + + int Size() const { return count_; } + int IsFull() const { return count_ == size_; } + int IsEmpty() const { return count_ == 0; } + + const ItemType & Head() { if (IsEmpty()) return garbage; + return theList_[current_ = 0]->item_; } + + const ItemType & Tail() { if (IsEmpty()) return garbage; + return theList_[current_ = count_-1]->item_; } + + const ItemType & Current() { if (IsEmpty()) return garbage; + return theList_[current_]->item_; } + + const ItemType & Next() { if (IsEmpty()) return garbage; + if (++current_ >= count_) current_ = count_-1; + return theList_[current_]->item_; } + + const ItemType & Prev() { if (IsEmpty()) return garbage; + if (current_ != 0) --current_; + return theList_[current_]->item_; } + + const ItemType & operator [] (unsigned long i) + { if (IsEmpty()) return garbage; + if (i >= count_) i = count_-1; + current_ = i; + return theList_[current_]->item_; } + + /* + void Isort() + { unsigned long i = 0, j; + while ((j = ++i) < count_) + { JXH_ListItem * x = theList_[j]; + while (j-- && (*x < *theList_[j])) + theList_[j+1] = theList_[j]; + theList_[j+1] = x; } } + */ + +protected: + // = Protected Interfaces + // + + void Dump() + { for (int i = 0; i < count_; i++) + cerr << "[" << i << "] " + << theList_[i]->item_ << endl; } + +public: + // = Private Data + // + + class JXH_ListItem + { + public: + JXH_ListItem(const ItemType & item) : item_(item) {}; + const ItemType item_; + }; + +private: + unsigned long count_; + unsigned long current_; + + unsigned long size_; + JXH_ListItem **theList_; + + ItemType garbage; +}; + +#endif // JXH_List_H diff --git a/apps/JAWS/server/JXH_String.h b/apps/JAWS/server/JXH_String.h new file mode 100644 index 00000000000..edf7bbd13af --- /dev/null +++ b/apps/JAWS/server/JXH_String.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +// JXH_String.h + +#ifndef JXH_STRING_H +#define JXH_STRING_H + +#include <stdlib.h> +#include <string.h> + +class String +{ +public: + + String() : str_(0) {} + + String(const char *s) : str_(::strcpy(new char[::strlen(s)+1], s)) {} + String(const String &s) : str_(::strcpy(new char[::strlen(s)+1], s)) {} + + ~String() { if (str_) delete [] str_; } + + operator char* () const { return str_; } + char & operator [] (int i) const { return str_[i]; } + + int operator == (const char *s) const { return ::strcmp(str_, s) == 0; } + int operator > (const char *s) const { return ::strcmp(str_, s) == 1; } + int operator < (const char *s) const { return ::strcmp(str_, s) == -1; } + int operator >= (const char *s) const { return ::strcmp(str_, s) >= 0; } + int operator <= (const char *s) const { return ::strcmp(str_, s) <= 0; } + + String & operator = (const char *s) + { delete [] str_; str_ = ::strcpy(new char[strlen(s)+1], s); + return *this; } + + String & operator += (const char *s) + { char * ss = ::strcpy(new char[::strlen(str_)+::strlen(s)+1], str_); + delete [] str_; str_ = ::strcat(ss, s); return *this; } + + int length (void) const { return ::strlen(str_); } + +private: + char * str_; +}; + +#endif diff --git a/apps/JAWS/server/Makefile b/apps/JAWS/server/Makefile new file mode 100644 index 00000000000..dcc645ebd90 --- /dev/null +++ b/apps/JAWS/server/Makefile @@ -0,0 +1,219 @@ +#---------------------------------------------------------------------------- +# %W% %G% +# +# Makefile for the ACE Adapter Web Server (JAWS) +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = main + +FILES = \ + HTTP_Server \ + HTTP_Handler \ + HTTP_Helpers \ + HTTP_Request \ + VFS \ + IO + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +#CPPFLAGS += -gstabs++ +#CPPFLAGS += -DACE_HAS_STL +#CPPFLAGS += -DACE_INLINE + +INCLDIRS += -I.. + +LDLIBS = $(addprefix .shobj/,$(SHOBJ)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/HTTP_Server.o .shobj/HTTP_Server.so: HTTP_Server.cpp HTTP_Server.h HTTP_Handler.h \ + HTTP_Helpers.h $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + HTTP_VFS.h JXH_List.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Task_T.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies_T.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Acceptor.h \ + $(WRAPPER_ROOT)/ace/Acceptor.i \ + $(WRAPPER_ROOT)/ace/SOCK_Acceptor.h \ + $(WRAPPER_ROOT)/ace/Get_Opt.h +.obj/HTTP_Handler.o .shobj/HTTP_Handler.so: HTTP_Handler.cpp HTTP_Handler.h HTTP_Helpers.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + HTTP_VFS.h JXH_List.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/Svc_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch_Options.h \ + $(WRAPPER_ROOT)/ace/Task.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Task_T.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies_T.h \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h +.obj/HTTP_Helpers.o .shobj/HTTP_Helpers.so: HTTP_Helpers.cpp HTTP_Helpers.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i +.obj/HTTP_VFS.o .shobj/HTTP_VFS.so: HTTP_VFS.cpp HTTP_VFS.h HTTP_Helpers.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + JXH_List.h $(WRAPPER_ROOT)/ace/Mem_Map.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/apps/JAWS/server/VFS.cpp b/apps/JAWS/server/VFS.cpp new file mode 100644 index 00000000000..c3c28883098 --- /dev/null +++ b/apps/JAWS/server/VFS.cpp @@ -0,0 +1,364 @@ +// VFS.cpp + +// Associate URI's to real path. +// Hash on URI. +// Maintain a table of files which are opened. +// Return a handle to the file, and provide I/O mechanisms for it. + +#include "JAWS/server/VFS.h" +#include "JAWS/server/HTTP_Helpers.h" + +#if defined (ACE_WIN32) +static const int READ_FLAGS = FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED | O_RDONLY; +static const int WRITE_FLAGS = FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED | O_RDWR | O_CREAT; +#else +static const int READ_FLAGS = O_RDONLY; +static const int WRITE_FLAGS = O_RDWR | O_CREAT; +#endif /* ACE_WIN32 */ + +JAWS_VFS_Node::JAWS_VFS_Node (char *uri) + : map_state_ (NOT_OPEN), + uri_ (ACE_OS::strdup (uri)) +{ + this->uritopath (); +} + +JAWS_VFS_Node::~JAWS_VFS_Node (void) +{ + ACE_OS::free (this->uri_); + if (handle_ != ACE_INVALID_HANDLE) + { + ACE_OS::close (handle_); + handle_ = ACE_INVALID_HANDLE; + } +} + +void +JAWS_VFS_Node::open (void) +{ + if (map_state_ == NOT_OPEN) + this->open (READ_FLAGS); +} + +int +JAWS_VFS_Node::open (int flags) +{ + if (map_state_ != NOT_OPEN) + { + ACE_OS::close (handle_); + handle_ = ACE_INVALID_HANDLE; + } + + this->handle_ = ACE_OS::open (this->path_, flags); + if (this->handle_ == ACE_INVALID_HANDLE) + { + switch (errno) + { + case EACCES: + case EAGAIN: + this->status_ = HTTP_Status_Code::STATUS_UNAUTHORIZED; + ACE_ERROR ((LM_ERROR, "%p unauthorized error.\n", "JAWS_VFS_Node::open")); + break; + case EFAULT: + case ENOTDIR: + this->status_ = HTTP_Status_Code::STATUS_BAD_REQUEST; + ACE_ERROR ((LM_ERROR, "%p bad request.\n", "JAWS_VFS_Node::open")); + break; + case ENOENT: +#if !defined (ACE_WIN32) + case ENOLINK: +#endif /* ACE_WIN32 */ + this->status_ = HTTP_Status_Code::STATUS_NOT_FOUND; + ACE_ERROR ((LM_ERROR, "%p file not found error.\n", "JAWS_VFS_Node::open")); + break; + default: + this->status_ = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + ACE_ERROR ((LM_ERROR, "%p internal server error.\n", "JAWS_VFS_Node::open")); + } + } + else if (ACE_OS::stat (this->path_, &this->stat_) == -1) + { + this->status_ = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + ACE_ERROR ((LM_ERROR, "%p stat failed.\n", "JAWS_VFS_Node::open")); + } + else + { + if (this->stat_.st_mode & S_IFDIR) + { + if ((this->stat_.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == (S_IXUSR|S_IXGRP|S_IXOTH)) + { + this->status_ = HTTP_Status_Code::STATUS_FORBIDDEN; + ACE_ERROR ((LM_ERROR, "%p file is forbidden.\n", "JAWS_VFS_Node::open")); + } + else + { + this->status_ = HTTP_Status_Code::STATUS_UNAUTHORIZED; + ACE_ERROR ((LM_ERROR, "%p file access is unauthorized.\n", "JAWS_VFS_Node::open")); + } + } + else if ((this->stat_.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)) != (S_IRUSR|S_IRGRP|S_IROTH)) + { + this->status_ = HTTP_Status_Code::STATUS_UNAUTHORIZED; + ACE_ERROR ((LM_ERROR, "%p file access is unauthorized.\n", "JAWS_VFS_Node::open")); + } + else + this->status_ = HTTP_Status_Code::STATUS_OK; + } + + if (this->status_ != HTTP_Status_Code::STATUS_OK) + { + if (handle_ != ACE_INVALID_HANDLE) + { + ACE_OS::close (handle_); + handle_ = ACE_INVALID_HANDLE; + } + return -1; + } + + map_state_ = OPENED; + return 0; +} + +int +JAWS_VFS_Node::map_read (void) +{ + if (map_state_ != MAPPED_READ && + map_state_ != MAPPED_READWRITE) + { + if (this->open (READ_FLAGS) == -1) + return -1; + + if (file_mapping_.map (handle_, -1, PROT_READ) == 0) + { + map_state_ = MAPPED_READ; + return 0; + } + else + { + this->status_ = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + ACE_ERROR ((LM_ERROR, "%p memory mapping for read.\n", "JAWS_VFS_Node::map_write")); + return -1; + } + } + else + return 0; +} + +int +JAWS_VFS_Node::map_write (u_long size) +{ + if (map_state_ != MAPPED_READWRITE) + { + if (this->open (WRITE_FLAGS) == -1) + return -1; + + if (file_mapping_.map (handle_, + size, + PROT_RDWR, + MAP_SHARED) == 0) + { + map_state_ = MAPPED_READWRITE; + return 0; + } + else + { + this->status_ = HTTP_Status_Code::STATUS_INTERNAL_SERVER_ERROR; + ACE_ERROR ((LM_ERROR, "%p memory mapping for read.\n", "JAWS_VFS_Node::map_write")); + return -1; + } + } + else + return 0; +} + +void +JAWS_VFS_Node::uritopath (void) +{ + char const *file_name = this->uri_; + + char buf[MAXPATHLEN+1]; + buf[0] = '\0'; + + if (*file_name == '/') file_name++; + if (*file_name == '~') { + char *ptr = buf; + + while (*++file_name && *file_name != '/') + *ptr++ = *file_name; + + *ptr = '\0'; + + if (ptr == buf) + ACE_OS::strcpy (buf, ACE_OS::getenv ("HOME")); + else { +#if !defined (ACE_WIN32) + char pw_buf[BUFSIZ]; + struct passwd pw_struct; + if (::getpwnam_r(buf, &pw_struct, pw_buf, sizeof (pw_buf)) == 0) + return; + ACE_OS::strcpy (buf, pw_struct.pw_dir); +#endif /* ACE_WIN32 */ + } + + ACE_OS::strcat (buf, "/.www-docs/"); + ACE_OS::strcat (buf, file_name); + } + else { + ACE_OS::strcat (buf, "./"); + ACE_OS::strcat (buf, file_name); + } + + ACE_OS::strcpy (this->path_, buf); +} + +ACE_HANDLE +JAWS_VFS_Node::get_handle (void) const +{ + return this->handle_; +} + +void * +JAWS_VFS_Node::addr (void) const +{ + return file_mapping_.addr (); +} + +char const * +JAWS_VFS_Node::URI (void) const +{ + return this->uri_; +} + +int +JAWS_VFS_Node::status (void) const +{ + return this->status_; +} + +unsigned long +JAWS_VFS_Node::size (void) const +{ + return this->stat_.st_size; +} + +JAWS_VFS_Node_List::JAWS_VFS_Node_List (int sz) + : JXH_List<JAWS_VFS_Node *> (sz) +{ +} + +template <class LOCK> +JAWS_VFS_Node_Bucket<LOCK>::JAWS_VFS_Node_Bucket (int size) + : bucket_ (size) +{ +} + +template <class LOCK> +JAWS_VFS_Node * +JAWS_VFS_Node_Bucket<LOCK>::find (char *URI) +{ + ACE_Guard<LOCK> g (this->lock_); + int found = -1; + + if (! this->bucket_.IsEmpty ()) + for (int i = 0; i < this->bucket_.Size (); i++) { + if (ACE_OS::strcmp (URI, this->bucket_[i]->URI ()) != 0) continue; + found = i; + break; + } + + if (found == -1) + { + JAWS_VFS_Node *new_node = new JAWS_VFS_Node (URI); + if (new_node == 0) + ACE_ERROR ((LM_ERROR, "%p.\n", "JAWS_VFS_Node")); + this->bucket_.Insert (new_node); + found = this->bucket_.Size () - 1; + } + + return this->bucket_[found]; +} + +JAWS_VFS_Hash_Table::JAWS_VFS_Hash_Table () +{ + ht_ = new JAWS_VFS_Node_Bucket<ACE_Thread_Mutex>[256]; +} + +JAWS_VFS_Hash_Table::~JAWS_VFS_Hash_Table () +{ + delete [] ht_; +} + +JAWS_VFS_Node * +JAWS_VFS_Hash_Table::operator[] (char *URI) +{ + int index = this->hashfunction (URI); + return ht_[index].find (URI); +} + +int +JAWS_VFS_Hash_Table::hashfunction (char *key) const +{ + unsigned long sum = 0; + int j = 0; + + for (int i = ACE_OS::strlen (key)-1; i >= 0; i-=3) { + sum *= 2; + sum += key[i]%2; + if (++j == 32) break; + } + return sum % 256U; +} + +int +JAWS_VFS::open (char *URI, JAWS_VFS_Node * &handle) +{ + handle = this->hash_[URI]; + + return handle->status (); +} + +int +JAWS_VFS::close (JAWS_VFS_Node * &handle) +{ + // In the future, do something intelligent here. + return 0; +} + + + +#if 0 +inline void +JAWS_VFS_Node::map_read (void) +{ + this->map_ = ACE_OS::mmap (0, this->stat_.st_size, PROT_READ, MAP_SHARED, + this->handle_, 0); + if (this->map_ == MAP_FAILED) + { + this->map_ = 0; + this->file_ = new char[this->stat_.st_size]; + int count = 0; + char *p = (char *)this->file_; + + while (count < this->stat_.st_size) + { + int n = ACE_OS::read (this->handle_, p, this->stat_.st_size-count); + if (n == -1) break; + p += n; + count += n; + } + + if (count == 0) + { + delete [] this->file_; + this->file_ = 0; + } + + ACE_OS::close (this->handle_); + } + else + this->file_ = 0; + + map_state_ = MAPPED_READ; +} +#endif + diff --git a/apps/JAWS/server/VFS.h b/apps/JAWS/server/VFS.h new file mode 100644 index 00000000000..a97040195fc --- /dev/null +++ b/apps/JAWS/server/VFS.h @@ -0,0 +1,119 @@ +// VFS.h + +// Associate URI's to real path. +// Hash on URI. +// Maintain a table of files which are opened. +// Return a handle to the file, and provide I/O mechanisms for it. + +#if !defined (VFS_H) +#define VFS_H + +#include "JAWS/server/JXH_List.h" + +#include "ace/Mem_Map.h" +#include "ace/Singleton.h" +#include "ace/Synch.h" + +class JAWS_VFS_Node +{ +public: + JAWS_VFS_Node (char *uri); + ~JAWS_VFS_Node (void); + + char const * URI (void) const; + int status (void) const; + + void open (void); + // This if for TransmitFile. + + int map_read (void); + // HTTP GET: File transfer without TransmitFile + + int map_write (u_long size); + // HTTP PUT + + void *addr (void) const; + // Address of memory mapped region + + ACE_HANDLE get_handle (void) const; + // HTTP GET: TransmitFile + + unsigned long size (void) const; + // File size + +private: + void uritopath (void); + + int open (int flags); + +private: + ACE_Mem_Map file_mapping_; + + char *uri_; + char path_[MAXPATHLEN+1]; + + // void *file_; + // char buf_[BUFSIZ]; + + struct stat stat_; + ACE_HANDLE handle_; + + int status_; + + enum { NOT_OPEN, OPENED, MAPPED_READ, MAPPED_READWRITE }; + u_long map_state_; +}; + +class JAWS_VFS_Node_List : public JXH_List<JAWS_VFS_Node *> +{ +public: + JAWS_VFS_Node_List (int sz); +}; + +template <class LOCK> +class JAWS_VFS_Node_Bucket +{ +public: + JAWS_VFS_Node_Bucket (int size = 1); + + JAWS_VFS_Node * find (char *URI); + +private: + JAWS_VFS_Node_List bucket_; + + LOCK lock_; +}; + +class JAWS_VFS_Hash_Table +{ +public: + JAWS_VFS_Hash_Table (); + + ~JAWS_VFS_Hash_Table (); + + JAWS_VFS_Node * operator[] (char *URI); + +private: + int hashfunction (char *key) const; + +private: + JAWS_VFS_Node_Bucket<ACE_Thread_Mutex> *ht_; +}; + +class JAWS_VFS +{ +public: + int open (char *URI, JAWS_VFS_Node * &handle); + int close (JAWS_VFS_Node * &handle); + +private: + JAWS_VFS_Hash_Table hash_; +}; + +typedef ACE_Singleton <JAWS_VFS, ACE_Thread_Mutex> VFS; + +#endif /* VFS_H */ + +/// Local Variables: +/// mode: c++ +/// End: diff --git a/apps/JAWS/server/jaws.mak b/apps/JAWS/server/jaws.mak new file mode 100644 index 00000000000..09aa5832a13 --- /dev/null +++ b/apps/JAWS/server/jaws.mak @@ -0,0 +1,972 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+!IF "$(CFG)" == ""
+CFG=jaws - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to jaws - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "jaws - Win32 Release" && "$(CFG)" != "jaws - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE on this makefile
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "jaws.mak" CFG="jaws - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "jaws - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "jaws - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+################################################################################
+# Begin Project
+# PROP Target_Last_Scanned "jaws - Win32 Debug"
+RSC=rc.exe
+CPP=cl.exe
+
+!IF "$(CFG)" == "jaws - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+OUTDIR=.
+INTDIR=.\Release
+
+ALL : "$(OUTDIR)\jaws.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\HTTP_Handler.obj"
+ -@erase "$(INTDIR)\HTTP_Helpers.obj"
+ -@erase "$(INTDIR)\HTTP_Request.obj"
+ -@erase "$(INTDIR)\HTTP_Server.obj"
+ -@erase "$(INTDIR)\IO.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\VFS.obj"
+ -@erase "$(OUTDIR)\jaws.exe"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /MDd /W3 /GX /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MDd /W3 /GX /O2 /I "..\.." /D "WIN32" /D "NDEBUG" /D\
+ "_CONSOLE" /Fp"$(INTDIR)/jaws.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Release/
+CPP_SBRS=.\.
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/jaws.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+LINK32_FLAGS=ace.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
+ comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
+ odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no\
+ /pdb:"$(OUTDIR)/jaws.pdb" /machine:I386 /out:"$(OUTDIR)/jaws.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\HTTP_Handler.obj" \
+ "$(INTDIR)\HTTP_Helpers.obj" \
+ "$(INTDIR)\HTTP_Request.obj" \
+ "$(INTDIR)\HTTP_Server.obj" \
+ "$(INTDIR)\IO.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\VFS.obj"
+
+"$(OUTDIR)\jaws.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "jaws - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+OUTDIR=.
+INTDIR=.\Debug
+
+ALL : "$(OUTDIR)\jaws.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\HTTP_Handler.obj"
+ -@erase "$(INTDIR)\HTTP_Helpers.obj"
+ -@erase "$(INTDIR)\HTTP_Request.obj"
+ -@erase "$(INTDIR)\HTTP_Server.obj"
+ -@erase "$(INTDIR)\IO.obj"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\vc40.idb"
+ -@erase "$(INTDIR)\vc40.pdb"
+ -@erase "$(INTDIR)\VFS.obj"
+ -@erase "$(OUTDIR)\jaws.exe"
+ -@erase "$(OUTDIR)\jaws.ilk"
+ -@erase "$(OUTDIR)\jaws.pdb"
+
+"$(INTDIR)" :
+ if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
+
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\.." /D "WIN32" /D "_DEBUG" /D\
+ "_CONSOLE" /Fp"$(INTDIR)/jaws.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=.\.
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/jaws.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 ace.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
+LINK32_FLAGS=ace.lib kernel32.lib user32.lib gdi32.lib winspool.lib\
+ comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib\
+ odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes\
+ /pdb:"$(OUTDIR)/jaws.pdb" /debug /machine:I386 /out:"$(OUTDIR)/jaws.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\HTTP_Handler.obj" \
+ "$(INTDIR)\HTTP_Helpers.obj" \
+ "$(INTDIR)\HTTP_Request.obj" \
+ "$(INTDIR)\HTTP_Server.obj" \
+ "$(INTDIR)\IO.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\VFS.obj"
+
+"$(OUTDIR)\jaws.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.c{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+################################################################################
+# Begin Target
+
+# Name "jaws - Win32 Release"
+# Name "jaws - Win32 Debug"
+
+!IF "$(CFG)" == "jaws - Win32 Release"
+
+!ELSEIF "$(CFG)" == "jaws - Win32 Debug"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\main.cpp
+
+!IF "$(CFG)" == "jaws - Win32 Release"
+
+DEP_CPP_MAIN_=\
+ "..\..\JAWS/server/HTTP_Handler.h"\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ "..\..\JAWS/server/HTTP_Server.h"\
+ {$(INCLUDE)}"\ace\Acceptor.cpp"\
+ {$(INCLUDE)}"\ace\Acceptor.h"\
+ {$(INCLUDE)}"\ace\Acceptor.i"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\Asynch_IO.h"\
+ {$(INCLUDE)}"\ace\Asynch_IO.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Dynamic.h"\
+ {$(INCLUDE)}"\ace\Dynamic.i"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\Module.cpp"\
+ {$(INCLUDE)}"\ace\Module.h"\
+ {$(INCLUDE)}"\ace\Module.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\Strategies.h"\
+ {$(INCLUDE)}"\ace\Strategies_T.cpp"\
+ {$(INCLUDE)}"\ace\Strategies_T.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
+ {$(INCLUDE)}"\ace\Stream_Modules.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.cpp"\
+ {$(INCLUDE)}"\ace\Svc_Handler.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task_T.cpp"\
+ {$(INCLUDE)}"\ace\Task_T.h"\
+ {$(INCLUDE)}"\ace\Task_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "jaws - Win32 Debug"
+
+DEP_CPP_MAIN_=\
+ "..\..\JAWS/server/HTTP_Server.h"\
+ {$(INCLUDE)}"\ace\Acceptor.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\Strategies.h"\
+ {$(INCLUDE)}"\ace\Strategies_T.cpp"\
+ {$(INCLUDE)}"\ace\Strategies_T.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task_T.h"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\HTTP_Helpers.cpp
+DEP_CPP_HTTP_=\
+ "..\..\JAWS/server/HTTP_Helpers.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\HTTP_Helpers.obj" : $(SOURCE) $(DEP_CPP_HTTP_) "$(INTDIR)"
+
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\HTTP_Server.cpp
+
+!IF "$(CFG)" == "jaws - Win32 Release"
+
+DEP_CPP_HTTP_S=\
+ "..\..\JAWS/server/HTTP_Handler.h"\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ "..\..\JAWS/server/HTTP_Server.h"\
+ "..\..\JAWS/server/IO.h"\
+ {$(INCLUDE)}"\ace\Acceptor.cpp"\
+ {$(INCLUDE)}"\ace\Acceptor.h"\
+ {$(INCLUDE)}"\ace\Acceptor.i"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.cpp"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.h"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.i"\
+ {$(INCLUDE)}"\ace\Asynch_IO.h"\
+ {$(INCLUDE)}"\ace\Asynch_IO.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Dynamic.h"\
+ {$(INCLUDE)}"\ace\Dynamic.i"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Get_Opt.h"\
+ {$(INCLUDE)}"\ace\Get_Opt.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\Module.cpp"\
+ {$(INCLUDE)}"\ace\Module.h"\
+ {$(INCLUDE)}"\ace\Module.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\Strategies.h"\
+ {$(INCLUDE)}"\ace\Strategies_T.cpp"\
+ {$(INCLUDE)}"\ace\Strategies_T.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
+ {$(INCLUDE)}"\ace\Stream_Modules.h"\
+ {$(INCLUDE)}"\ace\Stream_Modules.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.cpp"\
+ {$(INCLUDE)}"\ace\Svc_Handler.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task_T.cpp"\
+ {$(INCLUDE)}"\ace\Task_T.h"\
+ {$(INCLUDE)}"\ace\Task_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\HTTP_Server.obj" : $(SOURCE) $(DEP_CPP_HTTP_S) "$(INTDIR)"
+
+
+!ELSEIF "$(CFG)" == "jaws - Win32 Debug"
+
+DEP_CPP_HTTP_S=\
+ "..\..\JAWS/server/HTTP_Handler.h"\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ "..\..\JAWS/server/HTTP_Server.h"\
+ "..\..\JAWS/server/IO.h"\
+ {$(INCLUDE)}"\ace\Acceptor.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.cpp"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.h"\
+ {$(INCLUDE)}"\ace\Asynch_Acceptor.i"\
+ {$(INCLUDE)}"\ace\Asynch_IO.h"\
+ {$(INCLUDE)}"\ace\Asynch_IO.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Get_Opt.h"\
+ {$(INCLUDE)}"\ace\Get_Opt.i"\
+ {$(INCLUDE)}"\ace\Handle_Set.h"\
+ {$(INCLUDE)}"\ace\Handle_Set.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\Local_Tokens.h"\
+ {$(INCLUDE)}"\ace\Local_Tokens.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Map_Manager.cpp"\
+ {$(INCLUDE)}"\ace\Map_Manager.h"\
+ {$(INCLUDE)}"\ace\Map_Manager.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\Message_Queue.cpp"\
+ {$(INCLUDE)}"\ace\Message_Queue.h"\
+ {$(INCLUDE)}"\ace\Message_Queue.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Pipe.h"\
+ {$(INCLUDE)}"\ace\Pipe.i"\
+ {$(INCLUDE)}"\ace\Proactor.h"\
+ {$(INCLUDE)}"\ace\Proactor.i"\
+ {$(INCLUDE)}"\ace\Reactor.h"\
+ {$(INCLUDE)}"\ace\Reactor.i"\
+ {$(INCLUDE)}"\ace\ReactorEx.h"\
+ {$(INCLUDE)}"\ace\ReactorEx.i"\
+ {$(INCLUDE)}"\ace\Service_Config.h"\
+ {$(INCLUDE)}"\ace\Service_Config.i"\
+ {$(INCLUDE)}"\ace\Service_Object.h"\
+ {$(INCLUDE)}"\ace\Service_Object.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Shared_Object.h"\
+ {$(INCLUDE)}"\ace\Shared_Object.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
+ {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\Stack.cpp"\
+ {$(INCLUDE)}"\ace\Stack.h"\
+ {$(INCLUDE)}"\ace\Stack.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\Strategies.h"\
+ {$(INCLUDE)}"\ace\Strategies_T.cpp"\
+ {$(INCLUDE)}"\ace\Strategies_T.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
+ {$(INCLUDE)}"\ace\Svc_Handler.h"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_Options.h"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Task.h"\
+ {$(INCLUDE)}"\ace\Task.i"\
+ {$(INCLUDE)}"\ace\Task_T.h"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Thread_Manager.h"\
+ {$(INCLUDE)}"\ace\Thread_Manager.i"\
+ {$(INCLUDE)}"\ace\Time_Value.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.h"\
+ {$(INCLUDE)}"\ace\Timer_Queue.i"\
+ {$(INCLUDE)}"\ace\Token.h"\
+ {$(INCLUDE)}"\ace\Token.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\HTTP_Server.obj" : $(SOURCE) $(DEP_CPP_HTTP_S) "$(INTDIR)"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\HTTP_Handler.cpp
+DEP_CPP_HTTP_H=\
+ "..\..\JAWS/server/HTTP_Handler.h"\
+ "..\..\JAWS/server/HTTP_Helpers.h"\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ "..\..\JAWS/server/IO.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Asynch_IO.h"\
+ {$(INCLUDE)}"\ace\Asynch_IO.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\HTTP_Handler.obj" : $(SOURCE) $(DEP_CPP_HTTP_H) "$(INTDIR)"
+
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\IO.cpp
+DEP_CPP_IO_CP=\
+ "..\..\JAWS/server/HTTP_Handler.h"\
+ "..\..\JAWS/server/HTTP_Helpers.h"\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ "..\..\JAWS/server/IO.h"\
+ "..\..\JAWS/server/JXH_List.h"\
+ "..\..\JAWS/server/VFS.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\Addr.h"\
+ {$(INCLUDE)}"\ace\Addr.i"\
+ {$(INCLUDE)}"\ace\Asynch_IO.h"\
+ {$(INCLUDE)}"\ace\Asynch_IO.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\INET_Addr.h"\
+ {$(INCLUDE)}"\ace\INET_Addr.i"\
+ {$(INCLUDE)}"\ace\IPC_SAP.h"\
+ {$(INCLUDE)}"\ace\IPC_SAP.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Malloc.h"\
+ {$(INCLUDE)}"\ace\Malloc.i"\
+ {$(INCLUDE)}"\ace\Malloc_T.cpp"\
+ {$(INCLUDE)}"\ace\Malloc_T.h"\
+ {$(INCLUDE)}"\ace\Malloc_T.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\Memory_Pool.h"\
+ {$(INCLUDE)}"\ace\Memory_Pool.i"\
+ {$(INCLUDE)}"\ace\Message_Block.h"\
+ {$(INCLUDE)}"\ace\Message_Block.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Set.cpp"\
+ {$(INCLUDE)}"\ace\Set.h"\
+ {$(INCLUDE)}"\ace\Set.i"\
+ {$(INCLUDE)}"\ace\Signal.h"\
+ {$(INCLUDE)}"\ace\Signal.i"\
+ {$(INCLUDE)}"\ace\Singleton.cpp"\
+ {$(INCLUDE)}"\ace\Singleton.h"\
+ {$(INCLUDE)}"\ace\Singleton.i"\
+ {$(INCLUDE)}"\ace\SOCK.h"\
+ {$(INCLUDE)}"\ace\SOCK.i"\
+ {$(INCLUDE)}"\ace\SOCK_IO.h"\
+ {$(INCLUDE)}"\ace\SOCK_IO.i"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.h"\
+ {$(INCLUDE)}"\ace\SOCK_Stream.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\IO.obj" : $(SOURCE) $(DEP_CPP_IO_CP) "$(INTDIR)"
+
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\VFS.cpp
+DEP_CPP_VFS_C=\
+ "..\..\JAWS/server/HTTP_Helpers.h"\
+ "..\..\JAWS/server/JXH_List.h"\
+ "..\..\JAWS/server/VFS.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.h"\
+ {$(INCLUDE)}"\ace\Event_Handler.i"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\Mem_Map.h"\
+ {$(INCLUDE)}"\ace\Mem_Map.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\Singleton.cpp"\
+ {$(INCLUDE)}"\ace\Singleton.h"\
+ {$(INCLUDE)}"\ace\Singleton.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
+ {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
+ {$(INCLUDE)}"\ace\Synch.h"\
+ {$(INCLUDE)}"\ace\Synch.i"\
+ {$(INCLUDE)}"\ace\Synch_T.cpp"\
+ {$(INCLUDE)}"\ace\Synch_T.h"\
+ {$(INCLUDE)}"\ace\Synch_T.i"\
+ {$(INCLUDE)}"\ace\Thread.h"\
+ {$(INCLUDE)}"\ace\Thread.i"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\VFS.obj" : $(SOURCE) $(DEP_CPP_VFS_C) "$(INTDIR)"
+
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\HTTP_Request.cpp
+DEP_CPP_HTTP_R=\
+ "..\..\JAWS/server/HTTP_Request.h"\
+ {$(INCLUDE)}"\ace\ACE.h"\
+ {$(INCLUDE)}"\ace\ACE.i"\
+ {$(INCLUDE)}"\ace\config-win32-common.h"\
+ {$(INCLUDE)}"\ace\config.h"\
+ {$(INCLUDE)}"\ace\Log_Msg.h"\
+ {$(INCLUDE)}"\ace\Log_Priority.h"\
+ {$(INCLUDE)}"\ace\Log_Record.h"\
+ {$(INCLUDE)}"\ace\Log_Record.i"\
+ {$(INCLUDE)}"\ace\OS.h"\
+ {$(INCLUDE)}"\ace\OS.i"\
+ {$(INCLUDE)}"\ace\SString.h"\
+ {$(INCLUDE)}"\ace\SString.i"\
+ {$(INCLUDE)}"\ace\stdcpp.h"\
+ {$(INCLUDE)}"\ace\Trace.h"\
+ {$(INCLUDE)}"\ace\ws2tcpip.h"\
+
+
+"$(INTDIR)\HTTP_Request.obj" : $(SOURCE) $(DEP_CPP_HTTP_R) "$(INTDIR)"
+
+
+# End Source File
+# End Target
+# End Project
+################################################################################
diff --git a/apps/JAWS/server/jaws.mdp b/apps/JAWS/server/jaws.mdp Binary files differnew file mode 100644 index 00000000000..0a026c92708 --- /dev/null +++ b/apps/JAWS/server/jaws.mdp diff --git a/apps/JAWS/server/main.cpp b/apps/JAWS/server/main.cpp new file mode 100644 index 00000000000..d63b4d050a0 --- /dev/null +++ b/apps/JAWS/server/main.cpp @@ -0,0 +1,21 @@ +// main.cpp + +#include "ace/Service_Config.h" +#include "JAWS/server/HTTP_Server.h" + +ACE_STATIC_SVC_REQUIRE(HTTP_Server) + +int +main (int argc, char *argv[]) +{ + ACE_Service_Config daemon; + + if (daemon.open (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); + + // Run forever, performing the configured services until we receive + // a SIGINT. + + daemon.run_reactor_event_loop (); + return 0; +} diff --git a/apps/JAWS/server/svc.conf b/apps/JAWS/server/svc.conf new file mode 100644 index 00000000000..5a92aa00483 --- /dev/null +++ b/apps/JAWS/server/svc.conf @@ -0,0 +1,10 @@ +# +# -p port number +# -n threads in the server +# -s = 0 -> synch thread pool +# = 1 -> thread per request +# = 2 -> asynch thread pool +# +static HTTP_Server "HTTP_Server -p 5432 -n 10 -s 2" +#dynamic HTTP_Server Service_Object * .shobj/HTTP_Server:jaws "HTTP_Server -p 5432 -s HTTP_Service" + diff --git a/apps/JAWS/server/test_HTTP_Request.cpp b/apps/JAWS/server/test_HTTP_Request.cpp new file mode 100644 index 00000000000..5f75fa00607 --- /dev/null +++ b/apps/JAWS/server/test_HTTP_Request.cpp @@ -0,0 +1,52 @@ +#include <stdio.h> +#include "HTTP_Request.h" +#include "ace/Mem_Map.h" + +static char* request_strings [] = +{ + "PUT filename.html HTTP/1.0\nContent-type: text/plain\nContent-length: 15\r\n\r\nTHIS IS DATA!!!", + "GET \\~irfan\\hi\\mom.html\r\n\r\n", + "GET \\~harrison\\mybutt.html in my program\r\n\r\n", + "PUT \\~harrison\bilename.html HTTP/1.0\ni suck... asldkasldk Content-type: text/plain\nContent-length: 1024 alskdkls", + "PUT bomb in my program\r\n\r\n" +}; + +static int total = 1; + +int +main() +{ + int index = 0; + HTTP_Request request; + while (index < total) + { + const char *r = request_strings[index++]; + int len = ::strlen (r); + request.init (r, len); + request.dump (); + + if (request.type () == HTTP_Request::PUT) + { + ACE_Mem_Map outfile; + ACE_HANDLE handle = ACE_OS::open (request.filename (), + FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED | O_RDWR | O_CREAT); + if (outfile.map (handle, + request.content_length (), + PROT_RDWR, + MAP_SHARED) == -1) + ACE_ERROR ((LM_ERROR, "%p: opening %s.\n", + "main", + request.filename ())); + else + { + // Write the file. + ACE_OS::memcpy (outfile.addr (), + request.data (), + request.content_length ()); + outfile.sync (); + } + } + } + + return 0; +} |