date and time created 87/07/16 20:38:06 by denise
[unix-history] / usr / src / usr.bin / tn3270 / ctlr / api.c
index a9b6809..281811b 100644 (file)
@@ -7,10 +7,10 @@
 #include "api.h"
 #include "../general/general.h"
 
 #include "api.h"
 #include "../general/general.h"
 
-#include "../ascii/disp_asc.h"
+#include "../api/disp_asc.h"
 
 
-#include "../ctlr/screen.h"
-#include "../ctlr/oia.h"
+#include "screen.h"
+#include "oia.h"
 
 #include "../general/globals.h"
 
 
 #include "../general/globals.h"
 
@@ -25,8 +25,8 @@ static void movetous(char *, int, int, int);
 static void movetothem(int, int, char *, int);
 #endif /* defined(LINT_ARGS) */
 
 static void movetothem(int, int, char *, int);
 #endif /* defined(LINT_ARGS) */
 
-#define        access_api(foo,length)  (foo)
-#define        unaccess_api(foo,goo,length)
+#define        access_api(foo,length,copyin)   (foo)
+#define        unaccess_api(foo,goo,length,copyout)
 
 static void
 movetous(parms, es, di, length)
 
 static void
 movetous(parms, es, di, length)
@@ -355,7 +355,8 @@ struct SREGS *sregs;
  * Copy Services.
  */
 
  * Copy Services.
  */
 
-copy_subroutine(target, source, parms, what_is_user)
+static
+copy_subroutine(target, source, parms, what_is_user, length)
 BufferDescriptor *target, *source;
 CopyStringParms *parms;
 int what_is_user;
 BufferDescriptor *target, *source;
 CopyStringParms *parms;
 int what_is_user;
@@ -368,7 +369,6 @@ int what_is_user;
 #define        SOURCE_PC               8
 #define        NO_FIELD_ATTRIBUTES     16
     int needtodo = 0;
 #define        SOURCE_PC               8
 #define        NO_FIELD_ATTRIBUTES     16
     int needtodo = 0;
-    int length;
     int access_length;
     char far *input;
     char far *output;
     int access_length;
     char far *input;
     char far *output;
@@ -392,20 +392,20 @@ int what_is_user;
     if ((parms->copy_mode&COPY_MODE_FIELD_ATTRIBUTES) == 0) {
        needtodo |= NO_FIELD_ATTRIBUTES;
     }
     if ((parms->copy_mode&COPY_MODE_FIELD_ATTRIBUTES) == 0) {
        needtodo |= NO_FIELD_ATTRIBUTES;
     }
-    access_length = length = parms->source_end-source->begin;
+    access_length = length;
     if (what_is_user == USER_IS_TARGET) {
        if (target->characteristics&CHARACTERISTIC_EAB) {
            access_length *= 2;
        }
        input = (char far *) &Host[source->begin];
        access_pointer = target->buffer;
     if (what_is_user == USER_IS_TARGET) {
        if (target->characteristics&CHARACTERISTIC_EAB) {
            access_length *= 2;
        }
        input = (char far *) &Host[source->begin];
        access_pointer = target->buffer;
-       output = access_api(target->buffer, access_length);
+       output = access_api(target->buffer, access_length, 0);
     } else {
        if (source->characteristics&CHARACTERISTIC_EAB) {
            access_length *= 2;
        }
        access_pointer = source->buffer;
     } else {
        if (source->characteristics&CHARACTERISTIC_EAB) {
            access_length *= 2;
        }
        access_pointer = source->buffer;
-       input = access_api(source->buffer, access_length);
+       input = access_api(source->buffer, access_length, 1);
        output = (char far *) &Host[target->begin];
     }
     while (length--) {
        output = (char far *) &Host[target->begin];
     }
     while (length--) {
@@ -423,9 +423,9 @@ int what_is_user;
        }
     }
     if (what_is_user == USER_IS_TARGET) {
        }
     }
     if (what_is_user == USER_IS_TARGET) {
-       unaccess_api(target->buffer, access_pointer, access_length);
+       unaccess_api(target->buffer, access_pointer, access_length, 1);
     } else {
     } else {
-       unaccess_api(source->buffer, access_pointer, access_length);
+       unaccess_api(source->buffer, access_pointer, access_length, 0);
     }
 }
 
     }
 }
 
@@ -441,39 +441,55 @@ struct SREGS *sregs;
 
     movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);
 
 
     movetous((char *)&parms, sregs->es, regs->x.di, sizeof parms);
 
