add Berkeley specific header
[unix-history] / usr / src / usr.bin / tn3270 / ctlr / outbound.c
index 338be3c..04cbea4 100644 (file)
@@ -1,36 +1,27 @@
 /*
 /*
- *     Copyright (c) 1984, 1985, 1986 by the Regents of the
- *     University of California and by Gregory Glenn Minshall.
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
  *
  *
- *     Permission to use, copy, modify, and distribute these
- *     programs and their documentation for any purpose and
- *     without fee is hereby granted, provided that this
- *     copyright and permission appear on all copies and
- *     supporting documentation, the name of the Regents of
- *     the University of California not be used in advertising
- *     or publicity pertaining to distribution of the programs
- *     without specific prior permission, and notice be given in
- *     supporting documentation that copying and distribution is
- *     by permission of the Regents of the University of California
- *     and by Gregory Glenn Minshall.  Neither the Regents of the
- *     University of California nor Gregory Glenn Minshall make
- *     representations about the suitability of this software
- *     for any purpose.  It is provided "as is" without
- *     express or implied warranty.
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char    sccsid[] = "@(#)outbound.c      3.1  10/29/86";
-#endif /* lint */
-
+static char sccsid[] = "@(#)outbound.c 3.3 (Berkeley) %G%";
+#endif /* not lint */
 
 #include <stdio.h>
 
 #include "../general/general.h"
 
 #include "hostctlr.h"
 
 #include <stdio.h>
 
 #include "../general/general.h"
 
 #include "hostctlr.h"
+#include "oia.h"
 #include "screen.h"
 #include "screen.h"
-#include "ebc_disp.h"
+#include "../api/ebc_disp.h"
 
 #include "../general/globals.h"
 #include "options.ext"
 
 #include "../general/globals.h"
 #include "options.ext"
@@ -81,10 +72,8 @@ void
 init_ctlr()
 {
     LastWasTerminated = 1;
 init_ctlr()
 {
     LastWasTerminated = 1;
-#if    !defined(PURE3274)
-    OutputClock = TransparentClock = 0;
-#endif /* !defined(PURE3274) */
     init_inbound();
     init_inbound();
+    init_oia();
 }
 
 
 }
 
 
@@ -148,7 +137,6 @@ AddHost(position, character)
 int    position;
 char   character;
 {
 int    position;
 char   character;
 {
-#if    defined(SLOWSCREEN)
 #   define     AddHostA(p,c)                                   \
     {                                                          \
        if (IsStartField(p)) {                                  \
 #   define     AddHostA(p,c)                                   \
     {                                                          \
        if (IsStartField(p)) {                                  \
@@ -166,20 +154,6 @@ char       character;
        }                                                       \
        AddHostA(p,c);                                          \
     }  /* end of macro of AddHost */
        }                                                       \
        AddHostA(p,c);                                          \
     }  /* end of macro of AddHost */
-#else  /* defined(SLOWSCREEN) */
-#   define     AddHost(p,c)                                    \
-    {                                                          \
-       if (IsStartField(p)) {                                  \
-           DeleteField(p);                                     \
-           Highest = HighestScreen();                          \
-           Lowest = LowestScreen();                            \
-           SetHost(p, c);                                      \
-       } else {                                                \
-           SetHost(p, c);                                      \
-           SetHighestLowest(p);                                \
-       }                                                       \
-    }  /* end of macro of AddHost */
-#endif /* defined(SLOWSCREEN) */
 
     AddHost(position, character);
 }
 
     AddHost(position, character);
 }
@@ -199,6 +173,10 @@ int        control;                                /* this buffer ended block? */
 
     origCount = count;
 
 
     origCount = count;
 
