home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / newgccstart.lha / source.lha / stubs / stdio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-14  |  659 b   |  35 lines

  1. #include <stdio.h>
  2. #include <dos/dosextens.h>
  3. #include <workbench/startup.h>
  4. #ifdef __GNUC__
  5. #include <inline/dos.h>
  6. #endif
  7.  
  8. extern struct WBStartup *_WBenchMsg;
  9. extern FILE *stdin,*stdout,*stderr;
  10.  
  11. void __initstdio(void)
  12. {
  13.   BPTR window;
  14.   if(_WBenchMsg!=NULL)
  15.   {
  16.     if((window=Open("CON:\\AUTO",MODE_NEWFILE))==NULL)
  17.       exit(RETURN_FAIL);
  18.     SelectInput(window);
  19.     SelectOutput(window);
  20.   }
  21.   stdin->file=Input();
  22.   stdout->file=Output();
  23.   if((stderr->file=((struct Process *)FindTask(NULL))->pr_CES)==NULL)
  24.     stderr->file=stdout->file;
  25. }
  26.  
  27. void __exitstdio(void)
  28. {
  29.   if(_WBenchMsg!=NULL)
  30.   {
  31.     Flush(stdin->file);
  32.     Close(stdin->file);
  33.   }
  34. }
  35.