home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / uemacs / part4 / sys / vms / spawn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  2.2 KB  |  86 lines

  1. /*
  2.  * Name:    MicroEMACS
  3.  *        VAX/VMS spawn a DCL subprocess.
  4.  * Version:    29
  5.  * Last edit:    05-Feb-86
  6.  * By:        rex::conroy
  7.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  8.  */
  9. #include    "def.h"
  10.  
  11. #include    <ssdef.h>
  12. #include    <stsdef.h>
  13. #include    <descrip.h>
  14. #include    <iodef.h>
  15.  
  16. #define    EFN    0                /* Event flag.        */
  17.  
  18. extern    int    oldmode[3];            /* In "termio.c".    */
  19. extern    int    newmode[3];
  20. extern    short    iochan;
  21.  
  22. /*
  23.  * Create a subjob with a copy
  24.  * of the command intrepreter in it. When the
  25.  * command interpreter exits, mark the screen as
  26.  * garbage so that you do a full repaint. Bound
  27.  * to "C-C" and called from "C-Z". The message at
  28.  * the start in VMS puts out a newline. Under
  29.  * some (unknown) condition, you don't get one
  30.  * free when DCL starts up.
  31.  */
  32. spawncli(f, n, k)
  33. {
  34.     ttcolor(CTEXT);                /* Normal color.    */
  35.     ttwindow(0, nrow-1);            /* Full screen scroll.    */
  36.     ttmove(nrow-1, 0);            /* Last line.        */
  37.     eputs("[Starting DCL]");
  38.     ttputc('\r');
  39.     ttputc('\n');
  40.     ttflush();
  41.     sgarbf = TRUE;
  42.     return (sys(NULL));            /* NULL => DCL.        */
  43. }
  44.  
  45. /*
  46.  * Run a command. The "cmd" is a pointer
  47.  * to a command string, or NULL if you want to run
  48.  * a copy of DCL in the subjob (this is how the standard
  49.  * routine LIB$SPAWN works. You have to do wierd stuff
  50.  * with the terminal on the way in and the way out,
  51.  * because DCL does not want the channel to be
  52.  * in raw mode.
  53.  */
  54. sys(cmd)
  55. register char    *cmd;
  56. {
  57.     struct    dsc$descriptor    cdsc;
  58.     struct    dsc$descriptor    *cdscp;
  59.     long    status;
  60.     long    substatus;
  61.     long    iosb[2];
  62.  
  63.     status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  64.               oldmode, sizeof(oldmode), 0, 0, 0, 0);
  65.     if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  66.         return (FALSE);
  67.     cdscp = NULL;                /* Assume DCL.        */
  68.     if (cmd != NULL) {            /* Build descriptor.    */
  69.         cdsc.dsc$a_pointer = cmd;
  70.         cdsc.dsc$w_length  = strlen(cmd);
  71.         cdsc.dsc$b_dtype   = DSC$K_DTYPE_T;
  72.         cdsc.dsc$b_class   = DSC$K_CLASS_S;
  73.         cdscp = &cdsc;
  74.     }
  75.     status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0);
  76.     if (status != SS$_NORMAL)
  77.         substatus = status;
  78.     status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  79.               newmode, sizeof(newmode), 0, 0, 0, 0);
  80.     if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  81.         return (FALSE);
  82.     if ((substatus&STS$M_SUCCESS) == 0)    /* Command failed.    */
  83.         return (FALSE);
  84.     return (TRUE);
  85. }
  86.