diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-10 15:38:40 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-08-10 15:38:40 +0000 |
commit | 0a2895011904ebc32b024f018873df4d2d5e84a6 (patch) | |
tree | 3521b5b494aea0c220e1e66539b2157b17d9d93a /apps | |
parent | faf3738aaed030b3cbc16d5c6df3c6c66d1e18b1 (diff) | |
download | ATCD-0a2895011904ebc32b024f018873df4d2d5e84a6.tar.gz |
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r-- | apps/JAWS/clients/Caching/Location_Server.cpp | 4 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/Location_Server.h | 42 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/Location_Server.i | 3 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/Web_Locator.cpp | 3 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/Web_Locator.h | 80 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/Web_Locator.i | 38 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/http_client.cpp | 21 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/http_handler.cpp | 26 | ||||
-rw-r--r-- | apps/JAWS/clients/Caching/http_handler.h | 4 |
9 files changed, 133 insertions, 88 deletions
diff --git a/apps/JAWS/clients/Caching/Location_Server.cpp b/apps/JAWS/clients/Caching/Location_Server.cpp index 7fb23bfe9f1..bbb6b07a753 100644 --- a/apps/JAWS/clients/Caching/Location_Server.cpp +++ b/apps/JAWS/clients/Caching/Location_Server.cpp @@ -11,7 +11,7 @@ #include "Location_Server.i" #endif /* __ACE_INLINE__ */ - - +// @@ Nanbor, please make sure that you add the template +// specializations that are necessary to get this to work with GCC. #endif /* ACE_LOCATION_SERVER_C */ diff --git a/apps/JAWS/clients/Caching/Location_Server.h b/apps/JAWS/clients/Caching/Location_Server.h index cf12dfe8f67..a1cbea01165 100644 --- a/apps/JAWS/clients/Caching/Location_Server.h +++ b/apps/JAWS/clients/Caching/Location_Server.h @@ -64,8 +64,8 @@ class ACE_Location_Service { public: ACE_URL_OfferID export (ACE_URL_Offer &offer); - // Register an offer to the location server. Operation will fail - // if there is an offer with identical URL string exist in the + // Register an offer to the location server. Operation will fail if + // there is an offer with identical URL string exist in the // repository and the function returns NULL. On success, it returns // an OfferID. @@ -73,20 +73,21 @@ public: const ACE_URL_Property_Seq *pseq, const int how_many, ACE_URL_Offer_Seq *offer); - // Query the offer repository whether there're offers that match our - // requirement specified in <how> and <pseq>. Create an offer sequence - // that contains at most <how_many> offers in it. Offers are picked out - // from the beginning. So if there are too many offers that meet our - // requirement, some may never get picked. On success, the function - // return 0, non-zero indicates error condition. + // Query the offer repository whether there are offers that match + // our requirement specified in <how> and <pseq>. Create an offer + // sequence that contains at most <how_many> offers in it. Offers + // are picked out from the beginning. So if there are too many + // offers that meet our requirement, some may never get picked. On + // success, the function return 0, non-zero indicates error + // condition. int withdraw (const ACE_URL_OfferID offer); // Withdraw an image offer. return 0 if succeed, -1 otherwise (most // likely, there isn't an offer with id:<offer>. ACE_URL_Offer *describe (const ACE_URL_OfferID offer); - // Query a specific offer. This function returns a pointer - // points to the ACE_URL_Offer field with corresponding <offer> id. + // Query a specific offer. This function returns a pointer points + // to the ACE_URL_Offer field with corresponding <offer> id. int modify (const ACE_URL_OfferID offer, const char *url = 0, @@ -96,21 +97,22 @@ public: // the offer will be replaced by string pointed by <url>. <del> // points to a sequence of properties to be delete from the offer. // <modify> points to a sequence of properties to be modified. It - // this offer contains a property with the same name, the value of this - // property will be replaced by the new value. If the offer doesn't - // contain the same property, this property will be added to the offer. + // this offer contains a property with the same name, the value of + // this property will be replaced by the new value. If the offer + // doesn't contain the same property, this property will be added to + // the offer. protected: ACE_URL_Repository repository_; // URL back store. - unsigned long id_counter_; - // This number is used to maintain the uniqueness of OfferID. - // An offer ID is derived from concatenating two strings. First number is - // the ASCII representation of number from ACE_OS::time() and the second - // number is the ASCII representation of <id_counter_>. The <id_counter_> - // get incremented everytime a new offer ID is generated. The length of - // Offer ID is yet to be determined. + u_long id_counter_; + // This number is used to maintain the uniqueness of OfferID. An + // offer ID is derived from concatenating two strings. First number + // is the ASCII representation of number from ACE_OS::time() and the + // second number is the ASCII representation of <id_counter_>. The + // <id_counter_> get incremented everytime a new offer ID is + // generated. The length of Offer ID is yet to be determined. }; #if define (__ACE_INLINE__) diff --git a/apps/JAWS/clients/Caching/Location_Server.i b/apps/JAWS/clients/Caching/Location_Server.i index cb4255fd5dc..433dc65abc5 100644 --- a/apps/JAWS/clients/Caching/Location_Server.i +++ b/apps/JAWS/clients/Caching/Location_Server.i @@ -11,7 +11,8 @@ ACE_URL_Record::id (void) const ACE_INLINE void ACE_URL_Record::id (ACE_URL_OfferID id) { - delete[] this->id_; + delete [] this->id_; + if (id) { ACE_NEW (this->id_, TCHAR[ACE_OS::strlen (id) + 1]); diff --git a/apps/JAWS/clients/Caching/Web_Locator.cpp b/apps/JAWS/clients/Caching/Web_Locator.cpp index d2cfa7328ac..31bcc4c6cdf 100644 --- a/apps/JAWS/clients/Caching/Web_Locator.cpp +++ b/apps/JAWS/clients/Caching/Web_Locator.cpp @@ -27,7 +27,6 @@ ACE_URL_Locator_Query::query (const ACE_Specified_Property how, { // First send out request - // Then, receive offers or error code. return -1; @@ -75,4 +74,6 @@ ACE_URL_Locator_Register::modify (const ACE_URL_OfferID offer, return -1; } +// @@ Nanbor, please make sure that you add the template +// specializations that are necessary to get this to work with GCC. #endif /* ACE_WEB_LOCATOR_C */ diff --git a/apps/JAWS/clients/Caching/Web_Locator.h b/apps/JAWS/clients/Caching/Web_Locator.h index 6dde27fad8a..f8ea9cd67ca 100644 --- a/apps/JAWS/clients/Caching/Web_Locator.h +++ b/apps/JAWS/clients/Caching/Web_Locator.h @@ -15,6 +15,9 @@ // // ============================================================================ +// @@ Nanbor, should we change this name from "Web_Locator" to +// "Content_Locator" or "URL_Locator"? It seems like "Web" is too general! + #if !defined (ACE_WEB_LOCATOR_H) #define ACE_WEB_LOCATOR_H @@ -23,7 +26,7 @@ class ACE_Export ACE_URL_Property // = TITLE - // Defines a property of an URL. + // Defines a property of a URL. // // = DESCRIPTION // A property contains a <name> and a <value>. @@ -35,7 +38,7 @@ public: ACE_URL_Property (ACE_URL_Property &p); // Copy constructor. - ~ACE_URL_Property (); + ~ACE_URL_Property (void); // Destructor. ACE_URL_Property &operator= (ACE_URL_Property &rhs); @@ -64,17 +67,17 @@ protected: // Property name pointer. LPTSTR value_; - // Perperty value. + // Property value. } ; typedef ACE_Array<ACE_URL_Property> ACE_URL_Property_Seq; class ACE_Export ACE_URL_Offer // = TITLE - // Defines an URL offer. + // Defines a URL offer. // // = DESCRIPTION - // An URL offer is defined by an <url> and an + // A URL offer is defined by an <url> and an // <ACE_URL_Property_Seq>. { public: @@ -91,14 +94,16 @@ public: // Assignment operator. int operator== (ACE_URL_Offer &rhs) const; + // Equality operator. int operator!= (ACE_URL_Offer &rhs) const; + // Inequality operator. LPCTSTR url (void) const; - // Get url string. + // Get URL string. Void url (LPCTSTR url); - // Set url. + // Set URL. ACE_URL_Property_Seq &url_properties (void); // Get properties of this offer. @@ -114,9 +119,10 @@ protected: // Properties associate with this offer. private: + // @@ Nanbor, please make sure you move this definition into the *.cpp file. ACE_URL_Offer (void) {} // Do not allow access to default constructor -} ; +}; typedef ACE_Array<ACE_URL_Offer> ACE_URL_Offer_Seq; typedef char *ACE_URL_OfferID; @@ -126,17 +132,21 @@ class ACE_Export ACE_URL_Locator // Base class for the URL locator. // // = DESCRIPTION - // This class provide an interface for clients to - // communicate with an URL locator thru a stream - // specified in handle. + // This class provide an interface for clients to communicate + // with a URL locator thru a stream specified in <handle>. { public: - enum ACE_Specified_Property { NONE, SOME, ALL }; + enum ACE_Specified_Property + { + NONE, + SOME, + ALL + }; // Specify how to select offers. Ace_Url_Locator (ACE_HANDLE handle = ACE_INVALID_HANDLE, const ACE_Time_Value &timeout = ACE_Time_Value::zero); - // Try to "Bind" to an URL locator. + // Try to "Bind" to a URL locator. ~ACE_URL_Locator (void); // Default destructor. @@ -155,29 +165,37 @@ public: LPCTSTR error_status (void); // Provide detailed human readable error status. + protected: int errno_; // Record operation error (to avoid using exception.) ACE_Time_Value timeout_; - // Timeout value when communicate with the connected location server. + // Timeout value when communicate with the connected location + // server. ACE_HANDLE handle_; // Handle used to communicate with locator. }; +// @@ Nanbor, I'm not really sure why you are using inheritance here? +// Is this so that you don't have to reimplement the accessor methods +// in ACE_URL_Locator? There doesn't seem to be any virtual functions +// in the base class. Can you please explain this design choice to +// me?! + class ACE_Export ACE_URL_Locator_Query : public ACE_URL_Locator // = TITLE - // A query interface to locate an URL. + // A query interface to locate a URL. // // = DESCRIPTION // This class provide an interface for clients to - // query an URL locator with certain properties. + // query a URL locator with certain properties. { public: ACE_URL_Locator_Query (ACE_HANDLE handle = ACE_INVALID_HANDLE, const ACE_Time_Value &timeout = ACE_Time_Value::zero); - // Try to "Bind" to an URL locator. + // Try to "Bind" to a URL locator. ~ACE_URL_Locator_Query (void); // Default destructor. @@ -186,24 +204,21 @@ public: const ACE_URL_Property_Seq *pseq, const int how_many, ACE_URL_Offer_Seq *offer); - // Query the locator for images with designate - // properties (none, some, or all). The locator - // being queried will return a sequence of offers - // with <how_many> offers in it. This interface - // allocates <offer> so users must deallocate it - // after use. + // Query the locator for HTTP with designate properties (none, some, + // or all). The locator being queried will return a sequence of + // offers with <how_many> offers in it. This interface allocates + // <offer> so users must deallocate it after use. }; - class ACE_Export ACE_URL_Locator_Register : public ACE_URL_Locator // = TITLE - // This class provides interfaces for image servers to - // export their services. + // This class provides interfaces for HTTP servers to export + // their services. // // = DESCRIPTION - // HTTP servers can use this class to register their - // offers to an URL locator so clients can locate - // resources they provide thru the locator. + // HTTP servers can use this class to register their offers to a + // URL locator so clients can locate resources provided by + // servers thru the locator. { public: ACE_URL_Locator_Register (ACE_HANDLE handle = ACE_INVALID_HANDLE, @@ -214,10 +229,10 @@ public: // Default destructor. ACE_URL_OfferID export (const ACE_URL_Offer *offer); - // Export an image offer to the locator. + // Export an offer to the locator. int withdraw (const ACE_URL_OfferID offer); - // Withdraw an image offer. return 0 if succeed, -1 otherwise. + // Withdraw an offer. return 0 if succeed, -1 otherwise. ACE_URL_Offer *describe (const ACE_URL_OfferID offer); // Query a specific offer. @@ -226,10 +241,9 @@ public: const char *url = 0, const ACE_URL_Property_Seq *del = 0, const ACE_URL_Property_Seq *modify = 0); - // Modify an already registered offer. + // Modify a previously registered offer. }; - #if defined (__ACE_INLINE__) #include "Web_Locator.i" #endif /* __ACE_INLINE__ */ diff --git a/apps/JAWS/clients/Caching/Web_Locator.i b/apps/JAWS/clients/Caching/Web_Locator.i index 528d0cacb8b..32919f5ad8b 100644 --- a/apps/JAWS/clients/Caching/Web_Locator.i +++ b/apps/JAWS/clients/Caching/Web_Locator.i @@ -4,7 +4,8 @@ ACE_INLINE ACE_URL_Property::ACE_URL_Property (LPCTSTR name, LPCTSTR value) - : name_ (0), value_ (0) + : name_ (0), + value_ (0) { this->name (name); this->value (value); @@ -12,14 +13,15 @@ ACE_URL_Property::ACE_URL_Property (LPCTSTR name, LPCTSTR value) ACE_INLINE ACE_URL_Property::ACE_URL_Property (ACE_URL_Property &p) - : name_ (0), value_ (0) + : name_ (0), + value_ (0) { this->name (p.name ()); this->value (p.value ()); } ACE_INLINE -ACE_URL_Property::~ACE_URL_Property () +ACE_URL_Property::~ACE_URL_Property (void) { delete[] this->name_; delete[] this->value_; @@ -51,7 +53,7 @@ ACE_URL_Property::operator== (ACE_URL_Property &rhs) const ACE_INLINE int ACE_URL_Property::operator!= (ACE_URL_Property &rhs) const { - return ! (*this == rhs); + return !(*this == rhs); } ACE_INLINE LPCTSTR @@ -63,7 +65,8 @@ ACE_URL_Property::name (void) const ACE_INLINE void ACE_URL_Property::name (LPCTSTR name) { - delete[] this->name_; + delete [] this->name_; + if (name) { ACE_NEW (this->name_, TCHAR[ACE_OS::strlen (name) + 1]); @@ -82,7 +85,8 @@ ACE_URL_Property::value (void) const ACE_INLINE void ACE_URL_Property::value (LPCTSTR value) { - delete[] this->value_; + delete [] this->value_; + if (value) { ACE_NEW (this->value_, TCHAR[ACE_OS::strlen (value) + 1]); @@ -94,7 +98,8 @@ ACE_URL_Property::value (LPCTSTR value) ACE_INLINE ACE_URL_Offer::ACE_URL_Offer (LPCTSTR url, ACE_URL_Property_Seq &prop_seq) - : url_ (0), prop_ (prop_seq) + : url_ (0), + prop_ (prop_seq) { this->url (url); } @@ -102,7 +107,7 @@ ACE_URL_Offer::ACE_URL_Offer (LPCTSTR url, ACE_URL_Property_Seq &prop_seq) ACE_INLINE ACE_URL_Offer::~ACE_URL_Offer (void) { - delete[] this->url_; + delete [] this->url_; } ACE_INLINE ACE_URL_Offer & @@ -119,17 +124,21 @@ ACE_URL_Offer::operator= (ACE_URL_Offer &rhs) ACE_INLINE int ACE_URL_Offer::operator== (ACE_URL_Offer &rhs) const { - if (this != &rhs) - if (ACE_OS::strcmp (this->url (), rhs.url ()) || - (this->prop_ != rhs.url_properties ())) + // @@ Nanbor, I reformatted this expression. Please make sure it is + // still correct! + + if (this != &rhs + && (ACE_OS::strcmp (this->url (), rhs.url ()) + || this->prop_ != rhs.url_properties ())) return 0; - return 1; + else + return 1; } ACE_INLINE int ACE_URL_Offer::operator!= (ACE_URL_Offer &rhs) const { - return ! (*this == rhs); + return !(*this == rhs); } ACE_INLINE LPCTSTR @@ -141,7 +150,8 @@ ACE_URL_Offer::url (void) const ACE_INLINE void ACE_URL_Offer::url (LPCTSTR url) { - delete[] this->url_; + delete [] this->url_; + if (url != 0) { ACE_NEW (this->url_, TCHAR[ACE_OS::strlen (url) + 1]); diff --git a/apps/JAWS/clients/Caching/http_client.cpp b/apps/JAWS/clients/Caching/http_client.cpp index f8990bf9dec..3f624a6c9f6 100644 --- a/apps/JAWS/clients/Caching/http_client.cpp +++ b/apps/JAWS/clients/Caching/http_client.cpp @@ -31,19 +31,24 @@ main (int, char *[]) char buf[BUFSIZ]; - ACE_OS::fprintf (stderr, "* "); + ACE_DEBUG ((LM_DEBUG, "* ")); + while (ACE_OS::fgets (buf, sizeof (buf), stdin) != NULL) { - char * s = buf; - while (*s == ' ' || *s == '\t') + char *s = buf; + + while (isspace (*s)) s++; if (*s == '!') { - // Shell command - do s++; while (*s == ' ' || *s == '\t'); + do + s++; + while (isspace (*s)); + + // Shell command. if (ACE_OS::system (s) == -1) - ACE_OS::fprintf (stderr, " ! Error executing: %s\n", s); + ACE_ERROR ((LM_ERROR, " ! Error executing: %s\n", s)); } else if (ACE_OS::strncmp (s, "http://", 7) == 0) { @@ -52,9 +57,9 @@ main (int, char *[]) connector.connect (s); } else - ACE_OS::fprintf (stderr, " ? I don't understand: %s\n", s); + ACE_ERROR ((LM_ERROR, " ? I don't understand: %s\n", s)); - ACE_OS::fprintf (stderr, "* "); + ACE_ERROR ((LM_ERROR, "* ")); } ACE_DEBUG ((LM_DEBUG, "\nBye!\n")); diff --git a/apps/JAWS/clients/Caching/http_handler.cpp b/apps/JAWS/clients/Caching/http_handler.cpp index 876d8e3efd8..0ae1ecee741 100644 --- a/apps/JAWS/clients/Caching/http_handler.cpp +++ b/apps/JAWS/clients/Caching/http_handler.cpp @@ -37,6 +37,7 @@ HTTP_Handler::HTTP_Handler (const char * path) // Find the filename. const char *last = ACE_OS::strrchr (path, '/'); + if (last == 0) last = path; else if (last[1] == '\0') @@ -79,18 +80,23 @@ HTTP_Handler::svc (void) do { - while (((count += this->peer ().recv_n (buf+count, 1)) > 0) + while (((count += this->peer ().recv_n (buf + count, 1)) > 0) && ((u_int) count < sizeof (buf))) { buf[count] = '\0'; + if (count < 2) continue; - done = ACE_OS::strcmp (buf+count-4, "\n\n") == 0; + done = ACE_OS::strcmp (buf + count - 4, "\n\n") == 0; + if (done) break; + if (count < 4) continue; - done = ACE_OS::strcmp (buf+count-4, "\r\n\r\n") == 0; + + done = ACE_OS::strcmp (buf + count - 4, "\r\n\r\n") == 0; + if (done) break; } @@ -99,6 +105,7 @@ HTTP_Handler::svc (void) { char *last = ACE_OS::strrchr (buf, '\n'); last[0] = '\0'; + if ((contentlength = ACE_OS::strstr (buf, "\nContent-length:")) || (contentlength = ACE_OS::strstr (buf, "\nContent-Length:"))) done = 1; @@ -131,8 +138,9 @@ HTTP_Handler::svc (void) this->peer ().recv_n (afh.address (), this->response_size_); - ACE_OS::fprintf (stdout, " ``%s'' is now cached.\n", - this->filename_); + ACE_DEBUG ((LM_DEBUG, + " ``%s'' is now cached.\n", + this->filename_)); } else { @@ -167,7 +175,9 @@ HTTP_Connector::connect (const char * url) if (this->parseurl (url, host, &port, path) == -1) { - ACE_DEBUG ((LM_DEBUG, "HTTP_Connector, error parsing url: %s\n", url)); + ACE_DEBUG ((LM_DEBUG, + "HTTP_Connector, error parsing url: %s\n", + url)); return -1; } @@ -177,8 +187,8 @@ HTTP_Connector::connect (const char * url) // First check the cache. if (ACE_Filecache::instance ()->find (hh.filename ())) { - ACE_OS::fprintf (stdout, " ``%s'' is already cached.\n", - hh.filename ()); + ACE_DEBUG ((LM_DEBUG, " ``%s'' is already cached.\n", + hh.filename ())); return 0; } diff --git a/apps/JAWS/clients/Caching/http_handler.h b/apps/JAWS/clients/Caching/http_handler.h index 117a2a15f59..b0ea361c8d4 100644 --- a/apps/JAWS/clients/Caching/http_handler.h +++ b/apps/JAWS/clients/Caching/http_handler.h @@ -29,6 +29,7 @@ class HTTP_Handler // The fetched file is cached. { public: + // = Initialization methods. HTTP_Handler (void); HTTP_Handler (const char * path); @@ -36,7 +37,7 @@ public: virtual int svc (void); // Entry points defined by the abstract Svc_Handler. - const char * filename (void) const; + const char *filename (void) const; // Accessor to the file being fetched. private: @@ -64,6 +65,7 @@ private: char *host, u_short *port, char *path); + // Helper function. private: ACE_Connector<HTTP_Handler, ACE_SOCK_CONNECTOR> connector_; |