Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit a2193a89 authored by deuce's avatar deuce

Initial untested *nix support.

parent cac2123c
# OpenDoors 6.30
# (C} Copyright 1991 - 1997 by Brian Pirie. All Rights Reserved.
#
# Oct-2001 door32.sys/socket modifications by Rob Swindell (www.synchro.net}
#
#
# File: Win32.mak
#
# Description: Makefile used to build the Win32 OpenDoors libraries from
# the sources. Usage is described below.
#
# Revisions: Date Ver Who Change
# ---------------------------------------------------------------
# Aug 09, 2003 6.3 SH *nix port
#
###############################################################################
#
# USAGE INFORMATION
#
###############################################################################
#
# Command Line: make -fWin32.mak
# or
# nmake /f Win32.mak
#
###############################################################################
#
# CONFIGURATION
#
# Customize this section of the makefile to provide the relevant information
# for your compiler, assembler (if any} and build environment.
#
###############################################################################
# Compiler executable file name. Use:
#
# tcc - For Borland Turbo C and Turbo C++
# bcc - For Borland C++
# cl - For Microsoft compilers
#
CC := gcc
#
#------------------------------------------------------------------------------
#
# Linker executable file name. Use:
#
# tlink - For Borland compilers
# link - For Microsoft compilers
#
LD := ld
#
#------------------------------------------------------------------------------
#
# Compiler command-line flags.
#
CFLAGS += -O2
# /MTd /Zi - for debug
#
#------------------------------------------------------------------------------
#
# Link flags.
#
LDFLAGS :=
#
#------------------------------------------------------------------------------
#
# Output directories. customize for your own preferences. Note that trailing
# backslash (\} characters are required.
#
SHLIB := .so
STATICLIB := .a
OBJFILE := .o
#
###############################################################################
#
# DEPENDENCIES
#
# You won't normally have to change anything after this point in this makefile.
#
###############################################################################
#
# Define primary target.
#
all: ${LIBDIR}ODoors62${SHLIB} ${LIBDIR}ODoors62${STATICLIB}
#
#------------------------------------------------------------------------------
#
# Name of all headers.
#
HEADERS= ${HEADERDIR}ODCom.h\
${HEADERDIR}ODCore.h\
${HEADERDIR}ODGen.h\
${HEADERDIR}ODInEx.h\
${HEADERDIR}ODInQue.h\
${HEADERDIR}ODKrnl.h\
${HEADERDIR}ODPlat.h\
${HEADERDIR}ODRes.h\
${HEADERDIR}ODScrn.h\
${HEADERDIR}ODStat.h\
${HEADERDIR}ODSwap.h\
${HEADERDIR}ODTypes.h\
${HEADERDIR}ODUtil.h\
${HEADERDIR}OpenDoor.h
#
#------------------------------------------------------------------------------
#
# Build DLL from objects.
#
OBJECTS := ${OBJDIR}ODAuto${OBJFILE}\
${OBJDIR}ODBlock${OBJFILE}\
${OBJDIR}ODCFile${OBJFILE}\
${OBJDIR}ODCmdLn${OBJFILE}\
${OBJDIR}ODCom${OBJFILE}\
${OBJDIR}ODCore${OBJFILE}\
${OBJDIR}ODDrBox${OBJFILE}\
${OBJDIR}ODEdit${OBJFILE}\
${OBJDIR}ODEdStr${OBJFILE}\
${OBJDIR}ODEmu${OBJFILE}\
${OBJDIR}ODGetIn${OBJFILE}\
${OBJDIR}ODGraph${OBJFILE}\
${OBJDIR}ODInEx1${OBJFILE}\
${OBJDIR}ODInEx2${OBJFILE}\
${OBJDIR}ODInQue${OBJFILE}\
${OBJDIR}ODKrnl${OBJFILE}\
${OBJDIR}ODList${OBJFILE}\
${OBJDIR}ODLog${OBJFILE}\
${OBJDIR}ODMulti${OBJFILE}\
${OBJDIR}ODPlat${OBJFILE}\
${OBJDIR}ODPCB${OBJFILE}\
${OBJDIR}ODPopup${OBJFILE}\
${OBJDIR}ODPrntf${OBJFILE}\
${OBJDIR}ODRA${OBJFILE}\
${OBJDIR}ODScrn${OBJFILE}\
${OBJDIR}ODSpawn${OBJFILE}\
${OBJDIR}ODStand${OBJFILE}\
${OBJDIR}ODStat${OBJFILE}\
${OBJDIR}ODUtil${OBJFILE}\
${OBJDIR}ODWCat${OBJFILE}\
${OBJDIR}ODWin${OBJFILE}
# ${OBJDIR}ODoor.res
# ${OBJDIR}odsys${OBJFILE}\ this file is missing
${LIBDIR}ODoors62${SHLIB} : ${OBJECTS}
gcc -shared -o ${LIBDIR}libODoors${SHLIB}.6.2 ${OBJECTS}
${LIBDIR}ODoors62${STATICLIB} : ${OBJECTS}
ar -r ${LIBDIR}libODoors${STATICLIB} ${OBJECTS}
ranlib ${LIBDIR}libODoors${STATICLIB}
#
#------------------------------------------------------------------------------
......@@ -62,6 +62,10 @@
#include <time.h>
#include "OpenDoor.h"
#ifdef ODPLAT_NIX
#include <signal.h>
#include <sys/ioctl.h>
#endif
#include "ODCore.h"
#include "ODGen.h"
#include "ODPlat.h"
......@@ -100,6 +104,10 @@
#define INCLUDE_SOCKET_COM /* TCP/IP socket I/O. */
#endif /* ODPLAT_WIN32 */
/* Serial I/O mechanisms supported inder *nix version */
#ifdef ODPLAT_NIX
#define INCLUDE_STDIO_COM
#endif /* ODPLAT_NIX */
/* Include "windows.h" for Win32-API based serial I/O. */
#ifdef INCLUDE_WIN32_COM
......@@ -1748,6 +1756,22 @@ no_fossil:
}
#endif /* INCLUDE_WIN32_COM */
#ifdef INCLUDE_STDIO_COM
if(pPortInfo->Method == kComMethodStdIO ||
pPortInfo->Method == kComMethodUnspecified)
{
/* Set port state as open. */
pPortInfo->bIsOpen = TRUE;
/* Set serial I/O method. */
pPortInfo->Method = kComMethodStdIO;
/* Return with success. */
return(kODRCSuccess);
}
#endif /* INCLUDE_STDIO_COM */
/* If we get to this point, then no form of serial I/O could be */
/* initialized. */
return(kODRCGeneralFailure);
......@@ -1916,6 +1940,11 @@ tODResult ODComClose(tPortHandle hPort)
break;
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
break;
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -1944,6 +1973,9 @@ tODResult ODComClose(tPortHandle hPort)
*/
tODResult ODComCarrier(tPortHandle hPort, BOOL *pbIsCarrier)
{
#ifdef ODPLAT_NIX
sigset_t sigs;
#endif
tPortInfo *pPortInfo = ODHANDLE2PTR(hPort, tPortInfo);
int nPort;
......@@ -2035,6 +2067,15 @@ tODResult ODComCarrier(tPortHandle hPort, BOOL *pbIsCarrier)
break;
}
#endif
case kComMethodStdIO:
{
sigpending(&sigs);
if(sigismember(&sigs,SIGHUP))
*pbIsCarrier = FALSE;
else
*pbIsCarrier = TRUE;
break;
}
default:
/* If we get here, then the current serial I/O method is not */
......@@ -2136,6 +2177,11 @@ set_dtr:
break;
#endif /* INCLUDE_SOCKET_CO */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
return(kODRCUnsupported);
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -2231,6 +2277,12 @@ still_sending:
return(kODRCUnsupported);
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
*pnOutboundWaiting = 0;
return(kODRCUnsupported);
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -2295,6 +2347,11 @@ tODResult ODComClearOutbound(tPortHandle hPort)
return(kODRCUnsupported);
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
return(kODRCUnsupported);
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -2360,6 +2417,10 @@ tODResult ODComClearInbound(tPortHandle hPort)
return(kODRCUnsupported);
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
return(kODRCUnsupported);
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -2472,6 +2533,12 @@ tODResult ODComInbound(tPortHandle hPort, int *pnInboundWaiting)
break;
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
if(ioctl(0,FIONREAD,pnInboundWaiting) == -1)
*pnInboundWaiting = 0;
break;
#endif
default:
/* If we get here, then the current serial I/O method is not */
......@@ -2687,6 +2754,37 @@ tODResult ODComGetByte(tPortHandle hPort, char *pbtNext, BOOL bWait)
}
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
{
fd_set socket_set;
struct timeval tv;
int select_ret, recv_ret;
FD_ZERO(&socket_set);
FD_SET(0,&socket_set);
tv.tv_sec=0;
tv.tv_usec=0;
select_ret = select(1, &socket_set, NULL, NULL, bWait ? NULL : &tv);
if (select_ret == -1)
return (kODRCGeneralFailure);
if (select_ret == 0)
return (kODRCNothingWaiting);
recv_ret = read(0, pbtNext, 1);
if(recv_ret != -1)
break;
return (kODRCGeneralFailure);
if (recv_ret == 0)
return (kODRCNothingWaiting);
break;
}
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -2837,6 +2935,13 @@ keep_going:
}
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
{
write(1,&btToSend,1,0);
break;
}
#endif
default:
/* If we get here, then the current serial I/O method is not */
......@@ -3036,6 +3141,14 @@ tODResult ODComGetBuffer(tPortHandle hPort, BYTE *pbtBuffer, int nSize,
}
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
{
for(*pnBytesRead=0;
*pnBytesRead<nSize && (ODComGetByte(hPort, (pbtBuffer+*pnBytesRead), FALSE)==kODRCSuccess);
*pnBytesRead++);
}
#endif
default:
/* If we get here, then the current serial I/O method is not */
......@@ -3286,6 +3399,15 @@ try_again:
}
#endif /* INCLUDE_SOCKET_COM */
#ifdef INCLUDE_STDIO_COM
case kComMethodStdIO:
{
if(write(1,pbtBuffer,nSize)!=nSize)
return (kODRCGeneralFailure);
break;
}
#endif
default:
/* If we get here, then the current serial I/O method is not */
/* handled by this function. */
......@@ -3319,9 +3441,10 @@ tODResult ODComWaitEvent(tPortHandle hPort, tComEvent Event)
switch(pPortInfo->Method)
{
#if defined(INCLUDE_UART_COM) || defined(INCLUDE_FOSSIL_COM)
#if defined(INCLUDE_UART_COM) || defined(INCLUDE_FOSSIL_COM) || defined(INCLUDE_STDIO_COM)
case kComMethodFOSSIL:
case kComMethodUART:
case kComMethodStdIO:
switch(Event)
{
case kNoCarrier:
......
......@@ -92,6 +92,7 @@ typedef enum
kComMethodWin32,
kComMethodDoor32,
kComMethodSocket,
kComMethodStdIO,
} tComMethod;
/* Serial I/O event types. */
......
......@@ -71,6 +71,9 @@
#include <limits.h>
#include "OpenDoor.h"
#ifdef ODPLAT_NIX
#include <signal.h>
#endif
#include "ODCore.h"
#include "ODGen.h"
#include "ODPlat.h"
......@@ -164,7 +167,17 @@ tODSemaphoreHandle hODActiveSemaphore = NULL;
*/
tODResult ODKrnlInitialize(void)
{
#ifdef ODPLAT_NIX
sigset_t block;
#endif
tODResult Result = kODRCSuccess;
#ifdef ODPLAT_NIX
sigemptyset(&block);
sigaddset(&block,SIGHUP);
sigprocmask(SIG_BLOCK,&block,NULL);
#endif
/* Initialize time of next status update and next time deduction. */
nNextStatusUpdateTime = time(NULL) + STATUS_UPDATE_PERIOD;
......@@ -330,8 +343,9 @@ ODAPIDEF void ODCALL od_kernel(void)
ODKrnlHandleReceivedChar(ch, TRUE);
}
}
#endif
#ifdef ODPLAT_DOS
check_keyboard_again:
if(nKrnlFuncPending && !bShellChatActive)
{
......
......@@ -93,7 +93,7 @@
/* Private variables used by the screen I/O functions. */
/* Segment address of video buffer. */
#ifdef ODPLAT_DOS
#if defined(ODPLAT_DOS) || defined(ODPLAT_NIX)
static WORD wBufferSegment;
static void *pAllocatedBufferMemory;
#endif /* ODPLAT_DOS */
......@@ -942,13 +942,16 @@ tODResult ODScrnInitialize(void)
{
BOOL bClear = TRUE;
#ifdef ODPLAT_DOS
#if defined(ODPLAT_DOS) || defined(ODPLAT_NIX)
BYTE btDisplayMode;
/* In silent mode, we perform all output in a block of memory that is */
/* never displayed. */
/* *nix is always in "silent mode" */
#ifndef ODPLAT_NIX
if(od_control.od_silent_mode)
{
#endif
/* Allocate memory for screen buffer, using standard pointer type */
/* for current memory model. */
pAllocatedBufferMemory = malloc(SCREEN_BUFFER_SIZE);
......@@ -961,6 +964,7 @@ tODResult ODScrnInitialize(void)
/* Set the screen buffer far pointer to point to the allocated */
/* buffer. */
pScrnBuffer = pAllocatedBufferMemory;
#ifndef ODPLAT_NIX
}
else
{
......@@ -1054,6 +1058,7 @@ tODResult ODScrnInitialize(void)
}
}
#endif /* ODPLAT_DOS */
#endif /* ODPLAT_DOS/NIX */
#ifdef ODPLAT_WIN32
/* Allocate memory for screen buffer. */
......@@ -1108,13 +1113,18 @@ void ODScrnShutdown(void)
}
#else /* !ODPLAT_WIN32 */
/* In silent mode, we must deallocate screen buffer memory. */
/* *nix is always in silent mode */
#ifndef ODPLAT_NIX
if(od_control.od_silent_mode && pAllocatedBufferMemory != NULL)
{
#endif
free(pAllocatedBufferMemory);
pAllocatedBufferMemory = NULL;
pScrnBuffer = NULL;
#ifndef ODPLAT_NIX
}
#endif
#endif
}
......
......@@ -93,11 +93,17 @@
#define OD_DLL
#endif /* !OD_WIN32_STATIC */
#else /* !WIN32 */
#if defined(__unix__) || defined(__NetBSD__)
#define ODPLAT_NIX
#undef ODPLAT_DOS
#else
#define ODPLAT_DOS
#undef ODPLAT_WIN32
#pragma message("Compiling for DOS version of OpenDoors")
#endif /* !NIX */
#endif /* !WIN32 */
/* Include any other headers required by OpenDoor.h. */
#ifdef ODPLAT_WIN32
#include "windows.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment