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 END HISTORY COMMENTS */ 14 /* : PROCEDURE FUNCTION (init_cat) 15 16 Initialize the local and remote Capability Address Tables (CAT) to a state 17 which indicates that there are NO current entries in the tables. This is 18 done by setting the "mcb" field of local table to "NULL". And setting the 19 "major_capability" field of the remote table to "0". 20 */ 21 22 /* : NOTES: 23 24 A call must be made to this routine before any accessing of the CAT tables 25 can be made. Also a call to this routine will wipe out any entries that may 26 currently exist in the Tables. 27 */ 28 29 #include <dos.h> 30 #include <ws.h> 31 #include <cat.h> 32 #include <ws_error.h> 33 34 #define LOW_8_BITS 0x00FF 35 #define NULL 0 36 37 #ifndef TRUE 38 #define TRUE 1 39 #endif 40 41 #ifndef FALSE 42 #define FALSE 0 43 #endif 44 45 extern char MYSYSTEM; /* System ID */ 46 extern local_cat l_CAT[]; /* Local CAT */ 47 extern remote_cat r_CAT[]; /* Remote CAT */ 48 extern local_cat *sleepq; /* Sleeping queue */ 49 50 init_cat () 51 { 52 int i; 53 54 /* : Empty the sleepq */ 55 56 sleepq = NULL; 57 58 /* : for each entry in the cat tables 59 - set the mcb pointer in the local cat entry to NULL 60 - set the major capability number in remote cat entry to 0 */ 61 62 for (i = 0; i < NUMBER_OF_CAT_ENTRIES; i++) 63 { l_CAT[i].mcb_ptr = NULL; 64 l_CAT[i].flags = 0; 65 l_CAT[i].next_cat = NULL; 66 l_CAT[i].sleep_time = 0; 67 l_CAT[i].waitreg = 0; 68 l_CAT[i].ws_entry = NULL; 69 70 r_CAT[i].major_capability = 0; 71 r_CAT[i].system_id = 0; 72 r_CAT[i].capability_name[0] = 0; 73 r_CAT[i].flags = 0; 74 } 75 } 76 77 /* : PROCEDURE FUNCTION (find_free_cat) 78 79 Find a free entry into the local CAT table, i.e one that is not being used. 80 Return the index for this local CAT entry if one is found, otherwise return 81 an error code. 82 */ 83 84 find_free_cat () 85 { 86 int cat_entry_index; 87 int i; 88 89 /* : search local cat from 1st entry to last entry 90 - if the mcb pointer is NULL (not being used) 91 -- set output parameter cat entry index to current entry 92 -- free cat entry found, set code to 0 and return */ 93 94 for (i = 0; i < NUMBER_OF_CAT_ENTRIES; i++) 95 { if (l_CAT[i].mcb_ptr == NULL) 96 { cat_entry_index = i; 97 return(cat_entry_index); 98 } 99 } 100 101 /* : else search for free cat entry fails, set code for failed */ 102 103 return(WSCNTCRE); 104 } 105 106 /* : PROCEDURE FUNCTION (add_to_remote_cat) 107 108 Used to update the remote CAT entry, this is an internal MOWSE function call. 109 */ 110 111 add_to_remote_cat (p_system_id, p_major_capability_number, p_capability_name) 112 113 char p_system_id; 114 char p_major_capability_number; 115 char *p_capability_name; 116 { 117 int cap_num; 118 int i; 119 int pad; 120 121 /* : if system_id is not 'remote', set error code and return */ 122 123 cap_num = (int) p_major_capability_number - MIN_CAPABILITY_NUMBER; 124 if ((cap_num < 0) || (cap_num > NUMBER_OF_CAT_ENTRIES)) 125 return (WSINVNUM); 126 127 if (p_system_id == MYSYSTEM) 128 return (WSINVSYS); 129 130 /* : if capability is already used, set error code and return */ 131 132 if (r_CAT[cap_num].major_capability != 0) 133 return(WSINVNUM); 134 135 /* : - initialize the remote cat entry with given data */ 136 137 r_CAT[cap_num].major_capability = p_major_capability_number; 138 r_CAT[cap_num].system_id = p_system_id; 139 140 /* : copy the capability name into the remote cat, padding nulls on the 141 right of the string */ 142 143 i = stccpy (r_CAT[cap_num].capability_name, p_capability_name, CAPABILITY_NAME_LENGTH); 144 for (i = i; i < CAPABILITY_NAME_LENGTH; r_CAT[cap_num].capability_name[i++] = 0); 145 146 /* : reset all flags */ 147 148 r_CAT[cap_num].flags = 0; 149 150 /* : - no errors, set code returned to 0 */ 151 152 return (0); 153 } 154 ^Z