diff --git a/src/sbbs3/GNUmakefile b/src/sbbs3/GNUmakefile index fefc2e2a643b1b785a3cf53941e5bc61554d8325..7b0a1322278ad1f5c7b306d9454250a119c8e802 100644 --- a/src/sbbs3/GNUmakefile +++ b/src/sbbs3/GNUmakefile @@ -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) diff --git a/src/sbbs3/answer.cpp b/src/sbbs3/answer.cpp index 51b179d3db5a7479bebb9236603d362599ddd392..5e0c29ce1d955596060a048df7a076bcd29acf79 100644 --- a/src/sbbs3/answer.cpp +++ b/src/sbbs3/answer.cpp @@ -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) { diff --git a/src/sbbs3/inkey.cpp b/src/sbbs3/inkey.cpp index 9161090429a925a9b1ac28f1c36f82a9c80e41a7..f5604bdaad5ab858fdc5baf28fc1f964d6cf9e3f 100644 --- a/src/sbbs3/inkey.cpp +++ b/src/sbbs3/inkey.cpp @@ -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) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index a8e9a63977a8cec53b3d02325e128f3987a881e3..0005e99b0b1ea3c5293af33e1c9d26be44a2c2f2 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -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; diff --git a/src/sbbs3/ringbuf.c b/src/sbbs3/ringbuf.c index 708fe2447690e7e700bf7970093f2151e8886cdb..f49590729163fe0b80cca99dd0f5aace933ce352 100644 --- a/src/sbbs3/ringbuf.c +++ b/src/sbbs3/ringbuf.c @@ -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); diff --git a/src/sbbs3/sbbscon.c b/src/sbbs3/sbbscon.c index 246efa578ba7cb4162b23cb202aefa5b849398c9..81806b2ffae0393a215bc75a627cc47d2e96d231 100644 --- a/src/sbbs3/sbbscon.c +++ b/src/sbbs3/sbbscon.c @@ -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"); } diff --git a/src/sbbs3/scfg/GNUmakefile b/src/sbbs3/scfg/GNUmakefile index b2b5e061c16f2dac1e88b209becce39a25908b63..7eeffd07e48e62130ffe66b2dd5351acdf8006e0 100644 --- a/src/sbbs3/scfg/GNUmakefile +++ b/src/sbbs3/scfg/GNUmakefile @@ -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 diff --git a/src/sbbs3/xtrn.cpp b/src/sbbs3/xtrn.cpp index 82366b93ee8de7968b42aee65c640918342a3d5b..38644bd617b603b6397cbaa765d65cc2001b8078 100644 --- a/src/sbbs3/xtrn.cpp +++ b/src/sbbs3/xtrn.cpp @@ -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 {