Commit 0f307ae7 authored by rswindell's avatar rswindell

Update external mode flags (EX_*), changing EX_INR to EX_STDIN, EX_OUTR to

EX_STDOUT, defining EX_STDIO (to be both STDIN and STDOUT), adding XTRN_CONIO
and EX_CONIO (for future cioxtrn/doorway mode on Windows), change IO_INTS to
XTRN_STDIO
parent 606c8529
......@@ -717,8 +717,7 @@ bool sbbs_t::sysop_page(void)
if(i<cfg.total_pages) {
bprintf(text[PagingGuru],cfg.sys_op);
external(cmdstr(cfg.page[i]->cmd,nulstr,nulstr,NULL)
,cfg.page[i]->misc&IO_INTS ? EX_OUTL|EX_OUTR|EX_INR
: EX_OUTL);
,cfg.page[i]->misc&XTRN_STDIO ? EX_STDIO : 0);
}
else if(cfg.sys_misc&SM_SHRTPAGE) {
bprintf(text[PagingGuru],cfg.sys_op);
......
......@@ -1245,7 +1245,7 @@ int sbbs_t::exec(csi_t *csi)
external(cmdstr((char*)csi->ip,path,csi->str,(char*)buf),0);
break;
case CS_EXEC_INT:
external(cmdstr((char*)csi->ip,path,csi->str,(char*)buf),EX_OUTR|EX_INR|EX_OUTL);
external(cmdstr((char*)csi->ip,path,csi->str,(char*)buf),EX_STDIO);
break;
case CS_EXEC_XTRN:
for(i=0;i<cfg.total_xtrns;i++)
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -428,7 +428,7 @@ bool sbbs_t::logon()
}
if(cfg.sys_logon[0]) /* execute system logon event */
external(cmdstr(cfg.sys_logon,nulstr,nulstr,NULL),EX_OUTR|EX_OUTL); /* EX_SH */
external(cmdstr(cfg.sys_logon,nulstr,nulstr,NULL),EX_STDOUT); /* EX_SH */
if(qwklogon)
return(true);
......
......@@ -70,7 +70,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
const char* p;
const char* fmode;
ex=EX_OUTL|EX_OUTR; /* Need sh for wildcard expansion */
ex=EX_STDOUT;
if(prepack)
ex|=EX_OFFLINE;
......
......@@ -373,8 +373,8 @@ typedef enum { /* Values for xtrn_t.event */
/* Bits in xtrn_t.misc */
#define MULTIUSER (1<<0) /* allow multi simultaneous users */
#define XTRN_ANSI (1<<1) /* user must have ANSI, same as ^^^ */
#define IO_INTS (1<<2) /* Intercept I/O interrupts */
#define XTRN_ANSI (1<<1) /* LEGACY (not used) */
#define XTRN_STDIO (1<<2) /* Intercept Standard I/O (aka IO_INTS) */
#define MODUSERDAT (1<<3) /* Program can modify user data */
#define WWIVCOLOR (1<<4) /* Program uses WWIV color codes */
#define EVENTONLY (1<<5) /* Program executes as event only */
......@@ -394,6 +394,8 @@ typedef enum { /* Values for xtrn_t.event */
#define XTRN_PAUSE (1<<19) /* Force a screen pause on exit */
#define XTRN_NOECHO (1<<20) /* Don't echo stdin to stdout */
#define QUOTEWRAP (1<<21) /* Word-wrap the quoted text */
#define XTRN_CONIO (1<<31) /* Intercept Windows Console I/O (Drwy) */
/* Bits in cfg.xtrn_misc */
#define XTRN_NO_MUTEX (1<<0) /* Do not use exec_mutex for FOSSIL VXD */
......@@ -738,9 +740,9 @@ enum { /* readmail and delmailidx which types */
/* Bits in the mode of external() */
#define EX_SH (1<<0) /* Use command shell to load other process */
#define EX_OUTR (1<<1) /* Copy DOS output to remote */
#define EX_OUTL (1<<2) /* Use _lputc() for local DOS output */
#define EX_INR (1<<3) /* Trap int 16h keyboard input requests */
#define EX_STDOUT (1<<1) /* Copy DOS output to remote */
#define EX_OUTL (1<<2) /* Use _lputc() for local output (*legacy*) */
#define EX_STDIN (1<<3) /* Trap int 16h keyboard input requests */
#define EX_WWIV WWIVCOLOR /* Expand WWIV color codes to ANSI sequence */
#define EX_SWAP (1<<5) /* Swap out for this external (*legacy*) */
#define EX_POPEN (1<<7) /* Leave COM port open (*legacy*) */
......@@ -750,6 +752,8 @@ enum { /* readmail and delmailidx which types */
#define EX_NATIVE XTRN_NATIVE /* Native 32-bit application */
#define EX_CHKTIME XTRN_CHKTIME /* Check time left */
#define EX_NOECHO XTRN_NOECHO /* Don't echo stdin to stdout */
#define EX_STDIO (EX_STDIN|EX_STDOUT)
#define EX_CONIO (1<<31) /* Intercept Windows console I/O (doorway) */
#if defined(__unix)
#define EX_WILDCARD EX_SH /* Expand wildcards using 'sh' on Unix */
......
......@@ -135,7 +135,7 @@ void sbbs_t::temp_xfer()
logline(nulstr,tmp2);
SAFEPRINTF2(tmp2,"%s%s",cfg.temp_dir,str);
SAFEPRINTF2(str,"%s%s",cfg.temp_dir,f.name);
external(cmdstr(temp_cmd(),str,tmp2,NULL),EX_WILDCARD|EX_OUTL|EX_OUTR);
external(cmdstr(temp_cmd(),str,tmp2,NULL),EX_WILDCARD|EX_STDOUT);
break;
case 'D': /* download from temp dir */
SAFEPRINTF2(str,"%s%s",cfg.temp_dir,f.name);
......@@ -414,8 +414,7 @@ void sbbs_t::extract(uint dirnum)
break;
if(!checkfname(str))
break;
if((i=external(cmdstr(excmd,path,str,NULL)
,EX_INR|EX_OUTL|EX_OUTR))!=0) {
if((i=external(cmdstr(excmd,path,str,NULL),EX_STDIO))!=0) {
errormsg(WHERE,ERR_EXEC,cmdstr(excmd,path,str,NULL),i);
return;
}
......
......@@ -88,7 +88,7 @@ bool sbbs_t::unpack_rep(char* repfile)
break;
if(k>=cfg.total_fextrs)
k=0;
ex=EX_OUTL|EX_OUTR;
ex=EX_STDOUT;
if(online!=ON_REMOTE)
ex|=EX_OFFLINE;
i=external(cmdstr(cfg.fextr[k]->cmd,rep_fname,ALLFILES,NULL),ex);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -107,8 +107,8 @@ void sbbs_t::viewfiles(uint dirnum, char *fspec)
return;
}
sprintf(tmp,"%s%s",cfg.dir[dirnum]->path,fspec);
if((i=external(cmdstr(viewcmd,tmp,tmp,NULL),EX_OUTL|EX_OUTR|EX_INR|EX_SH))!=0)
errormsg(WHERE,ERR_EXEC,viewcmd,i); /* must of EX_SH to ^C */
if((i=external(cmdstr(viewcmd,tmp,tmp,NULL),EX_STDIO|EX_SH))!=0)
errormsg(WHERE,ERR_EXEC,viewcmd,i); /* must have EX_SH to ^C */
}
/****************************************************************************/
......@@ -139,7 +139,6 @@ void sbbs_t::viewfilecontents(file_t* f)
if(ext==NULL || i==cfg.total_fviews)
bprintf(text[NonviewableFile],ext);
else
if((i=external(cmdstr(cmd,path,path,NULL)
,EX_OUTL|EX_OUTR|EX_INR))!=0)
if((i=external(cmdstr(cmd,path,path,NULL),EX_STDIO))!=0)
errormsg(WHERE,ERR_EXEC,cmdstr(cmd,path,path,NULL),i);
}
......@@ -429,8 +429,8 @@ bool sbbs_t::writemsg(const char *fname, const char *top, char *title, long mode
,timeleft,cfg.xedit[useron.xedit-1]->misc);
}
if(cfg.xedit[useron.xedit-1]->misc&IO_INTS) {
ex_mode|=(EX_OUTR|EX_INR);
if(cfg.xedit[useron.xedit-1]->misc&XTRN_STDIO) {
ex_mode|=EX_STDIO;
if(cfg.xedit[useron.xedit-1]->misc&WWIVCOLOR)
ex_mode|=EX_WWIV;
}
......@@ -990,8 +990,8 @@ bool sbbs_t::editfile(char *fname)
mode|=EX_NATIVE;
if(cfg.xedit[useron.xedit-1]->misc&XTRN_SH)
mode|=EX_SH;
if(cfg.xedit[useron.xedit-1]->misc&IO_INTS) {
mode|=(EX_OUTR|EX_INR);
if(cfg.xedit[useron.xedit-1]->misc&XTRN_STDIO) {
mode|=EX_STDIO;
if(cfg.xedit[useron.xedit-1]->misc&WWIVCOLOR)
mode|=EX_WWIV;
}
......
......@@ -444,7 +444,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
return(GetLastError());
}
if(native && mode&EX_OUTR && !(mode&EX_OFFLINE))
if(native && mode&EX_STDOUT && !(mode&EX_OFFLINE))
use_pipes=true;
if(native) { // Native (32-bit) external
......@@ -535,9 +535,9 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(!(mode&EX_OFFLINE) && nt) { // Windows NT/2000
i=SBBSEXEC_MODE_FOSSIL;
if(mode&EX_INR)
if(mode&EX_STDIN)
i|=SBBSEXEC_MODE_DOS_IN;
if(mode&EX_OUTR)
if(mode&EX_STDOUT)
i|=SBBSEXEC_MODE_DOS_OUT;
sprintf(str," NT %u %u"
,cfg.node_num,i);
......@@ -609,9 +609,9 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
start.event=start_event;
start.mode=SBBSEXEC_MODE_FOSSIL;
if(mode&EX_INR)
if(mode&EX_STDIN)
start.mode|=SBBSEXEC_MODE_DOS_IN;
if(mode&EX_OUTR)
if(mode&EX_STDOUT)
start.mode|=SBBSEXEC_MODE_DOS_OUT;
sprintf(str," 95 %u %u"
......@@ -691,12 +691,12 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
}
if(native && !(mode&EX_OFFLINE)) {
if(!(mode&EX_INR) && input_thread_running) {
if(!(mode&EX_STDIN) && input_thread_running) {
pthread_mutex_lock(&input_thread_mutex);
input_thread_mutex_locked=true;
}
if(!(mode&EX_OUTR)) { /* Native Socket I/O program */
if(!(mode&EX_STDOUT)) { /* Native Socket I/O program */
/* Enable the Nagle algorithm */
BOOL nodelay=FALSE;
setsockopt(client_socket,IPPROTO_TCP,TCP_NODELAY,(char*)&nodelay,sizeof(nodelay));
......@@ -1579,7 +1579,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
* it's a timed event.
*/
if (!(mode&(EX_INR|EX_OUTR)) && online!=ON_LOCAL)
if (!(mode&(EX_STDIO)) && online!=ON_LOCAL)
SAFECOPY(virtualconf,"-I\"serial { virtual com 1 }\"");
else
virtualconf[0] = '\0';
......@@ -1588,7 +1588,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
* to intercept dos programs under Unix.
*/
mode |= (EX_INR|EX_OUTR);
mode |= EX_STDIO;
/* See if we have the dosemu link in the door's dir. If so, use the dosemu
* that it points to as our command to execute. If not, use DOSemuPath.
......@@ -1646,7 +1646,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
#endif
}
if(!(mode&EX_INR) && input_thread_running) {
if(!(mode&EX_STDIN) && input_thread_running) {
lprintf(LOG_DEBUG,"Locking input thread mutex");
if(pthread_mutex_lock(&input_thread_mutex)!=0)
errormsg(WHERE,ERR_LOCK,"input_thread_mutex",0);
......@@ -1660,7 +1660,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
}
#endif
if((mode&EX_INR) && (mode&EX_OUTR)) {
if((mode&EX_STDIO)==EX_STDIO) {
struct winsize winsize;
struct termios term;
memset(&term,0,sizeof(term));
......@@ -1689,12 +1689,12 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
out_pipe[0]=in_pipe[1];
}
else {
if(mode&EX_INR)
if(mode&EX_STDIN)
if(pipe(in_pipe)!=0) {
errormsg(WHERE,ERR_CREATE,"in_pipe",0);
return(-1);
}
if(mode&EX_OUTR)
if(mode&EX_STDOUT)
if(pipe(out_pipe)!=0) {
errormsg(WHERE,ERR_CREATE,"out_pipe",0);
return(-1);
......@@ -1754,13 +1754,13 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
argv[argc]=NULL;
}
if(mode&EX_INR && !(mode&EX_OUTR)) {
if(mode&EX_STDIN && !(mode&EX_STDOUT)) {
close(in_pipe[1]); /* close write-end of pipe */
dup2(in_pipe[0],0); /* redirect stdin */
close(in_pipe[0]); /* close excess file descriptor */
}
if(mode&EX_OUTR && !(mode&EX_INR)) {
if(mode&EX_STDOUT && !(mode&EX_STDIN)) {
close(out_pipe[0]); /* close read-end of pipe */
dup2(out_pipe[1],1); /* stdout */
#ifndef XTERN_LOG_STDERR
......@@ -1797,8 +1797,8 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
close(err_pipe[1]); /* close write-end of pipe */
#endif
if(mode&EX_OUTR) {
if(!(mode&EX_INR))
if(mode&EX_STDOUT) {
if(!(mode&EX_STDIN))
close(out_pipe[1]); /* close write-end of pipe */
while(!terminated) {
if(waitpid(pid, &i, WNOHANG)!=0) /* child exited */
......@@ -1814,7 +1814,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
}
/* Input */
if(mode&EX_INR && RingBufFull(&inbuf)) {
if(mode&EX_STDIN && RingBufFull(&inbuf)) {
if((wr=RingBufRead(&inbuf,buf,sizeof(buf)))!=0)
write(in_pipe[1],buf,wr);
}
......@@ -1933,7 +1933,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
kill(pid, SIGKILL); // terminate child process
}
/* close unneeded descriptors */
if(mode&EX_INR)
if(mode&EX_STDIN)
close(in_pipe[1]);
close(out_pipe[0]);
}
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -380,7 +380,7 @@ void sbbs_t::xtrndat(char *name, char *dropdir, uchar type, ulong tleft
sprintf(str,"%u\n%u\n%x\n%lu\n%s\n%s\n"
"%s\n%s\n%s\n%s\n%s\n%s\n%lu\n"
,misc&IO_INTS ? 0:cfg.com_port /* Com port or 0 if !FOSSIL */
,misc&(XTRN_STDIO|XTRN_CONIO) ? 0:cfg.com_port /* Com port or 0 if !FOSSIL */
,cfg.com_irq /* Com IRQ */
,cfg.com_base /* Com base in hex */
,dte_rate /* Com rate */
......@@ -441,7 +441,7 @@ void sbbs_t::xtrndat(char *name, char *dropdir, uchar type, ulong tleft
,temp_dir
,cfg.sys_id
,cfg.node_misc
,misc&IO_INTS ? INVALID_SOCKET : client_socket_dup
,misc&(XTRN_STDIO|XTRN_CONIO) ? INVALID_SOCKET : client_socket_dup
);
lfexpand(str,misc);
write(file,str,strlen(str));
......@@ -524,7 +524,7 @@ void sbbs_t::xtrndat(char *name, char *dropdir, uchar type, ulong tleft
#if 0
if(misc&XTRN_NATIVE) {
if(misc&IO_INTS) {
if(misc&(XTRN_STDIO|XTRN_CONIO)) {
strcpy(str,"COM0:STDIO\n");
}
else {
......@@ -1315,8 +1315,8 @@ void sbbs_t::xtrndat(char *name, char *dropdir, uchar type, ulong tleft
sprintf(str,"%d\n%d\n%u\n%s%c\n%d\n%s\n%s\n%d\n%ld\n"
"%d\n%d\n"
,misc&IO_INTS ? 0 /* Local */ : 2 /* Telnet */
,misc&IO_INTS ? INVALID_SOCKET : client_socket_dup
,misc&(XTRN_STDIO|XTRN_CONIO) ? 0 /* Local */ : 2 /* Telnet */
,misc&(XTRN_STDIO|XTRN_CONIO) ? INVALID_SOCKET : client_socket_dup
,dte_rate
,VERSION_NOTICE,REVISION
,useron.number
......@@ -1714,8 +1714,10 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
mode=0;
if(cfg.xtrn[xtrnnum]->misc&XTRN_SH)
mode|=EX_SH;
if(cfg.xtrn[xtrnnum]->misc&IO_INTS)
mode|=(EX_OUTR|EX_INR|EX_OUTL);
if(cfg.xtrn[xtrnnum]->misc&XTRN_STDIO)
mode|=EX_STDIO;
else if(cfg.xtrn[xtrnnum]->misc&XTRN_CONIO)
mode|=EX_CONIO;
mode|=(cfg.xtrn[xtrnnum]->misc&(XTRN_CHKTIME|XTRN_NATIVE|XTRN_NOECHO|WWIVCOLOR));
if(cfg.xtrn[xtrnnum]->misc&MODUSERDAT) { /* Delete MODUSER.DAT */
sprintf(str,"%sMODUSER.DAT",dropdir); /* if for some weird */
......@@ -1733,7 +1735,7 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
starttime+=end-start;
if(cfg.xtrn[xtrnnum]->clean[0]) {
external(cmdstr(cfg.xtrn[xtrnnum]->clean,path,nulstr,NULL)
,mode&~EX_INR, cfg.xtrn[xtrnnum]->path);
,mode&~(EX_STDIN|EX_CONIO), cfg.xtrn[xtrnnum]->path);
}
/* Re-open the logfile */
if(logfile_fp==NULL) {
......
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