New platform: MS-DOS/FreeDOS with DJGPP (i586-pc-msdosdjgpp). Detect & handle if sys/socket.h isn't present, which is default for DJGPP. Also handle slightly different struct stat, file type macros, absence of Posix signals.

This commit is contained in:
Brian Cox 2016-06-17 19:57:06 -07:00
parent b951838ff6
commit 0ee24bc84b
8 changed files with 52 additions and 18 deletions

View File

@ -87,6 +87,9 @@
/* Define to 1 if you have the <sys/param.h> header file. */ /* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H #undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/statfs.h> header file. */ /* Define to 1 if you have the <sys/statfs.h> header file. */
#undef HAVE_SYS_STATFS_H #undef HAVE_SYS_STATFS_H

2
configure vendored
View File

@ -5585,7 +5585,7 @@ fi
done done
for ac_header in sys/ustat.h sys/sysmacros.h sys/syslog.h for ac_header in sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h
do : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"

View File

@ -63,7 +63,7 @@ AC_CHECK_HEADERS(sys/mount.h,,,
#include <sys/param.h> #include <sys/param.h>
#endif #endif
]]) ]])
AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h) AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h)
AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h) AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h)
AC_CHECK_HEADERS(signum.h bits/signum.h, break ) AC_CHECK_HEADERS(signum.h bits/signum.h, break )
AC_CHECK_HEADERS(stdarg.h varargs.h, break ) AC_CHECK_HEADERS(stdarg.h varargs.h, break )

View File

