Make transparent input/output work.
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 16 Jul 1987 05:13:32 +0000 (21:13 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 16 Jul 1987 05:13:32 +0000 (21:13 -0800)
SCCS-vsn: usr.bin/tn3270/ctlr/inbound.c 1.16
SCCS-vsn: usr.bin/tn3270/ctlr/outbound.c 1.20
SCCS-vsn: usr.bin/tn3270/ascii/termin.c 1.10

usr/src/usr.bin/tn3270/ascii/termin.c
usr/src/usr.bin/tn3270/ctlr/inbound.c
usr/src/usr.bin/tn3270/ctlr/outbound.c

index 1eaf5b1..d863a24 100644 (file)
@@ -54,7 +54,8 @@ static        char    sccsid[] = "@(#)termin.c        3.1  10/29/86";
 static unsigned char
        ourBuffer[100],         /* where we store stuff */
        *ourPHead = ourBuffer,  /* first character in buffer */
 static unsigned char
        ourBuffer[100],         /* where we store stuff */
        *ourPHead = ourBuffer,  /* first character in buffer */
-       *ourPTail = ourBuffer;  /* where next character goes */
+       *ourPTail = ourBuffer,  /* where next character goes */
+       *TransPointer = 0;      /* For transparent mode data */
 
 static int InControl;
 static int WaitingForSynch;
 
 static int InControl;
 static int WaitingForSynch;
@@ -131,6 +132,19 @@ FlushChar()
     ourPHead = ourBuffer;
 }
 
     ourPHead = ourBuffer;
 }
 
+void
+TransInput(onoff, mode)
+int    mode;                   /* Which KIND of transparent input */
+int    onoff;                  /* Going in, or coming out */
+{
+    if (onoff) {
+       /* Flush pending input */
+       FlushChar();
+       TransPointer = ourBuffer;
+    } else {
+    }
+}
+
 int
 TerminalIn()
 {
 int
 TerminalIn()
 {
@@ -171,6 +185,26 @@ register int       count;                  /* how many bytes in this buffer */
     extern int bellwinup;
     static state *controlPointer;
 
     extern int bellwinup;
     static state *controlPointer;
 
+    if (TransPointer) {
+       int i;
+
+       if ((count+TransPointer) >= (ourBuffer+sizeof ourBuffer)) {
+           i = ourBuffer+sizeof ourBuffer-TransPointer;
+       } else {
+           i = count;
+       }
+       while (i--) {
+           c = (*buffer)&0x7f;
+           *TransPointer++ = c|0x80;
+           if (c == '\r') {
+               SendTransparent(ourBuffer, TransPointer-ourBuffer);
+               TransPointer = 0;               /* Done */
+               break;
+           }
+       }
+       return count;
+    }
+
     if (bellwinup) {
        BellOff();
     }
     if (bellwinup) {
        BellOff();
     }
index 0884890..ec25428 100644 (file)
@@ -486,13 +486,31 @@ DoReadBuffer()
        HadAid = 0;                     /* killed that buffer */
     }
 }
        HadAid = 0;                     /* killed that buffer */
     }
 }
+
+/* Send some transparent data to the host */
+
+void
+SendTransparent(buffer, count)
+char *buffer;
+int count;
+{
+    char stuff[3];
+
+    stuff[0] = AID_NONE_PRINTER;
+    stuff[1] = BufferTo3270_0(count);
+    stuff[2] = BufferTo3270_1(count);
+    DataToNetwork(stuff, sizeof stuff, 0);
+    DataToNetwork(buffer, count, 1);
+}
+
+
 /* Try to send some data to host */
 
 void
 SendToIBM()
 {
 #if    !defined(PURE3274)
 /* Try to send some data to host */
 
 void
 SendToIBM()
 {
 #if    !defined(PURE3274)
-    if (TransparentClock == OutputClock) {
+    if (TransparentClock >= OutputClock) {
        if (HadAid) {
            AddChar(AidByte);
            HadAid = 0;
        if (HadAid) {
            AddChar(AidByte);
            HadAid = 0;
@@ -600,10 +618,14 @@ int
            return 0;
        }
     }
            return 0;
        }
     }
-    /* now, either empty, or haven't seen aid yet */
 
 
+    /* now, either empty, or haven't seen aid yet */
 
 #if    !defined(PURE3274)
 
 #if    !defined(PURE3274)
+    /*
+     * If we are in transparent (output) mode, do something special
+     * with keystrokes.
+     */
     if (TransparentClock == OutputClock) {
        if (ctlrfcn == FCN_AID) {
            UnLocked = 0;
     if (TransparentClock == OutputClock) {
        if (ctlrfcn == FCN_AID) {
            UnLocked = 0;
index 1b4dbb2..0659225 100644 (file)
@@ -82,9 +82,6 @@ void
 init_ctlr()
 {
     LastWasTerminated = 1;
 init_ctlr()
 {
     LastWasTerminated = 1;
-#if    !defined(PURE3274)
-    OutputClock = TransparentClock = 0;
-#endif /* !defined(PURE3274) */
     init_inbound();
     init_oia();
 }
     init_inbound();
     init_oia();
 }
@@ -186,6 +183,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) {
@@ -322,6 +323,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... */
 
@@ -356,17 +364,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) */
@@ -494,10 +497,10 @@ int       control;                                /* this buffer ended block? */
        }
     }
     if (count == 0) {
        }
     }
     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) {
@@ -549,8 +552,10 @@ 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);
 }
 
     SetOiaReady3274(&OperatorInformationArea);
 }