]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fg_io.cxx
Code reorganization.
[flightgear.git] / src / Main / fg_io.cxx
index dca5d3bbf062b06939158ef4bf9db808f83b7f29..b5b15156cdebe8d4a980f03a474ecc98cff1aa87 100644 (file)
 // $Id$
 
 
-#include <Include/compiler.h>
+#include <simgear/compiler.h>
 
 #include STL_STRING
 
-#include <Debug/logstream.hxx>
-#include <Include/fg_types.hxx>
+#include <simgear/logstream.hxx>
+#include <simgear/fg_types.hxx>
+
 #include <Main/options.hxx>
 
 #include <Network/iochannel.hxx>
 #include <Network/fg_file.hxx>
 #include <Network/fg_serial.hxx>
+#include <Network/fg_socket.hxx>
 
 #include <Network/protocol.hxx>
+#include <Network/native.hxx>
 #include <Network/garmin.hxx>
 #include <Network/nmea.hxx>
 #include <Network/pve.hxx>
@@ -68,7 +71,10 @@ static FGProtocol *parse_port_config( const string& config )
     FG_LOG( FG_IO, FG_INFO, "  protocol = " << protocol );
 
     FGProtocol *io;
-    if ( protocol == "garmin" ) {
+    if ( protocol == "native" ) {
+       FGNative *native = new FGNative;
+       io = native;
+    } else if ( protocol == "garmin" ) {
        FGGarmin *garmin = new FGGarmin;
        io = garmin;
     } else if ( protocol == "nmea" ) {
@@ -138,14 +144,29 @@ static FGProtocol *parse_port_config( const string& config )
        io->set_io_channel( ch );
     } else if ( medium == "file" ) {
        FGFile *ch = new FGFile;
+       io->set_io_channel( ch );
 
        // file name
        ch->set_file_name( config.substr(begin) );
        FG_LOG( FG_IO, FG_INFO, "  file name = " << ch->get_file_name() );
-
-       io->set_io_channel( ch );
     } else if ( medium == "socket" ) {
-       // ch = new FGSocket;
+       FGSocket *ch = new FGSocket;
+       io->set_io_channel( ch );
+
+       // hostname
+       end = config.find(",", begin);
+       if ( end == string::npos ) {
+           return NULL;
+       }
+    
+       ch->set_hostname( config.substr(begin, end - begin) );
+       begin = end + 1;
+       FG_LOG( FG_IO, FG_INFO, "  hostname = " << ch->get_hostname() );
+
+       // port
+       ch->set_port_str( config.substr(begin) );
+       FG_LOG( FG_IO, FG_INFO, "  port string = " << ch->get_port_str() );
+
     }
 
     return io;