@ -72,9 +72,13 @@
#endif #endif
#include <sys/utsname.h> #include <sys/utsname.h>
#include <pwd.h> #include <pwd.h>
#include <sys/socket.h>
#include <netdb.h> #if HAVE_SYS_SOCKET_H
#include <netinet/in.h> # include <sys/socket.h>
# include <netdb.h>
# include <netinet/in.h>
#endif
#include <grp.h> #include <grp.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
@ -365,7 +369,11 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th
stat.size = statbuf.st_size; stat.size = statbuf.st_size;
stat.uid = statbuf.st_uid; stat.uid = statbuf.st_uid;
stat.blksize = statbuf.st_blksize; stat.blksize = statbuf.st_blksize;
#ifndef __DJGPP__
stat.blocks = statbuf.st_blocks; stat.blocks = statbuf.st_blocks;
#else
stat.blocks = 0;
#endif
// set the file type // set the file type
if(S_ISREG(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FILE; if(S_ISREG(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FILE;
@ -374,7 +382,9 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th
else if(S_ISBLK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_BLOCKDEV; else if(S_ISBLK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_BLOCKDEV;
else if(S_ISCHR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_CHARDEV; else if(S_ISCHR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_CHARDEV;
else if(S_ISFIFO(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FIFO; else if(S_ISFIFO(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FIFO;
#ifdef S_ISSOCK
else if(S_ISSOCK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SOCK; else if(S_ISSOCK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SOCK;
#endif
#ifdef S_IFDOOR #ifdef S_IFDOOR
else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR; else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR;
#endif #endif
@ -399,7 +409,7 @@ void cUnixFSServices::GetMachineNameFullyQualified( TSTRING& strName ) const
char buf[256]; char buf[256];
if (gethostname(buf, 256) != 0) if (gethostname(buf, 256) != 0)
{ {
#if defined(SOLARIS_NO_GETHOSTBYNAME) || defined(_SORTIX_SOURCE) #if defined(SOLARIS_NO_GETHOSTBYNAME) || defined(_SORTIX_SOURCE) || defined(__DJGPP__)
strName = buf; strName = buf;
return; return;
#else #else
@ -454,7 +464,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress )
bool fGotAddress = false; bool fGotAddress = false;
cDebug d( _T("cUnixFSServices::GetIPAddress") ); cDebug d( _T("cUnixFSServices::GetIPAddress") );
#ifndef _SORTIX_SOURCE #if !defined(_SORTIX_SOURCE) && !defined(__DJGPP__)
struct utsname utsnameBuf; struct utsname utsnameBuf;
if( EFAULT != uname( &utsnameBuf) ) if( EFAULT != uname( &utsnameBuf) )
{ {
@ -557,6 +567,10 @@ bool cUnixFSServices::GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tst
return( fSuccess ); return( fSuccess );
} }
#ifndef S_ISVTX // DOS/DJGPP doesn't have this
# define S_ISVTX 0
#endif
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Function name : cUnixFSServices::ConvertModeToString // Function name : cUnixFSServices::ConvertModeToString
// Description : takes a TSTRING and fills it with an "ls -l" representation // Description : takes a TSTRING and fills it with an "ls -l" representation

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#endif #endif
#ifdef __MINT__ // has memory.h, but memset defined in string.h anyway. #if defined(__MINT__) || defined(__MSDOS__) // has memory.h, but memset defined in string.h anyway.
#include <string.h> #include <string.h>
#endif #endif

View File

@ -38,8 +38,10 @@
#if IS_UNIX #if IS_UNIX
#include <sys/socket.h> # if HAVE_SYS_SOCKET_H
#define SOCKET int # include <sys/socket.h>
# endif
# define SOCKET int
#endif #endif

View File

@ -46,12 +46,14 @@
//All the spleck that it takes to run sockets in Unix... //All the spleck that it takes to run sockets in Unix...
#include <stdio.h> #include <stdio.h>
#include <sys/socket.h> #if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# include <netdb.h>
# include <netinet/in.h>
# include <arpa/inet.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#ifdef _SORTIX_SOURCE #ifdef _SORTIX_SOURCE
@ -191,12 +193,16 @@ long cSMTPMailMessage::GetServerAddress()
if (bIsNumeric) if (bIsNumeric)
{ {
#ifndef HAVE_SYS_SOCKET_H
return 0;
#else
// convert the numberic address to a long // convert the numberic address to a long
return mPfnInetAddr(sNarrowString.c_str()); return mPfnInetAddr(sNarrowString.c_str());
#endif
} }
else else
{ {
#ifdef _SORTIX_SOURCE #if defined(_SORTIX_SOURCE) || !defined(HAVE_SYS_SOCKET_H)
return INADDR_NONE; return INADDR_NONE;
#else #else
// do a DNS lookup of the hostname and get the long // do a DNS lookup of the hostname and get the long
@ -216,6 +222,9 @@ long cSMTPMailMessage::GetServerAddress()
// //
bool cSMTPMailMessage::OpenConnection() bool cSMTPMailMessage::OpenConnection()
{ {
#ifndef HAVE_SYS_SOCKET_H
return false;
#else
// Initialize the socket structure // Initialize the socket structure
sockaddr_in sockAddrIn; sockaddr_in sockAddrIn;
memset(&sockAddrIn, 0, sizeof(sockaddr)); memset(&sockAddrIn, 0, sizeof(sockaddr));
@ -262,6 +271,7 @@ bool cSMTPMailMessage::OpenConnection()
} }
return true; return true;
#endif
} }
@ -485,6 +495,9 @@ bool cSMTPMailMessage::MailMessage()
// //
bool cSMTPMailMessage::GetAcknowledgement() bool cSMTPMailMessage::GetAcknowledgement()
{ {
#ifndef HAVE_SYS_SOCKET_H
return false;
#else
cDebug d( "cSMTPMailMessage::GetAcknowledgement" ); cDebug d( "cSMTPMailMessage::GetAcknowledgement" );
const int bufsize = 512; const int bufsize = 512;
@ -547,17 +560,19 @@ bool cSMTPMailMessage::GetAcknowledgement()
throw eMailSMTPServer(estr.str()); throw eMailSMTPServer(estr.str());
return false; return false;
} }
#endif
} }
void cSMTPMailMessage::SendString( const std::string& str ) void cSMTPMailMessage::SendString( const std::string& str )
{ {
cDebug d("util_SendString()"); cDebug d("util_SendString()");
#if HAVE_SYS_SOCKET_H
if( str.length() < 800 ) if( str.length() < 800 )
d.TraceDebug( "Sending \"%s\"\n", str.c_str() ); d.TraceDebug( "Sending \"%s\"\n", str.c_str() );
else else
d.TraceDebug( "Sending (truncated in this debug output)\"%s\"\n", std::string( str.c_str(), 800 ).c_str() ); d.TraceDebug( "Sending (truncated in this debug output)\"%s\"\n", std::string( str.c_str(), 800 ).c_str() );
mPfnSend( mSocket, str.c_str(), str.length(), 0 ); mPfnSend( mSocket, str.c_str(), str.length(), 0 );
#endif
} }

View File

@ -284,7 +284,7 @@ void cTWInit::Init( const TSTRING& strArgv0 )
mpData->et.SetChild( &mpData->er ); mpData->et.SetChild( &mpData->er );
errorQueue.SetChild( &mpData->et ); errorQueue.SetChild( &mpData->et );
#if IS_UNIX #if IS_UNIX && !defined(__DJGPP__)
// ignore SIGPIPE // ignore SIGPIPE
tw_sigign(SIGPIPE); //TODO: somebody add comment here! tw_sigign(SIGPIPE); //TODO: somebody add comment here!