ace-6.3.3+dfsg.orig/0000775000175000017500000000000012576472437014420 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/lib/0000775000175000017500000000000012576472436015165 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/lib/.empty0000644000175000017500000000010412576461726016315 0ustar pgquilespgquilesThis file keeps the directory around even when using cvs update -dP ace-6.3.3+dfsg.orig/netsvcs/0000775000175000017500000000000012576472436016104 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/lib/0000775000175000017500000000000012576472436016652 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/lib/Token_Handler.h0000644000175000017500000001756212576461726021551 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Token_Handler.h * * @author Douglas C. Schmidt (schmidt@cs.wustl.edu) * Tim Harrison (harrison@cs.wustl.edu) */ //============================================================================= #ifndef ACE_TOKEN_HANDLER_H #define ACE_TOKEN_HANDLER_H #include "ace/Acceptor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Acceptor.h" #include "ace/Local_Tokens.h" #include "ace/Token_Collection.h" #include "ace/Token_Request_Reply.h" #include "ace/svc_export.h" #if defined (ACE_HAS_TOKENS_LIBRARY) /** * @class ACE_Token_Handler * * @brief Product object created by an . A * exchanges messages with a object * on the client-side. * * This class is the main workhorse of the ACE Token service. It * receives token operation requests from remote clients and turns * them into calls on local tokens (acquire, release, renew, and * remove). In OMG CORBA terms, it is an object adapter. It also * schedules and handles timeouts that are used to support "timed * waits." Clients used timed waits to bound the amount of time * they block trying to get a token. */ class ACE_Svc_Export ACE_Token_Handler : public ACE_Svc_Handler { public: // = Initialization and termination. /// Default constructor. ACE_Token_Handler (ACE_Thread_Manager * = 0); // = Accessor and mutator methods. // = Remote operations "exported" to a client. /** * Try to acquire the token. * Precondition: client *may* hold the token already (i.e., * supports recursive acquisitions). */ virtual int acquire (ACE_Token_Proxy *proxy); /// Try to acquire the token. virtual int try_acquire (ACE_Token_Proxy *proxy); /// Release the token and allow the next client that is waiting to /// proceed. Preconditions: client must hold the token. virtual int release (ACE_Token_Proxy *proxy); /// Yield the token if any clients are waiting, otherwise keep the /// token. Preconditions: client must hold the token. virtual int renew (ACE_Token_Proxy *proxy); /** * Remove the specified token from the Token_Map. Preconditions: * ACE_Token must exist. @@ Any other preconditions, e.g., must * client hold token, must there be no waiters, etc.? */ virtual int remove (ACE_Token_Proxy *proxy); /// Called by TS_[Mutex,RLock,WLock] when we hold the mutex and /// someone wants it. void sleep_hook (void); /// Called by TS_[Mutex,RLock,WLock] when we are waiting and acquire /// the mutex. void token_acquired (ACE_TPQ_Entry *); protected: // = Low level routines for framing requests, dispatching // operations, and returning replies. /// Our connection has been closed. virtual int abandon (int send_error); /// Receive, frame, and decode the client's request. virtual int recv_request (void); /// Dispatch the appropriate operation to handle the client's /// request. virtual int dispatch (void); /// Create and send a reply to the client. virtual int send_reply (ACE_UINT32 errnum); // = Demultiplexing hooks. /// Callback method invoked by the when client events /// arrive. virtual int handle_input (ACE_HANDLE); // = Timer hook. /// Enable clients to limit the amount of time they wait for a token. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); /// return a proxy for the calling client_id and token name. ACE_Token_Proxy *get_proxy (void); private: /// Switches on the type of token_request_ and creates a new /// Token_Proxy. virtual ACE_Token_Proxy *create_proxy (void); /// Keeps track of the synchronization options (i.e., the timeout /// interval). ACE_Synch_Options request_options_; /// collection of the client's token proxies. ACE_Token_Collection collection_; /// ID returned by the Reactor that is used to kill registered timers /// when a token operation times out. long timeout_id_; /// Cache request from the client. ACE_Token_Request token_request_; /// Cache reply to the client. ACE_Token_Reply token_reply_; }; // = DESCRIPTION of ACE_TS_* classes: // When Tokens are released, waiting token proxies are notified // when the releasing thread calls token_acquired on the waiting // proxy. The Token Server specializes ACE_Token_Proxy to // redefine the implementation of token_acquired. When // token_acquired is called, the Token_Handler can then send the // response back over the socket connection to unblock the // client side. // Since only the Token_Handler uses ACE_TS_Mutex, we've moved // the definition to the .cpp file. /** * @class ACE_TS_Mutex * * @brief ACE_TS_Mutex -- ACE_*T*oken_*S*erver_Mutex */ class ACE_TS_Mutex : public ACE_Local_Mutex { public: /// Creation. ACE_TS_Mutex (const ACE_TCHAR *name, ACE_Token_Handler *th); protected: /// Somebody wants our token! virtual void sleep_hook (void); /** * We've been taken off the waiters list and given the token! Call * the Token_Handler associated at construction, so it can tell the * remote client. */ virtual void token_acquired (ACE_TPQ_Entry *); /// Duplication. ACE_TS_Mutex (const ACE_TS_Mutex &); /// Return a deep copy. virtual ACE_Token_Proxy *clone (void) const; private: /// The Token Handler associated with this proxy. Set at /// construction and notified when blocking acquires succeed. ACE_Token_Handler* th_; }; /** * @class ACE_TS_RLock * * @brief ACE_TS_RLock -- ACE_*T*oken_*S*erver_RLock */ class ACE_TS_RLock : public ACE_Local_RLock { public: /// Creation. ACE_TS_RLock (const ACE_TCHAR *name, ACE_Token_Handler *th); protected: /// Somebody wants our token! virtual void sleep_hook (void); /** * We've been taken off the waiters list and given the token! Call * the Token_Handler associated at construction, so it can tell the * remote client. */ virtual void token_acquired (ACE_TPQ_Entry *); /// Duplication. ACE_TS_RLock (const ACE_TS_RLock&); /// Return a deep copy. virtual ACE_Token_Proxy *clone (void) const; private: /// the Token Handler associated with this proxy. Set at /// construction and notified when blocking acquires succeed. ACE_Token_Handler* th_; }; /** * @class ACE_TS_WLock * * @brief ACE_TS_WLock -- ACE_*T*oken_*S*erver_WLock */ class ACE_TS_WLock : public ACE_Local_WLock { public: /// Creation. ACE_TS_WLock (const ACE_TCHAR *name, ACE_Token_Handler *th); protected: /// Somebody wants our token! virtual void sleep_hook (void); /** * We've been taken off the waiters list and given the token! Call * the Token_Handler associated at construction, so it can tell the * remote client. */ virtual void token_acquired (ACE_TPQ_Entry *); /// Duplication. ACE_TS_WLock (const ACE_TS_WLock&); /// Return a deep copy. virtual ACE_Token_Proxy *clone (void) const; private: /// the Token Handler associated with this proxy. Set at /// construction and notified when blocking acquires succeed. ACE_Token_Handler* th_; }; /** * @class ACE_Token_Acceptor * * @brief This class contains the service-specific methods that can't * easily be factored into the . */ class ACE_Token_Acceptor : public ACE_Strategy_Acceptor { public: /// Dynamic linking hook. virtual int init (int argc, ACE_TCHAR *argv[]); /// Parse svc.conf arguments. int parse_args (int argc, ACE_TCHAR *argv[]); private: /// The scheduling strategy is designed for Reactive services. ACE_Schedule_All_Reactive_Strategy scheduling_strategy_; }; ACE_SVC_FACTORY_DECLARE (ACE_Token_Acceptor) #endif /* ACE_HAS_TOKENS_LIBRARY */ #endif /* ACE_TOKEN_HANDLER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Name_Handler.h0000644000175000017500000001366112576461726021345 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Name_Handler.h * * @author Prashant Jain * @author Gerhard Lenzer * @author and Douglas C. Schmidt */ //============================================================================= #ifndef ACE_NAME_HANDLER_H #define ACE_NAME_HANDLER_H #include "ace/Acceptor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Acceptor.h" #include "ace/SString.h" #include "ace/Svc_Handler.h" #include "ace/Naming_Context.h" #include "ace/Name_Request_Reply.h" #include "ace/Null_Mutex.h" #include "ace/svc_export.h" #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT template class ACE_Svc_Export ACE_Svc_Handler; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ /** * @class ACE_Name_Handler * * @brief Product object created by . An * exchanges messages with a * object on the client-side. * * This class is the main workhorse of the . It * handles client requests to bind, rebind, resolve, and unbind * names. It also schedules and handles timeouts that are used to * support "timed waits." Clients used timed waits to bound the * amount of time they block trying to get a name. */ class ACE_Svc_Export ACE_Name_Handler : public ACE_Svc_Handler { public: /// Pointer to a member function of ACE_Name_Handler returning int typedef int (ACE_Name_Handler::*OPERATION) (void); /// Pointer to a member function of ACE_Naming_Context returning int typedef int (ACE_Naming_Context::*LIST_OP) (ACE_PWSTRING_SET &, const ACE_NS_WString &); /// Pointer to a member function of ACE_Name_Handler returning ACE_Name_Request typedef ACE_Name_Request (ACE_Name_Handler::*REQUEST) (ACE_NS_WString *); // = Initialization and termination. /// Default constructor. ACE_Name_Handler (ACE_Thread_Manager * = 0); /// Activate this instance of the (called by the /// ). virtual int open (void * = 0); protected: // = Helper routines for the operations exported to clients. /// Give up waiting (e.g., when a timeout occurs or a client shuts /// down unexpectedly). virtual int abandon (void); // = Low level routines for framing requests, dispatching // operations, and returning replies. /// Receive, frame, and decode the client's request. virtual int recv_request (void); /// Dispatch the appropriate operation to handle the client's /// request. virtual int dispatch (void); /// Create and send a reply to the client. virtual int send_reply (ACE_INT32 status, ACE_UINT32 errnum = 0); /// Special kind of reply virtual int send_request (ACE_Name_Request &); // = Demultiplexing hooks. /// Return the underlying . virtual ACE_HANDLE get_handle (void) const; /// Callback method invoked by the when client events /// arrive. virtual int handle_input (ACE_HANDLE); // = Timer hook. /// Enable clients to limit the amount of time they wait for a name. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); /// Ensure dynamic allocation... ~ACE_Name_Handler (void); private: /// Table of pointers to member functions OPERATION op_table_[ACE_Name_Request::MAX_ENUM]; struct LIST_ENTRY { LIST_OP operation_; // A member function pointer that performs the appropriate // operation (e.g., LIST_NAMES, LIST_VALUES, or LIST_TYPES). REQUEST request_factory_; // A member function pointer that serves as a factory to create a // request that is passed back to the client. const char *description_; // Name of the operation we're dispatching (used for debugging). }; /// This is the table of pointers to functions that we use to /// simplify the handling of list requests. LIST_ENTRY list_table_[ACE_Name_Request::MAX_LIST]; /// Cache request from the client. ACE_Name_Request name_request_; /// Special kind of reply for resolve and listnames. ACE_Name_Request name_request_back_; /// Cache reply to the client. ACE_Name_Reply name_reply_; /// Address of client we are connected with. ACE_INET_Addr addr_; /// Naming Context ACE_Naming_Context *naming_context_; ACE_Naming_Context *naming_context (void); /// Handle binds. int bind (void); /// Handle rebinds. int rebind (void); /// Handle binds and rebinds. int shared_bind (int rebind); /// Handle find requests. int resolve (void); /// Handle unbind requests. int unbind (void); /// Handle LIST_NAMES, LIST_VALUES, and LIST_TYPES requests. int lists (void); /// Handle LIST_NAME_ENTRIES, LIST_VALUE_ENTRIES, and /// LIST_TYPE_ENTRIES requests. int lists_entries (void); /// Create a name request. ACE_Name_Request name_request (ACE_NS_WString *one_name); /// Create a value request. ACE_Name_Request value_request (ACE_NS_WString *one_name); /// Create a type request. ACE_Name_Request type_request (ACE_NS_WString *one_name); }; /** * @class ACE_Name_Acceptor * * @brief This class contains the service-specific methods that can't * easily be factored into the . */ class ACE_Name_Acceptor : public ACE_Strategy_Acceptor { public: /// Dynamic linking hook. virtual int init (int argc, ACE_TCHAR *argv[]); /// Parse svc.conf arguments. int parse_args (int argc, ACE_TCHAR *argv[]); /// Naming context for acceptor /for the listening port/ ACE_Naming_Context *naming_context (void); private: /// The scheduling strategy is designed for Reactive services. ACE_Schedule_All_Reactive_Strategy scheduling_strategy_; /// The Naming Context ACE_Naming_Context naming_context_; }; ACE_SVC_FACTORY_DECLARE (ACE_Name_Acceptor) #endif /* ACE_NAME_HANDLER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Server_Logging_Handler.h0000644000175000017500000000714612576461726023402 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Server_Logging_Handler.h * * @author Doug Schmidt and Per Andersson */ //============================================================================= #ifndef ACE_SERVER_LOGGING_HANDLER_H #define ACE_SERVER_LOGGING_HANDLER_H #include "Log_Message_Receiver.h" #include "Server_Logging_Handler_T.h" #include "ace/svc_export.h" // Typedefs for Logging Handlers & acceptors using a static type based // log message receivers. // Synched and NULL synched message receivers typedef Static_Log_Message_Receiver Null_Synch_Static_Receiver; typedef Static_Log_Message_Receiver Synch_Static_Receiver; // NULL synched logging handler typedef ACE_Server_Logging_Handler Null_Synch_Logging_Handler_Static_Receiver; // synched logging handlers typedef ACE_Server_Logging_Handler Synch_Logging_Handler_Static_Receiver; typedef ACE_Thr_Server_Logging_Handler Synch_Thr_Logging_Handler_Static_Receiver; // NULL synched logging acceptor typedef ACE_Server_Logging_Acceptor_T > Null_Synch_Logging_Handler_Static_Receiver_Acceptor; // NULL synched logging acceptors typedef ACE_Server_Logging_Acceptor_T > Synch_Logging_Handler_Static_Receiver_Acceptor; typedef ACE_Server_Logging_Acceptor_T > Synch_Thr_Logging_Handler_Static_Receiver_Acceptor; // typedefs for Logging Handlers & acceptors using a instance based // log message receivers. // Synched message receivers typedef Log_Message_Receiver Synch_Receiver; // synched logging handlers typedef ACE_Server_Logging_Handler Synch_Logging_Handler_Receiver; typedef ACE_Thr_Server_Logging_Handler Synch_Thr_Logging_Handler_Receiver; // synched logging acceptors typedef ACE_Server_Logging_Acceptor_T > Synch_Logging_Handler_Receiver_Acceptor; typedef ACE_Server_Logging_Acceptor_T > Synch_Thr_Logging_Handler_Receiver_Acceptor; // Define external acceptors // Acceptors that use static/type based log message receiver. typedef Null_Synch_Logging_Handler_Static_Receiver_Acceptor ACE_Server_Logging_Acceptor; typedef Synch_Thr_Logging_Handler_Static_Receiver_Acceptor ACE_Thr_Server_Logging_Acceptor; ACE_SVC_FACTORY_DECLARE (ACE_Server_Logging_Acceptor) ACE_SVC_FACTORY_DECLARE (ACE_Thr_Server_Logging_Acceptor) #endif /* ACE_SERVER_LOGGING_HANDLER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Time_Request_Reply.cpp0000644000175000017500000001250212576461726023135 0ustar pgquilespgquiles#include "ace/Basic_Types.h" #include "ace/CDR_Base.h" #include "ace/Log_Msg.h" #include "ace/Truncate.h" #include "ace/os_include/netinet/os_in.h" #include "ace/os_include/arpa/os_inet.h" #include "Time_Request_Reply.h" // Default "do nothing" constructor. ACE_Time_Request::ACE_Time_Request (void) { ACE_TRACE ("ACE_Time_Request::ACE_Time_Request"); } // Create a ACE_Time_Request message. ACE_Time_Request::ACE_Time_Request (ACE_INT32 t, // Type of request. const time_t time, ACE_Time_Value *timeout) // Max time waiting for request. { ACE_TRACE ("ACE_Time_Request::ACE_Time_Request"); this->msg_type (t); // If timeout is a NULL pointer, then block forever... if (timeout == 0) { this->transfer_.block_forever_ = 1; this->transfer_.sec_timeout_ = 0; this->transfer_.usec_timeout_ = 0; } else // Do a "timed wait." { this->block_forever (0); // Keep track of how long client is willing to wait. this->transfer_.sec_timeout_ = timeout->sec (); this->transfer_.usec_timeout_ = timeout->usec (); } // Copy time into request this->transfer_.time_ = this->time_ = time; } // Get the fixed size of message ssize_t ACE_Time_Request::size (void) const { ACE_TRACE ("ACE_Time_Request::size"); return sizeof (this->transfer_); } // = Set/get the type of the message. ACE_INT32 ACE_Time_Request::msg_type (void) const { ACE_TRACE ("ACE_Time_Request::msg_type"); return this->transfer_.msg_type_; } void ACE_Time_Request::msg_type (ACE_INT32 t) { ACE_TRACE ("ACE_Time_Request::msg_type"); this->transfer_.msg_type_ = t; } // = Set/get the blocking semantics. ACE_UINT32 ACE_Time_Request::block_forever (void) const { ACE_TRACE ("ACE_Time_Request::block_forever"); return this->transfer_.block_forever_; } void ACE_Time_Request::block_forever (ACE_UINT32 bs) { ACE_TRACE ("ACE_Time_Request::block_forever"); this->transfer_.block_forever_ = bs; } // = Set/get the timeout. ACE_Time_Value ACE_Time_Request::timeout (void) const { ACE_TRACE ("ACE_Time_Request::timeout"); time_t sec = ACE_Utils::truncate_cast (this->transfer_.sec_timeout_); return ACE_Time_Value (sec, this->transfer_.usec_timeout_); } void ACE_Time_Request::timeout (const ACE_Time_Value& timeout) { ACE_TRACE ("ACE_Time_Request::timeout"); this->transfer_.sec_timeout_ = timeout.sec (); this->transfer_.usec_timeout_ = timeout.usec (); } // = Set/get the time time_t ACE_Time_Request::time (void) const { ACE_TRACE ("ACE_Time_Request::time"); return this->time_; } void ACE_Time_Request::time (time_t t) { ACE_TRACE ("ACE_Time_Request::time"); this->time_ = t; } // Encode the transfer buffer into network byte order // so that it can be sent to the server. int ACE_Time_Request::encode (void *&buf) { ACE_TRACE ("ACE_Time_Request::encode"); // Compute the length *before* doing the marshaling. buf = (void *) &this->transfer_; this->transfer_.block_forever_ = ACE_HTONL (this->transfer_.block_forever_); this->transfer_.usec_timeout_ = ACE_HTONL (this->transfer_.usec_timeout_); this->transfer_.msg_type_ = ACE_HTONL (this->transfer_.msg_type_); #if defined (ACE_LITTLE_ENDIAN) ACE_UINT64 secs = this->transfer_.sec_timeout_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_); secs = this->transfer_.time_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.time_); #endif return this->size (); // Always fixed } // Decode the transfer buffer into host byte byte order // so that it can be used by the server. int ACE_Time_Request::decode (void) { ACE_TRACE ("ACE_Time_Request::decode"); // Decode this->transfer_.block_forever_ = ACE_NTOHL (this->transfer_.block_forever_); this->transfer_.usec_timeout_ = ACE_NTOHL (this->transfer_.usec_timeout_); this->transfer_.msg_type_ = ACE_NTOHL (this->transfer_.msg_type_); #if defined (ACE_LITTLE_ENDIAN) ACE_UINT64 secs = this->transfer_.sec_timeout_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.sec_timeout_); secs = this->transfer_.time_; ACE_CDR::swap_8 ((const char *)&secs, (char *)&this->transfer_.time_); #endif this->time_ = ACE_Utils::truncate_cast (this->transfer_.time_); return 0; } // Print out the current values of the ACE_Time_Request. void ACE_Time_Request::dump (void) const { #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_Time_Request::dump"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\nlength = %d\n"), this->size ())); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("message-type = "))); switch (this->msg_type ()) { case ACE_Time_Request::TIME_UPDATE: ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TIME_UPDATE\n"))); break; default: ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" = %d\n"), this->msg_type ())); break; } if (this->block_forever ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("blocking forever\n"))); else { #if !defined (ACE_NLOGGING) ACE_Time_Value tv = this->timeout (); #endif /* ! ACE_NLOGGING */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("waiting for %d secs and %d usecs\n"), (int)(tv.sec ()), tv.usec ())); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*******\ntime = %d\n"), (int)(this->time ()))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("+++++++\n"))); #endif /* ACE_HAS_DUMP */ } ace-6.3.3+dfsg.orig/netsvcs/lib/TS_Server_Handler.h0000644000175000017500000000606512576461726022341 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file TS_Server_Handler.h * * @author Prashant Jain */ //============================================================================= #ifndef ACE_TS_SERVER_HANDLER_H #define ACE_TS_SERVER_HANDLER_H #include "ace/Acceptor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Acceptor.h" #include "ace/Svc_Handler.h" #include "ace/svc_export.h" #include "Time_Request_Reply.h" #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT template class ACE_Svc_Export ACE_Svc_Handler; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ /** * @class ACE_TS_Server_Handler * * @brief Product object created by . */ class ACE_Svc_Export ACE_TS_Server_Handler : public ACE_Svc_Handler { public: // = Initialization and termination. /// Default constructor. ACE_TS_Server_Handler (ACE_Thread_Manager * = 0); /// Activate this instance of the (called by the /// ). virtual int open (void * = 0); protected: /// Must be allocated dynamically. ~ACE_TS_Server_Handler (void); // = Helper routines for the operations exported to clients. /// Give up waiting (e.g., when a timeout occurs or a client shuts /// down unexpectedly). virtual int abandon (void); // = Low level routines for framing requests, dispatching // operations, and returning replies. /// Receive, frame, and decode the client's request. virtual int recv_request (void); /// Dispatch the appropriate operation to handle the client's /// request. virtual int dispatch (void); /// Special kind of reply virtual int send_request (ACE_Time_Request &); // = Demultiplexing hooks. /// Return the underlying . virtual ACE_HANDLE get_handle (void) const; /// Callback method invoked by the when client events /// arrive. virtual int handle_input (ACE_HANDLE); // = Timer hook. /// Enable clients to limit the amount of time they wait. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); private: /// Cache request from the client. ACE_Time_Request time_request_; /// Address of client we are connected with. ACE_INET_Addr addr_; }; /** * @class ACE_TS_Server_Acceptor * * @brief This class contains the service-specific methods that can't * easily be factored into the . */ class ACE_TS_Server_Acceptor : public ACE_Strategy_Acceptor { public: /// Dynamic linking hook. virtual int init (int argc, ACE_TCHAR *argv[]); /// Parse svc.conf arguments. int parse_args (int argc, ACE_TCHAR *argv[]); private: /// The scheduling strategy is designed for Reactive services. ACE_Schedule_All_Reactive_Strategy scheduling_strategy_; }; ACE_SVC_FACTORY_DECLARE (ACE_TS_Server_Acceptor) #endif /* ACE_TS_SERVER_HANDLER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/TS_Server_Handler.cpp0000644000175000017500000001650012576461726022667 0ustar pgquilespgquiles#include "ace/SString.h" #include "ace/Containers.h" #include "ace/Get_Opt.h" #include "TS_Server_Handler.h" #include "ace/OS_NS_time.h" #include "ace/Signal.h" int ACE_TS_Server_Acceptor::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_TS_Server_Acceptor::parse_args"); int service_port = ACE_DEFAULT_SERVER_PORT; ACE_LOG_MSG->open (ACE_TEXT ("Time Service")); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"), 0); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'p': service_port = ACE_OS::atoi (get_opt.opt_arg ()); break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n[-p server-port]\n"), 1), -1); } } this->service_addr_.set (service_port); return 0; } int ACE_TS_Server_Acceptor::init (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_TS_Server_Acceptor::init"); // Use the options hook to parse the command line arguments and set // options. this->parse_args (argc, argv); // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), 0, 0, 0, &this->scheduling_strategy_, ACE_TEXT ("Time Server"), ACE_TEXT ("ACE time service")) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p on port %d\n"), ACE_TEXT ("acceptor::open failed"), this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each can handle this on its // own. ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE); ACE_UNUSED_ARG (sig); ACE_INET_Addr server_addr; // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_local_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("starting up Time Server at port %d on handle %d\n"), server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; } // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the Time Server ACE_SVC_FACTORY_DEFINE (ACE_TS_Server_Acceptor) // Default constructor. ACE_TS_Server_Handler::ACE_TS_Server_Handler (ACE_Thread_Manager *tm) : ACE_Svc_Handler (tm) { ACE_TRACE ("ACE_TS_Server_Handler::ACE_TS_Server_Handler"); } // Activate this instance of the ACE_TS_Server_Handler (called by the // ACE_TS_Server_Acceptor). /* VIRTUAL */ int ACE_TS_Server_Handler::open (void *) { ACE_TRACE ("ACE_TS_Server_Handler::open"); ACE_INET_Addr client_addr; // Determine the address of the client and display it. if (this->peer ().get_remote_addr (client_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) accepted connection from host %C on fd %d\n"), client_addr.get_host_name (), this->peer ().get_handle ())); // Call down to our parent to register ourselves with the Reactor. if (ACE_Svc_Handler::open (0) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); return 0; } /* VIRTUAL */ int ACE_TS_Server_Handler::send_request (ACE_Time_Request &request) { ACE_TRACE ("ACE_TS_Server_Handler::send_request"); void *buffer; ssize_t length = request.encode (buffer); if (length == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("encode failed")), -1); // Transmit request via a blocking send. if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n failed")), -1); return 0; } // Give up waiting (e.g., when a timeout occurs or a client shuts down // unexpectedly). /* VIRTUAL */ int ACE_TS_Server_Handler::abandon (void) { ACE_TRACE ("ACE_TS_Server_Handler::abandon"); // Note we are using the time field to report the errno in case of // failure. ACE_Time_Request rq (-1, errno); return this->send_request (rq); } // Enable clients to limit the amount of time they'll wait /* VIRTUAL */ int ACE_TS_Server_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_TRACE ("ACE_TS_Server_Handler::handle_timeout"); return this->abandon (); } // Return the underlying ACE_HANDLE. /* VIRTUAL */ ACE_HANDLE ACE_TS_Server_Handler::get_handle (void) const { ACE_TRACE ("ACE_TS_Server_Handler::get_handle"); return this->peer ().get_handle (); } // Dispatch the appropriate operation to handle the client request. /* VIRTUAL */ int ACE_TS_Server_Handler::dispatch (void) { ACE_TRACE ("ACE_TS_Server_Handler::dispatch"); // Get the system time and then create an ACE_Time_Request time_t t = ACE_OS::time (0); ACE_Time_Request rq (ACE_Time_Request::TIME_UPDATE, t); return this->send_request (rq); } // Receive, frame, and decode the client's request. Note, this method // should use non-blocking I/O. /* VIRTUAL */ int ACE_TS_Server_Handler::recv_request (void) { ACE_TRACE ("ACE_TS_Server_Handler::recv_request"); ssize_t bytes_expected = this->time_request_.size (); // Since Time_Request messages are fixed size, read the entire // message in one go. ssize_t n = this->peer ().recv ((void *) &this->time_request_, bytes_expected); if (n != bytes_expected) { switch (n) { case -1: /* FALLTHROUGH */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_request returned -1\n"))); default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, bytes_expected)); /* FALLTHROUGH */ case 0: // We've shutdown unexpectedly, let's abandon the // connection. this->abandon (); return -1; /* NOTREACHED */ } } else { // Decode the request into host byte order. if (this->time_request_.decode () == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed"))); return this->abandon (); } } return 0; } // Callback method invoked by the ACE_Reactor when events arrive from // the client. /* VIRTUAL */ int ACE_TS_Server_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_TS_Server_Handler::handle_input"); if (this->recv_request () == -1) return -1; else return this->dispatch (); } ACE_TS_Server_Handler::~ACE_TS_Server_Handler (void) { ACE_TRACE ("ACE_TS_Server_Handler::~ACE_TS_Server_Handler"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("closing down Handle %d\n"), this->get_handle ())); } ace-6.3.3+dfsg.orig/netsvcs/lib/Server_Logging_Handler_T.h0000644000175000017500000001550412576461726023662 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Server_Logging_Handler_T.h * * @author Doug Schmidt and Per Andersson */ //============================================================================= #ifndef ACE_SERVER_LOGGING_HANDLER_T_H #define ACE_SERVER_LOGGING_HANDLER_T_H #include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/TLI_Acceptor.h" #include "ace/SOCK_Acceptor.h" #include "ace/Svc_Handler.h" #include "ace/Acceptor.h" #include "ace/SString.h" #include "ace/Atomic_Op.h" #if !defined (__GNUG__) #include "Base_Optimizer.h" #endif /* ! __GNUG__ */ /** * @class ACE_Server_Logging_Handler_T * * @brief Product object created by an . An * receives, and frames logging * records. The logging record is then processed by the * * * Defines the classes that perform server logging daemon * functionality. */ template class ACE_Server_Logging_Handler_T : public ACE_Svc_Handler { public: /// Constructor. ACE_Server_Logging_Handler_T (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver ); /// Process remote logging records. virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); protected: /// Receive the logging record from a client. int handle_logging_record (void); /// Common parts of open function, sets hostname and diables NONBLOCK in peer /// called from derived classes open method. int open_common (void); #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) /// Count the number of logging records that arrive. static COUNTER request_count_; #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ #if !defined (__GNUG__) /** * Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together * in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often * a class with no instance data. */ Base_Optimizer receiver_; #else LOG_MESSAGE_RECEIVER receiver_; ACE_TString host_name_; #endif /* ! __GNUG__ */ /// Name of the host we are connected to. const ACE_TCHAR *host_name (void); /// The receiver of log records LOG_MESSAGE_RECEIVER &receiver (void){ return receiver_; } }; #if 1 //!defined (ACE_HAS_TLI) #define LOGGING_PEER_ACCEPTOR ACE_SOCK_ACCEPTOR #define LOGGING_PEER_STREAM ACE_SOCK_STREAM #else /* use sockets */ #define LOGGING_PEER_ACCEPTOR ACE_TLI_ACCEPTOR #define LOGGING_PEER_STREAM ACE_TLI_STREAM #endif /* ACE_HAS_TLI */ /** * @class ACE_Server_Logging_Acceptor_T * * @brief Factory that creates s scheduled with * and logging records proccessed by a * * * This class contains the service-specific methods that can't * easily be factored into the . */ template class ACE_Server_Logging_Acceptor_T : public ACE_Strategy_Acceptor { public: /// Dynamic linking hook. ACE_Server_Logging_Acceptor_T (void); virtual int init (int argc, ACE_TCHAR *argv[]); protected: /// Parse svc.conf arguments. int parse_args (int argc, ACE_TCHAR *argv[]); /** * Factory that creates a new . We need to * specialize this since the held by this Acceptor must be * passed into the . */ virtual int make_svc_handler (SERVER_LOGGING_HANDLER *&); private: // At the moment each ACE_Server_Logging_Acceptor_T contains // a attribute that is passed to the // at construction. A better idea might // be to have accessor class as template argument. The accessor // should be a factory/strategy that hands the // ACE_Server_Logging_Acceptor_T instance references // to a . This makes it possible // to change how are created without chaning the // ACE_Server_Logging_Acceptor_T code. #if !defined (__GNUG__) /** * Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together * in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often a * class with no instance data. */ Base_Optimizer receiver_; #else LOG_MESSAGE_RECEIVER receiver_; SCHEDULE_STRATEGY schedule_strategy_; #endif /* ! __GNUG__ */ /// The scheduling strategy for the service. SCHEDULE_STRATEGY &scheduling_strategy (void); /// The receiver of log records LOG_MESSAGE_RECEIVER &receiver (void); }; /** * @class ACE_Server_Logging_Handler * * @brief Product object created by a * >. An * ACE_Server_Logging_Handler receives, frames. The logging record * is then processed by the * * All clients are handled in the same thread. */ template class ACE_Server_Logging_Handler : public ACE_Server_Logging_Handler_T { public: ACE_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Server_Logging_Handler (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver); virtual int open (void* = 0); }; #if defined (ACE_HAS_THREADS) typedef ACE_Atomic_Op ACE_LOGGER_COUNTER; #define ACE_LOGGER_SYNCH ACE_MT_SYNCH #else typedef u_long ACE_LOGGER_COUNTER; #define ACE_LOGGER_SYNCH ACE_NULL_SYNCH #endif /* ACE_HAS_THREADS */ /** * @class ACE_Thr_Server_Logging_Handler * * @brief Product object created by a * * >. An ACE_Thr_Server_Logging_Handler receives, frames. The * logging record is then processed by the * * Each client is handled in its own separate thread. */ template class ACE_Thr_Server_Logging_Handler : public ACE_Server_Logging_Handler_T { public: ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver); virtual int open (void * = 0); virtual int svc (void); }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "Server_Logging_Handler_T.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Server_Logging_Handler_T.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* ACE_SERVER_LOGGING_HANDLER_T_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Base_Optimizer.cpp0000644000175000017500000000103412576461726022266 0ustar pgquilespgquiles#if !defined (BASE_OPTIMIZER_CPP) #define BASE_OPTIMIZER_CPP #include "Base_Optimizer.h" template Base_Optimizer::Base_Optimizer (void) { } template Base_Optimizer::Base_Optimizer (const Base &base, const Member &member) : Base (base), m_ (member) { } template Base_Optimizer::Base_Optimizer (const Base &base) : Base (base) { } #endif /* BASE_OPTIMIZER_CPP */ ace-6.3.3+dfsg.orig/netsvcs/lib/TS_Clerk_Handler.cpp0000644000175000017500000004543412576461726022471 0ustar pgquilespgquiles#include "ace/Get_Opt.h" #include "TS_Clerk_Handler.h" #include "ace/Lib_Find.h" #include "ace/Signal.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_time.h" #include "ace/os_include/os_netdb.h" ACE_TS_Clerk_Handler::ACE_TS_Clerk_Handler (ACE_TS_Clerk_Processor *processor, ACE_INET_Addr &addr) : state_ (ACE_TS_Clerk_Handler::IDLE), timeout_ (ACE_DEFAULT_TIMEOUT), max_timeout_ (ACE_TS_Clerk_Handler::MAX_RETRY_TIMEOUT), remote_addr_ (addr), processor_ (processor) { ACE_TRACE ("ACE_TS_Clerk_Handler::ACE_TS_Clerk_Handler"); this->time_info_.delta_time_ = 0; this->time_info_.sequence_num_ = 0; } // Set the connection state void ACE_TS_Clerk_Handler::state (ACE_TS_Clerk_Handler::State state) { ACE_TRACE ("ACE_TS_Clerk_Handler::state"); this->state_ = state; } // Get the connection state ACE_TS_Clerk_Handler::State ACE_TS_Clerk_Handler::state (void) { ACE_TRACE ("ACE_TS_Clerk_Handler::state"); return this->state_; } // Sets the timeout delay. void ACE_TS_Clerk_Handler::timeout (long to) { ACE_TRACE ("ACE_TS_Clerk_Handler::timeout"); if (to > this->max_timeout_) to = this->max_timeout_; this->timeout_ = to; } // Recalculate the current retry timeout delay using exponential // backoff. Returns the original timeout (i.e., before the // recalculation). long ACE_TS_Clerk_Handler::timeout (void) { ACE_TRACE ("ACE_TS_Clerk_Handler::timeout"); long old_timeout = this->timeout_; this->timeout_ *= 2; if (this->timeout_ > this->max_timeout_) this->timeout_ = this->max_timeout_; return old_timeout; } // This is called when a to the logging server fails... int ACE_TS_Clerk_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { return -1; } // Set the max timeout delay. void ACE_TS_Clerk_Handler::max_timeout (long mto) { ACE_TRACE ("ACE_TS_Clerk_Handler::max_timeout"); this->max_timeout_ = mto; } // Gets the max timeout delay. long ACE_TS_Clerk_Handler::max_timeout (void) { ACE_TRACE ("ACE_TS_Clerk_Handler::max_timeout"); return this->max_timeout_; } int ACE_TS_Clerk_Handler::open (void *) { ACE_TRACE ("ACE_TS_Clerk_Handler::open"); ACE_INET_Addr server_addr; // Set connection state as established this->state (ACE_TS_Clerk_Handler::ESTABLISHED); // Register ourselves to receive SIGPIPE so we can attempt // reconnections. #if !defined (ACE_WIN32) if (ACE_Reactor::instance ()->register_handler (SIGPIPE, this) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("register_handler (SIGPIPE)")), -1); #endif /* ACE_WIN32 */ // Register ourselves with the reactor to receive input if (ACE_Reactor::instance ()->register_handler (this->get_handle (), this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("register_handler (this)"))); // Figure out what remote port we're really bound to. else if (this->peer ().get_remote_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TS Clerk Daemon connected to port %d on handle %d\n"), server_addr.get_port_number (), this->peer ().get_handle ())); return 0; } ACE_HANDLE ACE_TS_Clerk_Handler::get_handle (void) const { ACE_TRACE ("ACE_TS_Clerk_Handler::get_handle"); return this->peer().get_handle (); } int ACE_TS_Clerk_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask mask) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_close"); ACE_UNUSED_ARG (mask); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) shutting down on handle %d\n"), this->get_handle ())); return this->reinitiate_connection (); } int ACE_TS_Clerk_Handler::reinitiate_connection (void) { ACE_TRACE ("ACE_TS_Clerk_Handler::reinitiate_connection"); // Skip over deactivated descriptors. // Set state to connecting so that we don't try to send anything // using this handler this->state (ACE_TS_Clerk_Handler::CONNECTING); if (this->get_handle () != ACE_INVALID_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Scheduling reinitiation of connection\n"))); // Reschedule ourselves to try and connect again. ACE_Time_Value const timeout (this->timeout ()); if (ACE_Reactor::instance ()->schedule_timer (this, 0, timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("schedule_timer")), -1); } return 0; } // Receive a time update from a server int ACE_TS_Clerk_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_input"); // We're getting a time update message from a server ACE_Time_Request reply; if (this->recv_reply (reply) != 0) return -1; else { // Get current local time time_t local_time = ACE_OS::time (0); // Compure delta time (difference between current local time and // system time obtained from the server) time_t t = reply.time () - local_time; // Compute round trip delay and adjust time accordingly time_t one_way_time = (local_time - this->start_time_)/2; t += one_way_time; // Now update time info (to be retrieved by Clerk_Processor) this->time_info_.delta_time_ = t; this->time_info_.sequence_num_ = this->cur_sequence_num_; } return 0; } // Restart connection asynchronously when timeout occurs. int ACE_TS_Clerk_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_timeout"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) attempting to reconnect to server with timeout = %d\n"), this->timeout_)); // Close down peer to reclaim descriptor if need be. Note this is // necessary to reconnect. this->peer ().close (); return this->processor_->initiate_connection (this, ACE_Synch_Options::asynch); } void ACE_TS_Clerk_Handler::remote_addr (ACE_INET_Addr &addr) { ACE_TRACE ("ACE_TS_Clerk_Handler::remote_addr"); this->remote_addr_ = addr; } ACE_INET_Addr & ACE_TS_Clerk_Handler::remote_addr (void) { ACE_TRACE ("ACE_TS_Clerk_Handler::remote_addr"); return this->remote_addr_; } int ACE_TS_Clerk_Handler::recv_reply (ACE_Time_Request &reply) { ACE_TRACE ("ACE_TS_Clerk_Handler::recv_reply"); const int bytes_expected = reply.size (); // Since Time_Request messages are fixed size, read the entire // message in one go. ssize_t n = this->peer ().recv ((void *) &reply, bytes_expected); if (n != bytes_expected) { switch (n) { case -1: // FALLTHROUGH ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_reply returned -1\n"))); default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, bytes_expected)); // FALLTHROUGH case 0: // We've shutdown unexpectedly return -1; // NOTREACHED } } else if (reply.decode () == -1) // Decode the request into host byte order. ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed")), -1); return 0; } int ACE_TS_Clerk_Handler::send_request (ACE_UINT32 sequence_num, ACE_Time_Info &time_info) { ACE_TRACE ("ACE_TS_Clerk_Handler::send_request"); void *buffer; ssize_t length; // Update current sequence number this->cur_sequence_num_ = sequence_num; // First update the current time info. time_info.delta_time_ = this->time_info_.delta_time_; time_info.sequence_num_ = this->time_info_.sequence_num_; // Now prepare a new time update request ACE_Time_Request request (ACE_Time_Request::TIME_UPDATE, 0, 0); if ((length = request.encode (buffer)) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("encode failed")), -1); // Compute start time of sending request (needed to compute // roundtrip delay) this->start_time_ = ACE_OS::time (0); // Send the request if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n failed")), -1); return 0; } ACE_TS_Clerk_Processor::ACE_TS_Clerk_Processor () : timeout_ (ACE_DEFAULT_TIMEOUT), blocking_semantics_ (0), cur_sequence_num_ (0) { #if defined (ACE_DEFAULT_BACKING_STORE) // Create a temporary file. ACE_OS::strcpy (this->poolname_, ACE_DEFAULT_BACKING_STORE); #else /* ACE_DEFAULT_BACKING_STORE */ if (ACE::get_temp_dir (this->poolname_, MAXPATHLEN - 17) == -1) // -17 for ace-malloc-XXXXXX { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->poolname_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->poolname_, ACE_TEXT ("ace-malloc-XXXXXX")); #endif /* ACE_DEFAULT_BACKING_STORE */ } void ACE_TS_Clerk_Processor::alloc (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::alloc"); ACE_NEW (this->shmem_, ALLOCATOR (this->poolname_)); void *temp = 0; // Only create the state if it doesn't already exist. if (this->shmem_->find (ACE_DEFAULT_TIME_SERVER_STR, temp) == -1) { // Allocate the space out of shared memory for the system time entry temp = (this->shmem_->malloc (2 * sizeof (time_t))); // Give it a name binding this->shmem_->bind (ACE_DEFAULT_TIME_SERVER_STR, temp); } // Set up pointers. Note that we add one to get to the second // field in the structure time_t *time_p = (time_t *)temp; this->system_time_.delta_time_ = time_p; this->system_time_.last_local_time_ = time_p + 1; // Initialize *(this->system_time_.delta_time_) = 0; *(this->system_time_.last_local_time_) = ACE_OS::time (0); } // Query the servers for the latest time int ACE_TS_Clerk_Processor::handle_timeout (const ACE_Time_Value &, const void *) { ACE_TRACE ("ACE_TS_Clerk_Processor::handle_timeout"); return this->update_time (); } int ACE_TS_Clerk_Processor::update_time () { ACE_TRACE ("ACE_TS_Clerk_Processor::update_time"); ACE_UINT32 expected_sequence_num = this->cur_sequence_num_; // Increment sequence number this->cur_sequence_num_++; int count = 0; time_t total_delta = 0; ACE_Time_Info time_info; // Call send_request() on all handlers ACE_TS_Clerk_Handler **handler = 0; for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) { if ((*handler)->state () == ACE_TS_Clerk_Handler::ESTABLISHED) { if ((*handler)->send_request (this->cur_sequence_num_, time_info) == -1) return -1; // Check if sequence numbers match; otherwise discard else if (expected_sequence_num != 0 && time_info.sequence_num_ == expected_sequence_num) { count++; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("[%d] Delta time: %d\n"), count, time_info.delta_time_)); // #### Can check here if delta value falls within a threshold #### total_delta += time_info.delta_time_; } } } // Update system_time_ using average of times obtained from all the servers. // Note that we are keeping two things in shared memory: the delta // time (difference between our system clock and the local clock), // and the last local time if (count > 0) { // At least one server is out there *(this->system_time_.delta_time_) = total_delta/count; } else { // No servers are out there (or this is the first time around // computing the time) so set delta time to zero. This // would mean that clients would use the actual local system time. *(this->system_time_.delta_time_) = 0; } // Update the last local time *(this->system_time_.last_local_time_) = ACE_OS::time (0); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Average delta time: %d\n"), (int)(*(this->system_time_.delta_time_)))); return 0; } int ACE_TS_Clerk_Processor::fini (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::fini"); // Cancel the timer if (this->timer_id_ != -1) ACE_Reactor::instance ()->cancel_timer (this->timer_id_); // Destroy all the handlers ACE_TS_Clerk_Handler **handler = 0; for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) { if ((*handler)->state () != ACE_TS_Clerk_Handler::IDLE) // Mark state as DISCONNECTING so we don't try to reconnect... (*handler)->state (ACE_TS_Clerk_Handler::DISCONNECTING); // Deallocate resources. (*handler)->destroy (); // Will trigger a delete } // Remove the backing store this->shmem_->remove (); ACE_Connector ::fini (); return 0; } int ACE_TS_Clerk_Processor::info (ACE_TCHAR **, size_t) const { ACE_TRACE ("ACE_TS_Clerk_Processor::info"); return 0; } int ACE_TS_Clerk_Processor::init (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_TS_Clerk_Processor::init"); // Use the options hook to parse the command line arguments and set // options. this->parse_args (argc, argv); this->alloc (); #if !defined (ACE_WIN32) // Ignore SIPPIPE so each Output_Channel can handle it. ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE); ACE_UNUSED_ARG (sig); #endif /* ACE_WIN32 */ ACE_Synch_Options &synch_options = this->blocking_semantics_ == 0 ? ACE_Synch_Options::asynch : ACE_Synch_Options::synch; // Now set up connections to all servers ACE_TS_Clerk_Handler **handler = 0; for (HANDLER_SET_ITERATOR set_iterator (this->handler_set_); set_iterator.next (handler) != 0; set_iterator.advance ()) { this->initiate_connection (*handler, synch_options); } // Now set up timer to receive updates from server // set the timer to go off after timeout value this->timer_id_ = ACE_Reactor::instance ()->schedule_timer (this, 0, ACE_Time_Value (this->timeout_), ACE_Time_Value (this->timeout_)); return 0; } int ACE_TS_Clerk_Processor::initiate_connection (ACE_TS_Clerk_Handler *handler, ACE_Synch_Options &synch_options) { ACE_TRACE ("ACE_TS_Clerk_Processor::initiate_connection"); ACE_TCHAR buf[MAXHOSTNAMELEN + 1]; // Mark ourselves as idle so that the various iterators will ignore // us until we are connected/reconnected. handler->state (ACE_TS_Clerk_Handler::IDLE); if (handler->remote_addr ().addr_to_string (buf, MAXHOSTNAMELEN) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("can't obtain peer's address")), -1); // Establish connection with the server. if (this->connect (handler, handler->remote_addr (), synch_options) == -1) { if (errno != EWOULDBLOCK) { handler->state (ACE_TS_Clerk_Handler::FAILED); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %p on address %s\n"), ACE_TEXT ("connect"), buf)); // Reschedule ourselves to try and connect again. if (synch_options[ACE_Synch_Options::USE_REACTOR]) { ACE_Time_Value const handler_timeout (handler->timeout ()); if (ACE_Reactor::instance ()->schedule_timer (handler, 0, handler_timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("schedule_timer")), -1); } else // Failures on synchronous connects are reported as errors // so that the caller can decide how to proceed. return -1; } else { handler->state (ACE_TS_Clerk_Handler::CONNECTING); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) in the process of connecting %s to %s\n"), synch_options[ACE_Synch_Options::USE_REACTOR] ? ACE_TEXT ("asynchronously") : ACE_TEXT ("synchronously"), buf)); } } else { handler->state (ACE_TS_Clerk_Handler::ESTABLISHED); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) connected to %s on %d\n"), buf, handler->get_handle ())); } return 0; } int ACE_TS_Clerk_Processor::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_TS_Clerk_Processor::parse_args"); ACE_INET_Addr server_addr; ACE_TS_Clerk_Handler *handler; ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("h:t:p:b"), 0); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': // Get the hostname:port and create an ADDR server_addr.set (get_opt.opt_arg ()); // Create a new handler ACE_NEW_RETURN (handler, ACE_TS_Clerk_Handler (this, server_addr), -1); // Cache the handler this->handler_set_.insert (handler); break; case 't': // Get the timeout value this->timeout_ = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'p': // Get the poolname ACE_OS::strncpy (this->poolname_, get_opt.opt_arg (), sizeof this->poolname_ / sizeof (ACE_TCHAR)); break; case 'b': // Blocking semantics this->blocking_semantics_ = 1; break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n[-h hostname:port] [-t timeout] [-p poolname]\n")), -1); } } return 0; } int ACE_TS_Clerk_Processor::suspend (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::suspend"); return 0; } int ACE_TS_Clerk_Processor::resume (void) { ACE_TRACE ("ACE_TS_Clerk_Processor::resume"); return 0; } // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the TS_Clerk. ACE_SVC_FACTORY_DEFINE (ACE_TS_Clerk_Processor) ace-6.3.3+dfsg.orig/netsvcs/lib/Client_Logging_Handler.h0000644000175000017500000000610112576461726023340 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Client_Logging_Handler.h * * @author Doug Schmidt */ //============================================================================= #ifndef ACE_CLIENT_LOGGER_H #define ACE_CLIENT_LOGGER_H #include "ace/SPIPE_Stream.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Stream.h" #include "ace/Svc_Handler.h" #include "ace/svc_export.h" #if (ACE_HAS_STREAM_LOG_MSG_IPC == 1) #define LOGGING_STREAM ACE_SPIPE_STREAM #define LOGGING_ACCEPTOR ACE_SPIPE_ACCEPTOR #define LOGGING_ADDR ACE_SPIPE_Addr #else #define LOGGING_STREAM ACE_SOCK_STREAM #define LOGGING_ACCEPTOR ACE_SOCK_ACCEPTOR #define LOGGING_ADDR ACE_INET_Addr #endif /* ACE_HAS_STREAM_LOG_MSG_IPC == 1 */ #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT template class ACE_Svc_Export ACE_Svc_Handler; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ /** * @class ACE_Client_Logging_Handler * * @brief This client logging daemon is a mediator that receives logging * records from local applications processes and forwards them to * the server logging daemon running on another host. * * The default implementation uses an ACE_SPIPE_Stream to * receive the logging message from the application and an * ACE_SOCK_Stream to forward the logging message to the * server. However, on platforms that don't support * (e.g., Win32) we use sockets instead. */ class ACE_Svc_Export ACE_Client_Logging_Handler : public ACE_Svc_Handler { public: // = Initialization and termination. /// Default constructor. @a handle is where the output is sent. ACE_Client_Logging_Handler (ACE_HANDLE handle = ACE_STDERR); /// Activate this instance of the ACE_Client_Logging_Handler /// (called by the ACE_Client_Logging_Acceptor). virtual int open (void * = 0); /// Return the handle of the IPC endpoint. virtual ACE_HANDLE get_handle (void) const; /// Called when object is removed from the ACE_Reactor. virtual int close (u_long); private: /// Handle SIGPIPE. virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); /// Receive logging records from applications. virtual int handle_input (ACE_HANDLE); /** * Receive logging records from applications. This is necessary to * handle madness with UNIX select, which can't deal with MSG_BAND * data easily due to its overly simple interface... This just * calls handle_input(). */ virtual int handle_exception (ACE_HANDLE); /// Called back when it's ok to send. virtual int handle_output (ACE_HANDLE); /// Send the @a log_record to the logging server. int send (ACE_Log_Record &log_record); /// This is either a SOCKET (if we're connected to a logging server) /// or ACE_STDERR. ACE_HANDLE logging_output_; }; ACE_SVC_FACTORY_DECLARE (ACE_Client_Logging_Acceptor) #endif /* ACE_CLIENT_LOGGER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/README0000644000175000017500000002333712576461726017540 0ustar pgquilespgquiles This directory provides a number of network services that utilize the ACE wrapper features. . Logging_Strategy -- Controls the output of all services that are invoked along with the Logging_Strategy service. Please see below for details on how to control the output. . [Thr_]Server_Logging_Handler.* -- Implements server portion of the ACE distributed logging service. Both multi-threaded and single-threaded implementations are provided. . Client_Logging_Handler.* -- Implements the client portion of the ACE distributed logging service. . Name_Handler.* -- Implements a distributed name service that allows applications to bind, find, and unbind names in a distributed system. . Token_Handler.* -- Implements a distributed token service that allows applications to acquire and release locks in a distributed system. . Time_Handler.* -- Implements a distributed time service that allows distributed applications to synchronize their time. The remainder of this README file explains how these services work. ==================== Logging_Strategy Service ==================== The Logging_Strategy Service can be used to control the output of all the network services. It can be invoked with certain flags that determine where the output of all the services should go. The Logging_Strategy Service sets the flags in ACE_Log_Msg which in turn controls all the streams through macros such as ACE_DEBUG, ACE_ERROR, and ACE_ERROR_RETURN. If default behavior is required, the Logging_Strategy Service need not be invoked or it can be invoked with no paramaters. Here are the command line arguments that can be given to the Logging_Strategy Service: -f || (etc...) where a flag can be any of the following: STDERR -- Write messages to stderr. LOGGER -- Write messages to the local client logger deamon. OSTREAM -- Write messages to the ostream that gets created by specifying a filename (see below) VERBOSE -- Display messages in a verbose manner SILENT -- Do not print messages at all Note: If more than one flag is specified, the flags need to be 'OR'ed as above syntax shows. Make sure there is no space in between the flag and '|'. -s filename If the OSTREAM flag is set, this can be used to specify the filename where the output should be directed. Note that if the OSTREAM flag is set and no filename is specified, ACE_DEFAULT_LOGFILE will be used to write the output to. Examples: To direct output only to STDERR, specify command line arguments as: "-f STDERR" To direct output to both STDERR and a file called "mylog", specify command line arguments as: "-f STDERR|OSTREAM -s mylog" ==================== Name Service ==================== This file describes the principles of the Name_Server server test application. 1. Startup configuration --------------------- To communicate with the server process, a client needs to know the INET_Addr, where the server offers its service. Class Name_Options holds all the configuration information of the Name Service. This consists of : - nameserver_port : Port number where the server process expects requests - nameserver_host : hostname where the server process resides - namespace_dir : directory that holds the NameBinding databases - process_name : name of the client process (argv[0]), NameBindings of a ProcessLocal namespace are stored in file "namespace_dir/process_name". NameBindings of NodeGlobal namespace are stored in "namespace_dir/localnames". NameBindings of Net_Local namespace are stored in file "namespace_dir/globalnames" on the server host. These configuration parameters are passed to the process as commandline arguments to main: -p nameserver port -h nameserver host -l namespace directory The main program _must_ initialize an instance of Name_Options with name name_options (since the shared libraries depend on this). Main should look like : #include "ace/Name_Options.h" Name_Options name_options; int main(int argc, char **argv) { name_options.process_name(argv[0]); name_options.parse_args (argc, argv); ...... } See the examples in the tests subdirectory of ...Name_Server/Client-Server/client and ...Name_Server/Client-Server/server 2. Class Naming_Context ------------------- This is the main workhorse of the Name Service. It is used by client processes as well as by the server process. It manages all accesses to the appropriate NameBinding database (that is the file where NameBindings are stored) and it also manages the communication between a client process and the server (by using class Name_Proxy, which is a private member of Naming_Context). (Note: no IPC is necessary, if a client process runs on the same host as the server). The strategy for all public methods of Naming_Context is common : 1. Transform the format of the arguments to ACE_SString (which is internally used) if necessary. 2. check if work can be done locally : -> call the appropriate local_* method otherwise call the appropriate global_* method. Removing Name_Bindings from the database (either with unbind or rebind) uses the ACE_Malloc class configured with the ACE_MMAP_Memory_Pool. This allows memory to be reclaimed when name/value tuples are unbound. 3. Class Name_Server ---------------- The Name_Server registers in its run method its Name_Acceptor (instantiated with the INET_Addr) at the Reactor, to receive incoming requests. 4. Class Name_Acceptor ------------------ The Name_Acceptor allocates in its handle_input routine a new instance of class Name_Handler on the heap, and accepts connections into this Name_Handler. 5. Class Name_Handler ----------------- The Name_Handler represents the server side of communication between client and server. It interprets incoming requests to the Net_Local namespace and dele- gates the requests to its own Naming_Context (which is the Net_Local namespace on the current host). For communication it uses the helper classes Name_Request (which up to now needs not only contain the request from the client, but also the appropriate reply from the server) and Name_Reply. Note that I want to change the usage of these classes to make the structure of the software clearer. 6. Dependencies ------------ As the Name service must be able to handle wide character strings, it uses ACE_WString String classes. ==================== Time Service ==================== The following is a description of the Time Server clerk and server services: 1. Startup configuration --------------------- Configuring a server requires specifying the port number of the server. This can be specified as a command line argument as follows: -p A clerk communicates with one or more server processes. To communicate with the server process, a client needs to know the INET_Addr, where the server offers its service. The configuration parameters namely the server port and server host are passed as command line arguments when starting up the clerk service as follows: -h : -h : ... Note that multiple servers can be specified in this manner for the clerk to connect to when it starts up. The server name and the port number need to be concatenated and separated by a ":". In addition, the timeout value can also be specified as a command line argument as follows: -t timeout The timeout value specifies the time interval at which the clerk should query the servers for time updates. By default a Clerk does a non-blocking connect to a server. This can be overridden and a Clerk can be made to do a blocking connect by using the -b flag. Here is what a config file would look like for starting up a server at port 20202: dynamic Time_Service Service_Object * ../lib/netsvcs:_make_ACE_TS_Server_Acceptor() "-p 20202" Here is what a config file would look like for starting up a clerk that needs to connect to two servers, one at tango and one at lambada: dynamic Time_Server_test Service_Object *../lib/netsvcs:_make_ACE_TS_Clerk_Processor () "-h tango:20202 -h lambada:20202 -t 4" 2. Class TS_Server_Handler ----------------------- TS_Server_Handler represents the server side of communication between clerk and server. It interprets incoming requests for time updates, gets the system time, creates a reply in response to the request and then sends the reply to the clerk from which it received the request. For communication it uses the helper class Time_Request. 3. Class TS_Server_Acceptor ------------------------ TS_Server_Acceptor allocates in its handle_input routine a new instance of class TS_Server_Handler on the heap, and accepts connections into this TS_Server_Handler. 4. Class TS_Clerk_Handler ---------------------- TS_Clerk_Handler represents the clerk side of communication between clerk and server. It generates requests for time updates every timeout period and then sends these requests to all the servers it is connected to asynchronously. It receives the replies to these requests from the servers through its handle_input method and then adjusts the time using the roundtrip estimate. It caches this time which is later retrieved by TS_Clerk_Processor. 5. Class TS_Clerk_Processor ------------------------ TS_Clerk_Processor creates a new instance of TS_Clerk_Handler for every server connection it needs to create. It periodically calls send_request() of every TS_Clerk_Handler to send a request for time update to all the servers. In the process, it retrieves the latest time cached by each TS_Clerk_Handler and then uses it to compute its notion of the local system time. 6. Algorithms ---------- Currently, updating the system time involves taking the average of all the times received from the servers. ace-6.3.3+dfsg.orig/netsvcs/lib/TS_Clerk_Handler.h0000644000175000017500000001672112576461726022133 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file TS_Clerk_Handler.h * * @author Prashant Jain */ //============================================================================= #ifndef ACE_TS_CLERK_HANDLER_H #define ACE_TS_CLERK_HANDLER_H #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Connector.h" #include "ace/Svc_Handler.h" #include "ace/Connector.h" #include "ace/MMAP_Memory_Pool.h" #include "ace/Malloc_T.h" #include "ace/Null_Mutex.h" #include "ace/svc_export.h" #include "ace/os_include/os_dirent.h" #include "Time_Request_Reply.h" /** * @class ACE_Time_Info * * @brief A simple struct containing delta time and a sequence number. */ class ACE_Time_Info { public: time_t delta_time_; ACE_UINT32 sequence_num_; }; class ACE_TS_Clerk_Processor; // forward declaration #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT template class ACE_Svc_Export ACE_Svc_Handler; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ /** * @class ACE_TS_Clerk_Handler * * @brief The Clerk Handler provides the interface that is used by the * Clerk Processor to send time update requests to all the * servers. It obtains these updates from the servers and passes * the updates to the Clerk Processor * * The Clerk Processor uses send_request() to send a request for * time update to a server. The Clerk Handler internally computes * the round trip delay for the reply to come back. Once it gets * the reply back from the server (handle_input), it adjusts the * system time using the round trip delay estimate and then * passes the delta time by reference back to the Clerk * Processor. */ class ACE_Svc_Export ACE_TS_Clerk_Handler : public ACE_Svc_Handler { public: /// Default constructor. ACE_TS_Clerk_Handler (ACE_TS_Clerk_Processor *processor = 0, ACE_INET_Addr &addr = (ACE_INET_Addr &) ACE_Addr::sap_any); // = Set/get the current state enum State { IDLE = 1, // Prior to initialization. CONNECTING, // During connection establishment. ESTABLISHED, // Connection is established and active. DISCONNECTING, // In the process of disconnecting. FAILED // Connection has failed. }; // = Set/get the current state. State state (void); void state (State); // = Set/get the current retry timeout delay. long timeout (void); void timeout (long); // = Set/get the maximum retry timeout delay. long max_timeout (void); void max_timeout (long); /// Activate this instance of the /// (called by the ). virtual int open (void * = 0); /// Return the handle of the message_fifo_; virtual ACE_HANDLE get_handle (void) const; /// Called when object is removed from the ACE_Reactor virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK); /// Receive time update from a server. virtual int handle_input (ACE_HANDLE); /// Restart connection asynchronously when timeout occurs. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); /// Get/Set remote addr void remote_addr (ACE_INET_Addr &addr); ACE_INET_Addr &remote_addr (void); /// Send request for time update to the server as well as return the /// current time info by reference. int send_request (ACE_UINT32 sequence_num, ACE_Time_Info &time_info); protected: /// Handle SIGPIPE. virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); static void stderr_output (int = 0); enum { MAX_RETRY_TIMEOUT = 300 // 5 minutes is the maximum timeout. }; private: /// Receive a reply from a server containing time update int recv_reply (ACE_Time_Request &reply); /// Reinitiate connection with the server int reinitiate_connection (void); /// The current state of the connection State state_; /// Amount of time to wait between reconnection attempts long timeout_; /// Maximum amount of time to wait between reconnection attempts long max_timeout_; /// Remote Addr used for connecting to the server ACE_INET_Addr remote_addr_; /// Instance of Clerk Processor used for re-establishing connections ACE_TS_Clerk_Processor *processor_; /// Time at which request was sent (used to compute round trip delay) time_t start_time_; /// Next sequence number of time request (waiting for this update from /// the server). ACE_UINT32 cur_sequence_num_; /// Record of current delta time and current sequence number ACE_Time_Info time_info_; }; /** * @class ACE_TS_Clerk_Processor * * @brief This class manages all the connections to the servers along * with querying them periodically for time updates. * * The Clerk Processor creates connections to all the servers and * creates an ACE_TS_Clerk_Handler for each connection to handle * the requests and replies. It periodically sends a request for * time update through each of the handlers and uses the replies * for computing a synchronized system time. */ class ACE_TS_Clerk_Processor : public ACE_Connector { public: /// Default constructor ACE_TS_Clerk_Processor (void); /// Query servers for time periodically (timeout value) virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg); /// Set up connections to all servers int initiate_connection (ACE_TS_Clerk_Handler *, ACE_Synch_Options &); protected: // = Dynamic linking hooks. /// Called when service is linked. virtual int init (int argc, ACE_TCHAR *argv[]); /// Called when service is unlinked. virtual int fini (void); /// Called to determine info about the service. virtual int info (ACE_TCHAR **strp, size_t length) const; // = Scheduling hooks. virtual int suspend (void); virtual int resume (void); private: /// Parse svc.conf arguments. int parse_args (int argc, ACE_TCHAR *argv[]); /// Allocate entry in shared memory for system time void alloc (void); /// Update delta_time using times obtained from all servers int update_time (); /// Allocator (used for reading/writing system time from/to shared memory) typedef ACE_Malloc MALLOC; typedef ACE_Allocator_Adapter ALLOCATOR; ALLOCATOR *shmem_; /// Set of TS_Clerk_Handlers and iterator over the set. typedef ACE_Unbounded_Set HANDLER_SET; typedef ACE_Unbounded_Set_Iterator HANDLER_SET_ITERATOR; HANDLER_SET handler_set_; struct System_Time { time_t *delta_time_; // Diff between system time and local time time_t *last_local_time_; // Last local time }; /// Clerk system time containing pointers to entries in shared memory System_Time system_time_; /// Timer id returned by Reactor long timer_id_; /// Time period for updating system time long timeout_; /// Pool name for backing store ACE_TCHAR poolname_[MAXNAMLEN + 1]; /// Do a blocking/non-blocking connect int blocking_semantics_; /// Sequence number of next expected update from servers ACE_UINT32 cur_sequence_num_; }; ACE_SVC_FACTORY_DECLARE (ACE_TS_Clerk_Processor) #endif /* ACE_TS_CLERK_HANDLER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Base_Optimizer.h0000644000175000017500000000202112576461726021730 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Base_Optimizer.h * * @author Per Andersson. */ //============================================================================= #ifndef BASE_OPTIMIZER_H #define BASE_OPTIMIZER_H #include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ /** * @class Base_Optimizer * * Thanks to Nathan Myers and Fergus Henderson for this little * beauty. */ template class Base_Optimizer : public Base { public: Base_Optimizer (void); Base_Optimizer (const Base &base); Base_Optimizer (const Base &base, const Member &member); Member m_; }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "Base_Optimizer.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Base_Optimizer.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* BASE_OPTIMIZER_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/Server_Logging_Handler.cpp0000644000175000017500000000146412576461726023732 0ustar pgquilespgquiles#if !defined (ACE_SERVER_LOGGING_HANDLER_C) #define ACE_SERVER_LOGGING_HANDLER_C #include "Server_Logging_Handler.h" // The following are "Factories" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the // single-threaded and multi-threaded logging server. ACE_SVC_FACTORY_DEFINE (ACE_Server_Logging_Acceptor) ACE_SVC_FACTORY_DEFINE (ACE_Thr_Server_Logging_Acceptor) #if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) template u_long ACE_Server_Logging_Handler_T::request_count_; #endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ #endif /* ACE_SERVER_LOGGING_HANDLER_C */ ace-6.3.3+dfsg.orig/netsvcs/lib/Time_Request_Reply.h0000644000175000017500000000572112576461726022607 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Time_Request_Reply.h * * Define the format used to exchange messages between the * ACE time server and clerks. * * @author Prashant Jain */ //============================================================================= #ifndef ACE_TIME_REQUEST_REPLY_H #define ACE_TIME_REQUEST_REPLY_H #include /**/ "ace/pre.h" #include "ace/Time_Value.h" #include "ace/svc_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ /** * @class ACE_Time_Request * * @brief Message format for delivering requests to the ACE_Time Server. * * This class is implemented to minimize data copying. * In particular, all marshaling is done in situ... */ class ACE_Svc_Export ACE_Time_Request { public: enum Constants { /// Request message types. TIME_UPDATE = 01, /// Class-specific constant values. MAX_TIME_LEN = MAXPATHLEN + 1 }; /// Default constructor. ACE_Time_Request (void); /** * Create a ACE_Time_Request message. * @param msg_type Type of request. * @param time Time. * @param timeout Max time waiting for request. */ ACE_Time_Request (ACE_INT32 msg_type, const time_t time, ACE_Time_Value *timeout = 0); // Get the fixed size of message ssize_t size (void) const; /// Get the type of the message. ACE_INT32 msg_type (void) const; /// Set the type of the message. void msg_type (ACE_INT32); /// Get the time time_t time (void) const; // Set the time void time (time_t t); /// Get the blocking semantics. ACE_UINT32 block_forever (void) const; /// Set the blocking semantics. void block_forever (ACE_UINT32); /// Get the timeout. ACE_Time_Value timeout (void) const; /// Set the timeout. void timeout (const ACE_Time_Value& timeout); /// Encode the message before transmission. int encode (void *&); /// Decode message after reception. int decode (void); /// Print out the values of the message for debugging purposes. void dump (void) const; private: // = The 5 fields in the struct are transmitted to the server. // The remaining 2 fields are not tranferred -- they are used only on // the server-side to simplify lookups. struct Transfer { /// Type of the request (i.e., ) ACE_INT32 msg_type_; /// Indicates if we should block forever. If 0, then sec_timeout_ /// and usec_timeout_ indicates how long we should wait. ACE_UINT32 block_forever_; /// Max seconds willing to wait for name if not blocking forever. ACE_UINT64 sec_timeout_; /// Max micro seconds to wait for name if not blocking forever. ACE_UINT32 usec_timeout_; /// The data portion contains ACE_UINT64 time_; }; /// Transfer buffer. Transfer transfer_; /// Time time_t time_; }; #include /**/ "ace/post.h" #endif /* ACE_TIME_REQUEST_REPLY_H */ ace-6.3.3+dfsg.orig/netsvcs/lib/lib.mpc0000644000175000017500000000071412576461726020121 0ustar pgquilespgquiles// -*- MPC -*- project(netsvcs): ace_output, acelib { avoids += ace_for_tao sharedname = netsvcs dynamicflags += ACE_BUILD_SVC_DLL Source_Files { Time_Request_Reply.cpp TS_Server_Handler.cpp TS_Clerk_Handler.cpp Client_Logging_Handler.cpp Name_Handler.cpp Log_Message_Receiver.cpp Server_Logging_Handler.cpp Token_Handler.cpp } Template_Files { Base_Optimizer.cpp Server_Logging_Handler_T.cpp } } ace-6.3.3+dfsg.orig/netsvcs/lib/Log_Message_Receiver.cpp0000644000175000017500000001215512576461726023371 0ustar pgquilespgquiles#if !defined (LOG_MESSAGE_RECEIVER_CPP) #define LOG_MESSAGE_RECEIVER_CPP #include "ace/Log_Msg.h" #include "Log_Message_Receiver.h" // Type based log message receiver template void Static_Log_Message_Receiver::log_record (const ACE_TCHAR *hostname, ACE_Log_Record &record) { #if defined (ACE_HAS_THREADS) static ACE_SYNCH_MUTEX_T lock_; ACE_GUARD (ACE_SYNCH_MUTEX_T, guard, lock_); #endif /* ACE_HAS_THREADS */ record.print (hostname, ACE_Log_Msg::instance ()->flags (), stderr); } template void Static_Log_Message_Receiver::log_output (const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *outputfile) { if (outputfile != 0) { #if defined (ACE_HAS_THREADS) static ACE_SYNCH_MUTEX_T lock_; ACE_GUARD (ACE_SYNCH_MUTEX_T, guard, lock_); #endif /* ACE_HAS_THREADS */ record.print (hostname, ACE_Log_Msg::instance ()->flags (), *outputfile); } } #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) template ACE_SYNCH_MUTEX_T Log_Message_Receiver_Impl::copy_lock_; #else static ACE_SYNCH_MUTEX global_copy_lock_; #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ template Log_Message_Receiver_Impl::Log_Message_Receiver_Impl (void) : count_ (0) { } template Log_Message_Receiver_Impl * Log_Message_Receiver_Impl::create (void) { return new Log_Message_Receiver_Impl; } template Log_Message_Receiver_Impl * Log_Message_Receiver_Impl::attach (Log_Message_Receiver_Impl *body) { ACE_ASSERT (body != 0); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, guard, copy_lock_, 0); # else // Use the "body"s print lock as copy lock. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, global_copy_lock_, 0); # endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ #endif /* ACE_HAS_THREADS */ ++body->count_; return body; } template void Log_Message_Receiver_Impl::detach (Log_Message_Receiver_Impl *body) { ACE_ASSERT (body != 0); #if defined (ACE_HAS_THREADS) # if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) ACE_GUARD (ACE_SYNCH_MUTEX_T, guard, copy_lock_); # else // Use the "body"s print lock as copy lock. ACE_GUARD (ACE_SYNCH_MUTEX, guard, global_copy_lock_); # endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ #endif /* ACE_HAS_THREADS */ if (body->count_-- == 0) delete body; } // Type based log message receiver template void Log_Message_Receiver_Impl::log_record (const ACE_TCHAR *hostname, ACE_Log_Record &record) { ACE_GUARD (ACE_SYNCH_MUTEX_T, guard, print_lock_); record.print (hostname, ACE_Log_Msg::instance ()->flags (), stderr); } template void Log_Message_Receiver_Impl::log_output (const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *outputfile) { if (outputfile != 0) { ACE_GUARD (ACE_SYNCH_MUTEX_T, guard, print_lock_); record.print (hostname, ACE_Log_Msg::instance ()->flags (), *outputfile); } } template Log_Message_Receiver_Impl::~Log_Message_Receiver_Impl (void) { ACE_ASSERT (count_ == 0 - 1); } template Log_Message_Receiver::Log_Message_Receiver (void) : receiver_impl_ (Log_Message_Receiver_Impl::create ()) { ACE_ASSERT (receiver_impl_ != 0); } template Log_Message_Receiver::Log_Message_Receiver (Log_Message_Receiver const &rhs) : receiver_impl_ (Log_Message_Receiver_Impl::attach (rhs.receiver_impl_)) { ACE_ASSERT (receiver_impl_ != 0); } // Type based log message receiver template void Log_Message_Receiver::log_record(const ACE_TCHAR *hostname, ACE_Log_Record &record) { ACE_ASSERT (receiver_impl_ != 0); receiver_impl_->log_record (hostname, record); } template void Log_Message_Receiver::log_output(const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *outputfile) { ACE_ASSERT (receiver_impl_ != 0); receiver_impl_->log_output (hostname, record, outputfile); } template Log_Message_Receiver::~Log_Message_Receiver (void) { ACE_ASSERT (receiver_impl_ != 0); Log_Message_Receiver_Impl::detach (receiver_impl_); } #endif /* LOG_MESSAGE_RECEIVER_CPP */ ace-6.3.3+dfsg.orig/netsvcs/lib/Name_Handler.cpp0000644000175000017500000005007512576461726021700 0ustar pgquilespgquiles#include "ace/Containers.h" #include "ace/Get_Opt.h" #include "ace/Singleton.h" #include "ace/Auto_Ptr.h" #include "Name_Handler.h" #include "ace/Signal.h" #include "ace/OS_NS_string.h" // Simple macro that does bitwise AND -- useful in table lookup #define ACE_TABLE_MAP(INDEX, MASK) (INDEX & MASK) // Simple macro that does bitwise AND and then right shift bits by 3 #define ACE_LIST_MAP(INDEX, MASK) (((unsigned long) (INDEX & MASK)) >> 3) int ACE_Name_Acceptor::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Name_Acceptor::parse_args"); int service_port = ACE_DEFAULT_SERVER_PORT; ACE_LOG_MSG->open (ACE_TEXT ("Name Service")); this->naming_context()->name_options()->parse_args( argc, argv ); service_port = this->naming_context()->name_options()->nameserver_port(); // dont allow to connect to another name serever if(this->naming_context()->name_options()->context() == ACE_Naming_Context::NET_LOCAL) this->naming_context()->name_options()->nameserver_host(ACE_TEXT ("localhost")); if (this->naming_context()->open( this->naming_context()->name_options()->context() ) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n open naming context failed.\n")), -1); this->service_addr_.set (service_port); return 0; } int ACE_Name_Acceptor::init (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Name_Acceptor::init"); // Use the options hook to parse the command line arguments and set // options. if( this->parse_args (argc, argv) == -1 ) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Name_Acceptor::parse_args failed")), -1); // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), 0, 0, 0, &this->scheduling_strategy_, ACE_TEXT ("Name Server"), ACE_TEXT ("ACE naming service")) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p on port %d\n"), ACE_TEXT ("acceptor::open failed"), this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each can handle this on its // own. ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE); ACE_UNUSED_ARG (sig); ACE_INET_Addr server_addr; // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_local_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("starting up Name Server at port %d on handle %d\n"), server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; } // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the Naming // Server. ACE_SVC_FACTORY_DEFINE (ACE_Name_Acceptor) // Default constructor. ACE_Name_Handler::ACE_Name_Handler (ACE_Thread_Manager *tm) : ACE_Svc_Handler (tm) { ACE_TRACE ("ACE_Name_Handler::ACE_Name_Handler"); // Set up pointers to member functions for the top-level dispatching // of client requests. this->op_table_[ACE_Name_Request::BIND] = &ACE_Name_Handler::bind; this->op_table_[ACE_Name_Request::REBIND] = &ACE_Name_Handler::rebind; this->op_table_[ACE_Name_Request::RESOLVE] = &ACE_Name_Handler::resolve; this->op_table_[ACE_Name_Request::UNBIND] = &ACE_Name_Handler::unbind; this->op_table_[ACE_Name_Request::LIST_NAMES] = &ACE_Name_Handler::lists; this->op_table_[ACE_Name_Request::LIST_NAME_ENTRIES] = &ACE_Name_Handler::lists_entries; // Assign references to simplify subsequent code. LIST_ENTRY &list_names_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_NAMES, ACE_Name_Request::LIST_OP_MASK)]; LIST_ENTRY &list_values_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_VALUES, ACE_Name_Request::LIST_OP_MASK)]; LIST_ENTRY &list_types_ref = this->list_table_[ACE_LIST_MAP (ACE_Name_Request::LIST_TYPES, ACE_Name_Request::LIST_OP_MASK)]; // Set up pointers to member functions for dispatching within the // LIST_{NAMES,VALUES,TYPES} methods. list_names_ref.operation_ = &ACE_Naming_Context::list_names; list_names_ref.request_factory_ = &ACE_Name_Handler::name_request; list_names_ref.description_ = "request for LIST_NAMES\n"; list_values_ref.operation_ = &ACE_Naming_Context::list_values; list_values_ref.request_factory_ = &ACE_Name_Handler::value_request; list_values_ref.description_ = "request for LIST_VALUES\n"; list_types_ref.operation_ = &ACE_Naming_Context::list_types; list_types_ref.request_factory_ = &ACE_Name_Handler::type_request; list_types_ref.description_ = "request for LIST_TYPES\n"; } // Activate this instance of the ACE_Name_Handler (called by the // ACE_Name_Acceptor). /* VIRTUAL */ int ACE_Name_Handler::open (void * v) { ACE_TRACE ("ACE_Name_Handler::open"); // Call down to our parent to register ourselves with the Reactor. if (ACE_Svc_Handler::open (0) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); ACE_Name_Acceptor* acceptor_ = static_cast(v); naming_context_ = acceptor_->naming_context(); return 0; } // Create and send a reply to the client. /* VIRTUAL */ int ACE_Name_Handler::send_reply (ACE_INT32 status, ACE_UINT32 err) { ACE_TRACE ("ACE_Name_Handler::send_reply"); void *buf; this->name_reply_.msg_type (status); this->name_reply_.errnum (err); this->name_reply_.init (); int len = this->name_reply_.encode (buf); if (len == -1) return -1; ssize_t n = this->peer ().send (buf, len); if (n != len) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n, expected len = %d, actual len = %d"), ACE_TEXT ("send failed"), len, n), -1); else return 0; } /* VIRTUAL */ int ACE_Name_Handler::send_request (ACE_Name_Request &request) { ACE_TRACE ("ACE_Name_Handler::send_request"); void *buffer; ssize_t length = request.encode (buffer); if (length == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("encode failed")), -1); // Transmit request via a blocking send. if (this->peer ().send_n (buffer, length) != length) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n failed")), -1); return 0; } // Give up waiting (e.g., when a timeout occurs or a client shuts down // unexpectedly). /* VIRTUAL */ int ACE_Name_Handler::abandon (void) { ACE_TRACE ("ACE_Name_Handler::abandon"); return this->send_reply (-1, errno); } // Enable clients to limit the amount of time they'll wait /* VIRTUAL */ int ACE_Name_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_TRACE ("ACE_Name_Handler::handle_timeout"); return this->abandon (); } // Return the underlying ACE_HANDLE. /* VIRTUAL */ ACE_HANDLE ACE_Name_Handler::get_handle (void) const { ACE_TRACE ("ACE_Name_Handler::get_handle"); return this->peer ().get_handle (); } // Dispatch the appropriate operation to handle the client request. /* VIRTUAL */ int ACE_Name_Handler::dispatch (void) { ACE_TRACE ("ACE_Name_Handler::dispatch"); // Dispatch the appropriate request. int index = this->name_request_.msg_type (); // Invoke the appropriate member function obtained by indexing into // the op_table_. ACE_TABLE_MAP returns the same index (by bitwise // AND) for list_names, list_values, and list_types since they are // all handled by the same method. Similarly, it returns the same // index for list_name_entries, list_value_entries, and // list_type_entries. return (this->*op_table_[ACE_TABLE_MAP (index, ACE_Name_Request::OP_TABLE_MASK)]) (); } // Receive, frame, and decode the client's request. Note, this method // should use non-blocking I/O. /* VIRTUAL */ int ACE_Name_Handler::recv_request (void) { ACE_TRACE ("ACE_Name_Handler::recv_request"); // Read the first 4 bytes to get the length of the message This // implementation assumes that the first 4 bytes are the length of // the message. ssize_t n = this->peer ().recv ((void *) &this->name_request_, sizeof (ACE_UINT32)); switch (n) { case -1: /* FALLTHROUGH */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("****************** recv_request returned -1\n"))); default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, sizeof (ACE_UINT32))); /* FALLTHROUGH */ case 0: // We've shutdown unexpectedly, let's abandon the connection. this->abandon (); return -1; /* NOTREACHED */ case sizeof (ACE_UINT32): { // Transform the length into host byte order. ssize_t length = ACE_NTOHL (this->name_request_.length ()); // Do a sanity check on the length of the message. if (length > (ssize_t) sizeof this->name_request_) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("length %d too long\n"), length)); return this->abandon (); } // Receive the rest of the request message. // @@ beware of blocking read!!!. n = this->peer ().recv ((void *) (((char *) &this->name_request_) + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); // Subtract off the size of the part we skipped over... if (n != (length - (ssize_t) sizeof (ACE_UINT32))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p expected %d, got %d\n"), ACE_TEXT ("invalid length"), length, n)); return this->abandon (); } // Decode the request into host byte order. if (this->name_request_.decode () == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed"))); return this->abandon (); } } } return 0; } // Callback method invoked by the ACE_Reactor when events arrive from // the client. /* VIRTUAL */ int ACE_Name_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Name_Handler::handle_input"); if (this->recv_request () == -1) return -1; else return this->dispatch (); } int ACE_Name_Handler::bind (void) { ACE_TRACE ("ACE_Name_Handler::bind"); return this->shared_bind (0); } int ACE_Name_Handler::rebind (void) { ACE_TRACE ("ACE_Name_Handler::rebind"); int result = this->shared_bind (1); return result == 1 ? 0 : result; } int ACE_Name_Handler::shared_bind (int rebind) { ACE_TRACE ("ACE_Name_Handler::shared_bind"); ACE_NS_WString a_name (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_WCHAR_T)); ACE_NS_WString a_value (this->name_request_.value (), this->name_request_.value_len () / sizeof (ACE_WCHAR_T)); int result; if (rebind == 0) { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for BIND\n"))); #endif /* 0 */ result = this->naming_context ()->bind (a_name, a_value, this->name_request_.type ()); } else { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for REBIND\n"))); #endif /* 0 */ result = this->naming_context ()->rebind (a_name, a_value, this->name_request_.type ()); if (result == 1) result = 0; } if (result == 0) return this->send_reply (0); else return this->send_reply (-1); } int ACE_Name_Handler::resolve (void) { ACE_TRACE ("ACE_Name_Handler::resolve"); #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for RESOLVE\n"))); #endif /* 0 */ ACE_NS_WString a_name (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_WCHAR_T)); // The following will deliver our reply back to client we // pre-suppose success (indicated by type RESOLVE). ACE_NS_WString avalue; char *atype; if (this->naming_context ()->resolve (a_name, avalue, atype) == 0) { ACE_Auto_Basic_Array_Ptr avalue_urep (avalue.rep ()); ACE_Name_Request nrq (ACE_Name_Request::RESOLVE, 0, 0, avalue_urep.get (), avalue.length () * sizeof (ACE_WCHAR_T), atype, ACE_OS::strlen (atype)); delete[] atype; return this->send_request (nrq); } ACE_Name_Request nrq (ACE_Name_Request::BIND, 0, 0, 0, 0, 0, 0); this->send_request (nrq); return 0; } int ACE_Name_Handler::unbind (void) { ACE_TRACE ("ACE_Name_Handler::unbind"); #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for UNBIND\n"))); #endif /* 0 */ ACE_NS_WString a_name (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_WCHAR_T)); if (this->naming_context ()->unbind (a_name) == 0) return this->send_reply (0); else return this->send_reply (-1); } ACE_Name_Request ACE_Name_Handler::name_request (ACE_NS_WString *one_name) { ACE_TRACE ("ACE_Name_Handler::name_request"); ACE_Auto_Basic_Array_Ptr one_name_urep (one_name->rep ()); return ACE_Name_Request (ACE_Name_Request::LIST_NAMES, one_name_urep.get (), one_name->length () * sizeof (ACE_WCHAR_T), 0, 0, 0, 0); } ACE_Name_Request ACE_Name_Handler::value_request (ACE_NS_WString *one_value) { ACE_TRACE ("ACE_Name_Handler::value_request"); ACE_Auto_Basic_Array_Ptr one_value_urep (one_value->rep ()); return ACE_Name_Request (ACE_Name_Request::LIST_VALUES, 0, 0, one_value_urep.get (), one_value->length () * sizeof (ACE_WCHAR_T), 0, 0); } ACE_Name_Request ACE_Name_Handler::type_request (ACE_NS_WString *one_type) { ACE_TRACE ("ACE_Name_Handler::type_request"); return ACE_Name_Request (ACE_Name_Request::LIST_TYPES, 0, 0, 0, 0, ACE_Auto_Basic_Array_Ptr (one_type->char_rep ()).get (), one_type->length ()); } int ACE_Name_Handler::lists (void) { ACE_TRACE ("ACE_Name_Handler::lists"); ACE_PWSTRING_SET set; ACE_NS_WString pattern (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_WCHAR_T)); // Get the index into the list table int index = ACE_LIST_MAP (this->name_request_.msg_type (), ACE_Name_Request::LIST_OP_MASK); // Print the message type ACE_DEBUG ((LM_DEBUG, list_table_[index].description_)); // Call the appropriate method if ((this->naming_context ()->*list_table_[index].operation_) (set, pattern) != 0) { // None found so send blank request back ACE_Name_Request end_rq (ACE_Name_Request::MAX_ENUM, 0, 0, 0, 0, 0, 0); if (this->send_request (end_rq) == -1) return -1; } else { ACE_NS_WString *one_entry = 0; for (ACE_Unbounded_Set_Iterator set_iterator (set); set_iterator.next (one_entry) !=0; set_iterator.advance()) { ACE_Name_Request nrq ((this->*list_table_[index].request_factory_) (one_entry)); // Create a request by calling the appropriate method obtained // by accessing into the table. Then send the request across. if (this->send_request (nrq) == -1) return -1; } // Send last message indicator. ACE_Name_Request nrq (ACE_Name_Request::MAX_ENUM, 0, 0, 0, 0, 0, 0); return this->send_request (nrq); } return 0; } int ACE_Name_Handler::lists_entries (void) { ACE_TRACE ("ACE_Name_Handler::lists_entries"); ACE_BINDING_SET set; ACE_NS_WString pattern (this->name_request_.name (), this->name_request_.name_len () / sizeof (ACE_WCHAR_T)); int result = -1; const ACE_Name_Request::Constants msg_type = static_cast (this->name_request_.msg_type ()); // NOTE: This multi-branch conditional statement used to be // (and should be) a switch statement. However, it caused // Internal compiler error 980331 with egcs 1.1 (2.91.57). // So, the pointer-to-member-function temporary has been removed. if (msg_type == ACE_Name_Request::LIST_NAME_ENTRIES) { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for LIST_NAME_ENTRIES\n"))); #endif /* 0 */ result = this->naming_context ()-> ACE_Naming_Context::list_name_entries (set, pattern); } else if (msg_type == ACE_Name_Request::LIST_VALUE_ENTRIES) { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for LIST_VALUE_ENTRIES\n"))); #endif /* 0 */ result = this->naming_context ()-> ACE_Naming_Context::list_value_entries (set, pattern); } else if (msg_type == ACE_Name_Request::LIST_TYPE_ENTRIES) { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request for LIST_TYPE_ENTRIES\n"))); #endif /* 0 */ result = this->naming_context ()-> ACE_Naming_Context::list_type_entries (set, pattern); } else return -1; if (result == 0) { ACE_Name_Binding *one_entry = 0; for (ACE_Unbounded_Set_Iterator set_iterator (set); set_iterator.next (one_entry) !=0; set_iterator.advance()) { ACE_Auto_Basic_Array_Ptr name_urep (one_entry->name_.rep ()); ACE_Auto_Basic_Array_Ptr value_urep (one_entry->value_.rep ()); ACE_Name_Request mynrq (this->name_request_.msg_type (), name_urep.get (), one_entry->name_.length () * sizeof (ACE_WCHAR_T), value_urep.get (), one_entry->value_.length () * sizeof (ACE_WCHAR_T), one_entry->type_, ACE_OS::strlen (one_entry->type_)); if (this->send_request (mynrq) == -1) return -1; } // send last message indicator ACE_Name_Request nrq (ACE_Name_Request::MAX_ENUM, 0, 0, 0, 0, 0, 0); if (this->send_request (nrq) == -1) return -1; } else { // None found so send blank request back. ACE_Name_Request end_rq (ACE_Name_Request::MAX_ENUM, 0, 0, 0, 0, 0, 0); if (this->send_request (end_rq) == -1) return -1; } return 0; } ACE_Naming_Context * ACE_Name_Handler::naming_context (void) { return naming_context_; } ACE_Naming_Context * ACE_Name_Acceptor::naming_context (void) { return &naming_context_; } ACE_Name_Handler::~ACE_Name_Handler (void) { ACE_TRACE ("ACE_Name_Handler::~ACE_Name_Handler"); #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("closing down Handle %d\n"), this->get_handle ())); #endif /* 0 */ } ace-6.3.3+dfsg.orig/netsvcs/lib/Token_Handler.cpp0000644000175000017500000004121512576461726022074 0ustar pgquilespgquiles#include "ace/Get_Opt.h" #include "Token_Handler.h" #if defined (ACE_HAS_TOKENS_LIBRARY) #include "ace/Signal.h" int ACE_Token_Acceptor::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Token_Acceptor::parse_args"); u_short svc_port = ACE_DEFAULT_SERVER_PORT; ACE_LOG_MSG->open (ACE_TEXT ("Token Service")); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"), 0); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'p': svc_port = static_cast (ACE_OS::atoi (get_opt.opt_arg ())); break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n[-p server-port]\n"), 1), -1); } } this->service_addr_.set (svc_port); return 0; } int ACE_Token_Acceptor::init (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Token_Acceptor::init"); // Use the options hook to parse the command line arguments and set // options. this->parse_args (argc, argv); // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), 0, 0, 0, &this->scheduling_strategy_, ACE_TEXT ("Token Server"), ACE_TEXT ("ACE token service")) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p on port %d\n"), ACE_TEXT ("acceptor::open failed"), this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each can handle this on its // own. ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE); ACE_UNUSED_ARG (sig); ACE_INET_Addr server_addr; if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("starting up Token Server at port %d on handle %d\n"), server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; } // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the Naming // Server. ACE_SVC_FACTORY_DEFINE (ACE_Token_Acceptor) // Default constructor. ACE_Token_Handler::ACE_Token_Handler (ACE_Thread_Manager *tm) : ACE_Svc_Handler (tm), collection_ (1), timeout_id_ (0) { ACE_TRACE ("ACE_Token_Handler::ACE_Token_Handler"); } // Create and send a reply to the client. /* VIRTUAL */ int ACE_Token_Handler::send_reply (ACE_UINT32 err) { ACE_TRACE ("ACE_Token_Handler::send_reply"); void *buf; size_t len; ssize_t n; this->token_reply_.errnum (err); len = this->token_reply_.encode (buf); n = this->peer ().send (buf, len); if (n != (ssize_t) len) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p, expected len = %d, actual len = %d\n"), ACE_TEXT ("send failed"), len, n), -1); else return 0; } // Acquire the token. /* VIRTUAL */ int ACE_Token_Handler::acquire (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::acquire"); #if 0 ACE_DEBUG ((LM_DEBUG, "in acquire for client id = %s\n", proxy->client_id ())); #endif /* 0 */ // @@ add notify in token request reply if (proxy->acquire (0, 0, ACE_Synch_Options::asynch) == -1) { if (errno != EWOULDBLOCK) // bad bad bad return this->send_reply (errno); // acquire would block if (request_options_[ACE_Synch_Options::USE_TIMEOUT] == 1) { // check for polling if ((request_options_.timeout ().sec () == 0) && (request_options_.timeout ().usec () == 0)) return this->send_reply (EWOULDBLOCK); // schedule a timer this->timeout_id_ = this->reactor ()->schedule_timer (this, (void *) proxy, request_options_.timeout ()); if (timeout_id_ == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer"))); return this->send_reply (errno); } } // send no reply. wait until we acquire it or until the timer // goes off. return 0; } else // success return this->send_reply (0); } // Try to acquire the token. Never block. /* VIRTUAL */ int ACE_Token_Handler::try_acquire (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::try_acquire"); #if 0 ACE_DEBUG ((LM_DEBUG, "in try_acquire for client id = %s\n", proxy->client_id ())); #endif /* 0 */ // @@ add notify in token request reply if (proxy->tryacquire () == -1) return this->send_reply (errno); else return this->send_reply (0); } // Release the token and allow the next client that is waiting to // proceed. /* VIRTUAL */ int ACE_Token_Handler::release (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::release"); #if 0 ACE_DEBUG ((LM_DEBUG, "in release for client id = %s\n", proxy->client_id ())); #endif /* 0 */ if (proxy->release (ACE_Synch_Options::asynch) == -1) // oops, it failed return this->send_reply (ACE_LOG_MSG->errnum ()); // success if (this->timeout_id_ != 0) { this->reactor ()->cancel_timer (timeout_id_); this->timeout_id_ = 0; } return this->send_reply (0); } // Yield the token if any clients are waiting, otherwise keep the // token. /* VIRTUAL */ int ACE_Token_Handler::renew (ACE_Token_Proxy *proxy) { ACE_TRACE ("ACE_Token_Handler::renew"); #if 0 ACE_DEBUG ((LM_DEBUG, "in renew for client id = %s\n", proxy->client_id ())); #endif /* 0 */ if (proxy->renew (token_request_.requeue_position (), ACE_Synch_Options::asynch) == -1) { int result = ACE_LOG_MSG->errnum (); if (result != EWOULDBLOCK) // bad bad bad return this->send_reply (result); // acquire would block if (request_options_[ACE_Synch_Options::USE_TIMEOUT] == 1) { this->timeout_id_ = this->reactor ()->schedule_timer (this, 0, request_options_.timeout ()); if (timeout_id_ == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer"))); return this->send_reply (ACE_LOG_MSG->errnum ()); } } // Send no reply. wait until we acquire it or until the timer // goes off. return 0; } else // Success, we still hold the token. return this->send_reply (0); } /* VIRTUAL */ int ACE_Token_Handler::remove (ACE_Token_Proxy * /* proxy */) { ACE_TRACE ("ACE_Token_Handler::remove"); #if 0 ACE_DEBUG ((LM_DEBUG, "in remove for client id = %s\n", proxy->client_id ())); #endif /* 0 */ ACE_ERROR ((LM_ERROR, ACE_TEXT ("sorry: ACE_Token_Handler::remove() is not implemented"))); return this->send_reply (ENOTSUP); } // Enable clients to limit the amount of time they'll wait for a // token. /* VIRTUAL */ int ACE_Token_Handler::handle_timeout (const ACE_Time_Value &, const void *tp) { ACE_TRACE ("ACE_Token_Handler::handle_timeout"); this->timeout_id_ = 0; // @@ add a try acquire here! // Try to acquire the token, but if we can't get it immediately // then abandon the wait. // if (this->try_acquire (&token_entry) == -1) // return this->abandon (token_entry); ACE_Token_Proxy *proxy = (ACE_Token_Proxy *) tp; #if 0 ACE_DEBUG ((LM_DEBUG, "in handle_timeout for client id = %s\n", proxy->client_id ())); #endif /* 0 */ // Remove ourselves from the waiter list. proxy->release (); this->send_reply (ETIME); return 0; } // Dispatch the appropriate operation to handle the client request. ACE_Token_Proxy * ACE_Token_Handler::get_proxy (void) { ACE_TRACE ("ACE_Token_Handler::get_proxy"); // See if the proxy already exists in the collection. ACE_Token_Proxy *proxy = collection_.is_member (token_request_.token_name ()); // If not, create one. if (proxy == 0) { proxy = this->create_proxy (); // Put the new_proxy in this client_id's collection. if (collection_.insert (*proxy) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("insert failed\n")), 0); // Delete our copy (one was created in the collection). delete proxy; proxy = collection_.is_member (token_request_.token_name ()); if (proxy == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("is_member failed\n")), 0); // Set the client_id (it was set to 1 since we're // single-threaded. proxy->client_id (token_request_.client_id ()); } return proxy; } ACE_Token_Proxy * ACE_Token_Handler::create_proxy (void) { ACE_TRACE ("ACE_Token_Handler::create_proxy"); ACE_Token_Proxy *proxy; switch (token_request_.token_type ()) { case ACE_Tokens::RWLOCK: if (token_request_.proxy_type () == ACE_RW_Token::READER) ACE_NEW_RETURN (proxy, ACE_TS_RLock (token_request_.token_name (), this), 0); else ACE_NEW_RETURN (proxy, ACE_TS_WLock (token_request_.token_name (), this), 0); break; case ACE_Tokens::MUTEX: ACE_NEW_RETURN (proxy, ACE_TS_Mutex (token_request_.token_name (), this), 0); break; default: // Nonexistent token type. errno = EINVAL; return 0; } // Check for failed new. if (proxy == 0) errno = ENOMEM; return proxy; } int ACE_Token_Handler::dispatch (void) { ACE_TRACE ("ACE_Token_Handler::dispatch"); ACE_Token_Proxy *proxy = this->get_proxy (); if (proxy == 0) return -1; // Dispatch the appropriate request. switch (this->token_request_.operation_type ()) { case ACE_Token_Request::ACQUIRE: return this->acquire (proxy); case ACE_Token_Request::TRY_ACQUIRE: return this->try_acquire (proxy); case ACE_Token_Request::RELEASE: return this->release (proxy); case ACE_Token_Request::RENEW: return this->renew (proxy); case ACE_Token_Request::REMOVE: return this->remove (proxy); default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("invalid type = %d\n"), this->token_request_.operation_type ()), -1); /* NOTREACHED */ } } // Receive, frame, and decode the client's request. // Note, this method should use non-blocking I/O. /* VIRTUAL */ int ACE_Token_Handler::recv_request (void) { ACE_TRACE ("ACE_Token_Handler::recv_request"); ssize_t n; // Read the first 4 bytes to get the length of the message // This implementation assumes that the first 4 bytes are // the length of the message. n = this->peer ().recv ((void *) &this->token_request_, sizeof (ACE_UINT32)); switch (n) { case -1: /* FALLTHROUGH */ default: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"), ACE_TEXT ("recv failed"), n, sizeof (ACE_UINT32))); /* FALLTHROUGH */ case 0: // We've shutdown unexpectedly, let's abandon the connection. this->abandon (0); return -1; /* NOTREACHED */ case sizeof (ACE_UINT32): { // Transform the length into host byte order. ssize_t length = this->token_request_.length (); // Do a sanity check on the length of the message. if (length > (ssize_t) sizeof this->token_request_) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("length %d too long\n"), length)); return this->abandon (1); } // Receive the rest of the request message. // @@ beware of blocking read!!!. n = this->peer ().recv ((void *) (((char *) &this->token_request_) + sizeof (ACE_UINT32)), length - sizeof (ACE_UINT32)); // Subtract off the size of the part we skipped over... if (n != (length - (ssize_t) sizeof (ACE_UINT32))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p expected %d, got %d\n"), ACE_TEXT ("invalid length"), length, n)); return this->abandon (1); } // Decode the request into host byte order. if (this->token_request_.decode () == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed"))); return this->abandon (1); } // if (OS::debug) this->token_request_.dump (); } } return 0; } // Callback method invoked by the ACE_Reactor when // events arrive from the client. /* VIRTUAL */ int ACE_Token_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_Token_Handler::handle_input"); #if 0 ACE_DEBUG ((LM_DEBUG, "****************** in handle_input\n")); #endif /* 0 */ if (this->recv_request () == -1) return -1; else return this->dispatch (); } void ACE_Token_Handler::sleep_hook (void) { ACE_TRACE ("ACE_Token_Handler::sleep_hook"); // @@ what should we do? return; } void ACE_Token_Handler::token_acquired (ACE_TPQ_Entry *) { ACE_TRACE ("ACE_Token_Handler::token_acquired"); if (this->timeout_id_ != 0) { this->reactor ()->cancel_timer (this->timeout_id_); this->timeout_id_ = 0; } this->send_reply (0); } int ACE_Token_Handler::abandon (int send_error) { ACE_TRACE ("ACE_Token_Handler::abandon"); // Release ownership or remove us from the waiter list. if (this->timeout_id_ != 0) { this->reactor ()->cancel_timer (timeout_id_); this->timeout_id_ = 0; } // @@ release all tokens collection_.release (); if (send_error) return this->send_reply (EIO); else return -1; } // ************************************************************ // ************************************************************ // ************************************************************ ACE_TS_Mutex::ACE_TS_Mutex (const ACE_TCHAR *name, ACE_Token_Handler *th) : ACE_Local_Mutex (name, 0, 1), // The 1 is debug. th_ (th) { ACE_TRACE ("ACE_TS_Mutex::ACE_TS_Mutex"); } ACE_TS_Mutex::ACE_TS_Mutex (const ACE_TS_Mutex &m) : ACE_Local_Mutex (m), th_ (m.th_) { ACE_TRACE ("ACE_TS_Mutex::ACE_TS_Mutex"); this->open (m.name (), m.ignore_deadlock_, m.debug_); } void ACE_TS_Mutex::sleep_hook (void) { ACE_TRACE ("ACE_TS_Mutex::sleep_hook"); th_->sleep_hook (); return; } void ACE_TS_Mutex::token_acquired (ACE_TPQ_Entry *e) { ACE_TRACE ("ACE_TS_Mutex::token_acquired"); // Notify the token handler. th_->token_acquired (e); return; } ACE_Token_Proxy * ACE_TS_Mutex::clone (void) const { ACE_TRACE ("ACE_TS_Mutex::clone"); ACE_Token_Proxy *temp; ACE_NEW_RETURN (temp, ACE_TS_Mutex (*this), 0); return temp; } // ************************************************************ ACE_TS_RLock::ACE_TS_RLock (const ACE_TCHAR *name, ACE_Token_Handler *th) : ACE_Local_RLock (name, 0, 1), // The 1 is debug. th_ (th) { ACE_TRACE ("ACE_TS_RLock::ACE_TS_RLock"); } ACE_TS_RLock::ACE_TS_RLock (const ACE_TS_RLock &r) : ACE_Local_RLock (r), th_ (r.th_) { ACE_TRACE ("ACE_TS_RLock::ACE_TS_RLock"); this->open (r.name (), r.ignore_deadlock_, r.debug_); } void ACE_TS_RLock::sleep_hook (void) { ACE_TRACE ("ACE_TS_RLock::sleep_hook"); th_->sleep_hook (); return; } void ACE_TS_RLock::token_acquired (ACE_TPQ_Entry *e) { ACE_TRACE ("ACE_TS_RLock::token_acquired"); // Notify the token handler. th_->token_acquired (e); return; } ACE_Token_Proxy * ACE_TS_RLock::clone (void) const { ACE_TRACE ("ACE_TS_RLock::clone"); ACE_Token_Proxy *temp; ACE_NEW_RETURN (temp, ACE_TS_RLock (*this), 0); return temp; } // ************************************************************ ACE_TS_WLock::ACE_TS_WLock (const ACE_TCHAR *name, ACE_Token_Handler *th) : ACE_Local_WLock (name, 0, 1), // The 1 is debug. th_ (th) { ACE_TRACE ("ACE_TS_WLock::ACE_TS_WLock"); } ACE_TS_WLock::ACE_TS_WLock (const ACE_TS_WLock &w) : ACE_Local_WLock (w), th_ (w.th_) { ACE_TRACE ("ACE_TS_WLock::ACE_TS_WLock"); this->open (w.name (), w.ignore_deadlock_, w.debug_); } void ACE_TS_WLock::sleep_hook (void) { ACE_TRACE ("ACE_TS_WLock::sleep_hook"); th_->sleep_hook (); return; } void ACE_TS_WLock::token_acquired (ACE_TPQ_Entry *e) { ACE_TRACE ("ACE_TS_WLock::token_acquired"); // Notify the token handler. th_->token_acquired (e); return; } ACE_Token_Proxy * ACE_TS_WLock::clone (void) const { ACE_TRACE ("ACE_TS_WLock::clone"); ACE_Token_Proxy *temp; ACE_NEW_RETURN (temp, ACE_TS_WLock (*this), 0); return temp; } #endif /* ACE_HAS_TOKENS_LIBRARY */ ace-6.3.3+dfsg.orig/netsvcs/lib/Client_Logging_Handler.cpp0000644000175000017500000005307712576461726023711 0ustar pgquilespgquiles#include "ace/Get_Opt.h" #include "ace/Acceptor.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SPIPE_Acceptor.h" #include "ace/Log_Record.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_NS_unistd.h" #include "ace/CDR_Stream.h" #include "ace/Auto_Ptr.h" #include "ace/SString.h" #include "ace/INET_Addr.h" #include "Client_Logging_Handler.h" ACE_Client_Logging_Handler::ACE_Client_Logging_Handler (ACE_HANDLE output_handle) : logging_output_ (output_handle) { // Register ourselves to receive SIGPIPE so we can attempt // reconnections. #if !defined (ACE_LACKS_UNIX_SIGNALS) if (ACE_Reactor::instance ()->register_handler (SIGPIPE, this) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("register_handler (SIGPIPE)"))); #endif /* !ACE_LACKS_UNIX_SIGNALS */ } // This is called when a to the logging server fails... int ACE_Client_Logging_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) { if (signum == SIGPIPE) return 0; else return -1; } // This function is called every time a client connects to us. int ACE_Client_Logging_Handler::open (void *) { LOGGING_ADDR server_addr; // Register ourselves to receive callbacks when // clients send us logging records. Note that since we're really a // Singleton, this->peer() will change after each connect, so we // need to grab the value now. if (ACE_Reactor::instance ()->register_handler (this->peer ().get_handle (), this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("register_handler")), -1); // Figure out what remote port we're really bound to. if (this->peer ().get_remote_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Connected to client on handle %u\n"), this->peer ().get_handle ())); return 0; } /* VIRTUAL */ ACE_HANDLE ACE_Client_Logging_Handler::get_handle (void) const { ACE_TRACE ("ACE_Client_Logging_Handler::get_handle"); ACE_ERROR ((LM_ERROR, ACE_TEXT ("get_handle() shouldn't be called\n"))); return ACE_INVALID_HANDLE; } // Receive a logging record from an application. int ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle) { #if 0 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in ACE_Client_Logging_Handler::handle_input, handle = %u\n"), handle)); #endif /* 0 */ if (handle == this->logging_output_) // We're getting a message from the logging server! ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Received data from server!\n")), -1); ACE_Log_Record log_record; // We need to use the old two-read trick here since TCP sockets // don't support framing natively. Allocate a message block for the // payload; initially at least large enough to hold the header, but // needs some room for alignment. ACE_Message_Block *payload_p = 0; ACE_Message_Block *header_p = 0; ACE_NEW_RETURN (header_p, ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE), -1); auto_ptr header (header_p); // Align the Message Block for a CDR stream ACE_CDR::mb_align (header.get ()); #if (ACE_HAS_STREAM_LOG_MSG_IPC == 1) // We're getting a logging message from a local application using // STREAM pipes, which are nicely prioritized for us. ACE_Str_Buf header_msg (header->wr_ptr (), 0, 8); ACE_SPIPE_Stream spipe; spipe.set_handle (handle); int flags = 0; // We've got a framed IPC mechanism, so we can just to a . ssize_t result = spipe.recv (&header_msg, (ACE_Str_Buf *) 0, &flags); if (result < 0 || header_msg.len == 0) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("client closing down unexpectedly\n"))); if (ACE_Reactor::instance ()->remove_handler (handle, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("remove_handler")), -1); spipe.close (); return 0; } #else // We're getting a logging message from a local application using // sockets pipes, which are NOT prioritized for us. ssize_t const count = ACE::recv_n (handle, header->wr_ptr (), 8); switch (count) { // Handle shutdown and error cases. default: case -1: case 0: ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("client closing down\n"))); if (ACE_Reactor::instance ()->remove_handler (handle, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("remove_handler")), 0); if (handle == this->peer ().get_handle ()) this->peer ().close (); else ACE_OS::closesocket (handle); // Release the memory to prevent a leak. return 0; /* NOTREACHED */ case 8: // Just fall through in this case.. break; } #endif /* ACE_HAS_STREAM_LOG_MSG_IPC == 1 */ // Reflect addition of 8 bytes for the header. header->wr_ptr (8); // Create a CDR stream to parse the 8-byte header. ACE_InputCDR header_cdr (header.get ()); // Extract the byte-order and use helper methods to disambiguate // octet, booleans, and chars. ACE_CDR::Boolean byte_order; if (!(header_cdr >> ACE_InputCDR::to_boolean (byte_order))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract byte_order\n"))); return 0; } // Set the byte-order on the stream... header_cdr.reset_byte_order (byte_order); // Extract the length ACE_CDR::ULong length; if (!(header_cdr >> length)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract length\n"))); return 0; } ACE_NEW_RETURN (payload_p, ACE_Message_Block (length), -1); auto_ptr payload (payload_p); // Ensure there's sufficient room for log record payload. ACE_CDR::grow (payload.get (), 8 + ACE_CDR::MAX_ALIGNMENT + length); #if (ACE_HAS_STREAM_LOG_MSG_IPC == 1) ACE_Str_Buf payload_msg (payload->wr_ptr (), 0, length); // We've got a framed IPC mechanism, so we can just do a . result = spipe.recv ((ACE_Str_Buf *) 0, &payload_msg, &flags); if (result < 0 || payload_msg.len != (int)length) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"), ACE_TEXT ("client closing down due to error\n"))); if (ACE_Reactor::instance ()->remove_handler (handle, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: result %d, length %d %p\n"), result, payload_msg.len, ACE_TEXT ("remove_handler")), -1); spipe.close (); return 0; } #else // Use to obtain the contents. if (ACE::recv_n (handle, payload->wr_ptr (), length) <= 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv_n()"))); if (ACE_Reactor::instance ()->remove_handler (handle, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::EXCEPT_MASK | ACE_Event_Handler::DONT_CALL) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%n: %p\n"), ACE_TEXT ("remove_handler"))); ACE_OS::closesocket (handle); return 0; } #endif /* ACE_HAS_STREAM_LOG_MSG_IPC == 1 */ // Reflect additional bytes for the message. payload->wr_ptr (length); ACE_InputCDR payload_cdr (payload.get ()); payload_cdr.reset_byte_order (byte_order); if (!(payload_cdr >> log_record)) // Finally extract the ACE_log_record. { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract log_record\n"))); return 0; } log_record.length (length); // Forward the logging record to the server. if (this->send (log_record) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send"))); return 0; } // Receive a logging record from an application send via a non-0 // MSG_BAND... This just calls handle_input(). int ACE_Client_Logging_Handler::handle_exception (ACE_HANDLE handle) { return this->handle_input (handle); } // Called when object is removed from the ACE_Reactor int ACE_Client_Logging_Handler::close (u_long) { if (this->logging_output_ != ACE_STDERR) ACE_OS::closesocket (this->logging_output_); this->destroy (); return 0; } int ACE_Client_Logging_Handler::handle_output (ACE_HANDLE) { return 0; } // Encodes the contents of log_record object using network byte-order // and sends it to the logging server. int ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record) { ostream *orig_ostream = ACE_Log_Msg::instance ()->msg_ostream (); // This logic must occur before we do the encode() on // since otherwise the values of the fields will be in // network byte order. if (orig_ostream) log_record.print (ACE_TEXT (""), ACE_Log_Msg::instance ()->flags (), *orig_ostream); if (this->logging_output_ == ACE_STDERR) { log_record.print (ACE_TEXT (""), ACE_Log_Msg::instance ()->flags (), stderr); } else { // Serialize the log record using a CDR stream, allocate enough // space for the complete . size_t const max_payload_size = 4 // type() + 8 // timestamp + 4 // process id + 4 // data length + ACE_Log_Record::MAXLOGMSGLEN // data + ACE_CDR::MAX_ALIGNMENT; // padding; // Insert contents of into payload stream. ACE_OutputCDR payload (max_payload_size); if (!(payload << log_record)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't insert log_record\n"))); return -1; } // Get the number of bytes used by the CDR stream. ACE_CDR::ULong const length = payload.total_length (); // Send a header so the receiver can determine the byte order and // size of the incoming CDR stream. ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8); if (!(header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't insert byte order\n"))); return -1; } // Store the size of the payload that follows if (!(header << ACE_CDR::ULong (length))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't insert length\n"))); return -1; } // Use an iovec to send both buffer and payload simultaneously. iovec iov[2]; iov[0].iov_base = header.begin ()->rd_ptr (); iov[0].iov_len = 8; iov[1].iov_base = payload.begin ()->rd_ptr (); iov[1].iov_len = length; // We're running over sockets, so send header and payload // efficiently using "gather-write". if (ACE::sendv_n (this->logging_output_,iov, 2) == -1) { ACE_DEBUG ((LM_DEBUG, "Something about the sendv_n() failed, so switch to stderr\n")); if (ACE_Log_Msg::instance ()->msg_ostream () == 0) // Switch over to logging to stderr for now. At some // point, we'll improve the implementation to queue up the // message, try to reestablish a connection, and then send // the queued data once we've reconnect to the logging // server. If you'd like to implement this functionality // and contribute it back to ACE that would be great! this->logging_output_ = ACE_STDERR; } else ACE_DEBUG ((LM_DEBUG, "Sent logging message %s successfully to Server Logging Daemon!\n", log_record.priority_name (ACE_Log_Priority (log_record.type ())))); } return 0; } class ACE_Client_Logging_Acceptor : public ACE_Acceptor { // = TITLE // This factory creates connections with the // . // // = DESCRIPTION // This class contains the service-specific methods that can't // easily be factored into the . public: // = Initialization method. ACE_Client_Logging_Acceptor (void); // Default constructor. protected: // = Dynamic linking hooks. virtual int init (int argc, ACE_TCHAR *argv[]); // Called when service is linked. virtual int fini (void); // Called when service is unlinked. virtual int info (ACE_TCHAR **strp, size_t length) const; // Called to determine info about the service. virtual int make_svc_handler (ACE_Client_Logging_Handler *&sh); // Factory that always returns the . // = Scheduling hooks. virtual int suspend (void); virtual int resume (void); private: int parse_args (int argc, ACE_TCHAR *argv[]); // Parse svc.conf arguments. const ACE_TCHAR *server_host_; // Host where the logging server is located. u_short server_port_; // Port number where the logging server is listening for // connections. ACE_INET_Addr server_addr_; // Address to connect to the server logging daemon. ACE_INET_Addr local_addr_; // Local IP/port number to use for the connection to the server logging // daemon. const ACE_TCHAR *logger_key_; // Communication endpoint where the client logging daemon will // listen for connections from clients. ACE_Client_Logging_Handler *handler_; // Pointer to the singleton handler that receives messages from // clients and forwards to the server. }; int ACE_Client_Logging_Acceptor::fini (void) { this->close (); if (this->handler_ != 0) this->handler_->close (0); // Try to unlink the logger key so weird things don't happen if // we're using STREAM pipes. ACE_OS::unlink (this->logger_key_); // This memory was allocated by . ACE_OS::free ((void *) this->logger_key_); ACE_OS::free ((void *) this->server_host_); return 0; } int ACE_Client_Logging_Acceptor::make_svc_handler (ACE_Client_Logging_Handler *&sh) { // Always return a pointer to the Singleton handler. sh = this->handler_; return 0; } int ACE_Client_Logging_Acceptor::info (ACE_TCHAR **strp, size_t length) const { ACE_TCHAR buf[BUFSIZ]; ACE_OS::sprintf (buf, ACE_TEXT ("%d/%s %s"), this->server_addr_.get_port_number (), "tcp", "# client logging daemon\n"); if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) return -1; else ACE_OS::strncpy (*strp, buf, length); return ACE_OS::strlen (buf); } ACE_Client_Logging_Acceptor::ACE_Client_Logging_Acceptor (void) : server_host_ (ACE_OS::strdup (ACE_DEFAULT_SERVER_HOST)), server_port_ (ACE_DEFAULT_LOGGING_SERVER_PORT), logger_key_ (ACE_OS::strdup (ACE_DEFAULT_LOGGER_KEY)), handler_ (0) { } int ACE_Client_Logging_Acceptor::init (int argc, ACE_TCHAR *argv[]) { // We'll log *our* error and debug messages to stderr! if (ACE_LOG_MSG->open (ACE_TEXT ("Client Logging Service")) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Can't open ACE_Log_Msg\n")), -1); // Use the options hook to parse the command line arguments and set // options. this->parse_args (argc, argv); // Try to unlink the logger key so weird things don't happen if // we're using STREAM pipes. ACE_OS::unlink (this->logger_key_); // Initialize the acceptor endpoint. if (this->open (LOGGING_ADDR (this->logger_key_)) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), this->logger_key_), -1); // Establish connection with the server. ACE_SOCK_Connector con; ACE_SOCK_Stream stream; ACE_INET_Addr server_addr; #if (ACE_HAS_STREAM_LOG_MSG_IPC == 1) ACE_SPIPE_Addr lserver_addr; // Figure out what local port we're really bound to. if (this->acceptor ().get_local_addr (lserver_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_local_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Starting up Client Logging Daemon, ") ACE_TEXT ("bounded to STREAM addr %s on handle %u\n"), lserver_addr.get_path_name (), this->acceptor ().get_handle ())); #else ACE_INET_Addr lserver_addr; // Figure out what local port we're really bound to. if (this->acceptor ().get_local_addr (lserver_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_local_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Starting up Client Logging Daemon, ") ACE_TEXT ("bounded to local port %d on handle %u\n"), lserver_addr.get_port_number (), this->acceptor ().get_handle ())); #endif /* ACE_HAS_STREAM_LOG_MSG_IPC == 1 */ if (con.connect (stream, this->server_addr_, 0, this->local_addr_) == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't connect to logging server %C on port %d: ") ACE_TEXT ("%m, using stderr\n"), this->server_addr_.get_host_name (), this->server_addr_.get_port_number (), ACE_ERRNO_GET)); if (ACE_Log_Msg::instance ()->msg_ostream () == 0) // If we can't connect to the server then we'll send the logging // messages to stderr. stream.set_handle (ACE_STDERR); } else { // Figure out what remote port we're really bound to. if (stream.get_remote_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client Logging Daemon is connected to Server ") ACE_TEXT ("Logging Daemon %C on port %d on handle %u\n"), server_addr.get_host_name (), server_addr.get_port_number (), stream.get_handle ())); } // Create the Singleton . ACE_NEW_RETURN (this->handler_, ACE_Client_Logging_Handler (stream.get_handle ()), -1); return 0; } int ACE_Client_Logging_Acceptor::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("h:k:p:l:"), 0); ACE_TString local_addr_str; for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': ACE_OS::free ((void *) this->server_host_); this->server_host_ = ACE_OS::strdup (get_opt.opt_arg ()); break; case 'k': ACE_OS::free ((void *) this->logger_key_); this->logger_key_ = ACE_OS::strdup (get_opt.opt_arg ()); break; case 'p': this->server_port_ = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'l': local_addr_str = get_opt.opt_arg (); break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n[-p server-port]\n") ACE_TEXT ("[-l local-ip[:local-port]]\n")), -1); } } this->local_addr_.set ((u_short)0); // "any" if (local_addr_str.length () > 0) { if (local_addr_str.rfind (ACE_TCHAR(':')) == ACE_TString::npos) local_addr_str += ACE_TEXT (":0"); ACE_TCHAR *local_addr_cstr = local_addr_str.rep (); if (-1 == local_addr_.string_to_addr (ACE_TEXT_ALWAYS_CHAR (local_addr_cstr))) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), local_addr_cstr)); delete [] local_addr_cstr; } if (this->server_addr_.set (this->server_port_, this->server_host_) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), this->server_host_), -1); return 0; } int ACE_Client_Logging_Acceptor::suspend (void) { // To be done... return 0; } int ACE_Client_Logging_Acceptor::resume (void) { // To be done... return 0; } // The following is a "Factory" used by the ACE_Service_Config and // svc.conf file to dynamically initialize the state of the // single-threaded logging server. ACE_SVC_FACTORY_DEFINE (ACE_Client_Logging_Acceptor) ace-6.3.3+dfsg.orig/netsvcs/lib/Server_Logging_Handler_T.cpp0000644000175000017500000003605712576461726024223 0ustar pgquilespgquiles#ifndef ACE_SERVER_LOGGING_HANDLERT_C #define ACE_SERVER_LOGGING_HANDLERT_C #include "ace/config-all.h" #include "ace/Get_Opt.h" #include "ace/Log_Record.h" #include "ace/CDR_Stream.h" #include "Server_Logging_Handler_T.h" #include "ace/Signal.h" #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) // Track number of requests. template COUNTER ACE_Server_Logging_Handler_T::request_count_ = (COUNTER) 0; #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ template ACE_Server_Logging_Handler_T::ACE_Server_Logging_Handler_T (ACE_Thread_Manager *, LMR const &receiver) // Initialize the CString to something that is not the empty string // to avoid problems when calling fast_rep() #if !defined (__GNUG__) : receiver_ (receiver, ACE_TString (ACE_TEXT(" "), 1)) #else : receiver_ (receiver), host_name_ (ACE_TString (ACE_TEXT (" "), 1)) #endif /* ! __GNUG__ */ { } // Callback routine for handling the reception of remote logging // transmissions. template int ACE_Server_Logging_Handler_T::handle_input (ACE_HANDLE) { int result = this->handle_logging_record (); return result >= 0 ? 0 : -1; } template const ACE_TCHAR * ACE_Server_Logging_Handler_T::host_name (void) { #if !defined (__GNUG__) return this->receiver_.m_.fast_rep (); #else return this->host_name_.fast_rep (); #endif /* ! __GNUG__ */ } template int ACE_Server_Logging_Handler_T::handle_logging_record () { ACE_Log_Record log_record; // We need to use the old two-read trick here since TCP sockets // don't support framing natively. Allocate a message block for the // payload; initially at least large enough to hold the header, but // needs some room for alignment. ACE_Message_Block *payload_p = 0; ACE_Message_Block *header_p = 0; ACE_NEW_RETURN (header_p, ACE_Message_Block (ACE_DEFAULT_CDR_BUFSIZE), -1); auto_ptr header (header_p); // Align the Message Block for a CDR stream ACE_CDR::mb_align (header.get ()); ACE_CDR::Boolean byte_order; ACE_CDR::ULong length; ssize_t count = ACE::recv_n (this->peer ().get_handle (), header->wr_ptr (), 8); switch (count) { // Handle shutdown and error cases. default: case -1: case 0: ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("server logging daemon closing down at host %s\n"), this->host_name ())); return -1; /* NOTREACHED */ case 8: // Just fall through in this case.. break; } header->wr_ptr (8); // Reflect addition of 8 bytes. // Create a CDR stream to parse the 8-byte header. ACE_InputCDR header_cdr (header.get ()); // Extract the byte-order and use helper methods to disambiguate // octet, booleans, and chars. if (!(header_cdr >> ACE_InputCDR::to_boolean (byte_order))) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract byte_order\n"))); return 0; } // Set the byte-order on the stream... header_cdr.reset_byte_order (byte_order); // Extract the length if (!(header_cdr >> length)) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract length\n"))); return 0; } ACE_NEW_RETURN (payload_p, ACE_Message_Block (length), -1); auto_ptr payload (payload_p); // Ensure there's sufficient room for log record payload. ACE_CDR::grow (payload.get (), 8 + ACE_CDR::MAX_ALIGNMENT + length); // Use to obtain the contents. if (ACE::recv_n (this->peer ().get_handle (), payload->wr_ptr (), length) <= 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv_n()"))); return -1; } payload->wr_ptr (length); // Reflect additional bytes ACE_InputCDR payload_cdr (payload.get ()); payload_cdr.reset_byte_order (byte_order); if (!(payload_cdr >> log_record)) // Finally extract the . { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Can't extract log_record\n"))); return 0; } log_record.length (length); // Send the log record to the log message receiver for processing. if (ACE_BIT_ENABLED (ACE_Log_Msg::instance ()->flags (), ACE_Log_Msg::STDERR)) receiver ().log_record (this->host_name (), log_record); ostream *orig_ostream = ACE_Log_Msg::instance ()->msg_ostream (); receiver ().log_output (this->host_name (), log_record, orig_ostream); return 0; #if 0 ACE_INT32 length; // We need to use the ol' two-read trick here since TCP sockets // don't support framing natively. Note that the first call is just // a "peek" -- we don't actually remove the data until the second // call. Note that this code is portable as long as ACE_UNIT32 is // always 32 bits on both the sender and receiver side. switch (this->peer ().recv ((void *) &length, sizeof length, MSG_PEEK)) { default: case -1: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p at host %s\n"), ACE_TEXT ("server logger"), this->host_name ()), -1); /* NOTREACHED */ case 0: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("closing log daemon at host %C\n"), this->host_name ()), -1); /* NOTREACHED */ case sizeof length: { ACE_Log_Record lp; // Use ACE_NTOHL to get around bug in egcs 2.91.6x. length = ACE_NTOHL (length); #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) ++this->request_count_; u_long count = this->request_count_; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("request count = %d, length = %d\n"), count, length)); #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ // Perform the actual this time. ssize_t n = this->peer ().recv_n ((void *) &lp, length); if (n != length) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%d != %d, %p at host %C\n"), n, length, ACE_TEXT ("server logger"), this->host_name ()), -1); lp.decode (); if (lp.length () == n) { // Send the log record to the log message receiver for // processing. if (ACE_BIT_ENABLED (ACE_Log_Msg::instance ()->flags (), ACE_Log_Msg::STDERR)) receiver ().log_record (this->host_name (), lp); ostream *orig_ostream = ACE_Log_Msg::instance ()->msg_ostream (); receiver ().log_output (this->host_name (), lp, orig_ostream); } else ACERROR ((LM_ERROR, ACE_TEXT ("error, lp.length = %d, n = %d\n"), lp.length (), n)); return n; } } #endif ACE_NOTREACHED (return -1;) } // Hook called by Server_Logging_Acceptor when connection is // established. template int ACE_Server_Logging_Handler_T::open_common (void) { // Shut off non-blocking IO if it was enabled... if (this->peer ().disable (ACE_NONBLOCK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("disable")), -1); ACE_PEER_STREAM_ADDR client_addr; // Determine the address of the client and display it. if (this->peer ().get_remote_addr (client_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); #if !defined (__GNUG__) this->receiver_.m_ = ACE_TString (ACE_TEXT_CHAR_TO_TCHAR (client_addr.get_host_name ())); #else this->host_name_ = ACE_TString (ACE_TEXT_CHAR_TO_TCHAR (client_addr.get_host_name ())); #endif /* ! __GNUG__ */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) accepted connection from host %C on fd %d\n"), client_addr.get_host_name (), this->peer ().get_handle ())); return 0; } template ACE_Server_Logging_Acceptor_T::ACE_Server_Logging_Acceptor_T (void) { } template LMR & ACE_Server_Logging_Acceptor_T::receiver (void) { return receiver_; } template SST & ACE_Server_Logging_Acceptor_T::scheduling_strategy (void) { #if !defined (__GNUG__) return receiver_.m_; #else return schedule_strategy_; #endif /* ! __GNUG__ */ } template int ACE_Server_Logging_Acceptor_T::init (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Server_Logging_Acceptor_T::init"); // Use the options hook to parse the command line arguments and set // options. this->parse_args (argc, argv); // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). if (this->open (this->service_addr_, ACE_Reactor::instance (), 0, 0, 0, &this->scheduling_strategy(), ACE_TEXT ("Logging Server"), ACE_TEXT ("ACE logging service")) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n: %p on port %d\n"), ACE_TEXT ("acceptor::open failed"), this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each can handle this on its // own. ACE_Sig_Action sig ((ACE_SignalHandler) SIG_IGN, SIGPIPE); ACE_UNUSED_ARG (sig); ACE_INET_Addr server_addr; // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_local_addr")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("starting up Logging Server at port %d on handle %d\n"), server_addr.get_port_number (), this->acceptor ().get_handle ())); return 0; } template int ACE_Server_Logging_Acceptor_T::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_TRACE ("ACE_Server_Logging_Acceptor_T::parse_args"); int service_port = ACE_DEFAULT_SERVER_PORT; ACE_LOG_MSG->open (ACE_TEXT ("Logging Service"), ACE_LOG_MSG->flags ()); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("p:"), 0); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'p': service_port = ACE_OS::atoi (get_opt.opt_arg ()); break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%n:\n[-p server-port]\n")), -1); } } this->service_addr_.set (service_port); return 0; } template int ACE_Server_Logging_Acceptor_T ::make_svc_handler (SERVER_LOGGING_HANDLER *&handler) { ACE_NEW_RETURN (handler, SERVER_LOGGING_HANDLER (ACE_Thread_Manager::instance (), this->receiver()), -1); return 0; } template ACE_Server_Logging_Handler::ACE_Server_Logging_Handler (ACE_Thread_Manager * tm, LOG_MESSAGE_RECEIVER const& receiver) : ACE_Server_Logging_Handler_T(tm, receiver) { } template ACE_Server_Logging_Handler::ACE_Server_Logging_Handler(ACE_Thread_Manager * tm) : ACE_Server_Logging_Handler_T(tm, LOG_MESSAGE_RECEIVER()) { } template int ACE_Server_Logging_Handler::open (void *) { // call base class open_common if (this->open_common () != 0) return -1; // Register ourselves with the Reactor to enable subsequent // dispatching. if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) return -1; return 0; } template ACE_Thr_Server_Logging_Handler::ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *tm, LOG_MESSAGE_RECEIVER const &receiver) : ACE_Server_Logging_Handler_T(tm, receiver) { } template ACE_Thr_Server_Logging_Handler::ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *tm) : ACE_Server_Logging_Handler_T(tm, LOG_MESSAGE_RECEIVER ()) { } template int ACE_Thr_Server_Logging_Handler::open (void *) { // call base class open_common if (this->open_common () != 0) return -1; // Spawn a new thread of control to handle logging records with the // client using a thread-per-connection concurrency model. Note // that this implicitly uses the to // control all the threads. if (this->activate (THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn")), -1); return 0; } // Process remote logging records. template int ACE_Thr_Server_Logging_Handler::svc (void) { int result = 0; // Loop until the client terminates the connection or an error occurs. while ((result = this->handle_input ()) == 0) continue; return result; } #endif /* ACE_SERVER_LOGGING_HANDLER_TT_C */ ace-6.3.3+dfsg.orig/netsvcs/lib/Log_Message_Receiver.h0000644000175000017500000001702512576461726023037 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Log_Message_Receiver.h * * @author Per Andersson */ //============================================================================= #ifndef LOG_MESSAGE_RECEIVER_H #define LOG_MESSAGE_RECEIVER_H #include "ace/Log_Record.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Synch_Traits.h" #include "ace/Guard_T.h" #if defined (ACE_HAS_THREADS) # include "ace/Thread_Mutex.h" #else # include "ace/Null_Mutex.h" #endif /* ACE_HAS_THREADS */ // ==========================================================================// //------------- General Requirements on a Log Message Receiver --------------// // ==========================================================================// // The requirements on a log manager receiver, T, are quite simple. // 1: There must exist one "log_record" member function with the following // prototype: // void log_record(const ACE_TCHAR *hostname, // ACE_Log_Record &record); // // 2: There must exist a public destructor. // 3: There must exist a public copy constructor. // 4: There must exist a default constructor. (for now) // // The semantics are also simple. A log message receiver should // behave as an accessor object (smart pointer or envelope class). // It should be very cheap to copy and the should be no noticeable // difference when using either the new copy or the old log message // receiver. // // Methods: // void log_record(const ACE_TCHAR* hostname, // ACE_Log_Record& record) // Description: // Processes the log record "record" from the host "hostname" // Precondition: // hostname != 0; // Requirements: // Record must be a valid ACE_Log_Record. // // ==========================================================================// // ==========================================================================// // ------------ General Description of a Log Message Receiver -------------- // // ==========================================================================// // Log Message Receivers, LRMs, are processing log records. It is the // LRM that writes a log message to stderr, stdout, a log file and maybee // converts some of the log messages to notifications, warnings, alarms // and forwards them to some operation and maintenance system (PATROL). // // The client logging handler and server logging handler are responsible // for forwarding, receiving, framing, processing log records. // That is a very usable service, but it should also be possible to change // how log records are processed without having to rewrite code in // the server log handler. This code should instead be written as a // separate entity, a Log Message Receiver. // // A simple LMR should be very easy to write but it should also // be possible to write more complex LMRs, like one that creates // a new log file each day or keeps a fixed size, round robin, // log file. It should also be possible to have separate LMRs // of the same type that uses different log files. // // ==========================================================================// // Type based log message receiver /** * @class Static_Log_Message_Receiver * * @brief Static_Log_Message_Receiver is a simple log message receiver. It * has no instance data and only static member * functions. Static/typed based receivers are best when all LMR * should do exactly the same thing. * * This class contains a static log_record member function that * prints the content of log_records on stderr. */ template class Static_Log_Message_Receiver { public: /// Prints the log_record to stderr using record.print (hostname, 0, stderr). /// Serializes the output by using a ACE_SYNCH_MUTEX. static void log_record(const ACE_TCHAR *hostname, ACE_Log_Record &record); /// Prints the log_record to a user specified ostream. static void log_output(const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *output); }; // Instance based log message receiver // ------------------------ Log_Message_Receiver --------------------------- // // Log_Message_Receiver is little more complicated log message receiver. // It is instance based and have a reference counted implementation. // Log_Message_Receiver is the envelope class for Log_Message_Receiver_Impl. // // ------------------------------------------------------------------------- // //Forward declaration template class Log_Message_Receiver_Impl; /** * @class Log_Message_Receiver * * @brief Log_Message_Receiver is a little more complicated log message * receiver. It is instance based and have a reference counted * implementation. Log_Message_Receiver is the envelope class for * Log_Message_Receiver_Impl. The difference between * Static_Log_Message_Receiver and Log_Message_Receiver is that is * possible to have instance data in Log_Message_Receiver. * Comment: * The practical usage of this is limited with the current * ACE_Server_Logging_Acceptor_T design. Since * ACE_Server_Logging_Acceptor_T will create the * Log_Message_Receiver using the default constructor. The main * reason for inclusion right now is to ensure that the code in * ACE_Server_Logging_Handler_T works both with type and instance * based LMRs. * * This class contains a log_record member function that prints the * content of log_records on stderr. */ template class Log_Message_Receiver { public: /// Creates a new Log_Message_Receiver Log_Message_Receiver (void); Log_Message_Receiver(Log_Message_Receiver const &rhs); ~Log_Message_Receiver (void); void log_record (const ACE_TCHAR *hostname, ACE_Log_Record &record); void log_output(const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *output); private: ACE_UNIMPLEMENTED_FUNC (void operator= (const Log_Message_Receiver &rhs)) // Attributes. Log_Message_Receiver_Impl *receiver_impl_; }; /** * @class Log_Message_Receiver_Impl * * @brief Implementation with reference count. */ template class Log_Message_Receiver_Impl { public: // Methods for handling reference count and instance lifetime static Log_Message_Receiver_Impl *create (void); static Log_Message_Receiver_Impl *attach (Log_Message_Receiver_Impl *body); static void detach (Log_Message_Receiver_Impl *body); void log_record (const ACE_TCHAR *hostname, ACE_Log_Record &record); void log_output(const ACE_TCHAR *hostname, ACE_Log_Record &record, ostream *output); protected: Log_Message_Receiver_Impl (void); ~Log_Message_Receiver_Impl (void); /// Attributes int count_; ACE_SYNCH_MUTEX_T print_lock_; private: #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) static ACE_SYNCH_MUTEX_T copy_lock_; #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ ACE_UNIMPLEMENTED_FUNC (void operator= (const Log_Message_Receiver_Impl &)) ACE_UNIMPLEMENTED_FUNC (Log_Message_Receiver_Impl (const Log_Message_Receiver_Impl &)) }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "Log_Message_Receiver.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Log_Message_Receiver.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* LOG_MESSAGE_RECEIVER_H */ ace-6.3.3+dfsg.orig/netsvcs/servers/0000775000175000017500000000000012576472436017575 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/servers/servers.mpc0000644000175000017500000000035612576461726021771 0ustar pgquilespgquiles// -*- MPC -*- project(Netsvcs_server) : aceexe, avoids_ace_for_tao { exename = ace_netsvcs libs += netsvcs after += netsvcs includes += $(ACE_ROOT)/netsvcs/lib avoids += ace_for_tao Source_Files { main.cpp } } ace-6.3.3+dfsg.orig/netsvcs/servers/main.cpp0000644000175000017500000001547012576461726021232 0ustar pgquilespgquiles#include "ace/Service_Config.h" #include "ace/Logging_Strategy.h" #include "ace/Sig_Adapter.h" #include "TS_Clerk_Handler.h" #include "TS_Server_Handler.h" #include "Client_Logging_Handler.h" #include "Name_Handler.h" #include "Token_Handler.h" #include "Server_Logging_Handler.h" int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Try to link in the svc.conf entries dynamically, enabling the // "ignore_debug_flag" as the last parameter so that we can override // the default ACE_Log_Priority settings in the svc.conf file. // // Warning - do not try to move the ACE_Reactor signal handling work // up to before this call - if the user specified -b (be a daemon), // all handles will be closed, including the Reactor's pipe. if (ACE_Service_Config::open (argc, argv, ACE_DEFAULT_LOGGER_KEY, 1, 0, 1) == -1) { if (errno != ENOENT) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), 1); else // Use static linking. { if (ACE::debug () == 0) ACE_LOG_MSG->priority_mask (~LM_DEBUG, ACE_Log_Msg::PROCESS); // Calling ACE_SVC_INVOKE to create a new Service_Object. // Stash the newly created Service_Object into an // ACE_Service_Object_Ptr which is an specialized // for ACE_Service_Object. ACE_TCHAR *l_argv[3]; ACE_TCHAR name_port[] = ACE_TEXT ("-p ") ACE_TEXT (ACE_DEFAULT_NAME_SERVER_PORT_STR); l_argv[0] = name_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_1 = ACE_SVC_INVOKE (ACE_Name_Acceptor); if (sp_1->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Name Service")), 1); ACE_TCHAR time_port[] = ACE_TEXT ("-p ") ACE_TEXT (ACE_DEFAULT_TIME_SERVER_PORT_STR); l_argv[0] = time_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_2 = ACE_SVC_INVOKE (ACE_TS_Server_Acceptor); if (sp_2->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("TS Server Acceptor")), 1); ACE_TCHAR clerk_port[] = ACE_TEXT ("-p 10011"); l_argv[0] = argv[0]; l_argv[1] = clerk_port; l_argv[2] = 0; ACE_Service_Object_Ptr sp_3 = ACE_SVC_INVOKE (ACE_TS_Clerk_Processor); if (sp_3->init (2, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("TS Clerk Processor")), 1); #if defined (ACE_HAS_TOKENS_LIBRARY) ACE_TCHAR token_port[] = ACE_TEXT ("-p ") ACE_TEXT (ACE_DEFAULT_TOKEN_SERVER_PORT_STR); l_argv[0] = token_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_4 = ACE_SVC_INVOKE (ACE_Token_Acceptor); if (sp_4->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Token Service")), 1); #endif /* ACE_HAS_TOKENS_LIBRARY */ ACE_TCHAR thr_logging_port[] = ACE_TEXT ("-p ") ACE_TEXT (ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR); l_argv[0] = thr_logging_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_5 = ACE_SVC_INVOKE (ACE_Thr_Server_Logging_Acceptor); if (sp_5->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Threaded Logging Server")), 1); ACE_TCHAR logging_port[] = ACE_TEXT ("-p ") ACE_TEXT (ACE_DEFAULT_LOGGING_SERVER_PORT_STR); l_argv[0] = logging_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_6 = ACE_SVC_INVOKE (ACE_Server_Logging_Acceptor); if (sp_6->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Logging Server")), 1); l_argv[0] = logging_port; l_argv[1] = 0; ACE_Service_Object_Ptr sp_7 = ACE_SVC_INVOKE (ACE_Client_Logging_Acceptor); if (sp_7->init (1, l_argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("Logging Client")), 1); // Run forever, performing the configured services until we // are shut down by a SIGINT/SIGQUIT signal. // Create an adapter to end the event loop. ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); ACE_Sig_Set sig_set; sig_set.sig_add (SIGINT); sig_set.sig_add (SIGQUIT); if (ACE_Reactor::instance ()->register_handler (sig_set, &sa) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register signals")), 1); } else { ACE_Reactor::instance ()->run_reactor_event_loop (); // Back from running the reactor we have to remove our signal handler ACE_Reactor::instance ()->remove_handler (sig_set); } // Destructors of ACE_Service_Object_Ptr's automagically // call fini(). } } else // Use dynamic linking. { // Run forever, performing the configured services until we are // shut down by a SIGINT/SIGQUIT signal. // Create an adapter to end the event loop. ACE_Sig_Adapter sa ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); ACE_Sig_Set sig_set; sig_set.sig_add (SIGINT); sig_set.sig_add (SIGQUIT); // Register ourselves to receive signals so we can shut down // gracefully. if (ACE_Reactor::instance ()->register_handler (sig_set, &sa) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register signals2")), 1); } else { ACE_Reactor::instance ()->run_reactor_event_loop (); // Back from running the reactor we have to remove our signal handler ACE_Reactor::instance ()->remove_handler (sig_set); } } return 0; } ace-6.3.3+dfsg.orig/netsvcs/servers/README0000644000175000017500000000312112576461726020450 0ustar pgquilespgquiles This directory contains the driver program that links the various services together, either statically or dynamically, to form complete server programs. You can configure the following ACE network services into the driver program by changing how the svc.conf file is setup: . Logger -- Controls the output of all services that are invoked along with the Logger service. Please see the README file in /netsvcs/lib for details on how to control the output. . [Thr_]Server_Logging_Handler.* -- Implements server portion of the ACE distributed logging service. Both multi-threaded and single-threaded implementations are provided. . Client_Logging_Handler.* -- Implements the client portion of the ACE distributed logging service. Note that you generally will run a netsvc daemon that's configured with *either* the server portion of the logging service or the client portion of the logging service, but not both in the same process. In other words, you'll need to have separate svc.conf files to configure the client logging process and the server logging process independently. . Name_Handler.* -- Implements a distributed name service that allows applications to bind, find, and unbind names in a distributed system. . Token_Handler.* -- Implements a distributed token service that allows distributed applications to acquire and release locks in a distributed system. . Time_Handler.* -- Implements a distributed time service that allows distributed applications to synchronize their time. ace-6.3.3+dfsg.orig/netsvcs/servers/svc.conf.xml0000644000175000017500000000346712576461726022046 0ustar pgquilespgquiles ace-6.3.3+dfsg.orig/netsvcs/servers/svc.conf0000644000175000017500000000236612576461726021244 0ustar pgquilespgquiles # These are the services that can be linked into ACE. # Note that you can append the "netsvcs" with # a relative path if you idn't set your LD search path correctly -- # ACE will locate this for you automatically by reading your LD search # path. Moreover, ACE will automatically insert the correct suffix # (e.g., ".dll", ".so", etc.). In addition, you can replace the # hardcoded "-p 20xxx" with "-p $PORTxxx" if you set your environment # variables correctly. dynamic Logger Service_Object * ACE:_make_ACE_Logging_Strategy() "-w -s foobar -f STDERR|OSTREAM|VERBOSE" dynamic Time_Service Service_Object * netsvcs:_make_ACE_TS_Server_Acceptor() "-p 20222" dynamic Name_Server Service_Object * netsvcs:_make_ACE_Name_Acceptor() "-p 20006" # This service is disabled by default -- only enable it ACE is compiled with ACE_HAS_TOKENS_LIBRARY. # dynamic Token_Service Service_Object * netsvcs:_make_ACE_Token_Acceptor() "-p 20202" dynamic Server_Logging_Service Service_Object * netsvcs:_make_ACE_Server_Logging_Acceptor() active "-p 20009" dynamic Thr_Server_Logging_Service Service_Object * netsvcs:_make_ACE_Thr_Server_Logging_Acceptor() active "-p 20020" dynamic Client_Logging_Service Service_Object * netsvcs:_make_ACE_Client_Logging_Acceptor() active "-p 20009" ace-6.3.3+dfsg.orig/netsvcs/README0000644000175000017500000000161412576461726016764 0ustar pgquilespgquiles This directory contains the ACE network service implementations and sample driver programs for dynamically configuring them into client and server processes. The subdirectories include the following: . lib -- contains implementations of the ACE network services. These services include a logging service, a name service, a distributed locking service, and a distributed time service. These can be built as shared libraries (i.e., DLLs), which are then linked into applications either statically or dynamically. . servers -- contains the driver program that links the various services together, either statically or dynamically, to form complete server programs. . clients -- contains a number of test programs that illustrate how to write clients for the various ACE network services. Please see the ACE-netsvcs.html file for an overview of the various services. ace-6.3.3+dfsg.orig/netsvcs/ACE-netsvcs.html0000644000175000017500000007342512576461726021056 0ustar pgquilespgquiles Overview of the ACE Network Services

Overview of the ACE Network Services

ACE provides a standard library of network services:

These services play two roles in ACE:

The heart of the ACE network services is the Service Configurator, which is an object-oriented framework that automates the configuration and reconfiguration of multi-service daemons. All the ACE network services are configured using the Service Configurator. Please refer to the online documentation for more information on installing and testing the ACE network services.


Overview of Naming Service

A Naming Service associates names with values in a distributed system. Clients can query these values using these names as keys. Such a name-to-value association is called a Name Binding . Name bindings are defined relative to a Naming Context . A naming context is a collection that contains a set of name bindings in which each name is unique. Different names can be bound to the same value in the same or different naming contexts at the same time. There are three types of naming contexts:

  1. Process Local Naming Context: Name bindings are accessible from processes with the same name running on the same host.

  2. Node Local Naming Context: Name bindings are accessible from all processes running on the same host.

  3. Network Local Naming Context: Name bindings are accessible from all processes running on any machine within a (sub)network.

To bind a name is to create a name binding in a given context. Querying a value using a name determines the value associated with the name in a given context. Note that a name is always bound relative to a context. Thus, there are no absolute names.

The following are the key classes in the ACE Naming Service:

  • Class Naming_Context

    This is the main class ``entry point'' into the Naming Service. It is used both by client processes and by server process. It manages access to the appropriate Name/Binding database (that is the file where Name/Bindings are stored) and it also manages the communication between a client process and the server (by using class Name_Proxy, which is a private member of Naming_Context). If a client process runs on the same host as the server no IPC is necessary because the Naming_Context uses shared memory.

  • Class Name_Acceptor

    The Name_Acceptor allocates in its handle_input() routine a new instance of class Name_Handler on the heap, and accepts connections into this Name_Handler.

  • Class Name_Handler

    The class Name_Handler represents the server side of communication between client and server. It interprets incoming requests to the Net_Local namespace and delegates the requests to its own Naming_Context (which is the Net_Local namespace on the current host). For communication it uses the helper classes Name_Request and Name_Reply.

  • Dependencies

    The ACE Naming Service uses ACE_WString String classes since it must handle wide character strings in order to support internationalization.

The following describes how to configure the Name_Server server and client test applications.

  • Startup configuration

    Configuring a Name_Server server or client requires specifying all or some of the following parameters. These parameters can be passed in to main through command line as follows:

    Option Description Default value
    -c <naming context>
    Naming Context to use. Can be either "PROC_LOCAL" or "NODE_LOCAL" or "NET_LOCAL"
    PROC_LOCAL
    -h <hostname> Specify the server hostname (needed by Name Server clients for PROC_LOCAL naming context) ACE_DEFAULT_SERVER_HOST
    -p <nameserver port>
    Port number where the server process expects requests
    ACE_DEFAULT_SERVER_PORT
    -l <namespace dir>
    Directory that holds the NameBinding databases
    ACE_DEFAULT_NAMESPACE_DIR
    -P <process name>
    Name of the client process argv[0]
    -s <database name>
    Name of the database. NameBindings for the appropriate naming context are stored in file <namespace_dir>/<database name>. null
    -d <debug> Turn debugging on/off 0 (off)
    -T <trace> Turn tracing on/off 0 (off)
    -v <verbose> Turn verbose on/off 0 (off)

  • Examples

    1. Here is what a config file would look like for starting up a server at port 20222 using NET_LOCAL naming context with database called MYDATABSE located in directory /tmp:
       
      dynamic Naming_Service Service_Object * 
        ../lib/netsvcs:_make_ACE_Name_Acceptor() 
        "-p 20222 -c NET_LOCAL -l /tmp -s MYDATABASE"
      
    2. Here is what a config file would look like for starting up a client that connects to a Name Server running on host tango.cs.wustl.edu at port 20222:
       
      dynamic Naming_Service_Client Service_Object * 
        ../lib/netsvcs:_make_Client_Test() 
        "-h tango.cs.wustl.edu -p 20222"
      
    Note:

    • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

    • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Overview of Time Service

Time Service provides accurate, fault-tolerant clock synchronization for computers collaborating in local area networks and wide area networks. Synchronized time services are important in distributed systems that require multiple hosts to maintain accurate global time. The architecture of the distributed time service contains the following Time Server, Clerk, and Client components:

  • Time Server answers queries about the time made by Clerks.

  • Clerk queries one or more Time Servers to determine the correct time, calculates the approximate correct time using one of several distributed time algorithms and updates its own local system time.

  • Client uses the global time information maintained by a Clerk to provide consistency with the notion of time used by clients on other hosts.

The following are the key classes in the ACE Time Service:

  • Class TS_Server_Handler

    TS_Server_Handler represents the server side of communication between clerk and server. It interprets incoming requests for time updates, gets the system time, creates a reply in response to the request and then sends the reply to the clerk from which it received the request. For communication it uses the helper class Time_Request.

  • Class TS_Server_Acceptor

    TS_Server_Acceptor allocates in its handle_input routine a new instance of class TS_Server_Handler on the heap, and accepts connections into this TS_Server_Handler.

  • Class TS_Clerk_Handler

    TS_Clerk_Handler represents the clerk side of communication between clerk and server. It generates requests for time updates every timeout period and then sends these requests to all the servers it is connected to asynchronously. It receives the replies to these requests from the servers through its handle_input method and then adjusts the time using the roundtrip estimate. It caches this time, which is subsequently retrieved by TS_Clerk_Processor.

  • Class TS_Clerk_Processor

    TS_Clerk_Processor creates a new instance of TS_Clerk_Handler for every server connection it needs to create. It periodically calls send_request() of every TS_Clerk_Handler to send a request for time update to all the servers. In the process, it retrieves the latest time cached by each TS_Clerk_Handler and then uses it to compute its notion of the local system time.

  • Algorithms

    Currently, updating the system time involves taking the average of all the times received from the servers.

The following is a description of how to configure the Time Server clerk and server services:

  • Startup configuration

    Configuring a server requires specifying the port number of the server. This can be specified as a command line argument as follows:

    -p <port number>

    A clerk communicates with one or more server processes. To communicate with the server process, a client needs to know the INET_Addr, where the server offers its service. The configuration parameters namely the server port and server host are passed as command line arguments when starting up the clerk service as follows:

    -h <server host1>:<server port1> -h <server host2>:<server port2> ...

    Note that multiple servers can be specified in this manner for the clerk to connect to when it starts up. The server name and the port number need to be concatenated and separated by a ":". In addition, the timeout value can also be specified as a command line argument as follows:

    -t timeout

    The timeout value specifies the time interval at which the clerk should query the servers for time updates.

    By default a Clerk does a non-blocking connect to a server. This can be overridden and a Clerk can be made to do a blocking connect by using the -b flag.

  • Examples

    1. Here is what a config file would look like for starting up a server at port 20202:
       
      dynamic Time_Service Service_Object * 
        ../lib/netsvcs:_make_ACE_TS_Server_Acceptor() 
        "-p 20202"
      
    2. Here is what a config file would look like for starting up a clerk that needs to connect to two servers, one at tango and one at lambada:
       
      dynamic Time_Server_test Service_Object *
        ../lib/netsvcs:_make_ACE_TS_Clerk_Connector () 
        "-h tango:20202 -h lambada:20202 -t 4"
      
    Note:

    • These files would vary if the services are run on NT. For example, instead of using *.so, we would have to use *.dll.

    • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

    • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Token Service

The ACE Token Service provides local and remote mutexes and readers/writer locks. For information regarding the deadlock detection algorithm, check out ACE_Token_Manager.h. For information about an implementation of the Composite Pattern for Tokens, check out Token_Collection.h. The classes which implement the local and remote synchronization primitives are listed below:

  • ACE_Local_Mutex

    This class is a more general-purpose synchronization mechanism than SunOS 5.x mutexes. For example, it implements "recursive mutex" semantics, where a thread that owns the token can reacquire it without deadlocking. In addition, threads that are blocked awaiting the token are serviced in strict FIFO order as other threads release the token (SunOS 5.x mutexes don't strictly enforce an acquisition order). Lastly, ACE_Local_Mutex performs deadlock detection on acquire calls.

  • ACE_Remote_Mutex

    This is the remote equivalent to ACE_Local_Mutex. The Remote_Mutex class offers methods for acquiring, renewing, and releasing a distributed synchronization mutex. Similar to ACE_Local_Mutex, ACE_Remote_Token_Proxy offers recursive acquisition, FIFO waiter ordering, and deadlock detection. It depends on the Token Server for its distributed synchronization semantics.

  • ACE_Local_RLock

    This class implements the reader interface to canonical readers/writer locks. Multiple readers can hold the lock simultaneously when no writers have the lock. Alternatively, when a writer holds the lock, no other participants (readers or writers) may hold the lock. This class is a more general-purpose synchronization mechanism than SunOS 5.x RLocks. For example, it implements "recursive RLock" semantics, where a thread that owns the token can reacquire it without deadlocking. In addition, threads that are blocked awaiting the token are serviced in strict FIFO order as other threads release the token (SunOS 5.x RLockes don't strictly enforce an acquisition order).

  • ACE_Local_WLock

    This class implements the writer interface to canonical readers/writer locks. Multiple readers can hold the lock simultaneously when no writers have the lock. Alternatively, when a writer holds the lock, no other participants (readers or writers) may hold the lock. This class is a more general-purpose synchronization mechanism than SunOS 5.x WLock. For example, it implements "recursive WLock" semantics, where a thread that owns the token can reacquire it without deadlocking. In addition, threads that are blocked awaiting the token are serviced in strict FIFO order as other threads release the token (SunOS 5.x WLocks don't strictly enforce an acquisition order).

  • ACE_Remote_RLock

    This is the remote equivalent to ACE_Local_RLock. Multiple readers can hold the lock simultaneously when no writers have the lock. Alternatively, when a writer holds the lock, no other participants (readers or writers) may hold the lock. ACE_Remote_RLock depends on the ACE Token Server for its distributed synchronization semantics.

  • ACE_Remote_RLock

    This is the remote equivalent to ACE_Local_WLock.

The Token Server provides distributed mutex and readers/writer lock semantics to the ACE Token library. ACE_Remote_Mutex, ACE_Remote_RLock, and ACE_Remote_WLock, are proxies to the Token Server. The following are the key classes in the ACE Token Server:

  • class Token_Acceptor

    The Token_Acceptor is a Token_Handler factory. It accepts connections and passes the service responsibilities off to a new Token_Handler.

  • class Token_Handler

    This class is the main class ``entry point'' of the ACE Token service. It receives token operation requests from remote clients and turns them into calls on local tokens (acquire, release, renew, and remove). In OMG CORBA terminology, it is an ``Object Adapter.'' It also schedules and handles timeouts that are used to support "timed waits." Clients used timed waits to bound the amount of time they block trying to get a token.

The following describes how to configure the Token Server:

  • Startup configuration

    The only parameter that the Token Server takes is a listen port number. You can specify a port number by passing a "-p " to the application. This can be done via the svc.conf file.

  • Examples

    Here is an example svc.conf entry that dynamically loads the Token Server specifying port number to listen on for client connections:

            dynamic Token_Service Service_Object * 
              ../lib/netsvcs:_make_ACE_Token_Acceptor() 
              "-p 10202"
           

Note:

  • These files would vary if the services are run on NT. For example, instead of using *.so, we would have to use *.dll.

  • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

  • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Overview of Server Logging Service

The Server Logging Service provides a concurrent, multi-service daemon that processes logging records received from one or more client hosts simultaneously. The object-oriented design of the Server Logging Service is decomposed into several modular components that perform well-defined tasks.

The following are the key classes in the Server Logging Service:

  • Server_Logging_Handler

    The Server_Logging_Handler class is a parameterized type that is responsible for processing logging records sent to the Server from participating client hosts. When logging records arrive from the client host associated with a particular Logging Handler object, the handle_input() method of the Server_Logging_Handler class is called which in turn formats and displays the records on one or more output devices (such as the printer, persistent storage, and/or console devices.

  • Server_Logging_Acceptor

    The class Server_Logging_Acceptor allocates in its handle_input() routine a new instance of class Server_Logging_Handler on the heap, and accepts connections into this Server_Logging_Handler.

The following describes how to configure the Logging Server:

  • Startup configuration

    The only parameter that the Logging Server takes is a listen port number. You can specify a port number by passing a "-p " to the application. This can be done via the svc.conf file.

  • Examples

    Here is an example svc.conf entry that dynamically loads the Logging Server specifying port number to listen on for client connections:

     
          dynamic Server_Logging_Service Service_Object * 
            ../lib/netsvcs:_make_ACE_Server_Logging_Acceptor() 
            "-p 10202"
          

Note:

  • These files would vary if the services are run on NT. For example, instead of using *.so, we would have to use *.dll.

  • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

  • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Overview of Client Logging Service

The Client Logging Service multiplexes messages received from different applications to the Server Logging Daemon running on a designated host in a network/internetwork. The following are the key classes in the Client Logging Service:

  • Client_Logging_Handler

    The Client_Logging_Handler class is a parameterized type that is responsible for setting up a named pipe and using it to communicate with different user processes on the same host. Once logging records arrive from these processes, the handler reads these records in priority order, performs network-byte order conversions on multiple-header fields, and then transmits these records to the Server Logging daemon across the network.

  • Client_Logging_Connector

    The class Client_Logging_Connector connects to the Server Logging daemon and then in its handle_input() routine it allocates a new instance of the Client_Logging_Handler on the heap.

The following describes how to configure the Logging Client:

  • Startup configuration

    Configuring a Logging Client requires specifying all or some of the following parameters. These parameters can be passed in to main through command line as follows:

    Option Description Default value
    -h <hostname>
    Hostname of the Server Logging Daemon
    ACE_DEFAULT_SERVER_HOST
    -p <port number> Port number of the Server Logging Daemon
    ACE_DEFAULT_LOGGING_SERVER_PORT
    -p <rendezvous key> Rendezvous key used to create named pipe ACE_DEFAULT_RENDEZVOUS

  • Examples

    Here is an example svc.conf entry that dynamically loads the Logging Client specifying host name and port number of the Logging Server:

     
          dynamic Client_Logging_Service Service_Object * 
            ../lib/netsvcs:_make_ACE_Client_Logging_Connector() 
            "-h tango.cs.wustl.edu -p 10202"
          

Note:

  • These files would vary if the services are run on NT. For example, instead of using *.so, we would have to use *.dll.

  • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

  • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Overview of Logging Strategy Service

The Logging Strategy Service can be used to control the output of all the network services. It can be invoked with certain flags that determine where the output of all the services should go. The Logging Strategy Service sets the flags in ACE_Log_Msg, which controls all the streams through macros such as ACE_DEBUG, ACE_ERROR, and ACE_ERROR_RETURN. If default behavior is required, the Logging Strategy Service need not be invoked or it can be invoked with no parameters.

The following describes how to configure the Logging Strategy Service:

  • Startup configuration

    Here are the command line arguments that can be given to the Logging Strategy Service:

    -f <flag1>|<flag2>|<flag3> (etc...)

    where a flag can be any of the following:

    Flags Description
    STDERR
    Write messages to stderr.
    LOGGER
    Write messages to the local client logger deamon.
    OSTREAM
    Write messages to the ostream that gets created by specifying a filename (see below)
    VERBOSE
    Display messages in a verbose manner
    SILENT
    Do not print messages at all

    Note: If more than one flag is specified, the flags need to be 'OR'ed as above syntax shows. Make sure there is no space in between the flag and '|'.

    -s filename

    If the OSTREAM flag is set, this can be used to specify the filename where the output should be directed. Note that if the OSTREAM flag is set and no filename is specified, ACE_DEFAULT_LOGFILE will be used to write the output to.

  • Examples:

    Here is an example svc.conf entry that dynamically loads the Logging Strategy Service specifying that the output be sent to STDERR:

     
          dynamic Logging_Strategy_Service Service_Object * 
            ../lib/netsvcs:_make_ACE_Logging_Strategy() 
            "-f STDERR"
          

    1. To direct output only to STDERR, specify command line arguments as:

      "-f STDERR"

    2. To direct output to both STDERR and a file called "mylog", specify command line arguments as:

      "-f STDERR|OSTREAM -s mylog"

    Note:

    • These files would vary if the services are run on NT. For example, instead of using *.so, we would have to use *.dll.

    • Values for parameters can also be passed in using environment variables. For example, instead of specifying absolute hostname or port numbers in the config file, we can use $HOST and $PORT, respectively, in the file (assuming that these environment variables have been set).

    • If the environment variable LD_LIBRARY_PATH (in the case of UNIX) or PATH (in the case of Win32) contains the path to the shared object files or dll, then the config file can be further simplified. Instead of specifying a path to the shared object or dll, only the name of the shared object or dll would suffice. That is, the Service Configurator makes use of LD_LIBRARY_PATH (on UNIX) or PATH (on Win32) to look for the shared object files or dlls.


Back to the ACE home page. ace-6.3.3+dfsg.orig/netsvcs/clients/0000775000175000017500000000000012576472436017545 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/README0000644000175000017500000000052212576461726020422 0ustar pgquilespgquiles This directory contains a number of test programs that illustrate how to write clients for the various ACE network services. . Logger -- client programs that illustrate the ACE logging service. . Naming -- client programs that illustrate the ACE name service. . Tokens -- client programs that illustrate the ACE token service. ace-6.3.3+dfsg.orig/netsvcs/clients/Logger/0000775000175000017500000000000012576472436020764 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Logger/indirect_logging.cpp0000644000175000017500000000361412576461726025001 0ustar pgquilespgquiles// This is a simple test that sends logging records to the Client // Logging Daemon running on the localhost. This daemon then forwards // them to the Server Logging Daemon. If there is no Server Logging // Daemon, the logging records will be written to stderr. #include "ace/OS_NS_time.h" #include "ace/OS_NS_stdlib.h" #include "ace/Log_Msg.h" #include "ace/Log_Record.h" int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { const ACE_TCHAR *prog_name = argv[0]; int iterations = argc < 2 ? 10 : ACE_OS::atoi (argv[1]); const ACE_TCHAR *logger_key = argc < 3 ? ACE_DEFAULT_LOGGER_KEY : argv[2]; int verbose = argc < 4 ? 0 : ACE_Log_Msg::VERBOSE; ACE_OS::srand ((u_int) ACE_OS::time (0)); if (ACE_LOG_MSG->open (prog_name, ACE_Log_Msg::LOGGER, logger_key) == -1) { ACE_ERROR ((LM_ERROR, "Cannot open logger, using STDERR\n")); if (ACE_LOG_MSG->open (prog_name, ACE_Log_Msg::STDERR | verbose) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open logger\n"), -1); } ACE_DEBUG ((LM_STARTUP, "starting up the test\n")); for (int i = 0; i < iterations; i++) { size_t priority = ACE_OS::rand () % int (LM_MAX); ACE_POW (priority); ACE_Log_Priority log_priority = ACE_Log_Priority (priority); ACE_DEBUG ((log_priority, "random message %s (%d)...\n", ACE_Log_Record::priority_name (log_priority), priority)); } ACE_DEBUG ((LM_SHUTDOWN, "closing down the test\n")); #if defined (ACE_WIN32) // !!Important, Winsock is broken in that if you don't close // down the connection before exiting main, you'll lose data. // More over, your server might get "Access Violation" from // within Winsock functions. // Here we close down the connection to Logger by redirecting // the logging destination back to stderr. ACE_LOG_MSG->open (0, ACE_Log_Msg::STDERR, 0); #endif /* ACE_WIN32 */ return 0; } ace-6.3.3+dfsg.orig/netsvcs/clients/Logger/README0000644000175000017500000000117212576461726021643 0ustar pgquilespgquiles This directory contains two sample logging applications that implement and test the ACE distributed logging service. . indirect_logging.cpp This program talks to the ACE Client Logging Daemon on the localhost, which forwards the messages to Server Logging Daemon. The Client Logging Daemon and Server Logging Daemon both must be started before you can run this test. . direct_logging.cpp This program talks directly to the Server Logging Daemon. The Server Logging Daemon must be started before you can run this test. To start these daemons, please check out the ../../servers/ directory. ace-6.3.3+dfsg.orig/netsvcs/clients/Logger/direct_logging.cpp0000644000175000017500000000517212576461726024453 0ustar pgquilespgquiles// This program sends logging records directly to the server, rather // than going through the client logging daemon. #include "ace/SOCK_Connector.h" #include "ace/Log_Record.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_time.h" #include "ace/OS_NS_stdlib.h" #include "ace/OS_NS_unistd.h" #include "ace/CDR_Stream.h" static u_short LOGGER_PORT = ACE_DEFAULT_SERVER_PORT; static const ACE_TCHAR *const LOGGER_HOST = ACE_DEFAULT_SERVER_HOST; static const ACE_TCHAR *const DATA = ACE_TEXT ("hello world\n"); int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { u_short logger_port = argc > 1 ? ACE_OS::atoi (argv[1]) : LOGGER_PORT; const ACE_TCHAR *logger_host = argc > 2 ? argv[2] : LOGGER_HOST; ACE_SOCK_Stream logger; ACE_SOCK_Connector connector; ACE_INET_Addr addr (logger_port, logger_host); ACE_Log_Record log_record (LM_DEBUG, ACE_OS::time ((time_t *) 0), ACE_OS::getpid ()); if (connector.connect (logger, addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); log_record.msg_data (DATA); const size_t max_payload_size = 4 // type() + 8 // timestamp + 4 // process id + 4 // data length + ACE_Log_Record::MAXLOGMSGLEN // data + ACE_CDR::MAX_ALIGNMENT; // padding; // Insert contents of into payload stream. ACE_OutputCDR payload (max_payload_size); payload << log_record; // Get the number of bytes used by the CDR stream. ACE_CDR::ULong length = payload.total_length (); // Send a header so the receiver can determine the byte order and // size of the incoming CDR stream. ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8); header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER); // Store the size of the payload that follows header << ACE_CDR::ULong (length); // Use an iovec to send both buffer and payload simultaneously. iovec iov[2]; iov[0].iov_base = header.begin ()->rd_ptr (); iov[0].iov_len = 8; iov[1].iov_base = payload.begin ()->rd_ptr (); iov[1].iov_len = length; if (logger.sendv_n (iov, 2) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); else if (logger.close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); #if defined (ACE_WIN32) // !!Important, Winsock is broken in that if you don't close // down the connection before exiting main, you'll lose data. // More over, your server might get "Access Violation" from // within Winsock functions. // Here we close down the connection to Logger by redirecting // the logging destination back to stderr. ACE_LOG_MSG->open (0, ACE_Log_Msg::STDERR, 0); #endif /* ACE_WIN32 */ return 0; } ace-6.3.3+dfsg.orig/netsvcs/clients/Logger/Logger.mpc0000644000175000017500000000056612576461726022711 0ustar pgquilespgquiles// -*- MPC -*- project(direct logging) : aceexe { avoids += ace_for_tao exename = direct_logging libs += netsvcs after += netsvcs Source_Files { direct_logging.cpp } } project(indirect logging) : aceexe { avoids += ace_for_tao exename = indirect_logging libs += netsvcs after += netsvcs Source_Files { indirect_logging.cpp } } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/0000775000175000017500000000000012576472436020756 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/0000775000175000017500000000000012576472436023366 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/main.cpp0000644000175000017500000000072312576461726025016 0ustar pgquilespgquiles// Test the client-side of the ACE Name Server... #include "ace/Service_Config.h" #include "ace/Log_Msg.h" #include "Dump_Restore.h" int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_Service_Config daemon (argv[0]); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("entering main\n"))); // Get a handler Dump_Restore client_handler (argc, argv); ACE_Reactor::run_event_loop (); /* NOTREACHED */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("leaving main\n"))); return 0; } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/README0000644000175000017500000000434412576461726024251 0ustar pgquilespgquiles This file describes the usage of the Dump-Restore utility for the ACE Name Server. Similar to the test application provided in the ../Client/ directory, a simple ASCII menu-driven interface is provided to the user: Name Service Main Menu ---------------------- *** Using Process Local Database *** ** No Input File Specified **

Use Process Local Database Use Node Local Database Set Remote Name server and Set Input File Bind Unbind Rebind Dump or ^C (exit) Initially, the user can select the type of database from the menu:

uses the process local database (i.e., the database is called the same name as the process and stored in /tmp). uses the node local database (which defaults to /tmp/localnames). uses the net local database by specifying host and port number (by default this is stored in a file called /tmp/globalnames on the server). Sets the name of the input file that will be used by the test application to populate the database. The format of the file should be: name= value= type=[] name= value= type=[] . . . Note that the type field is optional. However, if no type information is associated with a name binding, a null entry still needs to be present (i.e., type=). Once the input file has been specified, the user can then do one of the following: Bind -- bind all the bindings in the file to the database. This can be used to "restore" the state of the Name Server. Unbind -- unbind all the bindings in the file from the database. Rebind -- rebind all the bindings in the file to the database. Dump -- dump the state of the database to . or ^C (exit) -- exit gracefully, saving the contents of the Name Server in persistent shared memory. Note that the dump file is stored in ASCII with exactly the same format as the input file. Also, one can easily change the test application so that a call to Dump results in the state of the database dumped to standard output instead of a file. ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.mpc0000644000175000017500000000024412576461726026475 0ustar pgquilespgquiles// -*- MPC -*- project(Netsvcs_Dump_Restore) : aceexe { avoids += ace_for_tao exename = dump_restore Source_Files { main.cpp Dump_Restore.cpp } } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/createfile.cpp0000644000175000017500000000121512576461726026172 0ustar pgquilespgquiles#include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ace/ACE.h" int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { FILE *infile, *outfile; char buf[BUFSIZ]; if ((infile = ACE_OS::fopen (argv[1], "r")) == 0) return -1; if ((outfile = ACE_OS::fopen (argv[2], "w")) == 0) return -1; int count = 0; while (ACE_OS::fgets (buf, BUFSIZ, infile)) { buf[ACE_OS::strlen(buf) - 1] = '\0'; ACE_OS::fputs (buf, outfile); if (count % 2 == 0) ACE_OS::fputs (" ", outfile); else ACE_OS::fputs ("\n", outfile); count++; } ACE_OS::fclose (outfile); ACE_OS::fclose (infile); } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp0000644000175000017500000003021312576461726026477 0ustar pgquilespgquiles#include "ace/Malloc_Base.h" #include "ace/Read_Buffer.h" #include "ace/Thread_Manager.h" // FUZZ: disable check_for_streams_include #include "ace/streams.h" /* Because dump () uses ofstream. */ #include "Dump_Restore.h" #include "ace/OS_NS_signal.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" Dump_Restore::Dump_Restore (int argc, ACE_TCHAR *argv[]) : infile_ (0) { ACE_NEW (this->ns_context_, ACE_Naming_Context); // Cache the name options this->name_options_ = this->ns_context_->name_options (); this->name_options_->parse_args (argc, argv); //determine name context if (ACE_OS::strcmp (this->name_options_->nameserver_host (), ACE_TEXT ("localhost")) == 0) { if (ns_context_->open (ACE_Naming_Context::PROC_LOCAL) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->open"))); } else { // Don't really need to do this but it's a hack to fix the // problme of Display () not printing the right hostname ACE_OS::strcpy (this->hostname_, this->name_options_->nameserver_host ()); this->port_ = this->name_options_->nameserver_port (); if (this->ns_context_->open (ACE_Naming_Context::NET_LOCAL) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->open"))); } this->display_menu (); if (ACE_Event_Handler::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register_stdin_handler"))); } Dump_Restore::~Dump_Restore (void) { // Deregister this handler with the ACE_Reactor. ACE_Reactor::instance ()->remove_handler (ACE_STDIN, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK); ACE_OS::fclose (this->infile_); } int Dump_Restore::handle_input (ACE_HANDLE) { char option[BUFSIZ]; char buf1[BUFSIZ]; u_short port; if (::scanf ("%s", option) <= 0) { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("try again\n"))); return 0; } switch (option[0]) { case 'P' : case 'p' : set_proc_local (); break; case 'N' : case 'n' : set_node_local (); break; case 'H' : case 'h' : if (::scanf ("%s %hu", buf1, &port) <= 0) break; set_host (ACE_TEXT_CHAR_TO_TCHAR (buf1), port); break; case 'F': case 'f': if (::scanf ("%s", filename_) <= 0) break; if (this->infile_) ACE_OS::fclose (this->infile_); this->infile_ = ACE_OS::fopen(filename_, ACE_TEXT("r")); break; case 'B' : case 'b' : populate (Dump_Restore::BIND); break; case 'U' : case 'u' : populate (Dump_Restore::UNBIND); break; case 'R' : case 'r' : populate (Dump_Restore::REBIND); break; case 'D': case 'd': if (::scanf ("%s", dump_filename_) <= 0) break; this->dump (); break; case 'Q' : case 'q' : quit (); break; default : ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Unrecognized command.\n"))); } display_menu (); return 0; } void Dump_Restore::display_menu (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Name Service Main Menu\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("----------------------\n"))); // Check if using local name space or remote name space if (ACE_OS::strcmp (this->name_options_->nameserver_host (), ACE_TEXT ("localhost")) == 0) { if (this->ns_scope_ == ACE_Naming_Context::PROC_LOCAL) ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" *** Using Process Local Database ***\n\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" *** Using Node Local Database ***\n\n"))); } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Hostname: %s\n"), this->hostname_)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Port Number: %d\n"), this->port_)); } if (this->infile_) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Input File: %C\n"), this->filename_)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("** No Input File Specified **\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("

Use Process Local Database\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Use Node Local Database\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Set Remote Name server and \n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Set Input File \n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Bind\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Unbind\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Rebind\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Dump \n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" or ^C (exit)\n"))); } int Dump_Restore::set_proc_local (void) { // Set Name Options this->name_options_->nameserver_host (ACE_TEXT ("localhost")); this->name_options_->nameserver_port (0); // Set Naming Context scope this->ns_scope_ = ACE_Naming_Context::PROC_LOCAL; // Remove old naming context delete this->ns_context_; // Create new Naming Context ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1); if (this->ns_context_->open (ACE_Naming_Context::PROC_LOCAL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->open")), -1); return 0; } int Dump_Restore::set_node_local (void) { // Set Name Options this->name_options_->nameserver_host (ACE_TEXT ("localhost")); this->name_options_->nameserver_port (0); // Set Naming Context scope this->ns_scope_ = ACE_Naming_Context::NODE_LOCAL; // Remove old naming context delete this->ns_context_; // Create new Naming Context ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1); if (ns_context_->open (ACE_Naming_Context::NODE_LOCAL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->open")), -1); return 0; } int Dump_Restore::set_host (const ACE_TCHAR *hostname, int port) { // Set Name Options this->name_options_->nameserver_host (hostname); this->name_options_->nameserver_port (port); // Don't really need to do this but it's a hack to fix the problme // of Display () not printing the right hostname ACE_OS::strcpy (this->hostname_, hostname); this->port_ = port; this->ns_scope_ = ACE_Naming_Context::NET_LOCAL; // remove old naming context delete this->ns_context_; // Create new Naming Context ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1); // assume net_local context if (ns_context_->open (ACE_Naming_Context::NET_LOCAL) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->open")), -1); return 0; } int Dump_Restore::doit (Dump_Restore::Operation_Type op, const char *name, const char *value, const char *type) { int result = -1; switch (op) { case Dump_Restore::BIND: { result = this->bind (name, value, type); break; } case Dump_Restore::UNBIND: { result = this->unbind (name); break; } case Dump_Restore::REBIND: { result = this->rebind (name, value, type); break; } } return result; } int Dump_Restore::populate (Dump_Restore::Operation_Type op) { if (this->infile_) { int result = -1; enum State { NAME, VALUE, TYPE }; State state = NAME; // reset file pointer ACE_OS::rewind (this->infile_); ACE_Allocator *allocator = ACE_Allocator::instance (); ACE_Read_Buffer read_buffer (this->infile_, 0, allocator); for (char *temp; (temp = read_buffer.read ('\n')) != 0; ) { char *name = 0; const char *actual_name = 0; char *value = 0; const char *actual_value = 0; char *type = 0; const char *actual_type = 0; switch (state) { case NAME: name = temp; ACE_OS::strtok (name, "="); actual_name = ACE_OS::strtok (0, "="); state = VALUE; break; case VALUE: value = temp; ACE_OS::strtok (value, "="); actual_value = ACE_OS::strtok (0, "="); state = TYPE; break; case TYPE: type = temp; ACE_OS::strtok (type, "="); actual_type = ACE_OS::strtok (0, "="); if (actual_type) result = this->doit (op, actual_name, actual_value, actual_type); else result = this->doit (op, actual_name, actual_value); if (name) allocator->free(name); if (value) allocator->free(value); if (type) allocator->free(type); state = NAME; break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("populate")), -1); /* NOTREACHED */ } } return result; } else return -1; } int Dump_Restore::bind (const char *key, const char *value, const char *type) { int result = ns_context_->bind (key, value, type); if (result == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->bind")), -1); else if (result == 1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%s%s%s\n"), ACE_TEXT ("key <"), key, ACE_TEXT ("> already bound")), 1); return 0; } int Dump_Restore::unbind (const char *key) { int result = ns_context_->unbind (key); if (result == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->unbind")), -1); return 0; } int Dump_Restore::rebind (const char *key, const char *value, const char *type) { if (ns_context_->rebind (key, value, type) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ns_context_->rebind")), -1); return 0; } int Dump_Restore::quit (void) { return ACE_OS::kill (ACE_OS::getpid (), SIGINT); } void Dump_Restore::dump (void) { ofstream output_file (dump_filename_); ostream *orig_stream = ACE_Log_Msg::instance ()->msg_ostream (); ACE_Log_Msg::instance ()->msg_ostream (&output_file); ACE_Log_Msg::instance ()->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER ); ACE_Log_Msg::instance ()->set_flags (ACE_Log_Msg::OSTREAM); ns_context_->dump (); ACE_Log_Msg::instance ()->msg_ostream (orig_stream); ACE_Log_Msg::instance ()->clr_flags (ACE_Log_Msg::STDERR); } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h0000644000175000017500000000356712576461726026160 0ustar pgquilespgquiles// -*- C++ -*- #include "ace/Event_Handler.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Reactor.h" #include "ace/Naming_Context.h" class Dump_Restore : public ACE_Event_Handler { public: enum Operation_Type { BIND, UNBIND, REBIND }; Dump_Restore (int argc, ACE_TCHAR *argv[]); // Initialize name options and naming context ~Dump_Restore (void); virtual int handle_input (ACE_HANDLE handle); // Handle user entered commands void dump (void); private: ACE_TCHAR hostname_[MAXHOSTNAMELEN + 1]; // Cache the hostname and port number for remote case void display_menu (void); // Display user menu. int set_proc_local (void); // Set options to use PROC_LOCAL naming context. int set_node_local (void); // Set options to use NODE_LOCAL naming context. int set_host (const ACE_TCHAR *hostname, int port); // Set options to use NET_LOCAL naming context specifying host name // and port number. int quit (void); // Gracefully exit. int populate (Dump_Restore::Operation_Type op); int doit (Dump_Restore::Operation_Type op, const char *name, const char *value, const char *type = ""); int bind (const char *key, const char *value, const char *type = ""); int unbind (const char *key); int rebind (const char *key, const char *value, const char *type = ""); char filename_[MAXPATHLEN + 1]; char dump_filename_[MAXPATHLEN + 1]; u_short port_; // port server is listening on ACE_Naming_Context *ns_context_; // Current naming context ACE_Naming_Context::Context_Scope_Type ns_scope_; // Defines the scope of the naming context FILE *infile_; // input file ACE_Name_Options *name_options_; // Name Options associated with the Naming Context }; ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/0000775000175000017500000000000012576472436022174 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/Client_Test.h0000644000175000017500000000351312576461726024562 0ustar pgquilespgquiles// -*- C++ -*- #include "ace/Event_Handler.h" #include "ace/Naming_Context.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ class Client_Test : public ACE_Event_Handler { public: Client_Test (void); int open (void); // Cache reactor and then register self with reactor int close (void); // Close things down and free up resources. virtual int handle_input (ACE_HANDLE handle); // Handle user entered commands void list_options (void); // Print name options int bind (const char *key, const char *value, const char *type = ""); // Bind a key to a value int unbind (const char *key); // Unbind a name binding int rebind (const char *key, const char *value, const char *type = ""); // Rebind a name binding int find (const char *key); // Find the value associated with a key int list_names (const char *pattern); // Find all names that match pattern int list_values (const char *pattern); // Find all values that match pattern int list_types (const char *pattern); // Find all types that match pattern int list_name_entries (const char *pattern); // Find all names that match pattern int list_value_entries (const char *pattern); // Find all values that match pattern int list_type_entries (const char *pattern); // Find all types that match pattern private: ACE_Name_Options *name_options_; // Name Options associated with the Naming Context void display_menu (void); // Display user menu int set_proc_local (void); // Set options to use PROC_LOCAL naming context int set_node_local (void); // Set options to use NODE_LOCAL naming context int set_host (const char *hostname, int port); // Set options to use NET_LOCAL naming context specifying host name // and port number }; ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/main.cpp0000644000175000017500000000354412576461726023630 0ustar pgquilespgquiles// Test the client-side of the ACE Name Server... #include "ace/Service_Config.h" #include "ace/Naming_Context.h" #include "ace/ARGV.h" #include "ace/Log_Msg.h" #include "ace/Reactor.h" #include "Client_Test.h" int ACE_TMAIN (int, ACE_TCHAR *argv[]) { ACE_Service_Config daemon; ACE_ARGV new_args; // Load the existing into our new one. new_args.add (argv); // Enable loading of static services. new_args.add (ACE_TEXT ("-y")); // Enable debugging within dynamically linked services. new_args.add (ACE_TEXT ("-d")); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("argc = %d\n"), new_args.argc ())); // Print the contents of the combined . for (int i = 0; i < new_args.argc (); i++) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%d) %s\n"), i, new_args.argv ()[i])); if (daemon.open (new_args.argc (), new_args.argv ()) == -1) { if (errno != ENOENT) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), 1); else // Use static binding. { ACE_ARGV args; args.add (argv[0]); args.add (ACE_TEXT ("-p10011")); // Port number. ACE_Service_Object *so = ACE_SVC_INVOKE (ACE_Naming_Context); if (so->init (args.argc (), args.argv ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Naming_Context")), 1); } } Client_Test test_body; if (test_body.open () == -1) return 1; // Run forever, performing the configured services until we are shut // down by a SIGINT/SIGQUIT signal. ACE_Reactor::instance ()->run_reactor_event_loop (); test_body.close (); return 0; } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/Client_Test.cpp0000644000175000017500000003431512576461726025121 0ustar pgquilespgquiles#include "ace/Service_Config.h" #include "ace/Naming_Context.h" #include "ace/Dynamic_Service.h" #include "ace/Thread_Manager.h" #include "ace/Reactor.h" #include "ace/os_include/os_ctype.h" #include "ace/OS_NS_signal.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_ctype.h" #include "ace/os_include/os_assert.h" #include "Client_Test.h" // Get the instance of Name_Service using Dynamic_Service //inline Name_Service * //NAME_SERVICE (void) inline ACE_Naming_Context * NAMING_CONTEXT (void) { return ACE_Dynamic_Service::instance ("ACE_Naming_Context"); } Client_Test::Client_Test (void) { ACE_DEBUG ((LM_DEBUG, "Client_Test::Client_Test\n")); } int Client_Test::open (void) { // Cache the name options. this->name_options_ = NAMING_CONTEXT ()->name_options (); this->display_menu (); if (ACE_Event_Handler::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); return 0; } int Client_Test::close (void) { // Deregister this handler with the ACE_Reactor. return ACE_Reactor::instance ()->remove_handler (ACE_STDIN, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK); } int Client_Test::handle_input (ACE_HANDLE) { char option[BUFSIZ]; char buf1[BUFSIZ]; char buf2[BUFSIZ]; char buf3[BUFSIZ]; char *temp_buf; int port; char input[1024]; if (::scanf ("%s", option) <= 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Try again!\n", "Client_Test::handle_input"), 0); int result = -1; switch (ACE_OS::ace_isupper (option[0]) ? ACE_OS::ace_tolower (option[0]) : option[0]) { case 'p' : result = this->set_proc_local (); break; case 'n' : result = this->set_node_local (); break; case 'h' : if (::scanf ("%s %d", buf1, &port) <= 0) break; result = this->set_host (buf1, port); break; case 'b' : // get the input from stdin ACE_OS::fgets (input, sizeof input, stdin); // get the key if (0 != (temp_buf = ACE_OS::strtok (input, " "))) { ACE_OS::strcpy (buf1, temp_buf); temp_buf = ACE_OS::strtok (0, " "); // get the value if (temp_buf) { ACE_OS::strcpy (buf2, temp_buf); temp_buf = ACE_OS::strtok (0, " "); // get the type (if entered). if (temp_buf) { ACE_OS::strcpy (buf3, temp_buf); result = this->bind (buf1, buf2, buf3); } else result = this->bind (buf1, buf2); } else ACE_ERROR ((LM_ERROR, "Bind Failed! Value not entered.\n")); } else ACE_ERROR ((LM_ERROR, "Bind Failed! Key and Value not entered.\n")); break; case 'u' : if (::scanf ("%s", buf1) <= 0) break; result = this->unbind (buf1); break; case 'r' : // get the input from stdin ACE_OS::fgets (input, sizeof input, stdin); temp_buf = ACE_OS::strtok (input, " "); // get the key if (temp_buf) { ACE_OS::strcpy (buf1, temp_buf); temp_buf = ACE_OS::strtok (0, " "); // get the value if (temp_buf) { ACE_OS::strcpy (buf2, temp_buf); temp_buf = ACE_OS::strtok (0, " "); // get the type (if entered) if (temp_buf) { ACE_OS::strcpy (buf3, temp_buf); result = this->rebind (buf1, buf2, buf3); } else result = this->rebind (buf1, buf2); } else ACE_ERROR ((LM_ERROR, "Rebind Failed! Value not entered.\n")); } else ACE_ERROR ((LM_ERROR, "Reind Failed! Key and value not entered.\n")); break; case 'f' : if (::scanf ("%s", buf1) <= 0) break; result = this->find (buf1); break; case 'j' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_names (buf1); break; case 'k' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_values (buf1); break; case 'l' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_types (buf1); break; case 'c' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_name_entries (buf1); break; case 'd' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_value_entries (buf1); break; case 'e' : if (::scanf ("%s", buf1) <= 0) break; else result = this->list_type_entries (buf1); break; case 'q' : result = -1; break; default : ACE_DEBUG ((LM_DEBUG, "Unrecognized command.\n")); } if (result == -1) ACE_Reactor::instance ()->end_reactor_event_loop (); else this->display_menu (); return result; } void Client_Test::display_menu (void) { ACE_DEBUG ((LM_DEBUG, "\n")); this->list_options (); ACE_DEBUG ((LM_DEBUG, " Name Service Main Menu\n")); ACE_DEBUG ((LM_DEBUG, " ----------------------\n")); ACE_DEBUG ((LM_DEBUG, "

Use Process Local Database\n")); ACE_DEBUG ((LM_DEBUG, " Use Node Local Database\n"));; ACE_DEBUG ((LM_DEBUG, " Set Remote Name server and \n\n")); ACE_DEBUG ((LM_DEBUG, " Bind []\n")); ACE_DEBUG ((LM_DEBUG, " Unbind \n")); ACE_DEBUG ((LM_DEBUG, " Rebind []\n")); ACE_DEBUG ((LM_DEBUG, " Find \n")); ACE_DEBUG ((LM_DEBUG, " Lookup keys matching \n")); ACE_DEBUG ((LM_DEBUG, " Lookup values matching \n")); ACE_DEBUG ((LM_DEBUG, " Lookup types matching \n")); ACE_DEBUG ((LM_DEBUG, " Complete lookup keys matching \n")); ACE_DEBUG ((LM_DEBUG, " Complete lookup values matching \n")); ACE_DEBUG ((LM_DEBUG, " Complete lookup types matching \n")); ACE_DEBUG ((LM_DEBUG, " or ^C (exit)\n")); } void Client_Test::list_options (void) { switch (this->name_options_->context ()) { case ACE_Naming_Context::PROC_LOCAL: ACE_DEBUG ((LM_DEBUG, " *** Using Process Local Database\n")); break; case ACE_Naming_Context::NODE_LOCAL: ACE_DEBUG ((LM_DEBUG, " *** Using Node Local Database\n")); break; case ACE_Naming_Context::NET_LOCAL: ACE_DEBUG ((LM_DEBUG, " *** Hostname: %s\n", this->name_options_->nameserver_host ())); ACE_DEBUG ((LM_DEBUG, " *** Port Number: %d\n", this->name_options_->nameserver_port ())); break; default: ACE_ERROR ((LM_ERROR, "ERROR: shouldn't occur!\n")); break; } ACE_DEBUG ((LM_DEBUG, " *** Namespace directory is %s ***\n", this->name_options_->namespace_dir ())); } int Client_Test::set_proc_local (void) { // Close down original name space NAMING_CONTEXT ()->close (); this->name_options_->nameserver_host (ACE_TEXT ("localhost")); this->name_options_->context (ACE_Naming_Context::PROC_LOCAL); return NAMING_CONTEXT ()->open (ACE_Naming_Context::PROC_LOCAL); } int Client_Test::set_node_local (void) { // Close down original name space NAMING_CONTEXT ()->close (); this->name_options_->nameserver_host (ACE_TEXT ("localhost")); this->name_options_->context (ACE_Naming_Context::NODE_LOCAL); return NAMING_CONTEXT ()->open (ACE_Naming_Context::NODE_LOCAL); } int Client_Test::set_host (const char *hostname, int port) { // Close down original name space NAMING_CONTEXT ()->close (); this->name_options_->context (ACE_Naming_Context::NET_LOCAL); // Set Name Options this->name_options_->nameserver_host (ACE_TEXT_CHAR_TO_TCHAR (hostname)); this->name_options_->nameserver_port (port); return NAMING_CONTEXT ()->open (ACE_Naming_Context::NET_LOCAL); } int Client_Test::bind (const char *key, const char *value, const char *type) { if (NAMING_CONTEXT ()->bind (key, value, type) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Bind failed! Key %s exists\n", "Client_Test::bind", key), 0); return 0; } int Client_Test::unbind (const char *key) { if (NAMING_CONTEXT ()->unbind (key) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Unbind failed! Key %s not found\n", "Client_Test::unbind", key), 0); return 0; } int Client_Test::rebind (const char *key, const char *value, const char *type) { int result = NAMING_CONTEXT ()->rebind (key, value, type ); return result == 1 ? 0 : result; } int Client_Test::list_names (const char *pattern) { ACE_PWSTRING_SET set; if (NAMING_CONTEXT ()->list_names (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_names"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_NS_WString *name = 0; set_iterator.next (name) !=0; set_iterator.advance()) ACE_DEBUG ((LM_DEBUG, "%s\n", name->char_rep ())); } return 0; } int Client_Test::list_values (const char *pattern) { ACE_PWSTRING_SET set; if (NAMING_CONTEXT ()->list_values (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_values"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_NS_WString *value = 0; set_iterator.next (value) !=0; set_iterator.advance()) ACE_DEBUG ((LM_DEBUG, "%s\n", value->char_rep ())); } return 0; } int Client_Test::list_types (const char *pattern) { ACE_PWSTRING_SET set; if (NAMING_CONTEXT ()->list_types (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_types"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_NS_WString *type = 0; set_iterator.next (type) !=0; set_iterator.advance()) ACE_DEBUG ((LM_DEBUG, "%s\n", type->char_rep ())); } return 0; } int Client_Test::list_name_entries (const char *pattern) { ACE_BINDING_SET set; if (NAMING_CONTEXT ()->list_name_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_names"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; set_iterator.next (entry) !=0; set_iterator.advance()) { ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); if (entry->type_) ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); } } return 0; } int Client_Test::list_value_entries (const char *pattern) { ACE_BINDING_SET set; if (NAMING_CONTEXT ()->list_value_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_values"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; set_iterator.next (entry) !=0; set_iterator.advance()) { ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); if (entry->type_) ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); } } return 0; } int Client_Test::list_type_entries (const char *pattern) { ACE_BINDING_SET set; if (NAMING_CONTEXT ()->list_type_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", "Client_Test::list_types"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; set_iterator.next (entry) !=0; set_iterator.advance()) { ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); } } return 0; } int Client_Test::find (const char *key) { char *value = 0; char *type = 0; if (NAMING_CONTEXT ()->resolve (key, value, type) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Find failed! Key %s not found\n", "Client_Test::list_find", key), 0); else { ACE_DEBUG ((LM_DEBUG, "Binding for %s : value = %s\ttype = %s\n", key, value, type)); if (type) delete [] type; return 0; } } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/README0000644000175000017500000001172312576461726023056 0ustar pgquilespgquiles This directory contains a test for the ACE_Name_Server library. This test program also illustrates how to use the ACE Service_Config mechanism, which enables the client code to be dynamically linked into the process at installation-time or run-time. The client test is an application that allows the user to vary the test parameters through the following menu driven interface: Name Service Main Menu ---------------------- *** Using Process Local Database ***

Use Process Local Database Use Node Local Database Set Remote Name server and Bind [] Unbind Rebind [] Find Lookup keys matching Lookup values matching Lookup types matching Complete lookup keys matching Complete lookup values matching Complete lookup types matching or ^C (exit) Initially, the user can select the type of database -- process local, node local, or net local -- from the menu.

uses the process local database (i.e., the database is called the same name as the process and stored in /tmp). uses the node local database (which defaults to /tmp/localnames). uses the net local database by specifying host and port number (by default this is stored in a file called /tmp/globalnames on the server). The user can then create new bindings, delete existing bindings, or rebind bindings: Bind [] -- binds the key to the value and adds the binding to the database. Note that type information is optional. Unbind -- unbind a binding whose key is Rebind [] -- rebind to . Once again is optional. Find -- find the binding associated with key or ^C (exit) -- exit gracefully, saving the contents of the Name Server in persistent shared memory. In addition, the user can do pattern matching for keys, values, and types. Note that pattern matching is supported using regular expressions. Lookup keys matching -- find all keys that match Lookup values matching -- find all values that match Lookup types matching -- find all types that match Complete lookup keys matching -- find all bindings whose keys match Complete lookup values matching -- find all bindings whose values match Complete lookup types matching -- find all bindings whose types match ------------------------- Running the tests: The test program uses a DLL supported by the svc.conf file, which allows them to configure the client-side dynamically. The client test program accomplishes this by making use of a Singleton proxy object (Name_Service) to provide an interface to the client-side. The test programs rely on svc.conf to provide the necessary parameters for dynamically linking the Name Service library and then executing. In the absence of svc.conf, the test programs would use static binding. client: The client test can be started without any parameters. However, if the user wants to use the net local database, the hostname and the port number of the server containing the net local database can be given at "command line" in the svc.conf file, e.g.: dynamic ACE_Naming_Context Service_Object * libACE.so:_make_ACE_Naming_Context () "main -h tango.cs -p 7891" dynamic Name_Server_test Service_Object * .shobj/Client_Test.so:_make_Client_Test () "" The above example starts the client test application and sets up a connection to port 7891 to a Name Server running on tango.cs, which has the net local database. The Client_Test directive must come after ACE_Naming_Context since it relies on the ACE_Naming_Context having been dynamically linked. Note that you can also use environment variables in the "command line", as follows: dynamic ACE_Naming_Context Service_Object * libACE.so:_make_ACE_Naming_Context () "main -s $DB -p $PORT -h tango" dynamic Name_Server_test Service_Object * .shobj/Client_Test.so:_make_Client_Test () "" In this example, $DB and $PORT are environment variables that are automatically interpreted and substituted by ACE. In addition, note how you can give a relative name for the libACE_svcs.so and ACE will locate this for you automatically by reading your LD search path. server: The name server is needed only in the case where the net local database needs to be accessed. The server test needs to run on the machine that contains the net local database. To execute the server test, the user has to specify the port number at which the server will be listening in the svc.conf file. An implementation of a name service for ACE is available in the $ACE_ROOT/netsvcs/{lib,servers} directories. Please see the README files there for an explanation of how to run the server. ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/Client.mpc0000644000175000017500000000023712576461726024113 0ustar pgquilespgquiles// -*- MPC -*- project(Netsvcs_Client_Test) : aceexe { avoids += ace_for_tao exename = client_test Source_Files { main.cpp Client_Test.cpp } } ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/svc2.conf0000644000175000017500000000070512576461726023720 0ustar pgquilespgquiles # Note that $DB and $PORT are environment variables that are # automatically interpreted and substituted by ACE! In addition, note # how you can give a relative name for the libACE_svcs.so and ACE will # locate this for you automatically by reading your LD search path! dynamic ACE_Naming_Context Service_Object * ACE:_make_ACE_Naming_Context () "main -s $DB" dynamic ACE_Naming_Context2 Service_Object * ACE:_make_ACE_Naming_Context () "main -s $DB" ace-6.3.3+dfsg.orig/netsvcs/clients/Naming/Client/svc.conf0000644000175000017500000000040412576461726023632 0ustar pgquilespgquiles # Note that $PORT is an environment variable that is # automatically interpreted and substituted by ACE! # static ACE_Naming_Context "main -p $PORT -h tango" dynamic ACE_Naming_Context Service_Object * ACE:_make_ACE_Naming_Context () "main -p $PORT -h tango" ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/0000775000175000017500000000000012576472436021010 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/mutex/0000775000175000017500000000000012576472436022152 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/mutex/README0000644000175000017500000000114112576461726023025 0ustar pgquilespgquiles test_mutex test_mutex tests ACE_Local_Mutex and ACE_Remote_Mutex with both local and global proxies. "Local proxies" mean that each thread uses its own proxy (but same logical token.) "Global proxy" means that all threads access the same proxy (and, of course, the same logical token.) test_mutex can take the number of threads to run from the command-line. Thus, to run the test with one thread and local mutexes, type: % ./test_mutex To run the test with 10 threads and local mutexes, type: % ./test_mutex -t 10 To run the test with 10 threads and remote mutexes, type: % ./test_mutex -t 10 -r ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/mutex/test_mutex.cpp0000644000175000017500000000660112576461726025060 0ustar pgquilespgquiles //============================================================================= /** * @file test_mutex.cpp * * @author Tim Harrison */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) static ACE_Token_Proxy *mutex; static int remote_mutexes = 0; static const char *server_host = ACE_DEFAULT_SERVER_HOST; static int server_port = ACE_DEFAULT_SERVER_PORT; static int iterations = 100; static int spawn_count = 2; static void * run_test (void *) { int count = iterations; // test recursive acquisition of a global proxy while (count--) { if (mutex->acquire () == -1) { ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","test_mutex")); return (void *) -1; } // mutex->acquire (); if (mutex->renew () == -1) { ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","test_mutex")); return (void *) -1; } if (mutex->release () == -1) { ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","test_mutex")); return (void *) -1; } // mutex->release (); } return 0; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0]); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("t:uh:p:n:"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 't': spawn_count = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'h': // specify the host machine on which the server is running server_host = get_opt.opt_arg (); remote_mutexes = 1; break; case 'p': // specify the port on which the server is running server_port = ACE_OS::atoi (get_opt.opt_arg ()); remote_mutexes = 1; break; case 'n': // specify the port on which the server is running iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'u': default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-h ]\n" "[-p ]\n" "[-n ]\n" "[-t ]\n" "[-h ]\n" "[-p ]\n", 1), -1); /* NOTREACHED */ } } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_Thread_Manager thread_mgr; if (parse_args (argc, argv) == -1) return -1; if (remote_mutexes) { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); mutex = new ACE_Remote_Mutex ("Remote TOKEN", 0, 1); } else { mutex = new ACE_Local_Mutex ("Local TOKEN", 0, 1); } if (thread_mgr.spawn_n (spawn_count, ACE_THR_FUNC (run_test), 0, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn"), -1); thread_mgr.wait (); return 0; } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "you must have threads to run this test program\n"), -1); } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/collection/0000775000175000017500000000000012576472436023143 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/collection/README0000644000175000017500000000132312576461726024020 0ustar pgquilespgquiles Shows how applications can use the ACE_Token_Collection utility. This example creates three collections and spawns a thread to operate on each. The threads use the collective acquire, renew, and release features of ACE_Token_Collection. Here are the command-line parameters for collection: ./collection: [-h ] [-p ] [-n ] [-d debug] To run the collection locally with debugging info, type % ./collection -d To run the collection remotely with debugging info, first start a token server and the type: % ./collection -d -h -p The -n option is to control how often each thread iterates on the acquire, renew, release cycle. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/collection/rw_locks.cpp0000644000175000017500000001104112576461726025465 0ustar pgquilespgquiles#include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" #include "ace/Thread_Manager.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) static ACE_Token_Proxy *global_rlock; static ACE_Token_Proxy *global_wlock; static char *server_host = ACE_DEFAULT_SERVER_HOST; static int server_port = ACE_DEFAULT_SERVER_PORT; static int ignore_deadlock = 0; static int threads = 2; static int iterations = 50; static int debug = 0; static int remote = 0; static int reads = 4; static int write_sleep = 0; static void * run_thread (void *vp) { for (int x = 0; x < iterations; x++) { int y = 0; for (; y < reads; y++) { if (global_rlock->acquire () == -1) { if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected\n")); goto READ_DEADLOCK; } else return 0; } ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); } READ_DEADLOCK: for (; y > 0; y--) { if (global_rlock->release () == 0) ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); } if (global_wlock->acquire () == -1) { ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected\n")); } else { if (write_sleep) ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); if (global_wlock->release () == 0) ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); } } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); return 0; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("t:iun:drR:sp:h:"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': // specify the host machine on which the server is running server_host = get_opt.opt_arg (); break; case 'p': // specify the port on which the server is running server_port = ACE_OS::atoi (get_opt.opt_arg ()); break; case 't': threads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'R': reads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'd': debug = 1; break; case 'r': remote = 1; break; case 's': write_sleep = 1; break; case 'n': iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'i': ignore_deadlock = 1; break; case 'u': // usage: fallthrough default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-i ignore deadlock]\n" "[-n ]\n" "[-R ]\n" "[-r use remote locks]\n" "[-d debug]\n" "[-s sleep during writes]\n" "[-t \n", 1), -1); break; } } return 0; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; if (remote) { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); global_rlock = (ACE_Token_Proxy *) new ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug); } else { global_rlock = (ACE_Token_Proxy *) new ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug); } ACE_Thread_Manager mgr; if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread), (void *) 0, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); if (mgr.resume_all () == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); mgr.wait (); return 0; } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/collection/collection.cpp0000644000175000017500000001361612576461726026007 0ustar pgquilespgquiles //============================================================================= /** * @file collection.cpp * * Shows how applications can use the ACE_Token_Collection * utility. This example creates three collections and spawns a * thread to operate on each. The threads use the collective * acquire, renew, and release features of ACE_Token_Collection. * * @author Tim Harrison */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Token_Collection.h" #include "ace/Remote_Tokens.h" #include "ace/Thread_Manager.h" #include "ace/Service_Config.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) static const char *server_host = ACE_DEFAULT_SERVER_HOST; static int server_port = ACE_DEFAULT_SERVER_PORT; // unused: static int threads = 2; static int iterations = 50; static int debug = 0; static int remote = 0; // unused: static int tokens = 5; static void * run_thread (void *vp) { ACE_Token_Proxy *collection = (ACE_Token_Proxy *) vp; int count = iterations; while (count--) { if (collection->acquire () == -1) { if (ACE_OS::last_error () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "deadlock detected in acquire")); continue; } ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","run_thread")); return (void *) -1; } ACE_DEBUG ((LM_DEBUG, "(%t) %s acquired.\n", collection->name ())); if (collection->renew () == -1) { if (ACE_OS::last_error () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "deadlock detected")); goto deadlock; } ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","run_thread")); return (void *) -1; } ACE_DEBUG ((LM_DEBUG, "(%t) %s renewed.\n", collection->name ())); deadlock: if (collection->release () == -1) { ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","run_thread")); return (void *) -1; } ACE_DEBUG ((LM_DEBUG, "(%t) %s released.\n", collection->name ())); } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); return 0; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("un:dp:h:"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': // specify the host machine on which the server is running server_host = get_opt.opt_arg (); remote = 1; break; case 'p': // specify the port on which the server is running server_port = ACE_OS::atoi (get_opt.opt_arg ()); remote = 1; break; case 'd': debug = 1; break; case 'n': iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'u': // usage: fallthrough default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-h ]\n" "[-p ]\n" "[-n ]\n" "[-d debug]\n", 1), -1); /* NOTREACHED */ } } return 0; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; ACE_Token_Proxy *A; // Mutex *A*. ACE_Token_Proxy *B; // Mutex *B*. ACE_Token_Proxy *R; // *R*eader Lock. ACE_Token_Proxy *W; // *W*riter Lock. // Depending on the command line arguments, we will create local or // remote tokens. The names of the tokens are not important as long // as they are unique. if (remote) { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); A = new ACE_Remote_Mutex ("R Mutex A", 0, debug); B = new ACE_Remote_Mutex ("R Mutex B", 0, debug); R = new ACE_Remote_RLock ("R Reader Lock", 0, debug); W = new ACE_Remote_WLock ("R Writer Lock", 0, debug); } else { A = new ACE_Local_Mutex ("L Mutex A", 0, debug); B = new ACE_Local_Mutex ("L Mutex B", 0, debug); R = new ACE_Local_RLock ("L Reader Lock", 0, debug); W = new ACE_Local_WLock ("L Writer Lock", 0, debug); } // These collections will be treated as Tokens by the threads. ACE_Token_Collection collectionAR (debug, "A and Reader"); ACE_Token_Collection collectionAW (debug, "A and Writer"); ACE_Token_Collection collectionBR (debug, "B and Reader"); // AR and BR can run concurrently. Neither AR or BR can run when AW // is running. collectionAR.insert (*A); collectionAR.insert (*R); collectionAW.insert (*A); collectionAW.insert (*W); collectionBR.insert (*B); collectionBR.insert (*R); // Spawn off three threads. ACE_Thread_Manager *mgr = ACE_Thread_Manager::instance (); if (mgr->spawn (ACE_THR_FUNC (run_thread), (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1); if (mgr->spawn (ACE_THR_FUNC (run_thread), (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1); if (mgr->spawn (ACE_THR_FUNC (run_thread), (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1); #if ! defined (ACE_HAS_PTHREADS) if (mgr->resume_all () == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); #endif // Wait for all threads to exit. mgr->wait (); return 0; } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS && ACE_HAS_TOKENS_LIBRARY */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/manual/0000775000175000017500000000000012576472436022265 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/manual/README0000644000175000017500000000433012576461726023143 0ustar pgquilespgquiles ./manual gives users a text-based interactive interface to local or remote tokens. This is extremely useful for manually testing the token server and setting up deadlock scenarios. Run it as follows % ./manual -u ./manual: [-h ] [-p ] [-i ignore deadlock] [-d debug] ./manual gives you the following prompt. This is the client id of the current operation. This is set manually by ./manual for every operation. Be careful when using multiple 's during a remote session (see BUGS below). This is the name of the token for the operation. This is the type of the token. This can be: M - Corresponds to a Mutex lock. R - Corresponds to Readers/Writer lock. W - Corresponds to Readers/Writer lock. Obviously, a single can be M or it can R and/or W. If you perform and operation like this "tid1 tokenA M A" then don't do this "tid1 tokenA R A". This doesn't make sense. This is the operation to perform on the -- proxy. These include: A - acquire. N - renew. R - release. T - tryacquire. BUGS!!!! When performing remote tests, be careful when using a single running ./manual to impersonate two 's. The Token Server client connection policy is currently, one per thread. The Token Server assumes that the same is always on the other end of a connection. If you do something like the following, you will break it: lambada:Tokens/manual> ./manual -h tango -p 20202 tid1 tokenA M A ACE_TSS_Connection new connection (1) acquired tokenA remotely. Succeeded. tid2 tokenA M A (1) acquired tokenA remotely. <------ This is remote BADness!!! Succeeded. Violated invariant. <------ Locally detected badness. Notice that the local side discovered that this was incorrect. However, the Token Server thinks it was a recursive acquisition for tid1. Keep in mind that this is not a problem with the Token library. It is just a problem with how this primitive ./manual application maps STDIN to the ACE Token API. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/manual/manual.cpp0000644000175000017500000002101512576461726024243 0ustar pgquilespgquiles //============================================================================= /** * @file manual.cpp * * Allows manual operations on local and remote tokens. * * @author Tim Harrison */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" #include "ace/Singleton.h" #include "ace/Thread_Manager.h" #include "ace/Token_Invariants.h" #include "ace/Token_Collection.h" #include "ace/Map_Manager.h" #include "ace/Service_Config.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) typedef ACE_Token_Invariant_Manager ACE_TOKEN_INVARIANTS; /** * @class STDIN_Token * * @brief STDIN Token * * Translates STDIN commands to ACE Token commands. */ class STDIN_Token : public ACE_Event_Handler { public: /// Construction. STDIN_Token (void); /// Parse command-line arguments. int parse_args (int argc, ACE_TCHAR *argv[]); //FUZZ: disable check_for_lack_ACE_OS /// Register with whatever event dispatcher is needed and run. ///FUZZ: enable check_for_lack_ACE_OS int open (int argc, char *argv[]); // = Event_Handler methods. int handle_input (ACE_HANDLE); int handle_exception (ACE_HANDLE); typedef ACE_CString TID; private: /// Display options. void display_menu (void); /// Get or make a proxy to with a client id. ACE_Token_Proxy *get_proxy (const char *tid, const char *token, char type); /// Create a proxy to with a client id. ACE_Token_Proxy *create_proxy (const char *token, char type); // = Mapping from tid to Token_Collection. /// COLLECTION maintains a mapping from tid to a collection. typedef ACE_Map_Manager COLLECTIONS; /// Allows iterations through collections_. typedef ACE_Map_Iterator COLLECTIONS_ITERATOR; /// Allows iterations through collections_. typedef ACE_Map_Entry COLLECTIONS_ENTRY; /// A collection for each . COLLECTIONS collections_; const char *server_host_; int server_port_; int ignore_deadlock_; int debug_; int remote_; }; STDIN_Token::STDIN_Token (void) : server_host_ (ACE_DEFAULT_SERVER_HOST), server_port_ (ACE_DEFAULT_SERVER_PORT), ignore_deadlock_ (0), debug_ (0), remote_ (0) { } int STDIN_Token::parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("h:p:diu"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': // specify the host machine on which the server is running server_host_ = get_opt.opt_arg (); remote_ = 1; break; case 'p': // specify the port on which the server is running server_port_ = ACE_OS::atoi (get_opt.opt_arg ()); remote_ = 1; break; case 'd': debug_ = 1; break; case 'i': ignore_deadlock_ = 1; break; case 'u': // usage: fallthrough default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-h ]\n" "[-p ]\n" "[-i ignore deadlock]\n" "[-d debug]\n", 1), -1); } } if (remote_) ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port_, server_host_)); return 0; } int STDIN_Token::open (int argc, char *argv[]) { if (this->parse_args (argc, argv) == -1) return -1; // Register for signals. if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) ACE_DEBUG ((LM_DEBUG, "Can't register signal handler\n")); #if defined (ACE_WIN32) #else // Register for STDIN events with Reactor. if (ACE_Reactor::instance ()->register_handler (ACE_STDIN, this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "Can't register signal handler\n"), 0); #endif /* ACE_WIN32 */ this->display_menu (); #if defined (ACE_WIN32) #else ACE_Reactor::run_event_loop (); #endif /* ACE_WIN32 */ ACE_OS::printf ("Exiting...\n"); return 0; } int STDIN_Token::handle_input (ACE_HANDLE fd) { ACE_UNUSED_ARG (fd); char tid[BUFSIZ]; char token[BUFSIZ]; char type[16]; char operation[16]; if (::scanf ("%s %s %s %s", tid, token, type, operation) <= 0) { ACE_OS::printf ("Try again.\n"); return 0; } ACE_Token_Proxy *proxy = this->get_proxy (tid, token, type[0]); if (proxy == 0) return -1; switch (operation[0]) { case 'a': case 'A': if (proxy->acquire () == 0) { ACE_OS::printf ("Succeeded.\n"); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0) ACE_OS::printf ("Violated invariant.\n"); } else ACE_ERROR ((LM_ERROR, "%p.\n", "Acquire failed")); break; case 'n': case 'N': ACE_TOKEN_INVARIANTS::instance ()->releasing (proxy); if (proxy->renew () == 0) { ACE_OS::printf ("Succeeded.\n"); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0) ACE_OS::printf ("Violated invariant.\n"); } else ACE_ERROR ((LM_ERROR, "%p.\n", "Renew failed")); break; case 'r': case 'R': ACE_TOKEN_INVARIANTS::instance ()->releasing (proxy); if (proxy->release () == 0) ACE_OS::printf ("Succeeded.\n"); else ACE_ERROR ((LM_ERROR, "%p.\n", "Release failed")); break; case 't': case 'T': if (proxy->tryacquire () == 0) { ACE_OS::printf ("Succeeded.\n"); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0) ACE_OS::printf ("Violated invariant.\n"); } else ACE_ERROR ((LM_ERROR, "%p.\n", "Tryacquire failed")); break; } this->display_menu (); return 0; } void STDIN_Token::display_menu (void) { ACE_OS::printf (" \n"); } int STDIN_Token::handle_exception (ACE_HANDLE fd) { ACE_UNUSED_ARG (fd); ACE_Reactor::run_event_loop (); return -1; } ACE_Token_Proxy * STDIN_Token::get_proxy (const char *_tid, const char *token, char type) { ACE_Token_Collection *proxy_collection; TID tid (_tid); if (collections_.find (tid, proxy_collection) == -1) // We did not find a proxy_collection. { // Make one. proxy_collection = new ACE_Token_Collection (debug_, "no name collection"); // Put it in the collections. if (collections_.bind (tid, proxy_collection) == -1) { delete proxy_collection; return 0; } } // Either way, we have a proxy_collection now. // See if the proxy already exists in the collection. ACE_Token_Proxy *proxy = proxy_collection->is_member (token); // If not, create one. if (proxy == 0) { proxy = this->create_proxy (token, type); // Put the new_proxy in this tid's collection. if (proxy_collection->insert (*proxy) == -1) ACE_ERROR_RETURN ((LM_ERROR, "insert failed\n"), 0); // Delete our copy (one was created in the collection). delete proxy; proxy = proxy_collection->is_member (token); if (proxy == 0) ACE_ERROR_RETURN ((LM_ERROR, "is_member failed\n"), 0); // Set the client_id (it was set to 1 since we're // single-threaded. proxy->client_id (_tid); } return proxy; } ACE_Token_Proxy * STDIN_Token::create_proxy (const char *token, char type) { switch (type) { case 'm': case 'M': if (remote_) return new ACE_Remote_Mutex (token, ignore_deadlock_, debug_); else return new ACE_Local_Mutex (token, ignore_deadlock_, debug_); case 'r': case 'R': if (remote_) return new ACE_Remote_RLock (token, ignore_deadlock_, debug_); else return new ACE_Local_RLock (token, ignore_deadlock_, debug_); case 'w': case 'W': if (remote_) return new ACE_Remote_WLock (token, ignore_deadlock_, debug_); else return new ACE_Local_WLock (token, ignore_deadlock_, debug_); } // should never get here, but this avoids a compiler warning . . . return 0; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { STDIN_Token st; return st.open (argc, argv); } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads or ACE_HAS_TOKENS_LIBRARY not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS && ACE_HAS_TOKENS_LIBRARY */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/README0000644000175000017500000000155512576461726021674 0ustar pgquilespgquiles This directory contains a set of tests for the ACE Tokens library. . mutex Runs a few tests on ACE_Local_Mutex and ACE_Remote_Mutex. Tests recursive acquisition and global vs local proxies. . rw_locks App for testing ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_RLock, and ACE_Remote_WLock. . deadlock Tests the deadlock detection algorithm of the token manager using ACE_Local_Mutex and ACE_Remote_Mutex. . collection Tests the ACE_Token_Collection utility. Uses local and remote tokens and readers/writer locks. . invariant Tests the token Invariant testing utilities. Yes, this tests a testing utility. . manual Gives users a text-based interactive interface to local or remote tokens. This is extremely useful for manually testing the token server and setting up deadlock scenarios. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/deadlock/0000775000175000017500000000000012576472436022556 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/deadlock/README0000644000175000017500000000657412576461726023450 0ustar pgquilespgquiles deadlock_detection_test This example contains two deadlock tests, mutex and rwlock tests. % ./deadlock_detection_test -u ./deadlock_detection_test: [-r test readers/writer locks] [-n ] [-h ] [-p ] [-i ignore deadlock] For both mutex and rwlock tests, -h and -p specify to use remote mutexes. -i specifies to ignore deadlock. -n is repetitions through the respective algorithms (default 100). Both tests also use Token Invariants to ensure correctness of the mutexes and readers/writer locks. ------------------------------------------------------------ If you run ./deadlock_detection_test without -r, then the following mutex test is run. The mutex test spawns two threads which attempt to deadlock. Logically, there are two tokens A and B. Here is what both threads try to do: Thread 1 Thread 2 -------- -------- Repeat 100 times Repeat 100 times acquire A acquire B acquire B acquire A release A and B release A and B repeat repeat Notice that A and B are reversed in 1 and 2. If the token manager (which is not in the public interface, but hidden behind ACE_Local_Mutex) works properly, they should detect the deadlock. If a thread detects deadlock, the resources held are released, and it starts the whole process over again. What can be confusing about the test program is all the other tricks I'm pulling to test other aspects of the library. For instance, I'm using both "global" and "local" ACE_Local_Mutexes. This is to test the ability to have multiple threads using one token proxy as well as multiple threads each using their own proxies. All the while, the same logical token is being used. If this doesn't make sense, don't worry about it. Just use the ACE_Local_Mutex any way you want. Another confusing trick is that I'm testing recursive acquisition. (Two acquires in a row.) I have to make sure that the token manager doesn't detect a recursive acquire as deadlock. To run a test, simply type: % ./deadlock_detection_test This should run 100 times through the above pseudo code. If the application halts, then we have trouble. It should never ever halt. I've included a little flag with the ACE_Local_Mutex class to allow deadlock detection to be ignored. So, if you run the test as follows, deadlock detection will be ignored. % ./deadlock_detection_test -i In this case, the application should only run about a second before deadlock occurs and the application halts. This is good. ------------------------------------------------------------ If you run ./deadlock_detection_test *with* -r, then the following rwlock test is run: There are four tokens and four threads in the rwlock test. The readers/writer tokens are: reader first writer first 1 writer first 2 writer first 3 There are three reader threads that only acquire reader locks on the above tokens. Each of the reader threads first acquire "reader first" and then one "writer first " (where is the corresponding thread's id). So reader thread 1 acquires "reader first" and then "writer first 1". There is a single writer thread that uses the following algorithm: repeat 100 acquire "writer first 1" acquire "reader first" acquire "writer first 2" acquire "reader first" acquire "writer first 3" acquire "reader first" This strange mix of readers and writer create an interesting graph of tokens that the deadlock detection algorithm must traverse. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/deadlock/deadlock_detection_test.cpp0000644000175000017500000002254512576461726030133 0ustar pgquilespgquiles //============================================================================= /** * @file deadlock_detection_test.cpp * * @author Tim Harrison */ //============================================================================= #include "ace/Token_Manager.h" #include "ace/Remote_Tokens.h" #include "ace/Thread.h" #include "ace/Thread_Manager.h" #include "ace/Get_Opt.h" #include "ace/Token_Invariants.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) typedef ACE_Token_Invariant_Manager ACE_TOKEN_INVARIANTS; static ACE_Token_Proxy *global_mutex; struct Two_Tokens { public: Two_Tokens (ACE_Thread_Manager *tm): thr_mgr_ (tm) {} ACE_Token_Proxy *first_; ACE_Token_Proxy *second_; ACE_Thread_Manager *thr_mgr_; }; struct Four_Tokens { public: Four_Tokens (ACE_Thread_Manager *tm): thr_mgr_ (tm) {} ACE_Token_Proxy *first1_; ACE_Token_Proxy *first2_; ACE_Token_Proxy *first3_; ACE_Token_Proxy *second_; ACE_Thread_Manager *thr_mgr_; }; static int ignore_deadlock = 0; static int remote_mutexes = 0; static const char *server_host = ACE_DEFAULT_SERVER_HOST; static int server_port = ACE_DEFAULT_SERVER_PORT; static int iterations = 100; static int rwlocks = 0; static void * two_token_thread (void *vp) { Two_Tokens* tm = (Two_Tokens *) vp; for (int x = 0; x < iterations; x++) { if (tm->first_->acquire () == -1) { ACE_DEBUG ((LM_DEBUG, "Deadlock detected\n")); continue; } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (tm->first_) == 0) { tm->first_->dump (); ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); } if (tm->second_->acquire () == -1) { ACE_DEBUG ((LM_DEBUG, "Deadlock Detected\n")); goto G1; } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (tm->second_) == 0) { tm->second_->dump (); ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); } ACE_TOKEN_INVARIANTS::instance ()->releasing (tm->second_); tm->second_->release (); G1: ACE_TOKEN_INVARIANTS::instance ()->releasing (tm->first_); tm->first_->release (); } ACE_DEBUG ((LM_DEBUG, "thread %t exiting\n")); return 0; } static void * run_writer (void *vp) { Four_Tokens *ft = (Four_Tokens *) vp; int acquire_number = 0; for (int x = 0; x < iterations; x++) { // Cycle through each of the first three tokens. ACE_Token_Proxy *t = 0; switch (acquire_number) { case 0: t = ft->first1_; break; case 1: t = ft->first2_; break; case 2: t = ft->first3_; break; } acquire_number = (acquire_number + 1) % 3; if (t->acquire () == -1) { ACE_ASSERT (errno == EDEADLK); ACE_DEBUG ((LM_DEBUG, "Deadlock detected.\n")); continue; } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (t) == 0) { t->dump (); ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); } if (ft->second_->acquire () == -1) { ACE_ASSERT (errno == EDEADLK); ACE_DEBUG ((LM_DEBUG, "Deadlock Detected..\n")); goto G1; } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (ft->second_) == 0) { ft->second_->dump (); ACE_ERROR_RETURN ((LM_ERROR, "violated invariant.\n"), 0); } ACE_TOKEN_INVARIANTS::instance ()->releasing (ft->second_); ft->second_->release (); G1: ACE_TOKEN_INVARIANTS::instance ()->releasing (t); t->release (); } ACE_DEBUG ((LM_DEBUG, "thread %t exiting\n")); return 0; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0]); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("iuh:rp:n:"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'r': rwlocks = 1; break; case 'i': ignore_deadlock = 1; break; case 'h': server_host = get_opt.opt_arg (); remote_mutexes = 1; break; case 'p': server_port = ACE_OS::atoi (get_opt.opt_arg ()); remote_mutexes = 1; break; case 'n': iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'u': default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-r test readers/writer locks]\n" "[-n ]\n" "[-h ]\n" "[-p ]\n" "[-i ignore deadlock]\n%a", 1), -1); } } return 0; } int mutex_test (void) { ACE_Thread_Manager thr_mgr; Two_Tokens one (&thr_mgr); Two_Tokens two (&thr_mgr); if (remote_mutexes == 0) { global_mutex = new ACE_Local_Mutex ("global proxy", ignore_deadlock, 1); one.first_ = new ACE_Local_Mutex ("local proxy", ignore_deadlock, 1); two.second_ = new ACE_Local_Mutex ("local proxy", ignore_deadlock, 1); } else { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); global_mutex = new ACE_Remote_Mutex ("global proxy", ignore_deadlock, 1); one.first_ = new ACE_Remote_Mutex ("local proxy", ignore_deadlock, 1); two.second_ = new ACE_Remote_Mutex ("local proxy", ignore_deadlock, 1); } one.second_ = global_mutex; two.first_ = global_mutex; // Tell the token manager to be verbose when reporting deadlock. ACE_Token_Manager::instance ()->debug (1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), (void *) &one, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), (void *) &two, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "second spawn"), -1); // Wait for all threads to exit. thr_mgr.wait (); return 0; } static int rwlock_test (void) { ACE_Thread_Manager thr_mgr; Two_Tokens reader1 (&thr_mgr); Two_Tokens reader2 (&thr_mgr); Two_Tokens reader3 (&thr_mgr); Four_Tokens writer (&thr_mgr); if (remote_mutexes == 0) { reader1.first_ = new ACE_Local_RLock ("reader first", ignore_deadlock, 1); reader1.second_ = new ACE_Local_RLock ("writer first 1", ignore_deadlock, 1); reader2.first_ = new ACE_Local_RLock ("reader first", ignore_deadlock, 1); reader2.second_ = new ACE_Local_RLock ("writer first 2", ignore_deadlock, 1); reader3.first_ = new ACE_Local_RLock ("reader first", ignore_deadlock, 1); reader3.second_ = new ACE_Local_RLock ("writer first 3", ignore_deadlock, 1); writer.first1_ = new ACE_Local_WLock ("writer first 1", ignore_deadlock, 1); writer.first2_ = new ACE_Local_WLock ("writer first 2", ignore_deadlock, 1); writer.first3_ = new ACE_Local_WLock ("writer first 3", ignore_deadlock, 1); writer.second_ = new ACE_Local_WLock ("reader first", ignore_deadlock, 1); } else { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); reader1.first_ = new ACE_Remote_RLock ("writer first 1", ignore_deadlock, 1); reader1.second_ = new ACE_Remote_RLock ("reader first", ignore_deadlock, 1); reader2.first_ = new ACE_Remote_RLock ("writer first 2", ignore_deadlock, 1); reader2.second_ = new ACE_Remote_RLock ("reader first", ignore_deadlock, 1); reader3.first_ = new ACE_Remote_RLock ("writer first 3", ignore_deadlock, 1); reader3.second_ = new ACE_Remote_RLock ("reader first", ignore_deadlock, 1); writer.first1_ = new ACE_Remote_WLock ("writer first 1", ignore_deadlock, 1); writer.first2_ = new ACE_Remote_WLock ("writer first 2", ignore_deadlock, 1); writer.first3_ = new ACE_Remote_WLock ("writer first 3", ignore_deadlock, 1); writer.second_ = new ACE_Remote_WLock ("reader first", ignore_deadlock, 1); } // Tell the token manager to be verbose when reporting deadlock. ACE_Token_Manager::instance ()->debug (1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), (void *) &reader1, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), (void *) &reader2, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (two_token_thread), (void *) &reader3, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "first spawn"), -1); if (thr_mgr.spawn (ACE_THR_FUNC (run_writer), (void *) &writer, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "second spawn"), -1); // Wait for all threads to exit. thr_mgr.wait (); return 0; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; if (rwlocks) rwlock_test (); else mutex_test (); ACE_DEBUG ((LM_DEBUG, "test exiting.\n")); return 0; } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/invariant/0000775000175000017500000000000012576472436023003 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/invariant/README0000644000175000017500000000236612576461726023670 0ustar pgquilespgquiles invariants.cpp tests the ACE Token Invariant utilities. The ACE Token Invariant utilities allow an application to test the correctness of mutex and readers/writer locks. invariants.cpp takes no command-line arguments. invariants.cpp first tests readers/writer locks. This is done by spawning two threads which simulate reader and writer acquire/renew/release loops. However, the loops are performed without actual locks, so the competing threads quickly reach and invalid state. The test should report this violation of readers/writer lock invariants and both threads should exit. The second test is for mutexes. Similar to the readers/writer lock test, this test spawns two threads which perform acquire/renew/release loops. When to two threads reach an invalid mutex state, the error should be reported and the threads should exit. For these two previous tests, it is theoretically possible that the threads never reach an invalid token state. However, it is highly unlikely since the threads would have to execute the same code simultaneously for the duration of the test. Nevertheless, it is possible. The last test hardwires invalid token states. It runs two mutex and two readers/writer lock tests. It should report "succeeded" for the four tests. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/invariant/invariant.cpp0000644000175000017500000001345612576461726025511 0ustar pgquilespgquiles //============================================================================= /** * @file invariant.cpp * * @author Tim Harrison */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Singleton.h" #include "ace/Thread_Manager.h" #include "ace/Token_Invariants.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) typedef ACE_Token_Invariant_Manager ACE_TOKEN_INVARIANTS; static const char *rwname = "reader/writer"; static const char *mutexname = "mutex"; static void * run_reader_writer (void *) { for (int x = 0; x < 50; x++) { int y = 0; for (; y < 5; y++) { if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired (rwname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); } ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired (rwname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); for (; y > 0; y--) { ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); } if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired (rwname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired (rwname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing (rwname); } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); return 0; } static void * run_mutex (void *) { for (int x = 0; x < 50; x++) { if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired (mutexname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "mutex acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) mutex acquired.\n")); ACE_TOKEN_INVARIANTS::instance ()->mutex_releasing (mutexname); if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired (mutexname) == 0) ACE_ERROR_RETURN ((LM_ERROR, "mutex renew violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) mutex renewed.\n")); ACE_TOKEN_INVARIANTS::instance ()->mutex_releasing (mutexname); ACE_DEBUG ((LM_DEBUG, "(%t) mutex released.\n")); } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); return 0; } static int run_final_test (void) { ACE_DEBUG ((LM_DEBUG, "starting mutex tests 1 & 2\n")); // Mutex tests. if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired ("testing mutex") == 0) ACE_ERROR_RETURN ((LM_ERROR, "mutex test 1 failed.\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired ("testing mutex2") == 0) ACE_ERROR_RETURN ((LM_ERROR, "mutex test 2 failed.\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired ("testing mutex") == 0) ACE_DEBUG ((LM_DEBUG, "mutex test 1 succeeded.\n")); else ACE_ERROR_RETURN ((LM_ERROR, "mutex test 1 failed..\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->mutex_acquired ("testing mutex2") == 0) ACE_DEBUG ((LM_DEBUG, "mutex test 2 succeeded.\n")); else ACE_ERROR_RETURN ((LM_ERROR, "mutex test 2 failed..\n"), 0); // RW tests. ACE_DEBUG ((LM_DEBUG, "starting rwlock tests 1 & 2\n")); // Multiple readers. if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired ("testing rwlock") == 0) ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 1 failed.\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired ("testing rwlock 2") == 0) ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 2 failed.\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired ("testing rwlock") == 0) ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 1 failed..\n"), 0); if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired ("testing rwlock 2") == 0) ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 2 failed..\n"), 0); // Writer. if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired ("testing rwlock") == 0) ACE_DEBUG ((LM_ERROR, "rwlock test 1 succeded.\n")); else ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 1 failed...\n"), 0); // Releasing reader. ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing ("testing rwlock 2"); ACE_TOKEN_INVARIANTS::instance ()->rwlock_releasing ("testing rwlock 2"); // Writer. if (ACE_TOKEN_INVARIANTS::instance ()->writer_acquired ("testing rwlock 2") == 0) ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 2 failed....\n"), 0); // Reader. if (ACE_TOKEN_INVARIANTS::instance ()->reader_acquired ("testing rwlock 2") == 0) ACE_DEBUG ((LM_DEBUG, "rwlock test 2 succeeded.\n")); else ACE_ERROR_RETURN ((LM_ERROR, "rwlock test 2 failed.....\n"), 0); return 0; } int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_Thread_Manager mgr; // Run reader/writer test if (mgr.spawn_n (2, ACE_THR_FUNC (run_reader_writer), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); mgr.wait (); ACE_OS::sleep (2); // Run mutex test. if (mgr.spawn_n (2, ACE_THR_FUNC (run_mutex), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); mgr.wait (); ACE_OS::sleep (2); run_final_test (); return 0; } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/rw_lock/0000775000175000017500000000000012576472436022450 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/rw_lock/README0000644000175000017500000000157212576461726023333 0ustar pgquilespgquiles test_rw_locks shows how to use ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_RLock, and ACE_Remote_WLock. Here are the options to test_rw_locks: % ./test_rw_lock -u -i ignore deadlock -n -r -d debug -s sleep during writes -t test_rw_locks spawns number of threads which perform the following algorithm: for { for acquire read lock for release read lock acquire write lock if (sleep during writes) sleep for 1 second release write lock } The output should show that multiple readers can acquire the lock for reading simultaneously (note that this also tests recursive acquisition.) When a writer lock is acquired, the output should show that no thread holds a reader lock. To run a test, simply type: % ./test_rw_lock This should show output as described above. ace-6.3.3+dfsg.orig/netsvcs/clients/Tokens/rw_lock/rw_locks.cpp0000644000175000017500000001575412576461726025011 0ustar pgquilespgquiles //============================================================================= /** * @file rw_locks.cpp * * test_rw_locks shows how to use ACE_Local_RLock, ACE_Local_WLock, * ACE_Remote_RLock, and ACE_Remote_WLock. * * @author Tim Harrison */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Local_Tokens.h" #include "ace/Remote_Tokens.h" #include "ace/Thread_Manager.h" #include "ace/Token_Invariants.h" #if defined (ACE_HAS_THREADS) && defined (ACE_HAS_THREADS_LIBRARY) typedef ACE_Token_Invariant_Manager ACE_TOKEN_INVARIANTS; static ACE_Token_Proxy *global_rlock; static ACE_Token_Proxy *global_wlock; static const char *server_host = ACE_DEFAULT_SERVER_HOST; static int server_port = ACE_DEFAULT_SERVER_PORT; static int ignore_deadlock = 0; static int threads = 2; static int iterations = 50; static int debug = 0; static int remote = 0; static int reads = 4; static int write_sleep = 0; static int renew = 0; static void * run_thread (void *) { for (int x = 0; x < iterations; x++) { int y = 0; for (; y < reads; y++) { if (global_rlock->acquire () == -1) { if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected\n")); goto READ_DEADLOCK; } else return 0; } if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) ACE_ERROR_RETURN ((LM_ERROR, "reader acquire violated invariant.\n"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) rlock acquired.\n")); } if (renew) { ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); if (global_rlock->renew () == -1) { if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "rlock deadlock detected during renew\n")); goto READ_DEADLOCK; } else return 0; } ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_rlock) == 0) ACE_ERROR_RETURN ((LM_ERROR, "reader renew violated invariant.\n"), 0); } READ_DEADLOCK: for (; y > 0; y--) { ACE_TOKEN_INVARIANTS::instance ()->releasing (global_rlock); if (global_rlock->release () == 0) ACE_DEBUG ((LM_DEBUG, "(%t) r-released.\n")); } if (global_wlock->acquire () == -1) ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected\n")); else { if (write_sleep) ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "\t\t(%t) wlock acquired.\n")); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) ACE_ERROR_RETURN ((LM_ERROR, "writer acquire violated invariant.\n"), 0); if (renew) { ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); if (global_wlock->renew () == -1) { if (ACE_Log_Msg::instance ()->errnum () == EDEADLK) { ACE_DEBUG ((LM_DEBUG, "wlock deadlock detected during renew\n")); } else return 0; } ACE_DEBUG ((LM_DEBUG, "(%t) rlock renewed.\n")); if (ACE_TOKEN_INVARIANTS::instance ()->acquired (global_wlock) == 0) ACE_ERROR_RETURN ((LM_ERROR, "writer renew violated invariant.\n"), 0); } ACE_TOKEN_INVARIANTS::instance ()->releasing (global_wlock); if (global_wlock->release () == 0) ACE_DEBUG ((LM_DEBUG, "\t\t(%t) w-released.\n")); } } ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n")); return 0; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR); // | ACE_Log_Msg::VERBOSE); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("t:iun:dr:sp:h:R"), 1); for (int c; (c = get_opt ()) != -1; ) { switch (c) { case 'h': // specify the host machine on which the server is running server_host = get_opt.opt_arg (); remote = 1; break; case 'p': // specify the port on which the server is running server_port = ACE_OS::atoi (get_opt.opt_arg ()); remote = 1; break; case 't': threads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'R': renew = 1; break; case 'r': reads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'd': debug = 1; break; case 's': write_sleep = 1; break; case 'n': iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'i': ignore_deadlock = 1; break; case 'u': // usage: fallthrough default: ACE_ERROR_RETURN ((LM_ERROR, "%n:\n" "[-h ]\n" "[-p ]\n" "[-i ignore deadlock]\n" "[-n ]\n" "[-R perform renews]\n" "[-r ]\n" "[-d debug]\n" "[-s sleep during writes]\n" "[-t \n", 1), -1); } } return 0; } #if defined (ACE_HAS_PTHREADS) #define SUSPEND 0 #else #define SUSPEND THR_SUSPENDED #endif int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; if (remote) { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); global_rlock = (ACE_Token_Proxy *) new ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug); } else { global_rlock = (ACE_Token_Proxy *) new ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug); } ACE_Thread_Manager mgr; if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread), (void *) 0, THR_BOUND | SUSPEND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); #if ! defined (ACE_HAS_PTHREADS) if (mgr.resume_all () == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); #endif mgr.wait (); return 0; } #else int ACE_TMAIN(int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/NEWS0000644000175000017500000024373312576461726015130 0ustar pgquilespgquilesUSER VISIBLE CHANGES BETWEEN ACE-6.3.2 and ACE-6.3.3 ==================================================== . Visual Studio 2015 has adequate C++11 support, because of this ACE_HAS_CPP11 is now defined with this compiler. A large amount of warnings given by this new compiler have been fixed . As part of the release script we generate vc12 and vc14 solution files which are packaged as part of the release . Added support for VxWorks 7 (kernel mode and RTP). See the comments in include/makeinclude/platform_vxworks7.0.GNU for details. . Ended daily maintenance for OpenVMS . Fixed a defect in ACE_INET_Addr when there is a non-empty interface address list and set_port_number() is called. USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 ==================================================== . Added support for std::chrono to ACE_Time_Value. It's now possible to construct an ACE_Time_Value with a std::duration. Also streaming, adding and substracting an ACE_Time_Value to and from a std::duration is supported. Please see tests/Chrono_Test.cpp for more details. . Allow ACE_INET_Addr to hold all addresses associated with a hostname. The set of addresses always has a "current" address which is accessed by the usual "get"-type methods on the class. Two new methods are added to deal with multiple addresses: - bool next (void): makes the next available address the "current" one. Returns false if there are no more addresses. - void reset (void): resets the iteration mechanism to be able to examine all of the addresses again. ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() methods copy all available addresses related to each name. . The ACE_Addr::set_addr (void*, int) signature was changed to ACE_Addr::set_addr (const void*, int). All classes that inherit from ACE_Addr also have the same change. This affects ACE_ATM_Addr, ACE_Addr, ACE_INET_Addr, ACE_MEM_Addr, ACE_Netlink_Addr, ACE_SPIPE_Addr, ACE_UNIX_Addr. Any user-written classes derived from ACE_Addr will also need to change to match the new signature for virtual method dispatch to continue working properly in all cases. . Added the class ACE_CDR::Fixed (CDR_Base.h) for CDR's fixed-point decimal data type which stores up to 31 decimal digits and a sign bit. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== . ACE is now hosted on github (https://github.com/DOCGroup/ATCD). As part of the release process we now generate a ChangeLog for each release which is stored in the ChangeLogs directory . ACE has been ported to OpenBSD 5.6. Old versions of OpenBSD are no longer supported. USER VISIBLE CHANGES BETWEEN ACE-6.2.8 and ACE-6.3.0 ==================================================== . ACE now supports Oracle Solaris Studio 12.4 on Solaris. . New config macros were added: ACE_DISABLE_MKTEMP: Disables the availability of ACE_OS::mktemp(). ACE_DISABLE_TEMPNAM: Disables the availability of ACE_OS::tempnam(). These can be added to your $ACE_ROOT/ace/config.h to disable these wrappers which are considered to be a potential security risk. Disabling one or both will also disable the following: - ACE_FILE_Addr::set () with the 'any' address specified. - ACE_MMAP_Memory_Pool use of the 'unique' option. . Reduced size of all doxygen documentation by changing the type of diagrams shown . Removed Windows specific workarounds from ACE_OS::setsockopt, as a result SO_REUSEPORT is not defined anymore on Windows and SO_REUSEADDR is passed directly to the OS . By adding a 'specific' section to a MPC (base) project it is now possible to have object file output directories per project for GNUACE projects. The following should be added to MPC projects (bugzilla #3868): specific(gnuace) { build_dir_per_project=1 } . ACE_Asynch_Write_File will now correctly accept non-socket (file, TTY ..) handles (bugzilla #3762 and #3992) . Fixes for VxWorks 6.9 USER VISIBLE CHANGES BETWEEN ACE-6.2.7 and ACE-6.2.8 ==================================================== . Add new ACE::make_event_handler() which is similar to std::make_shared but than for allocation of ACE event handlers. This template method is only enabled when ACE_HAS_CPP11 has been defined, which is set automatically when a C++ compiler with adequate C++11 support is used. Also ACE_Event_Handler_var is extended with some C++11 specific operations . For all reactor types calling cancel_timer with a nullptr is now allowed, will result in a return of 0 . ACE_DLL and ACE_DLL_Manager have been extended with the support to retrieve any dynamic loader errors USER VISIBLE CHANGES BETWEEN ACE-6.2.6 and ACE-6.2.7 ==================================================== . Added configuration files for Microsoft Visual Studio 2014 . Added configuration files for MacOSX Yosemite . Added configuration files for IBM AIX XL C++ 12.1 USER VISIBLE CHANGES BETWEEN ACE-6.2.5 and ACE-6.2.6 ==================================================== . Resolved several data races reported by Intel Inspector XE . Added optional socket connection optimization for Windows . Improve functionality and stability of running tests on Android Virtual Device (AVD). USER VISIBLE CHANGES BETWEEN ACE-6.2.4 and ACE-6.2.5 ==================================================== . Added the ability to build RPMs for just ACE, using an ACE-src tarball. To do this add "--without tao" to the rpmbuild command line. . Added support for Embarcadero C++Builder XE5 using bcc32 in debug and release mode . Added support for Embarcadero C++Builder XE6 using bcc32 in debug and release mode . When Intel C++ 2013 SP1 Update 2 is used with C++11 enabled as compiler feature now also ACE_HAS_CPP11 will be defined, this compiler is now able to compile all our C++11 feature tests . Fixed several boundary bugs in the ACE RLE Compressor USER VISIBLE CHANGES BETWEEN ACE-6.2.3 and ACE-6.2.4 ==================================================== . Added support for FC20 and ended maintenance for FC19 . Extended C++11 feature test suite . Improved support for MingW64 . Improvements to IPv6 support on Windows USER VISIBLE CHANGES BETWEEN ACE-6.2.2 and ACE-6.2.3 ==================================================== . The ACE_OS::thr_join() method will detect if the thread to be waited on is the calling thread and avert that deadlock. The support needed for this method is available at Vista/Windows Server 2003 and higher; to enable the deadlock prevention, compile ACE with _WIN32_WINNT=0x0502 or higher. . Ended maintenance and support for FC12 CEEL . Further improvements of the Android port: Added new define ACE_HAS_EXPLICIT_TEMPLATE_CLASS_INSTANTIATION and related macros ACE_SINGLETON_TEMPLATE_INSTANTIATION and ACE_SINGLETON_TEMPLATE_INSTANTIATE providing a cleaner way to support explicit template (static member or class) instantiation. ' Improvements of the test framework for running tests in a mixed environment where different targets run on different physiscal devices (possibly having different OS). USER VISIBLE CHANGES BETWEEN ACE-6.2.1 and ACE-6.2.2 ==================================================== . The max_len argument to ACE_Process::command_line_buf changed from int* to size_t*. This corrects a mismatch between the argument type and the data member in ACE_Process from which the value comes. . Removed some include files from ACE.h. These were not required for ACE. The removed includes are OS_NS_math, Flag_Manip, Handle_Ops, Lib_Find, Init_ACE, Sock_Connect.h. You may have to explicitly add one of these in your own code to restore compiling. . Further improvements of the Android port, still work in progress. USER VISIBLE CHANGES BETWEEN ACE-6.2.0 and ACE-6.2.1 ==================================================== . Added support for Fedora 19, ended daily maintenance for Fedora 17 and 18 . Added support for Embarcadero C++BuilderXE4 using bcc32 in debug and release mode . Improved support for Android USER VISIBLE CHANGES BETWEEN ACE-6.1.9 and ACE-6.2.0 ==================================================== . None USER VISIBLE CHANGES BETWEEN ACE-6.1.8 and ACE-6.1.9 ==================================================== . Added MinGW64 as supported platform . Added support for GCC 4.8.0 USER VISIBLE CHANGES BETWEEN ACE-6.1.7 and ACE-6.1.8 ==================================================== . Small bug fixes USER VISIBLE CHANGES BETWEEN ACE-6.1.6 and ACE-6.1.7 ==================================================== . Integrated several patches to simplify Debian/Ubuntu packaging USER VISIBLE CHANGES BETWEEN ACE-6.1.5 and ACE-6.1.6 ==================================================== . Added new event and sema initialization methods to OS_NS_Thread to allow passing pre-initialized condition attributes providing basic support for using time policies in ACE Event classes. . Added TIME_POLICY support to ACE_Event classes to allow for monotonic timer support for ACE Events. . Added new regression test: Monotonic_Manual_Event_Test USER VISIBLE CHANGES BETWEEN ACE-6.1.4 and ACE-6.1.5 ==================================================== . When a ACE_Event_Handler registered for signals is unregistered, whether by unregistering, returning -1 from handle_signal(), or by the reactor closing, the ACE_Event_Handler::handle_close() hook will be called. The close_mask passed will be ACE_Event_Handler::SIGNAL_MASK. In previous versions, handle_close() would only be called when the handle_signal() callback returned -1. This resolves Bugzilla #2368. . Some initial ACE unit tests to validate the C++11 support of various compilers . Added support for OpenSuSE 12.2 USER VISIBLE CHANGES BETWEEN ACE-6.1.3 and ACE-6.1.4 ==================================================== . Added a new ACE_Time_Value derived template class (Time_Value_T.h): template class ACE_Time_Value_T This template class overloads 4 new virtual methods from the ACE_Time_Value base class to provide time policy aware time values: to_relative_time () to_absolute_time () now () duplicate () . Updated time policy classes to return ACE_Time_Value_T<> instantiations for the corresponding time policy instead of 'common' time values. . Added new ACE_Monotonic_Time_Policy (Monotonic_Time_Policy.h). This class provides a monotonic time source for supported platforms (Windows and POSIX platforms providing the required clock_gettime() time source; currently verified for Windows and Linux) . Updated OS_NS_Thread to use the new time policy support in ACE_Time_Value for (relative) time calculations and added new ACE_OS::condattr_setclock () method. . Added TIME_POLICY support to ACE_Condition_Attributes to allow for monotonic timer support for ACE_Condition. . Added TIME_POLICY support to ACE_Message_Queue-s, ACE_Task-s and related classes to enable support for monotonic timers in the timed wait methods (ACE_Condition based). See docs/ACE-monotonic-timer.html for how to use this. . Added two new regression tests: Monotonic_Task_Test Monotonic_Message_Queue_Test and updated the Bug_4055_Regression_Test to a fixed state. USER VISIBLE CHANGES BETWEEN ACE-6.1.2 and ACE-6.1.3 ==================================================== . Added support for Oracle Solaris Studio 12 Update 3 (SunCC 5.12) . Added new XML_Utils library which comes from DAnCE but is now also used by OpenDDS USER VISIBLE CHANGES BETWEEN ACE-6.1.1 and ACE-6.1.2 ==================================================== . Added compile time support for Windows CE 7, no runtime testing has been performed . The High Res Timer global scale factor on Windows is now 64bit, see bugzilla 3703 for the background of this. If you use the gsf in your code, use the new ACE_High_Res_Timer::global_scale_factor_type type trait to not get any conversion warnings . Removed Tandem NSK v2/v3 support which resulted in cleanup throughout all code. The emulations for ACE_INT64/ACE_UINT64 have been removed because no platform is using them anymore USER VISIBLE CHANGES BETWEEN ACE-6.1.0 and ACE-6.1.1 ==================================================== . Minor bug fixes USER VISIBLE CHANGES BETWEEN ACE-6.0.8 and ACE-6.1.0 ==================================================== . Added compilation support for VxWorks 6.9, no runtime testing has been performed . Added ACE Run-length encoding compressor . Fixed several Coverity reported issues USER VISIBLE CHANGES BETWEEN ACE-6.0.7 and ACE-6.0.8 ==================================================== . Added support for MPC's new feature that creates dependency files for IDL files when generating '-type gnuace' projects. Turned off by default, it can be enabled in a features file or on the command line with '-features ace_idl_dependencies=1'. USER VISIBLE CHANGES BETWEEN ACE-6.0.6 and ACE-6.0.7 ==================================================== . Added a new method to ACE_Atomic_Op, TYPE exchange (TYPE newval) which does an atomic exchange of the new value with ACE_Atomic_Op's value and returns the old value. The tests/Atomic_Op_Test.cpp test program has a test case that exemplifies its usage; see the Exchange_Tester class. . Added a new feature to timer queue templates classes: TIME_POLICY. This feature is specified through a new template argument and provides the timer queue with a policy for a timer (time of day) value. This feature is intended to replace (in time) the gettimeofday setter method which has been marked @deprecated. For now backwards compatibility is guaranteed. The TIME_POLICY feature provides flexibility with regards to providing a timer source to the timer queues as well as the possibility for a fully optimized calling path. A number of standard time policies are provided in ace/Time_Policy.h. The tests/Timer_Queue_Test.cpp has been updated to reflect and exemplify these changes. . Added the TIME_POLICY feature also to countdown time class which has now become a template (ace/Countdown_Time_T.h) . Initial support for Microsoft Visual Studio 11 . Increased overall code quality by using Coverity and Klocwork USER VISIBLE CHANGES BETWEEN ACE-6.0.5 and ACE-6.0.6 ==================================================== . Removed autoconf support, only traditional way of compilation is shipped from now . Add support for RHEL 6.1 64bit USER VISIBLE CHANGES BETWEEN ACE-6.0.4 and ACE-6.0.5 ==================================================== . Improved support for Android and added the ability to run all ACE/TAO tests automatically using the Android emulator USER VISIBLE CHANGES BETWEEN ACE-6.0.3 and ACE-6.0.4 ==================================================== . Removed support for C++ Builder . Added support for building with the Android NDK, at least r5c. This is currently available for linux host platforms. USER VISIBLE CHANGES BETWEEN ACE-6.0.2 and ACE-6.0.3 ==================================================== . Added support for GCC 4.6 USER VISIBLE CHANGES BETWEEN ACE-6.0.1 and ACE-6.0.2 ==================================================== . The ACE_wrappers/ace/OS.h file has been restored in order to ensure build-time compatibility with older ACE versions. Its use will still cause your build to incur more processing time than using the needed ace/OS_NS_*.h files; however, you should be able to build OS.h-including code without needing to replace it with OS_NS_* includes. . Improved and simplified QNX support . Changed rand_r() and getpwnam_r() to conform Single UNIX Specification. . Fixed performance of send_v on windows when individual iovec elements are particularly large. USER VISIBLE CHANGES BETWEEN ACE-6.0.0 and ACE-6.0.1 ==================================================== . Added support for MinGW with GCC 4.5 USER VISIBLE CHANGES BETWEEN ACE-5.8.3 and ACE-6.0.0 ==================================================== . Changed the string format produced by ACE::timestamp() from the ctime format "Day Mon dd hh:mm:ss yyyy" to ISO-8601 yyyy-mm-dd hh:mm:ss.mmmmmm. This makes the time easier to collate and removes any dependence on locale. The change affects the output from ACE_Log_Msg's %D format and both VERBOSE and VERBOSE_LIGHT timestamps in addition to application-made direct calls to ACE::timestamp(). . Removed GCC < 3 support . A new build system hook was added for users to include site-private rules in a build. If a file named "rules.private.GNU" in located in any build directory it will get included from $ACE_ROOT/include/makeinclude/rules.local.GNU. The "private_rules_file" make variable can be set to override the name and/or location of the file. If no such rules file exists, its absence is silently ignored. This facility can be used, for example, to integrate a specialized code checker into the build process. USER VISIBLE CHANGES BETWEEN ACE-5.8.2 and ACE-5.8.3 ==================================================== . Two new methods were added to ACE_Pipe: close_read() and close_write(). These methods can be used to close individual pipe handles. . The ACE::handle_ready() family of methods was changed to prefer using poll() over select() on platforms where poll() is available. This preference was previously only used if ACE_HAS_LIMITED_SELECT was set. The ACE_HAS_LIMITED_SELECT choice is removed, making ACE_HAS_POLL the setting that switches this preference. The driving reason for this is that if select() is called to detect changes on a handle whose values falls outside that which can safely be stored in an fdset, the handle-setting macros/functions will set/clear bits outside of the fdset. This results in very weird memory changes, often in the stack, which are very hard to diagnose. poll()'s operation does not suffer from this affect. With the growing use of large numbers of handles and use of ACE_Dev_Poll_Reactor on Linux, the rate at which this problem was cropping up was increasing. . Added a simple helper ACE::is_equal() which compares equality of two objects without using operator==. This is useful for comparing floating point values. . Removed all deprecated methods, arguments, files, classes, macros and anything else we kept for years. . Removed Irix/Tru64/SCO/Uniware/Cray support . ACE_Pair has been removed. Users should now use std::pair. . This is the last micro release that will work with GCC < 3, after x.8.3 support for GCC < 3 will be removed USER VISIBLE CHANGES BETWEEN ACE-5.8.1 and ACE-5.8.2 ==================================================== . Added support for the Microsoft Visual Studio 2010 IDE (vc10) . Removed complete support for emulated C++ exceptions USER VISIBLE CHANGES BETWEEN ACE-5.8.0 and ACE-5.8.1 ==================================================== . Added support for Microsoft Visual Studio 2010 using nmake . Reduced the amount of doxygen pages generated, the original settings caused a doxygen generated html package of 1.4GB which was way too large . Extended ACE INet addon library with: * HTTP Basic Authentication * SSL/HTTPS support. * Proxy CONNECT tunneling. USER VISIBLE CHANGES BETWEEN ACE-5.7.9 and ACE-5.8.0 ==================================================== . There are two new ACE_Time_Value methods for getting and setting millisecond values to/from ACE_UINT64 values: ACE_UINT64 ACE_Time_Value::get_msec () const void ACE_Time_Value::set_msec (const ACE_UINT64 &ms) The former is a replacement for the existing msec(ACE_UINT64&) methods that are "getter" methods whose signatures look confusingly like "setters". See Bugzilla #3336 for the history behind this change. The latter is for consistency and clarity. . Added ACE INet addon library for Inet protocol clients (and possibly servers at some point) like http://, ftp:// etc. The library implements standard C++ iostream wrapper classes for ACE Svc_Handler and Reactor based input/output handling, URL classes and protocol handler classes. NOTE: This is work in progress! There is no guarentee that the API won't change in the next few releases. Protocol handling is currently restricted to client side download requests for HTTP and FTP. Handling for upload requests should be added in the near future as well as HTTP Basic Authentication. USER VISIBLE CHANGES BETWEEN ACE-5.7.8 and ACE-5.7.9 ==================================================== . ACE's default makefiles (traditional ACE/GNU, not autoconf/automake) now support installation with "make install". Please see the ACE-INSTALL.html file for instructions. . Support for the ARCH make variable has been enhanced to apply to executables (in addition to libraries and object files), and the ARCH feature has been integrated into the MPC-generated makefiles (to work with MPC's requires and avoids features). USER VISIBLE CHANGES BETWEEN ACE-5.7.7 and ACE-5.7.8 ==================================================== . ACE now uses GCC builtin Atomic instructions for short, unsigned short, long, unsigned long, int, unsigned int, and bool. This makes our Atomic_Op around 7 times faster . ACE Service Configuration Framework now process first service configuration files and then command-line directives. Thus if application uses both service configuration files and command-line directives then the command-line directives may override results of directives in the configuration files. At the same time if the application uses only the default svc.conf file and command-line directives then the directives from svc.conf can not override results of the user provided command-line directives. . ACE_Dev_Poll_Reactor now dispatches notifications in only one thread at a time. This brings notification handling more in line with behavior in other Reactor implementations. USER VISIBLE CHANGES BETWEEN ACE-5.7.6 and ACE-5.7.7 ==================================================== . Integrated fix for bug 3104 and regression test for interval timers. . Added support for GCC builtin Atomic instructions which are enabled with GCC >= 4.1 for PPC32/PPC64/IA64 . Improved autoconf support for debian . Added support for -mcpu and -mtune. Add TCPU=.. to your environment/platform_macros.GNU to specify you cpu and than add cpumodelflag=1 and/or tunemodelflag=1. Using this with IBM Cell increased the performance significantly USER VISIBLE CHANGES BETWEEN ACE-5.7.5 and ACE-5.7.6 ==================================================== . Added support for iPhone/iPod Touch/iPad. The following environment variables are needed: IPHONE_TARGET, should be set to either SIMULATOR or HARDWARE. Set to HARDWARE if you want to deploy on the iPhone/iPod Touch/iPad device. IPHONE_VERSION, should be set to 3.1.2 or 3.2. One can set the version to any future or past versions, but only 3.1.2 and 3.2 have been tried. Note that one has to compile ACE/TAO statically as it is believed that the iPhone OS does not support dynamic loading of external libraries. The usual procedure of cross compiling ACE/TAO applies (such as setting HOST_ROOT environment variable). . Added support for Embarcadero C++ Builder 2010 . Added option to print a given ACE_Time_Value in the log message instead of system supplied timestamp as in %T and %D. The option is implemented as a variant of the %D/%T options by using the '#' flag character like '%#D' or '%#T'. When using this flag an ACE_Time_Value pointer is expected in the argument list supplied with the log message. This fixed Bugzilla #3221. . Fixed problems with ACE_INET_Addr::is_multicast() on little endian platforms. This fixed bugzilla #3729. . Added compilation support for VxWorks 6.8, no runtime testing has been performed USER VISIBLE CHANGES BETWEEN ACE-5.7.4 and ACE-5.7.5 ==================================================== . Added MacOSX Snow Leopard support . Added strsignal() wrapper . Improved LynxOS support . Updated Interix port . Fixed MinGW compilation problems USER VISIBLE CHANGES BETWEEN ACE-5.7.3 and ACE-5.7.4 ==================================================== . ACE_CDR::consolidate now returns an int, 0 is ok, -1 is failure . Fixed a bug in the realclean feature of the GNU makefiles . Improved Sun Studio for Linux support . Improved OpenBSD support USER VISIBLE CHANGES BETWEEN ACE-5.7.2 and ACE-5.7.3 ==================================================== . C++ Builder 2009 Update 3 is the only C++Builder that is supported, older and newer compilers are not supported anymore . Made final changes for the CEGCC port . Added a set of tests to validate C++ compiler and the stl implementation they ship. . HP-UX PARISC aCC < 3.80 are deprecated and can't be used anymore. Upgrade to aCC 3.80 or newer USER VISIBLE CHANGES BETWEEN ACE-5.7.1 and ACE-5.7.2 ==================================================== . Borland C++ makefiles aren't shipped anymore as part of the release but have to be generated by the user . Refactored gperf to have its own shared library so that we can reuse that in TAO . Added support for SuSE Enterprise 10 . ACE_Configuration_Heap::open() now returns -1 with errno EBUSY if it is called multiple times. Previous versions would allow multiple calls to open() but leak resources. USER VISIBLE CHANGES BETWEEN ACE-5.7.0 and ACE-5.7.1 ==================================================== . Added support for Sun Studio 12 Update Pack 1 . Fixed compile problems when using Windows CE x86 release mode . Fixed compile problems for FreeBSD USER VISIBLE CHANGES BETWEEN ACE-5.6.9 and ACE-5.7.0 ==================================================== . Added support for the VxWorks vxAtomicLib which is available with VxWorks 6.6 and newer. If you don't want to use this library undef ACE_HAS_VXATOMICLIB in your config.h file . Added support for C++ Builder 2009 Update 3 . Added support for ACE/TAO using the CEGCC project . Added support for upcoming Fedora 11 and OpenSuSE Factory USER VISIBLE CHANGES BETWEEN ACE-5.6.8 and ACE-5.6.9 ==================================================== . Removed Borland/CodeGear C++ Builder 2007 support. If you'd like to fund this support please let us know. . Removed VxWorks 5.5.x, 6.2, and 6.3 support. If you'd like to fund this support please let us know. . Improved Unicode support. . Added support for the native Windows Vista and Windows Server 2008 condition variables. These has to be enabled at compile time, and when enabled the application can only run on Vista or Server 2008. Add ACE_HAS_WTHREADS_CONDITION_VARIABLE to your config.h file to enable these . Fixed a bug when trying to read a file of 1 byte when unicode is enabled . Improved the Windows CE port . Fixed several Klocwork reported issues . Added support for MinGW 3.15 . Added support for Incredibuild, which is an MSVC++ feature that optimizes compiles via distributing builds. USER VISIBLE CHANGES BETWEEN ACE-5.6.7 and ACE-5.6.8 ==================================================== . Added a new function ACE::isdotdir() which determines if a specified pathname is "dot dir" (ie. "." or ".."). ACE::isdotdir() is significantly faster than pair of strcmp() calls. . Last micro release that is maintained for Borland/CodeGear C++ Builder 2007 and Intel C++ on Windows. . Fixed crash when ACE thread tries to inherit the logging attributes from non ACE threads. . Fixed many small compile and test errors that occur on some platforms. . Fixed log output formatting on some platforms. . Bugs fixed: 2748, 3164, 3480, 3494, 3502, 3541, 3542, 3544, 3557. USER VISIBLE CHANGES BETWEEN ACE-5.6.6 and ACE-5.6.7 ==================================================== . Changed the automake build's feature test for a "usable" config to warn on failure instead of exiting with an error. This should make it easier to diagnose configure failures, as the script will now generate a config.h file even when the test fails. . Removed borland MPC template, use the bmake template from now . Added Windows Mobile 6 support and improved the WinCE port . Removed BCB6 and BCB2006 support . Added BCB2009 MPC template . Updated stat struct on Windows CE to match the stat struct on other platforms so that application code can be written portable . Added new ACE_OS wrappers: raise, atof, atol, isblank, isascii, isctype, and iswctype . Added ACE_OS wrapper for narrow-char version of strtoll. . ACE_OS wrappers for wide-char versions of strtol, strtoul, strtoll, and strtoll. . Added Visual Studio 2010 (vc10) support . Added a new feature for the "Traditional Make" build facility to allow building for multiple architectures out of a single source directory. To use this facility, set the ARCH make variable. The ARCH value will be used to add a subdirectory layer below the source directory where the traditional .shobj, .obj, etc. directories will be placed. . Added support for HP-UX 11iv3 on Integrity using aC++ . ACE (and TAO) can now be built using GNU make and the Microsoft Visual C++ compiler and linker. See include/makeinclude/platform_win32_msvc.GNU for more details. . Added support for FC10 USER VISIBLE CHANGES BETWEEN ACE-5.6.5 and ACE-5.6.6 ==================================================== . Added an option to the ACE_Process_Options class to use a wchar_t environment buffer on Windows. . A new configure option, --enable-rcsid, was added to the autoconf build. This is used to embed RCS IDs in object files. . A new method was added: void ACE_Time_Value::msec (ACE_UINT64&) This method, like the existing msec(ACE_UINT64&)const method, obtains the time value in milliseconds and stores it in the passed ACE_UINT64 object. This method was added so that msec(ACE_UINT64&) can be called on both const and non-const ACE_Time_Value objects without triggering compile errors. Fixes Bugzilla #3336. . Added ACE_Stack_Trace class to allow users to obtain a stack trace within their application on supported platforms. A new conversion character, the question mark, was added to ACE_Log_Msg for stack trace logging. . Added iterator support to ACE_Message_Queue_Ex class. The resulted in the addition of ACE_Message_Queue_Ex_Iterator class and ACE_Message_Queue_Ex_Reverse_Iterator class. . Renamed gperf to ace_gperf to prevent clashes with the regular gperf tool that is available in linux distributions . Added support for FC9 . Added support for OpenSuSE 11.0 . Improved support for GCC 4.2 and 4.3 . Added support for CodeGear C++ Builder 2009 USER VISIBLE CHANGES BETWEEN ACE-5.6.4 and ACE-5.6.5 ==================================================== . Added new Monitoring lib that can be used to store and retrieve counters. This is disabled by default because it is not 100% finished yet, with the next release it will be enabled by default . Fixed bug in ACE_Service_Config when it was used from a thread not spawned by ACE . Add VxWorks 6.x kernel mode with shared library support to ACE . Extended the implementation of Unbounded_Set, which has been renamed Unbounded_Set_Ex, to accept a second parameter which is a comparator that implements operator() which returns true if the items are equivalent. Unbounded_Set has been reimplemented in terms of Unbounded_Set_Ex using a comparator that uses operator==, which captures the previous behavior. . Added support for Intel C++ on MacOSX USER VISIBLE CHANGES BETWEEN ACE-5.6.3 and ACE-5.6.4 ==================================================== . Reworked the relationship between ACE_Service_Config and ACE_Service_Gestalt . Improved autoconf support . Improved AIX with gcc support . Improved OpenVMS support . Improved VxWorks support USER VISIBLE CHANGES BETWEEN ACE-5.6.2 and ACE-5.6.3 ==================================================== . Deprecated Visual Age 5 and older . Closed a rare race condition hole whereby ACE_Atomic_Op<> function pointers would not be fully initialized prior to use. See bugzilla 3185 for details. . Tweaks to support MacOS X Leopard (10.5 and 10.5.1) on Intel . Fixed compile problems with MinGW with GCC 4.2. Do note that we do see much more test failures then when using GCC 3.4. . Changed to use synchronous exception handling with msvc 8/9 which is the default. Asynchrous exception handling does catch access violations but it leads to lower performance and other problems. See also bugzilla 3169 . Make ace_main extern C with VxWorks so that it doesn't get mangled . Fixed compile errors and warnings for VxWorks 6.6 . Added an MPC generator for the WindRiver Workbench 2.6 which is shipped with VxWorks 6.4 . Added support for CodeGear C++ Builder 2007 with December 2007 update installed . Added support for VxWorks 5.5.1 . Implemented the const reverse iterator for ACE_Hash_Map_Manager_Ex . Increased support for using ACE_Hash_Map_Manager_Ex with STL functions based on latest standard C++ draft USER VISIBLE CHANGES BETWEEN ACE-5.6.1 and ACE-5.6.2 ==================================================== . ACE-ified the UUID class, which will change user applications slightly. . Added support for Sun Studio 12 . Added support for Intel C++ 10.1 . Fixed runtime problems with VxWorks 6.x in kernel mode, several improvements have been made to ACE, but also some problems in the VxWorks kernel have been found for which WindRiver has made patches. . Added support for VxWorks 6.5 kernel mode . Added support for MacOS 10.5 . Support for MacOS 10.4 is now deprecated. . Added support for OpenSuSE 10.3 . Added support for RedHat 5.1 . Added support for Microsoft Visual Studio 2008 . Added support for Fedora Core 8 . Added support for Ubuntu 7.10 . With Ubuntu 7.04 and 7.10 we can't use visibility, that results in unresolved externals when building some tests. With lsb_release we now detect Ubuntu 7.04 and 7.10 automatically and then we disable visibility . Removed deprecated (un)subscribe methods from ACE_SOCK_Dgram_Mcast . Added an additional replace() method to ACE_OuptutCDR for replacing a ACE_CDR::Short value. Also added write_long_placeholder() and write_short_placeholder() to properly align the stream's write pointer, write a placeholder value and return the placeholder's pointer. The pointer can later be used in a call to replace() to replace the placeholder with a different value. . Initial support for VxWorks 6.6 . Removed support for pthread draft 4, 6, & 7. This makes the ACE threading code much cleaner . Improved autoconf support . Fixed TSS emulation problems . Changed ACE_thread_t and ACE_hthread_t to int for VxWorks kernel mode. All thread creation methods do have an additional const char* argument to specify the task name, this now also works with pthread support enabled . Use bool in much more interfaces where this is possible . Added support for Debian Etch . Fixed ACE CDR LongDouble support on VxWorks 6.x . Added Microsoft Visual Studio 2008 project files to the release packages . Fixed a few bugs in the ACE_Vector template USER VISIBLE CHANGES BETWEEN ACE-5.6 and ACE-5.6.1 ==================================================== . Added support for CodeGear RAD Studio 2007 . Added support for CodeGear C++ Builder 2007 Update 3 . Modified the definiton of ACE_DEFAULT_THREAD_KEYS on Windows so it is based on the version of the OS as defined by Microsoft in this web page: http://tinyurl.com/2jqcmd This fixes bugzilla #2753 USER VISIBLE CHANGES BETWEEN ACE-5.5.10 and ACE-5.6 ==================================================== . OpenVMS 8.3 on IA64 port . Added autoconf support for Intel C++ 10.0 . Improved autoconf support on Linux, Solaris, NetBSD and HPUX . CodeGear C++ Builder 2007 Update 2 support . The netsvcs's client logging daemon has a new configuration option, -llocal-ip[:local-port], which can be used to specify the local IP address and port number for the client logging daemon's connection to the server logging daemon. If the -l option is specified with an IP address but not a port number, an unused port number is selected. . A new ACE+TAO port to LabVIEW RT 8.2 with Pharlap ETS. The host build environment is Windows with Microsoft Visual Studio .NET 2003 (VC7.1). Please see the ACE-INSTALL.html file for build instructions. USER VISIBLE CHANGES BETWEEN ACE-5.5.9 and ACE-5.5.10 ==================================================== . The ACE_utsname struct, used in the ACE_OS::uname() function when the platform doesn't provide the standard utsname struct, was changed. It defines a number of text fields and their types were changed from ACE_TCHAR[] to char[] in order to be consistent with all other platforms. This removes the need to write different code for platforms where ACE_LACKS_UTSNAME_T is set and that have wide characters (most probably Windows). Fixes Bugzilla #2665. . The ACE::daemonize() "close_all_handles" parameter was changed from an "int" to a "bool" to better reflect how it is used. . VxWorks 6.5 support. Compilation of the core libraries has been validated but no runtime testing has been performed. . CodeGear C++ Builder 2007 support. . The FaCE utility was moved from the ACE_wrappers/apps directory to ACE_wrappers/contrib. It is used for testing ACE+TAO apps on WinCE. See the ACE_wrappers/contrib/FaCE/README file for more information. . ACE_INET_Addr::set (u_short port, char *host_name, ...) now favors IPv6 addresses when compiled with ACE_HAS_IPV6 defined and the supplied address family is AF_UNSPEC. This means that if host_name has an IPv6 address in DNS or /etc/hosts, that will be used over an IPv4 address. If no IPv6 address exists for host_name, then its IPv4 address will be used. . Intel C++ 10.0 support . Support for the version of vc8 for 64-bit (AMD64) shipped with the Microsoft Platform SDK. . Fixed ACE_Vector::swap() (bugzilla #2951). . Make use of the Atomic_Op optimizations on Intel EM64T processors. The Atomic_Op is now several times faster on EM64T then with previous versions of ACE USER VISIBLE CHANGES BETWEEN ACE-5.5.8 and ACE-5.5.9 ==================================================== . Use Intel C++ specific optimizations for Linux on IA64 . Improved support for ACE_OS::fgetc. Added support for ACE_OS::fputc, ACE_OS::getc, ACE_OS::putc and ACE_OS::ungetc. . Added support for ACE_OS::log2(double) and improved support for ACE::log2(u_long). . Shared library builds on AIX now produce a libxxx.so file instead of the previous practice of producing libxxx.a(shr.o). . GCC 4.1.2 that comes with Fedora 7 seems to have a fix for the visibility attribute we use for the singletons. F7 users will therefore need to define the following in your config.h file. ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 . Fixed (rare) problem in TP_Reactor where incorrect event handler was resumed. . Reduced footprint on some platforms, particularly those that use g++ >= 3.3. USER VISIBLE CHANGES BETWEEN ACE-5.5.7 and ACE-5.5.8 ==================================================== . Extended ACE_Event constructor with optional LPSECURITY_ATTRIBUTES argument . Added support for QT4 . Added support to integrate with the FOX Toolkit (www.fox-toolkit.org) . Added support for Microsoft Visual Studio Code Name "Orcas", which is the msvc9 beta . Added ability to provide an optional priority when calling ACE_Message_Queue_Ex::enqueue_prio(). There was previously no way to specify a priority for queueing. . Removed support for Visual Age on Windows. . ACE will compile once again with ACE_LACKS_CDR_ALIGNMENT #defined. . ACE_Process_Manager::terminate() no longer removes the process from the process descriptor table; the pid remains available in order to call ACE_Process_Manager::wait(). USER VISIBLE CHANGES BETWEEN ACE-5.5.6 and ACE-5.5.7 ==================================================== . ACE 5.5 contained a set of pragmas which prevented Visual Studio 2005 (VC8) from issuing warnings where C run-time functions are used but a more secure alternative is available. For more information on the C run-time issues and Microsoft's response, please see the following MSDN page: http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx. In this beta, the pragmas which prevented the warnings have been removed. The ACE library has been reviewed and most of the use of "unsafe" functions has been fixed where possible. Since not all of the warnings emanating from ACE are situations that can or should be fixed, the ACE VC8 projects will prevent the warnings while building the ACE kit and its contained examples, tests, etc. The warnings are disabled by adding Microsoft-specified macros to the compile line via MPC. If desired, the warnings can be re-enabled by regenerating the project files with different MPC features. Note, however, that while ACE without warnings caused by the new C run-time functions, your application builds may trigger these warnings either by use of the "unsafe" C run-time functions or via use of an inlined ACE_OS method which uses it. If the warning is caused by an ACE_OS method, there is a more safe alternate available, probably located by appending _r to the method name (e.g., instead of using ACE_OS::ctime(), use ACE_OS::ctime_r()). There are other cases where the compiler may have issued warnings and ACE prevented this via a #pragma. These #pragmas have been removed as well. This may cause your application builds to trigger more warnings from VC8 than past ACE versions. You should review your code and either correct the code or disable the warnings locally, as appropriate. . The "release" argument to a number of ACE_String_Base<> methods was changed from int to bool to more accurately reflect its purpose. The following methods were changed: ACE_String_Base (const CHAR *s, ACE_Allocator *the_allocator = 0, int release = 1); to ACE_String_Base (const CHAR *s, ACE_Allocator *the_allocator = 0, bool release = true); ACE_String_Base (const CHAR *s, size_type len, ACE_Allocator *the_allocator = 0, int release = 1); to ACE_String_Base (const CHAR *s, size_type len, ACE_Allocator *the_allocator = 0, bool release = true); void set (const CHAR * s, int release = 1); to void set (const CHAR * s, bool release = true); void set (const CHAR * s, size_type len, int release); to void set (const CHAR * s, size_type len, bool release); void clear (int release = 0); to void clear (bool release = false); Since ACE_String_Base forms the basis of the ACE_CString and ACE_TString classes, this may ripple out to user application code. If you encounter errors in this area while building your applications, replace the int argument you are passing to the method now with either true or false. . Solutions for the eVC3/4 platform have been removed from this release. Note that we package WinCE projects/workspaces for use with VC8. . There were 3 new ACE_Log_Msg logging format specifiers added to make logging easier for types that may change sizes across platforms. These all take one argument, and the new formats are: %b - format a ssize_t value %B - format a size_t value %: - format a time_t value . The ace/Time_Request_Reply.h and ace/Time_Request_Reply.cpp files were moved from $ACE_ROOT/ace to $ACE_ROOT/netsvcs/lib. The time arguments in the public API to ACE_Time_Request were changed from ACE_UINT32 to time_t and the portions of the on-wire protocol that contains time was changed from ACE_UINT32 to ACE_UINT64. Thus, code that uses the ACE_Time_Request class to transfer time information will not interoperate properly with prior ACE versions. This will affect uses of the netsvcs time clerk/server. . The portion of the ACE_Name_Request class that carries the on-wire seconds portion of a timeout value was changed from ACE_UINT32 to ACE_UINT64. This means that Name server/clients at ACE 5.5.7 and higher will not interoperate properly with previous ACE versions' name servers/clients. . In the ACE_Log_Record (ACE_Log_Priority, long, long) constructor, the second argument, long time_stamp, was changed to be of type time_t. This aligns the type with the expected value, a time stamp such as that returned from ACE_OS::time(). . Added support for VxWorks 6.x cross compilation using a Windows host system . Added support for VxWorks 6.x using the diab compiler . The destructor of ACE_Event_Handler no longer calls purge_pending_notifications(). Please see bugzilla #2845 for the full rationale. (http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=2845) USER VISIBLE CHANGES BETWEEN ACE-5.5.5 and ACE-5.5.6 ==================================================== . The ACE_TYPENAME macro has been added to those that are not available when the ACE_LACKS_DEPRECATED_MACROS config option is set (it is not set by default). You are encouraged to replace the use of ACE_TYPENAME with the C++ typename keyword before the ACE_TYPENAME macros is removed from ACE in the future. . A new script, rm_exception_macros.pl, has been added to help users remove the use of the ACE exception macros from their own code. USER VISIBLE CHANGES BETWEEN ACE-5.5.4 and ACE-5.5.5 ==================================================== . The prebuild MPC keyword is now supported by the gnuace project type. This fixes Bugzilla #2713. . Support for Windows earlier than NT 4 SP2 was removed. ACE will not build for Windows 95, 98, Me, etc. out of the box any longer. . Reformat stringified IPv6 addresses to use [addr]:port when printing addresses that contain ':' such as "::1". . Added method to ACE_INET_Addr to determine if address is IPv6 or IPv4 multicast. . Fixed a bug in ACE_Async_Timer_Adapter_Timer_Queue_Adapter where the gettimeofday function of the timer queue was ignored when setting the alarm. . Fixed a problem where, on Solaris 9 onwards, calling ACE_OS::thr_create(THR_NEW_LWP) more than 2^15 (65535) times in a process will fail. See changelog entry from "Wed Jan 3 22:31:05 UTC 2007 Chris Cleeland " for more information. . Fixed a bug in ACE_QtReactor where the two select() calls in that function might select on different handler sets. . ACE_SOCK_IO::recvv(iovec[], size_t, const ACE_Time_Value* = 0) and ACE_SOCK_IO::sendv (const iovec[], size_t, const ACE_Time_Value* = 0) methods were changed to specify the iovec count argument as int instead of size_t since it gets reduced to int in the underlying OS calls (usually). . The following deprecated methods were removed: ssize_t ACE_SOCK_IO::recv (iovec iov[], size_t n, const ACE_Time_Value *timeout = 0) const; ssize_t ACE_SOCK_IO::recv (iovec *io_vec, const ACE_Time_Value *timeout = 0) const; ssize_t ACE_SOCK_IO::send (const iovec iov[], size_t n, const ACE_Time_Value *timeout = 0) const; These were previously replaced with more specific recvv() and sendv() methods. . The ACE_Service_Repository::find(const ACE_TCHAR name[], const ACE_Service_Type **srp = 0, int ignore_suspended = true) const method's 'ignore_suspended' parameter was changed from int to bool to reflect it's purpose as a yes/no indicator. . Added --enable-ace-reactor-notification-queue configure script option to the autoconf build for enabling the Reactor's userspace notification queue (defines ACE_HAS_REACTOR_NOTIFICATION_QUEUE in config.h). . The int ACE_OutputCDR::consolidate(void) method was contributed by Howard Finer at Sonus Networks. This method consolidates any continuation blocks used by an ACE_OutputCDR object into a single block. It's useful for situations which require access to a single memory area containing the encoded stream, regardless of its length, when the length cannot be known in advance. . There are a number of new methods defined on ACE_String_Base: size_t capacity (void) const: This method returns the number of allocated CHAR units in the string object. void fast_resize (size_t): This method manage the sizing/reallocating of the string, but doesn't do the memory setting of resize(). bool operator!= (const CHAR *) const bool operator== (const CHAR *) const: These methods compare the string with a nul-terminated CHAR* string. nonmember functions operator== and operator!= where also added that compare const ACE_String_Base and const CHAR*; these make it possible to switch ACE_String and CHAR* on either side of the operator. Thank you to Kelly Hickel for these additions. . There are 2 new build options on the traditional make command: dmalloc and mtrace. When specified at build time (e.g. make mtrace=1) the PLATFORM_DMALLOC_CPPFLAGS and/or PLATFORM_MTRACE_CPPFLAGS values are added to CPPFLAGS. For dmalloc, the PLATFORM_DMALLOC_LDFLAGS and PLATFORM_DMALLOC_LIBS are added to LDFLAGS and LIBS, respectively. Thank you to Howard Finer for supplying these additions. . Added the ability to specify additional purify and quantify command-line options by setting PLATFORM_PURIFY_OPTIONS and PLATFORM_QUANTIFY_OPTIONS, respectively. Thank you to Howard Finer for supplying these additions. . Added the ability to use trio (http://sourceforge.net/projects/ctrio/) if platform lacks decent support for vsnprintf. trio support is enabled by defining trio=1 in plaform_macros.GNU . Removed Irix 5, DGUX, and m88k support . Improved LynxOS 4.2 support . VxWorks 6.4 support . Added support for FC6. Because the GCC 4.1.1 version that gets shipped has a fix for the visibility attribute we use for the singletons you will need to define the following in your config.h file. This can't be done automatically because SuSE 10.2 gets shipped with GCC 4.1.2 but doesn't have the same fix ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1 . RTEMS port USER VISIBLE CHANGES BETWEEN ACE-5.5.3 and ACE-5.5.4 ==================================================== . Added appropriate intptr_t and uintptr_t typedefs on platforms that don't provide them (i.e. when ACE_LACKS_INTPTR_T is defined). . Added ability to explicitly choose support for 32 bit or 64 bit file offsets on all platforms. Define the _FILE_OFFSET_BITS preprocessor symbol to either 32 or 64 to choose the desired number of file offset bits. This preprocessor symbol is supported natively by most UNIX and UNIX-like operating systems, and supported by ACE on Windows. Use the new ACE_OFF_T typedef to refer to file offsets across UNIX and Windows portably. . 64-bit file offsets are now enabled by default in Win64 configurations. . Improved support for 64 bit platforms (64 bit addresses, etc). . Added STL-style traits, iterators and a swap() method to the ACE_Array_Base<> class template. . Added STL-style traits and iterator accessors to the ACE_Hash_Map_Manager_Ex<> class template, as well as new find() and unbind() methods that return (as an "out" parameter) and accept iterators, respectively. . Greatly improved event handler dispatch performance in select()-based reactors (e.g. ACE_Select_Reactor and ACE_TP_Reactor) for large handle sets on Windows. Previous event handler search were linear, and are now constant on average. . Addressed a number of Coverity errors (CHECKED_RETURN, DEADCODE, LOCK, USE_AFTER_FREE, RESOURCE_LEAK, FORWARD_NULL). . Added STL-style "element_type" trait to all ACE auto_ptr class templates. . Removed support for LynxOS 3.x. . Resolved Bugzilla #2701 to ensure fini() is called for all Service Objects upon calling ACE_Service_Config::close() . VxWorks 5.5.2 has been tested, for ACE the support is exactly the same as for VxWorks 5.5.1. No specific defines or flags have to be used. USER VISIBLE CHANGES BETWEEN ACE-5.5.2 and ACE-5.5.3 ==================================================== . Added the base projects for executionmanager_stub and plan_generator. . Added the ACE_Hash_MultiMap_Manager class and its test file. . Changed the ACE_Synch_Options::operator[] method to return bool rather than int. The value returned is a yes/no indication of whether or not the specified option(s) are set in the object. . Changed the prototype(s) for ACE::debug () to return (and take) a bool. This is consistent with the original intent for this feature. If you have been using it like 'ACE::debug () > 0' or 'ACE::debug (1)', you may have to rebuild ACE. The value of the ACE_DEBUG environment variable can be used to specify the initial value for ACE::debug(), at the process start up. . An assembler (within a C source file) based implementation for SPARC of atomic operations suitable for use with the ACE_Atomic_Op and ACE_Atomic_Op specializations has been added. Currently, it can only be enabled by setting the atomic_ops_sparc make macro to 1 when using the GNUACE build system with the Solaris SunCC compiler. It should be noted that this requires the -xarch=v8plus (or higher) be added to the CFLAGS make macro or the assembler code will not compile. . The ACE_Message_Queue_Ex_N class is new, contributed by Guy Peleg . ACE_Message_Queue_Ex_N is similar to ACE_Message_Queue_Ex in that the object queued is a template parameter. However, ACE_Message_Queue_Ex_N allows the enqueueing and dequeueing of multiple chained objects at once. This wasn't added to ACE_Message_Queue_Ex because the chained object functionality requires the ACE_MESSAGE_TYPE class to have a ACE_MESSAGE_TYPE *next (void) const method, analogous to ACE_Message_Block::next(), to follow the chain and this would probably break existing applications using ACE_Message_Queue_Ex. The ACE_wrappers/tests/Message_Queue_Test_Ex.cpp test has an example of how to use the new class. . The selector and comparator function pointer arguments to ACE_OS::scandir() and ACE_Dirent_Selector are now marked as extern "C" to enforce their use with a C RTL function. User code that defines functions which are passed as the selector or comparator arguments which are not declared extern "C" may generate compile warnings. To resolve this, add extern "C" to the function's signature. See ACE_wrappers/tests/Dirent_Test.cpp for an example. . To address a problem in the ACE string interface that prevented substring or character searches in very large strings (e.g. greater than the maximum value of an ssize_t type) from being correctly reported to the caller, the find(), rfind() and strstr() methods now return an unsigned integer (size_t) instead of a signed one (ssize_t). Affected classes include: * ACE_CString * ACE_WString * ACE_TString * ACE_NS_WString Unless you have been explicitly using -1 instead of npos when comparing the return value of find(), rfind() and strstr(), and/or assigning the return value to ssize_t you should not see any difference. A new size_type typedef has been added to the ACE string class to aid developers. This typedef is analogous to the standard C++ string::size_type typedef. The ACE_String_Base<>::strstr() documentation and the default rfind() argument erroneously referred to -1 instead of npos. Those instances have been corrected. To summarize, a "no position" condition is denoted using the npos constant, not -1. It can be referred directly by scoping it with the appropriate string class (e.g. ACE_CString::npos, ACE_WString::npos, etc). . Changing the shared library extension for hpux ia64 to ".so". On HP-UX 11i Version 1.5 the naming scheme is lib*.sl for PA and lib*.so on IPF. . The ACE_Refcounted_Auto_Ptr reset() and release() methods were changed per Bugzilla #1925. They will both now detach from the underlying ACE_Refcounted_Auto_Ptr_Rep object; reset() will create a new one for the new pointer specified as its argument. This change may cause referenced objects to be deleted in cases where previous ACE versions would not have. . The return type of "ACE_Refcounted_Auto_Ptr::null (void) const" changed from int to bool. It's possible values, true and false, have not changed. . TTY_IO now accepts "none" as a valid parity value. Due to this change 'parityenb' member is now deprecated and will be removed in the future. The users of TTY_IO class should change their code to use only 'paritymode' member for parity control and leave 'parityenb' unchanged (it is enabled by default in class constructor). . Support for Intel C++ 9.1 on Windows and Linux . VxWorks 6.3 support . Fixed Bugzilla #2648 to make sure ACE_Service_Object::fini() is called iff ACE_Service_Object::init() succeeded, as per C++NPv2. . Added preliminary support for Mac OS X 10.4 on Intel CPU's. . Fixed Bugzilla #2602 to re-enable XML Service Configurator file support. USER VISIBLE CHANGES BETWEEN ACE-5.5.1 and ACE-5.5.2 ==================================================== . Added support for: - VxWorks 6.2 for the rtp model using pthread support - OpenVMS 8.2 for Alpha . Removed code and configurations that provided support for: - Visual C++ 6.0 and 7.0 - Chorus - pSOS - KAI C++ on all platforms . Explicit template instantiation support has been removed. This effectively removes support for Sun Forte 6 and 7 which required explicit template instantiation to build ACE reliably. . Added support for multiple independent Service Repositories through configuration contexts called "Gestalt". Full backwards compatibility is maintained through the existing ACE_Service_Config static methods, while direct individual repository access is enabled through instances of the new ACE_Service_Gestalt class. ACE_Service_Config has changed to a specialization of ACE_Service_Gestalt and is only responsible for the process-wide configuration. . To support dynamically-sized ACE_Log_Record messages, the netsvcs logging components now use ACE CDR encoding and transfer mechanisms inspired by the examples in Chapter 4 of the C++NPv1 book. The client and server logging daemons in ACE 5.5.2 and forward will not interoperate with those in previous ACE versions. . Added a wrapper for the sendfile API (ACE_OS::sendfile()). . Added support for netlink sockets on Linux. . Added a new method, ACE_Task::last_thread(). This method returns the thread ID (ACE_thread_t) of the last thread to exit from the ACE_Task object. Users checking to see if a thread is the last one out (for example, to know when to perform cleanup operations) should compare the current thread ID to the return value from last_thread(). This is a change from the previously recommended practice (C++NPv2, page 189) of comparing the return value of thr_count() with 0. . Changed the first argument to ACE_OS::strptime() to be 'const' which matches its usual usage in POSIX strptime(). This change allows users to pass const strings in - a common use case. . Made part of the file support in ACE 64bit but we have some places where 32bit types are used, this could lead to some conversion warnings which will be addressed in the near future, but getting everything 64bit compliant is a lot of work. USER VISIBLE CHANGES BETWEEN ACE-5.5 and ACE-5.5.1 ==================================================== . Added support for the --enable-symbol-visibility configure option to the autoconf build infrastructure instead of solely relying on feature tests to enable/disable symbol visibility support. This avoids build problems with icc, etc. . Added support for the --enable-fl-reactor configure option to the autoconf build infrastructure to build the ACE_FlReactor library. . Added support for the --enable-qt-reactor configure option to the autoconf build infrastructure to build the ACE_QtReactor library. . Added support for the --enable-xt-reactor configure option to the autoconf build infrastructure to build the ACE_XtReactor library. . Fixed a bug that would cause timer IDs from ACE_Timer_Heap to be improperly duplicated under certain conditions (Bugzilla #2447). . Fixed ACE_SSL_Context::private_key(), context(), and dh_params() methods to allow retrying a file load after a failed call. . Fixed ACE_SSL_Asynch_Stream so it can be instantiated; also moved the declarations for ACE_SSL_Asynch_Read_Stream_Result, ACE_SSL_Asynch_Write_Stream_Result, and ACE_SSL_Asynch_Result classes to the ace/SSL/SSL_Asynch_Stream.h file so applications can see them. USER VISIBLE CHANGES BETWEEN ACE-5.4.10 and ACE-5.5 ==================================================== . Added a platform macros option "templates=manual", currently only applies to AIX 5.3 with XL 7 compiler. It allows the user to tell the compiler to set -qnotempinc and -qnotemplateregistry and works well in static builds. . ACE and its tests compile error free with GCC 4.1 pre release. . ACE_Recursive_Thread_Mutex::get_nesting_level() fixed for 64-bit Windows XP on amd64/EM64T hardware. . Many build-time fixes for Windows Mobile 5 and Windows PocketPC 2003 using Visual Studio .NET 2005 (VC8). . Added support for the --enable-tk-reactor configure option to the autoconf build infrastructure to build the ACE_TkReactor library. USER VISIBLE CHANGES BETWEEN ACE-5.4.9 and ACE-5.4.10 ==================================================== . Fixed a bug in ACE_Timer_Heap_T::cancel(). . Improved ACE_Time_Value support for boundary conditions. . Fixed problems with operator placement delete on certain C++ compilers. . Fixed a bug with the ACE_SPIPE_Acceptor on Windows. . Correctly set sockaddr_in.sin_len and sockaddr_in6.sin6_len on platforms that have these fields. . Avoided problems with namespace pollution for max() macros. . Many fixes for ACE_LACKS* and ACE_HAS* macros for autoconfig. USER VISIBLE CHANGES BETWEEN ACE-5.4.8 and ACE-5.4.9 ==================================================== . Added dozens of new ACE_LACKS and ACE_HAS defines which are used to simplify the ACE_OS layer . Constructors of ACE_Time_Value have been made explicit to prevent implicit conversions. . Added a shutdown() method to ACE_Barrier. The new method aborts the wait by all threads. . Changed the behavior of ACE_Message_Queue::enqueue_head() and enqueue_tail(). If the enqueued message block has other blocks chained to it via its next() pointer, the entire chain of blocks will be enqueued at once. . Improved the support for high-resolution timers with ACE_Timer_Queue_Adapter. . Make it possible to disable file caching in JAWS. . Improved ACE_Pipe implementation so that it uses localhost to avoid firewall problems. . Added Unicode support to the Service Configurator. USER VISIBLE CHANGES BETWEEN ACE-5.4.7 and ACE-5.4.8 ==================================================== . Improved IPv6 support . Improved 64bit portability . TTY_IO overhaul - Improved documentation. - It is now possible to request infinite timeout in portable manner. This can be achieved by setting negative value to readtimeoutmsec. - Various bugs fixed and portability issues resolved. . Subset ACE for TAO and TAO Services . Support for Intel C++ 9.0 on Windows and Linux . Support for Microsoft Visual Studio 2005 (aka VC8) for Win32 as well as the Windows CE platforms Pocket PC 2003 and Windows Mobile 5. Solution/project files are generated with an appended "_vc8" for Win32 and "_WinCE" for the CE platforms. See ACE_wrappers/docs/CE-status.txt for more information. . Completed implementation of ACE_Dev_Poll_Reactor using the Linux epoll facility; tested on Red Hat Enterprise Linux 4. . The in-memory size of an ACE_RB_Tree will be smaller due to rearranged placement of pointers. . Added an optimization to CDR stream to ignores alignment when marshaling data. Use this new ACE_LACKS_CDR_ALIGNMENT compile-time option only when the ACE_DISABLE_SWAP_ON_READ macro is enabled. This new option requires ACE CDR engine to do both marshaling and demarshaling, and when this option is enabled the encoded streams are no longer compliant with the CORBA CDR specification. . Developed Feature Oriented Customizer (FOCUS) tool to enable specialization of middleware frameworks such as Reactor and Protocol framework. FOCUS provides an XML based transformation engine, where the transformations to specialize the components are captured in XML file and a weaver specializes the code. . Added support for unrolling ACE_OS::memcpy copy loop where applicable to improve performance. Autoconf tests empirically determine whether loop unrolling is at least 10% better than default version. . Added support for an ACE "versioned" namespace. When enabled, ACE library sources will be placed within a namespace of the user's choice or a namespace of the form ACE_5_4_7 by default, where "5_4_7" is the ACE major, minor and beta versions. The default may be overridden by defining the ACE_VERSIONED_NAMESPACE_NAME preprocessor symbol. Enable overall versioned namespace support by adding "versioned_namespace=1" to your MPC default.features file. USER VISIBLE CHANGES BETWEEN ACE-5.4.6 and ACE-5.4.7 ==================================================== . Support for shared libraries with VxWorks . Support for Solaris 10 on x86 with Sun Studio 10 (C++ 5.7). . Extended ACE_OS::event_xxx implementation to support platforms having either PThread support with Process Shared condition variables or POSIX semaphores with named (process shared) semaphore support or using the new FIFO based semaphores. . ACE_OS::closesocket() no longer calls ACE_OS::shutdown() on any platform while closing the socket. It previously called ACE_OS::shutdown() on HP-UX. Removing this call fixes the fork-and-close programming paradigm that's common to many networked applications. . RMCast - Support for message fragmentation. This will allow for messages larger than 64K. - Support for flow control. - Timed recv() in RMCast::Socket. - Per-instance configurable protocol parameters (e.g., message retention time, NAK timeout, etc). USER VISIBLE CHANGES BETWEEN ACE-5.4.5 and ACE-5.4.6 ==================================================== . Updated RMCast to include - Reactor-compatible interface. - Message unavailability reporting. - Protocol documentation. . Added support for 64bit Visual Age on AIX . Improved g++ 4.0 support. A number of RTTI related problems have been fixed. . Smaller footprint. . Fixed memory leaks ACE_DLL and ACE_Log_Msg classes. . The ACE::ICMP_Socket and ACE::Ping_Socket classes were moved out of the ACE namespace and "flattened" to ACE_ICMP_Socket and ACE_Ping_Socket to be consistent with the rest of ACE. . ACE_INET_Addr::set_address() - fixed a possible struct member alignment issue when building an IPv4-mapped IPv6 address. . Added a new ACE::wild_match() function to match a string based on wildcards. . Added efficient overloads for string concatenation to the ACE_String_Base class. . Added support for the use of pthread_getschedparam on MacOS X. . Fixed an issue with static initialization of TSS related classes on static builds for Windows. USER VISIBLE CHANGES BETWEEN ACE-5.4.4 and ACE-5.4.5 ==================================================== . Remove special handling in the Thread Specific Storage(TSS) code that released the TSS key for ACE_TSS. ACE_TSS has been changed to explicitly free the TSS key when necessary. . On Win32 systems: detect thread termination via a hook in DLLMain for ACE.dll. This allows cleanup of TSS objects for non-ACE threads that use ACE functions. The most common case was threads that used ACE logging. Formerly any TSS objects created by these threads would be leaked. . Added support for GNU G++ 4.0. The x.4.5 beta takes advantage of g++ 4.0's symbol visibility. This feature is conceptually similar to MS Windows "__declspec(dllexport)" DLL functionality. Using this new g++ feature results in substantially improved ACE/TAO/CIAO shared library binaries. A subset of the improvements include the following: * The number of unnecessarily exported DSO/DLL symbols is greatly reduced, resulting in faster program start times. * Smaller footprint. * Improved performance since run-time indirection of internal symbols is no longer needed. No changes to the ACE/TAO sources were necessary to support this feature since the required visibility attributes were hidden behind the various "*_Export" macros (formerly only useful for MS Windows DLLs) used throughout ACE/TAO. . The ACE_Reactor destructor will now call close() on the referenced reactor implementation. This assures that all handlers are notified before the ACE_Reactor object that's most likely referenced in these handlers is invalid. Although this should not be a user-visible change, it did catch some ACE tests off guard destroying reactor implementations and ACE_Reactor interfaces in the wrong order, so it may come up in the field as well. When using dynamically allocated reactor implementations, do not destroy the implementation object before the ACE_Reactor interface object. Use of the ACE_Reactor constructor's delete_implementation argument (with a value of 1) is recommended when dynamically allocating reactor implementations. . Improved performance of HTBP by not requiring a lookup of peer hostname. . Added new ACE_SizeCDR stream which allows one to calculate size of the representation without writing anything. . Number of improvements in RMCast, reliable multicast implementation. USER VISIBLE CHANGES BETWEEN ACE-5.4.3 and ACE-5.4.4 ==================================================== . The ace-config script has been replaced by pkg-config metadata files which are installed in ${prefix}/lib/pkgconfig by the automake build. . Remove ACE_OS::gets() implementation. While this ACE implementation of gets() did not contain the security holes that all standard gets() implementations have, keeping it around only serves to foster confusion since (1) some may incorrectly assume that this ACE-specific gets() implementation has the same holes as standard ones, and (2) invoking it with a default size argument so that it looks like a standard gets() call results in behavior that is different from the standard. Use ACE_OS::fgets() instead. . Removed ACE_Unbounded_Set_Ex, this gave the false idea that it had thread safe iterators. Use ACE_Unbounded_Set instead . Improved VxWorks support for static libraries. Shared libraries do cause several known problems which will be fixed in the x.4.5 release. . Removed the usage of the ACE_x_cast macros, we are using the C++ casts from now on. The ACE_x_cast macros are deprecated and will be removed after the x.5.1 release . Some improvements in autoconf support; better detection of available OS and compiler features. . Fixed bugs in ACE TSS emulation USER VISIBLE CHANGES BETWEEN ACE-5.4.2 and ACE-5.4.3 ==================================================== . Improved Cygwin 1.5.12 support, 90% of the tests now succeed . Improved OpenVMS support. . Added ability to use fltk with Cygwin/MinGW . Added ACE_INT64 that defines a native 64 bit type. . Added 'q' as usable specifier for ACE_Log_Msg to print out int64 bit number. . Added better support for Intel C++ compilers. . Improved HPUX support. . Added a new directory ("ACE_wrappers/protocols/ace") for new protocols that are not directly components of ACE, but are relate to ACE and defined a new protocol, HTBP (Hypertext Tunneling, Bidirectional Protocol) providing ACE_Acceptor/Connector/Stream semantics over a connection owned by an HTTP proxy. Test cases in ACE_wrappers/tests/HTBP provide examples of use. . Performace enhancement in TP_Reactor's handle_timer_events method [Bug 1971]. . Various changes to permit ACE to execute on HP NonStop platform (e.g support for its pthreads version). . Updated HP NonStop configuration files (config-tandem-nsk). . The "ACE" pseudo-namespace is now a true C++ namespace. Transitional pseudo-namespaces that were only meant to be used internally by ACE, such as "ACE_Sock_Connect", no longer exist. . ACE_CDR::Boolean type is now a true C++ "bool" on all platforms except MSVC++ 6. We plan to deprecate MSVC++ 6 support sometime after the x.5 release of ACE+TAO+CIAO, so we recommend you start migrating to a later version of MSVC++. . More GNU g++ 3.4.x fixes. . Added ICMP and "ping" socket support. . Added mkstemp() emulation. . Fixed problem on Linux < 2.5.47 platforms where equality comparison of two logically equal sockaddr_in structure instances would incorrectly fail. . Support for wide characters has been improved on non-Windows platforms. . A number of Windows CE problems have been fixed. . ACE's loading of DLLs (for example, as a result of loading synamic services) has been changed to use the native OS's facilities for locating the DLL instead of searching LD_LIBRARY_PATH (or its equivalent) then loading the DLL using a full pathname. This restores enforcement of a platform's loading and security policy. To use the old DLL locating method, add ACE_MUST_HELP_DLOPEN_SEARCH_PATH to your config.h file before building ACE. . A number of errors in the APG example programs have been corrected. . Select_Reactor and Priority_Reactor performance improved. [Bug 1890] . Wide-char functionality on POSIX (Linux, etc.) . TSS memory leak fixes [Bug 1542] . Ported to HPUX 11i v2 on Itanium . Added code to ACE for platform RedHat AS 3.0 on Opteron. . Changed ACE::crc32() family of functions to NOT fold in the length of the string/buffer/iovec into the CRC. USER VISIBLE CHANGES BETWEEN ACE-5.4.1 and ACE-5.4.2 ==================================================== . Support for g++ 3.4.1. . All ACE Makefiles, project files, etc, are now generated by OCI's "MakeProjectCreator" (MPC) tool. Makefiles and project files for commonly used configurations have been pre-generated and distributed with the beta(s). Please see: $ACE_ROOT/ACE-INSTALL.html for information on how to use MPC with ACE. . Improved Doxygen documentation. . Reduced header file dependencies, which should speedup compilation and help minimize static footprint. . ACE now requires support for the following standard C++ features: - "bool" keyword - "mutable" keyword - "explicit" keyword - C++ casts (e.g. static_cast<>, reinterpret_cast<>, dynamic_cast<> and const_cast<>) If you're using a compiler that does NOT support these features please contact Steve Huston for support. . Changed the select()-based reactor implementations to scan for broken handles to remove based on the registered handles, not on event handlers. This allows for bad handles to be removed from the reactor even if the event handler doesn't implement get_handle() the way we expect. . Support for Pthreads native recursive mutexes was added. This capability is specified to ACE_OS::mutex_init() as an optional argument, lock_type. To fix confusion from an earlier attempt to add this functionality, the meaning of the old 'type' argument to ACE_OS::thread_mutex_init() is changed. It previously combined the scope and type. Now it is just the type (e.g. recursive), as the scope is inherent in the method used. For clarification on ACE_HAS_RECURSIVE_MUTEXES, it means that the platform is capable of them, not that they always are, as one would expect. However, before Pthreads had recursion added, it was never optional. Now it is. . Initial support for new Linux sys_epoll() interface in Dev_Poll_Reactor. The obsolete Linux /dev/epoll interface is no longer supported. . Improved Cygwin support. - Threading works without problems. - Problems with shared memory, process shared mutexes, multicast and some other small things still exist. . New OpenVMS port. - This is for the latest version of OpenVMS with all available ECOs applied. Basic stuff works without problems. Advanced features still need some work. . Usage of ASYS_INLINE is deprecated in ACE. Use ACE_INLINE instead. . All inline source files now end in ".inl". The previous ".i" extension is generally used for preprocessed C sources. . Autoconf support has been improved and fixed on a number of platforms, including the BSD variants (e.g. FreeBSD). It is still not the preferred way to configure most platforms, but it is ready for wider testing. Please report any problems found to ace-bugs@cs.wustl.edu. . A number of fixes were made to quiet compile errors and warnings on 64-bit Windows. . For builds on AIX using Visual Age C++, the make rtti option default was changed to 1, enabling RTTI by default. . ACE_Service_Repository::remove() has a new, optional argument that can receive the service record pointer for the removed service. If the pointer is returned to the caller, it is not deleted. If the pointer is not returned to the caller (the default) it is deleted (this is the historic behavior). . The tutorials in ACE_wrappers/docs have been removed. They were not being maintained and caused confusion in a number of cases. Now that there are complete examples that match the printed books (C++NPv1, C++NPv2, APG), the older tutorials are no longer useful. Please see $ACE_ROOT/examples/C++NPv1/ $ACE_ROOT/examples/C++NPv2/ $ACE_ROOT/examples/APG/ for the source code of the examples in those books. . ACE_String_Base::fast_clear() is a new method which sets the string length to 0. Doesn't release string-allocated memory, but if the memory was externally supplied, it is no longer referenced from the string object. . A true C++ "bool" is now used as the CDR stream boolean type, if supported by the compiler. . Renamed AIX 5L configuration header from config-aix5.1.h to config-aix-5.x.h. . All C++ equality, relational and logical operators now return bool instead of int, as is the norm for modern C++. . Added new ACE_OS::realpath() implementation. Contributed by Olli Savia USER VISIBLE CHANGES BETWEEN ACE-5.4 and ACE-5.4.1 ==================================================== ACE --- . Fixed "make install" support in ACE+autoconf configurations. . Fixed autoconf support on Solaris. . Corrected invalid `aux' directory (on MS Windows) found in ACE distribution. . ACE/TAO build now without problems with MinGW and all ACE tests run now without problems . Added some more support for the new CBuilderX Preview compiler, this is not 100% ready yet because the compiler is still a preview and has its own problems. . Added Visual SlickEdit 8.1 MPC template . Added workaround for compile problems in Borland Release builds . Cygwin 1.5.9 is now supported . Tests for IPV6 have been added . Implement lstat() so that it'll use stat() on platforms that don't support lstat(). . Problems related to ACE_Event_Handler usage in WFMO_Reactor was fixed. . A wrapper for rmdir () has been added. . Threads spawned in thread-per-connection mode never inherited the priority. This problem was fixed and this fix is consistent with the C++ NPV* books. . Fixed memory leaks with ACE_String_Base::resize () . Enable the usage of native recursive mutexes for the implementation of ACE recursive mutexes on Linux. . The ACE Proactor framework can now be enabled for AIX 5.2. Since AIO functionality is not run-time enabled by default on AIX 5.2, the ACE Proactor code is not built by default on AIX. To enable it, the config.h file must contain #define ACE_HAS_AIO_CALLS before including the config-aix-5.1.h file. . The ACE_POSIX_CB_Proactor implementation is now built on all platforms except LynxOS. USER VISIBLE CHANGES BETWEEN ACE-5.3.6 and ACE-5.4 ================================================== ACE: --- . Added a new makefile commandline flag, static_link, that can be used to force static linking when static_libs_only is turned on. It uses the new STATIC_LINK_FLAG variable and is currently only implemented for for GNU ld, i.e., it adds the "-static" option to LDFLAGS. It's turned off by default since using it causes the footprint to go up by almost 1 MB on Linux, since it links all the system and compiler .a files, but can be turned on if users want/need to use it, by enabling both static_libs_only and static_link. . Added macros ACE_USES_GPROF which enables users to use gprof in a multithreaded environment with ACE libs. . Added a new functor template class, ACE_Malloc_Lock_Adapter_T, that's used by ACE_Malloc_T as a factory for the ACE_LOCK template parameter, and allows the use of locking strategy classes, like ACE_Process_Semaphore and ACE_Thread_Semaphore that don't have a satisfactory ctor taking a single required ACE_TCHAR* parameter, to be adapted to work with ACE_Malloc_T. . The source code examples from "The ACE Programmer's Guide" book by Huston, Syyid, and Johnston, are now located in $ACE_ROOT/examples/APG. . Support for GNU autoconf is now in ACE. Please see ACE-INSTALL.html for details. . Fixed problems that prevented ACE from being compiled on LynxOS 4.0.0. . Fixed compilation error which prevented ACE from being compiled when ACE_COMPILE_TIMEPROBES was set to 1. . Preliminary support for Tandem NSK has been added. . Lots of bug fixes with TLI and XPG5. Please see $ACE_ROOT/ChangeLog for details. . Fixed ACE_OS::event_timedwait() and ACE_OS::event_wait() so that they use a while loop around the ACE_OS::cond_[timed]wait() calls to avoid problems with spurious wakeups, etc. . ACE's wrapper around getipnodebyname() and getipnodebyaddr () has been made go through the IPv4-only case on ACE_WIN32. Since Windows IPv6 implementation doesn't offer support (at thistime) for getipnodebyname() the code has been changed to use the IPV4 part of the code. . Install with Borland C++ of ACE library fixed ACEXML: ------- . Fixed memory leak in ACEXML parser. . Fixed implementations of rewind() in all the CharStreams. They were broken previously. . Fixed bugs in the parser associated with incorrect handling of PE References for keywords. ace-6.3.3+dfsg.orig/AUTHORS0000644000175000017500000000056612576461726015474 0ustar pgquilespgquilesDouglas C. Schmidt d.schmidt@vanderbilt.edu Professor of Computer Science Associate Chair of Computer Science and Engineering Department of Electrical Engineering and Computer Science Senior Researcher at the Institute for Software Integrated Systems (ISIS) Vanderbilt University Nashville, TN 37203 www.dre.vanderbilt.edu/~schmidt TEL: (615) 343-8197 FAX: (615) 343-7440 ace-6.3.3+dfsg.orig/ACEXML/0000775000175000017500000000000012576472436015370 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/examples/0000775000175000017500000000000012576472436017206 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/0000775000175000017500000000000012576472436020656 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/SAXPrint_Handler.inl0000644000175000017500000000030112576461726024457 0ustar pgquilespgquiles// -*- C++ -*- ACEXML_INLINE void ACEXML_SAXPrint_Handler::inc_indent (void) { this->indent_ += 1; } ACEXML_INLINE void ACEXML_SAXPrint_Handler::dec_indent (void) { this->indent_ -= 1; } ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/main.cpp0000644000175000017500000001326212576461726022310 0ustar pgquilespgquiles#include "ACEXML/common/FileCharStream.h" #include "ACEXML/common/HttpCharStream.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/common/ZipCharStream.h" #include "ACEXML/parser/parser/Parser.h" #include "Print_Handler.h" #include "SAXPrint_Handler.h" #include "ace/Get_Opt.h" #include "ace/Auto_Ptr.h" #include "ace/Log_Msg.h" #include "ace/OS_main.h" static const ACEXML_Char *test_string = ACE_TEXT (" A " "); static void usage (const ACE_TCHAR* program) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Usage: %s [-sl] [-f | -u | -z ]\n") ACE_TEXT (" -s: Use SAXPrint_Handler (Default is Print_Handler)\n") ACE_TEXT (" -l: Parse the internal strings (test the StrCharStream class)\n") ACE_TEXT (" -f: Specify the filename when -l is not specified\n") ACE_TEXT (" -z: Specify that the file is inside a ZIP archive\n") ACE_TEXT (" -u: URL specifying the path to the file\n"), program)); } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACEXML_Char* filename = 0; int sax = 0; // Use SAXPrint handler or not. int str = 0; #ifdef USE_ZZIP int zip = 0; #endif ACEXML_Char* url = 0; ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("sf:lu:z")); int c; while ((c = get_opt ()) != EOF) { switch (c) { case 's': sax = 1; break; case 'l': str = 1; break; case 'f': filename = get_opt.opt_arg (); break; case 'u': url = get_opt.opt_arg(); break; case 'z': #ifndef USE_ZZIP ACE_ERROR ((LM_ERROR, ACE_TEXT ("ZZIPLIB support has not been") ACE_TEXT (" compiled in. Refer to ") ACE_TEXT ("$ACE_ROOT/ACEXML/README for more ") ACE_TEXT ("information.\n"))); return -1; #else zip = 1; break; #endif /* USE_ZZIP */ default: usage(argv[0]); return -1; } } if (str == 0 && filename == 0 && url == 0) { usage(argv[0]); return -1; } ACEXML_DefaultHandler *handler = 0; ACEXML_CharStream *stm = 0; ACEXML_FileCharStream *fstm = 0; ACEXML_HttpCharStream *ustm = 0; ACEXML_StrCharStream* sstm = 0; #ifdef USE_ZZIP ACEXML_ZipCharStream* zstm = 0; #endif /* USE_ZZIP */ if (filename != 0) { #ifdef USE_ZZIP if (zip) { ACE_NEW_RETURN (zstm, ACEXML_ZipCharStream(), -1); if (zstm->open (filename) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Failed to open XML file: %s\n"), filename), -1); stm = zstm; } else { #endif /* USE_ZZIP */ ACE_NEW_RETURN (fstm, ACEXML_FileCharStream (), -1); if (fstm->open (filename) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Failed to open XML file: %s\n"), filename), -1); stm = fstm; #ifdef USE_ZZIP } #endif /* USE_ZZIP */ } else if (url != 0) { ACE_NEW_RETURN (ustm, ACEXML_HttpCharStream (), -1); if (ustm->open (url) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Failed to open URL : %s\n"), url), -1); stm = ustm; } else { ACE_NEW_RETURN (sstm, ACEXML_StrCharStream, -1); if (sstm->open (test_string, ACE_TEXT ("test_string")) < 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Failed to open string : %s\n"), test_string), -1); stm = sstm; } ACEXML_Char* name = (filename == 0) ? url : filename; if (sax == 0) ACE_NEW_RETURN (handler, ACEXML_Print_Handler (name), -1); else ACE_NEW_RETURN (handler, ACEXML_SAXPrint_Handler (name), -1); auto_ptr cleanup_handler (handler); ACEXML_Parser parser; ACEXML_InputSource input (stm); parser.setContentHandler (handler); parser.setDTDHandler (handler); parser.setErrorHandler (handler); parser.setEntityResolver (handler); try { parser.parse (&input); } catch (const ACEXML_Exception& ex) { ex.print(); ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n"))); } try { parser.parse (&input); } catch (const ACEXML_SAXException& ex) { ex.print(); ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n"))); return 1; } // ACEXML_TRY_EX (THIRD) // { // parser.parse (&input ACEXML_ENV_ARG_PARAMETER); // ACEXML_TRY_CHECK_EX (THIRD); // } // ACEXML_CATCH (ACEXML_SAXException, ex) // { // ex.print(); // ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n"))); // return 1; // } // ACEXML_ENDTRY; // ACEXML_TRY_EX (FOURTH) // { // parser.parse (&input ACEXML_ENV_ARG_PARAMETER); // ACEXML_TRY_CHECK_EX (FOURTH); // } // ACEXML_CATCH (ACEXML_SAXException, ex) // { // ex.print(); // ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Exception occurred. Exiting...\n"))); // return 1; // } // ACEXML_ENDTRY; return 0; } ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/simple.svcconf.xml0000644000175000017500000000224712576461726024334 0ustar pgquilespgquiles A & ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/SAXPrint.mpc0000644000175000017500000000011512576461726023022 0ustar pgquilespgquiles// -*- MPC -*- project(SAXPrint): aceexe, acexml { exename = SAXPrint } ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/broken.xml0000644000175000017500000000024412576461726022656 0ustar pgquilespgquiles kid ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/svc.conf.xml0000644000175000017500000000367712576461726023132 0ustar pgquilespgquiles ]> A & ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/SAXPrint_Handler.h0000644000175000017500000001047412576461726024140 0ustar pgquilespgquiles//============================================================================= /** * @file SAXPrint_Handler.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_SAXPRINT_HANDLER_H #define ACEXML_SAXPRINT_HANDLER_H #include "ACEXML/common/DefaultHandler.h" /** * @class ACEXML_SAXPrint_Handler * * @brief ACEXML_SAXPrint_Handler is an example SAX event handler. * * This SAX event handler try to regenerate the XML document it * reads with correct indentation. */ class ACEXML_SAXPrint_Handler : public ACEXML_DefaultHandler { public: /* * Default constructor. */ ACEXML_SAXPrint_Handler (const ACEXML_Char* name); /* * Default destructor. */ virtual ~ACEXML_SAXPrint_Handler (void); // Methods inherit from ACEXML_ContentHandler. /* * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length) ; /* * Receive notification of the end of a document. */ virtual void endDocument (void) ; /* * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /* * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix); /* * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length); /* * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data); /* * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator); /* * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name); /* * Receive notification of the beginning of a document. */ virtual void startDocument (void); /* * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts); /* * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri); // *** Methods inherit from ACEXML_DTDHandler. /* * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId); /* * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName); // Methods inherit from ACEXML_EnitityResolver. /* * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId); // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception); /* * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception); /* * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception); void inc_indent (); void dec_indent (); void print_indent (); private: size_t indent_; ACEXML_Char* fileName_; ACEXML_Locator* locator_; }; #if defined (__ACEXML_INLINE__) # include "SAXPrint_Handler.inl" #endif /* __ACEXML_INLINE__ */ #endif /* ACEXML_SAXPRINT_HANDLER_H */ ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/Print_Handler.cpp0000644000175000017500000001402212576461726024110 0ustar pgquilespgquiles// -*- C++ -*- #include "Print_Handler.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" ACEXML_Print_Handler::ACEXML_Print_Handler (ACEXML_Char* fileName) : fileName_(ACE::strnew (fileName)) { } ACEXML_Print_Handler::~ACEXML_Print_Handler (void) { delete[] this->fileName_; } void ACEXML_Print_Handler::characters (const ACEXML_Char *cdata, size_t start, size_t length) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event characters () ** start: %u end: %u ***************\n%s\n- End event characters () ---------------\n"), start, length, cdata)); } void ACEXML_Print_Handler::endDocument (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event endDocument () ***************\n"))); } void ACEXML_Print_Handler::endElement (const ACEXML_Char *uri, const ACEXML_Char *name, const ACEXML_Char *qName) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event endElement (%s, %s, %s) ***************\n"), uri, name, qName)); } void ACEXML_Print_Handler::endPrefixMapping (const ACEXML_Char *prefix) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"), prefix)); } void ACEXML_Print_Handler::ignorableWhitespace (const ACEXML_Char *, int, int) { // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("* Event ignorableWhitespace () ***************\n"))); } void ACEXML_Print_Handler::processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event processingInstruction (%s, %s) ***************\n"), target, data)); } void ACEXML_Print_Handler::setDocumentLocator (ACEXML_Locator * locator) { this->locator_ = locator; // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n"))); } void ACEXML_Print_Handler::skippedEntity (const ACEXML_Char *name) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event skippedEntity (%s) ***************\n"), name)); } void ACEXML_Print_Handler::startDocument (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event startDocument () ***************\n"))); } void ACEXML_Print_Handler::startElement (const ACEXML_Char *uri, const ACEXML_Char *name, const ACEXML_Char *qName, ACEXML_Attributes *alist) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event startElement (%s, %s, %s) ***************\n"), uri, name, qName)); if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %s = \"%s\"\n"), alist->getQName (i), alist->getValue (i))); } } void ACEXML_Print_Handler::startPrefixMapping (const ACEXML_Char * prefix, const ACEXML_Char * uri) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event startPrefixMapping () ***************\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri)); } // *** Methods inherit from ACEXML_DTDHandler. void ACEXML_Print_Handler::notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicID, const ACEXML_Char *systemID) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event notationDecl: (%s) "), name)); if (publicID == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SYSTEM %s\n"), systemID)); else if (systemID == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("PUBLIC %s\n"), publicID)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("PUBLIC %s %s\n"), publicID, systemID)); } void ACEXML_Print_Handler::unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicID, const ACEXML_Char *systemID, const ACEXML_Char *notationName) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Unparsed Entity: %s"), name)); if (publicID == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" SYSTEM %s"), systemID)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" PUBLIC %s %s"), publicID, systemID)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" NDATA %s\n"), notationName)); } // Methods inherit from ACEXML_EnitityResolver. ACEXML_InputSource * ACEXML_Print_Handler::resolveEntity (const ACEXML_Char *, const ACEXML_Char *) { // No-op. return 0; } // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ void ACEXML_Print_Handler::error (ACEXML_SAXParseException & ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_Print_Handler::fatalError (ACEXML_SAXParseException& ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_Print_Handler::warning (ACEXML_SAXParseException & ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/ns.svc.conf.xml0000644000175000017500000000251612576461726023540 0ustar pgquilespgquiles -d -p 4911 A &lt; -p 3000 -p 3001 ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/Print_Handler.h0000644000175000017500000001013212576461726023553 0ustar pgquilespgquiles//============================================================================= /** * @file Print_Handler.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_PRINT_HANDLER_H #define ACEXML_PRINT_HANDLER_H #include "ACEXML/common/DefaultHandler.h" /** * @class ACEXML_Print_Handler * * @brief ACEXML_Print_Handler is an example SAX event handler. * * This SAX event handler prints out a detailed event report * on every event it receives. */ class ACEXML_Print_Handler : public ACEXML_DefaultHandler { public: /* * Default constructor. */ ACEXML_Print_Handler (ACEXML_Char* fileName); /* * Default destructor. */ virtual ~ACEXML_Print_Handler (void); // Methods inherited from ACEXML_ContentHandler. /* * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length); /* * Receive notification of the end of a document. */ virtual void endDocument (void); /* * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /* * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix); /* * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length); /* * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data); /* * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator) ; /* * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name); /* * Receive notification of the beginning of a document. */ virtual void startDocument (void); /* * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts); /* * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri); // *** Methods inherit from ACEXML_DTDHandler. /* * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId); /* * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName); // Methods inherit from ACEXML_EnitityResolver. /* * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId); // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception); /* * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception); /* * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception); private: ACEXML_Char* fileName_; ACEXML_Locator* locator_; }; #endif /* ACEXML_PRINT_HANDLER_H */ ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/namespaces.xml0000644000175000017500000001201312576461726023512 0ustar pgquilespgquiles Vignesh Blogs Here http://primates.ximian.com/~ravi/BoozeLog/ en-us 2002-10-11T00:50:42-06:00 2002-10-12T20:19:57-06:00 Happy Birthday Vidya Today is Vidya's birthday ! Happy Birthday Vidya! We had a midnight party,as usual, at Swapna's place, though I dont... http://primates.ximian.com/~ravi/BoozeLog/archives/000025.html Blog entry Booze 2002-10-11T00:50:42-06:00 Way to go, Shaastra! On Flash Back mode now: Shaastra is the technical festival at my alma mater, IIT Madras, that replaced the old,... http://primates.ximian.com/~ravi/BoozeLog/archives/000024.html Blog entry Booze 2002-10-10T11:52:02-06:00 Back and Forth in Time The blog is going to be a little skewed in time for the next coupla days.. Inspite of my laziness,... http://primates.ximian.com/~ravi/BoozeLog/archives/000023.html Blog entry Booze 2002-10-09T23:47:19-06:00 Frisco Rocks! If there be any reason the blog hasnt been updated,it is simply because I am enjoying my trip to San... http://primates.ximian.com/~ravi/BoozeLog/archives/000020.html Blog entry Booze 2002-10-03T23:53:16-06:00 Think but not make thoughts your aim A line from Rudyard Kipling's IF : would sum up my feelings for today, a lot of thinking from morning... http://primates.ximian.com/~ravi/BoozeLog/archives/000013.html Blog entry Booze 2002-09-28T22:48:09-06:00 New ARM but... ARM stands for Advanced Recording Model, a simulation software that I use for my work, and I have been tinkering... http://primates.ximian.com/~ravi/BoozeLog/archives/000012.html Blog entry Booze 2002-09-27T22:36:28-06:00 A much needed break Slowly got over the hangover of Sandhya's departure and moved to more mundane things in life : assignments, submissions and... http://primates.ximian.com/~ravi/BoozeLog/archives/000011.html Blog entry Booze 2002-09-26T23:05:46-06:00 Here we go ! My first attempts at Blogging, the idea was introduced to me by Ravi Pratap. MoveableType really makes it easy and... http://primates.ximian.com/~ravi/BoozeLog/archives/000008.html Blog entry Booze 2002-09-25T19:27:22-06:00 ace-6.3.3+dfsg.orig/ACEXML/examples/SAXPrint/SAXPrint_Handler.cpp0000644000175000017500000001270612576461726024473 0ustar pgquilespgquiles// -*- C++ -*- #include "SAXPrint_Handler.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #if !defined (__ACEXML_INLINE__) # include "SAXPrint_Handler.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_SAXPrint_Handler::ACEXML_SAXPrint_Handler (const ACEXML_Char* filename) : indent_ (0), fileName_(ACE::strnew (filename)), locator_ (0) { // no-op } ACEXML_SAXPrint_Handler::~ACEXML_SAXPrint_Handler (void) { delete [] this->fileName_; } void ACEXML_SAXPrint_Handler::characters (const ACEXML_Char *cdata, size_t, size_t) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), cdata)); } void ACEXML_SAXPrint_Handler::endDocument (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); } void ACEXML_SAXPrint_Handler::endElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { this->dec_indent (); this->print_indent (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (""), qName)); } void ACEXML_SAXPrint_Handler::endPrefixMapping (const ACEXML_Char *) { // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("* Event endPrefixMapping (%s) ***************\n"), // prefix)); } void ACEXML_SAXPrint_Handler::ignorableWhitespace (const ACEXML_Char * cdata, int, int) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s"), cdata)); // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("* Event ignorableWhitespace () ***************\n"))); } void ACEXML_SAXPrint_Handler::processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data) { this->print_indent (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"), target, data)); } void ACEXML_SAXPrint_Handler::setDocumentLocator (ACEXML_Locator * locator) { this->locator_ = locator; //ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event setDocumentLocator () ***************\n"))); } void ACEXML_SAXPrint_Handler::skippedEntity (const ACEXML_Char *name) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event skippedEntity (%s) ***************\n"), name)); } void ACEXML_SAXPrint_Handler::startDocument (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("* Event startDocument () ***************\n"))); } void ACEXML_SAXPrint_Handler::startElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName, ACEXML_Attributes *alist) { this->print_indent (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("<%s"), qName)); if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %s = \"%s\""), alist->getQName (i), alist->getValue (i))); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT (">"))); this->inc_indent (); } void ACEXML_SAXPrint_Handler::startPrefixMapping (const ACEXML_Char * , const ACEXML_Char *) { // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("* Event startPrefixMapping () ***************\n"))); // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("Prefix = %s, URI = %s\n"), prefix, uri)); } // *** Methods inherited from ACEXML_DTDHandler. void ACEXML_SAXPrint_Handler::notationDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } void ACEXML_SAXPrint_Handler::unparsedEntityDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } // Methods inherited from ACEXML_EnitityResolver. ACEXML_InputSource * ACEXML_SAXPrint_Handler::resolveEntity (const ACEXML_Char *, const ACEXML_Char *) { // No-op. return 0; } // Methods inherited from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ void ACEXML_SAXPrint_Handler::error (ACEXML_SAXParseException & ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_SAXPrint_Handler::fatalError (ACEXML_SAXParseException & ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_SAXPrint_Handler::warning (ACEXML_SAXParseException & ex) { ACE_DEBUG ((LM_DEBUG, "%s: line: %d col: %d ", (this->locator_->getSystemId() == 0 ? this->fileName_ : this->locator_->getSystemId()), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_SAXPrint_Handler::print_indent (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); for (size_t i = 0; i < this->indent_; ++i) ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" "))); } ace-6.3.3+dfsg.orig/ACEXML/ChangeLog0000644000175000017500000012406112576461726017144 0ustar pgquilespgquilesTue Feb 28 03:03:38 UTC 2012 Douglas C. Schmidt * parser/parser/Parser.cpp (ACEXML_Parser::parse_reference_name): Expression 'ch != '_' || ch != ':'' is always true. Used the '&&' operator instead. Thanks to Andrey Karpov for reporting this. Fri Oct 21 09:50:19 UTC 2011 Johnny Willemsen * parser/parser/Parser.cpp: Initialise variable with 0 Fri Oct 21 09:48:21 UTC 2011 Johnny Willemsen * common/Attributes.h: * common/AttributesImpl.h: * common/Attributes_Def_Builder.h: * common/CharStream.h: * common/ContentHandler.h: * common/DTDHandler.h: * common/DTD_Manager.h: * common/DefaultHandler.h: * common/Element_Def_Builder.h: * common/Encoding.h: * common/EntityResolver.h: * common/ErrorHandler.h: * common/Exception.h: * common/HttpCharStream.h: * common/InputSource.h: * common/Locator.h: * common/LocatorImpl.h: * common/Mem_Map_Stream.h: * common/NamespaceSupport.h: * common/SAXExceptions.h: * common/StrCharStream.h: * common/StreamFactory.h: * common/Transcode.h: * common/URL_Addr.h: * common/Validator.h: * common/XMLFilterImpl.h: * common/XMLReader.h: Doxygen changes, fix some Klocwork reports Tue Aug 3 16:50:57 UTC 2010 Johnny Willemsen * common/DTD_Manager.h: Fixed compile error * common/SAXExceptions.inl: Fixed fuzz Tue Aug 3 11:58:06 UTC 2010 Johnny Willemsen * common/Makefile.am: * common/common.mpc: Updated because of the removed files Tue Aug 3 11:52:06 UTC 2010 Johnny Willemsen * apps/svcconf/Svcconf.cpp: * apps/svcconf/Svcconf_Handler.h: * apps/svcconf/Svcconf_Handler.cpp: * common/Attributes_Def_Builder.h: * common/CharStream.h: * common/ContentHandler.h: * common/DTDHandler.h: * common/DTD_Manager.h: * common/DefaultHandler.h: * common/DefaultHandler.cpp: * common/Element_Def_Builder.h: * common/EntityResolver.h: * common/ErrorHandler.h: * common/Exception.h: * common/SAXExceptions.inl: * common/Validator.h: * common/XMLFilterImpl.h: * common/XMLFilterImpl.cpp: * common/XMLReader.h: * examples/SAXPrint/Print_Handler.h: * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.h: * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/main.cpp: * parser/debug_validator/Debug_Attributes_Builder.h: * parser/debug_validator/Debug_Attributes_Builder.cpp: * parser/debug_validator/Debug_DTD_Manager.h: * parser/debug_validator/Debug_DTD_Manager.cpp: * parser/debug_validator/Debug_Element_Builder.h: * parser/debug_validator/Debug_Element_Builder.cpp: * parser/parser/Parser.h: * parser/parser/Parser.cpp: * tests/ContentHandler_Test.cpp: * tests/Transcoder_Test.cpp: Removed support for emulated exceptions * common/Env.h: * common/Env.inl: * common/Env.cpp: * common/XML_Macros.h: Removed these files. Thu Mar 25 19:41:57 UTC 2010 Douglas C. Schmidt * parser/parser/Parser.cpp (ACEXML_Parser::parse_encoding_decl): Changed ACE_OS::strcmp() to ACE_OS::strcasecmp(). Thanks to Tim Pinkawa for reporting this. Tue Oct 13 09:37:48 UTC 2009 Johnny Willemsen * apps/svcconf/Svcconf_Handler.cpp: Fixed compile problems with unicode enabled. Thanks to Christian Freund for reporting this. This fixes bugzilla 3745. Mon Jul 30 08:38:12 UTC 2007 Johnny Willemsen * apps/svcconf/Svcconf_Handler.cpp: Layout changes Mon Jul 16 10:19:51 UTC 2007 Abdullah Sowayan * apps/svcconf/Svcconf_Handler.h: * apps/svcconf/Svcconf_Handler.cpp: * common/Attributes_Def_Builder.h: * common/ContentHandler.h: * common/DTDHandler.h: * common/DefaultHandler.h: * common/DefaultHandler.cpp: * common/Element_Def_Builder.h: * common/EntityResolver.h: * common/ErrorHandler.h: * common/Validator.h: * common/XMLFilterImpl.h: * common/XMLFilterImpl.cpp: * common/XMLReader.h: * examples/SAXPrint/Print_Handler.h: * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.h: * examples/SAXPrint/SAXPrint_Handler.cpp: * parser/debug_validator/Debug_Attributes_Builder.h: * parser/debug_validator/Debug_Attributes_Builder.cpp: * parser/debug_validator/Debug_Element_Builder.h: * parser/debug_validator/Debug_Element_Builder.cpp: * parser/parser/Parser.h: * parser/parser/Parser.cpp: * tests/ContentHandler_Test.cpp: Fixed Fuzz warnings. Zap the usage of exception specification. Sun Jun 3 20:02:32 UTC 2007 Olli Savia * common/FileCharStream.cpp: Replaced ungetc with ACE_OS::ungetc. Fri May 18 02:50:42 UTC 2007 Abdullah Sowayan * common/Mem_Map_Stream.cpp: It makes no sense to have code after a return statement (such as ACE_ERROR_RETURN). It causes some builds to have "statement is unreachable" warning. * examples/SAXPrint/main.cpp: Enhanced the "#ifndef" macros used to avoid "statement is unreachable" warning. Tue May 15 17:36:23 UTC 2007 Johnny Willemsen * parser/parser/ParserInternals.h: Removed msg_ member, it is not used at all. Thanks to Rajiv K. Shukla for reporting this Tue Feb 27 21:15:23 UTC 2007 Ossama Othman * common/FileCharStream.cpp (open): s/ACE_Utils::Truncate/ACE_Utils::truncate_cast/g. The former is deprecated. Tue Feb 20 17:26:28 UTC 2007 Krishnakumar B * common/InputSource.cpp: * parser/parser/ParserContext.h: * parser/parser/ParserContext.inl: Use std::swap instead of ACE_Swap Tue Feb 13 20:17:28 UTC 2007 Krishnakumar B * apps/svcconf/Svcconf_Handler.cpp: Fixed a problem with ACE_Module getting unloaded prematurely due to ACEXML_Svcconf_Handler failing to register it with the service repository. Thanks to gzeleniy@gmail.com for providing the fix. Wed Jan 03 14:20:00 UTC 2007 Simon Massey * common/XML_Macros.h: With MFC, must delete any caught and eaten "out of memory" exceptions. Fri Oct 28 02:29:57 UTC 2006 Ossama Othman From Russell Mora * common/ContentHandler.h: * common/DefaultHandler.h: * common/DefaultHandler.cpp: * common/FileCharStream.cpp: * common/FileCharStream.h: * common/HttpCharStream.cpp: * common/HttpCharStream.h: * common/Mem_Map_Stream.cpp: * common/Mem_Map_Stream.h: * common/XMLFilterImpl.cpp: * common/XMLFilterImpl.h: * common/ZipCharStream.cpp: * common/ZipCharStream.h: * common/StrCharStream.cpp: * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/Print_Handler.h: * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.h: * parser/parser/Parser.cpp: * parser/parser/Parser.h: * tests/ContentHandler_Test.cpp: Added support for 64-bit file offsets. Addressed 64-bit conversion warnings. Tue Oct 24 18:00:15 UTC 2006 Ossama Othman * common/common.mpc: * parser/parser/parser.mpc: Re-disabled ACEXML when ace_for_tao is enabled. ACEXML needs the ACE_Configuration and memory map classes that are not found in the ace_for_tao subset. Mon Oct 24 02:26:32 UTC 2006 Ossama Othman * common/common.mpc: * parser/parser/parser.mpc: No longer any need to explicitly disable ACEXML in the ace_for_tao configuration. * common/HttpCharStream.cpp: Fixed Coverity OVERRUN_STATIC and FORWARD_NULL errors. Improved const-correctness. * common/codecs.mpb: Disable ACEXML codecs support if ace_for_tao is enabled. * common/Mem_Map_Stream.cpp: Fixed Coverity NEGATIVE_RETURNS error. * common/SAXExceptions.cpp (_downcast): Removed redundant type checking code. (~ACEXML_SAXNotSupportedException): (~ACEXML_SAXNotRecognizedException): Addressed Coverity USE_AFTER_FREE errors. (exception_name_): * common/SAXExceptions.h (exception_name_): Declare this static constant as an array rather than a pointer. Allows the compiler to perform additional optimizations. Tue Jun 20 08:23:12 UTC 2006 Johnny Willemsen * parser/parser/Parser.cpp: 64bit fix Thu Mar 30 13:14:12 UTC 2006 Johnny Willemsen * common/NamespaceSupport.cpp: Fixed value might be unitialized warnings Tue Mar 14 20:58:12 UTC 2006 jiang,shanshan * common/FileCharStream.cpp * common/HttpCharStream.cpp * common/Transcode.cpp * common/XML_Macros.h * parser/parser/Parser.cpp * parser/parser/Parser.i Updated these files to solve the warnings when setting up "VC level 4 warnings" on Windows. These warnings include "unreachable code", "assignment within conditional expression", "conversion from some type to another type, possible loss of data", "local variable may be used without having been initialized" and so on. Thanks to Lukas Gruetzmacher for motivating the fix to these "VC level 4 warnings". Fri Feb 10 23:45:14 UTC 2006 Steve Huston * common/NamespaceSupport.cpp: Add missing template instantiations to match change below. Fri Feb 10 12:22:12 UTC 2006 Johnny Willemsen * common/NamespaceSupport.cpp: Fixed compile error in unicode build Thu Feb 9 22:49:18 UTC 2006 Krishnakumar B * common/NamespaceSupport.h: * common/NamespaceSupport.cpp: Use a normal ACE_Unbounded_Stack instead of yet another custom stack. * parser/parser/Parser.h: * parser/parser/Parser.cpp: Fixed a mismatched push/pop of the namespace context due to popping namespace contexts without matching the end of the element that caused a push. This resulted in more pops that push and corrupting the memory. Also fixed an indirection into a pointer that might have been corrupt when calling startNamespacePrefix(). Tue Jan 24 23:09:08 UTC 2006 Krishnakumar B * apps/svcconf/Svcconf.cpp: * apps/svcconf/Svcconf.h: Removed the overridden operator new/delete. I don't think that they serve any purpose, and end up hiding the default variations. Mon Jan 23 14:11:12 UTC 2006 Johnny Willemsen * common/ZipCharStream.h: Updated include of zziplib.h to zzip/zzip.h to get rid of deprecated warnings Wed Jan 4 22:44:38 UTC 2006 J.T. Conklin * ChangeLog: Untabify. Delete-trailing-whitespace. Changed "add-log-time-format" to a really ugly lambda expression that formats changelog timestamps in UTC and works with both GNU Emacs and XEmacs. Thu May 26 07:35:12 UTC 2005 Johnny Willemsen * common/XML_Util.h: Fixed pragma once warning Tue May 24 18:39:02 2005 J.T. Conklin * common/Makefile.am: Regenerate. * common/common.mpc: Added XML_Util.h to Header_Files section. Tue May 24 09:18:34 2005 Justin Michel * tests/util/test.cpp: Fixed for loop scoping problem for non-standard compilers. Mon May 23 14:52:19 2005 Justin Michel * tests/util/util.mpc: Add missing $ Id tag. Mon May 23 13:02:25 2005 Justin Michel * common/XML_Util.h: * common/XML_Util.cpp: Added new ACEXML_escape_string() functions to allow replacement of illegal characters, (', ", &, <, >, etc.) with the escaped versions. (", <, etc.) * tests/util/test.cpp: * tests/util/util.mpc: This is a performance test used while making the above functions, and testing performance with ACE_String_Base. Fri Apr 22 21:34:19 2005 Ossama Othman * parser/parser/Parser.cpp (parse_entity_decl): Fixed "variable may be used uninitialized" warning. Fri Apr 22 11:09:59 2005 J.T. Conklin * parser/parser/Makefile.am: * common/Makefile.am: Regenerated. * parser/parser/parser.mpc: * common/common.mpc: Add Pkgconfig_Files section. Wed Apr 20 12:20:26 2005 Ossama Othman * common/Attributes.h: * common/ContentHandler.h: * common/DTDHandler.h: * common/EntityResolver.h: * common/ErrorHandler.h: * common/Locator.h: * common/XMLReader.h: Added virtual destructors to address g++ 4.0 warnings. * common/Attributes.cpp: * common/ContentHandler.cpp: * common/DTDHandler.cpp: * common/EntityResolver.cpp: * common/ErrorHandler.cpp: * common/Locator.cpp: * common/XMLReader.cpp: New files containing destructors. * common/NamespaceSupport.cpp (getURI): Fixed "variable may be used uninitialized" warning. Mon Apr 18 14:10:12 UTC 2005 Johnny Willemsen * parser/parser/Entity_Manager.cpp: Removed not uses static const * parser/parser/Entity_Manager.i: Initialise pointer with 0 Sun Feb 13 23:54:25 2005 Ossama Othman From Lothar Werzinger * apps/svcconf/Svcconf_Handler.cpp: Enhanced error messages. Wed Jan 5 14:08:12 UTC 2004 Johnny Willemsen * common/DefaultHandler.{h,cpp,i}: * common/NamespaceSupport.{h,cpp,i}: * common/Transcode.{h,cpp,i}: * examples/SAXPrint/Print_Handler.{cpp,i}: Removed .i file and updated h/cpp file * common/Makefile.am: Updated Tue Aug 17 19:07:11 2004 J.T. Conklin * common/NamespaceSupport.cpp: Changed ACE_NEW_RETURN to use "NS_Node_T" instead of "struct NS_Node_T" --- the latter triggers a gcc 3.3 parser bug when used with the "new (std::nothrow)" version of ACE_NEW_RETURN. Fortunately, the "struct" is unnecessary. Sat Feb 21 23:51:25 2004 Krishnakumar B * common/Exception.h: * common/Exception.cpp: * common/SAXExceptions.h: * common/SAXExceptions.cpp: Fixed a few bugs in the way the exceptions were set-up in the case when exceptions=0. Provided implementations for operator assignment and duplicate(). This should fix problems with throwing and catching exceptions when exceptions=0. Sat Jan 31 20:06:57 2004 Krishnakumar B * parser/parser/Parser.cpp (parse_PE_reference): Added ACE_TEXT to satisfy WCHAR windows builds. Thanks to Johnny for reporting these errors. Fri Jan 30 16:04:43 2004 Krishnakumar B * parser/parser/Parser.cpp: Rewrote a simple string manipulation involving ACE_String_Base::operator +() to use const char* instead of char, so that we don't need an explicit template instantiation for it. * examples/SAXPrint/main.cpp: Added missing explicit template instantiations for ACE_Auto_Basic_Ptr. Thanks to Olli Savia for reporting problems with explicit template instantiation on LynxOS. Thu Jan 8 18:40:34 2004 Krishnakumar B * common/CharStream.h: Added a new rewind() method so that we can reuse the same parser instance to parse the same file multiple times. * common/FileCharStream.cpp: * common/HttpCharStream.h: * common/HttpCharStream.cpp: * common/StrCharStream.cpp: * common/ZipCharStream.cpp: Fixed implementation of rewind(). * common/Mem_Map_Stream.cpp: Fixed memory leak caused by the Svc_Handler not getting deleted. * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser: * parser/parser/Makefile.ACEXML_Parser: * examples/SAXPrint/Makefile.SAXPrint: * common/Makefile.ACEXML: * tests/Makefile.ContentHandler_Test: * tests/Makefile.HttpCharStream_Test: * tests/Makefile.NamespaceSupport_Test: * tests/Makefile.Transcoder_Test: Updated dependencies. * examples/SAXPrint/main.cpp: Added code to test the parser to parse the same file multiple times. This still needs some cleaning. * parser/parser/Entity_Manager.h: * parser/parser/Entity_Manager.i: * parser/parser/Entity_Manager.cpp: Use a pointer to ACE_Hash_Map_Manager_Ex and delete it on every reset() of the Entity_Manager. This should fix all the problems with SIGFPE's when we try to recover from a parse error. * parser/parser/Parser.cpp: * parser/parser/ParserContext.h: * parser/parser/ParserContext.inl: Fixed memory leaks reported by Ken Sedgewick . This should fix Bugzill bug 1694. While at it, fix bugs in handling of entity references in INCLUDE/IGNORE sections, ATTLIST sections. Thu Dec 18 13:13:57 2003 Krishnakumar B * common/Transcode.h (ACEXML_Transcoder): * common/Transcode.cpp (ACEXML_Transcoder): Renamed the ACEXML_Transcoder::STATUS enum to use ACEXML prefixes. Thanks to Johnny Willemsen for reporting the clash with native #defines on Tru64. Sat Jul 19 18:38:50 UTC 2003 Don Hinton * apps/svcconf/Svcconf.h: * common/*.h: * parser/*.h: * parser/parser/*.h: Added "/**/" between the #include and filename for pre.h and post.h so Doxygen won't include them in the file reference tree graphs. Fri Jul 18 10:29:55 2003 Krishnakumar B * tests/NamespaceSupport_Test.cpp (ACE_TMAIN): Added initialization of ACEXML_NamespaceSupport so that we don't crash. * tests/ContentHandler_Test.cpp: Removed "" at the end of the ACEXML_StrCharStream. XML is not HTML. Added a print statement to the catch clause so that we know what is happening when exception occurs. Mon Jul 14 18:49:01 UTC 2003 Johnny Willemsen * apps/svcconf/Makefile: * common/Makefile: * examples/SAXPrint/Makefile: * parser/parser/Makefile: * tests/Makefile: Removed windows specific rules. They are not needed and only cause problems when using a different command shell then cmd like msys. This solves errors in the MinGW build. Sat Jul 5 13:33:36 UTC 2003 Johnny Willemsen * Makefile: Removed windows specific rules. They are not needed and only cause problems when using a different command shell then cmd like msys. This solves errors in the MinGW build. Fri Jun 27 12:55:33 UTC 2003 Johnny Willemsen * parser/parser/Entity_Manager.h: * parser/parser/Entity_Manager.i: Removed not useful const return qualifier to resolve intel compiler warnings. Thu Jun 26 01:47:03 UTC 2003 Don Hinton * parser/parser/Parser.i: Added (int) cast to table index to get rid of a warning. Tue Jun 24 23:31:44 2003 Nanbor Wang * apps/svcconf/Svcconf.cpp: Turned off validation temporarily when handling svc.conf files. All of the converted svc.conf.xml files do not have associate doctype at the moment. Tue Jun 24 15:38:49 UTC 2003 Don Hinton * common/NamespaceSupport.i: Added include of ACE.h. Sun Jun 1 09:09:22 2003 Balachandran Natarajan * parser/parser/Parser.cpp: * parser/parser/Entity_Manager.cpp: Added explicit template instantiations. Fri May 30 14:16:33 2003 Krishnakumar B * examples/svcconf/.depend.Makefile.Svcconf: * examples/svcconf/Makefile: * examples/svcconf/Makefile.Svcconf: * examples/svcconf/Makefile.Svcconf.bor: * examples/svcconf/Makefile.bor: * examples/svcconf/README: * examples/svcconf/Svcconf.dsp: * examples/svcconf/Svcconf.dsw: * examples/svcconf/Svcconf.mpc: * examples/svcconf/Svcconf_Handler.cpp: * examples/svcconf/Svcconf_Handler.h: * examples/svcconf/Svcconf_Handler.i: * examples/svcconf/main.cpp: Removed directories causing problems with Win XP release. * ACEXML.dsw: * Makefile: * Makefile.bor: * apps/svcconf/Makefile: * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser.bor: * apps/svcconf/Makefile.bor: * common/Makefile: * common/Makefile.ACEXML.bor: * common/Makefile.bor: * examples/SAXPrint/Makefile: * examples/SAXPrint/Makefile.SAXPrint.bor: * examples/SAXPrint/Makefile.bor: * parser/parser/Makefile: * parser/parser/Makefile.ACEXML_Parser.bor: * parser/parser/Makefile.bor: * tests/.depend.Makefile.ContentHandler_Test: * tests/.depend.Makefile.HttpCharStream_Test: * tests/.depend.Makefile.NamespaceSupport_Test: * tests/.depend.Makefile.Transcoder_Test:: * tests/Makefile: * tests/Makefile.ContentHandler_Test: * tests/Makefile.ContentHandler_Test.bor: * tests/Makefile.HttpCharStream_Test.bor: * tests/Makefile.NamespaceSupport_Test.bor: * tests/Makefile.Transcoder_Test.bor: * tests/Makefile.bor: More build related delicacies needed updating because of the previous change. Fri May 30 13:56:40 2003 Krishnakumar B * common/XML_Common.dsp: Removed old dsp left over from previous merge. Fri May 30 13:54:57 2003 Krishnakumar B * parser/parser/Parser.dsp: Removed this erroneous dsp file left over from the merge. Fri May 30 13:50:11 2003 Krishnakumar B * common/ZipCharStream.h: Removed broken logic to undefine macro version of read. We don't want read to be a macro in ACEXML. Present because of brokenness in ZZIPLIB. Fri May 30 13:36:39 2003 Krishnakumar B * parser/parser/Parser.cpp (parse_ignoresect): Fixed a couple of warnings. Break out of infinite loop. * apps/svcconf/.depend.Makefile.ACEXML_XML_Svc_Conf_Parser: * common/.depend.Makefile.ACEXML: * examples/SAXPrint/.depend.Makefile.SAXPrint: * examples/svcconf/.depend.Makefile.Svcconf: * parser/parser/.depend.Makefile.ACEXML_Parser: Added missing dependency files. This should clear out the red. * examples/svcconf/main.cpp: * common/HttpCharStream.cpp: * parser/parser/Parser.i: Fixed warnings with BCB. Thanks to Johnny for reporting these. Thu May 29 23:13:40 2003 Krishnakumar B * examples/SAXPrint/SAXPrint_Handler.cpp: Fixed some minor warnings. Thu May 29 23:09:27 2003 Krishnakumar B * parser/parser/Makefile.Parser: Removed extra file left over by mistake. Thu May 29 23:00:24 2003 Krishnakumar B * tests/Makefile.ContentHandler_Test: * tests/Makefile: This file got left out by mistake during the big merge. Thu May 29 22:03:40 2003 Krishnakumar B * ACEXML.mwc: * ChangeLog: * apps/svcconf/ACEXML_XML_Svc_Conf_Parser.dsp: * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser: * apps/svcconf/Makefile.ACEXML_XML_Svc_Conf_Parser.bor: * common/ACEXML.dsp: * common/Makefile.ACEXML: * common/Makefile.ACEXML.bor: * examples/SAXPrint/Makefile.SAXPrint: * examples/SAXPrint/Makefile.SAXPrint.bor: * examples/svcconf/Makefile: * examples/svcconf/Makefile.Svcconf: * examples/svcconf/Makefile.Svcconf.bor: * examples/svcconf/Svcconf.mpc: * parser/parser/ACEXML_Parser.dsp: * parser/parser/Makefile.ACEXML_Parser: * parser/parser/Makefile.ACEXML_Parser.bor: * parser/parser/Makefile.Parser: * tests/Makefile.ContentHandler_Test.bor: * tests/Makefile.HttpCharStream_Test: * tests/Makefile.HttpCharStream_Test.bor: * tests/Makefile.NamespaceSupport_Test: * tests/Makefile.NamespaceSupport_Test.bor: * tests/Makefile.Transcoder_Test: * tests/Makefile.Transcoder_Test.bor: New files to build ACEXML generated using MPC. * apps/svcconf/svcconf.dtd: Moved the DTD from a hidden location to a prominent one. * examples/SAXPrint/namespaces.xml: New file to test namespace support. * common/ZipCharStream.cpp: * common/ZipCharStream.h: New files to support reading files from within a ZIP archive as a stream. * parser/parser/ParserContext.cpp: * parser/parser/ParserContext.h: * parser/parser/ParserContext.inl: New files to support a per stream context encountered when parsing references. * parser/parser/ParserInternals.cpp: * parser/parser/ParserInternals.h: Move some common functions from Parser.cpp to these files. * ACEXML.dsw: * Makefile: * Makefile.bor: * apps/svcconf/Makefile: * apps/svcconf/Makefile.bor: * common/Makefile: * common/Makefile.bor: * examples/SAXPrint/Makefile: * examples/SAXPrint/Makefile.bor: * examples/SAXPrint/SAXPrint.dsp: * examples/SAXPrint/SAXPrint.mpc: * examples/svcconf/Makefile.bor: * examples/svcconf/Svcconf.dsp: * parser/parser/Makefile: * parser/parser/Makefile.bor: * tests/ContentHandler_Test.cpp: * tests/ContentHandler_Test.dsp: * tests/HttpCharStream_Test.cpp: * tests/HttpCharStream_Test.dsp: * tests/Makefile: * tests/Makefile.bor: * tests/NamespaceSupport_Test.dsp: * tests/Transcoder_Test.dsp: Build related files changed with the introduction of MPC to build ACEXML. * examples/SAXPrint/ns.svc.conf.xml: * examples/SAXPrint/svc.conf.xml: New files to test specific features of the parser. * apps/svcconf/Svcconf.cpp: * common/Attributes.h: * common/Attributes_Def_Builder.h: * common/CharStream.h: * common/DefaultHandler.cpp: * common/Encoding.cpp: * common/Encoding.h: * common/Exception.cpp: * common/FileCharStream.cpp: * common/FileCharStream.h: * common/HttpCharStream.cpp: * common/HttpCharStream.h: * common/InputSource.cpp: * common/InputSource.h: * common/LocatorImpl.cpp: * common/LocatorImpl.h: * common/Mem_Map_Stream.cpp: * common/NamespaceSupport.cpp: * common/NamespaceSupport.h: * common/SAXExceptions.cpp: * common/StrCharStream.cpp: * common/StrCharStream.h: * common/StreamFactory.cpp: * common/Transcode.cpp: * common/Transcode.h: * common/Transcode.i: * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/main.cpp: * examples/svcconf/main.cpp: * parser/parser/Parser.cpp: * parser/parser/Parser.h: * parser/parser/Parser.i: * parser/parser/Entity_Manager.cpp: * parser/parser/Entity_Manager.h: * parser/parser/Entity_Manager.i: Merge from the Validator branch. It is not close to conformance related to Validation but is quite stable as a parser which recognizes the complete XML grammar. Fri Jan 24 20:28:22 2003 Krishnakumar B * parser/parser/Parser.cpp (pop_context): Bail out if there is only one element on the context stack. Bad things [TM] will happen if we pop the only context available. Mon Nov 25 04:25:15 2002 Krishnakumar B * parser/parser/Parser.cpp (reset): * parser/parser/Parser.h: Fixed a bunch of compilation errors. Removed unnecessary creation and destroyal of ACEXML_Strings which seems to speed up the parser quite a bit. * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/main.cpp: Don't report startPrefixMapping() and endPrefixMapping() as they obstruct the pretty-printing of SAXPrint. They are bogus anyway. Wed Nov 20 22:58:12 2002 Krishnakumar B * parser/parser/Parser.cpp (parse_char_reference): Fixed stupid thinko in conditional parsing of a hex character reference. * common/Mem_Map_Stream.cpp: We can use the old way of fetching on-demand and don't need to use a while loop. * common/NamespaceSupport.cpp: Fixed a long-standing bug with core dumping. With these changes, we are able to parse the XML specification itself. Is this called Meta or what ? Wed Nov 20 20:44:56 2002 Krishnakumar B * common/Mem_Map_Stream.cpp (grow_file_and_remap): Fixed bug where we were trying to remap two different files at the same location without closing the first. * common/HttpCharStream.cpp (get_url): Don't try to parse an empty file. Removes a nasty SIGSEGV. Wed Nov 20 01:06:26 2002 Krishnakumar B * common/Mem_Map_Stream.cpp: Minor indenting changes. * tests/HttpCharStream_Test.cpp: Modified test to show bug in ACE_File_Addr. Tue Nov 19 20:46:35 2002 Krishnakumar B * examples/SAXPrint/Print_Handler.cpp (warning): Missed syncing the function prototypes last time. Tue Nov 19 20:18:09 2002 Krishnakumar B * parser/parser/Parser.h: * parser/parser/Parser.cpp (normalize_systemid): Fix an off-by-one error in normalization. The document's base URI is never empty. Now we parse relative document URI correctly. Implement the previously unimplemented parsing from a systemId. * common/InputSource.cpp: * common/InputSource.h: Implement creating an InputSource from a systemId. * common/CharStream.h: Added a new method getSystemId(). * common/FileCharStream.cpp: * common/FileCharStream.h: * common/HttpCharStream.cpp: * common/HttpCharStream.h: * common/ZipCharStream.cpp: * common/ZipCharStream.h: * common/StrCharStream.cpp: * common/StrCharStream.h: Added implementation for getSystemId(). * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.cpp: Synched up the printing of exception messages. * examples/SAXPrint/main.cpp: Fixed broken internal string version of a sample XML file. Tue Nov 19 15:02:06 2002 Krishnakumar B * apps/svcconf/XML_Svc_Conf_Parser.dsp: * common/XML_Common.dsp: * examples/SAXPrint/SAXPrint.dsp: * parser/debug_validator/Debug_Validator.dsp: * parser/parser/Parser.dsp: Modified to accomodate zlib and zziplig. Will probably change before the merge. * parser/parser/Parser.cpp: Try to parse external DTD only if validation is required. Mon Nov 18 22:29:39 2002 Krishnakumar B * Makefile: Deleted this file in the previous check-in. Re-add it. Mon Nov 18 22:19:47 2002 Krishnakumar B * common/common.mpc: * parser/parser/parser.mpc: * parser/debug_validator/validator.mpc: * apps/svcconf/svcconf.mpc: * examples/svcconf/Svcconf.mpc: * examples/SAXPrint/saxprint.mpc: * tests/tests.mpc: * ACEXML.mwc: New MPC files and Workspace file. * common/Makefile.XML_Common: * apps/svcconf/Makefile.XML_Svc_Conf_Parser: * parser/parser/Makefile.Parser: * parser/debug_validator/Makefile.Validator: * examples/SAXPrint/Makefile.SAXPrint: * examples/svcconf/Makefile.Svcconf: * tests/Makefile.HttpCharStream_Test: * tests/Makefile.NamespaceSupport_Test: * tests/Makefile.Transcoder_Test: New Makefiles generated by MPC. * common/Makefile: * parser/parser/Makefile: * parser/Makefile: * examples/Makefile: * apps/Makefile: * apps/svcconf/Makefile: * examples/SAXPrint/Makefile: * tests/Makefile: Removed old Makefiles. * parser/parser/Parser.cpp: * common/StreamFactory.cpp: * common/ZipCharStream.cpp: * common/ZipCharStream.h: Fixed compilation errors. Mon Nov 18 20:30:30 2002 Krishnakumar B * common/CharStream.h: * common/Encoding.cpp: * common/FileCharStream.cpp: * common/FileCharStream.h: * common/StrCharStream.cpp: * common/StrCharStream.h: * common/HttpCharStream.cpp: * common/HttpCharStream.h: Fixed a number of minor typos and debugging statements. * common/LocatorImpl.cpp: Check for a valid string before assigning it to the new Locator. * common/NamespaceSupport.cpp: Make sure that we don't have a null prefix before trying to dereference the prefix. * common/ZipCharStream.cpp: * common/ZipCharStream.h: New stream which reads files from a ZIP archive. * common/StreamFactory.cpp: Modified to accomodate ZipCharStream. * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/main.cpp: Commented out a lot of unnecessary debug statements. * parser/parser/Parser.cpp: * parser/parser/Parser.h: Lots of bugfixes. Finally we parse the XML version of XHTML specification without dumping core. Sat Nov 16 21:18:55 2002 Krishnakumar B * parser/parser/Parser.cpp: * parser/parser/Parser.h: More bugs fixed. Add support for parsing PE references within attribute list declarations and clean up the same. Add support for parsing PE references within element declarations. Tue Nov 12 19:48:34 2002 Krishnakumar B * parser/parser/ParserContext.cpp: * parser/parser/ParserContext.h: * parser/parser/ParserContext.inl: New files which hold the ParserContext needed to handle the switching of input streams on the fly. * parser/parser/ParserInternals.cpp: * parser/parser/ParserInternals.h: Moved some generic code from Parser.cpp to here. * apps/svcconf/Makefile: * common/Makefile: * parser/parser/Makefile: Updated dependencies. * common/Attributes_Def_Builder.h: No need to typedef in C++. * common/DefaultHandler.cpp: Minor typos. * common/Encoding.cpp: If auto-detection of encoding fails, assume that it is UTF-8. * common/Exception.cpp: Change the error message from ACE_DEBUG to ACE_ERROR. * common/FileCharStream.cpp: Handle BOM of UTF-8 in addition to UTF-16. Cleanup unnecessary parens. * common/HttpCharStream.cpp: * common/HttpCharStream.h: Add support for auto-detection of encoding. * common/InputSource.cpp: * common/InputSource.h: Fixes for use with ACEXML_Parser_Context. * common/LocatorImpl.cpp: * common/LocatorImpl.h: Fixed bug in copy constructor which resulted in locator information not getting set properly. * common/NamespaceSupport.cpp: * common/NamespaceSupport.h: Implement reset() method. * common/SAXExceptions.cpp: Change the error message from ACE_DEBUG to ACE_ERROR. * common/StrCharStream.cpp: Handle copying of bytes according to sizeof (ACE_WCHAR). * common/StreamFactory.cpp: Create the appropriate stream given an URI. We don't try to normalize the URI here. It is done in the Parser. * common/Transcode.cpp: * common/Transcode.i: Moved some very big functions from .i to .cpp. * examples/SAXPrint/SAXPrint_Handler.cpp: * examples/SAXPrint/main.cpp: Updates to reflect the new calling convention in the Parser. * parser/parser/Entity_Manager.cpp: * parser/parser/Entity_Manager.h: * parser/parser/Entity_Manager.i: Implemented support for resolving SYSTEM and PUBLIC ids from the Entity_Manager. * parser/parser/Parser.cpp: * parser/parser/Parser.h: * parser/parser/Parser.i: Implemented support for external parameter and entity references. Rewrote a lot of the basic parsing functionality to adhere to the standard. Implment partial support for validation of XML files. Fri Oct 25 15:44:04 2002 Krishnakumar B * parser/parser/Parser.i: Handle end-of-line as required by the spec. Specifically any sequence of 0x0D or 0x0D 0x0A should be normalized to a 0x0A before passing to the XML processor. * parser/parser/Parser.cpp: Remove checks for 0x0D as it is handled tranparently now. Thu Oct 24 21:06:44 2002 Krishnakumar B * common/NamespaceSupport.cpp: Define strings normally and not as an array. * common/Attributes_Def_Builder.h: No need to typedef in C++. Thu Oct 24 01:52:46 2002 Krishnakumar B * ACEXML\parser\parser\Parser.cpp: Moved out the declaration of variables outside case labels. MSVC doesn't like it. Wed Oct 23 22:24:59 2002 Krishnakumar B * parser/parser/Parser.cpp: Fixed a stupid thinko in array initialization. Wed Oct 23 17:27:14 2002 Krishnakumar B * common/Encoding.cpp: * common/Encoding.h: Use UTF-16 instead of UTF-16LE/UTF-16BE as the specification doesn't require mentioning the endianness of the input. * common/Transcode.h: Fixed some minor typos. * examples/SAXPrint/namespaces.xml: New file which tests out the namespaces feature much better. * apps/svcconf/Makefile: * parser/parser/Makefile: Updated dependencies. * parser/parser/ParserErrors.h: New file which contains the error codes of all the error spit out by the parser. * examples/SAXPrint/Print_Handler.cpp: * examples/SAXPrint/SAXPrint_Handler.cpp: Make sure that the characters() function describes the arguments as start and length instead of start and end. * parser/parser/Parser.dsp: Added ParserErrors.h to the project file. * parser/parser/Parser.cpp: * parser/parser/Parser.h: Use minor codes when reporting error in the parser. This cleans up a lot of repeated error messages and indenting so that we don't need to spill over 80 columns and have a standardized way of reporting errors. Rewrote parse_cdata() so that is is much simpler. Removed try_grow_cdata() as it is no longer needed. Handle the case when the parser was accepting invalid character references(). Local Variables: mode: change-log add-log-time-format: (lambda () (progn (setq tz (getenv "TZ")) (set-time-zone-rule "UTC") (setq time (format-time-string "%a %b %e %H:%M:%S %Z %Y" (current-time))) (set-time-zone-rule tz) time)) indent-tabs-mode: nil End: ace-6.3.3+dfsg.orig/ACEXML/docs/0000775000175000017500000000000012576472436016320 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/docs/bugs.txt0000644000175000017500000000060112576461726020014 0ustar pgquilespgquiles/** @page acexml_bugs ACEXML Known Bugs

  • ACEXML currently do not validate an XML files. The validator hooks have not fully integrated into the parser yet.
  • Need to verify predefined entities are working correctly. Check out the SAXPrint example.
  • Currently, replacement of parameterized reference (PEReference) is not working.
*/ ace-6.3.3+dfsg.orig/ACEXML/docs/parser_features.txt0000644000175000017500000000143412576461726022253 0ustar pgquilespgquiles/** -*- HTML-Helper -*- @defgroup acexml_parser_features Configurable Special Features of ACEXML Parser @{ There are special features in ACEXML Parser that can be activated/deactivated thru @c setFeature. Likewise, whether a feature has been activated or not can be queried using @c getFeature. @sa ACEXML_XMLReader::setFeature @sa ACEXML_XMLReader::getFeature Here is a list of supported features:
  1. namespaces - When this feature is enabled, ACEXML parser allows access by namespace qualified names.
  2. namespace_prefixes - Normally the list of attributes returned by the parser will not contain attributes used as namespace declarations (xmlns:foo="bar"). When this feature is enabled, the list of attributes contains the namespace declarations also.
@} */ ace-6.3.3+dfsg.orig/ACEXML/docs/readme.txt0000644000175000017500000000253012576461726020314 0ustar pgquilespgquiles/** -*- HTML-Helper -*- @mainpage ACEXML - A Small and Portable XML Parser @section acexml_synopsis Synopsis ACEXML is a small footprint and portable framework for integrating XML parsing ability into user applications. The framework is based on the Simple API for XML (SAX 2.0) by David Megginson. A simple non-conformant XML parser is also included in the framework. Since our original motivation was to use the parser for specifying software composition and configuration descriptors, at the current stage, the parser does not fully support all the features specified in the XML specification. We do, however, plan to add more features to the parser and will either release a more versatile parser or allow the current parser to dynamically load in the extra features in the future. @section acexml_features Features of ACEXML
  • ACEXML only recognize UNICODE documents, although they can be in various different encoding, such as UTF-8, UTF-16, or UCS-4. Therefore, it might be a problem to handle document containing multi-byte charatersets. They can, however, be translated into UNICODE before being parsed by ACEXML parser.
@section acexml_others Other Topics
  1. @ref acexml_parser_features
  2. @ref acexml_guides
  3. @ref acexml_bugs
  4. @ref acexml_todo
*/ ace-6.3.3+dfsg.orig/ACEXML/docs/guidelines.txt0000644000175000017500000000321712576461726021212 0ustar pgquilespgquiles// -*- HTML-Helper -*- /** @page acexml_guides ACEXML Programming Guidelines
  • A lot of class names under @c $(ACE_ROOT)/ACEXML/common do not follow the naming convention suggested in ACE-guidelines.html. The reason for that is because those classes were derived from the SAX2 API and we would like to keep them as similar as possible.
  • Character encoding: The default character encoding for ACEXML can be set at compile time. ACEXML uses UTF-8 encoding in most platforms where ACEXML_Char maps to char in this case. When ACE is configured to use wchar and UNICODE, ACEXML uses UTF-16 encoding and ACEXML_Char maps to wchar_t. Notice that ACEXML assume sizeof (wchar_t) is of 2-byte long. For platforms using 4-byte wchar_t, ACEXML will not work correctly, but it should be trivial to fix.

  • Currently, there's only an example showing how to use the parser under @c $(ACE_ROOT)/ACEXML/examples/SAXPrint/.
  • (Not supported yet) To develop a new validator, one must create a DLL implementing @c ACEXML_Attributes_Def_Builder, @c ACEXML_Attribute_Def_Builder, @c ACEXML_Element_Def_Builder, @c ACEXML_Validator, and @c ACEXML_DTD_Manager. The DLL should also export a traditional C function called @c create_dtd_manager. The XML parser itself should also be modified to support and dynamically link with the new validator. See @c $(ACE_ROOT)/ACEXML/parser/debug_validator/ for an example.
*/ ace-6.3.3+dfsg.orig/ACEXML/docs/TODO.txt0000644000175000017500000000050612576461726017625 0ustar pgquilespgquiles/** @page acexml_todo ACEXML TO-DO List
  • Add Schema parsing ability.
  • Add support for resolving external entities, such as a schema/namespace definition located on the web.
  • Add parameterized entity management class. See above.
  • Define validator building/calling interfaces.
*/ ace-6.3.3+dfsg.orig/ACEXML/README0000644000175000017500000000107712576461726016253 0ustar pgquilespgquiles ACE XML PARSER Framework README file * Character set ACE XML only deal with pure unicode encoding. I.e., ACE XML does not care about language specific encoding information. * SAX - The Simple API for XML ACE XML Parser interfaces follows the the design of SAX 2.0, which is a public domain specification for Java. The major difference between ACE XML Parser interfaces and SAX is that we added an reference of ACEXML_Env to every SAX method to accomodate platforms/compilers that don't support C++ exceptions. SAX is defined by David Megginson ace-6.3.3+dfsg.orig/ACEXML/common/0000775000175000017500000000000012576472436016660 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/common/XMLFilter.h0000644000175000017500000000262512576461726020642 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file XMLFilter.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_XMLFILTER_H_ #define _ACEXML_XMLFILTER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XMLReader.h" /** * @class ACEXML_XMLFilter XMLFilter.h "ACEXML/common/XMLFilter.h" * * @brief ACEXML_XMLFilter * * An XML filter is like an XML reader, except that it obtains its events * from another XML reader rather than a primary source like an XML * document or database. Filters can modify a stream of events as they pass * on to the final application. * * The XMLFilterImpl helper class provides a convenient base for creating * SAX2 filters, by passing on all ACEXML_EntityResolver, * ACEXML_DTDHandler, ACEXML_ContentHandler and ACEXML_ErrorHandler events * automatically. */ class ACEXML_Export ACEXML_XMLFilter : public ACEXML_XMLReader { public: /** * Get the parent reader. */ virtual ACEXML_XMLReader *getParent (void) const = 0; /** * Set the parent reader. */ virtual void setParent (ACEXML_XMLReader *parent) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_XMLFILTER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/DTD_Manager.cpp0000644000175000017500000000013012576461726021421 0ustar pgquilespgquiles#include "ACEXML/common/DTD_Manager.h" ACEXML_DTD_Manager::~ACEXML_DTD_Manager () { } ace-6.3.3+dfsg.orig/ACEXML/common/CharStream.h0000644000175000017500000000375512576461726021072 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file CharStream.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_CHARSTREAM_H_ #define _ACEXML_CHARSTREAM_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_CharStream * * ACEXML_CharStream is an abstract class (interface) which defines the * basic opertions a parser could use to retrieve XML charater sequence. * The sequence can be read from a file or a character buffer. */ class ACEXML_Export ACEXML_CharStream { public: /** * Virtual destructor, must have. */ virtual ~ACEXML_CharStream (void) = 0; /** * Returns the available ACEXML_Char in the buffer. -1 * if the object is not initialized properly. */ virtual int available (void) = 0; /** * Close this stream and release all resources used by it. */ virtual int close (void) = 0; /** * Read the next ACEXML_Char. Return -1 if we are not able to * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed. */ virtual int get (ACEXML_Char& ch) = 0; /** * Read the next batch of ACEXML_Char strings */ virtual int read (ACEXML_Char *str, size_t len) = 0; /** * Peek the next ACEXML_Char in the CharStream. Return the * character if succeess, -1 if EOS is reached. */ virtual int peek (void) = 0; /** * Resets the pointer to the beginning of the stream. */ virtual void rewind (void) = 0; /* * Get the character encoding for a byte stream or URI. */ virtual const ACEXML_Char *getEncoding (void) = 0; /* * Get the systemId for the underlying CharStream */ virtual const ACEXML_Char* getSystemId (void) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_CHARSTREAM_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/XML_Util.h0000644000175000017500000000145212576461726020466 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file XML_Util.h * * Initially contains a function to escape strings for use in XML files. * * @author Justin Michel */ //============================================================================= #ifndef _ACEXML_XML_UTIL_H_ #define _ACEXML_XML_UTIL_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" ACEXML_Export ACEXML_String ACEXML_escape_string(const ACEXML_String& str); ACEXML_Export void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out); #include /**/ "ace/post.h" #endif /* _ACEXML_XML_UTIL_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Exception.inl0000644000175000017500000000034712576461726021324 0ustar pgquilespgquiles// -*- C++ -*- ACEXML_INLINE const ACEXML_Char * ACEXML_Exception::id (void) const { return ACEXML_Exception::exception_name_; } ACEXML_INLINE ACEXML_Exception* ACEXML_Exception::_downcast (ACEXML_Exception* x) { return x; } ace-6.3.3+dfsg.orig/ACEXML/common/SAXExceptions.cpp0000644000175000017500000001375512576461726022072 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/SAXExceptions.h" #include "ace/Log_Msg.h" #include "ace/ACE.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_string.h" const ACEXML_Char * ACEXML_SAXException::exception_name_ = ACE_TEXT ("ACEXML_SAXException"); const ACEXML_Char ACEXML_SAXNotSupportedException::exception_name_[] = ACE_TEXT ("ACEXML_SAXNotSupportedException"); const ACEXML_Char ACEXML_SAXNotRecognizedException::exception_name_[] = ACE_TEXT ("ACEXML_SAXNotRecognizedException"); const ACEXML_Char ACEXML_SAXParseException::exception_name_[] = ACE_TEXT ("ACEXML_SAXParseException"); #if !defined (__ACEXML_INLINE__) # include "ACEXML/common/SAXExceptions.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_SAXException::ACEXML_SAXException (void) : message_ (0) { } ACEXML_SAXException::ACEXML_SAXException (const ACEXML_Char *msg) : message_ (ACE::strnew (msg)) { } ACEXML_SAXException::ACEXML_SAXException (const ACEXML_SAXException &ex) : ACEXML_Exception (ex), message_ (ACE::strnew (ex.message_)) { } ACEXML_SAXException& ACEXML_SAXException::operator= (const ACEXML_SAXException& src) { if (this != &src) { ACE::strdelete (this->message_); this->message_ = ACE::strnew (src.message_); } return *this; } ACEXML_SAXException* ACEXML_SAXException::_downcast (ACEXML_Exception* ex) { return dynamic_cast (ex); } ACEXML_SAXException::~ACEXML_SAXException (void) { ACE::strdelete (this->message_); } ACEXML_Exception * ACEXML_SAXException::duplicate (void) const { ACEXML_Exception *tmp; ACE_NEW_RETURN (tmp, ACEXML_SAXException (*this), 0); return tmp; } int ACEXML_SAXException::is_a (const ACEXML_Char *name) { return ACE_OS::strcmp (ACEXML_SAXException::exception_name_, name) == 0 || this->ACEXML_Exception::is_a (name); } void ACEXML_SAXException::print (void) const { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"), this->exception_name_, this->message())); } ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (void) { } ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex) : ACEXML_SAXException (ex) { } ACEXML_SAXNotSupportedException& ACEXML_SAXNotSupportedException::operator= (const ACEXML_SAXNotSupportedException &ex) { this->ACEXML_SAXException::operator= (ex); return *this; } ACEXML_SAXNotSupportedException* ACEXML_SAXNotSupportedException::_downcast (ACEXML_Exception* ex) { return dynamic_cast (ex); } ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_Char* msg) : ACEXML_SAXException (msg) { } ACEXML_SAXNotSupportedException::~ACEXML_SAXNotSupportedException (void) { delete[] this->message_; } ACEXML_Exception * ACEXML_SAXNotSupportedException::duplicate (void) const { ACEXML_Exception *tmp; ACE_NEW_RETURN (tmp, ACEXML_SAXNotSupportedException (*this), 0); return tmp; } int ACEXML_SAXNotSupportedException::is_a (const ACEXML_Char *name) { return ACE_OS::strcmp (ACEXML_SAXNotSupportedException::exception_name_, name) == 0 || this->ACEXML_SAXException::is_a (name); } void ACEXML_SAXNotSupportedException::print (void) const { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"), this->exception_name_, this->message())); } ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (void) { } ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg) : ACEXML_SAXException (msg) { } ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex) : ACEXML_SAXException (ex) { } ACEXML_SAXNotRecognizedException& ACEXML_SAXNotRecognizedException::operator= (const ACEXML_SAXNotRecognizedException &ex) { this->ACEXML_SAXException::operator= (ex); return *this; } ACEXML_SAXNotRecognizedException* ACEXML_SAXNotRecognizedException::_downcast (ACEXML_Exception* ex) { return dynamic_cast (ex); } ACEXML_SAXNotRecognizedException::~ACEXML_SAXNotRecognizedException (void) { } ACEXML_Exception * ACEXML_SAXNotRecognizedException::duplicate (void) const { ACEXML_Exception *tmp; ACE_NEW_RETURN (tmp, ACEXML_SAXNotRecognizedException (*this), 0); return tmp; } int ACEXML_SAXNotRecognizedException::is_a (const ACEXML_Char *name) { return ACE_OS::strcmp (ACEXML_SAXNotRecognizedException::exception_name_, name) == 0 || this->ACEXML_SAXException::is_a (name); } void ACEXML_SAXNotRecognizedException::print (void) const { ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"), this->exception_name_, this->message())); } ACEXML_SAXParseException::ACEXML_SAXParseException (void) { } ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_Char *msg) : ACEXML_SAXException (msg) { } ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_SAXParseException &ex) : ACEXML_SAXException (ex) { } ACEXML_SAXParseException& ACEXML_SAXParseException::operator= (const ACEXML_SAXParseException &ex) { this->ACEXML_SAXException::operator= (ex); return *this; } ACEXML_SAXParseException* ACEXML_SAXParseException::_downcast (ACEXML_Exception* ex) { return dynamic_cast (ex); } ACEXML_SAXParseException::~ACEXML_SAXParseException (void) { } ACEXML_Exception * ACEXML_SAXParseException::duplicate (void) const { ACEXML_Exception *tmp; ACE_NEW_RETURN (tmp, ACEXML_SAXParseException (*this), 0); return tmp; } int ACEXML_SAXParseException::is_a (const ACEXML_Char *name) { return ACE_OS::strcmp (ACEXML_SAXParseException::exception_name_, name) == 0 || this->ACEXML_SAXException::is_a (name); } void ACEXML_SAXParseException::print (void) const { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"), this->exception_name_, this->message())); } ace-6.3.3+dfsg.orig/ACEXML/common/URL_Addr.cpp0000644000175000017500000001154112576461726020760 0ustar pgquilespgquiles#include "ACEXML/common/URL_Addr.h" #if !defined (__ACEXML_INLINE__) #include "ACEXML/common/URL_Addr.inl" #endif /* __ACEXML_INLINE__ */ #include "ace/Log_Msg.h" #include "ace/Auto_Ptr.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_stdlib.h" #include "ace/OS_NS_string.h" ACEXML_URL_Addr::ACEXML_URL_Addr (void) : path_name_ (0), addr_string_ (0), addr_string_len_ (0) { } int ACEXML_URL_Addr::addr_to_string (ACEXML_Char *s, size_t size, int ipaddr_format) const { size_t total_len = this->calculate_length (ipaddr_format); if (size < total_len) return -1; else { ACE_OS::sprintf (s, ACE_TEXT ("%s:%d/%s"), ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0 ? this->get_host_name () : this->get_host_addr ()), this->get_port_number (), this->get_path_name ()); return 0; } } const ACEXML_Char * ACEXML_URL_Addr::addr_to_string (int ipaddr_format) { size_t size = this->calculate_length (ipaddr_format); if (size > this->addr_string_len_) { ACE_ALLOCATOR_RETURN (this->addr_string_, (ACEXML_Char *) ACE_OS::realloc(this->addr_string_, size), 0); this->addr_string_len_ = size; } ACE_OS::sprintf (this->addr_string_, ACE_TEXT ("%s:%d/%s"), ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0 ? this->get_host_name () : this->get_host_addr ()), this->get_port_number (), this->get_path_name ()); return this->addr_string_; } #if defined (ACE_USES_WCHAR) int ACEXML_URL_Addr::string_to_addr (const char* s, int address_family) { return this->string_to_addr (ACE_TEXT_CHAR_TO_TCHAR (s), address_family); } #endif /* ACE_USES_WCHAR */ int ACEXML_URL_Addr::string_to_addr (const ACEXML_Char* s, int /*address_family */) { if (s == 0) return -1; const ACEXML_Char* http = ACE_TEXT ("http://"); size_t http_len = ACE_OS::strlen (http); // Check validity of URL if (ACE_OS::strncmp (http, s, http_len) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Invalid URL %s\n"), s), -1); const ACEXML_Char* url = 0; // Get the host name for (url = s + http_len; *url != '\0' && *url != ':' && *url != '/'; ++url) ; size_t host_len = url - s; host_len -= http_len; ACEXML_Char* host_name = 0; ACE_NEW_RETURN (host_name, ACEXML_Char[host_len + 1], -1); ACE_OS::strncpy (host_name, s + http_len, host_len); host_name[host_len] = '\0'; ACE_Auto_Basic_Array_Ptr cleanup_host_name (host_name); // Get the port number (if any) unsigned short port = ACE_DEFAULT_HTTP_PORT; if (*url == ':') { port = (unsigned short) ACE_OS::strtol (++url, 0, 10); // Skip over ':' while ( *url != '\0' && *url != '/' ) ++url; } // Set the addr int result = this->ACE_INET_Addr::set (port, host_name); if (result == -1) return -1; // Get the path name const ACEXML_Char* path_name = 0; if (*url == '\0') path_name = ACE_TEXT ("/"); else path_name = url; ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (path_name), -1); return result; } ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_URL_Addr &addr) : ACE_INET_Addr (), path_name_ (0), addr_string_ (0), addr_string_len_ (0) { if (this->set (addr) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr"))); } int ACEXML_URL_Addr::set (const ACEXML_URL_Addr &addr) { ACE_OS::free (this->path_name_); ACE_OS::free (this->addr_string_); if (this->ACE_INET_Addr::set (addr) == -1) return -1; else { if (addr.path_name_) ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (addr.path_name_), -1); if (addr.addr_string_) ACE_ALLOCATOR_RETURN (this->addr_string_, ACE_OS::strdup (addr.addr_string_), -1); this->addr_string_len_ = addr.addr_string_len_; return 0; } } ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_Char *host_name, const ACEXML_Char *path_name, unsigned short port) : ACE_INET_Addr (port, host_name), path_name_ (ACE_OS::strdup (path_name)), addr_string_ (0), addr_string_len_ (0) { } ACEXML_URL_Addr::~ACEXML_URL_Addr (void) { ACE_OS::free (this->path_name_); ACE_OS::free (this->addr_string_); this->path_name_ = 0; } ace-6.3.3+dfsg.orig/ACEXML/common/DTDHandler.cpp0000644000175000017500000000011212576461726021265 0ustar pgquilespgquiles#include "DTDHandler.h" ACEXML_DTDHandler::~ACEXML_DTDHandler (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/InputSource.h0000644000175000017500000000673012576461726021315 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file InputSource.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_INPUTSOURCE_H_ #define _ACEXML_INPUTSOURCE_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/CharStream.h" #include "ace/Copy_Disabled.h" /** * @class ACEXML_InputSource * * @brief ACEXML_InputSource encapsulates the actual input stream with some * added information. * * This class allows a SAX application to encapsulate information * about an input source in a single object, which may include a * public identifier, a system identifier, a byte stream (possibly * with a specified encoding), and/or a character stream. * * There are two places that the application will deliver this input * source to the parser: as the argument to the Parser.parse method, * or as the return value of the EntityResolver.resolveEntity method. * * The SAX parser will use the InputSource object to determine how to * read XML input. If there is a character stream available, the * parser will read that stream directly; if not, the parser will use * a byte stream, if available; if neither a character stream nor a * byte stream is available, the parser will attempt to open a URI * connection to the resource identified by the system identifier. * * An InputSource object belongs to the application: the SAX parser * shall never modify it in any way (it may modify a copy if * necessary). * * @sa ACEXML_CharStream */ class ACEXML_Export ACEXML_InputSource : private ACE_Copy_Disabled { public: /** * Default constructor. */ ACEXML_InputSource (void); /** * Create a new input source with a ACEXML_Char stream. * Notice that ACEXML_InputSource assumes the ownership * of */ explicit ACEXML_InputSource (ACEXML_CharStream *stream); /** * Create a new input source with a system identifier. */ ACEXML_InputSource (const ACEXML_Char *systemId); /** * Default destructor. */ virtual ~ACEXML_InputSource (void); /** * Get the ACEXML_Char stream for this input source. */ virtual ACEXML_CharStream *getCharStream (void) const; /** * Get the character encoding for a byte stream or URI. */ virtual const ACEXML_Char *getEncoding (void) const; /** * Get the public identifier for this input source. */ virtual const ACEXML_Char *getPublicId (void) const; /** * Get the system identifier for this input source. */ virtual const ACEXML_Char *getSystemId (void) const; /** * Set the ACEXML_Char stream for this input source. * Notice that ACEXML_InputSource assumes the ownership * of */ virtual void setCharStream (ACEXML_CharStream *charStream); /** * Set the character encoding, if known. */ virtual void setEncoding (const ACEXML_Char *encoding); /** * Set the public identifier for this input source. */ virtual void setPublicId (const ACEXML_Char *publicId); /** * Set the public identifier for this input source. */ virtual void setSystemId (const ACEXML_Char *systemId); private: ACEXML_CharStream *charStream_; ACEXML_Char *encoding_; ACEXML_Char *publicId_; ACEXML_Char *systemId_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_INPUTSOURCE_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/EntityResolver.h0000644000175000017500000000323412576461726022027 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file EntityResolver.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ENTITYHANDLER_H_ #define _ACEXML_ENTITYHANDLER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/InputSource.h" #include "ACEXML/common/SAXExceptions.h" /** * @class ACEXML_EntityResolver * * @brief ACEXML_EntityResolver * * If a SAX application needs to implement customized handling for * external entities, it must implement this interface and register an * instance with the SAX driver using the setEntityResolver method. * * The XML reader will then allow the application to intercept any * external entities (including the external DTD subset and external * parameter entities, if any) before including them. * * Many SAX applications will not need to implement this interface, * but it will be especially useful for applications that build XML * documents from databases or other specialised input sources, or for * applications that use URI types other than URLs. */ class ACEXML_Export ACEXML_EntityResolver { public: virtual ~ACEXML_EntityResolver (void); /** * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_ENTITYHANDLER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Mem_Map_Stream.h0000644000175000017500000001326212576461726021661 0ustar pgquilespgquiles/* -*- C++ -*- */ /** @file Mem_Map_Stream.h * * @author Douglas C. Schmidt * @author Krishnakumar B */ #ifndef _ACEXML_MEM_MAP_STREAM_H #define _ACEXML_MEM_MAP_STREAM_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/SOCK_Stream.h" #include "ace/Mem_Map.h" #include "ace/SOCK_Connector.h" #include "ace/Connector.h" #include "ace/Svc_Handler.h" #include "ACEXML/common/XML_Types.h" typedef ACE_Svc_Handler Svc_Handler; typedef ACE_Connector Connector; /** * @class ACEXML_Mem_Map_Stream * * @brief Provides a memory-mapped stream abstraction to simplify parsing * of tokens. * * This class makes it possible to treat an connection as a stream of * bytes, similar to the C library stdio streams. The contents of the * connection are buffered incrementally in a memory-mapped file. This * class maintains pointers to two positions in the stream: * * 1. The position, which keeps track of the beginning of a * token that is in the stream. * * 2. The position, which moves along character-by-character * until the end of the token is reached. * * Once a token has been located, it can be extracted from the stream by * calling the . The length of the token, i.e., the , is * the length in bytes between the position and the position. * Once the token has been extracted, the and positions can be * updated by the method. */ class ACEXML_Export ACEXML_Mem_Map_Stream { public: /// Default constructor ACEXML_Mem_Map_Stream (void); /// Initialize this object. virtual int open (Connector *connector, const ACE_INET_Addr &); /// Destructor. virtual ~ACEXML_Mem_Map_Stream (void); /// Returns the underlying . ACE_SOCK_Stream &stream (void); /** * Send bytes in to the connected peer. This is a * completely unbuffered call. */ virtual ssize_t send_n (const void *buf, size_t size, ACE_Time_Value *tv = 0); /** * Return the next character in the stream and advance the * position. Returns EOF when the position reaches the end of the * HTTP stream. */ virtual int get_char (void); /** * Returns a pointer to array of at most characters starting at * the position. If the position + extends past the * EOF then is set to the number of characters between the * position and the EOF and both the and positions are * advanced by . Returns 0 if the position is at the EOF. */ virtual const char *recv (size_t &len); /** * Returns a pointer to array of characters starting at the * position. */ virtual const char *recv (void) const; /** * Returns the length in bytes between the position and the * position. */ virtual size_t recv_len (void) const; /** * Returns the no. of bytes available in the stream. */ virtual size_t available (void) const; /** * Resets the and positions to the beginning of the stream. * This works since all the data has been cached in the memory-mapped * backing store. */ virtual void rewind (void); /** * Returns the nth character from the position in the * stream without advancing the position. Automatically extends * the backing store if necessary. Returns EOF if is past the * end of the stream. */ virtual int peek_char (size_t offset); /** * Return a pointer to an array of characters starting at * characters from the position in the stream without * advancing the position. Automatically extends the backing store * if necessary. Returns 0 if or is past the * end of the stream. */ virtual const char *peek_str (size_t offset, size_t size); /** * Sets the and positions as follows: * o If is , the positions are set to * bytes from the start of the stream. * o If is , the positions are set to the * current position plus . * o If is , the positions are set to the size * of the stream plus . * * If offset is greater than EOF, both and are set to EOF. * Note special return value is returned to indicate this condition. */ virtual ACE_OFF_T seek (ACE_OFF_T offset, int whence = SEEK_CUR); /// Returns 1 if we're at the end of the HTTP stream, else 0. virtual int eof (void) const; /// Returns the underlying service handler. Svc_Handler *svc_handler (void); private: /** * Grow the file by reading another chunk from the HTTP socket and * extend the mapping to cover this chunk. Returns -1 on failure or * EOF, else 0. */ int grow_file_and_remap (void); /** * Connection to peer. The granularity is at the Svc_Handler level. * The Svc_Handler has an SOCK_Stream. */ Svc_Handler *svc_handler_; /// Memory-mapped file that we're iterating over. ACE_Mem_Map mem_map_; /// Pointer to the address where the next method will start. char *recv_pos_; /** * Pointer to the address where the next method will * start. */ char *get_pos_; /// Address at the end of the file mapping. char *end_of_mapping_plus1_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_MEM_MAP_STREAM_H */ ace-6.3.3+dfsg.orig/ACEXML/common/NamespaceSupport.cpp0000644000175000017500000001373312576461726022662 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/NamespaceSupport.h" #include "ace/OS_NS_string.h" static const ACEXML_Char ACEXML_XMLNS_PREFIX_name[] = ACE_TEXT ("xmlns"); const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS_PREFIX = ACEXML_XMLNS_PREFIX_name; static const ACEXML_Char ACEXML_DEFAULT_NS_PREFIX[] = {0}; static const ACEXML_Char ACEXML_TABOO_NS_PREFIX[] = ACE_TEXT ("xml"); static const ACEXML_Char ACEXML_XMLNS_URI_name[] = ACE_TEXT ("http://www.w3.org/XML/1998/namespace"); const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name; ACEXML_Namespace_Context_Stack::ACEXML_Namespace_Context_Stack (void) { } ACEXML_Namespace_Context_Stack::~ACEXML_Namespace_Context_Stack (void) { // Clean up stuff. } int ACEXML_Namespace_Context_Stack::push (ACEXML_NS_CONTEXT *nsc) { return (this->stack_.push (nsc) < 0); } ACEXML_NS_CONTEXT * ACEXML_Namespace_Context_Stack::pop (void) { if (this->stack_.size() <= 0) return 0; ACEXML_NS_CONTEXT* temp = 0; int retval = this->stack_.pop (temp); if (retval != 0) { ACE_ERROR ((LM_ERROR, "Unable to pop Namespace context from stack\n")); return 0; } return temp; } int ACEXML_NamespaceSupport::popContext (void) { delete this->effective_context_; if ((this->effective_context_ = this->ns_stack_.pop ()) == 0) return -1; return 0; } int ACEXML_NamespaceSupport::pushContext (void) { ACEXML_NS_CONTEXT *temp = this->effective_context_; ACE_NEW_RETURN (this->effective_context_, ACEXML_NS_CONTEXT (), -1); // @@ Copy everything from the old context to the new one. ACEXML_NS_CONTEXT_ENTRY *entry = 0; for (ACEXML_NS_CONTEXT_ITER iter (*temp); iter.next (entry) != 0; iter.advance ()) this->effective_context_->bind (entry->ext_id_, entry->int_id_); this->ns_stack_.push (temp); return 0; } ACEXML_NamespaceSupport::ACEXML_NamespaceSupport (void) : ns_stack_ (), effective_context_ (0) {} int ACEXML_NamespaceSupport::init (void) { // @@ No way to tell if the new fails. ACE_NEW_RETURN (effective_context_, ACEXML_NS_CONTEXT(), -1); ACEXML_String prefix (ACEXML_TABOO_NS_PREFIX, 0, false); ACEXML_String uri (ACEXML_XMLNS_URI_name, 0, false); return this->effective_context_->bind (prefix, uri); } ACEXML_NamespaceSupport::~ACEXML_NamespaceSupport (void) { while (this->popContext () == 0) ; } int ACEXML_NamespaceSupport::declarePrefix (const ACEXML_Char *prefix, const ACEXML_Char *uri) { if (!prefix || !uri) return -1; // Unless predefined by w3.org(?) NS prefix can never start with // "xml". if (ACE_OS::strcmp (ACEXML_TABOO_NS_PREFIX, prefix) == 0) return -1; ACEXML_String ns_prefix (prefix, 0, false); ACEXML_String ns_uri (uri, 0, false); return this->effective_context_->rebind (ns_prefix, ns_uri); } int ACEXML_NamespaceSupport::getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const { ACEXML_NS_CONTEXT_ENTRY *entry = 0; // The prefix for default namespace (empty string) is included in // the return list. for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_); iter.next (entry) != 0; iter.advance ()) prefixes.enqueue_tail (entry->ext_id_.c_str ()); return 0; } const ACEXML_Char * ACEXML_NamespaceSupport::getPrefix (const ACEXML_Char *uri) const { if (!uri || *uri == 0) return 0; ACEXML_NS_CONTEXT_ENTRY *entry = 0; for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_); iter.next (entry) != 0; iter.advance ()) if (entry->int_id_ == ACEXML_String (uri, 0, false)) return entry->ext_id_.c_str (); return 0; // Nothing found. } int ACEXML_NamespaceSupport::getPrefixes (ACEXML_STR_LIST &prefixes) const { ACEXML_NS_CONTEXT_ENTRY *entry = 0; // The prefix for default namespace (empty string) is not included // in the return list. for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_); iter.next (entry) != 0; iter.advance ()) prefixes.enqueue_tail (entry->ext_id_.c_str ()); return 0; } int ACEXML_NamespaceSupport::getPrefixes (const ACEXML_Char *uri, ACEXML_STR_LIST &prefixes) const { if (!uri) return -1; ACEXML_NS_CONTEXT_ENTRY *entry = 0; for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_); iter.next (entry) != 0; iter.advance ()) if (entry->int_id_ == ACEXML_String (uri, 0, false) && entry->ext_id_ != ACEXML_String (ACEXML_DEFAULT_NS_PREFIX, 0, false)) prefixes.enqueue_tail (entry->ext_id_.c_str ()); else continue; return 0; // Nothing found. } const ACEXML_Char * ACEXML_NamespaceSupport::getURI (const ACEXML_Char *prefix) const { if (!prefix) return 0; ACEXML_NS_CONTEXT_ENTRY *entry = 0; if (this->effective_context_->find (ACEXML_String (prefix, 0, false), entry) == 0) return entry->int_id_.c_str (); return 0; } int ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName, const ACEXML_Char *&uri, const ACEXML_Char *&name, int is_attribute) const { int qlen = static_cast (ACE_OS::strlen (qName)); int len = -1; for (int i = 0; i < qlen; ++i) if (qName [i] == ':') { len = i; break; } ACEXML_String prefix (ACE_TEXT (""), 0, false); if (len == -1) name = qName; else { prefix.set (qName, len, 1); name = qName + len + 1; } if (is_attribute && len == -1) { uri = ACEXML_DEFAULT_NS_PREFIX; return 0; } ACEXML_NS_CONTEXT_ENTRY *entry = 0; if (this->effective_context_->find (prefix, entry) == 0) uri = entry->int_id_.c_str (); else { uri = ACEXML_DEFAULT_NS_PREFIX; return -1; } return 0; } int ACEXML_NamespaceSupport::reset (void) { while (this->popContext() != -1) ; return 0; } ace-6.3.3+dfsg.orig/ACEXML/common/Exception.cpp0000644000175000017500000000141212576461726021316 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/Exception.h" #include "ace/Log_Msg.h" #include "ace/ACE.h" #include "ace/OS_NS_string.h" const ACEXML_Char *ACEXML_Exception::exception_name_ = ACE_TEXT ("ACEXML_Exception"); const ACEXML_Char *ACEXML_Exception::null_ = ACE_TEXT (""); #if !defined (__ACEXML_INLINE__) # include "ACEXML/common/Exception.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_Exception::ACEXML_Exception() { } ACEXML_Exception::~ACEXML_Exception() { } int ACEXML_Exception::is_a (const ACEXML_Char *name) { return ACE_OS::strcmp (ACEXML_Exception::exception_name_, name) == 0; } void ACEXML_Exception::print (void) const { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACEXML: (%P|%t) EXCEPTION : %s\n"), this->exception_name_)); } ace-6.3.3+dfsg.orig/ACEXML/common/ZipCharStream.cpp0000644000175000017500000001234312576461726022101 0ustar pgquilespgquiles#ifdef USE_ZZIP #include "ACEXML/common/ZipCharStream.h" #include "ace/ACE.h" ACEXML_ZipCharStream::ACEXML_ZipCharStream (void) : filename_ (0), encoding_ (0), size_ (0), infile_ (0), pos_ (0), limit_ (0) { } ACEXML_ZipCharStream::~ACEXML_ZipCharStream (void) { this->close(); } int ACEXML_ZipCharStream::open (const ACEXML_Char *name) { delete[] this->filename_; this->filename_ = 0; delete[] this->encoding_; this->encoding_ = 0; this->infile_ = zzip_fopen (name, ACE_TEXT ("r")); if (this->infile_ == 0) return -1; this->filename_ = ACE::strnew (ACE::basename (name)); return this->determine_encoding(); } int ACEXML_ZipCharStream::determine_encoding (void) { if (this->infile_ == 0) return -1; char input[4]; int i = 0; for (; i < 4 && (input[i] = this->peekchar_i(i)) > 0; ++i) ; if (i < 4) return -1; const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input); if (!temp) return -1; else { if (this->encoding_) delete [] this->encoding_; this->encoding_ = ACE::strnew (temp); // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"), // this->encoding_)); } // Move over the byte-order-mark if present. for (int j = 0; j < 3; ++j) { ACEXML_Char ch; if ((ch = this->peekchar_i()) < 0) return -1; if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' || ch == '\xBF') this->get(ch); else break; } return 0; } void ACEXML_ZipCharStream::rewind() { if (this->infile_ == 0) return; zzip_rewind (this->infile_); this->determine_encoding(); } int ACEXML_ZipCharStream::available (void) { if (this->infile_ == 0) return -1; long curr; if ((curr = zzip_tell (this->infile_)) < 0) return -1; return (this->size_ - curr); } int ACEXML_ZipCharStream::close (void) { if (this->infile_ != 0) { zzip_close (this->infile_); this->infile_ = 0; } delete[] this->filename_; this->filename_ = 0; delete[] this->encoding_; this->encoding_ = 0; this->size_ = 0; this->pos_ = 0; this->limit_ = 0; return 0; } int ACEXML_ZipCharStream::getchar_i (char& ch) { if (this->infile_ == 0) return -1; if (this->pos_ < this->limit_) { ch = this->buf_[this->pos_++]; return 0; } this->limit_ = zzip_read (this->infile_, this->buf_, sizeof (this->buf_)); if (this->limit_ == 0) return -1; this->pos_ = 0; ch = this->buf_[this->pos_++]; return 0; } int ACEXML_ZipCharStream::peekchar_i (ACE_OFF_T offset) { if (this->infile_ == 0) return -1; if (offset > (ACE_OFF_T) sizeof (this->buf_)) return -1; if (this->pos_ + offset < this->limit_) return this->buf_[this->pos_ + offset]; int i = 0; for (; this->pos_ < this->limit_; ++this->pos_, ++i) this->buf_[i] = this->buf_[this->pos_]; this->limit_ = zzip_read (this->infile_, this->buf_ + i, sizeof (this->buf_) - i); this->limit_ += i; if (this->limit_ == 0) return -1; this->pos_ = 0; return this->buf_[this->pos_ + offset]; } int ACEXML_ZipCharStream::read (ACEXML_Char *str, size_t len) { if (this->infile_ == 0) return -1; size_t i = 0; for (; i < len && this->pos_ < this->limit_; ++i) str[i] = this->buf_[this->pos_++]; if (i == len) return len; len = len - i; this->pos_ = 0; this->limit_ = 0; int bytes = zzip_fread (str + i, sizeof (ACEXML_Char), len, this->infile_); return (bytes + i); } int ACEXML_ZipCharStream::get (ACEXML_Char& ch) { #if defined (ACE_USES_WCHAR) return this->get_i (ch); #else return this->getchar_i (ch); #endif /* ACE_USES_WCHAR */ } int ACEXML_ZipCharStream::peek (void) { #if defined (ACE_USES_WCHAR) return this->peek_i(); #else return this->peekchar_i(); #endif /* ACE_USES_WCHAR */ } const ACEXML_Char* ACEXML_ZipCharStream::getEncoding (void) { return this->encoding_; } const ACEXML_Char* ACEXML_ZipCharStream::getSystemId (void) { return this->filename_; } #if defined (ACE_USES_WCHAR) int ACEXML_ZipCharStream::get_i (ACEXML_Char& ch) { if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) return this->getchar_i (ch); int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; ACEXML_Char input[2]; int i = 0; for (; i < 2 && (this->getchar_i (input[i]) == 0); ++i) ; if (i < 2) { ch = 0; return -1; } ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]; return 0; } int ACEXML_ZipCharStream::peek_i (void) { // If we are reading a UTF-8 encoded file, just use the plain unget. if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) return this->peekchar_i(); // Peek into the stream. This reads two characters off the stream, keeps // it in peek_. int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; ACEXML_Char input[2]; int i = 0; for (; i < 2 && (input[i] = this->peekchar_i (i)) > 0; ++i) ; if (i < 2) return -1; return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]); } #endif /* ACE_USES_WCHAR */ #else #if defined (__HP_aCC) static int shut_up_aCC = 0; #endif /* __HP_aCC */ #endif /* USE_ZZIP */ ace-6.3.3+dfsg.orig/ACEXML/common/FileCharStream.cpp0000644000175000017500000001357212576461726022223 0ustar pgquilespgquiles#include "ACEXML/common/FileCharStream.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_sys_stat.h" #include "ace/Truncate.h" #if defined (ACE_USES_WCHAR) # include "ace/OS_NS_wchar.h" #endif /* ACE_USES_WCHAR */ ACEXML_FileCharStream::ACEXML_FileCharStream (void) : filename_ (0), encoding_ (0), size_ (0), infile_ (0), close_infile_ (true), peek_ (0) { } ACEXML_FileCharStream::~ACEXML_FileCharStream (void) { this->close(); } int ACEXML_FileCharStream::use_stream_i (FILE* open_file, const ACEXML_Char *name) { delete[] this->filename_; this->filename_ = 0; delete[] this->encoding_; this->encoding_ = 0; this->infile_ = open_file; if (this->infile_ == 0) return -1; ACE_stat statbuf; if (ACE_OS::stat (name, &statbuf) < 0) return -1; this->size_ = ACE_Utils::truncate_cast (statbuf.st_size); this->filename_ = ACE::strnew (name); return this->determine_encoding(); } int ACEXML_FileCharStream::use_stream (FILE* open_file, const ACEXML_Char *name) { if (open_file != 0) ACE_OS::rewind(open_file); this->close_infile_ = false; return use_stream_i(open_file, name); } int ACEXML_FileCharStream::open (const ACEXML_Char *name) { this->close_infile_ = true; return use_stream_i(ACE_OS::fopen (name, ACE_TEXT ("r")), name); } int ACEXML_FileCharStream::determine_encoding (void) { if (this->infile_ == 0) return -1; char input[4]; int retval = 0; int i = 0; for (; i < 4 && retval != -1; ++i) retval = this->getchar_i(input[i]); if (i < 4) return -1; // Rewind the stream ACE_OS::rewind (this->infile_); const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input); if (!temp) return -1; else { delete [] this->encoding_; this->encoding_ = ACE::strnew (temp); // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"), // this->encoding_)); } // Move over the byte-order-mark if present. char ch; for (int j = 0; j < 3; ++j) { if (this->getchar_i (ch) < 0) return -1; if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' || ch == '\xBF') continue; else { ACE_OS::ungetc (ch, this->infile_); break; } } return 0; } void ACEXML_FileCharStream::rewind() { if (this->infile_ == 0) return; ACE_OS::rewind (this->infile_); this->determine_encoding(); } int ACEXML_FileCharStream::available (void) { if (this->infile_ == 0) return -1; long curr; if ((curr = ACE_OS::ftell (this->infile_)) < 0) return -1; return static_cast (this->size_ - curr); } int ACEXML_FileCharStream::close (void) { if (this->infile_ != 0) { if (this->close_infile_) { ACE_OS::fclose (this->infile_); } this->infile_ = 0; } delete[] this->filename_; this->filename_ = 0; delete[] this->encoding_; this->encoding_ = 0; this->size_ = 0; this->peek_ = 0; return 0; } int ACEXML_FileCharStream::getchar_i (char& ch) { ch = static_cast (ACE_OS::fgetc (this->infile_)); return (feof(this->infile_) ? -1 : 0); } int ACEXML_FileCharStream::read (ACEXML_Char *str, size_t len) { if (this->infile_ == 0) return -1; return static_cast (ACE_OS::fread (str, sizeof (ACEXML_Char), len, this->infile_)); } int ACEXML_FileCharStream::get (ACEXML_Char& ch) { if (this->infile_ == 0) return -1; #if defined (ACE_USES_WCHAR) return this->get_i (ch); #else ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_); return (feof(this->infile_) ? -1 : 0); #endif /* ACE_USES_WCHAR */ } int ACEXML_FileCharStream::peek (void) { if (this->infile_ == 0) return -1; #if defined (ACE_USES_WCHAR) return this->peek_i(); #else ACEXML_Char ch = static_cast (ACE_OS::fgetc (this->infile_)); ACE_OS::ungetc (ch, this->infile_); return ch; #endif /* ACE_USES_WCHAR */ } #if defined (ACE_USES_WCHAR) int ACEXML_FileCharStream::get_i (ACEXML_Char& ch) { if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) { ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_); return (feof(this->infile_) ? -1 : 0); } // If we have a value in peek_, return it. if (this->peek_ != 0) { ch = this->peek_; this->peek_ = 0; return 0; } int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; ACEXML_Char input[2]; int i = 0; for (; i < 2 && !feof (this->infile_); ++i) { input[i] = ACE_OS::fgetwc (this->infile_); } if (i < 2) { ch = 0; return -1; } ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]; return 0; } int ACEXML_FileCharStream::peek_i (void) { // If we are reading a UTF-8 encoded file, just use the plain unget. if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) { ACEXML_Char ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_); ACE_OS::ungetc (ch, this->infile_); return ch; } // If somebody had already called peek() and not consumed it, return the // value held in this->peek_. if (this->peek_ != 0) return this->peek_; // Peek into the stream. This reads two characters off the stream, keeps // it in peek_. int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; ACEXML_Char input[2]; int i = 0; for (; i < 2 && !feof (this->infile_); ++i) { input[i] = ACE_OS::fgetwc (this->infile_); } if (i < 2) { this->peek_ = 0; return -1; } this->peek_ = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]; return this->peek_; } #endif /* ACE_USES_WCHAR */ const ACEXML_Char* ACEXML_FileCharStream::getEncoding (void) { return this->encoding_; } const ACEXML_Char* ACEXML_FileCharStream::getSystemId (void) { return this->filename_; } ace-6.3.3+dfsg.orig/ACEXML/common/Attributes_Def_Builder.h0000644000175000017500000000647312576461726023413 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Attributes_Def_Builder.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ATTRIBUTES_DEF_BUILDER_H_ #define _ACEXML_ATTRIBUTES_DEF_BUILDER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" #include "ACEXML/common/SAXExceptions.h" #include "ace/Auto_Ptr.h" /** * @class ACEXML_Attribute_Def_Builder * * @brief An abstract virtual class defining an interface for building an * attribute definition from DTD. * * This class should be invisible to application programmers and is only * used for validator implementors. */ class ACEXML_Export ACEXML_Attribute_Def_Builder { public: typedef auto_ptr VAR; enum ATT_TYPE { CDATA, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS, NOTATION, ENUMERATION, ERROR_TYPE }; enum DEFAULT_DECL { REQUIRED, IMPLIED, FIXED, INVALID }; virtual ~ACEXML_Attribute_Def_Builder () = 0; /** * Specify the name of the attribute. */ virtual int setName (const ACEXML_Char *n) = 0; /** * Get the name of the attribute. */ virtual const ACEXML_Char *getName (void) = 0; /** * Set the attribute type. */ virtual int setAttType (const ATT_TYPE type) = 0; /** * Insert an element for NOTATION or ENUMERATION type attribute. */ virtual int insertList (const ACEXML_Char *Name) = 0; /** * Set default attribute declaration. */ virtual int setDefault (const DEFAULT_DECL def, const ACEXML_Char *value) = 0; /** * Check validity of the current attribute definition being built. * * @retval 0 if the attribute is not a valid combo. */ virtual int validAttr (void) = 0; /** * Dump the content of the attribute definition. */ virtual void dump (void) = 0; }; /** * @ class ACEXML_Attributes_Def_Builder Attributes_Def_Builder.h "common/Attributes_Def_Builder.h" * * @ brief An abstract virtual class defining an interface for building * attribute definitions from DTD. * * This class should be invisible to application programmers and * is only used for validator implementors. */ class ACEXML_Export ACEXML_Attributes_Def_Builder { public: typedef auto_ptr VAR; virtual ~ACEXML_Attributes_Def_Builder () = 0; /** * Set the element name that the attribute builder applies. * * @retval 0 if valid, -1 otherwise. */ virtual int setElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; /** * Acquire an Attribute_Builder. */ virtual ACEXML_Attribute_Def_Builder *getAttribute_Def_Builder (void) = 0; /** * Add a definition for one attribute. */ virtual int insertAttribute (ACEXML_Attribute_Def_Builder *def) = 0; /** * Dump the content of the attribute definition. */ virtual void dump (void) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_ATTRIBUTES_DEF_BUILDER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/SAXExceptions.h0000644000175000017500000001222012576461726021521 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file SAXExceptions.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_SAXEXCEPTIONS_H_ #define _ACEXML_SAXEXCEPTIONS_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Exception.h" /** * @class ACEXML_SAXException * * @brief ACEXML_SAXException * * ACEXML_SAXException is the mother of all SAX related exceptions. */ class ACEXML_Export ACEXML_SAXException : public ACEXML_Exception { public: /// Default constructor. ACEXML_SAXException (void); /// Constructor initializing the exception message. ACEXML_SAXException (const ACEXML_Char *msg); /// Assignment operator ACEXML_SAXException& operator= (const ACEXML_SAXException& src); /// Copy constructor. ACEXML_SAXException (const ACEXML_SAXException &ex); /// Destructor. virtual ~ACEXML_SAXException (void); /// Throw the exception. virtual void _raise (void); /// Static narrow operation. static ACEXML_SAXException* _downcast (ACEXML_Exception* ex); /// Return the name of the exception. virtual const ACEXML_Char *id (void) const; /// Return the extra message accompanying the exception. const ACEXML_Char *message (void) const; virtual ACEXML_Exception *duplicate (void) const; virtual int is_a (const ACEXML_Char *name); virtual void print (void) const; protected: static const ACEXML_Char * exception_name_; /// A message providing more information about the exception being thrown. ACEXML_Char *message_; }; /** * @class ACEXML_SAXNotSupportedException SAXExceptions.h "ACEXML/common/SAXExceptions.h" * * @brief ACEXML_SAXNotSupportedException */ class ACEXML_Export ACEXML_SAXNotSupportedException : public ACEXML_SAXException { public: /// Default constructor. ACEXML_SAXNotSupportedException (void); /// Copy constructor. ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex); /// Assignment operator ACEXML_SAXNotSupportedException& operator= (const ACEXML_SAXNotSupportedException &ex); /// Constructor which accepts an informational message ACEXML_SAXNotSupportedException (const ACEXML_Char* msg); /// Destructor. virtual ~ACEXML_SAXNotSupportedException (void); /// Throw the exception. virtual void _raise (void); /// Static narrow operation. static ACEXML_SAXNotSupportedException* _downcast (ACEXML_Exception* ex); virtual const ACEXML_Char *id (void) const; virtual ACEXML_Exception *duplicate (void) const; virtual int is_a (const ACEXML_Char *name); virtual void print (void) const; protected: static const ACEXML_Char exception_name_[]; }; /** * @class ACEXML_SAXNotRecognizedException SAXExceptions.h "ACEXML/common/SAXExceptions.h" * * @brief ACEXML_SAXNotRecognizedException */ class ACEXML_Export ACEXML_SAXNotRecognizedException : public ACEXML_SAXException { public: /// Default constructor. ACEXML_SAXNotRecognizedException (void); /// Constructor with an initializing exception message. ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg); /// Copy constructor. ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex); /// Assignment operator. ACEXML_SAXNotRecognizedException& operator= (const ACEXML_SAXNotRecognizedException &ex); /// Destructor. virtual ~ACEXML_SAXNotRecognizedException (void); /// Throw the exception. virtual void _raise (void); /// Static narrow operation. static ACEXML_SAXNotRecognizedException* _downcast (ACEXML_Exception* ex); virtual const ACEXML_Char *id (void) const; virtual ACEXML_Exception *duplicate (void) const; virtual int is_a (const ACEXML_Char *name); virtual void print (void) const; protected: static const ACEXML_Char exception_name_[]; }; /** * @class ACEXML_SAXParseException SAXExceptions.h "ACEXML/common/SAXExceptions.h" * * @brief ACEXML_SAXParseException */ class ACEXML_Export ACEXML_SAXParseException : public ACEXML_SAXException { public: /// Default constructor. ACEXML_SAXParseException (void); /// Constructor with an initializing exception message. ACEXML_SAXParseException (const ACEXML_Char *msg); /// Copy constructor. ACEXML_SAXParseException (const ACEXML_SAXParseException &ex); /// Assignment operator. ACEXML_SAXParseException& operator= (const ACEXML_SAXParseException &ex); /// Destructor. virtual ~ACEXML_SAXParseException (void); /// Throw the exception. virtual void _raise (void); /// Static narrow operation. static ACEXML_SAXParseException* _downcast (ACEXML_Exception* ex); virtual const ACEXML_Char *id (void) const; virtual ACEXML_Exception *duplicate (void) const; virtual int is_a (const ACEXML_Char *name); virtual void print (void) const; protected: static const ACEXML_Char exception_name_[]; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/SAXExceptions.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* _ACEXML_SAXEXCEPTIONS_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/AttributesImpl.h0000644000175000017500000002073112576461726022002 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file AttributesImpl.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_ATTRIBUTESIMPL_H #define ACEXML_ATTRIBUTESIMPL_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Attributes.h" #include "ace/Containers_T.h" #if !defined ACEXML_AttributesImpl_Default_Size #define ACEXML_AttributesImpl_Default_Size 20 #endif /* ACEXML_AttributesImpl_Default_Size */ class ACEXML_AttributesImpl; /** * @class ACEXML_Attribute * * @brief ACEXML_Attribute defines the data structure of an attribute * * @sa ACEXML_AttributesImpl */ class ACEXML_Export ACEXML_Attribute { public: friend class ACEXML_AttributesImpl; /// Default constructor. ACEXML_Attribute (void); /// Copy constructor. ACEXML_Attribute (const ACEXML_Attribute &attr); /// Initialize all constructor. ACEXML_Attribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value); /// Destructor. ~ACEXML_Attribute (void); /// Set all members. void setAttribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value); /// Get \a uri_. const ACEXML_Char *uri (void) const; /// Set \a uri_. void uri (const ACEXML_Char *uri); /// Get \a localName_. const ACEXML_Char *localName (void) const; /// Set \a localName_. void localName (const ACEXML_Char *localName); /// Get \a qName_. const ACEXML_Char *qName (void) const; /// Set \a qName_. void qName (const ACEXML_Char *qName); /// Get \a type_. const ACEXML_Char *type (void) const; /// Set \a type_. void type (const ACEXML_Char *type); /// Get \a value_. const ACEXML_Char *value (void) const; /// Set \a value_. void value (const ACEXML_Char *value); /// Assignment operator. ACEXML_Attribute &operator= (const ACEXML_Attribute &rhs); /// Comparison operator. bool operator!= (const ACEXML_Attribute&rhs) const; private: /// Namespace URI of an attribute ACEXML_Char *uri_; ACEXML_Char *localName_; ACEXML_Char *qName_; ACEXML_Char *type_; ACEXML_Char *value_; }; /** * @typedef ACE_Array ACEXML_Attribute_Array */ typedef ACE_Array ACEXML_Attribute_Array; /** * @class ACEXML_AttributesImpl AttributesImpl.h "ACEXML/common/AttributesImpl.h" * * @brief ACEXML_AttributesImpl provides the default implementation * of interface ACEXML_Attributes. * * This class provides a default implementation of the SAX2 Attributes * interface, with the addition of manipulators so that the list can * be modified or reused. * * There are two typical uses of this class: * * - to take a persistent snapshot of an Attributes object in a * startElement event; or * - to construct or modify an Attributes object in a SAX2 driver or filter. * * This class replaces the now-deprecated SAX1 AttributeListImpl * class; in addition to supporting the updated Attributes interface * rather than the deprecated AttributeList interface, it also * includes a much more efficient implementation using a single array * rather than a set of Vectors. * * @sa ACEXML_Attributes */ class ACEXML_Export ACEXML_AttributesImpl : public ACEXML_Attributes { public: /** * Initialize an AttributesImpl that holds @a size attributes. */ ACEXML_AttributesImpl (int size = ACEXML_AttributesImpl_Default_Size); ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs); virtual ~ACEXML_AttributesImpl (void); /** * Add a new attribute using the argument(s) supplied. * Return -1 if an attribute with the same name already exists. */ virtual int addAttribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value); virtual int addAttribute (const ACEXML_Attribute &att); /** * Check for duplicate attributes. */ virtual int isDuplicate (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName); /** * Remove an attribute from the array. Notice that this * operation can invalidate previously acquired @a index * value. (It will repack the array.) */ virtual int removeAttribute (size_t index); /** * Look up the index of an attribute by XML 1.0 qualified name. * Return -1 if we fail to find a match. */ virtual int getIndex (const ACEXML_Char *qName); /** * Look up the index of an attribute by Namespace name. * Return -1 if we fail to find a match. */ virtual int getIndex (const ACEXML_Char *uri, const ACEXML_Char *localPart); /** * Return the number of attributes in the list. */ virtual size_t getLength (void); /** * Look up an attribute's local name by index. * Return 0 if index is out of range. */ virtual const ACEXML_Char *getLocalName (size_t index); /** * Look up an attribute's XML 1.0 qualified name by index. * Return 0 if index is out of range. */ virtual const ACEXML_Char *getQName (size_t index); /** * Look up an attribute's type by index. * Return 0 if index is out of range. */ virtual const ACEXML_Char *getType (size_t index); /** * Look up an attribute's type by XML 1.0 qualified name. * Return 0 if we fail to find a match. */ virtual const ACEXML_Char *getType (const ACEXML_Char *qName); /** * Look up an attribute's type by Namespace name. * Return 0 if we fail to find a match. */ virtual const ACEXML_Char *getType (const ACEXML_Char *uri, const ACEXML_Char *localPart); /** * Look up an attribute's Namespace URI by index. * Return 0 if index is out of range. */ virtual const ACEXML_Char *getURI (size_t index); /** * Look up an attribute's value by index. * Return 0 if index is out of range. */ virtual const ACEXML_Char *getValue (size_t index); /** * Look up an attribute's value by XML 1.0 qualified name. * Return 0 if we fail to find a match. */ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName); /** * Look up an attribute's value by Namespace name. * Return 0 if we fail to find a match. */ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri, const ACEXML_Char *localPart); /** * Set an attribute at index. Return -1 if index is out of * range. */ virtual int setAttribute (size_t index, const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value); /** * Set the localName of the attribute at @a index. * return -1 if @a index is out of range. */ virtual int setLocalName (size_t index, const ACEXML_Char *localName); /** * Set the qName of the attribute at @a index. * return -1 if @a index is out of range. */ virtual int setQName (size_t index, const ACEXML_Char *qName); /** * Set the URI of the attribute at @a index. * return -1 if @a index is out of range. */ virtual int setURI (size_t index, const ACEXML_Char *uri); /** * Set the type of the attribute at @a index. * return -1 if @a index is out of range. */ virtual int setType (size_t index, const ACEXML_Char *type); /** * Set the value of the attribute at @a index. * return -1 if @a index is out of range. */ virtual int setValue (size_t index, const ACEXML_Char *value); private: /// Container for all attributes. ACEXML_Attribute_Array attrs_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/AttributesImpl.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* ACEXML_ATTRIBUTESIMPL_H */ ace-6.3.3+dfsg.orig/ACEXML/common/AttributesImpl.inl0000644000175000017500000000677712576461726022353 0ustar pgquilespgquiles// -*- C++ -*- // #include "ace/ACE.h" #include "ace/OS_NS_string.h" ACEXML_INLINE ACEXML_Attribute::ACEXML_Attribute (void) : uri_ (0), localName_ (0), qName_ (0), type_ (0), value_ (0) { } ACEXML_INLINE ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Attribute &attr) : uri_ (ACE::strnew (attr.uri_)), localName_ (ACE::strnew (attr.localName_)), qName_ (ACE::strnew (attr.qName_)), type_ (ACE::strnew (attr.type_)), value_ (ACE::strnew (attr.value_)) { } ACEXML_INLINE ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value) : uri_ (ACE::strnew (uri)), localName_ (ACE::strnew (localName)), qName_ (ACE::strnew (qName)), type_ (ACE::strnew (type)), value_ (ACE::strnew (value)) { } ACEXML_INLINE ACEXML_Attribute::~ACEXML_Attribute (void) { delete[] this->uri_; delete[] this->localName_; delete[] this->qName_; delete[] this->type_; delete[] this->value_; } ACEXML_INLINE const ACEXML_Char * ACEXML_Attribute::uri (void) const { return this->uri_; } ACEXML_INLINE void ACEXML_Attribute::uri (const ACEXML_Char *uri) { delete[] this->uri_; this->uri_ = ACE::strnew (uri); } ACEXML_INLINE const ACEXML_Char * ACEXML_Attribute::localName (void) const { return this->localName_; } ACEXML_INLINE void ACEXML_Attribute::localName (const ACEXML_Char *localName) { delete[] this->localName_; this->localName_ = ACE::strnew (localName); } ACEXML_INLINE const ACEXML_Char * ACEXML_Attribute::qName (void) const { return this->qName_; } ACEXML_INLINE void ACEXML_Attribute::qName (const ACEXML_Char *qName) { delete[] this->qName_; this->qName_ = ACE::strnew (qName); } ACEXML_INLINE const ACEXML_Char * ACEXML_Attribute::type (void) const { return this->type_; } ACEXML_INLINE void ACEXML_Attribute::type (const ACEXML_Char *type) { delete[] this->type_; this->type_ = ACE::strnew (type); } ACEXML_INLINE const ACEXML_Char * ACEXML_Attribute::value (void) const { return this->value_; } ACEXML_INLINE void ACEXML_Attribute::value (const ACEXML_Char *value) { delete[] this->value_; this->value_ = ACE::strnew (value); } ACEXML_INLINE void ACEXML_Attribute::setAttribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value) { this->uri (uri); this->qName (qName); this->localName (localName); this->type (type); this->value (value); } ACEXML_INLINE ACEXML_Attribute & ACEXML_Attribute::operator= (const ACEXML_Attribute &rhs) { if (this != &rhs) // Check for self assignment { this->uri (rhs.uri ()); this->qName (rhs.qName ()); this->localName (rhs.localName ()); this->type (rhs.type ()); this->value (rhs.value ()); } return *this; } ACEXML_INLINE bool ACEXML_Attribute::operator!= (const ACEXML_Attribute &rhs) const { return (ACE_OS::strcmp (this->uri_, rhs.uri ()) == 0 && ACE_OS::strcmp (this->localName_, rhs.localName ()) == 0 && ACE_OS::strcmp (this->qName_, rhs .qName ()) == 0 && ACE_OS::strcmp (this->type_, rhs.type ()) == 0 && ACE_OS::strcmp (this->value_, rhs.value ()) == 0 ? false : true); } ace-6.3.3+dfsg.orig/ACEXML/common/URL_Addr.h0000644000175000017500000000774612576461726020441 0ustar pgquilespgquiles/* -*- C++ -*- */ /** @file URL_Addr.h * * @author Douglas C. Schmidt * @author Krishnakumar B */ #ifndef _ACEXML_URL_ADDR_H #define _ACEXML_URL_ADDR_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Default_Constants.h" #include "ace/INET_Addr.h" #include "ACEXML/common/XML_Types.h" #include "ACEXML/common/ACEXML_Export.h" /** * @class ACEXML_URL_Addr * * Defines a URL address family address format. */ class ACEXML_Export ACEXML_URL_Addr : public ACE_INET_Addr { public: /// Initialization and termination methods. ACEXML_URL_Addr (void); /// Constructor. ACEXML_URL_Addr (const ACEXML_Char *host_name, const ACEXML_Char *path_name, unsigned short port = ACE_DEFAULT_HTTP_PORT); /// Copy constructor. ACEXML_URL_Addr (const ACEXML_URL_Addr &addr); /// Essentially the copy constructor. int set (const ACEXML_URL_Addr &addr); /** * Initializes an from the
, which can be * "ip-number:port-number/path-name" (e.g., * "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name" * (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in the *
it is assumed to be an ip-number or ip-address number, with * the port number . */ virtual int string_to_addr (const ACEXML_Char* address, int address_family = AF_UNSPEC); // Function to shut up Borland C++ #if defined (ACE_USES_WCHAR) virtual int string_to_addr (const char* addresss, int address_family = AF_UNSPEC); #endif /** * Transform the current address into string format. If * is non-0 this produces * "ip-number:port-number/path-name" (e.g., * "128.252.166.57:80/~schmidt/"), whereas if is 0 this * produces "ip-name:port-number" (e.g., * "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the of the * is too small, else 0. */ virtual int addr_to_string (ACEXML_Char *s, size_t size, int ipaddr_format = 1) const; /** * Transform the current address into string format. If * is non-0 this produces * "ip-number:port-number/path-name" (e.g., * "128.252.166.57:80/~schmidt/"), whereas if is 0 this * produces "ip-name:port-number" (e.g., * "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which is * allocated on demand and deallocated when the object is destroyed. * Returns -1 if dynamic memory fails, else 0. */ virtual const ACEXML_Char *addr_to_string (int ipaddr_format = 1); /// Assignment operator. void operator= (const ACEXML_URL_Addr &addr); /// Destructor. ~ACEXML_URL_Addr (void); /** * Compare two addresses for equality. The addresses are considered * equal if they contain the same IP address, port number, and path name. */ bool operator == (const ACEXML_URL_Addr &SAP) const; /// Compare two addresses for inequality. bool operator != (const ACEXML_URL_Addr &SAP) const; /// Computes and returns hash value. virtual u_long hash (void) const; /// Return the path name. const ACEXML_Char *get_path_name (void) const; /// Commit suicide. int destroy (void); private: /// Calculate the maximum length of the address string size_t calculate_length (int ipaddr_format) const; /// Our path name. ACEXML_Char *path_name_; /// The dynamically created address string that's used for the /// method. ACEXML_Char *addr_string_; /// Current length of the size_t addr_string_len_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/URL_Addr.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* _ACEXML_URL_ADDR_H */ ace-6.3.3+dfsg.orig/ACEXML/common/ErrorHandler.cpp0000644000175000017500000000012012576461726021742 0ustar pgquilespgquiles#include "ErrorHandler.h" ACEXML_ErrorHandler::~ACEXML_ErrorHandler (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/HttpCharStream.cpp0000644000175000017500000003177012576461726022263 0ustar pgquilespgquiles#include "ace/ACE.h" #include "ace/ace_wchar.h" #include "ace/Auto_Ptr.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_string.h" #include "ACEXML/common/HttpCharStream.h" #include "ACEXML/common/Encoding.h" /* Header FSM states. */ static const int HDST_LINE1_PROTOCOL = 0; static const int HDST_LINE1_WHITESPACE = 1; static const int HDST_LINE1_STATUS = 2; static const int HDST_BOL = 10; static const int HDST_TEXT = 11; static const int HDST_LF = 12; static const int HDST_CR = 13; static const int HDST_CRLF = 14; static const int HDST_CRLFCR = 15; ACEXML_HttpCharStream::ACEXML_HttpCharStream (void) : url_(0), url_addr_(0), stream_(0), connector_(0), size_(0), data_offset_ (0), encoding_ (0) { } ACEXML_HttpCharStream::~ACEXML_HttpCharStream (void) { this->close (); } int ACEXML_HttpCharStream::open (const ACEXML_Char *url) { this->url_ = ACE::strnew (url); ACE_NEW_RETURN (this->url_addr_, ACEXML_URL_Addr, -1); ACE_NEW_RETURN (this->stream_, ACEXML_Mem_Map_Stream, -1); if (this->url_addr_->string_to_addr (this->url_) == -1) { this->close(); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot convert URL"), -1); } ACE_NEW_RETURN (this->connector_, Connector (0, ACE_NONBLOCK), -1); if (this->stream_->open (this->connector_, *this->url_addr_) == -1) { this->close(); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot open backing store"), -1); } int result = this->send_request(); if (result == -1) { this->close(); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_request"), -1); } size_t len = 0; result = this->get_url(len); if (result == -1) { this->close(); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_url"), -1); } if (result != 200) { this->close(); ACE_ERROR_RETURN ((LM_ERROR, "Server returned status %d : %s\n", result, "Refer HTTP/1.0 error code for details"), -1); } this->size_ = static_cast (len); return this->determine_encoding(); } // The FSM was taken from the implementation of http_get and that falls // under the following license: // // Copyrigh (c) 2000 by Jef Poskanzer . All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. int ACEXML_HttpCharStream::get_url (size_t& len) { if (this->stream_ == 0) { return -1; } int header_state = HDST_LINE1_PROTOCOL; int status = 0; size_t b = 0; char const * buf = 0; size_t buflen = BUFSIZ; for (;;) { buf = this->stream_->recv (buflen); if (buf == 0) { if (buflen == 0) { break; } else { continue; } } for (b = 0; b < buflen; ++b) { switch ( header_state ) { case HDST_LINE1_PROTOCOL: switch ( buf[b] ) { case ' ': case '\t': header_state = HDST_LINE1_WHITESPACE; break; case '\n': header_state = HDST_LF ; break; case '\r': header_state = HDST_CR; break; } break; case HDST_LINE1_WHITESPACE: switch ( buf[b] ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': status = buf[b] - '0'; header_state = HDST_LINE1_STATUS; break; case '\n': header_state = HDST_LF ; break; case '\r': header_state = HDST_CR; break; default: header_state = HDST_TEXT; break; } break; case HDST_LINE1_STATUS: switch ( buf[b] ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': status = status * 10 + buf[b] - '0'; break; case '\n': header_state = HDST_LF ; break; case '\r': header_state = HDST_CR; break; default: header_state = HDST_TEXT; break; } break; case HDST_BOL: switch ( buf[b] ) { case '\n': header_state = HDST_LF; break; case '\r': header_state = HDST_CR; break; default: header_state = HDST_TEXT; break; } break; case HDST_TEXT: switch ( buf[b] ) { case '\n': header_state = HDST_LF; break; case '\r': header_state = HDST_CR; break; } break; case HDST_LF: switch ( buf[b] ) { case '\n': goto end_of_headers; case '\r': header_state = HDST_CR; break; default: header_state = HDST_TEXT; break; } break; case HDST_CR: switch ( buf[b] ) { case '\n': header_state = HDST_CRLF; break; case '\r': goto end_of_headers; default: header_state = HDST_TEXT; break; } break; case HDST_CRLF: switch ( buf[b] ) { case '\n': goto end_of_headers; case '\r': header_state = HDST_CRLFCR; break; default: header_state = HDST_TEXT; break; } break; case HDST_CRLFCR: switch ( buf[b] ) { case '\n': case '\r': goto end_of_headers; default: header_state = HDST_TEXT; break; } break; } } } end_of_headers: if (b == 0) { return -1; } ++b; // Store the address of the beginning of data. We will use it to seek to // beginning of the data in the URL. char const * const data_beg = buf + b; buflen = BUFSIZ; // Get all of the data. Since this is backed by file store, we won't lose // any of the data. while ((buf = this->stream_->recv (buflen)) != 0) ; // Length of data in the URL. len = this->stream_->recv() - data_beg; // Move the pointer to the beginning of the file store. this->stream_->rewind(); this->data_offset_ = ACE_Utils::truncate_cast (data_beg - this->stream_->recv()); // Forward to the beginning of data. if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%s: %m", "Error in seeking to beginning of data"), -1); } return status; } int ACEXML_HttpCharStream::send_request (void) { char* path = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (this->url_addr_->get_path_name())); ACE_Auto_Basic_Array_Ptr path_ptr (path); size_t commandsize = ACE_OS::strlen (path) + ACE_OS::strlen (this->url_addr_->get_host_name ()) + 20 // Extra + 1 // NUL byte + 16 ; // Protocol filler... char* command; ACE_NEW_RETURN (command, char[commandsize], -1); // Ensure that the memory is deallocated. ACE_Auto_Basic_Array_Ptr cmd_ptr (command); int bytes = ACE_OS::sprintf (command, "GET %s HTTP/1.0\r\n", path); bytes += ACE_OS::sprintf (&command[bytes], "Host: %s\r\n", this->url_addr_->get_host_name ()); bytes += ACE_OS::sprintf (&command[bytes], "\r\n"); ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); // Send the command to the connected server. int retval = static_cast (this->stream_->send_n (command, bytes, &tv)); if (retval <= 0) return -1; return retval; } int ACEXML_HttpCharStream::available (void) { if (this->stream_ == 0) return -1; return static_cast (this->stream_->available()); } int ACEXML_HttpCharStream::close (void) { delete[] this->url_; this->url_ = 0; delete this->url_addr_; this->url_addr_ = 0; delete this->stream_; this->stream_ = 0; delete this->connector_; this->connector_ = 0; this->size_ = 0; this->data_offset_ = 0; delete[] this->encoding_; this->encoding_ = 0; return 0; } int ACEXML_HttpCharStream::determine_encoding (void) { if (this->stream_ == 0) return -1; char input[] = {0, 0, 0, 0}; size_t const len = sizeof (input) / sizeof (input[0]); size_t i = 0; for (; i < len && input[i] != static_cast (EOF); ++i) input[i] = this->stream_->peek_char (i); if (i < len) return -1; ACEXML_Char const * const temp = ACEXML_Encoding::get_encoding (input); if (!temp) return -1; else { if (this->encoding_) delete [] this->encoding_; this->encoding_ = ACE::strnew (temp); // ACE_DEBUG ((LM_DEBUG, "URI's encoding is %s\n", this->encoding_)); } // Move over the byte-order-mark if present. for (size_t j = 0; j < len; ++j) { if (input[j] == '\xFF' || input[j] == '\xFE' || input[j] == '\xEF' || input[j] == '\xBB' || input[j] == '\xBF') { this->stream_->get_char(); continue; } break; } return 0; } void ACEXML_HttpCharStream::rewind (void) { if (this->stream_ == 0) return; this->stream_->rewind(); // Forward to the beginning of data. if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1) ACE_ERROR ((LM_ERROR, "%s: %m", "Error in seeking to beginning of data")); this->determine_encoding(); } const ACEXML_Char* ACEXML_HttpCharStream::getEncoding (void) { return this->encoding_; } const ACEXML_Char* ACEXML_HttpCharStream::getSystemId (void) { return this->url_; } int ACEXML_HttpCharStream::read (ACEXML_Char *str, size_t len) { if (this->stream_ == 0) return -1; len = len * sizeof (ACEXML_Char); const char* temp = this->stream_->recv (len); if (temp == 0) return -1; ACE_OS::strncpy (str, ACE_TEXT_CHAR_TO_TCHAR (temp), len); return static_cast (len); } int ACEXML_HttpCharStream::get (ACEXML_Char& ch) { if (this->stream_ == 0) return -1; #if defined (ACE_USES_WCHAR) return this->get_i (ch); #else ch = (ACEXML_Char) this->stream_->get_char(); return (ch == (ACEXML_Char)EOF ? -1 :0); #endif /* ACE_USES_WCHAR */ } int ACEXML_HttpCharStream::peek (void) { if (this->stream_ == 0) return -1; #if defined (ACE_USES_WCHAR) return this->peek_i(); #else return this->stream_->peek_char (0); #endif /* ACE_USES_WCHAR */ } #if defined (ACE_USES_WCHAR) int ACEXML_HttpCharStream::get_i (ACEXML_Char& ch) { if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) { ch = (ACEXML_Char) this->stream_->get_char(); return (ch == (ACEXML_Char)EOF ? -1 : 0); } int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; ACEXML_Char input[2] = {0}; int i = 0; for (; i < 2 && (input[i] = this->stream_->get_char()) > 0; ++i) ; if (i < 2) { ch = 0; return input[i]; } ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]; return 0; } int ACEXML_HttpCharStream::peek_i (void) { // If we are reading a UTF-8 encoded file, just use the plain unget. if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0) { ACEXML_Char ch = (ACEXML_Char) this->stream_->peek_char (0); return ch; } int BE = (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0; // Peek into the stream. ACEXML_Char input[2]; int i = 0; for (; i < 2 && (input[i] = this->stream_->peek_char (i)) > 0; ++i) ; if (i < 2) return -1; return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]); } #endif /* ACE_USES_WCHAR */ ace-6.3.3+dfsg.orig/ACEXML/common/XMLFilterImpl.h0000644000175000017500000001560612576461726021467 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file XMLFilterImpl.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_XMLFILTERIMPL_H #define ACEXML_XMLFILTERIMPL_H #include /**/ "ace/pre.h" #include "ACEXML/common/XMLFilter.h" #include "ACEXML/common/XMLReader.h" #include "ACEXML/common/Locator.h" #include "ACEXML/common/ContentHandler.h" #include "ACEXML/common/DTDHandler.h" #include "ACEXML/common/EntityResolver.h" #include "ACEXML/common/ErrorHandler.h" /** * @class ACEXML_XMLFilterImpl * * @brief ACEXML_XMLFilterImpl * * This class is designed to sit between an XMLReader and the client * application's event handlers. By default, it does nothing but pass * requests up to the reader and events on to the handlers unmodified, but * subclasses can override specific methods to modify the event stream or * the configuration requests as they pass through. */ class ACEXML_Export ACEXML_XMLFilterImpl : public ACEXML_XMLFilter, public ACEXML_ContentHandler, public ACEXML_DTDHandler, public ACEXML_EntityResolver, public ACEXML_ErrorHandler { public: /** * Default constructor. Create with no parent. */ ACEXML_XMLFilterImpl (void); /** * Construct an XML filter with the specified parent. */ ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent); /** * Destructor. */ virtual ~ACEXML_XMLFilterImpl (void); /* * Look up the value of a feature. */ virtual int getFeature (const ACEXML_Char *name); /* * Look up the value of a property. */ virtual void * getProperty (const ACEXML_Char *name); /* * Parse an XML document. */ virtual void parse (ACEXML_InputSource *input); /* * Parse an XML document from a system identifier (URI). */ virtual void parse (const ACEXML_Char *systemId); /* * Set the state of a feature. */ virtual void setFeature (const ACEXML_Char *name, int boolean_value); /* * Set the value of a property. */ virtual void setProperty (const ACEXML_Char *name, void *value); /* * Get the parent reader. */ virtual ACEXML_XMLReader *getParent (void) const; /* * Set the parent reader. */ virtual void setParent (ACEXML_XMLReader *parent); /* * Get the current DTD event handler. */ virtual ACEXML_DTDHandler *getDTDHandler (void) const; /* * Get the current content event handler. */ virtual ACEXML_ContentHandler *getContentHandler (void) const; /* * Get the current entity resolver. */ virtual ACEXML_EntityResolver *getEntityResolver (void) const; /* * Get the current error event handler. */ virtual ACEXML_ErrorHandler *getErrorHandler (void) const; /* * Set the DTD event handler. */ virtual void setDTDHandler (ACEXML_DTDHandler *handler); /* * Set the content event handler. */ virtual void setContentHandler (ACEXML_ContentHandler *handler); /* * Set the entity resolver. */ virtual void setEntityResolver (ACEXML_EntityResolver *handler); /* * Set the error event handler. */ virtual void setErrorHandler (ACEXML_ErrorHandler *handler); /* * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length); /* * Receive notification of the end of a document. */ virtual void endDocument (void); /* * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /* * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix); /* * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length); /* * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data); /* * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator) ; /* * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name); /* * Receive notification of the beginning of a document. */ virtual void startDocument (void); /* * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts); /* * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri); // *** Methods inherit from ACEXML_DTDHandler. /* * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId); /* * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName); // Methods inherit from ACEXML_EnitityResolver. /* * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId); // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception); /* * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception); /* * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception); protected: int setupParser (void); // Set up the event handlers of parent parser to this. // Returns -1 if no valid parent is set. private: ACEXML_XMLReader *parent_; // ACEXML_Locator *locator_; ACEXML_EntityResolver *entityResolver_; ACEXML_DTDHandler *dtdHandler_; ACEXML_ContentHandler *contentHandler_; ACEXML_ErrorHandler *errorHandler_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/XMLFilterImpl.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* ACEXML_XMLFILTERIMPL_H */ ace-6.3.3+dfsg.orig/ACEXML/common/ZipCharStream.h0000644000175000017500000000622312576461726021546 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ZipCharStream.h * * @author Krishnakumar B */ //============================================================================= #ifndef _ACEXML_ZIPCHARSTREAM_H_ #define _ACEXML_ZIPCHARSTREAM_H_ #ifdef USE_ZZIP #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/CharStream.h" #include "ACEXML/common/Encoding.h" #include "zzip/zzip.h" // Ugly wart to get aroung a macro version of read defined in zzip.h. Evil... #ifdef read #undef read #endif /** * @class ACEXML_ZipCharStream * * An implementation of ACEXML_CharStream for reading input from a ZIP archive. */ class ACEXML_Export ACEXML_ZipCharStream : public ACEXML_CharStream { public: /// Default constructor. ACEXML_ZipCharStream (void); /// Destructor virtual ~ACEXML_ZipCharStream (void); /// Open a file. int open (const ACEXML_Char *name); /** * Returns the available ACEXML_Char in the buffer. -1 * if the object is not initialized properly. */ virtual int available (void); /** * Close this stream and release all resources used by it. */ virtual int close (void); /** * Read the next ACEXML_Char. Return -1 if we are not able to * return an ACEXML_Char, 0 if EOF is reached, or 1 if succeed. */ virtual int get (ACEXML_Char& ch); /** * Read the next batch of ACEXML_Char strings */ virtual int read (ACEXML_Char *str, size_t len); /** * Determine the encoding of the file. */ virtual int determine_encoding (void); /** * Peek the next ACEXML_Char in the CharStream. Return the * character if success, -1 if EOF is reached. */ virtual int peek (void); /** * Resets the file pointer to the beginning of the stream. */ virtual void rewind (void); /* * Get the character encoding for a byte stream or URI. */ virtual const ACEXML_Char *getEncoding (void); /* * Get the systemId for the underlying CharStream */ virtual const ACEXML_Char* getSystemId (void); protected: /** Read the next character as a normal character. Return -1 if EOF is * reached, else return 0. */ virtual int getchar_i (char& ch); /** * Peek @c offset bytes into the stream and return the character at @c * offset. If EOF is reached, return -1. */ virtual int peekchar_i (ACE_OFF_T offset = 0); private: #if defined (ACE_USES_WCHAR) /** * Read the next character from the stream taking into account the * encoding of the file. */ int get_i (ACEXML_Char& ch); /** * Return the next character from the stream taking into account the * encoding of the file. Subsequent call to get() returns this * character. */ int peek_i (void); #endif /* ACE_USES_WCHAR */ ACEXML_Char* filename_; ACEXML_Char* encoding_; ACE_OFF_T size_; ZZIP_FILE* infile_; char buf_[80]; int pos_; int limit_; }; #include /**/ "ace/post.h" #endif /* USE_ZZIP */ #endif /* _ACEXML_ZIPCHARSTREAM_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/InputSource.cpp0000644000175000017500000000413512576461726021645 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/InputSource.h" #include "ACEXML/common/StreamFactory.h" #include "ace/ACE.h" ACEXML_InputSource::ACEXML_InputSource (void) : charStream_ (0), encoding_ (0), publicId_ (0), systemId_ (0) { } ACEXML_InputSource::ACEXML_InputSource (ACEXML_CharStream *stm) : charStream_ (stm), encoding_ (ACE::strnew (stm->getEncoding())), publicId_ (0), systemId_ (stm->getSystemId() ? ACE::strnew (stm->getSystemId()): 0) { } /* * Create a new input source with a character stream. * */ ACEXML_InputSource::ACEXML_InputSource (const ACEXML_Char *systemId) : charStream_ (0), encoding_ (0), publicId_ (0), systemId_ (ACE::strnew (systemId)) { ACEXML_StreamFactory factory; ACEXML_CharStream* stm = factory.create_stream (this->systemId_); if (stm) { this->setCharStream (stm); this->setEncoding (this->charStream_->getEncoding()); } } ACEXML_InputSource::~ACEXML_InputSource (void) { delete[] this->publicId_; this->publicId_ = 0; delete[] this->systemId_; this->systemId_ = 0; delete this->charStream_; this->charStream_ = 0; delete[] this->encoding_; this->encoding_ = 0; } ACEXML_CharStream * ACEXML_InputSource::getCharStream (void) const { return this->charStream_; } const ACEXML_Char * ACEXML_InputSource::getEncoding (void) const { return this->encoding_; } const ACEXML_Char * ACEXML_InputSource::getPublicId (void) const { return this->publicId_; } const ACEXML_Char * ACEXML_InputSource::getSystemId (void) const { return this->systemId_; } void ACEXML_InputSource::setCharStream (ACEXML_CharStream *stm) { delete this->charStream_; this->charStream_ = stm; } void ACEXML_InputSource::setEncoding (const ACEXML_Char *encoding) { delete[] this->encoding_; this->encoding_ = ACE::strnew (encoding); } void ACEXML_InputSource::setPublicId (const ACEXML_Char *publicId) { delete[] this->publicId_; this->publicId_ = ACE::strnew (publicId); } void ACEXML_InputSource::setSystemId (const ACEXML_Char *systemId) { delete[] this->systemId_; this->systemId_ = ACE::strnew (systemId); } ace-6.3.3+dfsg.orig/ACEXML/common/DTDHandler.h0000644000175000017500000000464212576461726020746 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file DTDHandler.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_DTDHANDLER_H_ #define _ACEXML_DTDHANDLER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/SAXExceptions.h" /** * @class ACEXML_DTDHandler * * @brief ACEXML_DTDHandler * * If a SAX application needs information about notations and unparsed * entities, then the application implements this interface and registers * an instance with the SAX parser using the parser's setDTDHandler method. * The parser uses the instance to report notation and unparsed entity * declarations to the application. * * Note that this interface includes only those DTD events that the XML * recommendation requires processors to report: notation and unparsed * entity declarations. * * The SAX parser may report these events in any order, regardless of the * order in which the notations and unparsed entities were declared; * however, all DTD events must be reported after the document handler's * startDocument event, and before the first startElement event. * * It is up to the application to store the information for future use * (perhaps in a hash table or object tree). If the application encounters * attributes of type "NOTATION", "ENTITY", or "ENTITIES", it can use the * information that it obtained through this interface to find the entity * and/or notation corresponding with the attribute value. */ class ACEXML_Export ACEXML_DTDHandler { public: virtual ~ACEXML_DTDHandler (void); /** * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId) = 0; /** * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_DTDHANDLER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/XML_Util.cpp0000644000175000017500000000230512576461726021017 0ustar pgquilespgquiles#include "ACEXML/common/XML_Util.h" static const ACEXML_Char ESCAPED_AMP[] = ACE_TEXT("&"); static const ACEXML_Char ESCAPED_LESS[] = ACE_TEXT("<"); static const ACEXML_Char ESCAPED_GREATER[] = ACE_TEXT(">"); static const ACEXML_Char ESCAPED_APOS[] = ACE_TEXT("'"); static const ACEXML_Char ESCAPED_QUOTE[] = ACE_TEXT("""); #define CSTRLEN(x) ((sizeof(x) / sizeof(ACEXML_Char)) - 1) ACEXML_String ACEXML_escape_string(const ACEXML_String& str) { ACEXML_String ret(str.length ()); ACEXML_escape_string(str, ret); return ret; } void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out) { size_t len = in.length (); out.clear(); for (size_t stridx = 0; stridx < len; ++stridx) { switch (in[stridx]) { case '&': out.append(ESCAPED_AMP, CSTRLEN(ESCAPED_AMP)); break; case '<': out.append(ESCAPED_LESS, CSTRLEN(ESCAPED_LESS)); break; case '>': out.append(ESCAPED_GREATER, CSTRLEN(ESCAPED_GREATER)); break; case '\'': out.append(ESCAPED_APOS, CSTRLEN(ESCAPED_APOS)); break; case '\"': out.append(ESCAPED_QUOTE, CSTRLEN(ESCAPED_QUOTE)); break; default: out += in[stridx]; } } } ace-6.3.3+dfsg.orig/ACEXML/common/XML_Types.h0000644000175000017500000000452212576461726020656 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file XML_Types.h * * This file collects the type definitions for data types * used in ACE XML parser. * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_XML_TYPES_H_ #define _ACEXML_XML_TYPES_H_ #include /**/ "ace/pre.h" #include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Basic_Types.h" #include "ace/SString.h" #include "ace/Functor_String.h" # if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 2) typedef wchar_t ACEXML_UTF16; # else typedef ACE_UINT16 ACEXML_UTF16; # endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 2 */ # if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 4) typedef wchar_t ACEXML_UCS4; # else typedef ACE_UINT32 ACEXML_UCS4; # endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 4 */ typedef char ACEXML_UTF8; /** * @typedef ACEXML_Char * ACEXML_Char only maps to ACEXML_UTF16 when ACE_USES_WCHAR is defined. * Here we assume sizeof (wchar_t) is always 2 bytes. * * Default XML strings will use UTF-8 encoding. We would like to use * the string classes in standard C++ Library here. But they are not * very portable yet (as far as I know,) and I'll just use ACE_CString * for now, unless UNICODE support is turned on. Notice that you * should never convert strings between ACE_CString and ACE_WString * using the built-in conversion functions as they only perform simple * copy without any encoding conversion. */ typedef ACE_TCHAR ACEXML_Char; # if defined (ACE_USES_WCHAR) //typedef ACEXML_UTF16 ACEXML_Char; typedef ACE_WString ACEXML_String; # else //typedef ACEXML_UTF8 ACEXML_Char; typedef ACE_CString ACEXML_String; # endif /* ACE_USES_WCHAR */ # if (!defined (ACEXML_HAS_INLINE) && defined (__ACE_INLINE__)) || (ACEXML_HAS_INLINE == 1) # define __ACEXML_INLINE__ inline # else # if defined (__ACEXML_INLINE__) # undef __ACEXML_INLINE__ # endif /* __ACEXML_INLINE__ */ # endif /* (!ACEXML_HAS_INLINE) && (__ACE_INLINE__) || (ACEXML_HAS_INLINE == 1) */ # if defined (__ACEXML_INLINE__) # define ACEXML_INLINE inline # else # define ACEXML_INLINE # endif /* __ACEXML_INLINE */ #include /**/ "ace/post.h" #endif /* _ACEXML_XML_TYPE_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Element_Def_Builder.h0000644000175000017500000000603512576461726022650 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Element_Def_Builder.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ELEMENT_DEF_BUILDER_H_ #define _ACEXML_ELEMENT_DEF_BUILDER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Auto_Ptr.h" #include "ACEXML/common/XML_Types.h" #include "ACEXML/common/SAXExceptions.h" /** * @class ACEXML_Element_Def_Builder * * @brief An abstract virtual class that defines the interface to define an * element definition. * * This class defines how to define an element definition after parsing a * DTD. */ class ACEXML_Export ACEXML_Element_Def_Builder { public: typedef auto_ptr VAR; typedef enum { EMPTY, ANY, MIXED, CHILDREN, UNDEFINED } CONTENT_TYPE; typedef enum { ONE, ZERO_OR_MORE, ONE_OR_MORE, ONE_OR_ZERO } CARDINALITY; virtual ~ACEXML_Element_Def_Builder () = 0; /** * Define the name of the element. * * @retval 0 if valid, -1 otherwise. */ virtual int setElementName (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; /** * Define the content type of the element. * * @retval 0 if valid, -1 otherwise. */ virtual int setContentType (CONTENT_TYPE type) = 0; /** * Insert one more element into Mixed definition. */ virtual int insertMixedElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; /** * Start a new group of children. */ virtual int startChildGroup () = 0; /** * End a new group of children. * * @retval 0 on success. */ virtual int endChildGroup (CARDINALITY card) = 0; /** * Set the type of current child group to Choice. * * @retval 0 on success, -1 if the type of the child group has * already been set and this action conflicts with the previous * setting. */ virtual int setChoice () = 0; /** * Set the type of current child group to Sequence. * * @retval 0 on success, -1 if the type of the child group has * already been set and this action conflicts with the previous * setting. */ virtual int setSequence () = 0; /** * Insert an new element into the current child group. * * @retval 0 on success, -1 otherwise. */ virtual int insertElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; /** * Dump the content of the attribute definition. */ virtual void dump (void) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_ELEMENT_DEF_BUILDER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/XMLReader.cpp0000644000175000017500000000010712576461726021143 0ustar pgquilespgquiles#include "XMLReader.h" ACEXML_XMLReader::~ACEXML_XMLReader (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/Transcode.cpp0000644000175000017500000002034712576461726021312 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/Transcode.h" #include "ace/OS_NS_string.h" #include "ace/Truncate.h" int ACEXML_Transcoder::utf162utf8 (ACEXML_UTF16 src, ACEXML_UTF8 *dst, size_t len) { // Check for valid argument first... if (dst == 0) return ACEXML_INVALID_ARGS; if (src < 0x80) { if (len < 1) return ACEXML_DESTINATION_TOO_SHORT; *dst = static_cast (src); return 1; } else if (src < 0x800) { if (len < 2) return ACEXML_DESTINATION_TOO_SHORT; *dst = 0xc0 | (static_cast (src) / 0x40); *(dst+1) = 0x80 | (static_cast (src) % 0x40); return 2; } else { if (len < 3) return ACEXML_DESTINATION_TOO_SHORT; // Surrogates (0xD800 - 0xDFFF) are not valid unicode values if (src >= 0xD800 && src < 0xE000) return ACEXML_IS_SURROGATE; *dst = 0xe0 | (static_cast (src) / 0x1000); *(dst+1) = 0x80 | ((static_cast (src) % 0x1000) / 0x40); *(dst+2) = 0x80 | (static_cast (src) % 0x40); return 3; } } int ACEXML_Transcoder::ucs42utf8 (ACEXML_UCS4 src, ACEXML_UTF8 *dst, size_t len) { if (src < 0x10000) { int retv = ACEXML_Transcoder::utf162utf8 (static_cast (src), dst, len); return (retv == ACEXML_IS_SURROGATE ? ACEXML_NON_UNICODE : retv); } else if (src >= 0x100000 && src < 0x110000) { if (len < 4) return ACEXML_DESTINATION_TOO_SHORT; if (dst == 0) return ACEXML_INVALID_ARGS; *dst = 0xf0 | (static_cast (src / 0x40000)); *(dst+1) = 0x80 | ((static_cast (src % 0x40000)) / 0x1000); *(dst+2) = 0x80 | ((static_cast (src % 0x1000)) / 0x40); *(dst+3) = 0x80 | (static_cast (src % 0x40)); return 4; } return ACEXML_NON_UNICODE; } int ACEXML_Transcoder::ucs42utf16 (ACEXML_UCS4 src, ACEXML_UTF16 *dst, size_t len) { if (dst == 0) return ACEXML_INVALID_ARGS; if (src < 0x10000) { if (len < 1) return ACEXML_DESTINATION_TOO_SHORT; if (src >= 0xD800 && src < 0xE000) return ACEXML_NON_UNICODE; // Surrogates are not valid unicode value *dst = static_cast (src); return 1; } else if (src >= 0x100000 && src < 0x110000) // Scalar values are encoded into surrogates { if (len < 2) return ACEXML_DESTINATION_TOO_SHORT; *dst = 0xD800 | (static_cast (src) / 0x400); *(dst+1) = 0xDC00 | (static_cast (src) % 0x400); return 2; } return ACEXML_NON_UNICODE; } int ACEXML_Transcoder::surrogate2utf8 (ACEXML_UTF16 high, ACEXML_UTF16 low, ACEXML_UTF8 *dst, size_t len) { if (len < 3) return ACEXML_DESTINATION_TOO_SHORT; if (dst == 0 || (high >= 0xD800 && high < 0xDC00) || (low >= 0xDC00 && low < 0xE000)) return ACEXML_INVALID_ARGS; ACEXML_UCS4 src = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; *dst = static_cast (0xD800 | (src / 0x400)); *(dst+1) = static_cast (0xDC00 | (src % 0x400)); return 2; } int ACEXML_Transcoder::surrogate2ucs4 (ACEXML_UTF16 high, ACEXML_UTF16 low, ACEXML_UCS4 &dst) { if ((high >= 0xD800 && high < 0xDC00) || (low >= 0xDC00 && low < 0xE000)) return ACEXML_INVALID_ARGS; dst = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; return ACEXML_SUCCESS; } int ACEXML_Transcoder::utf82ucs4 (const ACEXML_UTF8 *the_src, size_t len, ACEXML_UCS4 &dst) { if (the_src == 0) { return ACEXML_INVALID_ARGS; } const unsigned char *src = reinterpret_cast (the_src); size_t forward = 1; if (forward > len) { return ACEXML_END_OF_SOURCE; } if (static_cast (*src) < 0x80) { dst = *src; } else if ((*src & 0xE0) == 0xC0) { dst = (*(src++) & 0x1f) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; // Error transcoding unicode scalar dst += *src & 0x3f; } else if ((*src & 0xF0) == 0xE0) { dst = (*src++ & 0x0f) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; dst = (dst + (*src++ & 0x3f)) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; dst += *src & 0x3f; } else if ((*src & 0xF8) == 0xF0) { dst = (*src++ & 0x0f) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; dst = (dst + (*src++ & 0x3f)) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; dst = (dst + (*src++ & 0x3f)) * 0x40; if (++forward > len) return ACEXML_END_OF_SOURCE; if ((*src & 0xC0) != 0x80) return ACEXML_NON_UNICODE; dst += *src & 0x3f; } else { return ACEXML_NON_UNICODE; } return ACE_Utils::truncate_cast (forward); } int ACEXML_Transcoder::utf162ucs4 (const ACEXML_UTF16 *src, size_t len, ACEXML_UCS4 &dst) { if (src == 0) { return ACEXML_INVALID_ARGS; } size_t forward = 1; if (*src >= 0xDC00 && *src < 0xE000) { if (len < 2) { return ACEXML_END_OF_SOURCE; } return ACEXML_Transcoder::surrogate2ucs4 (*src, *(src+1), dst); } else { if (len < 1) { return ACEXML_END_OF_SOURCE; } dst = *src; } return ACE_Utils::truncate_cast (forward); } int ACEXML_Transcoder::utf8s2utf16s (const ACEXML_UTF8 *src, ACEXML_UTF16 *dst, size_t len) { if (src == 0 || dst == 0) { return ACEXML_INVALID_ARGS; } size_t src_len = ACE_OS::strlen (src) + 1; size_t total_len = 0; int forward; ACEXML_UCS4 temp; while (src_len > 0) { if ((forward = ACEXML_Transcoder::utf82ucs4 (src, src_len, temp)) <= 0) return forward; src += forward; src_len -= forward; if ((forward = ACEXML_Transcoder::ucs42utf16 (temp, dst, len)) <= 0) return forward; total_len += forward; dst += forward; len -= forward; } return ACE_Utils::truncate_cast (total_len); } int ACEXML_Transcoder::utf16s2utf8s (const ACEXML_UTF16 *src, ACEXML_UTF8 *dst, size_t len) { if (src == 0 || dst == 0) return ACEXML_INVALID_ARGS; size_t src_len = 1; for (const ACEXML_UTF16 *p = src; *p++ != 0; ++src_len) ; size_t total_len = 0; int forward; ACEXML_UCS4 temp; while (src_len > 0) { if ((forward = ACEXML_Transcoder::utf162ucs4 (src, src_len, temp)) <= 0) return forward; src += forward; src_len -= forward; if ((forward = ACEXML_Transcoder::ucs42utf8 (temp, dst, len)) <= 0) return forward; total_len += forward; dst += forward; len -= forward; } return ACE_Utils::truncate_cast (total_len); } ace-6.3.3+dfsg.orig/ACEXML/common/ACEXML_Export.h0000644000175000017500000000316312576461726021344 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ACEXML_Export.h * * @author Nanbor Wang */ //============================================================================= // Definition for Win32 Export directives. // This file is generated automatically by generate_export_file.pl // ------------------------------ #ifndef ACEXML_EXPORT_H #define ACEXML_EXPORT_H #include "ace/config-all.h" #if defined (ACE_AS_STATIC_LIBS) # if !defined (ACEXML_HAS_DLL) # define ACEXML_HAS_DLL 0 # endif /* ! ACEXML_HAS_DLL */ #else # if !defined (ACEXML_HAS_DLL) # define ACEXML_HAS_DLL 1 # endif /* ! ACEXML_HAS_DLL */ #endif /* ACE_AS_STATIC_LIB */ #if defined (ACEXML_HAS_DLL) && (ACEXML_HAS_DLL == 1) # if defined (ACEXML_BUILD_DLL) # define ACEXML_Export ACE_Proper_Export_Flag # define ACEXML_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) # define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # else /* ACEXML_BUILD_DLL */ # define ACEXML_Export ACE_Proper_Import_Flag # define ACEXML_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) # define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # endif /* ACEXML_BUILD_DLL */ #else /* ACEXML_HAS_DLL == 1 */ # define ACEXML_Export # define ACEXML_SINGLETON_DECLARATION(T) # define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) #endif /* ACEXML_HAS_DLL == 1 */ #endif /* ACEXML_EXPORT_H */ // End of auto generated file. ace-6.3.3+dfsg.orig/ACEXML/common/LocatorImpl.h0000644000175000017500000000754112576461726021263 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file LocatorImpl.h * * @author Nanbor Wang * @author Krishnakumar Balasubramanian */ //============================================================================= #ifndef ACEXML_LOCALTORIMPL_H #define ACEXML_LOCALTORIMPL_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Locator.h" #include "ace/Copy_Disabled.h" /** * @class ACEXML_LocatorImpl * * @brief ACEXML_LocatorImpl is an implementation of ACEXML_Locator. * * This class is available mainly for application writers, who can * use it to make a persistent snapshot of a locator at any point * during a document parse: * * @code * ACEXML_Locator locator; * ACEXML_Locator startloc; * * public void setLocator (ACEXML_Locator locator) * { * // note the locator * this.locator = locator; * } * * public void startDocument () * { * // save the location of the start of the document * // for future use. * ACEXML_Locator startloc = new ACEXML_LocatorImpl(locator); * } * @endcode * * Normally, parser writers will not use this class, since it is more * efficient to provide location information only when requested, * rather than constantly updating a Locator object. * * @todo ACEXML parser doesn't support the use of Locator yet. * * @sa ACEXML_Locator */ class ACEXML_Export ACEXML_LocatorImpl : public ACEXML_Locator, private ACE_Copy_Disabled { public: /* * Default constructor. */ ACEXML_LocatorImpl (void); /** * Construct a locator with systemId and publicId * */ ACEXML_LocatorImpl (const ACEXML_Char* systemId, const ACEXML_Char* publicId); /** * Copy constructor. Create a persistent copy of the current state * of a locator. When the original locator changes, this copy will * still keep the original values (and it can be used outside the * scope of DocumentHandler methods). */ ACEXML_LocatorImpl (const ACEXML_Locator& locator); /* * Destructor. */ virtual ~ACEXML_LocatorImpl (void); /* * Return the column number where the current document event ends. */ virtual int getColumnNumber (void) const; /* * Return the line number where the current document event ends. */ virtual int getLineNumber (void) const; /* * Return the public identifier for the current document event. */ virtual const ACEXML_Char *getPublicId (void) const; /* * Return the system identifier for the current document event. */ virtual const ACEXML_Char *getSystemId (void) const; /* * Set the column number of this locator. */ void setColumnNumber (int cn); /* * Set the line number of this locator. */ void setLineNumber (int ln); /* * Set the public identifier of this locator. */ void setPublicId (const ACEXML_Char *id); /* * Set the system identifier of this locator. */ void setSystemId (const ACEXML_Char *id); /* * Increment the line number. */ void incrLineNumber (); /* * Increment the column number. */ void incrColumnNumber (); /* * Reset the Locator information. This is necessary because one might * want to use the same parser to parse multiple files. In that case, * tying the life of the Locator with the parser is not appropriate. The * parser calls this method as soon as issuing an endDocument() call. */ void reset (void); private: ACEXML_Char *publicId_; ACEXML_Char *systemId_; int lineNumber_; int columnNumber_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/LocatorImpl.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* ACEXML_LOCALTORIMPL_H */ ace-6.3.3+dfsg.orig/ACEXML/common/StreamFactory.cpp0000644000175000017500000000235112576461726022146 0ustar pgquilespgquiles#include "ace/OS_NS_string.h" #include "ACEXML/common/StreamFactory.h" #include "ACEXML/common/FileCharStream.h" #include "ACEXML/common/HttpCharStream.h" #ifdef USE_ZZIP #include "ACEXML/common/ZipCharStream.h" #endif /* USE_ZZIP */ ACEXML_CharStream* ACEXML_StreamFactory::create_stream (const ACEXML_Char* uri) { if (uri == 0) return 0; ACEXML_FileCharStream* fstream = 0; ACEXML_HttpCharStream* hstream = 0; if (ACE_OS::strstr (uri, ACE_TEXT("ftp://")) != 0) { return 0; } else if (ACE_OS::strstr (uri, ACE_TEXT ("http://")) != 0) { ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0); if (hstream->open (uri) != -1) return hstream; } else { if (ACE_OS::strstr (uri, ACE_TEXT ("file://")) != 0) uri += 7; // Skip over file:// ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0); if (fstream->open (uri) != -1) return fstream; #ifdef USE_ZZIP else { ACEXML_ZipCharStream* zstream = 0; ACE_NEW_RETURN (zstream, ACEXML_ZipCharStream, 0); if (zstream->open (uri) != -1) return zstream; } #endif /* USE_ZZIP */ } return 0; } ACEXML_StreamFactory::~ACEXML_StreamFactory () { // No op } ace-6.3.3+dfsg.orig/ACEXML/common/AttributesImpl.cpp0000644000175000017500000001576112576461726022344 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/AttributesImpl.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/common/AttributesImpl.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_AttributesImpl::ACEXML_AttributesImpl (int size) : attrs_ (size) { this->attrs_.size (0); // attrs array contains nothing } ACEXML_AttributesImpl::ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs) : ACEXML_Attributes (attrs), attrs_ (attrs.attrs_.size ()) { for (size_t i = 0; i < attrs.attrs_.size (); i++) this->attrs_[i] = attrs.attrs_[i]; } ACEXML_AttributesImpl::~ACEXML_AttributesImpl (void) { } int ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value) { if (this->isDuplicate (uri, localName, qName)) return -1; size_t length = this->attrs_.size (); this->attrs_.size (length+1); this->setAttribute (length, uri, localName, qName, type, value); return static_cast (length); } int ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute &att) { if (this->isDuplicate (att.uri(), att.localName(), att.qName())) return -1; size_t length = this->attrs_.size (); this->attrs_.size (length+1); this->attrs_[length] = att; return static_cast (length); } int ACEXML_AttributesImpl::isDuplicate (const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName) { for (size_t i = 0; i < this->attrs_.size(); ++i) { if (ACE_OS::strcmp (this->attrs_[i].localName(), localName) == 0) { if (qName != 0 && this->attrs_[i].qName() != 0 && ACE_OS::strcmp (this->attrs_[i].qName(), qName) == 0) { if (uri != 0 && this->attrs_[i].uri() != 0 && ACE_OS::strcmp (this->attrs_[i].uri(), uri) == 0) return 1; } } } return 0; } int ACEXML_AttributesImpl::removeAttribute (size_t index) { size_t length = this->attrs_.size (); if (index >= length) return -1; this->attrs_[index] = this->attrs_[length - 1]; this->attrs_.size (length - 1); return 0; } int ACEXML_AttributesImpl::getIndex (const ACEXML_Char *qName) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0) return static_cast (i); return -1; } int ACEXML_AttributesImpl::getIndex (const ACEXML_Char *uri, const ACEXML_Char *localPart) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 && ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0) return static_cast (i); return -1; } size_t ACEXML_AttributesImpl::getLength (void) { return this->attrs_.size (); } const ACEXML_Char * ACEXML_AttributesImpl::getLocalName (size_t index) { if (index < this->attrs_.size ()) return this->attrs_[index].localName (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getQName (size_t index) { if (index < this->attrs_.size ()) return this->attrs_[index].qName (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getType (size_t index) { if (index < this->attrs_.size ()) return this->attrs_[index].type (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getType (const ACEXML_Char *qName) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0) return this->attrs_[i].type (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getType (const ACEXML_Char *uri, const ACEXML_Char *localPart) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 && ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0) return this->attrs_[i].type (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getURI (size_t index) { if (index < this->attrs_.size ()) return this->attrs_[index].uri (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getValue (size_t index) { if (index < this->attrs_.size ()) return this->attrs_[index].value (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getValue (const ACEXML_Char *qName) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0) return this->attrs_[i].value (); return 0; } const ACEXML_Char * ACEXML_AttributesImpl::getValue (const ACEXML_Char *uri, const ACEXML_Char *localPart) { for (size_t i = 0; i < this->attrs_.size (); i++) if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 && ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0) return this->attrs_[i].value (); return 0; } int ACEXML_AttributesImpl::setAttribute (size_t index, const ACEXML_Char *uri, const ACEXML_Char *localName, const ACEXML_Char *qName, const ACEXML_Char *type, const ACEXML_Char *value) { if (index < this->attrs_.size ()) { this->attrs_[index].setAttribute (uri, localName, qName, type, value); return 0; } return -1; } int ACEXML_AttributesImpl::setLocalName (size_t index, const ACEXML_Char *localName) { if (index < this->attrs_.size ()) { this->attrs_[index].localName (localName); return 0; } return -1; } int ACEXML_AttributesImpl::setQName (size_t index, const ACEXML_Char *qName) { if (index < this->attrs_.size ()) { this->attrs_[index].qName (qName); return 0; } return -1; } int ACEXML_AttributesImpl::setURI (size_t index, const ACEXML_Char *uri) { if (index < this->attrs_.size ()) { this->attrs_[index].uri (uri); return 0; } return -1; } int ACEXML_AttributesImpl::setType (size_t index, const ACEXML_Char *type) { if (index < this->attrs_.size ()) { this->attrs_[index].type (type); return 0; } return -1; } int ACEXML_AttributesImpl::setValue (size_t index, const ACEXML_Char *value) { if (index < this->attrs_.size ()) { this->attrs_[index].value (value); return 0; } return -1; } ace-6.3.3+dfsg.orig/ACEXML/common/common.mpc0000644000175000017500000000120112576461726020641 0ustar pgquilespgquiles// -*- MPC -*- project(ACEXML): acelib, ace_output, codecs, install, zzip, zlib { avoids += ace_for_tao sharedname = ACEXML dynamicflags += ACEXML_BUILD_DLL specific { install_dir = ACEXML/common } Source_Files { // This file will only be added if the ace_codecs feature is enabled. // See codecs.mpb for more information. !XML_Codecs.cpp } Header_Files { ACEXML_Export.h Attributes.h ContentHandler.h DTDHandler.h EntityResolver.h ErrorHandler.h Locator.h XMLFilter.h XMLReader.h XML_Types.h XML_Util.h } Pkgconfig_Files { ACEXML.pc.in } } ace-6.3.3+dfsg.orig/ACEXML/common/XMLFilterImpl.cpp0000644000175000017500000001674112576461726022023 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/XMLFilterImpl.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/common/XMLFilterImpl.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (void) : parent_ (0), // locator_ (0), entityResolver_ (0), dtdHandler_ (0), contentHandler_ (0), errorHandler_ (0) { } ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent) : parent_ (parent), // locator_ (0), entityResolver_ (0), dtdHandler_ (0), contentHandler_ (0), errorHandler_ (0) { } ACEXML_XMLFilterImpl::~ACEXML_XMLFilterImpl (void) { // @@ How are all the object lifecycles managed? } void ACEXML_XMLFilterImpl::parse (ACEXML_InputSource *input) { if (this->setupParser () < 0) { throw ACEXML_SAXException (ACE_TEXT ("No Parent available")); } this->parent_->parse (input); } void ACEXML_XMLFilterImpl::parse (const ACEXML_Char *systemId) { if (this->setupParser () < 0) { throw ACEXML_SAXException (ACE_TEXT ("No Parent available")); } this->parent_->parse (new ACEXML_InputSource (systemId)); } int ACEXML_XMLFilterImpl::getFeature (const ACEXML_Char *name) { if (this->parent_ != 0) return this->parent_->getFeature (name); throw ACEXML_SAXNotRecognizedException (name); } void * ACEXML_XMLFilterImpl::getProperty (const ACEXML_Char *name) { if (this->parent_ != 0) return this->parent_->getProperty (name); throw ACEXML_SAXNotRecognizedException (name); } void ACEXML_XMLFilterImpl::setFeature (const ACEXML_Char *name, int boolean_value) { if (this->parent_ != 0) { this->parent_->setFeature (name, boolean_value); } else { throw ACEXML_SAXNotRecognizedException (name); } } void ACEXML_XMLFilterImpl::setProperty (const ACEXML_Char *name, void *value) { if (this->parent_ != 0) { this->parent_->setProperty (name, value); } else { throw ACEXML_SAXNotRecognizedException (name); } } ACEXML_XMLReader * ACEXML_XMLFilterImpl::getParent (void) const { return this->parent_; } void ACEXML_XMLFilterImpl::setParent (ACEXML_XMLReader *parent) { this->parent_ = parent; } void ACEXML_XMLFilterImpl::characters (const ACEXML_Char *ch, size_t start, size_t length) { if (this->contentHandler_ != 0) this->contentHandler_->characters (ch, start, length); } void ACEXML_XMLFilterImpl::endDocument (void) { if (this->contentHandler_ != 0) this->contentHandler_->endDocument (); } void ACEXML_XMLFilterImpl::endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) { if (this->contentHandler_ != 0) this->contentHandler_->endElement (namespaceURI, localName, qName); } void ACEXML_XMLFilterImpl::endPrefixMapping (const ACEXML_Char *prefix) { if (this->contentHandler_ != 0) this->contentHandler_->endPrefixMapping (prefix); } void ACEXML_XMLFilterImpl::ignorableWhitespace (const ACEXML_Char *ch, int start, int length) { if (this->contentHandler_ != 0) this->contentHandler_->ignorableWhitespace (ch, start, length); } void ACEXML_XMLFilterImpl::processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data) { if (this->contentHandler_ != 0) this->contentHandler_->processingInstruction (target, data); } void ACEXML_XMLFilterImpl::setDocumentLocator (ACEXML_Locator *locator) { if (this->contentHandler_ != 0) this->contentHandler_->setDocumentLocator (locator); } void ACEXML_XMLFilterImpl::skippedEntity (const ACEXML_Char *name) { if (this->contentHandler_ != 0) this->contentHandler_->skippedEntity (name); } void ACEXML_XMLFilterImpl::startDocument (void) { if (this->contentHandler_ != 0) this->contentHandler_->startDocument (); } void ACEXML_XMLFilterImpl::startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts) { if (this->contentHandler_ != 0) this->contentHandler_->startElement (namespaceURI, localName, qName, atts); } void ACEXML_XMLFilterImpl::startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri) { if (this->contentHandler_ != 0) this->contentHandler_->startPrefixMapping (prefix, uri); } void ACEXML_XMLFilterImpl::notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId) { if (this->dtdHandler_ != 0) this->dtdHandler_->notationDecl (name, publicId, systemId); } void ACEXML_XMLFilterImpl::unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName) { if (this->dtdHandler_ != 0) this->dtdHandler_->unparsedEntityDecl (name, publicId, systemId, notationName); } ACEXML_InputSource * ACEXML_XMLFilterImpl::resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId) { if (this->entityResolver_ != 0) return this->entityResolver_->resolveEntity (publicId, systemId); return 0; } void ACEXML_XMLFilterImpl::error (ACEXML_SAXParseException &exception) { if (this->errorHandler_ != 0) this->errorHandler_->error (exception); } void ACEXML_XMLFilterImpl::fatalError (ACEXML_SAXParseException &exception) { if (this->errorHandler_ != 0) this->errorHandler_->fatalError (exception); } void ACEXML_XMLFilterImpl::warning (ACEXML_SAXParseException &exception) { if (this->errorHandler_ != 0) this->errorHandler_->warning (exception); } ACEXML_DTDHandler * ACEXML_XMLFilterImpl::getDTDHandler (void) const { return this->dtdHandler_; } ACEXML_ContentHandler * ACEXML_XMLFilterImpl::getContentHandler (void) const { return this->contentHandler_; } ACEXML_EntityResolver * ACEXML_XMLFilterImpl::getEntityResolver (void) const { return this->entityResolver_; } ACEXML_ErrorHandler * ACEXML_XMLFilterImpl::getErrorHandler (void) const { return this->errorHandler_; } void ACEXML_XMLFilterImpl::setDTDHandler (ACEXML_DTDHandler *handler) { this->dtdHandler_ = handler; } void ACEXML_XMLFilterImpl::setContentHandler (ACEXML_ContentHandler *handler) { this->contentHandler_ = handler; } void ACEXML_XMLFilterImpl::setEntityResolver (ACEXML_EntityResolver *handler) { this->entityResolver_ = handler; } void ACEXML_XMLFilterImpl::setErrorHandler (ACEXML_ErrorHandler *handler) { this->errorHandler_ = handler; } ace-6.3.3+dfsg.orig/ACEXML/common/XMLReader.h0000644000175000017500000000616012576461726020615 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file XMLReader.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_XMLREADER_H_ #define _ACEXML_XMLREADER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/ContentHandler.h" #include "ACEXML/common/DTDHandler.h" #include "ACEXML/common/EntityResolver.h" #include "ACEXML/common/ErrorHandler.h" /** * @class ACEXML_XMLReader * * @brief ACEXML_XMLReader * * XMLReader is the interface that an XML parser's SAX2 driver must * implement. This interface allows an application to set and query * features and properties in the parser, to register event handlers * for document processing, and to initiate a document parse. * * All SAX interfaces are assumed to be synchronous: the parse methods * must not return until parsing is complete, and readers must wait * for an event-handler callback to return before reporting the next * event. */ class ACEXML_Export ACEXML_XMLReader { public: virtual ~ACEXML_XMLReader (void); /** * Return the current content handler. */ virtual ACEXML_ContentHandler *getContentHandler (void) const = 0; /** * Return the current DTD handler. */ virtual ACEXML_DTDHandler *getDTDHandler (void) const = 0; /** * Return the current entity resolver. */ virtual ACEXML_EntityResolver *getEntityResolver (void) const = 0; /** * Return the current error handler. */ virtual ACEXML_ErrorHandler *getErrorHandler (void) const = 0; /** * Look up the value of a feature. This method allows * programmers to check whether a specific feature has been * activated in the parser. */ virtual int getFeature (const ACEXML_Char *name) = 0; /** * Look up the value of a property. */ virtual void * getProperty (const ACEXML_Char *name) = 0; /** * Parse an XML document. */ virtual void parse (ACEXML_InputSource *input) = 0; /** * Parse an XML document from a system identifier (URI). */ virtual void parse (const ACEXML_Char *systemId) = 0; /** * Allow an application to register a content event handler. */ virtual void setContentHandler (ACEXML_ContentHandler *handler) = 0; /** * Allow an application to register a DTD event handler. */ virtual void setDTDHandler (ACEXML_DTDHandler *handler) = 0; /** * Allow an application to register an entity resolver. */ virtual void setEntityResolver (ACEXML_EntityResolver *resolver) = 0; /** * Allow an application to register an error event handler. */ virtual void setErrorHandler (ACEXML_ErrorHandler *handler) = 0; /** * Activating or deactivating a feature. */ virtual void setFeature (const ACEXML_Char *name, int boolean_value) = 0; /** * Set the value of a property. */ virtual void setProperty (const ACEXML_Char *name, void *value) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_XMLREADER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/ACEXML.pc.in0000644000175000017500000000032112576461726020554 0ustar pgquilespgquilesprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: ACEXML Description: ACE XML Library Requires: ACE Version: @VERSION@ Libs: -L${libdir} -lACEXML Cflags: -I${includedir} ace-6.3.3+dfsg.orig/ACEXML/common/StrCharStream.h0000644000175000017500000000440112576461726021550 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file StrCharStream.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_STRCHARSTREAM_H_ #define _ACEXML_STRCHARSTREAM_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/CharStream.h" /** * @class ACEXML_StrCharStream * * An implementation of ACEXML_CharStream for reading * input from a null-terminated ACEXML_Char string. */ class ACEXML_Export ACEXML_StrCharStream : public ACEXML_CharStream { public: /// Default constructor. ACEXML_StrCharStream (void); /// Destructor virtual ~ACEXML_StrCharStream (void); /// Initializing StrCharStream with @a str and @a name int open (const ACEXML_Char *str, const ACEXML_Char* name); /** * Returns the available ACEXML_Char in the buffer. -1 * if the object is not initialized properly. */ virtual int available (void); /** * Close this stream and release all resources used by it. */ virtual int close (void); /** * Determine the encoding of the file. */ virtual int determine_encoding (void); /** * Read the next ACEXML_Char. Return -1 if we are not able to * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed. */ virtual int get (ACEXML_Char& ch); /** * Read the next batch of ACEXML_Char strings */ virtual int read (ACEXML_Char *str, size_t len); /** * Peek the next ACEXML_Char in the CharStream. Return the * character if succeess, -1 if EOS is reached. */ virtual int peek (void); /* * Get the character encoding for a byte stream or URI. */ virtual const ACEXML_Char *getEncoding (void); /* * Get the systemId for the underlying CharStream */ virtual const ACEXML_Char* getSystemId (void); /** * Resets the pointer to the beginning of the stream. */ virtual void rewind (void); private: ACEXML_Char *start_; ACEXML_Char *ptr_; ACEXML_Char *end_; ACEXML_Char* encoding_; ACEXML_Char* name_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_STRCHARSTREAM_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Locator.cpp0000644000175000017500000000010112576461726020755 0ustar pgquilespgquiles#include "Locator.h" ACEXML_Locator::~ACEXML_Locator (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/FileCharStream.h0000644000175000017500000000637612576461726021674 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file FileCharStream.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_FILECHARSTREAM_H_ #define _ACEXML_FILECHARSTREAM_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/CharStream.h" #include "ACEXML/common/Encoding.h" /** * @class ACEXML_FileCharStream * * An implementation of ACEXML_CharStream for reading input from a file. */ class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream { public: /// Default constructor. ACEXML_FileCharStream (void); /// Destructor virtual ~ACEXML_FileCharStream (void); /// Open a file. int open (const ACEXML_Char *name); /** * Accept an already opened file. The stream does not * assume ownership of open_file. */ int use_stream (FILE* open_file, const ACEXML_Char *name); /** * Returns the available ACEXML_Char in the buffer. -1 * if the object is not initialized properly. */ virtual int available (void); /** * Close this stream and release all resources used by it. */ virtual int close (void); /** * Read the next ACEXML_Char. Return -1 if we are not able to * return an ACEXML_Char, 0 if succees. */ virtual int get (ACEXML_Char& ch); /** * Read the next batch of ACEXML_Char strings */ virtual int read (ACEXML_Char *str, size_t len); /** * Determine the encoding of the file. */ virtual int determine_encoding (void); /** * Peek the next ACEXML_Char in the CharStream. Return the * character if success, -1 if EOF is reached. */ virtual int peek (void); /** * Resets the file pointer to the beginning of the stream. */ virtual void rewind (void); /* * Get the character encoding for the file. */ virtual const ACEXML_Char *getEncoding (void); /* * Get the systemId for the underlying CharStream */ virtual const ACEXML_Char* getSystemId (void); private: /** Read the next character as a normal character. Return -1 if EOF is * reached, else return 0. */ int getchar_i (char& ch); #if defined (ACE_USES_WCHAR) /** * Read the next character from the stream taking into account the * encoding of the file. */ int get_i (ACEXML_Char& ch); /** * Read the next character from the stream taking into account the * encoding of the file. Subsequent call to get() returns this * character. */ int peek_i (void); #endif /* ACE_USES_WCHAR */ /// internal accept an already opened file. int use_stream_i (FILE* open_file, const ACEXML_Char *name); ACEXML_Char* filename_; ACEXML_Char* encoding_; ACE_OFF_T size_; FILE* infile_; bool close_infile_; // This is needed to ensure that we can implement a peek operation on a // UTF-16 encoded file. It is a bit hackish, but there is no other way of // implementing a peek() as the standard I/O FILE* guarantees only one // pushback. ACEXML_Char peek_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_FILECHARSTREAM_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Transcode.h0000644000175000017500000001176112576461726020757 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Transcode.h * * This file declares functions to convert char string among different * unicode encoding (utf8, utf16, utf32) * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_TRANSCODE_H_ #define _ACEXML_TRANSCODE_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Transcoder * * @brief ACEXML_Transcoder * * Wrapper class for performing transcoding among different UNICODE * encoding. */ class ACEXML_Export ACEXML_Transcoder { public: /* * Status of the conversion function. */ enum { ACEXML_SUCCESS = 0, ACEXML_DESTINATION_TOO_SHORT = -1, ACEXML_END_OF_SOURCE = -2, ACEXML_INVALID_ARGS = -3, ACEXML_IS_SURROGATE = -4, ACEXML_NON_UNICODE = -5 } ACEXML_STATUS; // The following functions translate a unicode characters // into different encoding. Return number of characters put into // destination or consumed from src if success without // error, otherwise, return corresponding error code. /* * Convert a UTF-16 character into a string in UTF-8 encoding. * * @return number of characters the function uses to store the * converted string if it succeeds or one of the error STATUS * otherwise. */ static int utf162utf8 (ACEXML_UTF16 src, ACEXML_UTF8 *dst, size_t len); /* * Convert a UCS-4 character into a string in UTF-8 encoding. * * @return number of characters the function uses to store the * converted string if it succeeds or one of the error STATUS * otherwise. */ static int ucs42utf8 (ACEXML_UCS4 src, ACEXML_UTF8 *dst, size_t len); /* * Convert a UCS-4 character into a string in UTF-16 encoding. * * @return number of characters the function uses to store the * converted string if it succeeds or one of the error STATUS * otherwise. */ static int ucs42utf16 (ACEXML_UCS4 src, ACEXML_UTF16 *dst, size_t len); /* * Convert a UTF-16 surrogate character pair into a string in UTF-8 encoding. * * @return number of characters the function uses to store the * converted string if it succeeds or one of the error STATUS * otherwise. */ static int surrogate2utf8 (ACEXML_UTF16 high, ACEXML_UTF16 low, ACEXML_UTF8 *dst, size_t len); /* * Convert a UTF-16 surrogate character pair into a UCS-4 character. * * @return SUCCESS if it succeeds or one of the error STATUS * otherwise. */ static int surrogate2ucs4 (ACEXML_UTF16 high, ACEXML_UTF16 low, ACEXML_UCS4 &dst); /* * Convert the first UNICODE character in a UTF-8 character string * into a UCS-4 character. * * @return number of characters the function consumed from the * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf82ucs4 (const ACEXML_UTF8 *src, size_t len, ACEXML_UCS4 &dst); /* * Convert the first UNICODE character in a UTF-16 character string * into a UCS-4 character. * * @return number of characters the function consumed from the * UTF-16 string if it succeeds or one of the error STATUS * otherwise. */ static int utf162ucs4 (const ACEXML_UTF16 *src, size_t len, ACEXML_UCS4 &dst); // static int utf82utf16 (const ACEXML_UTF8 *src, // size_t len, // ACEXML_UTF16 &dst); // This function does not handle surrogates. // = The following functions are non-inlined: /* * Convert a UTF-8 string into a UTF-16 string. * * @param len The length of @a dst string. * * @return number of characters the function consumed from the * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf8s2utf16s (const ACEXML_UTF8 *src, ACEXML_UTF16 *dst, size_t len); /* * Convert a UTF-16 string into a UTF-8 string. * * @param len The length of @a dst string. * * @return number of characters the function uses in * UTF-8 string if it succeeds or one of the error STATUS * otherwise. */ static int utf16s2utf8s (const ACEXML_UTF16 *src, ACEXML_UTF8 *dst, size_t len); }; #include /**/ "ace/post.h" #endif /* _ACEXML_TRANSCODE_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Validator.cpp0000644000175000017500000000012212576461726021302 0ustar pgquilespgquiles#include "ACEXML/common/Validator.h" ACEXML_Validator::~ACEXML_Validator () { } ace-6.3.3+dfsg.orig/ACEXML/common/LocatorImpl.cpp0000644000175000017500000000224012576461726021605 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/LocatorImpl.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/common/LocatorImpl.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_LocatorImpl::ACEXML_LocatorImpl (void) : publicId_ (0), systemId_ (0), lineNumber_ (1), columnNumber_ (0) { } ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Char* systemId, const ACEXML_Char* publicId) : publicId_ (publicId ? ACE::strnew (publicId) : 0), systemId_ (systemId ? ACE::strnew (systemId) : 0), lineNumber_ (1), columnNumber_ (0) { } ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Locator& locator) : publicId_ (locator.getPublicId() ? ACE::strnew(locator.getPublicId ()): 0), systemId_ (locator.getSystemId() ? ACE::strnew(locator.getSystemId ()): 0), lineNumber_ (locator.getLineNumber ()), columnNumber_ (locator.getColumnNumber ()) { } ACEXML_LocatorImpl::~ACEXML_LocatorImpl (void) { this->reset(); } void ACEXML_LocatorImpl::reset (void) { delete[] this->publicId_; this->publicId_ = 0; delete[] this->systemId_; this->systemId_ = 0; this->columnNumber_ = 0; this->lineNumber_ = 1; } ace-6.3.3+dfsg.orig/ACEXML/common/Locator.h0000644000175000017500000000415612576461726020440 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Locator.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_LOCATOR_H_ #define _ACEXML_LOCATOR_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Locator * * @brief ACEXML_Locator defines operations that an XML locator should support. * * If a SAX parser provides location information to the SAX * application, it does so by implementing this interface and then * passing an instance to the application using the content handler's * setDocumentLocator method. The application can use the object to * obtain the location of any other content handler event in the XML * source document. * * Note that the results returned by the object will be valid only * during the scope of each content handler method: the application * will receive unpredictable results if it attempts to use the * locator at any other time. * * SAX parsers are not required to supply a locator, but they are very * strongly encouraged to do so. If the parser supplies a locator, it * must do so before reporting any other document events. If no * locator has been set by the time the application receives the * startDocument event, the application should assume that a locator * is not available. */ class ACEXML_Export ACEXML_Locator { public: virtual ~ACEXML_Locator (void); /* * Return the column number where the current document event ends. */ virtual int getColumnNumber (void) const = 0; /* * Return the line number where the current document event ends. */ virtual int getLineNumber (void) const = 0; /* * Return the public identifier for the current document event. */ virtual const ACEXML_Char *getPublicId (void) const = 0; /* * Return the system identifier for the current document event. */ virtual const ACEXML_Char *getSystemId (void) const = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_LOCATOR_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/URL_Addr.inl0000644000175000017500000000311112576461726020752 0ustar pgquilespgquiles// -*- C++ -*- #include "ace/ACE.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_string.h" ACE_INLINE size_t ACEXML_URL_Addr::calculate_length (int ipaddr_format) const { return ACE_OS::strlen (ipaddr_format == 0 ? this->get_host_name () : this->get_host_addr ()) + ACE_OS::strlen ("65536") // Assume the max port number. + ACE_OS::strlen (this->get_path_name ()) + sizeof (':') + sizeof ('/') + sizeof ('\0'); // For trailing '\0'. } ACE_INLINE void ACEXML_URL_Addr::operator= (const ACEXML_URL_Addr &addr) { if (this->set (addr) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr"))); } ACE_INLINE u_long ACEXML_URL_Addr::hash (void) const { u_long result = this->ACE_INET_Addr::hash () + ACE::hash_pjw (this->get_path_name ()); return result; } ACE_INLINE bool ACEXML_URL_Addr::operator== (const ACEXML_URL_Addr &addr) const { return ACE_OS::strcmp (addr.get_path_name (), this->get_path_name ()) == 0 && addr.get_port_number () == this->get_port_number () && addr.get_ip_address () == this->get_ip_address (); } ACE_INLINE bool ACEXML_URL_Addr::operator!= (const ACEXML_URL_Addr &addr) const { return !(*this == addr); } ACE_INLINE const ACEXML_Char * ACEXML_URL_Addr::get_path_name (void) const { return this->path_name_; } ACE_INLINE int ACEXML_URL_Addr::destroy (void) { // Commit suicide. delete this; return 0; } ace-6.3.3+dfsg.orig/ACEXML/common/Attributes_Def_Builder.cpp0000644000175000017500000000027712576461726023742 0ustar pgquilespgquiles#include "ACEXML/common/Attributes_Def_Builder.h" ACEXML_Attribute_Def_Builder::~ACEXML_Attribute_Def_Builder () { } ACEXML_Attributes_Def_Builder::~ACEXML_Attributes_Def_Builder () { } ace-6.3.3+dfsg.orig/ACEXML/common/ContentHandler.h0000644000175000017500000000673412576461726021751 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ContentHandler.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_CONTENTHANDLER_H_ #define _ACEXML_CONTENTHANDLER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/SAXExceptions.h" #include "ACEXML/common/Locator.h" #include "ACEXML/common/Attributes.h" /** * @class ACEXML_ContentHandler * * @brief ACEXML_ContentHandler * * This is the main interface that most SAX applications implement: if the * application needs to be informed of basic parsing events, it implements * this interface and registers an instance with the SAX parser using the * setContentHandler method. The parser uses the instance to report basic * document-related events like the start and end of elements and character * data. * * The order of events in this interface is very important, and mirrors the * order of information in the document itself. For example, all of an * element's content (character data, processing instructions, and/or * subelements) will appear, in order, between the startElement event and * the corresponding endElement event. */ class ACEXML_Export ACEXML_ContentHandler { public: virtual ~ACEXML_ContentHandler (void); /** * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length) = 0; /** * Receive notification of the end of a document. */ virtual void endDocument (void) = 0; /** * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; /** * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix) = 0; /** * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length) = 0; /** * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data) = 0; /** * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator) = 0; /** * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name) = 0; /** * Receive notification of the beginning of a document. */ virtual void startDocument (void) = 0; /** * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts) = 0; /** * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_CONTENTHANDLER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Element_Def_Builder.cpp0000644000175000017500000000016112576461726023175 0ustar pgquilespgquiles#include "ACEXML/common/Element_Def_Builder.h" ACEXML_Element_Def_Builder::~ACEXML_Element_Def_Builder () { } ace-6.3.3+dfsg.orig/ACEXML/common/Attributes.cpp0000644000175000017500000000011212576461726021502 0ustar pgquilespgquiles#include "Attributes.h" ACEXML_Attributes::~ACEXML_Attributes (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/Attributes.h0000644000175000017500000000713012576461726021156 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Attributes.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ATTRIBUTES_H_ #define _ACEXML_ATTRIBUTES_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Attributes * * @brief ACEXML_Attributes defines a collection of attributes of an XML element. * * This is an abstract class (interface in Java) that defines * the API for accessing attributes of an XML entity. * * This interface allows access to a list of attributes in three different ways: * * - by attribute index; * - by Namespace-qualified name; or * - by qualified (prefixed) name. * * The list will not contain attributes that were declared #IMPLIED * but not specified in the start tag. It will also not contain * attributes used as Namespace declarations (xmlns*) unless the * http://xml.org/sax/features/namespace-prefixes feature is set to * true (it is false by default). * * If the namespace-prefixes feature (see above) is false, access by * qualified name may not be available; if the * http://xml.org/sax/features/namespaces feature is false, access by * Namespace-qualified names may not be available. * * This interface replaces the now-deprecated SAX1 AttributeList * interface, which does not contain Namespace support. In addition to * Namespace support, it adds the getIndex methods (below). * * The order of attributes in the list is unspecified, and will vary * from implementation to implementation. */ class ACEXML_Export ACEXML_Attributes { public: /// Destructor. virtual ~ACEXML_Attributes (void); /** * Look up the index of an attribute by XML 1.0 qualified name. */ virtual int getIndex (const ACEXML_Char *qName) = 0; /** * Look up the index of an attribute by Namespace name. */ virtual int getIndex (const ACEXML_Char *uri, const ACEXML_Char *localPart) = 0; /** * Return the number of attributes in the list. */ virtual size_t getLength (void) = 0; /** * Look up an attribute's local name by index. */ virtual const ACEXML_Char *getLocalName (size_t index) = 0; /** * Look up an attribute's XML 1.0 qualified name by index. */ virtual const ACEXML_Char *getQName (size_t index) = 0; /** * Look up an attribute's type by index. */ virtual const ACEXML_Char *getType (size_t index) = 0; /** * Look up an attribute's type by XML 1.0 qualified name. */ virtual const ACEXML_Char *getType (const ACEXML_Char *qName) = 0; /** * Look up an attribute's type by Namespace name. */ virtual const ACEXML_Char *getType (const ACEXML_Char *uri, const ACEXML_Char *localPart) = 0; /** * Look up an attribute's Namespace URI by index. */ virtual const ACEXML_Char *getURI (size_t index) = 0; /** * Look up an attribute's value by index. */ virtual const ACEXML_Char *getValue (size_t index) = 0; /** * Look up an attribute's value by XML 1.0 qualified name. */ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName) = 0; /** * Look up an attribute's value by Namespace name. */ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri, const ACEXML_Char *localPart) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_ ATTRIBUTES_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/XML_Codecs.h0000644000175000017500000000344112576461726020751 0ustar pgquilespgquiles// -*- C++ -*- /** * @file XML_Codecs.h * * @author Krishnakumar B * * XML_Codecs is a generic wrapper for various encoding and decoding * mechanisms used in ACEXML. Currently it includes support for handling * Base64 content transfer-encoding of ACEXML_Chars. */ #ifndef _ACEXML_XML_CODECS_H #define _ACEXML_XML_CODECS_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" #include "ace/Codecs.h" /** * @class ACEXML_Base64 * * @brief Encode/Decode a stream of ACEXML_Chars according to Base64 encoding. * * This class provides methods to encode or decode a stream of ACEXML_Chars * to/from Base64 encoding. It doesn't convert the input stream to a * canonical form before encoding. */ class ACEXML_Export ACEXML_Base64 : public ACE_Base64 { public: //@{ /** * Encodes a stream of octets to Base64 data * * @param input Binary data in ACEXML_Char stream. * @param output_len Length of the encoded Base64 ACEXML_Char stream. * @return Encoded Base64 data in ACEXML_Char stream or NULL if input data * cannot be encoded. */ static ACEXML_Char* encode (const ACEXML_Char* input, size_t* output_len); /** * Decodes a stream of Base64 to octets data * * @param input Encoded Base64 data in ACEXML_Char stream. * @param output_len Length of the binary ACEXML_Char stream. * @return Binary data in ACEXML_Char stream or NULL if input data cannot * be encoded. */ static ACEXML_Char* decode (const ACEXML_Char* input, size_t* output_len); //@} }; #include /**/ "ace/post.h" #endif /* _ACEXML_XML_CODECS_H */ ace-6.3.3+dfsg.orig/ACEXML/common/ContentHandler.cpp0000644000175000017500000000012612576461726022271 0ustar pgquilespgquiles#include "ContentHandler.h" ACEXML_ContentHandler::~ACEXML_ContentHandler (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/NamespaceSupport.h0000644000175000017500000001570212576461726022325 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file NamespaceSupport.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_NAMESPACESUPPORT_H #define ACEXML_NAMESPACESUPPORT_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" #include "ace/Functor.h" #include "ace/Hash_Map_Manager.h" #include "ace/Containers_T.h" #include "ace/Null_Mutex.h" typedef ACE_Hash_Map_Entry ACEXML_NS_CONTEXT_ENTRY; typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_NS_CONTEXT; typedef ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_NS_CONTEXT_ITER; typedef ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_NS_CONTEXT_REVERSE_ITER; typedef ACE_Unbounded_Queue ACEXML_STR_LIST; /** * @class ACEXML_Namespace_Context_Stack * * @brief ACEXML_Namespace_Context_Stack implements a simple stack * that ACEXML_NamespaceSupport uses to keep track of namespace scopes. * * @sa ACEXML_NamespaceSupport */ class ACEXML_Export ACEXML_Namespace_Context_Stack { public: /// Default constructor. ACEXML_Namespace_Context_Stack (void); /// Destructor. ~ACEXML_Namespace_Context_Stack (void); /// Push the old namespace before entering into a new namespace scope. int push (ACEXML_NS_CONTEXT * old); /// Pop the old namespace when exiting a namespace scope. ACEXML_NS_CONTEXT *pop (void); private: /// Internal stack structure to hold namespace context. ACE_Unbounded_Stack stack_; }; /** * @class ACEXML_NamespaceSupport NamespaceSupport.h "ACEXML/common/NamespaceSupport.h" * * @brief ACEXML_NamespaceSupport provides namespace management * operation for an XML parser. * * This class encapsulates the logic of Namespace processing: it * tracks the declarations currently in force for each context and * automatically processes qualified XML 1.0 names into their * Namespace parts; it can also be used in reverse for generating XML * 1.0 from Namespaces. * * Namespace support objects are reusable, but the reset method must * be invoked between each session. * * Here is a simple session (in Java :-p): * @code * String parts[] = new String[3]; * NamespaceSupport support = new NamespaceSupport(); * * support.pushContext(); * support.declarePrefix("", "http://www.w3.org/1999/xhtml"); * support.declarePrefix("dc", "http://www.purl.org/dc#"); * * String parts[] = support.processName("p", parts, false); * System.out.println("Namespace URI: " + parts[0]); * System.out.println("Local name: " + parts[1]); * System.out.println("Raw name: " + parts[2]); * * String parts[] = support.processName("dc:title", parts, false); * System.out.println("Namespace URI: " + parts[0]); * System.out.println("Local name: " + parts[1]); * System.out.println("Raw name: " + parts[2]); * * support.popContext(); * @endcode * * Note that this class is optimized for the use case where most * elements do not contain Namespace declarations: if the same * prefix/URI mapping is repeated for each context (for example), this * class will be somewhat less efficient. * * @sa ACEXML_Exception */ class ACEXML_Export ACEXML_NamespaceSupport { public: /** * Default constructor. */ ACEXML_NamespaceSupport (void); /** * Default destructor. */ ~ACEXML_NamespaceSupport (void); /** * Initialize the namespace support object */ int init(void); /** * XMLNS default prefix and URI strings. */ static const ACEXML_Char *XMLNS_PREFIX; static const ACEXML_Char *XMLNS; /** * Declare a Namespace prefix. Return -1 if the prefix was illegal * or an internal error occured. Return 0 if the prefix gets declared * successfully, 1 if the prefix replaces an existing prefix definition. */ int declarePrefix (const ACEXML_Char *prefix, const ACEXML_Char *uri); /** * Return all prefixes declared in current context in * the user-supplied list @a prefixes. It is user's reponsibility * to ensure the list was empty originally. */ int getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const; /** * Return one of the prefixes mapped to a Namespace URI. */ const ACEXML_Char *getPrefix (const ACEXML_Char *uri) const; /** * Return all prefixes currently declared in the user-supplied list. * @@ Known bug: This function should only return user-defined prefixes. */ int getPrefixes (ACEXML_STR_LIST &prefixes) const; /** * Return all prefixes currently declared for a URI in the * user-supplied list. */ int getPrefixes (const ACEXML_Char *uri, ACEXML_STR_LIST &prefixes) const; /** * Look up a prefix and get the currently-mapped Namespace URI. */ const ACEXML_Char *getURI (const ACEXML_Char *prefix) const; /** * Revert to the previous namespace context. */ int popContext (void); /** * Process a raw XML 1.0 name. * @a qName is the raw XML name we want to parse, * @a uri contains the URI string of the raw name. It points to a null * string if the namespace is not valid or there's no namespace defined. * @a name contains the original name without the prefix. * @a is_attribute specifies whether the name is an attribute or not. * Attributes have different scoping rules from elements. */ int processName (const ACEXML_Char *qName, const ACEXML_Char *&uri, const ACEXML_Char *&name, int is_attribute) const; /** * Start a new Namespace context. Prefixes defined in previous * context are copied over to the new context. */ int pushContext (void); /** * Reset this Namespace support object for reuse. * */ int reset (void); private: /** * Namespace Context stack. When we entering a new namespace * context, the old context is duplicated and pushed into * this stack. */ ACEXML_Namespace_Context_Stack ns_stack_; /** * The effective namespace context. */ ACEXML_NS_CONTEXT *effective_context_; }; #include /**/ "ace/post.h" #endif /* ACEXML_NAMESPACESUPPORT_H */ ace-6.3.3+dfsg.orig/ACEXML/common/Encoding.cpp0000644000175000017500000000526212576461726021115 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/Encoding.h" #include "ace/OS_NS_string.h" const ACEXML_Char* ACEXML_Encoding::encoding_names_[8] = { ACE_TEXT ("UCS-4BE"), ACE_TEXT ("UCS-4LE"), ACE_TEXT ("UCS-4_2143"), ACE_TEXT ("UCS-4_3412"), ACE_TEXT ("UTF-16"), ACE_TEXT ("UTF-16"), ACE_TEXT ("UTF-8"), ACE_TEXT ("Unsupported Encoding") }; const ACEXML_UTF8 ACEXML_Encoding::byte_order_mark_[][4] = { { '\x00', '\x00', '\xFE', '\xFF' }, // UCS-4, big-endian (1234 order) { '\xFF', '\xFE', '\x00', '\x00' }, // UCS-4, little-endian (4321 order) { '\x00', '\x00', '\xFF', '\xFE' }, // UCS-4, unusual octet order (2143) { '\xFE', '\xFF', '\x00', '\x00' }, // UCS-4, unusual octet order (3412) { '\xFE', '\xFF', '\xFF', '\xFF' }, // UTF-16, big-endian (3 & 4 != 0) { '\xFF', '\xFE', '\xFF', '\xFF' }, // UTF-16, little-endian ( 3 & 4 != 0) { '\xEF', '\xBB', '\xBF', '\xFF' } // UTF-8 }; const ACEXML_UTF8 ACEXML_Encoding::magic_values_[][4] = { { '\x00', '\x00', '\x00', '\x3c' }, // { '\x3c', '\x00', '\x00', '\x00' }, // UCS-4 and variants { '\x00', '\x00', '\x3c', '\x00' }, // { '\x00', '\x3c', '\x00', '\x00' }, // { '\x00', '\x3c', '\x00', '\x3f' }, // UTF-16BE { '\x3c', '\x00', '\x3f', '\x00' }, // UTF-16LE { '\x3c', '\x3f', '\x78', '\x6d' }, // UTF-8 }; const ACEXML_Char* ACEXML_Encoding::get_encoding (const char* input) { if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16BE][0], input, 2) == 0) && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE]; else if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16LE][0], input, 2) == 0) && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE]; else if (ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF8][0], input, 3) == 0) return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8]; else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16BE][0], input, 4) == 0) return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE]; else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16LE][0], input, 4) == 0) return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE]; else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF8][0], input, 4) == 0) return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8]; else { // ACE_ERROR ((LM_ERROR, "Unknown encoding. Assuming UTF-8\n")); return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8]; } } ace-6.3.3+dfsg.orig/ACEXML/common/SAXExceptions.inl0000644000175000017500000000205512576461726022061 0ustar pgquilespgquiles// -*- C++ -*- ACEXML_INLINE const ACEXML_Char * ACEXML_SAXException::message (void) const { return (this->message_ == 0 ? ACEXML_Exception::null_ : this->message_); } ACEXML_INLINE void ACEXML_SAXException::_raise (void) { throw *this; } ACEXML_INLINE void ACEXML_SAXNotSupportedException::_raise (void) { throw *this; } ACEXML_INLINE void ACEXML_SAXNotRecognizedException::_raise (void) { throw *this; } ACEXML_INLINE void ACEXML_SAXParseException::_raise (void) { throw *this; } ACEXML_INLINE const ACEXML_Char * ACEXML_SAXException::id (void) const { return ACEXML_SAXException::exception_name_; } ACEXML_INLINE const ACEXML_Char * ACEXML_SAXNotSupportedException::id (void) const { return ACEXML_SAXNotSupportedException::exception_name_; } ACEXML_INLINE const ACEXML_Char * ACEXML_SAXNotRecognizedException::id (void) const { return ACEXML_SAXNotRecognizedException::exception_name_; } ACEXML_INLINE const ACEXML_Char * ACEXML_SAXParseException::id (void) const { return ACEXML_SAXParseException::exception_name_; } ace-6.3.3+dfsg.orig/ACEXML/common/StreamFactory.h0000644000175000017500000000251212576461726021612 0ustar pgquilespgquiles/** * @file StreamFactory.h * * @author Krishnakumar B */ #ifndef _ACEXML_STREAM_FACTORY_H #define _ACEXML_STREAM_FACTORY_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" // Forward declarations class ACEXML_CharStream; /** * @class ACEXML_StreamFactory * * @brief A generic factory used to create an appropriate @sa * ACEXML_CharStream from a SYSTEM id. This class creates a @sa * ACEXML_FileCharStream or a @sa ACEXML_HttpCharStream depending on the * URI supplied. * * @todo Write a stream abstraction for handling ftp:// type URIs and add * a function to create and return such streams. That is the only chunk * missing in the armour. */ class ACEXML_Export ACEXML_StreamFactory { public: // Destructor virtual ~ACEXML_StreamFactory (void); /** * Create the appropriate stream from the @a uri passed and return the * stream. The caller is responsible for deallocating the returned * stream. * * @param uri SYSTEM id or a stream of characters (in the case of a * StrCharStream). */ virtual ACEXML_CharStream* create_stream (const ACEXML_Char* uri); }; #include /**/ "ace/post.h" #endif /* _ACEXML_STREAM_FACTORY_H */ ace-6.3.3+dfsg.orig/ACEXML/common/DefaultHandler.h0000644000175000017500000001144012576461726021711 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file DefaultHandler.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_DEFAULTHANDLER_H #define ACEXML_DEFAULTHANDLER_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/ContentHandler.h" #include "ACEXML/common/DTDHandler.h" #include "ACEXML/common/EntityResolver.h" #include "ACEXML/common/ErrorHandler.h" /** * @class ACEXML_DefaultHandler * * @brief ACEXML_DefaultHandler * * This class is available as a convenience base class for SAX2 * applications: it provides default implementations for all of the * callbacks in the four core SAX2 handler classes: * * - EntityResolver * - DTDHandler * - ContentHandler * - ErrorHandler * * Application writers can extend this class when they need to implement * only part of an interface; parser writers can instantiate this class to * provide default handlers when the application has not supplied its own. */ class ACEXML_Export ACEXML_DefaultHandler : public ACEXML_ContentHandler, public ACEXML_DTDHandler, public ACEXML_EntityResolver, public ACEXML_ErrorHandler { public: /** * Default constructor. */ ACEXML_DefaultHandler (void); /** * destructor. */ virtual ~ACEXML_DefaultHandler (void); // Methods inherit from ACEXML_ContentHandler. /* * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length); /* * Receive notification of the end of a document. */ virtual void endDocument (void); /* * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /* * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix); /* * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length); /* * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data); /* * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator) ; /* * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name); /* * Receive notification of the beginning of a document. */ virtual void startDocument (void); /* * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts); /* * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri); // *** Methods inherit from ACEXML_DTDHandler. /* * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId); /* * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName); // Methods inherit from ACEXML_EnitityResolver. /* * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId); // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception); /* * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception); /* * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception); }; #include /**/ "ace/post.h" #endif /* ACEXML_DEFAULTHANDLER_H */ ace-6.3.3+dfsg.orig/ACEXML/common/Validator.h0000644000175000017500000000275612576461726020766 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Validator.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_VALIDATOR_H_ #define _ACEXML_VALIDATOR_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Attributes.h" #include "ACEXML/common/SAXExceptions.h" /** * @class ACEXML_Validator * * @brief An abstract virtual class defining validator interface. * * An validator provides validation service for one XML element. * ACEXML_Validators are stateful object. Implementations should * remember the current element encountered and determine if * it's a valid sequence of child elements. A parser fishes * out a validator of certain */ class ACEXML_Export ACEXML_Validator { public: virtual ~ACEXML_Validator () = 0; /** * Validate attributes of an element. * * @retval 0 if valid, -1 otherwise. */ virtual int startElement (ACEXML_Attributes *atts) = 0; /** * Validate the next child element. * * @retval 0 if valid, -1 otherwise. */ virtual int nextElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_VALIDATOR_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/XMLFilterImpl.inl0000644000175000017500000000045312576461726022014 0ustar pgquilespgquiles// -*- C++ -*- ACEXML_INLINE int ACEXML_XMLFilterImpl::setupParser (void) { if (this->parent_ == 0) return -1; this->parent_->setEntityResolver (this); this->parent_->setDTDHandler (this); this->parent_->setContentHandler (this); this->parent_->setErrorHandler (this); return 0; } ace-6.3.3+dfsg.orig/ACEXML/common/CharStream.cpp0000644000175000017500000000015012576461726021407 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/CharStream.h" ACEXML_CharStream::~ACEXML_CharStream (void) { } ace-6.3.3+dfsg.orig/ACEXML/common/Exception.h0000644000175000017500000000361312576461726020770 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Exception.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_EXCEPTION_H_ #define _ACEXML_EXCEPTION_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Exception * * @brief ACEXML_Exception * * ACEXML_Exception is the base class for all ACEXML related exceptions. * Since ACEXML currently does not support native exceptions, all * exceptions should be thrown thru ACEXML_Env. * * @sa ACEXML_Env */ class ACEXML_Export ACEXML_Exception { public: /// Destructor. virtual ~ACEXML_Exception (void); /// Throw the exception. virtual void _raise (void) = 0; /// Static narrow operation. static ACEXML_Exception* _downcast (ACEXML_Exception* ex); /// Return the exception type. (for safe downcast.) virtual const ACEXML_Char *id (void) const ; /// Dynamically create a copy of this exception. virtual ACEXML_Exception *duplicate (void) const = 0; /// Check whether this is an exception of type specified by . virtual int is_a (const ACEXML_Char *name); /// Print out exception using ACE_DEBUG. virtual void print (void) const = 0; protected: /// Default constructor. ACEXML_Exception (void); /// All exceptions have names. This name is used to identify the /// type of an exception. static const ACEXML_Char *exception_name_; /// A null string that we return when there is no exception. static const ACEXML_Char *null_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/common/Exception.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* _ACEXML_EXCEPTION_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/DefaultHandler.cpp0000644000175000017500000000533212576461726022247 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/DefaultHandler.h" ACEXML_DefaultHandler::ACEXML_DefaultHandler (void) { // no-op } ACEXML_DefaultHandler::~ACEXML_DefaultHandler (void) { // no-op } void ACEXML_DefaultHandler::characters (const ACEXML_Char *, size_t, size_t) { // No-op. } void ACEXML_DefaultHandler::endDocument (void) { // No-op. } void ACEXML_DefaultHandler::endElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } void ACEXML_DefaultHandler::endPrefixMapping (const ACEXML_Char *) { // No-op. } void ACEXML_DefaultHandler::ignorableWhitespace (const ACEXML_Char *, int, int) { // No-op. } void ACEXML_DefaultHandler::processingInstruction (const ACEXML_Char *, const ACEXML_Char *) { // No-op. } void ACEXML_DefaultHandler::setDocumentLocator (ACEXML_Locator * ) { // No-op. } void ACEXML_DefaultHandler::skippedEntity (const ACEXML_Char *) { // No-op. } void ACEXML_DefaultHandler::startDocument (void) { // No-op. } void ACEXML_DefaultHandler::startElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *, ACEXML_Attributes *) { // No-op. } void ACEXML_DefaultHandler::startPrefixMapping (const ACEXML_Char *, const ACEXML_Char *) { // No-op. } // *** Methods inherited from ACEXML_DTDHandler. void ACEXML_DefaultHandler::notationDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } void ACEXML_DefaultHandler::unparsedEntityDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } // Methods inherited from ACEXML_EntityResolver. ACEXML_InputSource * ACEXML_DefaultHandler::resolveEntity (const ACEXML_Char *, const ACEXML_Char * ) { // No-op. return 0; } // Methods inherited from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ void ACEXML_DefaultHandler::error (ACEXML_SAXParseException &) { // No-op. } void ACEXML_DefaultHandler::fatalError (ACEXML_SAXParseException &) { // No-op. } void ACEXML_DefaultHandler::warning (ACEXML_SAXParseException &) { // No-op. } ace-6.3.3+dfsg.orig/ACEXML/common/Encoding.h0000644000175000017500000000230112576461726020551 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Encoding.h * * This file provides utility functions to determine the encoding of a file * or a byte stream automatically. * * @author Krishnakumar B */ //============================================================================= #ifndef _ACEXML_ENCODING_H #define _ACEXML_ENCODING_H #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Encoding Encoding.h * * @brief ACEXML_Encoding * * Wrapper class for determining the encoding of a file or a byte stream. */ class ACEXML_Export ACEXML_Encoding { public: enum { UCS4BE, UCS4LE, UCS4_2143, UCS4_3412, UTF16BE, UTF16LE, UTF8, OTHER } ENCODING; static const ACEXML_Char* encoding_names_[8]; static const ACEXML_UTF8 byte_order_mark_[][4]; static const ACEXML_UTF8 magic_values_[][4]; static const ACEXML_Char* get_encoding (const char* input); }; #include /**/ "ace/post.h" #endif /* _ACEXML_ENCODING_H */ ace-6.3.3+dfsg.orig/ACEXML/common/StrCharStream.cpp0000644000175000017500000000531512576461726022110 0ustar pgquilespgquiles#include "ACEXML/common/StrCharStream.h" #include "ACEXML/common/Encoding.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_string.h" ACEXML_StrCharStream::ACEXML_StrCharStream (void) : start_ (0), ptr_ (0), end_ (0), encoding_ (0), name_ (0) { } ACEXML_StrCharStream::~ACEXML_StrCharStream (void) { this->close(); } int ACEXML_StrCharStream::open (const ACEXML_Char *str, const ACEXML_Char* name) { if (str != 0 && name != 0) { delete [] this->start_; if ((this->start_ = ACE::strnew (str)) == 0) return -1; delete [] this->name_; if ((this->name_ = ACE::strnew (name)) == 0) return -1; this->ptr_ = this->start_; this->end_ = this->start_ + ACE_OS::strlen (this->start_); return this->determine_encoding(); } return -1; // Invalid string passed. } int ACEXML_StrCharStream::available (void) { if (this->start_ != 0) return static_cast (this->end_ - this->start_); // @@ Will this work on all platforms? return -1; } int ACEXML_StrCharStream::close (void) { delete[] this->start_; delete[] this->encoding_; this->encoding_ = 0; delete[] this->name_; this->name_ = 0; this->start_ = this->ptr_ = this->end_ = 0; return 0; } int ACEXML_StrCharStream::determine_encoding (void) { if (this->start_ == 0) return -1; char input[4] = {0,0,0,0}; char* sptr = (char*)this->start_; int i = 0; for ( ; i < 4 && sptr != (char*)this->end_; ++sptr, ++i) input[i] = *sptr; const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input); if (!temp) return -1; else { delete [] this->encoding_; this->encoding_ = ACE::strnew (temp); // ACE_DEBUG ((LM_DEBUG, "String's encoding is %s\n", this->encoding_)); } return 0; } void ACEXML_StrCharStream::rewind (void) { this->ptr_ = this->start_; this->determine_encoding(); } int ACEXML_StrCharStream::get (ACEXML_Char& ch) { if (this->start_ != 0 && this->ptr_ != this->end_) { ch = *this->ptr_++; return 0; } return -1; } int ACEXML_StrCharStream::read (ACEXML_Char *str, size_t len) { if (this->start_ != 0 && this->ptr_ != this->end_) { if (len * sizeof (ACEXML_Char) > (size_t) (this->end_ - this->ptr_)) len = this->end_ - this->ptr_; ACE_OS::strncpy (str, this->ptr_, len); this->ptr_ += len; return static_cast (len); } return 0; } int ACEXML_StrCharStream::peek (void) { if (this->start_ != 0 && this->ptr_ != this->end_) return *this->ptr_; return -1; } const ACEXML_Char* ACEXML_StrCharStream::getEncoding (void) { return this->encoding_; } const ACEXML_Char* ACEXML_StrCharStream::getSystemId(void) { return this->name_; } ace-6.3.3+dfsg.orig/ACEXML/common/ErrorHandler.h0000644000175000017500000000372612576461726021426 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ErrorHandler.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ERRORHANDLER_H_ #define _ACEXML_ERRORHANDLER_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/SAXExceptions.h" /** * @class ACEXML_ErrorHandler * * @brief ACEXML_ErrorHandler * * If a SAX application needs to implement customized error handling, * it must implement this interface and then register an instance with * the XML reader using the setErrorHandler method. The parser will * then report all errors and warnings through this interface. * * @b WARNING: If an application does not register an ErrorHandler, * XML parsing errors will go unreported and bizarre behaviour may * result. * * For XML processing errors, a SAX driver must use this interface * instead of throwing an exception: it is up to the application to * decide whether to throw an exception for different types of errors * and warnings. Note, however, that there is no requirement that the * parser continue to provide useful information after a call to * fatalError (in other words, a SAX driver class could catch an * exception and report a fatalError). */ class ACEXML_Export ACEXML_ErrorHandler { public: virtual ~ACEXML_ErrorHandler (void); /** * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception) = 0; /** * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception) = 0; /** * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_ERRORHANDLER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/Mem_Map_Stream.cpp0000644000175000017500000001503312576461726022212 0ustar pgquilespgquiles#include "ace/FILE_Addr.h" #include "ace/OS_NS_unistd.h" #include "ACEXML/common/Mem_Map_Stream.h" ACEXML_Mem_Map_Stream::ACEXML_Mem_Map_Stream (void) : svc_handler_ (0) { } ACE_SOCK_Stream & ACEXML_Mem_Map_Stream::stream (void) { return svc_handler_->peer (); } ssize_t ACEXML_Mem_Map_Stream::send_n (const void *buf, size_t size, ACE_Time_Value *tv) { return svc_handler_->peer ().send_n (buf, size, 0, tv); } int ACEXML_Mem_Map_Stream::eof (void) const { return this->get_pos_ >= this->end_of_mapping_plus1_; } int ACEXML_Mem_Map_Stream::get_char (void) { if (this->eof () && this->grow_file_and_remap () == -1) return EOF; return *this->get_pos_++; } void ACEXML_Mem_Map_Stream::rewind (void) { this->recv_pos_ = reinterpret_cast (this->mem_map_.addr ()); this->get_pos_ = this->recv_pos_; this->end_of_mapping_plus1_ = this->recv_pos_ + this->mem_map_.size (); } int ACEXML_Mem_Map_Stream::peek_char (size_t offset) { // We may need to iterate if the size of is large. while (this->get_pos_ + offset >= this->end_of_mapping_plus1_) if (this->grow_file_and_remap () == -1) return EOF; return this->get_pos_[offset]; } const char * ACEXML_Mem_Map_Stream::recv (void) const { return this->recv_pos_; } const char * ACEXML_Mem_Map_Stream::recv (size_t &len) { if (this->eof () && this->grow_file_and_remap () == -1) { len = 0; return 0; } const char *s = this->recv_pos_; this->seek (static_cast (len), SEEK_CUR); len = this->get_pos_ - s; return s; } size_t ACEXML_Mem_Map_Stream::recv_len (void) const { return this->get_pos_ - this->recv_pos_; } const char * ACEXML_Mem_Map_Stream::peek_str (size_t offset, size_t size) { // We will iterate if the size of is large. while (this->get_pos_ + (offset + size) > this->end_of_mapping_plus1_) if (this->grow_file_and_remap () == -1) return 0; return &this->get_pos_[offset]; } ACE_OFF_T ACEXML_Mem_Map_Stream::seek (ACE_OFF_T offset, int whence) { switch (whence) { case SEEK_SET: this->get_pos_ = reinterpret_cast (this->mem_map_.addr ()) + offset; break; case SEEK_CUR: this->get_pos_ += offset; break; case SEEK_END: this->get_pos_ = this->end_of_mapping_plus1_ + offset; // @@ Not sure how to implement this (yet). ACE_NOTSUP_RETURN (-1); } // Make sure that the backing store will cover this. while (this->get_pos_ > this->end_of_mapping_plus1_) if (this->grow_file_and_remap () == -1) this->get_pos_ = this->end_of_mapping_plus1_; this->recv_pos_ = this->get_pos_; return ACE_Utils::truncate_cast ( this->recv_pos_ - reinterpret_cast (this->mem_map_.addr ())); } Svc_Handler * ACEXML_Mem_Map_Stream::svc_handler (void) { return this->svc_handler_; } size_t ACEXML_Mem_Map_Stream::available (void) const { return this->end_of_mapping_plus1_ - this->get_pos_; } int ACEXML_Mem_Map_Stream::open (Connector *connector, const ACE_INET_Addr &addr) { svc_handler_ = 0; // Connect to the server at . If the handler has to be // connected to the server again, the Caching strategy takes care // and uses the same connection. if (connector->connect (svc_handler_, addr) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%p %s %d\n", "Connect failed", addr.get_host_name (), addr.get_port_number ()), -1); } // Create a temporary filename. ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &)); // Create the temporary file via the class API. if (this->mem_map_.open (file.get_path_name (), O_RDWR | O_CREAT | O_APPEND, ACE_DEFAULT_FILE_PERMS) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); // Make sure to unlink this right away so that if this process // crashes these files will be removed automatically. else if (ACE_OS::unlink (file.get_path_name ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "unlink"), -1); else // Initialize all the position pointers to 0. this->rewind (); return 0; } int ACEXML_Mem_Map_Stream::grow_file_and_remap (void) { char buf[8192]; // Copy the next chunk of bytes from the socket into the temporary // file. ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); ssize_t bytes = 0; ssize_t n = 0; while (1) { n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv); if (n < 0) { if (errno != EWOULDBLOCK) { ACE_ERROR ((LM_ERROR, "%p\n", "recv")); } return -1; } bytes += n; if (n == 0 && !bytes) return -1; else if (n == 0) break; else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write_n"), -1); } // ssize_t n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv); // if (n == -1) // { // ACE_ERROR ((LM_ERROR, "%p\n", "recv")); // return -1; // } // else if (n == 0) // return -1; // else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) // ACE_ERROR_RETURN ((LM_ERROR, // "%p\n", // "write_n"), // -1); // Grow the memory-mapping to encompass the entire temporary file. if (this->mem_map_.map (static_cast (-1), PROT_RDWR, ACE_MAP_PRIVATE, (void*)0) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "map"), -1); // MAP_FAILED is used as a "first time in" flag. if (this->recv_pos_ == MAP_FAILED) { this->recv_pos_ = reinterpret_cast (this->mem_map_.addr ()); this->get_pos_ = this->recv_pos_; } this->end_of_mapping_plus1_ = reinterpret_cast (this->mem_map_.addr ()) + this->mem_map_.size (); return 0; } ACEXML_Mem_Map_Stream::~ACEXML_Mem_Map_Stream (void) { // Remove the mapping and the file. this->mem_map_.remove (); delete this->svc_handler_; } ace-6.3.3+dfsg.orig/ACEXML/common/XML_Codecs.cpp0000644000175000017500000000346012576461726021305 0ustar pgquilespgquiles// -*- C++ -*- #include "ace/Auto_Ptr.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_string.h" #include "ACEXML/common/XML_Codecs.h" ACEXML_Char* ACEXML_Base64::encode (const ACEXML_Char* input, size_t* output_len) { if (!input) return 0; size_t len = ACE_OS::strlen (input); ACE_Byte* buf = 0; ACE_NEW_RETURN (buf, ACE_Byte[len], 0); ACE_Auto_Basic_Array_Ptr cleanup_buf (buf); for (size_t i = 0; i < len; ++i) buf[i] = (ACE_Byte)input[i]; buf[len] = 0; size_t encode_len = 0; ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len); if (!encodedBuf) return 0; ACEXML_Char* result = 0; ACE_NEW_RETURN (result, ACEXML_Char[encode_len+1], 0); for (size_t j = 0; j < encode_len; ++j) result[j] = (ACEXML_Char)encodedBuf[j]; result[encode_len] = 0; *output_len = encode_len; delete[] encodedBuf; return result; } ACEXML_Char* ACEXML_Base64::decode (const ACEXML_Char* input, size_t* output_len) { if (!input) return 0; size_t len = ACE_OS::strlen (input); ACE_Byte* buf = 0; ACE_NEW_RETURN (buf, ACE_Byte[len], 0); ACE_Auto_Basic_Array_Ptr cleanup (buf); for (size_t i = 0; i < len; ++i) buf[i] = (ACE_Byte)input[i]; buf[len] = 0; size_t decode_len = 0; ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len); if (!decodedBuf) return 0; ACEXML_Char* result = 0; ACE_NEW_RETURN (result, ACEXML_Char[decode_len+1], 0); for (size_t j = 0; j < decode_len; ++j) result[j] = (ACEXML_Char)decodedBuf[j]; result[decode_len] = 0; *output_len = decode_len; delete[] decodedBuf; return result; } ace-6.3.3+dfsg.orig/ACEXML/common/HttpCharStream.h0000644000175000017500000000560212576461726021723 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file HttpCharStream.h * * @author Krishnakumar B */ //============================================================================= #ifndef _ACEXML_HTTPCHARSTREAM_H_ #define _ACEXML_HTTPCHARSTREAM_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/CharStream.h" #include "ACEXML/common/URL_Addr.h" #include "ACEXML/common/Mem_Map_Stream.h" /** * @class ACEXML_HttpCharStream * * An implementation of ACEXML_CharStream for reading input from a URL. */ class ACEXML_Export ACEXML_HttpCharStream : public ACEXML_CharStream { public: /// Default constructor. ACEXML_HttpCharStream (void); /// Destructor virtual ~ACEXML_HttpCharStream (void); /// Open an URL. int open (const ACEXML_Char *url); /** * Returns the available ACEXML_Char in the buffer. -1 * if the object is not initialized properly. */ virtual int available (void); /** * Close this stream and release all resources used by it. */ virtual int close (void); /** * Read the next ACEXML_Char. Return -1 if we are not able to * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed. */ virtual int get (ACEXML_Char& ch); /** * Read the next batch of ACEXML_Char strings */ virtual int read (ACEXML_Char *str, size_t len); /** * Peek the next ACEXML_Char in the CharStream. Return the * character if succeess, -1 if EOS is reached. */ virtual int peek (void); /** * Resets the file pointer to the beginning of the stream. */ virtual void rewind (void); /** * Determine the encoding of the file. */ virtual int determine_encoding (void); /** * Get the encoding of the file */ virtual const ACEXML_Char* getEncoding (void); /* * Get the systemId for the underlying CharStream */ virtual const ACEXML_Char* getSystemId (void); private: #if defined (ACE_USES_WCHAR) /** * Read the next character from the stream taking into account the * encoding of the file. */ int get_i (ACEXML_Char& ch); /** * Read the next character from the stream taking into account the * encoding of the file. Subsequent call to get() returns this * character. */ int peek_i (void); #endif /* ACE_USES_WCHAR */ /** * Send a HTTP/1.1 request to fetch the contents of the URL. */ int send_request (void); /** * Fetch the URL and save it in backing store. */ int get_url (size_t& len); ACEXML_Char *url_; ACEXML_URL_Addr* url_addr_; ACEXML_Mem_Map_Stream* stream_; Connector* connector_; ACE_OFF_T size_; ACE_OFF_T data_offset_; ACEXML_Char* encoding_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_HTTPCHARSTREAM_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/codecs.mpb0000644000175000017500000000013512576461726020615 0ustar pgquilespgquiles// -*- MPC -*- feature(ace_codecs, !ace_for_tao) { Source_Files { XML_Codecs.cpp } } ace-6.3.3+dfsg.orig/ACEXML/common/LocatorImpl.inl0000644000175000017500000000213112576461726021604 0ustar pgquilespgquiles// -*- C++ -*- #include "ace/ACE.h" ACEXML_INLINE void ACEXML_LocatorImpl::setColumnNumber (int cn) { this->columnNumber_ = cn; } ACEXML_INLINE void ACEXML_LocatorImpl::setLineNumber (int ln) { this->lineNumber_ = ln; } ACEXML_INLINE int ACEXML_LocatorImpl::getColumnNumber (void) const { return this->columnNumber_; } ACEXML_INLINE int ACEXML_LocatorImpl::getLineNumber (void) const { return this->lineNumber_; } ACEXML_INLINE void ACEXML_LocatorImpl::setPublicId (const ACEXML_Char *id) { delete[] this->publicId_; this->publicId_ = ACE::strnew (id); } ACEXML_INLINE void ACEXML_LocatorImpl::setSystemId (const ACEXML_Char *id) { delete[] this->systemId_; this->systemId_ = ACE::strnew (id); } ACEXML_INLINE const ACEXML_Char * ACEXML_LocatorImpl::getPublicId (void) const { return this->publicId_; } ACEXML_INLINE const ACEXML_Char * ACEXML_LocatorImpl::getSystemId (void) const { return this->systemId_; } ACEXML_INLINE void ACEXML_LocatorImpl::incrLineNumber () { ++this->lineNumber_; } ACEXML_INLINE void ACEXML_LocatorImpl::incrColumnNumber () { ++this->columnNumber_; } ace-6.3.3+dfsg.orig/ACEXML/common/DTD_Manager.h0000644000175000017500000000435212576461726021100 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file DTD_Manager.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_DTD_Manager_H_ #define _ACEXML_DTD_Manager_H_ #include /**/ "ace/pre.h" #include "ACEXML/common/ACEXML_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Attributes_Def_Builder.h" #include "ACEXML/common/Element_Def_Builder.h" #include "ACEXML/common/Validator.h" /** * @class ACEXML_DTD_Manager * * @todo Fill in the blank. */ class ACEXML_Export ACEXML_DTD_Manager { public: virtual ~ACEXML_DTD_Manager () = 0; /** * Acquire a pointer to an element definition builder. * The XML parser use this interface to acquire the * definition builder and use the builder to create * the DTD element definition. The resulting builder * is then registered with the DTD Manager or destroyed * if error occured when the builder encountered errors. * * @retval 0 if error occurs creating the builder. */ virtual ACEXML_Element_Def_Builder *getElement_Def_Builder () = 0; /** * Insert a new element definition into the DTD Manager. * * @retval 0 if success, -1 if error. */ virtual int insertElement_Definition (ACEXML_Element_Def_Builder *def) = 0; /** * Acquire a pointer to an attributes definition builder. * */ virtual ACEXML_Attributes_Def_Builder *getAttribute_Def_Builder () = 0; /** * Insert a new attributes definition into the DTD Manager. * * @retval 0 if success, -1 otherwise. */ virtual int insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def) = 0; /** * Acquire an element validator to validate an XML element. * * @todo I haven't figured out what memory management scheme * we should use for the acquired validator. */ virtual ACEXML_Validator *getValidator (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) = 0; }; #include /**/ "ace/post.h" #endif /* _ACEXML_DTD_Manager_H_ */ ace-6.3.3+dfsg.orig/ACEXML/common/EntityResolver.cpp0000644000175000017500000000012612576461726022357 0ustar pgquilespgquiles#include "EntityResolver.h" ACEXML_EntityResolver::~ACEXML_EntityResolver (void) { } ace-6.3.3+dfsg.orig/ACEXML/apps/0000775000175000017500000000000012576472436016333 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/0000775000175000017500000000000012576472436017774 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/Svcconf.h0000644000175000017500000000164612576461726021553 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file Svcconf.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_SVCCONF_H #define ACEXML_SVCCONF_H #include /**/ "ace/pre.h" #include "ace/XML_Svc_Conf.h" #include "ACEXML/parser/parser/Parser.h" #include "Svcconf_Handler.h" #if (ACE_USES_CLASSIC_SVC_CONF == 0) class ACEXML_Svcconf_Parser : public ACE_XML_Svc_Conf { public: ACEXML_Svcconf_Parser (); virtual ~ACEXML_Svcconf_Parser (); virtual int parse_file (const ACE_TCHAR file[]); virtual int parse_string (const ACE_TCHAR str[]); protected: ACEXML_Parser parser_; ACEXML_Svcconf_Handler svcconf_handler_; ACEXML_InputSource input_stream_; }; #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ #include /**/ "ace/post.h" #endif /* ACEXML_SVCCONF_H */ ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/svcconf.mpc0000644000175000017500000000030012576461726022125 0ustar pgquilespgquiles// -*- MPC -*- project(ACEXML_XML_Svc_Conf_Parser): ace_output, acelib, acexml, install { sharedname = ACEXML_XML_Svc_Conf_Parser specific { install_dir = ACEXML/apps/svcconf } } ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/Svcconf.cpp0000644000175000017500000000511312576461726022077 0ustar pgquilespgquiles #include "Svcconf.h" #include "ACEXML/common/FileCharStream.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/parser/parser/Parser.h" #if (ACE_USES_CLASSIC_SVC_CONF == 0) extern "C" ACE_Proper_Export_Flag ACE_XML_Svc_Conf * _ACEXML_create_XML_Svc_Conf_Object (void) { ACE_XML_Svc_Conf *retp = 0; ACE_NEW_RETURN (retp, ACEXML_Svcconf_Parser (), 0); return retp; } ACEXML_Svcconf_Parser::ACEXML_Svcconf_Parser () { this->parser_.setContentHandler (&this->svcconf_handler_); this->parser_.setDTDHandler (&this->svcconf_handler_); this->parser_.setErrorHandler (&this->svcconf_handler_); this->parser_.setEntityResolver (&this->svcconf_handler_); try { this->parser_.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"), 0); } catch (const ACEXML_SAXException& ex) { ex.print (); // Can't do much except printing the error. } } ACEXML_Svcconf_Parser::~ACEXML_Svcconf_Parser () { } int ACEXML_Svcconf_Parser::parse_file (const ACE_TCHAR file[]) { if (file == 0) ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: No filename specified\n"), -1); ACEXML_FileCharStream *fstm = 0; ACE_NEW_RETURN (fstm, ACEXML_FileCharStream (), 1); if (fstm->open (file) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("ACEXML_Svcconf_Parser: Fail to open XML file: %s\n"), file), -1); this->input_stream_.setCharStream (fstm); try { this->parser_.parse (&this->input_stream_); } catch (const ACEXML_SAXException& ex) { ex.print (); return -1; } return 0; } int ACEXML_Svcconf_Parser::parse_string (const ACE_TCHAR str[]) { if (str == 0) ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Can't parse a null string\n"), -1); ACEXML_StrCharStream *stm = 0; ACE_NEW_RETURN (stm, ACEXML_StrCharStream, -1); if (stm->open (str, ACE_TEXT ("Svcconf")) < 0) ACE_ERROR_RETURN ((LM_ERROR, "ACEXML_Svcconf_Parser: Unable to create " "input stream.\n"), -1); this->input_stream_.setCharStream (stm); try { this->parser_.parse (&this->input_stream_); } catch (const ACEXML_SAXException& ex) { // If there was a problem parsing the stream, set the errno // to EINVAL to indicate to upper levels that the stream was // invalid. ACE_OS::last_error (EINVAL); ex.print (); return -1; } return 0; } #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/ACEXML_XML_Svc_Conf_Parser.pc.in0000644000175000017500000000042712576461726025513 0ustar pgquilespgquilesprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: ACEXML_XML_Svc_Conf_Parser Description: ACE XML Service Configurator Parser Requires: ACEXML_Parser Version: @VERSION@ Libs: -L${libdir} -lACEXML_XML_Svc_Conf_Parser Cflags: -I${includedir} ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/Svcconf_Handler.cpp0000644000175000017500000006170212576461726023542 0ustar pgquilespgquiles#include "Svcconf_Handler.h" #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/Service_Config.h" #include "ace/Service_Types.h" #include "ace/Service_Repository.h" #include "ace/Service_Gestalt.h" #include "ace/DLL.h" #include "ace/ARGV.h" #include "ace/Module.h" #include "ace/OS_NS_strings.h" #include "ace/SString.h" #if (ACE_USES_CLASSIC_SVC_CONF == 0) #if !defined (__ACEXML_INLINE__) # include "Svcconf_Handler.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_Svcconf_Handler::ACEXML_Svcconf_Handler (void) : in_stream_def_ (0), in_module_ (0), stream_svc_type_ (0), stream_ (0) { // no-op } ACEXML_Svcconf_Handler::~ACEXML_Svcconf_Handler (void) { // no-op } void ACEXML_Svcconf_Handler::characters (const ACEXML_Char *, int, int) { // no-op } void ACEXML_Svcconf_Handler::endDocument (void) { // no-op } void ACEXML_Svcconf_Handler::endElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0) { ACE_Parsed_Info *active_info = (this->in_stream_def_ == 0 ? &this->parsed_info_ : &this->stream_info_); // We must allocate a string here to ensure that the // name is still available by the time the // ACE_Service_Type_Dynamic_Guard is destructed. ACE_TString name = active_info->name (); ACE_Service_Type_Dynamic_Guard dummy ( *ACE_Service_Config::current ()->current_service_repository (), name.c_str ()); ACE_DLL svc_dll; if (svc_dll.open (active_info->path ()) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Cannot locate DLL: '")); msg += ACE_TString (active_info->path ()); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (active_info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } void *(*func) (ACE_Service_Object_Exterminator *) = 0; ACE_Service_Object_Exterminator gobbler = 0; void *symbol = 0; long temp_ptr = reinterpret_cast (svc_dll.symbol (active_info->init_func ())); func = reinterpret_cast (temp_ptr); if (func == 0) { // build the error message ACE_TString msg (ACE_TEXT ("Cannot locate init function: '")); msg += ACE_TString (active_info->init_func ()); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (active_info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } symbol = (*func)(&gobbler); // target object created in the loaded DLL. ACE_Service_Type_Impl *stp = ACE_Service_Config::create_service_type_impl (active_info->name (), active_info->service_type (), symbol, ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, gobbler); if (this->in_stream_def_) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Create dynamic %s for stream\n"), // this->stream_info_.name ())); if (active_info->service_type () == ACE_Service_Type::STREAM) { this->stream_ = (ACE_Stream_Type *) stp; } else { // We will not retain this stream delete stp; // build the error message ACE_TString msg (ACE_TEXT ("Expecting Stream type in stream header")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (active_info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } this->stream_svc_type_ = ACE_Service_Config::create_service_type (this->stream_info_.name (), this->stream_, svc_dll, this->stream_info_.active ()); } else { if (this->in_module_) { ACE_ARGV args (active_info->init_params ()); ACE_Module_Type *mt = (ACE_Module_Type *) stp; ACE_Module *mp = (ACE_Module *) mt->object (); if (ACE_OS::strcmp (mp->name (), active_info->name ()) != 0) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("warning: assigning Module_Type name %s to Module %s since names differ\n"), active_info->name (), mp->name ())); mp->name (active_info->name ()); } if (mt->init (args.argc (), args.argv ()) == -1 || this->stream_->push (mt) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Error initializing module")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (active_info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Push dynamic %s into stream %s\n"), // this->parsed_info_.name (), // this->stream_info_.name ())); } else { ACE_Service_Type *stype = ACE_Service_Config::create_service_type (active_info->name (), stp, svc_dll, active_info->active ()); // @@ Check error here. // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply dynamic %s\n"), // this->parsed_info_.name ())); if (ACE_Service_Config::initialize (stype, active_info->init_params ()) == -1) { // If it did not initialize correctly, the // ACE_Service_Config doesn't own this object delete stype; // build the error message ACE_TString msg (ACE_TEXT ("Failed to initialize dynamic service")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (active_info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } this->parsed_info_.reset (); } } else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0) { if (this->in_stream_def_) { // @@ Couldn't make sense out of the original Svc_Conf.y. ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Create static %s for stream\n"), this->stream_info_.name ())); } else { if (this->in_module_) { // @@ Couldn't make sense out of the original Svc_Conf.y. ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Push static %s into stream %s\n"), this->parsed_info_.name (), this->stream_info_.name ())); } else { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply static %s\n"), // this->parsed_info_.name ())); if (ACE_Service_Config::initialize (this->parsed_info_.name (), this->parsed_info_.init_params ()) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Failed to initialize static service")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } this->parsed_info_.reset (); } } else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0) { this->in_module_ = 0; } else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"), // this->stream_info_.name (), // this->stream_info_.name ())); ACE_Service_Config::initialize (this->stream_svc_type_, this->stream_info_.init_params ()); this->stream_info_.reset (); this->stream_svc_type_ = 0; this->stream_ = 0; } else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Apply stream %s of type %s\n"), // this->stream_info_.name (), // this->stream_info_.name ())); this->stream_info_.reset (); } else { } } void ACEXML_Svcconf_Handler::endPrefixMapping (const ACEXML_Char *) { // no-op } void ACEXML_Svcconf_Handler::ignorableWhitespace (const ACEXML_Char *, int, int) { // no-op } void ACEXML_Svcconf_Handler::processingInstruction (const ACEXML_Char *, const ACEXML_Char *) { // no-op } void ACEXML_Svcconf_Handler::setDocumentLocator (ACEXML_Locator* locator) { this->locator_ = locator; } void ACEXML_Svcconf_Handler::skippedEntity (const ACEXML_Char *) { // no-op } void ACEXML_Svcconf_Handler::startDocument (void) { // no-op } void ACEXML_Svcconf_Handler::startElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName, ACEXML_Attributes *alist) { if (ACE_OS::strcmp (qName, ACE_TEXT ("dynamic")) == 0) { this->get_dynamic_attrs (alist); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("initializer")) == 0) { this->get_initializer_attrs (alist); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("static")) == 0) { this->get_static_attrs (alist); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("stream")) == 0) { this->get_stream_id (alist); if (ACE_Service_Repository::instance()->find (this->stream_info_.name (), (const ACE_Service_Type **) &this->stream_svc_type_) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Cannot find stream '")); msg += ACE_TString (this->stream_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } this->stream_ = this->stream_svc_type_ == 0 ? 0 : dynamic_cast (const_cast (this->stream_svc_type_->type ())); // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Retrieve stream %s from repository\n"), // this->stream_info_.name ())); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("streamdef")) == 0) { this->in_stream_def_ = 1; // @@ Set up stream service object } else if (ACE_OS::strcmp (qName, ACE_TEXT ("module")) == 0) { this->in_stream_def_ = 0; this->in_module_ = 1; } else if (ACE_OS::strcmp (qName, ACE_TEXT ("resume")) == 0) { this->get_id (alist); if (this->in_module_) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s in stream %s\n"), // this->parsed_info_.name (), // this->stream_info_.name ())); ACE_Module_Type *mt = (this->stream_ == 0) ? 0 : this->stream_->find (this->parsed_info_.name ()); if (mt == 0) { // build the error message ACE_TString msg (ACE_TEXT ("Can't locate module '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } mt->resume (); } else { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Resume %s\n"), // this->parsed_info_.name ())); if (ACE_Service_Config::resume (this->parsed_info_.name ()) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Resume failed")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } this->parsed_info_.reset (); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("suspend")) == 0) { this->get_id (alist); if (this->in_module_) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s in stream %s\n"), // this->parsed_info_.name (), // this->stream_info_.name ())); ACE_Module_Type *mt = (this->stream_ == 0) ? 0 : this->stream_->find (this->parsed_info_.name ()); if (mt == 0) { // build the error message ACE_TString msg (ACE_TEXT ("Can't locate module '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } mt->suspend (); } else { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Suspend %s\n"), // this->parsed_info_.name ())); if (ACE_Service_Config::suspend (this->parsed_info_.name ()) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Suspend failed")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } this->parsed_info_.reset (); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("remove")) == 0) { this->get_id (alist); if (this->in_module_) { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s in stream %s\n"), // this->parsed_info_.name (), // this->stream_info_.name ())); ACE_Module_Type *mt = (this->stream_ == 0) ? 0 : this->stream_->find (this->parsed_info_.name ()); if (mt == 0) { // build the error message ACE_TString msg (ACE_TEXT ("Can't locate module '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } this->stream_->remove (mt); } else { // ACE_DEBUG ((LM_INFO, ACE_TEXT ("Remove %s\n"), // this->parsed_info_.name ())); if (ACE_Service_Config::remove (this->parsed_info_.name ()) == -1) { // build the error message ACE_TString msg (ACE_TEXT ("Remove failed")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } this->parsed_info_.reset (); } else if (ACE_OS::strcmp (qName, ACE_TEXT ("ACE_Svc_Conf")) == 0) { // Main document tag. no-op. // ACE_DEBUG ((LM_INFO, ACE_TEXT ("ACE_Svc_Conf tag\n"))); } else { // @@ Error. Perhaps we should relay to user event handler here, if available. } return; } void ACEXML_Svcconf_Handler::startPrefixMapping (const ACEXML_Char *, const ACEXML_Char *) { // No-op. } // *** Methods inherit from ACEXML_DTDHandler. void ACEXML_Svcconf_Handler::notationDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } void ACEXML_Svcconf_Handler::unparsedEntityDecl (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { // No-op. } // Methods inherit from ACEXML_EnitityResolver. ACEXML_InputSource * ACEXML_Svcconf_Handler::resolveEntity (const ACEXML_Char *, const ACEXML_Char *) { // No-op. return 0; } // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ void ACEXML_Svcconf_Handler::error (ACEXML_SAXParseException& ex) { ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_Svcconf_Handler::fatalError (ACEXML_SAXParseException& ex) { ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } void ACEXML_Svcconf_Handler::warning (ACEXML_SAXParseException& ex) { ACE_DEBUG ((LM_DEBUG, "%s: line :%d col: %d ", this->locator_->getSystemId(), this->locator_->getLineNumber(), this->locator_->getColumnNumber())); ex.print(); } int ACEXML_Svcconf_Handler::get_stream_id (ACEXML_Attributes *alist) { if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { this->stream_info_.name (alist->getValue (i)); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid stream attribute '")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (this->stream_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } return 0; } int ACEXML_Svcconf_Handler::get_id (ACEXML_Attributes *alist) { if (alist != 0) for (size_t i = 0; i < alist->getLength (); ++i) { if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { this->parsed_info_.name (alist->getValue (i)); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid attribute '")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("', expecting 'id'")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (this->parsed_info_.name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } return 0; } int ACEXML_Svcconf_Handler::get_dynamic_attrs (ACEXML_Attributes *alist) { if (alist != 0) { ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ? &this->parsed_info_ : &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { info->name (alist->getValue (i)); } else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("status")) == 0) { if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("inactive")) == 0) { info->active (0); } else if (ACE_OS::strcmp (alist->getValue (i), ACE_TEXT ("active")) == 0) { info->active (1); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid attribute value '")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("', expecting 'active' or 'inactive'")); msg += ACE_TString (ACE_TEXT (" for entity '")); msg += ACE_TString (info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("type")) == 0) { if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("service_object")) == 0) { info->service_type (ACE_Service_Type::SERVICE_OBJECT); } else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("stream")) == 0) { info->service_type (ACE_Service_Type::STREAM); } else if (ACE_OS::strcasecmp (alist->getValue (i), ACE_TEXT ("module")) == 0) { info->service_type (ACE_Service_Type::MODULE); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid Service_Object attribute value'")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid attribute'")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } } return 0; } int ACEXML_Svcconf_Handler::get_initializer_attrs (ACEXML_Attributes *alist) { if (alist != 0) { ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ? &this->parsed_info_ : &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("init")) == 0) { info->init_func (alist->getValue (i)); } else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("path")) == 0) { info->path (alist->getValue (i)); } else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) { info->init_params (alist->getValue (i)); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid initializer attribute'")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } } return 0; } int ACEXML_Svcconf_Handler::get_static_attrs (ACEXML_Attributes *alist) { if (alist != 0) { ACE_Parsed_Info *info = (this->in_stream_def_ == 0 ? &this->parsed_info_ : &this->stream_info_); for (size_t i = 0; i < alist->getLength (); ++i) { if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("id")) == 0) { info->name (alist->getValue (i)); } else if (ACE_OS::strcmp (alist->getQName (i), ACE_TEXT ("params")) == 0) { info->init_params (alist->getValue (i)); } else { // build the error message ACE_TString msg (ACE_TEXT ("Invalid static attribute '")); msg += ACE_TString (alist->getQName (i)); msg += ACE_TString (ACE_TEXT ("' for entity '")); msg += ACE_TString (info->name ()); msg += ACE_TString (ACE_TEXT ("'\n")); throw ACEXML_SAXException (msg.c_str ()); } } } return 0; } #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/README0000644000175000017500000000013612576461726020652 0ustar pgquilespgquiles This directory implement a DLL that contains the parser for XML based service configurator. ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/Svcconf_Handler.inl0000644000175000017500000000412712576461726023540 0ustar pgquilespgquiles// -*- C++ -*- ACE_INLINE ACE_Parsed_Info::ACE_Parsed_Info () : name_ (0), service_type_ (ACE_Service_Type::INVALID_TYPE), active_ (1), path_ (0), init_func_ (0), init_params_ (0) { } ACE_INLINE ACE_Parsed_Info::~ACE_Parsed_Info () { delete[] this->name_; delete[] this->path_; delete[] this->init_func_; delete[] this->init_params_; } ACE_INLINE int ACE_Parsed_Info::name (const ACEXML_Char *n) { if (this->name_ == 0) { this->name_ = ACE::strnew (n); return 0; } return -1; } ACE_INLINE const ACEXML_Char * ACE_Parsed_Info::name (void) { return this->name_; } ACE_INLINE int ACE_Parsed_Info::service_type (int type) { if (this->service_type_ == -1) { this->service_type_ = type; return 0; } return -1; } ACE_INLINE int ACE_Parsed_Info::service_type (void) { return this->service_type_; } ACE_INLINE int ACE_Parsed_Info::active (int a) { this->active_ = a; return 0; } ACE_INLINE int ACE_Parsed_Info::active (void) { return this->active_; } ACE_INLINE int ACE_Parsed_Info::path (const ACEXML_Char *p) { if (this->path_ == 0) { this->path_ = ACE::strnew (p); return 0; } return -1; } ACE_INLINE const ACEXML_Char * ACE_Parsed_Info::path (void) { return this->path_; } ACE_INLINE int ACE_Parsed_Info::init_func (const ACEXML_Char *n) { if (this->init_func_ == 0) { this->init_func_ = ACE::strnew (n); return 0; } return -1; } ACE_INLINE const ACEXML_Char * ACE_Parsed_Info::init_func (void) { return this->init_func_; } ACE_INLINE int ACE_Parsed_Info::init_params (const ACEXML_Char *n) { if (this->init_params_ == 0) { this->init_params_ = ACE::strnew (n); return 0; } return -1; } ACE_INLINE const ACEXML_Char * ACE_Parsed_Info::init_params (void) { return this->init_params_; } ACE_INLINE void ACE_Parsed_Info::reset (void) { delete[] this->name_; this->name_ = 0; this->service_type_ = -1; delete[] this->path_; this->path_ = 0; delete[] this->init_func_; this->init_func_ = 0; delete[] this->init_params_; this->init_params_ = 0; } ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/svcconf.dtd0000644000175000017500000000472612576461726022141 0ustar pgquilespgquiles ace-6.3.3+dfsg.orig/ACEXML/apps/svcconf/Svcconf_Handler.h0000644000175000017500000001421512576461726023204 0ustar pgquilespgquiles//============================================================================= /** * @file Svcconf_Handler.h * * @author Nanbor Wang */ //============================================================================= #ifndef ACEXML_SVCCONF_HANDLER_H #define ACEXML_SVCCONF_HANDLER_H #include "ACEXML/common/DefaultHandler.h" #include "ace/Service_Types.h" #if (ACE_USES_CLASSIC_SVC_CONF == 0) class ACE_Parsed_Info { public: ACE_Parsed_Info (); ~ACE_Parsed_Info (); /** * Set/get name of a parsed entity. */ int name (const ACEXML_Char *n); const ACEXML_Char *name (void); /** * Set/get type of a dynamic node. */ int service_type (int type); int service_type (void); /** * Set/Get active status. */ int active (int a); int active (void); /** * Set/get initializer path. */ int path (const ACEXML_Char *n); const ACEXML_Char *path (void); /** * Set/get initializer init function. */ int init_func (const ACEXML_Char *n); const ACEXML_Char *init_func (void); /** * Set/get initializer init parameter. */ int init_params (const ACEXML_Char *n); const ACEXML_Char *init_params (void); /** * Reset Parsed_Info. */ void reset (void); protected: ACEXML_Char *name_; int service_type_; int active_; ACEXML_Char *path_; ACEXML_Char *init_func_; ACEXML_Char *init_params_; }; /** * @class ACEXML_Svcconf_Handler * * @brief ACEXML_Svcconf_Handler is an example SAX event handler. * * This SAX event handler try to regenerate the XML document it * reads with correct indentation. */ class ACEXML_Svcconf_Handler : public ACEXML_DefaultHandler { public: /* * Default constructor. */ ACEXML_Svcconf_Handler (void); /* * Default destructor. */ virtual ~ACEXML_Svcconf_Handler (void); // Methods inherit from ACEXML_ContentHandler. /* * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, int start, int length); /* * Receive notification of the end of a document. */ virtual void endDocument (void); /* * Receive notification of the end of an element. */ virtual void endElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /* * End the scope of a prefix-URI mapping. */ virtual void endPrefixMapping (const ACEXML_Char *prefix); /* * Receive notification of ignorable whitespace in element content. */ virtual void ignorableWhitespace (const ACEXML_Char *ch, int start, int length); /* * Receive notification of a processing instruction. */ virtual void processingInstruction (const ACEXML_Char *target, const ACEXML_Char *data); /* * Receive an object for locating the origin of SAX document events. */ virtual void setDocumentLocator (ACEXML_Locator *locator) ; /* * Receive notification of a skipped entity. */ virtual void skippedEntity (const ACEXML_Char *name); /* * Receive notification of the beginning of a document. */ virtual void startDocument (void) ; /* * Receive notification of the beginning of an element. */ virtual void startElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName, ACEXML_Attributes *atts); /* * Begin the scope of a prefix-URI Namespace mapping. */ virtual void startPrefixMapping (const ACEXML_Char *prefix, const ACEXML_Char *uri); // *** Methods inherit from ACEXML_DTDHandler. /* * Receive notification of a notation declaration event. */ virtual void notationDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId); /* * Receive notification of an unparsed entity declaration event. */ virtual void unparsedEntityDecl (const ACEXML_Char *name, const ACEXML_Char *publicId, const ACEXML_Char *systemId, const ACEXML_Char *notationName); // Methods inherit from ACEXML_EnitityResolver. /* * Allow the application to resolve external entities. */ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId, const ACEXML_Char *systemId); // Methods inherit from ACEXML_ErrorHandler. /* * Receive notification of a recoverable error. */ virtual void error (ACEXML_SAXParseException &exception); /* * Receive notification of a non-recoverable error. */ virtual void fatalError (ACEXML_SAXParseException &exception); /* * Receive notification of a warning. */ virtual void warning (ACEXML_SAXParseException &exception); protected: /** * Get the only attribute in or . */ int get_stream_id (ACEXML_Attributes *alist); /** * Get the only attribute in , , */ int get_id (ACEXML_Attributes *alist); /** * Get the dynamic tag attributes. */ int get_dynamic_attrs (ACEXML_Attributes *alist); /** * Get the initializer tag attributes. */ int get_initializer_attrs (ACEXML_Attributes *alist); /** * Get the static tag attributes. */ int get_static_attrs (ACEXML_Attributes *alist); private: /// We are parsing a stream definition int in_stream_def_; /// We are defining a steam module int in_module_; /// @a stream_ holds the actually Stream_Type object managed by @a stream_svc_type_. ACE_Service_Type *stream_svc_type_; ACE_Stream_Type *stream_; //ACE_SHLIB_HANDLE dll_handle_; ACE_Parsed_Info parsed_info_; ACE_Parsed_Info stream_info_; ACEXML_Locator* locator_; }; #if defined (__ACEXML_INLINE__) # include "Svcconf_Handler.inl" #endif /* __ACEXML_INLINE__ */ #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */ #endif /* ACEXML_SVCCONF_HANDLER_H */ ace-6.3.3+dfsg.orig/ACEXML/parser/0000775000175000017500000000000012576472436016664 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/0000775000175000017500000000000012576472436022017 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_DTD_Manager.h0000644000175000017500000000426012576461726025343 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Debug_DTD_Manager.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_DEBUG_DTD_Manager_H_ #define _ACEXML_DEBUG_DTD_Manager_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/DTD_Manager.h" class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_DTD_Manager : public ACEXML_DTD_Manager { public: ACEXML_Debug_DTD_Manager (); virtual ~ACEXML_Debug_DTD_Manager (); /** * Acquire a pointer to an element definition builder. The XML parser use * this interface to acquire the definition builder and use the builder * to create the DTD element definition. The resulting builder is then * registered with the DTD Manager or destroyed if error occured when the * builder encountered errors. * * @retval 0 if error occurs creating the builder. */ virtual ACEXML_Element_Def_Builder *getElement_Def_Builder (); /** * Insert a new element definition into the DTD Manager. * * @retval 0 if success, -1 if error. */ virtual int insertElement_Definition (ACEXML_Element_Def_Builder *def); /** * Acquire a pointer to an attributes definition builder. * */ virtual ACEXML_Attributes_Def_Builder *getAttribute_Def_Builder (); /** * Insert a new attributes definition into the DTD Manager. * * @retval 0 if success, -1 otherwise. */ virtual int insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def); /** * Acquire an element validator to validate an XML element. * * @todo I haven't figured out what memory management scheme * we should use for the acquired validator. */ virtual ACEXML_Validator *getValidator (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); }; #include /**/ "ace/post.h" #endif /* _ACEXML_DTD_Manager_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Element_Tree.inl0000644000175000017500000000340012576461726025066 0ustar pgquilespgquilesACEXML_INLINE ACEXML_Element_Tree_Node::ACEXML_Element_Tree_Node () : next_ (0) { } ACEXML_INLINE ACEXML_Element_Tree_Node * ACEXML_Element_Tree_Node::next () { return this->next_; } ACEXML_INLINE void ACEXML_Element_Tree_Node::next (ACEXML_Element_Tree_Node * n) { this->next_ = n; } ACEXML_INLINE ACEXML_Element_Tree_Name_Node::ACEXML_Element_Tree_Name_Node (const ACEXML_Char *name, int release) : name_ (name, 0, release) { } ACEXML_INLINE void ACEXML_Element_Tree_Name_Node::set (const ACEXML_Char *name, int release) { this->name_.set (name, release); } ACEXML_INLINE ACEXML_Element_Tree_List_Node::ACEXML_Element_Tree_List_Node (void) : type_ (SEQUENCE), head_ (0), tail_ (0), pop_next_ (0) { } ACEXML_INLINE ACEXML_Element_Tree_List_Node::LIST_TYPE ACEXML_Element_Tree_List_Node::get (void) { return this->type_; } ACEXML_INLINE int ACEXML_Element_Tree_List_Node::set (ACEXML_Element_Tree_List_Node::LIST_TYPE type) { this->type_ = type; return 0; } ACEXML_INLINE ACEXML_Element_Tree_List_Stack::ACEXML_Element_Tree_List_Stack (void) : top_ (0) { } ACEXML_INLINE ACEXML_Element_Tree_List_Node * ACEXML_Element_Tree_List_Stack::top () { return this->top_; } ACEXML_INLINE void ACEXML_Element_Tree_List_Stack::push (ACEXML_Element_Tree_List_Node *n) { n->pop_next_ = this->top_; this->top_ = n; } ACEXML_INLINE ACEXML_Element_Tree_List_Node * ACEXML_Element_Tree_List_Stack::pop () { if (this->top_ != 0) { ACEXML_Element_Tree_List_Node *ptr = this->top_; this->top_ = this->top_->pop_next_; return ptr; } return 0; } ACEXML_INLINE int ACEXML_Element_Tree_List_Stack::empty () { return this->top_ == 0; } ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_Attributes_Builder.cpp0000644000175000017500000001064612576461726027432 0ustar pgquilespgquiles#include "ACEXML/common/SAXExceptions.h" #include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h" ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder () : type_ (ERROR_TYPE), default_decl_ (INVALID) { } ACEXML_Debug_Attribute_Builder::ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs) : name_ (rhs.name_), type_ (rhs.type_), default_decl_ (rhs.default_decl_), default_value_ (rhs.default_value_), att_value_queue_ (rhs.att_value_queue_) { } ACEXML_Debug_Attribute_Builder::~ACEXML_Debug_Attribute_Builder () { } int ACEXML_Debug_Attribute_Builder::setName (const ACEXML_Char *n) { this->name_.set (n, 0); return 0; } const ACEXML_Char * ACEXML_Debug_Attribute_Builder::getName (void) { return this->name_.fast_rep (); } int ACEXML_Debug_Attribute_Builder::setAttType (const ATT_TYPE type) { if (this->type_ == ERROR_TYPE) { this->type_ = type; return 0; } ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Attribute type redefinition in Debug Validator")), -1); } int ACEXML_Debug_Attribute_Builder::insertList (const ACEXML_Char *n) { ACEXML_String str (n, 0, 0); this->att_value_queue_.enqueue_tail (str); return 0; } int ACEXML_Debug_Attribute_Builder::setDefault (const DEFAULT_DECL def, const ACEXML_Char *value) { this->default_decl_ = def; this->default_value_.set (value, 0); return 0; } int ACEXML_Debug_Attribute_Builder::validAttr (void) { // @@ Not implemented. Always return 1 (true) for now. return 1; } void ACEXML_Debug_Attribute_Builder::dump (void) { cout << this->name_ << " "; switch (this->type_) { case CDATA: cout << "CDATA "; break; case ID: cout << "ID "; break; case IDREF: cout << "IDREF "; break; case IDREFS: cout << "IDREFS "; break; case ENTITY: cout << "ENTITY "; break; case ENTITIES: cout << "ENTITIES "; break; case NMTOKEN: cout << "NMTOKEN "; break; case NMTOKENS: cout << "NMTOKENS "; break; case NOTATION: cout << "NOTATION "; // Fall thru case ENUMERATION: { cout << "("; ACEXML_STRING_QUEUE_ITERATOR iter (this->att_value_queue_); ACEXML_String *n = 0; while (iter.advance () != 0) { if (n == 0) cout << " | "; iter.next (n); cout << *n; } cout << ") "; } break; default: cout << "*** UNKNOWN TYPE ***"; break; } switch (this->default_decl_) { case REQUIRED: cout << "#REQUIRED"; break; case IMPLIED: cout << "#IMPLIED"; break; case FIXED: cout << "#FIXED " << this->default_value_; break; default: cout << "**** UNDEFINED DEFAULT DECL ****"; break; } } // ======================================== ACEXML_Debug_Attributes_Builder::ACEXML_Debug_Attributes_Builder () { } ACEXML_Debug_Attributes_Builder::~ACEXML_Debug_Attributes_Builder () { } int ACEXML_Debug_Attributes_Builder::setElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { this->element_name_.set (qName, 0); return 0; } ACEXML_Attribute_Def_Builder * ACEXML_Debug_Attributes_Builder::getAttribute_Def_Builder () { ACEXML_Attribute_Def_Builder *tmp; ACE_NEW_RETURN (tmp, ACEXML_Debug_Attribute_Builder (), 0); return tmp; } int ACEXML_Debug_Attributes_Builder::insertAttribute ( ACEXML_Attribute_Def_Builder *def) { ACEXML_Attribute_Def_Builder::VAR ptr (def); if (def != 0) { ACEXML_String attname (def->getName (), 0, 0); ACEXML_Debug_Attribute_Builder *ptr = dynamic_cast (def); this->attributes_.bind (attname, *ptr); return 0; } ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1); } void ACEXML_Debug_Attributes_Builder::dump (void) { // @@ Print print. cout << "element_name_ << endl; ACEXML_ATT_MAP_ITER iter (this->attributes_); ACEXML_ATT_MAP_ENTRY *item; while (iter.advance () != 0) { iter.next (item); cout << "\n\t"; item->int_id_.dump (); } cout << ">" << endl; } ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h0000644000175000017500000000350312576461726026703 0ustar pgquilespgquiles // -*- C++ -*- // Definition for Win32 Export directives. // This file is generated automatically by generate_export_file.pl -s ACEXML_DEBUG_DTD_MANAGER // ------------------------------ #ifndef ACEXML_DEBUG_DTD_MANAGER_EXPORT_H #define ACEXML_DEBUG_DTD_MANAGER_EXPORT_H #include "ace/config-all.h" #if defined (ACE_AS_STATIC_LIBS) && !defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL) # define ACEXML_DEBUG_DTD_MANAGER_HAS_DLL 0 #endif /* ACE_AS_STATIC_LIBS && ACEXML_DEBUG_DTD_MANAGER_HAS_DLL */ #if !defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL) # define ACEXML_DEBUG_DTD_MANAGER_HAS_DLL 1 #endif /* ! ACEXML_DEBUG_DTD_MANAGER_HAS_DLL */ #if defined (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL) && (ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1) # if defined (ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL) # define ACEXML_DEBUG_DTD_MANAGER_Export ACE_Proper_Export_Flag # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # else /* ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL */ # define ACEXML_DEBUG_DTD_MANAGER_Export ACE_Proper_Import_Flag # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # endif /* ACEXML_DEBUG_DTD_MANAGER_BUILD_DLL */ #else /* ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1 */ # define ACEXML_DEBUG_DTD_MANAGER_Export # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARATION(T) # define ACEXML_DEBUG_DTD_MANAGER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) #endif /* ACEXML_DEBUG_DTD_MANAGER_HAS_DLL == 1 */ #endif /* ACEXML_DEBUG_DTD_MANAGER_EXPORT_H */ // End of auto generated file. ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_Attributes_Builder.h0000644000175000017500000001124212576461726027070 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Debug_Attributes_Builder.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_ #define _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Attributes_Def_Builder.h" #include "ace/Hash_Map_Manager.h" #include "ace/Unbounded_Queue.h" typedef ACE_Unbounded_Queue ACEXML_STRING_QUEUE; typedef ACE_Unbounded_Queue_Iterator ACEXML_STRING_QUEUE_ITERATOR; /** * @class ACEXML_Debug_Attribute_Builder Debug_Attributes_Builder.h "parser/debug_validator/Debug_Attributes_Builder.h" * * This class prints out the Attribute definition for debugging purpose. */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Attribute_Builder : public ACEXML_Attribute_Def_Builder { public: ACEXML_Debug_Attribute_Builder (); ACEXML_Debug_Attribute_Builder (const ACEXML_Debug_Attribute_Builder &rhs); virtual ~ACEXML_Debug_Attribute_Builder (); /** * Specify the name of the attribute. */ virtual int setName (const ACEXML_Char *n); virtual const ACEXML_Char *getName (void); /** * Set the attribute type. */ virtual int setAttType (const ATT_TYPE type); /** * Insert an element for NOTATION or ENUMERATION type attribute. */ virtual int insertList (const ACEXML_Char *Name); /** * Set default attribute declaration. */ virtual int setDefault (const DEFAULT_DECL def, const ACEXML_Char *value); /** * Check validity of the current attribute definition being built. * * @retval 0 if the attribute is not a valid combo. */ virtual int validAttr (void); /** * Dump the content of the attribute definition. */ virtual void dump (void); private: /// Attribute name. ACEXML_String name_; /// Type of attribute. ATT_TYPE type_; /// Default value type. DEFAULT_DECL default_decl_; /// Default attribute value. ACEXML_String default_value_; /// Holds a queue of enumerated attribute values. ACEXML_STRING_QUEUE att_value_queue_; }; typedef ACE_Hash_Map_Entry ACEXML_ATT_MAP_ENTRY; typedef ACE_Hash_Map_Manager_Ex , ACE_Equal_To, ACE_Null_Mutex> ACEXML_ATT_MAP; typedef ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ATT_MAP_ITER; typedef ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ATT_MAP_REVERSE_ITER; /** * @class ACEXML_Debug_Attributes_Builder Debug_Attributes_Builder.h "parser/debug_validator/Debug_Attributes_Builder.h" * * This class prints out Attribute definitions for debugging purpose. */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Attributes_Builder : public ACEXML_Attributes_Def_Builder { public: ACEXML_Debug_Attributes_Builder (); virtual ~ACEXML_Debug_Attributes_Builder (); /** * Set the element name that the attribute builder applies. * * @retval 0 if valid, -1 otherwise. */ virtual int setElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) ; /** * Acquire an Attribute_Builder. */ virtual ACEXML_Attribute_Def_Builder *getAttribute_Def_Builder (); /** * Add a definition for one attribute. */ virtual int insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL); /** * Dump the content of the attribute definition. */ virtual void dump (void); protected: /// The name of the element type these attributes applied. ACEXML_String element_name_; /// Collection of attributes. ACEXML_ATT_MAP attributes_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_DEBUG_ATTRIBUTES_BUILDER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_Element_Builder.h0000644000175000017500000000600412576461726026333 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Debug_Element_Builder.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_DEBUG_ELEMENT_BUILDER_H_ #define _ACEXML_DEBUG_ELEMENT_BUILDER_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/Element_Def_Builder.h" #include "ACEXML/parser/debug_validator/Element_Tree.h" /** * @class ACEXML_Debug_Element_Builder Debug_Element_Builder.h "parser/debug_validator/Debug_Element_Builder.h" * * This class prints out the element definition for debugging purpose. * * @todo This class is not namespace-aware. */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Debug_Element_Builder : public ACEXML_Element_Def_Builder { public: ACEXML_Debug_Element_Builder (); virtual ~ACEXML_Debug_Element_Builder (); /** * Define the name of the element. * * @retval 0 if valid, -1 otherwise. */ virtual int setElementName (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /** * Define the content type of the element. * * @retval 0 if valid, -1 otherwise. */ virtual int setContentType (CONTENT_TYPE type); /** * Insert one more element into Mixed definition. */ virtual int insertMixedElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName); /** * Start a new group of children. */ virtual int startChildGroup (); /** * End a new group of children. * * @retval 0 on success. */ virtual int endChildGroup (CARDINALITY card); /** * Set the type of current child group to Choice. * * @retval 0 on success, -1 if the type of the child group has * already been set and this action conflicts with the previous * setting. */ virtual int setChoice (); /** * Set the type of current child group to Sequence. * * @retval 0 on success, -1 if the type of the child group has * already been set and this action conflicts with the previous * setting. */ virtual int setSequence (); /** * Insert an new element into the current child group. * * @retval 0 on success, -1 otherwise. */ virtual int insertElement (const ACEXML_Char *namespaceURI, const ACEXML_Char *localName, const ACEXML_Char *qName) ; /** * Dump the content of the attribute definition. */ virtual void dump (void); private: CONTENT_TYPE type_; ACEXML_String element_; ACEXML_Element_Tree_List_Node *root_; ACEXML_Element_Tree_List_Stack active_list_; }; #include /**/ "ace/post.h" #endif /* _ACEXML_DEBUG_ELEMENT_BUILDER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_DTD_Manager.cpp0000644000175000017500000000323312576461726025675 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/SAXExceptions.h" #include "ACEXML/parser/debug_validator/Debug_DTD_Manager.h" #include "ACEXML/parser/debug_validator/Debug_Element_Builder.h" #include "ACEXML/parser/debug_validator/Debug_Attributes_Builder.h" ACEXML_Debug_DTD_Manager::ACEXML_Debug_DTD_Manager () { } ACEXML_Debug_DTD_Manager::~ACEXML_Debug_DTD_Manager () { } ACEXML_Element_Def_Builder * ACEXML_Debug_DTD_Manager::getElement_Def_Builder () { return new ACEXML_Debug_Element_Builder (); } int ACEXML_Debug_DTD_Manager::insertElement_Definition (ACEXML_Element_Def_Builder *def) { ACEXML_Element_Def_Builder::VAR ptr (def); if (def != 0) { ptr->dump (); return 0; } ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1); } ACEXML_Attributes_Def_Builder * ACEXML_Debug_DTD_Manager::getAttribute_Def_Builder () { ACEXML_Attributes_Def_Builder *tmp; ACE_NEW_RETURN (tmp, ACEXML_Debug_Attributes_Builder (), 0); return tmp; } int ACEXML_Debug_DTD_Manager::insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def) { ACEXML_Attributes_Def_Builder::VAR ptr (def); if (def != 0) { ptr->dump (); return 0; } ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("ACEXML_Debug_Attributes_Builder internal error")), -1); } ACEXML_Validator * ACEXML_Debug_DTD_Manager::getValidator (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *) { ACEXML_THROW_RETURN (ACEXML_SAXNotSupportedException (ACE_TEXT ("getValidator()")), 0); } ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Element_Tree.cpp0000644000175000017500000000244512576461726025076 0ustar pgquilespgquiles#include "ACEXML/parser/debug_validator/Element_Tree.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/parser/debug_validator/Element_Tree.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_Element_Tree_Node::~ACEXML_Element_Tree_Node () { delete this->next_; } ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_Node) void ACEXML_Element_Tree_Name_Node::dump () { cout << this->name_; } ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_Name_Node) ACEXML_Element_Tree_List_Node::~ACEXML_Element_Tree_List_Node (void) { delete this->head_; } int ACEXML_Element_Tree_List_Node::insert (ACEXML_Element_Tree_Node *node) { if (this->head_ == 0) { this->tail_ = this->head_ = node; } else { this->tail_->next (node); this->tail_ = node; } return 0; } void ACEXML_Element_Tree_List_Node::dump (void) { ACEXML_Element_Tree_Node *ptr = this->head_; const ACEXML_Char *separator = (this->type_ == SEQUENCE) ? ACE_TEXT(" , ") : ACE_TEXT(" | "); cout << "("; if (ptr != 0) { ptr->dump (); ptr = ptr->next (); while (ptr != 0) { cout << separator; ptr->dump (); ptr->next (); } } cout << ")"; } ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_List_Node) ACE_ALLOC_HOOK_DEFINE (ACEXML_Element_Tree_List_Stack) ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Debug_Element_Builder.cpp0000644000175000017500000000627112576461726026674 0ustar pgquilespgquiles#include "ACEXML/common/SAXExceptions.h" #include "ACEXML/parser/debug_validator/Debug_Element_Builder.h" ACEXML_Debug_Element_Builder::ACEXML_Debug_Element_Builder () : type_ (UNDEFINED), root_ (0) { } ACEXML_Debug_Element_Builder::~ACEXML_Debug_Element_Builder () { delete this->root_; } int ACEXML_Debug_Element_Builder::setElementName (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { this->element_.set (qName, 0); return 0; } int ACEXML_Debug_Element_Builder::setContentType (CONTENT_TYPE type) { if (this->type_ == UNDEFINED) { this->type_ = type; return 0; } ACEXML_THROW_RETURN (ACEXML_SAXParseException (ACE_TEXT("Element type redefinition in Debug_Validator.")), -1); } int ACEXML_Debug_Element_Builder::insertMixedElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { ACEXML_Element_Tree_Name_Node *node = 0; // @@ We should "throw" an exception here instead of returning -1. ACE_NEW_RETURN (node, ACEXML_Element_Tree_Name_Node (qName), -1); if (this->root_ == 0) // @@ Memory leak if fail? ACE_NEW_RETURN (this->root_, ACEXML_Element_Tree_List_Node (), -1); return this->root_->insert (node); } int ACEXML_Debug_Element_Builder::startChildGroup () { ACEXML_Element_Tree_List_Node *lnode = 0; ACE_NEW_RETURN (lnode, ACEXML_Element_Tree_List_Node (), -1); if (this->root_ == 0) { this->root_ = lnode; } else { // @@ check error? this->root_->insert (lnode); } this->active_list_.push (lnode); return 0; } int ACEXML_Debug_Element_Builder::endChildGroup (CARDINALITY ) { this->active_list_.pop (); return 0; } int ACEXML_Debug_Element_Builder::setChoice () { this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::CHOICE); return 0; } int ACEXML_Debug_Element_Builder::setSequence () { this->active_list_.top ()->set (ACEXML_Element_Tree_List_Node::SEQUENCE); return 0; } int ACEXML_Debug_Element_Builder::insertElement (const ACEXML_Char *, const ACEXML_Char *, const ACEXML_Char *qName) { ACEXML_Element_Tree_Name_Node *node = 0; // @@ We should "throw" an exception here instead of returning -1. ACE_NEW_RETURN (node, ACEXML_Element_Tree_Name_Node (qName), -1); return this->active_list_.top ()->insert (node); } void ACEXML_Debug_Element_Builder::dump () { cout << "element_; // @@ Also dump element contentspec here. switch (this->type_) { case EMPTY: cout << "EMPTY"; break; case ANY: cout << "ANY"; break; case MIXED: case CHILDREN: // @@ Dump the content of this->root_ cout << "*** not implemented ***"; break; default: cout << "*** Unidentified element type ***"; break; } cout << ">" << endl; } ace-6.3.3+dfsg.orig/ACEXML/parser/debug_validator/Element_Tree.h0000644000175000017500000000730312576461726024541 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Element_Tree.h * * @author Nanbor Wang */ //============================================================================= #ifndef _ACEXML_ELEMENT_TREE_H_ #define _ACEXML_ELEMENT_TREE_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/debug_validator/Debug_DTD_Manager_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_Element_Tree_Node Element_Tree.h "parser/debug_validator/Element_Tree.h" * * @brief An abstract base class for describing DTD child element definition. * * @sa ACEXML_Element_Tree_Name_Node, ACEXML_Element_Tree_List_Node */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Node { public: /// Default constructor. ACEXML_Element_Tree_Node (); /// Destructor virtual ~ACEXML_Element_Tree_Node (); /// Accessor for next element in chain ACEXML_Element_Tree_Node *next (); void next (ACEXML_Element_Tree_Node *n); /// Displaying the content. virtual void dump () = 0; ACE_ALLOC_HOOK_DECLARE; protected: ACEXML_Element_Tree_Node *next_; }; /** * @class ACEXML_Element_Tree_Name_Node Element_Tree.h "parser/debug_validator/Element_Tree.h" * * @brief An abstract base class for describing a name node in a DTD child * element definition. * * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_List_Node */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_Name_Node : public ACEXML_Element_Tree_Node { public: /// Constructor. ACEXML_Element_Tree_Name_Node (const ACEXML_Char *name, int release = 1); /// Change the name of this node. void set (const ACEXML_Char *name, int release = 1); virtual void dump (); ACE_ALLOC_HOOK_DECLARE; protected: ACEXML_String name_; }; class ACEXML_Element_Tree_List_Stack; /** * @class ACEXML_Element_Tree_List_Node Element_Tree.h "parser/debug_validator/Element_Tree.h" * * @brief An abstract base class for describing a node list in a DTD child * element definition. * * @sa ACEXML_Element_Tree_Node, ACEXML_Element_Tree_Name_Node */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Node : public ACEXML_Element_Tree_Node { public: friend class ACEXML_Element_Tree_List_Stack; typedef enum { SEQUENCE, CHOICE } LIST_TYPE; /// Default constructor. ACEXML_Element_Tree_List_Node (void); /// Destructor. virtual ~ACEXML_Element_Tree_List_Node (void); /// Insert a new ACEXML_Element_Tree_Node into the list. int insert (ACEXML_Element_Tree_Node *node); /// Get/set the type of list. LIST_TYPE get (void); int set (LIST_TYPE type); virtual void dump (); ACE_ALLOC_HOOK_DECLARE; protected: LIST_TYPE type_; ACEXML_Element_Tree_Node *head_; ACEXML_Element_Tree_Node *tail_; ACEXML_Element_Tree_List_Node *pop_next_; }; /** * @class ACEXML_Element_Tree_List_Stack Element_Tree.h "parser/debug_validator/Element_Tree.h" * * @brief A class for managing a stack of ACEXML_Element_Tree_List_Node's. * * @sa ACEXML_Element_Tree_List_Node */ class ACEXML_DEBUG_DTD_MANAGER_Export ACEXML_Element_Tree_List_Stack { public: ACEXML_Element_Tree_List_Stack (); void push (ACEXML_Element_Tree_List_Node *n); ACEXML_Element_Tree_List_Node *pop (void); ACEXML_Element_Tree_List_Node *top (void); int empty (void); ACE_ALLOC_HOOK_DECLARE; protected: ACEXML_Element_Tree_List_Node *top_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/parser/debug_validator/Element_Tree.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* _ACEXML_ELEMENT_TREE_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/parser/0000775000175000017500000000000012576472436020160 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/parser/parser/Entity_Manager.cpp0000644000175000017500000000047712576461726023600 0ustar pgquilespgquiles#include "ACEXML/parser/parser/Entity_Manager.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/Entity_Manager.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_Entity_Manager::ACEXML_Entity_Manager (void) : entities_ (0) { } ACEXML_Entity_Manager::~ACEXML_Entity_Manager (void) { this->reset(); } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ParserContext.cpp0000644000175000017500000000047212576461726023466 0ustar pgquilespgquiles#include "ACEXML/parser/parser/ParserContext.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/ParserContext.inl" #endif /* __ACEXML_INLINE__ */ ACEXML_Parser_Context::~ACEXML_Parser_Context() { delete this->instream_; this->instream_ = 0; delete this->locator_; this->locator_ = 0; } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Parser_export.h0000644000175000017500000000341312576461726023165 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Parser_export.h * * @author Nanbor Wang */ //============================================================================= // Definition for Win32 Export directives. // This file is generated automatically by generate_export_file.pl // ------------------------------ #ifndef ACEXML_PARSER_EXPORT_H #define ACEXML_PARSER_EXPORT_H #include "ace/config-all.h" #if defined (ACE_AS_STATIC_LIBS) && !defined (ACEXML_PARSER_HAS_DLL) # define ACEXML_PARSER_HAS_DLL 0 #endif /* ACE_AS_STATIC_LIBS && ACEXML_PARSER_HAS_DLL */ #if !defined (ACEXML_PARSER_HAS_DLL) # define ACEXML_PARSER_HAS_DLL 1 #endif /* ! ACEXML_PARSER_HAS_DLL */ #if defined (ACEXML_PARSER_HAS_DLL) && (ACEXML_PARSER_HAS_DLL == 1) # if defined (ACEXML_PARSER_BUILD_DLL) # define ACEXML_PARSER_Export ACE_Proper_Export_Flag # define ACEXML_PARSER_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) # define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # else /* ACEXML_PARSER_BUILD_DLL */ # define ACEXML_PARSER_Export ACE_Proper_Import_Flag # define ACEXML_PARSER_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) # define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) # endif /* ACEXML_PARSER_BUILD_DLL */ #else /* ACEXML_PARSER_HAS_DLL == 1 */ # define ACEXML_PARSER_Export # define ACEXML_PARSER_SINGLETON_DECLARATION(T) # define ACEXML_PARSER_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) #endif /* ACEXML_PARSER_HAS_DLL == 1 */ #endif /* ACEXML_PARSER_EXPORT_H */ // End of auto generated file. ace-6.3.3+dfsg.orig/ACEXML/parser/parser/parser.mpc0000644000175000017500000000051412576461726022153 0ustar pgquilespgquiles// -*- MPC -*- project(ACEXML_Parser): acelib, ace_output, install { avoids += ace_for_tao sharedname = ACEXML_Parser after += ACEXML libs += ACEXML dynamicflags += ACEXML_PARSER_BUILD_DLL specific { install_dir = ACEXML/parser/parser } Pkgconfig_Files { ACEXML_Parser.pc.in } } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ParserContext.h0000644000175000017500000000423212576461726023131 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ParserContext.h * * @author Krishnakumar B */ //============================================================================= #ifndef ACEXML_PARSER_CONTEXT_H #define ACEXML_PARSER_CONTEXT_H #include /**/ "ace/pre.h" #include "ACEXML/parser/parser/Parser_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" #include "ACEXML/common/InputSource.h" #include "ACEXML/common/Locator.h" #include "ACEXML/common/LocatorImpl.h" #include "ace/Functor.h" #include "ace/Containers_T.h" class ACEXML_PARSER_Export ACEXML_Parser_Context { public: /// Default constructor ACEXML_Parser_Context(); /// Constructor which initializes the context ACEXML_Parser_Context (ACEXML_InputSource* instream, ACEXML_LocatorImpl* locator); /// Comparison operator bool operator!= (const ACEXML_Parser_Context& src); /// Destructor virtual ~ACEXML_Parser_Context(); /// Reset the parser context. This does not free up the memory. Only sets /// it to zero. Meant to be called after a context is pushed on to a /// stack. void reset (void); /// Get the underlying input source. virtual ACEXML_InputSource* getInputSource(void); /// Get the underlying locator. virtual ACEXML_LocatorImpl* getLocator(void); /// Set the underlying input source. virtual void setInputSource(ACEXML_InputSource* ip); /// Set the underlying locator. virtual void setLocator(ACEXML_LocatorImpl* locator); private: /// Copy constructor ACEXML_Parser_Context (const ACEXML_Parser_Context& src); /// Assignment operator ACEXML_Parser_Context& operator= (const ACEXML_Parser_Context& src); /// Current input char stream. ACEXML_InputSource *instream_; /// Current Locator which provides line no., column no. systemId and publicId ACEXML_LocatorImpl* locator_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/ParserContext.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* ACEXML_PARSER_CONTEXT_H */ ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Parser.inl0000644000175000017500000001346612576461726022130 0ustar pgquilespgquiles//============================================================================= /** * @file Parser.inl * * @author Nanbor Wang */ //============================================================================= ACEXML_INLINE ACEXML_ContentHandler * ACEXML_Parser::getContentHandler (void) const { return this->content_handler_; } ACEXML_INLINE ACEXML_DTDHandler * ACEXML_Parser::getDTDHandler (void) const { return this->dtd_handler_; } ACEXML_INLINE ACEXML_EntityResolver * ACEXML_Parser::getEntityResolver (void) const { return this->entity_resolver_; } ACEXML_INLINE ACEXML_ErrorHandler * ACEXML_Parser::getErrorHandler (void) const { return this->error_handler_; } ACEXML_INLINE void ACEXML_Parser::setContentHandler (ACEXML_ContentHandler *handler) { this->content_handler_ = handler; } ACEXML_INLINE void ACEXML_Parser::setDTDHandler (ACEXML_DTDHandler *handler) { this->dtd_handler_ = handler; } ACEXML_INLINE void ACEXML_Parser::setEntityResolver (ACEXML_EntityResolver *resolver) { this->entity_resolver_ = resolver; } ACEXML_INLINE void ACEXML_Parser::setErrorHandler (ACEXML_ErrorHandler *handler) { this->error_handler_ = handler; } ACEXML_INLINE int ACEXML_Parser::isChar (ACEXML_UCS4 c) const { return (c == 0x9 || c == 0xA || c == 0xD || (c >= 0x20 && c <= 0xD7FF) || (c >= 0xE000 && c <= 0xFFFD) || (c >= 0x10000 && c <= 0x10FFFF)); } ACEXML_INLINE int ACEXML_Parser::isCharRef (const ACEXML_Char c) const { return ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); } ACEXML_INLINE int ACEXML_Parser::isNormalDigit (const ACEXML_Char c) const { return (c >= '\x30' && c <= '\x39'); } ACEXML_INLINE int ACEXML_Parser::isBasechar (const ACEXML_Char c) const { #if defined (ACE_USES_WCHAR) return ACEXML_ParserInt::isBasechar_i (c); #else return ACEXML_ParserInt::base_char_table_[(int) c]; #endif /* ACE_USES_WCHAR */ } ACEXML_INLINE int ACEXML_Parser::isIdeographic (const ACEXML_Char c) const { #if defined (ACE_USES_WCHAR) return ACEXML_ParserInt::isIdeographic_i (c); #else ACE_UNUSED_ARG (c); return 0; #endif /* ACE_USES_WCHAR */ } ACEXML_INLINE int ACEXML_Parser::isCombiningchar (const ACEXML_Char c) const { #if defined (ACE_USES_WCHAR) return ACEXML_ParserInt::isCombiningchar_i (c); #else ACE_UNUSED_ARG (c); return 0; #endif /* ACE_USES_WCHAR */ } ACEXML_INLINE int ACEXML_Parser::isDigit (const ACEXML_Char c) const { #if defined (ACE_USES_WCHAR) return ACEXML_ParserInt::isDigit_i (c); #else return (this->isNormalDigit (c)); #endif /* ACE_USES_WCHAR */ } ACEXML_INLINE int ACEXML_Parser::isExtender (const ACEXML_Char c) const { #if defined (ACE_USES_WCHAR) return ACEXML_ParserInt::isExtender_i (c); #else return (c == '\xB7'); #endif /* ACE_USES_WCHAR */ } ACEXML_INLINE int ACEXML_Parser::isLetter (const ACEXML_Char c) const { return (this->isBasechar (c) || this->isIdeographic (c)); } ACEXML_INLINE int ACEXML_Parser::isNameChar (const ACEXML_Char c) const { return (this->isLetter (c) || this->isDigit (c) || c == '.' || c == '-' || c == '_' || c == ':' || this->isCombiningchar (c) || this->isExtender (c)); } ACEXML_INLINE int ACEXML_Parser::isPubidChar (const ACEXML_Char c) const { return (c == '\x20' || c == '\x0D' || c == '\x0A' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '\'' || c == '(' || c == ')' || c == '+' || c == ',' || c == '.' || c == '/' || c == ':' || c == '=' || c == '?' || c == ';' || c == '!' || c == '*' || c == '#' || c == '@' || c == '$' || c == '_' || c == '%'); } ACEXML_INLINE int ACEXML_Parser::is_whitespace (const ACEXML_Char c) const { switch (c) { case '\x0A': case '\x20': case '\x09': case '\x0D': return 1; default: return 0; } } ACEXML_INLINE ACEXML_Char ACEXML_Parser::skip_whitespace (void) { ACEXML_Char ch = this->get(); while (this->is_whitespace (ch)) ch = this->get (); return ch; } ACEXML_INLINE int ACEXML_Parser::skip_whitespace_count (ACEXML_Char *peeky) { int wscount = 0; ACEXML_Char dummy; ACEXML_Char &forward = (peeky == 0 ? dummy : *peeky); for (;this->is_whitespace ((forward = this->peek ())); ++wscount) this->get (); return wscount; } ACEXML_INLINE int ACEXML_Parser::skip_equal (void) { if (this->skip_whitespace() != '=') return -1; while (this->is_whitespace (this->peek())) this->get(); return 0; } ACEXML_INLINE ACEXML_Char ACEXML_Parser::get (void) { ACEXML_Char ch = 0; const ACEXML_InputSource* ip = this->current_->getInputSource(); ACEXML_CharStream* instream = ip->getCharStream(); if (instream->get (ch) != -1) { this->current_->getLocator()->incrColumnNumber(); // Normalize white-space if (ch == '\x0D') { if (instream->peek() == 0x0A) instream->get (ch); ch = '\x0A'; } if (ch == '\x0A') { // Reset column number and increment Line Number. this->current_->getLocator()->incrLineNumber(); this->current_->getLocator()->setColumnNumber (0); } return ch; } return 0; } ACEXML_INLINE ACEXML_Char ACEXML_Parser::peek (void) { // Using an extra level of indirection so we can // manage document location in the future. ACEXML_Char ch = 0; const ACEXML_InputSource* ip = this->current_->getInputSource(); ACEXML_CharStream* instream = ip->getCharStream(); ch = static_cast (instream->peek ()); return (ch > 0 ? ch : 0); } ACEXML_INLINE int ACEXML_Parser::parse_token (const ACEXML_Char* keyword) { if (keyword == 0) return -1; const ACEXML_Char* ptr = keyword; for (; *ptr != 0 && (this->get() == *ptr); ++ptr) ; if (*ptr == 0) return 0; else return -1; } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ParserContext.inl0000644000175000017500000000272112576461726023465 0ustar pgquilespgquiles// -*- C++ -*- #include ACEXML_INLINE ACEXML_Parser_Context::ACEXML_Parser_Context() : instream_ (0), locator_ (0) { } ACEXML_INLINE ACEXML_Parser_Context::ACEXML_Parser_Context (ACEXML_InputSource* instream, ACEXML_LocatorImpl* locator) : instream_ (instream), locator_ (locator) { } ACEXML_INLINE ACEXML_Parser_Context::ACEXML_Parser_Context (const ACEXML_Parser_Context& src) : instream_ (src.instream_), locator_ (src.locator_) { } ACEXML_INLINE bool ACEXML_Parser_Context::operator!= (const ACEXML_Parser_Context& src) { return (this->instream_ != src.instream_ && this->locator_ != src.locator_); } ACEXML_INLINE ACEXML_Parser_Context& ACEXML_Parser_Context::operator= (const ACEXML_Parser_Context& src) { ACEXML_Parser_Context tmp (src); std::swap (this->instream_, tmp.instream_); std::swap (this->locator_, tmp.locator_); return *this; } ACEXML_INLINE ACEXML_InputSource* ACEXML_Parser_Context::getInputSource (void) { return this->instream_; } ACEXML_INLINE ACEXML_LocatorImpl* ACEXML_Parser_Context::getLocator (void) { return this->locator_; } ACEXML_INLINE void ACEXML_Parser_Context::setInputSource (ACEXML_InputSource* ip) { this->instream_ = ip; } ACEXML_INLINE void ACEXML_Parser_Context::setLocator (ACEXML_LocatorImpl* locator) { this->locator_ = locator; } ACEXML_INLINE void ACEXML_Parser_Context::reset (void) { this->instream_ = 0; this->locator_ = 0; } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Parser.h0000644000175000017500000005463612576461726021601 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Parser.h * * @author Nanbor Wang * @author Krishnakumar B */ //============================================================================= #ifndef _ACEXML_BASIC_PARSER_H_ #define _ACEXML_BASIC_PARSER_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/parser/Parser_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XMLReader.h" #include "ACEXML/common/LocatorImpl.h" #include "ACEXML/common/NamespaceSupport.h" #include "ACEXML/common/CharStream.h" #include "ace/Obstack.h" #include "ace/Functor.h" #include "ace/SString.h" #include "ace/Hash_Map_Manager.h" #include "ace/Unbounded_Set.h" #include "ace/Containers_T.h" #include "ace/Auto_Ptr.h" #include "ACEXML/parser/parser/Entity_Manager.h" #include "ACEXML/parser/parser/ParserInternals.h" #include "ACEXML/parser/parser/ParserContext.h" /** * @class ACEXML_Parser Parser.h "ACEXML/parser/parser/Parser.h" * * @brief A SAX based parser. */ class ACEXML_PARSER_Export ACEXML_Parser : public ACEXML_XMLReader { public: /// Default constructor. ACEXML_Parser (void); /// Destructor. virtual ~ACEXML_Parser (void); /** * Initialize the parser state. * * @retval 0 if parser was initialized correctly else -1. */ int initialize (ACEXML_InputSource* input); /** * Return the current content handler. */ virtual ACEXML_ContentHandler *getContentHandler (void) const; /* * Return the current DTD handler. */ virtual ACEXML_DTDHandler *getDTDHandler (void) const; /* * Return the current entity resolver. */ virtual ACEXML_EntityResolver *getEntityResolver (void) const; /* * Return the current error handler. */ virtual ACEXML_ErrorHandler *getErrorHandler (void) const; /** * Look up the value of a feature. This method allows * programmers to check whether a specific feature has been * activated in the parser. */ virtual int getFeature (const ACEXML_Char *name); /** * Activating or deactivating a feature. */ virtual void setFeature (const ACEXML_Char *name, int boolean_value); /* * Look up the value of a property. */ virtual void * getProperty (const ACEXML_Char *name); /* * Set the value of a property. */ virtual void setProperty (const ACEXML_Char *name, void *value); /* * Parse an XML document. */ virtual void parse (ACEXML_InputSource *input); /* * Parse an XML document from a system identifier (URI). */ virtual void parse (const ACEXML_Char *systemId) ; /* * Allow an application to register a content event handler. */ virtual void setContentHandler (ACEXML_ContentHandler *handler); /* * Allow an application to register a DTD event handler. */ virtual void setDTDHandler (ACEXML_DTDHandler *handler); /* * Allow an application to register an entity resolver. */ virtual void setEntityResolver (ACEXML_EntityResolver *resolver); /* * Allow an application to register an error event handler. */ virtual void setErrorHandler (ACEXML_ErrorHandler *handler); protected: /** * Parse XML Prolog. */ void parse_xml_prolog (void); /** * Parse VersionInfo declaration. * */ void parse_version_info (void); /** * Parse a EncodingDecl declaration. * */ void parse_encoding_decl (void); /** * Parse a XMLDecl declaration. * */ void parse_xml_decl (void); /** * Parse a TextDecl declaration. */ int parse_text_decl (void); /** * Parse a PI statement. The first character encountered * should always be '?' in the PI prefix "@doctype_. * * @todo Instead of simply checking for the root element based on the * argument @a is_root, we should instead either pass in some sort * of validator or allow the function to return the element name so it * can be used in a validator. */ void parse_element (int is_root); /** * Parse a content declaration. * */ int parse_content (const ACEXML_Char* startname, const ACEXML_Char*& ns_uri, const ACEXML_Char*& ns_lname, int ns_flag); /** * Parse a character reference, i.e., " " or "". The first * character encountered should be the '#' char. * * @param buf points to a character buffer for the result. * * @param len In/out argument which initially specifies the size of the * buffer and is later set to the no. of characters in the reference. * * @retval 0 on success and -1 otherwise. */ int parse_char_reference (ACEXML_Char *buf, size_t& len); /** * Parse a reference name, i.e., foo in "&foo;" or "%foo;". The first * character encountered should be the character following '&' or '%'. * Effectively the same as @sa parse_name but we don't use the parser's * obstack. Caller is responsible for deleting the memory. * * @retval A pointer to name of reference, 0 otherwise. */ ACEXML_Char* parse_reference_name (void); /** * Parse a CDATA section. The first character should always be the first * '[' in CDATA definition. * * @retval 0 on success. * @retval -1 if fail. */ int parse_cdata (void); /** * Parse a "markupdecl" section, this includes both "markupdecl" and * "DeclSep" sections in XML specification */ int parse_internal_dtd (void); /** * Skip over a comment. The first character encountered should always be * the first '-' in the comment prefix "@<@!--". */ int parse_comment (void); /** * Parse an "ELEMENT" decl. The first character this method * expects is always the 'L' (the second char) in the word * "ELEMENT". * * @retval 0 on success, -1 otherwise. */ int parse_element_decl (void); /** * Parse an "ENTITY" decl. The first character this method expects * is always the 'N' (the second char) in the word "ENTITY". * * @retval 0 on success, -1 otherwise. */ int parse_entity_decl (void); /** * Parse an "ATTLIST" decl. Thse first character this method * expects is always the 'A' (the first char) in the word * "ATTLIST". * * @retval 0 on success, -1 otherwise. */ int parse_attlist_decl (void); /** * Parse a AttType declaration. * */ int parse_atttype (void); /** *Parse a "NOTATION" decl. The first character this method * expects is always the 'N' (the first char) in the word * "NOTATION". * * @retval 0 on success, -1 otherwise. */ int parse_notation_decl (void); /** * Parse an ExternalID or a reference to PUBLIC ExternalID. * Possible cases are in the forms of: * * SYSTEM 'quoted string representing system resource' * PUBLIC 'quoted name of public ID' 'quoted resource' * PUBLIC 'quoted name we are referring to' * * * The first character this function sees must be either 'S' or 'P'. * When the function finishes parsing, the input stream points * at the first non-whitespace character. * * @param publicId returns the unquoted publicId read. If none * is available, it will be reset to 0. * @param systemId returns the unquoted systemId read. If none * is available, it will be reset to 0. * * @retval 0 on success, -1 otherwise. */ int parse_external_id (ACEXML_Char *&publicId, ACEXML_Char *&systemId); /** * Parse an external DTD. * */ int parse_external_dtd (void); /** * Parse an external subset. This does the actual parsing of an external * subset and is called by @sa parse_external_dtd. * */ int parse_external_subset (void); /** * Parse a markupDecl section. * */ int parse_markup_decl (void); /** * Parse a conditionalSect declaration. * */ int parse_conditional_section (void); /** * Parse a includeSect declaration. * */ int parse_includesect (void); /** * * Parse a ignoreSect declaration. */ int parse_ignoresect (void); /** * Parse a PEReference. * */ int parse_PE_reference (void); /** * Parse a Reference. * */ int parse_entity_reference (void); /** * Parse an entityValue. * */ int parse_entity_value (ACEXML_Char *&str); /** * Parse a DefaultDecl specification. * */ int parse_defaultdecl (void); /** * Parse the "children" and "Mixed" non-terminals in contentspec. * * The first character this function sees must be the first * open paren '(' in children. * * @retval 0 on success, -1 otherwise. */ int parse_children_definition (void); /** * Parse a @c cp non-terminal. @c cp can either be a @c seq or a @c choice. * This function calls itself recursively. * * @param skip_open_paren when non-zero, it indicates that the open paren of * the @c seq or @c choice has already been removed from the input * stream. * * @retval 0 on success, -1 otherwise. */ int parse_child (int skip_open_paren); /** * Parse a name from the input CharStream. If @a ch @!= 0, then we have * already consumed the first name character from the input CharStream, * otherwise, parse_name will use this->get() to acquire the initial * character. * * @return A pointer to the string in the obstack, 0 if it's not a * valid name. */ ACEXML_Char *parse_name (ACEXML_Char ch = 0); /** * Parse a NMTOKEN from the input stream. * * @return A pointer to the string in the obstack, 0 if it's not a valid * NMTOKEN. */ ACEXML_Char* parse_nmtoken (ACEXML_Char ch = 0); /** * Parse the version string in an XML Prolog section. * * @param str String containing the version number if successful. * @return 0 if the string was read successfully, 0 otherwise. */ int parse_version (ACEXML_Char*& str); /** * Parse the version number in a VersionInfo declaration. */ int parse_version_num (ACEXML_Char*& str); /** * Parse the encoding name in an XML Prolog section. * * @param str String containing the encoding name if successful. * @return 0 if the string was read successfully, 0 otherwise. */ int parse_encname (ACEXML_Char*& str); /** * Parse a SDDecl string. * * @param str String containing the encoding name if successful. * @return 0 if the string was read successfully, -1 otherwise. */ int parse_sddecl (ACEXML_Char*& str); /** * Parse an attribute name. * * @retval str String containing the value of the attribute name * if successful. * @retval 0 otherwise. */ ACEXML_Char* parse_attname (void); /** * Parse an attribute value. * * @param str String containing the value of the attribute if successful. * @return 0 if attribute value was read successfully, -1 otherwise. */ int parse_attvalue (ACEXML_Char*& str); /** * Parse a tokenized type attribute. * * @return 0 if attribute type was read successfully, -1 otherwise. */ int parse_tokenized_type (void); /** * Parse a SystemLiteral. * * @param str String containing the SystemLiteral if successful. * @return 0 if the string was read successfully, 0 otherwise. */ int parse_system_literal (ACEXML_Char*& str); /** * Parse a PubidLiteral. * * @param str String containing the PubidLiteral if successful. * @return 0 if the string was read successfully, 0 otherwise. */ int parse_pubid_literal (ACEXML_Char*& str); /** * Check if a character @a c is a whitespace. * * @retval 1 if @a c is a valid white space character. 0 otherwise. */ int is_whitespace (const ACEXML_Char c) const; /** * Check if a character @a c is a valid Char. * * @retval 1 if @a c is a valid character. 0 otherwise. */ int isChar (ACEXML_UCS4 c) const; /** * Check if a character @a c is a valid CharRef character. * * @retval 1 if @a c is a valid character reference character, 0 otherwise. */ int isCharRef (const ACEXML_Char c) const; /** * Check if a character @a c is a BaseChar. * * @retval 1 if @a c is a valid BaseChar character, 0 otherwise. */ int isBasechar (const ACEXML_Char c) const; /** * Check if a character @a c is a Ideographic. * * @retval 1 if @a c is a valid Ideographic character, 0 otherwise. */ int isIdeographic (const ACEXML_Char c) const; /** * Check if a character @a c is a CombiningChar. * * @retval 1 if @a c is a valid CombiningChar character, 0 otherwise. */ int isCombiningchar (const ACEXML_Char c) const; /** * Check if a character @a c is a Digit. * * @retval 1 if @a c is a valid Digit character, 0 otherwise. */ int isDigit (const ACEXML_Char c) const; /** * Check if a character @a c is an Extender. * * @retval 1 if @a c is a valid Extender character, 0 otherwise. */ int isExtender (const ACEXML_Char c) const; /** * Check if a character @a c is a Letter. * * @retval 1 if @a c is a valid Letter character, 0 otherwise. */ int isLetter (const ACEXML_Char c) const; /** * Check if a character is an acceptable NameChar. * * @retval 1 if @a c is a valid NameChar character, 0 otherwise. */ int isNameChar (const ACEXML_Char c) const; /** * Check if a character is a PubidChar. * * @retval 1 if @a c is a valid PubidChar character, 0 otherwise. */ int isPubidChar (const ACEXML_Char c) const; /// Get a character. virtual ACEXML_Char get (void); /// Peek a character. virtual ACEXML_Char peek (void); private: // *** Helper functions for parsing XML /** * Skip any whitespaces encountered until the first non-whitespace * character is encountered. * * @return The next non-whitespace character from the CharStream. * * @sa skip_whitespace_count */ ACEXML_Char skip_whitespace (void); /** * Skip any whitespaces encountered until the first non-whitespace * character. The first non-whitespace character is not consumed. * This method does peek into the input CharStream and therefore * is more expensive than @ref skip_whitespace. * * @param peek If non-null, @a peek points to a ACEXML_Char where * skip_whitespace_count stores the first non-whitespace * character it sees (character is not removed from the stream.) * * @return The number of whitespace characters consumed. * * @sa skip_whitespace */ int skip_whitespace_count (ACEXML_Char *peek = 0); /** * Skip an equal sign. * * @retval 0 when succeeds, -1 if no equal sign is found. */ int skip_equal (void); /** * Get a quoted string. Quoted strings are used to specify * attribute values and this routine will replace character and * entity references on-the-fly. Parameter entities are not allowed * (or replaced) in this function. (But regular entities are.) * * @param str returns the un-quoted string. * * @retval 0 on success, -1 otherwise. */ int get_quoted_string (ACEXML_Char *&str); /** * Check if a character @a c is a Digit. * * @retval 1 if @a c is a valid Digit character, 0 otherwise. */ int isNormalDigit (const ACEXML_Char c) const; /** * Dispatch errors to ErrorHandler. * */ void error (const ACEXML_Char* msg); /** * Dispatch warnings to ErrorHandler. * */ void warning (const ACEXML_Char* msg); /** * Dispatch fatal errors to ErrorHandler. * */ void fatal_error (const ACEXML_Char* msg); /** * Dispatch prefix mapping calls to the ContentHandler. * * @param prefix Namespace prefix * @param uri Namespace URI * @param name Local name * @param start 1 => startPrefixMapping 0 => endPrefixMapping */ void prefix_mapping (const ACEXML_Char* prefix, const ACEXML_Char* uri, int start); /** * Parse a keyword. */ int parse_token (const ACEXML_Char* keyword); /** * Push the current context on to the stack. * */ int push_context (ACEXML_Parser_Context* context); /** * Pop the top element in the stack and replace current context with that. */ size_t pop_context (int GE_ref); /** * Create a new ACEXML_CharStream from @a systemId and @a publicId and * replace the current input stream with the newly created stream. */ virtual int switch_input (ACEXML_CharStream* cstream, const ACEXML_Char* systemId, const ACEXML_Char* publicId = 0); /** * Create a new ACEXML_InputSource from @a systemId and @a publicId and * replace the current input source with the newly created InputSource. */ virtual int switch_input (ACEXML_InputSource* input, const ACEXML_Char* systemId, const ACEXML_Char* publicId = 0); /** * Check for a parameter entity reference. This is used to check for the * occurrence of a PE Reference withing markupDecl. Additionally this * function consumes any leading or trailing whitespace around the PE * Reference. * * @retval Number of whitespace characters skipped. */ int check_for_PE_reference (void); /** * Reset the parser state. * */ void reset (void); /** * Very trivial, non-conformant normalization of a systemid. * */ ACEXML_Char* normalize_systemid (const ACEXML_Char* systemId); // Feature names: /** * \addtogroup acexml_parser_features * @{ */ /** * @var simple_parsing_feature_ * * This constant string defines the name of "simple XML parsing" * feature. When this feature is enabled, ACEXML parser is allowed * to parse a simple XML stream without mandated XML prolog * and no DTD defintion. */ static const ACEXML_Char simple_parsing_feature_[]; /** * @var namespaces_feature_ * * This constant string defines the SAX XML Namespace feature. When this * feature is enabled, ACEXML parser allows access by namespace qualified * names. */ static const ACEXML_Char namespaces_feature_[]; /** * @var namespace_prefixes_feature_ * * This constant string defines the SAX XML Namespace prefixes feature. * Normally the list of attributes returned by the parser will not * contain attributes used as namespace declarations (xmlns*). When this * feature is enabled, the list of attributes contains the namespace * declarations also. */ static const ACEXML_Char namespace_prefixes_feature_[]; /** * @var validation_feature_ * * This constant string defines the SAX XML Validation feature. When * this feature is enabled, the parser validates the document in * addition to checking for well-formedness. */ static const ACEXML_Char validation_feature_[]; /* @} */ /// Keeping track of the handlers. We do not manage the memory for /// handlers. ACEXML_DTDHandler *dtd_handler_; ACEXML_EntityResolver *entity_resolver_; ACEXML_ContentHandler *content_handler_; ACEXML_ErrorHandler *error_handler_; /// Document Type ACEXML_Char *doctype_; /// Current parser context ACEXML_Parser_Context* current_; /// Stack used to hold the Parser_Context ACE_Unbounded_Stack ctx_stack_; /* * The following two are essentially chains of references and is used by * the parser to determine if there is any recursion. We keep two of * these one for general entities and one for parameter entities, as they * both fall under different namespaces. * */ /// Set used to hold the general entity references that are active. ACE_Unbounded_Stack GE_reference_; /// Set used to hold the parameter entity references that are active. ACE_Unbounded_Stack PE_reference_; /// Obstack used by the parser to hold all the strings parsed ACE_Obstack_T obstack_; /// Alternative obstack used to hold any strings when the original is in use ACE_Obstack_T alt_stack_; /// Namespace stack used by the parser to implement support for Namespaces ACEXML_NamespaceSupport xml_namespace_; /// T => We are processing a nested namespace int nested_namespace_; /// Set of internal parsed general entities in the document ACEXML_Entity_Manager internal_GE_; /// Set of external parsed general entities in the document ACEXML_Entity_Manager external_GE_; /// Set of unparsed entities in the document ACEXML_Entity_Manager unparsed_entities_; /// Set of predefined entities used by the parser ACEXML_Entity_Manager predef_entities_; /// Set of internal parsed parameter entities in the document ACEXML_Entity_Manager internal_PE_; /// Set of external parsed parameter entities in the document ACEXML_Entity_Manager external_PE_; /// Set of notations declared in the document ACEXML_Entity_Manager notations_; /// State of the parser when it encounters a reference. ACEXML_ParserInt::ReferenceState ref_state_; /// T => We are parsing an external subset int external_subset_; /// T => We are parsing an external entity value int external_entity_; /// T => Internal DTD has parameter entity references int has_pe_refs_; /// If set, the document is a standalone XML document int standalone_; /// If set, the document has an external DTD subset int external_dtd_; /// If set, the document has an internal DTD int internal_dtd_; /// Feature flags /// If set, the parser should parse a document without a prolog int simple_parsing_; /// If set, the parser should also validate int validate_; /// If set, the parser should allow access by namespace qualified names. int namespaces_; /// If set, the parser should include namespace declarations in the list /// of attributes of an element. int namespace_prefixes_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/Parser.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* _ACEXML_BASIC_PARSER_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ACEXML_Parser.pc.in0000644000175000017500000000035112576461726023373 0ustar pgquilespgquilesprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: ACEXML_Parser Description: ACE XML Parser Library Requires: ACEXML Version: @VERSION@ Libs: -L${libdir} -lACEXML_Parser Cflags: -I${includedir} ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Entity_Manager.inl0000644000175000017500000000305712576461726023575 0ustar pgquilespgquilesACEXML_INLINE int ACEXML_Entity_Manager::add_entity (const ACEXML_Char *ref, const ACEXML_Char *v) { if (!this->entities_ ) ACE_NEW_RETURN (this->entities_, ACEXML_ENTITIES_MANAGER, -1); ACEXML_String name (ref, 0, false); ACEXML_String value (v, 0, false); return this->entities_->bind (name, value); } ACEXML_INLINE const ACEXML_Char* ACEXML_Entity_Manager::resolve_entity (const ACEXML_Char *ref) { if (!this->entities_) return 0; ACEXML_ENTITY_ENTRY *entry = 0; if (this->entities_->find (ACEXML_String (ref, 0, false), entry) == 0) return entry->int_id_.c_str(); return 0; } ACEXML_INLINE int ACEXML_Entity_Manager::resolve_entity (const ACEXML_Char* ref, ACEXML_Char*& systemId, ACEXML_Char*& publicId) { if (!this->entities_) return 0; publicId = systemId = 0; ACEXML_ENTITY_ENTRY_ITERATOR iter (*this->entities_, ref); ACEXML_ENTITY_ENTRY_ITERATOR end (*this->entities_, ref, 1); if (iter != end) { systemId = const_cast ((*iter).int_id_.c_str()); ++iter; if (iter != end) publicId = const_cast ((*iter).int_id_.c_str()); return 0; } return -1; } ACEXML_INLINE int ACEXML_Entity_Manager::reset (void) { delete this->entities_; this->entities_ = 0; return 0; } ACEXML_INLINE size_t ACEXML_Entity_Manager::size (void) const { if (!this->entities_) return 0; return this->entities_->current_size(); } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Entity_Manager.h0000644000175000017500000000610112576461726023233 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file Entity_Manager.h * * @author Nanbor Wang * @author Krishnakumar B */ //============================================================================= #ifndef ACEXML_ENTITY_MANAGER_H #define ACEXML_ENTITY_MANAGER_H #include /**/ "ace/pre.h" #include "ACEXML/parser/parser/Parser_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" #include "ace/Hash_Map_Manager.h" #include "ace/Null_Mutex.h" typedef ACE_Hash_Map_Entry ACEXML_ENTITY_ENTRY; typedef ACE_Hash_Map_Manager_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER; typedef ACE_Hash_Map_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER_ITER; typedef ACE_Hash_Map_Reverse_Iterator_Ex, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ENTITIES_MANAGER_REVERSE_ITER; typedef ACE_Hash_Map_Bucket_Iterator, ACE_Equal_To, ACE_Null_Mutex> ACEXML_ENTITY_ENTRY_ITERATOR; /** * @class ACEXML_Entity_Manager Entity_Manager.h "ACEXML/parser/parser/Entity_Manager.h" * * @brief Class to manage and resolve entity references. * * @todo Fill in details for this class. */ class ACEXML_PARSER_Export ACEXML_Entity_Manager { public: /// Default constructor. ACEXML_Entity_Manager (void); /// Destructor. ~ACEXML_Entity_Manager (void); /// Add a new entity declaration. int add_entity (const ACEXML_Char *ref, const ACEXML_Char *value); /// Resolve an entity reference. const ACEXML_Char* resolve_entity (const ACEXML_Char *ref); /// Resolve an entity reference and return the tuple of @c systemId and /// @c publicId int resolve_entity (const ACEXML_Char* ref, ACEXML_Char*& systemId, ACEXML_Char*& publicId); /// Number of items in the Entity Manager size_t size(void) const; /// Reset the state int reset (void); private: ACEXML_ENTITIES_MANAGER* entities_; // bool init_; }; #if defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/Entity_Manager.inl" #endif /* __ACEXML_INLINE__ */ #include /**/ "ace/post.h" #endif /* ACEXML_ENTITY_MANAGER_H */ ace-6.3.3+dfsg.orig/ACEXML/parser/parser/Parser.cpp0000644000175000017500000025421112576461726022123 0ustar pgquilespgquiles#include "ACEXML/parser/parser/Parser.h" #if !defined (__ACEXML_INLINE__) # include "ACEXML/parser/parser/Parser.inl" #endif /* __ACEXML_INLINE__ */ #include "ace/ACE.h" #include "ACEXML/common/Transcode.h" #include "ACEXML/common/AttributesImpl.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/common/StreamFactory.h" #include "ACEXML/parser/parser/ParserInternals.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_strings.h" static const ACEXML_Char default_attribute_type[] = ACE_TEXT ("CDATA"); static const ACEXML_Char empty_string[] = { 0 }; const ACEXML_Char ACEXML_Parser::simple_parsing_feature_[] = ACE_TEXT ("Simple"); const ACEXML_Char ACEXML_Parser::namespaces_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespaces"); const ACEXML_Char ACEXML_Parser::namespace_prefixes_feature_[] = ACE_TEXT ("http://xml.org/sax/features/namespace-prefixes"); const ACEXML_Char ACEXML_Parser::validation_feature_[] = ACE_TEXT ("http://xml.org/sax/features/validation"); ACEXML_Parser::ACEXML_Parser (void) : dtd_handler_ (0), entity_resolver_ (0), content_handler_ (0), error_handler_ (0), doctype_ (0), current_ (0), alt_stack_ (MAXPATHLEN), nested_namespace_ (0), ref_state_ (ACEXML_ParserInt::INVALID), external_subset_ (0), external_entity_ (0), has_pe_refs_ (0), standalone_ (0), external_dtd_ (0), internal_dtd_ (0), simple_parsing_ (0), validate_ (1), namespaces_(1), namespace_prefixes_ (0) { } ACEXML_Parser::~ACEXML_Parser (void) { } int ACEXML_Parser::initialize(ACEXML_InputSource* input) { // Initialize namespace support if (this->xml_namespace_.init() == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error initializing namespace support\n"))); return -1; } for (int i = 0; i < 5; ++i) { if (this->predef_entities_.add_entity (ACEXML_ParserInt::predef_ent_[i], ACEXML_ParserInt::predef_val_[i]) != 0) { ACE_ERROR ((LM_DEBUG, ACE_TEXT ("Error adding entity %s to Manager\n"), ACEXML_ParserInt::predef_ent_[i])); return -1; } } return this->switch_input (input, input->getSystemId()); } void ACEXML_Parser::parse (const ACEXML_Char *systemId) { ACEXML_InputSource* input = 0; ACE_NEW (input, ACEXML_InputSource (systemId)); this->parse (input); } void ACEXML_Parser::parse (ACEXML_InputSource *input) { if (input == 0) { this->fatal_error(ACE_TEXT ("Invalid input source")); } if (this->content_handler_ == 0) { this->fatal_error (ACE_TEXT ("No content handlers defined. Exiting..")); } if (this->validate_ && this->dtd_handler_ == 0) { this->fatal_error (ACE_TEXT ("No DTD handlers defined. Exiting..")); } if (this->initialize(input) == -1) { this->fatal_error (ACE_TEXT ("Failed to initialize parser state")); } // Set up Locator. this->content_handler_->setDocumentLocator (this->current_->getLocator()); int xmldecl_defined = 0; ACEXML_Char fwd = this->get(); // Consume '<' if (fwd == '<' && this->peek() == '?') { this->get(); // Consume '?' fwd = this->peek(); if (fwd == 'x' && !xmldecl_defined) { this->parse_xml_decl (); xmldecl_defined = 1; } } // We need a XMLDecl in a Valid XML document if (this->validate_ && !xmldecl_defined) { this->fatal_error (ACE_TEXT ("Expecting an XMLDecl at the beginning of") ACE_TEXT (" a valid document")); } this->content_handler_->startDocument (); int doctype_defined = 0; for (int prolog_done = 0; prolog_done == 0; ) { // Expect a '<' only if we have encountered a XMLDecl, or we are // looping through Misc blocks. if (xmldecl_defined) { if (this->skip_whitespace () != '<') { this->fatal_error (ACE_TEXT ("Expecting '<' at the beginning of ") ACE_TEXT ("Misc section")); } fwd = this->peek(); } switch (fwd) { case '?': this->get(); this->parse_processing_instruction (); xmldecl_defined = 1; break; case '!': this->get(); fwd = this->peek (); if (fwd == 'D' && !doctype_defined) // DOCTYPE { // This will also take care of the trailing MISC block if any. this->parse_doctypedecl (); doctype_defined = 1; // Now that we have a DOCTYPE Decl defined, we shouldn't // accept XML Decl any longer xmldecl_defined = 1; } else if (fwd == 'D') { this->fatal_error (ACE_TEXT ("Duplicate DOCTYPE declaration")); } else if (fwd == '-') // COMMENT { if (this->parse_comment () < 0) { this->fatal_error(ACE_TEXT ("Invalid comment in document")); } xmldecl_defined = 1; } break; case 0: this->fatal_error (ACE_TEXT ("Unexpected end-of-file")); default: // Root element begins prolog_done = 1; break; } } if (this->validate_ && !doctype_defined) { this->warning (ACE_TEXT ("No doctypeDecl in valid document")); } // Now parse root element. this->parse_element (1); this->content_handler_->endDocument (); // Reset the parser state this->reset(); } int ACEXML_Parser::parse_doctypedecl (void) { if (this->parse_token (ACE_TEXT ("DOCTYPE")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword DOCTYPE in a doctypedecl")); } ACEXML_Char nextch = 0; if (this->skip_whitespace_count (&nextch) == 0) { this->fatal_error(ACE_TEXT ("Expecting a space between DOCTYPE keyword ") ACE_TEXT ("and name")); } this->doctype_ = this->parse_name (); if (this->doctype_ == 0) { this->fatal_error(ACE_TEXT ("Invalid DOCTYPE name")); } int count = this->skip_whitespace_count (&nextch); if (nextch == 'S' || nextch == 'P') // ExternalID defined { if (count == 0) { this->fatal_error(ACE_TEXT ("Expecting a space between DOCTYPE") ACE_TEXT ("keyword and name")); } this->external_dtd_ = 1; this->parse_external_dtd (); } nextch = this->skip_whitespace (); switch (nextch) { case '[': this->internal_dtd_ = 1; // Internal DTD definition this->parse_internal_dtd (); break; case '>': // End of DTD definition // This is an XML document without a doctypedecl. if (this->validate_ && !this->external_dtd_) { this->fatal_error (ACE_TEXT ("No DTD defined")); } return 0; case '0': this->fatal_error (ACE_TEXT ("Unexpected end-of-file")); default: break; } if (this->skip_whitespace() != '>') { this->fatal_error(ACE_TEXT ("Expecting '>' at end of doctypedecl")); } return 0; } int ACEXML_Parser::parse_internal_dtd (void) { this->ref_state_ = ACEXML_ParserInt::IN_INT_DTD; ACEXML_Char nextch = this->skip_whitespace (); do { switch (nextch) { case '<': nextch = this->get(); switch (nextch) { case '!': this->parse_markup_decl (); break; case '?': this->parse_processing_instruction (); break; default: this->fatal_error (ACE_TEXT ("Invalid internal subset")); break; } break; case '%': this->has_pe_refs_ = 1; this->parse_PE_reference (); break; case ']': // End of internal definitions. return 0; case '&': this->fatal_error (ACE_TEXT ("Invalid Reference in internal DTD")); break; case 0: this->pop_context (0); break; default: this->fatal_error (ACE_TEXT ("Invalid content in internal subset")); }; nextch = this->skip_whitespace (); } while (1); ACE_NOTREACHED (return -1); } int ACEXML_Parser::parse_external_dtd (void) { this->ref_state_ = ACEXML_ParserInt::IN_EXT_DTD; ACEXML_Char* publicId = 0; ACEXML_Char* systemId = 0; if (this->parse_external_id (publicId, systemId) != 0) { this->fatal_error (ACE_TEXT ("Error in parsing ExternalID")); } if (this->validate_) { ACEXML_Char* uri = this->normalize_systemid (systemId); ACE_Auto_Basic_Array_Ptr cleanup_uri (uri); ACEXML_InputSource* ip = 0; if (this->entity_resolver_) { ip = this->entity_resolver_->resolveEntity (publicId, (uri ? uri : systemId)); } if (ip) { if (this->switch_input (ip, (uri ? uri : systemId), publicId) != 0) return -1; } else { ACEXML_StreamFactory factory; ACEXML_CharStream* cstream = factory.create_stream (uri ? uri: systemId); if (!cstream) { this->fatal_error (ACE_TEXT ("Invalid input source")); } if (this->switch_input (cstream, systemId, publicId) != 0) return -1; } this->parse_external_subset (); } return 0; } int ACEXML_Parser::parse_external_subset (void) { this->ref_state_ = ACEXML_ParserInt::IN_EXT_DTD; this->external_subset_ = 1; size_t nrelems = 0; ACEXML_Char nextch = this->skip_whitespace(); do { switch (nextch) { case '<': nextch = this->get(); switch (nextch) { case '!': nextch = this->peek(); if (nextch == '[') this->parse_conditional_section (); else this->parse_markup_decl (); break; case '?': nextch = this->peek(); if (nextch == 'x') this->parse_text_decl (); else this->parse_processing_instruction (); break; default: this->fatal_error (ACE_TEXT ("Invalid content in external DTD")); } break; case '%': this->parse_PE_reference (); break; case 0: nrelems = this->pop_context (0); if (nrelems == 1) return 0; break; default: this->fatal_error (ACE_TEXT ("Invalid content in external DTD")); } nextch = this->skip_whitespace(); } while (1); } int ACEXML_Parser::parse_conditional_section (void) { ACEXML_Char ch = this->get (); int include = 0; if (ch != '[') { this->fatal_error(ACE_TEXT ("Internal Parser Error")); } ch = this->skip_whitespace(); if (ch == '%') { this->parse_PE_reference (); ch = this->skip_whitespace(); } if (ch == 'I') { ch = this->get(); switch (ch) { case 'N': if (this->parse_token (ACE_TEXT ("CLUDE")) < 0) { this->fatal_error (ACE_TEXT ("Expecting keyword INCLUDE in ") ACE_TEXT ("conditionalSect")); } include = 1; break; case 'G': if (this->parse_token (ACE_TEXT ("GNORE")) < 0) { this->fatal_error (ACE_TEXT ("Expecting keyword IGNORE in ") ACE_TEXT ("conditionalSect")); } include = 0; break; default: this->fatal_error (ACE_TEXT ("Invalid conditionalSect")); } ACEXML_Char fwd = '\xFF'; this->skip_whitespace_count (&fwd); if (fwd == 0) { this->get(); // Consume the 0 this->pop_context (0); } } else { this->fatal_error (ACE_TEXT ("Invalid conditionalSect")); } if (this->skip_whitespace() != '[') { this->fatal_error (ACE_TEXT ("Expecting '[' in conditionalSect")); } if (include) this->parse_includesect (); else this->parse_ignoresect (); return 0; } int ACEXML_Parser::parse_ignoresect (void) { ACEXML_Char nextch = this->skip_whitespace(); int count = 0; int done = 0; do { switch (nextch) { case '<': if (this->peek() == '!') { this->get(); if (this->peek() == '[') { this->get(); ++count; } } break; case ']': if (this->peek() == ']') { this->get(); if (this->peek() == '>') { this->get(); if (count) { --count; break; } done = 1; } } break; case 0: // [VC: Proper Conditional Section/PE Nesting] if (count != 0) { this->fatal_error (ACE_TEXT ("Invalid Conditional Section/PE ") ACE_TEXT ("Nesting ")); } default: break; } if (done) break; nextch = this->get(); } while (1); return 0; } int ACEXML_Parser::parse_includesect (void) { ACEXML_Char nextch = this->skip_whitespace(); do { switch (nextch) { case '<': nextch = this->get(); switch (nextch) { case '!': nextch = this->peek(); if (nextch == '[') this->parse_conditional_section (); else this->parse_markup_decl (); break; case '?': nextch = this->peek(); this->parse_processing_instruction (); break; default: this->fatal_error (ACE_TEXT ("Invalid includeSect")); } break; case '%': this->parse_PE_reference (); break; case 0: // [VC: Proper Conditional Section/PE Nesting] this->fatal_error (ACE_TEXT ("Invalid Conditional Section/PE ") ACE_TEXT ("Nesting ")); case ']': if (this->peek() == ']') { nextch = this->get(); if (this->peek() == '>') { nextch = this->get(); return 0; } } default: this->fatal_error (ACE_TEXT ("Invalid includeSect")); } nextch = this->skip_whitespace(); } while (1); } int ACEXML_Parser::parse_markup_decl (void) { ACEXML_Char nextch = this->peek (); switch (nextch) { case 'E': // An ELEMENT or ENTITY decl this->get (); nextch = this->peek (); switch (nextch) { case 'L': this->parse_element_decl (); break; case 'N': this->parse_entity_decl (); break; default: this->fatal_error(ACE_TEXT ("Expecting keyword ELEMENT/ENTITY")); } break; case 'A': // An ATTLIST decl this->parse_attlist_decl (); break; case 'N': // A NOTATION decl this->parse_notation_decl (); break; case '-': // a comment. if (this->parse_comment () < 0) { this->fatal_error(ACE_TEXT ("Invalid comment")); } break; case 0: // [VC: Proper Declaration/PE Nesting] this->fatal_error (ACE_TEXT ("Unexpected end-of-file")); default: this->fatal_error (ACE_TEXT ("Invalid markupDecl")); } return 0; } int ACEXML_Parser::parse_external_id (ACEXML_Char *&publicId, ACEXML_Char *&systemId) { publicId = systemId = 0; ACEXML_Char nextch = this->get (); ACEXML_Char fwd = 0; switch (nextch) { case 'S': // External SYSTEM id. if (this->parse_token (ACE_TEXT ("YSTEM")) < 0 || this->skip_whitespace_count () < 1) { this->fatal_error(ACE_TEXT ("Expecting keyword SYSTEM")); } if (this->parse_system_literal (systemId) != 0) { this->fatal_error(ACE_TEXT ("Invalid systemLiteral")); } break; case 'P': // External PUBLIC id or previously defined PUBLIC id. if (this->parse_token (ACE_TEXT ("UBLIC")) < 0 || this->skip_whitespace_count () < 1) { this->fatal_error(ACE_TEXT ("Expecting keyword PUBLIC")); } if (this->parse_pubid_literal (publicId) != 0) { this->fatal_error(ACE_TEXT ("Invalid PubidLiteral")); } this->skip_whitespace_count(&fwd); if (fwd == '\'' || fwd == '"') { if (this->parse_system_literal (systemId) != 0) { this->fatal_error(ACE_TEXT ("Invalid systemLiteral")); } } else if (this->ref_state_ != ACEXML_ParserInt::IN_NOTATION) { this->fatal_error(ACE_TEXT ("Expecting systemLiteral after a ") ACE_TEXT ("PUBLIC keyword")); } break; default: this->fatal_error(ACE_TEXT ("Invalid system/public Literal")); } return 0; } ACEXML_Char* ACEXML_Parser::normalize_systemid (const ACEXML_Char* systemId) { if (ACE_OS::strstr (systemId, ACE_TEXT("ftp://")) != 0 || ACE_OS::strstr (systemId, ACE_TEXT ("http://")) != 0 || ACE_OS::strstr (systemId, ACE_TEXT ("file://")) != 0) return 0; else { ACEXML_Char* normalized_uri = 0; const ACEXML_Char* baseURI = this->current_->getLocator()->getSystemId(); ACE_ASSERT (baseURI); const ACEXML_Char* temp = 0; if (ACE_OS::strstr (baseURI, ACE_TEXT ("http://")) != 0) { // baseURI is a HTTP URL and systemId is relative. Note that this // is not compliant with RFC2396. Caveat Emptor ! temp = ACE_OS::strrchr (baseURI, '/'); } else { // baseURI is a local file and systemId is relative // Unlike the HTTP one, this will work always. temp = ACE_OS::strrchr (baseURI, ACE_TEXT ('\\')); if (!temp) { temp = ACE_OS::strrchr (baseURI, ACE_TEXT ('/')); } } if (temp) { size_t pos = temp - baseURI + 1; size_t len = pos + ACE_OS::strlen (systemId) + 1; ACE_NEW_RETURN (normalized_uri, ACEXML_Char[len], 0); ACE_OS::strncpy (normalized_uri, baseURI, pos); ACE_OS::strcpy (normalized_uri + pos, systemId); return normalized_uri; } return 0; } } void ACEXML_Parser::parse_element (int is_root) { // Parse STag. const ACEXML_Char *startname = this->parse_name (); if (startname == 0) { this->fatal_error (ACE_TEXT ("Unexpected end-of-file")); return; } if (is_root && this->doctype_ != 0 && ACE_OS::strcmp (startname, this->doctype_) != 0) { this->fatal_error (ACE_TEXT ("Root element different from DOCTYPE")); return ; } ACEXML_AttributesImpl attributes; ACEXML_Char ch; int ns_flag = 0; // Push only one namespace context onto the stack // if there are multiple namespaces declared. const ACEXML_Char* ns_uri = 0; const ACEXML_Char* ns_lname = 0; // namespace URI and localName for (int start_element_done = 0; start_element_done == 0;) { ch = this->skip_whitespace (); switch (ch) { case 0: this->fatal_error(ACE_TEXT ("Internal Parser error")); return; case '/': if (this->get () != '>') { this->fatal_error(ACE_TEXT ("Expecting '>' at end of element ") ACE_TEXT ("definition")); return; } this->xml_namespace_.processName(startname, ns_uri, ns_lname, 0); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), ns_uri, 1); this->content_handler_->startElement(ns_uri, ns_lname, startname, &attributes); this->content_handler_->endElement (ns_uri, ns_lname, startname); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), ns_uri, 0); if (ns_flag) { this->xml_namespace_.popContext (); this->nested_namespace_--; } return; case '>': this->xml_namespace_.processName (startname, ns_uri, ns_lname, 0); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), ns_uri, 1); this->content_handler_->startElement(ns_uri, ns_lname, startname, &attributes); start_element_done = 1; break; default: ACEXML_Char *attvalue = 0; ACEXML_Char *attname = this->parse_name (ch); if (attname == 0 || this->skip_equal () != 0 || this->parse_attvalue (attvalue) != 0) { this->fatal_error(ACE_TEXT ("Error reading attribute value")); return; } // Handling new namespace if any. Notice that the order of // namespace declaration does matter. if (ACE_OS::strncmp (attname, ACE_TEXT("xmlns"), 5) == 0) { if (this->namespaces_) { if (!ns_flag) { this->xml_namespace_.pushContext (); this->nested_namespace_++; ns_flag = 1; } ACEXML_Char* name = ACE_OS::strchr (attname, ':'); const ACEXML_Char* ns_name = (name == 0)? empty_string:name+1; if (this->xml_namespace_.declarePrefix (ns_name, attvalue) == -1) { this->fatal_error(ACE_TEXT ("Duplicate definition of ") ACE_TEXT ("prefix")); return; } } if (this->namespace_prefixes_) { // Namespace_prefixes_feature_ is required. So add the // xmlns:foo to the list of attributes. if (attributes.addAttribute (ACE_TEXT (""), ACE_TEXT (""), attname, default_attribute_type, attvalue) == -1) { this->fatal_error(ACE_TEXT ("Duplicate attribute ") ACE_TEXT ("definition. Hint: Try ") ACE_TEXT ("setting namespace_prefix") ACE_TEXT ("es feature to 0")); return; } } if (!this->namespaces_ && !this->namespace_prefixes_) { this->fatal_error(ACE_TEXT ("One of namespaces or ") ACE_TEXT ("namespace_prefixes should be") ACE_TEXT (" declared")); return; } } else { const ACEXML_Char *uri, *lName; this->xml_namespace_.processName (attname, uri, lName, 1); if (attributes.addAttribute (uri, lName, attname, default_attribute_type, attvalue) == -1) { this->fatal_error(ACE_TEXT ("Duplicate attribute ") ACE_TEXT ("definition")); return; } } break; } } if (this->parse_content (startname, ns_uri, ns_lname, ns_flag) != 0) return; } int ACEXML_Parser::parse_content (const ACEXML_Char* startname, const ACEXML_Char*& ns_uri, const ACEXML_Char*& ns_lname, int ns_flag) { ACEXML_Char *cdata; size_t cdata_length = 0; // Parse element contents. while (1) { ACEXML_Char ch = this->get (); switch (ch) { case 0: this->pop_context (1); break; case '<': // Push out old 'characters' event. if (cdata_length != 0) { cdata = this->obstack_.freeze (); this->content_handler_->characters (cdata, 0, cdata_length); this->obstack_.unwind (cdata); cdata_length = 0; } ch = this->peek(); switch (ch) { case '!': // a comment or a CDATA section. this->get (); // consume '!' ch = this->peek (); if (ch == '-') // a comment { if (this->parse_comment () < 0) { this->fatal_error(ACE_TEXT ("Invalid comment in ") ACE_TEXT ("document")); } } else if (ch == '[') // a CDATA section. { this->parse_cdata (); } else { this->fatal_error(ACE_TEXT ("Expecting a CDATA section ") ACE_TEXT ("or a comment section")); } break; case '?': // a PI. this->get(); // consume the '?' this->parse_processing_instruction (); break; case '/': // an ETag. { this->get (); // consume '/' ACEXML_Char* endname = this->parse_name (); if (endname == 0 || ACE_OS::strcmp (startname, endname) != 0) { this->fatal_error(ACE_TEXT ("Name in ETag doesn't ") ACE_TEXT ("match name in STag")); } if (this->skip_whitespace () != '>') { this->fatal_error(ACE_TEXT ("Expecting '>' at end ") ACE_TEXT ("of element")); return -1; } this->content_handler_->endElement (ns_uri, ns_lname, endname); this->prefix_mapping (this->xml_namespace_.getPrefix(ns_uri), ns_uri, 0); if (this->namespaces_ && ns_flag) { if (this->nested_namespace_ >= 1) { this->xml_namespace_.popContext (); this->nested_namespace_--; } } return 0; } default: // a new nested element? this->parse_element (0); break; } break; case '&': if (this->peek () == '#') { ACEXML_Char buf[7]; size_t len = 0; do { len = sizeof (buf); if (this->parse_char_reference (buf, len) != 0) { // [WFC: Legal Character] this->fatal_error (ACE_TEXT ("Invalid CharRef")); } } while (buf[0] == '&' && this->peek() == '#'); for (size_t j = 0; j < len; ++j) this->obstack_.grow (buf[j]); cdata_length += len; } else { this->ref_state_ = ACEXML_ParserInt::IN_CONTENT; int const length = this->parse_entity_reference(); if (length == 1) ++cdata_length; } break; case '\x20': case '\x0D': case '\x0A': case '\x09': // if (this->validate_) // { // // Flush out any non-whitespace characters // if (cdata_length != 0) // { // cdata = this->obstack_.freeze (); // this->content_handler_->characters(cdata, 0, cdata_length // ACEXML_ENV_ARG_PARAMETER); // ACEXML_CHECK_RETURN (-1); // this->obstack_.unwind (cdata); // cdata_length = 0; // } // ++cdata_length; // this->obstack_.grow (ch); // while (1) // { // ch = this->peek(); // if (ch == '\x20' || ch == '\x0D' || ch == '\x0A' || // ch == '\x09') // { // ch = this->get(); // this->obstack_.grow (ch); // continue; // } // break; // } // cdata = this->obstack_.freeze (); // this->content_handler_->ignorableWhitespace (cdata, 0, // cdata_length // ACEXML_ENV_ARG_PARAMETER); // ACEXML_CHECK_RETURN (-1); // this->obstack_.unwind (cdata); // cdata_length = 0; // break; // } // Fall thru... default: ++cdata_length; this->obstack_.grow (ch); } } ACE_NOTREACHED (return 0;) } int ACEXML_Parser::parse_cdata (void) { if (this->parse_token (ACE_TEXT ("[CDATA[")) < 0) { this->fatal_error(ACE_TEXT ("Expecting '[CDATA[' at beginning of CDATA ") ACE_TEXT ("section")); } ACEXML_Char ch; int datalen = 0; ACEXML_Char *cdata = 0; while (1) { ch = this->get (); // Anything goes except the sequence "]]>". if (ch == ']' && this->peek() == ']') { ACEXML_Char temp = ch; ch = this->get(); if (ch == ']' && this->peek() == '>') { ch = this->get(); cdata = this->obstack_.freeze (); this->content_handler_->characters (cdata, 0, datalen); this->obstack_.unwind(cdata); return 0; } this->obstack_.grow (temp); ++datalen; } this->obstack_.grow (ch); ++datalen; }; ACE_NOTREACHED (return -1); } int ACEXML_Parser::parse_entity_decl (void) { ACEXML_Char nextch = 0; if ((this->parse_token (ACE_TEXT ("NTITY")) < 0) || this->skip_whitespace_count (&nextch) == 0) { this->fatal_error (ACE_TEXT ("Expecting keyword ENTITY followed by a ") ACE_TEXT ("space")); } int is_GEDecl = 1; if (nextch == '%') // This is a PEDecl. { is_GEDecl = 0; this->get (); // consume the '%' if (this->skip_whitespace_count (&nextch) == 0) { this->fatal_error (ACE_TEXT ("Expecting space between % and ") ACE_TEXT ("entity name")); } } ACEXML_Char *entity_name = this->parse_name (); if (entity_name == 0) { this->fatal_error (ACE_TEXT ("Invalid entity name")); } if (this->skip_whitespace_count (&nextch) == 0) { this->fatal_error (ACE_TEXT ("Expecting space between entity name and ") ACE_TEXT ("entityDef")); } int retval = 0; if (nextch == '\'' || nextch == '"') { ACEXML_Char *entity_value = 0; if (this->parse_entity_value (entity_value) != 0) { this->fatal_error(ACE_TEXT ("Invalid EntityValue")); } if (is_GEDecl) retval = this->internal_GE_.add_entity (entity_name, entity_value); else retval = this->internal_PE_.add_entity (entity_name, entity_value); if (retval < 0) { this->fatal_error (ACE_TEXT ("Internal Parser Error in adding") ACE_TEXT ("Entity to map")); } else if (retval == 1) { this->warning (ACE_TEXT ("Duplicate entity found")); } } else { ACEXML_Char *systemid = 0, *publicid = 0; this->parse_external_id (publicid, systemid); if (systemid == 0) { this->fatal_error(ACE_TEXT ("Invalid SystemLiteral")); } this->skip_whitespace_count (&nextch); if (nextch == 'N') // NDATA section followed { if (is_GEDecl == 0) { this->fatal_error(ACE_TEXT ("Invalid NDataDecl in PEDef")); } if ((this->parse_token (ACE_TEXT ("NDATA")) < 0) || this->skip_whitespace_count (&nextch) == 0) { this->fatal_error(ACE_TEXT ("Expecting keyword NDATA followed ") ACE_TEXT ("by a space")); } ACEXML_Char *ndata = this->parse_name (); if (this->validate_) // [VC: Notation Declared] { if (!this->notations_.resolve_entity (ndata)) { this->fatal_error (ACE_TEXT ("Undeclared Notation name")); } this->dtd_handler_->unparsedEntityDecl(entity_name, publicid, systemid, ndata); } } else { if (is_GEDecl) retval = this->external_GE_.add_entity (entity_name, systemid); else retval = this->external_PE_.add_entity (entity_name, systemid); if (retval < 0) { this->fatal_error(ACE_TEXT ("Internal Parser Error")); } else if (retval == 1) this->warning(ACE_TEXT ("Duplicate external entity")); if (is_GEDecl) retval = this->external_GE_.add_entity (entity_name, publicid); else retval = this->external_PE_.add_entity (entity_name, publicid); if (retval < 0) { this->fatal_error(ACE_TEXT ("Internal Parser Error")); } else if (retval == 1) this->warning (ACE_TEXT ("Duplicate entity definition")); } } // End of ENTITY definition if (this->skip_whitespace() != '>') { this->fatal_error(ACE_TEXT ("Expecting '>' at end of entityDef")); } return 0; } int ACEXML_Parser::parse_attlist_decl (void) { if (this->parse_token (ACE_TEXT ("ATTLIST")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword 'ATTLIST'")); } int count = check_for_PE_reference (); if (!count) { this->fatal_error(ACE_TEXT ("Expecting space between ATTLIST and ") ACE_TEXT ("element name")); } ACEXML_Char *element_name = this->parse_name (); if (element_name == 0) { this->fatal_error(ACE_TEXT ("Invalid element Name in attlistDecl")); } ACEXML_Char fwd = 0; count = this->skip_whitespace_count (&fwd); // Parse AttDef* while (fwd != '>') { if (!this->check_for_PE_reference () && !count) this->fatal_error(ACE_TEXT ("Expecting space between element ") ACE_TEXT ("name and AttDef")); this->skip_whitespace_count (&fwd); if (fwd == '>') break; count = this->check_for_PE_reference (); this->parse_attname (); count = this->check_for_PE_reference (); if (!count) { this->fatal_error(ACE_TEXT ("Expecting space between AttName and ") ACE_TEXT ("AttType")); } this->parse_atttype (); count = this->check_for_PE_reference (); if (!count) { this->fatal_error(ACE_TEXT ("Expecting space between AttType and") ACE_TEXT (" DefaultDecl")); } this->parse_defaultdecl (); count = this->check_for_PE_reference (); this->skip_whitespace_count(&fwd); } this->get (); // consume closing '>' return 0; } int ACEXML_Parser::check_for_PE_reference (void) { ACEXML_Char fwd = '\xFF'; // Skip any leading whitespaces and store the number of such chars skipped int count = this->skip_whitespace_count (&fwd); if (fwd == 0) { this->get(); // Consume the 0 this->pop_context (0); fwd = this->peek(); } if (fwd == '%') { this->get(); // Consume the % if (this->external_subset_) { this->parse_PE_reference (); } else { this->fatal_error(ACE_TEXT ("Illegal PERef within markupDecl")); } } if (count) { // We have atleast one whitespace. So just skip any more whitespaces // and return the count this->skip_whitespace_count(); return count; } return this->skip_whitespace_count(); } ACEXML_Char* ACEXML_Parser::parse_attname (void) { // Parse attribute name ACEXML_Char *att_name = this->parse_name (); if (att_name == 0) { this->fatal_error(ACE_TEXT ("Invalid AttName")); } return att_name; } int ACEXML_Parser::parse_defaultdecl (void) { // DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) ACEXML_Char nextch = this->peek (); ACEXML_Char *fixed_attr = 0; switch (nextch) { case '#': this->get (); // consume the '#' switch (this->get ()) { case 'R': if (this->parse_token (ACE_TEXT ("EQUIRED")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword REQUIRED")); } // We now know this attribute is required // @@ Set up the validator as such. break; case 'I': if (this->parse_token (ACE_TEXT ("MPLIED")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword IMPLIED")); } // We now know this attribute is implied. // @@ Set up the validator as such. break; case 'F': if (this->parse_token (ACE_TEXT ("IXED")) < 0 || this->skip_whitespace_count () == 0) { this->fatal_error(ACE_TEXT ("Expecting keyword FIXED")); } // We now know this attribute is fixed. if (this->parse_attvalue (fixed_attr) != 0) { this->fatal_error(ACE_TEXT ("Invalid Default AttValue")); } // @@ set up validator break; default: this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")); } break; case '\'': case '"': if (this->parse_attvalue (fixed_attr) != 0) { this->fatal_error(ACE_TEXT ("Invalid AttValue")); } // @@ set up validator break; default: this->fatal_error (ACE_TEXT ("Invalid DefaultDecl")); break; } return 0; } int ACEXML_Parser::parse_tokenized_type (void) { ACEXML_Char ch = this->get(); switch (ch) { case 'I': if (this->get () == 'D') { if (this->peek() != 'R' && this->is_whitespace (this->peek())) { // We have successfully identified the type of the // attribute as ID // @@ Set up validator as such. break; } if (this->parse_token (ACE_TEXT ("REF")) == 0) { if (this->peek() != 'S' && this->is_whitespace (this->peek())) { // We have successfully identified the type of // the attribute as IDREF // @@ Set up validator as such. break; } else if (this->peek() == 'S' && this->get() // consume the 'S' && this->is_whitespace (this->peek())) { // We have successfully identified the type of // the attribute as IDREFS // @@ Set up validator as such. break; } } } // Admittedly, this error message is not precise enough this->fatal_error(ACE_TEXT ("Expecting keyword `ID', `IDREF', or") ACE_TEXT ("`IDREFS'")); case 'E': // ENTITY or ENTITIES if (this->parse_token (ACE_TEXT ("NTIT")) == 0) { ACEXML_Char nextch = this->get (); if (nextch == 'Y') { // We have successfully identified the type of // the attribute as ENTITY // @@ Set up validator as such. } else if (this->parse_token (ACE_TEXT ("IES")) == 0) { // We have successfully identified the type of // the attribute as ENTITIES // @@ Set up validator as such. } if (this->is_whitespace (this->peek())) { // success break; } } // Admittedly, this error message is not precise enough this->fatal_error(ACE_TEXT ("Expecting keyword `ENTITY', or") ACE_TEXT ("`ENTITIES'")); case 'M': if (this->parse_token (ACE_TEXT ("TOKEN")) == 0) { if (this->is_whitespace (this->peek())) { // We have successfully identified the type of // the attribute as NMTOKEN // @@ Set up validator as such. break; } else if (this->peek() == 'S' && this->get() && this->is_whitespace (this->peek())) { // We have successfully identified the type of // the attribute as NMTOKENS // @@ Set up validator as such. break; } } this->fatal_error(ACE_TEXT ("Expecting keyword `NMTOKEN' or `NMTO") ACE_TEXT ("KENS'")); break; default: this->fatal_error (ACE_TEXT ("Internal Parser Error")); break; } return 0; } /** * AttType ::= StringType | TokenizedType | EnumeratedType * StringType ::= 'CDATA' * TokenizedType ::= 'ID' [VC: ID] * [VC: One ID per Element Type] * [VC: ID Attribute Default] * | 'IDREF' [VC: IDREF] * | 'IDREFS' [VC: IDREF] * | 'ENTITY' [VC: Entity Name] * | 'ENTITIES' [VC: Entity Name] * | 'NMTOKEN' [VC: Name Token] * | 'NMTOKENS' * * EnumeratedType ::= NotationType | Enumeration * NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' * [VC: Notation Attributes] * [VC: One Notation Per Element Type] * [VC: No Notation on Empty Element] * Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' * [VC: Enumeration] */ int ACEXML_Parser::parse_atttype (void) { ACEXML_Char nextch = this->peek(); switch (nextch) { case 'C': // CDATA if (this->parse_token (ACE_TEXT ("CDATA")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword 'CDATA'")); } // Else, we have successfully identified the type of the // attribute as CDATA // @@ Set up validator appropriately here. break; case 'I': case 'E': // ID, IDREF, IDREFS, ENTITY or ENTITIES this->parse_tokenized_type (); break; case 'N': // NMTOKEN, NMTOKENS, or NOTATION this->get(); nextch = this->peek(); if (nextch != 'M' && nextch != 'O') { this->fatal_error (ACE_TEXT ("Expecting keyword 'NMTOKEN', ") ACE_TEXT ("'NMTOKENS' or 'NOTATION'")); } if (nextch == 'M') { this->parse_tokenized_type (); break; } else // NOTATION { if (this->parse_token (ACE_TEXT ("OTATION")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword `NOTATION'")); } int count = this->check_for_PE_reference (); if (!count) { this->fatal_error (ACE_TEXT ("Expecting space between keyword ") ACE_TEXT ("NOTATION and '('")); } if (this->get () != '(') { this->fatal_error(ACE_TEXT ("Expecting '(' in NotationType")); } this->check_for_PE_reference (); do { this->skip_whitespace_count(); ACEXML_Char *notation_name = this->parse_name (); if (notation_name == 0) { this->fatal_error(ACE_TEXT ("Invalid notation name")); } // @@ get another notation name, set up validator as such this->check_for_PE_reference (); nextch = this->get(); } while (nextch == '|'); if (nextch != ')') { this->fatal_error (ACE_TEXT ("Expecting a ')' after a ") ACE_TEXT ("NotationType declaration")); } } break; case '(': // EnumeratedType - Enumeration this->get(); this->check_for_PE_reference (); do { this->skip_whitespace_count(); ACEXML_Char *token_name = this->parse_nmtoken (); if (token_name == 0) { this->fatal_error(ACE_TEXT ("Invalid enumeration name")); } // @@ get another nmtoken, set up validator as such this->check_for_PE_reference (); nextch = this->get(); } while (nextch == '|'); if (nextch != ')') { this->fatal_error (ACE_TEXT ("Expecting a ')' after a ") ACE_TEXT ("Enumeration declaration")); } break; default: { this->fatal_error(ACE_TEXT ("Invalid AttType")); } ACE_NOTREACHED (break); } return 0; } int ACEXML_Parser::parse_notation_decl (void) { if (this->parse_token (ACE_TEXT ("NOTATION")) < 0) { this->fatal_error(ACE_TEXT ("Expecting Keyword 'NOTATION'")); } int count = this->check_for_PE_reference (); if (!count) { this->fatal_error (ACE_TEXT ("Expecting a space between keyword NOTATION") ACE_TEXT (" and notation name")); } ACEXML_Char *notation = this->parse_name (); if (notation == 0) { this->fatal_error(ACE_TEXT ("Invalid Notation name")); } count = this->check_for_PE_reference (); if (!count) { this->fatal_error (ACE_TEXT ("Expecting a space between notation name ") ACE_TEXT ("and ExternalID/PublicID")); } ACEXML_Char *systemid, *publicid; // Gross hack but otherwise we need to go around a lot of loops to parse, // When the ExternalID starts with 'PUBLIC' we cannot distinguish a // PublicId from a ExternalID by looking using a one character read-ahead ACEXML_ParserInt::ReferenceState temp = this->ref_state_; this->ref_state_ = ACEXML_ParserInt::IN_NOTATION; this->parse_external_id (publicid, systemid); // Restore the original value. this->ref_state_ = temp; // [VC: Unique Notation Name] if (systemid && this->notations_.add_entity (notation, systemid) != 0 && this->validate_) { this->fatal_error(ACE_TEXT ("Internal Parser Error")); } if (publicid) { int retval = this->notations_.add_entity (notation, publicid); if (retval != 0 && !systemid && this->validate_) { this->fatal_error(ACE_TEXT ("Internal Parser Error")); } } if (this->skip_whitespace() != '>') { this->fatal_error(ACE_TEXT ("Expecting '>' at end of NotationDecl")); } if (this->validate_ && this->dtd_handler_) { this->dtd_handler_->notationDecl (notation, publicid, systemid); } return 0; } int ACEXML_Parser::parse_element_decl (void) { if (this->parse_token (ACE_TEXT ("LEMENT")) < 0) { this->fatal_error (ACE_TEXT ("Expecting keyword ELEMENT")); } int count = this->check_for_PE_reference (); if (!count) { this->fatal_error (ACE_TEXT ("Expecting a space between keyword ELEMENT") ACE_TEXT (" and element name")); } ACEXML_Char *element_name = this->parse_name (); if (element_name == 0) { this->fatal_error (ACE_TEXT ("Invalid element name")); } count = this->check_for_PE_reference (); if (!count) { this->fatal_error (ACE_TEXT ("Expecting a space between element name ") ACE_TEXT ("and element definition")); } ACEXML_Char nextch = this->peek(); switch (nextch) { case 'E': // EMPTY if (this->parse_token (ACE_TEXT ("EMPTY")) < 0) { this->fatal_error (ACE_TEXT ("Expecting keyword EMPTY")); } break; case 'A': // ANY if (this->parse_token (ACE_TEXT ("ANY")) < 0) { this->fatal_error (ACE_TEXT ("Expecting keyword ANY")); } break; case '(': // children this->parse_children_definition (); break; default: // error this->fatal_error (ACE_TEXT ("Invalid element definition")); } count = this->check_for_PE_reference (); if (this->skip_whitespace () != '>') { this->fatal_error (ACE_TEXT ("Expecting '>' after element defintion")); } return 0; } int ACEXML_Parser::parse_children_definition (void) { this->get (); // consume the '(' this->check_for_PE_reference (); int subelement_number = 0; ACEXML_Char nextch = this->peek(); switch (nextch) { case '#': // Mixed element, if (this->parse_token (ACE_TEXT ("#PCDATA")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword '#PCDATA'")); } this->check_for_PE_reference (); nextch = this->get(); while (nextch == '|') { this->check_for_PE_reference (); ACEXML_Char *name = this->parse_name (); // @@ name will be used in the Validator later. ACE_UNUSED_ARG (name); ++subelement_number; // @@ Install Mixed element name into the validator. this->check_for_PE_reference (); nextch = this->skip_whitespace(); } if (nextch != ')' || (subelement_number && this->get () != '*')) { this->fatal_error(ACE_TEXT ("Expecing ')' or ')*' at end of Mixed") ACE_TEXT (" element")); } // @@ close the element definition in the validator. break; default: int status = this->parse_child (1); if (status != 0) return -1; } // Check for trailing '?', '*', '+' nextch = this->peek (); switch (nextch) { case '?': // @@ Consume the character and inform validator as such, this->get (); break; case '*': // @@ Consume the character and inform validator as such, this->get (); break; case '+': // @@ Consume the character and inform validator as such, this->get (); break; default: break; // not much to do. } return 0; } int ACEXML_Parser::parse_child (int skip_open_paren) { // Conditionally consume the open paren. if (skip_open_paren == 0 && this->get () != '(') { this->fatal_error(ACE_TEXT ("Expecting '(' at beginning of children")); } ACEXML_Char node_type = 0; ACEXML_Char nextch = 0; do { this->check_for_PE_reference (); this->skip_whitespace_count (&nextch); switch (nextch) { case '(': this->check_for_PE_reference (); this->parse_child (0); break; default: this->check_for_PE_reference (); // must be an element name here. ACEXML_Char *subelement = this->parse_name (); if (subelement == 0) { this->fatal_error(ACE_TEXT ("Invalid subelement name")); } // Check for trailing '?', '*', '+' nextch = this->peek (); switch (nextch) { case '?': // @@ Consume the character and inform validator as such, this->get (); break; case '*': // @@ Consume the character and inform validator as such, this->get (); break; case '+': // @@ Consume the character and inform validator as such, this->get (); break; default: break; // not much to do. } // @@ Inform validator of the new element here. break; } this->check_for_PE_reference (); this->skip_whitespace_count (&nextch); switch (nextch) { case '|': switch (node_type) { case 0: node_type = '|'; // @@ inform validator of this new type?? break; case '|': break; default: this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ") ACE_TEXT ("while defining an element")); } break; case ',': switch (node_type) { case 0: node_type = ','; // @@ inform validator of this new type?? break; case ',': break; default: this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ") ACE_TEXT ("while defining an element")); } break; case ')': break; default: this->fatal_error (ACE_TEXT ("Expecting `,', `|', or `)' ") ACE_TEXT ("while defining an element")); } nextch = this->get(); // Consume the `,' or `|' or `)' if (nextch == ')') break; this->check_for_PE_reference (); this->skip_whitespace_count (&nextch); } while (nextch != ')'); // Check for trailing '?', '*', '+' nextch = this->peek (); switch (nextch) { case '?': // @@ Consume the character and inform validator as such, this->get (); break; case '*': // @@ Consume the character and inform validator as such, this->get (); break; case '+': // @@ Consume the character and inform validator as such, this->get (); break; default: break; // not much to do. } return 0; } int ACEXML_Parser::parse_char_reference (ACEXML_Char *buf, size_t& len) { if (len < 7) // Max size of a CharRef plus terminating '\0' return -1; ACEXML_Char ch = this->get(); if (ch != '#') // Internal error. return -1; int hex = 0; ch = this->peek(); if (ch == 'x') { hex = 1; this->get (); } size_t i = 0; int more_digit = 0; ch = this->get (); for ( ; i < len && (this->isNormalDigit (ch) || (hex ? this->isCharRef(ch): 0)); ++i) { buf[i] = ch; ch = this->get(); ++more_digit; } if (ch != ';' || !more_digit) return -1; buf[i] = 0; ACEXML_UCS4 sum = (ACEXML_UCS4) ACE_OS::strtol (buf, 0, (hex ? 16 : 10)); // [WFC: Legal Character] if (!this->isChar (sum)) return -1; int clen; #if defined (ACE_USES_WCHAR) # if (ACE_SIZEOF_WCHAR == 2) // UTF-16 if ((clen = ACEXML_Transcoder::ucs42utf16 (sum, buf, len)) < 0) return -1; # elif (ACE_SIZEOF_WCHAR == 4) // UCS 4 buf [0] = sum; buf [1] = 0; clen = 2; # endif /* ACE_SIZEOF_WCHAR */ #else // or UTF-8 if ((clen = ACEXML_Transcoder::ucs42utf8 (sum, buf, len)) < 0) return -1; #endif buf [clen] = 0; len = clen; return 0; } ACEXML_Char* ACEXML_Parser::parse_reference_name (void) { ACEXML_Char ch = this->get (); if (!this->isLetter (ch) && (ch != '_' && ch != ':')) return 0; while (ch) { this->alt_stack_.grow (ch); ch = this->peek (); if (!this->isNameChar (ch)) break; ch = this->get (); }; if (ch != ';') return 0; ch = this->get(); return this->alt_stack_.freeze (); } int ACEXML_Parser::parse_attvalue (ACEXML_Char *&str) { ACEXML_Char quote = this->get (); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; ACEXML_Char ch = this->get (); while (1) { if (ch == quote) { ACEXML_Char* temp = this->obstack_.freeze (); // If the attribute type is not CDATA, then the XML processor // must further process the normalized attribute value by // discarding any leading and trailing space (#x20) characters, // and by replacing sequences of space (#x20) characters by a // single space (#x20) character. // if (atttype != CDATA) { // ACEXML_Char* start = temp; // ACEXML_Char* end = temp + ACE_OS::strlen (temp); // while (*start == '\x20') // start++; // if (start == end) // String which is all spaces // str = start; // while (*start != 0) // { // this->obstack_.grow (*start); // start++; // while (*start == '\x20') // start++; // } // str = this->obstack_.freeze(); // } str = temp; return 0; } switch (ch) { case '&': if (this->peek () == '#') { ACEXML_Char buf[7]; size_t len = sizeof (buf); if (this->parse_char_reference (buf, len) != 0) { // [WFC: Legal Character] this->fatal_error (ACE_TEXT ("Invalid CharacterRef")); } for (size_t j = 0; j < len; ++j) this->obstack_.grow (buf[j]); } else { this->ref_state_ = ACEXML_ParserInt::IN_ATT_VALUE; this->parse_entity_reference (); } break; case '\x20': case '\x0D': case '\x0A': case '\x09': this->obstack_.grow ('\x20'); break; case '<': // [WFC: No < in Attribute Values] this->fatal_error (ACE_TEXT ("Illegal '<' in AttValue")); break; case 0: this->pop_context (1); break; default: this->obstack_.grow (ch); break; } ch = this->get(); } } int ACEXML_Parser::parse_entity_reference (void) { ACEXML_Char* replace = this->parse_reference_name (); if (replace == 0) { this->fatal_error (ACE_TEXT ("Invalid Reference name")); } // [WFC: Parsed Entity] if (this->unparsed_entities_.resolve_entity (replace)) { this->fatal_error (ACE_TEXT ("EntityRef refers to unparsed entity")); } // Look in the internal general entities set first. const ACEXML_Char* entity = this->internal_GE_.resolve_entity(replace); // Look in the predefined entities. if (!entity) { entity = this->predef_entities_.resolve_entity (replace); if (entity) { // Special case to return the length in case of predefined entities this->obstack_.grow (*entity); return 1; } } if (!this->validate_) { if (this->standalone_) { // [WFC: Entity Declared] this->fatal_error (ACE_TEXT ("Undeclared Entity reference")); } else { this->content_handler_->skippedEntity (replace); return 0; } } // No match in internal subset if (!entity // or No DTDs && (!(this->internal_dtd_ || this->external_dtd_) // or Only Internal DTD and no parameter entity references || (this->internal_dtd_ && !this->external_dtd_ && !this->has_pe_refs_) // or Standalone = 'yes' || this->standalone_)) { // [WFC: Entity Declared] this->fatal_error (ACE_TEXT ("Undeclared Entity reference")); } ACEXML_Char* systemId = 0; ACEXML_Char* publicId = 0; if (!entity) { if (this->external_GE_.resolve_entity (replace, systemId, publicId) < 0) { this->fatal_error (ACE_TEXT ("Undeclared Entity reference")); } if (this->ref_state_ == ACEXML_ParserInt::IN_ATT_VALUE) { this->fatal_error (ACE_TEXT ("External EntityRef in Attribute Value")); } this->external_entity_++; } // [WFC: No Recursion] ACEXML_Char* ref_name = replace; int present = this->GE_reference_.insert (ref_name); if (present == 1 || present == -1) { while (this->GE_reference_.pop(ref_name) != -1) ; this->fatal_error (ACE_TEXT ("Recursion in resolving entity")); } if (!this->external_entity_) { ACEXML_StrCharStream* str = 0; ACE_NEW_RETURN (str, ACEXML_StrCharStream, -1); if (str->open (entity, replace) < 0 || this->switch_input (str, replace) != 0) { this->fatal_error (ACE_TEXT ("Unable to create internal input ") ACE_TEXT ("stream")); } return 0; } else { ACEXML_Char* uri = this->normalize_systemid (systemId); ACE_Auto_Basic_Array_Ptr cleanup_uri (uri); ACEXML_InputSource* ip = 0; if (this->entity_resolver_) { ip = this->entity_resolver_->resolveEntity (publicId, (uri ? uri : systemId)); if (ip) { if (this->switch_input (ip, (uri ? uri : systemId), publicId) != 0) { this->fatal_error (ACE_TEXT ("Internal Parser Error")); } return 0; } } ACEXML_StreamFactory factory; ACEXML_CharStream* cstream = factory.create_stream (uri ? uri: systemId); if (!cstream) { this->fatal_error (ACE_TEXT ("Invalid input source")); } if (this->switch_input (cstream, systemId, publicId) != 0) { this->fatal_error (ACE_TEXT ("Internal Parser Error")); } } return 0; } int ACEXML_Parser::parse_PE_reference (void) { ACEXML_Char* replace = this->parse_reference_name (); if (replace == 0) { this->fatal_error (ACE_TEXT ("Invalid PEReference name")); } // Look in the internal general entities set first. const ACEXML_Char* entity = this->internal_PE_.resolve_entity(replace); if (!entity && // No match in internal (!this->external_dtd_ || // or No External DTDs this->standalone_)) // or Standalone { // [VC: Entity Declared] this->fatal_error (ACE_TEXT ("Undefined Internal PEReference")); } ACEXML_Char* systemId = 0; ACEXML_Char* publicId = 0; if (!entity && this->validate_) { if (this->external_PE_.resolve_entity (replace, systemId, publicId) < 0) { this->fatal_error (ACE_TEXT ("Undefined PEReference")); } this->external_entity_++; } // [WFC: No Recursion] ACEXML_Char* ref_name = replace; int present = this->PE_reference_.insert (ref_name); if (present == 1 || present == -1) { while (this->PE_reference_.pop(ref_name) != -1) ; this->fatal_error (ACE_TEXT ("Recursion in resolving entity")); } if (entity && !this->external_entity_) { ACEXML_StrCharStream* sstream = 0; ACEXML_String str (entity); if (this->ref_state_ != ACEXML_ParserInt::IN_ENTITY_VALUE) { const ACEXML_Char* ch = ACE_TEXT (" "); str = ch + str + ch; } // ACE_DEBUG ((LM_DEBUG, // ACE_TEXT ("Entity is %s\n Replacement Text is : %s\n"), // replace, str.c_str())); ACE_NEW_RETURN (sstream, ACEXML_StrCharStream, -1); if (sstream->open (str.c_str(), replace) < 0 || this->switch_input (sstream, replace) != 0) { this->fatal_error (ACE_TEXT ("Error in switching InputSource")); } return 0; } else if (this->external_entity_ && this->validate_) { ACEXML_Char* uri = this->normalize_systemid (systemId); ACE_Auto_Basic_Array_Ptr cleanup_uri (uri); ACEXML_InputSource* ip = 0; if (this->entity_resolver_) { ip = this->entity_resolver_->resolveEntity (publicId, (uri ? uri : systemId)); } if (ip) { if (this->switch_input (ip, (uri ? uri : systemId), publicId) != 0) { this->fatal_error (ACE_TEXT ("Error in switching InputSource")); } return 0; } else { ACEXML_StreamFactory factory; ACEXML_CharStream* cstream = factory.create_stream (uri ? uri: systemId); if (!cstream) { this->fatal_error (ACE_TEXT ("Invalid input source")); } if (this->switch_input (cstream, systemId, publicId) != 0) { this->fatal_error (ACE_TEXT ("Error in switching InputSource")); } if (this->ref_state_ == ACEXML_ParserInt::IN_ENTITY_VALUE) { ACEXML_Char less, mark; if (this->peek() == '<') { less = this->get(); if (this->peek() == '?') { mark = this->get(); if (this->peek() == 'x') { this->parse_text_decl (); } else { this->obstack_.grow (less); this->obstack_.grow (mark); } } this->obstack_.grow (less); } } return 0; } } this->fatal_error (ACE_TEXT ("Undefined PEReference")); return -1; } int ACEXML_Parser::parse_entity_value (ACEXML_Char *&str) { ACEXML_ParserInt::ReferenceState temp = this->ref_state_; ACEXML_Char quote = this->get (); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; ACEXML_Char ch = this->get (); while (1) { if (ch == quote) { str = this->obstack_.freeze (); this->ref_state_ = temp; return 0; } switch (ch) { case '&': if (this->peek () == '#') { if (!this->external_entity_) { ACEXML_Char buf[7]; size_t len = sizeof (buf); if (this->parse_char_reference (buf, len) != 0) { // [WFC: Legal Character] this->fatal_error (ACE_TEXT ("Invalid character ") ACE_TEXT ("reference")); return -1; } for (size_t j = 0; j < len; ++j) this->obstack_.grow (buf[j]); break; } } this->obstack_.grow (ch); break; case '%': if (!this->external_entity_) { this->ref_state_ = ACEXML_ParserInt::IN_ENTITY_VALUE; this->parse_PE_reference(); break; } this->obstack_.grow (ch); break; case 0: this->pop_context (0); break; default: this->obstack_.grow (ch); break; } ch = this->get(); } } ACEXML_Char * ACEXML_Parser::parse_name (ACEXML_Char ch) { if (ch == 0) ch = this->get (); if (!this->isLetter (ch) && ch != '_' && ch != ':') return 0; while (ch) { this->obstack_.grow (ch); ch = this->peek (); if (!this->isNameChar (ch)) break; ch = this->get (); }; return this->obstack_.freeze (); } ACEXML_Char* ACEXML_Parser::parse_nmtoken (ACEXML_Char ch) { if (ch == 0) ch = this->get (); if (!this->isNameChar (ch)) return 0; while (ch) { this->obstack_.grow (ch); ch = this->peek (); if (!this->isNameChar (ch)) break; ch = this->get (); }; return this->obstack_.freeze (); } int ACEXML_Parser::parse_version_num (ACEXML_Char*& str) { ACEXML_Char quote = this->get (); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; int numchars = 0; while (1) { ACEXML_Char ch = this->get (); if (ch == quote && !numchars) return -1; else if (ch == quote) { str = this->obstack_.freeze (); return 0; } // [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+ if (ch == '-' || ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_' || ch == '.' || ch == ':'))) { this->obstack_.grow (ch); numchars++; } else return -1; } } int ACEXML_Parser::parse_system_literal (ACEXML_Char*& str) { const ACEXML_Char quote = this->get(); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; while (1) { ACEXML_Char ch = this->get (); if (ch == quote) { str = this->obstack_.freeze (); return 0; } switch (ch) { case '\x00': case '\x01': case '\x02': case '\x03': case '\x04': case '\x05': case '\x06': case '\x07': case '\x08': case '\x09': case '\x0A': case '\x0B': case '\x0C': case '\x0D': case '\x0E': case '\x0F': case '\x10': case '\x11': case '\x12': case '\x13': case '\x14': case '\x15': case '\x16': case '\x17': case '\x18': case '\x19': case '\x1A': case '\x1B': case '\x1C': case '\x1D': case '\x1E': case '\x1F': case '\x7F': case '\x20': case '<': case '>': case '#': case '%': ACE_ERROR ((LM_ERROR, ACE_TEXT ("Invalid char %c in SystemLiteral\n"), ch)); return -1; default: this->obstack_.grow (ch); } } } int ACEXML_Parser::parse_pubid_literal (ACEXML_Char*& str) { const ACEXML_Char quote = this->get(); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; while (1) { ACEXML_Char ch = this->get (); if (ch == quote) { str = this->obstack_.freeze (); return 0; } else if (this->isPubidChar (ch)) this->obstack_.grow (ch); else return -1; } } int ACEXML_Parser::parse_encname (ACEXML_Char*& str) { const ACEXML_Char quote = this->get (); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; int numchars = 0; while (1) { ACEXML_Char ch = this->get (); if (ch == quote && !numchars) return -1; else if (ch == quote) { str = this->obstack_.freeze (); return 0; } // [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')* if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) && !numchars) return -1; if (ch == '-' || ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_' || ch == '.'))) { this->obstack_.grow (ch); numchars++; } else return -1; } } int ACEXML_Parser::parse_sddecl (ACEXML_Char*& str) { ACEXML_Char quote = this->get (); if (quote != '\'' && quote != '"') // Not a quoted string. return -1; int numchars = 0; while (1) { ACEXML_Char ch = this->get (); if (ch == quote && numchars < 2) return -1; else if (ch == quote) { str = this->obstack_.freeze (); return 0; } // [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") // | ('"' ('yes' | 'no') '"')) switch (ch) { case 'y': case 'e': case 's': case 'n': case 'o': this->obstack_.grow (ch); numchars++; break; default: return -1; } } } void ACEXML_Parser::prefix_mapping (const ACEXML_Char* prefix, const ACEXML_Char* uri, int start) { if (this->namespaces_) { const ACEXML_Char* temp = (prefix == 0) ? empty_string : prefix; if (start) { this->content_handler_->startPrefixMapping (temp, uri); } else { this->content_handler_->endPrefixMapping(temp); } } } int ACEXML_Parser::switch_input (ACEXML_CharStream* cstream, const ACEXML_Char* systemId, const ACEXML_Char* publicId) { ACEXML_InputSource* input = 0; ACE_NEW_RETURN (input, ACEXML_InputSource (cstream), -1); return this->switch_input (input, systemId, publicId); } int ACEXML_Parser::switch_input (ACEXML_InputSource* input, const ACEXML_Char* systemId, const ACEXML_Char* publicId) { ACEXML_LocatorImpl* locator = 0; if (!systemId) systemId = input->getSystemId(); ACE_NEW_RETURN (locator, ACEXML_LocatorImpl (systemId, publicId), -1); ACEXML_Parser_Context* new_context = 0; ACE_NEW_RETURN (new_context, ACEXML_Parser_Context(input, locator), -1); if (this->push_context (new_context) != 0) { ACE_ERROR ((LM_ERROR, "Unable to switch input streams")); delete new_context; return -1; } this->current_ = new_context; this->content_handler_->setDocumentLocator (this->current_->getLocator()); return 0; } int ACEXML_Parser::push_context (ACEXML_Parser_Context* context) { if (this->ctx_stack_.push (context) < 0) { ACE_ERROR ((LM_ERROR, "Unable to push input source onto the stack")); return -1; } return 0; } size_t ACEXML_Parser::pop_context (int GE_ref) { size_t nrelems = this->ctx_stack_.size(); if (nrelems <= 1) { this->fatal_error(ACE_TEXT ("Unexpected end-of-file")); } ACEXML_Parser_Context* temp = 0; int retval = this->ctx_stack_.pop (temp); if (retval != 0) { this->fatal_error (ACE_TEXT ("Unable to pop element of the input stack")); } delete temp; if (this->ctx_stack_.top (this->current_) != 0) { this->fatal_error (ACE_TEXT ("Unable to read top element of input stack")); } ACEXML_Char* reference = 0; if (GE_ref == 1 && this->GE_reference_.size() > 0) { if (this->GE_reference_.pop (reference) < 0) { this->fatal_error (ACE_TEXT ("Internal Parser Error")); } } else if (GE_ref == 0 && this->PE_reference_.size() > 0) { if (this->PE_reference_.pop (reference) < 0) { this->fatal_error (ACE_TEXT ("Internal Parser Error")); } } nrelems = this->ctx_stack_.size(); if (this->external_entity_ && (GE_ref == 0 || GE_ref == 1)) this->external_entity_--; this->content_handler_->setDocumentLocator (this->current_->getLocator()); return nrelems; } int ACEXML_Parser::getFeature (const ACEXML_Char *name) { if (ACE_OS::strcmp (name, ACEXML_Parser::simple_parsing_feature_) == 0) { return this->simple_parsing_; } else if (ACE_OS::strcmp (name, ACEXML_Parser::namespaces_feature_) == 0) { return this->namespaces_; } else if (ACE_OS::strcmp (name, ACEXML_Parser::namespace_prefixes_feature_) == 0) { return this->namespace_prefixes_; } else if (ACE_OS::strcmp (name, ACEXML_Parser::validation_feature_) == 0) { return this->validate_; } throw ACEXML_SAXNotRecognizedException (name); } void ACEXML_Parser::setFeature (const ACEXML_Char *name, int boolean_value) { if (ACE_OS::strcmp (name, ACEXML_Parser::simple_parsing_feature_) == 0) { this->simple_parsing_ = (boolean_value == 0 ? 0 : 1); return; } else if (ACE_OS::strcmp (name, ACEXML_Parser::namespaces_feature_) == 0) { this->namespaces_ = (boolean_value == 0 ? 0 : 1); return; } else if (ACE_OS::strcmp (name, ACEXML_Parser::namespace_prefixes_feature_) == 0) { this->namespace_prefixes_ = (boolean_value == 0 ? 0 : 1); return; } else if (ACE_OS::strcmp (name, ACEXML_Parser::validation_feature_) == 0) { this->validate_ = (boolean_value == 0 ? 0 : 1); return; } throw ACEXML_SAXNotRecognizedException (name); } void * ACEXML_Parser::getProperty (const ACEXML_Char *name) { throw ACEXML_SAXNotSupportedException (name); } void ACEXML_Parser::setProperty (const ACEXML_Char *name, void *) { throw ACEXML_SAXNotSupportedException (name); } void ACEXML_Parser::error (const ACEXML_Char* msg) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg)); if (this->error_handler_) this->error_handler_->error (*exception); else throw exception; return; } void ACEXML_Parser::warning (const ACEXML_Char* msg) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg)); if (this->error_handler_) this->error_handler_->warning (*exception); delete exception; return; } void ACEXML_Parser::fatal_error (const ACEXML_Char* msg) { ACEXML_SAXParseException* exception = 0; ACE_NEW_NORETURN (exception, ACEXML_SAXParseException (msg)); if (this->error_handler_) this->error_handler_->fatalError (*exception); this->reset(); throw exception; return; } void ACEXML_Parser::parse_version_info (void) { ACEXML_Char* astring; if (this->parse_token (ACE_TEXT("ersion")) < 0 || this->skip_equal () != 0 || this->parse_version_num (astring) != 0) { this->fatal_error (ACE_TEXT ("Invalid VersionInfo specification")); return; } if (ACE_OS::strcmp (astring, ACE_TEXT ("1.0")) != 0) { this->fatal_error (ACE_TEXT ("ACEXML Parser supports XML version 1.0 ") ACE_TEXT ("documents only")); } } void ACEXML_Parser::parse_encoding_decl (void) { ACEXML_Char* astring = 0; if ((this->parse_token (ACE_TEXT("ncoding")) < 0) || this->skip_equal () != 0 || this->parse_encname (astring) != 0) { this->fatal_error (ACE_TEXT ("Invalid EncodingDecl specification")); } const ACEXML_Char* encoding = this->current_->getInputSource()->getEncoding(); if (encoding != 0 && ACE_OS::strcasecmp (astring, encoding) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Detected Encoding is %s ") ACE_TEXT (": Declared Encoding is %s\n"), encoding, astring)); this->warning (ACE_TEXT ("Declared encoding differs from detected ") ACE_TEXT ("encoding")); } } int ACEXML_Parser::parse_text_decl (void) { // Read xml if (this->parse_token (ACE_TEXT("xml")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword 'xml' in TextDecl")); } ACEXML_Char fwd = this->skip_whitespace(); // Read version if (fwd == 'v') { this->parse_version_info (); fwd = this->skip_whitespace(); } if (fwd == 'e') { this->parse_encoding_decl (); fwd = this->skip_whitespace(); } else { this->fatal_error (ACE_TEXT ("Missing encodingDecl in TextDecl")); } if (fwd == '?' && this->get() == '>') return 0; // All the rules fail. So return an error. this->fatal_error (ACE_TEXT ("Invalid TextDecl")); return -1; } void ACEXML_Parser::parse_xml_decl (void) { // Read parse_token (ACE_TEXT("xml")) < 0) { this->fatal_error(ACE_TEXT ("Expecting keyword xml in XMLDecl")); } ACEXML_Char fwd = this->skip_whitespace(); // Read version if (fwd != 'v') { this->fatal_error (ACE_TEXT ("Expecting VersionInfo declaration")); } this->parse_version_info (); fwd = this->skip_whitespace(); if (fwd != '?') { if (fwd == 'e') { this->parse_encoding_decl (); fwd = this->skip_whitespace(); } if (fwd == 's') { ACEXML_Char* astring; if ((this->parse_token (ACE_TEXT("tandalone")) == 0) && this->skip_equal () == 0 && this->parse_sddecl (astring) == 0) { if (ACE_OS::strcmp (astring, ACE_TEXT ("yes")) == 0) this->standalone_ = 1; fwd = this->skip_whitespace(); } } } if (fwd == '?' && this->get() == '>') return; // All the rules fail. So return an error. this->fatal_error (ACE_TEXT ("Invalid XMLDecl declaration")); } int ACEXML_Parser::parse_comment (void) { int state = 0; if (this->get () != '-' || // Skip the opening "'. Notice that // according to the spec, '--->' is not a valid closing comment // sequence. But we'll let it pass anyway. { ACEXML_Char fwd = this->get (); if ((fwd == '-' && state < 2) || (fwd == '>' && state == 2)) state += 1; else state = 0; // Reset parse state. } return 0; } int ACEXML_Parser::parse_processing_instruction (void) { const ACEXML_Char *pitarget = this->parse_name (); ACEXML_Char *instruction = 0; if (!ACE_OS::strcasecmp (ACE_TEXT ("xml"), pitarget)) { // Invalid PITarget name. this->fatal_error(ACE_TEXT ("PI can't have 'xml' in PITarget")); } int state = 0; ACEXML_Char ch = this->skip_whitespace(); while (state < 2) { switch (ch) { case '?': if (state == 0) state = 1; break; case '>': if (state == 1) { instruction = this->obstack_.freeze (); this->content_handler_->processingInstruction (pitarget, instruction); this->obstack_.unwind (const_cast (pitarget)); return 0; } break; case 0x0A: // Fall thru... default: if (state == 1) this->obstack_.grow ('?'); this->obstack_.grow (ch); state = 0; } ch = this->get (); } return -1; } void ACEXML_Parser::reset (void) { this->doctype_ = 0; if (this->ctx_stack_.pop (this->current_) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("Mismatched push/pop of Context stack"))); if (this->current_) { this->current_->getInputSource()->getCharStream()->rewind(); this->current_->setInputSource (0); delete this->current_; this->current_ = 0; } ACEXML_Char* temp = 0; while (this->GE_reference_.pop (temp) != -1) ; while (this->PE_reference_.pop (temp) != -1) ; this->obstack_.release(); this->alt_stack_.release(); this->xml_namespace_.reset(); this->nested_namespace_ = 0; this->internal_GE_.reset(); this->external_GE_.reset(); this->unparsed_entities_.reset(); this->predef_entities_.reset(); this->internal_PE_.reset(); this->external_PE_.reset(); this->notations_.reset(); this->ref_state_ = ACEXML_ParserInt::INVALID; this->external_subset_ = 0; this->external_entity_ = 0; this->has_pe_refs_ = 0; this->standalone_ = 0; this->external_dtd_ = 0; this->internal_dtd_ = 0; } ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ParserInternals.h0000644000175000017500000000516312576461726023450 0ustar pgquilespgquiles// -*- C++ -*- //============================================================================= /** * @file ParserInternals.h * * @author Krishnakumar B */ //============================================================================= #ifndef _ACEXML_PARSER_INTERNALS_H_ #define _ACEXML_PARSER_INTERNALS_H_ #include /**/ "ace/pre.h" #include "ACEXML/parser/parser/Parser_export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ACEXML/common/XML_Types.h" /** * @class ACEXML_ParserInt ParserInternals.h "ACEXML/parser/parser/ParserInternals.h" * * @brief A class to hide some of the internal implementation details of * the parser. */ class ACEXML_PARSER_Export ACEXML_ParserInt { public: #if defined (ACE_USES_WCHAR) /** * Check if a character @a c is a BaseChar. This method checks for the * complete set of characters allowed when WCHAR support is enabled. * * @retval 1 if @a c is a valid XML Character, 0 otherwise. */ static int isBasechar_i (const ACEXML_Char c); /** * Check if a character @a c is a Ideographic. This method checks for the * complete set of characters allowed when WCHAR support is enabled. * * @retval 1 if @a c is a valid XML Character, 0 otherwise. */ static int isIdeographic_i (const ACEXML_Char c); /** * Check if a character @a c is a CombiningChar. This method checks for the * complete set of characters allowed when WCHAR support is enabled. * * @retval 1 if @a c is a valid XML Character, 0 otherwise. */ static int isCombiningchar_i (const ACEXML_Char c); /** * Check if a character @a c is a Digit. This method checks for the * complete set of characters allowed when WCHAR support is enabled. * * @retval 1 if @a c is a valid XML Character, 0 otherwise. */ static int isDigit_i (const ACEXML_Char c); /** * Check if a character @a c is an Extender. This method checks for the * complete set of characters allowed when WCHAR support is enabled. * * @retval 1 if @a c is a valid XML Character, 0 otherwise. */ static int isExtender_i (const ACEXML_Char c); #endif /* ACE_USES_WCHAR */ static const ACEXML_Char base_char_table_[256]; static const ACEXML_Char* predef_ent_[]; static const ACEXML_Char* predef_val_[]; // Enum describing the position in a document when a reference occurs. enum ReferenceState { IN_CONTENT, IN_ATT_VALUE, AS_ATT_VALUE, IN_ENTITY_VALUE, IN_INT_DTD, IN_EXT_DTD, IN_NOTATION, INVALID = -1 }; }; #include /**/ "ace/post.h" #endif /* _ACEXML_PARSER_INTERNALS_H_ */ ace-6.3.3+dfsg.orig/ACEXML/parser/parser/ParserInternals.cpp0000644000175000017500000003513412576461726024004 0ustar pgquilespgquiles#include "ACEXML/parser/parser/ParserInternals.h" const ACEXML_Char* ACEXML_ParserInt::predef_ent_[] = { ACE_TEXT ("amp"), ACE_TEXT ("lt"), ACE_TEXT ("gt"), ACE_TEXT ("apos"), ACE_TEXT ("quot") }; const ACEXML_Char* ACEXML_ParserInt::predef_val_[] = { ACE_TEXT ("&"), ACE_TEXT ("<"), ACE_TEXT (">"), ACE_TEXT ("'"), ACE_TEXT ("\"") }; // Optimize away the most common cases. Any compiler worth it's salt should // give generate a single memory access. const ACEXML_Char ACEXML_ParserInt::base_char_table_[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 - 0x000F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 - 0x001F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0020 - 0x002F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0030 - 0x003F */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0040 - 0x004F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0050 - 0x005F */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0060 - 0x006F */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0070 - 0x007F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 - 0x008F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0090 - 0x009F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00A0 - 0x00AF */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00B0 - 0x00BF */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00C0 - 0x00CF */ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00D0 - 0x00DF */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00E0 - 0x00EF */ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00F0 - 0x00FF */ }; #if defined (ACE_USES_WCHAR) int ACEXML_ParserInt::isBasechar_i (const ACEXML_Char c) { if (c < 0x0100) return ACEXML_ParserInt::base_char_table_[c]; else if (c < 0x0905) return ((c >= 0x0100 && c <= 0x0131) || (c >= 0x0134 && c <= 0x013E) || (c >= 0x0141 && c <= 0x0148) || (c >= 0x014A && c <= 0x017E) || (c >= 0x0180 && c <= 0x01C3) || (c >= 0x01CD && c <= 0x01F0) || (c >= 0x01F4 && c <= 0x01F5) || (c >= 0x01FA && c <= 0x0217) || (c >= 0x0250 && c <= 0x02A8) || (c >= 0x02BB && c <= 0x02C1) || (c == 0x0386) || (c >= 0x0388 && c <= 0x038A) || (c == 0x038C) || (c >= 0x038E && c <= 0x03A1) || (c >= 0x03A3 && c <= 0x03CE) || (c >= 0x03D0 && c <= 0x03D6) || (c == 0x03DA) || (c == 0x03DC) || (c == 0x03DE) || (c == 0x03E0) || (c >= 0x03E2 && c <= 0x03F3) || (c >= 0x0401 && c <= 0x040C) || (c >= 0x040E && c <= 0x044F) || (c >= 0x0451 && c <= 0x045C) || (c >= 0x045E && c <= 0x0481) || (c >= 0x0490 && c <= 0x04C4) || (c >= 0x04C7 && c <= 0x04C8) || (c >= 0x04CB && c <= 0x04CC) || (c >= 0x04D0 && c <= 0x04EB) || (c >= 0x04EE && c <= 0x04F5) || (c >= 0x04F8 && c <= 0x04F9) || (c >= 0x0531 && c <= 0x0556) || (c == 0x0559) || (c >= 0x0561 && c <= 0x0586) || (c >= 0x05D0 && c <= 0x05EA) || (c >= 0x05F0 && c <= 0x05F2) || (c >= 0x0621 && c <= 0x063A) || (c >= 0x0641 && c <= 0x064A) || (c >= 0x0671 && c <= 0x06B7) || (c >= 0x06BA && c <= 0x06BE) || (c >= 0x06C0 && c <= 0x06CE) || (c >= 0x06D0 && c <= 0x06D3) || (c == 0x06D5) || (c >= 0x06E5 && c <= 0x06E6)); else if (c < 0x10A0) return ((c >= 0x0905 && c <= 0x0939) || (c == 0x093D) || (c >= 0x0958 && c <= 0x0961) || (c >= 0x0985 && c <= 0x098C) || (c >= 0x098F && c <= 0x0990) || (c >= 0x0993 && c <= 0x09A8) || (c >= 0x09AA && c <= 0x09B0) || (c == 0x09B2) || (c >= 0x09B6 && c <= 0x09B9) || (c >= 0x09DC && c <= 0x09DD) || (c >= 0x09DF && c <= 0x09E1) || (c >= 0x09F0 && c <= 0x09F1) || (c >= 0x0A05 && c <= 0x0A0A) || (c >= 0x0A0F && c <= 0x0A10) || (c >= 0x0A13 && c <= 0x0A28) || (c >= 0x0A2A && c <= 0x0A30) || (c >= 0x0A32 && c <= 0x0A33) || (c >= 0x0A35 && c <= 0x0A36) || (c >= 0x0A38 && c <= 0x0A39) || (c >= 0x0A59 && c <= 0x0A5C) || (c == 0x0A5E) || (c >= 0x0A72 && c <= 0x0A74) || (c >= 0x0A85 && c <= 0x0A8B) || (c == 0x0A8D) || (c >= 0x0A8F && c <= 0x0A91) || (c >= 0x0A93 && c <= 0x0AA8) || (c >= 0x0AAA && c <= 0x0AB0) || (c >= 0x0AB2 && c <= 0x0AB3) || (c >= 0x0AB5 && c <= 0x0AB9) || (c == 0x0ABD || c == 0x0AE0) || (c >= 0x0B05 && c <= 0x0B0C) || (c >= 0x0B0F && c <= 0x0B10) || (c >= 0x0B13 && c <= 0x0B28) || (c >= 0x0B2A && c <= 0x0B30) || (c >= 0x0B32 && c <= 0x0B33) || (c >= 0x0B36 && c <= 0x0B39) || (c == 0x0B3D) || (c >= 0x0B5C && c <= 0x0B5D) || (c >= 0x0B5F && c <= 0x0B61) || (c >= 0x0B85 && c <= 0x0B8A) || (c >= 0x0B8E && c <= 0x0B90) || (c >= 0x0B92 && c <= 0x0B95) || (c >= 0x0B99 && c <= 0x0B9A) || (c == 0x0B9C) || (c >= 0x0B9E && c <= 0x0B9F) || (c >= 0x0BA3 && c <= 0x0BA4) || (c >= 0x0BA8 && c <= 0x0BAA) || (c >= 0x0BAE && c <= 0x0BB5) || (c >= 0x0BB7 && c <= 0x0BB9) || (c >= 0x0C05 && c <= 0x0C0C) || (c >= 0x0C0E && c <= 0x0C10) || (c >= 0x0C12 && c <= 0x0C28) || (c >= 0x0C2A && c <= 0x0C33) || (c >= 0x0C35 && c <= 0x0C39) || (c >= 0x0C60 && c <= 0x0C61) || (c >= 0x0C85 && c <= 0x0C8C) || (c >= 0x0C8E && c <= 0x0C90) || (c >= 0x0C92 && c <= 0x0CA8) || (c >= 0x0CAA && c <= 0x0CB3) || (c >= 0x0CB5 && c <= 0x0CB9) || (c == 0x0CDE) || (c >= 0x0CE0 && c <= 0x0CE1) || (c >= 0x0D05 && c <= 0x0D0C) || (c >= 0x0D0E && c <= 0x0D10) || (c >= 0x0D12 && c <= 0x0D28) || (c >= 0x0D2A && c <= 0x0D39) || (c >= 0x0D60 && c <= 0x0D61) || (c >= 0x0E01 && c <= 0x0E2E) || (c == 0x0E30) || (c >= 0x0E32 && c <= 0x0E33) || (c >= 0x0E40 && c <= 0x0E45) || (c >= 0x0E81 && c <= 0x0E82) || (c == 0x0E84) || (c >= 0x0E87 && c <= 0x0E88) || (c == 0x0E8A || c == 0x0E8D) || (c >= 0x0E94 && c <= 0x0E97) || (c >= 0x0E99 && c <= 0x0E9F) || (c >= 0x0EA1 && c <= 0x0EA3) || (c == 0x0EA5 || c == 0x0EA7) || (c >= 0x0EAA && c <= 0x0EAB) || (c >= 0x0EAD && c <= 0x0EAE) || (c == 0x0EB0) || (c >= 0x0EB2 && c <= 0x0EB3) || (c == 0x0EBD) || (c >= 0x0EC0 && c <= 0x0EC4) || (c >= 0x0F40 && c <= 0x0F47) || (c >= 0x0F49 && c <= 0x0F69)); else return ((c >= 0x10A0 && c <= 0x10C5) || (c >= 0x10D0 && c <= 0x10F6) || (c == 0x1100) || (c >= 0x1102 && c <= 0x1103) || (c >= 0x1105 && c <= 0x1107) || (c == 0x1109) || (c >= 0x110B && c <= 0x110C) || (c >= 0x110E && c <= 0x1112) || (c == 0x113C || c == 0x113E || c == 0x1140) || (c == 0x114C || c == 0x114E || c == 0x1150) || (c >= 0x1154 && c <= 0x1155) || (c == 0x1159) || (c >= 0x115F && c <= 0x1161) || (c == 0x1163) || (c == 0x1165) || (c == 0x1167) || (c == 0x1169) || (c >= 0x116D && c <= 0x116E) || (c >= 0x1172 && c <= 0x1173) || (c == 0x1175) || (c == 0x119E) || (c == 0x11A8) || (c == 0x11AB) || (c >= 0x11AE && c <= 0x11AF) || (c >= 0x11B7 && c <= 0x11B8) || (c == 0x11BA) || (c >= 0x11BC && c <= 0x11C2) || (c == 0x11EB) || (c == 0x11F0) || (c == 0x11F9) || (c >= 0x1E00 && c <= 0x1E9B) || (c >= 0x1EA0 && c <= 0x1EF9) || (c >= 0x1F00 && c <= 0x1F15) || (c >= 0x1F18 && c <= 0x1F1D) || (c >= 0x1F20 && c <= 0x1F45) || (c >= 0x1F48 && c <= 0x1F4D) || (c >= 0x1F50 && c <= 0x1F57) || (c == 0x1F59) || (c == 0x1F5B) || (c == 0x1F5D) || (c >= 0x1F5F && c <= 0x1F7D) || (c >= 0x1F80 && c <= 0x1FB4) || (c >= 0x1FB6 && c <= 0x1FBC) || (c == 0x1FBE) || (c >= 0x1FC2 && c <= 0x1FC4) || (c >= 0x1FC6 && c <= 0x1FCC) || (c >= 0x1FD0 && c <= 0x1FD3) || (c >= 0x1FD6 && c <= 0x1FDB) || (c >= 0x1FE0 && c <= 0x1FEC) || (c >= 0x1FF2 && c <= 0x1FF4) || (c >= 0x1FF6 && c <= 0x1FFC) || (c == 0x2126) || (c >= 0x212A && c <= 0x212B) || (c == 0x212E) || (c >= 0x2180 && c <= 0x2182) || (c >= 0x3041 && c <= 0x3094) || (c >= 0x30A1 && c <= 0x30FA) || (c >= 0x3105 && c <= 0x312C) || (c >= 0xAC00 && c <= 0xD7A3)); }; int ACEXML_ParserInt::isIdeographic_i (const ACEXML_Char c) { return ((c >= 0x4E00 && c <= 0x9FA5) || (c == 3007) || (c >= 0x3021 && c <= 0x3029)); } int ACEXML_ParserInt::isCombiningchar_i (const ACEXML_Char c) { if (c < 0x0901) return ((c >= 0x0300 && c <= 0x0345) || (c >= 0x0360 && c <= 0x0361) || (c >= 0x0483 && c <= 0x0486) || (c >= 0x0591 && c <= 0x05A1) || (c >= 0x05A3 && c <= 0x05B9) || (c >= 0x05BB && c <= 0x05BD) || (c == 0x05BF) || (c >= 0x05C1 && c <= 0x05C2) || (c == 0x05C4) || (c >= 0x064B && c <= 0x0652) || (c == 0x0670) || (c >= 0x06D6 && c <= 0x06DC) || (c >= 0x06DD && c <= 0x06DF) || (c >= 0x06E0 && c <= 0x06E4) || (c >= 0x06E7 && c <= 0x06E8) || (c >= 0x06EA && c <= 0x06ED)); else return ((c >= 0x0901 && c <= 0x0903) || (c == 0x093C) || (c >= 0x093E && c <= 0x094C) || (c == 0x094D) || (c >= 0x0951 && c <= 0x0954) || (c >= 0x0962 && c <= 0x0963) || (c >= 0x0981 && c <= 0x0983) || (c == 0x09BC) || (c == 0x09BE) || (c == 0x09BF) || (c >= 0x09C0 && c <= 0x09C4) || (c >= 0x09C7 && c <= 0x09C8) || (c >= 0x09CB && c <= 0x09CD) || (c == 0x09D7) || (c >= 0x09E2 && c <= 0x09E3) || (c == 0x0A02) || (c == 0x0A3C) || (c == 0x0A3E) || (c == 0x0A3F) || (c >= 0x0A40 && c <= 0x0A42) || (c >= 0x0A47 && c <= 0x0A48) || (c >= 0x0A4B && c <= 0x0A4D) || (c >= 0x0A70 && c <= 0x0A71) || (c >= 0x0A81 && c <= 0x0A83) || (c == 0x0ABC) || (c >= 0x0ABE && c <= 0x0AC5) || (c >= 0x0AC7 && c <= 0x0AC9) || (c >= 0x0ACB && c <= 0x0ACD) || (c >= 0x0B01 && c <= 0x0B03) || (c == 0x0B3C) || (c >= 0x0B3E && c <= 0x0B43) || (c >= 0x0B47 && c <= 0x0B48) || (c >= 0x0B4B && c <= 0x0B4D) || (c >= 0x0B56 && c <= 0x0B57) || (c >= 0x0B82 && c <= 0x0B83) || (c >= 0x0BBE && c <= 0x0BC2) || (c >= 0x0BC6 && c <= 0x0BC8) || (c >= 0x0BCA && c <= 0x0BCD) || (c == 0x0BD7) || (c >= 0x0C01 && c <= 0x0C03) || (c >= 0x0C3E && c <= 0x0C44) || (c >= 0x0C46 && c <= 0x0C48) || (c >= 0x0C4A && c <= 0x0C4D) || (c >= 0x0C55 && c <= 0x0C56) || (c >= 0x0C82 && c <= 0x0C83) || (c >= 0x0CBE && c <= 0x0CC4) || (c >= 0x0CC6 && c <= 0x0CC8) || (c >= 0x0CCA && c <= 0x0CCD) || (c >= 0x0CD5 && c <= 0x0CD6) || (c >= 0x0D02 && c <= 0x0D03) || (c >= 0x0D3E && c <= 0x0D43) || (c >= 0x0D46 && c <= 0x0D48) || (c >= 0x0D4A && c <= 0x0D4D) || (c == 0x0D57) || (c == 0x0E31) || (c >= 0x0E34 && c <= 0x0E3A) || (c >= 0x0E47 && c <= 0x0E4E) || (c == 0x0EB1) || (c >= 0x0EB4 && c <= 0x0EB9) || (c >= 0x0EBB && c <= 0x0EBC) || (c >= 0x0EC8 && c <= 0x0ECD) || (c >= 0x0F18 && c <= 0x0F19) || (c == 0x0F35) || (c == 0x0F37) || (c == 0x0F39) || (c == 0x0F3E) || (c == 0x0F3F) || (c >= 0x0F71 && c <= 0x0F84) || (c >= 0x0F86 && c <= 0x0F8B) || (c >= 0x0F90 && c <= 0x0F95) || (c == 0x0F97) || (c >= 0x0F99 && c <= 0x0FAD) || (c >= 0x0FB1 && c <= 0x0FB7) || (c == 0x0FB9) || (c >= 0x20D0 && c <= 0x20DC) || (c == 0x20E1) || (c >= 0x302A && c <= 0x302F) || (c == 0x3099) || (c == 0x309A)); } int ACEXML_ParserInt::isDigit_i (const ACEXML_Char c) { if (c < 0x0040) return (c >= 0x0030 && c <= 0x0039); else return ((c >= 0x0660 && c <= 0x0669) || (c >= 0x06F0 && c <= 0x06F9) || (c >= 0x0966 && c <= 0x096F) || (c >= 0x09E6 && c <= 0x09EF) || (c >= 0x0A66 && c <= 0x0A6F) || (c >= 0x0AE6 && c <= 0x0AEF) || (c >= 0x0B66 && c <= 0x0B6F) || (c >= 0x0BE7 && c <= 0x0BEF) || (c >= 0x0C66 && c <= 0x0C6F) || (c >= 0x0CE6 && c <= 0x0CEF) || (c >= 0x0D66 && c <= 0x0D6F) || (c >= 0x0E50 && c <= 0x0E59) || (c >= 0x0ED0 && c <= 0x0ED9) || (c >= 0x0F20 && c <= 0x0F29)); } int ACEXML_ParserInt::isExtender_i (const ACEXML_Char c) { // The compiler should generate a jump table and index into it directly. switch (c) { case 0x00B7: case 0x02D0: case 0x02D1: case 0x0387: case 0x0640: case 0x0E46: case 0x0EC6: case 0x3005: case 0x3031: case 0x3032: case 0x3033: case 0x3034: case 0x3035: case 0x309D: case 0x309E: case 0x30FC: case 0x30FD: case 0x30FE: return 1; default: return 0; } } #endif /* ACE_USES_WCHAR */ ace-6.3.3+dfsg.orig/ACEXML/ACEXML.mwc0000644000175000017500000000003512576461726017045 0ustar pgquilespgquiles// -*- MPC -*- workspace { } ace-6.3.3+dfsg.orig/ACEXML/tests/0000775000175000017500000000000012576472436016532 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/tests/HttpCharStream_Test.cpp0000644000175000017500000000157512576461726023134 0ustar pgquilespgquiles#include "ACEXML/common/HttpCharStream.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_main.h" int ACE_TMAIN (int, ACE_TCHAR *[]) { const ACEXML_Char* test = ACE_TEXT("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); const ACEXML_Char* simple = ACE_TEXT("http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"); ACEXML_HttpCharStream first; ACEXML_HttpCharStream second; ACEXML_Char ch; if (first.open (test) != -1) { while (first.get (ch) != -1) ACE_OS::printf ("%c", ch); } else { first.close(); ACE_ERROR ((LM_ERROR, "Error in opening stream : %m\n")); } if (second.open (simple) != -1) { while (second.get (ch) != -1) ACE_OS::printf ("%c", ch); } else { second.close(); ACE_ERROR ((LM_ERROR, "Error in opening stream : %m\n")); } first.close(); second.close(); return 0; } ace-6.3.3+dfsg.orig/ACEXML/tests/NamespaceSupport_Test.cpp0000644000175000017500000001231012576461726023521 0ustar pgquilespgquiles#include "ACEXML/common/NamespaceSupport.h" #include "ace/OS_main.h" int ACE_TMAIN (int, ACE_TCHAR *[]) { ACEXML_NamespaceSupport xmlns; if (xmlns.init() == -1) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Error in initializing namespace support."))); return 1; } xmlns.pushContext(); xmlns.declarePrefix(ACE_TEXT (""), ACE_TEXT ("http://www.w3.org/1999/xhtml")); xmlns.declarePrefix(ACE_TEXT ("dc"), ACE_TEXT ("http://www.purl.org/dc#")); xmlns.declarePrefix(ACE_TEXT ("xc"), ACE_TEXT ("http://www.purl.org/dc#")); const ACEXML_Char *lName, *uri; const ACEXML_Char *n1 = ACE_TEXT ("p"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("*** Checking processName:\n"))); if (xmlns.processName (n1, uri, lName, 0) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to resolve namespace name %s\n"), n1)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"), uri, lName, n1)); const ACEXML_Char *n2 = ACE_TEXT ("dc:title"); if (xmlns.processName(n2, uri, lName, 0) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to resolve namespace name %S\n"), n2)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"), uri, lName, n2)); const ACEXML_Char *n3 = ACE_TEXT ("xml:title"); if (xmlns.processName(n3, uri, lName, 0) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to resolve namespace name %S\n"), n3)); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Namespace URI: %s\nLocal name: %s\nRaw name: %s\n"), uri, lName, n3)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getDeclaredPrefixes\n"))); ACEXML_STR_LIST prefixes; if (xmlns.getDeclaredPrefixes (prefixes) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get a list of declared prefixes\n"))); else { ACEXML_STR_LIST::ITERATOR iter = prefixes.begin (); const ACEXML_Char **prefix = 0; for (; iter.next (prefix);iter.advance ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix)); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefix\n"))); const ACEXML_Char *prefix = 0; if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.purl.org/dc#"))) == 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get prefix of http://www.purl.org/dc#\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Prefix of http://www.purl.org/dc# is %s\n"), prefix)); if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/1999/xhtml"))) == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Fail to get prefix of http://www.w3.org/1999/xhtml which is okay\n"))); else ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: Prefix of http://www.w3.org/1999/xhtml is %s\n"), prefix)); if ((prefix = xmlns.getPrefix (ACE_TEXT ("http://www.w3.org/XML/1998/namespace"))) == 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get prefix of http://www.w3.org/XML/1998/namespace\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Prefix of http://www.w3.org/XML/1998/namespace is %s\n"), prefix)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes with known URI\n"))); prefixes.reset (); if (xmlns.getPrefixes (ACE_TEXT ("http://www.purl.org/dc#"), prefixes) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes based on known URI\n"))); else { ACEXML_STR_LIST::ITERATOR iter = prefixes.begin (); const ACEXML_Char **prefix = 0; for (; iter.next (prefix);iter.advance ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix)); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getPrefixes\n"))); prefixes.reset (); if (xmlns.getPrefixes (prefixes) != 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to getPrefixes\n"))); else { ACEXML_STR_LIST::ITERATOR iter = prefixes.begin (); const ACEXML_Char **prefix = 0; for (; iter.next (prefix);iter.advance ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("prefix: \"%s\"\n"), *prefix)); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n*** Checking getURI\n"))); const ACEXML_Char *URI = 0; if ((URI = xmlns.getURI (ACE_TEXT ("dc"))) == 0) ACE_DEBUG((LM_ERROR, ACE_TEXT ("Fail to get URI for \"dc\"\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"dc\" is %s\n"), URI)); if ((URI = xmlns.getURI (ACE_TEXT ("xc"))) == 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xc\"\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xc\" is %s\n"), URI)); if ((URI = xmlns.getURI (ACE_TEXT ("xml"))) == 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get URI for \"xml\"\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for \"xml\" is %s\n"), URI)); if ((URI = xmlns.getURI (ACE_TEXT (""))) == 0) ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Fail to get default namespace URI\n"))); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("URI for default namespace is %s\n"), URI)); xmlns.popContext(); return 0; } ace-6.3.3+dfsg.orig/ACEXML/tests/util/0000775000175000017500000000000012576472436017507 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/ACEXML/tests/util/util.mpc0000644000175000017500000000005512576461726021163 0ustar pgquilespgquilesproject: aceexe, acexml { exename = test } ace-6.3.3+dfsg.orig/ACEXML/tests/util/test.cpp0000644000175000017500000000660512576461726021177 0ustar pgquilespgquiles// A simple test for performance of the ACEXML_escape_string() function #include "ACEXML/common/XML_Util.h" #include "ace/OS_main.h" #include "ace/Time_Value.h" #include "ace/OS_NS_sys_time.h" #include "ace/Log_Msg.h" const int MAX_ITERATIONS = 100 * 1000; const int NUM_TEST_STRS = 6; static bool is_escaped(const ACEXML_String& s) { if (s[0] != ACE_TEXT('&')) return false; if (s[s.length() - 1] != ACE_TEXT(';')) return false; return true; } static int run_tests(ACEXML_String test_strings[NUM_TEST_STRS], int iterations) { // Test 1 - Escape the strings using a new temporary string each iteration. ACE_Time_Value start = ACE_OS::gettimeofday(); int i = 0; for (i = 0; i < iterations; ++i) { ACEXML_String tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]); if (! is_escaped(tmp)) { ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); return 1; } } ACE_DEBUG((LM_DEBUG, "Test1 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); // Test 2 - Escape the strings using a shared temporary string. This shouldn't // be any faster than Test 1 as long as the compiler has return value optimization. ACEXML_String tmp; start = ACE_OS::gettimeofday(); for (i = 0; i < iterations; ++i) { tmp = ACEXML_escape_string(test_strings[i % NUM_TEST_STRS]); if (! is_escaped(tmp)) { ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); return 1; } } ACE_DEBUG((LM_DEBUG, "Test2 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); // Test 3 - Escape the strings using a shared temporary string. This time, we use // the alternate form of ACEXML_escape_string() so that our temporary buffer is reused. tmp.clear(1); start = ACE_OS::gettimeofday(); for (i = 0; i < iterations; ++i) { ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp); if (! is_escaped(tmp)) { ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); return 1; } } ACE_DEBUG((LM_DEBUG, "Test3 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); // Test 4 - Same as Test 3, except that the tmp buffer shouldn't have to resize. start = ACE_OS::gettimeofday(); for (i = 0; i < iterations; ++i) { ACEXML_escape_string(test_strings[i % NUM_TEST_STRS], tmp); if (! is_escaped(tmp)) { ACE_ERROR((LM_ERROR, "Error: Failed to escape string\n")); return 1; } } ACE_DEBUG((LM_DEBUG, "Test4 took %dms\n", (ACE_OS::gettimeofday() - start).msec())); return 0; } int ACE_TMAIN (int, ACE_TCHAR *[]) { ACEXML_String test_strings[NUM_TEST_STRS] = { ACE_TEXT("\"xxxxx\"xxxxxxxx xx\"xxxxxx xxxxxx\"xxxxxxxxxx xxxxxxxx\"xxxxxx\""), ACE_TEXT("'xxxxx\'xxxxxxxx' xxxxxxxx xx'xxxxxxxx'xxxxxx xxxxxxx'xxxxxxx'"), ACE_TEXT("&xxxx&xxxxxxxxx &xxxxxxxx xxxxx&xxxxxxxxxxx xxxx&xxxxxxxxxx&"), ACE_TEXT(">xx>xxxxxxxxxxx >xxxxxxxx xxxxx>xxxxxxxxxxx xxxxx>xxxxxxxxx>"), ACE_TEXT("xxxxxxx xx\"xxxxxxxxxxxx>"), }; if (run_tests(test_strings, MAX_ITERATIONS) != 0) return 1; ACE_DEBUG((LM_DEBUG, "Rerun tests with larger strings\n")); for (int i = 0; i < NUM_TEST_STRS; ++i) { for (int j = 0; j < 5; ++j) { test_strings[i] += test_strings[i]; } } if (run_tests(test_strings, MAX_ITERATIONS / 10) != 0) return 1; return 0; } ace-6.3.3+dfsg.orig/ACEXML/tests/Transcoder_Test.cpp0000644000175000017500000000313112576461726022335 0ustar pgquilespgquiles// -*- C++ -*- #include "ACEXML/common/Transcode.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_string.h" #include "ace/OS_main.h" void dump_utf16 (const ACEXML_UTF16 *data, size_t len) { size_t ptr = 0; while (1) { ACE_DEBUG ((LM_DEBUG, "%04x", data[ptr])); if (++ptr >= len) break; if (ptr % 4 == 0) ACE_DEBUG ((LM_DEBUG, "\n")); else ACE_DEBUG ((LM_DEBUG, " ")); } ACE_DEBUG ((LM_DEBUG, "\n")); return; } int ACE_TMAIN (int, ACE_TCHAR*[]) { ACEXML_UTF16 org [18]; // = { 1, 2, 4, 8, 0x10, 0x20, 0x40, // 0x80, // 0x100, 0x200, 0x400, // 0x800, 0x801, 0x802, 0x804, 0x808, 0x810, 0x820, // 0x840, 0x880, 0x900, 0xa00, 0xc00, // 0x1000, 0x2000, 0x4000, 0x8000, 0 } ACEXML_UCS4 temp = 1; ACE_OS::memset (org, 0, sizeof org); size_t x; for (x = 0; temp < 0x10000; x++, temp <<= 1) { org[x] = static_cast (temp); } ACE_DEBUG ((LM_DEBUG, "Original UTF16 string:\n")); dump_utf16 (org, x); ACE_DEBUG ((LM_DEBUG, "\n\n")); ACEXML_UTF8 decoded [MAXPATHLEN]; ACE_OS::memset (decoded, 0, sizeof decoded); ACEXML_Transcoder::utf16s2utf8s (org, decoded, MAXPATHLEN); ACE_DEBUG ((LM_DEBUG, "Transcoded UTF8 string:\n")); ACE_HEX_DUMP ((LM_DEBUG, decoded, ACE_OS::strlen (decoded) + 1)); ACE_DEBUG ((LM_DEBUG, "\n\n")); ACEXML_UTF16 after [18]; ACE_OS::memset (after, 0, sizeof after); ACEXML_Transcoder::utf8s2utf16s (decoded, after, 18); ACE_DEBUG ((LM_DEBUG, "Restored UTF16 string:\n")); dump_utf16 (after, x); ACE_DEBUG ((LM_DEBUG, "\n\n")); return 0; } ace-6.3.3+dfsg.orig/ACEXML/tests/tests.mpc0000644000175000017500000000102512576461726020371 0ustar pgquilespgquiles// -*- MPC -*- project(Transcoder_Test): aceexe, acexml { exename = Transcoder_Test Source_Files { Transcoder_Test.cpp } } project(NamespaceSupport_Test): aceexe, acexml { exename = NamespaceSupport_Test Source_Files { NamespaceSupport_Test.cpp } } project(HttpCharStream_Test): aceexe, acexml { exename = HttpCharStream_Test Source_Files { HttpCharStream_Test.cpp } } project(ContentHandler_Test): aceexe, acexml { exename = ContentHandler_Test Source_Files { ContentHandler_Test.cpp } } ace-6.3.3+dfsg.orig/ACEXML/tests/ContentHandler_Test.cpp0000644000175000017500000000522712576461726023151 0ustar pgquilespgquiles//============================================================================= /** * @file ContentHandler_Test.cpp * * @author Steve Huston */ //============================================================================= #include "ACEXML/common/DefaultHandler.h" #include "ACEXML/common/InputSource.h" #include "ACEXML/common/StrCharStream.h" #include "ACEXML/parser/parser/Parser.h" #include "ace/OS_NS_string.h" #include "ace/OS_main.h" class Basic_Content_Tester : public ACEXML_DefaultHandler { public: /** * Receive notification of character data. */ virtual void characters (const ACEXML_Char *ch, size_t start, size_t length); const ACEXML_Char *get_test_string (void) { return Basic_Content_Tester::test_string_; } private: static const ACEXML_Char *test_string_; }; const ACEXML_Char * Basic_Content_Tester::test_string_ = ACE_TEXT ("") ACE_TEXT ("Example\n") ACE_TEXT ("d'internationalisation"); void Basic_Content_Tester::characters (const ACEXML_Char *ch, size_t start, size_t length) { static bool already_called = false; static const ACEXML_Char *expect = ACE_TEXT ("Example\nd'internationalisation"); if (already_called) { throw ACEXML_SAXException (ACE_TEXT ("characters() called too much\n")); } already_called = true; size_t const expected_len = ACE_OS::strlen (expect); if (length != expected_len) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("characters() expected len %u (%*s); ") ACE_TEXT ("got %u (%*s)\n"), expected_len, expected_len, ch + start, length, length, ch + start)); throw ACEXML_SAXException (ACE_TEXT ("Functionality failure")); } } int ACE_TMAIN (int, ACE_TCHAR *[]) { int status = 0; Basic_Content_Tester tester; ACEXML_StrCharStream *test_stream = 0; ACE_NEW_RETURN (test_stream, ACEXML_StrCharStream, -1); if (test_stream->open (tester.get_test_string (), ACE_TEXT ("test_stream")) < 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unable to create input stream\n"))); return -1; } ACEXML_InputSource input (test_stream); ACEXML_Parser parser; parser.setContentHandler (&tester); try { parser.setFeature (ACE_TEXT ("http://xml.org/sax/features/validation"), 0); parser.parse (&input); } catch (const ACEXML_SAXException& ex) { ex.print(); status = 1; } return status; } ace-6.3.3+dfsg.orig/examples/0000775000175000017500000000000012576472437016236 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/0000775000175000017500000000000012576472436017634 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/Proactor/0000775000175000017500000000000012576472436021425 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_udp_proactor.cpp0000644000175000017500000003073012576461726025672 0ustar pgquilespgquiles //============================================================================= /** * @file test_udp_proactor.cpp * * This program illustrates how the can be used to * implement an application that does asynchronous operations using * datagrams. * * @author Irfan Pyarali and Roger Tragin */ //============================================================================= #include "ace/OS_NS_string.h" #include "ace/OS_main.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Dgram.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on asynch I/O-capable platforms. // Host that we're connecting to. static ACE_TCHAR *host = 0; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; // Keep track of when we're done. static int done = 0; /** * @class Receiver * * @brief This class will receive data from * the network connection and dump it to a file. */ class Receiver : public ACE_Service_Handler { public: // = Initialization and termination. Receiver (void); ~Receiver (void); int open_addr (const ACE_INET_Addr &localAddr); protected: // These methods are called by the framework /// This method will be called when an asynchronous read completes on /// a UDP socket. virtual void handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result); private: ACE_SOCK_Dgram sock_dgram_; /// rd (read dgram): for reading from a UDP socket. ACE_Asynch_Read_Dgram rd_; const char* completion_key_; const char* act_; }; Receiver::Receiver (void) : completion_key_ ("Receiver Completion Key"), act_ ("Receiver ACT") { } Receiver::~Receiver (void) { sock_dgram_.close (); } int Receiver::open_addr (const ACE_INET_Addr &localAddr) { ACE_DEBUG ((LM_DEBUG, "%N:%l:Receiver::open_addr called\n")); // Create a local UDP socket to receive datagrams. if (this->sock_dgram_.open (localAddr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram::open"), -1); // Initialize the asynchronous read. if (this->rd_.open (*this, this->sock_dgram_.get_handle (), this->completion_key_, ACE_Proactor::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Dgram::open"), -1); // Create a buffer to read into. We are using scatter/gather to // read the message header and message body into 2 buffers // create a message block to read the message header ACE_Message_Block* msg = 0; ACE_NEW_RETURN (msg, ACE_Message_Block (1024), -1); // the next line sets the size of the header, even though we // allocated a the message block of 1k, by setting the size to 20 // bytes then the first 20 bytes of the reveived datagram will be // put into this message block. msg->size (20); // size of header to read is 20 bytes // create a message block to read the message body ACE_Message_Block* body = 0; ACE_NEW_RETURN (body, ACE_Message_Block (1024), -1); // The message body will not exceed 1024 bytes, at least not in this test. // set body as the cont of msg. This associates the 2 message // blocks so that a read will fill the first block (which is the // header) up to size (), and use the cont () block for the rest of // the data. You can chain up to IOV_MAX message block using this // method. msg->cont (body); // ok lets do the asynch read size_t number_of_bytes_recvd = 0; int res = rd_.recv (msg, number_of_bytes_recvd, 0, PF_INET, this->act_); switch (res) { case 0: // this is a good error. The proactor will call our handler when the // read has completed. break; case 1: // actually read something, we will handle it in the handler callback ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes received immediately", number_of_bytes_recvd)); ACE_DEBUG ((LM_DEBUG, "********************\n")); res = 0; break; case -1: // Something else went wrong. ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Dgram::recv")); // the handler will not get called in this case so lets clean up our msg msg->release (); break; default: // Something undocumented really went wrong. ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Dgram::recv")); msg->release (); break; } return res; } void Receiver::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_dgram called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_INET_Addr peerAddr; result.remote_address (peerAddr); ACE_DEBUG ((LM_DEBUG, "%s = %s:%d\n", "peer_address", peerAddr.get_host_addr (), peerAddr.get_port_number ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "flags", result.flags ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "act", result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "completion_key", result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); if (result.success () && result.bytes_transferred () != 0) { // loop through our message block and print out the contents for (const ACE_Message_Block* msg = result.message_block (); msg != 0; msg = msg->cont ()) { // use msg->length () to get the number of bytes written to the message // block. ACE_DEBUG ((LM_DEBUG, "Buf=[size=<%d>", msg->length ())); for (u_long i = 0; i < msg->length (); ++i) ACE_DEBUG ((LM_DEBUG, "%c", (msg->rd_ptr ())[i])); ACE_DEBUG ((LM_DEBUG, "]\n")); } } ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); // No need for this message block anymore. result.message_block ()->release (); // Note that we are done with the test. done++; } /** * @class Sender * * @brief The class will be created by
. */ class Sender : public ACE_Handler { public: Sender (void); ~Sender (void); //FUZZ: disable check_for_lack_ACE_OS ///FUZZ: enable check_for_lack_ACE_OS int open (const ACE_TCHAR *host, u_short port); protected: // These methods are called by the freamwork /// This is called when asynchronous writes from the dgram socket /// complete virtual void handle_write_dgram (const ACE_Asynch_Write_Dgram::Result &result); private: /// Network I/O handle ACE_SOCK_Dgram sock_dgram_; /// wd (write dgram): for writing to the socket ACE_Asynch_Write_Dgram wd_; const char* completion_key_; const char* act_; }; Sender::Sender (void) : completion_key_ ("Sender completion key"), act_ ("Sender ACT") { } Sender::~Sender (void) { this->sock_dgram_.close (); } int Sender::open (const ACE_TCHAR *host, u_short port) { // Initialize stuff if (this->sock_dgram_.open (ACE_INET_Addr::sap_any) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram::open"), -1); // Initialize the asynchronous read. if (this->wd_.open (*this, this->sock_dgram_.get_handle (), this->completion_key_, ACE_Proactor::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Dgram::open"), -1); // We are using scatter/gather to send the message header and // message body using 2 buffers // create a message block for the message header ACE_Message_Block* msg = 0; ACE_NEW_RETURN (msg, ACE_Message_Block (100), -1); const char raw_msg [] = "To be or not to be."; // Copy buf into the Message_Block and update the wr_ptr (). msg->copy (raw_msg, ACE_OS::strlen (raw_msg) + 1); // create a message block for the message body ACE_Message_Block* body = 0; ACE_NEW_RETURN (body, ACE_Message_Block (100), -1); ACE_OS::memset (body->wr_ptr (), 'X', 100); body->wr_ptr (100); // always remember to update the wr_ptr () // set body as the cont of msg. This associates the 2 message blocks so // that a send will send the first block (which is the header) up to // length (), and use the cont () to get the next block to send. You can // chain up to IOV_MAX message block using this method. msg->cont (body); // do the asynch send size_t number_of_bytes_sent = 0; ACE_INET_Addr serverAddr (port, host); int res = this->wd_.send (msg, number_of_bytes_sent, 0, serverAddr, this->act_); switch (res) { case 0: // this is a good error. The proactor will call our handler when the // send has completed. break; case 1: // actually sent something, we will handle it in the handler callback ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes sent immediately", number_of_bytes_sent)); ACE_DEBUG ((LM_DEBUG, "********************\n")); res = 0; break; case -1: // Something else went wrong. ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Dgram::recv")); // the handler will not get called in this case so lets clean up our msg msg->release (); break; default: // Something undocumented really went wrong. ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Dgram::recv")); msg->release (); break; } return res; } void Sender::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_dgram called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "flags", result.flags ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "act", result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "completion_key", result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "Sender completed\n")); // No need for this message block anymore. result.message_block ()->release (); // Note that we are done with the test. done++; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("h:p:")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'h': host = get_opt.opt_arg (); break; case 'p': port = ACE_OS::atoi (get_opt.opt_arg ()); break; default: ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "usage :\n" "-h \n"), -1); } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; Sender sender; Receiver receiver; // If passive side if (host == 0) { if (receiver.open_addr (ACE_INET_Addr (port)) == -1) return -1; } // If active side else if (sender.open (host, port) == -1) return -1; for (int success = 1; success > 0 && !done; ) // Dispatch events via Proactor singleton. success = ACE_Proactor::instance ()->handle_events (); return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS*/ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example does not work on this platform.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/post_completions.cpp0000644000175000017500000002005412576461726025531 0ustar pgquilespgquiles//============================================================================= /** * @file post_completions.cpp * * This program demonstrates how to post fake completions to The * Proactor. It also shows the how to specify the particular * real-time signals to post completions. The Real-time signal * based completion strategy is implemented with * ACE_POSIX_SIG_PROACTOR. * (So, it can be used only if both ACE_HAS_AIO_CALLS and * ACE_HAS_POSIX_REALTIME_SIGNALS are defined.) * Since it is faking results, you have to pay by knowing and * using platform-specific implementation objects for Asynchronous * Result classes. * This example shows using an arbitrary result class for faking * completions. You can also use the predefined Result classes for * faking. The factory methods in the Proactor class create the * Result objects. * make * ./post_completions * * @author Alexander Babu Arulanthu */ //============================================================================= #include "ace/OS_NS_unistd.h" #include "ace/OS_main.h" #include "ace/Proactor.h" #include "ace/Task.h" #include "ace/WIN32_Proactor.h" #include "ace/POSIX_Proactor.h" #include "ace/Atomic_Op.h" #include "ace/Thread_Mutex.h" // Keep track of how many completions are still expected. static ACE_Atomic_Op Completions_To_Go; #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. #if defined (ACE_HAS_AIO_CALLS) #define RESULT_CLASS ACE_POSIX_Asynch_Result #elif defined (ACE_HAS_WIN32_OVERLAPPED_IO) #define RESULT_CLASS ACE_WIN32_Asynch_Result #endif /* ACE_HAS_AIO_CALLS */ /** * @class My_Result * * @brief Result Object that we will post to the Proactor. */ class My_Result : public RESULT_CLASS { public: My_Result (ACE_Handler &handler, const void *act, int signal_number, size_t sequence_number) : RESULT_CLASS (handler.proxy (), act, ACE_INVALID_HANDLE, 0, // Offset 0, // OffsetHigh 0, // Priority signal_number), sequence_number_ (sequence_number) {} // Constructor. virtual ~My_Result (void) {} // Destructor. /** * This is the method that will be called by the Proactor for * dispatching the completion. This method generally calls one of * the call back hood methods defined in the ACE_Handler * class. But, we will just handle the completions here. */ void complete (size_t, int success, const void *completion_key, u_long error) { this->success_ = success; this->completion_key_ = completion_key; this->error_ = error; size_t to_go = --Completions_To_Go; // Print the completion details. ACE_DEBUG ((LM_DEBUG, "(%t) Completion sequence number %d, success : %d, error : %d, signal_number : %d, %u more to go\n", this->sequence_number_, this->success_, this->error_, this->signal_number (), to_go)); // Sleep for a while. ACE_OS::sleep (4); } private: /// Sequence number for the result object. size_t sequence_number_; }; /** * @class My_Handler * * @brief Handler class for faked completions. */ class My_Handler : public ACE_Handler { public: /// Constructor. My_Handler (void) {} /// Destructor. virtual ~My_Handler (void) {} }; /** * @class My_Task: * * @brief Contains thread functions which execute event loops. Each * thread waits for a different signal. */ class My_Task: public ACE_Task { public: /// Constructor. My_Task (void) {} /// Destructor. virtual ~My_Task (void) {} //FUZZ: disable check_for_lack_ACE_OS int open (void *proactor) { //FUZZ: enable check_for_lack_ACE_OS // Store the proactor. this->proactor_ = (ACE_Proactor *) proactor; // Activate the Task. this->activate (THR_NEW_LWP, 5); return 0; } int svc (void) { // Handle events for 13 seconds. ACE_Time_Value run_time (13); ACE_DEBUG ((LM_DEBUG, "(%t):Starting svc routine\n")); if (this->proactor_->handle_events (run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t):%p.\n", "Worker::svc"), -1); ACE_DEBUG ((LM_DEBUG, "(%t) work complete\n")); return 0; } private: /// Proactor for this task. ACE_Proactor *proactor_; }; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_DEBUG ((LM_DEBUG, "(%P | %t):Test starts\n")); // = Get two POSIX_SIG_Proactors, one with SIGRTMIN and one with // SIGRTMAX. ACE_Proactor proactor1; // Proactor1. SIGRTMIN Proactor. (default). // = Proactor2. SIGRTMAX Proactor. #if defined (ACE_HAS_AIO_CALLS) && defined (ACE_HAS_POSIX_REALTIME_SIGNALS) ACE_DEBUG ((LM_DEBUG, "Using ACE_POSIX_SIG_Proactor\n")); sigset_t signal_set; // Signal set that we want to mask. // Clear the signal set. if (ACE_OS::sigemptyset (&signal_set) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error:%p\n", "sigemptyset failed"), 1); // Add the SIGRTMAX to the signal set. if (ACE_OS::sigaddset (&signal_set, ACE_SIGRTMAX) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error:%p\n", "sigaddset failed"), 1); // Make the POSIX Proactor. ACE_POSIX_SIG_Proactor posix_proactor (signal_set); // Get the Proactor interface out of it. ACE_Proactor proactor2 (&posix_proactor); #else /* ACE_HAS_AIO_CALLS && ACE_HAS_POSIX_REALTIME_SIGNALS */ ACE_Proactor proactor2; #endif /* ACE_HAS_AIO_CALLS && ACE_HAS_POSIX_REALTIME_SIGNALS */ // = Create Tasks. One pool of threads to handle completions on // SIGRTMIN and the other one to handle completions on SIGRTMAX. My_Task task1, task2; task1.open (&proactor1); task2.open (&proactor2); // Handler for completions. My_Handler handler; // = Create a few MyResult objects and post them to Proactor. const size_t NrCompletions (10); My_Result *result_objects [NrCompletions]; int signal_number = ACE_SIGRTMAX; size_t ri = 0; Completions_To_Go = NrCompletions; // Creation. for (ri = 0; ri < NrCompletions; ri++) { // Use RTMIN and RTMAX proactor alternatively, to post // completions. if (ri % 2) signal_number = ACE_SIGRTMIN; else signal_number = ACE_SIGRTMAX; // Create the result. ACE_NEW_RETURN (result_objects [ri], My_Result (handler, 0, signal_number, ri), 1); } ACE_OS::sleep(5); // Post all the result objects. ACE_Proactor *proactor; for (ri = 0; ri < NrCompletions; ri++) { // Use RTMIN and RTMAX Proactor alternatively, to post // completions. if (ri % 2) proactor = &proactor1; else proactor = &proactor2; if (result_objects [ri]->post_completion (proactor->implementation ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Test failed\n"), 1); } ACE_Thread_Manager::instance ()->wait (); int status = 0; size_t to_go = Completions_To_Go.value (); if (size_t (0) != to_go) { ACE_ERROR ((LM_ERROR, "Fail! Expected all completions to finish but %u to go\n", to_go)); status = 1; } ACE_DEBUG ((LM_DEBUG, "(%P | %t):Test ends\n")); return status; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example cannot work with AIOCB_Proactor.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_cancel.cpp0000644000175000017500000001476312576461726024426 0ustar pgquilespgquiles //============================================================================= /** * @file test_cancel.cpp * * This program tests cancelling an Asynchronous Operation in the * Proactor framework. * * This tests accepts a connection and issues an Asynchronous Read * Stream. It reads (option -s) number of bytes and * when this operation completes, it issues another Asynchronous * Read Stream to and immediately calls to * cancel the operation and so the program exits closing the * connection. * * Works fine on NT. On Solaris platforms, the asynch read is * pending, but the cancel returns with the value * indicating all the operations in that handle are done. * But, LynxOS has a good implementation. It works * fine. * * = RUN * ./test_cancel -p * Then telnet to this port and send bytes and your * connection should get closed down. * * @author Irfan Pyarali (irfan@cs.wustl.edu) */ //============================================================================= #include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Asynch_Acceptor.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_sys_socket.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. #include "test_cancel.h" static u_short port = ACE_DEFAULT_SERVER_PORT; static int done = 0; static int read_size = 2; Receiver::Receiver (void) : mb_ (read_size + 1), handle_ (ACE_INVALID_HANDLE) { } Receiver::~Receiver (void) { ACE_DEBUG ((LM_DEBUG, "Receiver: Closing down Remote connection:%d\n", this->handle_)); ACE_OS::closesocket (this->handle_); } void Receiver::open (ACE_HANDLE handle, ACE_Message_Block &) { // New connection, initiate stuff ACE_DEBUG ((LM_DEBUG, "%N:%l:Receiver::open called\n")); // Cache the new connection this->handle_ = handle; // Initiate ACE_Asynch_Read_Stream if (this->rs_.open (*this, this->handle_) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::open")); return; } // Try to read bytes from the stream. ACE_DEBUG ((LM_DEBUG, "Receiver::open: Issuing Asynch Read of (%d) bytes from the stream\n", read_size)); if (this->rs_.read (this->mb_, read_size) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "Receiver::open: Failed to issue the read")); } void Receiver::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); // Reset pointers result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); if (result.success () && !result.error ()) { // Successful read: No error. // Set the pointers back in the message block. result.message_block ().wr_ptr (result.message_block ().rd_ptr ()); // Issue another read, but immediately cancel it. // Issue the read. ACE_DEBUG ((LM_DEBUG, "Issuing Asynch Read of (%d) bytes from the stream\n", read_size)); if (this->rs_.read (this->mb_, read_size) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "Receiver::handle_read_stream: Failed to issue the read")); // Cancel the read. ACE_DEBUG ((LM_DEBUG, "Cacelling Asynch Read ")); int ret_val = this->rs_.cancel (); if (ret_val == -1) ACE_ERROR ((LM_ERROR, "%p\n", "Receiver::handle_read_stream: Failed to cancel the read")); ACE_DEBUG ((LM_DEBUG, "Asynch IO : Cancel : Result = %d\n", ret_val)); } else { done = 1; ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); // Print the error message if any. if (result.error () != 0) { errno = result.error (); ACE_ERROR ((LM_ERROR, "%p\n", "Asynch Read Stream Error: ")); } } } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("p:s:")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'p': port = ACE_OS::atoi (get_opt.opt_arg ()); break; case 's': read_size = ACE_OS::atoi (get_opt.opt_arg ()); break; default: ACE_ERROR ((LM_ERROR, "%p.\n", "usage :\n" "-p \n" "-s \n")); return -1; } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; // Note: acceptor parameterized by the Receiver ACE_Asynch_Acceptor acceptor; // Listening passively. if (acceptor.open (ACE_INET_Addr (port), read_size, 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE:acceptor::open failed\n"), 1); int success = 1; while (success > 0 && !done) // dispatch events success = ACE_Proactor::instance ()->handle_events (); return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example does not work on this platform.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_end_event_loop.cpp0000644000175000017500000001067512576461726026177 0ustar pgquilespgquiles//============================================================================= /** * @file test_end_event_loop.cpp * * This program tests the event loop mechanism of the * Proactor. To end the event loop, threads that are blocked in * waiting for completions are woken up and the event loop comes * to the end. This is tested in this program. * Threads are doing with/without time_out * values and the main thread calls . * make * ./test_end_event_loop * * @author Alexander Babu Arulanthu */ //============================================================================= #include "ace/OS_NS_unistd.h" #include "ace/Proactor.h" #include "ace/Task.h" #include "ace/WIN32_Proactor.h" #include "ace/POSIX_Proactor.h" #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. /** * @class My_Task: * * @brief Contains thread functions which execute event loops. Each * thread waits for a different signal. */ class My_Task: public ACE_Task { public: // Constructor. My_Task (void) : time_flag_ (0) {} /// Destructor. virtual ~My_Task (void) {} //FUZZ: disable check_for_lack_ACE_OS // If time_flag is zero do the eventloop indefinitely, otherwise do // it for finite amount of time (13secs!!!). int open (void *timed_event_loop) { //FUZZ: enble check_for_lack_ACE_OS // Set the local variable. if (timed_event_loop == 0) this->time_flag_ = 0; else this->time_flag_ = 1; // Spawn the threads. if (this->activate (THR_NEW_LWP, 5) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:%p\n", "My_Task:open: failed"), -1); return 0; } // Thread function. int svc (void) { ACE_DEBUG ((LM_DEBUG, "(%P|%t):Starting svc routine\n")); if (this->time_flag_) { ACE_DEBUG ((LM_DEBUG, "(%P|%t):Going to do *timed* \n")); ACE_Time_Value run_time (13); if (ACE_Proactor::instance ()->run_event_loop (run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t):%p.\n", " failed"), -1); } else { ACE_DEBUG ((LM_DEBUG, "(%P|%t):Going to do *indefinite* \n")); if (ACE_Proactor::instance ()->run_event_loop () == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t):%p.\n", " failed"), -1); } return 0; }; private: /// If zero, indefinite event loop, otherwise timed event loop. int time_flag_; }; int ACE_TMAIN (int argc, ACE_TCHAR *argv []) { ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_DEBUG ((LM_DEBUG, "(%P | %t):Test starts\n")); // Let us get the singleton proactor created here. This is very // important. This will mask the signal used in the Proactor masked // for the main thread (and all the threads). ACE_Proactor *proactor = ACE_Proactor::instance (); ACE_UNUSED_ARG (proactor); My_Task task1, task2; // Test the indefinite run event loop. if (task1.open (0) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t):Failed to the task\n"), 1); // Test the indefinite run event loop. Just pass a non-zero. if (task2.open ((void *)&task2) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t):Failed to the task\n"), 1); // Give a gap. ACE_OS::sleep (3); // End the event loop. if (ACE_Proactor::instance ()->end_event_loop () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t):Failed to \n"), 1); ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "(%P | %t):Test ends\n")); return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example cannot work with AIOCB_Proactor.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_timeout.cpp0000644000175000017500000000656412576461726024667 0ustar pgquilespgquiles //============================================================================= /** * @file test_timeout.cpp * * This example application shows how to write event loops that * handle events for some fixed amount of time. Note that any * thread in the Proactor thread pool can call back the handler. On * POSIX4 systems, this test works only with POSIX_SIG_Proactor, * which can work with multiple threads. * * @author Irfan Pyarali and Alexander Babu Arulanthu */ //============================================================================= #include "ace/Proactor.h" #include "ace/Task.h" #include "ace/Atomic_Op.h" #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. /** * @class Timeout_Handler * * @brief Generic timeout handler. */ class Timeout_Handler : public ACE_Handler { public: Timeout_Handler (void) : start_time_ (ACE_OS::gettimeofday ()) { } virtual void handle_time_out (const ACE_Time_Value &tv, const void *arg) { // Print out when timeouts occur. ACE_DEBUG ((LM_DEBUG, "(%t) %d timeout occurred for %s @ %d.\n", ++count_, (char *) arg, (tv - this->start_time_).sec ())); // Sleep for a while ACE_OS::sleep (4); } private: /// Number of the timer event. ACE_Atomic_Op count_; /// Starting time of the test. ACE_Time_Value start_time_; }; class Worker : public ACE_Task { public: int svc (void) { // Handle events for 13 seconds. ACE_Time_Value run_time (13); ACE_DEBUG ((LM_DEBUG, "(%t):Starting svc routine\n")); if (ACE_Proactor::run_event_loop(run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t):%p.\n", "Worker::svc"), -1); ACE_DEBUG ((LM_DEBUG, "(%t) work complete\n")); return 0; } }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Timeout_Handler handler; // Register a 2 second timer. ACE_Time_Value foo_tv (2); if (ACE_Proactor::instance ()->schedule_timer (handler, (void *) "Foo", ACE_Time_Value::zero, foo_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); // Register a 3 second timer. ACE_Time_Value bar_tv (3); if (ACE_Proactor::instance ()->schedule_timer (handler, (void *) "Bar", ACE_Time_Value::zero, bar_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); Worker worker; if (worker.activate (THR_NEW_LWP, 10) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); ACE_Thread_Manager::instance ()->wait (); return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example is multithreaded version of test_timeout_st.cpp\n" "This doesnt work on this platform !!!\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_proactor2.cpp0000644000175000017500000005120312576461726025102 0ustar pgquilespgquiles //============================================================================= /** * @file test_proactor2.cpp * * Alexander Libman modified * and made this test. Instead of writing received * data to the file, the receiver sends them back to the * sender,i.e. ACE_Asynch_Write_File wf_ has been changed to * ACE_Asynch_Write_Stream wf_. * * @author Irfan Pyarali and Alexander Libman . */ //============================================================================= #include "ace/Signal.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Asynch_Acceptor.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" // FUZZ: disable check_for_streams_include #include "ace/streams.h" #include "ace/Task.h" #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) #include "ace/WIN32_Proactor.h" #elif defined (ACE_HAS_AIO_CALLS) #include "ace/POSIX_Proactor.h" #endif // Some debug helper functions int DisableSignal ( int SigNum ); int PrintSigMask (); #define COUT(X) cout << X ; cout.flush (); // Host that we're connecting to. static ACE_TCHAR *host = 0; // duplex mode: ==0 half-duplex // !=0 full duplex static int duplex = 0 ; // number threads in the Proactor thread pool static int nThreads = 1; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; // Size of each initial asynchronous operation. static int initial_read_size = BUFSIZ; #define MyMutex ACE_Recursive_Thread_Mutex //#define MyMutex ACE_Thread_Mutex //#define MyMutex ACE_Null_Mutex //-------------------------------------------------------------------------- // MyTask plays role for Proactor threads pool //-------------------------------------------------------------------------- class MyTask: public ACE_Task { public: int svc (void) ; }; int MyTask::svc (void ) { ACE_DEBUG ((LM_DEBUG, "(%t) MyTask started\n")); while ( ACE_Proactor::event_loop_done () == 0 ) { ACE_Proactor::run_event_loop (); } ACE_DEBUG ((LM_DEBUG, "(%t) MyTask finished\n")); return 0 ; } //----------------------------------------------------------- // Receiver //----------------------------------------------------------- class Receiver : public ACE_Service_Handler { public: Receiver (void); ~Receiver (void); //FUZZ: disable check_for_lack_ACE_OS /// This is called after the new connection has been accepted. ///FUZZ: enable check_for_lack_ACE_OS virtual void open (ACE_HANDLE handle, ACE_Message_Block &message_block); protected: // These methods are called by the framework /// This is called when asynchronous operation from the socket /// complete. virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); /// This is called when an asynchronous to the file /// completes. virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); private: int initiate_read_stream (void); int initiate_write_stream (ACE_Message_Block & mb, int nBytes ); bool check_destroy () ; ACE_Asynch_Read_Stream rs_; ACE_Asynch_Write_Stream ws_; ACE_HANDLE handle_; MyMutex m_Mtx ; long nIOCount ; static long nSessions ; }; long Receiver::nSessions = 0 ; Receiver::Receiver (void) : handle_ (ACE_INVALID_HANDLE), nIOCount ( 0 ) { ACE_GUARD (MyMutex, locker, m_Mtx); nSessions ++ ; ACE_DEBUG ((LM_DEBUG, "Receiver Ctor nSessions=%d\n", nSessions )); } Receiver::~Receiver (void) { ACE_GUARD (MyMutex, locker, m_Mtx); nSessions -- ; ACE_OS::closesocket (this->handle_); ACE_DEBUG ((LM_DEBUG, "~Receiver Dtor nSessions=%d\n", nSessions )); } //--------------------------------------------------------------------- // return true if we alive, false we commited suicide // //--------------------------------------------------------------------- bool Receiver::check_destroy () { { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx, false); if ( nIOCount > 0 ) { return true ; } } delete this ; return false ; } void Receiver::open (ACE_HANDLE handle, ACE_Message_Block &) { ACE_DEBUG ((LM_DEBUG, "%N:%l:Receiver::open called\n")); this->handle_ = handle; if (this->ws_.open (*this, this->handle_ ) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::open")); } else if (this->rs_.open (*this, this->handle_) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::open")); } else { initiate_read_stream (); } check_destroy (); } int Receiver::initiate_read_stream (void) { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx, -1); // Create a new . Note that this message block will // be used both to data asynchronously from the socket and to // data asynchronously to the file. ACE_DEBUG ((LM_DEBUG, "initiate_read_stream called\n")); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate read if (this->rs_.read (*mb, mb->size ()- 1) == -1) { mb->release () ; ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::read"), -1); } nIOCount++ ; return 0; } int Receiver::initiate_write_stream (ACE_Message_Block & mb, int nBytes ) { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx, -1); if (this->ws_.write (mb , nBytes ) == -1) { mb.release (); ACE_ERROR_RETURN((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::write"), -1); } nIOCount++ ; return 0; } void Receiver::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); // Reset pointers. result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); if ( result.success () && result.bytes_transferred () != 0) { // Successful read: write the data to the file asynchronously. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . if(this->initiate_write_stream (result.message_block (), result.bytes_transferred () ) == 0 ) { if ( duplex != 0 ) { // Initiate new read from the stream. this->initiate_read_stream () ; } } } else { result.message_block ().release (); ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); } { ACE_GUARD (MyMutex, locker, m_Mtx); --nIOCount; } check_destroy () ; } void Receiver::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_stream called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); result.message_block ().release (); if (result.success ()) { // This code is not robust enough to deal with short file writes // (which hardly ever happen) ;-) //ACE_ASSERT (result.bytes_to_write () == result.bytes_transferred ()); if ( duplex == 0 ) { initiate_read_stream () ; } } { ACE_GUARD (MyMutex, locker, m_Mtx); --nIOCount; } check_destroy () ; } //------------------------------------------------------------------------- // Sender: sends indefinetely welcome message // and recieves it back //------------------------------------------------------------------------ class Sender : public ACE_Handler { public: Sender (void); ~Sender (void); //FUZZ: disable check_for_lack_ACE_OS ///FUZZ: enable check_for_lack_ACE_OS int open (const ACE_TCHAR *host, u_short port); void close (); ACE_HANDLE handle (void) const; void handle (ACE_HANDLE); protected: // These methods are called by the freamwork /// This is called when asynchronous reads from the socket complete virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); /// This is called when asynchronous writes from the socket complete virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); private: int initiate_read_stream (void); int initiate_write_stream (void); /// Network I/O handle ACE_SOCK_Stream stream_; /// ws (write stream): for writing to the socket ACE_Asynch_Write_Stream ws_; /// rs (read file): for reading from the socket ACE_Asynch_Read_Stream rs_; /// Welcome message ACE_Message_Block welcome_message_; MyMutex m_Mtx ; long nIOCount ; }; static const char *data = "Welcome to Irfan World! Irfan RULES here !!\n"; Sender::Sender (void) :nIOCount ( 0 ) { // Moment of inspiration... :-) this->welcome_message_.init (data, ACE_OS::strlen (data)); } Sender::~Sender (void) { this->close (); } void Sender::close () { this->stream_.close (); } ACE_HANDLE Sender::handle (void) const { return this->stream_.get_handle (); } void Sender::handle (ACE_HANDLE handle) { this->stream_.set_handle (handle); } int Sender::open (const ACE_TCHAR *host, u_short port) { // Initialize stuff // Connect to remote host ACE_INET_Addr address (port, host); ACE_SOCK_Connector connector; if (connector.connect (this->stream_, address) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Connector::connect"), -1); } // Open ACE_Asynch_Write_Stream if (this->ws_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::open"), -1); // Open ACE_Asynch_Read_Stream if (this->rs_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::open"), -1); // Start an asynchronous transmit file if ( this->initiate_write_stream () == -1) return -1; if ( duplex != 0 ) { // Start an asynchronous read file if (this->initiate_read_stream () == -1) return -1; } return 0; } int Sender::initiate_write_stream (void) { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx, -1); welcome_message_.rd_ptr( welcome_message_.base ()); welcome_message_.wr_ptr( welcome_message_.base ()); welcome_message_.wr_ptr (ACE_OS::strlen (data)); if (this->ws_.write (welcome_message_, welcome_message_.length () ) == -1) { ACE_ERROR_RETURN((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::write"), -1); } nIOCount++ ; return 0; } int Sender::initiate_read_stream (void) { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx, -1); // Create a new . Note that this message block will // be used both to data asynchronously from the socket and to // data asynchronously to the file. ACE_DEBUG ((LM_DEBUG, "initiate_read_stream called\n")); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate read if (this->rs_.read (*mb, mb->size ()- 1) == -1) { mb->release () ; ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::read"), -1); } nIOCount++ ; return 0; } void Sender::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_stream called\n")); // Reset pointers. result.message_block ().rd_ptr (result.message_block ().rd_ptr () - result.bytes_transferred ()); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); // Simplify just for Test if (result.success () && result.bytes_transferred () != 0) { if ( duplex != 0 ) // full duplex, continue write { initiate_write_stream () ; } else // half-duplex read reply, after read we will start // write { initiate_read_stream () ; } } { ACE_GUARD_RETURN (MyMutex, locker, m_Mtx); --nIOCount; } } void Sender::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); // Reset pointers. result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); result.message_block().release (); if ( result.success () && result.bytes_transferred () != 0) { // Successful read: write the data to the file asynchronously. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . if ( duplex != 0 ) // full duplex, continue read { initiate_read_stream () ; } else // half-duplex writey, after write we will start read { initiate_write_stream () ; } } { ACE_GUARD (MyMutex, locker, m_Mtx); --nIOCount; } } //-------------------------------------------------------------------------- static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("n:p:d:h:")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'h': host = get_opt.opt_arg (); break; case 'n': nThreads = ACE_OS::atoi (get_opt.opt_arg ()) ; break; case 'p': port = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'd': duplex = ACE_OS::atoi (get_opt.opt_arg ()); break; default: ACE_ERROR ((LM_ERROR, "%p.\n", "usage :\n" "-h for Sender mode\n" "-d \n" "-p \n" "-n \n")); return -1; } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_UNUSED_ARG (initial_read_size); if (parse_args (argc, argv) == -1) return -1; #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) ACE_WIN32_Proactor * pImpl = new ACE_WIN32_Proactor; #elif defined (ACE_HAS_AIO_CALLS) // ACE_POSIX_AIOCB_Proactor * pImpl = new ACE_POSIX_AIOCB_Proactor; ACE_POSIX_SIG_Proactor * pImpl = new ACE_POSIX_SIG_Proactor; #endif ACE_Proactor Proactor ( pImpl ,1 ); ACE_Proactor::instance( & Proactor ); MyTask Task1 ; if (Task1.activate (THR_NEW_LWP, nThreads ) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); } Sender sender; ACE_Asynch_Acceptor acceptor; int Rc = -1 ; if ( host == 0 ) // Acceptor { // Simplify , initial read with zero size Rc = acceptor.open (ACE_INET_Addr (port),0,1); } else { Rc = sender.open (host, port); } if ( Rc == 0 ) { char c ; cout << "Press any key to stop and exit=>\n" << flush ; cin.clear (); cin >> c ; } ACE_Proactor::end_event_loop () ; if ( host != 0 ) // we are sender { sender.close () ; // disconnect to get reciever error !!! } ACE_Thread_Manager * pTM = ACE_Thread_Manager::instance(); pTM->wait_task ( & Task1 ) ; ACE_Proactor::instance( ( ACE_Proactor* )0 ); return 0; } //-------------------------------------------------------------------- // //-------------------------------------------------------------------- int DisableSignal ( int SigNum ) { #ifndef ACE_WIN32 sigset_t signal_set; if ( ACE_OS::sigemptyset (&signal_set) == - 1 ) { ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "sigemptyset failed")); } ACE_OS::sigaddset (&signal_set, SigNum); // Put the . if (ACE_OS::pthread_sigmask (SIG_BLOCK, &signal_set, 0) != 0) { ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "pthread_sigmask failed")); } #else ACE_UNUSED_ARG(SigNum); #endif return 1; } //-------------------------------------------------------------------- // Get the back from the OS. //-------------------------------------------------------------------- int PrintSigMask () { #ifndef ACE_WIN32 sigset_t mask ; int member = 0; COUT ( "\n=============Signal Mask==========" ) if (ACE_OS::pthread_sigmask (SIG_SETMASK, 0, & mask ) != 0) { ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "ACE_OS::pthread_sigmask failed")); } else for (int i = 1 ; i < 1000; i++) { member = ACE_OS::sigismember (&mask,i); COUT ( "\nSig " ) COUT ( i ) COUT ( " is " ) COUT (member ) if (member == -1) { break ; } } #endif return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example does not work on this platform.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_proactor.h0000644000175000017500000000263112576461726024466 0ustar pgquilespgquiles/* ** */ #ifndef _TEST_PROACTOR_H #define _TEST_PROACTOR_H #include "ace/Asynch_IO.h" class Receiver : public ACE_Service_Handler { // = TITLE // The class will be created by when new // connections arrive. This class will then receive data from // the network connection and dump it to a file. public: // = Initialization and termination. Receiver (void); ~Receiver (void); virtual void open (ACE_HANDLE handle, ACE_Message_Block &message_block); // This is called after the new connection has been accepted. protected: // These methods are called by the framework virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); // This is called when asynchronous operation from the socket // complete. virtual void handle_write_file (const ACE_Asynch_Write_File::Result &result); // This is called when an asynchronous to the file // completes. private: int initiate_read_stream (void); // Initiate an asynchronous operation on the socket. ACE_Asynch_Read_Stream rs_; // rs (read stream): for reading from a socket. ACE_HANDLE dump_file_; // File for dumping data. ACE_Asynch_Write_File wf_; // wf (write file): for writing to a file. u_long file_offset_; // Offset for the file. ACE_HANDLE handle_; // Handle for IO to remote peer. }; #endif /* _TEST_PROACTOR_H */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/README0000644000175000017500000000545312576461726022312 0ustar pgquilespgquiles This README file lists all the example applications for the Proactor framework. Test/Example Applications for Proactor: ========================================= The following tests are available. o $ACE_ROOT/tests/Aio_Platform_Test.cpp : Tests basic limits pertaining to the POSIX features o $ACE_ROOT/examples/Reactor/Proactor/test_aiocb.cpp : This is a C++ program for testing the AIOCB (AIO Control Blocks) based completion approach which uses for completion querying. o $ACE_ROOT/examples/Reactor/Proactor/test_aiosig.cpp : This is a C++ program for testing the Signal based completion approach that uses for completion querying. o $ACE_ROOT/examples/Reactor/Proactor/test_aiocb_ace.cpp: Portable version of test_aiocb.cpp. (Same as test_aiocb.cpp, but uses ACE_DEBUGs instead of printf's and ACE_Message_Blocks instead of char*'s. o $ACE_ROOT/examples/Reactor/Proactor/test_aiosig_ace.cpp: Portable version of test_aiosig.cpp. (Same as test_aiosig.cpp, but uses ACE_DEBUGs instead of printf's and ACE_Message_Blocks instead of char*'s. o test_proactor.cpp (with ACE_POSIX_AIOCB_Proactor) : Test for ACE_Proactor which uses AIOCB (AIO Control Blocks) based completions strategy Proactor. (#define ACE_POSIX_AIOCB_PROACTOR in the config file, but this is the default option) o test_proactor.cpp (with ACE_POSIX_SIG_Proactor) : Test for ACE_Proactor which uses real time signal based completion strategy proactor. (#define ACE_POSIX_SIG_PROACTOR in the config file) o test_multiple_loops.cpp : This example application shows how to write programs that combine the Proactor and Reactor event loops. This is possible only on WIN32 platform. o test_timeout.cpp : Multithreaded application testing the Timers mechanism of the Proactor. o test_timeout_st.cpp : Single-threaded version of test_timeout.cpp. o post_completions.cpp : Tests the completion posting mechanism of the Proactor. o test_end_event_loop.cpp : Tests the event loop mechanism of the Proactor. o test_cancel.cpp : Tests interface of the Asynch_Operation class. Behavior of POSIX AIO of various platforms: ========================================== Sun 5.6 : POSIX4 Real-Time signals implementation is broken in this platform. Only POSIX AIOCB Proactor works in this platform. Therefore, it is not possible to use multiple threads with in the framework. Sun 5.7 : AIOCB and SIG Proactors work fine. LynxOS 3.0.0 : is not available in this platform. So, only AIOCB Proactor works here. ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/Proactor.mpc0000644000175000017500000000227612576461726023724 0ustar pgquilespgquiles// -*- MPC -*- project(*cancel) : aceexe, avoids_ace_for_tao { exename = test_cancel Source_Files { test_cancel.cpp } } project(*end_event_loops) : aceexe, avoids_ace_for_tao { exename = test_end_event_loop Source_Files { test_end_event_loop.cpp } } project(*multiple_loops) : aceexe, avoids_ace_for_tao { exename = test_multiple_loops Source_Files { test_multiple_loops.cpp } } project(*post_completions) : aceexe, avoids_ace_for_tao { exename = test_post_completions Source_Files { post_completions.cpp } } project(*proactor) : aceexe, avoids_ace_for_tao { exename = test_proactor Source_Files { test_proactor.cpp } } // project(*proactor2) : aceexe, avoids_ace_for_tao { // exename = test_proactor2 // Source_Files { // test_proactor2.cpp // } // } // project(*proactor3) : aceexe, avoids_ace_for_tao { // exename = test_proactor3 // Source_Files { // test_proactor3.cpp // } // } project(*timeout) : aceexe, avoids_ace_for_tao { exename = test_timeout Source_Files { test_timeout.cpp } } project(*udp_proactor) : aceexe, avoids_ace_for_tao { exename = test_udp_proactor Source_Files { test_udp_proactor.cpp } } ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_proactor3.cpp0000644000175000017500000005622612576461726025115 0ustar pgquilespgquiles //============================================================================= /** * @file test_proactor3.cpp * * This program illustrates how the can be used to * implement an application that does various asynchronous * operations. * * @author Irfan Pyarali modified by Alexander Libman from original test_proactor.cpp */ //============================================================================= #include "ace/Signal.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Asynch_Acceptor.h" #include "ace/INET_Addr.h" #include "ace/Manual_Event.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" // FUZZ: disable check_for_streams_include #include "ace/streams.h" #include "ace/Task.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms // supporting POSIX aio calls. #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) #include "ace/WIN32_Proactor.h" #elif defined (ACE_HAS_AIO_CALLS) #include "ace/POSIX_Proactor.h" #include "ace/SUN_Proactor.h" #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ // Some debug helper functions static int disable_signal (int sigmin, int sigmax); #if 0 static int print_sigmask (void); #endif #define COUT(X) cout << X; cout.flush (); // Proactor Type (UNIX only, Win32 ignored) 0-default, 1 -AIOCB, // 2-SIG, 3-SUN static int proactor_type = 0; // POSIX : > 0 max number aio operations proactor, static int max_aio_operations = 0; // Host that we're connecting to. static ACE_TCHAR *host = 0; // number of Senders instances static int senders = 1; static const int MaxSenders = 100; // duplex mode: ==0 half-duplex // !=0 full duplex static int duplex = 0; // number threads in the Proactor thread pool static int threads = 1; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; /** * @class MyTask: * * @brief MyTask plays role for Proactor threads pool */ class MyTask: public ACE_Task { public: MyTask (void) : threads_ (0), proactor_ (0) {} int svc (void); void waitready (void) { event_.wait (); } private: ACE_Recursive_Thread_Mutex mutex_; int threads_; ACE_Proactor *proactor_; ACE_Manual_Event event_; void create_proactor (void); void delete_proactor (void); }; void MyTask::create_proactor (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); if (threads_ == 0) { #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) ACE_WIN32_Proactor *proactor = new ACE_WIN32_Proactor; ACE_DEBUG ((LM_DEBUG,"(%t) Create Proactor Type=WIN32")); #elif defined (ACE_HAS_AIO_CALLS) ACE_POSIX_Proactor *proactor = 0; switch (proactor_type) { case 1: proactor = new ACE_POSIX_AIOCB_Proactor (max_aio_operations); ACE_DEBUG ((LM_DEBUG,"(%t) Create Proactor Type=AIOCB\n")); break; case 2: proactor = new ACE_POSIX_SIG_Proactor; ACE_DEBUG ((LM_DEBUG,"(%t) Create Proactor Type=SIG\n")); break; # if defined (sun) case 3: proactor = new ACE_SUN_Proactor (max_aio_operations); ACE_DEBUG ((LM_DEBUG,"(%t) Create Proactor Type=SUN\n")); break; # endif /* sun */ default: proactor = new ACE_POSIX_SIG_Proactor; ACE_DEBUG ((LM_DEBUG,"(%t) Create Proactor Type=SIG\n")); break; } #endif proactor_ = new ACE_Proactor (proactor, 1); ACE_Proactor::instance(proactor_); event_.signal (); } threads_++; } void MyTask::delete_proactor (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); if (--threads_ == 0) { ACE_DEBUG ((LM_DEBUG, "(%t) Delete Proactor\n")); ACE_Proactor::instance ((ACE_Proactor *) 0); delete proactor_; proactor_ = 0; } } int MyTask::svc (void) { ACE_DEBUG ((LM_DEBUG, "(%t) MyTask started\n")); create_proactor (); disable_signal (ACE_SIGRTMIN, ACE_SIGRTMAX); while (ACE_Proactor::event_loop_done () == 0) ACE_Proactor::run_event_loop (); delete_proactor (); ACE_DEBUG ((LM_DEBUG, "(%t) MyTask finished\n")); return 0; } class Receiver : public ACE_Service_Handler { public: Receiver (void); ~Receiver (void); //FUZZ: disable check_for_lack_ACE_OS /// This is called after the new connection has been accepted. ///FUZZ: enable check_for_lack_ACE_OS virtual void open (ACE_HANDLE handle, ACE_Message_Block &message_block); static long get_number_sessions (void) { return sessions_; } protected: // These methods are called by the framework /// This is called when asynchronous operation from the socket /// complete. virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); /// This is called when an asynchronous to the file /// completes. virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); private: int initiate_read_stream (void); int initiate_write_stream (ACE_Message_Block & mb, int nBytes); int check_destroy (void); ACE_Asynch_Read_Stream rs_; ACE_Asynch_Write_Stream ws_; ACE_HANDLE handle_; ACE_Recursive_Thread_Mutex mutex_; long io_count_; static long sessions_; }; long Receiver::sessions_ = 0; Receiver::Receiver (void) : handle_ (ACE_INVALID_HANDLE), io_count_ (0) { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); sessions_++; ACE_DEBUG ((LM_DEBUG, "Receiver Ctor sessions_=%d\n", sessions_)); } Receiver::~Receiver (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); sessions_--; ACE_OS::closesocket (this->handle_); ACE_DEBUG ((LM_DEBUG, "~Receiver Dtor sessions_=%d\n", sessions_)); } // return true if we alive, false we commited suicide int Receiver::check_destroy (void) { { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, locker, mutex_, -1); if (io_count_ > 0) return 1; } delete this; return 0; } void Receiver::open (ACE_HANDLE handle, ACE_Message_Block &) { ACE_DEBUG ((LM_DEBUG, "%N:%l:Receiver::open called\n")); this->handle_ = handle; if (this->ws_.open (*this, this->handle_) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::open")); else if (this->rs_.open (*this, this->handle_) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::open")); else initiate_read_stream (); check_destroy (); } int Receiver::initiate_read_stream (void) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, locker, mutex_, -1); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate read if (this->rs_.read (*mb, mb->size ()- 1) == -1) { mb->release (); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::read"), -1); } io_count_++; return 0; } int Receiver::initiate_write_stream (ACE_Message_Block &mb, int nbytes) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, locker, mutex_, -1); if (nbytes <= 0) { mb.release (); ACE_ERROR_RETURN((LM_ERROR, "ACE_Asynch_Write_Stream::write nbytes <0 "), -1); } if (this->ws_.write (mb, nbytes) == -1) { mb.release (); ACE_ERROR_RETURN((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::write"), -1); } io_count_++; return 0; } void Receiver::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { // Reset pointers. result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; if (result.bytes_transferred () == 0 || result.error () != 0) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); } if (result.success () && result.bytes_transferred () != 0) { // Successful read: write the data to the file asynchronously. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . if(this->initiate_write_stream (result.message_block (), result.bytes_transferred ()) == 0) { if (duplex != 0) { // Initiate new read from the stream. this->initiate_read_stream (); } } } else { result.message_block ().release (); ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); } { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); --io_count_; } check_destroy (); } void Receiver::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { if (result.bytes_transferred () == 0 || result.error () != 0) { ACE_DEBUG ((LM_DEBUG, "handle_write_stream called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); } result.message_block ().release (); if (result.success () && result.bytes_transferred () != 0) { // This code is not robust enough to deal with short file writes // (which hardly ever happen);-) // ACE_ASSERT (result.bytes_to_write () == result.bytes_transferred ()); if (duplex == 0) initiate_read_stream (); } { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); --io_count_; } check_destroy (); } /** * @class Sender * * @brief Sends welcome messages receives them back. */ class Sender : public ACE_Handler { public: Sender (void); ~Sender (void); //FUZZ: disable check_for_lack_ACE_OS ///FUZZ: enable check_for_lack_ACE_OS int open (const ACE_TCHAR *host, u_short port); void close (void); ACE_HANDLE handle (void) const; virtual void handle (ACE_HANDLE); protected: // These methods are called by the freamwork /// This is called when asynchronous reads from the socket complete virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); /// This is called when asynchronous writes from the socket complete virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); private: int initiate_read_stream (void); int initiate_write_stream (void); /// Network I/O handle ACE_SOCK_Stream stream_; /// ws (write stream): for writing to the socket ACE_Asynch_Write_Stream ws_; /// rs (read file): for reading from the socket ACE_Asynch_Read_Stream rs_; /// Welcome message ACE_Message_Block welcome_message_; ACE_Recursive_Thread_Mutex mutex_; long io_count_; }; static const char *data = "Welcome to Irfan World! Irfan RULES here !!\n"; Sender::Sender (void) : io_count_ (0) { // Moment of inspiration... :-) this->welcome_message_.init (data, ACE_OS::strlen (data)); } Sender::~Sender (void) { this->close (); } void Sender::close (void) { this->stream_.close (); } ACE_HANDLE Sender::handle (void) const { return this->stream_.get_handle (); } void Sender::handle (ACE_HANDLE handle) { this->stream_.set_handle (handle); } int Sender::open (const ACE_TCHAR *host, u_short port) { // Initialize stuff // Connect to remote host ACE_INET_Addr address (port, host); ACE_SOCK_Connector connector; if (connector.connect (this->stream_, address) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Connector::connect"), -1); } // Open ACE_Asynch_Write_Stream if (this->ws_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::open"), -1); // Open ACE_Asynch_Read_Stream if (this->rs_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::open"), -1); // Start an asynchronous transmit file if (this->initiate_write_stream () == -1) return -1; if (duplex != 0) // Start an asynchronous read file if (this->initiate_read_stream () == -1) return -1; return 0; } int Sender::initiate_write_stream (void) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, locker, mutex_, -1); welcome_message_.rd_ptr(welcome_message_.base ()); welcome_message_.wr_ptr(welcome_message_.base ()); welcome_message_.wr_ptr (ACE_OS::strlen (data)); if (this->ws_.write (welcome_message_, welcome_message_.length ()) == -1) ACE_ERROR_RETURN((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::write"), -1); io_count_++; return 0; } int Sender::initiate_read_stream (void) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, locker, mutex_, -1); // Create a new . Note that this message block will // be used both to data asynchronously from the socket and to // data asynchronously to the file. ACE_DEBUG ((LM_DEBUG, "initiate_read_stream called\n")); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate read if (this->rs_.read (*mb, mb->size ()- 1) == -1) { mb->release (); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::read"), -1); } io_count_++; return 0; } void Sender::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { if (result.bytes_transferred () == 0 || result.error () != 0) { ACE_DEBUG ((LM_DEBUG, "handle_write_stream called\n")); // Reset pointers. result.message_block ().rd_ptr (result.message_block ().rd_ptr () - result.bytes_transferred ()); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); } // Simplify just for Test if (result.success () && result.bytes_transferred () != 0) { if (duplex != 0) // full duplex, continue write initiate_write_stream (); else // half-duplex read reply, after read we will start write initiate_read_stream (); } { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); --io_count_; } } void Sender::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { if (result.bytes_transferred () == 0 || result.error () != 0) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); // Reset pointers. result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); } result.message_block().release (); if (result.success () && result.bytes_transferred () != 0) { // Successful read: write the data to the file asynchronously. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . if (duplex != 0) // full duplex, continue read initiate_read_stream (); else // half-duplex writey, after write we will start read initiate_write_stream (); } { ACE_GUARD (ACE_Recursive_Thread_Mutex, locker, mutex_); --io_count_; } } static int set_proactor_type (const char *ptype) { if (!ptype) return false; switch (ACE_OS::ace_toupper (*ptype)) { case 'D' : proactor_type = 0; return true; case 'A' : proactor_type = 1; return true; case 'I' : proactor_type = 2; return true; #if defined (sun) case 'S' : proactor_type = 3; return true; #endif /* sun */ } return false; } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("t:o:n:p:d:h:s:u")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'd': // duplex duplex = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'h': // host for sender host = get_opt.opt_arg (); break; case 'p': // port number port = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'n': // thread pool size threads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 's': // number of senders senders = ACE_OS::atoi (get_opt.opt_arg ()); if (senders > MaxSenders) senders = MaxSenders; break; case 'o': // max number of aio for proactor max_aio_operations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 't': // Proactor Type if (set_proactor_type (get_opt.opt_arg ())) break; case 'u': default: ACE_ERROR ((LM_ERROR, "%p.", "\nusage:" "\n-o " "\n-t UNIX-only, Win32-default always:" "\n a AIOCB" "\n i SIG" "\n s SUN" "\n d default" "\n-d " "\n-h for Sender mode" "\n-n " "\n-p " "\n-s " "\n-u show this message" "\n")); return -1; } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { #if defined (sun) ACE_DEBUG ((LM_DEBUG, "\nSUN defined!\n")); #endif if (parse_args (argc, argv) == -1) return -1; disable_signal (ACE_SIGRTMIN, ACE_SIGRTMAX); MyTask task1; if (task1.activate (THR_NEW_LWP, threads) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); // wait for creation of Proactor task1.waitready (); Sender * send_list[MaxSenders]; ACE_Asynch_Acceptor acceptor; int rc = -1; int i; char c; if (host == 0) // Acceptor { // Simplify, initial read with zero size if (acceptor.open (ACE_INET_Addr (port),0,1) == 0) rc = 1; } else { for (i = 0; i < senders; ++i) send_list[i] = new Sender; for (i = 0; i < senders; ++i) if (send_list[i]->open (host, port) == 0) rc++; } if (rc > 0) { cout << "Press any key to stop=>" << flush; cin.clear (); cin >> c; } ACE_Proactor::end_event_loop (); if (host != 0) // we are sender { for (i = 0; i < senders; ++i) send_list[i]->close (); } ACE_Thread_Manager *tm = ACE_Thread_Manager::instance(); tm->wait_task (&task1); cout << "\nNumber of Receivers objects=" << Receiver::get_number_sessions () << flush; for (i = 0; i < senders; ++i) { delete (send_list[i]); send_list[i] = 0; } return 0; } static int disable_signal (int sigmin, int sigmax) { #ifndef ACE_WIN32 sigset_t signal_set; if (ACE_OS::sigemptyset (&signal_set) == - 1) ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "sigemptyset failed")); for (int i = sigmin; i <= sigmax; i++) ACE_OS::sigaddset (&signal_set, i); // Put the . if (ACE_OS::pthread_sigmask (SIG_BLOCK, &signal_set, 0) != 0) ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "pthread_sigmask failed")); #else ACE_UNUSED_ARG (sigmin); ACE_UNUSED_ARG (sigmax); #endif /* ACE_WIN32 */ return 1; } // Get the back from the OS. #if 0 static int print_sigmask (void) { #ifndef ACE_WIN32 sigset_t mask; int member = 0; COUT ("\n=============Signal Mask==========") if (ACE_OS::pthread_sigmask (SIG_SETMASK, 0, & mask) != 0) ACE_ERROR ((LM_ERROR, "Error:(%P | %t):%p\n", "ACE_OS::pthread_sigmask failed")); else for (int i = 1; i < 1000; i++) { member = ACE_OS::sigismember (&mask,i); COUT ("\nSig ") COUT (i) COUT (" is ") COUT (member) if (member == -1) break; } #endif /* ACE_WIN32 */ return 0; } #endif /* 0 */ #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example does not work on this platform.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_aiosig.cpp0000644000175000017500000001705612576461726024452 0ustar pgquilespgquiles//============================================================================= /** * @file test_aiosig.cpp * * Check out test_aiosig_ace.cpp, the ACE'ified version of this * program. This program may not be uptodate. * CC -g -o test_aiosig -lrt test_aiosig.cpp * ./test_aiosig * * @author Programming for the Real World. Bill O. GallMeister. Modified by Alexander Babu Arulanthu */ //============================================================================= //FUZZ: disable check_for_lack_ACE_OS //FUZZ: disable check_for_improper_main_declaration #include #include #include #include #include #include #include #include #include #include #include int file_handle = -1; char mb1 [BUFSIZ + 1]; char mb2 [BUFSIZ + 1]; aiocb aiocb1, aiocb2; sigset_t completion_signal; // Function prototypes. int setup_signal_delivery (void); int issue_aio_calls (void); int query_aio_completions (void); int test_aio_calls (void); int setup_signal_handler (void); int setup_signal_handler (int signal_number); int setup_signal_delivery (void) { // Make the sigset_t consisting of the completion signal. if (sigemptyset (&completion_signal) == -1) { perror ("Error:Couldnt init the RT completion signal set\n"); return -1; } if (sigaddset (&completion_signal, SIGRTMIN) == -1) { perror ("Error:Couldnt init the RT completion signal set\n"); return -1; } // Mask them. if (pthread_sigmask (SIG_BLOCK, &completion_signal, 0) == -1) { perror ("Error:Couldnt maks the RT completion signals\n"); return -1; } return setup_signal_handler (SIGRTMIN); } int issue_aio_calls (void) { // Setup AIOCB. aiocb1.aio_fildes = file_handle; aiocb1.aio_offset = 0; aiocb1.aio_buf = mb1; aiocb1.aio_nbytes = BUFSIZ; aiocb1.aio_reqprio = 0; aiocb1.aio_sigevent.sigev_notify = SIGEV_SIGNAL; aiocb1.aio_sigevent.sigev_signo = SIGRTMIN; aiocb1.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb1; // Fire off the aio write. if (aio_read (&aiocb1) == -1) { // Queueing failed. perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n"); return -1; } // Setup AIOCB. aiocb2.aio_fildes = file_handle; aiocb2.aio_offset = BUFSIZ + 1; aiocb2.aio_buf = mb2; aiocb2.aio_nbytes = BUFSIZ; aiocb2.aio_reqprio = 0; aiocb2.aio_sigevent.sigev_notify = SIGEV_SIGNAL; aiocb2.aio_sigevent.sigev_signo = SIGRTMIN; aiocb2.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb2; // Fire off the aio write. if (aio_read (&aiocb2) == -1) { // Queueing failed. perror ("Error:Asynch_Read_Stream: aio_read queueing failed\n"); return -1; } return 0; } int query_aio_completions (void) { size_t number_of_compleions = 0; for (number_of_compleions = 0; number_of_compleions < 2; number_of_compleions ++) { // Wait for amount of time. // @@ Assigning to tv_sec. timespec timeout; timeout.tv_sec = INT_MAX; timeout.tv_nsec = 0; // To get back the signal info. siginfo_t sig_info; // Await the RT completion signal. int sig_return = sigtimedwait (&completion_signal, &sig_info, &timeout); // Error case. // If failure is coz of timeout, then return *0* but set // errno appropriately. This is what the WinNT proactor // does. if (sig_return == -1) { perror ("Error:Error waiting for RT completion signals\n"); return -1; } // RT completion signals returned. if (sig_return != SIGRTMIN) { printf ("Unexpected signal (%d) has been received while waiting for RT Completion Signals\n", sig_return); return -1; } // @@ Debugging. printf ("Sig number found in the sig_info block : %d\n", sig_info.si_signo); // Is the signo returned consistent? if (sig_info.si_signo != sig_return) { printf ("Inconsistent signal number (%d) in the signal info block\n", sig_info.si_signo); return -1; } // @@ Debugging. printf ("Signal code for this signal delivery : %d\n", sig_info.si_code); // Is the signal code an aio completion one? if ((sig_info.si_code != SI_ASYNCIO) && (sig_info.si_code != SI_QUEUE)) { printf ("Unexpected signal code (%d) returned on completion querying\n", sig_info.si_code); return -1; } // Retrive the aiocb. aiocb* aiocb_ptr = (aiocb *) sig_info.si_value.sival_ptr; // Analyze error and return values. Return values are // actually 's associated with the call // corresponding to aiocb_ptr. int error_code = aio_error (aiocb_ptr); if (error_code == -1) { perror ("Error:Invalid control block was sent to for compleion querying\n"); return -1; } if (error_code != 0) { // Error occurred in the call. Return the errno // corresponding to that call. printf ("Error:An AIO call has failed:Error code = %d\n", error_code); return -1; } // No error occured in the AIO operation. int nbytes = aio_return (aiocb_ptr); if (nbytes == -1) { perror ("Error:Invalid control block was send to \n"); return -1; } if (number_of_compleions == 0) // Print the buffer. printf ("Number of bytes transferred : %d\n The buffer : %s\n", nbytes, mb1); else // Print the buffer. printf ("Number of bytes transferred : %d\n The buffer : %s\n", nbytes, mb2); } return 0; } int test_aio_calls (void) { // Set up the input file. // Open file (in SEQUENTIAL_SCAN mode) file_handle = open ("test_aiosig.cpp", O_RDONLY); if (file_handle == -1) { perror ("Error:Opening the inputfile"); return -1; } if (setup_signal_delivery () < 0) return -1; if (issue_aio_calls () < 0) return -1; if (query_aio_completions () < 0) return -1; return 0; } void null_handler (int /* signal_number */, siginfo_t * /* info */, void * /* context */) { } int setup_signal_handler (int signal_number) { // Setting up the handler(!) for these signals. struct sigaction reaction; sigemptyset (&reaction.sa_mask); // Nothing else to mask. reaction.sa_flags = SA_SIGINFO; // Realtime flag. #if defined (SA_SIGACTION) // Lynx says, it is better to set this bit to be portable. reaction.sa_flags &= SA_SIGACTION; #endif /* SA_SIGACTION */ reaction.sa_sigaction = null_handler; // Null handler. int sigaction_return = sigaction (SIGRTMIN, &reaction, 0); if (sigaction_return == -1) { perror ("Error:Proactor couldnt do sigaction for the RT SIGNAL"); return -1; } return 0; } int main (int, char *[]) { if (test_aio_calls () == 0) printf ("RT SIG test successful:\n" "ACE_POSIX_SIG_PROACTOR should work in this platform\n"); else printf ("RT SIG test failed:\n" "ACE_POSIX_SIG_PROACTOR may not work in this platform\n"); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/simple_test_proactor.cpp0000644000175000017500000001672712576461726026405 0ustar pgquilespgquiles //============================================================================= /** * @file simple_test_proactor.cpp * * Very simple version of test_proactor.cpp. * * @author Alexander Babu Arulanthu (alex@cs.wustl.edu) */ //============================================================================= #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. static ACE_TCHAR *file = ACE_TEXT("simple_test_proactor.cpp"); static ACE_TCHAR *dump_file = ACE_TEXT("simple_output"); /** * @class Simple_Tester * * @brief Simple_Tester * * The class will be created by main(). This class reads a block * from the file and write that to the dump file. */ class Simple_Tester : public ACE_Handler { public: /// Constructor. Simple_Tester (void); ~Simple_Tester (void); //FUZZ: disable check_for_lack_ACE_OS /// Open the operations and initiate read from the file. ///FUZZ: enble check_for_lack_ACE_OS int open (void); protected: // = These methods are called by the freamwork. /// This is called when asynchronous reads from the socket complete. virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result); /// This is called when asynchronous writes from the socket complete. virtual void handle_write_file (const ACE_Asynch_Write_File::Result &result); private: int initiate_read_file (void); /// rf (read file): for writing from the file. ACE_Asynch_Read_File rf_; /// ws (write File): for writing to the file. ACE_Asynch_Write_File wf_; /// File to read from. ACE_HANDLE input_file_; /// File for dumping data. ACE_HANDLE dump_file_; // u_long file_offset_; // Current file offset // u_long file_size_; // File size }; Simple_Tester::Simple_Tester (void) : input_file_ (ACE_INVALID_HANDLE), dump_file_ (ACE_INVALID_HANDLE) { } Simple_Tester::~Simple_Tester (void) { ACE_OS::close (this->input_file_); ACE_OS::close (this->dump_file_); } int Simple_Tester::open (void) { // Initialize stuff // Open input file (in OVERLAPPED mode) this->input_file_ = ACE_OS::open (file, GENERIC_READ | FILE_FLAG_OVERLAPPED); if (this->input_file_ == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1); // Open dump file (in OVERLAPPED mode) this->dump_file_ = ACE_OS::open (dump_file, O_CREAT | O_RDWR | O_TRUNC | FILE_FLAG_OVERLAPPED, 0644); if (this->dump_file_ == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1); // Open ACE_Asynch_Read_File if (this->rf_.open (*this, this->input_file_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::open"), -1); // Open ACE_Asynch_Write_File if (this->wf_.open (*this, this->dump_file_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::open"), -1); ACE_DEBUG ((LM_DEBUG, "Simple_Tester::open: Files and Asynch Operations opened successfully\n")); // Start an asynchronous read file if (this->initiate_read_file () == -1) return -1; return 0; } int Simple_Tester::initiate_read_file (void) { // Create Message_Block ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate an asynchronous read from the file if (this->rf_.read (*mb, mb->size () - 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::read"), -1); ACE_DEBUG ((LM_DEBUG, "Simple_Tester:initiate_read_file: Asynch Read File issued successfully\n")); return 0; } void Simple_Tester::handle_read_file (const ACE_Asynch_Read_File::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_file called\n")); result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); // Watch out if you need to enable this... the ACE_Log_Record::MAXLOGMSGLEN // value controls to max length of a log record, and a large output // buffer may smash it. #if 0 ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); #endif /* 0 */ if (result.success ()) { // Read successful: write this to the file. if (this->wf_.write (result.message_block (), result.bytes_transferred ()) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::write")); return; } } } void Simple_Tester::handle_write_file (const ACE_Asynch_Write_File::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_File called\n")); // Reset pointers result.message_block ().rd_ptr (result.message_block ().rd_ptr () - result.bytes_transferred ()); result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (u_long) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (u_long) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); // Watch out if you need to enable this... the ACE_Log_Record::MAXLOGMSGLEN // value controls to max length of a log record, and a large output // buffer may smash it. #if 0 ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); #endif /* 0 */ ACE_Proactor::end_event_loop (); } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("f:d:")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'f': file = get_opt.opt_arg (); break; case 'd': dump_file = get_opt.opt_arg (); break; default: ACE_ERROR ((LM_ERROR, "%p.\n", "usage :\n" "-d \n" "-f \n")); return -1; } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; Simple_Tester Simple_Tester; if (Simple_Tester.open () == -1) return -1; int success = 1; // dispatch events success = !(ACE_Proactor::run_event_loop () == -1); return success ? 0 : 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_cancel.h0000644000175000017500000000203612576461726024061 0ustar pgquilespgquiles/* ** */ #ifndef _TEST_CANCEL_H #define _TEST_CANCEL_H #include "ace/Asynch_IO.h" class Receiver : public ACE_Service_Handler { // = TITLE // // Receiver // // = DESCRIPTION // // The class will be created by ACE_Asynch_Acceptor when new // connections arrive. This class will then receive data from // the network connection and dump it to a file. public: Receiver (void); ~Receiver (void); virtual void open (ACE_HANDLE handle, ACE_Message_Block &message_block); // This is called after the new connection has been accepted. protected: // These methods are called by the framework virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); // This is called when asynchronous read from the socket complete private: ACE_Asynch_Read_Stream rs_; // rs (read stream): for reading from a socket ACE_Message_Block mb_; // Message block to read from the stream. ACE_HANDLE handle_; // Handle for IO to remote peer }; #endif /* _TEST_CANCEL_H */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/Aio_Platform_Test_C.cpp0000644000175000017500000000656412576461726025757 0ustar pgquilespgquiles//============================================================================= /** * @file Aio_Platform_Test_C.cpp * * Testing the platform for POSIX Asynchronous I/O. This is the C * version of the $ACE_ROOT/tests/Aio_Platform_Test.cpp. Useful * to send bug reports. * * @author Programming for the Real World. Bill O. GallMeister. Modified by Alexander Babu Arulanthu */ //============================================================================= #include #include #include #include #include #include #include #include #include #include int do_sysconf (void); int have_asynchio (void); static int file_handle = -1; char mb1 [BUFSIZ + 1]; char mb2 [BUFSIZ + 1]; aiocb aiocb1, aiocb2; sigset_t completion_signal; // For testing the stuff. int test_aio_calls (void); int issue_aio_calls (void); int query_aio_completions (void); int setup_signal_delivery (void); int do_sysconf (void); int have_asynchio (void); int do_sysconf (void) { // Call sysconf to find out runtime values. errno = 0; #if defined (_SC_LISTIO_AIO_MAX) printf ("Runtime value of LISTIO_AIO_MAX is %d, errno = %d\n", sysconf(_SC_LISTIO_AIO_MAX), errno); #else printf ("Runtime value of AIO_LISTIO_MAX is %d, errno = %d\n", sysconf(_SC_AIO_LISTIO_MAX), errno); #endif errno = 0; printf ("Runtime value of AIO_MAX is %d, errno = %d\n", sysconf (_SC_AIO_MAX), errno); errno = 0; printf ("Runtime value of _POSIX_ASYNCHRONOUS_IO is %d, errno = %d\n", sysconf (_SC_ASYNCHRONOUS_IO), errno); errno = 0; printf ("Runtime value of _POSIX_REALTIME_SIGNALS is %d, errno = %d\n", sysconf (_SC_REALTIME_SIGNALS), errno); errno = 0; printf ("Runtime value of RTSIG_MAX %d, Errno = %d\n", sysconf (_SC_RTSIG_MAX), errno); errno = 0; printf ("Runtime value of SIGQUEUE_MAX %d, Errno = %d\n", sysconf (_SC_SIGQUEUE_MAX), errno); return 0; } int have_asynchio (void) { #if defined (_POSIX_ASYNCHRONOUS_IO) // POSIX Asynch IO is present in this system. #if defined (_POSIX_ASYNC_IO) // If this is defined and it is not -1, POSIX_ASYNCH is supported // everywhere in the system. #if _POSIX_ASYNC_IO == -1 printf ("_POSIX_ASYNC_IO = -1.. ASYNCH IO NOT supported at all\n"); return -1; #else /* Not _POSIX_ASYNC_IO == -1 */ printf ("_POSIX_ASYNC_IO = %d\n ASYNCH IO is supported FULLY\n", _POSIX_ASYNC_IO); #endif /* _POSIX_ASYNC_IO == -1 */ #else /* Not defined _POSIX_ASYNC_IO */ printf ("_POSIX_ASYNC_IO is not defined.\n"); printf ("AIO might *not* be supported on some paths\n"); #endif /* _POSIX_ASYNC_IO */ // System defined POSIX Values. printf ("System claims to have POSIX_ASYNCHRONOUS_IO\n"); printf ("_POSIX_AIO_LISTIO_MAX = %d\n", _POSIX_AIO_LISTIO_MAX); printf ("_POSIX_AIO_MAX = %d\n", _POSIX_AIO_MAX); // Check and print the run time values. do_sysconf (); return 0; #else /* Not _POSIX_ASYNCHRONOUS_IO */ printf ("No support._POSIX_ASYNCHRONOUS_IO itself is not defined\n"); return -1; #endif /* _POSIX_ASYNCHRONOUS_IO */ } int ACE_TMAIN (int, ACE_TCHAR *[]) { if (have_asynchio () == 0) printf ("Test successful\n"); else printf ("Test not successful\n"); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_timeout_st.cpp0000644000175000017500000000513112576461726025362 0ustar pgquilespgquiles //============================================================================= /** * @file test_timeout_st.cpp * * This example application shows how to write event loops that * handle events for some fixed amount of time. This is the single * threaded version of the test_timeout.cpp application. * * @author Irfan Pyarali and Alexander Babu Arulanthu */ //============================================================================= #include "ace/Proactor.h" #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. /** * @class Timeout_Handler * * @brief Generic timeout handler. */ class Timeout_Handler : public ACE_Handler { public: Timeout_Handler (void) : count_ (0), start_time_ (ACE_OS::gettimeofday ()) { } virtual void handle_time_out (const ACE_Time_Value &tv, const void *arg) { // Print out when timeouts occur. ACE_DEBUG ((LM_DEBUG, "(%t) %d timeout occurred for %s @ %d.\n", ++count_, (char *) arg, (tv - this->start_time_).sec ())); } private: /// Sequence number for the timeouts. int count_; /// Starting time of the test. ACE_Time_Value start_time_; }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Timeout_Handler handler; // Register a 2 second timer. ACE_Time_Value foo_tv (2); if (ACE_Proactor::instance ()->schedule_timer (handler, (void *) "Foo", ACE_Time_Value::zero, foo_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); // Register a 3 second timer. ACE_Time_Value bar_tv (3); if (ACE_Proactor::instance ()->schedule_timer (handler, (void *) "Bar", ACE_Time_Value::zero, bar_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); // Handle events for 13 seconds. ACE_Time_Value run_time (13); ACE_DEBUG ((LM_DEBUG, "Starting event loop\n")); // Run the event loop. if (ACE_Proactor::run_event_loop(run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t):%p.\n", "Worker::svc"), 1); ACE_DEBUG ((LM_DEBUG, "Ending event loop\n")); return 0; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_proactor.cpp0000644000175000017500000005121612576461726025024 0ustar pgquilespgquiles //============================================================================= /** * @file test_proactor.cpp * * This program illustrates how the can be used to * implement an application that does various asynchronous * operations. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_NS_string.h" #include "ace/OS_main.h" #include "ace/Service_Config.h" #include "ace/Proactor.h" #include "ace/Asynch_IO.h" #include "ace/Asynch_IO_Impl.h" #include "ace/Asynch_Acceptor.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/SOCK_Stream.h" #include "ace/Message_Block.h" #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" #include "ace/Truncate.h" #include "ace/OS_NS_sys_stat.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS) // This only works on Win32 platforms and on Unix platforms supporting // POSIX aio calls. #include "test_proactor.h" // Host that we're connecting to. static ACE_TCHAR *host = 0; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; // File that we're sending. static const ACE_TCHAR *file = ACE_TEXT("test_proactor.cpp"); // Name of the output file. static const ACE_TCHAR *dump_file = ACE_TEXT("output"); // Keep track of when we're done. static int done = 0; // Size of each initial asynchronous operation. static int initial_read_size = BUFSIZ; Receiver::Receiver (void) : dump_file_ (ACE_INVALID_HANDLE), handle_ (ACE_INVALID_HANDLE) { } Receiver::~Receiver (void) { ACE_OS::close (this->dump_file_); ACE_OS::closesocket (this->handle_); } void Receiver::open (ACE_HANDLE handle, ACE_Message_Block &message_block) { ACE_DEBUG ((LM_DEBUG, "%N:%l:Receiver::open called\n")); // New connection, so initiate stuff. // Cache the new connection this->handle_ = handle; // File offset starts at zero this->file_offset_ = 0; // Open dump file (in OVERLAPPED mode) this->dump_file_ = ACE_OS::open (dump_file, O_CREAT | O_RDWR | O_TRUNC | \ FILE_FLAG_OVERLAPPED); if (this->dump_file_ == ACE_INVALID_HANDLE) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_OS::open")); return; } // Initiate . if (this->wf_.open (*this, this->dump_file_) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::open")); return; } // Initiate . if (this->rs_.open (*this, this->handle_) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::open")); return; } // Fake the result and make the get // called. But, not, if there is '0' is transferred. if (message_block.length () != 0) { // Duplicate the message block so that we can keep it around. ACE_Message_Block &duplicate = *message_block.duplicate (); // Fake the result so that we will get called back. ACE_Asynch_Read_Stream_Result_Impl *fake_result = ACE_Proactor::instance ()->create_asynch_read_stream_result (this->proxy (), this->handle_, duplicate, initial_read_size, 0, ACE_INVALID_HANDLE, 0, 0); size_t bytes_transferred = message_block.length (); // for Accept would have already moved the // forward. Update it to the beginning position. duplicate.wr_ptr (duplicate.wr_ptr () - bytes_transferred); // This will call the callback. fake_result->complete (message_block.length (), 1, 0); // Zap the fake result. delete fake_result; } else // Otherwise, make sure we proceed. Initiate reading the socket // stream. if (this->initiate_read_stream () == -1) return; } int Receiver::initiate_read_stream (void) { // Create a new . Note that this message block will // be used both to data asynchronously from the socket and to // data asynchronously to the file. ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate read if (this->rs_.read (*mb, mb->size () - 1) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_Stream::read"), -1); return 0; } void Receiver::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_stream called\n")); // Reset pointers. result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); #if 0 // This can overrun the ACE_Log_Msg buffer and do bad things. // Re-enable it at your risk. ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); #endif /* 0 */ if (result.success () && result.bytes_transferred () != 0) { // Successful read: write the data to the file asynchronously. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . if (this->wf_.write (result.message_block (), result.bytes_transferred (), this->file_offset_) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_File::write")); return; } // Initiate new read from the stream. if (this->initiate_read_stream () == -1) return; } else { ACE_DEBUG ((LM_DEBUG, "Receiver completed\n")); // No need for this message block anymore. result.message_block ().release (); // Note that we are done with the test. done = 1; // We are done: commit suicide. delete this; } } void Receiver::handle_write_file (const ACE_Asynch_Write_File::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_file called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); result.message_block ().release (); if (result.success ()) // Write successful: Increment file offset this->file_offset_ += ACE_Utils::truncate_cast (result.bytes_transferred ()); // This code is not robust enough to deal with short file writes // (which hardly ever happen) ;-) ACE_ASSERT (result.bytes_to_write () == result.bytes_transferred ()); } /** * @class Sender * * @brief The class will be created by
. After connecting to the * host, this class will then read data from a file and send it * to the network connection. */ class Sender : public ACE_Handler { public: Sender (void); ~Sender (void); //FUZZ: disable check_for_lack_ACE_OS ///FUZZ: enable check_for_lack_ACE_OS int open (const ACE_TCHAR *host, u_short port); ACE_HANDLE handle (void) const; void handle (ACE_HANDLE); protected: // These methods are called by the freamwork /** * This is called when asynchronous transmit files complete * This is called when asynchronous writes from the socket complete * This is called when asynchronous reads from the socket complete */ virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result); virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result); private: /// Transmit the entire file in one fell swoop. int transmit_file (void); /// Initiate an asynchronous file read. int initiate_read_file (void); /// Network I/O handle ACE_SOCK_Stream stream_; /// ws (write stream): for writing to the socket ACE_Asynch_Write_Stream ws_; /// rf (read file): for writing from the file ACE_Asynch_Read_File rf_; /// Transmit file. ACE_Asynch_Transmit_File tf_; /// File to read from ACE_HANDLE input_file_; /// Current file offset u_long file_offset_; /// File size u_long file_size_; /// Welcome message ACE_Message_Block welcome_message_; /// Header and trailer which goes with transmit_file ACE_Asynch_Transmit_File::Header_And_Trailer header_and_trailer_; /// These flags help to determine when to close down the event loop int stream_write_done_; int transmit_file_done_; }; Sender::Sender (void) : input_file_ (ACE_INVALID_HANDLE), file_offset_ (0), file_size_ (0), stream_write_done_ (0), transmit_file_done_ (0) { // Moment of inspiration... :-) static const char *data = "Welcome to Irfan World! Irfan RULES here !!\n"; this->welcome_message_.init (data, ACE_OS::strlen (data)); this->welcome_message_.wr_ptr (ACE_OS::strlen (data)); } Sender::~Sender (void) { this->stream_.close (); } ACE_HANDLE Sender::handle (void) const { return this->stream_.get_handle (); } void Sender::handle (ACE_HANDLE handle) { this->stream_.set_handle (handle); } int Sender::open (const ACE_TCHAR *host, u_short port) { // Initialize stuff // Open input file (in OVERLAPPED mode) this->input_file_ = ACE_OS::open (file, GENERIC_READ | FILE_FLAG_OVERLAPPED); if (this->input_file_ == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1); // Find file size this->file_size_ = ACE_OS::filesize (this->input_file_); // Connect to remote host ACE_INET_Addr address (port, host); ACE_SOCK_Connector connector; if (connector.connect (this->stream_, address) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Connector::connect"), -1); // Open ACE_Asynch_Write_Stream if (this->ws_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::open"), -1); // Open ACE_Asynch_Read_File if (this->rf_.open (*this, this->input_file_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::open"), -1); // Start an asynchronous transmit file if (this->transmit_file () == -1) return -1; // Start an asynchronous read file if (this->initiate_read_file () == -1) return -1; return 0; } int Sender::transmit_file (void) { // Open file (in SEQUENTIAL_SCAN mode) ACE_HANDLE file_handle = ACE_OS::open (file, GENERIC_READ | FILE_FLAG_SEQUENTIAL_SCAN); if (file_handle == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1); // Open ACE_Asynch_Transmit_File if (this->tf_.open (*this) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Transmit_File::open"), -1); // Header and trailer data for the file. // @@ What happens if header and trailer are the same? this->header_and_trailer_.header_and_trailer (&this->welcome_message_, this->welcome_message_.length (), &this->welcome_message_, this->welcome_message_.length ()); // Send the entire file in one fell swoop! if (this->tf_.transmit_file (file_handle, &this->header_and_trailer_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Transmit_File::transmit_file"), -1); return 0; } void Sender::handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_transmit_file called\n")); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "socket", result.socket ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "file", result.file ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_per_send", result.bytes_per_send ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "flags", result.flags ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); // Done with file ACE_OS::close (result.file ()); this->transmit_file_done_ = 1; if (this->stream_write_done_) done = 1; } int Sender::initiate_read_file (void) { // Create a new . Note that this message block will // be used both to data asynchronously from the file and to // data asynchronously to the socket. ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (BUFSIZ + 1), -1); // Inititiate an asynchronous read from the file if (this->rf_.read (*mb, mb->size () - 1, this->file_offset_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Asynch_Read_File::read"), -1); return 0; } void Sender::handle_read_file (const ACE_Asynch_Read_File::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_read_file called\n")); result.message_block ().rd_ptr ()[result.bytes_transferred ()] = '\0'; ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_read", result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); //ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); if (result.success ()) { // Read successful: increment offset and write data to network. // Note how we reuse the for the writing. // Therefore, we do not delete this buffer because it is handled // in . this->file_offset_ += ACE_Utils::truncate_cast (result.bytes_transferred ()); if (this->ws_.write (result.message_block (), result.bytes_transferred ()) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::write")); return; } if (this->file_size_ > this->file_offset_) { // Start an asynchronous read file. if (initiate_read_file () == -1) return; } } } void Sender::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { ACE_DEBUG ((LM_DEBUG, "handle_write_stream called\n")); // Reset pointers. result.message_block ().rd_ptr (result.message_block ().rd_ptr () - result.bytes_transferred ()); ACE_DEBUG ((LM_DEBUG, "********************\n")); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_to_write", result.bytes_to_write ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "handle", result.handle ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "bytes_transfered", result.bytes_transferred ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "act", (uintptr_t) result.act ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "success", result.success ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "completion_key", (uintptr_t) result.completion_key ())); ACE_DEBUG ((LM_DEBUG, "%s = %d\n", "error", result.error ())); ACE_DEBUG ((LM_DEBUG, "********************\n")); #if 0 ACE_DEBUG ((LM_DEBUG, "%s = %s\n", "message_block", result.message_block ().rd_ptr ())); #endif if (result.success ()) { // Partial write to socket int unsent_data = ACE_Utils::truncate_cast ( result.bytes_to_write () - result.bytes_transferred ()); if (unsent_data != 0) { // Reset pointers result.message_block ().rd_ptr (result.bytes_transferred ()); // Duplicate the message block and retry remaining data if (this->ws_.write (*result.message_block ().duplicate (), unsent_data) == -1) { ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Asynch_Write_Stream::write")); return; } } else if (!(this->file_size_ > this->file_offset_)) { this->stream_write_done_ = 1; if (this->transmit_file_done_) done = 1; } } // Release message block. result.message_block ().release (); } static int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("h:p:f:d:")); int c; while ((c = get_opt ()) != EOF) switch (c) { case 'h': host = get_opt.opt_arg (); break; case 'p': port = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'f': file = get_opt.opt_arg (); break; case 'd': dump_file = get_opt.opt_arg (); break; default: ACE_ERROR ((LM_ERROR, "%p.\n", "usage :\n" "-h \n" "-p \n" "-f \n")); return -1; } return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; Sender sender; // Note: acceptor parameterized by the Receiver. ACE_Asynch_Acceptor acceptor; // If passive side if (host == 0) { if (acceptor.open (ACE_INET_Addr (port), initial_read_size, 1) == -1) return -1; } // If active side else if (sender.open (host, port) == -1) return -1; int success = 1; while (success > 0 && !done) // Dispatch events via Proactor singleton. success = ACE_Proactor::instance ()->handle_events (); return 0; } #else /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_DEBUG ((LM_DEBUG, "This example does not work on this platform.\n")); return 1; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_aiosig_ace.cpp0000644000175000017500000002634212576461726025260 0ustar pgquilespgquiles //============================================================================= /** * @file test_aiosig_ace.cpp * * This program helps you to test the calls on a * platform. * Before running this test, make sure the platform can * support POSIX calls, using ACE_ROOT/tests/Aio_Plaform_Test.cpp * This program tests the Signal based completion approach which * uses for completion querying. * If this test is successful, ACE_POSIX_SIG_PROACTOR * can be used on this platform. * This program is a ACE version of the * $ACE_ROOT/examples/Reactor/Proactor/test_aiosig.cpp, with * ACE_DEBUGs and Message_Blocks. * This test does the following: * Issue two s. * Assign SIGRTMIN as the notification signal. * Mask these signals from delivery. * Receive this signal by doing . * Wait for two completions (two signals) * make * ./test_aiosig_ace * @author Programming for the Real World. Bill O. GallMeister. Modified by Alexander Babu Arulanthu */ //============================================================================= #include "ace/Message_Block.h" #include "ace/Log_Msg.h" #include "ace/os_include/os_aio.h" #include "ace/OS_NS_signal.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" #include "ace/Asynch_IO.h" // for ACE_INFINITE static ACE_HANDLE file_handle = ACE_INVALID_HANDLE; static ACE_Message_Block mb1 (BUFSIZ + 1); static ACE_Message_Block mb2 (BUFSIZ + 1); static aiocb aiocb1; static aiocb aiocb2; static aiocb aiocb3; static sigset_t completion_signal; // Function prototypes. static int setup_signal_delivery (void); static int issue_aio_calls (void); static int query_aio_completions (void); static int test_aio_calls (void); static void null_handler (int signal_number, siginfo_t *info, void *context); static int setup_signal_handler (int signal_number); static int setup_signal_delivery (void) { // = Mask all the signals. sigset_t full_set; // Get full set. if (ACE_OS::sigfillset (&full_set) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Error:(%P | %t):%p\n", "sigfillset failed"), -1); // Mask them. if (ACE_OS::pthread_sigmask (SIG_SETMASK, &full_set, 0) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Error:(%P | %t):%p\n", "pthread_sigmask failed"), -1); // = Make a mask with SIGRTMIN only. We use only that signal to // issue 's. if (ACE_OS::sigemptyset (&completion_signal) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Couldnt init the RT completion signal set"), -1); if (ACE_OS::sigaddset (&completion_signal, SIGRTMIN) == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Couldnt init the RT completion signal set"), -1); // Set up signal handler for this signal. return setup_signal_handler (SIGRTMIN); } static int setup_signal_handler (int signal_number) { ACE_UNUSED_ARG (signal_number); // Setting up the handler(!) for these signals. struct sigaction reaction; ACE_OS::sigemptyset (&reaction.sa_mask); // Nothing else to mask. reaction.sa_flags = SA_SIGINFO; // Realtime flag. #if defined (SA_SIGACTION) // Lynx says, it is better to set this bit to be portable. reaction.sa_flags &= SA_SIGACTION; #endif /* SA_SIGACTION */ reaction.sa_sigaction = null_handler; // Null handler. int sigaction_return = ACE_OS::sigaction (SIGRTMIN, &reaction, 0); if (sigaction_return == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Proactor couldnt do sigaction for the RT SIGNAL"), -1); return 0; } static int issue_aio_calls (void) { // Setup AIOCB. aiocb1.aio_fildes = file_handle; aiocb1.aio_offset = 0; aiocb1.aio_buf = mb1.wr_ptr (); aiocb1.aio_nbytes = BUFSIZ; aiocb1.aio_reqprio = 0; aiocb1.aio_sigevent.sigev_notify = SIGEV_SIGNAL; aiocb1.aio_sigevent.sigev_signo = SIGRTMIN; aiocb1.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb1; // Fire off the aio read. if (aio_read (&aiocb1) == -1) // Queueing failed. ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Asynch_Read_Stream: aio_read queueing failed"), -1); // Setup AIOCB. aiocb2.aio_fildes = file_handle; aiocb2.aio_offset = BUFSIZ + 1; aiocb2.aio_buf = mb2.wr_ptr (); aiocb2.aio_nbytes = BUFSIZ; aiocb2.aio_reqprio = 0; aiocb2.aio_sigevent.sigev_notify = SIGEV_SIGNAL; aiocb2.aio_sigevent.sigev_signo = SIGRTMIN; aiocb2.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb2; // Fire off the aio read. if (aio_read (&aiocb2) == -1) // Queueing failed. ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Asynch_Read_Stream: aio_read queueing failed"), -1); // Setup sigval. aiocb3.aio_fildes = ACE_INVALID_HANDLE; aiocb3.aio_offset = 0; aiocb3.aio_buf = 0; aiocb3.aio_nbytes = 0; aiocb3.aio_reqprio = 0; aiocb3.aio_sigevent.sigev_notify = SIGEV_SIGNAL; aiocb3.aio_sigevent.sigev_signo = SIGRTMIN; aiocb3.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb3; sigval value; value.sival_ptr = reinterpret_cast (&aiocb3); // Queue this one for completion right now. if (sigqueue (ACE_OS::getpid (), SIGRTMIN, value) == -1) // Queueing failed. ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "sigqueue"), -1); return 0; } static int query_aio_completions (void) { for (size_t number_of_compleions = 0; number_of_compleions < 3; number_of_compleions ++) { // Wait for amount of time. @@ Assigning // to tv_sec. timespec timeout; timeout.tv_sec = ACE_INFINITE; timeout.tv_nsec = 0; // To get back the signal info. siginfo_t sig_info; // Await the RT completion signal. int sig_return = ACE_OS::sigtimedwait (&completion_signal, &sig_info, &timeout); // Error case. // If failure is coz of timeout, then return *0* but set // errno appropriately. This is what the WinNT proactor // does. if (sig_return == -1) ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n", "Error waiting for RT completion signals"), -1); //FUZZ: disable check_for_lack_ACE_OS // RT completion signals returned. if (sig_return != SIGRTMIN) ACE_ERROR_RETURN ((LM_ERROR, "Unexpected signal (%d) has been received while waiting for RT Completion Signals\n", sig_return), -1); //FUZZ: enble check_for_lack_ACE_OS // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "Sig number found in the sig_info block : %d\n", sig_info.si_signo)); // Is the signo returned consistent? if (sig_info.si_signo != sig_return) ACE_ERROR_RETURN ((LM_ERROR, "Inconsistent signal number (%d) in the signal info block\n", sig_info.si_signo), -1); // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "Signal code for this signal delivery : %d\n", sig_info.si_code)); // Is the signal code an aio completion one? if ((sig_info.si_code != SI_ASYNCIO) && (sig_info.si_code != SI_QUEUE)) ACE_ERROR_RETURN ((LM_DEBUG, "Unexpected signal code (%d) returned on completion querying\n", sig_info.si_code), -1); // Retrive the aiocb. aiocb* aiocb_ptr = (aiocb *) sig_info.si_value.sival_ptr; if (aiocb_ptr == &aiocb3) { ACE_ASSERT (sig_info.si_code == SI_QUEUE); ACE_DEBUG ((LM_DEBUG, "sigqueue caught... good\n")); } else { // Analyze error and return values. Return values are // actually 's associated with the call // corresponding to aiocb_ptr. int error_code = aio_error (aiocb_ptr); if (error_code == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Invalid control block was sent to for completion querying"), -1); if (error_code != 0) // Error occurred in the call. Return the errno // corresponding to that call. ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "An AIO call has failed"), error_code); // No error occured in the AIO operation. int nbytes = aio_return (aiocb_ptr); if (nbytes == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "Invalid control block was send to "), -1); if (number_of_compleions == 0) { // Print the buffer. ACE_DEBUG ((LM_DEBUG, "\n Number of bytes transferred : %d\n", nbytes)); // Note... the dumps of the buffers are disabled because they // may easily overrun the ACE_Log_Msg output buffer. If you need // to turn the on for some reason, be careful of this. #if 0 ACE_DEBUG ((LM_DEBUG, "The buffer : %s\n", mb1.rd_ptr ())); #endif /* 0 */ } else { // Print the buffer. ACE_DEBUG ((LM_DEBUG, "\n Number of bytes transferred : %d\n", nbytes)); #if 0 ACE_DEBUG ((LM_DEBUG, "The buffer : %s\n", mb2.rd_ptr ())); #endif /* 0 */ } } } return 0; } static int test_aio_calls (void) { // Set up the input file. // Open file (in SEQUENTIAL_SCAN mode) file_handle = ACE_OS::open ("test_aiosig_ace.cpp", O_RDONLY); if (file_handle == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::open"), -1); if (setup_signal_delivery () == -1) return -1; if (issue_aio_calls () == -1) return -1; if (query_aio_completions () == -1) return -1; return 0; } static void null_handler (int signal_number, siginfo_t */* info */, void * /* context */) { ACE_ERROR ((LM_ERROR, "Error:%s:Signal number %d\n" "Mask all the RT signals for this thread", "ACE_POSIX_SIG_Proactor::null_handler called", signal_number)); } int ACE_TMAIN (int, ACE_TCHAR *[]) { if (test_aio_calls () == 0) ACE_OS::printf ("RT SIG test successful:\n" "ACE_POSIX_SIG_PROACTOR should work in this platform\n"); else ACE_OS::printf ("RT SIG test failed:\n" "ACE_POSIX_SIG_PROACTOR may not work in this platform\n"); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_aiocb.cpp0000644000175000017500000001410612576461726024245 0ustar pgquilespgquiles //============================================================================= /** * @file test_aiocb.cpp * * Checkout $ACE_ROOT/examples/Reactor/Proactor/test_aiocb_ace.cpp, * which is the ACE'ified version of this program. * * = COMPILE and RUN * % CC -g -o test_aiocb -lrt test_aiocb.cpp * % ./test_aiocb * * @author Alexander Babu Arulanthu */ //============================================================================= //FUZZ: disable check_for_lack_ACE_OS //FUZZ: disable check_for_improper_main_declaration #include #include #include #include #include #include #include #include #include #include class Test_Aio { public: /// Default constructor. Test_Aio (void); /// Initting the output file and the buffer. int init (void); /// Doing the testing stuff. int do_aio (void); /// Destructor. ~Test_Aio (void); private: /// Output file descriptor. int out_fd_; /// For writing to the file. struct aiocb *aiocb_write_; /// Reading stuff from the file. struct aiocb *aiocb_read_; /// The buffer to be written to the out_fd. char *buffer_write_; /// The buffer to be read back from the file. char *buffer_read_; }; Test_Aio::Test_Aio (void) : aiocb_write_ (new struct aiocb), aiocb_read_ (new struct aiocb), buffer_write_ (0), buffer_read_ (0) { } Test_Aio::~Test_Aio (void) { delete aiocb_write_; delete aiocb_read_; delete buffer_write_; delete buffer_read_; } // Init the output file and init the buffer. int Test_Aio::init (void) { // Open the output file. this->out_fd_ = open ("test_aio.log", O_RDWR | O_CREAT | O_TRUNC, 0666); if (this->out_fd_ == 0) { cout << "Error : Opening file" << endl; return -1; } // Init the buffers. this->buffer_write_ = strdup ("Welcome to the world of AIO... AIO Rules !!!"); cout << "The buffer : " << this->buffer_write_ << endl; this->buffer_read_ = new char [strlen (this->buffer_write_) + 1]; return 0; } // Set the necessary things for the AIO stuff. // Write the buffer asynchly.hmm Disable signals. // Go on aio_suspend. Wait for completion. // Print out the result. int Test_Aio::do_aio (void) { // = Write to the file. // Setup AIOCB. this->aiocb_write_->aio_fildes = this->out_fd_; this->aiocb_write_->aio_offset = 0; this->aiocb_write_->aio_buf = this->buffer_write_; this->aiocb_write_->aio_nbytes = strlen (this->buffer_write_); this->aiocb_write_->aio_reqprio = 0; this->aiocb_write_->aio_sigevent.sigev_notify = SIGEV_NONE; //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; this->aiocb_write_->aio_sigevent.sigev_value.sival_ptr = (void *) this->aiocb_write_; // Fire off the aio write. if (aio_write (this->aiocb_write_) != 0) { perror ("aio_write"); return -1; } // = Read from that file. // Setup AIOCB. this->aiocb_read_->aio_fildes = this->out_fd_; this->aiocb_read_->aio_offset = 0; this->aiocb_read_->aio_buf = this->buffer_read_; this->aiocb_read_->aio_nbytes = strlen (this->buffer_write_); this->aiocb_read_->aio_reqprio = 0; this->aiocb_read_->aio_sigevent.sigev_notify = SIGEV_NONE; //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; this->aiocb_read_->aio_sigevent.sigev_value.sival_ptr = (void *) this->aiocb_read_; // Fire off the aio write. If it doesnt get queued, carry on to get // the completion for the first one. if (aio_read (this->aiocb_read_) < 0) perror ("aio_read"); // Wait for the completion on aio_suspend. struct aiocb *list_aiocb[2]; list_aiocb [0] = this->aiocb_write_; list_aiocb [1] = this->aiocb_read_; // Do suspend till all the aiocbs in the list are done. int done = 0; int return_val = 0; while (!done) { return_val = aio_suspend (list_aiocb, 2, 0); cerr << "Return value :" << return_val << endl; // Analyze return and error values. if (list_aiocb[0] != 0) { if (aio_error (list_aiocb [0]) != EINPROGRESS) { if (aio_return (list_aiocb [0]) == -1) { perror ("aio_return"); return -1; } else { // Successful. Store the pointer somewhere and make the // entry NULL in the list. this->aiocb_write_ = list_aiocb [0]; list_aiocb [0] = 0; } } else cout << "AIO write in progress" << endl; } if (list_aiocb[1] != 0) { if (aio_error (list_aiocb [1]) != EINPROGRESS) { int read_return = aio_return (list_aiocb[1]); if (read_return == -1) { perror ("aio_return"); return -1; } else { // Successful. Store the pointer somewhere and make the // entry NULL in the list. this->aiocb_read_ = list_aiocb [1]; list_aiocb [1] = 0; this->buffer_read_[read_return] = '\0'; } } else cout << "AIO read in progress" << endl; } // Is it done? if ((list_aiocb [0] == 0) && (list_aiocb [1] == 0)) done = 1; } cout << "Both the AIO operations done." << endl; cout << "The buffer is :" << this->buffer_read_ << endl; return 0; } int main (int argc, char **argv) { Test_Aio test_aio; if (test_aio.init () != 0) { printf ("AIOCB test failed:\n" "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"); return -1; } if (test_aio.do_aio () != 0) { printf ("AIOCB test failed:\n" "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"); return -1; } printf ("AIOCB test successful:\n" "ACE_POSIX_AIOCB_PROACTOR should work in this platform\n"); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_multiple_loops.cpp0000644000175000017500000000704712576461726026245 0ustar pgquilespgquiles //============================================================================= /** * @file test_multiple_loops.cpp * * This example application shows how to write programs that * combine the Proactor and Reactor event loops. This is possible * only on WIN32 platform. * * @author Irfan Pyarali */ //============================================================================= #include "ace/Task.h" #include "ace/Proactor.h" #include "ace/WIN32_Proactor.h" #include "ace/Atomic_Op.h" #include "ace/OS_NS_unistd.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) /** * @class Timeout_Handler * * @brief Generic timeout handler. */ class Timeout_Handler : public ACE_Handler, public ACE_Event_Handler { public: Timeout_Handler (void) { } // This is called by the Proactor. This is declared in ACE_Handler. virtual void handle_time_out (const ACE_Time_Value &tv, const void *arg) { // Print out when timeouts occur. ACE_DEBUG ((LM_DEBUG, "(%t) %d timeout occurred for %s @ %d.\n", ++count_, (char *) arg, tv.sec ())); // Since there is only one thread that can do the timeouts in // Reactor, lets keep the handle_timeout short for that // thread. if (ACE_OS::strcmp ((char *) arg, "Proactor") == 0) // Sleep for a while ACE_OS::sleep (1); } // This method is declared in ACE_Event_Handler. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg) { this->handle_time_out (tv, arg); return 0; } private: ACE_Atomic_Op count_; }; class Worker : public ACE_Task { public: // Thread fuction. int svc (void) { ACE_DEBUG ((LM_DEBUG, "(%t) Worker started\n")); // Handle events for 13 seconds. ACE_Time_Value run_time (13); // Try to become the owner ACE_Reactor::instance ()->owner (ACE_Thread::self ()); if (ACE_Reactor::run_event_loop (run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "Worker::svc"), -1); else ACE_DEBUG ((LM_DEBUG, "(%t) work complete\n")); return 0; } }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Timeout_Handler handler; ACE_WIN32_Proactor win32_proactor (0, 1); ACE_Proactor proactor (&win32_proactor, 0, 0); ACE_Reactor::instance ()->register_handler (proactor.implementation ()); // Register a 2 second timer. ACE_Time_Value foo_tv (2); if (proactor.schedule_timer (handler, (void *) "Proactor", ACE_Time_Value::zero, foo_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); // Register a 3 second timer. ACE_Time_Value bar_tv (3); if (ACE_Reactor::instance ()->schedule_timer (&handler, (void *) "Reactor", ACE_Time_Value::zero, bar_tv) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); Worker worker; if (worker.activate (THR_NEW_LWP, 10) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); ACE_Thread_Manager::instance ()->wait (); // Remove from reactor ACE_Reactor::instance ()->remove_handler (&proactor, ACE_Event_Handler::DONT_CALL); return 0; } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ ace-6.3.3+dfsg.orig/examples/Reactor/Proactor/test_aiocb_ace.cpp0000644000175000017500000001560112576461726025056 0ustar pgquilespgquiles //============================================================================= /** * @file test_aiocb_ace.cpp * * This program helps you to test the calls on a * platform. * * Before running this test, make sure the platform can * support POSIX calls, using * ACE_ROOT/tests/Aio_Platform_Test. * * This program tests the AIOCB (AIO Control Blocks) based * completion approach which uses for completion * querying. * * If this test is successful, ACE_POSIX_AIOCB_PROACTOR * can be used on this platform. * * = COMPILE and RUN * % make * % ./test_aiocb_ace * * @author Alexander Babu Arulanthu */ //============================================================================= #include "ace/ACE.h" #include "ace/Log_Msg.h" #include "ace/os_include/os_aio.h" #include "ace/OS_NS_string.h" class Test_Aio { public: /// Default constructor. Test_Aio (void); /// Initting the output file and the buffer. int init (void); /// Doing the testing stuff. int do_aio (void); /// Destructor. ~Test_Aio (void); private: /// Output file descriptor. int out_fd_; /// For writing to the file. struct aiocb *aiocb_write_; /// Reading stuff from the file. struct aiocb *aiocb_read_; /// The buffer to be written to the out_fd. char *buffer_write_; /// The buffer to be read back from the file. char *buffer_read_; }; Test_Aio::Test_Aio (void) : aiocb_write_ (0), aiocb_read_ (0), buffer_write_ (0), buffer_read_ (0) { ACE_NEW (this->aiocb_write_, struct aiocb); ACE_NEW (this->aiocb_read_, struct aiocb); } Test_Aio::~Test_Aio (void) { delete aiocb_write_; delete aiocb_read_; delete buffer_write_; delete buffer_read_; } // Init the output file and init the buffer. int Test_Aio::init (void) { // Open the output file. this->out_fd_ = ACE_OS::open ("test_aio.log", O_RDWR | O_CREAT | O_TRUNC, 0666); if (this->out_fd_ == 0) ACE_ERROR_RETURN ((LM_ERROR, "Error: Opening file\n"), -1); // Init the buffers. this->buffer_write_ = ACE::strnew ("Welcome to the world of AIO... AIO Rules !!!"); ACE_DEBUG ((LM_DEBUG, "The buffer : %s\n", this->buffer_write_)); // Allocate memory for the read buffer. ACE_NEW_RETURN (this->buffer_read_, char [ACE_OS::strlen (this->buffer_write_)], -1); return 0; } // Set the necessary things for the AIO stuff. // Write the buffer asynchly.hmm Disable signals. // Go on aio_suspend. Wait for completion. // Print out the result. int Test_Aio::do_aio (void) { // = Write to the file. // Setup AIOCB. this->aiocb_write_->aio_fildes = this->out_fd_; this->aiocb_write_->aio_offset = 0; this->aiocb_write_->aio_buf = this->buffer_write_; this->aiocb_write_->aio_nbytes = ACE_OS::strlen (this->buffer_write_); this->aiocb_write_->aio_reqprio = 0; this->aiocb_write_->aio_sigevent.sigev_notify = SIGEV_NONE; //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; this->aiocb_write_->aio_sigevent.sigev_value.sival_ptr = (void *) this->aiocb_write_; // Fire off the aio write. if (aio_write (this->aiocb_write_) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "aio_write"), -1); // = Read from that file. // Setup AIOCB. this->aiocb_read_->aio_fildes = this->out_fd_; this->aiocb_read_->aio_offset = 0; this->aiocb_read_->aio_buf = this->buffer_read_; this->aiocb_read_->aio_nbytes = ACE_OS::strlen (this->buffer_write_); this->aiocb_read_->aio_reqprio = 0; this->aiocb_read_->aio_sigevent.sigev_notify = SIGEV_NONE; //this->this->aiocb_.aio_sigevent.sigev_signo = SIGRTMAX; this->aiocb_read_->aio_sigevent.sigev_value.sival_ptr = (void *) this->aiocb_read_; // Fire off the aio write. If it doesnt get queued, carry on to get // the completion for the first one. if (aio_read (this->aiocb_read_) < 0) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "aio_read"), -1); // Wait for the completion on aio_suspend. struct aiocb *list_aiocb[2]; list_aiocb [0] = this->aiocb_write_; list_aiocb [1] = this->aiocb_read_; // Do suspend till all the aiocbs in the list are done. int to_finish = 2; int return_val = 0; while (to_finish > 0) { return_val = aio_suspend (list_aiocb, to_finish, 0); ACE_DEBUG ((LM_DEBUG, "Result of : %d\n", return_val)); // Analyze return and error values. if (to_finish > 1) { if (aio_error (list_aiocb [1]) != EINPROGRESS) { if (aio_return (list_aiocb [1]) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "aio_return, item 1"), -1); else { // Successful. Remember we have one less thing to finish. --to_finish; list_aiocb [1] = 0; } } else ACE_DEBUG ((LM_DEBUG, "aio_error says aio 1 is in progress\n")); } if (aio_error (list_aiocb [0]) != EINPROGRESS) { if (aio_return (list_aiocb [0]) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "aio_return, item 0"), -1); else { // Successful. Store the pointer somewhere and bump the // read entry up to the front, if it is still not done. --to_finish; list_aiocb [0] = this->aiocb_read_; } } else ACE_DEBUG ((LM_DEBUG, "aio_error says aio 0 is in progress\n")); } ACE_DEBUG ((LM_DEBUG, "Both the AIO operations done.\n" "The buffer is : %s\n", this->buffer_read_)); return 0; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); Test_Aio test_aio; if (test_aio.init () != 0) ACE_ERROR_RETURN ((LM_ERROR, "AIOCB test failed:\n" "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"), -1); if (test_aio.do_aio () != 0) ACE_ERROR_RETURN ((LM_ERROR, "AIOCB test failed:\n" "ACE_POSIX_AIOCB_PROACTOR may not work in this platform\n"), -1); ACE_DEBUG ((LM_DEBUG, "AIOCB test successful:\n" "ACE_POSIX_AIOCB_PROACTOR should work in this platform\n")); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Ntalker/0000775000175000017500000000000012576472436021234 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/Ntalker/ntalker.cpp0000644000175000017500000001377112576461726023407 0ustar pgquilespgquiles// Listens to multicast address. After first message received, will // listen for 5 more seconds. Prints Mbits/sec received from client. #include "ace/OS_main.h" #include "ace/OS_NS_unistd.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Dgram_Mcast.h" #include "ace/Reactor.h" #include "ace/Get_Opt.h" #include "ace/Thread_Manager.h" #include "ace/Service_Config.h" #if defined (ACE_HAS_IP_MULTICAST) // Network interface to subscribe to. This is hardware specific. use // netstat(1M) to find whether your interface is le0 or ie0 static const ACE_TCHAR *INTERFACE = 0; static const char *MCAST_ADDR = ACE_DEFAULT_MULTICAST_ADDR; static const u_short UDP_PORT = ACE_DEFAULT_MULTICAST_PORT; class Handler : public ACE_Event_Handler { // = TITLE // Handle both multicast and stdin events. public: // = Initialization and termination methods. Handler (u_short udp_port, const char *ip_addr, const ACE_TCHAR *a_interface, ACE_Reactor & ); // Constructor. ~Handler (void); // Destructor. // Event demuxer hooks. virtual int handle_input (ACE_HANDLE); virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); virtual ACE_HANDLE get_handle (void) const; private: ACE_SOCK_Dgram_Mcast mcast_; // Multicast wrapper. ACE_INET_Addr sockmc_addr_; // Address to multicast to. }; ACE_HANDLE Handler::get_handle (void) const { return this->mcast_.get_handle (); } int Handler::handle_input (ACE_HANDLE h) { char buf[BUFSIZ]; if (h == ACE_STDIN) { ssize_t result = ACE_OS::read (h, buf, BUFSIZ); if (result > 0) { if (this->mcast_.send (buf, result) != result) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send error"), -1); return 0; } else if (result == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "can't read from STDIN"), -1); else // result == 0 { ACE_Reactor::end_event_loop (); return -1; } } else { ACE_INET_Addr remote_addr; // Receive message from multicast group. ssize_t result = this->mcast_.recv (buf, sizeof buf, remote_addr); if (result != -1) { ACE_DEBUG ((LM_DEBUG, "received datagram from host %s on port %d bytes = %d\n", remote_addr.get_host_name (), remote_addr.get_port_number (), result)); ACE_OS::write (ACE_STDERR, buf, result); ACE_DEBUG ((LM_DEBUG, "\n")); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "something amiss"), -1); } } int Handler::handle_close (ACE_HANDLE h, ACE_Reactor_Mask) { if (h == ACE_STDIN) { ACE_DEBUG ((LM_DEBUG, "STDIN_Events handle removed from reactor.\n")); if (ACE_Reactor::instance ()->remove_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "remove_handler"), -1); } else ACE_DEBUG ((LM_DEBUG, "Mcast_Events handle removed from reactor.\n")); return 0; } Handler::~Handler (void) { if (this->mcast_.leave (sockmc_addr_) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "leave fails")); } Handler::Handler (u_short udp_port, const char *ip_addr, const ACE_TCHAR *a_interface, ACE_Reactor &reactor) { // Create multicast address to listen on. this->sockmc_addr_ = ACE_INET_Addr (udp_port, ip_addr); // subscribe to multicast group. if (this->mcast_.join (sockmc_addr_, 1, a_interface) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "can't subscribe to multicast group")); // Disable loopbacks. // if (this->mcast_.set_option (IP_MULTICAST_LOOP, 0) == -1 ) // ACE_OS::perror (" can't disable loopbacks " ), ACE_OS::exit (1); // Register callbacks with the ACE_Reactor. else if (reactor.register_handler (this->mcast_.get_handle (), this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "can't register with Reactor\n")); // Register the STDIN handler. else if (ACE_Event_Handler::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler")); } static void parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("i:u")); int c; while ((c = get_opt ()) != -1) switch (c) { case 'i': INTERFACE = get_opt.opt_arg (); break; case 'u': // Usage fallthrough. default: ACE_DEBUG ((LM_DEBUG, "%s -i interface\n", argv[0])); ACE_OS::exit (1); } } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { parse_args (argc, argv); Handler handler (UDP_PORT, MCAST_ADDR, INTERFACE, *ACE_Reactor::instance ()); // Run the event loop. ACE_Reactor::run_event_loop (); ACE_DEBUG ((LM_DEBUG, "talker Done.\n")); return 0; } #else int ACE_TMAIN (int, ACE_TCHAR *argv[]) { ACE_ERROR_RETURN ((LM_ERROR, "error: %s must be run on a platform that support IP multicast\n", argv[0]), 0); } #endif /* ACE_HAS_IP_MULTICAST */ ace-6.3.3+dfsg.orig/examples/Reactor/Ntalker/README0000644000175000017500000000067612576461726022123 0ustar pgquilespgquiles This test program illustrates how the ACE datagram multicast feature works. To run the test simply do the following on multiple machines: # Machine 1 % ./ntalker # Machine 2 % ./ntalker # Machine 3 % ./ntalker Then, on one (or all) of the machines, type input into the keyboard. This input will be multicast to all the machines using IP multicast via the ACE_SOCK_Dgram_Mcast wrapper. When you want to shut down the sender, just type ^D. ace-6.3.3+dfsg.orig/examples/Reactor/Ntalker/Reactor_Ntalker.mpc0000644000175000017500000000007012576461726025007 0ustar pgquilespgquiles// -*- MPC -*- project : aceexe { exename = ntalker } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/0000775000175000017500000000000012576472436021636 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/run_test.pl0000755000175000017500000000135712576461726024045 0ustar pgquilespgquileseval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; use PerlACE::TestTarget; $status = 0; $SV = new PerlACE::Process ("server", ""); $CL1 = new PerlACE::Process ("client", "80 100"); $CL2 = new PerlACE::Process ("client", "80 100"); $SV->Spawn (); sleep (1); $client1 = $CL1->Spawn (); if ($client1 != 0) { print STDERR "ERROR: client 1 returned $client1\n"; $status = 1; } $client2 = $CL2->Spawn (); if ($client2 != 0) { print STDERR "ERROR: client 2 returned $client2\n"; $status = 1; } $server = $SV->WaitKill (1000); if ($server != 0) { print STDERR "ERROR: server returned $server\n"; $status = 1; } exit $status; ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/TP_Reactor.mpc0000644000175000017500000000034612576461726024342 0ustar pgquilespgquiles// -*- MPC -*- project (*client) : aceexe { exename = client Source_Files { client.cpp } } project (*server) : aceexe { exename = server Source_Files { server.cpp AcceptHandler.cpp ReadHandler.cpp } } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/ReadHandler.h0000644000175000017500000000416412576461726024163 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #ifndef __READHANDLER_H__ #define __READHANDLER_H__ #include #include /** * This read handler is created by the accept handler and handles all the data * exchange between client and server. The client makes two requests to the * server. The first asks the server to create a buffer which will hold the * data sent in the second call. */ class ReadHandler : public ACE_Event_Handler { private: /** * The stream socket used for data exchange. */ ACE_SOCK_Stream mStream; /** * The size of the data array. */ int mDataSize; /** * The array containing the client's data. */ char *mData; /** * The call counter to distinguish between first and second call. */ int mCallCounter; /** * Count the numer of invocations of handle_*(). According to the * docs, there should be only one invocation at any given time. */ int mInvocationCounter; public: /** * Initialization. */ ReadHandler(void); /** * Clean up data. */ virtual ~ReadHandler(); /** * Provide access to the internal stream socket. */ ACE_SOCK_Stream &getStream(void); /** * @name Overridden methods from the ACE_Event_Handler */ // @{ /** * Provides the handle of mStream; */ virtual ACE_HANDLE get_handle(void) const; /** * Handles the data excahnge between client and server. On the first * invocation, mData is allocated to the requested size and on the * second invocation, that buffer is filled with the client's data. */ virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE); /** * Deletes this instance of the read handler. */ virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask); // @} }; #endif /* __READHANDLER_H__ */ ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/README0000644000175000017500000000701512576461726022517 0ustar pgquilespgquiles ACE reactor demonstration ========================= Martin Kolleck Tino Riethmuller 1. Introduction This program demonstrates what we think is a bug in the ACE library. The affected component is the ACE_TP_Reactor. According to the documentation, the reactor ensures that only one of the handle_*() methods of an event handler is called at a time. Tino found this to be not true and I wrote this example program showing the behavior. I do not exclude the possibility that we are using the ACE library in an unintended/wrong way. So comments on the code as well as any other remarks are welcome. 2. The program The program consists of a client and a server. The general implementation is taken from the example solution to exercise 4c of the ACE course. The client will send a request to the server. This request is interpreted to be the size of the following data. The server allocates the memory required to hold the client's data and then sends a confirmation to the client, that it may proceed. The the client sends the large data chunk and the server again confirms it. The client runs in a loop which can be configured to run indefinitely or a previously set amount of times. The configuration i done from the command line. To invoke the client type: $ ./client size [count] sets the size (in MiB) of the buffer sent to the server. Depending on the systems, values between 60 and 100 have been used for testing. determines how often the buffer is sent. If left out, the clients send the buffer until interrupted. The server is started without arguments. Both programs will print a dot for each successful connection. I found this an easy and unintrusive way of showing progress whithout flooding the console too fast. This also makes it easier to see when an error has occurred. 3. Building the program This example was created on a Linux box. You will need the environment variable ACE_ROOT set up to the location where ACE is installed. It might be possible, that the path where the ACE libraries are found, needs to be adjusted in the Makefile. To compile simply type 'make' on the command prompt. $ make This will create two executable files. One for the server and one for the client. (named respectively) 4. Running the program The error seems to be of statistical nature. Occurring only under certain conditions (which I am not sure of, what they are). I successfully produced the error on the four machines given below (architecture, ACE and compiler version). I tested the program with localhost connections, as well as over a real network connection and could always reproduce the error. To detect the error I introduced a member variable to the read event handler. This counter is initialized to zero in the constructor. When handle_input() of the event handler is called, the counter is increased and decreased, when handle_input() returns. Before increasing the counter, It is compared to zero (which it should alway be, if only one invocation to handle_input() is made at a time) and an error message is printed if it is not zero. To test for the error, I ran one instance of the server program and TWO instances of the client program. The sizes of the buffers were between 60 and 100 MiB and no count was given (running until stopped) The three Linux boxes showed the error within one minute of starting both clients. For the Windows box I decreased the buffer size to 15 and 20 MiB (Windows does not seem to have very performant localhost connectivity) and it took about half an hour until the error occurred the first time. ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/client.cpp0000644000175000017500000001131512576461726023617 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #include #include #include #include #include #include #include #include #include "common.h" /** * Print usage information for the client. * * @param arg The progams name (argv[0]). */ int printUsage(ACE_TCHAR *arg) { cerr << "Usage: " << arg << " size [count]" << endl; cerr << "\tSends MiB to the server and optionally repeats that " << " times." << endl; cerr << "\tAll arguments must be positive numbers. If no is " << "given, the\n\tclient runs until interrupted." << endl; return -1; } int ACE_TMAIN(int argc, ACE_TCHAR **argv) { // size and count for transmissions int size = 0, count = -1; // the server's answer is a single byte char answer; // parse the argument if ((argc < 2) || (((size = ACE_OS::strtol(argv[1], 0, 10)) < 1) || (errno == EINVAL))) return printUsage(argv[0]); // take size as the number of MiB and create appropriate buffer size *= BASE; char *someData = new (std::nothrow) char[size]; if (someData == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%N:%l: Failed to allocate ") ACE_TEXT ("data buffer.\n")), -1); // put someData in a kind of auto_ptr so it gets deleted automatically ACE_Auto_Array_Ptr pSomeData(someData); // parse the argument if available if ((argc == 3) && (((count = ACE_OS::strtol(argv[2], 0, 10)) < 1) || (errno == EINVAL))) return printUsage(argv[0]); // the server listens on localhost on default port (from common.h) ACE_INET_Addr serverAddr(PORT, "localhost"); ACE_SOCK_Stream stream; ACE_SOCK_Connector connector; // -1 is running indefinitely while ((count == -1) || (count-- != 0)) { // some output, that we know something is happening //ACE_DEBUG((LM_DEBUG, ACE_TEXT("%N:%l: Passes left: %i\n"), count)); ACE_DEBUG((LM_DEBUG, ACE_TEXT("."))); // connect to the server and get the stream if (connector.connect(stream, serverAddr) == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to connect to ") ACE_TEXT ("server. (errno = %i: %m)\n"), ACE_ERRNO_GET)); break; } try { // send the request to the server (number of MiB in the next call) // Note: only use the sizeof and pointer to int on compatible // platforms (i.e. little-endian/big-endian, data type size) if (stream.send_n(&size, sizeof(size), &connTimeout) != (ssize_t) sizeof(size)) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to send ") ACE_TEXT ("request. (errno = %i: %m)\n"), ACE_ERRNO_GET)); throw 1; } // receive the answer if (stream.recv_n(&answer, sizeof(answer), &connTimeout) != 1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N: %l: Failed to receive ") ACE_TEXT ("1st response. (errno = %i: %m)\n"), ACE_ERRNO_GET)); throw 1; } // server answer, 'K" indicates a positive answer if (answer == 'K') { // send a huge message to the server if (stream.send_n(someData, size, &connTimeout) != size) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to send ") ACE_TEXT ("someData. (errno = %i: %m)\n"), ACE_ERRNO_GET)); throw 1; } // get an answer if (stream.recv_n(&answer, sizeof(answer), &connTimeout) != 1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N: %l: Failed to receive ") ACE_TEXT ("2nd response. (errno = %i: %m)\n"), ACE_ERRNO_GET)); throw 1; } // check the answer if (answer != 'K') { cout << "The server was unable to process the data." << endl; } } } catch (...) { // ok we know an error occurred, we need to close the socket. // The we'll try again. } // close the current stream if (stream.close() == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to close ") ACE_TEXT ("socket. (errno = %i: %m)\n"), ACE_ERRNO_GET)); break; } } // while cout << "Bye. Bye" << endl; return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/AcceptHandler.cpp0000644000175000017500000000666612576461726025053 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #include "common.h" #include "AcceptHandler.h" #include "ReadHandler.h" #include #include #include AcceptHandler:: AcceptHandler(ACE_Reactor *reactor) : ACE_Event_Handler(), mReactor(reactor == 0 ? ACE_Reactor::instance() : reactor), mAcceptor() { ACE_TRACE("AcceptHandler:: AcceptHandler(ACE_Reactor *)"); } AcceptHandler::~AcceptHandler() { ACE_TRACE("AcceptHandler::~AcceptHandler()"); } int AcceptHandler::open(void) { ACE_TRACE("AcceptHandler::open(void)"); // create the local address used for the service (PORT is from common.h) ACE_INET_Addr addr(PORT); // open a port using the acceptor; reuse the address later if (mAcceptor.open(addr, 1) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to open ") ACE_TEXT ("listening socket. (errno = %i: %m)\n"), ACE_ERRNO_GET), -1); // register the handler with the reactor if (mReactor->register_handler(this, ACE_Event_Handler::ACCEPT_MASK) == -1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to register accept ") ACE_TEXT ("handler. (errno = %i: %m)\n"), ACE_ERRNO_GET)); // don't leave the acceptor open if (mAcceptor.close() == -1) ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to close the socket ") ACE_TEXT ("after previous error. (errno = %i: %m)\n"), ACE_ERRNO_GET)); return -1; } return 0; } ACE_HANDLE AcceptHandler::get_handle(void) const { ACE_TRACE("AcceptHandler::get_handle(void)"); return mAcceptor.get_handle(); } int AcceptHandler::handle_input(ACE_HANDLE) { ACE_TRACE("AcceptHandler::handle_input(ACE_HANDLE)"); ACE_INET_Addr clientAddr; // create a new ReadHandler ReadHandler *reader = 0; ACE_NEW_NORETURN (reader, ReadHandler()); if (reader == 0) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to allocate ") ACE_TEXT ("reader. (errno = %i: %m)\n"), ACE_ERRNO_GET), -1); // put reader in an auto pointer so we can use ACE_ERROR_RETURN safely auto_ptr pReader(reader); // accept the connection using the reader's stream if (mAcceptor.accept(reader->getStream(), &clientAddr) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to accept ") ACE_TEXT ("client connection. (errno = %i: %m)\n"), ACE_ERRNO_GET), -1); // register the reader with the reactor if (mReactor->register_handler(reader, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to register ") ACE_TEXT ("read handler. (errno = %i: %m)\n"), ACE_ERRNO_GET), -1); // from now on the read handler takes care of itself pReader.release(); return 0; // keep going } int AcceptHandler::handle_close(ACE_HANDLE, ACE_Reactor_Mask) { ACE_TRACE("AcceptHandler::handle_close(ACE_HANDLE, ACE_Reactor_Mask)"); // close the listening socket if (mAcceptor.close() == -1) ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to close the ") ACE_TEXT ("socket. (errno = %i: %m)\n"), ACE_ERRNO_GET)); // no need to distinguish between error during close and normal close // since ACE does not evaluate the return value of handle_close() delete this; return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/ReadHandler.cpp0000644000175000017500000001170512576461726024515 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #include "common.h" #include "ReadHandler.h" #include #include #include /** * This macro is used to increase the invocation counter by one when entering * handle_input(). It also checks wether the counter is greater than zero * indicating, that handle_input() has been called before. */ #define INVOCATION_ENTER() do { if (mInvocationCounter > 0) \ ACE_ERROR((LM_ERROR, ACE_TEXT("Multiple invocations detected.\n"))); \ mInvocationCounter++; } while (0) /** * THis macro is the counter part to INVOCATION_ENTER(). It decreases the * invocation counter and then returns the given value. This macro is * here for convenience to decrease the invocation counter also when returning * due to errors. */ #define INVOCATION_RETURN(retval) do { mInvocationCounter--; \ return retval; } while(0) ReadHandler::ReadHandler() : ACE_Event_Handler(), mStream(), mDataSize(0), mData(0), mCallCounter(0), mInvocationCounter(0) { ACE_TRACE("ReadHandler::ReadHandler()"); } ReadHandler::~ReadHandler() { ACE_TRACE("ReadHandler::~ReadHandler()"); if (mStream.close() == -1) ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to close socket. ") ACE_TEXT ("(errno = %i: %m)\n"), ACE_ERRNO_GET)); delete[] mData; } ACE_SOCK_Stream &ReadHandler::getStream(void) { ACE_TRACE("ReadHandler::getStream(void)"); return mStream; } ACE_HANDLE ReadHandler::get_handle(void) const { ACE_TRACE("ReadHandler::get_handle(void)"); return mStream.get_handle(); } int ReadHandler::handle_input(ACE_HANDLE) { ACE_TRACE("ReadHandler::handle_input(ACE_HANDLE)"); INVOCATION_ENTER(); // the response sent to the client char response = 0; if (mCallCounter == 0) { /* * This is the first request from the client. */ // increase the call counter so the next client request goes to else-if mCallCounter++; // get the desired size from the client // Note: only use the sizeof and pointer to int on compatible // platforms (i.e. little-endian/big-endian, data type size) if (mStream.recv_n(&mDataSize, sizeof(mDataSize), &connTimeout) != (ssize_t) sizeof(mDataSize)) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to receive ") ACE_TEXT ("request. (errno = %i: %m)\n"), ACE_ERRNO_GET)); INVOCATION_RETURN(-1); } // The verbose debug output is replaced with some unintrusive dots. // This increases visibility of the desired effect. // ACE_DEBUG((LM_DEBUG, ACE_TEXT("%@: Data size: %i\n"), this, mDataSize)); ACE_DEBUG((LM_DEBUG, ACE_TEXT("."))); // check mDataSize for plausability then allocate memory if (mDataSize > 0) { mData = new (std::nothrow) char[mDataSize]; if (mData == 0) ACE_DEBUG((LM_DEBUG, ACE_TEXT("%N:%l: Failed to allocate ") ACE_TEXT ("data buffer.\n"))); else response = 'K'; } // send the response to the client (which is still 0, if the // allocation did not succeed) if (mStream.send_n(&response, sizeof(response), &connTimeout) != 1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to send ") ACE_TEXT ("response. (errno = %i: %m)\n"), ACE_ERRNO_GET)); INVOCATION_RETURN(-1); } if (response == 'K') INVOCATION_RETURN(0); // get another request from the same client else INVOCATION_RETURN(-1); // the client will not send data if response != 'K' } else if (mCallCounter == 1) { /* * This is the second request from the client. */ // increase the call counter, this read handler should not be called // again mCallCounter++; // receive the data from the client if (mStream.recv_n(mData, mDataSize, &connTimeout) != mDataSize) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to receive data.") ACE_TEXT ("(errno = %i: %m)\n"), ACE_ERRNO_GET)); INVOCATION_RETURN(-1); } response = 'K'; if (mStream.send_n(&response, 1, &connTimeout) != 1) { ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: Failed to send ") ACE_TEXT ("confirmation. (errno = %i: %m)\n"), ACE_ERRNO_GET)); INVOCATION_RETURN(-1); } INVOCATION_RETURN(-1); // ask for removal, since client does not send any more data } // this is to find strange actions with the call counter ACE_ERROR((LM_ERROR, ACE_TEXT("%N:%l: We should not get here."))); INVOCATION_RETURN(-1); } int ReadHandler::handle_close(ACE_HANDLE, ACE_Reactor_Mask) { ACE_TRACE("ReadHandler::handle_close(ACE_HANDLE, ACE_Reactor_Mask)"); delete this; return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/AcceptHandler.h0000644000175000017500000000316512576461726024507 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #ifndef __ACCEPTHANDLER_H__ #define __ACCEPTHANDLER_H__ #include #include #include /** * This accept handler is based on the provided solution from the ACE course. */ class AcceptHandler : public ACE_Event_Handler { private: /** * The reactor to which the accept handler belongs. */ ACE_Reactor *mReactor; /** * The socket used for incoming conections. */ ACE_SOCK_Acceptor mAcceptor; public: /** * @param reactor The reactor which will use this accept handler. */ AcceptHandler(ACE_Reactor *reactor = 0); /** * The destructor exists for tracing purposes. */ virtual ~AcceptHandler(); /** * Open the listening socket and register the handler with the reactor. * * @return 0 on success, -1 on failure */ int open(void); /** * @name Overridden methods from the ACE_Event_Handler */ // @{ /** * Provides the handle of mAcceptor. */ virtual ACE_HANDLE get_handle(void) const; /** * Create a read handler for the new connection and register that * handler with the reactor. */ virtual int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE); /** * Close the listening socket. */ virtual int handle_close(ACE_HANDLE, ACE_Reactor_Mask); // @} }; #endif /* __ACCEPTHANDLER_H__ */ ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/server.cpp0000644000175000017500000000336312576461726023653 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #include #include #include #include #include #include #include #include "AcceptHandler.h" /** * This is the function run by all threads in the thread pool. * * @param arg is expected to be of type (ACE_Reactor *) */ ACE_THR_FUNC_RETURN threadFunc(void *arg) { ACE_TRACE("threadFunc(void *)"); ACE_Reactor *reactor = (ACE_Reactor *) arg; reactor->run_reactor_event_loop(); return 0; } /** * The main function sets up the TP reactor. The code is basically taken from * the solution to exercise 4c of the ACE course. */ int ACE_TMAIN(int, ACE_TCHAR **) { // create a reactor from a TP reactor ACE_TP_Reactor tpReactor; ACE_Reactor reactor(&tpReactor); // create a new accept handler using that reactor AcceptHandler *acceptHandler = 0; ACE_NEW_NORETURN (acceptHandler, AcceptHandler(&reactor)); if (acceptHandler == 0) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to allocate ") ACE_TEXT ("accept handler. (errno = %i: %m)\n"), ACE_ERRNO_GET), -1); // open the accept handler if (acceptHandler->open() == -1) { delete acceptHandler; ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: Failed to open accept ") ACE_TEXT ("handler. Exiting.\n")), -1); } // spawn some threads which run the reactor event loop(s) ACE_Thread_Manager::instance()->spawn_n(9, threadFunc, &reactor); // let the thread manager wait for all threads ACE_Thread_Manager::instance()->wait(); ACE_DEBUG((LM_DEBUG, ACE_TEXT("Bye. Bye.\n"))); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/TP_Reactor/common.h0000644000175000017500000000065412576461726023302 0ustar pgquilespgquiles/* * ACE reactor demonstration * * Date: 26-Jan-2006 */ #ifndef __COMMON_H__ #define __COMMON_H__ #include /** * The port number used by client and server. */ static const int PORT = 4711; /** * The base size. 0x100000 = 1 MiB */ static const int BASE = 0x100000; /** * The timeout value for connections. (30 seconds) */ static const ACE_Time_Value connTimeout(30); #endif /* __COMMON_H__ */ ace-6.3.3+dfsg.orig/examples/Reactor/README0000644000175000017500000000101212576461726020504 0ustar pgquilespgquiles This directory contains subdirectories that test the ACE Reactor and Proactor . Dgram Tests the CODgram and Dgram classes with the Reactor. . Misc Various miscellaneous tests of Reactor functionality (e.g., signals, timers, notification, etc.). . Multicast Tests out the ACE multicast capabilities in conjunction with the Reactor. . Ntalker A program that implements a multicast "chat" program. . Proactor A program that illustrates the "Proactive" version of the Reactor ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/0000775000175000017500000000000012576472436022063 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Console_Input.cpp0000644000175000017500000000353312576461726025352 0ustar pgquilespgquiles //============================================================================= /** * @file Console_Input.cpp * * This application tests the working of WFMO_Reactor when users * are interested in console input. * * @author Irfan Pyarali */ //============================================================================= #include "ace/Reactor.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_string.h" #include "ace/OS_main.h" #include "ace/Log_Msg.h" class Event_Handler : public ACE_Event_Handler { public: Event_Handler (ACE_Reactor &reactor); int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); }; Event_Handler::Event_Handler (ACE_Reactor &reactor) { this->reactor (&reactor); if (this->reactor ()->register_handler (this, ACE_STDIN) != 0) ACE_ERROR ((LM_ERROR, "Registration with Reactor could not be done\n")); } int Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { ACE_TCHAR buffer[BUFSIZ]; int result = ACE_OS::read (ACE_STDIN, buffer, sizeof buffer); buffer[result] = '\0'; if (result <= 0) { this->reactor ()->close (); ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_OS::read"), -1); } if (ACE_OS::strcmp (ACE_TEXT("quit\r\n"), buffer) == 0) this->reactor ()->close (); ACE_DEBUG ((LM_DEBUG, "User input: %s", buffer)); return 0; } int Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Event_Handler removed from Reactor\n")); return 0; } int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_Reactor reactor; Event_Handler handler (reactor); int result = 0; while (result != -1) result = reactor.handle_events (); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Exceptions.cpp0000644000175000017500000000432112576461726024706 0ustar pgquilespgquiles//============================================================================= /** * @file Exceptions.cpp * * This test application tests the state of WFMO_Reactor when * exceptions occurs when executing user callbacks. * * The thread count in WFMO_Reactor is used to ensure that state of * WFMO_Reactor is not fouled up when exceptions occur in user code. * This example also shows how to write event loops that survive * user exceptions * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/WFMO_Reactor.h" class Event_Handler : public ACE_Event_Handler { public: Event_Handler (void) : event_ (1) { ACE_DEBUG ((LM_DEBUG, "Event_Handler created\n")); } ~Event_Handler (void) { ACE_DEBUG ((LM_DEBUG, "Event_Handler destroyed\n")); } int handle_signal (int, siginfo_t * = 0, ucontext_t * = 0) { char *cause_exception = 0; char a = *cause_exception; ACE_UNUSED_ARG(a); return 0; } ACE_HANDLE get_handle (void) const { return this->event_.handle (); } private: ACE_Manual_Event event_; }; class ACE_WFMO_Reactor_Test { public: static void doit (ACE_WFMO_Reactor &wfmo_reactor) { for (int i = 1; i <= 10; i++) { ACE_DEBUG ((LM_DEBUG, "Active threads in WFMO_Reactor (before handle_events) = %d\n", wfmo_reactor.active_threads_)); ACE_SEH_TRY { wfmo_reactor.handle_events (); } ACE_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER) { ACE_DEBUG ((LM_DEBUG, "Exception occurred\n")); } ACE_DEBUG ((LM_DEBUG, "Active threads in WFMO_Reactor (after handle_events) = %d\n", wfmo_reactor.active_threads_)); } } }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Event_Handler handler; ACE_WFMO_Reactor wfmo_reactor; wfmo_reactor.register_handler (&handler); ACE_WFMO_Reactor_Test::doit (wfmo_reactor); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Abandoned.cpp0000644000175000017500000000612712576461726024446 0ustar pgquilespgquiles //============================================================================= /** * @file Abandoned.cpp * * Tests the WFMO_Reactor's ability to handle abandoned mutexes. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Reactor.h" #include "ace/Thread_Manager.h" #include "ace/Process_Mutex.h" #include "ace/Auto_Event.h" class Event_Handler : public ACE_Event_Handler { public: int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); ACE_Auto_Event handle_; ACE_Process_Mutex *mutex_; int iterations_; }; static int abandon = 1; static ACE_THR_FUNC_RETURN worker (void *data) { Event_Handler *handler = (Event_Handler *) data; handler->handle_.signal (); handler->mutex_->acquire (); if (!abandon) handler->mutex_->release (); return 0; } int Event_Handler::handle_signal (int, siginfo_t *s, ucontext_t *) { ACE_HANDLE handle = s->si_handle_; if (handle == this->handle_.handle ()) ACE_Reactor::instance ()->register_handler (this, this->mutex_->lock ().proc_mutex_); else { ACE_Reactor::instance ()->remove_handler (this->mutex_->lock ().proc_mutex_, ACE_Event_Handler::DONT_CALL); delete this->mutex_; } return 0; } int Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) { --this->iterations_; ACE_DEBUG ((LM_DEBUG, "(%t) timeout occured @ %T, iterations left %d\n", this->iterations_)); if (this->iterations_ == 0) { ACE_Reactor::instance ()->remove_handler (this->handle_.handle (), ACE_Event_Handler::DONT_CALL); ACE_Reactor::instance ()->cancel_timer (this); ACE_Reactor::end_event_loop (); } else { ACE_NEW_RETURN (this->mutex_, ACE_Process_Mutex, -1); int result = ACE_Thread_Manager::instance ()->spawn (&worker, this); ACE_TEST_ASSERT (result != -1); } return 0; } int ACE_TMAIN (int , ACE_TCHAR *[]) { Event_Handler event_handler; event_handler.iterations_ = 5; int result = ACE_Reactor::instance ()->register_handler (&event_handler, event_handler.handle_.handle ()); ACE_TEST_ASSERT (result == 0); ACE_Time_Value timeout (2); result = ACE_Reactor::instance ()->schedule_timer (&event_handler, 0, timeout, timeout); ACE_TEST_ASSERT (result != -1); ACE_Reactor::run_event_loop (); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int , ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/run_test.pl0000755000175000017500000000346512576461726024274 0ustar pgquilespgquileseval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; use PerlACE::TestTarget; # # These tests only run on Win32 # if ($^O ne "MSWin32") { exit; } @tests = ( "Abandoned", "APC", # "Console_Input", # This test is interactive "Directory_Changes", "Exceptions", "Handle_Close", "Multithreading", # "Network_Events", # This test is interactive "Prerun_State_Changes", "Registration", "Registry_Changes", "Removals", "Suspended_Removals", # "Talker", # This test is interactive "Timeouts", "Window_Messages", ); my $target = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";; $test_timeout = 60 + $target->ProcessStartWaitInterval(); for $test (@tests) { print STDOUT "\n________________________________________\n"; print STDOUT "\nStarting test \"$test\""; print STDOUT "\n________________________________________\n\n"; my $test_process = $target->CreateProcess($test); if (! -e $test_process->Executable ()) { print STDERR "Error: " . $test_process->Executable () . " does not exist or is not runnable\n"; } else { $test_process->Spawn (); $test_result = $test_process->WaitKill ($test_timeout); if ($test_result != 0) { print STDERR "\n________________________________________\n"; print STDERR "\nERROR: \"$test\" returned $test_result"; print STDERR "\n________________________________________\n"; } } print STDOUT "\n________________________________________\n"; print STDOUT "\n\"$test\" completed"; print STDOUT "\n________________________________________\n"; } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Network_Events.cpp0000644000175000017500000001217212576461726025545 0ustar pgquilespgquiles//============================================================================= /** * @file Network_Events.cpp * * This application tests Reactor to make sure that it responds * correctly to different kinds of network events. * * The test starts off by creating a Network_Listener, that listens * for connections at ACE_DEFAULT_SERVER_PORT. When a client * connects, a Network_Handler is created. Network_Handler reads * messages off the socket and prints them out. This is done until * the remote side shuts down. Multiple clients can connect at the * same time. * * Events tested in this example includes ACCEPT, READ, and CLOSE masks. * * To run this example, start an instance of this example and * connect to it using telnet (to port * ACE_DEFAULT_SERVER_PORT(20002)). * * @author Irfan Pyarali */ //============================================================================= #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" #include "ace/INET_Addr.h" #include "ace/SOCK_Stream.h" #include "ace/SOCK_Acceptor.h" #include "ace/OS_main.h" class Network_Handler : public ACE_Event_Handler { public: /// Default constructor Network_Handler (ACE_SOCK_Stream &s); virtual int handle_input (ACE_HANDLE handle); virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); virtual ACE_HANDLE get_handle (void) const; ACE_SOCK_Stream stream_; }; Network_Handler::Network_Handler (ACE_SOCK_Stream &s) : stream_ (s) { this->reactor (ACE_Reactor::instance ()); int result = this->reactor ()->register_handler (this, READ_MASK); ACE_TEST_ASSERT (result == 0); } ACE_HANDLE Network_Handler::get_handle (void) const { return this->stream_.get_handle (); } int Network_Handler::handle_input (ACE_HANDLE handle) { ACE_DEBUG ((LM_DEBUG, "Network_Handler::handle_input handle = %d\n", handle)); while (1) { char message[BUFSIZ]; int result = this->stream_.recv (message, sizeof message); if (result > 0) { message[result] = 0; ACE_DEBUG ((LM_DEBUG, "Remote message: %s\n", message)); } else if (result == 0) { ACE_DEBUG ((LM_DEBUG, "Connection closed\n")); return -1; } else if (errno == EWOULDBLOCK) { return 0; } else { ACE_DEBUG ((LM_DEBUG, "Problems in receiving data, result = %d", result)); return -1; } } } int Network_Handler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Network_Handler::handle_close handle = %d\n", handle)); this->stream_.close (); delete this; ACE_Reactor::end_event_loop (); return 0; } class Network_Listener : public ACE_Event_Handler { public: /// Default constructor /// Default constructor Network_Listener (void); ~Network_Listener (void); virtual int handle_input (ACE_HANDLE handle); virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); ACE_HANDLE get_handle (void) const; ACE_INET_Addr local_address_; ACE_SOCK_Acceptor acceptor_; }; Network_Listener::Network_Listener (void) : local_address_ (ACE_DEFAULT_SERVER_PORT), acceptor_ (local_address_, 1) { this->reactor (ACE_Reactor::instance ()); int result = this->reactor ()->register_handler (this, ACE_Event_Handler::ACCEPT_MASK); ACE_TEST_ASSERT (result == 0); } Network_Listener::~Network_Listener (void) { } ACE_HANDLE Network_Listener::get_handle (void) const { return this->acceptor_.get_handle (); } int Network_Listener::handle_input (ACE_HANDLE handle) { ACE_DEBUG ((LM_DEBUG, "Network_Listener::handle_input handle = %d\n", handle)); ACE_INET_Addr remote_address; ACE_SOCK_Stream stream; // Try to find out if the implementation of the reactor that we are // using requires us to reset the event association for the newly // created handle. This is because the newly created handle will // inherit the properties of the listen handle, including its event // associations. int reset_new_handle = this->reactor ()->uses_event_associations (); int result = this->acceptor_.accept (stream, // stream &remote_address, // remote address 0, // timeout 1, // restart reset_new_handle); // reset new handler ACE_TEST_ASSERT (result == 0); ACE_DEBUG ((LM_DEBUG, "Remote connection from: ")); remote_address.dump (); Network_Handler *handler = 0; ACE_NEW_RETURN (handler, Network_Handler (stream), -1); return 0; } int Network_Listener::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Network_Listener::handle_close handle = %d\n", handle)); this->acceptor_.close (); delete this; return 0; } int ACE_TMAIN (int, ACE_TCHAR *[]) { Network_Listener *listener = 0; listener = new Network_Listener; ACE_UNUSED_ARG (listener); ACE_Reactor::run_event_loop (); return 0; }; ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Registration.cpp0000644000175000017500000001120512576461726025236 0ustar pgquilespgquiles//============================================================================= /** * @file Registration.cpp * * This test application tests a wide range of registration, * suspension, resumption, and removal of events from Reactor. * * The application initially registers two events with Reactor. A * auxiliary thread is created to do the signaling on the * events. When the first event is signaled, the event is suspended * from Reactor. The event is then signaled again, but is "lost" * since the handler has been suspended. When the second event is * signal, the first event is resumed and the second is * suspended. When the first event is signaled again, both events * are removed from Reactor. * * This test shows off the following features of Reactor: * - Registration * - Suspension * - Resumption * - Removal (while active and while suspended) * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Reactor.h" #include "ace/Auto_Event.h" #include "ace/OS_NS_unistd.h" #include "ace/Log_Msg.h" // Globals for this test int stop_test = 0; ACE_Reactor reactor; class Simple_Handler : public ACE_Event_Handler { public: /// Default constructor Simple_Handler (void); virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); ACE_Auto_Event event1_; ACE_Auto_Event event2_; int handle_signal_count_; int handle_close_count_; }; Simple_Handler::Simple_Handler (void) : handle_signal_count_ (0), handle_close_count_ (0) { } int Simple_Handler::handle_signal (int, siginfo_t *s, ucontext_t *) { ACE_HANDLE handle = s->si_handle_; ACE_UNUSED_ARG (handle); this->handle_signal_count_++; if (this->handle_signal_count_ == 1) this->reactor ()->suspend_handler (event1_.handle ()); else if (this->handle_signal_count_ == 2) { this->reactor ()->resume_handler (event1_.handle ()); this->reactor ()->suspend_handler (event2_.handle ()); } else if (this->handle_signal_count_ == 3) { this->reactor ()->remove_handler (event1_.handle (), ACE_Event_Handler::NULL_MASK); this->reactor ()->remove_handler (event2_.handle (), ACE_Event_Handler::NULL_MASK); } return 0; } int Simple_Handler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Simple_Handler::handle_close handle = %d\n", handle)); this->handle_close_count_++; if (this->handle_close_count_ == 1) stop_test = 0; else if (this->handle_close_count_ == 2) stop_test = 1; return 0; } // Globals for this test Simple_Handler simple_handler; void worker (void) { ACE_DEBUG ((LM_DEBUG, "(%t) Thread creation\n")); ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "(%t) Thread signaling %d\n", simple_handler.event1_.handle())); simple_handler.event1_.signal (); ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "(%t) Thread signaling %d\n", simple_handler.event1_.handle())); ACE_DEBUG ((LM_DEBUG, "Note: This signal should be \"lost\" because of the suspended handler\n")); simple_handler.event1_.signal (); ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "(%t) Thread resetting %d\n", simple_handler.event1_.handle())); simple_handler.event1_.reset (); ACE_DEBUG ((LM_DEBUG, "(%t) Thread signaling %d\n", simple_handler.event2_.handle())); simple_handler.event2_.signal (); ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "(%t) Thread signaling %d\n", simple_handler.event1_.handle())); simple_handler.event1_.signal (); ACE_DEBUG ((LM_DEBUG, "(%t) Thread death\n")); } int ACE_TMAIN (int, ACE_TCHAR *[]) { int result = reactor.register_handler (&simple_handler, simple_handler.event1_.handle ()); ACE_TEST_ASSERT (result == 0); result = reactor.register_handler (&simple_handler, simple_handler.event2_.handle ()); ACE_TEST_ASSERT (result == 0); result = ACE_OS::thr_create ((ACE_THR_FUNC) worker, 0, 0, 0); ACE_TEST_ASSERT (result == 0); result = 0; while (!stop_test && result != -1) { result = reactor.handle_events (); } return 0; }; #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/APC.cpp0000644000175000017500000000550312576461726023173 0ustar pgquilespgquiles //============================================================================= /** * @file APC.cpp * * Tests the WFMO_Reactor's ability to handle regular APC * notifications. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) #include "ace/Reactor.h" #include "ace/Auto_Event.h" #include "ace/Log_Msg.h" class Event_Handler : public ACE_Event_Handler { public: int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); ACE_Auto_Event handle_; int iterations_; }; static Event_Handler *global_event_handler; static void WINAPI apc_callback (DWORD) { ACE_DEBUG ((LM_DEBUG, "(%t) apc occured @ %T\n")); global_event_handler->handle_.signal (); } void queue_apc (void) { DWORD result = ::QueueUserAPC (reinterpret_cast (&apc_callback), // pointer to APC function ::GetCurrentThread (), // handle to the thread 0); // argument for the APC function if (result == FALSE) ACE_OS::exit (-1); } int Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { --this->iterations_; if (this->iterations_ == 0) { ACE_Reactor::instance ()->remove_handler (this->handle_.handle (), ACE_Event_Handler::DONT_CALL); ACE_Reactor::end_event_loop (); } return 0; } int Event_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, "(%t) timeout occured @ %T\n")); queue_apc (); return 0; } int ACE_TMAIN (int, ACE_TCHAR *[]) { Event_Handler event_handler; event_handler.iterations_ = 5; global_event_handler = &event_handler; int result = ACE_Reactor::instance ()->register_handler (&event_handler, event_handler.handle_.handle ()); ACE_TEST_ASSERT (result == 0); ACE_Time_Value timeout (2); result = ACE_Reactor::instance ()->schedule_timer (&event_handler, 0, timeout, timeout); ACE_TEST_ASSERT (result != -1); ACE_Reactor::run_alertable_event_loop (); ACE_Reactor::instance ()->cancel_timer(&event_handler); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/WFMO_Reactor.mpc0000644000175000017500000000344312576461726025015 0ustar pgquilespgquiles// -*- MPC -*- project(*Abandoned): aceexe, wfmo { exename = abandoned Source_Files { Abandoned.cpp } } project(*APC): aceexe, wfmo { exename = apc Source_Files { APC.cpp } } project(*Console_Input): aceexe, wfmo { exename = console_input Source_Files { Console_Input.cpp } } project(*Directory_Changes): aceexe, wfmo { exename = directory_changes Source_Files { Directory_Changes.cpp } } project(*Exceptions): aceexe, wfmo { exename = exceptions Source_Files { Exceptions.cpp } } project(*Handle_Close): aceexe, wfmo { exename = handle_close Source_Files { Handle_Close.cpp } } project(*Multithreading): aceexe, wfmo { exename = multithreading Source_Files { Multithreading.cpp } } project(*Network_Events): aceexe, wfmo { exename = network_events Source_Files { Network_Events.cpp } } project(*Prerun_State_Changes): aceexe, wfmo { exename = prerun_state_changes Source_Files { Prerun_State_Changes.cpp } } project(*Registration): aceexe, wfmo { exename = registration Source_Files { Registration.cpp } } project(*Registry_Changes): aceexe, wfmo, avoids_ace_for_tao { exename = registry_changes Source_Files { Registry_Changes.cpp } } project(*Removals): aceexe, wfmo { exename = removals Source_Files { Removals.cpp } } project(*Suspended_Removals): aceexe, wfmo { exename = suspended_removals Source_Files { Suspended_Removals.cpp } } project(*Talker): aceexe, wfmo, avoids_ace_for_tao { exename = talker Source_Files { Talker.cpp } } project(*Timeouts): aceexe, wfmo { exename = timeouts Source_Files { Timeouts.cpp } } project(*Window_Messages): aceexe, wfmo, avoids_ace_for_tao { exename = window_messages Source_Files { Window_Messages.cpp } } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Multithreading.cpp0000644000175000017500000001641212576461726025551 0ustar pgquilespgquiles//============================================================================= /** * @file Multithreading.cpp * * This application tests multiple threads simultaneously calling * Reactor::handle_events(). It also shows how different threads * can update the state of Reactor by registering and removing * Event_Handlers. * * Note that this test will only work with WFMO_Reactor * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Task.h" #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" #include "ace/Get_Opt.h" #include "ace/OS_NS_time.h" static int concurrent_threads = 1; static int number_of_handles = static_cast (ACE_Reactor::instance ()->size ()); static int number_of_handles_to_signal = 1; static int interval = 2; static int iterations = 10; // Explain usage and exit. static void print_usage_and_die (void) { ACE_DEBUG ((LM_DEBUG, "usage: \n\t" "[-t (# of threads - default 1)] \n\t" "[-h (# of handlers) - default 62] \n\t" "[-i (# time interval between signals) - default 2] \n\t" "[-s (# of handles to signal) - default 1] \n\t" "[-e (# of iterations) - default 10] \n\t")); ACE_OS::exit (1); } // Parse the command-line arguments and set options. static void parse_args (int argc, ACE_TCHAR **argv) { ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("t:h:s:i:e:")); int c; while ((c = get_opt ()) != -1) switch (c) { case 't': concurrent_threads = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'e': iterations = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'h': number_of_handles = ACE_OS::atoi (get_opt.opt_arg ()); break; case 'i': interval = ACE_OS::atoi (get_opt.opt_arg ()); break; case 's': number_of_handles_to_signal = ACE_OS::atoi (get_opt.opt_arg ()); break; default: print_usage_and_die (); break; } } class Task_Handler : public ACE_Task { public: /// Constructor. Task_Handler (size_t number_of_handles, size_t concurrent_threads); /// Destructor. ~Task_Handler (void); /// Called when object is removed from the ACE_Reactor virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); /// Handle events being signaled by the main thread. int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); /// Called when timer expires. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); /// Task event loop. int svc (void); //FUZZ: disable check_for_lack_ACE_OS /// Signal an event. ///FUZZ: enable check_for_lack_ACE_OS int signal (size_t index); private: ACE_Auto_Event *events_; }; // All threads do reactor->handle_events () int Task_Handler::svc (void) { // Try to become the owner ACE_Reactor::instance ()->owner (ACE_Thread::self ()); // Run the event loop. return ACE_Reactor::run_event_loop (); } Task_Handler::Task_Handler (size_t number_of_handles, size_t concurrent_threads) { ACE_NEW (this->events_, ACE_Auto_Event [number_of_handles]); for (size_t i = 0; i < number_of_handles; ++i) if (ACE_Reactor::instance ()->register_handler (this, this->events_[i].handle ()) == -1) ACE_ERROR ((LM_ERROR, "%p\t cannot register handle %d with Reactor\n", "Task_Handler::Task_Handler", i)); // Make us an active object. if (this->activate (THR_NEW_LWP, static_cast (concurrent_threads)) == -1) ACE_ERROR ((LM_ERROR, "%p\t cannot activate task\n", "activate")); } Task_Handler::~Task_Handler (void) { this->reactor (0); delete [] this->events_; } int Task_Handler::handle_signal (int, siginfo_t *siginfo, ucontext_t *) { // When signaled, print message, remove self, and add self // This will force Reactor to update its internal handle tables ACE_DEBUG ((LM_DEBUG, "(%t) calls handle_signal for handle %d\n", siginfo->si_handle_)); if (ACE_Reactor::instance ()->remove_handler (siginfo->si_handle_, ACE_Event_Handler::DONT_CALL) == -1) return -1; // ACE_ERROR_RETURN ((LM_ERROR, // "(%t) %p\tTask cannot be unregistered from Reactor: handle value = %d\n", // "Task_Handler::handle_signal", // siginfo->si_handle_), -1); if (ACE_Reactor::instance ()->register_handler (this, siginfo->si_handle_) == -1) return -1; // ACE_ERROR_RETURN ((LM_ERROR, // "(%t) %p\tTask cannot be registered with Reactor: handle value = %d\n", // "Task_Handler::handle_signal", // siginfo->si_handle_), -1); return 0; } int Task_Handler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "(%t) handle_close() called: handle value = %d\n", handle)); return 0; } int Task_Handler::handle_timeout (const ACE_Time_Value &, const void *arg) { ACE_DEBUG ((LM_DEBUG, "(%t) handle_timeout() called: iteration value = %d\n", size_t (arg))); return 0; } int Task_Handler::signal (size_t index) { return this->events_[index].signal (); } int ACE_TMAIN (int argc, ACE_TCHAR **argv) { parse_args (argc, argv); Task_Handler task (number_of_handles, concurrent_threads); ACE_OS::srand ((u_int) ACE_OS::time (0L)); for (int i = 1; i <= iterations; i++) { // Sleep for a while ACE_OS::sleep (interval); // Randomly generate events ACE_DEBUG ((LM_DEBUG, "********************************************************\n")); ACE_DEBUG ((LM_DEBUG, "(%t -- main thread) signaling %d events : iteration = %d\n", number_of_handles_to_signal, i)); ACE_DEBUG ((LM_DEBUG, "********************************************************\n")); // Setup a timer for the task if (ACE_Reactor::instance ()->schedule_timer (&task, (void *)((size_t)i), ACE_Time_Value::zero) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); for (int i = 0; i < number_of_handles_to_signal; i++) // Randomly select a handle to signal. task.signal (ACE_OS::rand() % number_of_handles); } // Sleep for a while ACE_OS::sleep (interval); // End the Reactor event loop ACE_Reactor::end_event_loop (); // Wait for all threads to exit ACE_Thread_Manager::instance ()->wait (); // Close the Reactor singleton before exiting this function. // If we wait for the Object Manager to do this, it will be too // late since Task_Handler instance would have disappeared. ACE_Reactor::close_singleton (); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Window_Messages.cpp0000644000175000017500000000434212576461726025666 0ustar pgquilespgquiles //============================================================================= /** * @file Window_Messages.cpp * * Tests the Msg_WFMO_Reactor's ability to handle regular events * and window messages. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) && !defined (ACE_LACKS_MSG_WFMO) #include "ace/Msg_WFMO_Reactor.h" #include "ace/Reactor.h" #include "ace/Auto_Ptr.h" #include "ace/Auto_Event.h" class Event_Handler : public ACE_Event_Handler { public: int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); ACE_Auto_Event handle_; int iterations_; }; int Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { --this->iterations_; if (this->iterations_ == 0) ACE_Reactor::end_event_loop (); return 0; } static Event_Handler *global_event_handler; void WINAPI timer_callback (HWND, UINT, UINT, DWORD dwTime) { ACE_DEBUG ((LM_DEBUG, "(%t) timeout occured @ %u\n", dwTime)); global_event_handler->handle_.signal (); } int ACE_TMAIN (int, ACE_TCHAR*[]) { // Manage memory automagically. ACE_Reactor_Impl *impl = new ACE_Msg_WFMO_Reactor; auto_ptr reactor (new ACE_Reactor (impl, 1)); ACE_Reactor::instance (reactor.get ()); Event_Handler event_handler; global_event_handler = &event_handler; event_handler.iterations_ = 5; int result = ACE_Reactor::instance ()->register_handler (&event_handler, event_handler.handle_.handle ()); ACE_TEST_ASSERT (result == 0); ACE_Time_Value timeout (1); result = ACE_Utils::truncate_cast ( ::SetTimer (0, // handle of window for timer messages 0, // timer identifier timeout.msec (), // time-out value (TIMERPROC) &timer_callback)); // address of timer procedure ACE_TEST_ASSERT (result != 0); ACE_Reactor::run_event_loop (); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int , ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 && !ACE_LACKS_MSG_WFMO */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Directory_Changes.cpp0000644000175000017500000000632712576461726026171 0ustar pgquilespgquiles//============================================================================= /** * @file Directory_Changes.cpp * * This application tests the working of WFMO_Reactor when users * are interested in monitoring changes in the filesystem. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Reactor.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" #include "ace/Log_Msg.h" static int stop_test = 0; static const ACE_TCHAR *directory = ACE_TEXT ("."); static const ACE_TCHAR *temp_file = ACE_TEXT ("foo"); class Event_Handler : public ACE_Event_Handler { public: Event_Handler (ACE_Reactor &reactor); ~Event_Handler (void); int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); private: ACE_HANDLE handle_; }; Event_Handler::Event_Handler (ACE_Reactor &reactor) : handle_ (ACE_INVALID_HANDLE) { this->reactor (&reactor); int change_notification_flags = FILE_NOTIFY_CHANGE_FILE_NAME; this->handle_ = ACE_TEXT_FindFirstChangeNotification (directory, // pointer to name of directory to watch FALSE, // flag for monitoring directory or directory tree change_notification_flags // filter conditions to watch for ); if (this->handle_ == ACE_INVALID_HANDLE) ACE_ERROR ((LM_ERROR, "FindFirstChangeNotification could not be setup\n")); if (this->reactor ()->register_handler (this, this->handle_) != 0) ACE_ERROR ((LM_ERROR, "Registration with Reactor could not be done\n")); } Event_Handler::~Event_Handler (void) { } int Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { ::FindNextChangeNotification (this->handle_); if (stop_test) this->reactor ()->close (); return 0; } int Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Event_Handler removed from Reactor\n")); ::FindCloseChangeNotification (this->handle_); return 0; } void worker (void) { ACE_DEBUG ((LM_DEBUG, "(%t) Thread creation\n")); ACE_DEBUG ((LM_DEBUG, "(%t) Thread creating temporary file\n")); ACE_HANDLE file = ACE_OS::open (temp_file, _O_CREAT | _O_EXCL); if (file == ACE_INVALID_HANDLE) ACE_ERROR ((LM_ERROR, "Error in creating %s: %p\n", temp_file, "ACE_OS::open")); else { ACE_OS::close (file); ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (3); ACE_DEBUG ((LM_DEBUG, "(%t) Thread removing temporary file\n")); stop_test = 1; ACE_OS::unlink (temp_file); } } int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_Reactor reactor; Event_Handler handler (reactor); int result = ACE_OS::thr_create ((ACE_THR_FUNC) worker, 0, 0, 0); ACE_TEST_ASSERT (result == 0); for (result = 0; result != -1; result = reactor.handle_events ()) continue; return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Removals.cpp0000644000175000017500000000505012576461726024355 0ustar pgquilespgquiles//============================================================================= /** * @file Removals.cpp * * Tests the Reactor's ability to handle simultaneous events. If * you pass anything on the command-line, then each handler * requests to be removed from the Reactor after each event. * * @author Tim Harrison Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Reactor.h" #include "ace/Service_Config.h" #include "ace/Event.h" /** * @class Event_Handler * * @brief Generic Event Handler. * * Creates event. Registers with Reactor. Signals event. If * created with -close_down- it returns -1 from handle signal. */ class Event_Handler : public ACE_Event_Handler { public: Event_Handler (int event_number, int close_down) : event_number_ (event_number), close_down_ (close_down) { if (ACE_Reactor::instance ()->register_handler (this, this->event_.handle ()) == -1) ACE_ERROR ((LM_ERROR, "%p\tevent handler %d cannot be added to Reactor\n", "", event_number_)); this->event_.signal (); } virtual int handle_signal (int, siginfo_t *, ucontext_t *) { if (this->close_down_) return -1; else return 0; } virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "event handler %d closed.\n", event_number_)); delete this; return 0; } virtual ACE_HANDLE get_handle (void) const { return event_.handle (); } private: /// Our event number. int event_number_; /// Shall we close down or not. int close_down_; /// Signaled to shut down the handler. ACE_Event event_; }; int ACE_TMAIN (int argc, ACE_TCHAR *[]) { int close_down = argc > 1 ? 1 : 0; for (size_t i = 1; i <= ACE_Reactor::instance ()->size (); i++) new Event_Handler (static_cast (i), close_down); int result = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_Time_Value time (1); //FUZZ: enable check_for_lack_ACE_OS while (1) { result = ACE_Reactor::instance ()->handle_events (time); if (result == 0 && errno == ETIME) { ACE_DEBUG ((LM_DEBUG, "No more work left: timing out\n")); break; } if (result == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); } return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int , ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Talker.cpp0000644000175000017500000004471012576461726024015 0ustar pgquilespgquiles //============================================================================= /** * @file Talker.cpp * * This test application tests a wide range of events that can be * demultiplexed using various ACE utilities. Events used include * ^C events, reading from STDIN, vanilla Win32 events, thread * exits, Reactor notifications, proactive reads, and proactive * writes. * * The proactive I/O events are demultiplexed by the ACE_Proactor. * The thread exits, notications, and vanilla Win32 events are * demultiplexed by the ACE_Reactor. To enable a single thread * to run all these events, the Proactor is integrated with the * Reactor. * * The test application prototypes a simple talk program. Two * instances of the application connect. Input from either console * is displayed on the others console also. Because of the evils * of Win32 STDIN, a separate thread is used to read from STDIN. * To test the Proactor and Reactor, I/O between the remote * processes is performed proactively and interactions between the * STDIN thread and the main thread are performed reactively. * * The following description of the test application is in two * parts. The participants section explains the main components * involved in the application. The collaboration section * describes how the partipants interact in response to the * multiple event types which occur. * * The Reactor test application has the following participants: * * . Reactor -- The Reactor demultiplexes Win32 "waitable" * events using WaitForMultipleObjects. * * . Proactor -- The proactor initiates and demultiplexes * overlapped I/O operations. The Proactor registers with the * Reactor so that a single-thread can demultiplex all * application events. * * . STDIN_Handler -- STDIN_Handler is an Active Object which reads * from STDIN and forwards the input to the Peer_Handler. This * runs in a separate thread to make the test more interesting. * However, STDIN is "waitable", so in general it can be waited on * by the ACE Reactor, thanks MicroSlush! * * . Peer_Handler -- The Peer_Handler connects to another instance * of test_reactor. It Proactively reads and writes data to the * peer. When the STDIN_Handler gives it messages, it fowards them * to the remote peer. When it receives messages from the remote * peer, it prints the output to the console. * * The collaborations of the participants are as follows: * * . Initialization * * Peer_Handler -- connects to the remote peer. It then begins * proactively reading from the remote connection. Note that it * will be notified by the Proactor when a read completes. It * also registers a notification strategy with message queue so * that it is notified when the STDIN_Handler posts a message * onto the queue. * * STDIN_Handler -- STDIN_Handler registers a signal handler for * SIGINT. This just captures the exception so that the kernel * doesn't kill our process; We want to exit gracefully. It also * creates an Exit_Hook object which registers the * STDIN_Handler's thread handle with the Reactor. The * Exit_Hook will get called back when the STDIN_Handler thread * exits. After registering these, it blocks reading from STDIN. * * Proactor -- is registered with the Reactor. * * The main thread of control waits in the Reactor. * * . STDIN events -- When the STDIN_Handler thread reads from * STDIN, it puts the message on Peer_Handler's message queue. It * then returns to reading from STDIN. * * . Message enqueue -- The Reactor thread wakes up and calls * Peer_Handler::handle_output. The Peer_Handler then tries to * dequeue a message from its message queue. If it can, the * message is Proactively sent to the remote peer. Note that the * Peer_Handler will be notified with this operation is complete. * The Peer_Handler then falls back into the Reactor event loop. * * . Send complete event -- When a proactive send is complete, the * Proactor is notified by the Reactor. The Proactor, in turn, * notifies the Peer_Handler. The Peer_Handler then checks for * more messages from the message queue. If there are any, it * tries to send them. If there are not, it returns to the * Reactor event loop. * * . Read complete event -- When a proactive read is complete (the * Peer_Handler initiated a proactive read when it connected to the * remote peer), the Proactor is notified by the Reactor. The * Proactor, in turn notifies the Peer_Handler. If the read was * successful the Peer_Handler just displays the received msg to * the console and reinvokes a proactive read from the network * connection. If the read failed (i.e. the remote peer exited), * the Peer_Handler sets a flag to end the event loop and returns. * This will cause the application to exit. * * . ^C events -- When the user types ^C at the console, the * STDIN_Handler's signal handler will be called. It does nothing, * but as a result of the signal, the STDIN_Handler thread will * exit. * * . STDIN_Handler thread exits -- The Exit_Hook will get called * back from the Reactor. Exit_Hook::handle_signal sets a flag * to end the event loop and returns. This will cause the * application to exit. * * To run example, start an instance of the test with an optional * local port argument (as the acceptor). Start the other instance * with -h and -p . Type in either the * client or server windows and your message should show up in the * other window. Control C to exit. * * @author Tim Harrison Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) #include "ace/Reactor.h" #include "ace/Reactor_Notification_Strategy.h" #include "ace/WIN32_Proactor.h" #include "ace/Proactor.h" #include "ace/SOCK_Connector.h" #include "ace/SOCK_Acceptor.h" #include "ace/Get_Opt.h" #include "ace/Service_Config.h" #include "ace/Task.h" #include "ace/OS_NS_unistd.h" typedef ACE_Task MT_TASK; /** * @class Peer_Handler * * @brief Connect to a server. Receive messages from STDIN_Handler * and forward them to the server using proactive I/O. */ class Peer_Handler : public MT_TASK, public ACE_Handler { public: // = Initialization methods. Peer_Handler (int argc, ACE_TCHAR *argv[]); ~Peer_Handler (void); //FUZZ: disable check_for_lack_ACE_OS /** * This method creates the network connection to the remote peer. * It does blocking connects and accepts depending on whether a * hostname was specified from the command line. *FUZZ: enable check_for_lack_ACE_OS */ int open (void * =0); /** * This method will be called when an asynchronous read completes on a stream. * The remote peer has sent us something. If it succeeded, print * out the message and reinitiate a read. Otherwise, fail. In both * cases, delete the message sent. */ virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); /** * This method will be called when an asynchronous write completes on a strea_m. * One of our asynchronous writes to the remote peer has completed. * Make sure it succeeded and then delete the message. */ virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); /** * Get the I/O handle used by this . This method will be * called by the ACE_Asynch_* classes when an ACE_INVALID_HANDLE is * passed to . */ virtual ACE_HANDLE handle (void) const; /// Set the ACE_HANDLE value for this Handler. void handle (ACE_HANDLE); /// We've been removed from the Reactor. virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); /** * Called when output events should start. Note that this is * automatically invoked by the * . */ virtual int handle_output (ACE_HANDLE fd); private: /// Socket that we have connected to the server. ACE_SOCK_Stream stream_; /// The strategy object that the reactor uses to notify us when /// something is added to the queue. ACE_Reactor_Notification_Strategy strategy_; // = Remote peer info. /// Name of remote host. ACE_TCHAR *host_; /// Port number for remote host. u_short port_; /// Read stream ACE_Asynch_Read_Stream rd_stream_; /// Write stream ACE_Asynch_Write_Stream wr_stream_; /// Message Block for reading from the network ACE_Message_Block mb_; }; /** * @class STDIN_Handler * * @brief Active Object. Reads from STDIN and passes message blocks to * the peer handler. */ class STDIN_Handler : public ACE_Task { public: /// Initialization. STDIN_Handler (MT_TASK &ph); //FUZZ: disable check_for_lack_ACE_OS /// Activate object. virtual int open (void * = 0); /// Shut down. ///FUZZ: enable check_for_lack_ACE_OS virtual int close (u_long = 0); /// Thread runs here as an active object. int svc (void); int handle_close (ACE_HANDLE, ACE_Reactor_Mask); private: /// Handle a ^C. (Do nothing, this just illustrates how we can catch /// signals along with the other things). static void handler (int signum); /// Helper function to register with the Reactor for thread exit. void register_thread_exit_hook (void); /// The STDIN thread has exited. This means the user hit ^C. We can /// end the event loop. virtual int handle_signal (int index, siginfo_t *, ucontext_t *); /// Send all input to ph_. MT_TASK &ph_; /// Handle of our thread. ACE_HANDLE thr_handle_; }; Peer_Handler::Peer_Handler (int argc, ACE_TCHAR *argv[]) : strategy_ (ACE_Reactor::instance (), this, ACE_Event_Handler::WRITE_MASK), host_ (0), port_ (ACE_DEFAULT_SERVER_PORT), mb_ (BUFSIZ) { // This code sets up the message to notify us when a new message is // added to the queue. Actually, the queue notifies Reactor which // then notifies us. this->msg_queue ()->notification_strategy (&this->strategy_); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("h:p:")); int c; while ((c = get_opt ()) != EOF) { switch (c) { case 'h': host_ = get_opt.opt_arg (); break; case 'p': port_ = ACE_OS::atoi (get_opt.opt_arg ()); break; } } } Peer_Handler::~Peer_Handler (void) { } // This method creates the network connection to the remote peer. It // does blocking connects and accepts depending on whether a hostname // was specified from the command line. int Peer_Handler::open (void *) { if (host_ != 0) // Connector { ACE_INET_Addr addr (port_, host_); ACE_SOCK_Connector connector; // Establish connection with server. if (connector.connect (stream_, addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); ACE_DEBUG ((LM_DEBUG, "(%t) connected.\n")); } else // Acceptor { ACE_SOCK_Acceptor acceptor; ACE_INET_Addr local_addr (port_); if ((acceptor.open (local_addr) == -1) || (acceptor.accept (this->stream_) == -1)) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept failed"), -1); ACE_DEBUG ((LM_DEBUG, "(%t) accepted.\n")); } int result = this->rd_stream_.open (*this); if (result != 0) return result; result = this->wr_stream_.open (*this); if (result != 0) return result; result = this->rd_stream_.read (this->mb_, this->mb_.size ()); return result; } // One of our asynchronous writes to the remote peer has completed. // Make sure it succeeded and then delete the message. void Peer_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result) { if (result.bytes_transferred () <= 0) ACE_DEBUG ((LM_DEBUG, "(%t) %p bytes = %d\n", "Message failed", result.bytes_transferred ())); // This was allocated by the STDIN_Handler, queued, dequeued, passed // to the proactor, and now passed back to us. result.message_block ().release (); } // The remote peer has sent us something. If it succeeded, print // out the message and reinitiate a read. Otherwise, fail. In both // cases, delete the message sent. void Peer_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { if (result.bytes_transferred () > 0 && this->mb_.length () > 0) { this->mb_.rd_ptr ()[result.bytes_transferred ()] = '\0'; // Print out the message received from the server. ACE_DEBUG ((LM_DEBUG, "%s", this->mb_.rd_ptr ())); } else { // If a read failed, we will assume it's because the remote peer // went away. We will end the event loop. Since we're in the // main thread, we don't need to do a notify. ACE_Reactor::end_event_loop(); return; } // Reset pointers this->mb_.wr_ptr (this->mb_.wr_ptr () - result.bytes_transferred ()); // Start off another read if (this->rd_stream_.read (this->mb_, this->mb_.size ()) == -1) ACE_ERROR ((LM_ERROR, "%p Read initiate.\n", "Peer_Handler")); } // This is so the Proactor can get our handle. ACE_HANDLE Peer_Handler::handle (void) const { return this->stream_.get_handle (); } void Peer_Handler::handle (ACE_HANDLE handle) { this->stream_.set_handle (handle); } // We've been removed from the Reactor. int Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "(%t) Peer_Handler closing down\n")); return 0; } // New stuff added to the message queue. Try to dequeue a message. int Peer_Handler::handle_output (ACE_HANDLE) { ACE_Message_Block *mb = 0; ACE_Time_Value tv (ACE_Time_Value::zero); // Forward the message to the remote peer receiver. if (this->getq (mb, &tv) != -1) { if (this->wr_stream_.write (*mb, mb->length ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p Write initiate.\n", "Peer_Handler"), -1); } return 0; } void STDIN_Handler::handler (int signum) { ACE_DEBUG ((LM_DEBUG, "(%t) signal = %S\n", signum)); } STDIN_Handler::STDIN_Handler (MT_TASK &ph) : ph_ (ph) { // Register for ^C from the console. We just need to catch the // exception so that the kernel doesn't kill our process. // Registering this signal handler just tells the kernel that we // know what we're doing; to leave us alone. ACE_OS::signal (SIGINT, (ACE_SignalHandler) STDIN_Handler::handler); }; // Activate object. int STDIN_Handler::open (void *) { if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); return 0; } // Shut down. int STDIN_Handler::close (u_long) { ACE_DEBUG ((LM_DEBUG, "(%t) thread is exiting.\n")); return 0; } // Thread runs here. int STDIN_Handler::svc (void) { this->register_thread_exit_hook (); for (;;) { ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); // Read from stdin into mb. int read_result = ACE_OS::read (ACE_STDIN, mb->rd_ptr (), mb->size ()); // If read succeeds, put mb to peer handler, else end the loop. if (read_result > 0) { mb->wr_ptr (read_result); // Note that this call will first enqueue mb onto the peer // handler's message queue, which will then turn around and // notify the Reactor via the Notification_Strategy. This // will subsequently signal the Peer_Handler, which will // react by calling back to its handle_output() method, // which dequeues the message and sends it to the peer // across the network. this->ph_.putq (mb); } else { mb->release (); break; } } // handle_signal will get called on the main proactor thread since // we just exited and the main thread is waiting on our thread exit. return 0; } // Register an exit hook with the reactor. void STDIN_Handler::register_thread_exit_hook (void) { // Get a real handle to our thread. ACE_Thread_Manager::instance ()->thr_self (this->thr_handle_); // Register ourselves to get called back when our thread exits. if (ACE_Reactor::instance ()-> register_handler (this, this->thr_handle_) == -1) ACE_ERROR ((LM_ERROR, "Exit_Hook Register failed.\n")); } // The STDIN thread has exited. This means the user hit ^C. We can // end the event loop and delete ourself. int STDIN_Handler::handle_signal (int, siginfo_t *si, ucontext_t *) { if (si != 0) { ACE_TEST_ASSERT (this->thr_handle_ == si->si_handle_); ACE_Reactor::end_event_loop (); } return 0; } int STDIN_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { delete this; return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Let the proactor know that it will be used with Reactor // Create specific proactor ACE_WIN32_Proactor win32_proactor (0, 1); // Get the interface proactor ACE_Proactor proactor (&win32_proactor); // Put it as the instance. ACE_Proactor::instance (&proactor); // Open handler for remote peer communications this will run from // the main thread. Peer_Handler peer_handler (argc, argv); if (peer_handler.open () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p open failed, errno = %d.\n", "peer_handler", errno), 0); // Open active object for reading from stdin. STDIN_Handler *stdin_handler = new STDIN_Handler (peer_handler); // Spawn thread. if (stdin_handler->open () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p open failed, errno = %d.\n", "stdin_handler", errno), 0); // Register proactor with Reactor so that we can demultiplex // "waitable" events and I/O operations from a single thread. if (ACE_Reactor::instance ()->register_handler (ACE_Proactor::instance ()->implementation ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p failed to register Proactor.\n", argv[0]), -1); // Run main event demultiplexor. ACE_Reactor::run_event_loop (); // Remove proactor with Reactor. if (ACE_Reactor::instance ()->remove_handler (ACE_Proactor::instance ()->implementation (), ACE_Event_Handler::DONT_CALL) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p failed to register Proactor.\n", argv[0]), -1); return 0; } #else /* !ACE_HAS_WIN32_OVERLAPPED_IO */ int ACE_TMAIN (int , ACE_TCHAR *[]) { return 0; } #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Registry_Changes.cpp0000644000175000017500000001015612576461726026030 0ustar pgquilespgquiles//============================================================================= /** * @file Registry_Changes.cpp * * This application tests the working of Reactor when users are * interested in monitoring changes in the registry. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_REGISTRY) && !defined (ACE_LACKS_REGNOTIFYCHANGEKEYVALUE) #include "ace/Reactor.h" #include "ace/Registry.h" #include "ace/Auto_Event.h" #include "ace/OS_NS_unistd.h" static int stop_test = 0; static HKEY context_to_monitor = HKEY_CURRENT_USER; static const ACE_TCHAR *temp_context_name = ACE_TEXT ("ACE temporary context"); class Event_Handler : public ACE_Event_Handler { public: Event_Handler (ACE_Reactor &reactor); ~Event_Handler (void); int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); ACE_Registry::Naming_Context &context (void); private: ACE_Auto_Event event_; ACE_Registry::Naming_Context context_; }; Event_Handler::Event_Handler (ACE_Reactor &reactor) : context_ (context_to_monitor) { this->reactor (&reactor); if (::RegNotifyChangeKeyValue (this->context_.key (), // handle of key to watch FALSE, // flag for subkey notification REG_NOTIFY_CHANGE_NAME, // changes to be reported this->event_.handle (), // handle of signaled event TRUE // flag for asynchronous reporting ) != ERROR_SUCCESS) ACE_ERROR ((LM_ERROR, "RegNotifyChangeKeyValue could not be setup\n")); if (this->reactor ()->register_handler (this, this->event_.handle ()) != 0) ACE_ERROR ((LM_ERROR, "Registration with Reactor could not be done\n")); } Event_Handler::~Event_Handler (void) { } int Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { if (stop_test) this->reactor ()->close (); else if (::RegNotifyChangeKeyValue (this->context_.key (), // handle of key to watch FALSE, // flag for subkey notification REG_NOTIFY_CHANGE_NAME, // changes to be reported this->event_.handle (), // handle of signaled event TRUE // flag for asynchronous reporting ) != ERROR_SUCCESS) ACE_ERROR ((LM_ERROR, "RegNotifyChangeKeyValue could not be setup\n")); return 0; } int Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "Event_Handler removed from Reactor\n")); return 0; } ACE_Registry::Naming_Context & Event_Handler::context (void) { return this->context_; } void worker (Event_Handler *event_handler) { ACE_DEBUG ((LM_DEBUG, "(%t) Thread creation\n")); ACE_DEBUG ((LM_DEBUG, "(%t) Thread creating temporary registry entry\n")); ACE_Registry::Naming_Context temp_context; int result = event_handler->context ().bind_new_context (temp_context_name, temp_context); if (result == -1) ACE_ERROR ((LM_ERROR, "Error in creating %s: %p\n", temp_context_name, "bind_new_context")); else { ACE_DEBUG ((LM_DEBUG, "(%t) Thread sleeping\n")); ACE_OS::sleep (3); ACE_DEBUG ((LM_DEBUG, "(%t) Thread removing registry entry\n")); stop_test = 1; event_handler->context ().unbind_context (temp_context_name); } } int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_Reactor reactor; Event_Handler handler (reactor); int result = ACE_OS::thr_create ((ACE_THR_FUNC) worker, &handler, 0, 0); ACE_TEST_ASSERT (result == 0); for (result = 0; result != -1; result = reactor.handle_events ()) continue; return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int, ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Timeouts.cpp0000644000175000017500000000373112576461726024402 0ustar pgquilespgquiles//============================================================================= /** * @file Timeouts.cpp * * This example application shows how to write Reactor event * loops that handle events for some fixed amount of time. * * Run this example (without arguments) to see the timers * expire. The order should be: * * foo, bar, foo, bar, foo, foo, bar, foo, bar, foo * * @author Tim Harrison Irfan Pyarali */ //============================================================================= #include "ace/Reactor.h" #include "ace/Service_Config.h" #include "ace/OS_main.h" /** * @class Timeout_Handler * * @brief Generic timeout handler. */ class Timeout_Handler : public ACE_Event_Handler { public: Timeout_Handler (void) : count_ (0) {} /// Print out when timeouts occur. virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg) { ACE_UNUSED_ARG(tv); ACE_DEBUG ((LM_DEBUG, "%d timeout occurred for %s.\n", ++count_, (char *) arg)); return 0; } private: int count_; }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Timeout_Handler handler; // Register a 3 second timer. ACE_Time_Value bar_tv (3); ACE_Reactor::instance ()->schedule_timer (&handler, (void *) "Bar", bar_tv, bar_tv); // Register a 2 second timer. ACE_Time_Value foo_tv (2); ACE_Reactor::instance ()->schedule_timer (&handler, (void *) "Foo", foo_tv, foo_tv); // Handle events for 12 seconds. ACE_Time_Value run_time (12); if (ACE_Reactor::run_event_loop(run_time) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); ACE_Reactor::instance ()->cancel_timer(&handler); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Prerun_State_Changes.cpp0000644000175000017500000000333712576461726026636 0ustar pgquilespgquiles//============================================================================= /** * @file Prerun_State_Changes.cpp * * Tests the Reactor's ability to handle state changes before * getting a chance to run. * * @author Irfan Pyarali */ //============================================================================= #include "ace/Reactor.h" #include "ace/OS_main.h" #include "ace/OS_NS_sys_socket.h" #include "ace/Log_Msg.h" /** * @class Event_Handler * * @brief Generic Event Handler. */ class Event_Handler : public ACE_Event_Handler { public: virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_UNUSED_ARG(mask); ACE_DEBUG ((LM_DEBUG, "event handler %d closed.\n", (size_t) handle)); delete this; return 0; } }; int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_HANDLE handle = ACE_OS::socket (PF_INET, SOCK_STREAM, 0); Event_Handler *event_handler = new Event_Handler; int result = ACE_Reactor::instance ()->register_handler (handle, event_handler, ACE_Event_Handler::READ_MASK); ACE_TEST_ASSERT (result == 0); result = ACE_Reactor::instance ()->register_handler (handle, event_handler, ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::QOS_MASK); ACE_TEST_ASSERT (result == 0); result = ACE_Reactor::instance ()->remove_handler (handle, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); ACE_TEST_ASSERT (result == 0); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Handle_Close.cpp0000644000175000017500000001663112576461726025114 0ustar pgquilespgquiles//============================================================================= /** * @file Handle_Close.cpp * * This application tests whether handle_close gets called and if * the correct masks are passed along. The handler should get * handle_close called for all three masks (READ, WRITE, and * EXCEPT). * * @author Irfan Pyarali */ //============================================================================= #include "ace/Get_Opt.h" #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" #include "ace/Select_Reactor.h" #include "ace/Auto_Ptr.h" #include "ace/Pipe.h" #include "ace/OS_main.h" // Use the WFMO_Reactor static int opt_wfmo_reactor = 0; // Use the Select_Reactor static int opt_select_reactor = 0; // Make pipe readable in main() static int write_to_pipe_in_main = 0; // Cancel reads static int cancel_reads = 0; // Write some data to the pipe. This will cause handle_input to get // called. void write_to_pipe (ACE_Pipe &pipe) { const char *data = "hello"; size_t len = ACE_OS::strlen (data); ssize_t result = ACE::send (pipe.write_handle (), data, len); ACE_TEST_ASSERT ((size_t)result == len); } // Simple handler class class Handler : public ACE_Event_Handler { public: Handler (ACE_Pipe &pipe) : pipe_ (pipe) { } ~Handler (void) { this->reactor (0); } ACE_HANDLE get_handle (void) const { return this->pipe_.read_handle (); } int handle_close (ACE_HANDLE, ACE_Reactor_Mask close_mask) { ACE_DEBUG ((LM_DEBUG, "Handler::handle_close called with mask = %d\n", close_mask)); return 0; } int handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, "Handler::handle_input\n")); // Remove for reading return -1; } int handle_output (ACE_HANDLE handle) { ACE_UNUSED_ARG (handle); ACE_DEBUG ((LM_DEBUG, "Handler::handle_output\n")); // Optionally cancel reads if (cancel_reads) { int result = this->reactor ()->cancel_wakeup (this, ACE_Event_Handler::READ_MASK); ACE_TEST_ASSERT (result != -1); } // Write to the pipe; this causes handle_input to get called. if (!write_to_pipe_in_main) write_to_pipe (this->pipe_); // Remove for writing return -1; } protected: ACE_Pipe &pipe_; }; class Different_Handler : public ACE_Event_Handler { public: Different_Handler (ACE_Pipe &pipe) : pipe_ (pipe) { } ~Different_Handler (void) { this->reactor (0); } ACE_HANDLE get_handle (void) const { return this->pipe_.read_handle (); } int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) { ACE_UNUSED_ARG (handle); ACE_DEBUG ((LM_DEBUG, "Different_Handler::handle_close called with mask = %d\n", close_mask)); return 0; } int handle_input (ACE_HANDLE handle) { ACE_UNUSED_ARG (handle); ACE_DEBUG ((LM_DEBUG, "Different_Handler::handle_input\n")); // Remove for reading int result = this->reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK); ACE_TEST_ASSERT (result == 0); return 0; } int handle_output (ACE_HANDLE handle) { ACE_UNUSED_ARG (handle); ACE_DEBUG ((LM_DEBUG, "Different_Handler::handle_output\n")); // Add for reading int result = this->reactor ()->mask_ops (this, ACE_Event_Handler::READ_MASK, ACE_Reactor::ADD_MASK); ACE_TEST_ASSERT (result != -1); ACE_Reactor_Mask old_masks = ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::EXCEPT_MASK; ACE_TEST_ASSERT (old_masks == static_cast (result)); // Get new masks result = this->reactor ()->mask_ops (this, ACE_Event_Handler::NULL_MASK, ACE_Reactor::GET_MASK); ACE_TEST_ASSERT (result != -1); ACE_Reactor_Mask current_masks = ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::EXCEPT_MASK; ACE_TEST_ASSERT (current_masks == static_cast (result)); // Remove for writing ACE_Reactor_Mask mask = ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL; result = this->reactor ()->remove_handler (this, mask); ACE_TEST_ASSERT (result == 0); // Write to the pipe; this causes handle_input to get called. if (!write_to_pipe_in_main) write_to_pipe (this->pipe_); return 0; } protected: ACE_Pipe &pipe_; }; // // Selection of which reactor should get created // ACE_Reactor * create_reactor (void) { ACE_Reactor_Impl *impl = 0; if (opt_wfmo_reactor) { #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) ACE_NEW_RETURN (impl, ACE_WFMO_Reactor, 0); #endif /* ACE_WIN32 */ } else if (opt_select_reactor) { ACE_NEW_RETURN (impl, ACE_Select_Reactor, 0); } else { ACE_Reactor *singleton_reactor = ACE_Reactor::instance (); ACE_Reactor::instance (0); return singleton_reactor; } ACE_Reactor *reactor = 0; ACE_NEW_RETURN (reactor, ACE_Reactor (impl, 1), 0); return reactor; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int result = 0; //FUZZ: disable check_for_lack_ACE_OS // Parse args ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("swmc"), 1); for (int c; (c = getopt ()) != -1; ) //FUZZ: enable check_for_lack_ACE_OS switch (c) { case 's': opt_select_reactor = 1; break; case 'w': opt_wfmo_reactor = 1; break; case 'm': write_to_pipe_in_main = 1; break; case 'c': cancel_reads = 1; break; } // Create pipes ACE_Pipe pipe1, pipe2; result = pipe1.open (); ACE_TEST_ASSERT (result == 0); result = pipe2.open (); ACE_TEST_ASSERT (result == 0); // Create handlers Handler handler (pipe1); Different_Handler different_handler (pipe2); // Manage memory automagically. auto_ptr reactor (create_reactor ()); // Register handlers ACE_Reactor_Mask handler_mask = ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::EXCEPT_MASK; ACE_Reactor_Mask different_handler_mask = ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::EXCEPT_MASK; result = reactor->register_handler (&handler, handler_mask); ACE_TEST_ASSERT (result == 0); result = reactor->register_handler (&different_handler, different_handler_mask); ACE_TEST_ASSERT (result == 0); // Write to the pipe; this causes handle_input to get called. if (write_to_pipe_in_main) { write_to_pipe (pipe1); write_to_pipe (pipe2); } // Note that handle_output will get called automatically since the // pipe is writable! // Run for three seconds ACE_Time_Value wait_time (3); reactor->run_reactor_event_loop (wait_time); ACE_DEBUG ((LM_DEBUG, "\nClosing down the application\n\n")); return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/WFMO_Reactor/Suspended_Removals.cpp0000644000175000017500000001154312576461726026373 0ustar pgquilespgquiles//============================================================================= /** * @file Suspended_Removals.cpp * * Tests the Reactor's ability to handle removal of suspended * handles. * * @author Irfan Pyarali */ //============================================================================= #include "ace/OS_main.h" #if defined (ACE_WIN32) #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" class Event_Handler : public ACE_Event_Handler { public: ACE_HANDLE get_handle (void) const { return this->event_.handle (); } ACE_Event event_; }; class ACE_WFMO_Reactor_Test { public: static void check_for_valid_state (ACE_WFMO_Reactor &wfmo_reactor, size_t handles_to_be_added, size_t handles_to_be_suspended, size_t handles_to_be_resumed, size_t handles_to_be_deleted) { ACE_TEST_ASSERT (wfmo_reactor.handler_rep_.handles_to_be_added_ == handles_to_be_added); ACE_TEST_ASSERT (wfmo_reactor.handler_rep_.handles_to_be_suspended_ == handles_to_be_suspended); ACE_TEST_ASSERT (wfmo_reactor.handler_rep_.handles_to_be_resumed_ == handles_to_be_resumed); ACE_TEST_ASSERT (wfmo_reactor.handler_rep_.handles_to_be_deleted_ == handles_to_be_deleted); } }; int ACE_TMAIN (int, ACE_TCHAR *[]) { Event_Handler handler; ACE_WFMO_Reactor reactor; ACE_Reactor base_reactor (&reactor); //FUZZ: disable check_for_lack_ACE_OS ACE_Time_Value time (1); //FUZZ: enable check_for_lack_ACE_OS int result = reactor.register_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 1, 0, 0, 0); result = reactor.remove_handler (&handler, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::ALL_EVENTS_MASK); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 1, 0, 0, 1); result = base_reactor.run_reactor_event_loop (time); ACE_TEST_ASSERT (result != -1); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 0); result = reactor.register_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 1, 0, 0, 0); result = base_reactor.run_reactor_event_loop (time); ACE_TEST_ASSERT (result != -1); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 0); result = reactor.suspend_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 1, 0, 0); result = reactor.remove_handler (&handler, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::ALL_EVENTS_MASK); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 1); result = base_reactor.run_reactor_event_loop (time); ACE_TEST_ASSERT (result != -1); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 0); result = reactor.register_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 1, 0, 0, 0); result = reactor.suspend_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 1, 1, 0, 0); result = base_reactor.run_reactor_event_loop (time); ACE_TEST_ASSERT (result != -1); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 0); result = reactor.resume_handler (&handler); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 1, 0); result = reactor.remove_handler (&handler, ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::ALL_EVENTS_MASK); ACE_TEST_ASSERT (result == 0); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 1); result = base_reactor.run_reactor_event_loop (time); ACE_TEST_ASSERT (result != -1); ACE_WFMO_Reactor_Test::check_for_valid_state (reactor, 0, 0, 0, 0); return 0; } #else /* !ACE_WIN32 */ int ACE_TMAIN (int , ACE_TCHAR *[]) { return 0; } #endif /* ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Reactor/Dgram/0000775000175000017500000000000012576472436020666 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/Dgram/Reactor_Dgram.mpc0000644000175000017500000000030212576461726024071 0ustar pgquilespgquiles// -*- MPC -*- project(*CO) : aceexe, avoids_ace_for_tao { exename = codgram Source_Files { CODgram.cpp } } project : aceexe { exename = dgram Source_Files { Dgram.cpp } } ace-6.3.3+dfsg.orig/examples/Reactor/Dgram/Dgram.cpp0000644000175000017500000001525012576461726022425 0ustar pgquilespgquiles// Exercise the wrapper along with the . // This test simply ping-pongs datagrams back and forth between the // peer1 and peer2 processes. This test can be run in two ways: // // 1. Stand-alone -- e.g., // // % ./Dgram // // which will spawn a child process and run peer1 and peer2 // in different processes on the same machine. // // 2. Distributed -- e.g., // // # Peer1 // % ./Dgram 10002 tango.cs.wustl.edu 10003 peer1 // // # Peer1 // % ./Dgram 10003 tango.cs.wustl.edu 10002 peer2 // // which will run peer1 and peer2 in different processes // on the same or different machines. Note that you MUST // give the name "peer1" as the final argument to one and // only one of the programs so that the test will work properly. #include "ace/OS_main.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" #include "ace/Reactor.h" #include "ace/Process.h" #include "ace/SOCK_Dgram.h" #include "ace/INET_Addr.h" #include "ace/Log_Msg.h" // Port used to receive for dgrams. static u_short port1; class Dgram_Endpoint : public ACE_Event_Handler { public: Dgram_Endpoint (const ACE_INET_Addr &local_addr); // = Hook methods inherited from the . virtual ACE_HANDLE get_handle (void) const; virtual int handle_input (ACE_HANDLE handle); virtual int handle_timeout (const ACE_Time_Value & tv, const void *arg = 0); virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); //FUZZ: disable check_for_lack_ACE_OS int send (const char *buf, size_t len, const ACE_INET_Addr &); // Send the to the peer. //FUZZ: enable check_for_lack_ACE_OS private: ACE_SOCK_Dgram endpoint_; // Wrapper for sending/receiving dgrams. }; int Dgram_Endpoint::send (const char *buf, size_t len, const ACE_INET_Addr &addr) { return this->endpoint_.send (buf, len, addr); } Dgram_Endpoint::Dgram_Endpoint (const ACE_INET_Addr &local_addr) : endpoint_ (local_addr) { } ACE_HANDLE Dgram_Endpoint::get_handle (void) const { return this->endpoint_.get_handle (); } int Dgram_Endpoint::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_UNUSED_ARG (handle); this->endpoint_.close (); delete this; return 0; } int Dgram_Endpoint::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; ACE_INET_Addr from_addr; ACE_DEBUG ((LM_DEBUG, "(%P|%t) activity occurred on handle %d!\n", this->endpoint_.get_handle ())); ssize_t n = this->endpoint_.recv (buf, sizeof buf, from_addr); if (n == -1) ACE_ERROR ((LM_ERROR, "%p\n", "handle_input")); else ACE_DEBUG ((LM_DEBUG, "(%P|%t) buf of size %d = %*s\n", n, n, buf)); return 0; } int Dgram_Endpoint::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) timed out for endpoint\n")); return 0; } static int run_test (u_short localport, const ACE_TCHAR *remotehost, u_short remoteport, const ACE_TCHAR *peer) { ACE_INET_Addr remote_addr (remoteport, remotehost); ACE_INET_Addr local_addr (localport); Dgram_Endpoint *endpoint; ACE_NEW_RETURN (endpoint, Dgram_Endpoint (local_addr), -1); // Read data from other side. if (ACE_Reactor::instance ()->register_handler (endpoint, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::register_handler"), -1); char buf[BUFSIZ]; ACE_OS::strcpy (buf, "Data to transmit"); size_t len = ACE_OS::strlen (buf); if (ACE_OS::strncmp (peer, ACE_TEXT("peer1"), 5) == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) sending data\n")); for (size_t i = 0; i < 20; i++) { endpoint->send (buf, len, remote_addr); ACE_DEBUG ((LM_DEBUG, "(%P|%t) .\n")); ACE_OS::sleep (1); } } for (int i = 0; i < 40; i++) { // Wait up to 10 seconds for data. ACE_Time_Value tv (10, 0); if (ACE_Reactor::instance ()->handle_events (tv) <= 0) ACE_ERROR_RETURN ((LM_DEBUG, "(%P|%t) %p\n", "handle_events"), -1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) return from handle events\n")); endpoint->send (buf, len, remote_addr); ACE_DEBUG ((LM_DEBUG, "(%P|%t) .\n")); } if (ACE_Reactor::instance ()->remove_handler (endpoint, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::remove_handler"), -1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) exiting\n")); return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Estabish call backs and socket names. port1 = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; const ACE_TCHAR *remotehost = argc > 2 ? argv[2] : ACE_DEFAULT_SERVER_HOST; const u_short port2 = argc > 3 ? ACE_OS::atoi (argv[3]) : port1 + 1; // Providing the fourth command line argument indicate we don't want // to spawn a new process. On Win32, we use this to exec the new // program. if (argc > 4) run_test (port1, remotehost, port2, argv[4]); else { ACE_DEBUG ((LM_DEBUG, "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", port1, remotehost, port2)); ACE_Process_Options options; options.command_line (ACE_TEXT ("%s %d %s %d %c"), argv[0], port1, remotehost, port2, 'c'); // This has no effect on NT and will spawn a process that exec // the above run_test function. options.creation_flags (ACE_Process_Options::NO_EXEC); ACE_Process new_process; switch (new_process.spawn (options)) { case -1: return -1; case 0: run_test (port1, remotehost, port2, ACE_TEXT("peer1")); break; default: run_test (port2, remotehost, port1, ACE_TEXT("peer2")); new_process.wait (); break; } } return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Dgram/CODgram.cpp0000644000175000017500000001506312576461726022651 0ustar pgquilespgquiles// Exercise the wrapper along with the // . This test simply ping-pongs datagrams back and // forth between the peer1 and peer2 processes. This test can // be run in two ways: // // 1. Stand-alone -- e.g., // // % ./CODgram // // which will spawn a child process and run peer1 and peer2 // in different processes on the same machine. // // 2. Distributed -- e.g., // // # Peer1 // % ./CODgram 10002 tango.cs.wustl.edu 10003 peer1 // // # Peer1 // % ./CODgram 10003 tango.cs.wustl.edu 10002 peer2 // // which will run peer1 and peer2 in different processes // on the same or different machines. Note that you MUST // give the name "peer1" as the final argument to one and // only one of the programs so that the test will work properly. #include "ace/OS_main.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" #include "ace/Reactor.h" #include "ace/SOCK_CODgram.h" #include "ace/INET_Addr.h" #include "ace/Process.h" #include "ace/Log_Msg.h" // Port used to receive for dgrams. static u_short port1; class Dgram_Endpoint : public ACE_Event_Handler { public: Dgram_Endpoint (const ACE_INET_Addr &remote_addr, const ACE_INET_Addr &local_addr); // = Hook methods inherited from the . virtual ACE_HANDLE get_handle (void) const; virtual int handle_input (ACE_HANDLE handle); virtual int handle_timeout (const ACE_Time_Value & tv, const void *arg = 0); virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask); //FUZZ: disable check_for_lack_ACE_OS int send (const char *buf, size_t len); // Send the to the peer. //FUZZ: enable check_for_lack_ACE_OS private: ACE_SOCK_CODgram endpoint_; // Wrapper for sending/receiving dgrams. }; int Dgram_Endpoint::send (const char *buf, size_t len) { return this->endpoint_.send (buf, len); } int Dgram_Endpoint::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask) { ACE_UNUSED_ARG (handle); this->endpoint_.close (); return 0; } Dgram_Endpoint::Dgram_Endpoint (const ACE_INET_Addr &remote_addr, const ACE_INET_Addr &local_addr) : endpoint_ (remote_addr, local_addr) { } ACE_HANDLE Dgram_Endpoint::get_handle (void) const { return this->endpoint_.get_handle (); } int Dgram_Endpoint::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; ACE_DEBUG ((LM_DEBUG, "(%P|%t) activity occurred on handle %d!\n", this->endpoint_.get_handle ())); ssize_t n = this->endpoint_.recv (buf, sizeof buf); if (n == -1) ACE_ERROR ((LM_ERROR, "%p\n", "handle_input")); else ACE_DEBUG ((LM_DEBUG, "(%P|%t) buf of size %d = %*s\n", n, n, buf)); return 0; } int Dgram_Endpoint::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) timed out for endpoint\n")); return 0; } static int run_test (u_short localport, const ACE_TCHAR *remotehost, u_short remoteport, const ACE_TCHAR *peer) { ACE_INET_Addr remote_addr (remoteport, remotehost); ACE_INET_Addr local_addr (localport); Dgram_Endpoint endpoint (remote_addr, local_addr); // Read data from other side. if (ACE_Reactor::instance ()->register_handler (&endpoint, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::register_handler"), -1); char buf[BUFSIZ]; ACE_OS::strcpy (buf, "Data to transmit"); size_t len = ACE_OS::strlen (buf); // "peer1" is the "initiator." if (ACE_OS::strncmp (peer, ACE_TEXT("peer1"), 5) == 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) sending data\n")); for (size_t i = 0; i < 20; i++) { endpoint.send (buf, len); ACE_DEBUG ((LM_DEBUG, "(%P|%t) .\n")); ACE_OS::sleep (1); } } for (int i = 0; i < 40; i++) { // Wait up to 10 seconds for data. ACE_Time_Value tv (10, 0); if (ACE_Reactor::instance ()->handle_events (tv) <= 0) ACE_ERROR_RETURN ((LM_DEBUG, "(%P|%t) %p\n", "handle_events"), -1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) return from handle events\n")); endpoint.send (buf, len); ACE_DEBUG ((LM_DEBUG, "(%P|%t) .\n")); } if (ACE_Reactor::instance ()->remove_handler (&endpoint, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::remove_handler"), -1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) exiting\n")); return 0; } int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Estabish call backs and socket names. port1 = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; const ACE_TCHAR *remotehost = argc > 2 ? argv[2] : ACE_DEFAULT_SERVER_HOST; const u_short port2 = argc > 3 ? ACE_OS::atoi (argv[3]) : port1 + 1; // Providing the fourth command line argument indicates we don't // want to spawn a new process. On Win32, we use this to exec the // new program. if (argc > 4) run_test (port1, remotehost, port2, argv[4]); else { ACE_DEBUG ((LM_DEBUG, "(%P|%t) local port = %d, remote host = %s, remote port = %d\n", port1, remotehost, port2)); ACE_Process_Options options; options.command_line (ACE_TEXT("%s %d %s %d %c"), argv[0], port1, remotehost, port2, 'c'); // This has no effect on NT and will spawn a process that exec // the above run_test function. options.creation_flags (ACE_Process_Options::NO_EXEC); ACE_Process new_process; switch (new_process.spawn (options)) { case -1: return -1; case 0: run_test (port1, remotehost, port2, ACE_TEXT("peer1")); break; default: run_test (port2, remotehost, port1, ACE_TEXT("peer2")); new_process.wait (); break; } } return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Misc/0000775000175000017500000000000012576472436020527 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Reactor/Misc/test_timer_queue.cpp0000644000175000017500000000551512576461726024622 0ustar pgquilespgquiles#include "ace/OS_NS_sys_time.h" #include "ace/Timer_Heap.h" #include "ace/Timer_List.h" #include "ace/Timer_Queue.h" #include "ace/Log_Msg.h" #include "ace/Recursive_Thread_Mutex.h" #include "ace/Null_Mutex.h" #include "ace/Event_Handler.h" class Example_Handler : public ACE_Event_Handler { public: Example_Handler (void) : count_ (1) {} virtual int handle_timeout (const ACE_Time_Value &, const void *arg) { int *times = (int *) arg; ACE_DEBUG ((LM_DEBUG, "yow, the time has come and gone %d times %d, Horatio!\n", this->count_++, *times)); delete times; return 0; } private: int count_; }; static void test_functionality (ACE_Timer_Queue *tq) { Example_Handler eh; ACE_TEST_ASSERT (tq->is_empty ()); ACE_TEST_ASSERT (ACE_Time_Value::zero == ACE_Time_Value (0)); const void *timer_act = 0; ACE_NEW (timer_act, int (1)); long timer_id1 = tq->schedule (&eh, timer_act, ACE_OS::gettimeofday ()); // Use timer_id outside of an assert, so that we don't get compile // warnings with ACE_NDEBUG about it being unused. if (timer_id1 == -1) ACE_ERROR ((LM_ERROR, "%p\n", "schedule () failed")); ACE_TEST_ASSERT (timer_id1 != -1); ACE_NEW (timer_act, int (42)); long result = tq->schedule (&eh, timer_act, ACE_OS::gettimeofday ()); ACE_TEST_ASSERT (result != -1); ACE_NEW (timer_act, int (42)); result = tq->schedule (&eh, timer_act, ACE_OS::gettimeofday ()); ACE_TEST_ASSERT (result != -1); result = tq->cancel (timer_id1, &timer_act); ACE_TEST_ASSERT (result == 1); delete (int *) timer_act; result = tq->is_empty (); ACE_TEST_ASSERT (!result); result = tq->expire (); ACE_TEST_ASSERT (result == 2); ACE_NEW (timer_act, int (4)); timer_id1 = tq->schedule (&eh, timer_act, ACE_OS::gettimeofday ()); ACE_TEST_ASSERT (timer_id1 != -1); ACE_NEW (timer_act, int (5)); long timer_id2 = tq->schedule (&eh, timer_act, ACE_OS::gettimeofday ()); ACE_TEST_ASSERT (timer_id2 != -1); result = tq->cancel (timer_id1, &timer_act); ACE_TEST_ASSERT (result == 1); delete (int *) timer_act; result = tq->cancel (timer_id2, &timer_act); ACE_TEST_ASSERT (result == 1); delete (int *) timer_act; result = tq->is_empty (); ACE_TEST_ASSERT (result == 1); result = tq->expire (); ACE_TEST_ASSERT (result == 0); } struct Timer_Queues { ACE_Timer_Queue *queue_; // Pointer to the subclass of that we're testing. const char *name_; // Name of the Queue that we're testing. }; static Timer_Queues timer_queues[] = { { new ACE_Timer_List, "ACE_Timer_List" }, { new ACE_Timer_Heap, "ACE_Timer_Heap" }, { 0, 0 }, }; int ACE_TMAIN (int, ACE_TCHAR *[]) { for (int i = 0; timer_queues[i].name_ != 0; i++) { test_functionality (timer_queues[i].queue_); delete timer_queues[i].queue_; } return 0; } ace-6.3.3+dfsg.orig/examples/Reactor/Misc/test_reactors.cpp0000644000175000017500000001041312576461726024111 0ustar pgquilespgquiles// Perform a torture test of multiple ACE_Reactors and ACE_Tasks in // the same process... Thanks to Detlef Becker for contributing this. #include "ace/Reactor.h" #include "ace/Service_Config.h" #include "ace/Task.h" #include "ace/Atomic_Op.h" #if defined (ACE_HAS_THREADS) #include "ace/Recursive_Thread_Mutex.h" static const int NUM_INVOCATIONS = 10; static const int MAX_TASKS = 20; class Test_Task : public ACE_Task { public: Test_Task (void); ~Test_Task (void); //FUZZ: disable check_for_lack_ACE_OS virtual int open (void *args = 0); virtual int close (u_long flags = 0); //FUZZ: enable check_for_lack_ACE_OS virtual int svc (void); virtual int handle_input (ACE_HANDLE handle); virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask close_mask); private: int handled_; static int task_count_; }; int Test_Task::task_count_ = 0; static ACE_Atomic_Op done_count = MAX_TASKS * 2; static ACE_Recursive_Thread_Mutex reclock_; Test_Task::Test_Task (void) : handled_ (0) { ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); Test_Task::task_count_++; ACE_DEBUG ((LM_DEBUG, "(%t) TT+ Test_Task::task_count_ = %d\n", Test_Task::task_count_)); } Test_Task::~Test_Task (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, reclock_); ACE_DEBUG ((LM_DEBUG, "(%t) TT- Test_Task::task_count_ = %d\n", Test_Task::task_count_)); } int Test_Task::open (void *args) { this->reactor ((ACE_Reactor *) args); return this->activate (THR_NEW_LWP); } int Test_Task::close (u_long) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, reclock_, -1); Test_Task::task_count_--; ACE_DEBUG ((LM_DEBUG, "(%t) close Test_Task::task_count_ = %d\n", Test_Task::task_count_)); return 0; } int Test_Task::svc (void) { for (int i = 0; i < NUM_INVOCATIONS; i++) { ACE_OS::thr_yield (); // ACE_DEBUG ((LM_DEBUG, "(%t) calling notify %d\n", i)); if (this->reactor ()->notify (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); // ACE_DEBUG ((LM_DEBUG, "(%t) leaving notify %d\n", i)); } return 0; } int Test_Task::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { ACE_DEBUG ((LM_DEBUG, "(%t) handle_close\n")); return 0; } int Test_Task::handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, "(%t) handle_input\n")); this->handled_++; if (this->handled_ == NUM_INVOCATIONS) { done_count--; ACE_DEBUG ((LM_DEBUG, "(%t) handle_input, handled_ = %d, done_count = %d\n", this->handled_, done_count.value ())); } ACE_OS::thr_yield (); return -1; } static void * worker (void *args) { ACE_Reactor *reactor = (ACE_Reactor *) args; reactor->owner (ACE_Thread::self ()); ACE_Time_Value timeout (4); for (;;) { //ACE_DEBUG ((LM_DEBUG, "(%t) calling handle_events\n")); switch (reactor->handle_events (timeout)) { case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0); /* NOTREACHED */ case 0: ACE_ERROR_RETURN ((LM_ERROR, "(%t) timeout\n"), 0); /* NOTREACHED */ } // ACE_DEBUG ((LM_DEBUG, "(%t) done with handle_events\n")); } ACE_NOTREACHED(return 0); } int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_Reactor *react1 = ACE_Reactor::instance (); ACE_Reactor *react2 = new ACE_Reactor (); Test_Task tt1[MAX_TASKS]; Test_Task tt2[MAX_TASKS]; for (int i = 0; i < MAX_TASKS; i++) { tt1[i].open (react1); tt2[i].open (react2); } if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) react1, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) react2, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "(%t) done\n")); return 0; } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); return 0; } #endif /* ACE_HAS_THREADS */ ace-6.3.3+dfsg.orig/examples/Reactor/Misc/notification.cpp0000644000175000017500000002404512576461726023724 0ustar pgquilespgquiles#include "ace/OS_NS_unistd.h" #include "ace/Service_Config.h" #include "ace/Reactor.h" #include "ace/Thread_Manager.h" #include "ace/Thread.h" #include "ace/Signal.h" #include "ace/Truncate.h" #if defined (ACE_HAS_THREADS) #define MAX_ITERATIONS 10000 class Thread_Handler : public ACE_Event_Handler { // = TITLE // Illustrate how the ACE_Reactor's thread-safe event notification // mechanism works. // // = DESCRIPTION // Handle timeouts in the main thread via the ACE_Reactor and I/O // events in a separate thread. Just before the separate I/O // thread exits it notifies the ACE_Reactor in the main thread // using the ACE_Reactor's notification mechanism. public: Thread_Handler (long delay, long interval, size_t n_threads, size_t max_iterations); // Constructor. Thread_Handler (size_t id, size_t max_iterations); ~Thread_Handler (void); // Destructor. virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); // Handle signals. virtual int handle_exception (ACE_HANDLE); // Print data from main thread. virtual int handle_output (ACE_HANDLE); // Print data from main thread. virtual int handle_timeout (const ACE_Time_Value &, const void *); // Handle timeout events in the main thread. virtual int handle_input (ACE_HANDLE); // General notification messages to the Reactor. virtual int notify (ACE_Time_Value *tv = 0); // Perform notifications. virtual int svc (void); // Handle I/O events in a separate threads. private: static void *svc_run (void *); // Glues C++ to C thread library functions. size_t id_; // ID passed in by Thread_Handler constructor. size_t iterations_; static sig_atomic_t shutdown_; // Shutting down. // = Timing variables. // Delay factor for timer-driven I/O. static ACE_Time_Value delay_; // Interval factor for Event_Handler timer. static ACE_Time_Value interval_; }; // Shutdown flag. sig_atomic_t Thread_Handler::shutdown_ = 0; // Delay factor for timer-driven I/O. ACE_Time_Value Thread_Handler::delay_; // Interval factor for Event_Handler timer. ACE_Time_Value Thread_Handler::interval_; Thread_Handler::Thread_Handler (size_t id, size_t max_iterations) : id_ (id), iterations_ (max_iterations) { } Thread_Handler::~Thread_Handler (void) { // Cleanup resources so that we don't crash and burn when shutdown. ACE_Event_Handler::remove_stdin_handler (ACE_Reactor::instance (), ACE_Thread_Manager::instance ()); ACE_Reactor::instance ()->cancel_timer (this); } Thread_Handler::Thread_Handler ( long delay, long interval, size_t n_threads, size_t max_iterations) : iterations_ (max_iterations) { ACE_Sig_Set sig_set; sig_set.sig_add (SIGQUIT); sig_set.sig_add (SIGINT); delay_.set (delay); interval_.set (interval); this->id_ = 0; if (ACE_Event_Handler::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler")); else if (ACE_Reactor::instance ()->register_handler (sig_set, this) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "register_handler")); else if (ACE_Reactor::instance ()->schedule_timer (this, 0, Thread_Handler::delay_, Thread_Handler::interval_) == -1) ACE_ERROR ((LM_ERROR, "(%t) %p\n", "schedule_timer")); // Set up this thread's signal mask to block all the signal in the // , which is inherited by the threads it spawns. ACE_Sig_Guard guard (&sig_set); // Create N new threads of control Thread_Handlers. for (size_t i = 0; i < n_threads; i++) { Thread_Handler *th; ACE_NEW (th, Thread_Handler (i + 1, this->iterations_)); if (ACE_Thread::spawn (reinterpret_cast (&Thread_Handler::svc_run), reinterpret_cast (th), THR_NEW_LWP | THR_DETACHED) != 0) ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn")); } // The destructor of unblocks the signal set so that only // this thread receives them! } int Thread_Handler::notify (ACE_Time_Value *timeout) { // Just do something to test the ACE_Reactor's multi-thread // capabilities... if (ACE_Reactor::instance ()->notify (this, ACE_Event_Handler::EXCEPT_MASK, timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notification::notify:exception"), -1); else if (ACE_Reactor::instance ()->notify (this, ACE_Event_Handler::WRITE_MASK, timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notification::notify:write"), -1); return 0; } // Test stdin handling that uses Minimum value is 1 usec, defaults to 10000 usec (10 msec). 3 Minimum value is 1 usec, defaults to 10000 usec (10 msec). 4 Minimum value is 1 usec, defaults to 20000000 usec (20 sec). A value of 0 is also a valid input, in which case no limit will be placed on the duration of the transmission (it will end when all packets have been relayed from the input device to the output device). 5 0 - does no logging 1 - logs packets created by the input device 2 - logs packets consumed by the output device 4 - prints contents of packets consumed by the output device To set several flags, pass their sum as the logging level value: e.g., a logging level value of 7 turns on all possible logging. Action commands: 6 - runs a transmission using the current settings 7 - cancels a transmission if there is one running 8 - reports statistics from the most recent transmission 9 - quits the program 3. APPLICATION DESIGN 3.1. KEY COMPONENTS The design of this example application consists of four main components: the driver object, the relay object, the input device object, and the output device object. The driver object is responsible for receiving user input and overall handling of user input commands. The driver object is active, with separate threads for receiving user input and managing its transmission timer queue. This allows the user to issue commands while a transmission is in progress. The driver object uses an ACE_Thread_Timer_Queue_Adapter, which is derived from ACE_Task_Base. The driver object starts another active object, called User_Input_Task, which is also derived from ACE_Task_Base. This allows both the timer queue and the user input object to be made active, running in their own threads of control. The relay object is passive, managing a message queue and necessary locks to allow safe access from multiple threads. It provides methods to receive and enqueue a mesage from the input device, dequeue a message and send it to the output device, and to start or end a transmission. It uses ACE_Message_Queue (which contains ACE_Message_Block objects) and ACE_Thread_Mutex objects to implement this functionality. The input object is active, managing timeouts and input events in its own thread. The input object is also reactive, using an ACE_Reactor to allow response to multiple input handles as well as to do polling at specific timeouts. The input pseudo-device wrapper in this example does not make use of input handles and only does timed polling, but extending this only requires registering the appropriate input handles and handlers with the reactor. The input object is derived from ACE_Task_Base, and is activated by the relay object when a new transmission starts. The input object packages each data packet in an ACE_Message_Block before sending it to the relay object. The output object is passive. If logging is turned on, it will report the arrival time, relative to the start of the transmission, of each output message, and the contents of that message. The output object will also "consume" each ACE_Message_Block passed to it, calling delete on the passed pointer. 3.2. RUN-TIME CHARACTERSITICS When the user initiates a transmission, the appropriate settings are passed by the driver to the relay object's start transmission method. The relay object tries to start a new transmission. If another transmission is in progress, the method returns an error. Otherwise, the relay object's start transmission method initializes itself and the input and output device objects, activates the input device object, and stores the handle for the new input device thread. The driver then constructs a timeout handler with a count of the number of messages to relay and a send timeout value, and pushes a timer with this handler onto the timer queue. If there is a limit on the duration of the transmission, the driver constructs a different handler for end-of-transmission, and pushes a timer for the end of the transmission with this handler onto the timer queue as well. When the user issues a cancel transmission command, the driver calls the relay's end transmission method. When a send timeout expires, the handler (running in the timer queue thread) calls the send method of the relay. If there are any enqueued messages from the input device object in its queue, the relay object's send method will dequeue a message, pass it to the output device object, and return success. If there are no messages in the queue, the relay object's send method will return failure. If the send was successful, the handler will decrement its count of remaining messages. If the count is greater than zero, the handler will register a new send timer for itself and exit. If the count is zero, then the handler will call the relay's end transmission method, clear the timer queue, and mark itself inactive before exiting. Similarly, if the end-of-transmission timer expires before all packets have been sent, that handler will call the relay's end transmission method, clear the timer queue, release the semaphore, and then exit. When the relay's end transmission method is called, it marks the relay itself inactive, and calls the input device's deactivate method, which sets the input device's activity flag to inactive (see below). The relay's end transmission method then waits until the input device thread exits, before returning. While it is still active, the input device thread blocks on a reactor timeout for the duration it was given by the relay. When the timeout expires, the input device checks a flag to see if it is still active. If the flag says the input device is inactive, the thread simply exits. This allows cancellation of the input device when a transmission has ended. If the flag says it is still active, the thread builds a new character buffer, and wraps this with a new ACE_Message_Block. The input device passes this message block to the execution method of the send input message command object with which it was constructed. This level of indirection allows the input device to be used with arbitrary types, so that it could for example be connected directly to an output device. The input device also maintains a count of the number of messages it has sent. Once the input device has sent all its messages, it marks itself inactive, and its thread simply exits. 4. ACCESSING THE SOURCE CODE The files for this example are located in $ACE_ROOT/examples/Bounded_Packet_Relay in the latest release of ACE, which is located at http://www.cs.wustl.edu/~schmidt/ACE_wrappers/ACE.tar.gz Source Files: Thread_Bounded_Packet_Relay.h Thread_Bounded_Packet_Relay.cpp BPR_Driver.h BPR_Driver.cpp BPR_Driver_T.h BPR_Driver_T.cpp bpr_thread.cpp Make file: Makefile Doc file: README (this file) Executable: bpr_thread ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/BPR_Drivers.cpp0000644000175000017500000003326612576461726025075 0ustar pgquilespgquiles //============================================================================= /** * @file BPR_Drivers.cpp * * This code builds an abstraction to factor out common code for * the different implementations of the Timer_Queue. * * @author Chris Gill and Douglas C. Schmidt Based on the Timer Queue Test example written by Carlos O'Ryan and Douglas C. Schmidt and Sergio Flores-Gaitan */ //============================================================================= #include "ace/OS_NS_sys_time.h" #include "BPR_Drivers.h" // Constructor. Input_Device_Wrapper_Base::Input_Device_Wrapper_Base (ACE_Thread_Manager *input_task_mgr) : ACE_Task_Base (input_task_mgr), send_input_msg_cmd_ (0), input_period_ (ACE_ONE_SECOND_IN_USECS), is_active_ (0), send_count_ (0) { } // Destructor. Input_Device_Wrapper_Base::~Input_Device_Wrapper_Base (void) { } // Sets send input message command in the input device driver object. int Input_Device_Wrapper_Base::set_send_input_msg_cmd (ACE_Command_Base *send_input_msg_cmd) { // Set the new command. Input device is not responsible // for deleting the old command, if any. send_input_msg_cmd_ = send_input_msg_cmd; return 0; } // Sets period between when input messages are produced. int Input_Device_Wrapper_Base::set_input_period (u_long input_period) { input_period_ = input_period; return 0; } // Sets count of messages to send. int Input_Device_Wrapper_Base::set_send_count (long count) { send_count_ = count; return 0; } // Request that the input device stop sending messages // and terminate its thread. Should return 1 if it will do so, 0 // if it has already done so, or -1 if there is a problem doing so. int Input_Device_Wrapper_Base::request_stop (void) { if (is_active_) { is_active_ = 0; return 1; } return 0; } // This method runs the input device loop in the new thread. int Input_Device_Wrapper_Base::svc (void) { ACE_Time_Value timeout; ACE_Message_Block *message; // Set a flag to indicate we're active. is_active_ = 1; // Start with the total count of messages to send. for (current_count_ = send_count_; // While we're still marked active, and there are packets to send. (is_active_) && (current_count_ != 0); ) { // Create an input message to send. message = create_input_message (); if (message == 0) { if (is_active_) { is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "Failed to create input message object"), -1); } break; } // Make sure there is a send command object. if (send_input_msg_cmd_ == 0) { delete message; if (is_active_) { is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "send message command object not instantiated"), -1); } break; } // Send the input message. if (send_input_msg_cmd_->execute ((void *) message) < 0) { delete message; if (is_active_) { is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "Failed executing send message command object"), -1); } break; } // If all went well, decrement count of messages to send, and // run the reactor event loop unti we get a timeout or something // happens in a registered upcall. if (current_count_ > 0) --current_count_; timeout = ACE_Time_Value (0, input_period_); reactor_.run_event_loop (timeout); } is_active_ = 0; return 0; } // Sends a newly created message block, carrying data read from the // underlying input device, by passing a pointer to the message block // to its command execution. int Input_Device_Wrapper_Base::send_input_message (ACE_Message_Block *amb) { if (send_input_msg_cmd_) return send_input_msg_cmd_->execute ((void *) amb); else { if (is_active_) ACE_ERROR ((LM_ERROR, "%t %p\n", "Input_Device_Wrapper_Base::send_input_message: " "command object not instantiated")); return -1; } } Output_Device_Wrapper_Base::~Output_Device_Wrapper_Base (void) { } // Constructor. Bounded_Packet_Relay::Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, Input_Device_Wrapper_Base *input_wrapper, Output_Device_Wrapper_Base *output_wrapper) : is_active_ (0), input_task_mgr_ (input_task_mgr), input_wrapper_ (input_wrapper), output_wrapper_ (output_wrapper), queue_ (Bounded_Packet_Relay::DEFAULT_HWM, Bounded_Packet_Relay::DEFAULT_LWM), queue_hwm_ (Bounded_Packet_Relay::DEFAULT_HWM), queue_lwm_ (Bounded_Packet_Relay::DEFAULT_LWM), transmission_number_ (0), packets_sent_ (0), status_ (Bounded_Packet_Relay::UN_INITIALIZED), transmission_start_ (ACE_Time_Value::zero), transmission_end_ (ACE_Time_Value::zero) { if (input_task_mgr_ == 0) input_task_mgr_ = ACE_Thread_Manager::instance (); } // Destructor. Bounded_Packet_Relay::~Bounded_Packet_Relay (void) { // Reactivate the queue, and then clear it. queue_.activate (); while (! queue_.is_empty ()) { ACE_Message_Block *msg; queue_.dequeue_head (msg); delete msg; } } // Requests output be sent to output device. int Bounded_Packet_Relay::send_input (void) { // Don't block, return immediately if queue is empty. ACE_Message_Block *item; // Using a separate (non-const) time value // is necessary on some platforms ACE_Time_Value immediate (ACE_Time_Value::zero); if (queue_.dequeue_head (item, &immediate) < 0) return 1; // If a message block was dequeued, send it to the output device. if (output_wrapper_->write_output_message ((void *) item) < 0) { if (is_active_) ACE_ERROR ((LM_ERROR, "%t %p\n", "failed to write to output device object")); return -1; } // If all went OK, increase count of packets sent. ++packets_sent_; return 0; } // Requests a transmission be started. int Bounded_Packet_Relay::start_transmission (u_long packet_count, u_long arrival_period, int logging_level) { // Serialize access to start and end transmission calls, statistics // reporting calls. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); // If a transmission is already in progress, just return. if (is_active_) return 1; // Set transmission in progress flag true. is_active_ = 1; // Update statistics for a new transmission. ++transmission_number_; packets_sent_ = 0; status_ = STARTED; transmission_start_ = ACE_OS::gettimeofday (); // Reactivate the queue, and then clear it. queue_.activate (); while (! queue_.is_empty ()) { ACE_Message_Block *msg; queue_.dequeue_head (msg); delete msg; } // Initialize the output device. if (output_wrapper_->modify_device_settings ((void *) &logging_level) < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed to initialize output device object"), -1); } // Initialize the input device. if (input_wrapper_->modify_device_settings ((void *) &logging_level) < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed to initialize output device object"), -1); } else if (input_wrapper_->set_input_period (arrival_period) < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed to initialize input device object"), -1); } else if (input_wrapper_->set_send_count (packet_count) < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed to initialize input device object"), -1); } // Activate the input device. else if (input_wrapper_->activate () < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); is_active_ = 0; ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed to activate input device object"), -1); } // If all went well, print a startup message and return success. ACE_DEBUG ((LM_DEBUG, "\n\nTransmission %u started\n\n", transmission_number_)); return 0; } // Requests a transmission be ended. int Bounded_Packet_Relay::end_transmission (Transmission_Status status) { // Serialize access to start and end transmission calls, // statistics reporting calls. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); // If a transmission is not already in progress, just return. if (! is_active_) return 1; // Set transmission in progress flag false. is_active_ = 0; // Ask the the input thread to stop. if (input_wrapper_->request_stop () < 0) { status_ = ERROR_DETECTED; transmission_end_ = ACE_OS::gettimeofday (); ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "failed asking input device thread to stop"), -1); } // Deactivate the queue, allowing all waiting threads to continue. queue_.deactivate (); // Wait for input thread to stop. input_task_mgr_->wait_task (input_wrapper_); // Reactivate the queue, and then clear it. queue_.activate (); while (! queue_.is_empty ()) { ACE_Message_Block *msg; queue_.dequeue_head (msg); delete msg; } // If all went well, set passed status, stamp end time, print a // termination message, and return success. status_ = status; transmission_end_ = ACE_OS::gettimeofday (); ACE_DEBUG ((LM_DEBUG, "\n\nTransmission %u ended with status: %s\n\n", transmission_number_, status_msg ())); return 0; } // Requests a report of statistics from the last transmission. int Bounded_Packet_Relay::report_statistics (void) { // Serialize access to start and end transmission calls, // statistics reporting calls. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); // If a transmission is already in progress, just return. if (is_active_) return 1; // Calculate duration of trasmission. ACE_Time_Value duration (transmission_end_); duration -= transmission_start_; // Report transmission statistics. ACE_DEBUG ((LM_DEBUG, "\n\nStatisics for transmission %u:\n\n" "Transmission status: %s\n" "Start time: %d (sec) %d (usec)\n" "End time: %d (sec) %d (usec)\n" "Duration: %d (sec) %d (usec)\n" "Packets relayed: %u\n\n", transmission_number_, status_msg (), transmission_start_.sec (), transmission_start_.usec (), transmission_end_.sec (), transmission_end_.usec (), duration.sec (), duration.usec (), packets_sent_)); return 0; } // Public entry point to which to push input. int Bounded_Packet_Relay::receive_input (void * arg) { if (! arg) { if (is_active_) ACE_ERROR ((LM_ERROR, "%t %p\n", "Bounded_Packet_Relay::receive_input: " "null argument")); return -1; } ACE_Message_Block *message = static_cast (arg); if (queue_.enqueue_tail (message) < 0) { if (is_active_) ACE_ERROR ((LM_ERROR, "%t %p\n", "Bounded_Packet_Relay::receive_input failed")); return -1; } return 0; } // Get high water mark for relay queue. ACE_UINT32 Bounded_Packet_Relay::queue_hwm (void) { return queue_lwm_; } // Set high water mark for relay queue. void Bounded_Packet_Relay::queue_hwm (ACE_UINT32 hwm) { queue_hwm_ = hwm; } // Get low water mark for relay queue. ACE_UINT32 Bounded_Packet_Relay::queue_lwm (void) { return queue_lwm_; } // Set low water mark for relay queue. void Bounded_Packet_Relay::queue_lwm (ACE_UINT32 lwm) { queue_lwm_ = lwm; } // Returns string corresponding to current status. const char * Bounded_Packet_Relay::status_msg (void) { const char *status_msg; switch (status_) { case UN_INITIALIZED: status_msg = "uninitialized"; break; case STARTED: status_msg = "in progress"; break; case COMPLETED: status_msg = "completed with all packets sent"; break; case TIMED_OUT: status_msg = "terminated by transmission duration timer"; break; case CANCELLED: status_msg = "cancelled by external control"; break; case ERROR_DETECTED: status_msg = "error was detected"; break; default: status_msg = "unknown transmission status"; break; } return status_msg; } ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp0000644000175000017500000002103012576461726025342 0ustar pgquilespgquiles //============================================================================= /** * @file BPR_Drivers_T.cpp * * This code builds an abstraction to factor out common code for * the different implementations of the Timer_Queue. * * @author Chris Gill and Douglas C. Schmidt Based on the Timer Queue Test example written by Carlos O'Ryan and Douglas C. Schmidt and Sergio Flores-Gaitan */ //============================================================================= #ifndef _BPR_DRIVER_T_CPP_ #define _BPR_DRIVER_T_CPP_ // #include BPR_Drivers.h instead of BPR_Drivers_T.h // to avoid problems with circular includes #include "BPR_Drivers.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_unistd.h" // Constructor. template Bounded_Packet_Relay_Driver::Bounded_Packet_Relay_Driver (void) : packet_count_cmd_ (0), arrival_period_cmd_ (0), transmit_period_cmd_ (0), duration_limit_cmd_ (0), logging_level_cmd_ (0), run_transmission_cmd_ (0), cancel_transmission_cmd_ (0), report_stats_cmd_ (0), shutdown_cmd_ (0), packet_count_ (1000), arrival_period_ (10000), send_period_ (10000), duration_limit_ (20000000), logging_level_ (0) { } // Destructor. template Bounded_Packet_Relay_Driver::~Bounded_Packet_Relay_Driver (void) { // delete all instantiated command objects delete packet_count_cmd_; delete arrival_period_cmd_; delete transmit_period_cmd_; delete duration_limit_cmd_; delete logging_level_cmd_; delete run_transmission_cmd_; delete cancel_transmission_cmd_; delete report_stats_cmd_; delete shutdown_cmd_; } // Parse the input and execute the corresponding command. template int Bounded_Packet_Relay_Driver::parse_commands (const char *buf) { int option; if (::sscanf (buf, "%d", &option) <= 0) // If there was an error reading the option simply try on the next // line. return 0; switch (option) { case 1: // set packet count { u_long count; // We just reread the option, this simplies parsing (since // sscanf can do it for us). if (::sscanf (buf, "%d %lu", &option, &count) < 2) // If there was not enough information on the line, ignore // option and try the next line. return 0; if (packet_count_cmd_->execute ((void *) &count) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "set packet count failed"), -1); break; } case 2: // Set the arrival period. { u_long usec; // We just reread the option, this simplies parsing (since // sscanf can do it for us). if (::sscanf (buf, "%d %lu", &option, &usec) < 2) // If there was not enough information on the line, ignore // option and try the next line. return 0; if (arrival_period_cmd_->execute ((void *) &usec) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "set arrival period failed"), -1); break; } case 3: // Set transmit period. { u_long usec; // We just reread the option, this simplies parsing (since // sscanf can do it for us). if (::sscanf (buf, "%d %lu", &option, &usec) < 2) // If there was not enough information on the line, ignore // option and try the next line. return 0; if (transmit_period_cmd_->execute ((void *) &usec) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "set transmit period failed"), -1); break; } case 4: // Set duration limit. { u_long usec; // We just reread the option, this simplies parsing (since // sscanf can do it for us). if (::sscanf (buf, "%d %lu", &option, &usec) < 2) // If there was not enough information on the line, ignore // option and try the next line. return 0; if (duration_limit_cmd_->execute ((void *) &usec) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "\nSet duration limit failed."), -1); break; } case 5: // Set logging level. { int level; // We just reread the option, this simplies parsing (since // sscanf can do it for us). if ((::sscanf (buf, "%d %d", &option, &level) < 2) || (level < 0) || (level > 7)) { // If there was not enough information on the line, or the // passed value was invalid, ignore and try again. return 0; } if (logging_level_cmd_->execute ((void *) &level) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "set logging level failed"), -1); break; } case 6: // Run one transmission. return run_transmission_cmd_->execute (0); /* NOTREACHED */ case 7: // Cancel current transmission. return cancel_transmission_cmd_->execute (0); /* NOTREACHED */ case 8: // Report statistics. return report_stats_cmd_->execute (0); /* NOTREACHED */ case 9: // Shut down the driver. return shutdown_cmd_->execute (0); /* NOTREACHED */ default: // Display an error message. ACE_ERROR_RETURN ((LM_ERROR, "invalid input %s\n", buf), 0); ACE_NOTREACHED (break); /* NOTREACHED */ } /* ENDSWITCH */ return 0; } // Runs the test. template int Bounded_Packet_Relay_Driver::run (void) { this->init (); // Process all the incoming events. for (;;) if (this->get_next_request () == -1) return -1; ACE_NOTREACHED (return 0); } // Gets the next request from the user input. template int Bounded_Packet_Relay_Driver::get_next_request (void) { char buf[BUFSIZ]; this->display_menu (); // Reads input from the user. if (this->read_input (buf, sizeof buf) <= 0) return -1; // Parse and run the command. return this->parse_commands (buf); } // Reads input from the user from ACE_STDIN into the buffer specified. template ssize_t Bounded_Packet_Relay_Driver::read_input (char *buf, size_t bufsiz) { ACE_OS::memset (buf, 0, bufsiz); // Wait for user to type commands. This call is automatically // restarted when SIGINT or SIGALRM signals occur. return ACE_OS::read (ACE_STDIN, buf, bufsiz); } // Get count of packets to send in a transmission. template u_long Bounded_Packet_Relay_Driver::packet_count (void) { return packet_count_; } // Set count of packets to send in a transmission. template void Bounded_Packet_Relay_Driver::packet_count (u_long pc) { packet_count_ = pc; } // Get rate at which input packets are to arrive. template u_long Bounded_Packet_Relay_Driver::arrival_period (void) { return arrival_period_; } // Set rate at which input packets are to arrive. template void Bounded_Packet_Relay_Driver::arrival_period (u_long ap) { arrival_period_ = ap; } // Get rate at which packets are to be relayed (usec). template u_long Bounded_Packet_Relay_Driver::send_period (void) { return send_period_; } // Set rate at which packets are to be relayed (usec). template void Bounded_Packet_Relay_Driver::send_period (u_long sp) { send_period_ = sp; } // Get limit on the duration of the transmission (usec). template u_long Bounded_Packet_Relay_Driver::duration_limit (void) { return duration_limit_; } // Set limit on the duration of the transmission (usec). template void Bounded_Packet_Relay_Driver::duration_limit (u_long dl) { duration_limit_ = dl; } // Get logging level. template int Bounded_Packet_Relay_Driver::logging_level (void) { return logging_level_; } // Set logging level. template void Bounded_Packet_Relay_Driver::logging_level (int ll) { logging_level_ = ll; } #endif /* _BPR_DRIVER_T_CPP_ */ ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/bpr_thread.cpp0000644000175000017500000000712012576461726025054 0ustar pgquilespgquiles //============================================================================= /** * @file bpr_thread.cpp * * Exercises drivers for a bounded packet relay, based on threaded timer queues. * * @author Chris Gill and Douglas C. Schmidt Based on the Timer Queue Test example written by Carlos O'Ryan and Douglas C. Schmidt and Sergio Flores-Gaitan */ //============================================================================= #include "ace/Auto_Ptr.h" #include "Thread_Bounded_Packet_Relay.h" typedef Bounded_Packet_Relay_Driver THREAD_BOUNDED_PACKET_RELAY_DRIVER; typedef ACE_Command_Callback INPUT_CALLBACK; // A snippet from Andrew Marvell (Oliver Cromwell's poet laureate) static const char input_text [] = "But ever at my back I hear\n" " Time's winged chariot hurrying near."; int ACE_TMAIN (int, ACE_TCHAR *[]) { // Construct a new thread manager for the input device task. Auto // ptr ensures memory is freed when we exit this scope. ACE_Thread_Manager *input_task_mgr; ACE_NEW_RETURN (input_task_mgr, ACE_Thread_Manager, -1); auto_ptr mgr (input_task_mgr); // Construct a new input device wrapper. Auto ptr ensures memory is // freed when we exit this scope. Text_Input_Device_Wrapper *input_device; ACE_NEW_RETURN (input_device, Text_Input_Device_Wrapper (input_task_mgr, sizeof (input_text), input_text), -1); auto_ptr input (input_device); // Construct a new output device wrapper. Auto ptr ensures memory // is freed when we exit this scope. Text_Output_Device_Wrapper *output_device = 0; ACE_NEW_RETURN (output_device, Text_Output_Device_Wrapper, -1); auto_ptr output (output_device); // Construct a new bounded packet relay. Auto ptr ensures memory is // freed when we exit this scope. Bounded_Packet_Relay *packet_relay = 0; ACE_NEW_RETURN (packet_relay, Bounded_Packet_Relay (input_task_mgr, input_device, output_device), -1); auto_ptr relay (packet_relay); // Construct a receive input callback command for the relay, and register // it with the input device. Auto ptr ensures memory is freed when we exit // this scope. INPUT_CALLBACK *input_callback = 0; ACE_NEW_RETURN (input_callback, INPUT_CALLBACK (*packet_relay, &Bounded_Packet_Relay::receive_input), -1); auto_ptr callback (input_callback); if (input_device->set_send_input_msg_cmd (input_callback) < 0) { ACE_ERROR_RETURN ((LM_ERROR, "failed to register input callback"), -1); } // Construct a new bounded packet relay driver. Auto ptr ensures // memory is freed when we exit this scope. THREAD_BOUNDED_PACKET_RELAY_DRIVER *tbprd = 0; ACE_NEW_RETURN (tbprd, Thread_Bounded_Packet_Relay_Driver (packet_relay), -1); auto_ptr driver (tbprd); return driver->run (); // All dynamically allocated memory is released when main() returns. } ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/Bounded_Packet_Relay.mpc0000644000175000017500000000014712576461726026744 0ustar pgquilespgquiles// -*- MPC -*- project : aceexe { exename = bpr_thread macros += ACE_HAS_DEFERRED_TIMER_COMMANDS } ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/BPR_Drivers.h0000644000175000017500000002047412576461726024537 0ustar pgquilespgquiles/* -*- C++ -*- */ //============================================================================= /** * @file BPR_Drivers.h * * This code builds abstractions to factor out common code from * the different possible implementations of the Timer_Queue based * bounded packet relay example. * * @author Chris Gill and Douglas C. Schmidt Based on the Timer Queue Test example written by Carlos O'Ryan and Douglas C. Schmidt and Sergio Flores-Gaitan */ //============================================================================= #ifndef _BPR_DRIVERS_H_ #define _BPR_DRIVERS_H_ #include "ace/Functor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Reactor.h" #include "ace/Task.h" // forward declarations class Input_Device_Wrapper_Base; class Output_Device_Wrapper_Base; /** * @class Bounded_Packet_Relay * * @brief This class defines a packet relay abstraction for a * transmission bounded external commands to start and end the * transmission. The transmission may be bounded by the number * of packets to send, the dration of the transmission, or any * other factors. * * The relay abstraction implemented by this class registers a * callback command with an input device wrapper, and relays * input to an output device at a pace specified in the start * transmission call. */ class Bounded_Packet_Relay { public: // = Enumerates possible status values for a transmission. enum Transmission_Status { UN_INITIALIZED, STARTED, COMPLETED, TIMED_OUT, CANCELLED, ERROR_DETECTED }; enum Queue_Defaults { DEFAULT_HWM = 0x7FFFFFFF, DEFAULT_LWM = 0x7FFFFFFF }; /// Command entry point type definition. typedef int (Bounded_Packet_Relay::*ACTION) (void *); // = Initialization method /// Constructor. Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, Input_Device_Wrapper_Base *input_wrapper, Output_Device_Wrapper_Base *output_wrapper); /// Destructor. virtual ~Bounded_Packet_Relay (void); /// Requests output be sent to output device. int send_input (void); /// Requests a transmission be started. int start_transmission (u_long packet_count, u_long arrival_period, int logging_level); /// Requests a transmission be ended. int end_transmission (Transmission_Status status); /// Requests a report of statistics from the last transmission. int report_statistics (void); // = Command accessible entry points. /// Public entry point to which to push input. int receive_input (void *); // = Accessors and mutators for relay settings /// Get high water mark for relay queue. ACE_UINT32 queue_hwm (void); /// Set high water mark for relay queue. void queue_hwm (ACE_UINT32 hwm); /// Get low water mark for relay queue. ACE_UINT32 queue_lwm (void); /// Set low water mark for relay queue. void queue_lwm (ACE_UINT32 lwm); private: // = Concurrency Management. /// flag for whether or not a transmission is active int is_active_; /// Thread manager for the input device task. ACE_Thread_Manager * input_task_mgr_; /// Pointer to the input device wrapper. Input_Device_Wrapper_Base * input_wrapper_; /// Pointer to the output device wrapper. Output_Device_Wrapper_Base * output_wrapper_; /// Queue used to buffer input messages. ACE_Message_Queue queue_; /// High water mark for relay queue. ACE_UINT32 queue_hwm_; /// Low water mark for relay queue. ACE_UINT32 queue_lwm_; /// Lock for thread-safe synchronization of transmission startup and /// termination. ACE_SYNCH_MUTEX transmission_lock_; // = Transmission Statistics /// Returns string corresponding to current status. const char *status_msg (void); /// Number of transmissions sent. u_long transmission_number_; /// Count of packets sent in the most recent transmission. u_long packets_sent_; /// Status of the current or most recent transmission. Transmission_Status status_; /// Start time of the most recent transmission. ACE_Time_Value transmission_start_; /// Ending time of the most recent transmission. ACE_Time_Value transmission_end_; }; /** * @class Input_Device_Wrapper_Base * * @brief This class defines an abstract base class for an input device * wrapper that hides the details of the specific device and * provides a consistent message passing interface without * knowing anything about the implementation of the input device * or the message receiver. * The abstract base class ctor takes a command template object * that is instantiated with the correct receiver and action * types. This command object is used to send newly created input * messages to the receiver. * The abstract base class is designed to operate in an active * "push" mode, sending input data to the receiver whenever the * data is ready. The underlying device may be active, notifying * the wrapper when data is ready, or may be passive in which * case the wrapper must rely on a reactive and/or polling * mechanism. * * Derived classes are responsible for filling in concrete * definitions for the abstract message creation method and the * svc method. */ class Input_Device_Wrapper_Base : public ACE_Task_Base { public: // = Initialization and termination methods. /// Constructor. Input_Device_Wrapper_Base (ACE_Thread_Manager *input_task_mgr); /// Destructor. virtual ~Input_Device_Wrapper_Base (); /// Sets send input message command in the input device driver /// object. int set_send_input_msg_cmd (ACE_Command_Base *send_input_msg_cmd); /// Sets period (in usecs) between when inputs are created. int set_input_period (u_long input_period); /// Sets count of messages to send. int set_send_count (long count); /** * Requests that the input device stop sending messages and * terminate its thread. Should return 1 if it will do so, 0 if it * has already done so, or -1 if there is a problem doing so. */ int request_stop (void); /// This method runs the input device loop in the new thread. virtual int svc (void); /// Provides an abstract interface to allow modifying device /// settings. virtual int modify_device_settings (void *) = 0; protected: /// Creates a new message block, carrying data read from the /// underlying input device. virtual ACE_Message_Block *create_input_message (void) = 0; /** * Sends a newly created message block, carrying data read from the * underlying input device, by passing a pointer to the message * block to its command execution. */ virtual int send_input_message (ACE_Message_Block *); /// Send newly created input message. ACE_Command_Base *send_input_msg_cmd_; /// Period between when input values are produced (usecs). u_long input_period_; /// Reactor used to multiplex input streams, timeouts. ACE_Reactor reactor_; /// Flag to indicate whether or not input object is /// (and should remain) active. int is_active_; /// Count of messages to send before stopping (-1 indicates the /// device should not stop). long send_count_; /// Currently remaining count of messages to send before stopping /// (-1 indicates the device should not stop). long current_count_; }; /** * @class Output_Device_Wrapper_Base * * @brief This class defines an abstract base class for an output device * wrapper that hides the details of the specific device and * provides a consistent write method interface without knowing * anything about the implementation. * * The abstract methods write_output_message () and * modify_device_settings () are defined in derived classes to * write the contents of the passed message out the underlying * output device, and update device settings, respectively. */ class Output_Device_Wrapper_Base { public: virtual ~Output_Device_Wrapper_Base (void); /// Writes contents of the passed message block out to the underlying /// output device. virtual int write_output_message (void *) = 0; /// Provides an abstract interface to allow modifying device /// settings. virtual int modify_device_settings (void *) = 0; }; // include the templates #include "BPR_Drivers_T.h" #endif /* _BPR_DRIVERS_H_ */ ace-6.3.3+dfsg.orig/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp0000644000175000017500000005303612576461726030243 0ustar pgquilespgquiles //============================================================================= /** * @file Thread_Bounded_Packet_Relay.cpp * * Method definitions for the threaded-bounded packet relay class. * * @author Chris Gill and Douglas C. Schmidt Based on the Timer Queue Test example written by Carlos O'Ryan and Douglas C. Schmidt and Sergio Flores-Gaitan */ //============================================================================= #include "ace/OS_NS_string.h" #include "ace/OS_NS_sys_time.h" #include "ace/Condition_T.h" #include "ace/Null_Mutex.h" #include "Thread_Bounded_Packet_Relay.h" typedef Thread_Bounded_Packet_Relay_Driver::MYCOMMAND DRIVER_CMD; typedef ACE_Command_Callback HANDLER_CMD; typedef ACE_Command_Callback SEND_HANDLER_CMD; // Constructor. Text_Input_Device_Wrapper::Text_Input_Device_Wrapper (ACE_Thread_Manager *input_task_mgr, size_t read_length, const char* text, int logging) : Input_Device_Wrapper_Base (input_task_mgr), read_length_ (read_length), text_ (text), index_ (0), logging_ (logging), packet_count_ (0) { } // Destructor. Text_Input_Device_Wrapper::~Text_Input_Device_Wrapper (void) { } // Modifies device settings based on passed pointer to a u_long. int Text_Input_Device_Wrapper::modify_device_settings (void *logging) { packet_count_ = 0; if (logging) logging_ = *static_cast (logging); else ACE_ERROR_RETURN ((LM_ERROR, "Text_Input_Device_Wrapper::modify_device_settings: " "null argument"), -1); return 0; } // Creates a new message block, carrying data // read from the underlying input device. ACE_Message_Block * Text_Input_Device_Wrapper::create_input_message (void) { // Construct a new message block to send. ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block (read_length_), 0); // Zero out a "read" buffer to hold data. char read_buf [BUFSIZ]; ACE_OS::memset (read_buf, 0, BUFSIZ); // Loop through the text, filling in data to copy into the read // buffer (leaving room for a terminating zero). for (size_t i = 0; i < read_length_ - 1; ++i) { read_buf [i] = text_ [index_]; index_ = (index_ + 1) % ACE_OS::strlen (text_); } // Copy buf into the Message_Block and update the wr_ptr (). if (mb->copy (read_buf, read_length_) < 0) { delete mb; ACE_ERROR_RETURN ((LM_ERROR, "read buffer copy failed"), 0); } // log packet creation if logging is turned on if (logging_ & Text_Input_Device_Wrapper::LOG_MSGS_CREATED) { ++packet_count_; ACE_DEBUG ((LM_DEBUG, "input message %d created\n", packet_count_)); } return mb; } // Constructor. Text_Output_Device_Wrapper::Text_Output_Device_Wrapper (int logging) : logging_ (logging) { } // Consume and possibly print out the passed message. int Text_Output_Device_Wrapper::write_output_message (void *message) { if (message) { ++packet_count_; if (logging_ & Text_Output_Device_Wrapper::LOG_MSGS_RCVD) ACE_DEBUG ((LM_DEBUG, "output message %d received\n", packet_count_)); if (logging_ & Text_Output_Device_Wrapper::PRINT_MSGS_RCVD) ACE_DEBUG ((LM_DEBUG, "output message %d:\n[%s]\n", packet_count_, static_cast (message)->rd_ptr ())); delete static_cast (message); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "Text_Output_Device_Wrapper::" "write_output_message: null argument"), -1); } // Modifies device settings based on passed pointer to a u_long. int Text_Output_Device_Wrapper::modify_device_settings (void *logging) { packet_count_ = 0; if (logging) logging_ = *static_cast (logging); else ACE_ERROR_RETURN ((LM_ERROR, "Text_Output_Device_Wrapper::modify_device_settings: " "null argument"), -1); return 0; } // Constructor. User_Input_Task::User_Input_Task (Bounded_Packet_Relay *relay, Thread_Timer_Queue *queue, Thread_Bounded_Packet_Relay_Driver &tbprd) : ACE_Task_Base (ACE_Thread_Manager::instance ()), usecs_ (ACE_ONE_SECOND_IN_USECS), relay_ (relay), queue_ (queue), driver_ (tbprd) { } // Destructor. User_Input_Task::~User_Input_Task (void) { this->clear_all_timers (); } // Runs the main event loop. int User_Input_Task::svc (void) { for (;;) // Call back to the driver's implementation of how to read and // parse input. if (this->driver_.get_next_request () == -1) break; // We are done. this->relay_->end_transmission (Bounded_Packet_Relay::CANCELLED); this->queue_->deactivate (); ACE_DEBUG ((LM_DEBUG, "terminating user input thread\n")); this->clear_all_timers (); return 0; } // Sets the number of packets for the next transmission. int User_Input_Task::set_packet_count (void *argument) { if (argument) { driver_.packet_count (*static_cast (argument)); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::set_packet_count: null argument"), -1); } // Sets the input device packet arrival period (usecs) for the next // transmission. int User_Input_Task::set_arrival_period (void *argument) { if (argument) { driver_.arrival_period (*static_cast (argument)); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::set_arrival_period: null argument"), -1); } // Sets the period between output device sends (usecs) for the next // transmission. int User_Input_Task::set_send_period (void *argument) { if (argument) { driver_.send_period (*static_cast (argument)); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::set_send_period: null argument"), -1); } // Sets a limit on the transmission duration (usecs). int User_Input_Task::set_duration_limit (void *argument) { if (argument) { driver_.duration_limit (*static_cast (argument)); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::set_duration_limit: null argument"), -1); } // Sets logging level (0 or 1) for output device for the next // transmission. int User_Input_Task::set_logging_level (void *argument) { if (argument) { driver_.logging_level (*static_cast (argument)); return 0; } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::set_logging_level: null argument"), -1); } // Runs the next transmission (if one is not in progress). int User_Input_Task::run_transmission (void *) { if (relay_) { switch (relay_->start_transmission (driver_.packet_count (), driver_.arrival_period (), driver_.logging_level ())) { case 1: ACE_DEBUG ((LM_DEBUG, "\nRun transmission: " " Transmission already in progress\n")); return 0; /* NOTREACHED */ case 0: { ACE_Time_Value now = ACE_OS::gettimeofday (); ACE_Time_Value send_every (0, driver_.send_period ()); ACE_Time_Value send_at (send_every + now); Send_Handler *send_handler; ACE_NEW_RETURN (send_handler, Send_Handler (driver_.packet_count (), send_every, *relay_, *queue_, driver_), -1); if (queue_->schedule (send_handler, 0, send_at) < 0) { delete send_handler; ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::run_transmission: " "failed to schedule send handler"), -1); } if (driver_.duration_limit ()) { ACE_Time_Value terminate_at (0, driver_.duration_limit ()); terminate_at += now; Termination_Handler *termination_handler; termination_handler = new Termination_Handler (*relay_, *queue_, driver_); if (! termination_handler) { this->clear_all_timers (); ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::run_transmission: " "failed to allocate termination " "handler"), -1); } if (queue_->schedule (termination_handler, 0, terminate_at) < 0) { delete termination_handler; this->clear_all_timers (); ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::run_transmission: " "failed to schedule termination " "handler"), -1); } } return 0; } /* NOTREACHED */ default: return -1; /* NOTREACHED */ } } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::run_transmission: " "relay not instantiated"), -1); } // Ends the current transmission (if one is in progress). int User_Input_Task::end_transmission (void *) { if (relay_) { switch (relay_->end_transmission (Bounded_Packet_Relay::CANCELLED)) { case 1: ACE_DEBUG ((LM_DEBUG, "\nEnd transmission: " "no transmission in progress\n")); /* Fall through to next case */ case 0: // Cancel any remaining timers. this->clear_all_timers (); return 0; /* NOTREACHED */ default: return -1; /* NOTREACHED */ } } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::end_transmission: " "relay not instantiated"), -1); } // Reports statistics for the previous transmission // (if one is not in progress). int User_Input_Task::report_stats (void *) { if (relay_) { switch (relay_->report_statistics ()) { case 1: ACE_DEBUG ((LM_DEBUG, "\nRun transmission: " "\ntransmission already in progress\n")); return 0; /* NOTREACHED */ case 0: this->clear_all_timers (); return 0; /* NOTREACHED */ default: return -1; /* NOTREACHED */ } } ACE_ERROR_RETURN ((LM_ERROR, "User_Input_Task::report_stats: " "relay not instantiated"), -1); } // Shut down the task. int User_Input_Task::shutdown (void *) { // Clear any outstanding timers. this->clear_all_timers (); #if !defined (ACE_LACKS_PTHREAD_CANCEL) // Cancel the thread timer queue task "preemptively." ACE_Thread::cancel (this->queue_->thr_id ()); #else // Cancel the thread timer queue task "voluntarily." this->queue_->deactivate (); #endif /* ACE_LACKS_PTHREAD_CANCEL */ // -1 indicates we are shutting down the application. return -1; } // Helper method: clears all timers. int User_Input_Task::clear_all_timers (void) { // loop through the timers in the queue, cancelling each one for (ACE_Timer_Node_T *node; (node = queue_->timer_queue ()->get_first ()) != 0; ) queue_->timer_queue ()->cancel (node->get_timer_id (), 0, 0); return 0; } // Constructor. BPR_Handler_Base::BPR_Handler_Base (Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue) : relay_ (relay), queue_ (queue) { } // Destructor. BPR_Handler_Base::~BPR_Handler_Base (void) { } // Helper method: clears all timers. int BPR_Handler_Base::clear_all_timers (void *) { // Loop through the timers in the queue, cancelling each one. for (ACE_Timer_Node_T *node; (node = queue_.timer_queue ()->get_first ()) != 0; ) queue_.timer_queue ()->cancel (node->get_timer_id (), 0, 0); // queue_.cancel (node->get_timer_id (), 0); // Invoke the handler's (virtual) destructor delete this; return 0; } // Constructor. Send_Handler::Send_Handler (u_long send_count, const ACE_Time_Value &duration, Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue, Thread_Bounded_Packet_Relay_Driver &driver) : BPR_Handler_Base (relay, queue), send_count_ (send_count), duration_ (duration), driver_ (driver) { } // Destructor. Send_Handler::~Send_Handler (void) { } // Call back hook. int Send_Handler::handle_timeout (const ACE_Time_Value &, const void *) { switch (relay_.send_input ()) { case 0: // Decrement count of packets to relay. --send_count_; /* Fall through to next case. */ case 1: if (send_count_ > 0) { // Enqueue a deferred callback to the reregister command. SEND_HANDLER_CMD *re_register_callback_; ACE_NEW_RETURN (re_register_callback_, SEND_HANDLER_CMD (*this, &Send_Handler::reregister), -1); return queue_.enqueue_command (re_register_callback_); } else { // All packets are sent, time to end the transmission, redisplay // the user menu, cancel any other timers, and go away. relay_.end_transmission (Bounded_Packet_Relay::COMPLETED); driver_.display_menu (); // Enqueue a deferred callback to the clear_all_timers command. HANDLER_CMD *clear_timers_callback_; ACE_NEW_RETURN (clear_timers_callback_, HANDLER_CMD (*this, &BPR_Handler_Base::clear_all_timers), -1); return queue_.enqueue_command (clear_timers_callback_); } /* NOTREACHED */ default: return -1; } } // Cancellation hook. int Send_Handler::cancelled (void) { delete this; return 0; } // Helper method: re-registers this timer int Send_Handler::reregister (void *) { // Re-register the handler for a new timeout. if (queue_.schedule (this, 0, duration_ + ACE_OS::gettimeofday ()) < 0) ACE_ERROR_RETURN ((LM_ERROR, "Send_Handler::reregister: " "failed to reschedule send handler"), -1); return 0; } // Constructor. Termination_Handler::Termination_Handler (Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue, Thread_Bounded_Packet_Relay_Driver &driver) : BPR_Handler_Base (relay, queue), driver_ (driver) { } // Destructor. Termination_Handler::~Termination_Handler (void) { } // Call back hook. int Termination_Handler::handle_timeout (const ACE_Time_Value &, const void *) { // Transmission timed out, so end the transmission, display the user // menu, and register a callback to clear the timer queue and then // make this object go away. relay_.end_transmission (Bounded_Packet_Relay::TIMED_OUT); driver_.display_menu (); // Enqueue a deferred callback to the clear_all_timers command. HANDLER_CMD *clear_timers_callback_; ACE_NEW_RETURN (clear_timers_callback_, HANDLER_CMD (*this, &BPR_Handler_Base::clear_all_timers), -1); return queue_.enqueue_command (clear_timers_callback_); } // Cancellation hook int Termination_Handler::cancelled (void) { delete this; return 0; } // Constructor. Thread_Bounded_Packet_Relay_Driver::Thread_Bounded_Packet_Relay_Driver (Bounded_Packet_Relay *relay) : input_task_ (relay, &timer_queue_, *this) { } // Destructor. Thread_Bounded_Packet_Relay_Driver::~Thread_Bounded_Packet_Relay_Driver (void) { } // Display the user menu. int Thread_Bounded_Packet_Relay_Driver::display_menu (void) { static char menu[] = "\n\n Options:\n" " ----------------------------------------------------------------------\n" " 1 \n" " min = 1 packet.\n" " 2 \n" " min = 1.\n" " 3 \n" " min = 1.\n" " 4 \n" " min = 1, no limit = 0.\n" " 5 \n" " no logging = 0,\n" " log packets created by input device = 1,\n" " log packets consumed by output device = 2,\n" " logging options 1,2 = 3,\n" " print contents of packets consumed by output put device = 4,\n" " logging options 1,4 = 5,\n" " logging options 2,4 = 6,\n" " logging options 1,2,4 = 7.\n" " ----------------------------------------------------------------------\n" " 6 - runs a transmission using the current settings\n" " 7 - cancels a transmission (if there is one running)\n" " 8 - reports statistics from the most recent transmission\n" " 9 - quits the program\n" " ----------------------------------------------------------------------\n" " Please enter your choice: "; ACE_DEBUG ((LM_DEBUG, menu, this->packet_count (), this->arrival_period (), this->send_period (), this->duration_limit (), this->logging_level ())); return 0; } // Initialize the driver. int Thread_Bounded_Packet_Relay_Driver::init (void) { // Initialize the objects with their corresponding // methods from . ACE_NEW_RETURN (packet_count_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::set_packet_count), -1); ACE_NEW_RETURN (arrival_period_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::set_arrival_period), -1); ACE_NEW_RETURN (transmit_period_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::set_send_period), -1); ACE_NEW_RETURN (duration_limit_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::set_duration_limit), -1); ACE_NEW_RETURN (logging_level_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::set_logging_level), -1); ACE_NEW_RETURN (run_transmission_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::run_transmission), -1); ACE_NEW_RETURN (cancel_transmission_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::end_transmission), -1); ACE_NEW_RETURN (report_stats_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::report_stats), -1); ACE_NEW_RETURN (shutdown_cmd_, DRIVER_CMD (input_task_, &User_Input_Task::shutdown), -1); if (this->input_task_.activate () == -1) ACE_ERROR_RETURN ((LM_ERROR, "cannot activate input task"), -1); else if (this->timer_queue_.activate () == -1) ACE_ERROR_RETURN ((LM_ERROR, "cannot activate timer queue"), -1); else if (ACE_Thread_Manager::instance ()->wait () == -1) ACE_ERROR_RETURN ((LM_ERROR, "wait on Thread_Manager failed"), -1); return 0; } // Run the driver int Thread_Bounded_Packet_Relay_Driver::run (void) { this->init (); return 0; } ace-6.3.3+dfsg.orig/examples/Connection/0000775000175000017500000000000012576472436020334 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Connection/non_blocking/0000775000175000017500000000000012576472436022776 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_tli_acceptor.cpp0000644000175000017500000000152712576461726027214 0ustar pgquilespgquiles// ACE_TLI Server. #include "ace/TLI_Acceptor.h" #include "ace/INET_Addr.h" #include "ace/Service_Config.h" #include "CPP-acceptor.h" #if defined (ACE_HAS_TLI) typedef Svc_Handler SVC_HANDLER; typedef IPC_Server IPC_SERVER; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_acceptor.svc (); } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("your platform does not support TLI\n")), 1); } #endif /* ACE_HAS_TLI */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/CPP-acceptor.cpp0000644000175000017500000001542212576461726025724 0ustar pgquilespgquiles#if !defined (CPP_ACCEPTOR_C) #define CPP_ACCEPTOR_C #include "ace/Service_Config.h" #include "CPP-acceptor.h" #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" template Svc_Handler::Svc_Handler (ACE_Reactor *r) : SVC_HANDLER (0, 0, r) { } template int Svc_Handler::close (u_long) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("calling Svc_Handler close\n"))); // Free up the handle. this->peer ().close (); return 0; } template int Svc_Handler::open (void *) { typename PEER_STREAM::PEER_ADDR client_addr; ACE_TCHAR buf[BUFSIZ]; if (this->peer ().get_remote_addr (client_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("get_remote_addr")), -1); else if (client_addr.addr_to_string (buf, sizeof buf) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("addr_to_string")), -1); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("client addr %s on handle %d\n"), buf, this->peer ().get_handle ())); // Process the connection immediately since we are an interative // server. return this->handle_input (); } // Receive and process the data from the client. template int Svc_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; // Read data from client (terminate on error). ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) in handle_input\n"))); for (ssize_t r_bytes; (r_bytes = this->peer ().recv (buf, sizeof buf)) > 0; ) if (ACE_OS::write (ACE_STDOUT, buf, r_bytes) != r_bytes) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE::send_n")), -1); // Send back ack. if (this->peer ().send_n ("", 1) != 1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("send_n")), -1); return 0; } template int Svc_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"), ACE_TEXT ("handle_timeout"))); return 0; } template int IPC_Server::init (int argc, ACE_TCHAR *argv[]) { const ACE_TCHAR *local_addr = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_PORT_STR; ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); int use_reactor = argc > 3 ? ACE_Synch_Options::USE_REACTOR : 0; this->options_.set (ACE_Synch_Options::USE_TIMEOUT | use_reactor, timeout); if (this->server_addr_.set (local_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("set")), -1); // Call down to the ACCEPTOR's method to do the // initialization. if (this->inherited::open (this->server_addr_, use_reactor ? ACE_Reactor::instance () : 0) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")), -1); // Handle the SIGINT signal through the . else if (ACE_Reactor::instance ()->register_handler (SIGINT, &this->done_handler_) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")), -1); #if !defined (ACE_WIN32) // Handle the SIGPIPE signal through the . else if (ACE_Reactor::instance ()->register_handler (SIGPIPE, &this->done_handler_) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")), -1); #endif /* ACE_WIN32 */ else return 0; } template IPC_Server::IPC_Server (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } template int IPC_Server::fini (void) { return 0; } template IPC_Server::~IPC_Server (void) { } template int IPC_Server::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (mask); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("calling IPC_Server handle_close, but accept handle stays open!\n"))); return 0; } // Run the interative service. template int IPC_Server::svc (void) { ACE_TCHAR buf[BUFSIZ]; if (this->server_addr_.addr_to_string (buf, sizeof buf) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("addr_to_string")), -1); else ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("starting server addr %s on handle %d\n"), buf, this->get_handle ())); // Performs the iterative server activities. while (ACE_Reactor::event_loop_done () == 0) { SVC_HANDLER sh (this->reactor ()); // Create a new endpoint, which performs all processing in // its method (note no automatic restart if errno == // EINTR). if (this->accept (&sh, 0, this->options_, 0) == -1) { if (errno == EWOULDBLOCK && this->reactor ()) // Handle the accept asynchronously if necessary. this->reactor ()->handle_events (); else // We've probably timed out... ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p on handle %d\n"), ACE_TEXT ("accept"), this->acceptor ().get_handle ())); } // 's destructor closes the stream implicitly but the // listening endpoint stays open. } /* NOTREACHED */ return 0; } #endif /* CPP_ACCEPTOR_C */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_tli_connector.cpp0000644000175000017500000000150312576461726027400 0ustar pgquilespgquiles// ACE_TLI Client. #include "ace/TLI_Connector.h" #include "ace/INET_Addr.h" #include "CPP-connector.h" #if defined (ACE_HAS_TLI) typedef Peer_Handler PEER_HANDLER; typedef IPC_Client IPC_CLIENT; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_CLIENT peer_connector; if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_connector.svc (); } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("your platform does not support TLI\n")), 1); } #endif /* ACE_HAS_TLI */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_spipe_acceptor.cpp0000644000175000017500000000153612576461726027544 0ustar pgquilespgquiles#include "ace/SPIPE_Acceptor.h" #include "ace/SPIPE_Addr.h" #include "ace/Service_Config.h" #include "CPP-acceptor.h" #if !defined (ACE_WIN32) typedef Svc_Handler SVC_HANDLER; typedef IPC_Server IPC_SERVER; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_acceptor.svc (); } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "This test is not ported to Win32 (yet)\n"), -1); } #endif /* !ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_spipe_connector.cpp0000644000175000017500000000150412576461726027731 0ustar pgquilespgquiles// ACE_SPIPE Client. #include "ace/SPIPE_Connector.h" #include "ace/SPIPE_Addr.h" #include "CPP-connector.h" #if !defined (ACE_WIN32) typedef Peer_Handler PEER_HANDLER; typedef IPC_Client IPC_CLIENT; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_CLIENT peer_connector; if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_connector.svc (); } #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "This test is not ported to Win32 (yet)\n"), -1); } #endif /* !ACE_WIN32 */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_lsock_acceptor.cpp0000644000175000017500000000204112576461726027527 0ustar pgquilespgquiles// ACE_LSOCK Server. #include "ace/LSOCK_Acceptor.h" #include "ace/Log_Msg.h" #include "ace/Service_Config.h" #if defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) int ACE_TMAIN (int, ACE_TCHAR *argv[]) { ACE_ERROR_RETURN ((LM_INFO, ACE_TEXT ("%s: not supported with ") ACE_TEXT ("ACE_LACKS_UNIX_DOMAIN_SOCKETS\n"), argv[0]), -1); } #else /* ! ACE_LACKS_UNIX_DOMAIN_SOCKETS */ #include "ace/UNIX_Addr.h" #include "CPP-acceptor.h" typedef Svc_Handler SVC_HANDLER; typedef IPC_Server IPC_SERVER; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_SERVER peer_acceptor; if (peer_acceptor.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_acceptor.svc (); } #endif /* ! ACE_LACKS_UNIX_DOMAIN_SOCKETS */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/README0000644000175000017500000000176112576461726023661 0ustar pgquilespgquiles This code illustrates how to write a single set of source code (for a client and server) and then parameterize in the desired IPC mechanism. In this case, the IPC mechanisms include sockets, TLI, and STREAM pipes. The single set of source code is located in CPP-acceptor.cpp (which is the server) and CPP-connector.cpp (which is the non-blocking client). Here's how I typically run these tests: % test_sock_acceptor localhost:10020 & starting up daemon ./test_sock_acceptor starting server addr 127.0.0.1:10020 on handle 5 client addr 127.0.0.1:10003 on handle 6 hello % test_sock_connector localhost:10020 starting up daemon ./test_sock_connector activating 5 in handle_output please enter input..: hello in handle_output There are a number of other options that you can provide. Please see the source code for details. Note that only the sock tests work on all platforms. The other tests reply on features (in particular, non-blocking connections and TLI) that are mostly found on UNIX platforms. ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/CPP-connector.h0000644000175000017500000000503712576461726025564 0ustar pgquilespgquiles/* -*- C++ -*- */ #ifndef CPP_CONNECTOR_H #define CPP_CONNECTOR_H #include "ace/Service_Config.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Connector.h" #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" template class Peer_Handler : public ACE_Svc_Handler { // = TITLE // Handles communication with the server. // // = DESCRIPTION // This class uses a very clever state machine pattern to keep // track of how it interacts with the user and the server. public: Peer_Handler (ACE_Reactor *r = 0); virtual int open (void * = 0); // Activate the handler when connection is established. virtual int close (u_long flags = 0); // Called on failed connection attempt. // = Demultiplexing hooks. virtual int handle_output (ACE_HANDLE); virtual int handle_input (ACE_HANDLE); virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask mask); virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); virtual int handle_timeout (const ACE_Time_Value &time, const void *); protected: // = These methods implement the State pattern. int uninitialized (void); int connected (void); int stdio (void); int (Peer_Handler::*action_) (void); // Keeps track of which state we are in. }; template class IPC_Client : public ACE_Connector { // = TITLE // This class illustrates how the works. public: // = Initialization and termination methods. IPC_Client (void); // Constructor. ~IPC_Client (void); // Destructor. // = Dynamic linking hooks. virtual int init (int argc, ACE_TCHAR *argv[]); // Initialize the IPC client. virtual int fini (void); // Destroy the IPC client. virtual int svc (void); // Run the svc. private: typedef ACE_Connector inherited; ACE_Synch_Options options_; // Options for the active connection factory. ACE_Sig_Adapter done_handler_; // Keeps track of when we shut down due to receipt of the SIGINT // signal. }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "CPP-connector.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("CPP-connector.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* CPP_CONNECTOR_H */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_lsock_connector.cpp0000644000175000017500000000201412576461726027721 0ustar pgquilespgquiles#include "ace/LSOCK_Connector.h" #include "ace/Log_Msg.h" #if defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) int ACE_TMAIN (int, ACE_TCHAR *argv[]) { ACE_ERROR_RETURN ((LM_INFO, ACE_TEXT ("%s: not supported with ") ACE_TEXT ("ACE_LACKS_UNIX_DOMAIN_SOCKETS\n"), argv[0]), -1); } #else /* ! ACE_LACKS_UNIX_DOMAIN_SOCKETS */ #include "ace/UNIX_Addr.h" #include "CPP-connector.h" typedef Peer_Handler PEER_HANDLER; typedef IPC_Client IPC_CLIENT; // ACE_LSOCK Client. int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Perform Service_Config initializations ACE_Service_Config daemon (argv[0]); IPC_CLIENT peer_connector; if (peer_connector.init (argc, argv) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init")), -1); return peer_connector.svc (); } #endif /* ! ACE_LACKS_UNIX_DOMAIN_SOCKETS */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/CPP-connector.cpp0000644000175000017500000001704012576461726026114 0ustar pgquilespgquiles#if !defined (CPP_CONNECTOR_C) #define CPP_CONNECTOR_C #include "CPP-connector.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" template Peer_Handler::Peer_Handler (ACE_Reactor *r) : action_ (&Peer_Handler::uninitialized) { this->reactor (r); } template int Peer_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("activating %d\n"), this->peer ().get_handle ())); this->action_ = &Peer_Handler::connected; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("please enter input..: "))); if (this->reactor ()) #if defined (ACE_WIN32) // On Win32, the stdin HANDLE must be registered directly (and not // as a socket). this->reactor ()->register_handler (this, ACE_STDIN); #else // On non-Win32, the stdin HANDLE must be registered as a normal // handle with the . this->reactor ()->register_handler (ACE_STDIN, this, ACE_Event_Handler::READ_MASK); #endif /* ACE_WIN32 */ else { while (this->connected () != -1) continue; this->handle_close (ACE_INVALID_HANDLE, ACE_Event_Handler::READ_MASK); } return 0; } template int Peer_Handler::close (u_long) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect not successful: ending reactor event loop\n"))); this->reactor ()->end_reactor_event_loop(); return 0; } template int Peer_Handler::uninitialized (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("uninitialized!\n"))); return 0; } template int Peer_Handler::connected (void) { char buf[BUFSIZ]; ssize_t n = ACE_OS::read (ACE_STDIN, buf, sizeof buf); if (n > 0 && this->peer ().send_n (buf, n) != n) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("write failed")), -1); else if (n == 0) { // Explicitly close the connection. if (this->peer ().close () == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("close")), 1); return -1; } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("please enter input..: "))); return 0; } } template int Peer_Handler::stdio (void) { char buf[BUFSIZ]; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in stdio\nplease enter input..: "))); ssize_t n = ACE_OS::read (ACE_STDIN, buf, sizeof buf); if (n > 0) { if (ACE_OS::write (ACE_STDOUT, buf, n) != n) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("write")), -1); return 0; } else return -1; } template int Peer_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect timedout. "))); return this->close (); } template int Peer_Handler::handle_output (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_output\n"))); return (this->*action_) (); } template int Peer_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { // @@ Note that this code is not portable to all OS platforms since // it uses print statements within signal handler context. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_signal\n"))); return (this->*action_) (); } template int Peer_Handler::handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_input\n"))); return (this->*action_) (); } template int Peer_Handler::handle_close (ACE_HANDLE h, ACE_Reactor_Mask mask) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("closing down handle %d with mask %d\n"), h, mask)); if (this->action_ == &Peer_Handler::stdio) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to closed state\n"))); this->reactor ()->end_reactor_event_loop (); } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to stdio state\n"))); this->action_ = &Peer_Handler::stdio; this->peer ().close (); ACE_OS::rewind (stdin); if (this->reactor ()) #if defined (ACE_WIN32) // On Win32, the std handle must be registered directly (and not // as a socket) return this->reactor ()->register_handler (this, ACE_STDIN); #else // On non-Win32, the std handle must be registered as a normal // handle with the READ mask return this->reactor ()->register_handler (ACE_STDIN, this, ACE_Event_Handler::READ_MASK); #endif /* ACE_WIN32 */ else delete this; } return 0; } template int IPC_Client::svc (void) { if (this->reactor ()) this->reactor ()->run_reactor_event_loop (); return 0; } template int IPC_Client::fini (void) { return 0; } template IPC_Client::IPC_Client (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } template int IPC_Client::init (int argc, ACE_TCHAR *argv[]) { // Call down to the CONNECTOR's open() method to do the // initialization. this->inherited::open (ACE_Reactor::instance ()); const ACE_TCHAR *r_addr = argc > 1 ? argv[1] : ACE_SERVER_ADDRESS (ACE_DEFAULT_SERVER_HOST, ACE_DEFAULT_SERVER_PORT_STR); ACE_Time_Value timeout (argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_TIMEOUT); // Handle signals through the ACE_Reactor. if (ACE_Reactor::instance ()->register_handler (SIGINT, &this->done_handler_) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")), -1); typename PEER_CONNECTOR::PEER_ADDR remote_addr (r_addr); this->options_.set (ACE_Synch_Options::USE_REACTOR, timeout); SVC_HANDLER *sh; ACE_NEW_RETURN (sh, SVC_HANDLER (this->reactor ()), -1); // Connect to the peer. if (this->connect (sh, remote_addr, this->options_) == -1 && errno != EWOULDBLOCK) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("connect")), -1); else return 0; } template IPC_Client::~IPC_Client (void) { } #endif /* CPP_CONNECTOR_C */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/CPP-acceptor.h0000644000175000017500000000455312576461726025374 0ustar pgquilespgquiles/* -*- C++ -*- */ #ifndef CPP_ACCEPTOR_H #define CPP_ACCEPTOR_H #include "ace/Acceptor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" template class Svc_Handler : public ACE_Svc_Handler { // = TITLE // This class does the work once the has // accepted a connection. public: // = Initialization method. Svc_Handler (ACE_Reactor *r); virtual int open (void *); // Perform the work of the SVC_HANDLER. virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); // Handle data from the client. virtual int close (u_long); // Called if ACE_Svc_Handler is closed down unexpectedly. virtual int handle_timeout (const ACE_Time_Value &, const void *arg); // Handles acceptor timeouts. private: typedef ACE_Svc_Handler SVC_HANDLER; }; template class IPC_Server : public ACE_Oneshot_Acceptor { // = TITLE // This class illustrates how the works. public: // = Initialization and termination. IPC_Server (void); // Constructor. ~IPC_Server (void); // Destructor. // = Demultiplexing hooks. virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask); // Make sure not to close down the if we're removed from // the . // = Dynamic linking hooks. virtual int init (int argc, ACE_TCHAR *argv[]); // Initialize the network server. virtual int fini (void); // Close down the server. virtual int svc (void); // Run the interative service. private: typedef ACE_Oneshot_Acceptor inherited; typename PEER_ACCEPTOR::PEER_ADDR server_addr_; // Address of this server. ACE_Synch_Options options_; // Options that this server is using. ACE_Sig_Adapter done_handler_; // Keeps track of when we shut down due to receipt of the SIGINT // signal. }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "CPP-acceptor.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("CPP-acceptor.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* CPP_ACCEPTOR_H */ ace-6.3.3+dfsg.orig/examples/Connection/non_blocking/test_sock_connector.cpp0000644000175000017500000000266412576461726027560 0ustar pgquilespgquiles#include "ace/SOCK_Connector.h" #include "ace/INET_Addr.h" #include "ace/Reactor.h" #include "ace/WFMO_Reactor.h" #include "CPP-connector.h" typedef Peer_Handler PEER_HANDLER; typedef IPC_Client IPC_CLIENT; // ACE_SOCK Client. int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // Since this test waits on the STDIN handle to become ready, we // have to make sure that the WFMO_Reactor is used on Win32. This is // necessary since .xml. # -verbose: Verbose output. # -nocomment: Remove all comments. Use this argument if you have comments # mixing in the middle of a classic svc.conf directive. $indent = 0; sub inc_indent { $indent += 2; } sub dec_indent { $indent -= 2; } sub get_indent { $retv = 0; print STDERR "$0 (", $lineno, "): Unbalanced macro pairs\n" if ($indent < 0); $retv = $indent - 1 if ($indent > 0); $retv; } sub acexml_comment { my $comment = shift; print OUT " " x &get_indent (), "\n"; } sub acexml_start { my $name = shift; my $standalone = shift; print OUT " " x &get_indent (), "<$name"; while (@attnames) { print OUT " ", pop (@attnames), '="', pop (@attvalues), '"'; } if ($standalone != 0) { print OUT "/>\n"; } else { print OUT ">\n"; inc_indent (); } } sub acexml_end { my $name = shift; dec_indent (); print OUT " " x &get_indent (), "\n"; } $verbose = 0; $nocomment = 0; @attvalues = (); @attnames = (); $stream = ""; $infile = ""; $outfile = ""; while ( $#ARGV >= 0) { if ($ARGV[0] =~ m/^-i/i) { shift; $infile = "$ARGV[0]"; } elsif ($ARGV[0] =~ m/^-o/i) { shift; $outfile = "$ARGV[0]"; } elsif ($ARGV[0] =~ m/^-verbose/i) { $verbose = 1; } elsif ($ARGV[0] =~ m/^-nocomment/i) { $nocomment = 1; } elsif ($ARGV[0] =~ m/^-(\?|h|help)/i) { # Help information print " Usage: svcconf-convert.pl [-i infile] [-o outfile] [-verbose] [-nocomment] -i: Specify the input classic svc.conf filename. If omitted, the default input filename is 'svc.conf'. -o: Specify the output XML svc.conf filename. If this argument is omitted, the resulting XML file will be written to file called .xml. -verbose: Verbose output. -nocomment: Remove all comments. Use this argument if you have comments mixing in the middle of a classic svc.conf directive. "; exit; } elsif ($ARGV[0] =~ m/^-/) { warn "$0: unknown option $ARGV[0]\n"; exit 1; } else { die "unknow argument\n"; } shift; } if ($infile eq "") { print "Using default svc.conf name\n" if ($verbose != 0); $infile = "svc.conf"; } if ($outfile eq "") { $outfile = "$infile.xml"; } print "OUTFILE = $outfile \n" if ($verbose); open (OUT, "> $outfile") or die "Unable to open $outfile\n"; undef $/; open (FH, "< $infile"); $_ = ; if ($nocomment) { if (s/^\#(.*)$//mg) { print "ts = $_\n" if ($verbose != 0); } } print "------------------------------------------------------------\n" if ($verbose != 0); print OUT "\n"; print OUT "\n"; acexml_start ("ACE_Svc_Conf", 0); while (length ($_) != 0) { s/^\s*$//mg; print "INPUT =\n$_\n" if ($verbose); PARSE: { if (s/^\s*\#(.*)//) { acexml_comment ($1); print "# $1\n" if ($verbose); } if (s/^\s*{//) { acexml_start ("module", 0); print "open module\n" if ($verbose); } if (s/^\s*}//) { acexml_end ("module"); acexml_end ($stream); print "close module\n" if ($verbose); } if (s/^\s*stream\s+dynamic\s+(\w+)\s+(\w+)\s*\*\s*(\S+):(\S+)\s*\(\s*\)(\s+(active|inactive))?(\s+"([^"]*)")?//) { $name = $1; $type = $2; $path = $3; $init = $4; $state = $6; $param = $8; acexml_start ("streamdef"); if ($status ne "") { push @attnames, ("status"); push @attvalues, ("$state"); } push @attnames, ("type"); push @attvalues, ("$type"); push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("dynamic", 0); if ($param ne "") { push @attnames, ("params"); push @attvalues, ("$param"); } push @attnames, ("init"); push @attvalues, ("$init"); push @attnames, ("path"); push @attvalues, ("$path"); acexml_start ("initializer", 1); acexml_end ("dynamic"); $stream = "streamdef"; print "stream dynamic $name $type * $init:$path \"$param\" $state\n" if ($verbose); } if (s/^\s*stream\s+static\s+(\w+)(\s+("(.*)"))?//) { $name = $1; $param = $4; acexml_start ("streamdef", 0); if ($param ne "") { push @attnames, ("params"); push @attvalues, ("$param"); } push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("static", 1); $stream = "streamdef"; print "static $name \"$param\"\n" if ($verbose); } if (s/^\s*stream\s+(\w+)//) { $name = $1; push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("stream", 0); $stream = "stream"; print "stream $name\n" if ($verbose); } if (s/^\s*dynamic\s+(\w+)\s+(\w+)\s*\*\s*(\S+):(\S+)\s*\(\s*\)(\s+(active|inactive))?(\s+"([^"]*)")?//) { $name = $1; $type = $2; $path = $3; $init = $4; $state = $6; $param = $8; if ($status ne "") { push @attnames, ("status"); push @attvalues, ("$state"); } push @attnames, ("type"); push @attvalues, ("$type"); push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("dynamic", 0); if ($param ne "") { push @attnames, ("params"); push @attvalues, ("$param"); } push @attnames, ("init"); push @attvalues, ("$init"); push @attnames, ("path"); push @attvalues, ("$path"); acexml_start ("initializer", 1); acexml_end ("dynamic"); print "dynamic $name $type * $init:$path \"$param\" $state\n" if ($verbose); } if (s/^\s*static\s+(\w+)(\s+("(.*)"))?//) { $name = $1; $param = $4; if ($param ne "") { push @attnames, ("params"); push @attvalues, ("$param"); } push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("static", 1); print "static $name \"$param\"\n" if ($verbose); } if ( s/^\s*resume\s+(\w+)//) { $name = $1; push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("resume", 1); print "resume $name\n" if ($verbose); } if ( s/^\s*remove\s+(\w+)//) { $name = $1; push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("remove", 1); print "remove $name\n" if ($verbose); } if ( s/^\s*suspend\s+(\w+)//) { $name = $1; push @attnames, ("id"); push @attvalues, ("$name"); acexml_start ("suspend", 1); print "suspend $name\n" if ($verbose); } $nothing = 1; } } acexml_end ("ACE_Svc_Conf"); ace-6.3.3+dfsg.orig/bin/split-cpp.pl0000755000175000017500000003075012576461726017445 0ustar pgquilespgquiles#! /usr/bin/perl eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' & eval 'exec perl -w -S $0 $argv:q' if 0; # # Splits C++ source files into one file per function or data item. # # Author: David L. Levine, with much help and encouragment from # Umar Syyid and Gonzalo A. Diethelm. # Completed by Andrew Gilpin, July 2000 # Date: 10 November 1998 # # For each C++ source file: # 1) Extracts the "intro" code, i.e., #includes and declarations. # 2) Identifies function definitions, relying on {, and } at the # beginning of a line, to delineate the function begin and # end. # # Assumptions: (applies only to the files being split, i.e. .cpp files) # * Function definition bodies are terminated with } appearing at # the beginning of a line. # * Free-standing (outside of functions) macro invocations must be # followed by a blank line, or terminated with a semicolon. # * A function must not have a blank line between its header # (signature) and its body. # * There aren't multiple C-style comments on one line, with code # between them. # * typedefs are on a single line # * A #endif doesn't have a multi-line C comment starting on that line. # The first three lines above let this script run without specifying the # full path to perl, as long as it is in the user's PATH. # Taken from perlrun man page. # Changes made by Andrew Gilpin (June - July 2000) # * Added option -c to use .c extension instead of .cpp extension # * Prints message when no filenames are specified on the command line # * Changed -? option to -h so that it works properly in most shells # * Added option -s to skip certain files, but copy them to $split_dir, # renaming them. (filename.cpp -> $split_dir/filename_S1.cpp). This is # here so that ACE can selectively not split certain files (namely those # that this script doesn't work with :) # * Added support for classes declared in the .cpp file. $usage="usage: $0 [-h] [-d] [-v] [-c] [-s filename] filenames\n"; #### Configuration parameters. $verbose = 0; $debug = 0; $split_dir = 'SPLIT'; $extension = 'cpp'; @files_to_skip = (); #### Constants. $DIR_SEPARATOR = $^O eq "MSWin32" ? '\\' : '/'; #### #### Process command line args. #### while ( $#ARGV >= $[ && $ARGV[0] =~ /^-/ ) { if ( $ARGV[0] eq '-d' ) { $debug = 1; } elsif ( $ARGV[0] eq '-v' ) { $verbose = 1; } elsif ( $ARGV[0] eq '-c' ) { $extension = 'c'; } elsif ( $ARGV[0] eq '-s' ) { push @files_to_skip, $ARGV[1]; shift; } elsif ( $ARGV[0] eq '-h' ) { print "$usage"; exit; } else { print STDERR "$0: unknown option $ARGV[0]\n"; die $usage; } shift; } &main (); #### #### Reset state, to process a new file starting with a clean slate. #### sub reset { #### Working data buffers. @intro = (); @current_comments = (); @current_code = (); @if = (); @save_if = (); @endif = (); @unknown = (); ####@unknown_s = (); #### State variables. $current_file_number = 0; $top_of_file = 1; $in_braces = 0; $in_nonfunction_code = 0; $in_C_comment = 0; $intro_length = 0; $preprocessor_continuation = 0; $preserved_ifs = 0; } sub main { #### Print error message if no files are specified. #### We need to do this before we modify anything on disk. die "No files specified!\n$usage" if (@ARGV == 0); #### Remove the destination subdirectory, if it exists. #### Attempts to clean it out using unlink may fail because #### it can have many files. if (-d "$split_dir") { system ("/bin/rm -r $split_dir") << 256 && die "$0: unable to rm \"$split_dir\"\n"; } #### Create the destination subdirectory. mkdir "$split_dir", 0755 || die "$0: unable to create $split_dir directory: $!\n"; MAIN_LOOP: foreach $file (@ARGV) { #### Strip off filename extension. ($basename = $file) =~ s/\.[^\.]+$//; foreach $skip_file (@files_to_skip) { if ($skip_file eq $file) { system ("/bin/cp $file $split_dir/" . $basename. "_S1\.$extension"); next MAIN_LOOP; } } &reset (); print "FILE: $file\n" if $verbose; open INPUT, "$file" || die "$0: unable to open \"$file\"\n"; while () { #### Strip comments from $line and use that for processing. #### But, use $_ for output, so that comments will be preserved. my $line = $_; #### If we're in the midst of a multiline C comment, see #### if it's finished on this line. if ($in_C_comment) { if ($line =~ s%^.*\*/%%) { #### End C-style comment. $in_C_comment = 0; if ($line =~ /^\s*$/ && ! $in_braces) { #### No code on the line. #&save_comment ($_); next; } } else { unless ($in_braces) { #&save_comment ($_); next; } } } #### Strip C++-style comments. if ($line =~ s%\s*//.*$%%) { if ($line =~ /^\s*$/ && ! $in_braces) { #### C++-style comment, without any code on the line. #&save_comment ($_); next; } } #### And C-style comments. if ($line =~ m%/\*%) { #### Begin C-style comment. Strip any complete comment(s), #### then see what's left. $line =~ s%\s*/\*.*\*/\s*%%g; #### check to see if a preprocessor is on this line if (! $in_braces) { if ($line eq '') { #### The line just had comment(s). Save it. #&save_comment ($_); next; } else { #### There's other text on the line. See if it's just the #### start of a comment. if ($line =~ m%/\*% && $line !~ m%\*/%) { #### The C-style comment isn't terminated on this line. $in_C_comment = 1; #&save_comment ($_); next; } } } } #### For now, skip ACE_RCSID's. Eventually, we might want to #### consider putting them in _every_ file, if they're enabled. next if $line =~ /^ACE_RCSID/; if ($in_braces) { push @unknown, $_; if ($line =~ /{/) { ++$in_braces; } elsif ($line =~ /^};/) { #### }; at beginning of line could signify end of class --$in_braces; if ($in_braces == 0) { push @intro, @unknown; @unknown = (); } } elsif ($line =~ /^}/) { #### } at beginning of line signifies end of function. --$in_braces; push @current_code, @unknown; @unknown = (); &finish_current ($basename, ++$current_file_number); } elsif ($line =~ /};/) { #### end of multi-line data delcaration --$in_braces; if ($in_braces == 0) { push @current_code, @unknown; @unknown = (); &finish_current ($basename, ++$current_file_number); } } } else { #### Not in braces. if (($line =~ m%[^/]*{%) && (! $preprocessor_continuation)) { #### { signifies beginning of braces (obviously :). if ($line =~ /};/) { #### braces end on this line push @unknown, $_; push @current_code, @unknown; @unknown = (); &finish_current ($basename, ++$current_file_number); } else { push @unknown, $_; $in_braces = 1; $in_nonfunction_code = $top_of_file = 0; } } elsif ($line =~ /^}/) { warn "$0: skipping unexpected } on line $. of \"$file\"\n"; next; } elsif ($line =~ /^typedef/) { push @intro, $_; } elsif ($line =~ /^\s*#/ || $preprocessor_continuation) { #### Preprocessor directive. if ($in_nonfunction_code) { push @unknown, $_; } else { push @intro, $_; } $top_of_file = 0; $preprocessor_continuation = /\\$/ ? 1 : 0; if ($line =~ m%^\s*#\s*if\s*(.*)(/.*)*$%) { push @save_if, $_; unshift @endif, "#endif /* $1 [Added by split-cpp.] */\n"; } elsif ($line =~ /^\s*#\s*endif/) { #### End an #if/#else block. unless (defined pop @save_if) { pop @if; if ($preserved_ifs > 0) { --$preserved_ifs; } } shift @endif; #### } elsif ($line =~ /^\s*#/) { #### Any other preprocessor directive. } } elsif ($line =~ /^\s*$/) { #### Whitespace only, or empty line.. push @current_code, "\n"; if ($in_nonfunction_code) { #### In the midst of non-function code, we reached a #### blank line. Assume that we're done with it. &finish_current ($basename, ++$current_file_number); } else { #### Not in a function, so add to intro. Just in case data or #### a function follow it, flush now. $preserved_ifs += $#save_if + 1; &flush_current (\@intro); } } elsif ($line =~ /;/) { #### Data definition or semicolon-terminated macro invocation. push @unknown, $_; $top_of_file = 0; #### Is it file-static? Squash newlines out of @current_code. my $statement = join (' ', @current_code); if ($statement =~ /([^=[(]+)[=[(](.*)/) { if ($1 =~ /static/) { #### Move code to the intro. push @intro, @current_comments; @current_comments = (); &flush_current (\@intro); #### Not separate code. $in_nonfunction_code = 0; #### ???? Extract name from the left side and save for #### later matching. } else { if ($statement =~ /^USEUNIT\s*\(/) { #### Special-case those Borland USEUNIT things. &flush_current (\@intro); } else { #### Non-static entity, with semicolon. Wrap it up. push @current_code, @unknown; @unknown = (); &finish_current ($basename, ++$current_file_number); } } } else { #### Dunno. Wrap it up, anyways. push @current_code, @unknown; @unknown = (); &finish_current ($basename, ++$current_file_number); } } else { #### Beginning of data definition or function or class. push @unknown, $_; $in_nonfunction_code = 1; $top_of_file = 0; } } if (eof) { close (ARGV); #### To reset line number counter. if ($#intro > $intro_length) { #### Leftover prepreprocessor statement(s), such as #pragma #### instantiate. &finish_current ($basename, ++$current_file_number); } } } close INPUT; } }; #### #### Save a comment in the appropriate array. #### #sub save_comment { # my ($comment) = @_; # # if ($top_of_file) { # push @intro, $comment; # } else { # push @current_comments, $comment; # } #} #### #### Flush the contents of the @current_code array to the destination #### argument array. It is passed by reference. #### sub flush_current { my ($destination) = @_; push @$destination, @current_code; @current_code = (); } #### #### Flush what we've got now to an output (split) file. #### sub finish_current { my ($basename, $current_file_number) = @_; my $current_file_name = sprintf "$split_dir$DIR_SEPARATOR${basename}_S%d.$extension", $current_file_number++; if ($verbose) { print "CURRENT OUTPUT FILE: $current_file_name\n"; print "INTRO:\n"; print @intro; print @if; print @current_comments; print "CURRENT CODE:\n"; print @current_code; print @endif; } open OUTPUT, "> $current_file_name" || die "unable to open $current_file_name\n"; print OUTPUT "// Automatically generated by ACE's split-cpp.\n" . "// DO NOT EDIT!\n\n"; if ($debug) { print OUTPUT "INTRO:\n", @intro, "IF:\n", @if, "COMMENTS:\n", @current_comments, "CURRENT:\n", @current_code, "ENDIF:\n", @endif; } else { print OUTPUT @intro, @if, @current_comments, @current_code, @endif; } close OUTPUT; #### For detection of leftover preprocessor statements and #### comments at end of file. $intro_length = $#intro; @current_comments = @current_code = @save_if = (); $in_braces = $in_nonfunction_code = 0; } ace-6.3.3+dfsg.orig/bin/valgrind.supp0000644000175000017500000001161712576461726017712 0ustar pgquilespgquiles { Memcheck:Leak fun:* obj:*cc1plus } { Memcheck:Leak fun:* obj:*g++* } { Memcheck:Leak ... obj:*/bin/perl } { Memcheck:Leak ... obj:*/bin/bash } { Memcheck:Leak ... obj:*/bin/grep } { Memcheck:Cond ... obj:*/bin/grep } { Memcheck:Leak ... obj:*/bin/ps } { Memcheck:Leak ... obj:*/bin/ls } # { # # Memcheck:Param # fun:* # fun:NDDS_Transport_UDPv4_send # fun:RTINetioSender_send # } { Memcheck:Addr8 fun:__memcpy_ssse3_back } { Memcheck:Addr8 fun:__strspn_sse42 } { Memcheck:Leak fun:* fun:*ACE_Log_Msg_Manager*get_lock* } { Memcheck:Leak ... fun:*ACE_Log_Msg*close* } { Memcheck:Leak fun:* fun:*ACE_Log_Msg_Manager*init_backend* } { Memcheck:Leak fun:calloc fun:_dlerror_run } { Memcheck:Leak fun:malloc fun:add_to_global fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:calloc fun:_dl_new_object fun:_dl_map_object_from_fd fun:_dl_map_object fun:openaux fun:_dl_catch_error fun:_dl_map_object_deps fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:malloc fun:_dl_map_object_deps fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:calloc fun:_dl_check_map_versions fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:malloc fun:_dl_new_object fun:_dl_map_object_from_fd fun:_dl_map_object fun:openaux fun:_dl_catch_error fun:_dl_map_object_deps fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:malloc fun:open_path fun:_dl_map_object fun:openaux fun:_dl_catch_error fun:_dl_map_object_deps fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:malloc fun:_dl_close_worker fun:_dl_close fun:_dl_catch_error fun:_dlerror_run fun:dlclose } { Memcheck:Leak fun:malloc ... fun:dl_open_worker fun:_dl_catch_error fun:_dl_open fun:dlopen_doit fun:_dl_catch_error fun:_dlerror_run } { Memcheck:Leak fun:malloc obj:/usr/lib64/libicuuc.so.42.0 } { Memcheck:Leak fun:calloc fun:_dl_new_object } { Memcheck:Leak fun:malloc fun:_dl_scope_free } { Memcheck:Leak fun:malloc fun:_dl_lookup_symbol_x } { Memcheck:Leak fun:malloc fun:_dl_new_object } { Memcheck:Leak fun:malloc fun:open_path fun:_dl_map_object } { Memcheck:Leak fun:malloc fun:realloc fun:_dl_new_object } { Memcheck:Leak fun:* fun:*_dl_scope_free* } { Memcheck:Leak fun:* fun:*_dl_new_object* } { Memcheck:Leak fun:* fun:*NDDSConfigLogger*get_instance* } { Memcheck:Leak fun:* fun:*register_or_unregister_typeI* } { Memcheck:Leak fun:malloc fun:dl_open_worker } { Memcheck:Addr8 fun:wcscmp } { Memcheck:Leak ... fun:PRESPsReaderQueue_initializeQueryConditionInventory } { Memcheck:Param writev(vector[...]) fun:writev fun:*ACE*sendv* fun:*TAO_IIOP_Transport*send* fun:*TAO_Transport*drain_queue_helper* fun:*TAO_Transport*drain_queue_i* fun:*TAO_Transport*send_synch_message_helper* ... fun:*TAO_IIOP_Transport*send_message* } { Memcheck:Value8 fun:*nibble2hex* fun:*ORB*object_to_string* } { Memcheck:Cond obj:/usr/lib/libz.so.1.2.3 obj:/usr/lib/libz.so.1.2.3 fun:deflate fun:compress2 } ace-6.3.3+dfsg.orig/bin/g++dep0000755000175000017500000001121212576461726016155 0ustar pgquilespgquiles#! /bin/sh # $Id$ # This utility is a lightly editted version of the freed Berkeley # script `mkdep'. The current script is intended to work for GNU G++. # Here is the original BSD header: # @(#)mkdep.sh 1.7 (Berkeley) 10/13/87 # if [ $# = 0 ] ; then echo 'usage: g++dep [-p] [-f makefile] [flags] file ...' exit 1 fi DO_ACE_MAKE_DEPEND=0 MAKE=GNUmakefile STOPNOW=0 REL="" while [ $STOPNOW -eq 0 ] do case $1 in # -e for compatibility with depgen.pl -e) shift; shift ;; # -f allows you to select a makefile name -f) MAKE=$2 shift; shift ;; # the -p flag produces "program: program.c" style dependencies # so .o's don't get produced -p) SED='s;\.o;;' shift ;; # -A implies -r and fixes the .obj line, hate -A) REL="ACE_ROOT TAO_ROOT "$REL DO_ACE_MAKE_DEPEND=1 shift ;; # -r allows the use of relative pathnames... -r) REL="ACE_ROOT TAO_ROOT "$REL shift ;; # -R VARNAME allows you to specify a variable which should be used # to generate relative paths if it's defined. You can use multiple # -R options, but be careful if one of the values is a proper # subset of a subsequent value, because I suspect that sed will # substitute for the first value properly, but not for the # second. You might be able to get around this by reordering and # having the more specific values lead the less specific values. -R) REL=$2" "$REL shift; shift;; *) STOPNOW=1 esac done if [ ! -w $MAKE ]; then echo "g++dep: no writeable file \"$MAKE\"" exit 1 fi TMP=/tmp/g++dep$$ SCRIPT=${TMP}_script trap 'rm -f $TMP $SCRIPT; exit 1' 1 2 3 13 15 cp $MAKE ${MAKE}.bak sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP cat << _EOF_ >> $TMP # DO NOT DELETE THIS LINE -- g++dep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. _EOF_ # Local files may appear as './foo' change that to 'foo' echo 's; \./; ;g' >$SCRIPT # If the -p flag is set we want to change 'foo.o' to simply 'foo' echo $SED >>$SCRIPT # Dependencies on local files are better expressed like that, instead # of using $(TAO_ROOT) or $(ACE_ROOT). This is specially important # for IDL generated files. echo "s;`pwd`/;;g" >>$SCRIPT if [ -z "$TAO_ROOT" ]; then TAO_ROOT=${ACE_ROOT}/TAO fi # This is a long series of commands to change the actual value of # $ACE_ROOT to '$(ACE_ROOT)', similar changes are done for TAO_ROOT # and any number of "variables" defined via the -R option. for varname in $REL; do varvalue=$(eval echo \$${varname}) echo "s;"$varvalue";$""("$varname");g" >>$SCRIPT done if [ $DO_ACE_MAKE_DEPEND -eq 1 ]; then # Append a series of commands to the sed script that help with the # ACE build style (.obj subdirectories, plaform indenpendent # dependencies, etc.) # To avoid interpolation we build this string in pieces, the idea is # to generate a rule that will convert # foo.o: # into # .obj/foo.o .shobj/foo.o .obj/foo.so .shobj/foo.so: # # will be foo.o foo. LONG_TARGET="$""(sort " for i in VDIR VSHDIR; do for j in OBJEXT SOEXT; do LONG_TARGET=${LONG_TARGET}"$""("${i}")\1.$""("${j}") " done done LONG_TARGET=${LONG_TARGET}")" cat >>$SCRIPT <>$TMP /bin/rm -f $SCRIPT cat << _EOF_ >> $TMP # IF YOU PUT ANYTHING HERE IT WILL GO AWAY _EOF_ # copy to preserve permissions cp $TMP $MAKE rm -f ${MAKE}.bak $TMP exit 0 ace-6.3.3+dfsg.orig/bin/msvc_static_order.lst0000644000175000017500000004542312576461726021433 0ustar pgquilespgquiles# $Id$ # # This file lists the project files that must be build first in a static # build using msvc_static_compile.pl ace/ace ace/ACE_ETCL ace/ACE_ETCL_Parser ace/MonitorControl/MonitorControl Kokyu/Kokyu ACEXML/parser/parser/ACEXML_Parser ACEXML/common/ACEXML apps/gperf/src/gperf TAO/TAO_IDL/TAO_IDL_BE TAO/TAO_IDL/TAO_IDL_FE TAO/TAO_IDL/TAO_IDL_EXE TAO/tao/TAO TAO/tao/AnyTypeCode TAO/tao/CodecFactory TAO/tao/Codeset TAO/tao/PI TAO/tao/PortableServer TAO/tao/PI_Server TAO/tao/Valuetype TAO/tao/ObjRefTemplate TAO/tao/IORInterceptor TAO/tao/DynamicAny TAO/tao/IORManipulation TAO/tao/IORTable TAO/tao/Messaging TAO/tao/DynamicInterface TAO/tao/Strategies TAO/tao/RTCORBA TAO/tao/RTPortableServer TAO/tao/Utils TAO/tao/TAO_Utils TAO/tao/RTScheduler TAO/tao/IFR_Client TAO/tao/TypeCodeFactory TAO/tao/ImR_Client TAO/tao/CSD_Framework TAO/tao/CSD_ThreadPool TAO/tao/TC TAO/tao/DiffServPolicy TAO/tao/Monitor TAO/orbsvcs/orbsvcs/Svc_Utils TAO/orbsvcs/orbsvcs/CosNaming_IDL TAO/orbsvcs/orbsvcs/CosNaming TAO/orbsvcs/orbsvcs/CosNaming_Skel TAO/orbsvcs/orbsvcs/CosNaming_Serv TAO/orbsvcs/orbsvcs/CosProperty_IDL TAO/orbsvcs/orbsvcs/CosProperty TAO/orbsvcs/orbsvcs/CosProperty_Skel TAO/orbsvcs/orbsvcs/CosProperty_Serv TAO/orbsvcs/orbsvcs/CosTrading_IDL TAO/orbsvcs/orbsvcs/CosTrading TAO/orbsvcs/orbsvcs/CosTrading_Skel TAO/orbsvcs/orbsvcs/CosTrading_Serv TAO/orbsvcs/orbsvcs/HTIOP TAO/orbsvcs/orbsvcs/AV TAO/orbsvcs/orbsvcs/ETCL TAO/orbsvcs/orbsvcs/RTCosScheduling TAO/orbsvcs/orbsvcs/RTEvent TAO/orbsvcs/orbsvcs/RTEvent_Skel TAO/orbsvcs/orbsvcs/RTEvent_Serv TAO/orbsvcs/orbsvcs/RTSched TAO/orbsvcs/orbsvcs/RTSchedEvent TAO/orbsvcs/orbsvcs/CosEvent_IDL TAO/orbsvcs/orbsvcs/CosEvent TAO/orbsvcs/orbsvcs/CosEvent_Skel TAO/orbsvcs/orbsvcs/CosEvent_Serv TAO/orbsvcs/orbsvcs/RTKokyuEvent TAO/orbsvcs/orbsvcs/CosConcurrency_IDL TAO/orbsvcs/orbsvcs/CosConcurrency TAO/orbsvcs/orbsvcs/CosConcurrency_Skel TAO/orbsvcs/orbsvcs/CosConcurrency_Serv TAO/orbsvcs/orbsvcs/CosLifeCycle TAO/orbsvcs/orbsvcs/CosTime TAO/orbsvcs/orbsvcs/CosNotification_IDL TAO/orbsvcs/orbsvcs/CosNotification TAO/orbsvcs/orbsvcs/CosNotification_Skel TAO/orbsvcs/orbsvcs/CosNotification_Serv TAO/orbsvcs/orbsvcs/CosNotification_Persist TAO/orbsvcs/orbsvcs/DsLogAdmin_IDL TAO/orbsvcs/orbsvcs/DsLogAdmin TAO/orbsvcs/orbsvcs/DsLogAdmin_Skel TAO/orbsvcs/orbsvcs/DsLogAdmin_Serv TAO/orbsvcs/orbsvcs/DsEventLogAdmin_IDL TAO/orbsvcs/orbsvcs/DsEventLogAdmin TAO/orbsvcs/orbsvcs/DsEventLogAdmin_Skel TAO/orbsvcs/orbsvcs/DsEventLogAdmin_Serv TAO/orbsvcs/orbsvcs/DsNotifyLogAdmin_IDL TAO/orbsvcs/orbsvcs/DsNotifyLogAdmin TAO/orbsvcs/orbsvcs/DsNotifyLogAdmin_Skel TAO/orbsvcs/orbsvcs/DsNotifyLogAdmin_Serv TAO/orbsvcs/orbsvcs/PortableGroup TAO/orbsvcs/orbsvcs/FTORB_Utils TAO/orbsvcs/orbsvcs/FT_ClientORB TAO/orbsvcs/orbsvcs/FT_ServerORB TAO/orbsvcs/orbsvcs/FtRtEvent TAO/orbsvcs/orbsvcs/FaultTolerance TAO/orbsvcs/orbsvcs/CosLoadBalancing TAO/orbsvcs/orbsvcs/IFRService TAO/orbsvcs/orbsvcs/RTCORBAEvent TAO/orbsvcs/orbsvcs/RT_Notification TAO/orbsvcs/orbsvcs/RTEventLogAdmin_IDL TAO/orbsvcs/orbsvcs/RTEventLogAdmin TAO/orbsvcs/orbsvcs/RTEventLogAdmin_Skel TAO/orbsvcs/orbsvcs/RTEventLogAdmin_Serv TAO/orbsvcs/orbsvcs/Security TAO/orbsvcs/Naming_Service/Naming_Service TAO/orbsvcs/ImplRepo_Service/ImR_Activator_IDL TAO/orbsvcs/ImplRepo_Service/ImR_Locator_IDL TAO/orbsvcs/ImplRepo_Service/ImR_Activator TAO/orbsvcs/ImplRepo_Service/ImR_Activator_Service TAO/orbsvcs/ImplRepo_Service/ImR_Locator TAO/orbsvcs/ImplRepo_Service/ImR_Locator_Service TAO/orbsvcs/ImplRepo_Service/tao_imr TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager_Lib TAO/orbsvcs/orbsvcs/FTRT_ClientORB TAO/orbsvcs/tests/Concurrency/CC_client TAO/orbsvcs/tests/Event/lib/Event_Test_Lib TAO/orbsvcs/tests/Event/Mcast/Common/ECMcastTests_lib TAO/orbsvcs/tests/Trading/Trading_Test_Lib TAO/orbsvcs/examples/CosEC/RtEC_Based/lib/CosEC_RtEC_Based_lib TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Perf TAO/tests/CSD_Strategy_Tests/TP_Common/CSD_TP_Test_Lib TAO/tests/Smart_Proxies/Collocation/SP_Collocation_Idl TAO/tests/Smart_Proxies/Collocation/SP_Collocation_TestStubsLib TAO/tests/Collocation/Collocation_Idl TAO/tests/Collocation/Collocation_Test_Stub TAO/tests/Collocation/Collocation_Diamond TAO/tests/ORB_Local_Config/Two_DLL_ORB/Two_DLL_ORB_Idl TAO/tests/TransportCurrent/lib/Current_Test_Lib_Idl TAO/tests/TransportCurrent/lib/Current_Test_Lib_Client TAO/tests/TransportCurrent/lib/Current_Test_Lib_Server TAO/examples/POA/Generic_Servant/POA_Generic_Servant_Lib TAO/examples/Simple/time-date/Simple_Time_Date_Lib TAO/docs/tutorials/Quoter/idl/Quoter_Idl_Lib TAO/performance-tests/RTCorba/Multiple_Endpoints/Common/RTCORBA_Common TAO/examples/RTScheduling/Job TAO/examples/RTScheduling/RTSchedSynch TAO/examples/RTScheduling/RTSchedTestLib tests/Test_Output tests/DLL_Test_Parent TAO/tests/CSD_Strategy_Tests/TP_Common/CSD_TP_Test_Lib performance-tests/Synch-Benchmarks/Synch_Lib/Synch_Lib examples/Service_Configurator/Misc/Service_Configurator_Misc_Timer examples/Timer_Queue/Timer_Queue_Library ASNMP/asnmp/asnmp_lib netsvcs/lib/netsvcs netsvcs/clients/Naming/Client/Netsvsc_Client_Test_Lib netsvcs/clients/Naming/Dump_Restore/Netsvcs_Dump_Restore_Lib websvcs/lib/websvcs protocols/ace/HTBP/HTBP protocols/ace/RMCast/RMCast protocols/ace/TMCast/TMCast TAO/CIAO/CCF/CCF/CIDL/CIDL TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements TAO/CIAO/CCF/CCF/IDL2/IDL2 TAO/CIAO/CCF/CCF/IDL3/IDL3 TAO/CIAO/CIDLC/CIDLC TAO/CIAO/ciao/CIAO_Client TAO/CIAO/ciao/CIAO_Container TAO/CIAO/ciaosvcs/Events/CIAO_Events_Base/CIAO_Events_Base TAO/DAnCE/Deployment/Deployment_stub TAO/CIAO/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent TAO/CIAO/ciaosvcs/Events/CIAO_Events TAO/DAnCE/Deployment/Deployment_svnt TAO/DAnCE/Interfaces/ExecutionManager_stub TAO/DAnCE/DomainApplicationManager/DomainApplicationManager TAO/CIAO/ciao/CIAO_Server TAO/DAnCE/ExecutionManager/ExecutionManager TAO/DAnCE/Interfaces/NodeManager_stub TAO/DAnCE/NodeApplication/Config_Manager TAO/DAnCE/NodeApplication/NodeApp_Configurator TAO/DAnCE/NodeApplication/NA_Configurator TAO/DAnCE/NodeApplication/NoOp_Configurator TAO/DAnCE/NodeApplication/NodeApplicationLib TAO/DAnCE/NodeApplication/NodeApplication TAO/DAnCE/NodeApplication/RTNA_Configurator TAO/DAnCE/TargetManager/CIAO_TargetManager_stub TAO/DAnCE/NodeApplicationManager/NodeApplicationManager TAO/DAnCE/NodeManager/Monitor_Monitorlib TAO/DAnCE/NodeManager/NodeManager_svnt TAO/DAnCE/NodeManager/NodeManager TAO/CIAO/tools/Config_Handlers/XSC_XML_Generation TAO/CIAO/tools/Config_Handlers/XSC_XML_Handlers TAO/CIAO/tools/Config_Handlers/Utils/CIAO_XML_Utils TAO/CIAO/tools/Config_Handlers/XSC_DynAny_Handler TAO/CIAO/tools/Config_Handlers/XSC_Config_Handlers_Common TAO/CIAO/tools/Config_Handlers/CIAO_Events/CIAO_Events_XML_Generation TAO/CIAO/tools/Config_Handlers/CIAO_Events/CIAO_Events_Handlers TAO/CIAO/tools/Config_Handlers/RT-CCM/RT_CCM_XML_Generation TAO/CIAO/tools/Config_Handlers/RT-CCM/RT_CCM_Config_Handlers TAO/CIAO/tools/Config_Handlers/XSC_Config_Handlers TAO/CIAO/tools/Config_Handlers/Package_Handlers/Package_Config_Handlers TAO/DAnCE/RepositoryManager/RepositoryManager TAO/DAnCE/Plan_Generator/Plan_Generator TAO/DAnCE/Utils/DAnCE_Utils TAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl TAO/DAnCE/Plan_Launcher/Plan_Launcher TAO/DAnCE/RepositoryManager/RMAdmin TAO/DAnCE/StaticConfigurator/StaticDAnCEParser TAO/DAnCE/TargetManager/CIAO_TargetManager_svnt TAO/DAnCE/TargetManager/CIAO_TargetManager_exec TAO/DAnCE/TargetManager/TMClient TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_RoundTrip_stub TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_RoundTrip_svnt TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_RoundTrip_exec TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_client TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_client_dynamic TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_client_ex TAO/DAnCE/tests/NodeApplicationTest/NodeAppTest_client_simple TAO/bin/PerlCIAO/PerlCIAO TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_idl_gen TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_stub TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_skel TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBroker_idl_gen TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBroker_cidl_gen TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBroker_stub TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBroker_exec TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBroker_svnt TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockBrokerDriver TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributor_idl_gen TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributor_cidl_gen TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributor_stub TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributor_exec TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributor_svnt TAO/CIAO/docs/tutorials/Quoter/Simple/Stock_Base/Stock_Base_StockDistributorDriver TAO/CIAO/examples/BasicSP/BasicSP_lem_gen TAO/CIAO/examples/BasicSP/BasicSP_stub_gen TAO/CIAO/examples/BasicSP/BasicSP_stub TAO/CIAO/examples/BasicSP/BasicSP_exec TAO/CIAO/examples/BasicSP/BMClosedED/BMClosedED_lem_gen TAO/CIAO/examples/BasicSP/BMClosedED/BMClosedED_stub_gen TAO/CIAO/examples/BasicSP/BMClosedED/BMClosedED_stub TAO/CIAO/examples/BasicSP/BMClosedED/BMClosedED_exec TAO/CIAO/examples/BasicSP/BasicSP_svnt TAO/CIAO/examples/BasicSP/BMClosedED/BMClosedED_svnt TAO/CIAO/examples/BasicSP/BMDevice/BMDevice_lem_gen TAO/CIAO/examples/BasicSP/BMDevice/BMDevice_stub_gen TAO/CIAO/examples/BasicSP/BMDevice/BMDevice_stub TAO/CIAO/examples/BasicSP/BMDevice/BMDevice_exec TAO/CIAO/examples/BasicSP/BMDevice/BMDevice_svnt TAO/CIAO/examples/BasicSP/BMDisplay/BMDisplay_lem_gen TAO/CIAO/examples/BasicSP/BMDisplay/BMDisplay_stub_gen TAO/CIAO/examples/BasicSP/BMDisplay/BMDisplay_stub TAO/CIAO/examples/BasicSP/BMDisplay/BMDisplay_exec TAO/CIAO/examples/BasicSP/BMDisplay/BMDisplay_svnt TAO/CIAO/examples/BasicSP/EC/EC_stub_gen TAO/CIAO/examples/BasicSP/EC/EC_stub TAO/CIAO/examples/BasicSP/EC/EC_client TAO/CIAO/examples/BasicSP/EC/EC_controller TAO/CIAO/examples/BasicSP/EC/EC_lem_gen TAO/CIAO/examples/BasicSP/EC/EC_exec TAO/CIAO/examples/BasicSP/EC/EC_svnt TAO/CIAO/examples/Display/Display_Base/Display_Base_idl_gen TAO/CIAO/examples/Display/Display_Base/Display_Base_stub TAO/CIAO/examples/Display/Display_Base/Display_Base_skel TAO/CIAO/examples/Display/GPS/Display_GPS_idl_gen TAO/CIAO/examples/Display/GPS/Display_GPS_cidl_gen TAO/CIAO/examples/Display/GPS/Display_GPS_stub TAO/CIAO/examples/Display/GPS/Display_GPS_exec TAO/CIAO/examples/Display/GPS/Display_GPS_svnt TAO/CIAO/examples/Display/NavDisplay/Display_NavDisplay_idl_gen TAO/CIAO/examples/Display/NavDisplay/Display_NavDisplay_cidl_gen TAO/CIAO/examples/Display/NavDisplay/Display_NavDisplay_stub TAO/CIAO/examples/Display/NavDisplay/Display_NavDisplay_exec TAO/CIAO/examples/Display/NavDisplay/Display_NavDisplay_svnt TAO/CIAO/examples/Display/NavDisplayGUI_exec/Display_NavDisplayGUI_exec TAO/CIAO/examples/Display/NavDisplayGUI_exec/Display_NavDisplayGUI_svnt TAO/CIAO/examples/Display/RateGen/Display_RateGen_idl_gen TAO/CIAO/examples/Display/RateGen/Display_RateGen_cidl_gen TAO/CIAO/examples/Display/RateGen/Display_RateGen_stub TAO/CIAO/examples/Display/RateGen/Display_RateGen_exec TAO/CIAO/examples/Display/RateGen/Display_RateGen_svnt TAO/CIAO/examples/Display/RateGen/Display_controller TAO/CIAO/examples/Hello/Hello_Base/Hello_Base_idl_gen TAO/CIAO/examples/Hello/Hello_Base/Hello_Base_stub TAO/CIAO/examples/Hello/Hello_Base/Hello_Base_skel TAO/CIAO/examples/Hello/Receiver/Hello_Receiver_idl_gen TAO/CIAO/examples/Hello/Receiver/Hello_Receiver_cidl_gen TAO/CIAO/examples/Hello/Receiver/Hello_Receiver_stub TAO/CIAO/examples/Hello/Receiver/Hello_Receiver_exec TAO/CIAO/examples/Hello/Receiver/Hello_Receiver_svnt TAO/CIAO/examples/Hello/Sender/Hello_Sender_idl_gen TAO/CIAO/examples/Hello/Sender/Hello_Sender_cidl_gen TAO/CIAO/examples/Hello/Sender/Hello_Sender_stub TAO/CIAO/examples/Hello/Sender/Hello_Sender_exec TAO/CIAO/examples/Hello/Sender/Hello_Sender_svnt TAO/CIAO/examples/Hello/Sender/Hello_starter TAO/CIAO/examples/Null_Component/Null_Interface_idl_gen TAO/CIAO/examples/Null_Component/Null_Interface_stub TAO/CIAO/examples/Null_Component/Null_Interface_skel TAO/CIAO/examples/Null_Component/Null_Component_idl_gen TAO/CIAO/examples/Null_Component/Null_Component_cidl_gen TAO/CIAO/examples/Null_Component/Null_Component_stub TAO/CIAO/examples/Null_Component/Null_Component_exec TAO/CIAO/examples/Null_Component/Null_Component_svnt TAO/CIAO/examples/Null_Component/Null_Component_StaticDAnCEApp TAO/CIAO/examples/Swapping/Hello_Base/Swapping_Hello_Base_idl_gen TAO/CIAO/examples/Swapping/Hello_Base/Swapping_Hello_Base_stub TAO/CIAO/examples/Swapping/Hello_Base/Swapping_Hello_Base_skel TAO/CIAO/examples/Swapping/Receiver/Swapping_Hello_Receiver_idl_gen TAO/CIAO/examples/Swapping/Receiver/Swapping_Hello_Receiver_cidl_gen TAO/CIAO/examples/Swapping/Receiver/Swapping_Hello_Receiver_stub TAO/CIAO/examples/Swapping/Receiver/Swapping_Hello_Receiver_exec TAO/CIAO/examples/Swapping/Receiver/Swapping_Hello_Receiver_svnt TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_idl_gen TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_cidl_gen TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_stub TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_exec TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_exec_1 TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_exec_2 TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Sender_svnt TAO/CIAO/examples/Swapping/Sender/Swapping_Hello_Starter TAO/CIAO/performance-tests/Benchmark/Benchmark_idl_gen TAO/CIAO/performance-tests/Benchmark/Benchmark_stub TAO/CIAO/performance-tests/Benchmark/Benchmark_skel TAO/CIAO/performance-tests/Benchmark/Benchmark_server TAO/CIAO/performance-tests/Benchmark/RoundTripClient/Benchmark_RoundTripClient_idl_gen TAO/CIAO/performance-tests/Benchmark/RoundTripClient/Benchmark_RoundTripClient_cidl_gen TAO/CIAO/performance-tests/Benchmark/RoundTripClient/Benchmark_RoundTripClient_stub TAO/CIAO/performance-tests/Benchmark/RoundTripClient/Benchmark_RoundTripClient_exec TAO/CIAO/performance-tests/Benchmark/RoundTripClient/Benchmark_RoundTripClient_svnt TAO/CIAO/performance-tests/Benchmark/RoundTripClient/RoundTripClient_client TAO/CIAO/performance-tests/Benchmark/Multi_Threaded/Multi_Threaded_client TAO/CIAO/performance-tests/Benchmark/RoundTrip/Benchmark_RoundTrip_idl_gen TAO/CIAO/performance-tests/Benchmark/RoundTrip/Benchmark_RoundTrip_cidl_gen TAO/CIAO/performance-tests/Benchmark/RoundTrip/Benchmark_RoundTrip_stub TAO/CIAO/performance-tests/Benchmark/RoundTrip/Benchmark_RoundTrip_exec TAO/CIAO/performance-tests/Benchmark/RoundTrip/Benchmark_RoundTrip_svnt TAO/CIAO/performance-tests/Benchmark/RoundTrip/RoundTrip_client TAO/CIAO/performance-tests/Benchmark/RoundTripServer/RoundTrip_server TAO/CIAO/performance-tests/Protocols/common/Protocols_idl_gen TAO/CIAO/performance-tests/Protocols/common/Protocols_stub TAO/CIAO/performance-tests/Protocols/common/Protocols_skel TAO/CIAO/performance-tests/Protocols/Receiver/Protocols_Receiver_idl_gen TAO/CIAO/performance-tests/Protocols/Receiver/Protocols_Receiver_cidl_gen TAO/CIAO/performance-tests/Protocols/Receiver/Protocols_Receiver_stub TAO/CIAO/performance-tests/Protocols/Receiver/Protocols_Receiver_exec TAO/CIAO/performance-tests/Protocols/Receiver/Protocols_Receiver_svnt TAO/CIAO/performance-tests/Protocols/Sender/Protocols_Sender_idl_gen TAO/CIAO/performance-tests/Protocols/Sender/Protocols_Sender_cidl_gen TAO/CIAO/performance-tests/Protocols/Sender/Protocols_Sender_stub TAO/CIAO/performance-tests/Protocols/Sender/Protocols_Sender_exec TAO/CIAO/performance-tests/Protocols/Sender/Protocols_Sender_svnt TAO/CIAO/performance-tests/Protocols/Controller/Protocols_Controller TAO/CIAO/tests/Bug_2130_Regression/interfaces/ENW_stub TAO/CIAO/tests/Bug_2130_Regression/SEC_CheckPoint/TSEC_CheckPoint_stub TAO/CIAO/tests/Bug_2130_Regression/SEC_CheckPoint/TSEC_CheckPoint_controller TAO/CIAO/tests/Bug_2130_Regression/interfaces/ENW_skel TAO/CIAO/tests/Bug_2130_Regression/SEC_CheckPoint/TSEC_CheckPoint_svnt TAO/CIAO/tests/Bug_2130_Regression/SEC_CheckPoint/TSEC_CheckPoint_exec TAO/CIAO/tests/CIDL/CodeGen/Basic_idl_gen TAO/CIAO/tests/CIDL/CodeGen/Basic_stub TAO/CIAO/tests/CIDL/CodeGen/Basic_skel TAO/CIAO/tests/CIDL/CodeGen/Basic_CodeGen_idl_gen TAO/CIAO/tests/CIDL/CodeGen/Basic_CodeGen_cidl_gen TAO/CIAO/tests/CIDL/CodeGen/Basic_CodeGen_stub TAO/CIAO/tests/CIDL/CodeGen/Basic_CodeGen_exec TAO/CIAO/tests/CIDL/CodeGen/Basic_CodeGen_svnt TAO/CIAO/tests/IDL3/Components/ComplexComponent/Attributes/Attributes_stub TAO/CIAO/tests/IDL3/Components/ComplexComponent/EventSink/EventSink_stub TAO/CIAO/tests/IDL3/Components/ComplexComponent/EventSource/EventSource_stub TAO/CIAO/tests/IDL3/Components/ComplexComponent/Facets/Facets_stub TAO/CIAO/tests/IDL3/Components/ComplexComponent/Receptacles/Receptacles_stub TAO/CIAO/tests/IDL3/Components/SimpleComponent/SimpleComponent_stub TAO/CIAO/tests/IDL3/Events/Abstract/Abstract_stub TAO/CIAO/tests/IDL3/Events/Any/EventAny_local TAO/CIAO/tests/IDL3/Events/Regular/Regular_stub TAO/CIAO/tests/IDL3/Homes/Attributes/HomeAttributes_stub TAO/CIAO/tests/IDL3/Homes/Basic/IDL3_Basic_stub TAO/CIAO/tests/IDL3/Homes/Factory/Factory_stub TAO/CIAO/tests/IDL3/Homes/Finder/Finder_stub TAO/CIAO/tests/IDL3/Homes/Inheritance/Inheritance_stub TAO/CIAO/tools/IDL3_to_IDL2/TAO_IDL3_TO_IDL2_BE TAO/CIAO/tools/IDL3_to_IDL2/TAO_IDL3_TO_IDL2_EXE TAO/CIAO/tests/IDL3/ImpliedIDL/All/ConvertIDL3 TAO/CIAO/tests/IDL3/ImpliedIDL/Components/Basic/ICBasic_stub TAO/CIAO/tests/IDL3/ImpliedIDL/Components/EventSink/ICEventSink_stub TAO/CIAO/tests/IDL3/ImpliedIDL/Components/EventSource/ICEventSource_stub TAO/CIAO/tests/IDL3/ImpliedIDL/Components/Receptacles/ICReceptacles_stub TAO/CIAO/tests/IDL3/ImpliedIDL/Events/Events_stub TAO/CIAO/tests/IDL3/ImpliedIDL/Homes/Homes_stub TAO/CIAO/tests/IDL3/Lookup/LookupTest_stub TAO/CIAO/tests/Minimum/Minimum_Base/Minimum_Base_idl_gen TAO/CIAO/tests/Minimum/Minimum_Base/Minimum_Base_stub TAO/CIAO/tests/Minimum/Minimum_Base/Minimum_Base_skel TAO/CIAO/tests/Minimum/Receiver/Minimum_Base_Receiver_idl_gen TAO/CIAO/tests/Minimum/Receiver/Minimum_Base_Receiver_cidl_gen TAO/CIAO/tests/Minimum/Receiver/Minimum_Base_Receiver_stub TAO/CIAO/tests/Minimum/Receiver/Minimum_Base_Receiver_exec TAO/CIAO/tests/Minimum/Receiver/Minimum_Base_Receiver_svnt TAO/CIAO/tests/Minimum/Sender/Minimum_Base_Sender_idl_gen TAO/CIAO/tests/Minimum/Sender/Minimum_Base_Sender_cidl_gen TAO/CIAO/tests/Minimum/Sender/Minimum_Base_Sender_stub TAO/CIAO/tests/Minimum/Sender/Minimum_Base_Sender_exec TAO/CIAO/tests/Minimum/Sender/Minimum_Base_Sender_svnt TAO/CIAO/tools/Config_Handlers/CIAO_Events/CIAO_Events_Handlers_Tests TAO/CIAO/tools/Config_Handlers/XSC_Config_Handlers_Tests TAO/CIAO/tools/Config_Handlers/Package_Handlers/Package_Config_Handlers_Tests ace-6.3.3+dfsg.orig/bin/ace_components0000755000175000017500000000453412576461726020116 0ustar pgquilespgquiles#! /bin/sh # $Id$ # # Encapsulates set/access of a components file, which records set of # components that were built in a library. Intended to be used by # GNUmakefiles and scripts. See ACE_wrappers/ace/GNUmakefile for an # example. # usage="usage: $0 --ace | --orbsvcs | --tao \ [--remove | --set \" \"]" #### #### Make sure that ACE_ROOT, and TAO_ROOT are set. #### if [ ! "$ACE_ROOT" ]; then echo $0': your ACE_ROOT environment variable is not set!' 1>&2 exit -1 fi if [ ! "$TAO_ROOT" ]; then TAO_ROOT=$ACE_ROOT/TAO export TAO_ROOT fi #### #### Process command line arguments. #### if [ $# -ge 1 ]; then case $1 in --ace) components_file=$ACE_ROOT/ace/ACE_COMPONENTS.list ;; --orbsvcs) components_file=$TAO_ROOT/orbsvcs/orbsvcs/ORBSVCS_COMPONENTS.list ;; --tao) components_file=$TAO_ROOT/tao/TAO_COMPONENTS.list ;; *) echo $usage; exit -1 ;; esac shift else echo $usage exit -1 fi set_components=0 append_components=0 if [ $# -ge 1 ]; then if [ $1 = '--set' ]; then set_components=1 shift if [ $# -eq 1 ]; then components=$1 shift else echo $usage exit -1 fi elif [ $1 = '--append' ]; then append_components=1 shift if [ $# -eq 1 ]; then components=$1 shift else echo $usage exit -1 fi elif [ $1 = '--remove' ]; then rm -f $components_file else echo $usage exit -1 fi fi if [ $set_components -eq 1 ]; then #### #### Update the components file, if it has changed since last set. #### if [ -f $components_file ]; then if echo "$components" | diff - $components_file > /dev/null; then : else echo "$components" > $components_file fi else echo "$components" > $components_file fi elif [ $append_components -eq 1 ]; then #### #### Update the components file, if it has changed since last set. #### if [ -f $components_file ]; then if cat $components_file | grep "$components" > /dev/null; then : else (cat $components_file; echo "$components") | tr ' ' '\012' | sort -u > $components_file.$$ mv -f $components_file.$$ $components_file fi else echo "$components" > $components_file fi else #### #### Access the contents of the components file, if it exists. #### if [ -f $components_file ]; then cat $components_file fi fi ace-6.3.3+dfsg.orig/bin/make-components0000755000175000017500000000056012576461726020214 0ustar pgquilespgquiles#! /bin/sh # $Id$ # Allow each ACE component to be built in a simple way, as follows: # # $ACE_ROOT/bin/make-components "your flags" # # to build libACE.$(SOEXT), libACE_OS.$(SOEXT), etc. flags="$*" cd $ACE_ROOT/ace make $flags for component in `cat $ACE_ROOT/ace/ACE_COMPONENTS.list` do make $flags LIBACE=libACE_$component ACE_COMPONENTS=$component done exit 0 ace-6.3.3+dfsg.orig/bin/mpc-mode.el0000644000175000017500000001601312576461726017211 0ustar pgquilespgquiles;;; mpc-mode.el --- Makefile Project Creator mode for Emacs ;; Author: Jules Colding ;; Maintainer: Jules Colding ;; Keywords: languages, faces, mpc ;; Copyright (C) 2008 Jules Colding ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;; A major mode for editing MPC input. Please see: ;; ;; http://downloads.ociweb.com/MPC/MakeProjectCreator.pdf ;; ;; Derived from autoconf-mode.el by Martin Buchholz (martin@xemacs.org) ;; Many thanks to the follwing kind people for extensions, bugfixes and ;; other contributions: ;; ;; * William R. Otte ;; Indentation and syntax table. ;; ;; Put this file somewhere in your emacs load path and add the following ;; to your Emacs configuration file: ;; ;; (require 'mpc-mode) ;; ;; ;; You may also add something like this to the top of your MPC files ;; to force a specific indentation mode: ;; ;; // -*- Mode: MPC; tab-width: 2; indent-tabs-mode: t; -*- ;;; Code: (require 'font-lock) (defvar mpc-mode-hook nil) (defvar mpc-mode-map (let ((mpc-mode-map (make-sparse-keymap))) (define-key mpc-mode-map '[(control c) (control c)] 'comment-region) (define-key mpc-mode-map '[(control j)] 'newline-and-indent) mpc-mode-map) "Keymap for MPC major mode") (defvar mpc-font-lock-keywords `( ("\\(project\\)" 1 font-lock-warning-face t) ("\\(workspace\\)" 1 font-lock-warning-face t) ("(\\([^()]*\\))" 1 font-lock-constant-face t) ("\\(IDL_Files\\)" 1 font-lock-keyword-face t) ("\\(Source_Files\\)" 1 font-lock-keyword-face t) ("\\(Header_Files\\)" 1 font-lock-keyword-face t) ("\\(Inline_Files\\)" 1 font-lock-keyword-face t) ("\\(Template_Files\\)" 1 font-lock-keyword-face t) ("\\(Resource_Files\\)" 1 font-lock-keyword-face t) ("\\(Pkgconfig_Files\\)" 1 font-lock-keyword-face t) ("\\(exclude\\)" 1 font-lock-type-face t) ("\\(custom_only\\)" 1 font-lock-type-face t) ("\\(cmdline\\)" 1 font-lock-type-face t) ("\\(avoids\\)" 1 font-lock-type-face t) ("\\(exename\\)" 1 font-lock-type-face t) ("\\(install =\\)" 1 font-lock-type-face t) ("\\(install +=\\)" 1 font-lock-type-face t) ("\\(install -=\\)" 1 font-lock-type-face t) ("\\(libs\\)" 1 font-lock-type-face t) ("\\(lit_libs\\)" 1 font-lock-type-face t) ("\\(linkflags\\)" 1 font-lock-type-face t) ("\\(specific\\)" 1 font-lock-type-face t) ("\\(macros\\)" 1 font-lock-type-face t) ("\\(after\\)" 1 font-lock-type-face t) ("\\(libout\\)" 1 font-lock-type-face t) ("\\(libpaths\\)" 1 font-lock-type-face t) ("\\(includes\\)" 1 font-lock-type-face t) ("\\(automatic\\)" 1 font-lock-type-face t) ("\\(command\\)" 1 font-lock-type-face t) ("\\(output_option\\)" 1 font-lock-type-face t) ("\\(header_pre_extension\\)" 1 font-lock-type-face t) ("\\(header_outputext\\)" 1 font-lock-type-face t) ("\\(sharedname\\)" 1 font-lock-type-face t) ("\\(dynamicflags\\)" 1 font-lock-type-face t) ("\\(idlflags\\)" 1 font-lock-type-face t) ("\\(:\\)" 1 font-lock-builtin-face t) ("\\( = \\)" 1 font-lock-builtin-face t) ("\\(+=\\)" 1 font-lock-builtin-face t) ("\\(-=\\)" 1 font-lock-builtin-face t) ("\\(//\\)" 1 font-lock-comment-face t) ("\\//\\(.*\\)" 1 font-lock-comment-face t) "default font-lock-keywords") ) ;; Indenting logic (defun mpc-indent-line () "Indent current line as MPC directives" (interactive) (beginning-of-line) (if (bobp) (indent-line-to 0) ; if we are at start of file, zero indent (let ((not-found-hint t) cur-indent (close-brace nil)) (save-excursion ; otherwise, we are not looking at a }, so we need to go back to find the (if (looking-at ".*}") (setq close-brace t)) (while not-found-hint ; nearest indentation hint (forward-line -1) (if (looking-at ".*{") (progn (setq cur-indent (+ (current-indentation) tab-width)) (setq not-found-hint nil)) (if (looking-at ".*}") (progn (setq cur-indent (current-indentation)) (if (< cur-indent 0) (setq cur-indent 0)) (setq not-found-hint nil)) (if (bobp) (setq not-found-hint nil)))))) (if close-brace (setq cur-indent (- cur-indent tab-width))) (if cur-indent (indent-line-to cur-indent) (indent-line-to 0)))) ) ;; Create a syntax table. Derived from fundamental mode, it will automatically ;; highlight strings, and behave correctly on most words. (defvar mpc-mode-syntax-table nil "syntax table used in mpc mode") (setq mpc-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?_ "w" mpc-mode-syntax-table) ; underscore is a valid part of a word (modify-syntax-entry ?- "w" mpc-mode-syntax-table) ; hyphen is a valid part of a word (modify-syntax-entry ?/ ". 12b" mpc-mode-syntax-table) ; c++-style comments (modify-syntax-entry ?\n "> b" mpc-mode-syntax-table) ; c++-style comments ;;;###autoload (defun mpc-mode () "A major-mode to edit MPC files. \\{mpc-mode-map} " (interactive) (kill-all-local-variables) (use-local-map mpc-mode-map) (make-local-variable 'comment-start) (setq comment-start "//") (make-local-variable 'parse-sexp-ignore-comments) (setq parse-sexp-ignore-comments t) (make-local-variable 'tab-width) (make-local-variable 'font-lock-defaults) (make-local-variable 'indent-line-function) (setq major-mode 'mpc-mode) (setq mode-name "MPC") (setq font-lock-defaults `(mpc-font-lock-keywords nil t)) (setq indent-line-function 'mpc-indent-line) (set-syntax-table mpc-mode-syntax-table) (run-hooks 'mpc-mode-hook) ) (add-to-list 'auto-mode-alist '("\\.mwb\\'" . mpc-mode)) (add-to-list 'auto-mode-alist '("\\.mwc\\'" . mpc-mode)) (add-to-list 'auto-mode-alist '("\\.mpb\\'" . mpc-mode)) (add-to-list 'auto-mode-alist '("\\.mpc\\'" . mpc-mode)) (provide 'mpc-mode) ;;; mpc-mode.el ends here ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/0000775000175000017500000000000012576472437016766 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/bin/LabVIEW_RT/PXI_Reset.ini0000755000175000017500000000404112576461726021270 0ustar pgquilespgquiles[PXI_Reset] server.app.propertiesEnabled=True server.ole.enabled=True server.tcp.paranoid=True server.tcp.servic="My Computer/VI Server" server.vi.callsEnabled=True server.vi.propertiesEnabled=True WebServer.DirectoryIndex="index.htm" WebServer.MimeTypes="htm;text/html;gif;image/gif;jpg;image/jpeg;png;image/png;txt;text/plain;html;text/html;jpeg;image/jpeg;css;text/css;llb;application/x-labview-llb;vi;application/x-labview-vi;doc;application/msword;dot;application/msword;bin;application/octet-stream;exe;application/octet-stream;rtf;application/rtf;pdf;application/pdf;ai;application/postscript;eps;application/postscript;ps;application/postscript;csh;application/x-csh;gtar;application/x-gtar;gz;application/x-gz;sh;application/x-sh;tar;application/x-tar;zip;application/zip;hqx;application/mac-binhex40;ua;audio/basic;wav;audio/wav;tif;image/tiff;tiff;image/tiff;xbm;image/x-xbitmap;rtx;text/richtext;qt;video/quicktime;mov;video/quicktime;avi;video/x-msvideo;movie;video/x-sgi-movie;aif;audio/aif;aifc;audio/aif;aiff;audio/aif;aim;application/x-aim;dif;video/x-dv;div;video/x-dv;js;application/x-javascript;pntg;image/x-macpaint;xlb;application/vnd.ms-excel;xls;application/vnd.ms-excel;ppa;application/vnd.ms-powerpoint;ppt;application/vnd.ms-powerpoint;pps;application/vnd.ms-powerpoint;pot;application/vnd.ms-powerpoint;pwz;application/vnd.ms-powerpoint;mid;audio/mid;midi;audio/mid;enc;video/mpeg;m1v;video/mpeg;mp2;video/mpeg;mpa;video/mpeg;mpe;video/mpeg;mpeg;video/mpeg;mpg;video/mpeg;psd;image/x-photoshop;bmp;image/bmp;pic;image/pic;ra;audio/vnd.rn-realaudio;rf;image/vnd.rf-realflash;rm;application/vnd.rn-realmedia;rp;image/vnd.rn-realpix;ram;audio/x-pn-realaudio;rmm;audio/x-pn-realaudio;rnx;application/vnd.rn-realplayer;rt;text/vnd.rn-realtext;rv;video/vnd.rn-realvideo;smi;application/smil;ssm;application/streamingmedia;sithqx;application/mac-binhex40;sit;application/x-stuffit" WebServer.RootPath=C:\Program Files\National Instruments\LabVIEW 8.0\www WebServer.TcpAccess="c+*" WebServer.ViAccess="+*" DebugServerEnabled=False DebugServerWaitOnLaunch=False ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/0000775000175000017500000000000012576472436023720 5ustar pgquilespgquilesace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/stdafx.h0000644000175000017500000000056012576461726025361 0ustar pgquilespgquiles// stdafx.h : include file for standard system include files, or // project specific include files that are used frequently, but are // changed infrequently // #pragma once #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include // TODO: reference additional headers your program requires here ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/labview_test_controller.sln0000644000175000017500000000305612576461726031373 0ustar pgquilespgquilesMicrosoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "labview_test_controller", "labview_test_controller.vcproj", "{646E6863-F3BE-403A-8B53-20C02664907B}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{01781FA2-36A3-49DA-A00C-2DEAE6A286FF}" ProjectSection(ProjectDependencies) = postProject {646E6863-F3BE-403A-8B53-20C02664907B} = {646E6863-F3BE-403A-8B53-20C02664907B} EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectDependencies) = postSolution EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {646E6863-F3BE-403A-8B53-20C02664907B}.Debug.ActiveCfg = Debug|Win32 {646E6863-F3BE-403A-8B53-20C02664907B}.Debug.Build.0 = Debug|Win32 {646E6863-F3BE-403A-8B53-20C02664907B}.Release.ActiveCfg = Release|Win32 {646E6863-F3BE-403A-8B53-20C02664907B}.Release.Build.0 = Release|Win32 {01781FA2-36A3-49DA-A00C-2DEAE6A286FF}.Debug.ActiveCfg = Debug|Win32 {01781FA2-36A3-49DA-A00C-2DEAE6A286FF}.Debug.Build.0 = Debug|Win32 {01781FA2-36A3-49DA-A00C-2DEAE6A286FF}.Release.ActiveCfg = Release|Win32 {01781FA2-36A3-49DA-A00C-2DEAE6A286FF}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/stdafx.cpp0000644000175000017500000000045612576461726025720 0ustar pgquilespgquiles// stdafx.cpp : source file that includes just the standard includes // labview_test_controller.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/ReadMe.txt0000644000175000017500000000762212576461726025623 0ustar pgquilespgquiles ======================================================================== DYNAMIC LINK LIBRARY : labview_test_controller Project Overview ======================================================================== The labview_test_controller DLL is needed to control execution and reporting for ACE+TAO tests on a LabVIEW RT/Pharlap ETS target. The LabVIEW RT environment can not execute programs - LabVIEW RT itself is the one program that runs on the Pharlap ETS base, so no other processes can be started. This DLL is built on the host VC7.1 Windows machine and copied to the target. The target's \ni-rt.ini file must have the full path of the labview_test_controller.dll on the target added to the [STARTUP] section, EarlyStartupLibraries key. If there are already entries in that key, append labview_test_controller.dll's path with a semi-colon separator. For example, this is what mine ended up as: [STARTUP] EarlyStartupLibraries=C:\ni-rt\system\lvuste.dll;C:\ni-rt\system\tsengine.dll;C:\ni-rt\system\nisl_emb.dll;C:\ni-rt\labview_test_controller.dll; MainExe=/ni-rt/system/emblview.exe After setting up the ni-rt.ini file and the DLL, reboot the target to load the controller DLL. Keep in mind that the current working directory while tests are running will be, at least on mine, \ni-rt\system. The test logs end up in \ni-rt\system\log. The labview_test_controller spawns a thread when the DLL is loaded at system start. The child thread starts listening on TCP port 8888. For each new connection to port 8888 a new thread is spawned to run the session. The test host issues text commands to the controller via this TCP connection. The responses are text as well. Thus, it's possible to test it using plain telnet. There's also a "test" project in this VC7.1 solution. The test project is a simple console app that calls the main thread's entrypoint in labview_test_controller, facilitating its testing on the host Windows machine where there's decent debugging capability. Debugging on the LabVIEW target is by printf only. The client side of the TCP connection that drives this test controller is in the ACE_wrappers/bin/PerlACE/ProcessLVRT.pm. The TestTarget_LVRT.pm is also involved in testing on the LabVIEW RT target. The remainder of this is what Visual Studio .NET generated for this project. ======================================================================== AppWizard has created this labview_test_controller DLL for you. This file contains a summary of what you will find in each of the files that make up your labview_test_controller application. labview_test_controller.vcproj This is the main project file for VC++ projects generated using an Application Wizard. It contains information about the version of Visual C++ that generated the file, and information about the platforms, configurations, and project features selected with the Application Wizard. labview_test_controller.cpp This is the main DLL source file. When created, this DLL does not export any symbols. As a result, it will not produce a .lib file when it is built. If you wish this project to be a project dependency of some other project, you will either need to add code to export some symbols from the DLL so that an export library will be produced, or you can set the Ignore Input Library property to Yes on the General propert page of the Linker folder in the project's Property Pages dialog box. ///////////////////////////////////////////////////////////////////////////// Other standard files: StdAfx.h, StdAfx.cpp These files are used to build a precompiled header (PCH) file named labview_test_controller.pch and a precompiled types file named StdAfx.obj. ///////////////////////////////////////////////////////////////////////////// Other notes: AppWizard uses "TODO:" comments to indicate parts of the source code you should add to or customize. ///////////////////////////////////////////////////////////////////////////// ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/test.vcproj0000644000175000017500000000661712576461726026134 0ustar pgquilespgquiles ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/labview_test_controller.vcproj0000644000175000017500000001022712576461726032100 0ustar pgquilespgquiles ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/labview_test_controller.cpp0000644000175000017500000004143712576461726031366 0ustar pgquilespgquiles// // Defines the entry point for the LabVIEW RT test controller DLL application. // This DLL is loaded at system boot by LabVIEW RT. The controller waits for // TCP connections from the ACE+TAO test scripts. The test scripts will direct // operation of the tests via commands sent over TCP. In order to be ready for // connections without intervention via VI, the initial load will spawn a // thread that sets up the listening socket. #include "stdafx.h" #include #include #include #include #include #include #include #include #include #include #include // NULL is the documented way to check DLL handles, and this is plain // Windows code, not ACE, so we stick to the Microsoft way... // FUZZ: disable check_for_NULL // This is plain Windows code, not ACE. Therefore we disable // the check for ACE_OS // FUZZ: disable check_for_lack_ACE_OS // TEST_FUNC is the prototype for the called test's main entrypoint. It's // the normal C main. typedef int (*TEST_FUNC) (int argc, char *argv[]); // Thread entrypoints static unsigned int __stdcall test_control (void *param); static unsigned int __stdcall peer_svc (void *peer_p); static unsigned int __stdcall run_test (void *test_p); static const char *format_errmsg (unsigned int errcode, const char *prefix); // Logging information static const char *LogName = "acetao.log"; static HANDLE logf = INVALID_HANDLE_VALUE; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { return (0 != _beginthreadex (0, // security 8 * 1024, // stack size test_control, // entrypoint 0, // param 0, // creation flags 0)); // ptr to thread id } return TRUE; } class Test { public: Test () : dll_handle_ (NULL), thr_handle_ (0), entry_ (0), running_ (false), status_ (-1) {} ~Test (); HANDLE handle (void) { return this->thr_handle_; } int run (void); const char *start (const char *name); bool status (int *exit_status); int wait (void); void kill (void); // Clean up remnants of a test run. void cleanup (void); private: HMODULE dll_handle_; HANDLE thr_handle_; TEST_FUNC entry_; bool running_; int status_; enum { CMDLINE_LEN = 1024, ARGV_SIZE = 100 }; char name_[CMDLINE_LEN]; char cmdline_[CMDLINE_LEN]; int argc_; char *argv_[ARGV_SIZE]; }; class Peer { public: Peer (SOCKET h) : handle_ (h) {} // Run the Peer's session; intended to be called from a new thread devoted // to this peer's session. int svc (void); private: Peer () {}; // Process command input from socket. int command (void); // Send a reply string to the peer. int reply (const char *msg); SOCKET handle_; Test test_; }; // Run a peer session; assume there's a thread for each session, so this // object has all it needs for context located in 'this' object, and it can // block at any point as long as one remembers that there is one or more // test threads running and some attention must be paid to the encapsulated // socket handle over which this object receives control commands from the // host test driver. int Peer::svc (void) { // Read commands until EOF (peer closed) or protocol error while (0 == this->command ()) ; closesocket (this->handle_); this->handle_ = INVALID_SOCKET; return 0; } int Peer::command (void) { // The protocol exchanges with the peer are execpted to be lock-step // request-reply command lines, so we can make assumptions about a complete // line being available to make life easier. const int MAX_RECV = 1024; char line[MAX_RECV], *p; p = &line[0]; int count = 0, len = 0; while ((count = recv (this->handle_, p, MAX_RECV - len, 0)) > 0) { p[count] = '\0'; len += count; p += count; char *nl; if ((nl = strchr (line, '\n')) == 0) continue; // At this point we have a 0-terminated string with a newline ending // the command line. Break out and process the command. break; } if (count <= 0) return -1; // Relay closed/error socket to caller char *cmd = strtok (line, "\t \n\r"); if (cmd == 0) { char err[1024]; sprintf (err, "Can't parse input: %s\n", line); this->reply (err); return -1; } // Which command is it? These commands are known: // // run [args] // Run test in the named test-dll; respond with "OK" or an error string. // status // If test still running return "RUNNING" else return exit status. // wait // Wait for test to exit; return "OK" // kill // Kill the thread with the most recent test; return "OK". // snaplog // Take a snapshot of the current stdout/stderr log to a new file // name and reset the stdout/stderr log. if (strcmp ("run", cmd) == 0) { char *test = strtok (0, "\t \n\r"); if (test == 0) { this->reply ("Malformed run command\n"); return -1; } // start() pulls apart the rest of the command line... const char *errmsg = this->test_.start (test); if (errmsg == 0) this->reply ("OK\n"); else this->reply (errmsg); } else if (strcmp ("status", cmd) == 0) { int status; if (this->test_.status (&status)) { char retvalmsg[64]; sprintf (retvalmsg, "%d\n", status); this->reply (retvalmsg); } else this->reply ("RUNNING\n"); } else if (strcmp ("wait", cmd) == 0) { int status = this->test_.wait (); char retvalmsg[64]; sprintf (retvalmsg, "%d\n", status); this->reply (retvalmsg); } else if (strcmp ("kill", cmd) == 0) { // Killing things is bad... say we can't and the host should reboot us. this->reply ("NO - please reboot me\n"); } else if (strcmp ("waitforfile", cmd) == 0) { char *name = strtok (0, "\t \n\r"); if (name == 0) { this->reply ("Malformed waitforfile command\n"); return -1; } char *secs_s = strtok (0, "\t \n\r"); int secs = 0; if (secs_s == 0 || (secs = atoi (secs_s)) <= 0) { this->reply ("Malformed waitforfile command\n"); return -1; } struct _stat info; const char *msg = 0; bool found = false; while (secs > 0) { if (_stat (name, &info) == -1) // No file yet { if (errno != ENOENT) { // Something more serious than no file yet; bail out. msg = format_errmsg (errno, name); break; } } else { if (info.st_size > 0) { found = true; break; } } // Either no file yet, or it's there but with no content yet. Sleep (1 * 1000); // arg is in msec --secs; } if (found) this->reply ("OK\n"); else if (secs == 0) this->reply ("TIMEOUT\n"); else this->reply (msg); } else if (strcmp ("snaplog", cmd) == 0) { if (logf == INVALID_HANDLE_VALUE) { this->reply ("NONE\n"); } else { CloseHandle (logf); if (0 == rename (LogName, "snapshot.txt")) { char abspath[1024]; if (_fullpath (abspath, "snapshot.txt", 1024)) { strcat (abspath, "\n"); this->reply (abspath); } else { // Last ditch effort to get a name back to the client this->reply ("\\ni-rt\\system\\snapshot.txt\n"); } } else { this->reply ("NONE\n"); } // Reset stdout/stderr to a new file logf = CreateFile (LogName, FILE_ALL_ACCESS, FILE_SHARE_READ, 0, // security CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); SetStdHandle (STD_OUTPUT_HANDLE, logf); SetStdHandle (STD_ERROR_HANDLE, logf); } } else { this->reply ("Unrecognized command\n"); return -1; } return 0; } int Peer::reply (const char *msg) { int len = (int)strlen (msg); // size_t -> int return send (this->handle_, msg, len, 0) > 0 ? 0 : -1; } Test::~Test () { this->cleanup (); } int Test::run (void) { this->running_ = true; try { this->status_ = (this->entry_) (this->argc_, this->argv_); } catch (...) { // Try to note this exception then save the log file before bailing out. DWORD bl; char msg[256]; sprintf (msg, "Exception in %s caught by labview_test_controller\n", this->name_); WriteFile (logf, msg, (DWORD)strlen(msg), &bl, 0); FlushFileBuffers (logf); CloseHandle (logf); throw; } this->running_ = false; // It's possible to cleanup() here; however, that would introduce a race // with start() following beginthreadex(). So do all the cleanup on user // action - either getting status, waiting, killing, or running another // test. Or, terminating the connection. return 0; } const char * Test::start (const char *name) { if (this->running_) return "Already running\n"; const char *msg = 0; // Reset test status to not inadvertantly report a previous test. this->status_ = -1; this->cleanup (); // Resets cmdline_, argc_, argv_ // The command line is part-way through being tokenized by strtok(). It // left off after the program name. Anything remaining are the command // line arguments for the program. Pick off whatever is there, copy it // to the cmdline_ array and fill in argc_/argv_ for the eventual run. strcpy (this->name_, name); this->argv_[0] = this->name_; this->argc_ = 1; size_t cmdchars = 0; for (char *token = strtok (0, "\t \n\r"); token != 0 && (cmdchars + strlen (token) + 1) < CMDLINE_LEN; token = strtok (0, "\t \n\r")) { // We have a new token and it will fit in cmdline_. Copy it to the // next spot in cmdline_, add it to argv_/argc_ then update cmdchars // to account for the copied-in token and its nul terminator. strcpy (&this->cmdline_[cmdchars], token); this->argv_[this->argc_] = &this->cmdline_[cmdchars]; ++this->argc_; cmdchars += (strlen (token) + 1); } char libspec[1024]; sprintf (libspec, "%s.dll", name); if ((this->dll_handle_ = LoadLibrary (libspec)) == NULL) return format_errmsg (GetLastError (), libspec); this->entry_ = (TEST_FUNC) GetProcAddress (this->dll_handle_, "main"); if (this->entry_ == NULL) { msg = format_errmsg (GetLastError (), "main"); this->cleanup (); return msg; } else { unsigned int thread_id; /* unused */ uintptr_t h = _beginthreadex (0, // security 1024 * 1024, // stack size run_test, // entrypoint (void *)this, // arglist 0, // initflag &thread_id); // thread ID this->thr_handle_ = (HANDLE) h; if (h == 0) // Test thread may have access to thr_handle_ { msg = format_errmsg (GetLastError (), "spawn"); this->cleanup (); return msg; } } return 0; } bool Test::status (int *exit_status) { if (this->running_) return false; // still running *exit_status = this->status_; this->cleanup (); return true; } int Test::wait (void) { WaitForSingleObject (this->thr_handle_, INFINITE); if (!this->running_) this->cleanup (); return this->status_; } void Test::kill (void) { TerminateThread (this->thr_handle_, -1); this->cleanup (); this->running_ = false; this->status_ = -1; } // Clean up remnants of a test run. void Test::cleanup (void) { if (this->dll_handle_ != NULL) { FreeLibrary (this->dll_handle_); this->dll_handle_ = NULL; } if (this->thr_handle_ != 0) { CloseHandle (this->thr_handle_); this->thr_handle_ = 0; } this->entry_ = 0; this->argc_ = 0; for (int i = 0; i < ARGV_SIZE; ++i) this->argv_[i] = 0; memset (this->cmdline_, 0, CMDLINE_LEN); } static unsigned int __stdcall test_control (void * /* param */) { // cd to ace dir?? (can this be an env variable?) // redirect stdout/stderr to a file logf = CreateFile (LogName, FILE_ALL_ACCESS, FILE_SHARE_READ, 0, // security OPEN_ALWAYS, // Don't crush a previous one FILE_ATTRIBUTE_NORMAL, 0); if (logf == INVALID_HANDLE_VALUE) perror (LogName); else { SetFilePointer (logf, 0, 0, FILE_END); // Append new content SetStdHandle (STD_OUTPUT_HANDLE, logf); SetStdHandle (STD_ERROR_HANDLE, logf); } WORD want; WSADATA offer; want = MAKEWORD (2, 2); if (0 != WSAStartup (want, &offer)) { perror ("WSAStartup"); CloseHandle (logf); return WSAGetLastError (); } // listen on port 8888 (can I set an env variable for this?) SOCKET acceptor = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); sockaddr_in listen_addr; memset (&listen_addr, 0, sizeof (listen_addr)); listen_addr.sin_family = AF_INET; listen_addr.sin_addr.s_addr = INADDR_ANY; listen_addr.sin_port = htons (8888); if (SOCKET_ERROR == bind (acceptor, (struct sockaddr *)&listen_addr, sizeof (listen_addr))) { perror ("bind"); } else { listen (acceptor, 10); SOCKET peer; while ((peer = accept (acceptor, 0, 0)) != INVALID_SOCKET) { Peer *p = new Peer (peer); if (p == 0) { perror ("Out of memory"); closesocket (peer); peer = INVALID_SOCKET; continue; } if (0 == _beginthreadex (0, // security 64 * 1024, // stack size peer_svc, // entrypoint (void *)p, // param 0, // creation flags 0)) // ptr to thread id { perror ("beginthreadex peer"); closesocket (peer); delete p; } p = 0; peer = INVALID_SOCKET; } perror ("accept"); } closesocket (acceptor); WSACleanup (); return 0; } // Entrypoint for thread that's spawned to run a peer's session. Direct // control to the peer class. static unsigned int __stdcall peer_svc (void *peer_p) { Peer *p = (Peer *)peer_p; DWORD status = p->svc (); delete p; return status; } // Entrypoint for the thread spawned to run a test. The thread arg is the // Test * - call back to the test's run() method; return the test exit code // as the thread's return value. static unsigned int __stdcall run_test (void *test_p) { Test *t = (Test *)test_p; return t->run (); } // Format a Windows system or Winsock error message given an error code. static const char * format_errmsg (unsigned int errcode, const char *prefix) { static const size_t errmsgsize = 1024; static char errmsg[errmsgsize]; sprintf (errmsg, "%s: ", prefix); size_t len = strlen (errmsg); char *next = &errmsg[len]; size_t max_fmt = errmsgsize - len; if (0 != FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, errcode, 0, // Use default language next, (DWORD)max_fmt, 0)) { strcat (errmsg, "\n"); return errmsg; } errno = errcode; char *msg = _strerror (prefix); sprintf (errmsg, "err %d: %s", errcode, msg); return errmsg; } #ifdef TEST_RUNNER_EXPORTS #define TEST_RUNNER_API __declspec(dllexport) #else #define TEST_RUNNER_API __declspec(dllimport) #endif __declspec(dllexport) int test_entry(void) { return 0; } ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/labview_test_controller/test.cpp0000644000175000017500000000056512576461726025407 0ustar pgquilespgquiles#include __declspec(dllimport) int test_entry(void); // This is plain Windows code, not ACE. Therefore we disable // the check for ACE_OS // FUZZ: disable check_for_lack_ACE_OS // FUZZ: disable check_for_improper_main_declaration int main (int, char *[]) { char line[80]; test_entry(); puts ("Ok, go... hit return to stop."); gets (line); return 0; } ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/README0000644000175000017500000000575412576461726017656 0ustar pgquilespgquiles This directory contains utilities for running the ACE+TAO test suite on a LabVIEW RT 8 / Phar Lap ETS target. Although it's running Phar Lap ETS, and thus would normally be able to run programs, this environment is different than plain Phar Lap ETS in that the LabVIEW RT layer takes up the only process able to run on Phar Lap. Thus, everything executed needs to be done via LabVIEW RT facilities. Thus, we have the following restrictions: 1. There's no NFS, no SMB; there's a target filesystem but no direct access. 2. No executables can be directly executed. This yields the following: - All test "programs" are built as DLLs instead of executables. The DLL has a known "main" entrypoint. To run the test, the DLL must be copied down to the target, explicitly loaded, and its entrypoint called. MPC will automatically build these DLLs when an executable is specified in the MPC file by basing the MPC project on the labviewrt_dll.mpb base. This is done by supplying "-base labviewrt_dll" on the MPC command line. - There is a test-controlling DLL that lives on the LabVIEW RT target, and is loaded when the target boots. This DLL spawns a thread that listens on a TCP port for connections; it runs a text-based protocol by which it can be directed to load and run test DLLs and report results. This DLL is in the labview_test_controller subdirectory; see its ReadMe.txt file for more details. - The Perl test framework in PerlACE has a ProcessLVRT.pm and TestTarget_LVRT.pm that know how to run the test protocol, get the log file back from the target, etc. in order to integrate the LabVIEW RT scheme into the ACE+TAO testing framework. - If a test encounters any significant errors that would produce something akin to a crash or significant leak on a multi-process OS, it will probably render the LabVIEW RT target unuseable and unresponsive. There are two utilities in this directory that will help in this sort of situation: 1. Reboot_Target.exe: A Windows executable that runs a LabVIEW VI to reboot a local target box. If the box is alive enough to be contacted and run the LabVIEW VI that triggers the reboot, this works fine. However, if the box is unresponsive, as it usually is, this doesn't work. The advantage of this utility is that it doesn't require any additional hardware or software. 2. PXI_Reset.exe: A Windows executable that runs a LabVIEW VI to trigger a hardware reset on the target box. This utility works all the time since it does a hardware reset. However, it requires an additional piece of hardware that connects to the host PC via USB and connects to the DB9 on the back of the PXI target. This little hardware box was custom-made by Lockheed Martin, so you can't just go buy one at Radio Shack. If neither of these utilities is workable for you, you can probably use a programmable power strip that can cycle the power on the target, and write a utility that drives it. ace-6.3.3+dfsg.orig/bin/LabVIEW_RT/Reboot_Target.ini0000755000175000017500000000404512576461726022232 0ustar pgquilespgquiles[Reboot_Target] server.app.propertiesEnabled=True server.ole.enabled=True server.tcp.paranoid=True server.tcp.servic="My Computer/VI Server" server.vi.callsEnabled=True server.vi.propertiesEnabled=True WebServer.DirectoryIndex="index.htm" WebServer.MimeTypes="htm;text/html;gif;image/gif;jpg;image/jpeg;png;image/png;txt;text/plain;html;text/html;jpeg;image/jpeg;css;text/css;llb;application/x-labview-llb;vi;application/x-labview-vi;doc;application/msword;dot;application/msword;bin;application/octet-stream;exe;application/octet-stream;rtf;application/rtf;pdf;application/pdf;ai;application/postscript;eps;application/postscript;ps;application/postscript;csh;application/x-csh;gtar;application/x-gtar;gz;application/x-gz;sh;application/x-sh;tar;application/x-tar;zip;application/zip;hqx;application/mac-binhex40;ua;audio/basic;wav;audio/wav;tif;image/tiff;tiff;image/tiff;xbm;image/x-xbitmap;rtx;text/richtext;qt;video/quicktime;mov;video/quicktime;avi;video/x-msvideo;movie;video/x-sgi-movie;aif;audio/aif;aifc;audio/aif;aiff;audio/aif;aim;application/x-aim;dif;video/x-dv;div;video/x-dv;js;application/x-javascript;pntg;image/x-macpaint;xlb;application/vnd.ms-excel;xls;application/vnd.ms-excel;ppa;application/vnd.ms-powerpoint;ppt;application/vnd.ms-powerpoint;pps;application/vnd.ms-powerpoint;pot;application/vnd.ms-powerpoint;pwz;application/vnd.ms-powerpoint;mid;audio/mid;midi;audio/mid;enc;video/mpeg;m1v;video/mpeg;mp2;video/mpeg;mpa;video/mpeg;mpe;video/mpeg;mpeg;video/mpeg;mpg;video/mpeg;psd;image/x-photoshop;bmp;image/bmp;pic;image/pic;ra;audio/vnd.rn-realaudio;rf;image/vnd.rf-realflash;rm;application/vnd.rn-realmedia;rp;image/vnd.rn-realpix;ram;audio/x-pn-realaudio;rmm;audio/x-pn-realaudio;rnx;application/vnd.rn-realplayer;rt;text/vnd.rn-realtext;rv;video/vnd.rn-realvideo;smi;application/smil;ssm;application/streamingmedia;sithqx;application/mac-binhex40;sit;application/x-stuffit" WebServer.RootPath=C:\Program Files\National Instruments\LabVIEW 8.2\www WebServer.TcpAccess="c+*" WebServer.ViAccess="+*" DebugServerEnabled=False DebugServerWaitOnLaunch=False ace-6.3.3+dfsg.orig/bin/ACE-casts-convert0000755000175000017500000000524612576461726020303 0ustar pgquilespgquiles#! /bin/sh # ============================================================================= # # @file ACE-casts-convert # # $Id$ # # Script to convert all ACE cast macro calls (e.g. # ACE_static_cast (foo, bar)) to their standard C++ counterparts (e.g. # static_cast (bar)). # # Use this script at your own risk. It appears to work correctly for # most cases, but verify the results "just in case". # # @note Wildcards may be supplied as the "FILE" arguments to this # script since the shell should expand the wildcards before # executing the script. # # @bug The sed program used in this script may loop indefinitely on # ACE casts with arguments split across multiple lines # containing patterns it doesn't recognize. # # @author Ossama Othman # # ============================================================================= if test "$#" -eq 0; then echo "Usage: $0 FILE [FILE2] ..." echo "" exit 1 fi echo "" echo "Converting ACE cast macro calls to standard C++ syntax in:" while test "$#" -gt 0 do arg="$1" shift if grep "ACE_\(static\|dynamic\|const\|reinterpret\)_cast" $arg > /dev/null 2>&1; then echo " $arg" sed -e :a -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*\([^ \t].*\)/\1_cast<\2> (\3/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*(/ba' \ -e :aa -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*\([^,]*\)[ \t]*,\(.*\),[ \t]*\([^,]*\)/\1_cast<\2<\3> \&> (\4/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*(/baa' \ -e :aaa -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*\([^,]*\)[ \t]*,\(.*\),[ \t]*\([^,]*\)/\1_cast<\2<\3> \*> (\4/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*(/baaa' $arg > ${arg}.new mv ${arg}.new $arg fi done ace-6.3.3+dfsg.orig/bin/reverse_clean0000755000175000017500000000100012576461726017717 0ustar pgquilespgquileseval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # -*- perl -*- # $Id$ # # This script does a realclean of the list in the reverse order that # is passed to this. This is just a utility script @ARGS = (); if ($ARGV[0] eq ''){ print STDERR "$0: No directories provided\n"; die "provide list of directories"; } my $make = $ARGV[0]; shift; @BUILD_LIST = @ARGV; foreach $i (reverse (@BUILD_LIST)) { system ("$make -k -C $i realclean"); } ace-6.3.3+dfsg.orig/bin/clean_sems.sh0000755000175000017500000000074212576461726017640 0ustar pgquilespgquiles#!/bin/sh SYSTEM=`uname -s` IPCS="ipcs" IPCRM="ipcrm -s" if [ "$SYSTEM" = "Darwin" ]; then USER=`id | sed 's/(.*//; s/uid=//'` IPCS="ngvipc -s" IPCRM="ngvipc -s -R" elif [ -z "$USER" ]; then USER=`id | sed 's/).*//; s/.*(//'` fi case "$SYSTEM" in "Linux" ) ipcs -a | grep $USER | awk '{ print ($2) }' | xargs -r ipcrm sem; ;; * ) semids=`$IPCS | grep "^s" | grep $USER | awk '{ print ($2) }'` for p in $semids do $IPCRM $p done ;; esac ace-6.3.3+dfsg.orig/bin/footprint_stats.sh0000755000175000017500000000412312576461726020766 0ustar pgquilespgquiles#!/bin/sh # if [ $# -lt 1 ]; then echo "Usage: $0 [DEST]" exit 0 fi DEST=$1 DATE=`date +%Y/%m/%d-%H:%M` BINS="$TAO_ROOT/tests/ORB_init/ORB_init $TAO_ROOT/tests/ORB_destroy/ORB_destroy" LIBS="$ACE_ROOT/ace/libACE.a \ $TAO_ROOT/tao/libTAO.a \ $TAO_ROOT/tao/PortableServer/libTAO_PortableServer.a \ $TAO_ROOT/tao/Strategies/libTAO_Strategies.a \ $TAO_ROOT/tao/SmartProxies/libTAO_SmartProxies.a \ $TAO_ROOT/tao/DynamicAny/libTAO_DynamicAny.a \ $TAO_ROOT/tao/DynamicInterface/libTAO_DynamicInterface.a \ $TAO_ROOT/tao/IFR_Client/libTAO_IFR_Client.a \ $TAO_ROOT/tao/BiDir_GIOP/libTAO_BiDirGIOP.a \ $TAO_ROOT/tao/IORManipulation/libTAO_IORManip.a \ $TAO_ROOT/tao/IORTable/libTAO_IORTable.a \ $TAO_ROOT/tao/TypeCodeFactory/libTAO_TypeCodeFactory.a \ $TAO_ROOT/tao/RTCORBA/libTAO_RTCORBA.a \ $TAO_ROOT/tao/IORInterceptor/libTAO_IORInterceptor.a \ $TAO_ROOT/tao/Messaging/libTAO_Messaging.a \ $TAO_ROOT/tao/ObjRefTemplate/libTAO_ObjRefTemplate.a \ $TAO_ROOT/tao/Valuetype/libTAO_Valuetype.a \ $TAO_ROOT/tao/RTScheduling/libTAO_RTScheduler.a \ $TAO_ROOT/tao/AnyTypeCode/libTAO_AnyTypeCode.a \ $TAO_ROOT/tao/PI/libTAO_PI.a \ $TAO_ROOT/tao/PI_Server/libTAO_PI_Server.a \ $TAO_ROOT/tao/Codeset/libTAO_Codeset.a \ $TAO_ROOT/tao/CodecFactory/libTAO_CodecFactory.a \ $TAO_ROOT/tao/RTPortableServer/libTAO_RTPortableServer.a" mkdir -p $DEST/source mkdir -p $DEST/data mkdir -p $DEST/images for i in $BINS; do b=`basename $i` if [ -x $i ]; then ( echo -n $DATE " "; size $i | grep -v text | awk '{print $4}' ) >> $DEST/source/${b}_size.txt fi done for i in $LIBS; do b=`basename $i`; if [ -f $i ]; then ( echo -n $DATE " "; size $i | awk '{s += $4} END {print s}' ) >> $DEST/source/${b}_size.txt fi done cd $DEST/source for i in $LIBS $BINS; do b=`basename $i` /usr/bin/tac ${b}_size.txt > $DEST/data/${b}_size.txt /usr/bin/tail -5 ${b}_size.txt > $DEST/data/LAST_${b}_size.txt $ACE_ROOT/bin/generate_footprint_chart.sh ${b}_size.txt $DEST/images/${b}_size.png $b done ace-6.3.3+dfsg.orig/bin/zap_svn_id.pl0000755000175000017500000000761712576461726017674 0ustar pgquilespgquileseval '(exit $?0)' && eval 'exec perl -pi -S $0 ${1+"$@"}' & eval 'exec perl -0 -S $0 $argv:q' if 0; # You may want to run the "find" command with this script, which maybe # something like this: # # find . -type f \( -name "*.inl" -o -name "*.h" -o -name "*.cxx" -o -name "*.java" -o -name "*.l" -o -name "*.c" -o -name "*.mpd" -o -name "*.py" -o -name "*.cpp" -o -name "*.mpc" -o -name "*.idl" -o -name "*.conf" -o -name "*.mpb" -o -name "*.hpp" -o -name "*.pl" -o -name "*.mpt" -o -name "*.pm" -o -name "*.html" -o -name "*.xml" -o -name "*.y" \) -print | xargs $ACE_ROOT/bin/zap_svn_id.pl # The first three lines above let this script run without specifying the # full path to perl, as long as it is in the user's PATH. # Taken from perlrun man page. # Replace the old cvs-id tag with nothing BEGIN{undef $/;} s///smg; # Replace a single doxygen style with two spaces before the Id with one space BEGIN{undef $/;} s/ \*\n \* \$Id\$\n \*\n/ \*\n \* \$Id\$\n \*\n/smg; # Replace a three line doxygen style Id tag with just line * BEGIN{undef $/;} s/ \*\n \* \$Id\$\n \*\n/ \*\n/smg; # Replace a three line doxygen style Id tag with just line * BEGIN{undef $/;} s/\*\*\n \* \$Id\$\n \*\n/\*\*\n/smg; # Replace a three line c-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\/\n\/\/ \$Id\$\n\/\/\n\n//smg; # Replace a three line c-style id tag with nothing BEGIN{undef $/;} s/\/\/\n\/\/ \$Id\$\n\/\/\n//smg; # Replace a two line c-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\/\n\/\/ \$Id\$\n\n//smg; # Replace a two line c-style id tag with nothing BEGIN{undef $/;} s/\/\/\n\/\/ \$Id\$\n//smg; # Replace a one line c-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\/ \$Id\$\n\n//smg; # Replace a one line c-style id tag with nothing BEGIN{undef $/;} s/\/\/ \$Id\$\n//smg; # Replace a one line c-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\/\$Id\$\n\n//smg; # Replace a one line c-style id tag with nothing BEGIN{undef $/;} s/\/\/\$Id\$\n//smg; # Replace a one line start C++ line with Id with BEGIN{undef $/;} s/\/\/ -\*- C\+\+ -\*- \$Id\$\n/\/\/ -\*- C\+\+ -\*-\n/smg; # Replace a one line start C++ line with Id with BEGIN{undef $/;} s/\/\/ -\*- C\+\+ -\*- \$Id\$\n/\/\/ -\*- C\+\+ -\*-\n/smg; # Replace a one line start C++ line with Id with BEGIN{undef $/;} s/\/\/ -\*- C\+\+ -\*- \$Id\$\n/\/\/ -\*- C\+\+ -\*-\n/smg; # Replace a three line doxygen style Id tag with just line * BEGIN{undef $/;} s/\/\*\n \* \$Id\$\n \*\n/\/\*\n/smg; # Replace a one line c++-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\* \$Id\$ \*\/\n\n//smg; # Replace a one line c++-style id tag with an empty line below that with nothing BEGIN{undef $/;} s/\/\* \$Id\$ \*\/\n//smg; # Replace a three perl style Id tag with just line # BEGIN{undef $/;} s/ \#\n \# \$Id\$\n \#\n/ \#\n/smg; BEGIN{undef $/;} s/\#\n\# \$Id\$\n\#\n/\#\n/smg; BEGIN{undef $/;} s/ \#\n \#\$Id\$\n \#\n/ \#\n/smg; BEGIN{undef $/;} s/\#\n\#\$Id\$\n\#\n/\#\n/smg; BEGIN{undef $/;} s/\#\$Id\$\n//smg; BEGIN{undef $/;} s/\# \$Id\$\n//smg; BEGIN{undef $/;} s/\$Id\$//smg; # Trailing whitespaces BEGIN{undef $/;} s/\# \n//smg; BEGIN{undef $/;} s/\*\* \n/\*\*\n/smg; BEGIN{undef $/;} s/\/\*\n\*\*\n\*\*\n/\/\*\n/smg; BEGIN{undef $/;} s/\/\* \n/\/\*\n/smg; BEGIN{undef $/;} s/ \* \n/ \*\n/smg; BEGIN{undef $/;} s/ \* \n/ \*\n/smg; BEGIN{undef $/;} s/\*\n\* \n\*\n/\*\n/smg; BEGIN{undef $/;} s/ \*\n \*\n \*\n/ \*\n/smg; BEGIN{undef $/;} s/ \*\n \*\/\n/ \*\/\n/smg; BEGIN{undef $/;} s/\/\/ \n/\/\/\n/smg; BEGIN{undef $/;} s/ \*\n \*\n/ \*\n/smg; BEGIN{undef $/;} s/\/\/\n\/\/\n/\/\/\n/smg; BEGIN{undef $/;} s/ \n/\n/smg; BEGIN{undef $/;} s/\/\/ cvs-id :\n//smg; # Empty header BEGIN{undef $/;} s/\/\*\n \*\/\n//smg; BEGIN{undef $/;} s/\/\*\*\n \*\/\n//smg; BEGIN{undef $/;} s/\/\*\*\n \*\n \*\/\n//smg; BEGIN{undef $/;} s/\/\*\*\n\*\n\*\/\n//smg; ace-6.3.3+dfsg.orig/bin/msvc_mpc_auto_compile.pl0000755000175000017500000002651012576461726022100 0ustar pgquilespgquileseval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # Win32 auto_compile script. use File::Find; use Cwd; if (!$ENV{ACE_ROOT}) { $ACE_ROOT = getcwd ()."\\"; warn "ACE_ROOT not defined, defaulting to ACE_ROOT=$ACE_ROOT"; } else { $ACE_ROOT = $ENV{ACE_ROOT}; $TAO_ROOT = $ENV{TAO_ROOT}; $CIAO_ROOT = $ENV{CIAO_ROOT}; $DANCE_ROOT = $ENV{DANCE_ROOT}; } @directories = (); @ace_core_dirs = ("$ACE_ROOT\\ace", "$ACE_ROOT\\Kokyu", "$ACE_ROOT\\ACEXML", "$ACE_ROOT\\examples", "$ACE_ROOT\\tests", "$ACE_ROOT\\protocols"); @tao_core_dirs = ("$ACE_ROOT\\apps\\gperf\\src", "$TAO_ROOT\\TAO_IDL", "$TAO_ROOT\\tao", "$TAO_ROOT\\tests"); @orbsvcs_core_dirs = ("$TAO_ROOT\\orbsvcs\\orbsvcs"); @dance_core_dirs = ("$DANCE_ROOT"); @ciao_core_dirs = ("$CIAO_ROOT"); $debug = 0; $verbose = 0; $print_status = 0; $Ignore_errors = 0; # By default, bail out if an error occurs. $Build_Debug = 0; $Build_Release = 0; $build_all = 0; $Build_Cmd = "/BUILD"; $use_custom_dir = 0; $useenv = ''; $vc7 = 0; $project_root = "$ACE_ROOT"; # Build_Config takes in a string of the type "project--configuration" and # runs msdev to build it. # sub Build_Config ($) #{ # my ($arg) = @_; # my ($project, $config) = split /--/, $arg; # # return Build ($project, $config); #} # Build sub Build ($$) { my ($project, $config) = @_; if ($debug == 1) { print "$project\n"; return 0; } else { print "Auto_compiling $project : $config\n"; print "Building $project $config\n" if $verbose; return system ("msdev.com $project /MAKE \"$config\" $Build_Cmd $useenv"); } } # Build sub Build_VC7 ($$) { my ($project, $config) = @_; if ($debug == 1) { print "$project\n"; return 0; } else { print "Auto_compiling $project : $config\n"; print "Building $project $config\n" if $verbose; return system ("devenv.com $project $Build_Cmd $config $useenv"); } } sub Find_Dsw (@) { my (@dir) = @_; @array = (); sub wanted_dsw { $array[++$#array] = $File::Find::name if ($File::Find::name =~ /\.dsw$/i); } find (\&wanted_dsw, @dir); print "List of dsw's\n" if ($verbose == 1); return @array; } sub Find_Sln (@) { my (@dir) = @_; @array = (); print "Searching for list of sln's\n" if ($verbose == 1); sub wanted_sln { $array[++$#array] = $File::Find::name if ($File::Find::name =~ /\.sln$/i); } find (\&wanted_sln, @dir); print "List of sln's\n" if ($verbose == 1); return @array; } # Only builds the core libraries. sub Build_Custom () { print STDERR "Building Custom\n"; print "Building Custom directories specified\n";# if ($verbose == 1); print "Build " if ($verbose); print "Debug " if ($verbose) && ($Build_Debug); print "Release " if ($verbose) && ($Build_Release); print "\n" if ($verbose); my @custom_list = Find_Dsw (@directories); print "List now is @custom_list \n"; foreach $c (@custom_list) { print "List now is $c \n"; if ($Build_Debug) { $Status = Build ($c, "ALL - Win32 Debug"); return if $Status != 0 && !$Ignore_errors; } if ($Build_Release) { $Status = Build ($c, "ALL - Win32 Release"); return if $Status != 0 && !$Ignore_errors; } } } # Build all examples and directories sub Build_All () { push @directories, @ace_core_dirs; push @directories, @tao_core_dirs; push @directories, @orbsvcs_core_dirs; push @directories, @dance_core_dirs; push @directories, @ciao_core_dirs; print STDERR "First pass (libraries)\n" if ($print_status == 1); print "\nmsvc_mpc_auto_compile: First Pass CORE (libraries)\n"; Build_Custom (); my @new_directory_search = "$project_root"; my @configurations = Find_Dsw (@new_directory_search); print STDERR "Second pass (for other things)\n" if ($print_status == 1); print "\nmsvc_mpc_auto_compile: Second Pass (rest of the stuff)\n"; foreach $c (@configurations) { print "\nUsing $c for compilation\n"; if ($Build_Debug) { $Status = Build ($c, "ALL - Win32 Debug"); return if $Status != 0 && !$Ignore_errors; } if ($Build_Release) { $Status = Build ($c, "ALL - Win32 Release"); return if $Status != 0 && !$Ignore_errors; } } } # Only builds the core libraries. sub Build_Custom_VC7 () { print STDERR "Building Custom\n"; print "Building Custom directories specified\n";# if ($verbose == 1); print "Build " if ($verbose); print "Debug " if ($verbose) && ($Build_Debug); print "Release " if ($verbose) && ($Build_Release); print "\n" if ($verbose); my @custom_list = Find_Sln (@directories); print "List now is @custom_list \n"; foreach $c (@custom_list) { print "List now is $c \n"; if ($Build_Debug) { $Status = Build_VC7 ($c, "debug"); return if $Status != 0 && !$Ignore_errors; } if ($Build_Release) { $Status = Build_VC7 ($c, "release"); return if $Status != 0 && !$Ignore_errors; } } } # Build all examples and directories sub Build_All_VC7 () { push @directories, @ace_core_dirs; push @directories, @tao_core_dirs; push @directories, @orbsvcs_core_dirs; push @directories, @dance_core_dirs; push @directories, @ciao_core_dirs; print STDERR "First pass (libraries)\n" if ($print_status == 1); print "\nmsvc_mpc_auto_compile: First Pass CORE (libraries)\n"; Build_Custom_VC7 (); my @new_directory_search = "$project_root"; my @configurations = Find_Sln (@new_directory_search); print STDERR "Second pass (for other things)\n" if ($print_status == 1); print "\nmsvc_mpc_auto_compile: Second Pass (rest of the stuff)\n"; foreach $c (@configurations) { print "\nUsing $c for compilation\n"; if ($Build_Debug) { $Status = Build_VC7 ($c, "debug"); return if $Status != 0 && !$Ignore_errors; } if ($Build_Release) { $Status = Build_VC7 ($c, "release"); return if $Status != 0 && !$Ignore_errors; } } } ## Parse command line argument while ( $#ARGV >= 0 && $ARGV[0] =~ /^(-|\/)/ ) { if ($ARGV[0] =~ '-k') { # Ignore errors print "Ignore errors\n" if ( $verbose ); $Ignore_errors = 1; } elsif ($ARGV[0] =~ /^-d$/i) { # debug $debug = 1; } elsif ($ARGV[0] =~ '-vc7') { # Use VC7 project and solution files. print "Using VC7 files\n" if ( $verbose ); $vc7 = 1; } elsif ($ARGV[0] =~ '-vc8') { # Use VC8 project and solution files. print "Using VC8 files\n" if ( $verbose ); $vc7 = 1; # vc8 is like vc7 } elsif ($ARGV[0] =~ '-vc9') { # Use VC9 project and solution files. print "Using VC9 files\n" if ( $verbose ); $vc7 = 1; # vc9 is like vc7 } elsif ($ARGV[0] =~ '-v') { # verbose mode $verbose = 1; } elsif ($ARGV[0] =~ '-s') { # status messages $print_status = 1; } elsif ($ARGV[0] =~ '-u') { # USEENV print "Using Environment\n" if ($verbose); $useenv = '/USEENV'; } elsif ($ARGV[0] =~ '-ACE') {# Build ACE and its tests print "Building ACE\n" if ( $verbose ); $use_custom_dir = 1; push @directories, @ace_core_dirs; } elsif ($ARGV[0] =~ '-TAO') {# Build TAO and its tests print "Building TAO\n" if ( $verbose ); $use_custom_dir = 1; push @directories, @ace_core_dirs; push @directories, @tao_core_dirs; } elsif ($ARGV[0] =~ '-ORBSVCS') {# Build TAO/ORBSVCS and its tests print "Building ACE+TAO+orbsvcs\n" if ( $verbose ); $use_custom_dir = 1; push @directories, @ace_core_dirs; push @directories, @tao_core_dirs; push @directories, @orbsvcs_core_dirs; } elsif ($ARGV[0] =~ '-CIAO') {# Build the CIAO and related # libraries print "Building only CIAO\n" if ( $verbose ); $use_custom_dir = 1; push @directories, @ace_core_dirs; push @directories, @tao_core_dirs; push @directories, @orbsvcs_core_dirs; push @directories, @dance_core_dirs; push @directories, @ciao_core_dirs; } elsif ($ARGV[0] =~ '-ALL') {# Build the CIAO and related # libraries print "Building ALL \n" if ( $verbose ); $build_all = 1; } elsif ($ARGV[0] =~ '-dir') { # Compile only a specific directory shift; print "Adding directory $ARGV[0]\n" if ( $verbose ); $use_custom_dir = 1; push @directories, $ARGV[0]; } elsif ($ARGV[0] =~ '-project_root') { # use different root than ACE_ROOT shift; print "Using project root $ARGV[0]\n" if ( $verbose ); $project_root = $ARGV[0]; } elsif ($ARGV[0] =~ '-rebuild') { # Rebuild all print "Rebuild all\n" if ( $verbose ); $Build_Cmd = "/REBUILD"; } elsif ($ARGV[0] =~ '-clean') { # Clean print "Cleaning all\n" if ( $verbose ); $Build_Cmd = "/CLEAN"; } elsif ($ARGV[0] =~ '-Debug') { # Debug versions print "Building Debug Version\n" if ( $verbose ); $Build_Debug = 1; } elsif ($ARGV[0] =~ '-Release') { # Release versions print "Building Release Version\n" if ( $verbose ); $Build_Release = 1; } elsif ($ARGV[0] =~ '-(\?|h)') { # Help information print "Options\n"; print "-d = Debug (only print out projects)\n"; print "-k = Ignore Errors\n"; print "-v = Script verbose Mode\n"; print "-s = Print status messages to STDERR\n"; print "-u = Tell MSVC to use the environment\n"; print "-vc7 = Use MSVC 7 toolset\n"; print "-vc8 = Use MSVC 8 toolset\n"; print "-vc9 = Use MSVC 9 toolset\n"; print "\n"; print "-ACE = Build ACE and its tests\n"; print "-TAO = Build ACE+TAO and its tests\n"; print "-ORBSVCS = Build ACE+TAO+ORBSVCS and its tests\n"; print "-CIAO = Build ACE+TAO+ORBSVCS+CIAO and its tests\n"; print "-dir = Compile custom directories\n"; print "-project_root = Use different root directory than ACE_ROOT\n"; print "\n"; print "-rebuild = Rebuild All\n"; print "-clean = Clean\n"; print "-Debug = Compile Debug versions\n"; print "-Release = Compile Release versions\n"; exit; } else { warn "$0: error unknown option $ARGV[0]\n"; die -1; } shift; } if (!$Build_Debug && !$Build_Release) { $Build_Debug = 1; $Build_Release = 1; } print "MPC version of msvc_mpc_auto_compile: Begin\n"; if ($vc7) { Build_All_VC7 if ($build_all && !$use_custom_dir); Build_Custom_VC7 if $use_custom_dir; } else { Build_All if ($build_all && !$use_custom_dir); Build_Custom if $use_custom_dir; } print "msvc_mpc_auto_compile: End\n"; print STDERR "End\n" if ($print_status == 1); ace-6.3.3+dfsg.orig/bin/topinfo_stats.sh0000755000175000017500000000335712576461726020430 0ustar pgquilespgquiles#!/bin/sh # if [ $# -lt 2 ]; then echo "Usage: $0 [DEST] [USER]" exit 0 fi DEST=$1 US=$2 DATE=`date +%Y/%m/%d-%H:%M` cd $ACE_ROOT LD_LIBRARY_PATH=$ACE_ROOT/ace export LD_LIBRARY_PATH PATH=/usr/bin:$PATH export PATH cd $TAO_ROOT/performance-tests/Memory/Single_Threaded # start the server ./server & s_id=$!; # Just sleep for 2 seconds. sleep 2; # Check whether the server has started file="test.ior" if test -f $file then # Just get the size as soon the server is started, ie. the vanilla # server. s_up=`top -p $s_id -n 1 -b | grep $US| awk '{print $5}'`; # Write it a file echo $DATE $s_up >> $DEST/source/st_start_size.txt # start the client ./client & c_id=$!; # Wait till all the invocations are done sleep 10; # Get the size once the client has made sufficient invocations. s_invocations=`top -p $s_id -n 1 -b | grep $US| awk '{print $5}'`; echo $DATE $s_invocations >> $DEST/source/st_after_invoke_size.txt # Kill the server and client. We will look at better ways of doing # this later. kill -9 $c_id; # Just sleep for the server to release memory etc. sleep 5; # Get the size once the client is killed or crashed s_client_death=`top -p $s_id -n 1 -b | grep $US| awk '{print $5}'`; echo $DATE $s_client_death >> $DEST/source/st_after_peer_death_size.txt kill -9 $s_id; rm -f $file else echo $file doesnt exist fi cd $DEST/source STRING="" FILES="start after_invoke after_peer_death" for i in $FILES ; do /usr/bin/tac st_${i}_size.txt > $DEST/data/st_${i}_size.txt /usr/bin/tail -5 st_${i}_size.txt > $DEST/data/LAST_st_${i}_size.txt $ACE_ROOT/bin/generate_topinfo_charts.sh st_${i}_size.txt $DEST/images/st_${i}_size.png st_${i}_size.txt $STRING done ace-6.3.3+dfsg.orig/bin/generate_compile_stats.sh0000755000175000017500000007566212576461726022264 0ustar pgquilespgquiles#! /bin/sh # # This script generate metrics html pages for either compile times or # footprint. # # Compile times: # Parse the build.txt file from an autobuild that was generated with the # g++_metric.sh script, e.g., with CXX=g++_metric.sh which outputs # compile times on a per object basis, and use the data to generate time # series graphs with gnuplot. # # Footprint: # Parse the build.txt file and and the *.map files, generated with LDFLAGS # set to =-Xlinker -M -Xlinker -Map -Xlinker \$@.map and static_libs_only=1. # # For use with an autobuild, place a line something like this in the xml file, # after the log file is closed, but before it's moved. # # # ############################################################################### # # usage # ############################################################################### usage () { echo "Usage: `basename $0` [--base=] [--name=] [--compiler=compiler]" echo " [target_file]" echo " [Footprint|Compilation] [] []" echo "" echo "--base This option can be used to set the base root directory to" echo " something other than the default \$ACE_ROOT." echo "--name This option can be used to set the software title to something" echo " other than the default ACE+TAO+CIAO+DAnCE." echo "--compiler This option can be used to set the compiler to something" echo " other than the default gcc." echo "input_file This is the compilation log file." echo "destination_directory This designates the location of the generated html." echo "target_file This is similar to input_file, but should contain no errors." echo "date Set the date used in all generated html pages." echo "fudge_factor Add the specified number of seconds to the compilation time" echo " for each target." echo "" echo "Options must be specified in the order shown above." exit } ############################################################################### # # parse_time # # this only works for english # assumes the date is formatted like this: Sat Apr 12 18:19:31 UTC 2003 # and outputs this: 2003/04/12-18:19 # ############################################################################### parse_time () { # todo: add a format parameter local INDEX=0 local PT_MONTH="" local PT_DAY="" local PT_YEAR="" local PT_HOUR="" local PT_MINUTE="" local PT_SECOND="" local PT_TIMEZONE="" read -a line for token in "${line[@]}"; do #echo "$INDEX = $token" case $INDEX in 1 ) case $token in Jan ) PT_MONTH="01" ;; Feb ) PT_MONTH="02" ;; Mar ) PT_MONTH="03" ;; Apr ) PT_MONTH="04" ;; May ) PT_MONTH="05" ;; Jun ) PT_MONTH="06" ;; Jul ) PT_MONTH="07" ;; Aug ) PT_MONTH="08" ;; Sep ) PT_MONTH="09" ;; Oct ) PT_MONTH="10" ;; Nov ) PT_MONTH="11" ;; Dec ) PT_MONTH="12" ;; esac ;; 2 ) PT_DAY="$token" ;; 3 ) PT_HOUR="${token%%:*}" PT_MINUTE="${token%:*}" PT_MINUTE="${PT_MINUTE#*:}" PT_SECOND="${token##*:}" ;; 4 ) PT_TIMEZONE="$token" ;; 5 ) PT_YEAR="$token" ;; esac let INDEX=$INDEX+1 done if [ "$1" = "debug" ]; then echo "month = $PT_MONTH" echo "day = $PT_DAY" echo "year = $PT_YEAR" echo "hour = $PT_HOUR" echo "min = $PT_MINUTE" echo "sec = $PT_SECOND" echo "tz = $PT_TIMEZONE" fi echo "$PT_YEAR/$PT_MONTH/$PT_DAY-$PT_HOUR:$PT_MINUTE" } ############################################################################### # # strip_date # # grab date from line with following format: # ################### End [Fri Apr 11 00:18:31 2003 UTC] # and return it in this format: Fri Apr 11 00:18:31 UTC 2003 which is # what parse_time() expects # ############################################################################### strip_date () { local INDEX=0 local TEMP_DATE="" local DATE="" read -a line for token in "${line[@]}"; do #echo "$INDEX = $token" case $INDEX in 2 ) DATE=${token#[} ;; 7 ) DATE="$DATE ${token%]} $TEMP_DATE" ;; # this is a hack since the autobuild scripts don't format the date # correctly... :-( 6 ) TEMP_DATE=$token ;; * ) DATE="$DATE $token" ;; esac let INDEX=$INDEX+1 done echo $DATE } ############################################################################### # # parse # # Parse the commandline and validate the inputs # ############################################################################### parse () { echo "parse()" while [ $# -gt 1 ]; do if [ -n "`echo $1 | grep '^--base=.*'`" ]; then BASE_ROOT=`echo $1 | sed 's/^--base=//'` shift elif [ -n "`echo $1 | grep '^--name=.*'`" ]; then BASE_TITLE=`echo $1 | sed 's/^--name=//'` shift elif [ -n "`echo $1 | grep '^--compiler.*'`" ]; then COMPILER=`echo $1 | sed 's/^--compiler=//'` shift else break fi done # set input file and destination (required) if [ $# -gt 1 ]; then INFILE=$1 DEST=$2 if ! [ -e "$INFILE" ]; then echo "input_file $INFILE does not exist." usage fi else usage fi # set the target file from command line if [ $# -gt 2 ]; then TARGETS=$3 else TARGETS=$INFILE fi # set type of metric from command line if [ $# -gt 3 ]; then METRIC=$4 else METRIC="Compilation" fi echo "metric = ($METRIC)" # set the date from command line if [ $# -gt 4 ]; then DATE=$5 else DATE=`tail -n 1 $INFILE | strip_date | parse_time` fi echo "date = ($DATE)" # set fudge factor from commandline (for testing) if [ $# -gt 5 ]; then FUDGE_FACTOR=$6 else FUDGE_FACTOR=0 fi } ############################################################################### # # gen_chart # # Generate the actual charts and move them to ${DEST} # ############################################################################### gen_chart () { local object=$1 local DEST=$2 local TYPE=$3 local EXT="txt" local YLABEL="Compile Time (Seconds)" local FACTOR=1 local low=$4 local high=$5 if [ "$TYPE" = "Footprint" ]; then EXT="size" if [ ${high} -gt 1024 ]; then YLABEL="Footprint (KBytes)" FACTOR=1024 else YLABEL="Footprint (Bytes)" FACTOR=1 fi fi let low="${low}/${FACTOR}" let high="${high}/${FACTOR}" sort -t'/' -k1n -k2n -k3n ${DEST}/data/${object}.${EXT} | grep -E ^2 > tmp.txt gnuplot <