X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/d4c3b068004c89b284bface19768274e13d82795..483a2fe00ba4de6d1f0b6312c17809ac108e474c:/usr/src/usr.bin/tn3270/sys_curses/termout.c diff --git a/usr/src/usr.bin/tn3270/sys_curses/termout.c b/usr/src/usr.bin/tn3270/sys_curses/termout.c index 33aa1f2aaa..d7bfa91c69 100644 --- a/usr/src/usr.bin/tn3270/sys_curses/termout.c +++ b/usr/src/usr.bin/tn3270/sys_curses/termout.c @@ -31,19 +31,24 @@ static char sccsid[] = "@(#)outbound.c 3.1 10/29/86"; #include #include +#include "../general/general.h" + #include "terminal.h" #include "../telnet.ext" +#include "../apilib/disp_asc.h" + #include "../ctlr/hostctlr.h" #include "../ctlr/inbound.ext" +#include "../ctlr/oia.h" #include "../ctlr/options.ext" #include "../ctlr/outbound.ext" #include "../ctlr/screen.h" -#include "../keyboard/map3270.ext" +#include "../ascii/map3270.ext" -#include "../system/globals.h" +#include "../general/globals.h" extern void EmptyTerminal(); @@ -51,41 +56,50 @@ extern void EmptyTerminal(); terminalCursorAddress:UnLocked? CursorAddress: HighestScreen()) -#if defined(unix) -extern int tin, tout; /* file descriptors */ -#endif /* defined(unix) */ - -static int terminalCursorAddress = 0; /* where the cursor is on term */ -static int screenInitd = 0; /* the screen has been initialized */ -static int screenStopped = 1; /* the screen has been stopped */ -#if defined(SLOWSCREEN) +static int terminalCursorAddress; /* where the cursor is on term */ +static int screenInitd; /* the screen has been initialized */ +static int screenStopped; /* the screen has been stopped */ static int max_changes_before_poll; /* how many characters before looking */ /* at terminal and net again */ -#endif /* defined(SLOWSCREEN) */ -static int needToRing = 0; /* need to ring terinal bell */ +static int needToRing; /* need to ring terinal bell */ static char *bellSequence = "\07"; /* bell sequence (may be replaced by * VB during initialization) */ -static WINDOW *bellwin; /* The window the bell message is in */ +static WINDOW *bellwin = 0; /* The window the bell message is in */ int bellwinup = 0; /* Are we up with it or not */ #if defined(unix) static char *KS, *KE; #endif /* defined(unix) */ + +static int inHighlightMode = 0; +ScreenImage Terminal[MAXSCREENSIZE]; + +/* Variables for transparent mode */ #if defined(unix) static int tcflag = -1; /* transparent mode command flag */ static int savefd[2]; /* for storing fds during transcom */ +extern int tin, tout; /* file descriptors */ #endif /* defined(unix) */ + -#if defined(SLOWSCREEN) -static int inHighlightMode = 0; -#endif /* defined(SLOWSCREEN) */ +/* + * init_screen() + * + * Initialize variables used by screen. + */ + +void +init_screen() +{ + bellwinup = 0; + inHighlightMode = 0; + ClearArray(Terminal); +} -#include "disp_asc.out" - /* OurExitString - designed to keep us from going through infinite recursion */ static void @@ -126,7 +140,6 @@ int where; /* cursor address */ /* NOTREACHED */ } -#if defined(SLOWSCREEN) /* What is the screen address of the attribute byte for the terminal */ static int @@ -146,7 +159,6 @@ register int p; return(LowestScreen()); /* unformatted screen... */ } -#endif /* defined(SLOWSCREEN) */ /* * There are two algorithms for updating the screen. @@ -166,7 +178,6 @@ register int p; */ -#if defined(SLOWSCREEN) #if defined(NOT43) static int #else /* defined(NOT43) */ @@ -314,8 +325,8 @@ SlowScreen() columnsleft = NumberColumns; } SetHighlightMode(pointer); /* Turn on highlighting */ - while (!IsStartField(pointer) && - !TermIsStartField(pointer)) { + while ((!IsStartField(pointer)) && + (!TermIsStartField(pointer))) { c = GetHost(pointer); DoCharacterAt(c,pointer); /* MACRO */ pointer = ScreenInc(pointer); @@ -362,6 +373,10 @@ SlowScreen() * the end of the screen. */ if (j > pointer) { + /* + * pointer is guaranteed to be higher than Highest... + */ + pointer = Highest+1; /* We did the highest thing */ break; } } else { @@ -379,7 +394,8 @@ SlowScreen() } } else { SetHighlightMode(pointer); - /* The following will terminate at least when we get back + /* + * The following will terminate at least when we get back * to the original 'pointer' location (since we force * things to be equal). */ @@ -419,7 +435,6 @@ SlowScreen() EmptyTerminal(); /* move data along */ return; } -#endif /* defined(SLOWSCREEN) */ #if defined(NOT43) static int @@ -428,11 +443,11 @@ static void #endif /* defined(NOT43) */ FastScreen() { -#if defined(msdos) +#if defined(MSDOS) #define SaveCorner 0 -#else /* defined(msdos) */ +#else /* defined(MSDOS) */ #define SaveCorner 1 -#endif /* defined(msdos) */ +#endif /* defined(MSDOS) */ #define DoAttribute(a) if (IsHighlightedAttr(a)) { \ standout(); \ @@ -459,24 +474,25 @@ FastScreen() move(ScreenLine(Lowest), ScreenLineOffset(Lowest)); p = &Host[Lowest]; -#if !defined(msdos) +#if !defined(MSDOS) if (Highest == HighestScreen()) { Highest = ScreenDec(Highest); } -#endif /* !defined(msdos) */ +#endif /* !defined(MSDOS) */ upper = &Host[Highest]; fieldattr = FieldAttributes(Lowest); DoAttribute(fieldattr); /* Set standout, non-display status */ columnsleft = NumberColumns-ScreenLineOffset(p-Host); while (p <= upper) { - if (p->field & ATTR_MASK) { /* New field? */ + if (IsStartFieldPointer(p)) { /* New field? */ Highest = HighestScreen(); Lowest = LowestScreen(); FastScreen(); /* Recurse */ return; } else if (fieldattr) { /* Should we display? */ - addch(disp_asc[p->data]); /* Display translated data */ + /* Display translated data */ + addch(disp_asc[GetTerminalPointer(p)]); } else { addch(' '); /* Display a blank */ } @@ -505,20 +521,20 @@ FastScreen() DoAttribute(fieldattr); /* Set standout, non-display status */ while (p <= End) { - if (p->field & ATTR_MASK) { /* New field? */ + if (IsStartFieldPointer(p)) { /* New field? */ if (tmp != tmpbuf) { *tmp++ = 0; /* close out */ addstr(tmpbuf); tmp = tmpbuf; tmpend = tmpbuf + NumberColumns - ScreenLineOffset(p-Host); } - fieldattr = p->field; /* Get attributes */ + fieldattr = FieldAttributesPointer(p); /* Get attributes */ DoAttribute(fieldattr); /* Set standout, non-display */ *tmp++ = ' '; } else { if (fieldattr) { /* Should we display? */ /* Display translated data */ - *tmp++ = disp_asc[p->data]; + *tmp++ = disp_asc[GetTerminalPointer(p)]; } else { *tmp++ = ' '; } @@ -571,10 +587,17 @@ void #endif /* defined(NOT43) */ (*TryToSend)() = FastScreen; -/* StartScreen - called to initialize the screen, etc. */ +void +ScreenOIA(oia) +OIA *oia; +{ +} + + +/* InitTerminal - called to initialize the screen, etc. */ void -StartScreen() +InitTerminal() { #if defined(unix) struct sgttyb ourttyb; @@ -582,6 +605,7 @@ StartScreen() 2400, 4800, 9600 }; #endif + InitMapping(); /* Go do mapping file (MAP3270) first */ if (!screenInitd) { /* not initialized */ #if defined(unix) char KSEbuffer[2050]; @@ -590,32 +614,14 @@ StartScreen() extern char *tgetstr(); #endif /* defined(unix) */ - bzero((char *)Host, sizeof Host); - - bzero(Orders, sizeof Orders); - Orders[ORDER_SF] = Orders[ORDER_SBA] = Orders[ORDER_IC] - = Orders[ORDER_PT] = Orders[ORDER_RA] = Orders[ORDER_EUA] - = Orders[ORDER_YALE] = 1; - - DeleteAllFields(); -#if defined(SLOWSCREEN) - bzero((char *)Terminal, sizeof Terminal); -#endif /* defined(SLOWSCREEN) */ - Lowest = HighestScreen()+1; - Highest = LowestScreen()-1; - terminalCursorAddress = - CursorAddress = - BufferAddress = SetBufferAddress(0,0); - UnLocked = 1; - Initialized = 1; - OutputClock = 1; - TransparentClock = -1; + ClearArray(Terminal); + terminalCursorAddress = SetBufferAddress(0,0); #if defined(unix) signal(SIGHUP, abort); #endif TryToSend = FastScreen; -#if defined(unix) && defined(SLOWSCREEN) +#if defined(unix) ioctl(1, TIOCGETP, (char *) &ourttyb); if ((ourttyb.sg_ospeed < 0) || (ourttyb.sg_ospeed > B9600)) { max_changes_before_poll = 1920; @@ -627,7 +633,7 @@ StartScreen() TryToSend = SlowScreen; HaveInput = 1; /* get signals going */ } -#endif /* defined(unix) && defined(SLOWSCREEN) */ +#endif /* defined(unix) */ setcommandmode(); /* * By now, initscr() (in curses) has been called (from telnet.c), @@ -671,9 +677,7 @@ int doNewLine; if (screenInitd && !screenStopped) { move(NumberLines-1, 1); standend(); -#if defined(SLOWSCREEN) inHighlightMode = 0; -#endif /* defined(SLOWSCREEN) */ DoARefresh(); setcommandmode(); endwin(); @@ -726,9 +730,7 @@ LocalClearScreen() { outputPurge(); /* flush all data to terminal */ clear(); /* clear in curses */ -#if defined(SLOWSCREEN) - bzero((char *)Terminal, sizeof Terminal); -#endif /* defined(SLOWSCREEN) */ + ClearArray(Terminal); Clear3270(); Lowest = HighestScreen()+1; /* everything in sync... */ Highest = LowestScreen()+1; @@ -742,11 +744,6 @@ BellOff() delwin(bellwin); bellwin = 0; bellwinup = 0; - Lowest = MIN(Lowest, LINES/2); - Highest = MAX(Highest, (LINES/2)+3); -#if defined(SLOWSCREEN) - bzero(Terminal+LINES/2, (sizeof Terminal[0])*(3*COLS)); -#endif /* defined(SLOWSCREEN) */ touchwin(stdscr); DoARefresh(); } @@ -796,14 +793,120 @@ int DoTerminalOutput() { /* called just before a select to conserve IO to terminal */ - if (Initialized && - ((Lowest <= Highest) || needToRing || - (terminalCursorAddress != CorrectTerminalCursor()))) { + if (!(screenInitd||screenStopped)) { + return 1; /* No output if not initialized */ + } + if ((Lowest <= Highest) || needToRing || + (terminalCursorAddress != CorrectTerminalCursor())) { (*TryToSend)(); } if (Lowest > Highest) { - return(1); /* no more output now */ + return 1; /* no more output now */ } else { - return(0); /* more output for future */ + return 0; /* more output for future */ } } + +/* + * The following are defined to handle transparent data. + */ + +void +TransStop() +{ +#if defined(unix) + if (tcflag == 0) { + tcflag = -1; + (void) signal(SIGCHLD, SIG_DFL); + } else if (tcflag > 0) { + setcommandmode(); + (void) close(tin); + (void) close(tout); + tin = savefd[0]; + tout = savefd[1]; + setconnmode(); + tcflag = -1; + (void) signal(SIGCHLD, SIG_DFL); + } +#endif /* defined(unix) */ + RefreshScreen(); +} + +void +TransOut(buffer, count) +unsigned char *buffer; +int count; +{ +#if defined(unix) + extern char *transcom; + int inpipefd[2], outpipefd[2], savemode; + void aborttc(); +#endif /* defined(unix) */ + + while (DoTerminalOutput() == 0) { +#if defined(unix) + HaveInput = 0; +#endif /* defined(unix) */ + } +#if defined(unix) + if (transcom && tcflag == -1) { + while (1) { /* go thru once */ + if (pipe(outpipefd) < 0) { + break; + } + if (pipe(inpipefd) < 0) { + break; + } + if ((tcflag = fork()) == 0) { + (void) close(outpipefd[1]); + (void) close(0); + if (dup(outpipefd[0]) < 0) { + exit(1); + } + (void) close(outpipefd[0]); + (void) close(inpipefd[0]); + (void) close(1); + if (dup(inpipefd[1]) < 0) { + exit(1); + } + (void) close(inpipefd[1]); + if (execl("/bin/csh", "csh", "-c", transcom, (char *) 0)) { + exit(1); + } + } + (void) close(inpipefd[1]); + (void) close(outpipefd[0]); + savefd[0] = tin; + savefd[1] = tout; + setcommandmode(); + tin = inpipefd[0]; + tout = outpipefd[1]; + (void) signal(SIGCHLD, aborttc); + setconnmode(); + tcflag = 1; + break; + } + if (tcflag < 1) { + tcflag = 0; + } + } +#endif /* defined(unix) */ + (void) DataToTerminal(buffer, count); +} + + +#if defined(unix) +static void +aborttc() +{ + int savemode; + + setcommandmode(); + (void) close(tin); + (void) close(tout); + tin = savefd[0]; + tout = savefd[1]; + setconnmode(); + tcflag = 0; +} +#endif /* defined(unix) */