+    /*
+     * If this is the start of a new data stream, then look
+     * for an op-code and (possibly) a WCC.
+     */
     if (LastWasTerminated) {
 
        if (count < 2) {
     if (LastWasTerminated) {
 
        if (count < 2) {
@@ -211,12 +189,14 @@ int       control;                                /* this buffer ended block? */
            case CMD_READ_MODIFIED:
            case CMD_SNA_READ_MODIFIED:
            case CMD_SNA_READ_MODIFIED_ALL:
            case CMD_READ_MODIFIED:
            case CMD_SNA_READ_MODIFIED:
            case CMD_SNA_READ_MODIFIED_ALL:
-               OiaOnlineA(1);
+               SetOiaOnlineA(&OperatorInformationArea);
+               SetOiaModified();
                DoReadModified(Command);
                break;
            case CMD_READ_BUFFER:
            case CMD_SNA_READ_BUFFER:
                DoReadModified(Command);
                break;
            case CMD_READ_BUFFER:
            case CMD_SNA_READ_BUFFER:
-               OiaOnlineA(1);
+               SetOiaOnlineA(&OperatorInformationArea);
+               SetOiaModified();
                DoReadBuffer();
                break;
            default:
                DoReadBuffer();
                break;
            default:
@@ -252,8 +232,9 @@ int control;                                /* this buffer ended block? */
            {
                int newlines, newcolumns;
 
            {
                int newlines, newcolumns;
 
-               OiaOnlineA(1);
-               OiaTWait(0);
+               SetOiaOnlineA(&OperatorInformationArea);
+               ResetOiaTWait(&OperatorInformationArea);
+               SetOiaModified();
                if ((Command == CMD_ERASE_WRITE)
                                || (Command == CMD_SNA_ERASE_WRITE)) {
                    newlines = 24;
                if ((Command == CMD_ERASE_WRITE)
                                || (Command == CMD_SNA_ERASE_WRITE)) {
                    newlines = 24;
@@ -287,8 +268,9 @@ int control;                                /* this buffer ended block? */
 
        case CMD_ERASE_ALL_UNPROTECTED:
        case CMD_SNA_ERASE_ALL_UNPROTECTED:
 
        case CMD_ERASE_ALL_UNPROTECTED:
        case CMD_SNA_ERASE_ALL_UNPROTECTED:
-           OiaOnlineA(1);
-           OiaTWait(0);
+           SetOiaOnlineA(&OperatorInformationArea);
+           ResetOiaTWait(&OperatorInformationArea);
+           SetOiaModified();
            CursorAddress = HighestScreen()+1;
            for (i = LowestScreen(); i <= HighestScreen(); i = ScreenInc(i)) {
                if (IsUnProtected(i)) {
            CursorAddress = HighestScreen()+1;
            for (i = LowestScreen(); i <= HighestScreen(); i = ScreenInc(i)) {
                if (IsUnProtected(i)) {
@@ -306,13 +288,15 @@ int       control;                                /* this buffer ended block? */
            }
            UnLocked = 1;
            AidByte = 0;
            }
            UnLocked = 1;
            AidByte = 0;
-           OiaSystemLocked(0);
+           ResetOiaSystemLocked(&OperatorInformationArea);
+           SetOiaModified();
            TerminalIn();
            break;
        case CMD_WRITE:
        case CMD_SNA_WRITE:
            TerminalIn();
            break;
        case CMD_WRITE:
        case CMD_SNA_WRITE:
-           OiaOnlineA(1);
-           OiaTWait(0);
+           SetOiaOnlineA(&OperatorInformationArea);
+           ResetOiaTWait(&OperatorInformationArea);
+           SetOiaModified();
            break;
        default:
            {
            break;
        default:
            {
@@ -329,6 +313,13 @@ int        control;                                /* this buffer ended block? */
        count -= 2;                     /* strip off command and wcc */
        buffer += 2;
 
        count -= 2;                     /* strip off command and wcc */
        buffer += 2;
 
+    } else {
+#if    !defined(PURE3274)
+       if (TransparentClock == OutputClock) {
+           TransOut(buffer, count, -1, control);
+           count = 0;
+       }
+#endif /* !defined(PURE3274) */
     }
     LastWasTerminated = 0;             /* then, reset at end... */
 
     }
     LastWasTerminated = 0;             /* then, reset at end... */
 
@@ -363,17 +354,12 @@ int       control;                                /* this buffer ended block? */
                i = buffer[0];
                c = buffer[1];
 #if    !defined(PURE3274)
                i = buffer[0];
                c = buffer[1];
 #if    !defined(PURE3274)
-               if (!i && !c) { /* transparent write */
-                   if (!control) {
-                       return(origCount-(count+1));
-                   } else {
-                       TransparentClock = OutputClock;         /* clock next */
-                       TransOut(buffer+2, count-2);            /* output */
-                       SendToIBM();                            /* ack block */
-                       TransparentClock = OutputClock+1;       /* clock next */
-                       buffer += count;
-                       count -= count;
-                   }
+               /* Check for transparent write */
+               if ((i == 0) && ((c == 0) || (c == 1) || (c == 5))) {
+                   TransparentClock = OutputClock+1;
+                   TransOut(buffer+2, count-2, c, control);
+                   buffer += count;
+                   count -= count;
                    break;
                }
 #endif /* !defined(PURE3274) */
                    break;
                }
 #endif /* !defined(PURE3274) */
@@ -426,14 +412,15 @@ int       control;                                /* this buffer ended block? */
                 */
                i = WhereAttrByte(BufferAddress);
                c = FieldAttributes(i);
                 */
                i = WhereAttrByte(BufferAddress);
                c = FieldAttributes(i);
-               for (i = Addr3270(buffer[0], buffer[1]); i != BufferAddress;
-                               BufferAddress = ScreenInc(BufferAddress)) {
+               i = Addr3270(buffer[0], buffer[1]);
+               do {
                    if (IsStartField(BufferAddress)) {
                        c = FieldAttributes(BufferAddress);
                    } else if (!IsProtectedAttr(BufferAddress, c)) {
                        AddHost(BufferAddress, 0);
                    }
                    if (IsStartField(BufferAddress)) {
                        c = FieldAttributes(BufferAddress);
                    } else if (!IsProtectedAttr(BufferAddress, c)) {
                        AddHost(BufferAddress, 0);
                    }
-               }
+                   BufferAddress = ScreenInc(BufferAddress);
+               } while (i != BufferAddress);
                buffer += 2;
                count -= 2;
                break;
                buffer += 2;
                count -= 2;
                break;
@@ -482,41 +469,29 @@ int       control;                                /* this buffer ended block? */
        } else {
            /* Data comes in large clumps - take it all */
            i = BufferAddress;
        } else {
            /* Data comes in large clumps - take it all */
            i = BufferAddress;
-#if    !defined(SLOWSCREEN)
-           AddHost(i, ebc_disp[c]);
-#else  /* !defined(SLOWSCREEN) */
            AddHostA(i, ebc_disp[c]);
            SetHighestLowest(i);
            AddHostA(i, ebc_disp[c]);
            SetHighestLowest(i);
-#endif /* !defined(SLOWSCREEN) */
            i = ScreenInc(i);
            c = *buffer;
            while (count && !IsOrder(c)) {
            i = ScreenInc(i);
            c = *buffer;
            while (count && !IsOrder(c)) {
-#if    !defined(SLOWSCREEN)
-               AddHost(i, ebc_disp[c]);
-#else  /* !defined(SLOWSCREEN) */
                AddHostA(i, ebc_disp[c]);
                AddHostA(i, ebc_disp[c]);
-#endif /* !defined(SLOWSCREEN) */
                i = ScreenInc(i);
                i = ScreenInc(i);
-#if    defined(SLOWSCREEN)
                if (i == LowestScreen()) {
                    SetHighestLowest(HighestScreen());
                }
                if (i == LowestScreen()) {
                    SetHighestLowest(HighestScreen());
                }
-#endif /* defined(SLOWSCREEN) */
                count--;
                buffer++;
                c = *buffer;
            }
                count--;
                buffer++;
                c = *buffer;
            }
-#if    defined(SLOWSCREEN)
            SetHighestLowest(i);
            SetHighestLowest(i);
-#endif /* defined(SLOWSCREEN) */
            BufferAddress = i;
        }
     }
     if (count == 0) {
            BufferAddress = i;
        }
     }
     if (count == 0) {
+       if (control) {
 #if    !defined(PURE3274)
 #if    !defined(PURE3274)
-       OutputClock++;          /* time rolls on */
+           OutputClock++;              /* time rolls on */
 #endif /* !defined(PURE3274) */
 #endif /* !defined(PURE3274) */
-       if (control) {
            if (Wcc & WCC_RESTORE) {
 #if    !defined(PURE3274)
                if (TransparentClock != OutputClock) {
            if (Wcc & WCC_RESTORE) {
 #if    !defined(PURE3274)
                if (TransparentClock != OutputClock) {
@@ -526,7 +501,9 @@ int control;                                /* this buffer ended block? */
                AidByte = 0;
 #endif /* !defined(PURE3274) */
                UnLocked = 1;
                AidByte = 0;
 #endif /* !defined(PURE3274) */
                UnLocked = 1;
-               OiaSystemLocked(0);
+               ResetOiaSystemLocked(&OperatorInformationArea);
+               SetOiaModified();
+               SetPsModified();
                TerminalIn();
            }
            if (Wcc & WCC_ALARM) {
                TerminalIn();
            }
            if (Wcc & WCC_ALARM) {
@@ -566,6 +543,16 @@ Init3270()
     Highest = LowestScreen()-1;
     CursorAddress = BufferAddress = SetBufferAddress(0,0);
     UnLocked = 1;
     Highest = LowestScreen()-1;
     CursorAddress = BufferAddress = SetBufferAddress(0,0);
     UnLocked = 1;
+#if    !defined(PURE3274)
     OutputClock = 1;
     TransparentClock = -1;
     OutputClock = 1;
     TransparentClock = -1;
+#endif /* !defined(PURE3274) */
+    SetOiaReady3274(&OperatorInformationArea);
+}
+
+
+void
+Stop3270()
+{
+    ResetOiaReady3274(&OperatorInformationArea);
 }
 }