Re: c subroutine returning tty
Posted in 1995
John, For what its worth - here is my get_tty function. This works for me on Solaris 2.4 using Informix RDS 4.13.UD1 compiled with gcc-2.6.3. I have deliberately used Alan Popiel's format for describing this function. Many thanks Alan. As usual standard disclaimers apply - hope its of some use. Cheers, Peter ----------- begin get_tty.c -------------- /* function: get_tty - return associated tty * author: Peter K. Botcherby * date: 10 Apr 1995 * * get_tty() returns the associated tty for the current program * * usage: * CALL get_tty() RETURNING string * LET string = fgl_tty() * * CALL arguments: * none; no checking is done to ensure no input argument is passed * * RETURNING argument: * character string -- associated tty line */ int get_tty(int n) { /* Push return argument to the stack. */ retquote( ttyname(0) ); /* Name of associated tty */ return(1); /* Number of arguments pushed. */ } ------------ end fgl_tty.c --------------- ----------- begin get_tty.4gl -------------- main define ttyname char(15) let ttyname = get_tty() display "Associated tty is :", ttyname end main ------------ end get_tty.4gl --------------- +--------------------------------------------------------------------------+ | Peter K. Botcherby, Paediatric Research Unit, Guys Hospital, London, UK. | | p.botcherby@umds.ac.uk Fax +44 (0) 171 9554644 | +--------------------------------------------------------------------------+