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-07-11,Westcott), approve(87-07-13,MCR7580),
11      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
12      Created.
13   2) change(86-11-15,Flegel), approve(87-07-13,MCR7580),
14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
15      Removed removal of pending messages for
16      the application to be suspended.
17   3) change(86-11-21,Flegel), approve(87-07-13,MCR7580),
18      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
19      Added message for SET_SUSPEND to remote.
20                                                    END HISTORY COMMENTS */
21 
22 /* : PROCEDURE FUNCTION (i_suspnd)
23 
24 Perform the necessary action to suspend an application, setting its suspend
25 flag and forwarding a message to the remote system indicating the change.
26 */
27 
28 #include <dos.h>
29 #include <stdio.h>
30 #include <ws.h>
31 #include <ws_error.h>
32 #include <ws_msg.h>
33 #include <ws_dcls.h>
34 #include <ws_fgb.h>
35 #include <cat.h>
36 #include <wsmincap.h>
37 
38 #define HEADER_LENGTH    5             /* Length of message header */
39 
40 extern local_cat  l_CAT[];             /* Local CAT */
41 extern remote_cat r_CAT[];             /* Remote CAT */
42 extern char mysystem;
43 
44 i_suspnd (p_suspend_message)
45 
46 struct xcap_struc *p_suspend_message;
47 {
48 char *flags;                           /* Pointer to flags field in CAT */
49 int  cap_num;                          /* Capability index */
50 int  code;
51 struct input_msg message;              /* Message to remote to set bit */
52 
53 /* : Verify that major capability number is valid */
54 
55    cap_num = p_suspend_message -> major - MIN_CAPABILITY_NUMBER;
56    if ((cap_num < 0) || (cap_num > NUMBER_OF_CAT_ENTRIES))
57       return(WSINVNUM);
58 
59 /* : Verify that the application that the capability number refers to exists
60      and get the flag field */
61 
62    if (p_suspend_message -> system == mysystem)
63    {  if (l_CAT[cap_num].mcb_ptr  == NULL)
64          return (WSINVNUM);
65       flags = &(l_CAT[cap_num].flags);
66    }
67    else
68    {  if (r_CAT[cap_num].major_capability == 0)
69          return (WSINVNUM);
70       flags = &(r_CAT[cap_num].flags);
71    }
72 
73 /* : Verify that the application is not already suspended */
74 
75    if (*flags & SUSPENDED_BIT)
76       return (WSSUSPND);
77 
78 /* : Set and send suspend message to the remote MOWSE */
79 
80    *flags |= SUSPENDED_BIT;
81    if (code = send_i_mess (p_suspend_message, HEADER_LENGTH, NULL, 0))
82       return (code);
83 
84 /* : If the destination of the message is local, then send a message to the
85      remote indicating the application is suspended */
86 
87    if (p_suspend_message -> system == mysystem)
88    {  message.system        = WSMULTICS;
89       message.major         = WSMAJCAP;
90       message.minor         = SET_SUSPEND;
91       message.source_system = mysystem;
92       message.source_major  = p_suspend_message -> major;
93       message.msg_data[0]   = 0;
94       code = send_i_mess (&message, HEADER_LENGTH, NULL, 0);
95    }
96 
97    return (code);
98 }