/* console.c */ /* Copyright © 1989 by Donald T. Meyer, Stormgate Software * All Rights Reserved */ #include "rxil.h" #include #include /* NAME * RxilOpenConsole * * SYNOPSIS * RxilOpenConsole( console, rexxmsg ); * * char *console; * struct RexxMsg *rexxmsg; * * FUNCTION * This will open an AmigaDOS stream as specified by the console * string. The filehandle is then placed in the rm_Stdin and * rm_Stdout fields of the RexxMsg. * * INPUTS * console = a string which defines the console stream to be opened. * This will normally be something like "CON:0/0/400/100/". * rexxmsg = pointer to the RexxMsg that the AmigaDOS file handles * are to be set into. * * RESULT * None * * SIDES * * HISTORY * 01-Aug-89 Creation. * * BUGS * * SEE ALSO * RxilCloseConsole() */ void RxilOpenConsole( char *console, struct RexxMsg *rexxmsg ) { struct FileHandle *fh; fh = (struct Filehandle *)Open( console, MODE_NEWFILE ); if( fh == NULL ) { return; } rexxmsg->rm_Stdin = (LONG)fh; rexxmsg->rm_Stdout = (LONG)fh; } /* NAME * RxilCloseConsole * * SYNOPSIS * RxilCloseConsole( rexxmsg ) * * struct RexxMsg *rexxmsg; * * FUNCTION * This will close the AmigaDOS file handles contained in the * rm_Stdin and rm_Stdout fields of the RexxMsg. If the handles * are the same, only one close is performed. * This clears the fields. If the fields are NULL, then no action * is taken. * This function supports the rm_Stdin and rm_Stdout being seperate * handles, even though it's complimentary function, * RxilOpenConsole() does not do this. * * INPUTS * rexxmsg = pointer to the RexxMsg whose IO streams are to be * closed. * * RESULT * None * * SIDES * * HISTORY * 01-Aug-89 Creation. * * BUGS * * SEE ALSO * RxilOpenConsole() */ void RxilCloseConsole( struct RexxMsg *rexxmsg ) { if( ( rexxmsg->rm_Stdin == NULL ) && ( rexxmsg->rm_Stdout == NULL ) ) { /* Nothing to close */ return; } /* There is something to close */ if( rexxmsg->rm_Stdin == rexxmsg->rm_Stdout ) { /* File handles are the same, only close once! */ rexxmsg->rm_Stdout = NULL; } /* Close file handles individualy */ if( rexxmsg->rm_Stdin ) { Close( rexxmsg->rm_Stdin ); rexxmsg->rm_Stdin = NULL; } if( rexxmsg->rm_Stdout ) { Close( rexxmsg->rm_Stdout ); rexxmsg->rm_Stdout = NULL; } }