Commit 64a40960 authored by deuce's avatar deuce
Browse files

Initial NetBSD and QNX Support. Stay tuned for performance figures from

old 486 hardware!
parent db5505d8
......@@ -96,6 +96,15 @@ ifeq ($(os),sunos) # Solaris
LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif
ifeq ($(os),netbsd)
CFLAGS += -D_REENTRANT -D_NEED_SEM -D__unix__ -I/usr/pkg/include -DNEEDS_FORKPTY
LFLAGS := -lm -lpthread -L/usr/pkg/lib
endif
ifeq ($(os),qnx)
LFLAGS := -lm -lsocket
endif
ifdef DEBUG
ifdef bcc
CFLAGS += -y -v -Od
......@@ -122,7 +131,11 @@ ifdef USE_FLTK
endif
ifdef USE_CURSES
CFLAGS += -DUSE_CURSES
UIFC_LFLAGS += -lcurses
ifeq ($(os),qnx)
UIFC_LFLAGS += -lncurses
else
UIFC_LFLAGS += -lcurses
endif
UIFC_OBJS += $(EXEODIR)/uifcc.o
endif
......@@ -135,6 +148,10 @@ ifeq ($(os),gnu)
OBJS += $(LIBODIR)$(SLASH)sem.$(OFILE)
endif
ifeq ($(os),netbsd)
OBJS += $(LIBODIR)$(SLASH)sem.$(OFILE)
endif
SBBSLIB = $(LIBODIR)/sbbs.a
vpath %.c $(XPDEV) $(UIFC)
......
......@@ -132,6 +132,10 @@ bool sbbs_t::answer()
strcat(str,COPYRIGHT_NOTICE);
strip_ctrl(str);
center(str);
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
while(i++<50 && l<(int)sizeof(str)-1) { /* wait up to 5 seconds for response */
c=(incom()&0x7f);
if(!c) {
......
......@@ -49,6 +49,10 @@ char sbbs_t::inkey(long mode)
{
uchar ch=0;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(keybuftop!=keybufbot) {
ch=keybuf[keybufbot++];
if(keybufbot==KEY_BUFSIZE)
......
......@@ -946,6 +946,9 @@ void input_thread(void *arg)
while(sbbs->online && sbbs->client_socket!=INVALID_SOCKET
&& node_socket[sbbs->cfg.node_num-1]!=INVALID_SOCKET) {
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
pthread_mutex_lock(&sbbs->input_thread_mutex);
FD_ZERO(&socket_set);
......@@ -1101,6 +1104,10 @@ void output_thread(void* arg)
sbbs->console|=CON_R_ECHO;
while(sbbs->client_socket!=INVALID_SOCKET && telnet_socket!=INVALID_SOCKET) {
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(bufbot==buftop)
avail=RingBufFull(&sbbs->outbuf);
else
......@@ -2618,6 +2625,9 @@ int sbbs_t::incom(void)
{
uchar ch;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(!RingBufRead(&inbuf, &ch, 1))
return(NOINP);
#if 0 // removed Jan-2003
......@@ -2636,6 +2646,9 @@ int sbbs_t::outcom(uchar ch)
return(TXBOF);
sem_post(&output_sem);
return(0);
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
}
void sbbs_t::putcom(char *str, int len)
......@@ -2984,6 +2997,9 @@ void node_thread(void* arg)
if(sbbs->exec(&sbbs->main_csi))
break;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
}
}
......@@ -3262,7 +3278,7 @@ long DLLCALL bbs_ver_num(void)
{
char* minor;
if((minor=strchr(VERSION,'.'))==NULL)
if((minor=(char *)strchr(VERSION,'.'))==NULL)
return(0);
minor++;
......@@ -3711,6 +3727,9 @@ void DLLCALL bbs_thread(void* arg)
}
while(telnet_socket!=INVALID_SOCKET) {
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(node_threads_running==0 && !event_mutex_locked) { /* check for re-run flags */
bool rerun=false;
......
......@@ -186,6 +186,10 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src, DWORD cnt )
pthread_mutex_unlock(&rb->mutex);
#endif
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
return(cnt);
}
......@@ -194,6 +198,10 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* rb, BYTE* dst, DWORD cnt )
{
DWORD max, first, remain, len;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
len = RingBufFull( rb );
if( len == 0 )
return(0);
......@@ -244,6 +252,10 @@ DWORD RINGBUFCALL RingBufPeek( RingBuf* rb, BYTE* dst, DWORD cnt)
{
DWORD max, first, remain, len;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
len = RingBufFull( rb );
if( len == 0 )
return(0);
......
......@@ -1427,16 +1427,16 @@ int main(int argc, char** argv)
|| (run_web && !(web_running || web_stopped))
|| (run_mail && !(mail_running || mail_stopped))
|| (run_services && !(services_running || services_stopped))) {
mswait(1);
if(run_bbs && !bbs_running)
mswait(1000);
if(run_bbs && !(bbs_running || bbs_stopped))
bbs_lputs("Waiting for BBS thread");
if(run_web && !web_running)
if(run_web && !(web_running || web_stopped))
bbs_lputs("Waiting for Web thread");
if(run_ftp && !ftp_running)
if(run_ftp && !(ftp_running || ftp_stopped))
bbs_lputs("Waiting for FTP thread");
if(run_mail && !mail_running)
if(run_mail && !(mail_running || mail_stopped))
bbs_lputs("Waiting for Mail thread");
if(run_services && !services_running)
if(run_services && !(services_running || services_stopped))
bbs_lputs("Waiting for Services thread");
}
......
......@@ -49,13 +49,19 @@ CFLAGS += -Wall -I$(UIFC) -I$(XPDEV) -I../ -D_THREAD_SAFE
LFLAGS := -L/usr/local/lib
ifeq ($(os),qnx)
CURSESLIB := -lncurses
else
CURSESLIB := -lcurses
endif
ifdef USE_DIALOG
LFLAGS += -L../../libdialog -ldialog -lcurses
LFLAGS += -L../../libdialog -ldialog $(CURSESLIB)
CFLAGS += -I../../libdialog -DUSE_DIALOG
endif
ifdef USE_CURSES
LFLAGS += -lcurses
LFLAGS += $(CURSESLIB)
CFLAGS += -DUSE_CURSES
endif
......
......@@ -52,6 +52,8 @@
#include <util.h>
#elif defined(__linux__)
#include <pty.h>
#elif defined(__QNX__)
#include <unix.h>
#endif
#ifdef NEEDS_FORKPTY
......@@ -60,7 +62,37 @@
#include <termios.h>
#if defined(__solaris__)
#if defined(__QNX__)
/*
* Control Character Defaults
*/
#define CTRL(x) (x&037)
#define CEOF CTRL('d')
#define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */
#define CERASE 0177
#define CERASE2 CTRL('h')
#define CINTR CTRL('c')
#define CSTATUS CTRL('t')
#define CKILL CTRL('u')
#define CMIN 1
#define CQUIT 034 /* FS, ^\ */
#define CSUSP CTRL('z')
#define CTIME 0
#define CDSUSP CTRL('y')
#define CSTART CTRL('q')
#define CSTOP CTRL('s')
#define CLNEXT CTRL('v')
#define CDISCARD CTRL('o')
#define CWERASE CTRL('w')
#define CREPRINT CTRL('r')
#define CEOT CEOF
/* compat */
#define CBRK CEOL
#define CRPRNT CREPRINT
#define CFLUSH CDISCARD
#endif
#if defined(__solaris__) || defined(__QNX__)
#define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
#define TTYDEF_OFLAG (OPOST | ONLCR)
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
......@@ -1169,7 +1201,8 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
struct winsize winsize;
struct termios term;
memset(&term,0,sizeof(term));
cfsetspeed(&term,B19200);
cfsetispeed(&term,B19200);
cfsetospeed(&term,B19200);
if(mode&EX_BIN)
cfmakeraw(&term);
else {
......
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