1 /* ***********************************************************
  2    *                                                         *
  3    * Copyright, (C) Honeywell Bull Inc., 1987                *
  4    *                                                         *
  5    * Copyright, (C) Honeywell Information Systems Inc., 1986 *
  6    *                                                         *
  7    *********************************************************** */
  8 
  9 /* HISTORY COMMENTS:
 10   1) change(86-05-05,Lee), approve(87-07-13,MCR7580), audit(87-07-13,Leskiw),
 11      install(87-08-07,MR12.1-1072):
 12      Created.
 13   2) change(86-06-10,Westcott), approve(87-07-13,MCR7580),
 14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 15      Removed from capabil.c
 16   3) change(86-11-14,Flegel), approve(87-07-13,MCR7580),
 17      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 18      Check for WSMAJCAP as a capability number.
 19                                                    END HISTORY COMMENTS */
 20 
 21 /* : PROCEDURE FUNCTION (c_pack):
 22 
 23 Pack system_id and major capability number into one integer
 24 */
 25 
 26 /* : RETURNS:
 27 
 28      0         - if pack successful
 29      WSINVNUM  - if major_number outside of the range MIN_CAPABILITY_NUMBER and
 30                  MAX_CAPABILITY_NUMBER
 31      WSINVSYS  - if system_id is outside of the range MIN_SYSTEM_ID and
 32                  MAX_SYSTEM_ID
 33 */
 34 
 35 /* : NOTES
 36 
 37 Both system_id and major number are considered to be 8 bit unsigned integers.
 38 The system_id is moved to the high order half of major capability is moved
 39 to the low order half.
 40 */
 41 
 42 #include <dos.h>
 43 #include <ws.h>
 44 #include <cat.h>
 45 #include <ws_error.h>
 46 
 47 #define LOW_8_BITS  0x00FF
 48 #define BYTE_SHIFT  8
 49 
 50 c_pack (system_id, major_number, major_capability)
 51 int system_id;           /* system id */
 52 int major_number;        /* Major capability number */
 53 int *major_capability;   /* Resultant capability number (packed) */
 54 {
 55 
 56 /* : if major_number not between 32 and 64 inclusive then
 57      - set code to invalid major number */
 58 
 59    if (major_number < WSMAJCAP || major_number > MAX_CAPABILITY_NUMBER)
 60       return(WSINVNUM);
 61 
 62 /* : if system id not between 32 and 64 and not WSLOCAL and WSREMOTE then
 63      - set code to invalid system id */
 64 
 65    if ((system_id != WSLOCAL) && (system_id != WSREMOTE) &&
 66        ((system_id < MIN_SYSTEM_ID) || (system_id > MAX_SYSTEM_ID)))
 67    {
 68       return(WSINVSYS);
 69    }
 70 
 71 /* : return major capability number, where system id occupies high 8 bits,
 72      major_number low 8 bits */
 73 
 74    *major_capability = (system_id << BYTE_SHIFT) | major_number;
 75    return(0);
 76 }
 77 
 78 /* : PROCEDURE FUNCTION (c_unpack):
 79 
 80 Unpack system_id and major capability number from one integer into two
 81 separate integers.
 82 */
 83 
 84 /* : RETURNS:
 85 
 86      0, if unpack successful
 87      WSINVNUM - if major_number outside of the range
 88                 MIN_CAPABILITY_NUMBER and MAX_CAPABILITY_NUMBER
 89 */
 90 
 91 /* : NOTES
 92 
 93 Both system_id and major number are considered to be 8 bit unsigned integers.
 94 The high order half of major_capability is moved to the low order byte in
 95 system_id, while the low order half of major_capability is moved to the low
 96 order half of major_number.
 97 */
 98 
 99 c_unpack (system_id, major_number, major_capability)
100 int *system_id;        /* Pointer to system id (resultant) */
101 int *major_number;     /* Pointer to major number (resultant) */
102 int major_capability;  /* Capability number to be unpacked */
103 {
104 
105 /* : - system id is high 8 bits */
106 
107    *system_id = (major_capability >> BYTE_SHIFT) & LOW_8_BITS;
108 
109 /* : - major number is low 8 bits */
110 
111    *major_number = major_capability & LOW_8_BITS;
112 
113 /* : - if major number unpacked is invalid, return error code */
114 
115    if (*major_number < WSMAJCAP || *major_number > MAX_CAPABILITY_NUMBER)
116       return(WSINVNUM);
117 
118 /* : if system id not between 32 and 64 and is not WSREMOTE and WSLOCAL then
119      -  return invalid system id error code */
120 
121    if ((*system_id != WSLOCAL) && (*system_id != WSREMOTE) &&
122        ((*system_id < MIN_SYSTEM_ID) || (*system_id > MAX_SYSTEM_ID)))
123    {
124       return(WSINVSYS);
125    }
126 
127    return(0);
128 }
129 ^Z