home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d4xx / d430 / smartfields.lha / SmartFields / Functions / console_open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-11  |  1.2 KB  |  41 lines

  1. /***************************************
  2. *  CONSOLE OPEN v1.03
  3. *  © Copyright 1988 Timm Martin
  4. *  All Rights Reserved
  5. ****************************************/
  6.  
  7. #include <exec/io.h>
  8. #include <exec/ports.h>
  9. #include <intuition/intuition.h>
  10. #include <console/console.h>
  11. #include <console/functions.h>
  12.  
  13. int console_open( window, header, buffer )
  14.   struct Window *window;
  15.   struct ConsoleHeader *header;
  16.   UBYTE  *buffer;
  17. {
  18.   struct MsgPort *CreatePort();    /* exec.library */
  19.   struct IOStdReq *CreateStdIO();  /* exec.library */
  20.  
  21.   header->Window   = window;
  22.   header->Buffer   = buffer;
  23.   header->TypeMode = DEFAULT_TYPE_MODE;
  24.  
  25.   if (!(header->WritePort = CreatePort( "console.write", 0L )))
  26.     return (CONSOLE_EXIT_WPORT);
  27.   if (!(header->WriteReq = CreateStdIO( header->WritePort )))
  28.     return (CONSOLE_EXIT_WREQ);
  29.   if (!(header->ReadPort = CreatePort( "console.read", 0L )))
  30.     return (CONSOLE_EXIT_RPORT);
  31.   if (!(header->ReadReq = CreateStdIO( header->ReadPort )))
  32.     return (CONSOLE_EXIT_RREQ);
  33.   header->ConsoleError = con_open( window, header->WriteReq, header->ReadReq );
  34.   if (header->ConsoleError)
  35.     return (CONSOLE_EXIT_CONSOLE);
  36.  
  37.   con_read( header->ReadReq, header->Buffer );  /* "prime" the buffer */
  38.  
  39.   return (CONSOLE_OPEN_OK);
  40. }
  41.