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-13,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-11,Flegel), approve(87-07-13,MCR7580),
 14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 15      Moved buffer clearing to when the destination is
 16      called to be compatible with same message type from remote.
 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 RESET_SUSPEND to the remote
 20      to be generated.
 21                                                    END HISTORY COMMENTS */
 22 
 23 /* : PROCEDURE FUNCTION (i_reset)
 24 
 25 Send a reset or resume message to a background application from a
 26 foreground program.
 27 */
 28 
 29 #include <dos.h>
 30 #include <stdio.h>
 31 #include <ws.h>
 32 #include <ws_error.h>
 33 #include <ws_msg.h>
 34 #include <ws_dcls.h>
 35 #include <ws_fgb.h>
 36 #include <cat.h>
 37 #include <wsmincap.h>
 38 
 39 extern local_cat  l_CAT[];
 40 extern remote_cat r_CAT[];
 41 extern char mysystem;
 42 
 43 i_reset (p_msg, p_length)
 44 
 45 struct xcap_struc *p_msg;
 46 int p_length;
 47 {
 48 int cap_num;                           /* capability number of caller */
 49 char *flags;                           /* Address of flags to adjust */
 50 struct input_msg message;              /* Extrac message to be generated */
 51 int  code;
 52 
 53 /* : Verify that major capability number is valid */
 54 
 55    cap_num = p_msg -> major - MIN_CAPABILITY_NUMBER;
 56    if ((cap_num < 0) || (cap_num >= NUMBER_OF_CAT_ENTRIES))
 57       return(WSINVNUM);
 58 
 59    if (p_msg -> system == mysystem)
 60    {  if (l_CAT[cap_num].mcb_ptr  == NULL )
 61          return (WSINVNUM);
 62    }
 63    else
 64    {  if (r_CAT[cap_num].major_capability == 0)
 65          return (WSINVNUM);
 66    }
 67 
 68 /* : Set the appropriate reset bit for the destination capability */
 69 
 70    if (p_msg -> system == mysystem )
 71       flags = &(l_CAT[cap_num].flags);
 72    else
 73       flags = &(r_CAT[cap_num].flags);
 74 
 75    if (p_msg -> minor == RESET_APPLICATION)
 76       *flags |= RESET_BIT;
 77    else if (p_msg -> minor == RESUME_APPLICATION)
 78    {  if (*flags & SUSPENDED_BIT)
 79          *flags &= ~SUSPENDED_BIT;
 80       else
 81          return (WSNOSPND);
 82    }
 83 
 84 /* : Send the message */
 85 
 86    if (code = send_i_mess (p_msg, p_length, NULL, 0))
 87       return (code);
 88 
 89 /* : If it was a RESUME for a local capability, send a RESET_SUSPEND to
 90      the remote */
 91 
 92    if ((p_msg -> minor == RESUME_APPLICATION) && (p_msg -> system == mysystem))
 93    {  message.minor         = RESET_SUSPEND;
 94       message.major         = WSMAJCAP;
 95       message.system        = WSMULTICS;
 96       message.source_system = mysystem;
 97       message.source_major  = p_msg -> major;
 98       message.msg_data[0]   = 0;
 99       code = send_i_mess (&message, 5, NULL, 0);
100    }
101 
102    return (code);
103 }
104 ^Z