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-09-14,ASmith), approve(87-07-13,MCR7580),
11      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
12      Fixed CAT table.
13   2) change(86-12-08,Flegel), approve(87-07-13,MCR7580),
14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
15      Check for sleep queue.
16                                                    END HISTORY COMMENTS */
17 /* :  PROCEDURE FUNCTION (i_desins)
18 
19 Interrupt routine to free up the cat entry in the local CAT for a given
20 capability and to send a message to the remote machine to get rid of the
21 same capability in its CAT table.
22 */
23 
24 #include <dos.h>
25 #include <cat.h>
26 #include <ws_dcls.h>
27 #include <ws_error.h>
28 #include <ws_msg.h>
29 #include <wsmincap.h>
30 
31 #define NULL 0
32 
33 extern local_cat l_CAT[];              /* Local CAT */
34 extern char mysystem;                  /* System id */
35 extern local_cat *sleepq;              /* List of sleepers */
36 
37 i_desins (param)
38 
39 struct destinst_param_struct *param;
40 {
41 int cap_index;                         /* Index into CAT */
42 struct alter_cat_msg alter_cat;        /* Message to remote */
43 local_cat *catp;                       /* For traversiong the cat */
44 int  code;                             /* Error code */
45 
46 /* : if mcb pointer passed is not the same as the mcb pointer in the cat entry
47      given by the derived index, return with code for invalid mcb */
48 
49    cap_index = param -> cap_index;
50    if ((cap_index < 0) || (cap_index >= NUMBER_OF_CAT_ENTRIES))
51       return(WSINVMCB);
52    if (l_CAT[cap_index].mcb_ptr == NULL)
53       return(WSINVMCB);
54    if (l_CAT[cap_index].mcb_ptr != param -> mcb_ptr)
55       return(WSINVMCB);
56 
57 /* : Null out the mcb_ptr in the CAT (destinst will free it)
58      Adjust the sleeping queue (this capability might have been in it) */
59 
60    l_CAT[cap_index].mcb_ptr = NULL;
61 
62    for (catp = sleepq; catp != NULL; catp = catp -> next_cat)
63    {  if (catp -> next_cat == &(l_CAT[cap_index]))
64       {  catp -> next_cat = catp -> next_cat -> next_cat;
65          break;
66       }
67    }
68 
69 /* : Send the message to the remote */
70 
71    alter_cat.system = WSMULTICS;
72    alter_cat.major = WSMAJCAP;
73    alter_cat.minor = WS_DELETE_FROM_RAT;
74    alter_cat.source_system = mysystem;
75    alter_cat.source_major = WSMAJCAP;
76    alter_cat.rat_major = cap_index + MIN_CAPABILITY_NUMBER;
77 
78    code = send_i_mess (&alter_cat, sizeof(alter_cat) - 2,NULL,0);
79 
80 /* : Release the program memory */
81 
82    if (!(l_CAT[cap_index].flags & NULL_BIT))
83       free_cat_program (&l_CAT[cap_index]);
84 
85    return (code);
86 }