From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  4-FEB-1991 22:51:09.89
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	PTD -- PHOTO-like utility using the FTDRIVER (part 2 of 2)

Received:  by crdgw1.ge.com (5.57/GE 1.80)
	 id AA23939; Mon, 4 Feb 91 22:21:41 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Mon,  4 FEB 91 12:23:06 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA28353; Mon, 4 Feb 91 12:05:55 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 4 Feb 91 19:11:07 GMT
From: peirce@gumby.wisc.edu  (Leonard Peirce)
Organization: Western Michigan University Academic Computing Services
Subject: PTD -- PHOTO-like utility using the FTDRIVER (part 2 of 2)
Message-Id: <1991Feb4.191107.13405@gumby.cc.wmich.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

-+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+
X      return(status);
X   `7D
X`7D
Xelse
X`7B
X   return(SS$_FORCEDEXIT);
X`7D
X
X`7D
X`0C
X/*
X**+
X** subprocess_exit - Set up exit status when subprocess exists
X**
X** Functional Description:
X**
X**`09This routine will be called when the subprocess has completed and
X** exited.  This routine will see if program is already exiting.  If not the
Vn it
X** will indicate that the program is exiting  and wake up the main program.
X**
X** Explicit Inputs:
X**
X**`09None
X**
X** Implicit Inputs:
X**
X**`09exiting`09`09-`09Flag indicating if program is finishing up
X**`09`09`09`09processing
X**`09exit_status`09-`09Contains the reason while logging is stopping
X**`09have_subprocess`09-`09Flag indicating if subprocess is still running
X**
X** Local Variables:
X**
X**`09None
X**
X** Outputs:
X**
X**       None
X**
X** NOTES:
X**
X**       None
X**
X**-
X*/
X
Xvoid subprocess_exit(void)
X`7B
X
X
Xif (!exiting)`20
X`7B
X   have_subprocess = FALSE;
X   exit_status = SS$_NORMAL;
X   exiting = TRUE;`20
X   SYS$WAKE (0, 0);
X`7D
X
X`7D
X`0C
X/*
X**+
X** xon_ast - Send XON character to terminal
X**
X** Functional Description:
X**
X**`09This routine is called when the pseudo terminal driver wants to signal
X** that it is ready to accept keyboard input. The routine will attempt to se
Vnd
X** an XON character to the terminal.   This is done on a best effort basis -
V if
X** it fails it will not be retried.  This is done by sending XON DC1 to the`
V20
X** terminal using SYS$QIO.
X**
X** Explicit Inputs:
X**
X**`09None
X**
X** Implicit Inputs:
X**
X**`09exiting`09`09-`09Flag indicating if program is finishing up
X**`09`09`09`09processing
X**`09tty_chan`09-`09VMS channel pointing to terminal
X**
X** Local Variables:
X**
X**`09dc1`09`09-`09ASCII XON character to be sent to terminal
X**
X** Outputs:
X**
X**       None
X**
X** NOTES:
X**
X**       None
X**
X**-
X*/
X
Xvoid xon_ast(void)
X`7B
X
Xchar`09`09`09dc1 = XON;
X
Xif (!exiting)
X`7B
X   SYS$QIO (0, tty_chan, IO$_WRITEVBLK, 0, 0, 0, &dc1, 1, 0, 0, 0, 0);
X`7D
X
X`7D
X`0C
X/*
X**+
X** bell_ast - Send BELL character to terminal
X**
X** Functional Description:
X**
X**`09This routine is called when the pseudo terminal driver wants to warn th
Ve
X** user to stop sending keyboard data.  The routine will attempt to ring the
X** terminals bell.  This is done on a best effort basis - if it fails it wil
Vl`20
X** not be retried.  This is done by send the BELL character to the terminal`
V20
X** using SYS$QIO.
X**
X** Explicit Inputs:
X**
X**`09None
X**
X** Implicit Inputs:
X**
X**`09exiting`09`09-`09Flag indicating if program is finishing up
X**`09`09`09`09processing
X**`09tty_chan`09-`09VMS channel pointing to terminal
X**
X** Local Variables:
X**
X**`09bell`09`09- `09ASCII bell character to be sent to terminal
X**
X** Outputs:
X**
X**       None
X**
X** NOTES:
X**
X**       None
X**
X**-
X*/
X
Xvoid bell_ast(void)
X`7B
X
Xchar`09`09`09bell = BELL;
X
Xif (!exiting)
X`7B
X   SYS$QIO (0, tty_chan, IO$_WRITEVBLK, 0, 0, 0, &bell, 1, 0, 0, 0, 0);
X`7D
X
X`7D
X`0C
X/*
X**+
X** xoff_ast - Send XOFF character to terminal
X**
X** Functional Description:
X**
X**`09This routine is called when the pseudo terminal driver wants to signal
X** that it wants to stop accepting  keyboard input. The routine will attempt
V to
X** send an XOFF character to the terminal.   This is done on a best effort`2
V0
X** basis - if it fails it will not be retried.  This is done by sending XOFF
X** <DC3> to the terminal using SYS$QIO.
X**
X** Explicit Inputs:
X**
X**`09None
X**
X** Implicit Inputs:
X**
X**`09exiting`09`09-`09Flag indicating if program is finishing up
X**`09`09`09`09processing
X**`09tty_chan`09-`09VMS channel pointing to terminal
X**
X** Local Variables:
X**
X**`09dc3`09`09-`09ASCII XOFF character to be sent to terminal
X**
X** Outputs:
X**
X**       None
X**
X** NOTES:
X**
X**       None
X**
X**-
X*/
X
Xvoid xoff_ast(void)
X`7B
X
Xchar`09`09`09dc3 = XOFF;
X
Xif (!exiting)
X`7B
X   SYS$QIO (0, tty_chan, IO$_WRITEVBLK, 0, 0, 0, &dc3, 1, 0, 0, 0, 0);
X`7D
X
X`7D
X`0C
X/*
X**+
X** set_line_ast - Mirror changes to FT changes onto TT
X**
X** Functional Description:
X**
X**  `09This routine is called when the pseudo terminal's device characterist
Vics
X** changed.  It will read the current pseudo terminal characteristics.  Thes
Ve
X** characteristics will be changed to have PASTHRU and NOECHO set.  They wil
Vl`20
X** then be applied to the user's input terminal.  Altering the terminal`20
X** characteristics will be done on a best effort basis - if it fails it will
V`20
X** not be retried.
X**
X** Explicit Inputs:
X**
X**`09None
X**
X** Implicit Inputs:
X**
X**`09exiting`09`09-`09Flag indicating if program is finishing up
X**`09`09`09`09processing
X**`09ft_chan`09`09-`09VMS channel pointing to control side of pseudo
X**`09`09`09`09terminal
X**`09tty_chan`09-`09VMS channel pointing to terminal
X**
X** Local Variables:
X**
X**`09device_chars`09-`09Structure used to hold to new pseudo temrinal
X**`09`09`09`09charateristics that need to be applied to the
X**`09`09`09`09actual terminal.  These characteristics will be
X**`09`09`09`09changed to have TT$M_NOECHO and TT2$M_PASTHRU
X**`09`09`09`09set.
X**`09fill`09`09-`09Word containing the <CR> and <LF> fill values
X**`09sense_iosb`09-`09I/O status block filled in upon completion of
X**`09`09`09`09sense mode $QIO
X**`09set_iosb`09-`09I/O status block filled in upon completions of
X**`09`09`09`09set mode $QIO
X**`09speed`09`09-`09Terminal transmit and receive speeds
X**`09status`09`09-`09Return status of set and sense mode $QIO
X**`09`09`09`09operations
X**
X** Outputs:
X**
X**       None
X**
X** NOTES:
X**
X**       None
X**
X**-
X*/
X
Xvoid set_line_ast(void)
X`7B
X
Xshort`09int`09`09fill;
Xshort`09int`09`09speed;
Xint`09`09`09status;
X
Xstruct`09dev_char`09device_chars;
Xstruct`09iosb`09`09set_iosb;
Xstruct`09sense_iosb `09sense_iosb;
X
Xif (!exiting)
X`7B
X   status = SYS$QIOW (0, ft_chan, IO$_SENSEMODE, &sense_iosb, 0, 0,
X`09`09      &device_chars, sizeof(device_chars), 0, 0, 0, 0);
X   if (status & SS$_NORMAL)`20
X   `7B
X      device_chars.basic_chars = device_chars.basic_chars `7C TT$M_NOECHO;`2
V0
X      device_chars.extended_chars = device_chars.extended_chars `7C TT2$M_PA
VSTHRU;
X      speed = sense_iosb.xmit_speed `7C (sense_iosb.rcv_speed << 8);
X      fill = sense_iosb.cr_fill `7C (sense_iosb.lf_fill << 8);
X      status = SYS$QIO (0, tty_chan, IO$_SETMODE, &set_iosb, 0, 0,`20
X`09`09`09&device_chars, sizeof(device_chars), speed, fill,
X`09`09`09sense_iosb.parity_flags,0);
X   `7D
X`7D
X
X`7D
$ CALL UNPACK FTDRIVER.C;1 1865036384
$ v=f$verify(v)
$ EXIT