+    length = 1+parms.source_end-source->begin;
     if ((parms.rc != 0) || (parms.function_id !=0)) {
        parms.rc = 0x0c;
     } else if (target->session_id == 0) {      /* Target is buffer */
        if (source->session_id != 23) {         /* A no-no */
            parms.rc = 0x2;
        } else {
     if ((parms.rc != 0) || (parms.function_id !=0)) {
        parms.rc = 0x0c;
     } else if (target->session_id == 0) {      /* Target is buffer */
        if (source->session_id != 23) {         /* A no-no */
            parms.rc = 0x2;
        } else {
-           if ((source->characteristics == target->characteristics) &&
+           if ((source->begin < 0) || (source->begin > highestof(Host))) {
+               parms.rc = 0x06;                /* invalid source definition */
+           } else {
+               if ((source->begin+length) > highestof(Host)) {
+                   length = highestof(Host)-source->begin;
+                   parms.rc = 0x0f;    /* Truncate */
+               }
+               if ((source->characteristics == target->characteristics) &&
                    (source->session_type == target->session_type)) {
                    (source->session_type == target->session_type)) {
-               length = parms.source_end-source->begin;
-               if (source->characteristics&CHARACTERISTIC_EAB) {
-                   length *= 2;
+                   if (source->characteristics&CHARACTERISTIC_EAB) {
+                       length *= 2;
+                   }
+                   movetothem( (int) FP_SEG(target->buffer),
+                           (int) FP_OFF(target->buffer),
+                           (char *)&Host[source->begin], length);
+               } else {
+                   copy_subroutine(target, source, &parms,
+                                                       USER_IS_TARGET, length);
                }
                }
-               movetothem( (int) FP_SEG(target->buffer),
-                       (int) FP_OFF(target->buffer),
-                       (char *)&Host[source->begin], length);
-           } else {
-               copy_subroutine(target, source, &parms, USER_IS_TARGET);
            }
        }
     } else if (source->session_id != 0) {
            parms.rc = 0xd;
     } else {
            }
        }
     } else if (source->session_id != 0) {
            parms.rc = 0xd;
     } else {
-       if ((source->characteristics == target->characteristics) &&
-               (source->session_type == target->session_type)) {
-           length = parms.source_end-source->begin;
-           if (source->characteristics&CHARACTERISTIC_EAB) {
-               length *= 2;
-           }
-           movetous((char *)&Host[target->begin],
-                       (int) FP_SEG(source->buffer),
-                       (int) FP_OFF(source->buffer), length);
+       if ((target->begin < 0) || (source->begin > highestof(Host))) {
+           parms.rc = 0x07;            /* invalid source definition */
        } else {
        } else {
-           copy_subroutine(target, source, &parms, USER_IS_SOURCE);
+           if ((source->begin+length) > highestof(Host)) {
+               length = highestof(Host)-source->begin;
+               parms.rc = 0x0f;        /* Truncate */
+           }
+           if ((source->characteristics == target->characteristics) &&
+                   (source->session_type == target->session_type)) {
+               if (source->characteristics&CHARACTERISTIC_EAB) {
+                   length *= 2;
+               }
+               movetous((char *)&Host[target->begin],
+                           (int) FP_SEG(source->buffer),
+                           (int) FP_OFF(source->buffer), length);
+           } else {
+               copy_subroutine(target, source, &parms, USER_IS_SOURCE, length);
+           }
        }
     }
     movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);
        }
     }
     movetothem(sregs->es, regs->x.di, (char *)&parms, sizeof parms);
@@ -537,6 +553,13 @@ struct SREGS *sregs;
 {
     if (regs->h.ah == NAME_RESOLUTION) {
        name_resolution(regs, sregs);
 {
     if (regs->h.ah == NAME_RESOLUTION) {
        name_resolution(regs, sregs);
+#if    defined(unix)
+    } else if (regs->h.ah == PS_OR_OIA_MODIFIED) {
+       while ((oia_modified == 0) && (ps_modified == 0)) {
+           (void) Scheduler(1);
+       }
+       oia_modified = ps_modified = 0;
+#endif /* defined(unix) */
     } else if (regs->h.ah != 0x09) {
        regs->h.ch = 0x12;
        regs->h.cl = 0x0f;              /* XXX Invalid environmental access */
     } else if (regs->h.ah != 0x09) {
        regs->h.ch = 0x12;
        regs->h.cl = 0x0f;              /* XXX Invalid environmental access */