]> git.mxchange.org Git - flightgear.git/commitdiff
Moved iochannel stuff over into SimGear.
authorcurt <curt>
Tue, 11 Jul 2000 20:40:12 +0000 (20:40 +0000)
committercurt <curt>
Tue, 11 Jul 2000 20:40:12 +0000 (20:40 +0000)
21 files changed:
src/Main/Makefile.am
src/Main/fg_io.cxx
src/Main/fg_io.hxx
src/Network/Makefile.am
src/Network/fg_file.cxx [deleted file]
src/Network/fg_file.hxx [deleted file]
src/Network/fg_serial.cxx [deleted file]
src/Network/fg_serial.hxx [deleted file]
src/Network/fg_socket.cxx [deleted file]
src/Network/fg_socket.hxx [deleted file]
src/Network/garmin.cxx
src/Network/iochannel.cxx [deleted file]
src/Network/iochannel.hxx [deleted file]
src/Network/joyclient.cxx
src/Network/native.cxx
src/Network/nmea.cxx
src/Network/protocol.cxx
src/Network/protocol.hxx
src/Network/pve.cxx
src/Network/ray.cxx
src/Network/rul.cxx

index 705c7aba46f7e2a8df229a54e258fdbef6659faf..169ed434c85493b00435e3b9d287659d452e5a1c 100644 (file)
@@ -43,8 +43,6 @@ fgfs_SOURCES = \
        splash.cxx splash.hxx \
        views.cxx views.hxx
 
-#      fg_serial.cxx fg_serial.hxx \
-
 fgfs_LDADD = \
        $(top_builddir)/src/Aircraft/libAircraft.a \
        $(top_builddir)/src/Autopilot/libAutopilot.a \
@@ -65,9 +63,9 @@ fgfs_LDADD = \
        $(top_builddir)/src/Time/libTime.a \
        $(WEATHER_LIBS) \
        $(top_builddir)/src/Joystick/libJoystick.a \
-       $(SERIAL_LIBS) \
-       -lsgsky -lsgephem -lsgtiming -lsgscreen -lsgmath -lsgbucket \
+       -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen -lsgmath -lsgbucket \
        -lsgdebug -lsgmagvar -lsgmisc \
+       $(SERIAL_LIBS) \
        -lplibpu -lplibfnt -lplibssg -lplibsg \
        -lmk4 -lz \
        $(opengl_LIBS) \
index a54f4c0ca8ed9f84a19426d6cb111060a51c2166..c3859db6e754f8e9ab55602416c0b192a5fb3df7 100644 (file)
 #include STL_STRING
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
+#include <simgear/io/sg_file.hxx>
+#include <simgear/io/sg_serial.hxx>
+#include <simgear/io/sg_socket.hxx>
+
 #include <simgear/math/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>
