Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,15 @@ ifeq ($(os),sunos) # Solaris ...@@ -96,6 +96,15 @@ ifeq ($(os),sunos) # Solaris
LFLAGS := -lm -lpthread -lsocket -lnsl -lrt LFLAGS := -lm -lpthread -lsocket -lnsl -lrt
endif 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 DEBUG
ifdef bcc ifdef bcc
CFLAGS += -y -v -Od CFLAGS += -y -v -Od
...@@ -122,7 +131,11 @@ ifdef USE_FLTK ...@@ -122,7 +131,11 @@ ifdef USE_FLTK
endif endif
ifdef USE_CURSES ifdef USE_CURSES
CFLAGS += -DUSE_CURSES CFLAGS += -DUSE_CURSES
UIFC_LFLAGS += -lcurses ifeq ($(os),qnx)
UIFC_LFLAGS += -lncurses
else
UIFC_LFLAGS += -lcurses
endif
UIFC_OBJS += $(EXEODIR)/uifcc.o UIFC_OBJS += $(EXEODIR)/uifcc.o
endif endif
...@@ -135,6 +148,10 @@ ifeq ($(os),gnu) ...@@ -135,6 +148,10 @@ ifeq ($(os),gnu)
OBJS += $(LIBODIR)$(SLASH)sem.$(OFILE) OBJS += $(LIBODIR)$(SLASH)sem.$(OFILE)
endif endif
ifeq ($(os),netbsd)
OBJS += $(LIBODIR)$(SLASH)sem.$(OFILE)
endif
SBBSLIB = $(LIBODIR)/sbbs.a SBBSLIB = $(LIBODIR)/sbbs.a
vpath %.c $(XPDEV) $(UIFC) vpath %.c $(XPDEV) $(UIFC)
......
...@@ -132,6 +132,10 @@ bool sbbs_t::answer() ...@@ -132,6 +132,10 @@ bool sbbs_t::answer()
strcat(str,COPYRIGHT_NOTICE); strcat(str,COPYRIGHT_NOTICE);
strip_ctrl(str); strip_ctrl(str);
center(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 */ while(i++<50 && l<(int)sizeof(str)-1) { /* wait up to 5 seconds for response */
c=(incom()&0x7f); c=(incom()&0x7f);
if(!c) { if(!c) {
......
...@@ -49,6 +49,10 @@ char sbbs_t::inkey(long mode) ...@@ -49,6 +49,10 @@ char sbbs_t::inkey(long mode)
{ {
uchar ch=0; uchar ch=0;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(keybuftop!=keybufbot) { if(keybuftop!=keybufbot) {
ch=keybuf[keybufbot++]; ch=keybuf[keybufbot++];
if(keybufbot==KEY_BUFSIZE) if(keybufbot==KEY_BUFSIZE)
......
...@@ -946,6 +946,9 @@ void input_thread(void *arg) ...@@ -946,6 +946,9 @@ void input_thread(void *arg)
while(sbbs->online && sbbs->client_socket!=INVALID_SOCKET while(sbbs->online && sbbs->client_socket!=INVALID_SOCKET
&& node_socket[sbbs->cfg.node_num-1]!=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); pthread_mutex_lock(&sbbs->input_thread_mutex);
FD_ZERO(&socket_set); FD_ZERO(&socket_set);
...@@ -1101,6 +1104,10 @@ void output_thread(void* arg) ...@@ -1101,6 +1104,10 @@ void output_thread(void* arg)
sbbs->console|=CON_R_ECHO; sbbs->console|=CON_R_ECHO;
while(sbbs->client_socket!=INVALID_SOCKET && telnet_socket!=INVALID_SOCKET) { while(sbbs->client_socket!=INVALID_SOCKET && telnet_socket!=INVALID_SOCKET) {
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(bufbot==buftop) if(bufbot==buftop)
avail=RingBufFull(&sbbs->outbuf); avail=RingBufFull(&sbbs->outbuf);
else else
...@@ -2618,6 +2625,9 @@ int sbbs_t::incom(void) ...@@ -2618,6 +2625,9 @@ int sbbs_t::incom(void)
{ {
uchar ch; uchar ch;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
if(!RingBufRead(&inbuf, &ch, 1)) if(!RingBufRead(&inbuf, &ch, 1))
return(NOINP); return(NOINP);
#if 0 // removed Jan-2003 #if 0 // removed Jan-2003
...@@ -2636,6 +2646,9 @@ int sbbs_t::outcom(uchar ch) ...@@ -2636,6 +2646,9 @@ int sbbs_t::outcom(uchar ch)
return(TXBOF); return(TXBOF);
sem_post(&output_sem); sem_post(&output_sem);
return(0); return(0);
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
} }
void sbbs_t::putcom(char *str, int len) void sbbs_t::putcom(char *str, int len)
...@@ -2984,6 +2997,9 @@ void node_thread(void* arg) ...@@ -2984,6 +2997,9 @@ void node_thread(void* arg)
if(sbbs->exec(&sbbs->main_csi)) if(sbbs->exec(&sbbs->main_csi))
break; break;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
} }
} }
...@@ -3262,7 +3278,7 @@ long DLLCALL bbs_ver_num(void) ...@@ -3262,7 +3278,7 @@ long DLLCALL bbs_ver_num(void)
{ {
char* minor; char* minor;
if((minor=strchr(VERSION,'.'))==NULL) if((minor=(char *)strchr(VERSION,'.'))==NULL)
return(0); return(0);
minor++; minor++;
...@@ -3711,6 +3727,9 @@ void DLLCALL bbs_thread(void* arg) ...@@ -3711,6 +3727,9 @@ void DLLCALL bbs_thread(void* arg)
} }
while(telnet_socket!=INVALID_SOCKET) { 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 */ if(node_threads_running==0 && !event_mutex_locked) { /* check for re-run flags */
bool rerun=false; bool rerun=false;
......
...@@ -186,6 +186,10 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src, DWORD cnt ) ...@@ -186,6 +186,10 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src, DWORD cnt )
pthread_mutex_unlock(&rb->mutex); pthread_mutex_unlock(&rb->mutex);
#endif #endif
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
return(cnt); return(cnt);
} }
...@@ -194,6 +198,10 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* rb, BYTE* dst, DWORD cnt ) ...@@ -194,6 +198,10 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* rb, BYTE* dst, DWORD cnt )
{ {
DWORD max, first, remain, len; DWORD max, first, remain, len;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
len = RingBufFull( rb ); len = RingBufFull( rb );
if( len == 0 ) if( len == 0 )
return(0); return(0);
...@@ -244,6 +252,10 @@ DWORD RINGBUFCALL RingBufPeek( RingBuf* rb, BYTE* dst, DWORD cnt) ...@@ -244,6 +252,10 @@ DWORD RINGBUFCALL RingBufPeek( RingBuf* rb, BYTE* dst, DWORD cnt)
{ {
DWORD max, first, remain, len; DWORD max, first, remain, len;
#if defined(_PTH_H_) /* Cooperative multitasking! */
pth_yield(NULL);
#endif
len = RingBufFull( rb ); len = RingBufFull( rb );
if( len == 0 ) if( len == 0 )
return(0); return(0);
......
...@@ -1427,16 +1427,16 @@ int main(int argc, char** argv) ...@@ -1427,16 +1427,16 @@ int main(int argc, char** argv)
|| (run_web && !(web_running || web_stopped)) || (run_web && !(web_running || web_stopped))
|| (run_mail && !(mail_running || mail_stopped)) || (run_mail && !(mail_running || mail_stopped))
|| (run_services && !(services_running || services_stopped))) { || (run_services && !(services_running || services_stopped))) {
mswait(1); mswait(1000);
if(run_bbs && !bbs_running) if(run_bbs && !(bbs_running || bbs_stopped))
bbs_lputs("Waiting for BBS thread"); bbs_lputs("Waiting for BBS thread");
if(run_web && !web_running) if(run_web && !(web_running || web_stopped))
bbs_lputs("Waiting for Web thread"); bbs_lputs("Waiting for Web thread");
if(run_ftp && !ftp_running) if(run_ftp && !(ftp_running || ftp_stopped))
bbs_lputs("Waiting for FTP thread"); bbs_lputs("Waiting for FTP thread");
if(run_mail && !mail_running) if(run_mail && !(mail_running || mail_stopped))
bbs_lputs("Waiting for Mail thread"); bbs_lputs("Waiting for Mail thread");
if(run_services && !services_running) if(run_services && !(services_running || services_stopped))
bbs_lputs("Waiting for Services thread"); bbs_lputs("Waiting for Services thread");
} }
......
...@@ -49,13 +49,19 @@ CFLAGS += -Wall -I$(UIFC) -I$(XPDEV) -I../ -D_THREAD_SAFE ...@@ -49,13 +49,19 @@ CFLAGS += -Wall -I$(UIFC) -I$(XPDEV) -I../ -D_THREAD_SAFE
LFLAGS := -L/usr/local/lib LFLAGS := -L/usr/local/lib
ifeq ($(os),qnx)
CURSESLIB := -lncurses
else
CURSESLIB := -lcurses
endif
ifdef USE_DIALOG ifdef USE_DIALOG
LFLAGS += -L../../libdialog -ldialog -lcurses LFLAGS += -L../../libdialog -ldialog $(CURSESLIB)
CFLAGS += -I../../libdialog -DUSE_DIALOG CFLAGS += -I../../libdialog -DUSE_DIALOG
endif endif
ifdef USE_CURSES ifdef USE_CURSES
LFLAGS += -lcurses LFLAGS += $(CURSESLIB)
CFLAGS += -DUSE_CURSES CFLAGS += -DUSE_CURSES
endif endif
......
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
#include <util.h> #include <util.h>
#elif defined(__linux__) #elif defined(__linux__)
#include <pty.h> #include <pty.h>
#elif defined(__QNX__)
#include <unix.h>
#endif #endif
#ifdef NEEDS_FORKPTY #ifdef NEEDS_FORKPTY
...@@ -60,7 +62,37 @@ ...@@ -60,7 +62,37 @@
#include <termios.h> #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_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
#define TTYDEF_OFLAG (OPOST | ONLCR) #define TTYDEF_OFLAG (OPOST | ONLCR)
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) #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) ...@@ -1169,7 +1201,8 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
struct winsize winsize; struct winsize winsize;
struct termios term; struct termios term;
memset(&term,0,sizeof(term)); memset(&term,0,sizeof(term));
cfsetspeed(&term,B19200); cfsetispeed(&term,B19200);
cfsetospeed(&term,B19200);
if(mode&EX_BIN) if(mode&EX_BIN)
cfmakeraw(&term); cfmakeraw(&term);
else { else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment