arnacaw-svn Mailing List for Arnacaw Online MMORPG
Status: Pre-Alpha
Brought to you by:
shoyru
You can subscribe to this list here.
2007 |
Jan
|
Feb
(4) |
Mar
(7) |
Apr
(7) |
May
(4) |
Jun
(12) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <sh...@us...> - 2009-08-31 01:02:49
|
Revision: 78 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=78&view=rev Author: shoyru Date: 2009-08-31 01:02:41 +0000 (Mon, 31 Aug 2009) Log Message: ----------- random checkin prior to merge with new client code developed independently by myself for a summer project Modified Paths: -------------- trunk/common/NetworkSocket.cpp trunk/common/NetworkSocket.h trunk/server/Server.layout trunk/server/ServerNetworkManager.cpp Modified: trunk/common/NetworkSocket.cpp =================================================================== --- trunk/common/NetworkSocket.cpp 2009-04-05 02:01:04 UTC (rev 77) +++ trunk/common/NetworkSocket.cpp 2009-08-31 01:02:41 UTC (rev 78) @@ -103,6 +103,10 @@ /* retry later */ throw NonBlockingException(); } + else if ( error == NL_MESSAGE_END ) { + /* disconnected */ + return AO_NS_DISCONNECTED; + } stringstream s; s << "error writing to socket: " << nlGetErrorStr(error); MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); @@ -122,6 +126,10 @@ /* wait for the connection */ throw NonBlockingException(); } + else if ( error == NL_MESSAGE_END ) { + /* disconnected */ + return AO_NS_DISCONNECTED; + } stringstream s; s << "error reading from socket: " << nlGetErrorStr(error); MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); Modified: trunk/common/NetworkSocket.h =================================================================== --- trunk/common/NetworkSocket.h 2009-04-05 02:01:04 UTC (rev 77) +++ trunk/common/NetworkSocket.h 2009-08-31 01:02:41 UTC (rev 78) @@ -30,8 +30,11 @@ #ifndef __ARNACAW_NETWORKSOCKET_H__ #define __ARNACAW_NETWORKSOCKET_H__ -/* Type of connection to use */ +/** Type of connection to use */ #define ARNACAW_CONNTYPE NL_RELIABLE_PACKETS + +/** Return value of read() and write() upon disconnect. */ +#define AO_NS_DISCONNECTED -1 /** * Thrown when a non-blocking networking operation cannot @@ -74,10 +77,26 @@ /* destructor */ virtual ~NetworkSocket(); - /* reads from the socket */ + /** + * Reads from the socket. + * @throw NonBlockingException + * If there is nothing to be read, a NonBlockingException + * will be thrown. + * @throw Exception + * If an error occurs, an Exception will be thrown. + * @return the length of data read, or -1 upon disconnect + */ virtual int read(unsigned char *buf, int len); - /* writes to the socket */ + /** + * Writes to the socket. + * @throw NonBlockingException + * If the socket is not ready for writing, a + * NonBlockingException will be thrown. + * @throw Exception + * If an error occurs, an Exception will be thrown. + * @return the length of data read, or -1 upon disconnect + */ virtual int write(const unsigned char *buf, int len); /** Modified: trunk/server/Server.layout =================================================================== --- trunk/server/Server.layout 2009-04-05 02:01:04 UTC (rev 77) +++ trunk/server/Server.layout 2009-08-31 01:02:41 UTC (rev 78) @@ -10,11 +10,11 @@ <File name="../common/MessageManager.h" open="1" top="0" tabpos="9"> <Cursor position="2912" topLine="2" /> </File> - <File name="../common/NetworkSocket.cpp" open="1" top="0" tabpos="4"> - <Cursor position="7106" topLine="216" /> + <File name="../common/NetworkSocket.cpp" open="1" top="1" tabpos="4"> + <Cursor position="4288" topLine="108" /> </File> <File name="../common/NetworkSocket.h" open="1" top="0" tabpos="5"> - <Cursor position="4977" topLine="153" /> + <Cursor position="3597" topLine="72" /> </File> <File name="../common/Packet.cpp" open="0" top="0" tabpos="2"> <Cursor position="3129" topLine="66" /> @@ -94,8 +94,8 @@ <File name="Server.h" open="1" top="0" tabpos="7"> <Cursor position="3191" topLine="71" /> </File> - <File name="ServerNetworkManager.cpp" open="1" top="1" tabpos="2"> - <Cursor position="2906" topLine="60" /> + <File name="ServerNetworkManager.cpp" open="1" top="0" tabpos="2"> + <Cursor position="3292" topLine="60" /> </File> <File name="ServerNetworkManager.h" open="1" top="0" tabpos="3"> <Cursor position="2918" topLine="49" /> Modified: trunk/server/ServerNetworkManager.cpp =================================================================== --- trunk/server/ServerNetworkManager.cpp 2009-04-05 02:01:04 UTC (rev 77) +++ trunk/server/ServerNetworkManager.cpp 2009-08-31 01:02:41 UTC (rev 78) @@ -92,4 +92,8 @@ { /* no connections pending, do nothing */ } + + /* read from connected sockets */ + + /* write to connected sockets */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-04-05 02:01:09
|
Revision: 77 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=77&view=rev Author: shoyru Date: 2009-04-05 02:01:04 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Begin network integration. Server listens. Modified Paths: -------------- trunk/common/MessageManager.h trunk/common/NetworkSocket.cpp trunk/common/NetworkSocket.h trunk/server/ChangeLog trunk/server/LogOutputStream.cpp trunk/server/PathBuilder.cpp trunk/server/Server.cbp trunk/server/Server.cpp trunk/server/Server.h trunk/server/Server.layout trunk/server/ServerNetworkManager.cpp trunk/server/ServerNetworkManager.h trunk/server/config/default.cfg Modified: trunk/common/MessageManager.h =================================================================== --- trunk/common/MessageManager.h 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/common/MessageManager.h 2009-04-05 02:01:04 UTC (rev 77) @@ -39,6 +39,9 @@ #define MSGP_WARN 2 #define MSGP_ERROR 3 +/** Conveinence macro for posting messages */ +#define AO_POSTMESSAGE(m,l) MessageManager::getSingleton().postMessage(m,l) + /** * Passes strings to various registered OutputStreams * depending on a given priority level. @@ -56,7 +59,7 @@ * Stream to register * @param level * Priority level - * @throws Exception + * @throw Exception * If bad data is passed, an Exception will be thrown. */ void registerStream(OutputStream *stream, int level); @@ -69,11 +72,11 @@ * Pointer to array of priority levels * @param pcount * Number of elements in the array - * @throws Exception + * @throw Exception * If bad data is passed, an Exception will be thrown. */ void registerStreamMP(OutputStream *stream, int *levels, int pcount); - + /** * Unregisters a stream for all priority levels. * If the stream is not registered, nothing will happen. @@ -81,7 +84,7 @@ * Stream to unregister */ void unregisterStream(OutputStream *stream); - + /** * Posts a message to a given priority level. * @param message @@ -90,7 +93,7 @@ * Priority level to post to */ void postMessage(const string &message, int level); - + protected: /** Constructor is protected because of Singleton */ MessageManager(); Modified: trunk/common/NetworkSocket.cpp =================================================================== --- trunk/common/NetworkSocket.cpp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/common/NetworkSocket.cpp 2009-04-05 02:01:04 UTC (rev 77) @@ -76,6 +76,16 @@ MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); throw Exception(s.str()); } + + /* make the socket listen */ + if ( nlListen(wrapped_socket) != NL_TRUE ) { + /* error */ + stringstream s; + int err = nlGetError(); + s << "failed to listen on server socket: " << nlGetErrorStr(err); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } } /* writes to the socket */ @@ -180,11 +190,60 @@ throw Exception(s.str()); } - /* got a connection */ - /* TODO: Check for banned IP */ + /* got a connection; further processing will occur higher up */ return retval; } +/* gets the remote address */ +NLaddress *NetworkSocket::getAddress() +{ + /* allocate an address structure */ + NLaddress *retval = new NLaddress; + + /* look up the remote address */ + if ( nlGetRemoteAddr(wrapped_socket, retval) != NL_TRUE ) { + /* failed */ + int error = nlGetError(); + stringstream err; + err << "failed to determine remote address of socket: "; + err << nlGetErrorStr(error); + MessageManager::getSingleton().postMessage(err.str(),MSGP_ERROR); + delete retval; + throw Exception(err.str()); + } + + /* success */ + return retval; +} + +/* gets the remote address as a string */ +string NetworkSocket::getAddressStr() +{ + /* get the address structure */ + NLaddress *base = getAddress(); + + /* convert it */ + char buf[NL_MAX_STRING_LENGTH]; + nlAddrToString(base,buf); + freeAddress(base); + string retval(buf); + + /* strip any trailing port information */ + unsigned int endpos = retval.find(':'); + if ( endpos == string::npos ) { + /* no port information */ + return retval; + } + return retval.substr(0, endpos); +} + +/* frees a remote address */ +void NetworkSocket::freeAddress(NLaddress *addr) +{ + if ( addr ) + delete addr; +} + /* default constructor for NetworkSocketFactory */ NetworkSocketFactory::NetworkSocketFactory() { Modified: trunk/common/NetworkSocket.h =================================================================== --- trunk/common/NetworkSocket.h 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/common/NetworkSocket.h 2009-04-05 02:01:04 UTC (rev 77) @@ -109,7 +109,8 @@ void connect(const string &address, uint16_t port); /** - * Disconnects the socket. + * Disconnects the socket. + * @note For server sockets, this method closes the socket. */ void disconnect(); @@ -124,7 +125,31 @@ * If setServerMode() has not been called, an Exception will be thrown. * @returns A connected socket. */ - NetworkSocket *acceptConnection(); + NetworkSocket *acceptConnection(); + + /** + * Gets the IP address of the remote computer to which + * this socket is connected. The returned pointer should + * be freed with a call to the freeAddress() method. + * @throw Exception + * If an error occurs, an Exception will be thrown. A description + * of the cause of the error can be found in the reason. + * @return pointer to IP address structure of remote computer + */ + NLaddress *getAddress(); + + /** + * Gets the IP address of the remote computer to which + * this socket is connected, in string form. + * @return remote IP address as string + */ + string getAddressStr(); + + /** + * Frees an IP address structure returned by getAddress(). + * @param addr pointer to address structure to free + */ + void freeAddress(NLaddress *addr); protected: /** Modified: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/ChangeLog 2009-04-05 02:01:04 UTC (rev 77) @@ -8,6 +8,42 @@ ------------------------------------------------- +4 April 2009 - Jim Buchwald + +server/PathBuilder.h, server/PathBuilder.cpp: + * Replace temporary implementation of LogFile(). + It now checks against the primary configuration + file to see where logs are kept. This also + makes the implementation platform-independent. + Also gives log files a ".log" file extension, just + because I didn't like the way the log filenames looked + without it. + +server/Server.h, server/Server.cpp: + * Add accessor methods and a conveinence macro + for accessing the primary configuration file. + I wouldn't normally expose the entire configuration + file like that, but since it's going to be used + just about everywhere, it makes sense. + * Lots of other random changes. Improved error handling, + initialization of the ServerNetworkManager, etc. + +server/LogOutputStream.cpp: + * Fix a bug where the months were offset by 1; i.e. + April 4 was being output as 03/04. + * Add 4-digit year to logging timestamps. + +server/NetworkManager.h, server/NetworkManager.cpp: + * ServerNetworkManager can now open the server socket + on the port specified in the configuration file. + +common/NetworkSocket.h, common/NetworkSocket.cpp: + * Added functions for determining the IP address + of the remote machine to which a socket is + connected. + +------------------------------------------------- + 3 April 2009 - Jim Buchwald (This includes some other changes from between Modified: trunk/server/LogOutputStream.cpp =================================================================== --- trunk/server/LogOutputStream.cpp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/LogOutputStream.cpp 2009-04-05 02:01:04 UTC (rev 77) @@ -34,13 +34,13 @@ /* constructor */ LogOutputStream::LogOutputStream(const string &path) : FileOutputStream(path,false,true) { - + } /* destructor */ LogOutputStream::~LogOutputStream() { - + } /* write() method */ @@ -49,7 +49,7 @@ /* format the string */ string buf = (const char *)data; buf = formatString(buf); - + /* write the string to the log */ FileOutputStream::write((const unsigned char *)buf.c_str(), buf.length()); @@ -64,16 +64,17 @@ tm *curtime = localtime(&tmp); stringstream timestamp; if ( curtime->tm_mon < 10 ) timestamp << "0"; - timestamp << curtime->tm_mon << "/"; + timestamp << curtime->tm_mon + 1 << "/"; if ( curtime->tm_mday < 10 ) timestamp << "0"; - timestamp << curtime->tm_mday << " "; + timestamp << curtime->tm_mday << "/"; + timestamp << curtime->tm_year + 1900 << " "; if ( curtime->tm_hour < 10 ) timestamp << "0"; timestamp << curtime->tm_hour << ":"; if ( curtime->tm_min < 10 ) timestamp << "0"; timestamp << curtime->tm_min << ":"; if ( curtime->tm_sec < 10 ) timestamp << "0"; - timestamp << curtime->tm_sec << " "; - + timestamp << curtime->tm_sec << " - "; + /* put it all together */ timestamp << text; return timestamp.str(); Modified: trunk/server/PathBuilder.cpp =================================================================== --- trunk/server/PathBuilder.cpp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/PathBuilder.cpp 2009-04-05 02:01:04 UTC (rev 77) @@ -32,18 +32,14 @@ /* constructor */ PathBuilder::PathBuilder() { - + } /* log filepath */ string PathBuilder::LogFile(const string &name) { -#ifdef POSIX - /* temporary implementation for Linux */ - string retval("/var/log/arnacaw/"); - retval += name; + /* look up the log directory from the primary configuration file */ + string retval(AO_GETCONFIG().getField("Resources.LogPath")); + retval += name + ".log"; return retval; -#elif WIN32 - /* TODO: implement */ -#endif } Modified: trunk/server/Server.cbp =================================================================== --- trunk/server/Server.cbp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/Server.cbp 2009-04-05 02:01:04 UTC (rev 77) @@ -59,6 +59,7 @@ <Unit filename="../common/packets/ArnacawPackets.h" /> <Unit filename="../common/packets/SimplePacket.cpp" /> <Unit filename="../common/packets/SimplePacket.h" /> + <Unit filename="../configure.ac" /> <Unit filename="ArnacawServer.h" /> <Unit filename="CLIArgumentInterpreter.cpp" /> <Unit filename="CLIArgumentInterpreter.h" /> @@ -69,6 +70,7 @@ <Unit filename="ConfigFile.h" /> <Unit filename="ConnectedClient.cpp" /> <Unit filename="ConnectedClient.h" /> + <Unit filename="DefaultValues.h" /> <Unit filename="IPBanManager.h" /> <Unit filename="LogManager.cpp" /> <Unit filename="LogManager.h" /> Modified: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/Server.cpp 2009-04-05 02:01:04 UTC (rev 77) @@ -50,11 +50,11 @@ /* runs the application */ void ServerApplication::go(int argc, char **argv) { - /* set up messaging */ - initMessaging(); - /* set up needed resources */ - initLibraries(); + if ( !initLibraries() ) { + /* something went wrong, exit */ + return; + } /* initialize event system */ initEventSystem(); @@ -78,8 +78,14 @@ return; } + /* set up logging, etc. */ + initMessaging(); + /* initialize networking */ - initNetworking(); + if ( !initNetworking() ) { + /* fatal error while initializing the network */ + return; + } /* register self as an event handler */ EventDispatcher::getSingleton().registerHandler(this, EVENT_QUIT); @@ -105,22 +111,31 @@ /* clean up libraries */ cleanupLibraries(); - /* clean up messaging */ + /* clean up messaging (we do this out of order so that we can log shutdown errors) */ cleanupMessaging(); } /* initializes libraries */ -void ServerApplication::initLibraries() +bool ServerApplication::initLibraries() { /* HawkNL */ if ( nlInit() != NL_TRUE ) { - /* failed */ - stringstream s; + /* failed; logging is not yet up yet either, so use cout */ int err = nlGetError(); - s << "fatal error: failed to initialize HawkNL: " << nlGetErrorStr(err); - MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); - throw Exception("failed to initialize HawkNL"); - } + cout << "[FATAL ERROR] failed to initialize HawkNL: "; + cout << nlGetErrorStr(err) << endl; + return false; + } + if ( nlSelectNetwork(NL_IP) != NL_TRUE ) { + /* failed */ + int err = nlGetError(); + cout << "[FATAL ERROR] failed to initialize HawkNL: "; + cout << nlGetErrorStr(err) << endl; + return false; + } + + /* success */ + return true; } /* cleans up libraries */ @@ -348,16 +363,32 @@ } /* initializes networking */ -void ServerApplication::initNetworking() +bool ServerApplication::initNetworking() { /* set up the PacketFactory */ PacketFactory::getSingleton().buildInitialDatabase(); + + /* initialize the network manager */ + try { + network.Initialize(); + } + catch ( Exception &e ) + { + /* failed */ + cout << "[!] A fatal error has occured during network initialization." << endl; + cout << "[!] Please check the error log for more information." << endl; + return false; + } + + /* success */ + return true; } /* cleans up networking */ void ServerApplication::cleanupNetworking() { - + /* clean up the network manager */ + network.Cleanup(); } /* loads configuration files */ Modified: trunk/server/Server.h =================================================================== --- trunk/server/Server.h 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/Server.h 2009-04-05 02:01:04 UTC (rev 77) @@ -31,6 +31,9 @@ #ifndef __ARNACAW_SERVER_H__ #define __ARNACAW_SERVER_H__ + +/** Conveinence macro to retrieve the primary configuration file */ +#define AO_GETCONFIG() ServerApplication::getSingleton().getConfig() /** * Main application class for the Server component. @@ -61,7 +64,13 @@ * Checks if the program is running in debug mode. * @returns true if the program is running in debug mode */ - inline bool isDebugMode() { return issetBool("--debug"); } + inline bool isDebugMode() { return issetBool("--debug"); } + + /** + * Gets a handle to the configuration file. + * @return handle to the configuration file + */ + inline ConfigFile &getConfig() { return primary_cfg; } protected: /** protected as part of Singleton pattern */ @@ -69,12 +78,9 @@ /** * Initializes libraries used by the server. - * - * @throws Exception - * If a library fails to be initialized, an Exception will - * be thrown. + * @return true if successful, or false if a fatal error occurs. */ - void initLibraries(); + bool initLibraries(); /** * Initializes the messaging system, including logging services. @@ -83,8 +89,9 @@ /** * Initializes the networking system. + * @return true if successful, or false if a fatal error occurs. */ - void initNetworking(); + bool initNetworking(); /** * Cleans up the networking system. Modified: trunk/server/Server.layout =================================================================== --- trunk/server/Server.layout 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/Server.layout 2009-04-05 02:01:04 UTC (rev 77) @@ -7,12 +7,15 @@ <File name="../common/EventFactory.h" open="0" top="0" tabpos="0"> <Cursor position="474" topLine="0" /> </File> - <File name="../common/NetworkSocket.cpp" open="1" top="0" tabpos="2"> - <Cursor position="2908" topLine="46" /> + <File name="../common/MessageManager.h" open="1" top="0" tabpos="9"> + <Cursor position="2912" topLine="2" /> </File> - <File name="../common/NetworkSocket.h" open="0" top="0" tabpos="1"> - <Cursor position="1963" topLine="15" /> + <File name="../common/NetworkSocket.cpp" open="1" top="0" tabpos="4"> + <Cursor position="7106" topLine="216" /> </File> + <File name="../common/NetworkSocket.h" open="1" top="0" tabpos="5"> + <Cursor position="4977" topLine="153" /> + </File> <File name="../common/Packet.cpp" open="0" top="0" tabpos="2"> <Cursor position="3129" topLine="66" /> </File> @@ -46,40 +49,55 @@ <File name="../common/packets/SimplePacket.h" open="0" top="0" tabpos="8"> <Cursor position="2817" topLine="34" /> </File> - <File name="ArnacawServer.h" open="1" top="0" tabpos="5"> - <Cursor position="3123" topLine="45" /> + <File name="../configure.ac" open="0" top="0" tabpos="0"> + <Cursor position="973" topLine="19" /> </File> + <File name="ArnacawServer.h" open="0" top="0" tabpos="5"> + <Cursor position="3053" topLine="40" /> + </File> <File name="CLIArgumentInterpreter.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="60" /> + <Cursor position="1686" topLine="0" /> </File> - <File name="ChangeLog" open="1" top="0" tabpos="1"> - <Cursor position="549" topLine="0" /> + <File name="ChangeLog" open="1" top="0" tabpos="8"> + <Cursor position="1090" topLine="6" /> </File> - <File name="ConfigFile.cpp" open="1" top="1" tabpos="10"> - <Cursor position="2788" topLine="47" /> + <File name="ConfigFile.cpp" open="0" top="0" tabpos="10"> + <Cursor position="4953" topLine="126" /> </File> - <File name="ConfigFile.h" open="1" top="0" tabpos="9"> - <Cursor position="6047" topLine="138" /> + <File name="ConfigFile.h" open="0" top="0" tabpos="9"> + <Cursor position="1974" topLine="12" /> </File> + <File name="DefaultValues.h" open="0" top="0" tabpos="0"> + <Cursor position="2428" topLine="28" /> + </File> + <File name="LogManager.cpp" open="0" top="0" tabpos="0"> + <Cursor position="2472" topLine="29" /> + </File> <File name="LogManager.h" open="0" top="0" tabpos="0"> - <Cursor position="2531" topLine="30" /> + <Cursor position="2531" topLine="39" /> </File> - <File name="Makefile.am" open="1" top="0" tabpos="6"> - <Cursor position="742" topLine="0" /> + <File name="LogOutputStream.cpp" open="1" top="0" tabpos="1"> + <Cursor position="3043" topLine="46" /> </File> - <File name="Server.cpp" open="1" top="0" tabpos="7"> - <Cursor position="6904" topLine="238" /> + <File name="Makefile.am" open="0" top="0" tabpos="6"> + <Cursor position="877" topLine="0" /> </File> - <File name="Server.h" open="1" top="0" tabpos="3"> - <Cursor position="4527" topLine="125" /> + <File name="PathBuilder.cpp" open="0" top="0" tabpos="0"> + <Cursor position="2075" topLine="10" /> </File> - <File name="ServerNetworkManager.cpp" open="1" top="0" tabpos="8"> - <Cursor position="2054" topLine="19" /> + <File name="PathBuilder.h" open="0" top="0" tabpos="0"> + <Cursor position="2585" topLine="36" /> </File> - <File name="ServerNetworkManager.h" open="1" top="0" tabpos="4"> - <Cursor position="2794" topLine="37" /> + <File name="Server.cpp" open="1" top="0" tabpos="6"> + <Cursor position="3920" topLine="262" /> </File> - <File name="tinyxml/tinyxml.h" open="0" top="0" tabpos="0"> - <Cursor position="2682" topLine="75" /> + <File name="Server.h" open="1" top="0" tabpos="7"> + <Cursor position="3191" topLine="71" /> </File> + <File name="ServerNetworkManager.cpp" open="1" top="1" tabpos="2"> + <Cursor position="2906" topLine="60" /> + </File> + <File name="ServerNetworkManager.h" open="1" top="0" tabpos="3"> + <Cursor position="2918" topLine="49" /> + </File> </CodeBlocks_layout_file> Modified: trunk/server/ServerNetworkManager.cpp =================================================================== --- trunk/server/ServerNetworkManager.cpp 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/ServerNetworkManager.cpp 2009-04-05 02:01:04 UTC (rev 77) @@ -36,19 +36,60 @@ } /* initializes networking */ -void ServerNetworkManager::Initialize(uint8_t port) +void ServerNetworkManager::Initialize() { + /* check which port to listen on */ + int tmp = (uint16_t)AO_GETCONFIG().getIntField("Network.ServerPort"); + if ( tmp < 1 || tmp > 65535 ) { + /* invalid port */ + throw Exception("Server port is invalid (must be between 1 and 65535"); + } + uint16_t port = (uint16_t)tmp; + /* open the main socket */ + try { + main_socket.setServerMode(port); + } + catch ( Exception &e ) + { + /* failed; we're going to let something higher up handle this one */ + throw; + } } /* cleans up networking */ void ServerNetworkManager::Cleanup() { - + /* close the socket */ + main_socket.disconnect(); } /* called once per iteration of main loop */ void ServerNetworkManager::Cycle() { + /* accept a pending connection if there is one */ + acceptConnection(); +} +/* accepts a connection (if any) */ +void ServerNetworkManager::acceptConnection() +{ + /* accept a pending connection if there is one */ + try { + NetworkSocket *client = main_socket.acceptConnection(); + if ( client ) { + /* log the connection attempt */ + string msg = "new connection from " + client->getAddressStr(); + AO_POSTMESSAGE(msg,MSGP_GENERAL); + + /* TODO: Check IP address against list of banned IPs */ + + /* looks good, accept the connection */ + client_sockets.insert(client); + } + } + catch ( NonBlockingException &e ) + { + /* no connections pending, do nothing */ + } } Modified: trunk/server/ServerNetworkManager.h =================================================================== --- trunk/server/ServerNetworkManager.h 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/ServerNetworkManager.h 2009-04-05 02:01:04 UTC (rev 77) @@ -44,11 +44,10 @@ /** * Initializes server networking. - * The main action performed by this method - * is to open the server socket on the correct port. - * @param port port to listen on + * The main action performed by this method is to + * open the server socket on the correct port. */ - void Initialize(uint8_t port); + void Initialize(); /** * Shuts down server networking. @@ -73,9 +72,16 @@ /** Main server socket */ NetworkSocket main_socket; - /** Child sockets */ - set<NetworkSocket*> child_sockets; + /** Client sockets */ + set<NetworkSocket*> client_sockets; + /** + * Accepts a pending connection (if any). + * Also logs the connection and checks it against + * the list of banned IP addresses. + */ + void acceptConnection(); + }; #endif Modified: trunk/server/config/default.cfg =================================================================== --- trunk/server/config/default.cfg 2009-04-04 14:12:16 UTC (rev 76) +++ trunk/server/config/default.cfg 2009-04-05 02:01:04 UTC (rev 77) @@ -28,6 +28,9 @@ # Linux: /var/log/arnacawd/ # #Resources.LogPath=/var/log/arnacawd/ +# +# Another value for this that could be useful for development: +Resources.LogPath=./logs/ # # Resources.DataPath=<string> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-04-04 14:12:21
|
Revision: 76 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=76&view=rev Author: shoyru Date: 2009-04-04 14:12:16 +0000 (Sat, 04 Apr 2009) Log Message: ----------- added configuration file stuff, started some more networking stuff Modified Paths: -------------- trunk/common/ArnacawCommon.h trunk/common/NetworkSocket.cpp trunk/common/NetworkSocket.h trunk/common/PacketFactory.h trunk/server/ArnacawServer.h trunk/server/ChangeLog trunk/server/Makefile.am trunk/server/PathBuilder.h trunk/server/Server.cbp trunk/server/Server.cpp trunk/server/Server.h trunk/server/Server.layout Added Paths: ----------- trunk/server/ConfigFile.cpp trunk/server/ConfigFile.h trunk/server/DefaultValues.h trunk/server/ServerNetworkManager.cpp trunk/server/ServerNetworkManager.h trunk/server/config/ trunk/server/config/default.cfg Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/common/ArnacawCommon.h 2009-04-04 14:12:16 UTC (rev 76) @@ -77,8 +77,10 @@ #include <map> #include <list> #include <queue> -#include <set> -#include <stdint.h> +#include <set> +#include <vector> +#include <stdint.h> +#include <stdio.h> #ifdef HAVE_UNISTD_H #ifndef POSIX Modified: trunk/common/NetworkSocket.cpp =================================================================== --- trunk/common/NetworkSocket.cpp 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/common/NetworkSocket.cpp 2009-04-04 14:12:16 UTC (rev 76) @@ -33,7 +33,7 @@ /* default constructor */ NetworkSocket::NetworkSocket() { - + } /* wrapper constructor */ @@ -45,7 +45,7 @@ /* destructor */ NetworkSocket::~NetworkSocket() { - + } /* sets client behavior */ @@ -135,7 +135,7 @@ MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); throw Exception(s.str()); } - + /* connect */ if ( nlConnect(wrapped_socket, &addr) == NL_FALSE ) { /* error */ @@ -153,8 +153,19 @@ nlClose(wrapped_socket); } +/* accepts and wraps a connection */ +NetworkSocket *NetworkSocket::acceptConnection() +{ + /* try to accept a connection; if an Exception of + some sort comes out of this, just let it ascend */ + NLsocket toWrap = acceptLowerConnection(); + + /* wrap the connection */ + return NetworkSocketFactory::getSingleton().createSocket(toWrap); +} + /* accepts a connection */ -NLsocket NetworkSocket::acceptConnection() +NLsocket NetworkSocket::acceptLowerConnection() { /* try to accept a connection */ NLsocket retval = nlAcceptConnection(wrapped_socket); @@ -168,8 +179,35 @@ MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); throw Exception(s.str()); } - + /* got a connection */ /* TODO: Check for banned IP */ return retval; } + +/* default constructor for NetworkSocketFactory */ +NetworkSocketFactory::NetworkSocketFactory() +{ + +} + +/* allocates a NetworkSocket */ +NetworkSocket *NetworkSocketFactory::createSocket(NLsocket sck) +{ + return new NetworkSocket(sck); +} + +/* releases a NetworkSocket */ +void NetworkSocketFactory::releaseSocket(NetworkSocket *sck) +{ + /* validity check */ + if ( !sck ) { + string err = "NULL pointer passed to NetworkSocketFactory::" + "releaseSocket()"; + MessageManager::getSingleton().postMessage(err, MSGP_DEBUG); + throw Exception(err); + } + + /* release the socket */ + delete sck; +} Modified: trunk/common/NetworkSocket.h =================================================================== --- trunk/common/NetworkSocket.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/common/NetworkSocket.h 2009-04-04 14:12:16 UTC (rev 76) @@ -66,9 +66,10 @@ NetworkSocket(); /** - * Creates a wrapper around an existing HawkNL socket. + * Creates a wrapper around an existing HawkNL socket. + * @param sck HawkNL socket to wrap */ - NetworkSocket(NLsocket socket); + NetworkSocket(NLsocket sck); /* destructor */ virtual ~NetworkSocket(); @@ -79,8 +80,6 @@ /* writes to the socket */ virtual int write(const unsigned char *buf, int len); - - /** * Configures the socket for client behavior. * This opens the socket on a random port and does not listen. @@ -90,7 +89,7 @@ * If an error occurs, an Exception will be thrown. */ void setClientMode(); - + /** * Configures the socket for server behavior. * This opens the socket on a given port and listens for connections. @@ -99,7 +98,7 @@ * If an error occurs, an Exception will be thrown. */ void setServerMode(uint16_t port); - + /** * Connects the socket to a remote machine. * @param address Address of remote machine @@ -108,26 +107,87 @@ * If an error occurs, an Exception will be thrown. */ void connect(const string &address, uint16_t port); - + /** * Disconnects the socket. */ - void disconnect(); - - /** - * Accepts a connection if one is pending. - * @throws NonBlockingException - * If no connections were pending, a NonBlockingException will be thrown. - * @throws Exception - * If setServerMode() has not been called, an Exception will be thrown. - * @returns A connected socket. - */ - NLsocket acceptConnection(); + void disconnect(); + + /** + * Accepts a connection if one is pending, and wraps + * the connected socket in another NetworkSocket object. + * The returned socket should be freed with a call to + * NetworkSocketFactory::releaseSocket(). + * @throws NonBlockingException + * If no connections were pending, a NonBlockingException will be thrown. + * @throws Exception + * If setServerMode() has not been called, an Exception will be thrown. + * @returns A connected socket. + */ + NetworkSocket *acceptConnection(); -protected: +protected: + /** + * Accepts a connection if one is pending. + * This function does not wrap the new socket. + * @throws NonBlockingException + * If no connections were pending, a NonBlockingException will be thrown. + * @throws Exception + * If setServerMode() has not been called, an Exception will be thrown. + * @returns A connected socket. + */ + NLsocket acceptLowerConnection(); + /** Wrapped socket */ NLsocket wrapped_socket; }; + +/** + * Provides memory management for <b>some</b> + * NetworkSocket objects. This is only used + * for child sockets of server sockets, namely + * those returned by NetworkSocket::acceptConnection(). + * @brief Manages server child sockets + * @ingroup Common + */ +class NetworkSocketFactory : public Singleton<NetworkSocketFactory> +{ +public: + friend class Singleton<NetworkSocketFactory>; + friend class NetworkSocket; + + /** + * Releases a socket allocated by the factory. + * @warn This method does not check if a socket + * was allocated by the factory. Ensure + * that sockets allocated elsewhere are not + * passed to this method. + * @param sck socket to free + * @throw Exception + * If a NULL pointer is passed, an Exception + * will be thrown. + */ + void releaseSocket(NetworkSocket *sck); + +protected: + /** + * The default constructor is protected in + * order to implement the Singleton design + * pattern. + */ + NetworkSocketFactory(); + + /** + * Allocates a new NetworkSocket that wraps + * a pre-existing lower level socket. This + * method is protected so that it may only be + * called from within the NetworkSocket class. + * @param sck socket to wrap + * @return A newly allocated NetworkSocket + */ + NetworkSocket *createSocket(NLsocket sck); + +}; #endif Modified: trunk/common/PacketFactory.h =================================================================== --- trunk/common/PacketFactory.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/common/PacketFactory.h 2009-04-04 14:12:16 UTC (rev 76) @@ -42,15 +42,15 @@ { public: /** - * Creates an object. + * Creates a packet. * @throws Exception - * @returns A new object. + * @returns A new packet. */ virtual Packet *create()=0; /** - * Destroys an object. - * @param obj Object to destroy + * Destroys a packet. + * @param pkt Packet to destroy * @throws Exception */ virtual void destroy(Packet *pkt)=0; Modified: trunk/server/ArnacawServer.h =================================================================== --- trunk/server/ArnacawServer.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/ArnacawServer.h 2009-04-04 14:12:16 UTC (rev 76) @@ -36,11 +36,6 @@ #ifndef __ARNACAW_SERVER_BIGHEADER_H__ #define __ARNACAW_SERVER_BIGHEADER_H__ -/* Miscellaneous configuration values */ - -/** Default port for server to listen on. */ -#define AO_DEFAULT_PORT 9462 - /* Version information */ #define PRODUCT_NAME "Arnacaw Online Server" #define MAJOR_VERSION 0 @@ -65,10 +60,13 @@ "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA." /* Common component */ -#include "ArnacawCommon.h" +#include "ArnacawCommon.h" -/* Server component */ -#include "CLIArgumentInterpreter.h" +/* Server component */ +#include "DefaultValues.h" +#include "ConfigFile.h" +#include "CLIArgumentInterpreter.h" +#include "ServerNetworkManager.h" #include "Server.h" #include "LogOutputStream.h" #include "LogManager.h" Modified: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/ChangeLog 2009-04-04 14:12:16 UTC (rev 76) @@ -8,6 +8,92 @@ ------------------------------------------------- +3 April 2009 - Jim Buchwald + +(This includes some other changes from between + the last update and this one that I forgot to log.) + +server/ConfigFile.cpp: + * Finish implementing the ConfigFile class. + +server/Server.h, server/Server.cpp: + * Integrate primary configuration file + * Move command line argument processing earlier + in the startup process to fix a bug where a + nonexistant configuration file would result + in the information arguments (--help, etc.) + not working. + * Add some diagnostic information to the version + information printout for Linux builds. Prints + compile-time options (for right now, this just + means the default datadir). + * Fix bug where some information arguments would + not cause the program to exit. + +server/config/default.cfg: + * Create a basic default configuration file for + the server with documentation. Added 3 values: + Resources.LogPath, Resources.DataPath, + Network.ServerPort + +------------------------------------------------- + +8 March 2009 - Jim Buchwald + +Undid all of the TinyXML stuff from yesterday. +Decided that XML was needlessly complex for +configuration files. + +------------------------------------------------- + +7 March 2009 - Jim Buchwald + +server/Makefile.am: + * Add source files for the TinyXML + library used by the server. The + library is built directly into + the server rather than linked. + +server/ArnacawServer.h: + * Include the header for the TinyXML + library. Also include ConfigFile.h. + +server/ConfigFile.h, server/ConfigFile.cpp: + * Define and begin implementing the + ConfigFile class using the TinyXML + library. + +common/ArnacawCommon.h: + * Include stdio.h. + +------------------------------------------------- + +6 March 2009 - Jim Buchwald + +common/NetworkSocket.h, common/NetworkSocket.cpp: + * Modify the acceptConnection() method + to make it actually useful. + * Add the NetworkSocketFactory class to + assist in the new implementation of + acceptConnection(). + +server/ServerNetworkManager.h, server/ServerNetworkManager.cpp: + * Define the ServerNetworkManager class. + +common/PacketFactory.h: + * Fix typos in comments. + +server/Server.h, server/Server.cpp: + * Add a 1ms sleep cycle to each iteration + of the main loop so that the server shares + processor resources nicely. + +server/Makefile.am: + * Add ServerNetworkManager.cpp to the build + process. + +------------------------------------------------- + 5 March 2009 - Jim Buchwald Lots of fixes to the packet files. Added: trunk/server/ConfigFile.cpp =================================================================== --- trunk/server/ConfigFile.cpp (rev 0) +++ trunk/server/ConfigFile.cpp 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,242 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ConfigFile.cpp + * @ingroup Server + * Implements the ConfigFile class, which parses and + * stores values from a configuration file. It can + * also store configuration values to a file. + * @brief ConfigFile class + */ + +#include "ArnacawServer.h" + +/* look how complicated the exception is! */ +ConfigFileException::ConfigFileException(const string &r) : Exception(r) +{ + +} + +/* default constructor */ +ConfigFile::ConfigFile() : last_filename("") +{ + +} + +/* load constructor */ +ConfigFile::ConfigFile(const string &filename) +{ + load(filename); +} + +/* loads and parses a file */ +void ConfigFile::load(const string &filename) +{ + /* attempt to open the file */ + ifstream cfgfile(filename.c_str()); + if ( cfgfile.fail() || cfgfile.bad() ) { + /* failed */ + string err = "failed to open file in ConfigFile::load(): "; + err += filename; + MessageManager::getSingleton().postMessage(err,MSGP_ERROR); + throw ConfigFileException(err); + } + + last_filename = filename; + + /* begin parsing the file */ + string curline; + int lineno=0; + while ( 1 ) + { + /* read the next line of the file */ + getline(cfgfile,curline); + if ( cfgfile.eof() ) break; + if ( cfgfile.fail() || cfgfile.bad() ) { + /* failed */ + string err = "file I/O error in ConfigFile::load(\""; + err += filename + "\")"; + MessageManager::getSingleton().postMessage(err,MSGP_ERROR); + throw ConfigFileException(err); + } + + /* check if line is a comment */ + if ( curline[0] == AO_CONFIG_COMMENT || curline.length() == 0 ) { + /* comment or empty line */ + continue; + } + + /* parse the configuration pair */ + parseConfigPair(curline,lineno); + + lineno++; + } +} + +/* loads and parses the last file */ +void ConfigFile::load() +{ + /* check if a file has been referenced */ + if ( last_filename.length() == 0 ) { + throw Exception("Unused ConfigFile object asked to load " + "last referenced file."); + } + + /* load */ + load(last_filename); +} + +/* saves a configuration file */ +void ConfigFile::save(const string &filename) +{ + +} + +/* saves to the last referenced file */ +void ConfigFile::save() +{ + /* check if a file has been referenced */ + if ( last_filename.length() == 0 ) { + throw Exception("Unused ConfigFile object asked to save " + "to last referenced file."); + } + + /* save */ + save(last_filename); +} + +/* checks if a field exists */ +bool ConfigFile::fieldExists(const string &name) +{ + return (bool)fields.count(name); +} + +/* gets configuration value by name */ +string ConfigFile::getField(const string &name) +{ + /* check if a value exists with the given name */ + if ( !fieldExists(name) ) { + /* field does not exist */ + string err = "ConfigFile: attempted to getValue() of " + "nonexistant field " + name; + MessageManager::getSingleton().postMessage(err, MSGP_WARN); + throw Exception(err); + } + + /* return value */ + return fields[name]; +} + +/* parses a single configuration pair */ +void ConfigFile::parseConfigPair(const string &pair, int line) +{ + /* split the pair into name and value */ + int split = pair.find(AO_CONFIG_DELIM); + if ( split == string::npos ) { + /* syntax error */ + stringstream error; + error << "no value found "; + if ( line >= 0 ) { + error << "at line " << line << " of"; + } else { + error << " in"; + } + error << " file " << last_filename << "."; + throw ConfigFileException(error.str()); + } + string name = pair.substr(0,split); + string value = pair.substr(split+1); + + /* store */ + setField(name, value); +} + +/* sets a configuration value */ +void ConfigFile::setField(const string &name, const string &value) +{ + /* if it exists, we overwrite it */ + fields[name] = value; +} + +/* gets a configuration value as int */ +int ConfigFile::getIntField(const string &name) +{ + /* + * attempt to get the field in string form. + * if it doesn't exist, let the Exception proceed + */ + string base = getField(name); + + /* convert to integer and return */ + int retval=0; + stringstream tmp(base); + tmp >> retval; + return retval; +} + +/* gets a configuration value as float */ +float ConfigFile::getFloatField(const string &name) +{ + /* + * attempt to get the field in string form. + * if it doesn't exist, let the Exception proceed + */ + string base = getField(name); + + /* convert to float and return */ + float retval=0; + stringstream tmp(base); + tmp >> retval; + return retval; +} + +/* gets a configuration value as double */ +double ConfigFile::getDoubleField(const string &name) +{ + /* + * attempt to get the field in string form. + * if it doesn't exist, let the Exception proceed + */ + string base = getField(name); + + /* convert to double and return */ + double retval=0; + stringstream tmp(base); + tmp >> retval; + return retval; +} + +/* gets a configuration value as boolean */ +bool ConfigFile::getBoolField(const string &name) +{ + /* + * attempt to get the field in string form. + * if it doesn't exist, let the Exception proceed + */ + string base = getField(name); + + /* convert to boolean and return */ + bool retval=0; + stringstream tmp(base); + tmp >> retval; + return retval; +} Added: trunk/server/ConfigFile.h =================================================================== --- trunk/server/ConfigFile.h (rev 0) +++ trunk/server/ConfigFile.h 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,236 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ConfigFile.h + * @ingroup Server + * Defines the ConfigFile class, which parses and + * stores values from a configuration file. It can + * also store configuration fields to a file. + * @brief ConfigFile class + */ + +#ifndef __ARNACAW_CONFIGFILE_H__ +#define __ARNACAW_CONFIGFILE_H__ + +/** Delimiter to separate field names from their associated values. */ +#define AO_CONFIG_DELIM 0x3D + +/** Character that indicates that a line is a comment. */ +#define AO_CONFIG_COMMENT 0x23 + +/** + * Special type of Exception for handling errors that occur + * during the parsing of configuration files. These are not + * thrown if a value does not exist when a lookup is performed; + * rather, they apply to file I/O and syntax errors during the + * act of parsing the configuration files. + * @brief Config file syntax error + * @ingroup Server + */ +class ConfigFileException : public Exception +{ +public: + ConfigFileException(const string &r); +}; + +/** + * Parses and stores values from a configuration file. + * @par Internal Value Naming Conventions + * Values are named and can be accessed through a dot-separated + * list of names starting with the parent tag and descending to + * the final tag; eg. "config.main.field1". Such a field would + * appear in a configuration file as "config.main.field1 = value" + * @brief Loads config files + * @ingroup Server + */ +class ConfigFile +{ +public: + /** + * Creates an empty object with no parsed values. + */ + ConfigFile(); + + /** + * Creates a ConfigFile object from a given file, + * parsing all available data within the file. + * @param filename Config file to load and parse + * @throw Exception + * If an invalid or nonexistant filename is passed, + * an Exception will be thrown. + */ + ConfigFile(const string &filename); + + /** + * Loads and parses a configuration file. + * @note If values have already been set, they will + * be overwritten by this function if the + * configuration file defines them. + * @param filename Config file to load and parse + * @throw Exception + * If an invalid or nonexistant filename is passed, + * an Exception will be thrown. + */ + void load(const string &filename); + + /** + * Loads and parses the last configuration file + * referenced by this object. + * @note If values have already been set, they will + * be overwritten by this function if the + * configuration file defines them. + * @throw Exception + * If no configuration file has been referenced, + * or if the configuration file is now invalid, + * an Exception will be thrown. + */ + void load(); + + /** + * Saves a configuration file. + * @param filename Config file to store to + * @throw Exception + * If an invalid filename is passed, an Exception + * will be thrown. + */ + void save(const string &filename); + + /** + * Saves the last configuration file referenced + * by this object. + * @throw Exception + * If no configuration file has been referenced, + * or if the configuration file is now invalid, + * an Exception will be thrown. + */ + void save(); + + /** + * Checks if a given configuration field exists. + * @param name Name of field to check + * @return true if the field exists; false otherwise. + */ + bool fieldExists(const string &name); + + /** + * Gets a configuration field by name. + * @note This function only returns values + * as strings; other functions should + * be used to convert the data to the + * appropriate format. + * @param name Name of value to get + * @throw Exception + * If the requested value is not found, an + * Exception will be thrown. + * @return The value as a string. + */ + string getField(const string &name); + + /** + * Gets an integer configuration field by name. + * @param name Name of value to get + * @throw Exception + * If the requested value is not found, or + * if it is not an integer, an Exception will + * be thrown. + * @return The value as an integer. + */ + int getIntField(const string &name); + + /** + * Gets a float configuration field by name. + * @param name Name of value to get + * @throw Exception + * If the requested value is not found, or + * if it is not a floating-point, an Exception + * will be thrown. + * @return The value as a floating-point. + */ + float getFloatField(const string &name); + + /** + * Gets a double configuration field by name. + * @param name Name of value to get + * @throw Exception + * If the requested value is not found, or + * if it is not a double, an Exception will + * be thrown. + * @return The value as a double. + */ + double getDoubleField(const string &name); + + /** + * Gets a boolean configuration value by name. + * @param name Name of value to get + * @throw Exception + * If the requested value is not found, or + * if it is not a double, an Exception will + * be thrown. + * @return The value as a double. + */ + bool getBoolField(const string &name); + + /** + * Sets a configuration field by name. + * @note This function only accepts values + * as strings; other functions should + * be used to convert the data to the + * appropriate format. + * @param name Name of value to set + * @param value New value + */ + void setField(const string &name, const string &value); + + /** + * Removes a field by name. + * @param name Name of value to remove + * @throw Exception + * If the requested value is not found, an + * Exception will be thrown. + */ + void removeField(const string &name); + + /** + * Removes all values. + */ + void clearField(); + +protected: + /** Currently loaded fields */ + map<string,string> fields; + + /** Last used filename */ + string last_filename; + + /** + * Parses an individual configuration pair. + * @param pair Configuration pair to parse + * @param line Line in file (optional, used for error messages) + * @throw ConfigFileException + * If the configuration pair is invalid, a ConfigFileException + * will be thrown. + */ + void parseConfigPair(const string &pair, int line=-1); + +}; + +#endif Added: trunk/server/DefaultValues.h =================================================================== --- trunk/server/DefaultValues.h (rev 0) +++ trunk/server/DefaultValues.h 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,63 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file DefaultValues.h + * @ingroup Server + * Defines default configuration values. + * @brief Default configuration values + */ + +#ifndef __ARNACAW_DEFAULTVALUES_H__ +#define __ARNACAW_DEFAULTVALUES_H__ + +/* + * All default configuration values should be set as strings. + * This is because the ConfigFile class only converts values + * to their respective types on demand. + */ + +#ifdef WIN32 + /* Windows default values */ + + /* Directory in which logs are stored */ + #define AO_DEFAULT_LOGDIR "C:/Program Files/Arnacaw Server/logs/" + + /* Directory in which data is stored */ + #define AO_DEFAULT_DATADIR "C:/Program Files/Arnacaw Server/data/" + +#else + /* Linux default values */ + + /* Directory in which logs are stored */ + #define AO_DEFAULT_LOGDIR "/var/log/arnacawd/" + + /* Directory in which data is stored */ + #define AO_DEFAULT_DATADIR DATA_ROOT + +#endif + +/* Platform-independent default values */ + +/* Default port on which the server runs */ +#define AO_DEFAULT_PORT "12078" + +#endif Modified: trunk/server/Makefile.am =================================================================== --- trunk/server/Makefile.am 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/Makefile.am 2009-04-04 14:12:16 UTC (rev 76) @@ -12,6 +12,8 @@ LogManager.cpp \ PathBuilder.cpp \ ConnectedClient.cpp \ + ServerNetworkManager.cpp \ + ConfigFile.cpp \ ../common/Packet.cpp \ ../common/NetworkSocket.cpp \ ../common/MessageManager.cpp \ @@ -22,5 +24,7 @@ ../common/PacketType.cpp \ ../common/packets/SimplePacket.cpp -arnacawd_CPPFLAGS = -I../common -I../common/packets -DINSTALL_ROOT=\"@prefix@\" +arnacawd_CPPFLAGS = -I../common -I../common/packets \ + -DINSTALL_ROOT=\"@prefix@\" \ + -DDATA_ROOT=\"@localstatedir@/arnacawd/\" arnacawd_LDADD = $(LIBS) Modified: trunk/server/PathBuilder.h =================================================================== --- trunk/server/PathBuilder.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/PathBuilder.h 2009-04-04 14:12:16 UTC (rev 76) @@ -22,11 +22,9 @@ /** * @file PathBuilder.h * @ingroup Server - * - * @brief PathBuilder class - * * Defines the PathBuilder class, which creates absolute * filepaths at runtime. + * @brief PathBuilder class */ #ifndef __ARNACAW_PATHBUILDER_H__ @@ -50,7 +48,7 @@ * Generates a path to a log file. * @param name * Name of the log file - * @returns an absolute path to the log file. + * @return an absolute path to the log file. * * @internal * The current implementation is temporary. @@ -59,7 +57,7 @@ * from a configuration file. */ string LogFile( const string &name ); - + protected: /** * Do not create objects of this class directly. @@ -67,7 +65,7 @@ * methods instead. */ PathBuilder(); - + }; #endif Modified: trunk/server/Server.cbp =================================================================== --- trunk/server/Server.cbp 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/Server.cbp 2009-04-04 14:12:16 UTC (rev 76) @@ -65,6 +65,8 @@ <Unit filename="ChangeLog" /> <Unit filename="ClientManager.cpp" /> <Unit filename="ClientManager.h" /> + <Unit filename="ConfigFile.cpp" /> + <Unit filename="ConfigFile.h" /> <Unit filename="ConnectedClient.cpp" /> <Unit filename="ConnectedClient.h" /> <Unit filename="IPBanManager.h" /> @@ -78,6 +80,8 @@ <Unit filename="Server.cpp" /> <Unit filename="Server.h" /> <Unit filename="ServerMain.cpp" /> + <Unit filename="ServerNetworkManager.cpp" /> + <Unit filename="ServerNetworkManager.h" /> <Extensions> <code_completion /> <debugger /> Modified: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/Server.cpp 2009-04-04 14:12:16 UTC (rev 76) @@ -59,6 +59,25 @@ /* initialize event system */ initEventSystem(); + /* get command line arguments */ + setupCmdLineArguments(); + if ( !getCmdLineArguments(argc, argv) ) { + /* bad arguments, exit */ + return; + } + + /* handle information arguments */ + if ( !checkInformationArguments() ) { + /* time to exit */ + return; + } + + /* load initial configuration settings */ + if ( !loadConfig() ) { + /* fatal error while loading config */ + return; + } + /* initialize networking */ initNetworking(); @@ -68,19 +87,6 @@ /* hook the signals */ hookSignals(); - /* get command line arguments */ - setupCmdLineArguments(); - if ( !getCmdLineArguments(argc, argv) ) { - /* bad arguments, exit */ - return; - } - - /* handle information arguments */ - if ( !checkInformationArguments() ) { - /* time to exit */ - return; - } - #ifdef POSIX /* run in daemon mode? */ if ( cmd_args.IsArgumentStored("--daemon") ) { @@ -115,9 +121,6 @@ MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); throw Exception("failed to initialize HawkNL"); } - stringstream buf; - buf << "Loaded HawkNL: " << nlGetString(NL_VERSION); - MessageManager::getSingleton().postMessage(buf.str(), MSGP_ERROR); } /* cleans up libraries */ @@ -158,7 +161,12 @@ cmd_args.AddArgument("-sU", "Uninstall NT service with given name", CMDARG_STRING); -#endif +#endif + + /* SECTION 3: Initial Configuration */ + cmd_args.AddArgument("--cfgfile", + "Primary configuration file to use", + CMDARG_STRING); } /* gets command line arguments */ @@ -194,14 +202,21 @@ if ( cmd_args.GetBooleanValue("--version") ) { /* show version information and exit */ cout << PRODUCT_NAME << " v" << RELEASE_VERSION << endl << endl; - cout << "Copyright (c) 2008 James Buchwald" << endl << endl; - cout << LICENSE_INFO << endl << endl; + cout << "Copyright (c) 2009 James Buchwald" << endl << endl; + cout << LICENSE_INFO << endl << endl; + #ifndef WIN32 + cout << "Compile Time Options:" << endl; + cout << "\tdefault datadir = " << AO_DEFAULT_DATADIR << endl; + cout << endl; + #endif + return false; } /* show license information? */ if ( cmd_args.GetBooleanValue("--license") ) { /* show license information and exit */ - cout << LICENSE_INFO << endl << endl; + cout << LICENSE_INFO << endl << endl; + return false; } /* do not exit */ @@ -242,7 +257,8 @@ void ServerApplication::mainLoop() { /* announce startup */ - MessageManager::getSingleton().postMessage("*** Server startup", MSGP_GENERAL); + MessageManager::getSingleton().postMessage("*** Server startup", MSGP_GENERAL); + /* enter loop */ while (1) { /* check if we need to quit */ @@ -251,10 +267,16 @@ /* quit */ break; - } + } + + /* poll the network */ + network.Cycle(); /* run the event dispatcher */ - EventDispatcher::getSingleton().dispatch(); + EventDispatcher::getSingleton().dispatch(); + + /* share the processor */ + napTime(); } /* announce shutdown */ MessageManager::getSingleton().postMessage("*** Server shutdown", MSGP_GENERAL); @@ -337,3 +359,40 @@ { } + +/* loads configuration files */ +bool ServerApplication::loadConfig() +{ + /* determine location of primary config file */ + string cfgpath; + if ( !cmd_args.IsArgumentStored("--cfgfile") ) { + /* default path */ + #ifdef WIN32 + cfgpath = "C:/Program Files/Arnacaw Server/config/arnacaw.cfg"; + #else + cfgpath = "/etc/arnacawd/arnacaw.cfg"; + #endif + } + else + { + /* get path from command line argument */ + cfgpath = cmd_args.GetStringValue("--cfgfile"); + } + + /* set up default values */ + primary_cfg.setField("Resources.LogPath",AO_DEFAULT_LOGDIR); + primary_cfg.setField("Resources.DataPath",AO_DEFAULT_DATADIR); + primary_cfg.setField("Network.ServerPort",AO_DEFAULT_PORT); + + /* attempt to load primary config file */ + try { + primary_cfg.load(cfgpath); + } catch ( ConfigFileException &e ) { + /* failed; logging isn't up yet, so dump to console */ + cout << "[FATAL ERROR] " << e.getReason() << endl; + return false; + } + + /* success */ + return true; +} Modified: trunk/server/Server.h =================================================================== --- trunk/server/Server.h 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/Server.h 2009-04-04 14:12:16 UTC (rev 76) @@ -99,7 +99,13 @@ /** * Cleans up libraries used by the server. */ - void cleanupLibraries(); + void cleanupLibraries(); + + /** + * Loads the initial primary configuration files and stuff like that. + * @return true on success, false on (fatal) error + */ + bool loadConfig(); /** * Sets up allowed command line arguments. @@ -130,7 +136,19 @@ /** * Main loop. */ - void mainLoop(); + void mainLoop(); + + /** + * Takes a nice little nap. + */ + inline void napTime() + { + #ifdef POSIX + usleep(1000); + #else + Sleep(1); + #endif + } /** * Intializes the event systems. @@ -147,7 +165,13 @@ void notify(Event *event); /** Stores command line arguments */ - CLIArgumentInterpreter cmd_args; + CLIArgumentInterpreter cmd_args; + + /** Manages network resources. */ + ServerNetworkManager network; + + /** Primary configuration file. */ + ConfigFile primary_cfg; /** Flags the main loop to terminate. */ bool time_to_quit; Modified: trunk/server/Server.layout =================================================================== --- trunk/server/Server.layout 2009-03-06 21:26:52 UTC (rev 75) +++ trunk/server/Server.layout 2009-04-04 14:12:16 UTC (rev 76) @@ -2,14 +2,17 @@ <CodeBlocks_layout_file> <ActiveTarget name="Release" /> <File name="../common/ArnacawCommon.h" open="0" top="0" tabpos="6"> - <Cursor position="4120" topLine="86" /> + <Cursor position="3254" topLine="54" /> </File> <File name="../common/EventFactory.h" open="0" top="0" tabpos="0"> <Cursor position="474" topLine="0" /> </File> - <File name="../common/NetworkSocket.h" open="1" top="0" tabpos="1"> - <Cursor position="1653" topLine="21" /> + <File name="../common/NetworkSocket.cpp" open="1" top="0" tabpos="2"> + <Cursor position="2908" topLine="46" /> </File> + <File name="../common/NetworkSocket.h" open="0" top="0" tabpos="1"> + <Cursor position="1963" topLine="15" /> + </File> <File name="../common/Packet.cpp" open="0" top="0" tabpos="2"> <Cursor position="3129" topLine="66" /> </File> @@ -20,7 +23,7 @@ <Cursor position="3514" topLine="59" /> </File> <File name="../common/PacketFactory.h" open="0" top="0" tabpos="12"> - <Cursor position="4948" topLine="78" /> + <Cursor position="2232" topLine="33" /> </File> <File name="../common/PacketQueue.cpp" open="0" top="0" tabpos="4"> <Cursor position="3665" topLine="40" /> @@ -43,19 +46,40 @@ <File name="../common/packets/SimplePacket.h" open="0" top="0" tabpos="8"> <Cursor position="2817" topLine="34" /> </File> - <File name="ChangeLog" open="1" top="1" tabpos="2"> - <Cursor position="505" topLine="0" /> + <File name="ArnacawServer.h" open="1" top="0" tabpos="5"> + <Cursor position="3123" topLine="45" /> </File> + <File name="CLIArgumentInterpreter.h" open="0" top="0" tabpos="0"> + <Cursor position="0" topLine="60" /> + </File> + <File name="ChangeLog" open="1" top="0" tabpos="1"> + <Cursor position="549" topLine="0" /> + </File> + <File name="ConfigFile.cpp" open="1" top="1" tabpos="10"> + <Cursor position="2788" topLine="47" /> + </File> + <File name="ConfigFile.h" open="1" top="0" tabpos="9"> + <Cursor position="6047" topLine="138" /> + </File> <File name="LogManager.h" open="0" top="0" tabpos="0"> <Cursor position="2531" topLine="30" /> </File> - <File name="Makefile.am" open="0" top="0" tabpos="10"> - <Cursor position="686" topLine="0" /> + <File name="Makefile.am" open="1" top="0" tabpos="6"> + <Cursor position="742" topLine="0" /> </File> - <File name="Server.cpp" open="0" top="0" tabpos="13"> - <Cursor position="3191" topLine="31" /> + <File name="Server.cpp" open="1" top="0" tabpos="7"> + <Cursor position="6904" topLine="238" /> </File> - <File name="Server.h" open="0" top="0" tabpos="14"> - <Cursor position="2972" topLine="0" /> + <File name="Server.h" open="1" top="0" tabpos="3"> + <Cursor position="4527" topLine="125" /> </File> + <File name="ServerNetworkManager.cpp" open="1" top="0" tabpos="8"> + <Cursor position="2054" topLine="19" /> + </File> + <File name="ServerNetworkManager.h" open="1" top="0" tabpos="4"> + <Cursor position="2794" topLine="37" /> + </File> + <File name="tinyxml/tinyxml.h" open="0" top="0" tabpos="0"> + <Cursor position="2682" topLine="75" /> + </File> </CodeBlocks_layout_file> Added: trunk/server/ServerNetworkManager.cpp =================================================================== --- trunk/server/ServerNetworkManager.cpp (rev 0) +++ trunk/server/ServerNetworkManager.cpp 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,54 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ServerNetworkManager.cpp + * @ingroup Server + * @brief ServerNetworkManager class + * Contains the implementation of the ServerNetworkManager + * class, which manages server-side network resources. + */ + +#include "ArnacawServer.h" + +/* default constructor */ +ServerNetworkManager::ServerNetworkManager() +{ + +} + +/* initializes networking */ +void ServerNetworkManager::Initialize(uint8_t port) +{ + +} + +/* cleans up networking */ +void ServerNetworkManager::Cleanup() +{ + +} + +/* called once per iteration of main loop */ +void ServerNetworkManager::Cycle() +{ + +} Added: trunk/server/ServerNetworkManager.h =================================================================== --- trunk/server/ServerNetworkManager.h (rev 0) +++ trunk/server/ServerNetworkManager.h 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,81 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ServerNetworkManager.h + * @ingroup Server + * @brief ServerNetworkManager class + * Defines the ServerNetworkManager class, which manages + * server-side networking resources including the main + * server socket. + */ + +#ifndef __ARNACAW_SERVERNETWORKMANAGER_H__ +#define __ARNACAW_SERVERNETWORKMANAGER_H__ + +/** + * Manages server-side networking resources including + * the main server socket. + * @brief Manages server networking + * @ingroup Server + */ +class ServerNetworkManager +{ +public: + friend class ServerApplication; + + /** + * Initializes server networking. + * The main action performed by this method + * is to open the server socket on the correct port. + * @param port port to listen on + */ + void Initialize(uint8_t port); + + /** + * Shuts down server networking. + */ + void Cleanup(); + + /** + * Called once per cycle to perform + * networking operations. + */ + void Cycle(); + +protected: + /** + * The default constructor is protected as we + * do not want ServerNetworkManager objects to + * be created anywhere but in the ServerApplication + * class. + */ + ServerNetworkManager(); + + /** Main server socket */ + NetworkSocket main_socket; + + /** Child sockets */ + set<NetworkSocket*> child_sockets; + +}; + +#endif Added: trunk/server/config/default.cfg =================================================================== --- trunk/server/config/default.cfg (rev 0) +++ trunk/server/config/default.cfg 2009-04-04 14:12:16 UTC (rev 76) @@ -0,0 +1,57 @@ +# +# Default configuration file for Arnacaw Online server +# Copyright (c) 2009 James Buchwald +# Linux variant +# +# Lines that start with a # are comments. +# Comments must start at the beginning of lines; you cannot +# put a # after a value, otherwise it will be parsed as part +# of a string value. +# +# Values are stored in the format <name>=<value>. +# Do not put a space between the equal sign and either the +# name or the value (unless the value is a string which starts +# with a space). Strings do NOT need to be wrapped in quotes. +# + +# +# Section 1: Resources +# These values are used to determine the locations of +# files needed by the server. All directories should +# be ended with a trailing forward slash. +# + +# +# Resources.LogPath=<string> +# Default Value: +# Windows: C:/Program Files/Arnacaw Server/logs/ +# Linux: /var/log/arnacawd/ +# +#Resources.LogPath=/var/log/arnacawd/ + +# +# Resources.DataPath=<string> +# Default Value: +# Windows: C:/Program Files/Arnacaw Server/data/ +# Linux: The directory set using ./configure at compile time +# through the --localstatedir=DIR option, plus an extra +# "/arnacawd/" at the end. Typically something along +# the lines of /usr/local/var/arnacawd/. The default +# value can be obtained by running arnacawd with the +# option "--version" and checking the "default datadir" +# compile time option. +# +#Resources.DataPath=/usr/local/var/arnacawd/ + +# +# Section 2: Network +# These values are used to control the behavior of +# the networking components of the server. +# + +# +# Networking.ServerPort=<number 1-65535> +# Default Value: 12078 +# +#Network.ServerPort=12078 + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-03-06 21:27:28
|
Revision: 75 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=75&view=rev Author: shoyru Date: 2009-03-06 21:26:52 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Lots of random work, particularly on packets. Compiles. Modified Paths: -------------- trunk/common/ArnacawCommon.h trunk/common/Packet.cpp trunk/common/Packet.h trunk/common/PacketFactory.h trunk/docs/design/Arnacaw.dia trunk/docs/design/Design.odt trunk/server/ChangeLog trunk/server/Makefile.am trunk/server/Server.cbp trunk/server/Server.cpp trunk/server/Server.h Added Paths: ----------- trunk/common/PacketFactory.cpp trunk/common/PacketType.cpp trunk/common/PacketType.h trunk/common/packets/ trunk/common/packets/ArnacawPackets.h trunk/common/packets/SimplePacket.cpp trunk/common/packets/SimplePacket.h trunk/server/Server.layout Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/common/ArnacawCommon.h 2009-03-06 21:26:52 UTC (rev 75) @@ -111,9 +111,12 @@ #include "EventDispatcher.h" #include "StderrOutputStream.h" #include "RawDataInputStream.h" -#include "RawDataOutputStream.h" +#include "RawDataOutputStream.h" +#include "PacketType.h" #include "Packet.h" -#include "NetworkSocket.h" +#include "NetworkSocket.h" +#include "PacketFactory.h" +#include "ArnacawPackets.h" #include "PacketQueue.h" #endif Modified: trunk/common/Packet.cpp =================================================================== --- trunk/common/Packet.cpp 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/common/Packet.cpp 2009-03-06 21:26:52 UTC (rev 75) @@ -44,15 +44,15 @@ /* first field is always 0x3F9B */ SerializableUint16 field1(0x3F9B); field1.serialize(dst); - + /* next field is the ID */ SerializableUint32 field2(packet_id); field2.serialize(dst); - + /* next field is the packet type */ SerializableUint16 field3(packet_type); field3.serialize(dst); - + /* last field is the data length */ SerializableUint32 field4(data_length); field4.serialize(dst); @@ -68,7 +68,7 @@ /* bad packet */ throw PacketException("corrupt header"); } - + /* next field is the ID */ SerializableUint32 field2; try { @@ -78,17 +78,17 @@ throw PacketException("corrupt header"); } packet_id = field2.getNumber(); - + /* next is the packet type */ - SerializableUint16 field3; + SerializablePacketType field3; try { field3.deserialize(src); } catch (Exception &e) { throw PacketException("corrupt header"); } - packet_type = field3.getNumber(); - + packet_type = field3.getType(); + /* finally, the data length */ SerializableUint32 field4; try { @@ -103,11 +103,35 @@ /* default constructor for packets */ Packet::Packet() { - + } /* destructor for packets */ Packet::~Packet() { - + } + +/* no-packet packet exception constructor */ +PacketException::PacketException(const string &r) : Exception(r) +{ + +} + +/* packet serialization function: SHOULD BE EXTENDED */ +void Packet::serialize(OutputStream &dst) +{ + packet_header.serialize(dst); +} + +/* packet deserialization function: SHOULD BE EXTENDED */ +void Packet::deserialize(InputStream &src) +{ + packet_header.deserialize(src); +} + +/* standard packet exception constructor */ +PacketException::PacketException(const Packet &pkt, const string &r) : Exception(r) +{ + /* TODO: handle that pkt variable */ +} Modified: trunk/common/Packet.h =================================================================== --- trunk/common/Packet.h 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/common/Packet.h 2009-03-06 21:26:52 UTC (rev 75) @@ -47,7 +47,7 @@ /** @throws PacketException */ virtual void serialize(OutputStream &dst); - + /** @throws PacketException */ virtual void deserialize(InputStream &src); @@ -56,25 +56,25 @@ * @returns the packet ID. */ inline uint32_t getPacketID() { return packet_id; } - + /** * Gets the packet type. * @returns the packet type */ - inline uint16_t getPacketType() { return packet_type; } - + inline PacketType getPacketType() { return packet_type; } + /** * Sets the packet type. * @param type packet type */ - inline void setPacketType(uint16_t type) { packet_type = type; } - + inline void setPacketType(PacketType type) { packet_type = type; } + /** * Gets the data length. * @returns the length of the data */ inline uint32_t getDataLength() { return data_length; } - + /** * Sets the data length. * @param length length of the data @@ -87,10 +87,10 @@ /** Packet ID, the second field, offset 16, 32 bits */ uint32_t packet_id; - /** Packet type, the third field, offset 48, 16 bits */ - uint16_t packet_type; + /** Packet type, the third field, offset 48, 32 bits */ + PacketType packet_type; - /** Length of data, the fourth field, offset 64, 32 bits */ + /** Length of data, the fourth field, offset 80, 32 bits */ uint32_t data_length; /** Serial counter to generate packet IDs */ @@ -102,7 +102,7 @@ * Provides means to store data for transport over the network. * Objects of Packet classes should not be created directly. * Use the PacketFactory class instead. All packet types should - * have an extended version of this class for themselves. They + * have an extended version of this class for themselves. They * should also have a registered extension of the SpecificPacketFactory * class. * @see @@ -134,24 +134,24 @@ * Conveinence method that gets the packet type from the header. * @returns packet type */ - inline uint16_t getPacketType() { return packet_header.getPacketType(); } + inline PacketType getPacketType() { return packet_header.getPacketType(); } /** * Allows modification of the packet header. * @returns pointer to the packet header object */ inline PacketHeader *getPacketHeader() { return &packet_header; } - + /** @throws PacketException */ - virtual void serialize(OutputStream &dst)=0; - + virtual void serialize(OutputStream &dst); + /** @throws PacketException */ - virtual void deserialize(InputStream &src)=0; - + virtual void deserialize(InputStream &src); + protected: /** Packet header. First field, offset 0, 96 bits */ PacketHeader packet_header; - + /* Type-specific packet data goes in extended versions of this class. */ }; @@ -166,10 +166,23 @@ class PacketException : public Exception { public: - PacketException(const Packet &pkt); + /** + * Special constructor for exceptions without a parent packet, + * eg. those received with a corrupt header. + * @param r reason the exception was thrown + */ + PacketException(const string &r=""); + /** + * Constructor for use when a packet with a valid header has + * an error. + * @param pkt packet responsible for the exception + * @param r reason the exception was thrown + */ + PacketException(const Packet &pkt, const string &r=""); + protected: - + }; #endif Added: trunk/common/PacketFactory.cpp =================================================================== --- trunk/common/PacketFactory.cpp (rev 0) +++ trunk/common/PacketFactory.cpp 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,94 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketFactory.cpp + * @ingroup Common + * @brief PacketFactory class + * Contains the implementation of the PacketFactory class, + * which dynamically creates objects of specialized Packet + * classes given a type identifier. + */ + +#include "ArnacawCommon.h" + +/* the constructor */ +PacketFactory::PacketFactory() { } + +/* registers a factory */ +void PacketFactory::registerFactory(SpecificPacketFactory *factory, PacketType type) +{ + /* simple validity check */ + if ( !factory ) + throw PacketException("NULL pointer passed to PacketFactory::registerFactory()"); + + /* register */ + registered_factories[type] = factory; +} + +/* creates a packet */ +Packet *PacketFactory::createPacket(PacketType type) +{ + /* check if a factory has been registered for this type */ + map<PacketType,SpecificPacketFactory*>::iterator itr; + itr = registered_factories.find(type); + if ( itr == registered_factories.end() ) { + stringstream buf; + buf << "attempt to create packet of unregistered type "; + buf << type; + throw PacketException(buf.str()); + } + + /* ask the factory to create the packet */ + return (*itr).second->create(); +} + +/* destroys a packet */ +void PacketFactory::releasePacket(Packet *packet) +{ + /* simple validity check */ + if ( !packet ) + throw PacketException("NULL pointer passed to PacketFactory::releasePacket()"); + + /* determine the packet type */ + PacketType type = packet->getPacketHeader()->getPacketType(); + map<PacketType,SpecificPacketFactory*>::iterator itr; + itr = registered_factories.find(type); + if ( itr == registered_factories.end() ) { + stringstream buf; + buf << "attempt to release packet of unregistered type "; + buf << type; + throw PacketException(buf.str()); + } + + /* ask the factory to destroy the packet */ + (*itr).second->destroy(packet); +} + +/* builds the initial database of packet types */ +void PacketFactory::buildInitialDatabase() +{ + /* ok, first up, the "simple" packets */ + registerFactory(new SimplePacketFactory(AMF_LOGINSUCCESS), + AMF_LOGINSUCCESS); + registerFactory(new SimplePacketFactory(AMF_LOGOFF), + AMF_LOGOFF); +} Modified: trunk/common/PacketFactory.h =================================================================== --- trunk/common/PacketFactory.h 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/common/PacketFactory.h 2009-03-06 21:26:52 UTC (rev 75) @@ -46,7 +46,7 @@ * @throws Exception * @returns A new object. */ - virtual Packet * create()=0; + virtual Packet *create()=0; /** * Destroys an object. @@ -70,12 +70,57 @@ /** * Registers a new factory for creating events. + * @note If a factory has already been registered + * for a given PacketType, it will be replaced + * with the newly passed factory. * @param factory Factory to register + * @param type Type of packet to handle * @throws Exception * If a NULL pointer is passed, an Exception will * be thrown. */ + void registerFactory(SpecificPacketFactory *factory, PacketType type); + /** + * Builds an initial database of factories to rely upon. + * This will include ALL types of packet factories, regardless + * of which component is being built. We do this because + * we don't want to needlessly complicate things as we did + * with the EventFactory class; and, if the client ever needs + * to act as a server for some reason (why? good question), it + * would be simple enough to implement...-ish. + */ + void buildInitialDatabase(); + + /** + * Creates a packet of a given type. + * @warn The reference returned must be freed + * with a call to releasePacket(). Do + * not attempt to call delete on it yourself. + * @param type Type of packet to create + * @throws PacketException + * If no factory is available for the requested packet + * type, a PacketException will be thrown. Also, be aware + * that Exceptions and PacketExceptions can propagate from + * the individual packet factories as well. + * @return A reference to the newly-created packet. + */ + Packet *createPacket(PacketType type); + + /** + * Frees a packet returned by a call to createPacket(). + * @note For safety reasons, it is a good idea to set the + * pointer to NULL after passing it to this method. + * @warn Do not pass pointers that were not returned by + * createPacket(). This can cause a segmentation + * fault and (possibly) a security issue. + * @param packet Packet to free + * @throws PacketException + * If a NULL pointer is passed, or the packet is invalid, + * a PacketException will be thrown. + */ + void releasePacket(Packet *packet); + protected: /** * Do not create objects of this class directly. @@ -84,8 +129,11 @@ */ PacketFactory(); - /** Registered packet factories */ - map<uint16_t, SpecificPacketFactory*> registered_factories; + /** + * Registered packet factories. + * Factories are mapped by packet type. + */ + map<PacketType,SpecificPacketFactory*> registered_factories; }; Added: trunk/common/PacketType.cpp =================================================================== --- trunk/common/PacketType.cpp (rev 0) +++ trunk/common/PacketType.cpp 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,55 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketType.cpp + * @ingroup Common + * @brief PacketType-related class implementations + * Contains the implementations for the helper classes + * related to the PacketType enum. + */ + +#include "ArnacawCommon.h" + +/* empty constructor for SerializablePacketType */ +SerializablePacketType::SerializablePacketType() : type(AMF_UNKNOWN) +{ + +} + +/* wrapper constructor for SerializablePacketType */ +SerializablePacketType::SerializablePacketType(PacketType type) : type(type) +{ + +} + +/* Serializable methods for SerializablePacketType */ +void SerializablePacketType::serialize(OutputStream &dst) +{ + SerializableUint32(type).serialize(dst); +} + +void SerializablePacketType::deserialize(InputStream &src) +{ + SerializableUint32 x; + x.deserialize(src); + type = (PacketType)x.getNumber(); +} Added: trunk/common/PacketType.h =================================================================== --- trunk/common/PacketType.h (rev 0) +++ trunk/common/PacketType.h 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,107 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketType.h + * @ingroup Common + * @brief PacketType enum + * Defines the PacketType enum, which contains + * the full set of packet types for both client->server + * and server->client traffic. These could technically + * be separated out into a file just for the server and + * a file just for the client, but that would needlessly + * complicate things. + */ + +#ifndef __ARNACAW_PACKETTYPE_H__ +#define __ARNACAW_PACKETTYPE_H__ + +/** + * This is the full set of packet types for both + * client->server and server->client traffic. These + * could technically be separated out into a file just + * for the server and a file just for the client, but + * that would needlessly complicate things. For more + * detailed information about what the individual packet + * types do, refer to the file docs/Design.odt (or + * docs/Design.pdf, available with official releases). + * @brief Packet type identifiers + * @ingroup Common + */ +enum PacketType +{ + /* FIRST SECTION : Bidirectional Packets (0x0 - 0xFFFF) */ + + /* SECOND SECTION : Client->Server Packets (0x10000 - 0xFFFFF) */ + AMF_HELLO=0x10000, + AMF_LOGIN=0x10001, + AMF_LOGOFF=0x10002, + AMF_REGISTER=0x10003, + + /* THIRD SECTION : Server->Client Packets (0x100000 - 0xFFFFFF) */ + AMF_HANDSHAKE=0x100000, + AMF_AUTHINFO=0x100001, + AMF_LOGINFAILURE=0x100002, + AMF_LOGINSUCCESS=0x100003, + AMF_DISCONNECT=0x100004, + AMF_REGISTERFAILURE=0x100005, + + /* Finally, let's make sure that this enum is at least 4 bytes wide. */ + AMF_UNKNOWN=0xFFFFFFFF, + +}; + +/** + * Wrapper around the PacketType enum that adds + * Serializable capabilities. + * @brief Serializable PacketType + * @ingroup Common + */ +class SerializablePacketType : public Serializable +{ +public: + /** + * Creates an empty object for deserialization + * from a stream. + */ + SerializablePacketType(); + + /** + * Wraps a PacketType enum. + * @param type PacketType value to wrap + */ + SerializablePacketType(PacketType type); + + /** + * Gets the wrapped PacketType. + * @return The wrapped PacketType + */ + inline PacketType getType() { return type; } + + void deserialize(InputStream &src); + void serialize(OutputStream &dst); + +protected: + PacketType type; + +}; + +#endif Added: trunk/common/packets/ArnacawPackets.h =================================================================== --- trunk/common/packets/ArnacawPackets.h (rev 0) +++ trunk/common/packets/ArnacawPackets.h 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,42 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ArnacawPackets.h + * @ingroup Common + * + * Single header that wraps all of the specialized Packet classes. + * Do not include this file directly; include ArnacawCommon.h instead. + * + * @brief Specialized Packet superheader + */ + +#ifndef __ARNACAW_PACKETS_H__ +#define __ARNACAW_PACKETS_H__ + +/* Bidirectional packets */ +#include "SimplePacket.h" + +/* Client->Server packets */ + +/* Server->Client packets */ + +#endif Added: trunk/common/packets/SimplePacket.cpp =================================================================== --- trunk/common/packets/SimplePacket.cpp (rev 0) +++ trunk/common/packets/SimplePacket.cpp 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,60 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file SimplePacket.cpp + * @ingroup Common + * @brief SimplePacketFactory class + * Contains the implementation of the SimplePacketFactory + * class, which defines a generic SpecificPacketFactory + * implementation for packets with no extended fields. + * @see PacketType + */ + +#include "ArnacawCommon.h" + +/* constructor */ +SimplePacketFactory::SimplePacketFactory(PacketType type) : type(type) +{ + +} + +/* creates a packet */ +Packet *SimplePacketFactory::create() +{ + Packet *retval = new Packet; + retval->getPacketHeader()->setPacketType(type); + managed_packets.insert(retval); + return retval; +} + +/* destroys a packet */ +void SimplePacketFactory::destroy(Packet *pkt) +{ + /* simple validity checks */ + if ( !pkt ) + throw PacketException("NULL pointer passed to SimplePacketFactory::destroy()"); + if ( managed_packets.count(pkt) == 0 ) + throw PacketException("SimplePacketFactory asked to destroy unowned packet"); + + /* destroy the packet */ + delete pkt; +} Added: trunk/common/packets/SimplePacket.h =================================================================== --- trunk/common/packets/SimplePacket.h (rev 0) +++ trunk/common/packets/SimplePacket.h 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,72 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2009 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file SimplePacket.h + * @ingroup Common + * @brief Simplest possible packet and lookalikes + * Defines aliases for simple packets (eg. AMF_LOGINSUCCESS), + * as well as a generic SpecificPacketFactory for their production. + * @see PacketType + */ + +#ifndef __ARNACAW_SIMPLEPACKET_H__ +#define __ARNACAW_SIMPLEPACKET_H__ + +/** + * Produces simple packets with no extended fields. + * @note This provides a fairly standard implementation + * of packet header handling. This makes the class + * suitable for extending into more complex Packets. + * @brief SpecificPacketFactory for simple Packets + * @ingroup Common + */ +class SimplePacketFactory : public SpecificPacketFactory +{ +public: + /** + * Special constructor that allows the specialization + * of a SimplePacketFactory without having to extend + * the class. + * @param type type of packet to produce + */ + SimplePacketFactory(PacketType type); + + /* implements SpecificPacketFactory */ + virtual Packet *create(); + + /* implements SpecificPacketFactory */ + virtual void destroy(Packet *pkt); + +protected: + /** Type of packet to produce; set this with the constructor. */ + PacketType type; + + /** Packets currently managed by the factory. */ + set<Packet*> managed_packets; + +}; + +/** Aliases of simple packets */ +typedef Packet LoginSuccessPacket; +typedef Packet LogoffPacket; + +#endif Modified: trunk/docs/design/Arnacaw.dia =================================================================== (Binary files differ) Modified: trunk/docs/design/Design.odt =================================================================== (Binary files differ) Modified: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/server/ChangeLog 2009-03-06 21:26:52 UTC (rev 75) @@ -5,6 +5,117 @@ | ChangeLog | | | +===============================================+ + +------------------------------------------------- + +5 March 2009 - Jim Buchwald + +Lots of fixes to the packet files. +The code finally compiles again. + +------------------------------------------------- + +4 March 2009 - Jim Buchwald + +common/PacketType.cpp: + * Implement the SerializablePacketType class. + +server/Makefile.am: + * Add common/PacketType.cpp to build sequence. + +------------------------------------------------- + +3 March 2009 - Jim Buchwald + +common/PacketType.h: + * Define a SerializablePacketType helper + class for the PacketType enum. + +------------------------------------------------- + +2 March 2009 - Jim Buchwald + +The 27 pages for American Studies class are +out of the way; finally back to working on +the code! :) + +common/Packet.h: + * Move to the new PacketType enum from the + old uint16_t packet typing. Expand packet + type field in header to 32 bits. + +------------------------------------------------- + +22 Feb 2009 - Jim Buchwald + +docs/design/Arnacaw.dia: + * This file is completely out of date. + Good for a general reference of things, + but I'll get around to fixing it up later. + +common/PacketFactory.h: + * Looks like I forgot to finish this one too. + More work on it. + +common/PacketType.h: + * It's about time we finally have that enum, + so created it. Now to check if I ever + started designing that protocol... note + to self: no more six-month breaks from code. + Ah, so I have... docs/Design.odt has them. + +docs/Design.odt: + * More work on packet types. Looks like I had + left some stuff unfinished here too. + +common/ArnacawCommon.h: + * Add reference to PacketType.h and PacketFactory.h. + Not exactly sure why I hadn't added the Factory + reference earlier, but whatever. + +ChangeLog: + * Fix the dates. I had been writing these down + as 2008. Sadly, I have not yet mastered the + art of controlling the flow of time. Fixed to + a more accurate 2009. + +common/packets/ArnacawPackets.h: + * Create this file to wrap the specialized packet headers. + +common/packets/SimplePacket.h, common/packets/SimplePacket.cpp: + * Create the simplest packets and SpecificPacketFactory + implementation. SimplePacketFactory can now be + extended to act as a basis for more complex factories. + +common/Packet.h, common/Packet.cpp: + * Changed Packet from an interface to a header-only + implementation that can be extended for more + complex packets. + +Makefile.am: + * Add some more source files to the build process + +------------------------------------------------- + +21 Feb 2009 - Jim Buchwald + +common/Packet.h, common/Packet.cpp: + * Fix some compilation issues caused by + me not finishing my code before committing + it to Subversion. PacketException needs + to be finished still, see the TODO comments. + +common/PacketQueue.h, common/PacketQueue.cpp: + * More work on completing what I started earlier. + +docs/design/Arnacaw.dia: + * Fix some formatting issues. They seem to differ + from computer to computer... good old Dia. + +------------------------------------------------- + +Lots of miscellaneous updates between July and +August 2008 to the Streams. Logging implemented. ------------------------------------------------- @@ -37,7 +148,7 @@ 05 March 2008 - Jim Buchwald - * Implement and test Serializable base types + * Implement and test Serializable base types for integers ------------------------------------------------- @@ -52,12 +163,12 @@ ------------------------------------------------- 01 March 2008 - Jim Buchwald - + * Start designing class diagrams * Begin implementation of some classes * ServerApplication, Exception, Singleton, InputStream, OutputStream * Server application will now run (but doesn't do anything) - + ------------------------------------------------- Modified: trunk/server/Makefile.am =================================================================== --- trunk/server/Makefile.am 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/server/Makefile.am 2009-03-06 21:26:52 UTC (rev 75) @@ -17,7 +17,10 @@ ../common/MessageManager.cpp \ ../common/RawDataInputStream.cpp \ ../common/RawDataOutputStream.cpp \ - ../common/PacketQueue.cpp - -arnacawd_CPPFLAGS = -I../common -DINSTALL_ROOT=\"@prefix@\" + ../common/PacketQueue.cpp \ + ../common/PacketFactory.cpp \ + ../common/PacketType.cpp \ + ../common/packets/SimplePacket.cpp + +arnacawd_CPPFLAGS = -I../common -I../common/packets -DINSTALL_ROOT=\"@prefix@\" arnacawd_LDADD = $(LIBS) Modified: trunk/server/Server.cbp =================================================================== --- trunk/server/Server.cbp 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/server/Server.cbp 2009-03-06 21:26:52 UTC (rev 75) @@ -41,9 +41,12 @@ <Unit filename="../common/OutputStream.h" /> <Unit filename="../common/Packet.cpp" /> <Unit filename="../common/Packet.h" /> + <Unit filename="../common/PacketFactory.cpp" /> <Unit filename="../common/PacketFactory.h" /> <Unit filename="../common/PacketQueue.cpp" /> <Unit filename="../common/PacketQueue.h" /> + <Unit filename="../common/PacketType.cpp" /> + <Unit filename="../common/PacketType.h" /> <Unit filename="../common/RawDataInputStream.cpp" /> <Unit filename="../common/RawDataInputStream.h" /> <Unit filename="../common/RawDataOutputStream.cpp" /> @@ -53,6 +56,9 @@ <Unit filename="../common/Singleton.h" /> <Unit filename="../common/SpecificEventFactory.h" /> <Unit filename="../common/StderrOutputStream.h" /> + <Unit filename="../common/packets/ArnacawPackets.h" /> + <Unit filename="../common/packets/SimplePacket.cpp" /> + <Unit filename="../common/packets/SimplePacket.h" /> <Unit filename="ArnacawServer.h" /> <Unit filename="CLIArgumentInterpreter.cpp" /> <Unit filename="CLIArgumentInterpreter.h" /> Modified: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/server/Server.cpp 2009-03-06 21:26:52 UTC (rev 75) @@ -49,19 +49,22 @@ /* runs the application */ void ServerApplication::go(int argc, char **argv) -{ +{ /* set up messaging */ initMessaging(); - + /* set up needed resources */ initLibraries(); - + /* initialize event system */ - initEventSystem(); - + initEventSystem(); + + /* initialize networking */ + initNetworking(); + /* register self as an event handler */ EventDispatcher::getSingleton().registerHandler(this, EVENT_QUIT); - + /* hook the signals */ hookSignals(); @@ -71,13 +74,13 @@ /* bad arguments, exit */ return; } - + /* handle information arguments */ if ( !checkInformationArguments() ) { /* time to exit */ return; } - + #ifdef POSIX /* run in daemon mode? */ if ( cmd_args.IsArgumentStored("--daemon") ) { @@ -88,11 +91,14 @@ #endif /* enter main loop */ - mainLoop(); - - /* clean up remaining stuff */ + mainLoop(); + + /* clean up networking */ + cleanupNetworking(); + + /* clean up libraries */ cleanupLibraries(); - + /* clean up messaging */ cleanupMessaging(); } @@ -125,7 +131,7 @@ void ServerApplication::setupCmdLineArguments() { /* Command line arguments! */ - + /* SECTION 1: Information */ cmd_args.AddArgument("--help", "Display this message", @@ -136,7 +142,7 @@ cmd_args.AddArgument("--license", "Show license information", CMDARG_BOOLEAN); - + /* SECTION 2: Behavior */ cmd_args.AddArgument("--debug", "Run in debug mode", @@ -168,7 +174,7 @@ cmd_args.WriteHelpInfo(ConsoleOutputStream::getSingleton()); return false; } - + /* success */ return true; } @@ -183,7 +189,7 @@ cmd_args.WriteHelpInfo(ConsoleOutputStream::getSingleton()); return false; } - + /* show version information? */ if ( cmd_args.GetBooleanValue("--version") ) { /* show version information and exit */ @@ -191,13 +197,13 @@ cout << "Copyright (c) 2008 James Buchwald" << endl << endl; cout << LICENSE_INFO << endl << endl; } - + /* show license information? */ if ( cmd_args.GetBooleanValue("--license") ) { /* show license information and exit */ cout << LICENSE_INFO << endl << endl; } - + /* do not exit */ return true; } @@ -214,18 +220,18 @@ /* this is the parent process - get out! */ exit(0); } - + /* set stuff up! */ pid_t sid = setsid(); if ( sid < 0 ) { throw Exception("setsid() failed; daemon mode critical failure"); } - + /* change current directory */ if ( chdir("/") < 0 ) { throw Exception("chdir() failed; daemon mode critical failure"); } - + /* do stuff with files and things */ close(STDIN_FILENO); close(STDOUT_FILENO); @@ -242,11 +248,11 @@ /* check if we need to quit */ if ( time_to_quit ) { /* handle in-loop cleanups */ - + /* quit */ break; } - + /* run the event dispatcher */ EventDispatcher::getSingleton().dispatch(); } @@ -274,7 +280,7 @@ { /* register the common events */ EventFactory::getSingleton().buildInitialDatabase(); - + /* register server-specific events */ } @@ -301,13 +307,13 @@ int stdout_count = sizeof(stdout_levels) / sizeof(int); MessageManager::getSingleton().registerStreamMP(ConsoleOutputStream::getSingletonPtr(), stdout_levels, stdout_count); - + /* set up output to stderr */ int stderr_levels[] = { MSGP_WARN, MSGP_ERROR }; int stderr_count = sizeof(stderr_levels) / sizeof(int); MessageManager::getSingleton().registerStreamMP(StderrOutputStream::getSingletonPtr(), stderr_levels, stderr_count); - + /* set up logging services */ LogManager::getSingleton().initLogs(); } @@ -317,4 +323,17 @@ { /* close logs */ LogManager::getSingleton().closeAllLogs(); +} + +/* initializes networking */ +void ServerApplication::initNetworking() +{ + /* set up the PacketFactory */ + PacketFactory::getSingleton().buildInitialDatabase(); +} + +/* cleans up networking */ +void ServerApplication::cleanupNetworking() +{ + } Modified: trunk/server/Server.h =================================================================== --- trunk/server/Server.h 2008-09-29 01:43:07 UTC (rev 74) +++ trunk/server/Server.h 2009-03-06 21:26:52 UTC (rev 75) @@ -25,14 +25,14 @@ * * @brief ServerApplication class * - * Defines the ServerApplication class, which is the main application + * Defines the ServerApplication class, which is the main application * class for the Server component. */ #ifndef __ARNACAW_SERVER_H__ #define __ARNACAW_SERVER_H__ -/** +/** * Main application class for the Server component. * @ingroup Server * @brief Server application @@ -43,14 +43,14 @@ public: friend class Singleton<ServerApplication>; - /** + /** * Begins execution of the application. * @param argc argument count * @param argv array of arguments */ void go(int argc, char **argv); - /** + /** * Determines if a boolean argument is set. * @param arg name of argument to check * @returns true if the argument is set, false if not @@ -79,7 +79,17 @@ /** * Initializes the messaging system, including logging services. */ - void initMessaging(); + void initMessaging(); + + /** + * Initializes the networking system. + */ + void initNetworking(); + + /** + * Cleans up the networking system. + */ + void cleanupNetworking(); /** * Cleans up the messaging system, including logging services. @@ -90,55 +100,55 @@ * Cleans up libraries used by the server. */ void cleanupLibraries(); - + /** * Sets up allowed command line arguments. */ void setupCmdLineArguments(); - + /** * Gets command line arguments. - * + * * @returns false if the program should terminate */ bool getCmdLineArguments(int argc, char **argv); - + /** * Checks information arguments. * * @returns false if the program should terminate */ bool checkInformationArguments(); - + #ifdef POSIX /** * Switches to daemon mode (not reversible). */ void goDaemonMode(); #endif - + /** * Main loop. */ void mainLoop(); - + /** * Intializes the event systems. * Registration of server-specific factories happens here. */ void initEventSystem(); - + /** * Hooks signals so that they don't cause undesirable behavior. */ void hookSignals(); - + /* Implements EventHandler */ void notify(Event *event); - + /** Stores command line arguments */ CLIArgumentInterpreter cmd_args; - + /** Flags the main loop to terminate. */ bool time_to_quit; Added: trunk/server/Server.layout =================================================================== --- trunk/server/Server.layout (rev 0) +++ trunk/server/Server.layout 2009-03-06 21:26:52 UTC (rev 75) @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_layout_file> + <ActiveTarget name="Release" /> + <File name="../common/ArnacawCommon.h" open="0" top="0" tabpos="6"> + <Cursor position="4120" topLine="86" /> + </File> + <File name="../common/EventFactory.h" open="0" top="0" tabpos="0"> + <Cursor position="474" topLine="0" /> + </File> + <File name="../common/NetworkSocket.h" open="1" top="0" tabpos="1"> + <Cursor position="1653" topLine="21" /> + </File> + <File name="../common/Packet.cpp" open="0" top="0" tabpos="2"> + <Cursor position="3129" topLine="66" /> + </File> + <File name="../common/Packet.h" open="0" top="0" tabpos="3"> + <Cursor position="3276" topLine="74" /> + </File> + <File name="../common/PacketFactory.cpp" open="0" top="0" tabpos="11"> + <Cursor position="3514" topLine="59" /> + </File> + <File name="../common/PacketFactory.h" open="0" top="0" tabpos="12"> + <Cursor position="4948" topLine="78" /> + </File> + <File name="../common/PacketQueue.cpp" open="0" top="0" tabpos="4"> + <Cursor position="3665" topLine="40" /> + </File> + <File name="../common/PacketQueue.h" open="0" top="0" tabpos="0"> + <Cursor position="0" topLine="12" /> + </File> + <File name="../common/PacketType.cpp" open="0" top="0" tabpos="0"> + <Cursor position="2367" topLine="20" /> + </File> + <File name="../common/PacketType.h" open="0" top="0" tabpos="5"> + <Cursor position="3377" topLine="66" /> + </File> + <File name="../common/packets/ArnacawPackets.h" open="0" top="0" tabpos="7"> + <Cursor position="1910" topLine="0" /> + </File> + <File name="../common/packets/SimplePacket.cpp" open="0" top="0" tabpos="9"> + <Cursor position="2538" topLine="25" /> + </File> + <File name="../common/packets/SimplePacket.h" open="0" top="0" tabpos="8"> + <Cursor position="2817" topLine="34" /> + </File> + <File name="ChangeLog" open="1" top="1" tabpos="2"> + <Cursor position="505" topLine="0" /> + </File> + <File name="LogManager.h" open="0" top="0" tabpos="0"> + <Cursor position="2531" topLine="30" /> + </File> + <File name="Makefile.am" open="0" top="0" tabpos="10"> + <Cursor position="686" topLine="0" /> + </File> + <File name="Server.cpp" open="0" top="0" tabpos="13"> + <Cursor position="3191" topLine="31" /> + </File> + <File name="Server.h" open="0" top="0" tabpos="14"> + <Cursor position="2972" topLine="0" /> + </File> +</CodeBlocks_layout_file> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-09-29 01:43:17
|
Revision: 74 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=74&view=rev Author: shoyru Date: 2008-09-29 01:43:07 +0000 (Mon, 29 Sep 2008) Log Message: ----------- forgot to save the project file before adding it, oops! Modified Paths: -------------- trunk/server/Server.cbp Modified: trunk/server/Server.cbp =================================================================== --- trunk/server/Server.cbp 2008-09-29 01:42:18 UTC (rev 73) +++ trunk/server/Server.cbp 2008-09-29 01:43:07 UTC (rev 74) @@ -3,20 +3,12 @@ <FileVersion major="1" minor="6" /> <Project> <Option title="Server" /> + <Option makefile_is_custom="1" /> <Option pch_mode="2" /> <Option compiler="gcc" /> <Build> - <Target title="Debug"> - <Option output="bin/Debug/Server" prefix_auto="1" extension_auto="1" /> - <Option object_output="obj/Debug/" /> - <Option type="1" /> - <Option compiler="gcc" /> - <Compiler> - <Add option="-g" /> - </Compiler> - </Target> <Target title="Release"> - <Option output="bin/Release/Server" prefix_auto="1" extension_auto="1" /> + <Option output="arnacawd" prefix_auto="1" extension_auto="1" /> <Option object_output="obj/Release/" /> <Option type="1" /> <Option compiler="gcc" /> @@ -31,6 +23,55 @@ <Compiler> <Add option="-Wall" /> </Compiler> + <Unit filename="../common/ArnacawCommon.h" /> + <Unit filename="../common/CommonEvents.h" /> + <Unit filename="../common/ConsoleOutputStream.h" /> + <Unit filename="../common/Event.h" /> + <Unit filename="../common/EventDispatcher.h" /> + <Unit filename="../common/EventFactory.h" /> + <Unit filename="../common/EventHandler.h" /> + <Unit filename="../common/Exception.h" /> + <Unit filename="../common/FileInputStream.h" /> + <Unit filename="../common/FileOutputStream.h" /> + <Unit filename="../common/InputStream.h" /> + <Unit filename="../common/MessageManager.cpp" /> + <Unit filename="../common/MessageManager.h" /> + <Unit filename="../common/NetworkSocket.cpp" /> + <Unit filename="../common/NetworkSocket.h" /> + <Unit filename="../common/OutputStream.h" /> + <Unit filename="../common/Packet.cpp" /> + <Unit filename="../common/Packet.h" /> + <Unit filename="../common/PacketFactory.h" /> + <Unit filename="../common/PacketQueue.cpp" /> + <Unit filename="../common/PacketQueue.h" /> + <Unit filename="../common/RawDataInputStream.cpp" /> + <Unit filename="../common/RawDataInputStream.h" /> + <Unit filename="../common/RawDataOutputStream.cpp" /> + <Unit filename="../common/RawDataOutputStream.h" /> + <Unit filename="../common/Serializable.h" /> + <Unit filename="../common/SerializableBaseTypes.h" /> + <Unit filename="../common/Singleton.h" /> + <Unit filename="../common/SpecificEventFactory.h" /> + <Unit filename="../common/StderrOutputStream.h" /> + <Unit filename="ArnacawServer.h" /> + <Unit filename="CLIArgumentInterpreter.cpp" /> + <Unit filename="CLIArgumentInterpreter.h" /> + <Unit filename="ChangeLog" /> + <Unit filename="ClientManager.cpp" /> + <Unit filename="ClientManager.h" /> + <Unit filename="ConnectedClient.cpp" /> + <Unit filename="ConnectedClient.h" /> + <Unit filename="IPBanManager.h" /> + <Unit filename="LogManager.cpp" /> + <Unit filename="LogManager.h" /> + <Unit filename="LogOutputStream.cpp" /> + <Unit filename="LogOutputStream.h" /> + <Unit filename="Makefile.am" /> + <Unit filename="PathBuilder.cpp" /> + <Unit filename="PathBuilder.h" /> + <Unit filename="Server.cpp" /> + <Unit filename="Server.h" /> + <Unit filename="ServerMain.cpp" /> <Extensions> <code_completion /> <debugger /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-09-29 01:42:30
|
Revision: 73 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=73&view=rev Author: shoyru Date: 2008-09-29 01:42:18 +0000 (Mon, 29 Sep 2008) Log Message: ----------- add Code::Blocks workspace files Modified Paths: -------------- trunk/common/PacketFactory.h trunk/docs/design/Arnacaw.dia Added Paths: ----------- trunk/arnacaw.workspace trunk/server/Server.cbp Added: trunk/arnacaw.workspace =================================================================== --- trunk/arnacaw.workspace (rev 0) +++ trunk/arnacaw.workspace 2008-09-29 01:42:18 UTC (rev 73) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_workspace_file> + <Workspace title="Arnacaw Online"> + <Project filename="server/Server.cbp" active="1" /> + </Workspace> +</CodeBlocks_workspace_file> Modified: trunk/common/PacketFactory.h =================================================================== --- trunk/common/PacketFactory.h 2008-08-15 22:10:45 UTC (rev 72) +++ trunk/common/PacketFactory.h 2008-09-29 01:42:18 UTC (rev 73) @@ -38,11 +38,9 @@ * @brief Backend of PacketFactory * @ingroup Common */ -class SpecificPacketFactory : public Singleton<SpecificPacketFactory> +class SpecificPacketFactory { public: - friend class Singleton<SpecificPacketFactory>; - /** * Creates an object. * @throws Exception @@ -57,14 +55,6 @@ */ virtual void destroy(Packet *pkt)=0; -protected: - /** - * Do not create objects of this class directly. - * Use the getSingleton() and getSingletonPtr() - * methods instead. - */ - SpecificPacketFactory(); - }; /** Added: trunk/server/Server.cbp =================================================================== --- trunk/server/Server.cbp (rev 0) +++ trunk/server/Server.cbp 2008-09-29 01:42:18 UTC (rev 73) @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Server" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Build> + <Target title="Debug"> + <Option output="bin/Debug/Server" prefix_auto="1" extension_auto="1" /> + <Option object_output="obj/Debug/" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + </Compiler> + </Target> + <Target title="Release"> + <Option output="bin/Release/Server" prefix_auto="1" extension_auto="1" /> + <Option object_output="obj/Release/" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-O2" /> + </Compiler> + <Linker> + <Add option="-s" /> + </Linker> + </Target> + </Build> + <Compiler> + <Add option="-Wall" /> + </Compiler> + <Extensions> + <code_completion /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-08-15 22:10:38
|
Revision: 72 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=72&view=rev Author: shoyru Date: 2008-08-15 22:10:45 +0000 (Fri, 15 Aug 2008) Log Message: ----------- check in for backup purposes after vacation Modified Paths: -------------- trunk/autogen.sh trunk/client/Client.h trunk/client/Makefile.am trunk/common/ArnacawCommon.h trunk/common/ConsoleOutputStream.h trunk/common/EventDispatcher.h trunk/common/Exception.h trunk/common/FileOutputStream.h trunk/common/InputStream.h trunk/common/Serializable.h trunk/common/SerializableBaseTypes.h trunk/docs/design/Design.odt trunk/server/ArnacawServer.h trunk/server/CLIArgumentInterpreter.cpp trunk/server/CLIArgumentInterpreter.h trunk/server/LogManager.cpp trunk/server/LogManager.h trunk/server/Makefile.am trunk/server/PathBuilder.cpp trunk/server/PathBuilder.h trunk/server/Server.cpp trunk/server/Server.h Added Paths: ----------- trunk/common/MessageManager.cpp trunk/common/MessageManager.h trunk/common/NetworkSocket.cpp trunk/common/NetworkSocket.h trunk/common/Packet.cpp trunk/common/Packet.h trunk/common/PacketFactory.h trunk/common/PacketQueue.cpp trunk/common/PacketQueue.h trunk/common/RawDataInputStream.cpp trunk/common/RawDataInputStream.h trunk/common/RawDataOutputStream.cpp trunk/common/RawDataOutputStream.h trunk/common/StderrOutputStream.h trunk/server/ClientManager.cpp trunk/server/ClientManager.h trunk/server/ConnectedClient.cpp trunk/server/ConnectedClient.h trunk/server/IPBanManager.h trunk/server/LogOutputStream.cpp trunk/server/LogOutputStream.h Removed Paths: ------------- trunk/server/MessageManager.cpp trunk/server/MessageManager.h Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/autogen.sh 2008-08-15 22:10:45 UTC (rev 72) @@ -1,6 +1,6 @@ #!/bin/sh aclocal +autoheader autoconf -autoheader automake Modified: trunk/client/Client.h =================================================================== --- trunk/client/Client.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/client/Client.h 2008-08-15 22:10:45 UTC (rev 72) @@ -34,6 +34,7 @@ /** * Main application class for the Client component + * @brief Client application * @ingroup Client */ class ClientApplication : public Singleton<ClientApplication>, Modified: trunk/client/Makefile.am =================================================================== --- trunk/client/Makefile.am 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/client/Makefile.am 2008-08-15 22:10:45 UTC (rev 72) @@ -4,6 +4,17 @@ # See the LICENSE file for details bin_PROGRAMS = arnacaw -arnacaw_SOURCES = ClientMain.cpp Client.cpp Display.cpp SDLEventAdaptor.cpp + +arnacaw_SOURCES = ClientMain.cpp \ + Client.cpp \ + Display.cpp \ + SDLEventAdaptor.cpp \ + ../common/Packet.cpp \ + ../common/NetworkSocket.cpp \ + ../common/MessageManager.cpp \ + ../common/RawDataInputStream.cpp \ + ../common/RawDataOutputStream.cpp \ + ../common/PacketQueue.cpp + arnacaw_CPPFLAGS = -I../common $(SDL_CFLAGS) arnacaw_LDADD = $(SDL_LIBS) $(LIBS) Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/ArnacawCommon.h 2008-08-15 22:10:45 UTC (rev 72) @@ -37,8 +37,9 @@ * Arnacaw Online codebase. * * These files are intended for developer use only; most users will not - * be interested in lists of classes and dependency graphs. If you are - * a geek, though, then maybe you will enjoy these pages. Not likely, though. + * be interested in lists of classes and dependency graphs. Documentation + * intended for the end-user can be found at the Arnacaw Online website + * at http://arnacaw.sourceforge.net . * * @section contrib_sec Contributing * @@ -47,6 +48,11 @@ * so, using these pages as a reference. Please make sure that any new code is * also documented using Javadoc-style comments and licensed under the GPL. * + * @section contact_sec Contact + * + * The Arnacaw Online website can be found at http://arnacaw.sourceforge.net . + * Several mailing lists can also be found at the project page at + * http://sourceforge.net/projects/arnacaw . */ /** @@ -58,6 +64,11 @@ #include "config.h" +/* Miscellaneous configuration values */ + +/** Maximum size of a packet in bytes */ +#define AO_MAX_PACKET_SIZE 4096 + /* Standard headers */ #include <iostream> #include <fstream> @@ -67,6 +78,7 @@ #include <list> #include <queue> #include <set> +#include <stdint.h> #ifdef HAVE_UNISTD_H #ifndef POSIX @@ -90,11 +102,18 @@ #include "ConsoleOutputStream.h" #include "Serializable.h" #include "SerializableBaseTypes.h" +#include "MessageManager.h" #include "Event.h" #include "EventHandler.h" #include "SpecificEventFactory.h" #include "CommonEvents.h" #include "EventFactory.h" #include "EventDispatcher.h" +#include "StderrOutputStream.h" +#include "RawDataInputStream.h" +#include "RawDataOutputStream.h" +#include "Packet.h" +#include "NetworkSocket.h" +#include "PacketQueue.h" #endif Modified: trunk/common/ConsoleOutputStream.h =================================================================== --- trunk/common/ConsoleOutputStream.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/ConsoleOutputStream.h 2008-08-15 22:10:45 UTC (rev 72) @@ -39,13 +39,27 @@ * @ingroup Common * @brief OutputStream for the console */ -class ConsoleOutputStream : public OutputStream +class ConsoleOutputStream : public OutputStream, + public Singleton<ConsoleOutputStream> { +public: + friend class Singleton<ConsoleOutputStream>; + /* write method */ virtual int write(const unsigned char *buf, int len) { cout << buf; + return len; } + +protected: + /** + * Do not create objects of this class directly. + * Use the getSingleton() or getSingletonPtr() + * methods instead. + */ + ConsoleOutputStream() { } + }; #endif Modified: trunk/common/EventDispatcher.h =================================================================== --- trunk/common/EventDispatcher.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/EventDispatcher.h 2008-08-15 22:10:45 UTC (rev 72) @@ -66,7 +66,6 @@ /* add the handler to the appropriate list */ handlers[type].push_back(handler); - cout << "[debug] registered handler " << handler << endl; } /** @@ -158,7 +157,6 @@ } /* dispatch to handlers */ - cout << "[debug] dispatching event " << event << endl; list<EventHandler*>::iterator i; for (i = l->begin(); i != l->end(); i++) { (*i)->notify(event); Modified: trunk/common/Exception.h =================================================================== --- trunk/common/Exception.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/Exception.h 2008-08-15 22:10:45 UTC (rev 72) @@ -40,9 +40,23 @@ class Exception { public: - /** constructor/destructor */ - Exception(string r) + /** + * Constructor that sets the reason as empty. + * For an example of where this is appropriate, + * see the NonBlockingException class. + * @see NonBlockingException + */ + Exception() { + reason = ""; + } + + /** + * Constructor that sets the reason of the exception. + * @param r reason + */ + Exception(const string &r) + { reason = r; } Modified: trunk/common/FileOutputStream.h =================================================================== --- trunk/common/FileOutputStream.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/FileOutputStream.h 2008-08-15 22:10:45 UTC (rev 72) @@ -41,12 +41,6 @@ class FileOutputStream : public OutputStream { public: - /* default constructor */ - FileOutputStream() - { - - } - /** * Special constructor that creates a FileOutputStream * object and opens a file to write to. This is the @@ -56,15 +50,16 @@ * * @param path path of file to write to * @param binary if true, open the file in binary mode + * @param append if true, append rather than overwrite * * @throws Exception * If an error occurs, an Exception will be thrown. * The reason of the error can be found by calling the * getReason() method of the Exception object. */ - FileOutputStream(const string &path, bool binary=false) + FileOutputStream(const string &path, bool binary=false, bool append=false) { - this->open(path, binary); + this->open(path, binary, append); } virtual ~FileOutputStream() @@ -78,13 +73,14 @@ * * @param path path of file to write to * @param binary if true, open the file in binary mode + * @param append if true, append rather than overwrite * * @throws Exception * If an error occurs, an Exception will be thrown. * The reason of the error can be found by calling the * getReason() method of the Exception object. */ - void open(const string &path, bool binary=false) + void open(const string &path, bool binary=false, bool append=false) { /* check if file already open */ if (m_filestream.is_open()) @@ -95,6 +91,8 @@ mode = ios_base::out; if (binary) mode |= ios_base::binary; + if (append) + mode |= ios_base::app; m_filestream.open(path.c_str(), mode); if (!m_filestream.good()) { @@ -127,7 +125,7 @@ /* check for errors */ if (!m_filestream.good()) throw Exception("Error while writing to FileOutputStream"); - + /* success */ return len; } @@ -135,6 +133,7 @@ protected: /** file output stream */ ofstream m_filestream; + }; #endif Modified: trunk/common/InputStream.h =================================================================== --- trunk/common/InputStream.h 2008-07-28 01:33:11 UTC (rev 71) +++ trunk/common/InputStream.h 2008-08-15 22:10:45 UTC (rev 72) @@ -53,11 +53,7 @@ * @throws Exception * If an error occurs, an Exception must be thrown. */ - virtual int read(unsigned char *buf, int len) - { - /* this is only an interface - it can't actually read */ - return 0; - } + virtual int read(unsigned char *buf, int len)=0; }; Added: trunk/common/MessageManager.cpp =================================================================== --- trunk/common/MessageManager.cpp (rev 0) +++ trunk/common/MessageManager.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,100 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file MessageManager.cpp + * @ingroup Common + * + * @brief MessageManager class + * + * Contains the implementation for the MessageManager class, + * which dispatches strings to various OutputStreams depending + * on priority. + */ + +#include "ArnacawCommon.h" + +/* constructor */ +MessageManager::MessageManager() +{ + +} + +/* registers a stream for a single priority level */ +void MessageManager::registerStream(OutputStream *stream, int level) +{ + int lar = level; + registerStreamMP(stream, &lar, 1); +} + +/* registers a stream for multiple priority levels */ +void MessageManager::registerStreamMP(OutputStream *stream, int *levels, int pcount) +{ + /* check validity */ + if ( !stream || !levels || pcount < 1 ) + throw Exception("invalid data passed to registerStreamMP()"); + + /* register */ + list<OutputStream*> *curlist; + for (int i = 0; i < pcount; ++i) { + curlist = ®istered_streams[ levels[i] ]; + curlist->push_back(stream); + } +} + +/* unregisters a stream */ +void MessageManager::unregisterStream(OutputStream *stream) +{ + /* check validity */ + if ( !stream ) + throw Exception("NULL pointer passed to unregisterStream()"); + + /* search through the lists */ + map<int,list<OutputStream*> >::iterator i; + list<OutputStream*>::iterator j; + for (i = registered_streams.begin(); i != registered_streams.end(); i++) { + for (j = i->second.begin(); j != i->second.end(); j++) { + if ( *j == stream ) { + /* found one, remove it */ + i->second.erase(j); + } + } + } +} + +/* posts a message to a priority level */ +void MessageManager::postMessage(const string &message, int level) +{ + /* check priority level */ + if ( !registered_streams.count(level) ) { + /* nothing to notify */ + return; + } + + /* iterate through the priority levels */ + list<OutputStream*>::iterator i; + list<OutputStream*> *streams = ®istered_streams[level]; + stringstream msg2; + msg2 << message << endl; + for (i = streams->begin(); i != streams->end(); i++) { + (*i)->write( (const unsigned char *)msg2.str().c_str(), msg2.str().length() ); + } +} Added: trunk/common/MessageManager.h =================================================================== --- trunk/common/MessageManager.h (rev 0) +++ trunk/common/MessageManager.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,103 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file MessageManager.h + * @ingroup Common + * + * @brief MessageManager class + * + * Contains the definition of the MessageManager class, + * which passes strings to various registered OutputStreams + * depending on a given priority level. + */ + +#ifndef __ARNACAW_MESSAGEMANAGER_H__ +#define __ARNACAW_MESSAGEMANAGER_H__ + +/* Priority levels */ +#define MSGP_GENERAL 0 +#define MSGP_DEBUG 1 +#define MSGP_WARN 2 +#define MSGP_ERROR 3 + +/** + * Passes strings to various registered OutputStreams + * depending on a given priority level. + * @brief Selectively outputs messages + * @ingroup Common + */ +class MessageManager : public Singleton<MessageManager> +{ +public: + friend class Singleton<MessageManager>; + + /** + * Registers an output stream for a given priority level. + * @param stream + * Stream to register + * @param level + * Priority level + * @throws Exception + * If bad data is passed, an Exception will be thrown. + */ + void registerStream(OutputStream *stream, int level); + + /** + * Registers an output stream for multiple priority levels. + * @param stream + * Stream to register + * @param levels + * Pointer to array of priority levels + * @param pcount + * Number of elements in the array + * @throws Exception + * If bad data is passed, an Exception will be thrown. + */ + void registerStreamMP(OutputStream *stream, int *levels, int pcount); + + /** + * Unregisters a stream for all priority levels. + * If the stream is not registered, nothing will happen. + * @param stream + * Stream to unregister + */ + void unregisterStream(OutputStream *stream); + + /** + * Posts a message to a given priority level. + * @param message + * Message to post + * @param level + * Priority level to post to + */ + void postMessage(const string &message, int level); + +protected: + /** Constructor is protected because of Singleton */ + MessageManager(); + + /** Registered OutputStreams */ + map<int,list<OutputStream*> > registered_streams; + +}; + +#endif Added: trunk/common/NetworkSocket.cpp =================================================================== --- trunk/common/NetworkSocket.cpp (rev 0) +++ trunk/common/NetworkSocket.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,175 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file NetworkSocket.cpp + * @ingroup Common + * @brief NetworkSocket class + * Contains the implementation of the NetworkSocket + * class, which provides an adaptor to the sockets + * of the lower-level networking API. + */ + +#include "ArnacawCommon.h" + +/* default constructor */ +NetworkSocket::NetworkSocket() +{ + +} + +/* wrapper constructor */ +NetworkSocket::NetworkSocket(NLsocket socket) +{ + wrapped_socket = socket; +} + +/* destructor */ +NetworkSocket::~NetworkSocket() +{ + +} + +/* sets client behavior */ +void NetworkSocket::setClientMode() +{ + /* open the socket on a random port */ + wrapped_socket = nlOpen(0, ARNACAW_CONNTYPE); + if ( wrapped_socket == NL_INVALID ) { + /* error */ + stringstream s; + int err = nlGetError(); + s << "failed to set client mode on socket: " << nlGetErrorStr(err); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } +} + +/* sets server behavior */ +void NetworkSocket::setServerMode(uint16_t port) +{ + /* open the socket on the given port */ + wrapped_socket = nlOpen(port, ARNACAW_CONNTYPE); + if ( wrapped_socket == NL_INVALID ) { + /* error */ + stringstream s; + int err = nlGetError(); + s << "failed to set server mode on socket: " << nlGetErrorStr(err); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } +} + +/* writes to the socket */ +int NetworkSocket::write(const unsigned char *buf, int len) +{ + int result = nlWrite(wrapped_socket, buf, len); + if ( result == 0 ) { + /* retry later */ + throw NonBlockingException(); + } + if ( result == NL_INVALID ) { + /* error */ + int error = nlGetError(); + if ( error == NL_CON_PENDING ) { + /* retry later */ + throw NonBlockingException(); + } + stringstream s; + s << "error writing to socket: " << nlGetErrorStr(error); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } + return result; +} + +/* reads from the socket */ +int NetworkSocket::read(unsigned char *buf, int len) +{ + int result = nlRead(wrapped_socket, buf, len); + if ( result == NL_INVALID ) { + /* error */ + int error = nlGetError(); + if ( error == NL_CON_PENDING ) { + /* wait for the connection */ + throw NonBlockingException(); + } + stringstream s; + s << "error reading from socket: " << nlGetErrorStr(error); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } + return result; +} + +/* connects to a remote machine */ +void NetworkSocket::connect(const string &address, uint16_t port) +{ + /* resolve the address */ + NLaddress addr; + stringstream tmp; + tmp << address << ":" << port; + if ( nlGetAddrFromName(tmp.str().c_str(), &addr) == NL_FALSE ) { + /* error */ + stringstream s; + int err = nlGetError(); + s << "error resolving hostname: " << nlGetErrorStr(err); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } + + /* connect */ + if ( nlConnect(wrapped_socket, &addr) == NL_FALSE ) { + /* error */ + stringstream s; + int err = nlGetError(); + s << "error connecting socket: " << nlGetErrorStr(err); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } +} + +/* disconnects the socket */ +void NetworkSocket::disconnect() +{ + nlClose(wrapped_socket); +} + +/* accepts a connection */ +NLsocket NetworkSocket::acceptConnection() +{ + /* try to accept a connection */ + NLsocket retval = nlAcceptConnection(wrapped_socket); + if ( retval == NL_INVALID ) { + /* failed */ + int error = nlGetError(); + if ( error == NL_NO_PENDING ) + throw NonBlockingException(); /* no pending connections */ + stringstream s; + s << "error accepting connection: " << nlGetErrorStr(error); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + throw Exception(s.str()); + } + + /* got a connection */ + /* TODO: Check for banned IP */ + return retval; +} Added: trunk/common/NetworkSocket.h =================================================================== --- trunk/common/NetworkSocket.h (rev 0) +++ trunk/common/NetworkSocket.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,133 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file NetworkSocket.h + * @ingroup Common + * @brief NetworkSocket class + * Defines the NetworkSocket class, which provides an + * adaptor to the sockets of the lower-level networking API. + */ + +#ifndef __ARNACAW_NETWORKSOCKET_H__ +#define __ARNACAW_NETWORKSOCKET_H__ + +/* Type of connection to use */ +#define ARNACAW_CONNTYPE NL_RELIABLE_PACKETS + +/** + * Thrown when a non-blocking networking operation cannot + * be completed at the given time. The operation should + * be retried at a later time. + * @brief Non-blocking I/O exception + * @ingroup Common + */ +class NonBlockingException : public Exception +{ +public: + /** Default constructor for when no extended information is needed. */ + NonBlockingException() { } + + /* inherited constructor */ + NonBlockingException(const string &reason) : Exception(reason) { } + +}; + +/** + * Provides an adaptor to the lower-level networking API's sockets. + * @brief Socket adaptor + * @ingroup Common + */ +class NetworkSocket : public InputStream, + public OutputStream +{ +public: + /** + * Initializes an unconnected socket. + */ + NetworkSocket(); + + /** + * Creates a wrapper around an existing HawkNL socket. + */ + NetworkSocket(NLsocket socket); + + /* destructor */ + virtual ~NetworkSocket(); + + /* reads from the socket */ + virtual int read(unsigned char *buf, int len); + + /* writes to the socket */ + virtual int write(const unsigned char *buf, int len); + + + + /** + * Configures the socket for client behavior. + * This opens the socket on a random port and does not listen. + * @note This method should not be used with objects created + * using the wrapper constructor. + * @throws Exception + * If an error occurs, an Exception will be thrown. + */ + void setClientMode(); + + /** + * Configures the socket for server behavior. + * This opens the socket on a given port and listens for connections. + * @param port Port to listen on + * @throws Exception + * If an error occurs, an Exception will be thrown. + */ + void setServerMode(uint16_t port); + + /** + * Connects the socket to a remote machine. + * @param address Address of remote machine + * @param port Port to connect to + * @throws Exception + * If an error occurs, an Exception will be thrown. + */ + void connect(const string &address, uint16_t port); + + /** + * Disconnects the socket. + */ + void disconnect(); + + /** + * Accepts a connection if one is pending. + * @throws NonBlockingException + * If no connections were pending, a NonBlockingException will be thrown. + * @throws Exception + * If setServerMode() has not been called, an Exception will be thrown. + * @returns A connected socket. + */ + NLsocket acceptConnection(); + +protected: + /** Wrapped socket */ + NLsocket wrapped_socket; + +}; + +#endif Added: trunk/common/Packet.cpp =================================================================== --- trunk/common/Packet.cpp (rev 0) +++ trunk/common/Packet.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,113 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Packet.cpp + * @ingroup Common + * @brief Packet class + * Contains the implementation of the Packet class, which + * stores data in a form suitable for network transmission. + */ + +#include "ArnacawCommon.h" + +/* packet header static members */ +uint32_t PacketHeader::next_id=0; + +/* packet header constructor */ +PacketHeader::PacketHeader() +{ + packet_id = next_id++; +} + +/* packet header serialization */ +void PacketHeader::serialize(OutputStream &dst) +{ + /* first field is always 0x3F9B */ + SerializableUint16 field1(0x3F9B); + field1.serialize(dst); + + /* next field is the ID */ + SerializableUint32 field2(packet_id); + field2.serialize(dst); + + /* next field is the packet type */ + SerializableUint16 field3(packet_type); + field3.serialize(dst); + + /* last field is the data length */ + SerializableUint32 field4(data_length); + field4.serialize(dst); +} + +/* packet header deserialization */ +void PacketHeader::deserialize(InputStream &src) +{ + /* first field should always be 0x3F9B */ + SerializableUint16 field1; + field1.deserialize(src); + if ( field1.getNumber() != 0x3F9B ) { + /* bad packet */ + throw PacketException("corrupt header"); + } + + /* next field is the ID */ + SerializableUint32 field2; + try { + field2.deserialize(src); + } catch (Exception &e) + { + throw PacketException("corrupt header"); + } + packet_id = field2.getNumber(); + + /* next is the packet type */ + SerializableUint16 field3; + try { + field3.deserialize(src); + } catch (Exception &e) + { + throw PacketException("corrupt header"); + } + packet_type = field3.getNumber(); + + /* finally, the data length */ + SerializableUint32 field4; + try { + field4.deserialize(src); + } catch (Exception &e) + { + throw PacketException("corrupt header"); + } + data_length = field4.getNumber(); +} + +/* default constructor for packets */ +Packet::Packet() +{ + +} + +/* destructor for packets */ +Packet::~Packet() +{ + +} Added: trunk/common/Packet.h =================================================================== --- trunk/common/Packet.h (rev 0) +++ trunk/common/Packet.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,175 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Packet.h + * @ingroup Common + * @brief Packet class + * Defines the Packet class, which provides means to store + * data for transport over the network. + */ + +#ifndef __ARNACAW_PACKET_H__ +#define __ARNACAW_PACKET_H__ + +/* Packet type identifiers */ + +/** + * Stores the header of a network packet. + * @brief Network packet header + * @ingroup Common + */ +class PacketHeader : public Serializable +{ +public: + /** + * Creates a new header and automatically sets the packet ID. + */ + PacketHeader(); + + /** @throws PacketException */ + virtual void serialize(OutputStream &dst); + + /** @throws PacketException */ + virtual void deserialize(InputStream &src); + + /** + * Gets the packet ID. + * @returns the packet ID. + */ + inline uint32_t getPacketID() { return packet_id; } + + /** + * Gets the packet type. + * @returns the packet type + */ + inline uint16_t getPacketType() { return packet_type; } + + /** + * Sets the packet type. + * @param type packet type + */ + inline void setPacketType(uint16_t type) { packet_type = type; } + + /** + * Gets the data length. + * @returns the length of the data + */ + inline uint32_t getDataLength() { return data_length; } + + /** + * Sets the data length. + * @param length length of the data + */ + inline void setDataLength(uint32_t length) { data_length = length; } + +protected: + /* The first field is always 0x3F9B. Offset 0, 16 bits */ + + /** Packet ID, the second field, offset 16, 32 bits */ + uint32_t packet_id; + + /** Packet type, the third field, offset 48, 16 bits */ + uint16_t packet_type; + + /** Length of data, the fourth field, offset 64, 32 bits */ + uint32_t data_length; + + /** Serial counter to generate packet IDs */ + static uint32_t next_id; + +}; + +/** + * Provides means to store data for transport over the network. + * Objects of Packet classes should not be created directly. + * Use the PacketFactory class instead. All packet types should + * have an extended version of this class for themselves. They + * should also have a registered extension of the SpecificPacketFactory + * class. + * @see + * PacketFactory + * SpecificPacketFactory + * @brief Network packet + * @ingroup Common + */ +class Packet : public Serializable +{ +public: + /** + * Constructs a new packet with default values. + */ + Packet(); + + /** + * Constructor that sets the type of the packet. + * This should not be called normally; it should be + * used in the constructor of extended Packet classes. + * @param type Type of packet + */ + Packet(uint16_t type); + + /* destructor */ + virtual ~Packet(); + + /** + * Conveinence method that gets the packet type from the header. + * @returns packet type + */ + inline uint16_t getPacketType() { return packet_header.getPacketType(); } + + /** + * Allows modification of the packet header. + * @returns pointer to the packet header object + */ + inline PacketHeader *getPacketHeader() { return &packet_header; } + + /** @throws PacketException */ + virtual void serialize(OutputStream &dst)=0; + + /** @throws PacketException */ + virtual void deserialize(InputStream &src)=0; + +protected: + /** Packet header. First field, offset 0, 96 bits */ + PacketHeader packet_header; + + /* Type-specific packet data goes in extended versions of this class. */ + +}; + +/** + * This Exception is raised when a non-fatal error occurs + * related to a packet. This is typically the arrival + * of a corrupt packet. When this is thrown, the connection + * from which the packet originated is automatically terminated. + * @brief Invalid packet error + */ +class PacketException : public Exception +{ +public: + PacketException(const Packet &pkt); + +protected: + +}; + +#endif Added: trunk/common/PacketFactory.h =================================================================== --- trunk/common/PacketFactory.h (rev 0) +++ trunk/common/PacketFactory.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,102 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketFactory.h + * @ingroup Common + * @brief PacketFactory class + * Defines the PacketFactory class, which dynamically creates + * objects of specialized Packet classes given a type identifier. + */ + +#ifndef __ARNACAW_PACKETFACTORY_H__ +#define __ARNACAW_PACKETFACTORY_H__ + +/** + * Creates and destroys a specific type of packet. + * @warning The type passed to the template must be an + * extended version of the Packet class. It + * must not be a pointer. + * @brief Backend of PacketFactory + * @ingroup Common + */ +class SpecificPacketFactory : public Singleton<SpecificPacketFactory> +{ +public: + friend class Singleton<SpecificPacketFactory>; + + /** + * Creates an object. + * @throws Exception + * @returns A new object. + */ + virtual Packet * create()=0; + + /** + * Destroys an object. + * @param obj Object to destroy + * @throws Exception + */ + virtual void destroy(Packet *pkt)=0; + +protected: + /** + * Do not create objects of this class directly. + * Use the getSingleton() and getSingletonPtr() + * methods instead. + */ + SpecificPacketFactory(); + +}; + +/** + * Dynamically creates objects of specialized Packet classes + * given a type identifier. + * @brief Creates specific packet types + * @ingroup Common + */ +class PacketFactory : public Singleton<PacketFactory> +{ +public: + friend class Singleton<PacketFactory>; + + /** + * Registers a new factory for creating events. + * @param factory Factory to register + * @throws Exception + * If a NULL pointer is passed, an Exception will + * be thrown. + */ + +protected: + /** + * Do not create objects of this class directly. + * Use the getSingleton() and getSingletonPtr() + * methods instead. + */ + PacketFactory(); + + /** Registered packet factories */ + map<uint16_t, SpecificPacketFactory*> registered_factories; + +}; + +#endif Added: trunk/common/PacketQueue.cpp =================================================================== --- trunk/common/PacketQueue.cpp (rev 0) +++ trunk/common/PacketQueue.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,171 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketQueue.cpp + * @ingroup Common + * @brief PacketQueue class + * Contains the implementation for the PacketQueue + * class, which stores packets waiting for retrieval + * or transmission. + */ + +#include "ArnacawCommon.h" + +/* default constructor */ +PacketQueue::PacketQueue() +{ + +} + +/* destructor */ +PacketQueue::~PacketQueue() +{ + /* free packets in outgoing queue */ + Packet *current; + while ( !outgoing_packets.empty() ) { + current = outgoing_packets.front(); + if ( current ) + delete current; + outgoing_packets.pop(); + } + + /* free packets in incoming queue */ + while ( !incoming_packets.empty() ) { + current = incoming_packets.front(); + if ( current ) + delete current; + incoming_packets.pop(); + } + + /* flag all streams as invalid */ + set<RawDataOutputStream*>::iterator i; + for (i = packets_incomplete.begin(); i != packets_incomplete.end(); i++) { + if (*i) + (*i)->flagInvalid(); + } +} + +/* begins packet construction */ +RawDataOutputStream * PacketQueue::beginPacket() +{ + /* allocate a new stream */ + RawDataOutputStream *retval = new RawDataOutputStream(AO_MAX_PACKET_SIZE); + packets_incomplete.insert(retval); + return retval; +} + +/* finalizes packet construction */ +void PacketQueue::finalizePacket(RawDataOutputStream *pkt) +{ + /* check packet stream */ + if ( !pkt ) + throw Exception("NULL pointer passed to finalizePacket()"); + if ( packets_incomplete.count(pkt) == 0 ) + throw Exception("unrecognized RawDataOutputStream passed to finalizePacket()"); + + /* build a packet */ + RawDataInputStream s(pkt->getBuffer(), pkt->getCurrentLength()); + Packet *final = new Packet; + final->deserialize(s); + + /* enqueue the packet */ + outgoing_packets.push(final); + + /* release the stream */ + pkt->flagInvalid(); + packets_incomplete.erase(pkt); + delete pkt; +} + +/* reads next packet */ +Packet * PacketQueue::readPacket() +{ + /* check if any packets are queued */ + if ( incoming_packets.empty() ) { + /* incoming queue is empty */ + return NULL; + } + + /* retrieve next packet */ + Packet *retval = incoming_packets.front(); + incoming_packets.pop(); + return retval; +} + +/* releases an incoming packet */ +void PacketQueue::releasePacket(Packet *pkt) +{ + /* check pointer */ + if ( !pkt ) + throw Exception("NULL pointer passed to PacketQueue::releasePacket()"); + + /* free the pointer */ + delete pkt; +} + +/* reads a packet from a socket */ +void PacketQueue::readSocket(NetworkSocket *sock) +{ + /* check pointer */ + if ( !sock ) + throw Exception("NULL pointer passed to PacketQueue::readSocket()"); + + /* read a packet */ + Packet *pkt = new Packet; + try { + pkt->deserialize(*sock); + } + catch (NonBlockingException &e) { + /* not ready for read operations */ + delete pkt; + return; + } + + /* enqueue the received packet */ + incoming_packets.push(pkt); +} + +/* writes a packet to a socket */ +void PacketQueue::writeSocket(NetworkSocket *sock) +{ + /* check if any packets are waiting to be sent */ + if ( outgoing_packets.empty() ) + return; /* no packets to send */ + + /* check pointer */ + if ( !sock ) + throw Exception("NULL pointer passed to PacketQueue::writeSocket()"); + + /* write a packet */ + Packet *pkt = outgoing_packets.front(); + try { + pkt->serialize(*sock); + } + catch (NonBlockingException &e) { + /* not ready for write operations */ + return; + } + + /* remove the outgoing packet */ + outgoing_packets.pop(); + delete pkt; +} Added: trunk/common/PacketQueue.h =================================================================== --- trunk/common/PacketQueue.h (rev 0) +++ trunk/common/PacketQueue.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,117 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PacketQueue.h + * @ingroup Common + * @brief PacketQueue class + * Defines the PacketQueue class, which stores packets + * waiting for retrieval or transmission. + */ + +#ifndef __ARNACAW_PACKETQUEUE_H__ +#define __ARNACAW_PACKETQUEUE_H__ + +/** + * Stores packets waiting for retrieval or transmission. + * @brief Stores packets + * @ingroup Common + */ +class PacketQueue +{ +public: + /** + * Creates an empty packet queue. + */ + PacketQueue(); + + /* Destructor */ + virtual ~PacketQueue(); + + /** + * Begins construction of a packet. + * @returns a pointer to a stream for a new packet + */ + RawDataOutputStream * beginPacket(); + + /** + * Finalizes a packet and enqueues it. + * @param pkt Stream from beginPacket() to finalize + * @throws Exception + * If a stream is passed that did not come from this object's + * beginPacket() method, an Exception will be thrown. + */ + void finalizePacket(RawDataOutputStream *pkt); + + /** + * Reads the next packet from the queue. + * The object returned should be copied, and the + * returned pointer should be freed using releasePacket(). + * @returns a pointer to the next packet in queue, or NULL + * if the queue is empty. + */ + Packet * readPacket(); + + /** + * Frees a packet returned by readPacket(). + * @param pkt Packet to free + * @throws Exception + * If an invalid pointer is passed, an Exception will be thrown. + */ + void releasePacket(Packet *pkt); + + /** + * Reads a packet from the provided socket. + * The socket should be ready for read operations. + * @param sock Socket to read from + * @throws Exception + * If there is a problem with the socket other than + * it not being ready for read operations, an + * Exception will be thrown. + */ + void readSocket(NetworkSocket *sock); + + /** + * Writes the next packet to the provided socket. + * The socket should be ready for write operations. + * If there are no outgoing packets in the queue, + * nothing will be written to the socket. + * @param sock Socket to write to + * @throws Exception + * If there is a problem with the socket other than + * it not being ready for write operations, an + * Exception will be thrown. + */ + void writeSocket(NetworkSocket *sock); + +protected: + /** Packets waiting to be sent. */ + queue<Packet*> outgoing_packets; + + /** Packets waiting to be retrieved. */ + queue<Packet*> incoming_packets; + + /** Packets in production. */ + set<RawDataOutputStream*> packets_incomplete; + +}; + +#endif Added: trunk/common/RawDataInputStream.cpp =================================================================== --- trunk/common/RawDataInputStream.cpp (rev 0) +++ trunk/common/RawDataInputStream.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,65 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file RawDataInputStream.cpp + * @ingroup Common + * @brief RawDataInputStream class + * Contains the implementation of the RawDataInputStream + * class, which handles read operations from raw data + * stored in memory. + */ + +#include "ArnacawCommon.h" + +/* default constructor */ +RawDataInputStream::RawDataInputStream() +{ + current_pos = 0; +} + +/* wrapper constructor */ +RawDataInputStream::RawDataInputStream(const unsigned char *buf, int length) +{ + setBuffer(buf, length); +} + +/* reads from the buffer */ +int RawDataInputStream::read(unsigned char *buf, int len) +{ + /* check pointers */ + if ( !buf ) + throw Exception("NULL pointer passed to RawDataInputStream::read()"); + if ( len <= 0 ) + throw Exception("invalid length passed to RawDataInputStream::read()"); + + /* check if there is enough data available */ + if ( current_pos + len > buffer_length ) { + /* not enough, read through the end */ + int transfer = buffer_length - current_pos; + memcpy(buf, buffer, transfer); + current_pos = buffer_length; + return transfer; + } + memcpy(buf, buffer, len); + current_pos += len; + return len; +} Added: trunk/common/RawDataInputStream.h =================================================================== --- trunk/common/RawDataInputStream.h (rev 0) +++ trunk/common/RawDataInputStream.h 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,86 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file RawDataInputStream.h + * @ingroup Common + * @brief RawDataInputStream class + * Defines the RawDataInputStream class, which handles + * read operations from raw data in memory. + */ + +#ifndef __ARNACAW_RAWDATAINPUTSTREAM_H__ +#define __ARNACAW_RAWDATAINPUTSTREAM_H__ + +/** + * Handles read operations from raw data in memory. + * @brief Reads from a memory buffer + * @ingroup Common + */ +class RawDataInputStream : public InputStream +{ +public: + /** + * Creates an empty stream. + */ + RawDataInputStream(); + + /** + * Creates a stream wrapped around a buffer. + * @param buf buffer to wrap + * @param length length of buffer + */ + RawDataInputStream(const unsigned char *buf, int length); + + /* implemented as part of InputStream */ + virtual int read(unsigned char *buf, int len); + + /** + * Gets the buffer. + * @returns a pointer to the buffer + */ + inline const unsigned char * getBuffer() { return buffer; } + + /** + * Sets the buffer. + * @param buf pointer to the new buffer + * @param length length of the new buffer + */ + inline void setBuffer(const unsigned char *buf, int length) + { + buffer = buf; + buffer_length = length; + current_pos = 0; + } + +protected: + /** Wrapped buffer */ + const unsigned char *buffer; + + /** Length of the buffer */ + int buffer_length; + + /** Current position in the buffer */ + int current_pos; + +}; + +#endif Added: trunk/common/RawDataOutputStream.cpp =================================================================== --- trunk/common/RawDataOutputStream.cpp (rev 0) +++ trunk/common/RawDataOutputStream.cpp 2008-08-15 22:10:45 UTC (rev 72) @@ -0,0 +1,82 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file RawDataOutputStream.cpp + * @ingroup Common + * @brief RawDataOutputStream class + * Contains the implementation for the RawDataOutputStream class, + * which handles write operations to a buffer in memory. + */ + +#include "ArnacawCommon.h" + +/* wrapper constructor */ +RawDataOutputStream::RawDataOutputStream(int length) +{ + /* check validity */ + if ( length < 1 ) + throw Exception("invalid length specified in RawDataOutputStream constructor"); + + /* create the buffer */ + buffer = new unsigned char[length]; + if ( !buffer ) + throw Exception("not enough memory to create buffer in RawDataOutputStream"); + + /* set up variables */ + invalid = false; + maximum_length = length; + current_pos = 0; +} + +/* destructor */ +RawDataOutputStream::~RawDataOutputStream() +{ + /* free the buffer */ + if ( buffer ) + delete [] buffer; +} + +/* writes to the buffer */ +int RawDataOutputStream::write(const unsigned char *buf, int len) +{ + /* check validity */ + if ( isInvalid() ) + th... [truncated message content] |
From: <sh...@us...> - 2008-07-28 01:33:05
|
Revision: 71 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=71&view=rev Author: shoyru Date: 2008-07-28 01:33:11 +0000 (Mon, 28 Jul 2008) Log Message: ----------- begin implementing server internal messaging; backing up code Modified Paths: -------------- trunk/server/ArnacawServer.h trunk/server/Makefile.am Added Paths: ----------- trunk/server/LogManager.cpp trunk/server/LogManager.h trunk/server/MessageManager.cpp trunk/server/MessageManager.h trunk/server/PathBuilder.cpp trunk/server/PathBuilder.h Modified: trunk/server/ArnacawServer.h =================================================================== --- trunk/server/ArnacawServer.h 2008-07-26 17:44:01 UTC (rev 70) +++ trunk/server/ArnacawServer.h 2008-07-28 01:33:11 UTC (rev 71) @@ -65,5 +65,8 @@ /* Server component */ #include "CLIArgumentInterpreter.h" #include "Server.h" +#include "MessageManager.h" +#include "LogManager.h" +#include "PathBuilder.h" #endif Added: trunk/server/LogManager.cpp =================================================================== --- trunk/server/LogManager.cpp (rev 0) +++ trunk/server/LogManager.cpp 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,66 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file LogManager.cpp + * @ingroup Server + * + * @brief LogManager class + * + * Contains the implementation of the LogManager class, which + * manages an assortment of log files used by the server. + */ + +#include "ArnacawServer.h" + +/* constructor */ +LogManager::LogManager() +{ + +} + +/* creates a new log file */ +void LogManager::newLog(const string &name, int level) +{ + /* check if log has already been registered */ + if ( (bool)managed_logs.count(name) ) { + stringstream s; + s << "log '" << name << "' already registered"; + throw Exception(s.str()); + } + + /* try to open the log file */ + string filepath = PathBuilder::getSingleton().LogFile(name); + try { + FileOutputStream *fos = new FileOutputStream(filepath); + } catch ( Exception &e ) + { + /* problem with the log file */ + stringstream s; + s << "failed to open logfile " << filepath; + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + s.str(""); + s << "exception: " e.getReason(); + MessageManager::getSingleton().postMessage(s.str(), MSGP_ERROR); + return; + } + +} Added: trunk/server/LogManager.h =================================================================== --- trunk/server/LogManager.h (rev 0) +++ trunk/server/LogManager.h 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,88 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file LogManager.h + * @ingroup Server + * + * @brief LogManager class + * + * Defines the LogManager class, which manages an + * assortment of log files used by the server. + */ + +#ifndef __ARNACAW_LOGMANAGER_H__ +#define __ARNACAW_LOGMANAGER_H__ + +/** + * Manages an assortment of log files used by the server. + * @brief Manages log files + * @ingroup Server + */ +class LogManager : public Singleton<LogManager> +{ +public: + friend class Singleton<LogManager>; + friend class ServerApplication; + + /** + * Registers a new log file for a given message priority. + * @param name + * Name of the log file + * @param level + * Message priority level to log + * @throws Exception + * An Exception is thrown if the given name is already registered. + */ + void newLog(const string &name, int level); + + /** + * Closes and releases a registered log. + * If the given name is not registered, the method will return. + * @param name + * Name of the log file to close + */ + void closeLog(const string &name); + +protected: + /** + * Do not create objects of this class directly. + * Use the getSingleton() or getSingletonPtr() + * static methods instead. + */ + LogManager(); + + /** + * Closes and releases all open logs. + */ + void closeAllLogs(); + + /** + * Creates the default logs - standard, error, debug. + */ + void initLogging(); + + /** Open logs. */ + map<string,FileOutputStream*> managed_logs; + +}; + +#endif Modified: trunk/server/Makefile.am =================================================================== --- trunk/server/Makefile.am 2008-07-26 17:44:01 UTC (rev 70) +++ trunk/server/Makefile.am 2008-07-28 01:33:11 UTC (rev 71) @@ -4,6 +4,7 @@ # See the LICENSE file for details bin_PROGRAMS = arnacawd -arnacawd_SOURCES = Server.cpp ServerMain.cpp CLIArgumentInterpreter.cpp +arnacawd_SOURCES = Server.cpp ServerMain.cpp CLIArgumentInterpreter.cpp \ + MessageManager.cpp arnacawd_CPPFLAGS = -I../common arnacawd_LDADD = $(LIBS) Added: trunk/server/MessageManager.cpp =================================================================== --- trunk/server/MessageManager.cpp (rev 0) +++ trunk/server/MessageManager.cpp 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,92 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file MessageManager.cpp + * @ingroup Server + * + * @brief MessageManager class + * + * Contains the implementation for the MessageManager class, + * which dispatches strings to various OutputStreams depending + * on priority. + */ + +#include "ArnacawServer.h" + +/* constructor */ +MessageManager::MessageManager() +{ + +} + +/* registers a stream for a single priority level */ +void MessageManager::registerStream(OutputStream *stream, int level) +{ + int lar = level; + registerStreamMP(stream, &lar, 1); +} + +/* registers a stream for multiple priority levels */ +void MessageManager::registerStreamMP(OutputStream *stream, int *levels, int pcount) +{ + /* check validity */ + if ( !stream || !levels || pcount < 1 ) + throw Exception("invalid data passed to registerStreamMP()"); + + /* register */ + list<OutputStream*> *curlist; + for (int i = 0; i < pcount; ++i) { + curlist = ®istered_streams[ levels[i] ]; + curlist->push_back(stream); + } +} + +/* unregisters a stream */ +void MessageManager::unregisterStream(OutputStream *stream) +{ + /* check validity */ + if ( !stream ) + throw Exception("NULL pointer passed to unregisterStream()"); + + /* search through the lists */ + map<int,list<OutputStream*> >::iterator i; + list<OutputStream*>::iterator j; + for (i = registered_streams.begin(); i != registered_streams.end(); i++) { + for (j = i->second.begin(); j != i->second.end(); j++) { + if ( *j == stream ) { + /* found one, remove it */ + i->second.erase(j); + } + } + } +} + +/* posts a message to a priority level */ +void MessageManager::postMessage(const string &message, int level) +{ + /* iterate through the priority level */ + list<OutputStream*>::iterator i; + list<OutputStream*> *streams; + for (i = streams->begin(); i != streams->end(); i++) { + (*i)->write( (const unsigned char *)message.c_str(), message.length() ); + } +} Added: trunk/server/MessageManager.h =================================================================== --- trunk/server/MessageManager.h (rev 0) +++ trunk/server/MessageManager.h 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,101 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file MessageManager.h + * @ingroup Server + * + * @brief MessageManager class + * + * Contains the definition of the MessageManager class, + * which passes strings to various registered OutputStreams + * depending on a given priority level. + */ + +#ifndef __ARNACAW_MESSAGEMANAGER_H__ +#define __ARNACAW_MESSAGEMANAGER_H__ + +/* Priority levels */ +#define MSGP_GENERAL 0 +#define MSGP_DEBUG 1 +#define MSGP_WARN 2 +#define MSGP_ERROR 3 + +/** + * Passes strings to various registered OutputStreams + * depending on a given priority level. + * @brief Selectively outputs messages + * @ingroup Server + */ +class MessageManager : public Singleton<MessageManager> +{ +public: + friend class Singleton<MessageManager>; + + /** + * Registers an output stream for a given priority level. + * @param stream + * Stream to register + * @param level + * Priority level + */ + void registerStream(OutputStream *stream, int level); + + /** + * Registers an output stream for multiple priority levels. + * @param stream + * Stream to register + * @param levels + * Pointer to array of priority levels + * @param pcount + * Number of elements in the array + * @throws Exception + * If bad data is passed, an Exception will be thrown. + */ + void registerStreamMP(OutputStream *stream, int *levels, int pcount); + + /** + * Unregisters a stream for all priority levels. + * If the stream is not registered, nothing will happen. + * @param stream + * Stream to unregister + */ + void unregisterStream(OutputStream *stream); + + /** + * Posts a message to a given priority level. + * @param message + * Message to post + * @param level + * Priority level to post to + */ + void postMessage(const string &message, int level); + +protected: + /** Constructor is protected because of Singleton */ + MessageManager(); + + /** Registered OutputStreams */ + map<int,list<OutputStream*> > registered_streams; + +}; + +#endif Added: trunk/server/PathBuilder.cpp =================================================================== --- trunk/server/PathBuilder.cpp (rev 0) +++ trunk/server/PathBuilder.cpp 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,48 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PathBuilder.cpp + * @ingroup Server + * Contains the implementation for the PathBuilder class, + * which generates absolute filepaths at runtime. + */ + +#include "ArnacawServer.h" + +/* constructor */ +PathBuilder::PathBuilder() +{ + +} + +/* log filepath */ +string & PathBuilder::LogFile(const string &name) +{ +#ifdef POSIX + /* temporary implementation for Linux */ + string retval("/var/log/arnacaw/"); + retval += name; + return retval; +#elif WIN32 + /* TODO: implement */ +#endif +} Added: trunk/server/PathBuilder.h =================================================================== --- trunk/server/PathBuilder.h (rev 0) +++ trunk/server/PathBuilder.h 2008-07-28 01:33:11 UTC (rev 71) @@ -0,0 +1,73 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file PathBuilder.h + * @ingroup Server + * + * @brief PathBuilder class + * + * Defines the PathBuilder class, which creates absolute + * filepaths at runtime. + */ + +#ifndef __ARNACAW_PATHBUILDER_H__ +#define __ARNACAW_PATHBUILDER_H__ + +/** + * Generates absolute filepaths at runtime. + * @note New methods are frequently added to this class + * as new features require them. However, no methods + * will be removed; they will instead be deprecated, + * then removed at the next major version. + * @brief Filepaths + * @ingroup Server + */ +class PathBuilder : public Singleton<PathBuilder> +{ +public: + friend class Singleton<PathBuilder>; + + /** + * Generates a path to a log file. + * @param name + * Name of the log file + * @returns an absolute path to the log file. + * + * @internal + * The current implementation is temporary. + * It assumes a fixed log directory of /var/log/arnacaw. + * This should be changed to read the log directory + * from a configuration file. + */ + string & LogFile( const string &name ); + +protected: + /** + * Do not create objects of this class directly. + * Use the getSingleton() and getSingletonPtr() + * methods instead. + */ + PathBuilder(); + +}; + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-26 17:43:53
|
Revision: 70 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=70&view=rev Author: shoyru Date: 2008-07-26 17:44:01 +0000 (Sat, 26 Jul 2008) Log Message: ----------- moving some stuff around Modified Paths: -------------- trunk/common/Event.h trunk/docs/design/Arnacaw.dia Modified: trunk/common/Event.h =================================================================== --- trunk/common/Event.h 2008-07-11 20:46:54 UTC (rev 69) +++ trunk/common/Event.h 2008-07-26 17:44:01 UTC (rev 70) @@ -100,6 +100,7 @@ EVENT_MOUSEMOTION = 21847, #elif COMPONENT == 2 /* 43690 - 65535: SERVER */ + EVENT_RELOADCONFIG = 43690, #endif }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-11 20:46:46
|
Revision: 69 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=69&view=rev Author: shoyru Date: 2008-07-11 13:46:54 -0700 (Fri, 11 Jul 2008) Log Message: ----------- move from SDL_net to HawkNL; retest serialization code Modified Paths: -------------- trunk/client/ArnacawClient.h trunk/common/ArnacawCommon.h trunk/common/SerializableBaseTypes.h trunk/config.h.in trunk/configure.ac trunk/server/Makefile.am trunk/server/Server.cpp Modified: trunk/client/ArnacawClient.h =================================================================== --- trunk/client/ArnacawClient.h 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/client/ArnacawClient.h 2008-07-11 20:46:54 UTC (rev 69) @@ -61,6 +61,9 @@ /* Common component */ #include "ArnacawCommon.h" +/* SDL headers */ +#include <SDL/SDL.h> + /* Client component */ #include "Client.h" #include "Display.h" Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/common/ArnacawCommon.h 2008-07-11 20:46:54 UTC (rev 69) @@ -77,9 +77,8 @@ using namespace std; -/* SDL headers */ -#include <SDL/SDL.h> -#include <SDL/SDL_net.h> +/* HawkNL headers */ +#include <nl.h> /* Arnacaw headers */ #include "Exception.h" Modified: trunk/common/SerializableBaseTypes.h =================================================================== --- trunk/common/SerializableBaseTypes.h 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/common/SerializableBaseTypes.h 2008-07-11 20:46:54 UTC (rev 69) @@ -93,8 +93,7 @@ /* serialize */ void serialize(OutputStream &dst) { - unsigned short tmp = 0; - SDLNet_Write16(wrapped, &tmp); + unsigned short tmp = nlSwaps(wrapped); dst.write((unsigned char*)&tmp, sizeof(unsigned short)); } @@ -103,7 +102,7 @@ { unsigned short tmp = 0; src.read((unsigned char*)&tmp, sizeof(unsigned short)); - wrapped = SDLNet_Read16(&tmp); + wrapped = nlSwaps(tmp); } /** @@ -138,8 +137,7 @@ /* serialize */ void serialize(OutputStream &dst) { - unsigned int tmp = 0; - SDLNet_Write32(wrapped, &tmp); + unsigned int tmp = nlSwapl(wrapped); dst.write((unsigned char*)&tmp, sizeof(unsigned int)); } @@ -148,7 +146,7 @@ { unsigned int tmp = 0; src.read((unsigned char*)&tmp, sizeof(unsigned int)); - wrapped = SDLNet_Read32(&tmp); + wrapped = nlSwapl(tmp); } /** @@ -225,7 +223,7 @@ void serialize(OutputStream &dst) { signed short tmp = 0; - SDLNet_Write16((Uint16)wrapped, (Uint16*)&tmp); + tmp = (signed short)nlSwaps((unsigned short)wrapped); dst.write((unsigned char*)&tmp, sizeof(signed short)); } @@ -234,7 +232,7 @@ { signed short tmp = 0; src.read((unsigned char*)&tmp, sizeof(signed short)); - wrapped = SDLNet_Read16(&tmp); + wrapped = (signed short)nlSwaps((unsigned short)tmp); } /** @@ -269,8 +267,8 @@ /* serialize */ void serialize(OutputStream &dst) { - signed int tmp = 0; - SDLNet_Write32(wrapped, &tmp); + signed int tmp; + tmp = (signed int)nlSwapl((unsigned int)wrapped); dst.write((unsigned char*)&tmp, sizeof(signed int)); } @@ -279,7 +277,7 @@ { signed int tmp = 0; src.read((unsigned char*)&tmp, sizeof(signed int)); - wrapped = SDLNet_Read32(&tmp); + wrapped = (signed int)nlSwapl((unsigned int)tmp); } /** Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/config.h.in 2008-07-11 20:46:54 UTC (rev 69) @@ -3,8 +3,8 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `SDL_net' library (-lSDL_net). */ -#undef HAVE_LIBSDL_NET +/* Define to 1 if you have the `NL' library (-lNL). */ +#undef HAVE_LIBNL /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/configure.ac 2008-07-11 20:46:54 UTC (rev 69) @@ -31,16 +31,18 @@ AC_PROG_CC # Checks for libraries. -AM_PATH_SDL([1.2.0],,AC_MSG_ERROR([ *** SDL needed for compilation!])) -AC_CHECK_LIB([SDL_net], - [SDLNet_Init], +if test x$enable_client = xyes; then + AM_PATH_SDL([1.2.0],,AC_MSG_ERROR([ *** SDL needed for compilation!])) +fi +AC_CHECK_LIB([NL], + [nlListen], [], - AC_MSG_ERROR([ *** SDL_net needed for compilation!])) + AC_MSG_ERROR([ *** HawkNL needed for compilation!])) # Checks for header files. -AC_CHECK_HEADER([SDL/SDL_net.h], +AC_CHECK_HEADER([nl.h], [], - AC_MSG_ERROR([ *** SDL_net.h not found])) + AC_MSG_ERROR([ *** nl.h not found; install HawkNL])) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL Modified: trunk/server/Makefile.am =================================================================== --- trunk/server/Makefile.am 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/server/Makefile.am 2008-07-11 20:46:54 UTC (rev 69) @@ -5,5 +5,5 @@ bin_PROGRAMS = arnacawd arnacawd_SOURCES = Server.cpp ServerMain.cpp CLIArgumentInterpreter.cpp -arnacawd_CPPFLAGS = -I../common $(SDL_CFLAGS) -arnacawd_LDADD = $(SDL_LIBS) $(LIBS) +arnacawd_CPPFLAGS = -I../common +arnacawd_LDADD = $(LIBS) Modified: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp 2008-07-11 17:22:32 UTC (rev 68) +++ trunk/server/Server.cpp 2008-07-11 20:46:54 UTC (rev 69) @@ -94,33 +94,13 @@ /* initializes libraries */ void ServerApplication::initLibraries() { - /* initialize SDL (basic capabilities only) */ - int result = SDL_Init(0); - if (result < 0) { - /* failed */ - stringstream err; - err << "Failed to initialize SDL: " << SDL_GetError(); - throw Exception(err.str()); - } - /* initialize SDL_net */ - result = SDLNet_Init(); - if (result < 0) { - /* failed */ - stringstream err; - err << "Failed to initialize SDL_net: " << SDLNet_GetError(); - throw Exception(err.str()); - } } /* cleans up libraries */ void ServerApplication::cleanupLibraries() { - /* cleanup SDL_net */ - SDLNet_Quit(); - /* cleanup SDL */ - SDL_Quit(); } /* sets up command line arguments */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-11 17:22:27
|
Revision: 68 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=68&view=rev Author: shoyru Date: 2008-07-11 10:22:32 -0700 (Fri, 11 Jul 2008) Log Message: ----------- events work in the server now; daemon mode works Modified Paths: -------------- trunk/common/ArnacawCommon.h trunk/server/ChangeLog trunk/server/Server.cpp trunk/server/Server.h Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-07-11 04:15:14 UTC (rev 67) +++ trunk/common/ArnacawCommon.h 2008-07-11 17:22:32 UTC (rev 68) @@ -56,6 +56,8 @@ #ifndef __ARNACAW_COMMON_H__ #define __ARNACAW_COMMON_H__ +#include "config.h" + /* Standard headers */ #include <iostream> #include <fstream> @@ -65,6 +67,14 @@ #include <list> #include <queue> #include <set> + +#ifdef HAVE_UNISTD_H +#ifndef POSIX +#define POSIX +#endif +#include <unistd.h> +#endif + using namespace std; /* SDL headers */ Modified: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog 2008-07-11 04:15:14 UTC (rev 67) +++ trunk/server/ChangeLog 2008-07-11 17:22:32 UTC (rev 68) @@ -8,6 +8,13 @@ ------------------------------------------------- +11 July 2008 - Jim Buchwald + + * Integrate the event handling code + * Add option to run in daemon mode + +------------------------------------------------- + 21 June 2008 - Jim Buchwald * Write and test code to parse Modified: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp 2008-07-11 04:15:14 UTC (rev 67) +++ trunk/server/Server.cpp 2008-07-11 17:22:32 UTC (rev 68) @@ -30,11 +30,21 @@ */ #include "ArnacawServer.h" +#include <signal.h> +/* catches termination signals */ +void catchterm(int param) +{ + /* throw a QuitEvent */ + Event *q = EventFactory::getSingleton().createEvent(EVENT_QUIT); + EventDispatcher::getSingleton().push(q); +} + /* default constructor */ ServerApplication::ServerApplication() { /* initialize stuff here */ + time_to_quit = false; } /* runs the application */ @@ -42,6 +52,15 @@ { /* set up needed resources */ initLibraries(); + + /* initialize event system */ + initEventSystem(); + + /* register self as an event handler */ + EventDispatcher::getSingleton().registerHandler(this, EVENT_QUIT); + + /* hook the signals */ + hookSignals(); /* get command line arguments */ setupCmdLineArguments(); @@ -56,8 +75,18 @@ return; } - /* TODO: begin execution of program */ +#ifdef POSIX + /* run in daemon mode? */ + if ( cmd_args.IsArgumentStored("-d") ) { + if ( cmd_args.GetBooleanValue("-d") ) { + goDaemonMode(); + } + } +#endif + /* enter main loop */ + mainLoop(); + /* clean up after self */ cleanupLibraries(); } @@ -109,6 +138,11 @@ cmd_args.AddArgument("--license", "Show license information", CMDARG_BOOLEAN); +#ifdef POSIX + cmd_args.AddArgument("-d", + "Run in daemon mode", + CMDARG_BOOLEAN); +#endif } /* gets command line arguments */ @@ -159,3 +193,83 @@ /* do not exit */ return true; } + +#ifdef POSIX +/* switches to daemon mode */ +void ServerApplication::goDaemonMode() +{ + /* try to switch */ + pid_t pid = fork(); + if ( pid < 0 ) + throw Exception("fork() failed; daemon mode critical failure"); + if ( pid > 0 ) { + /* this is the parent process - get out! */ + exit(0); + } + + /* set stuff up! */ + pid_t sid = setsid(); + if ( sid < 0 ) { + throw Exception("setsid() failed; daemon mode critical failure"); + } + + /* change current directory */ + if ( chdir("/") < 0 ) { + throw Exception("chdir() failed; daemon mode critical failure"); + } + + /* do stuff with files and things */ + close(STDIN_FILENO); + close(STDOUT_FILENO); +} +#endif + +/* main loop */ +void ServerApplication::mainLoop() +{ + /* enter loop */ + while (1) { + /* check if we need to quit */ + if ( time_to_quit ) { + /* handle in-loop cleanups */ + + /* quit */ + break; + } + + /* run the event dispatcher */ + EventDispatcher::getSingleton().dispatch(); + } +} + +/* implements EventHandler */ +void ServerApplication::notify(Event *event) +{ + /* check the event type */ + switch (event->getType()) { + case EVENT_QUIT: + /* terminate the main loop */ + time_to_quit = true; + break; + default: + /* we don't care about this event here */ + break; + } +} + +/* initializes the event system */ +void ServerApplication::initEventSystem() +{ + /* register the common events */ + EventFactory::getSingleton().buildInitialDatabase(); + + /* register server-specific events */ +} + +/* hooks signals */ +void ServerApplication::hookSignals() +{ + /* termination signals: SIGINT, SIGTERM, etc. */ + signal(SIGINT, catchterm); + signal(SIGTERM, catchterm); +} Modified: trunk/server/Server.h =================================================================== --- trunk/server/Server.h 2008-07-11 04:15:14 UTC (rev 67) +++ trunk/server/Server.h 2008-07-11 17:22:32 UTC (rev 68) @@ -37,7 +37,8 @@ * @ingroup Server * @brief Server application */ -class ServerApplication : public Singleton<ServerApplication> +class ServerApplication : public Singleton<ServerApplication>, + public EventHandler /* EVENT_QUIT */ { public: friend class Singleton<ServerApplication>; @@ -82,8 +83,37 @@ */ bool checkInformationArguments(); +#ifdef POSIX + /** + * Switches to daemon mode (not reversible). + */ + void goDaemonMode(); +#endif + + /** + * Main loop. + */ + void mainLoop(); + + /** + * Intializes the event systems. + * Registration of server-specific factories happens here. + */ + void initEventSystem(); + + /** + * Hooks signals so that they don't cause undesirable behavior. + */ + void hookSignals(); + + /* Implements EventHandler */ + void notify(Event *event); + /** Stores command line arguments */ CLIArgumentInterpreter cmd_args; + + /** Flags the main loop to terminate. */ + bool time_to_quit; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-11 04:15:11
|
Revision: 67 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=67&view=rev Author: shoyru Date: 2008-07-10 21:15:14 -0700 (Thu, 10 Jul 2008) Log Message: ----------- design some classes, implement some of them... events are working now! w00t! Modified Paths: -------------- trunk/client/ArnacawClient.h trunk/client/ChangeLog trunk/client/Client.cpp trunk/client/Client.h trunk/client/Makefile.am trunk/common/ArnacawCommon.h trunk/common/Singleton.h trunk/docs/design/Arnacaw.dia trunk/server/ArnacawServer.h Added Paths: ----------- trunk/client/Display.cpp trunk/client/Display.h trunk/client/SDLEventAdaptor.cpp trunk/client/SDLEventAdaptor.h trunk/common/CommonEvents.h trunk/common/Event.h trunk/common/EventDispatcher.h trunk/common/EventFactory.h trunk/common/EventHandler.h trunk/common/SpecificEventFactory.h Modified: trunk/client/ArnacawClient.h =================================================================== --- trunk/client/ArnacawClient.h 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/client/ArnacawClient.h 2008-07-11 04:15:14 UTC (rev 67) @@ -40,6 +40,7 @@ #define MAJOR_VERSION 0 #define MINOR_VERSION 1 #define RELEASE_VERSION "0.01a" +#define COMPONENT 1 /* License information */ #define LICENSE_INFO \ @@ -62,5 +63,7 @@ /* Client component */ #include "Client.h" +#include "Display.h" +#include "SDLEventAdaptor.h" #endif Modified: trunk/client/ChangeLog =================================================================== --- trunk/client/ChangeLog 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/client/ChangeLog 2008-07-11 04:15:14 UTC (rev 67) @@ -8,8 +8,31 @@ ------------------------------------------------- +10 July 2008 - Jim Buchwald + + * Clean up some stuff with the event classes + +------------------------------------------------- + +8 July 2008 - Jim Buchwald + + * Tie the event handling system into + the client + * Add the main loop for the client + * Make Singleton accessors inline + +------------------------------------------------- + +7 July 2008 - Jim Buchwald + + * Implement event handling system + +------------------------------------------------- + 6 July 2008 - Jim Buchwald + * Implement basics of Display class + ------------------------------------------------- 29 June 2008 - Jim Buchwald Modified: trunk/client/Client.cpp =================================================================== --- trunk/client/Client.cpp 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/client/Client.cpp 2008-07-11 04:15:14 UTC (rev 67) @@ -34,11 +34,102 @@ /* default constructor */ ClientApplication::ClientApplication() { - + time_to_quit = false; } /* runs the application */ void ClientApplication::go() { + /* initialize libraries */ + try { initLibraries(); } + catch (Exception &e) { + /* failed */ + cout << "FATAL ERROR: library initialization failure" << endl; + cout << e.getReason() << endl; + return; + } + /* initialize the event system */ + initEventSystem(); + + /* register self as an event handler */ + EventDispatcher::getSingleton().registerHandler(this, EVENT_QUIT); + + /* initialize the screen */ + Display::getSingleton().init(640, 480, false); + + /* enter the main loop */ + mainLoop(); + + /* clean up the screen */ + Display::getSingleton().cleanup(); + + /* stop listening for events */ + EventDispatcher::getSingleton().unregisterHandler(this, EVENT_QUIT); + + /* clean up libraries */ + cleanupLibraries(); } + +/* initializes libraries */ +void ClientApplication::initLibraries() +{ + /* initialize SDL */ + if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0 ) { + /* failed */ + stringstream s_err; + s_err << "error initializing SDL: "; + s_err << SDL_GetError(); + throw Exception(s_err.str()); + } +} + +/* cleans up libraries */ +void ClientApplication::cleanupLibraries() +{ + /* clean up SDL */ + SDL_Quit(); +} + +/* handles EVENT_QUIT events */ +void ClientApplication::notify(Event *event) +{ + if ( event->getType() == EVENT_QUIT ) + time_to_quit = true; + else + cout << "[warn] ClientApplication notified of event (type != EVENT_QUIT)" << endl; +} + +/* main loop */ +void ClientApplication::mainLoop() +{ + while (1) + { + /* check if we need to quit */ + if ( time_to_quit ) { + /* do stuff we need to do before quitting */ + + /* quit */ + break; + } + + /* convert SDL events */ + SDLEventAdaptor::getSingleton().drive(); + + /* dispatch events */ + EventDispatcher::getSingleton().dispatch(); + + /* let other processes get a chance to run */ + SDL_Delay(1); + } +} + +/* initializes the event system */ +void ClientApplication::initEventSystem() +{ + /* register the common events */ + EventFactory::getSingleton().buildInitialDatabase(); + + /* register client-specific events */ + +} Modified: trunk/client/Client.h =================================================================== --- trunk/client/Client.h 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/client/Client.h 2008-07-11 04:15:14 UTC (rev 67) @@ -36,13 +36,17 @@ * Main application class for the Client component * @ingroup Client */ -class ClientApplication : public Singleton<ClientApplication> +class ClientApplication : public Singleton<ClientApplication>, + public EventHandler /* implements for EVENT_QUIT */ { public: friend class Singleton<ClientApplication>; /** Runs the application. */ void go(); + + /* Implements the EventHandler interface. */ + void notify(Event *event); protected: /** Protected to support the Singleton implementation */ @@ -62,6 +66,22 @@ */ void cleanupLibraries(); + /** + * This is the main loop of the application. It should be called + * after all initialization takes place. The loop will not + * exit until an event of type EVENT_QUIT is received. + */ + void mainLoop(); + + /** + * Initializes the event systems. + * Client-specific event factory registration happens here. + */ + void initEventSystem(); + + /** Flags the main loop to stop when true. */ + bool time_to_quit; + }; #endif Added: trunk/client/Display.cpp =================================================================== --- trunk/client/Display.cpp (rev 0) +++ trunk/client/Display.cpp 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,76 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Client * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Display.cpp + * @ingroup Client + * @brief Display class + * + * Contains the implementation for the Display class, + * which handles access to the screen. + */ + +#include "ArnacawClient.h" + +/* default constructor */ +Display::Display() +{ + +} + +/* initializes the display */ +void Display::init(int w, int h, bool fs) +{ + /* set up */ + const int flags = SDL_HWSURFACE | SDL_DOUBLEBUF; + const int bpp = 32; + + /* figure out what to do */ + if ( fs ) { + /* try to run in fullscreen mode */ + screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_FULLSCREEN); + if ( screen ) { + /* success */ + cout << "[info] screen initialized: " << w << "x" << h << endl; + this->w = w; + this->h = h; + return; + } + /* failed */ + cout << "[error] set fullscreen: " << SDL_GetError() << endl; + } + + /* try to run in windowed mode */ + screen = SDL_SetVideoMode(w, h, bpp, flags); + if ( !screen ) { + /* failed */ + stringstream error; + error << "SDL_SetVideoMode failed: " << SDL_GetError(); + throw Exception(error.str()); + } + this->w = w; + this->h = h; +} + +/* cleans up */ +void Display::cleanup() { + /* nothing to do */ +} Added: trunk/client/Display.h =================================================================== --- trunk/client/Display.h (rev 0) +++ trunk/client/Display.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,95 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Client * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Display.h + * @ingroup Client + * @brief Display class + * + * Contains the implementation for the Display class, which + * handles access to the screen. + */ + +#ifndef __ARNACAW_DISPLAY_H__ +#define __ARNACAW_DISPLAY_H__ + +/** + * Handles access to the screen. + * @ingroup Client + * @brief Controls the screen + */ +class Display : public Singleton<Display> +{ +public: + friend class Singleton<Display>; + + /** + * Initializes the screen. + * + * @param w + * Desired width of the screen + * + * @param h + * Desired height of the screen + * + * @note + * For fullscreen mode, the ratio h/w should be 0.75 for + * maximum portability. 640x480 and 800x600 are examples. + * + * @param fs + * If true, the screen will be placed in fullscreen mode. + * + * @note + * If the screen is initialized in fullscreen mode, but + * an error occurs, the function will attempt to initialize + * in windowed mode. A non-fatal error message will be + * displayed. + * + * @throws Exception + * If an error occurs during initialization, an Exception is + * thrown. The error message, if any, will be given as the reason. + */ + void init(int w=640, int h=480, bool fs=false); + + /** + * Cleans up the screen. + */ + void cleanup(); + +protected: + /** + * The constructor is protected as part of + * the Singleton design pattern. + */ + Display(); + + /** Surface that represents the screen. */ + SDL_Surface *screen; + + /** Width of the screen. */ + int w; + + /** Height of the screen. */ + int h; + +}; + +#endif Modified: trunk/client/Makefile.am =================================================================== --- trunk/client/Makefile.am 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/client/Makefile.am 2008-07-11 04:15:14 UTC (rev 67) @@ -4,6 +4,6 @@ # See the LICENSE file for details bin_PROGRAMS = arnacaw -arnacaw_SOURCES = ClientMain.cpp Client.cpp +arnacaw_SOURCES = ClientMain.cpp Client.cpp Display.cpp SDLEventAdaptor.cpp arnacaw_CPPFLAGS = -I../common $(SDL_CFLAGS) arnacaw_LDADD = $(SDL_LIBS) $(LIBS) Added: trunk/client/SDLEventAdaptor.cpp =================================================================== --- trunk/client/SDLEventAdaptor.cpp (rev 0) +++ trunk/client/SDLEventAdaptor.cpp 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,76 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Client * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file SDLEventAdaptor.cpp + * @ingroup Client + * @brief SDLEventAdaptor class + * + * Contains the implementation of the SDLEventAdaptor + * class, which converts certain events from the SDL + * library into compatible forms for the Arnacaw event + * handling system. + */ + +#include "ArnacawClient.h" + +/* default constructor */ +SDLEventAdaptor::SDLEventAdaptor() +{ + +} + +/* converts the SDL event queue */ +void SDLEventAdaptor::drive() +{ + /* loop through the SDL event queue */ + SDL_Event event; + Event *newevent = NULL; + while (SDL_PollEvent(&event)) { + /* process */ + newevent = convertSingleEvent(&event); + if ( newevent ) + EventDispatcher::getSingleton().push(newevent); + } +} + +/* converts a single SDL event */ +Event *SDLEventAdaptor::convertSingleEvent(SDL_Event *event) +{ + /* validity check */ + if ( !event ) + throw Exception("NULL pointer passed to convertSingleEvent()"); + + /* check if the conversion is possible */ + Event *converted = NULL; + switch (event->type) { + case SDL_QUIT: + /* SDL_QUIT -> EVENT_QUIT */ + converted = EventFactory::getSingleton().createEvent(EVENT_QUIT); + return converted; + default: + /* not supported */ + break; + } + + /* conversion not supported */ + return NULL; +} Added: trunk/client/SDLEventAdaptor.h =================================================================== --- trunk/client/SDLEventAdaptor.h (rev 0) +++ trunk/client/SDLEventAdaptor.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,83 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Client * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file SDLEventAdaptor.h + * @ingroup Client + * @brief SDLEventAdaptor class + * + * Defines the SDLEventAdaptor class, which converts certain + * events from the SDL library into compatible forms for the + * Arnacaw event handling system. + * + * @see Event.h + * @see EventDispatcher.h + * @see EventHandler.h + */ + +#ifndef __ARNACAW_SDLEVENTADAPTOR_H__ +#define __ARNACAW_SDLEVENTADAPTOR_H__ + +/** + * Converts certain events from the SDL library into compatible + * forms for the Arnacaw event handling system. + * @see Event + * @see EventHandler + * @see EventDispatcher + * @see QuitEvent + * + * @brief Converts SDL events to Arnacaw events + * @ingroup Client + */ +class SDLEventAdaptor : public Singleton<SDLEventAdaptor> +{ +public: + friend class Singleton<SDLEventAdaptor>; + + /** + * Processes the entire SDL event queue into + * the Arnacaw event queue. This should be + * called once per iteration of the main loop. + */ + void drive(); + +protected: + /** The default constructor is protected as part of the Singleton. */ + SDLEventAdaptor(); + + /** + * Converts a single Event, if possible. + * + * @param event + * Event from the SDL library to convert. + * + * @throws Exception + * If a NULL pointer is passed for event, an Exception + * will be thrown. + * + * @returns a pointer to an Event object if the conversion was possible, + * or NULL if the conversion was not possible. + */ + Event *convertSingleEvent(SDL_Event *event); + +}; + +#endif Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/common/ArnacawCommon.h 2008-07-11 04:15:14 UTC (rev 67) @@ -62,6 +62,9 @@ #include <string> #include <sstream> #include <map> +#include <list> +#include <queue> +#include <set> using namespace std; /* SDL headers */ @@ -78,5 +81,11 @@ #include "ConsoleOutputStream.h" #include "Serializable.h" #include "SerializableBaseTypes.h" +#include "Event.h" +#include "EventHandler.h" +#include "SpecificEventFactory.h" +#include "CommonEvents.h" +#include "EventFactory.h" +#include "EventDispatcher.h" #endif Added: trunk/common/CommonEvents.h =================================================================== --- trunk/common/CommonEvents.h (rev 0) +++ trunk/common/CommonEvents.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,63 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file CommonEvents.h + * @ingroup Common + * @brief Common event classes + * + * Contains specialized Event classes for event types common + * to both client and server. + */ + +#ifndef __ARNACAW_COMMONEVENTS_H__ +#define __ARNACAW_COMMONEVENTS_H__ + +/** + * Extends the Event class to represent events of type EVENT_QUIT. + * @brief EVENT_QUIT + * @ingroup Common + */ +class QuitEvent : public Event +{ +public: + /** Initializes an object with type EVENT_QUIT. */ + QuitEvent() : Event(EVENT_QUIT) { } + +}; + +/** + * Implements the SpecificEventFactory class to allocate + * and deallocate QuitEvent objects. + * @brief QuitEvent memory management + * @ingroup Common + */ +class QuitEventFactory : public SpecificEventFactory, + public Singleton<QuitEventFactory> +{ +public: + friend class Singleton<QuitEventFactory>; + /* implements SpecificEventFactory */ + Event *allocateEvent() { return new QuitEvent; } + void deallocateEvent(Event *event) { delete (QuitEvent*)event; } +}; + +#endif Added: trunk/common/Event.h =================================================================== --- trunk/common/Event.h (rev 0) +++ trunk/common/Event.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,175 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Event.h + * @ingroup Common + * @brief Event interface + * + * Defines the Event interface, which is passed to + * the appropriate handlers by the EventDispatcher class. + */ + +#ifndef __ARNACAW_EVENT_H__ +#define __ARNACAW_EVENT_H__ + +/** + * @page addevents Adding New Events + * Adding new events is a relatively easy three-step process. + * By following the guidelines in this document, you can + * add a new type of event quickly and painlessly. + * + * @section step1 Step One: Designate a type identifier + * The first step in creating a new type of event is + * to designate a type identifier in the EventType enum. + * This enum is located in the common/Event.h file. The + * enum is divided into three sections: one for events + * specific to the client, another for those specific to the + * server, and a third for those used in both. Be sure + * to add the appropriate integer value to the new identifier. + * + * @section step2 Step Two: Extend the Event class + * Next, the Event class must be extended to represent + * the new type. Create source files in the appropriate + * directory (or add on to common/CommonEvents.h for + * events used in both client and server) and define + * a class which inherits the Event class. Create a + * default constructor which calls the Event constructor + * specifying the new type identifier. Replace the + * create() and release() static methods with code to + * allocate and deallocate objects and handle pointers + * to them (these are used by the EventFactory class). + * Add any member variables, accessors, and modifiers + * that are needed. + * + * @section step3 Step Three: Hook the EventFactory class + * Create a new class in the source files used in step two. + * Have it implement SpecificEventFactory. For events used by + * both the client and server, edit common/EventFactory.h + * and add an extra call to registerFactory() in the + * buildInitialDatabase(). For events specific to either + * component, add a call in the initEventSystem() method + * attached to the component's application class. + * Compile and test the new event. + */ + +/** + * The EventType enum represents different types of + * events. A corresponding implementation of the Event + * interface exists for each. + * + * Because some event types will be common to both client + * and server, the enum is defined in the common files. + * This means that entries for both client and server are + * stored in the client files. Event interface implementations, + * however, are stored in their respective groupings. + * + * The values for the types are divided into three ranges + * based on what grouping they belong to. The ranges (inclusive) are: + * + * 0 - 21844 : Common + * 21845 - 43689 : Client + * 43690 - 65535 : Server + */ +enum EventType +{ + /* 0 - 21844: COMMON */ + EVENT_QUIT = 0, /* QuitEvent */ +#if COMPONENT == 1 + /* 21845 - 43689: CLIENT */ + EVENT_KEYBOARD = 21845, + EVENT_MOUSEBUTTON = 21846, + EVENT_MOUSEMOTION = 21847, +#elif COMPONENT == 2 + /* 43690 - 65535: SERVER */ +#endif +}; + +/** + * Event objects are pushed into the EventDispatcher class, + * from where they are sent to the appropriate handlers. + * + * @brief Event interface + * @ingroup Common + */ +class Event +{ +public: + /** + * This constructor creates an Event with the given type. + * It only sets the type member; it does not do any extra + * initialization based on the type. This can be done by + * subclassing the Event class. + */ + Event(EventType t) { type = t; } + + /** + * This constructor copies an existing Event object. + * Copies of extended Event classes should be made using + * the copy constructor of the extended class. + * + * @note + * in_transit is set to false for every copy because it + * represents the internal state of a single object in + * the engine. This allows event handlers to make copies + * for later use without having to worry about the original + * object being destructed. + */ + Event(Event &e) + { + type = e.type; + in_transit = false; + } + + /** + * Public accessor for the type member. + * @returns Type of event represented + */ + virtual EventType getType() { return type; } + + /** + * Public accessor for the in_transit member. + * This should always be checked before destructing + * an Event object. + * @returns true if it is safe to destruct the object + */ + virtual bool isSafeToDestruct() { return !in_transit; } + + /** + * Called by the dispatcher at the beginning of dispatch. + */ + virtual void beginDispatch() { in_transit = true; } + + /** + * Called by the dispatcher at the end of dispatch. + */ + virtual void endDispatch() { in_transit = false; } + +protected: + /** Stores the type of event represented by the object. */ + EventType type; + + /** Safeguard to prevent object destruction while being passed. */ + bool in_transit; + +}; + +#endif Added: trunk/common/EventDispatcher.h =================================================================== --- trunk/common/EventDispatcher.h (rev 0) +++ trunk/common/EventDispatcher.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,184 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file EventDispatcher.h + * @ingroup Common + * @brief EventDispatcher class + * + * Defines the EventDispatcher class, which delivers different + * types of events to the EventHandlers that are expecting them. + */ + +#ifndef __ARNACAW_EVENTDISPATCHER_H__ +#define __ARNACAW_EVENTDISPATCHER_H__ + +/** + * Delivers different types of events to the EventHandlers + * that have asked to be notified of them. + * @brief Delivers events + * @ingroup Common + */ +class EventDispatcher : public Singleton<EventDispatcher> +{ +public: + friend class Singleton<EventDispatcher>; + + /** + * Registers a handler for a particular type of event. + * Handlers may be registered for multiple events by + * making multiple calls to this method. + * + * @param handler + * Pointer to an object of a class which implements + * the EventHandler interface. + * + * @param type + * Type of the event to be notified of. + * + * @throws Exception + * If a NULL pointer is passed for handler, an Exception + * will be thrown. + */ + void registerHandler(EventHandler *handler, EventType type) + { + /* validity check */ + if ( !handler ) + throw Exception("NULL handler passed to registerHandler()"); + + /* add the handler to the appropriate list */ + handlers[type].push_back(handler); + cout << "[debug] registered handler " << handler << endl; + } + + /** + * Unregisters a handler for a particular type of event. + * If the handler is not registered for the specified + * event type, nothing will happen. + * + * @param handler + * Pointer to an object of a class which implements + * the EventHandler interface. + * + * @param type + * Type of the event to no longer be notified of. + * + * @throws Exception + * If a NULL pointer is passed for handler, an Exception + * will be thrown. + */ + void unregisterHandler(EventHandler *handler, EventType type) + { + /* validity check */ + if ( !handler ) + throw Exception("NULL handler passed to unregisterHandler()"); + + /* find the handler */ + list<EventHandler*>::iterator i; + list<EventHandler*> *l = &handlers[type]; + for (i = l->begin(); i != l->end(); i++) { + if ( *i == handler ) { + /* found it */ + l->erase(i); + return; + } + } + } + + /** + * Adds an event to the queue for dispatch. + * + * @param event + * Pointer to an Event object. + * + * @throws Exception + * If a NULL pointer is passed for event, an Exception + * will be thrown. + */ + void push(Event *event) + { + /* validity check */ + if ( !event ) + throw Exception("NULL event passed to EventDispatcher::push()"); + + /* push the event */ + event->beginDispatch(); + event_queue.push(event); + } + + /** + * Dispatches all queued events. + * This should be called from the main loop + * once per frame. + */ + void dispatch() + { + /* loop through the queue */ + Event *event = NULL; + while ( !event_queue.empty() ) { + /* get next event */ + event = event_queue.front(); + event_queue.pop(); + + /* check if any registered handlers for type */ + if ( handlers.count(event->getType()) == 0 ) { + /* map entry does not exist; skip event */ + event->endDispatch(); + EventFactory::getSingleton().releaseEvent(event); + event = NULL; + continue; + } + + /* check if handlers were unregistered */ + list<EventHandler*> *l = &handlers[event->getType()]; + if ( l->empty() ) { + /* all handlers unregistered; skip event */ + event->endDispatch(); + EventFactory::getSingleton().releaseEvent(event); + event = NULL; + continue; + } + + /* dispatch to handlers */ + cout << "[debug] dispatching event " << event << endl; + list<EventHandler*>::iterator i; + for (i = l->begin(); i != l->end(); i++) { + (*i)->notify(event); + } + event->endDispatch(); + EventFactory::getSingleton().releaseEvent(event); + event = NULL; + } + } + +protected: + /** The default constructor is protected because this is a Singleton. */ + EventDispatcher() { } + + /** Queues events for later dispatch */ + queue<Event*> event_queue; + + /** Keeps track of registered handlers for different types of events */ + map< EventType, list<EventHandler*> > handlers; + +}; + +#endif Added: trunk/common/EventFactory.h =================================================================== --- trunk/common/EventFactory.h (rev 0) +++ trunk/common/EventFactory.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,175 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file EventFactory.h + * @ingroup Common + * @brief EventFactory class + * + * Defines the EventFactory class, which manages + * the creation and deletion of events in memory. + */ + +#ifndef __ARNACAW_EVENTFACTORY_H__ +#define __ARNACAW_EVENTFACTORY_H__ + +/** + * Centralizes the memory management of Event + * objects, including those which are specialized + * for a single type of event. + * @brief Manages Event objects + * @ingroup Common + */ +class EventFactory : public Singleton<EventFactory> +{ +public: + friend class Singleton<EventFactory>; + + /** + * Creates an event of a given type. + * + * @param type + * Type of event to create. + * + * @throws Exception + * If a SpecificEventFactory has not been registered + * for the specified type, an Exception will be thrown. + * If NULL is returned by the SpecificEventFactory, + * an Exception will be thrown. + * + * @returns a pointer to a specialized Event object. + */ + Event *createEvent(EventType type) + { + /* try to find a factory */ + if ( factories.count(type) == 0 ) { + /* no factories available */ + stringstream s; + s << "createEvent(): no factory registered for type "; + s << type; + throw Exception(s.str()); + } + + /* create an event */ + Event *event = factories[type]->allocateEvent(); + if ( !event ) { + /* error */ + stringstream s; + s << "createEvent(): NULL event for type " << type; + throw Exception(s.str()); + } + managed_events.insert(event); + return event; + } + + /** + * Releases an Event object from memory. + * + * @param event + * Pointer to event to release. + * + * @throws Exception + * If a NULL pointer or a pointer not managed by this + * class is passed for event, an Exception will be thrown. + */ + void releaseEvent(Event *event) + { + /* validity check */ + if ( !event ) + throw Exception("NULL pointer passed to releaseEvent()"); + if ( managed_events.count(event) == 0 ) { + stringstream s; + s << "unmanaged pointer " << event << " passed to releaseEvent()"; + throw Exception(s.str()); + } + + /* release the event */ + managed_events.erase(event); + EventType type = event->getType(); + factories[type]->deallocateEvent(event); + } + + /** + * Registers a SpecificEventFactory to provide + * memory management services for a given type + * of event. + * + * @param factory + * Return value of the getSingletonPtr() member + * of the SpecificEventFactory to use. + * + * @param type + * Type of event to provide. + * + * @throws Exception + * If a NULL pointer is passed for factory, an Exception + * will be thrown. If a factory has already been registered + * for the given type, an Exception will be thrown. + */ + void registerFactory(SpecificEventFactory *factory, EventType type) + { + /* validity check */ + if ( !factory ) + throw Exception("NULL pointer passed to registerFactory()"); + + /* check if type is already registered */ + if ( factories.count(type) != 0 ) { + /* already registered */ + stringstream s; + s << "Attempted re-register of factory (event type: "; + s << type << ")"; + throw Exception(s.str()); + } + + /* register the factory */ + factories[type] = factory; + } + + /** + * Builds an initial database of factories to rely upon. + * This method should be extended for every new type + * of event that is common to both client and server. + * Events specific to either component should be implemented + * in the initEventSystem() methods attached to their + * application classes. + */ + void buildInitialDatabase() + { + /* EVENT_QUIT/QuitEvent */ + registerFactory(QuitEventFactory::getSingletonPtr(), EVENT_QUIT); + } + +protected: + /** Protected because of the Singleton design pattern. */ + EventFactory() + { + + } + + /** Managed events */ + set<Event*> managed_events; + + /** Registered SpecificEventFactories */ + map<EventType,SpecificEventFactory*> factories; + +}; + +#endif Added: trunk/common/EventHandler.h =================================================================== --- trunk/common/EventHandler.h (rev 0) +++ trunk/common/EventHandler.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,49 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file EventHandler.h + * @ingroup Common + * @brief EventHandler interface + * + * Defines the EventHandler interface, which provides a + * mechanism to passively listen for events. + */ + +#ifndef __ARNACAW_EVENTHANDLER_H__ +#define __ARNACAW_EVENTHANDLER_H__ + +/** + * Provides a mechanism to passively listen for events. + * @brief Listens for events + * @ingroup Common + */ +class EventHandler +{ +public: + /** + * Called by the dispatcher to deliver an event. + */ + virtual void notify(Event *event)=0; + +}; + +#endif Modified: trunk/common/Singleton.h =================================================================== --- trunk/common/Singleton.h 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/common/Singleton.h 2008-07-11 04:15:14 UTC (rev 67) @@ -48,7 +48,7 @@ /** * @return Reference to the single object */ - static t &getSingleton() + inline static t &getSingleton() { InitSingleton(); return *m_singleton; @@ -58,7 +58,7 @@ * @return Pointer to the single object * @warning The returned pointer is borrowed; do not delete it. */ - static t *getSingletonPtr() + inline static t *getSingletonPtr() { InitSingleton(); return m_singleton; Added: trunk/common/SpecificEventFactory.h =================================================================== --- trunk/common/SpecificEventFactory.h (rev 0) +++ trunk/common/SpecificEventFactory.h 2008-07-11 04:15:14 UTC (rev 67) @@ -0,0 +1,62 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file SpecificEventFactory.h + * @ingroup Common + * @brief SpecificEventFactory interface + * + * Defines the SpecificEventFactory interface, which manages + * the creation and deletion of specific types of events in memory. + */ + +#ifndef __ARNACAW_SPECIFICEVENTFACTORY_H__ +#define __ARNACAW_SPECIFICEVENTFACTORY_H__ + +/** + * Implemented by other classes to allow for the + * allocation and deallocation of specialized + * Event classes while managing the memory from a + * single point through the EventFactory class. + * @brief Memory management of specific event types + * @ingroup Common + */ +class SpecificEventFactory +{ +public: + /** + * Allocates a specialized Event object. + * @returns a pointer to a specialized Event object, + * or NULL on failure. + */ + virtual Event *allocateEvent()=0; + + /** + * Deallocates a specialized Event object. + * + * @param event + * Pointer to the specialized Event object to free. + */ + virtual void deallocateEvent(Event *event)=0; + +}; + +#endif Modified: trunk/docs/design/Arnacaw.dia =================================================================== (Binary files differ) Modified: trunk/server/ArnacawServer.h =================================================================== --- trunk/server/ArnacawServer.h 2008-07-07 18:13:25 UTC (rev 66) +++ trunk/server/ArnacawServer.h 2008-07-11 04:15:14 UTC (rev 67) @@ -41,6 +41,7 @@ #define MAJOR_VERSION 0 #define MINOR_VERSION 1 #define RELEASE_VERSION "0.01a" +#define COMPONENT 2 /* License information */ #define LICENSE_INFO \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-07 18:13:15
|
Revision: 66 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=66&view=rev Author: shoyru Date: 2008-07-07 11:13:25 -0700 (Mon, 07 Jul 2008) Log Message: ----------- simplify the event system design Modified Paths: -------------- trunk/docs/design/Arnacaw.dia Modified: trunk/docs/design/Arnacaw.dia =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-07-07 17:21:43
|
Revision: 65 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=65&view=rev Author: shoyru Date: 2008-07-07 10:21:52 -0700 (Mon, 07 Jul 2008) Log Message: ----------- more design for the event passing system Modified Paths: -------------- trunk/docs/design/Arnacaw.dia Modified: trunk/docs/design/Arnacaw.dia =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-03-05 14:55:13
|
Revision: 57 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=57&view=rev Author: shoyru Date: 2008-03-05 06:55:20 -0800 (Wed, 05 Mar 2008) Log Message: ----------- slight restructuring of project documentation Added Paths: ----------- trunk/docs/design/ Removed Paths: ------------- trunk/design/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-03-05 14:37:35
|
Revision: 56 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=56&view=rev Author: shoyru Date: 2008-03-05 06:37:39 -0800 (Wed, 05 Mar 2008) Log Message: ----------- add and test Serializable interface, Serializable wrappers for integers Modified Paths: -------------- trunk/client/client.vcproj trunk/common/ArnacawCommon.h trunk/common/FileInputStream.cpp trunk/common/FileInputStream.h trunk/common/FileOutputStream.cpp trunk/common/FileOutputStream.h trunk/design/Arnacaw.dia trunk/server/ChangeLog trunk/server/Server.cpp trunk/server/Server.h trunk/server/server.vcproj Added Paths: ----------- trunk/common/Serializable.h trunk/common/SerializableBaseTypes.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-03-02 18:23:40
|
Revision: 55 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=55&view=rev Author: shoyru Date: 2008-03-02 10:21:21 -0800 (Sun, 02 Mar 2008) Log Message: ----------- documentation fixes, finish implementation and testing of FileOutputStream class Modified Paths: -------------- trunk/common/ArnacawCommon.h trunk/common/Exception.cpp trunk/common/Exception.h trunk/common/FileInputStream.cpp trunk/common/FileInputStream.h trunk/common/InputStream.h trunk/common/OutputStream.h trunk/common/Singleton.h trunk/design/Arnacaw.dia trunk/server/ArnacawServer.h trunk/server/Server.cpp trunk/server/Server.h trunk/server/ServerMain.cpp trunk/server/server.vcproj Added Paths: ----------- trunk/common/FileOutputStream.cpp trunk/common/FileOutputStream.h trunk/docs/ trunk/docs/doxygen/ trunk/doxygen_config trunk/gendocs.bat Removed Paths: ------------- trunk/arnacaw.ncb trunk/arnacaw.suo Deleted: trunk/arnacaw.ncb =================================================================== (Binary files differ) Deleted: trunk/arnacaw.suo =================================================================== (Binary files differ) Modified: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/ArnacawCommon.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,10 +23,32 @@ * @file ArnacawCommon.h * @ingroup Common * - * Encapsulates the shared header files of the - * Common component. + * Encapsulates the shared header files of the Common component. + * + * @brief Superheader for everything */ +/** + * @mainpage Arnacaw Online Code Documentation + * + * @section intro_sec Introduction + * + * This is the Doxygen-generated documentation of the + * Arnacaw Online codebase. + * + * These files are intended for developer use only; most users will not + * be interested in lists of classes and dependency graphs. If you are + * a geek, though, then maybe you will enjoy these pages. Not likely, though. + * + * @section contrib_sec Contributing + * + * Arnacaw Online is open source software licensed under the GNU General Public + * License. If you're interested in contributing to the project, feel free to do + * so, using these pages as a reference. Please make sure that any new code is + * also documented using Javadoc-style comments and licensed under the GPL. + * + */ + #ifndef __ARNACAW_COMMON_H__ #define __ARNACAW_COMMON_H__ @@ -43,5 +65,6 @@ #include "InputStream.h" #include "OutputStream.h" #include "FileInputStream.h" +#include "FileOutputStream.h" #endif Modified: trunk/common/Exception.cpp =================================================================== --- trunk/common/Exception.cpp 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/Exception.cpp 2008-03-02 18:21:21 UTC (rev 55) @@ -24,6 +24,8 @@ * @ingroup Common * * Contains the implementation of the Exception class. + * + * @brief Exception implementation */ #include "ArnacawCommon.h" Modified: trunk/common/Exception.h =================================================================== --- trunk/common/Exception.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/Exception.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,6 +23,8 @@ * @file Exception.h * @ingroup Common * + * @brief Exception class + * * Defines the Exception class, which is thrown * by other Arnacaw classes as an exception. */ @@ -30,7 +32,11 @@ #ifndef __ARNACAW_EXTENSION_H__ #define __ARNACAW_EXTENSION_H__ -/** Thrown by other Arnacaw classes as an exception. */ +/** + * Thrown by other Arnacaw classes as an exception. + * + * @brief General exception + */ class Exception { public: @@ -39,10 +45,11 @@ virtual ~Exception(); /** returns reason that this was thrown */ - string getReason(); + virtual string getReason(); protected: - string reason; /** reason that this was thrown */ + /** reason that exception was thrown */ + string reason; }; Modified: trunk/common/FileInputStream.cpp =================================================================== --- trunk/common/FileInputStream.cpp 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/FileInputStream.cpp 2008-03-02 18:21:21 UTC (rev 55) @@ -23,11 +23,19 @@ * @file FileInputStream.cpp * @ingroup Common * + * @brief FileInputStream implementation + * * Contains the implementation of the FileInputStream class. */ #include "ArnacawCommon.h" +/* default constructor */ +FileInputStream::FileInputStream() +{ + +} + /* file open constructor */ FileInputStream::FileInputStream(const string &filepath, bool binary) { Modified: trunk/common/FileInputStream.h =================================================================== --- trunk/common/FileInputStream.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/FileInputStream.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,6 +23,8 @@ * @file FileInputStream.h * @ingroup Common * + * @brief FileInputStream class + * * Defines the FileInputStream class, which provides an implementation * of the InputStream interface to handle file read operations. */ @@ -32,15 +34,23 @@ /** * Implements the InputStream interface to handle file read operations. + * + * @brief InputStream for files */ class FileInputStream : public InputStream { public: + /* default constructor */ + FileInputStream(); + /** * Creates a FileInputStream object and opens a file - * for reading. + * for reading. This is the same as creating a FileInputStream + * object and then calling its open() method. + * @see FileInputStream::open * * @param filepath path (relative or absolute) of the file to open + * @param binary if true, open the file in binary mode * * @throws Exception * If an error occurs, a generic Exception will be thrown. @@ -56,19 +66,21 @@ * This can also be done with a specialized constructor. * * @param filepath path (relative or absolute) of the file to open + * @param binary if true, open the file in binary mode * * @throws Exception * If an error occurs, a generic Exception will be thrown. * Detailed error information can be retrieved by calling the * getReason() method of the Exception. */ - virtual void open(const string &filepath, bool binary=false); + void open(const string &filepath, bool binary=false); /* extended version of the read() method */ virtual int read(unsigned char *buf, int len); protected: - ifstream m_filestream; /** file input stream */ + /** file input stream */ + ifstream m_filestream; }; Added: trunk/common/FileOutputStream.cpp =================================================================== --- trunk/common/FileOutputStream.cpp (rev 0) +++ trunk/common/FileOutputStream.cpp 2008-03-02 18:21:21 UTC (rev 55) @@ -0,0 +1,90 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file FileOutputStream.cpp + * @ingroup Common + * + * @brief FileOutputStream implementation + * + * Contains the implementation of the FileOutputStream class. + */ + +#include "ArnacawCommon.h" + +/* default constructor */ +FileOutputStream::FileOutputStream() +{ + +} + +/* file open constructor */ +FileOutputStream::FileOutputStream(const std::string &path, bool binary) +{ + this->open(path, binary); +} + +/* destructor */ +FileOutputStream::~FileOutputStream() +{ + if (m_filestream.is_open()) + m_filestream.close(); +} + +/* open() method */ +void FileOutputStream::open(const string &path, bool binary) +{ + /* check if file already open */ + if (m_filestream.is_open()) + m_filestream.close(); + + /* open file and check for errors */ + ios_base::openmode mode; + mode = ios_base::out; + if (binary) + mode |= ios_base::binary; + + m_filestream.open(path.c_str(), mode); + if (!m_filestream.good()) { + /* error */ + stringstream err; + err << "Failed to open file " << path; + throw Exception(err.str()); + } +} + +/* write() method */ +int FileOutputStream::write(const unsigned char *buf, int len) +{ + /* check the starting status of the file */ + if (!m_filestream.good()) + throw Exception("File stream not good at beginning of write() method"); + + /* write to the file */ + m_filestream.write((const char*)buf, len); + + /* check for errors */ + if (!m_filestream.good()) + throw Exception("Error while writing to FileOutputStream"); + + /* success */ + return len; +} Added: trunk/common/FileOutputStream.h =================================================================== --- trunk/common/FileOutputStream.h (rev 0) +++ trunk/common/FileOutputStream.h 2008-03-02 18:21:21 UTC (rev 55) @@ -0,0 +1,87 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file FileOutputStream.h + * @ingroup Common + * + * @brief FileOutputStream class + * + * Contains the definition of the FileOutputStream class, + * which implements the OutputStream class to provide + * file write operations. + */ + +#ifndef __ARNACAW_FILEOUTPUTSTREAM_H__ +#define __ARNACAW_FILEOUTPUTSTREAM_H__ + +/** + * Implements the OutputStream class to provide file write operations. + * + * @brief OutputStream for files + */ +class FileOutputStream : public OutputStream +{ +public: + /* default constructor */ + FileOutputStream(); + + /** + * Special constructor that creates a FileOutputStream + * object and opens a file to write to. This is the + * same as constructing a FileOutputStream object and + * calling its open() method. + * @see FileOutputStream::open + * + * @param path path of file to write to + * @param binary if true, open the file in binary mode + * + * @throws Exception + * If an error occurs, an Exception will be thrown. + * The reason of the error can be found by calling the + * getReason() method of the Exception object. + */ + FileOutputStream(const string &path, bool binary=false); + + virtual ~FileOutputStream(); + + /** + * Opens a file for writing. + * + * @param path path of file to write to + * @param binary if true, open the file in binary mode + * + * @throws Exception + * If an error occurs, an Exception will be thrown. + * The reason of the error can be found by calling the + * getReason() method of the Exception object. + */ + void open(const string &path, bool binary=false); + + /* write() method */ + virtual int write(const unsigned char *buf, int len); + +protected: + /** file output stream */ + ofstream m_filestream; +}; + +#endif Modified: trunk/common/InputStream.h =================================================================== --- trunk/common/InputStream.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/InputStream.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,6 +23,8 @@ * @file InputStream.h * @ingroup Common * + * @brief InputStream class + * * Defines the InputStream class, which provides a * reusable API for reading from any data source. */ @@ -30,7 +32,11 @@ #ifndef __ARNACAW_INPUTSTREAM_H__ #define __ARNACAW_INPUTSTREAM_H__ -/** Provides a reusable API for reading from any data source. */ +/** + * Provides a reusable API for reading from any data source. + * + * @brief Interface for reading data + */ class InputStream { public: @@ -40,12 +46,10 @@ * @param buf buffer to read into * @param len size of buffer, in bytes * - * @return - * Return codes should be the following: - * >= 0 - Return code is the number of bytes read. - * If this does not equal len, it is assumed - * that the end of the stream was reached. - * + * @return + * Returns the number of bytes read. If this is less than + * len, not enough bytes were available to fill the buffer. + * * @throws Exception * If an error occurs, an Exception must be thrown. */ Modified: trunk/common/OutputStream.h =================================================================== --- trunk/common/OutputStream.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/OutputStream.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,6 +23,8 @@ * @file OutputStream.h * @ingroup Common * + * @brief OutputStream class + * * Defines the OutputStream class, which provides * a reusable API for writing data to any destination, * including files and network packets. @@ -31,7 +33,12 @@ #ifndef __ARNACAW_OUTPUTSTREAM_H__ #define __ARNACAW_OUTPUTSTREAM_H__ -/** Provides a reusable API for writing data to any destination. */ +/** + * Provides a reusable API for writing data to any destination. + * + * @brief Interface for writing data + * + */ class OutputStream { public: @@ -43,6 +50,9 @@ * * @return the number of bytes written if no error occurs, * or a negative value if an error occurs. + * + * @exception Exception + * If an error occurs, an Exception must be thrown. */ virtual int write(const unsigned char *buf, int len) { Modified: trunk/common/Singleton.h =================================================================== --- trunk/common/Singleton.h 2008-03-02 14:31:18 UTC (rev 54) +++ trunk/common/Singleton.h 2008-03-02 18:21:21 UTC (rev 55) @@ -23,6 +23,8 @@ * @file Singleton.h * @ingroup Common * + * @brief Singleton template + * * Defines the Singleton template, which implements the * Singleton pattern. */ @@ -31,8 +33,11 @@ #define __ARNACAW_SINGLETON_H__ /** + * @brief Singleton design pattern + * * Implementation of the Singleton design pattern * + * @note * Any class that inherits this class MUST declare it as * a friend class, and MUST make its constructors protected. */ @@ -41,7 +46,9 @@ { public: - /** returns a reference to the single object */ + /** + * @return Reference to the single object + */ static t &getSingleton() { InitSingleton(); @@ -49,8 +56,8 @@ } /** - * returns a pointer to the single object - * this is a borrowed pointer; do not delete it + * @return Pointer to the single object + * @warning The returned pointer is borrowed; do not delete it. */ static t *getSingletonPtr() { @@ -58,7 +65,7 @@ return m_singleton; } - /** cleans up after self */ + /** Cleans up after self */ virtual ~Singleton() { if (m_singleton) { @@ -69,7 +76,7 @@ protected: - /** creates the single object if it has not been created */ + /** Creates the single object if it has not been created */ static void InitSingleton() { /* check if created */ @@ -79,7 +86,8 @@ } } - static t *m_singleton; /** pointer to the single object */ + /** pointer to the single object */ + static t *m_singleton; }; template<typename t> Modified: trunk/design/Arnacaw.dia =================================================================== (Binary files differ) Added: trunk/doxygen_config =================================================================== --- trunk/doxygen_config (rev 0) +++ trunk/doxygen_config 2008-03-02 18:21:21 UTC (rev 55) @@ -0,0 +1,1356 @@ +# Doxyfile 1.5.5 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for Arnacaw Online +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "Arnacaw Online" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 1 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs/doxygen + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = NO + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = client common server + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Arnacaw docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = arnacaw.Arnacaw + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put.... [truncated message content] |
From: <sh...@us...> - 2008-03-02 14:31:13
|
Revision: 54 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=54&view=rev Author: shoyru Date: 2008-03-02 06:31:18 -0800 (Sun, 02 Mar 2008) Log Message: ----------- add unfinished design documents, diagrams Added Paths: ----------- trunk/design/ trunk/design/Arnacaw.dia trunk/design/SoftwareDesignNotes.odt Added: trunk/design/Arnacaw.dia =================================================================== (Binary files differ) Property changes on: trunk/design/Arnacaw.dia ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/design/SoftwareDesignNotes.odt =================================================================== (Binary files differ) Property changes on: trunk/design/SoftwareDesignNotes.odt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-03-02 14:24:02
|
Revision: 53 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=53&view=rev Author: shoyru Date: 2008-03-02 06:24:03 -0800 (Sun, 02 Mar 2008) Log Message: ----------- add project structure and a small amount of base code Added Paths: ----------- trunk/LICENSE trunk/arnacaw.ncb trunk/arnacaw.sln trunk/arnacaw.suo trunk/client/ trunk/client/client.vcproj trunk/common/ trunk/common/ArnacawCommon.h trunk/common/Exception.cpp trunk/common/Exception.h trunk/common/FileInputStream.cpp trunk/common/FileInputStream.h trunk/common/InputStream.h trunk/common/OutputStream.h trunk/common/Singleton.h trunk/server/ trunk/server/ArnacawServer.h trunk/server/ChangeLog trunk/server/Server.cpp trunk/server/Server.h trunk/server/ServerMain.cpp trunk/server/linux/ trunk/server/server.vcproj trunk/server/win32/ Added: trunk/LICENSE =================================================================== --- trunk/LICENSE (rev 0) +++ trunk/LICENSE 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 2 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, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. Added: trunk/arnacaw.ncb =================================================================== (Binary files differ) Property changes on: trunk/arnacaw.ncb ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/arnacaw.sln =================================================================== --- trunk/arnacaw.sln (rev 0) +++ trunk/arnacaw.sln 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server\server.vcproj", "{A2071F73-2E33-4743-B6EB-120B4031773E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcproj", "{AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A2071F73-2E33-4743-B6EB-120B4031773E}.Debug|Win32.ActiveCfg = Debug|Win32 + {A2071F73-2E33-4743-B6EB-120B4031773E}.Debug|Win32.Build.0 = Debug|Win32 + {A2071F73-2E33-4743-B6EB-120B4031773E}.Release|Win32.ActiveCfg = Release|Win32 + {A2071F73-2E33-4743-B6EB-120B4031773E}.Release|Win32.Build.0 = Release|Win32 + {AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}.Debug|Win32.ActiveCfg = Debug|Win32 + {AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}.Debug|Win32.Build.0 = Debug|Win32 + {AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}.Release|Win32.ActiveCfg = Release|Win32 + {AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: trunk/arnacaw.suo =================================================================== (Binary files differ) Property changes on: trunk/arnacaw.suo ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/client/client.vcproj =================================================================== --- trunk/client/client.vcproj (rev 0) +++ trunk/client/client.vcproj 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,220 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="client" + ProjectGUID="{AE3A9396-E9D4-4ED9-A905-BED0E345E5AD}" + RootNamespace="client" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + <Filter + Name="Header Files (Common)" + > + <File + RelativePath="..\common\ArnacawCommon.h" + > + </File> + <File + RelativePath="..\common\Exception.h" + > + </File> + <File + RelativePath="..\common\FileInputStream.h" + > + </File> + <File + RelativePath="..\common\InputStream.h" + > + </File> + <File + RelativePath="..\common\OutputStream.h" + > + </File> + <File + RelativePath="..\common\Singleton.h" + > + </File> + </Filter> + <Filter + Name="Source Files (Common)" + > + <File + RelativePath="..\common\Exception.cpp" + > + </File> + <File + RelativePath="..\common\FileInputStream.cpp" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: trunk/common/ArnacawCommon.h =================================================================== --- trunk/common/ArnacawCommon.h (rev 0) +++ trunk/common/ArnacawCommon.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,47 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ArnacawCommon.h + * @ingroup Common + * + * Encapsulates the shared header files of the + * Common component. + */ + +#ifndef __ARNACAW_COMMON_H__ +#define __ARNACAW_COMMON_H__ + +/* Standard headers */ +#include <iostream> +#include <fstream> +#include <string> +#include <sstream> +using namespace std; + +/* Arnacaw headers */ +#include "Exception.h" +#include "Singleton.h" +#include "InputStream.h" +#include "OutputStream.h" +#include "FileInputStream.h" + +#endif Added: trunk/common/Exception.cpp =================================================================== --- trunk/common/Exception.cpp (rev 0) +++ trunk/common/Exception.cpp 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,44 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Exception.cpp + * @ingroup Common + * + * Contains the implementation of the Exception class. + */ + +#include "ArnacawCommon.h" + +Exception::Exception(string r) +{ + reason = r; +} + +Exception::~Exception() +{ + +} + +string Exception::getReason() +{ + return reason; +} Added: trunk/common/Exception.h =================================================================== --- trunk/common/Exception.h (rev 0) +++ trunk/common/Exception.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,49 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Exception.h + * @ingroup Common + * + * Defines the Exception class, which is thrown + * by other Arnacaw classes as an exception. + */ + +#ifndef __ARNACAW_EXTENSION_H__ +#define __ARNACAW_EXTENSION_H__ + +/** Thrown by other Arnacaw classes as an exception. */ +class Exception +{ +public: + /** constructor/destructor */ + Exception(string r); + virtual ~Exception(); + + /** returns reason that this was thrown */ + string getReason(); + +protected: + string reason; /** reason that this was thrown */ + +}; + +#endif Added: trunk/common/FileInputStream.cpp =================================================================== --- trunk/common/FileInputStream.cpp (rev 0) +++ trunk/common/FileInputStream.cpp 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,89 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file FileInputStream.cpp + * @ingroup Common + * + * Contains the implementation of the FileInputStream class. + */ + +#include "ArnacawCommon.h" + +/* file open constructor */ +FileInputStream::FileInputStream(const string &filepath, bool binary) +{ + this->open(filepath, binary); +} + +/* destructor */ +FileInputStream::~FileInputStream() +{ + if (m_filestream.is_open()) + m_filestream.close(); +} + +/* open file method */ +void FileInputStream::open(const string &filepath, bool binary) +{ + /* clean up any old files */ + if (m_filestream.is_open()) + m_filestream.close(); + + /* open new file */ + ios_base::openmode mode; + mode = ios_base::in; + if (binary) + mode |= ios_base::binary; + m_filestream.open(filepath.c_str(), mode); + + /* check for errors */ + if (!m_filestream.good()) { + /* error */ + stringstream tmp; + tmp << "Failed to open file "; + tmp << filepath; + tmp << " for reading."; + throw Exception(tmp.str()); + } +} + +/* read method */ +int FileInputStream::read(unsigned char *buf, int len) +{ + /* check ability to read */ + if (!m_filestream.is_open()) + throw Exception("File stream not open when trying to read!"); + if (m_filestream.eof()) + return 0; /* nothing left to read */ + if (!m_filestream.good()) + throw Exception("File stream not good at beginning of read operation."); + + /* read */ + m_filestream.read((char*)buf, len); + if (m_filestream.eof()) + return m_filestream.gcount(); /* EOF reached */ + if (!m_filestream.good()) + throw Exception("Error while reading from file stream."); + + /* success */ + return m_filestream.gcount(); +} Added: trunk/common/FileInputStream.h =================================================================== --- trunk/common/FileInputStream.h (rev 0) +++ trunk/common/FileInputStream.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,75 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file FileInputStream.h + * @ingroup Common + * + * Defines the FileInputStream class, which provides an implementation + * of the InputStream interface to handle file read operations. + */ + +#ifndef __ARNACAW_FILEINPUTSTREAM_H__ +#define __ARNACAW_FILEINPUTSTREAM_H__ + +/** + * Implements the InputStream interface to handle file read operations. + */ +class FileInputStream : public InputStream +{ +public: + /** + * Creates a FileInputStream object and opens a file + * for reading. + * + * @param filepath path (relative or absolute) of the file to open + * + * @throws Exception + * If an error occurs, a generic Exception will be thrown. + * Detailed error information can be retrieved by calling the + * getReason() method of the Exception. + */ + FileInputStream(const string &filepath, bool binary=false); + + virtual ~FileInputStream(); + + /** + * Opens a file for reading, closing any already-open files. + * This can also be done with a specialized constructor. + * + * @param filepath path (relative or absolute) of the file to open + * + * @throws Exception + * If an error occurs, a generic Exception will be thrown. + * Detailed error information can be retrieved by calling the + * getReason() method of the Exception. + */ + virtual void open(const string &filepath, bool binary=false); + + /* extended version of the read() method */ + virtual int read(unsigned char *buf, int len); + +protected: + ifstream m_filestream; /** file input stream */ + +}; + +#endif Added: trunk/common/InputStream.h =================================================================== --- trunk/common/InputStream.h (rev 0) +++ trunk/common/InputStream.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,60 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file InputStream.h + * @ingroup Common + * + * Defines the InputStream class, which provides a + * reusable API for reading from any data source. + */ + +#ifndef __ARNACAW_INPUTSTREAM_H__ +#define __ARNACAW_INPUTSTREAM_H__ + +/** Provides a reusable API for reading from any data source. */ +class InputStream +{ +public: + /** + * Reads data from the stream. + * + * @param buf buffer to read into + * @param len size of buffer, in bytes + * + * @return + * Return codes should be the following: + * >= 0 - Return code is the number of bytes read. + * If this does not equal len, it is assumed + * that the end of the stream was reached. + * + * @throws Exception + * If an error occurs, an Exception must be thrown. + */ + virtual int read(unsigned char *buf, int len) + { + /* this is only an interface - it can't actually read */ + return 0; + } + +}; + +#endif Added: trunk/common/OutputStream.h =================================================================== --- trunk/common/OutputStream.h (rev 0) +++ trunk/common/OutputStream.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,55 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file OutputStream.h + * @ingroup Common + * + * Defines the OutputStream class, which provides + * a reusable API for writing data to any destination, + * including files and network packets. + */ + +#ifndef __ARNACAW_OUTPUTSTREAM_H__ +#define __ARNACAW_OUTPUTSTREAM_H__ + +/** Provides a reusable API for writing data to any destination. */ +class OutputStream +{ +public: + /** + * Writes data to the stream. + * + * @param buf buffer to write from + * @param len length of buffer, in bytes + * + * @return the number of bytes written if no error occurs, + * or a negative value if an error occurs. + */ + virtual int write(const unsigned char *buf, int len) + { + /* this is only an interface - it can't actually write */ + return 0; + } + +}; + +#endif Added: trunk/common/Singleton.h =================================================================== --- trunk/common/Singleton.h (rev 0) +++ trunk/common/Singleton.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,88 @@ +/*****************************************************************************\ + * * + * Arnacaw Online * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Singleton.h + * @ingroup Common + * + * Defines the Singleton template, which implements the + * Singleton pattern. + */ + +#ifndef __ARNACAW_SINGLETON_H__ +#define __ARNACAW_SINGLETON_H__ + +/** + * Implementation of the Singleton design pattern + * + * Any class that inherits this class MUST declare it as + * a friend class, and MUST make its constructors protected. + */ +template <typename t> +class Singleton +{ +public: + + /** returns a reference to the single object */ + static t &getSingleton() + { + InitSingleton(); + return *m_singleton; + } + + /** + * returns a pointer to the single object + * this is a borrowed pointer; do not delete it + */ + static t *getSingletonPtr() + { + InitSingleton(); + return m_singleton; + } + + /** cleans up after self */ + virtual ~Singleton() + { + if (m_singleton) { + delete m_singleton; + m_singleton = NULL; + } + } + +protected: + + /** creates the single object if it has not been created */ + static void InitSingleton() + { + /* check if created */ + if (m_singleton == NULL) { + /* not yet created */ + m_singleton = new t; + } + } + + static t *m_singleton; /** pointer to the single object */ +}; + +template<typename t> +t *Singleton<t>::m_singleton = NULL; + +#endif Added: trunk/server/ArnacawServer.h =================================================================== --- trunk/server/ArnacawServer.h (rev 0) +++ trunk/server/ArnacawServer.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,39 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ArnacawServer.h + * Component: Server + * Purpose: Encapsulates the header files of the + * Server component, making them easier + * to include and reducing build errors. + */ + +#ifndef __ARNACAW_SERVER_BIGHEADER_H__ +#define __ARNACAW_SERVER_BIGHEADER_H__ + +/* Common component */ +#include "ArnacawCommon.h" + +/* Server component */ +#include "Server.h" + +#endif Added: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog (rev 0) +++ trunk/server/ChangeLog 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,26 @@ ++===============================================+ +| ARNACAW ONLINE SERVER | ++-----------------------------------------------+ +| | +| ChangeLog | +| | ++===============================================+ + +------------------------------------------------- + +02 March 2008 - Jim Buchwald + + * Implement and test file stream classes + +------------------------------------------------- + +01 March 2008 - Jim Buchwald + + * Start designing class diagrams + * Begin implementation of some classes + * ServerApplication, Exception, Singleton, + InputStream, OutputStream + * Server application will now run (but doesn't + do anything) + +------------------------------------------------- \ No newline at end of file Added: trunk/server/Server.cpp =================================================================== --- trunk/server/Server.cpp (rev 0) +++ trunk/server/Server.cpp 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,40 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Server.cpp + * @ingroup Server + * + * Contains the implementation of the ServerApplication class, + * which is the main application class for the Server component. + */ + +#include "ArnacawServer.h" + +ServerApplication::ServerApplication() +{ + /* initialize stuff here */ +} + +void ServerApplication::go() +{ + /* TODO: begin execution of program */ +} Added: trunk/server/Server.h =================================================================== --- trunk/server/Server.h (rev 0) +++ trunk/server/Server.h 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,48 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file Server.h + * @ingroup Server + * + * Defines the ServerApplication class, which is the main application + * class for the Server component. + */ + +#ifndef __ARNACAW_SERVER_H__ +#define __ARNACAW_SERVER_H__ + +/** Main application class for the Server component. */ +class ServerApplication : public Singleton<ServerApplication> +{ +public: + friend class Singleton<ServerApplication>; + + /** begins execution of the application */ + void go(); + +protected: + /** protected as part of Singleton pattern */ + ServerApplication(); + +}; + +#endif Added: trunk/server/ServerMain.cpp =================================================================== --- trunk/server/ServerMain.cpp (rev 0) +++ trunk/server/ServerMain.cpp 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,43 @@ +/*****************************************************************************\ + * * + * Arnacaw Online Server * + * Copyright (c) 2008 James Buchwald * + * * + * 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 2 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, write to the Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * * +\*****************************************************************************/ + +/** + * @file ServerMain.cpp + * @ingroup Server + * + * Contains the main entry point of the executable. + */ + +#include "ArnacawServer.h" + +/** main entry point */ +int main(int argc, char **argv) +{ + try { + ServerApplication::getSingleton().go(); + } + catch (Exception &e) { + /* caught unhandled exception */ + cerr << "UNHANDLED EXCEPTION CAUGHT: " << e.getReason() << endl; + } + + return 0; +} Added: trunk/server/server.vcproj =================================================================== --- trunk/server/server.vcproj (rev 0) +++ trunk/server/server.vcproj 2008-03-02 14:24:03 UTC (rev 53) @@ -0,0 +1,246 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="server" + ProjectGUID="{A2071F73-2E33-4743-B6EB-120B4031773E}" + RootNamespace="server" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../common" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + Whol... [truncated message content] |
From: <sh...@us...> - 2008-03-02 14:15:14
|
Revision: 52 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=52&view=rev Author: shoyru Date: 2008-03-02 06:15:20 -0800 (Sun, 02 Mar 2008) Log Message: ----------- oh, uh... probably shouldn't have deleted the entire directory structure... recreating Added Paths: ----------- branches/ tags/ trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-03-02 14:12:47
|
Revision: 51 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=51&view=rev Author: shoyru Date: 2008-03-02 06:12:51 -0800 (Sun, 02 Mar 2008) Log Message: ----------- clear out to prepare for work on new code base Removed Paths: ------------- branches/ tags/ trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2007-07-01 00:03:15
|
Revision: 50 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=50&view=rev Author: shoyru Date: 2007-06-30 17:03:17 -0700 (Sat, 30 Jun 2007) Log Message: ----------- update to packet header structure Modified Paths: -------------- trunk/docs/PACKETS_C2S trunk/docs/PACKETS_S2C Modified: trunk/docs/PACKETS_C2S =================================================================== --- trunk/docs/PACKETS_C2S 2007-06-30 17:53:59 UTC (rev 49) +++ trunk/docs/PACKETS_C2S 2007-07-01 00:03:17 UTC (rev 50) @@ -21,12 +21,17 @@ +--(bits 16-47) packet id (Uint32) | +--(bits 48-63) various boolean flags (16 in total) - | - +--(bit 48) require verification flag - | - +--(bits 49-63) reserved for future use - As such, each packet has a 64-bit overhead. + | | + | +--(bit 48) require verification flag + | | + | +--(bit 49) zlib compression flag + | | + | +--(bits 50-63) reserved for future use + | + +--(bits 64-79) original packet length before compression + As such, each packet has a 80-bit overhead. + AO_C2S_CONNECT The connect packet tells the server that the client is trying to connect. Its structure is as follows: @@ -35,7 +40,7 @@ +--(bits 0-15) major_version (Uint16) | +--(bits 16-31) minor_version (Uint16) - As such, this is a 32-bit packet. + As such, this is a 112-bit packet. AO_C2S_PING The ping packet is sent if the client hasn't sent anything in a while. Modified: trunk/docs/PACKETS_S2C =================================================================== --- trunk/docs/PACKETS_S2C 2007-06-30 17:53:59 UTC (rev 49) +++ trunk/docs/PACKETS_S2C 2007-07-01 00:03:17 UTC (rev 50) @@ -21,18 +21,23 @@ +--(bits 16-47) packet id (Uint32) | +--(bits 48-63) various boolean flags (16 in total) - | - +--(bit 48) require verification flag - | - +--(bits 49-63) reserved for future use - As such, each packet has a 64-bit overhead. + | | + | +--(bit 48) require verification flag + | | + | +--(bit 49) zlib compression flag + | | + | +--(bits 50-63) reserved for future use + | + +--(bits 64-79) original packet length before compression + As such, each packet has a 80-bit overhead. + AO_S2C_CONN_RESULT The connection result packet is sent to the client to tell it if its connection is accepted or rejected. Its structure is as follows: + | - +--(bits 0-15) result (Uint16) + +--(bits 0-7) result (Uint8) As such, this is a 16-bit packet. The result field can contain the possible values: AO_S2C_CONN_RESULT_ACCEPTED: connection accepted @@ -51,16 +56,16 @@ Its structure is as follows: + | - +--(bits 0-127) reason (char[128]) - As such, this is a 128-bit packet. + +--(bits 0-?[max 4016]) + As such, this is potentially a 4096 byte packet (512 bytes) AO_S2C_BANNED The banned packet is sent when the client has been banned from the server. Its structure is as follows: + | - +--(bits 0-127) reason (char[128]) - As such, this is a 128-bit packet. + +--(bits 0-?[max 4016]) + As such, this is potentially a 4096 byte packet (512 bytes) AO_S2C_ACK Acknowledges a received must-verify packet. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2007-06-30 17:53:59
|
Revision: 49 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=49&view=rev Author: shoyru Date: 2007-06-30 10:53:59 -0700 (Sat, 30 Jun 2007) Log Message: ----------- switch to GPLv3 license Modified Paths: -------------- trunk/client/LICENSE trunk/client/src/aodialog.cpp trunk/client/src/chatbox.cpp trunk/client/src/client.cpp trunk/client/src/connectdialog.cpp trunk/client/src/dirs.cpp trunk/client/src/graphics.cpp trunk/client/src/include/aodialog.h trunk/client/src/include/chatbox.h trunk/client/src/include/client.h trunk/client/src/include/common.h trunk/client/src/include/connectdialog.h trunk/client/src/include/crossplatform.h trunk/client/src/include/dirs.h trunk/client/src/include/dlgtextcapture.h trunk/client/src/include/gamecfg.h trunk/client/src/include/graphics.h trunk/client/src/include/network.h trunk/client/src/include/packet.h trunk/client/src/include/packetqueue.h trunk/client/src/include/packettypes.h trunk/client/src/include/packetvar.h trunk/client/src/include/textcapture.h trunk/client/src/main.cpp trunk/client/src/mainloop.cpp trunk/client/src/network.cpp trunk/client/src/packet.cpp trunk/client/src/packetqueue.cpp trunk/client/src/packetvar.cpp trunk/client/src/textcapture.cpp Modified: trunk/client/LICENSE =================================================================== --- trunk/client/LICENSE 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/LICENSE 2007-06-30 17:53:59 UTC (rev 49) @@ -1,282 +1,624 @@ + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + TERMS AND CONDITIONS - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + 0. Definitions. -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + "This License" refers to version 3 of the GNU General Public License. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + A "covered work" means either the unmodified Program or a work based +on the Program. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + 1. Source Code. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + The Corresponding Source for a work in source code form is that +same work. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + 2. Basic Permissions. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. + 14. Revised Versions of this License. - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs @@ -287,15 +629,15 @@ To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> - This program is free software; you can redistribute it and/or modify + 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 2 of the License, or + 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, @@ -303,37 +645,32 @@ 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. Modified: trunk/client/src/aodialog.cpp =================================================================== --- trunk/client/src/aodialog.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/aodialog.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/client/src/chatbox.cpp =================================================================== --- trunk/client/src/chatbox.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/chatbox.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2006 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -13,8 +13,7 @@ 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, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/client/src/client.cpp =================================================================== --- trunk/client/src/client.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/client.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -13,8 +13,7 @@ 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, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/client/src/connectdialog.cpp =================================================================== --- trunk/client/src/connectdialog.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/connectdialog.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/client/src/dirs.cpp =================================================================== --- trunk/client/src/dirs.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/dirs.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ // dirs.cpp Modified: trunk/client/src/graphics.cpp =================================================================== --- trunk/client/src/graphics.cpp 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/graphics.cpp 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2006 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -13,8 +13,7 @@ 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, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/client/src/include/aodialog.h =================================================================== --- trunk/client/src/include/aodialog.h 2007-06-30 17:47:31 UTC (rev 48) +++ trunk/client/src/include/aodialog.h 2007-06-30 17:53:59 UTC (rev 49) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can re... [truncated message content] |
From: <sh...@us...> - 2007-06-30 17:47:30
|
Revision: 48 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=48&view=rev Author: shoyru Date: 2007-06-30 10:47:31 -0700 (Sat, 30 Jun 2007) Log Message: ----------- move to GPLv3 Modified Paths: -------------- trunk/server/ChangeLog trunk/server/LICENSE trunk/server/src/account.cpp trunk/server/src/cfgfile.cpp trunk/server/src/connections.cpp trunk/server/src/dirs.cpp trunk/server/src/include/account.h trunk/server/src/include/cfgfile.h trunk/server/src/include/common.h trunk/server/src/include/connectedplayers.h trunk/server/src/include/connections.h trunk/server/src/include/dirs.h trunk/server/src/include/gamecfg.h trunk/server/src/include/logger.h trunk/server/src/include/logmanager.h trunk/server/src/include/mainloop.h trunk/server/src/include/network.h trunk/server/src/include/packet.h trunk/server/src/include/packetqueue.h trunk/server/src/include/packetsorter.h trunk/server/src/include/packettypes.h trunk/server/src/include/packetvar.h trunk/server/src/include/player.h trunk/server/src/include/rtopts.h trunk/server/src/include/sdl_wrapper.h trunk/server/src/include/utils.h trunk/server/src/logger.cpp trunk/server/src/logmanager.cpp trunk/server/src/main.cpp trunk/server/src/mainloop.cpp trunk/server/src/network.cpp trunk/server/src/packet.cpp trunk/server/src/packetqueue.cpp trunk/server/src/packetsorter.cpp trunk/server/src/packetvar.cpp trunk/server/src/player.cpp trunk/server/src/rtopts.cpp trunk/server/src/sdl_wrapper.cpp Modified: trunk/server/ChangeLog =================================================================== --- trunk/server/ChangeLog 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/ChangeLog 2007-06-30 17:47:31 UTC (rev 48) @@ -12,6 +12,13 @@ change --------------------------------------------------------- +6/30/07 - <James Buchwald> + + Add support for logging to stdout (for debugging) + Switch to GPLv3 license + +--------------------------------------------------------- + 6/28/07 - <James Buchwald> Add support for properly handling received ACK packets Modified: trunk/server/LICENSE =================================================================== --- trunk/server/LICENSE 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/LICENSE 2007-06-30 17:47:31 UTC (rev 48) @@ -1,282 +1,624 @@ + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + TERMS AND CONDITIONS - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + 0. Definitions. -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + "This License" refers to version 3 of the GNU General Public License. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + A "covered work" means either the unmodified Program or a work based +on the Program. - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + 1. Source Code. -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + The Corresponding Source for a work in source code form is that +same work. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + 2. Basic Permissions. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of this License. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 13. Use with the GNU Affero General Public License. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. + 14. Revised Versions of this License. - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. - NO WARRANTY + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. + 15. Disclaimer of Warranty. - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs @@ -287,15 +629,15 @@ To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least +state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> - This program is free software; you can redistribute it and/or modify + 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 2 of the License, or + 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, @@ -303,37 +645,32 @@ 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. Modified: trunk/server/src/account.cpp =================================================================== --- trunk/server/src/account.cpp 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/account.cpp 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/server/src/cfgfile.cpp =================================================================== --- trunk/server/src/cfgfile.cpp 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/cfgfile.cpp 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/server/src/connections.cpp =================================================================== --- trunk/server/src/connections.cpp 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/connections.cpp 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/server/src/dirs.cpp =================================================================== --- trunk/server/src/dirs.cpp 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/dirs.cpp 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common.h" Modified: trunk/server/src/include/account.h =================================================================== --- trunk/server/src/include/account.h 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/include/account.h 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; you can redistribute it and/or modify +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 2 of the License, or +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, @@ -12,9 +12,8 @@ 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, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __AO_ACCOUNT_H__ Modified: trunk/server/src/include/cfgfile.h =================================================================== --- trunk/server/src/include/cfgfile.h 2007-06-28 21:24:09 UTC (rev 47) +++ trunk/server/src/include/cfgfile.h 2007-06-30 17:47:31 UTC (rev 48) @@ -2,9 +2,9 @@ // Copyright (c) 2007 James Buchwald /* -This program is free software; y... [truncated message content] |
From: <sh...@us...> - 2007-06-28 21:24:07
|
Revision: 47 http://arnacaw.svn.sourceforge.net/arnacaw/?rev=47&view=rev Author: shoyru Date: 2007-06-28 14:24:09 -0700 (Thu, 28 Jun 2007) Log Message: ----------- add support for receiving ACK messages Modified Paths: -------------- trunk/client/ChangeLog trunk/client/src/packetqueue.cpp Modified: trunk/client/ChangeLog =================================================================== --- trunk/client/ChangeLog 2007-06-28 21:22:50 UTC (rev 46) +++ trunk/client/ChangeLog 2007-06-28 21:24:09 UTC (rev 47) @@ -5,6 +5,12 @@ ------------------------------------------------- +6/28/07 [James Buchwald] + +Add support for receiving ACK messages from server + +------------------------------------------------- + 6/27/07 [James Buchwald] Fix copy+paste typo in packetqueue.cpp Modified: trunk/client/src/packetqueue.cpp =================================================================== --- trunk/client/src/packetqueue.cpp 2007-06-28 21:22:50 UTC (rev 46) +++ trunk/client/src/packetqueue.cpp 2007-06-28 21:24:09 UTC (rev 47) @@ -107,6 +107,26 @@ Uint32 id = packet->read32(); Uint16 flags = packet->read16(); + // check if this is an ACK packet + if (type == AO_S2C_ACK) { + // check that the current verifying packet matches + AO_Packet *tmp = outgoing_verify.front(); + if (!tmp) { + g_network->freePacket(packet); + continue; // if there aren't any, then the ACK is bad + } + tmp->beginning(); + tmp->read16(); + if (id == tmp->read32()) { + // they match, so remove the packet from the queue + outgoing_verify.pop(); + g_network->freePacket(tmp); + } + // now discard it - we have no further use for it + g_network->freePacket(packet); + continue; + } + // check if we already received this packet if (alreadyReceived.count(id) > 0) { // already received this packet, ACK must have been dropped This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |