home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / tn3270 / ctlr / api.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-26  |  8.5 KB  |  404 lines

  1. /*-
  2.  * Copyright (c) 1988 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)api.h    4.4 (Berkeley) 4/26/91
  34.  */
  35.  
  36. /*
  37.  * This file contains header information used by the PC API routines.
  38.  */
  39.  
  40. #if    !defined(MSDOS)
  41. #define far            /* For 'far *' checks */
  42. #endif    /* !defined(MSDOS) */
  43.  
  44. #define    API_INTERRUPT_NUMBER    0x7A        /* API Interrupt Number */
  45.  
  46. /*
  47.  * Define the gate numbers.  These are returned via the Name Resolution
  48.  * service.
  49.  */
  50.  
  51. #define    GATE_SESSMGR    1234
  52. #define    GATE_KEYBOARD    5678
  53. #define    GATE_COPY    9101
  54. #define    GATE_OIAM    1121
  55.  
  56. /*
  57.  * The names which correspond to the above gate numbers.
  58.  */
  59.  
  60. #define    NAME_SESSMGR    "SESSMGR "
  61. #define    NAME_KEYBOARD    "KEYBOARD"
  62. #define    NAME_COPY    "COPY    "
  63. #define    NAME_OIAM    "OIAM    "
  64.  
  65.  
  66. /*
  67.  * Name Resolution is specified in AH.
  68.  */
  69.  
  70. #define    NAME_RESOLUTION        0x81
  71.  
  72. #if    defined(unix)
  73. /*
  74.  * In unix, we offer a service to allow the application to keep from
  75.  * having to poll us constantly.
  76.  */
  77. #define    PS_OR_OIA_MODIFIED    0x99
  78.  
  79. #endif    /* defined(unix) */
  80.  
  81. /*
  82.  * Codes specified in AL for various services.
  83.  */
  84.  
  85. #define    QUERY_SESSION_ID        0x01
  86. #define    QUERY_SESSION_PARAMETERS    0x02
  87. #define    QUERY_SESSION_CURSOR        0x0b
  88.  
  89. #define    CONNECT_TO_KEYBOARD        0x01
  90. #define    DISCONNECT_FROM_KEYBOARD    0x02
  91. #define    WRITE_KEYSTROKE            0x04
  92. #define    DISABLE_INPUT            0x05
  93. #define    ENABLE_INPUT            0x06
  94.  
  95. #define    COPY_STRING            0x01
  96.  
  97. #define    READ_OIA_GROUP            0x02
  98.  
  99. /*
  100.  * For each service, we define the assoicated parameter blocks.
  101.  */
  102.  
  103. /*
  104.  * Supervisor Services
  105.  */
  106.  
  107. typedef struct {
  108.     char    gate_name[8];
  109. } NameResolveParms;
  110.  
  111.  
  112. /*
  113.  * Session Information Services
  114.  */
  115.  
  116. typedef struct {
  117.     char
  118.     short_name,
  119.     type,
  120.     session_id,
  121.     reserved,
  122.     long_name[8];
  123. } NameArrayElement;
  124.  
  125. typedef struct {
  126.     unsigned char
  127.     length,
  128.     number_matching_session;
  129.     NameArrayElement
  130.     name_array_element;        /* Variable number */
  131. } NameArray;
  132.  
  133. typedef struct {
  134.     char
  135.     rc,
  136.     function_id,
  137.     option_code,
  138.     data_code;
  139.     NameArray far
  140.     *name_array;
  141.     char
  142.     long_name[8];
  143. } QuerySessionIdParms;
  144.  
  145. #define    ID_OPTION_BY_NAME    0x01        /* By short (or long) name */
  146. #define    ID_OPTION_ALL        0x00        /* All (of specified type */
  147.  
  148. typedef struct {
  149.     char
  150.     rc,
  151.     function_id,
  152.     session_id,
  153.     reserved,
  154.     session_type,
  155.     session_characteristics,
  156.     rows,
  157.     columns;
  158.     char far
  159.     *presentation_space;
  160. } QuerySessionParametersParms;
  161.  
  162. #define    TYPE_WSCTL        0x01        /* Work Station Control */
  163. #define    TYPE_DFT        0x02        /* DFT Host Session */
  164. #define    TYPE_CUT        0x03        /* CUT Host Session */
  165. #define    TYPE_NOTEPAD        0x04        /* Notepad Session */
  166. #define    TYPE_PC            0x05        /* Personal Computer Session */
  167.  
  168. #define    CHARACTERISTIC_EAB    0x80        /* Extended Attribute Buffer */
  169. #define    CHARACTERISTIC_PSS    0x40        /* Program Symbols Supported */
  170.  
  171. typedef struct {
  172.     char
  173.     rc,
  174.     function_id,
  175.     session_id,
  176.     cursor_type,
  177.     row_address,                /* from 0 */
  178.     column_address;                /* from 0 */
  179. } QuerySessionCursorParms;
  180.  
  181. #define    CURSOR_INHIBITED_AUTOSCROLL    0x10
  182. #define    CURSOR_INHIBITED        0x04
  183. #define    CURSOR_BLINKING            0x02
  184. #define    CURSOR_BOX            0x01
  185. typedef struct {
  186.     char
  187.     rc,
  188.     function_id,
  189.     session_id,
  190.     reserved;
  191.     short
  192.     event_queue_id,
  193.     input_queue_id;
  194.     char
  195.     intercept_options,
  196.     first_connection_identifier;
  197. } ConnectToKeyboardParms;
  198.  
  199. typedef struct {
  200.     char
  201.     rc,
  202.     function_id,
  203.     session_id,
  204.     reserved;
  205.     short
  206.     connectors_task_id;
  207. } DisconnectFromKeyboardParms;
  208.  
  209. typedef struct {
  210.     unsigned char
  211.     scancode,
  212.     shift_state;
  213. } KeystrokeEntry;
  214.  
  215. typedef struct {
  216.     short
  217.     length;            /* Length (in bytes) of list */
  218.     KeystrokeEntry keystrokes;    /* Variable size */
  219. } KeystrokeList;
  220.  
  221. typedef struct {
  222.     char
  223.     rc,
  224.     function_id,
  225.     session_id,
  226.     reserved;
  227.     short
  228.     connectors_task_id;
  229.     char
  230.     options,
  231.     number_of_keys_sent;
  232.     union {
  233.     KeystrokeEntry
  234.         keystroke_entry;
  235.     KeystrokeList far
  236.         *keystroke_list;
  237.     } keystroke_specifier;
  238. } WriteKeystrokeParms;
  239.  
  240. #define    OPTION_SINGLE_KEYSTROKE        0x20
  241. #define    OPTION_MULTIPLE_KEYSTROKES    0x30
  242.  
  243. typedef struct {
  244.     char
  245.     rc,
  246.     function_id,
  247.     session_id,
  248.     reserved;
  249.     short
  250.     connectors_task_id;
  251. } DisableInputParms;
  252.  
  253. typedef DisableInputParms EnableInputParms;
  254.  
  255. typedef struct {
  256.     char
  257.     session_id,
  258.     reserved;
  259.     char far
  260.     *buffer;
  261.     char
  262.     characteristics,
  263.     session_type;
  264.     short
  265.     begin;            /* Offset within buffer */
  266. } BufferDescriptor;
  267.     
  268. typedef struct {
  269.     char
  270.     rc,
  271.     function_id;
  272.     BufferDescriptor
  273.     source;
  274.     short
  275.     source_end;        /* Offset within source buffer */
  276.     BufferDescriptor
  277.     target;
  278.     char
  279.     copy_mode,
  280.     reserved;
  281. } CopyStringParms;
  282.  
  283. #define    COPY_MODE_7_COLOR        0x80    /* Else 4 color mode */
  284. #define    COPY_MODE_FIELD_ATTRIBUTES    0x40    /* Else don't copy attributes */
  285.  
  286. typedef struct {
  287.     char
  288.     rc,
  289.     function_id,
  290.     session_id,
  291.     reserved;
  292.     char far
  293.     *oia_buffer;
  294.     char
  295.     oia_group_number;
  296. } ReadOiaGroupParms;
  297.  
  298. /* If the user wants all groups, we return API_OIA_BYTES_ALL_GROUPS bytes */
  299. #define    API_OIA_ALL_GROUPS        '\377'
  300. #define    API_OIA_BYTES_ALL_GROUPS    22    /* 22 bytes of data */
  301.  
  302. /* API_OIA_INPUT_INHIBITED is special.  It returns more than on byte of data */
  303. #define    API_OIA_INPUT_INHIBITED        8
  304.  
  305. #define    API_OIA_LAST_LEGAL_GROUP    18    /* Highest legal number */
  306.  
  307.  
  308.  
  309. #if    defined(MSDOS)
  310.  
  311. #if    !defined(FP_SEG)
  312. #include <dos.h>
  313. #endif    /* !defined(FP_SEG) */
  314.  
  315. #else    /* defined(MSDOS) */
  316.  
  317. /*
  318.  * These definitions are here to provide the descriptions of
  319.  * some registers which are, normally, defined in <dos.h> on
  320.  * a dos system.
  321.  */
  322.  
  323. #define    FP_SEG(x)    ((unsigned int)(((unsigned long)(x))>>16))
  324. #define    FP_OFF(y)    ((unsigned int)(((unsigned long)(y))&0xFFFF))
  325.  
  326. /*
  327.  * Undo the preceeding.
  328.  */
  329.  
  330. #define    SEG_OFF_BACK(x,y)    (((x)<<16)|(y))
  331.  
  332. /*
  333.  * Now, it is somewhat of a pain, but we need to keep
  334.  * 8086 conventions about which of the "highlow"'s map
  335.  * into which of the "words".
  336.  */
  337.  
  338. #include <sys/param.h>        /* Get ENDIAN from machine/endian.h */
  339.  
  340. /* Determine endian'ess (if necessary) */
  341.  
  342. #if    !(defined(BYTE_ORDER) && defined(BIG_ENDIAN))
  343. #define    LITTLE_ENDIAN    1234    /* least-significant byte first (vax) */
  344. #define    BIG_ENDIAN    4321    /* most-significant byte first (IBM, net) */
  345.  
  346. #if    defined(vax) || defined(ns32000) || defined(i386) || (defined(mips)&&defined(MIPSEL))
  347. #define    BYTE_ORDER    LITTLE_ENDIAN
  348. #endif    /* defined(vax) || defined(ns32000) */ 
  349.  
  350. #if    defined(sun) || defined(tahoe) || defined(ibm032) || defined(pyr) || defined(gould) || (defined(mips)&&defined(MIPSEB))
  351. #define    BYTE_ORDER    BIG_ENDIAN
  352. #endif    /* defined(sun) || defined(tahoe) || defined(ibm032) || defined(pyr) || defined(gould) */
  353.  
  354. #endif    /* !(defined(BYTE_ORDER) && defined(BIG_ENDIAN)) */
  355.  
  356. struct highlow {
  357.     unsigned char
  358. #if    BYTE_ORDER == LITTLE_ENDIAN
  359.     al,
  360.     ah,
  361.     bl,
  362.     bh,
  363.     cl,
  364.     ch,
  365.     dl,
  366.     dh;
  367. #endif    /* BYTE_ORDER == LITTLE_ENDIAN */
  368. #if    BYTE_ORDER == BIG_ENDIAN
  369.     ah,
  370.     al,
  371.     bh,
  372.     bl,
  373.     ch,
  374.     cl,
  375.     dh,
  376.     dl;
  377. #endif    /* BYTE_ORDER == BIG_ENDIAN */
  378. };
  379.  
  380. struct words {
  381.     unsigned short
  382.     ax,
  383.     bx,
  384.     cx,
  385.     dx;
  386.     unsigned short
  387.     si,
  388.     di;
  389. };
  390.  
  391. union REGS {
  392.     struct highlow h;
  393.     struct words x;
  394. };
  395.  
  396. struct SREGS {
  397.     unsigned short
  398.     cs,
  399.     ds,
  400.     es,
  401.     ss;
  402. };
  403. #endif    /* defined(MSDOS) (else section) */
  404.