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:
		
							parent
							
								
									b951838ff6
								
							
						
					
					
						commit
						0ee24bc84b
					
				| 
						 | 
				
			
			@ -87,6 +87,9 @@
 | 
			
		|||
/* Define to 1 if you have the <sys/param.h> header file. */
 | 
			
		||||
#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. */
 | 
			
		||||
#undef HAVE_SYS_STATFS_H
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5585,7 +5585,7 @@ fi
 | 
			
		|||
 | 
			
		||||
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 :
 | 
			
		||||
  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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ AC_CHECK_HEADERS(sys/mount.h,,,
 | 
			
		|||
#include <sys/param.h>
 | 
			
		||||
#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(signum.h bits/signum.h, break )
 | 
			
		||||
AC_CHECK_HEADERS(stdarg.h varargs.h, break )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,9 +72,13 @@
 | 
			
		|||
#endif
 | 
			
		||||
#include <sys/utsname.h>
 | 
			
		||||
#include <pwd.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <netdb.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
 | 
			
		||||
#if HAVE_SYS_SOCKET_H
 | 
			
		||||
# include <sys/socket.h>
 | 
			
		||||
# include <netdb.h>
 | 
			
		||||
# include <netinet/in.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <grp.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -365,7 +369,11 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th
 | 
			
		|||
    stat.size       = statbuf.st_size;
 | 
			
		||||
    stat.uid        = statbuf.st_uid;
 | 
			
		||||
    stat.blksize    = statbuf.st_blksize;
 | 
			
		||||
#ifndef __DJGPP__
 | 
			
		||||
    stat.blocks     = statbuf.st_blocks;
 | 
			
		||||
#else
 | 
			
		||||
    stat.blocks     = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // set the file type
 | 
			
		||||
    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_ISCHR(statbuf.st_mode))   stat.mFileType = cFSStatArgs::TY_CHARDEV;
 | 
			
		||||
    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;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef S_IFDOOR
 | 
			
		||||
    else if(S_ISDOOR(statbuf.st_mode))  stat.mFileType = cFSStatArgs::TY_DOOR;
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -399,7 +409,7 @@ void cUnixFSServices::GetMachineNameFullyQualified( TSTRING& strName ) const
 | 
			
		|||
    char buf[256];
 | 
			
		||||
    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;
 | 
			
		||||
        return;
 | 
			
		||||
#else
 | 
			
		||||
| 
						 | 
				
			
			@ -454,7 +464,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress )
 | 
			
		|||
    bool    fGotAddress = false;    
 | 
			
		||||
    cDebug  d( _T("cUnixFSServices::GetIPAddress") );
 | 
			
		||||
 | 
			
		||||
#ifndef _SORTIX_SOURCE
 | 
			
		||||
#if !defined(_SORTIX_SOURCE) && !defined(__DJGPP__)
 | 
			
		||||
    struct utsname utsnameBuf;    
 | 
			
		||||
    if( EFAULT != uname( &utsnameBuf) )
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -557,6 +567,10 @@ bool cUnixFSServices::GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tst
 | 
			
		|||
    return( fSuccess );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef S_ISVTX // DOS/DJGPP doesn't have this
 | 
			
		||||
# define S_ISVTX 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Function name    : cUnixFSServices::ConvertModeToString
 | 
			
		||||
// Description      : takes a TSTRING and fills it with an "ls -l" representation
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
 #include <string.h>
 | 
			
		||||
#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>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,9 +37,11 @@
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if IS_UNIX
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#define SOCKET int
 | 
			
		||||
#if IS_UNIX 
 | 
			
		||||
# if HAVE_SYS_SOCKET_H
 | 
			
		||||
#  include <sys/socket.h>
 | 
			
		||||
# endif
 | 
			
		||||
# define SOCKET int
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,12 +46,14 @@
 | 
			
		|||
 | 
			
		||||
//All the spleck that it takes to run sockets in Unix...
 | 
			
		||||
#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/time.h>
 | 
			
		||||
#include <netdb.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <sys/utsname.h>
 | 
			
		||||
 | 
			
		||||
#ifdef _SORTIX_SOURCE
 | 
			
		||||
| 
						 | 
				
			
			@ -191,12 +193,16 @@ long cSMTPMailMessage::GetServerAddress()
 | 
			
		|||
 | 
			
		||||
    if (bIsNumeric)
 | 
			
		||||
    {
 | 
			
		||||
#ifndef HAVE_SYS_SOCKET_H
 | 
			
		||||
        return 0;
 | 
			
		||||
#else
 | 
			
		||||
        // convert the numberic address to a long
 | 
			
		||||
        return mPfnInetAddr(sNarrowString.c_str());
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
#ifdef _SORTIX_SOURCE
 | 
			
		||||
#if defined(_SORTIX_SOURCE) || !defined(HAVE_SYS_SOCKET_H)
 | 
			
		||||
        return INADDR_NONE;
 | 
			
		||||
#else
 | 
			
		||||
        // do a DNS lookup of the hostname and get the long
 | 
			
		||||
| 
						 | 
				
			
			@ -216,6 +222,9 @@ long cSMTPMailMessage::GetServerAddress()
 | 
			
		|||
//
 | 
			
		||||
bool cSMTPMailMessage::OpenConnection()
 | 
			
		||||
{
 | 
			
		||||
#ifndef HAVE_SYS_SOCKET_H
 | 
			
		||||
    return false;
 | 
			
		||||
#else
 | 
			
		||||
    // Initialize the socket structure
 | 
			
		||||
    sockaddr_in sockAddrIn;
 | 
			
		||||
    memset(&sockAddrIn, 0, sizeof(sockaddr));
 | 
			
		||||
| 
						 | 
				
			
			@ -262,6 +271,7 @@ bool cSMTPMailMessage::OpenConnection()
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -485,6 +495,9 @@ bool cSMTPMailMessage::MailMessage()
 | 
			
		|||
//
 | 
			
		||||
bool cSMTPMailMessage::GetAcknowledgement()
 | 
			
		||||
{
 | 
			
		||||
#ifndef HAVE_SYS_SOCKET_H
 | 
			
		||||
    return false;
 | 
			
		||||
#else  
 | 
			
		||||
    cDebug d( "cSMTPMailMessage::GetAcknowledgement" );
 | 
			
		||||
 | 
			
		||||
    const int bufsize = 512;
 | 
			
		||||
| 
						 | 
				
			
			@ -547,17 +560,19 @@ bool cSMTPMailMessage::GetAcknowledgement()
 | 
			
		|||
        throw eMailSMTPServer(estr.str());
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cSMTPMailMessage::SendString( const std::string& str )
 | 
			
		||||
{
 | 
			
		||||
    cDebug d("util_SendString()");
 | 
			
		||||
 | 
			
		||||
#if HAVE_SYS_SOCKET_H
 | 
			
		||||
    if( str.length() < 800 )
 | 
			
		||||
        d.TraceDebug( "Sending \"%s\"\n", str.c_str() );
 | 
			
		||||
    else
 | 
			
		||||
        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 );
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -284,7 +284,7 @@ void cTWInit::Init( const TSTRING& strArgv0 )
 | 
			
		|||
    mpData->et.SetChild( &mpData->er );
 | 
			
		||||
    errorQueue.SetChild( &mpData->et );
 | 
			
		||||
 | 
			
		||||
#if IS_UNIX
 | 
			
		||||
#if IS_UNIX && !defined(__DJGPP__)
 | 
			
		||||
    // ignore SIGPIPE
 | 
			
		||||
    tw_sigign(SIGPIPE); //TODO: somebody add comment here!
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue