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-11-11,Flegel), approve(87-07-13,MCR7580),
 11      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 12      Created.
 13                                                    END HISTORY COMMENTS */
 14 
 15 /* : PROCEDURE FUNCTION (external)
 16 
 17 Examine the application's message in MOWSE's address space to reset appropriate
 18 flags (stored in MOWSE data space).
 19 */
 20 
 21 #include <stdio.h>
 22 #include <dos.h>
 23 #include <wsmincap.h>
 24 #include <cat.h>
 25 #include <ws_msg.h>
 26 #include <ws_error.h>
 27 
 28 #define MESSAGE_HEADER_LENGTH 5
 29 
 30 extern char mysystem;
 31 extern local_cat l_cat[];
 32 extern remote_cat r_cat[];
 33 
 34 external_mowse (p_cat, p_message, p_message_len)
 35 
 36 local_cat *p_cat;                      /* Pointer to applciation cat entry */
 37 char *p_message;                       /* Message */
 38 int  p_message_len;                    /* Length of message */
 39 {
 40 struct input_msg *message;
 41 
 42    message = (struct input_msg *) p_message;
 43 
 44 /* : Switch to the appropriate handler for each minor */
 45 
 46    switch (message -> minor)
 47    {
 48       case TERMINATE_APPLICATION:
 49 
 50          return (extern_terminate (p_cat, message, p_message_len));
 51 
 52       case RESET_APPLICATION:
 53 
 54          return (extern_reset (p_cat, p_message, p_message_len));
 55 
 56       case SUSPEND_APPLICATION:
 57 
 58          return (extern_suspend (p_cat, p_message, p_message_len));
 59 
 60       case RESUME_APPLICATION:
 61 
 62          return (extern_resume (p_cat, p_message, p_message_len));
 63 
 64       default:
 65 
 66          return (wsexecap (p_cat, p_message, p_message_len));
 67    }
 68 }
 69 /*^L*/
 70 /* : PROCEDURE FUNCTION (extern_reset)
 71 
 72 Perform the operations necessary to handle resetting the application.
 73 */
 74 
 75 extern_reset (p_cat, p_message, p_message_len)
 76 
 77 local_cat *p_cat;
 78 struct input_msg *p_message;
 79 int p_message_len;
 80 {
 81 struct input_msg message;
 82 
 83 /* : Pass the message on to the application */
 84 
 85    wsexecap (p_cat, p_message, p_message_len);
 86 
 87 /* : Send the reset reply to the source only if it is from a remote system */
 88 
 89    if (p_message -> source_system == mysystem)
 90    {  p_cat -> flags &= ~RESET_BIT;
 91       return (0);
 92    }
 93 
 94    message.system        = WSMULTICS;
 95    message.major         = WSMAJCAP;
 96    message.minor         = RESET_REPLY;
 97    message.source_system = mysystem;
 98    message.source_major  = p_message -> major;
 99    message.msg_data[0]   = 0;
100 
101    return (send_i_mess (&message, MESSAGE_HEADER_LENGTH, NULL, 0));
102 }
103 /*^L*/
104 /* : PROCEDURE FUNCTION (extern_suspend)
105 
106 Perform the operations necessary to suspending the application.
107 */
108 
109 /* : NOTES
110 
111 POTENTIAL PROBLEM:  if a suspended application is refused messages then
112 a calling application which is not aware of this will not see an answer
113 until this is resumed.
114 */
115 
116 extern_suspend (p_cat, p_message, p_message_len)
117 
118 local_cat *p_cat;                      /* CAT entry of application */
119 struct input_msg *p_message;           /* Message */
120 int  p_message_len;                    /* Length of message */
121 {
122 int major_sender;
123 
124 /* : Set the suspend bit in the flags */
125 
126    p_cat -> flags |= SUSPENDED_BIT;
127 
128 /* : Send the message on to the application */
129 
130    return (wsexecap (p_cat, p_message, p_message_len));
131 }
132 /*^L*/
133 /* : PROCEDURE FUNCTION (extern_resuem)
134 
135 Perform the operations necessary to resuming the application.
136 */
137 
138 /* : NOTES
139 
140 POTENTIAL PROBLEM:  if a suspended application is refused messages then
141 a calling application which is not aware of this will not see an answer
142 until this is resumed.
143 */
144 
145 extern_resume (p_cat, p_message, p_message_len)
146 
147 local_cat *p_cat;                      /* CAT entry of application */
148 struct input_msg *p_message;           /* Message */
149 int  p_message_len;                    /* Length of message */
150 {
151 int major_sender;
152 
153 /* : Set the suspend bit in the flags */
154 
155    p_cat -> flags &= ~SUSPENDED_BIT;
156 
157 /* : Send the message on to the application */
158 
159    return (wsexecap (p_cat, p_message, p_message_len));
160 }
161 /*^L*/
162 /* : PROCEDURE FUNCTION (extern_terminate)
163 
164 Perform the operations necessary to terminating the application.
165 */
166 
167 extern_terminate (p_cat, p_message, p_message_len)
168 
169 local_cat *p_cat;                      /* CAT entry of application */
170 struct input_msg *p_message;           /* Message */
171 int  p_message_len;                    /* Length of message */
172 {
173 
174    p_cat -> flags |= MCB_TERMINATE;
175    p_cat -> flags &= ~MCB_SUSPEND;
176 
177    return (wsexecap (p_cat, p_message, p_message_len));
178 }