@@ -132,7 +132,7 @@ static FGProtocol *parse_port_config( const string& config )
     FG_LOG( FG_IO, FG_INFO, "  hertz = " << hertz );
 
     if ( medium == "serial" ) {
-       FGSerial *ch = new FGSerial;
+       SGSerial *ch = new SGSerial;
        io->set_io_channel( ch );
 
        // device name
@@ -151,14 +151,14 @@ static FGProtocol *parse_port_config( const string& config )
 
        io->set_io_channel( ch );
     } else if ( medium == "file" ) {
-       FGFile *ch = new FGFile;
+       SGFile *ch = new SGFile;
        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() );
     } else if ( medium == "socket" ) {
-       FGSocket *ch = new FGSocket;
+       SGSocket *ch = new SGSocket;
        io->set_io_channel( ch );
 
        // hostname
index b92a50a84133c441a7eea9b6858d654c6e4bdbcd..6f7f55cb19c855de0d17593bdc45802ac9215999 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <simgear/compiler.h>
 
-#include <Network/iochannel.hxx>
-
 
 // initialize I/O channels based on command line options (if any)
 void fgIOInit();
@@ -39,5 +37,3 @@ void fgIOProcess();
 
 
 #endif // _FG_IO_HXX
-
-
index 3f200aea474e62ffbe50cbc31ccbc8276c8abda6..305c3363a605bc6c89c1bcbc89033c5ed1cb1b61 100644 (file)
@@ -1,10 +1,6 @@
 noinst_LIBRARIES = libNetwork.a
 
 libNetwork_a_SOURCES = \
-       iochannel.cxx iochannel.hxx \
-       fg_file.cxx fg_file.hxx \
-       fg_serial.cxx fg_serial.hxx \
-       fg_socket.cxx fg_socket.hxx \
        protocol.cxx protocol.hxx \
        native.cxx native.hxx \
        garmin.cxx garmin.hxx \
diff --git a/src/Network/fg_file.cxx b/src/Network/fg_file.cxx
deleted file mode 100644 (file)
index e8e0f36..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-// fg_file.cxx -- File I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <simgear/compiler.h>
-
-#include STL_STRING
-
-#ifdef _MSC_VER
-#  include <io.h>
-#endif
-
-#include <simgear/debug/logstream.hxx>
-
-#include "fg_file.hxx"
-
-FG_USING_STD(string);
-
-
-FGFile::FGFile() {
-    set_type( fgFileType );
-}
-
-
-FGFile::~FGFile() {
-}
-
-
-// open the file based on specified direction
-bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
-    if ( dir == FGProtocol::out ) {
-#ifdef _MSC_VER
-       fp = _open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
-                       00666 );
-#else
-       fp = std::open( file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
-                       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | 
-                       S_IROTH | S_IWOTH );
-#endif
-    } else if ( dir == FGProtocol::in ) {
-#ifdef _MSC_VER
-       fp = _open( file_name.c_str(), O_RDONLY );
-#else
-       fp = std::open( file_name.c_str(), O_RDONLY );
-#endif
-    } else {
-       FG_LOG( FG_IO, FG_ALERT, 
-               "Error:  bidirection mode not available for files." );
-       return false;
-    }
-
-    if ( fp == -1 ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error opening file: " << file_name );
-       return false;
-    }
-
-    return true;
-}
-
-
-// read a block of data of specified size
-int FGFile::read( char *buf, int length ) {
-    // read a chunk
-#ifdef _MSC_VER
-    int result = _read( fp, buf, length );
-#else
-    int result = std::read( fp, buf, length );
-#endif
-
-    return result;
-}
-
-
-// read a line of data, length is max size of input buffer
-int FGFile::readline( char *buf, int length ) {
-    // save our current position
-    int pos = lseek( fp, 0, SEEK_CUR );
-
-    // read a chunk
-#ifdef _MSC_VER
-    int result = _read( fp, buf, length );
-#else
-    int result = std::read( fp, buf, length );
-#endif
-
-    // find the end of line and reset position
-    int i;
-    for ( i = 0; i < result && buf[i] != '\n'; ++i );
-    if ( buf[i] == '\n' ) {
-       result = i + 1;
-    } else {
-       result = i;
-    }
-    lseek( fp, pos + result, SEEK_SET );
-    
-    // just in case ...
-    buf[ result ] = '\0';
-
-    return result;
-}
-
-
-// write data to a file
-int FGFile::write( char *buf, int length ) {
-#ifdef _MSC_VER
-    int result = _write( fp, buf, length );
-#else
-    int result = std::write( fp, buf, length );
-#endif
-    if ( result != length ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << file_name );
-    }
-
-    return result;
-}
-
-
-// write null terminated string to a file
-int FGFile::writestring( char *str ) {
-    int length = strlen( str );
-    return write( str, length );
-}
-
-
-// close the port
-bool FGFile::close() {
-#ifdef _MSC_VER
-    if ( _close( fp ) == -1 ) {
-#else
-    if ( std::close( fp ) == -1 ) {
-#endif
-       return false;
-    }
-
-    return true;
-}
diff --git a/src/Network/fg_file.hxx b/src/Network/fg_file.hxx
deleted file mode 100644 (file)
index 4029825..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-// fg_file.hxx -- File I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _FG_FILE_HXX
-#define _FG_FILE_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/compiler.h>
-
-#include <string>
-
-#include <sys/types.h>         // for open(), read(), write(), close()
-#include <sys/stat.h>          // for open(), read(), write(), close()
-#include <fcntl.h>             // for open(), read(), write(), close()
-#if !defined( _MSC_VER )
-#  include <unistd.h>          // for open(), read(), write(), close()
-#endif
-
-#include "iochannel.hxx"
-#include "protocol.hxx"
-
-FG_USING_STD(string);
-
-
-class FGFile : public FGIOChannel {
-
-    string file_name;
-    int fp;
-
-public:
-
-    FGFile();
-    ~FGFile();
-
-    // open the file based on specified direction
-    bool open( FGProtocol::fgProtocolDir dir );
-
-    // read a block of data of specified size
-    int read( char *buf, int length );
-
-    // read a line of data, length is max size of input buffer
-    int readline( char *buf, int length );
-
-    // write data to a file
-    int write( char *buf, int length );
-
-    // write null terminated string to a file
-    int writestring( char *str );
-
-    // close file
-    bool close();
-
-    inline string get_file_name() const { return file_name; }
-    inline void set_file_name( const string& fn ) { file_name = fn; }
-};
-
-
-#endif // _FG_FILE_HXX
-
-
diff --git a/src/Network/fg_serial.cxx b/src/Network/fg_serial.cxx
deleted file mode 100644 (file)
index 6fae04c..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-// fg_serial.cxx -- Serial I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <simgear/compiler.h>
-
-#include STL_STRING
-
-#include <simgear/debug/logstream.hxx>
-#include <simgear/serial/serial.hxx>
-
-#include <Aircraft/aircraft.hxx>
-
-#include "fg_serial.hxx"
-
-FG_USING_STD(string);
-
-
-FGSerial::FGSerial() :
-    save_len(0)
-{
-    set_type( fgSerialType );
-}
-
-
-FGSerial::~FGSerial() {
-}
-
-
-// open the serial port based on specified direction
-bool FGSerial::open( FGProtocol::fgProtocolDir dir ) {
-    if ( ! port.open_port( device ) ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error opening device: " << device );
-       return false;
-    }
-
-    // cout << "fd = " << port.fd << endl;
-
-    if ( ! port.set_baud( atoi( baud.c_str() ) ) ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error setting baud: " << baud );
-       return false;
-    }
-
-    return true;
-}
-
-
-// Read data from port.  If we don't get enough data, save what we did
-// get in the save buffer and return 0.  The save buffer will be
-// prepended to subsequent reads until we get as much as is requested.
-
-int FGSerial::read( char *buf, int length ) {
-    int result;
-
-    // read a chunk, keep in the save buffer until we have the
-    // requested amount read
-
-    char *buf_ptr = save_buf + save_len;
-    result = port.read_port( buf_ptr, length - save_len );
-    
-    if ( result + save_len == length ) {
-       strncpy( buf, save_buf, length );
-       save_len = 0;
-
-       return length;
-    }
-    
-    return 0;
-}
-
-
-// read data from port
-int FGSerial::readline( char *buf, int length ) {
-    int result;
-
-    // read a chunk, keep in the save buffer until we have the
-    // requested amount read
-
-    char *buf_ptr = save_buf + save_len;
-    result = port.read_port( buf_ptr, FG_MAX_MSG_SIZE - save_len );
-    save_len += result;
-
-    // look for the end of line in save_buf
-    int i;
-    for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i );
-    if ( save_buf[i] == '\n' ) {
-       result = i + 1;
-    } else {
-       // no end of line yet
-       return 0;
-    }
-
-    // we found an end of line
-
-    // copy to external buffer
-    strncpy( buf, save_buf, result );
-    buf[result] = '\0';
-    FG_LOG( FG_IO, FG_INFO, "fg_serial line = " << buf );
-
-    // shift save buffer
-    for ( i = result; i < save_len; ++i ) {
-       save_buf[ i - result ] = save_buf[i];
-    }
-    save_len -= result;
-
-    return result;
-}
-
-
-// write data to port
-int FGSerial::write( char *buf, int length ) {
-    int result = port.write_port( buf, length );
-
-    if ( result != length ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error writing data: " << device );
-    }
-
-    return result;
-}
-
-
-// write null terminated string to port
-int FGSerial::writestring( char *str ) {
-    int length = strlen( str );
-    return write( str, length );
-}
-
-
-// close the port
-bool FGSerial::close() {
-    if ( ! port.close_port() ) {
-       return false;
-    }
-
-    return true;
-}
diff --git a/src/Network/fg_serial.hxx b/src/Network/fg_serial.hxx
deleted file mode 100644 (file)
index f95b813..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// fg_serial.hxx -- Serial I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _FG_SERIAL_HXX
-#define _FG_SERIAL_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/compiler.h>
-
-#include <string>
-
-// #ifdef FG_HAVE_STD_INCLUDES
-// #  include <ctime>
-// #else
-// #  include <time.h>
-// #endif
-
-#include <simgear/serial/serial.hxx>
-
-#include "iochannel.hxx"
-#include "protocol.hxx"
-
-FG_USING_STD(string);
-
-
-class FGSerial : public FGIOChannel {
-
-    string device;
-    string baud;
-    FGSerialPort port;
-
-    char save_buf[ 2 * FG_MAX_MSG_SIZE ];
-    int save_len;
-
-public:
-
-    FGSerial();
-    ~FGSerial();
-
-    // open the serial port based on specified direction
-    bool open( FGProtocol::fgProtocolDir dir );
-
-    // read a block of data of specified size
-    int read( char *buf, int length );
-
-    // read a line of data, length is max size of input buffer
-    int readline( char *buf, int length );
-
-    // write data to port
-    int write( char *buf, int length );
-
-    // write null terminated string to port
-    int writestring( char *str );
-
-    // close port
-    bool close();
-
-    inline string get_device() const { return device; }
-    inline void set_device( const string& d ) { device = d; }
-    inline string get_baud() const { return baud; }
-    inline void set_baud( const string& b ) { baud = b; }
-};
-
-
-#endif // _FG_SERIAL_HXX
-
-
diff --git a/src/Network/fg_socket.cxx b/src/Network/fg_socket.cxx
deleted file mode 100644 (file)
index e57b09a..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-// fg_socket.cxx -- Socket I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <simgear/compiler.h>
-
-#if ! defined( _MSC_VER )
-#  include <sys/time.h>                // select()
-#  include <sys/types.h>       // socket(), bind(), select(), accept()
-#  include <sys/socket.h>      // socket(), bind(), listen(), accept()
-#  include <netinet/in.h>      // struct sockaddr_in
-#  include <netdb.h>           // gethostbyname()
-#  include <unistd.h>          // select(), fsync()/fdatasync()
-#else
-#  include <sys/timeb.h>       // select()
-#  include <winsock2.h>                // socket(), bind(), listen(), accept(),
-                               // struct sockaddr_in, gethostbyname()
-#  include <windows.h>
-#  include <io.h>
-#endif
-
-#if defined( sgi )
-#include <strings.h>
-#endif
-
-#include STL_STRING
-
-#include <simgear/debug/logstream.hxx>
-
-#include "fg_socket.hxx"
-
-FG_USING_STD(string);
-
-
-FGSocket::FGSocket() :
-    save_len(0)
-{
-    set_type( fgSocketType );
-}
-
-
-FGSocket::~FGSocket() {
-}
-
-
-int FGSocket::make_server_socket () {
-    struct sockaddr_in name;
-
-#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER )
-    int length;
-#else
-    socklen_t length;
-#endif
-     
-    // Create the socket.
-    sock = socket (PF_INET, SOCK_STREAM, 0);
-    if (sock < 0) {
-       FG_LOG( FG_IO, FG_ALERT, 
-               "Error: socket() failed in make_server_socket()" );
-       return -1;
-    }
-     
-    // Give the socket a name.
-    name.sin_family = AF_INET;
-    name.sin_addr.s_addr = INADDR_ANY;
-    name.sin_port = htons(port); // set port to zero to let system pick
-    name.sin_addr.s_addr = htonl (INADDR_ANY);
-    if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
-       FG_LOG( FG_IO, FG_ALERT,
-               "Error: bind() failed in make_server_socket()" );
-       return -1;
-    }
-     
-    // Find the assigned port number
-    length = sizeof(struct sockaddr_in);
-    if ( getsockname(sock, (struct sockaddr *) &name, &length) ) {
-       FG_LOG( FG_IO, FG_ALERT,
-               "Error: getsockname() failed in make_server_socket()" );
-       return -1;
-    }
-    port = ntohs(name.sin_port);
-
-    return sock;
-}
-
-
-int FGSocket::make_client_socket () {
-    struct sockaddr_in name;
-    struct hostent *hp;
-     
-    FG_LOG( FG_IO, FG_INFO, "Make client socket()" );
-
-    // Create the socket.
-    sock = socket (PF_INET, SOCK_STREAM, 0);
-    if (sock < 0) {
-       FG_LOG( FG_IO, FG_ALERT, 
-               "Error: socket() failed in make_client_socket()" );
-       return -1;
-    }
-     
-    // specify address family
-    name.sin_family = AF_INET;
-
-    // get the hosts official name/info
-    hp = gethostbyname( hostname.c_str() );
-
-    // Connect this socket to the host and the port specified on the
-    // command line
-#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
-    bcopy(hp->h_addr, (char *)(&(name.sin_addr.s_addr)), hp->h_length);
-#else
-    bcopy(hp->h_addr, &(name.sin_addr.s_addr), hp->h_length);
-#endif
-    name.sin_port = htons(port);
-
-    if ( connect(sock, (struct sockaddr *) &name, 
-                sizeof(struct sockaddr_in)) < 0 )
-    {
-#ifdef _MSC_VER
-       _close(sock);
-#else
-       std::close(sock);
-#endif
-       FG_LOG( FG_IO, FG_ALERT, 
-               "Error: connect() failed in make_client_socket()" );
-       return -1;
-    }
-
-    return sock;
-}
-
-
-// If specified as a server (out direction for now) open the master
-// listening socket.  If specified as a client, open a connection to a
-// server.
-
-bool FGSocket::open( FGProtocol::fgProtocolDir dir ) {
-    if ( port_str == "" || port_str == "any" ) {
-       port = 0; 
-    } else {
-       port = atoi( port_str.c_str() );
-    }
-    
-    client_connections.clear();
-
-    if ( dir == FGProtocol::out ) {
-       // this means server for now
-
-       // Setup socket to listen on.  Set "port" before making this
-       // call.  A port of "0" indicates that we want to let the os
-       // pick any available port.
-       sock = make_server_socket();
-       FG_LOG( FG_IO, FG_INFO, "socket is connected to port = " << port );
-
-       // Specify the maximum length of the connection queue
-       listen(sock, FG_MAX_SOCKET_QUEUE);
-
-    } else if ( dir == FGProtocol::in ) {
-       // this means client for now
-
-       sock = make_client_socket();
-    } else {
-       FG_LOG( FG_IO, FG_ALERT, 
-               "Error:  bidirection mode not available yet for sockets." );
-       return false;
-    }
-
-    if ( sock < 0 ) {
-       FG_LOG( FG_IO, FG_ALERT, "Error opening socket: " << hostname
-               << ":" << port );
-       return false;
-    }
-
-    return true;
-}
-
-
-// read data from socket (client)
-// read a block of data of specified size
-int FGSocket::read( char *buf, int length ) {
-    int result = 0;
-
-    // check for potential input
-    fd_set ready;
-    FD_ZERO(&ready);
-    FD_SET(sock, &ready);
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 0;
-
-    // test for any input read on sock (returning immediately, even if
-    // nothing)
-    select(32, &ready, 0, 0, &tv);
-
-    if ( FD_ISSET(sock, &ready) ) {
-#ifdef _MSC_VER
-       result = _read( sock, buf, length );
-#else
-       result = std::read( sock, buf, length );
-#endif
-       if ( result != length ) {
-           FG_LOG( FG_IO, FG_INFO, 
-                   "Warning: read() not enough bytes." );
-       }
-    }
-
-    return result;
-}
-
-
-// read a line of data, length is max size of input buffer
-int FGSocket::readline( char *buf, int length ) {
-    int result = 0;
-
-    // check for potential input
-    fd_set ready;
-    FD_ZERO(&ready);
-    FD_SET(sock, &ready);
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 0;
-
-    // test for any input read on sock (returning immediately, even if
-    // nothing)
-    select(32, &ready, 0, 0, &tv);
-
-    if ( FD_ISSET(sock, &ready) ) {
-       // read a chunk, keep in the save buffer until we have the
-       // requested amount read
-
-       char *buf_ptr = save_buf + save_len;
-#ifdef _MSC_VER
-       result = _read( sock, buf_ptr, FG_MAX_MSG_SIZE - save_len );
-#else
-       result = std::read( sock, buf_ptr, FG_MAX_MSG_SIZE - save_len );
-#endif
-       save_len += result;
-       // cout << "current read = " << buf_ptr << endl;
-       // cout << "current save_buf = " << save_buf << endl;
-       // cout << "save_len = " << save_len << endl;
-    }
-
-    // look for the end of line in save_buf
-    int i;
-    for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i );
-    if ( save_buf[i] == '\n' ) {
-       result = i + 1;
-    } else {
-       // no end of line yet
-       // cout << "no eol found" << endl;
-       return 0;
-    }
-    // cout << "line length = " << result << endl;
-
-    // we found an end of line
-
-    // copy to external buffer
-    strncpy( buf, save_buf, result );
-    buf[result] = '\0';
-    // cout << "fg_socket line = " << buf << endl;
-    
-    // shift save buffer
-    for ( i = result; i < save_len; ++i ) {
-       save_buf[ i - result ] = save_buf[i];
-    }
-    save_len -= result;
-
-    return result;
-}
-
-
-// write data to socket (server)
-int FGSocket::write( char *buf, int length ) {
-
-    // check for any new client connection requests
-    fd_set ready;
-    FD_ZERO(&ready);
-    FD_SET(sock, &ready);
-    struct timeval tv;
-    tv.tv_sec = 0;
-    tv.tv_usec = 0;
-
-    // test for any input on sock (returning immediately, even if
-    // nothing)
-    select(32, &ready, 0, 0, &tv);
-
-    // any new connections?
-    if ( FD_ISSET(sock, &ready) ) {
-       int msgsock = accept(sock, 0, 0);
-       if ( msgsock < 0 ) {
-           FG_LOG( FG_IO, FG_ALERT, 
-                   "Error: accept() failed in write()" );
-           return 0;
-       } else {
-           client_connections.push_back( msgsock );
-       }
-    }
-
-    bool error_condition = false;
-    FG_LOG( FG_IO, FG_INFO, "Client connections = " << 
-           client_connections.size() );
-    for ( int i = 0; i < (int)client_connections.size(); ++i ) {
-       int msgsock = client_connections[i];
-
-       // read and junk any possible incoming messages.
-       // char junk[ FG_MAX_MSG_SIZE ];
-       // std::read( msgsock, junk, FG_MAX_MSG_SIZE );
-
-       // write the interesting data to the socket
-#ifdef _MSC_VER
-       if ( _write(msgsock, buf, length) < 0 ) {
-#else
-       if ( std::write(msgsock, buf, length) < 0 ) {
-#endif
-           FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
-           error_condition = true;
-       } else {
-#ifdef _POSIX_SYNCHRONIZED_IO
-           // fdatasync(msgsock);
-#else
-           // fsync(msgsock);
-#endif
-       }
-    }
-
-    if ( error_condition ) {
-       return 0;
-    }
-
-    return length;
-}
-
-
-// write null terminated string to socket (server)
-int FGSocket::writestring( char *str ) {
-    int length = strlen( str );
-    return write( str, length );
-}
-
-
-// close the port
-bool FGSocket::close() {
-    for ( int i = 0; i < (int)client_connections.size(); ++i ) {
-       int msgsock = client_connections[i];
-#ifdef _MSC_VER
-       _close( msgsock );
-#else
-       std::close( msgsock );
-#endif
-    }
-
-#ifdef _MSC_VER
-    _close( sock );
-#else
-    std::close( sock );
-#endif
-    return true;
-}
diff --git a/src/Network/fg_socket.hxx b/src/Network/fg_socket.hxx
deleted file mode 100644 (file)
index 21ff995..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-// fg_socket.hxx -- Socket I/O routines
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _FG_SOCKET_HXX
-#define _FG_SOCKET_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/compiler.h>
-
-#include <string>
-
-#include <simgear/math/fg_types.hxx>
-
-#include "iochannel.hxx"
-#include "protocol.hxx"
-
-FG_USING_STD(string);
-
-
-#define FG_MAX_SOCKET_QUEUE 32
-
-
-class FGSocket : public FGIOChannel {
-
-    string hostname;
-    string port_str;
-
-    char save_buf[ 2 * FG_MAX_MSG_SIZE ];
-    int save_len;
-
-    int sock;
-    short unsigned int port;
-
-    // make a server (master listening) socket
-    int make_server_socket();
-
-    // make a client socket
-    int make_client_socket();
-
-    int_list client_connections;
-
-public:
-
-    FGSocket();
-    ~FGSocket();
-
-    // open the file based on specified direction
-    bool open( FGProtocol::fgProtocolDir dir );
-
-    // read data from socket
-    int read( char *buf, int length );
-
-    // read data from socket
-    int readline( char *buf, int length );
-
-    // write data to a socket
-    int write( char *buf, int length );
-
-    // write null terminated string to a socket
-    int writestring( char *str );
-
-    // close file
-    bool close();
-
-    inline string get_hostname() const { return hostname; }
-    inline void set_hostname( const string& hn ) { hostname = hn; }
-    inline string get_port_str() const { return port_str; }
-    inline void set_port_str( const string& p ) { port_str = p; }
-};
-
-
-#endif // _FG_SOCKET_HXX
-
-
index 41aa2a48b8f998809ce8f5462109188cabf693c2..5fdeb81d58f72004c3aa7d56a9d40d2555a17571 100644 (file)
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
+#include <simgear/io/iochannel.hxx>
 
 #include <FDM/flight.hxx>
 #include <Main/globals.hxx>
 
-#include "iochannel.hxx"
 #include "garmin.hxx"
 
 
@@ -350,7 +350,7 @@ bool FGGarmin::open() {
        return false;
     }
 
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     if ( ! io->open( get_direction() ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
@@ -365,15 +365,15 @@ bool FGGarmin::open() {
 
 // process work for this port
 bool FGGarmin::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
            FG_LOG( FG_IO, FG_ALERT, "Success reading data." );
            if ( parse_message() ) {
@@ -404,7 +404,7 @@ bool FGGarmin::process() {
 
 // close the channel
 bool FGGarmin::close() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
 
diff --git a/src/Network/iochannel.cxx b/src/Network/iochannel.cxx
deleted file mode 100644 (file)
index afce400..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// iochannel.cxx -- High level IO channel class
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include "iochannel.hxx"
-#include "garmin.hxx"
-#include "nmea.hxx"
-
-
-// constructor
-FGIOChannel::FGIOChannel()
-{
-}
-
-
-// destructor
-FGIOChannel::~FGIOChannel()
-{
-}
-
-
-// dummy configure routine
-bool FGIOChannel::open( FGProtocol::fgProtocolDir dir ) {
-    return false;
-}
-
-
-// dummy process routine
-int FGIOChannel::read( char *buf, int length ) {
-    return 0;
-}
-
-
-// dummy process routine
-int FGIOChannel::readline( char *buf, int length ) {
-    return 0;
-}
-
-
-// dummy process routine
-int FGIOChannel::write( char *buf, int length ) {
-    return false;
-}
-
-
-// dummy process routine
-int FGIOChannel::writestring( char *str ) {
-    return false;
-}
-
-
-// dummy close routine
-bool FGIOChannel::close() {
-    return false;
-}
diff --git a/src/Network/iochannel.hxx b/src/Network/iochannel.hxx
deleted file mode 100644 (file)
index 0793ef7..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// iochannel.hxx -- High level IO channel class
-//
-// Written by Curtis Olson, started November 1999.
-//
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
-//
-// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _IOCHANNEL_HXX
-#define _IOCHANNEL_HXX
-
-
-#include <simgear/compiler.h>
-
-#include "protocol.hxx"
-
-#include STL_STRING
-#include <vector>
-
-FG_USING_STD(vector);
-FG_USING_STD(string);
-
-
-// forward declaration
-class FGProtocol;
-
-
-enum FGChannelType {
-    fgFileType = 0,
-    fgSerialType = 1,
-    fgSocketType = 2
-};
-
-class FGIOChannel {
-
-    FGChannelType type;
-
-public:
-
-    FGIOChannel();
-    virtual ~FGIOChannel();
-
-    virtual bool open( FGProtocol::fgProtocolDir dir );
-    virtual int read( char *buf, int length );
-    virtual int readline( char *buf, int length );
-    virtual int write( char *buf, int length );
-    virtual int writestring( char *str );
-    virtual bool close();
-
-    virtual void set_type( FGChannelType t ) { type = t; }
-    virtual FGChannelType get_type() const { return type; }
-};
-
-
-#endif // _IOCHANNEL_HXX
-
-
index 2d05092fccbb33b7de36bc92e52041a4de1ca027..4805d639c059a9aaf3d2869066d0456a66bbc883 100644 (file)
 
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
 
 #include <Aircraft/aircraft.hxx>
 
-#include "iochannel.hxx"
 #include "joyclient.hxx"
 
 
@@ -44,7 +44,7 @@ bool FGJoyClient::open() {
        return false;
     }
 
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     if ( ! io->open( get_direction() ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
@@ -59,15 +59,15 @@ bool FGJoyClient::open() {
 
 // process work for this port
 bool FGJoyClient::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
     int length = sizeof(int[2]);
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        FG_LOG( FG_IO, FG_ALERT, "joyclient protocol is read only" );
        return false;
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        FG_LOG( FG_IO, FG_DEBUG, "Searching for data." );
-       if ( io->get_type() == fgFileType ) {
+       if ( io->get_type() == sgFileType ) {
            if ( io->read( (char *)(& buf), length ) == length ) {
                FG_LOG( FG_IO, FG_DEBUG, "Success reading data." );
                int *msg;
@@ -112,7 +112,7 @@ bool FGJoyClient::process() {
 
 // close the channel
 bool FGJoyClient::close() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
 
index f60f0cc90ae308816e4bf2ed25c08f74aff9b2e2..83682604fdc11e45eefd6368f11e8c025fbbbdd3 100644 (file)
@@ -23,8 +23,8 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
+#include <simgear/io/iochannel.hxx>
 
-#include "iochannel.hxx"
 #include "native.hxx"
 
 
@@ -43,7 +43,7 @@ bool FGNative::open() {
        return false;
     }
 
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     if ( ! io->open( get_direction() ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
@@ -58,18 +58,18 @@ bool FGNative::open() {
 
 // process work for this port
 bool FGNative::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
     int length = sizeof(*cur_fdm_state);
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        // cout << "size of cur_fdm_state = " << length << endl;
        buf = *cur_fdm_state;
        if ( ! io->write( (char *)(& buf), length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
-       if ( io->get_type() == fgFileType ) {
+    } else if ( get_direction() == SG_IO_IN ) {
+       if ( io->get_type() == sgFileType ) {
            if ( io->read( (char *)(& buf), length ) == length ) {
                FG_LOG( FG_IO, FG_ALERT, "Success reading data." );
                *cur_fdm_state = buf;
@@ -88,7 +88,7 @@ bool FGNative::process() {
 
 // close the channel
 bool FGNative::close() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
 
index 369f30affc214e269cde12941b241080c401e9e4..7f9b47184751a2b2c4e2c233f92347fd8ae72a72 100644 (file)
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
+#include <simgear/io/iochannel.hxx>
 
 #include <FDM/flight.hxx>
 #include <Main/globals.hxx>
 
-#include "iochannel.hxx"
 #include "nmea.hxx"
 
 
@@ -453,7 +453,7 @@ bool FGNMEA::open() {
        return false;
     }
 
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     if ( ! io->open( get_direction() ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
@@ -468,15 +468,15 @@ bool FGNMEA::open() {
 
 // process work for this port
 bool FGNMEA::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
            parse_message();
        } else {
@@ -497,7 +497,7 @@ bool FGNMEA::process() {
 
 // close the channel
 bool FGNMEA::close() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
 
index 07fc52c6612d99ec0c3c585da84cf30f76ec7fdb..b6918f98fe74e1a22ec6094fcb2cff4ea1bffca1 100644 (file)
@@ -22,8 +22,8 @@
 
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
 
-#include "iochannel.hxx"
 #include "protocol.hxx"
 
 
@@ -47,7 +47,7 @@ bool FGProtocol::open() {
        return false;
     }
 
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     if ( ! io->open( get_direction() ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
@@ -76,7 +76,7 @@ bool FGProtocol::close() {
 
 // standard I/O channel close routine
 bool FGProtocol::gen_message() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
     set_enabled( false );
 
index f3c7fe4d68959e169d3e0edf82f987106edb586a..0417d1860bd7f91f031411f5e101f14b6f820692 100644 (file)
@@ -37,26 +37,17 @@ FG_USING_STD(vector);
 #define FG_MAX_MSG_SIZE 16384
 
 // forward declaration
-class FGIOChannel;
+class SGIOChannel;
 
 
 class FGProtocol {
 
-public:
-
-    enum fgProtocolDir {
-       none = 0,
-       in = 1,
-       out = 2,
-       bi = 3
-    };
-
 private:
 
     double hz;
     int count_down;
 
-    fgProtocolDir dir;
+    SGProtocolDir dir;
 
     // string protocol_str;
 
@@ -65,7 +56,7 @@ private:
 
     bool enabled;
 
-    FGIOChannel *io;
+    SGIOChannel *io;
 
 public:
 
@@ -76,16 +67,16 @@ public:
     virtual bool process();
     virtual bool close();
 
-    inline fgProtocolDir get_direction() const { return dir; }
+    inline SGProtocolDir get_direction() const { return dir; }
     inline void set_direction( const string& d ) {
        if ( d == "in" ) {
-           dir = in;
+           dir = SG_IO_IN;
        } else if ( d == "out" ) {
-           dir = out;
+           dir = SG_IO_OUT;
        } else if ( d == "bi" ) {
-           dir = bi;
+           dir = SG_IO_BI;
        } else {
-           dir = none;
+           dir = SG_IO_NONE;
        }
     }
 
@@ -108,8 +99,8 @@ public:
     inline bool is_enabled() const { return enabled; }
     inline void set_enabled( const bool b ) { enabled = b; }
 
-    inline FGIOChannel *get_io_channel() const { return io; }
-    inline void set_io_channel( FGIOChannel *c ) { io = c; }
+    inline SGIOChannel *get_io_channel() const { return io; }
+    inline void set_io_channel( SGIOChannel *c ) { io = c; }
 };
 
 
index d54c3b11b2b12a74f218288a1e567d898907f5ce..d52f1a6be3d17785fcd02f059f08204989d87bb0 100644 (file)
 #include <stdio.h>             // sprintf()
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/fg_geodesy.hxx>
+#include <simgear/io/iochannel.hxx>
 
 #include <FDM/flight.hxx>
 
-#include "iochannel.hxx"
 #include "pve.hxx"
 
 
@@ -110,15 +110,15 @@ bool FGPVE::parse_message() {
 
 // process work for this port
 bool FGPVE::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        FG_LOG( FG_IO, FG_ALERT, "in direction not supported for RUL." );
        return false;
     }
index df991197476532d8d38d76eb1a1fdd13db08e7e3..0cb0b05672fac3a1ea43b95addbb2e5cc8633d1d 100644 (file)
 
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
 #include <simgear/math/fg_geodesy.hxx>
 
 #include <FDM/flight.hxx>
 
-#include "iochannel.hxx"
 #include "ray.hxx"
 
 
@@ -199,15 +199,15 @@ bool FGRAY::parse_message() {
 
 // process work for this port
 bool FGRAY::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        FG_LOG( FG_IO, FG_ALERT, "in direction not supported for RAY." );
        return false;
     }
index 343e6b154097aa968d288a5c2119c2d6e8f2dea0..c9554956be048a5a49c859eccaf7e6099b438607 100644 (file)
 #include <stdio.h>             // sprintf()
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/io/iochannel.hxx>
 #include <simgear/math/fg_geodesy.hxx>
 
 #include <FDM/flight.hxx>
 
-#include "iochannel.hxx"
 #include "rul.hxx"
 
 
@@ -102,15 +102,15 @@ bool FGRUL::parse_message() {
 
 // process work for this port
 bool FGRUL::process() {
-    FGIOChannel *io = get_io_channel();
+    SGIOChannel *io = get_io_channel();
 
-    if ( get_direction() == out ) {
+    if ( get_direction() == SG_IO_OUT ) {
        gen_message();
        if ( ! io->write( buf, length ) ) {
            FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
            return false;
        }
-    } else if ( get_direction() == in ) {
+    } else if ( get_direction() == SG_IO_IN ) {
        FG_LOG( FG_IO, FG_ALERT, "in direction not supported for RUL." );
        return false;
     }