This version works for i386 sequent's and for mips (like 3100)
[unix-history] / usr / src / usr.bin / tn3270 / ctlr / api.h
index 7cb6e5c..efc9abd 100644 (file)
@@ -1,7 +1,24 @@
 /*
 /*
- * This file contains header information used by the PC API routines.
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, 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'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  *
- * @(#)api.h   1.13 (Berkeley) %G%
+ *     @(#)api.h       4.3 (Berkeley) %G%
+ */
+
+/*
+ * This file contains header information used by the PC API routines.
  */
 
 #if    !defined(MSDOS)
  */
 
 #if    !defined(MSDOS)
@@ -155,7 +172,7 @@ typedef struct {
        function_id,
        session_id,
        reserved;
        function_id,
        session_id,
        reserved;
-    int
+    short
        event_queue_id,
        input_queue_id;
     char
        event_queue_id,
        input_queue_id;
     char
@@ -169,18 +186,18 @@ typedef struct {
        function_id,
        session_id,
        reserved;
        function_id,
        session_id,
        reserved;
-    int
+    short
        connectors_task_id;
 } DisconnectFromKeyboardParms;
 
 typedef struct {
        connectors_task_id;
 } DisconnectFromKeyboardParms;
 
 typedef struct {
-    char
+    unsigned char
        scancode,
        shift_state;
 } KeystrokeEntry;
 
 typedef struct {
        scancode,
        shift_state;
 } KeystrokeEntry;
 
 typedef struct {
-    int
+    short
        length;                 /* Length (in bytes) of list */
     KeystrokeEntry keystrokes; /* Variable size */
 } KeystrokeList;
        length;                 /* Length (in bytes) of list */
     KeystrokeEntry keystrokes; /* Variable size */
 } KeystrokeList;
@@ -191,7 +208,7 @@ typedef struct {
        function_id,
        session_id,
        reserved;
        function_id,
        session_id,
        reserved;
-    int
+    short
        connectors_task_id;
     char
        options,
        connectors_task_id;
     char
        options,
@@ -213,7 +230,7 @@ typedef struct {
        function_id,
        session_id,
        reserved;
        function_id,
        session_id,
        reserved;
-    int
+    short
        connectors_task_id;
 } DisableInputParms;
 
        connectors_task_id;
 } DisableInputParms;
 
@@ -228,7 +245,7 @@ typedef struct {
     char
        characteristics,
        session_type;
     char
        characteristics,
        session_type;
-    int
+    short
        begin;                  /* Offset within buffer */
 } BufferDescriptor;
     
        begin;                  /* Offset within buffer */
 } BufferDescriptor;
     
@@ -238,7 +255,7 @@ typedef struct {
        function_id;
     BufferDescriptor
        source;
        function_id;
     BufferDescriptor
        source;
-    int
+    short
        source_end;             /* Offset within source buffer */
     BufferDescriptor
        target;
        source_end;             /* Offset within source buffer */
     BufferDescriptor
        target;
@@ -287,8 +304,14 @@ typedef struct {
  * a dos system.
  */
 
  * a dos system.
  */
 
-#define        FP_SEG(x)       (x)
-#define        FP_OFF(y)       (y)
+#define        FP_SEG(x)       ((unsigned int)(((unsigned long)(x))>>16))
+#define        FP_OFF(y)       ((unsigned int)(((unsigned long)(y))&0xFFFF))
+
+/*
+ * Undo the preceeding.
+ */
+
+#define        SEG_OFF_BACK(x,y)       (((x)<<16)|(y))
 
 /*
  * Now, it is somewhat of a pain, but we need to keep
 
 /*
  * Now, it is somewhat of a pain, but we need to keep
@@ -296,9 +319,27 @@ typedef struct {
  * into which of the "words".
  */
 
  * into which of the "words".
  */
 
+#include <sys/param.h>         /* Get ENDIAN from machine/endian.h */
+
+/* Determine endian'ess (if necessary) */
+
+#if    !(defined(BYTE_ORDER) && defined(BIG_ENDIAN))
+#define        LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
+#define        BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
+
+#if    defined(vax) || defined(ns32000) || defined(i386) || (defined(mips)&&defined(MIPSEL))
+#define        BYTE_ORDER      LITTLE_ENDIAN
+#endif /* defined(vax) || defined(ns32000) */ 
+
+#if    defined(sun) || defined(tahoe) || defined(ibm032) || defined(pyr) || defined(gould) || (defined(mips)&&defined(MIPSEB))
+#define        BYTE_ORDER      BIG_ENDIAN
+#endif /* defined(sun) || defined(tahoe) || defined(ibm032) || defined(pyr) || defined(gould) */
+
+#endif /* !(defined(BYTE_ORDER) && defined(BIG_ENDIAN)) */
+
 struct highlow {
     unsigned char
 struct highlow {
     unsigned char
-#if    defined(vax)
+#if    BYTE_ORDER == LITTLE_ENDIAN
        al,
        ah,
        bl,
        al,
        ah,
        bl,
@@ -307,8 +348,8 @@ struct highlow {
        ch,
        dl,
        dh;
        ch,
        dl,
        dh;
-#endif /* defined(vax) */
-#if    defined(sun) || defined(tahoe) || defined(ibm032)
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+#if    BYTE_ORDER == BIG_ENDIAN
        ah,
        al,
        bh,
        ah,
        al,
        bh,
@@ -317,7 +358,7 @@ struct highlow {
        cl,
        dh,
        dl;
        cl,
        dh,
        dl;
-#endif /* defined(sun) || defined(tahoe) || defined(ibm032) */
+#endif /* BYTE_ORDER == BIG_ENDIAN */
 };
 
 struct words {
 };
 
 struct words {
@@ -326,7 +367,7 @@ struct words {
        bx,
        cx,
        dx;
        bx,
        cx,
        dx;
-    unsigned int
+    unsigned short
        si,
        di;
 };
        si,
        di;
 };
@@ -337,7 +378,7 @@ union REGS {
 };
 
 struct SREGS {
 };
 
 struct SREGS {
-    unsigned int
+    unsigned short
        cs,
        ds,
        es,
        cs,
        ds,
        es,