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-08-12,Flegel), approve(87-07-13,MCR7580),
 11      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 12      Created.
 13   2) change(86-08-27,Flegel), approve(87-07-13,MCR7580),
 14      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 15      Modified error display.
 16   3) change(87-01-22,Flegel), approve(87-07-13,MCR7580),
 17      audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072):
 18      Added /F(orce) option.
 19                                                    END HISTORY COMMENTS */
 20 
 21 /* : PROCEDURE FUNCTION
 22 
 23 Destroy the MOWSE environment on the PC if Multics has detached (dtm).
 24 
 25 Arguments:
 26 
 27    /F - (Force) destruction whether or not Multics has detached.
 28 */
 29 
 30 #include <stdio.h>
 31 #include <ws_error.h>
 32 #include <ws_func.h>
 33 
 34 #define EXTRA_ARG   -1                 /* Unexpected argument */
 35 #define BAD_ARG     -2                 /* Invalid argument */
 36 
 37 #define TIME_OUT        1              /* Disconnect timed out */
 38 #define DISCONNECT_OUT  2              /* Disconnect verified */
 39 
 40 #define FORCE        0x01              /* Force requested */
 41 
 42 main (argc, argv)
 43 
 44 int  argc;                             /* Argument count */
 45 char *argv[];                          /* Argument strings */
 46 {
 47 int  code;                             /* Error code */
 48 int  i;
 49 char flag;                             /* Force flag */
 50 
 51 /* INITIALIZATION */
 52 
 53 /* : Parse through the arguments */
 54 
 55    for (i = 1, code = 0, flag = 0; (i < argc) && (!code); i++)
 56    {  if (argv[i][0] != '/')
 57          code = BAD_ARG;
 58       else switch (argv[i][1])
 59       {
 60          case 'F': case 'f':           /* FORCE */
 61             if (argv[i][2])
 62                code = BAD_ARG;
 63             else
 64                flag |= FORCE;
 65             break;
 66 
 67          default:                      /* ERROR */
 68             code = BAD_ARG;
 69             break;
 70       }
 71    }
 72 
 73 /* : Call mowse_interrupt to disconnect mowse */
 74 
 75    if (!code)
 76    {  printf ("EXITMOWS ...");
 77       while ((code = call_mowse_int (I$DISCONNECT, &flag, 1)) == WSDISPEN);
 78       if (code == DISCONNECT_OUT)
 79          code = WSACTIVE;
 80       else if (code == TIME_OUT)
 81       {  flag = FORCE;
 82          code = call_mowse_int (I$DISCONNECT, &flag, 1);
 83       }
 84    }
 85 
 86 
 87 /* : Parse the error codes */
 88 
 89    switch (code)
 90    {
 91       case BAD_ARG:
 92          printf ("exitmows: bad argument %s.", argv[i-1]);
 93          break;
 94 
 95       case EXTRA_ARG:
 96          printf ("exitmows: unexpected option %s.", argv[i-1]);
 97          break;
 98 
 99       case 0:
100          printf (" MOWSE terminated.");
101          break;
102 
103       case WSACTIVE:
104          printf (" MOWSE is not detached on Multics.");
105          break;
106 
107       case WSNOTACT:
108          printf (" MOWSE is not resident.");
109          break;
110 
111       default:
112          printf (" error %d.", code);
113          break;
114    }
115 }
116 ^Z