1
0
Fork 0

MSVC5 portability changes contributed by Bruce Finney.

This commit is contained in:
curt 2000-05-24 06:10:01 +00:00
parent d423fa9337
commit b074559216
12 changed files with 87 additions and 13 deletions

View file

@ -50,6 +50,7 @@
#include "simple.hxx"
FG_USING_NAMESPACE(std);
FGAirports::FGAirports( const string& file ) {
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_READER, 0, NULL );
@ -180,13 +181,13 @@ bool FGAirportsUtil::dump_gdbm( const string& file ) {
GDBM_FILE dbf;
#if !defined( MACOS )
#if defined( MACOS ) || defined( _MSC_VER )
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
NULL, NULL );
#else
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
NULL );
#else
dbf = gdbm_open( (char *)file.c_str(), 0, GDBM_NEWDB | GDBM_FAST,
NULL, NULL );
#endif
if ( dbf == NULL ) {

View file

@ -61,6 +61,7 @@ This source is not checked in this configuration in any way.
#include "ls_types.h"
#include "ls_generic.h"
#include "ls_cockpit.h"
#include "ls_constants.h"
@ -140,7 +141,7 @@ void cherokee_aero()
Cz = Cz0 + Cza*Alpha + Czat*(Alpha_dot*c/2.0/V) + Czq*(q*c/2.0/V) + Czde * elevator;
Cm = Cm0 + Cma*Alpha + Cmat*(Alpha_dot*c/2.0/V) + Cmq*(q*c/2.0/V) + Cmde * elevator;
Cx = Cx0 - (Cza*Alpha)*(Cza*Alpha)/(M_PI*5.71*0.6);
Cx = Cx0 - (Cza*Alpha)*(Cza*Alpha)/(PI*5.71*0.6);
Cl = Clb*Beta + Clp*(p*b/2.0/V) + Clr*(r*b/2.0/V) + Clda * aileron;
Cy = Cyb*Beta + Cyr*(r*b/2.0/V);

View file

@ -34,6 +34,9 @@
$Header$
$Log$
Revision 1.3 2000/05/24 04:10:01 curt
MSVC5 portability changes contributed by Bruce Finney.
Revision 1.2 2000/04/10 18:09:41 curt
David Megginson made a few (mostly minor) mods to the LaRCsim files, and
it's now possible to choose the LaRCsim model at runtime, as in
@ -141,6 +144,9 @@ static char rcsid[] = "$Id$";
#define FACILITY_NAME_STRING "init"
#define CURRENT_VERSION 10
void cherokee_init( void );
void c172_init( void );
typedef struct
{
symbol_rec Symbol;
@ -215,7 +221,12 @@ void ls_init_init( void ) {
if (error) Discrete_States[i].Symbol.Addr = NIL_POINTER;
}
*/
}
/* not all system have strcasecmp */
#ifdef _MSC_VER
# define strcasecmp stricmp
#endif
void ls_init( char * aircraft ) {
/* int i; */

View file

@ -148,7 +148,8 @@ private:
T* object;
Method0v method0v;
typedef void * (fgMethodCallback::*DoPtr)( void ** );
// typedef void * (fgMethodCallback::*DoPtr)( void ** );
typedef void * (fgMethodCallback<T>::*DoPtr)( void ** );
DoPtr doPtr;
};

View file

@ -41,7 +41,8 @@ FG_USING_STD(string);
class FGFixList {
typedef map < string, FGFix, less<string> > fix_map_type;
// typedef map < string, FGFix, less<string> > fix_map_type;
typedef map < string, FGFix > fix_map_type;
typedef fix_map_type::iterator fix_map_iterator;
typedef fix_map_type::const_iterator fix_map_const_iterator;

View file

@ -44,7 +44,8 @@ class FGILSList {
typedef ils_list_type::iterator ils_list_iterator;
typedef ils_list_type::const_iterator ils_list_const_iterator;
typedef map < int, ils_list_type, less<int> > ils_map_type;
// typedef map < int, ils_list_type, less<int> > ils_map_type;
typedef map < int, ils_list_type > ils_map_type;
typedef ils_map_type::iterator ils_map_iterator;
typedef ils_map_type::const_iterator ils_map_const_iterator;

View file

@ -44,7 +44,8 @@ class FGNavList {
typedef nav_list_type::iterator nav_list_iterator;
typedef nav_list_type::const_iterator nav_list_const_iterator;
typedef map < int, nav_list_type, less<int> > nav_map_type;
// typedef map < int, nav_list_type, less<int> > nav_map_type;
typedef map < int, nav_list_type > nav_map_type;
typedef nav_map_type::iterator nav_map_iterator;
typedef nav_map_type::const_iterator nav_map_const_iterator;

View file

@ -25,6 +25,10 @@
#include STL_STRING
#ifdef _MSC_VER
# include <io.h>
#endif
#include <simgear/debug/logstream.hxx>
#include "fg_file.hxx"
@ -43,11 +47,20 @@ 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." );
@ -66,7 +79,11 @@ bool FGFile::open( FGProtocol::fgProtocolDir dir ) {
// 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;
}
@ -78,7 +95,11 @@ int FGFile::readline( char *buf, int length ) {
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;
@ -99,7 +120,11 @@ int FGFile::readline( char *buf, int length ) {
// 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 );
}
@ -117,7 +142,11 @@ int FGFile::writestring( char *str ) {
// close the port
bool FGFile::close() {
#ifdef _MSC_VER
if ( _close( fp ) == -1 ) {
#else
if ( std::close( fp ) == -1 ) {
#endif
return false;
}

View file

@ -134,7 +134,11 @@ int FGSocket::make_client_socket () {
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;
@ -207,7 +211,11 @@ int FGSocket::read( char *buf, int length ) {
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." );
@ -239,7 +247,11 @@ int FGSocket::readline( char *buf, int length ) {
// 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;
@ -313,7 +325,11 @@ int FGSocket::write( char *buf, int length ) {
// 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 {
@ -344,10 +360,17 @@ int FGSocket::writestring( char *str ) {
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;
}

View file

@ -49,6 +49,7 @@
#include <plib/ssg.h> // plib include
#include "material.hxx"
#include "fragment.hxx"
FG_USING_STD(string);
FG_USING_STD(map);

View file

@ -49,6 +49,7 @@
#include "tilecache.hxx"
#include "tileentry.hxx"
FG_USING_NAMESPACE(std);
// a cheesy hack (to be fixed later)
extern ssgBranch *terrain;
@ -201,7 +202,7 @@ FGTileCache::fill_in( int index, const FGBucket& p )
while ( ! in.eof() ) {
in >> token;
in >> name;
#ifdef MACOS
#if defined ( MACOS ) || defined ( _MSC_VER )
in >> ::skipws;
#else
in >> skipws;
@ -333,6 +334,9 @@ FGTileCache::next_avail( void )
FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
exit( -1 );
}
// avoid a potential compiler warning
return -1;
}

View file

@ -270,8 +270,8 @@ void fgUpdateWeatherDatabase(void)
#define KPHTOFPS 0.9113 //km/hr to ft/s
#define MSTOFPS 3.2808 //m/s to ft/s
current_aircraft.fdm_state->set_Velocities_Local_Airmass(my_value.Wind[1]*KPHTOFPS,
my_value.Wind[0]*KPHTOFPS,
my_value.Wind[2]*KPHTOFPS);
my_value.Wind[0]*KPHTOFPS,
my_value.Wind[2]*KPHTOFPS);
}