]> git.mxchange.org Git - flightgear.git/commitdiff
PLIB net removed from FlightGear
authorJames Turner <zakalawe@mac.com>
Sat, 23 Oct 2010 19:37:26 +0000 (20:37 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 24 Oct 2010 06:10:51 +0000 (07:10 +0100)
16 files changed:
src/FDM/ExternalNet/ExternalNet.cxx
src/FDM/ExternalNet/ExternalNet.hxx
src/Main/Makefile.am
src/Main/main.cxx
src/MultiPlayer/multiplaymgr.cxx
src/MultiPlayer/multiplaymgr.hxx
src/MultiPlayer/tiny_xdr.cxx
src/Network/ATC-Main.hxx
src/Network/httpd.cxx
src/Network/httpd.hxx
src/Network/jpg-httpd.cxx
src/Network/jpg-httpd.hxx
src/Network/props.cxx
src/Network/props.hxx
utils/TerraSync/Makefile.am
utils/TerraSync/terrasync.cxx

index 741bb3b784ce53b9d6bf5b958a857fdc72903687..7a3a141563e6eb69c86d79228ef0d137d9c5f626 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/lowlevel.hxx> // endian tests
+#include <simgear/io/sg_netBuffer.hxx>
 
 #include <Main/fg_props.hxx>
 #include <Network/native_ctrls.hxx>
 #include "ExternalNet.hxx"
 
 
+class HTTPClient : public simgear::NetBufferChannel
+{
+
+    bool done;
+    SGTimeStamp start;
+
+public:
+
+    HTTPClient ( const char* host, int port, const char* path ) :
+        done( false )
+    {
+       open ();
+       connect (host, port);
+
+  char buffer[256];
+  ::snprintf (buffer, 256, "GET %s HTTP/1.0\r\n\r\n", path );
+       bufferSend(buffer, strlen(buffer) ) ;
+
+        start.stamp();
+    }
+
+    virtual void handleBufferRead (simgear::NetBuffer& buffer)
+    {
+       const char* s = buffer.getData();
+       while (*s)
+           fputc(*s++,stdout);
+
+       printf("done\n");
+       buffer.remove();
+       printf("after buffer.remove()\n");
+        done = true;
+    }
+
+    bool isDone() const { return done; }
+    bool isDone( long usec ) const { 
+        if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
+            return true;
+        } else {
+            return done;
+        }
+    }
+};
+
 FGExternalNet::FGExternalNet( double dt, string host, int dop, int dip, int cp )
 {
 //     set_delta_t( dt );
index 92d76a3229a2c3b75946ffd1fd4aaeb942f9e7b9..a3f80891a67642364860ee0446f66b955628de8a 100644 (file)
 #ifndef _EXTERNAL_NET_HXX
 #define _EXTERNAL_NET_HXX
 
-#include <plib/netBuffer.h>
-#include <plib/netSocket.h>
-
 #include <simgear/timing/timestamp.hxx> // fine grained timing measurements
+#include <simgear/io/raw_socket.hxx>
 
 #include <Network/net_ctrls.hxx>
 #include <Network/net_fdm.hxx>
 #include <FDM/flight.hxx>
 
 
-class HTTPClient : public netBufferChannel
-{
-
-    bool done;
-    SGTimeStamp start;
-
-public:
-
-    HTTPClient ( const char* host, int port, const char* path ) :
-        done( false )
-    {
-       open ();
-       connect (host, port);
-
-       const char* s = netFormat ( "GET %s HTTP/1.0\r\n\r\n", path );
-       bufferSend( s, strlen(s) ) ;
-
-        start.stamp();
-    }
-
-    virtual void handleBufferRead (netBuffer& buffer)
-    {
-       const char* s = buffer.getData();
-       while (*s)
-           fputc(*s++,stdout);
-
-       printf("done\n");
-       buffer.remove();
-       printf("after buffer.remove()\n");
-        done = true;
-    }
-
-    bool isDone() const { return done; }
-    bool isDone( long usec ) const { 
-        if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
-            return true;
-        } else {
-            return done;
-        }
-    }
-};
-
-
 class FGExternalNet: public FGInterface {
 
 private:
@@ -85,8 +40,8 @@ private:
     int cmd_port;
     string fdm_host;
 
-    netSocket data_client;
-    netSocket data_server;
+    simgear::Socket data_client;
+    simgear::Socket data_server;
 
     bool valid;
 
index bafc883241e39c1ff2c0d25e66ffc891b6d705cd..b7d7ed87caa5cbebc241eca399be81e70d1db70d 100644 (file)
@@ -24,11 +24,9 @@ endif
 
 if HAVE_FRAMEWORK_PLIB
 fgfs_PLIB_FW = $(plib_FRAMEWORK)
-metar_PLIB_FW = $(plib_FRAMEWORK)
 else
-fgfs_PLIB_LIBS = -lplibpuaux -lplibpu -lplibfnt -lplibjs -lplibnet \
+fgfs_PLIB_LIBS = -lplibpuaux -lplibpu -lplibfnt -lplibjs  \
        -lplibsg -lplibul 
-metar_PLIB_LIBS = -lplibnet -lplibul 
 endif
 
 if HAVE_FRAMEWORK_OSG
@@ -133,9 +131,8 @@ metar_SOURCES = metar_main.cxx
 
 metar_LDADD = \
         -lsgenvironment -lsgio -lsgbucket -lsgmisc -lsgstructure -lsgdebug \
-        $(metar_PLIB_LIBS) $(network_LIBS) \
+        $(network_LIBS) \
         -lz $(base_LIBS)
 
-metar_LDFLAGS = $(metar_PLIB_FW)
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
index 8849644b3cd28a26bad5ea17779d40593ffef476..fc28ce963aa92b55d85b408fc04cac727fcdd8ee 100644 (file)
@@ -48,6 +48,7 @@
 #include <simgear/props/props.hxx>
 #include <simgear/timing/sg_time.hxx>
 #include <simgear/math/sg_random.h>
+#include <simgear/io/raw_socket.hxx>
 
 #include <Time/light.hxx>
 #include <Aircraft/replay.hxx>
@@ -588,8 +589,8 @@ int fgMainInit( int argc, char **argv ) {
     fgRegisterIdleHandler( &fgIdleFunction );
     fgRegisterDrawHandler( &FGRenderer::update );
 
-    // Initialize plib net interface
-    netInit( &argc, argv );
+    // Initialize sockets (WinSock needs this)
+    simgear::Socket::initSockets();
 
     // Clouds3D requires an alpha channel
     fgOSOpenWindow(true /* request stencil buffer */);
index 317d2df41da8e98be0b1ee8a096871fb78cf7453..27c455c259e50a9939168e0924de6363cf5edff4 100644 (file)
@@ -35,7 +35,6 @@
 #include <algorithm>
 #include <cstring>
 #include <osg/Math>             // isNaN
-#include <plib/netSocket.h>
 
 #include <simgear/misc/stdint.hxx>
 #include <simgear/timing/timestamp.hxx>
@@ -411,7 +410,7 @@ FGMultiplayMgr::init (void)
   SG_LOG(SG_NETWORK,SG_INFO,"FGMultiplayMgr::init-callsign= "<<mCallsign);
   Close(); // Should Init be called twice, close Socket first
            // A memory leak was reported here by valgrind
-  mSocket = new netSocket();
+  mSocket = new simgear::Socket();
   if (!mSocket->open(false)) {
     SG_LOG( SG_NETWORK, SG_DEBUG,
             "FGMultiplayMgr::init - Failed to create data socket" );
@@ -731,7 +730,7 @@ FGMultiplayMgr::update(double)
     //  returned will only be that of the next
     //  packet waiting to be processed.
     //////////////////////////////////////////////////
-    netAddress SenderAddress;
+    simgear::IPAddress SenderAddress;
     bytes = mSocket->recvfrom(msgBuf.Msg, sizeof(msgBuf.Msg), 0,
                               &SenderAddress);
     //////////////////////////////////////////////////
@@ -815,7 +814,7 @@ FGMultiplayMgr::update(double)
 //////////////////////////////////////////////////////////////////////
 void
 FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg,
-                              const netAddress& SenderAddress, long stamp)
+                              const simgear::IPAddress& SenderAddress, long stamp)
 {
   const T_MsgHdr* MsgHdr = Msg.msgHdr();
   if (MsgHdr->MsgLen < sizeof(T_MsgHdr) + sizeof(T_PositionMsg)) {
@@ -965,7 +964,7 @@ FGMultiplayMgr::ProcessPosMsg(const FGMultiplayMgr::MsgBuf& Msg,
 //////////////////////////////////////////////////////////////////////
 void
 FGMultiplayMgr::ProcessChatMsg(const MsgBuf& Msg,
-                               const netAddress& SenderAddress)
+                               const simgear::IPAddress& SenderAddress)
 {
   const T_MsgHdr* MsgHdr = Msg.msgHdr();
   if (MsgHdr->MsgLen < sizeof(T_MsgHdr) + 1) {
index b2417f8dd5b5c1c6fde9b65548b41e43ecb3cea9..5a08e1aab27a61f9164cc8d6e35cff2c4f5d9dfc 100644 (file)
@@ -38,8 +38,8 @@
 
 #include <simgear/compiler.h>
 #include <simgear/props/props.hxx>
-#include <plib/netSocket.h>
 #include <Main/globals.hxx>
+#include <simgear/io/raw_socket.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 
 #include <AIModel/AIMultiplayer.hxx>
@@ -78,16 +78,16 @@ private:
                                   const std::string& modelName);
   FGAIMultiplayer* getMultiplayer(const std::string& callsign);
   void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u);
-  void ProcessPosMsg(const MsgBuf& Msg, const netAddress& SenderAddress,
+  void ProcessPosMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress,
                      long stamp);
-  void ProcessChatMsg(const MsgBuf& Msg, const netAddress& SenderAddress);
+  void ProcessChatMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress);
 
   /// maps from the callsign string to the FGAIMultiplayer
   typedef std::map<std::string, SGSharedPtr<FGAIMultiplayer> > MultiPlayerMap;
   MultiPlayerMap mMultiPlayerMap;
 
-  netSocket* mSocket;
-  netAddress mServer;
+  simgear::Socket* mSocket;
+  simgear::IPAddress mServer;
   bool mHaveServer;
   bool mInitialised;
   std::string mCallsign;
index b0c57d3a7413bc0596f2f6460c104497fe89dbed..e8f292141108923d2b635a57fe6b0699e87b78e7 100644 (file)
@@ -13,9 +13,6 @@
 
 #include <string>
 
-#include <plib/ul.h>
-#include <plib/netSocket.h>
-
 #include "tiny_xdr.hxx"
 
 /* XDR 8bit integers */
index f72bd8da57f9aedfd44457f4c8b2d1480588611e..b6adc73ef1574d023dc24de1383530eb1d1e50df 100644 (file)
@@ -28,8 +28,6 @@
 #  include <config.h>
 #endif
 
-#include <plib/netChat.h>
-
 #include <simgear/misc/sg_path.hxx>
 
 #include <Main/fg_props.hxx>
index 7adc4214d7a2cfff8c7dd35ef042aee738f192f7..e2e6a918f5326eb52b18536a0cd4d50ca158e303 100644 (file)
@@ -66,7 +66,7 @@ bool FGHttpd::open() {
 
 
 bool FGHttpd::process() {
-    netChannel::poll();
+    simgear::NetChannel::poll();
 
     return true;
 }
index 487ddd3f231a9ae16667fc342ffc4d206797c341..580097ffb7c2fcd2db664c0fc3e5976f46da96b3 100644 (file)
@@ -32,7 +32,7 @@
 #  include <config.h>
 #endif
 
-#include <plib/netChat.h>
+#include <simgear/io/sg_netChat.hxx>
 
 #include "protocol.hxx"
 
 /* simple httpd server that makes an hasty stab at following the http
    1.1 rfc.  */
 
-class HttpdChannel : public netChat
+class HttpdChannel : public simgear::NetChat
 {
 
-    netBuffer buffer ;
+    simgear::NetBuffer buffer ;
 
     string urlEncode(string);
     string urlDecode(string);
@@ -61,12 +61,12 @@ public:
 } ;
 
 
-class HttpdServer : private netChannel
+class HttpdServer : private simgear::NetChannel
 {
     virtual bool writable (void) { return false ; }
 
     virtual void handleAccept (void) {
-        netAddress addr ;
+        simgear::IPAddress addr ;
         int handle = accept ( &addr ) ;
         SG_LOG( SG_IO, SG_INFO, "Client " << addr.getHost() << ":" << addr.getPort() << " connected" );
 
index abf2911e3893210411f82a2c9d21c0e192d90923..ba5e5e3c25a51114d75d611f1dad46803c827eb2 100644 (file)
@@ -75,7 +75,7 @@ bool FGJpegHttpd::open() {
 
 
 bool FGJpegHttpd::process() {
-    netChannel::poll();
+    simgear::NetChannel::poll();
 
     return true;
 }
index 1628dff7b43013710987a62157b581f6ba36cd7c..e4fde9e9b9a835a026fd04446b32db7c69326d85 100644 (file)
@@ -32,7 +32,7 @@
 #  include <config.h>
 #endif
 
-#include <plib/netChat.h>
+#include <simgear/io/sg_netChat.hxx>
 
 #ifdef FG_JPEG_SERVER
 #  include <simgear/screen/jpgfactory.hxx>
@@ -57,10 +57,10 @@ class trJpgFactory;
 /* simple httpd server that makes an hasty stab at following the http
    1.1 rfc.  */
 
-class HttpdImageChannel : public netChat
+class HttpdImageChannel : public simgear::NetChat
 {
 
-    netBuffer buffer ;
+    simgear::NetBuffer buffer ;
     trJpgFactory *JpgFactory;
     
 public:
@@ -89,12 +89,12 @@ public:
 };
 
 
-class HttpdImageServer : private netChannel
+class HttpdImageServer : private simgear::NetChannel
 {
     virtual bool writable (void) { return false ; }
 
     virtual void handleAccept (void) {
-        netAddress addr ;
+        simgear::IPAddress addr ;
         int handle = accept ( &addr ) ;
         SG_LOG( SG_IO, SG_INFO, "Client " << addr.getHost() << ":" << addr.getPort() << " connected" );
 
index e6760eaff1a0bce67540ff1e068473a423668786..5b9eb7a1a64f6b5ad9577e1fa10699feb1399208 100644 (file)
@@ -40,7 +40,7 @@
 #include <Main/globals.hxx>
 #include <Main/viewmgr.hxx>
 
-#include <plib/netChat.h>
+#include <simgear/io/sg_netChat.hxx>
 
 #include "props.hxx"
 
@@ -54,9 +54,9 @@ using std::endl;
  * Props connection class.
  * This class represents a connection to props client.
  */
-class PropsChannel : public netChat
+class PropsChannel : public simgear::NetChat
 {
-    netBuffer buffer;
+    simgear::NetBuffer buffer;
 
     /**
      * Current property node name.
@@ -471,9 +471,9 @@ FGProps::open()
         return false;
     }
 
-    netChannel::open();
-    netChannel::bind( "", port );
-    netChannel::listen( 5 );
+    simgear::NetChannel::open();
+    simgear::NetChannel::bind( "", port );
+    simgear::NetChannel::listen( 5 );
     SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
 
     set_enabled( true );
@@ -496,7 +496,7 @@ FGProps::close()
 bool
 FGProps::process()
 {
-    netChannel::poll();
+    simgear::NetChannel::poll();
     return true;
 }
 
@@ -506,7 +506,7 @@ FGProps::process()
 void
 FGProps::handleAccept()
 {
-    netAddress addr;
+    simgear::IPAddress addr;
     int handle = accept( &addr );
     SG_LOG( SG_IO, SG_INFO, "Props server accepted connection from "
             << addr.getHost() << ":" << addr.getPort() );
index bb661aed1e35676717f34efff8c1d83c99e2e26d..e55f7c1330c38783ba8ec62c70bc934298a9a071 100644 (file)
 #include <string>
 #include <vector>
 
-using std::string;
-using std::vector;
-
-#include <plib/netChannel.h>
+#include <simgear/io/sg_netChannel.hxx>
 
 #include "protocol.hxx"
 
@@ -43,7 +40,7 @@ using std::vector;
  * FlightGear properties.
  */
 class FGProps : public FGProtocol,
-               public netChannel
+               public simgear::NetChannel
 {
 private:
 
@@ -58,7 +55,7 @@ public:
      * 
      * @param tokens Tokenized configuration parameters
      */
-    FGProps( const vector<string>& tokens );
+    FGProps( const std::vector<std::string>& tokens );
 
     /**
      * Destructor.
index 0b71b9ea4979b7932603235f361cced534d6033e..7106cc72f2d49a92b97e24d92c492915acb46238 100644 (file)
@@ -6,10 +6,4 @@ terrasync_SOURCES = terrasync.cxx
 
 AM_CPPFLAGS = $(svn_CPPFLAGS)
 
-if HAVE_FRAMEWORK_PLIB
-terrasync_LDFLAGS = $(plib_FRAMEWORK)
-else
-terrasync_PLIB_LIBS = -lplibnet -lplibul  
-endif
-
-terrasync_LDADD = $(terrasync_PLIB_LIBS) -lsgmisc -lsgdebug $(network_LIBS) $(svn_LIBS)
+terrasync_LDADD = -lsgio -lsgmisc -lsgdebug $(network_LIBS) $(svn_LIBS)
index c8138e708564ff14c2490384047bd3807c9890e5..0628e2aef0dd35fc2a594b9a8d995cde8cf91ece 100644 (file)
@@ -47,9 +47,7 @@
 #include <deque>
 #include <map>
 
-#include <plib/netSocket.h>
-#include <plib/ul.h>
-
+#include <simgear/io/raw_socket.hxx>
 #include <simgear/bucket/newbucket.hxx>
 #include <simgear/misc/sg_path.hxx>
 
@@ -115,7 +113,7 @@ static void usage( const string& prog ) {
 deque<string> waitingTiles;
 typedef map<string,time_t> CompletedTiles;
 CompletedTiles completedTiles;
-netSocket theSocket;
+simgear::Socket theSocket;
 
 #ifdef HAVE_SVN_CLIENT_H
 
@@ -513,7 +511,7 @@ int main( int argc, char **argv ) {
     }
     
     // Must call this before any other net stuff
-    netInit( &argc,argv );
+    simgear::Socket::initSockets();
 
     if ( ! theSocket.open( false ) ) {  // open a UDP socket
         printf("error opening socket\n");
@@ -624,7 +622,11 @@ int main( int argc, char **argv ) {
            terminating = true;
        } else
 
-        ulSleep( 1 );
+        #ifdef _WIN32
+                Sleep(1000);
+#else
+               sleep(1);
+#endif
     } // while !terminating
         
     return 0;