home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / applications / xlispstat / src / src1.lzh / Amiga / Console.c < prev    next >
C/C++ Source or Header  |  1990-10-11  |  2KB  |  60 lines

  1. /* Console.c - Amiga specific console routines                         */
  2. /* Copyright (c) 1990 by J.K. Lindsey                                  */
  3. /* Additions to XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney     */
  4. /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
  5. /* You may give out copies of this software; for conditions see the    */
  6. /* file COPYING included with this distribution.                       */
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/intuition.h>
  10. #include "autil2.h"
  11.  
  12. OpenConsole(wrequest,rrequest,wport,rport,wname,rname,window)
  13. struct IOStdReq **wrequest,**rrequest;
  14. struct MsgPort **wport,**rport;
  15. char *wname,*rname;
  16. struct Window *window;{
  17.    if(!(*wport=(struct MsgPort *)CreatePort(wname,0)))return(1);
  18.    if(!(*wrequest=(struct IOStdReq *)CreateStdIO(*wport)))return(1);
  19.    if(!(*rport=(struct MsgPort *)CreatePort(rname,0)))return(1);
  20.    if(!(*rrequest=(struct IOStdReq *)CreateStdIO(*rport)))return(1);
  21.    (*wrequest)->io_Data=(APTR)window;
  22.    (*wrequest)->io_Length=sizeof(*window);
  23.    if(OpenDevice("console.device",0,(struct IORequest *)*wrequest,0)!=0)return(1);
  24.    (*rrequest)->io_Device=(*wrequest)->io_Device;
  25.    (*rrequest)->io_Unit=(*wrequest)->io_Unit;
  26.    return(0);}
  27.  
  28. void ConsoleWrite(request,string,length)
  29. struct IOStdReq *request;
  30. char *string;
  31. int length;{
  32.   request->io_Command=CMD_WRITE;
  33.   request->io_Data=(APTR)string;
  34.   request->io_Length=length;
  35.   DoIO((struct IORequest *)request);}
  36.  
  37. char ConsoleRead(struct MsgPort *rport,char *string){
  38.    register temp;
  39.    struct IOStdReq *readreq;
  40.    WaitPort(rport);
  41.    readreq=(struct IOStdReq *)GetMsg(rport);
  42.    temp=*string;
  43.    QueueRead(readreq,string);
  44.    return((char)temp);}
  45.  
  46. int ConsoleMayRead(struct MsgPort *rport,char *string){
  47.    register temp;
  48.    struct IOStdReq *readreq;
  49.    if(!(readreq=(struct IOStdReq *)GetMsg(rport)))return(-1);
  50.    temp=*string;
  51.    QueueRead(readreq,string);
  52.    return(temp);}
  53.  
  54. void QueueRead(request,buffer)
  55. struct IOStdReq *request;
  56. char *buffer;{
  57.    request->io_Command=CMD_READ;
  58.    request->io_Data=(APTR)buffer;
  59.    request->io_Length=1;
  60.    SendIO((struct IORequest *)request);}