home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 206.lha / Flist_v1.2 / Sources / errout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-28  |  1.3 KB  |  42 lines

  1. /* 
  2.     This module was created because of the need for error
  3.     output when flist is 'run' or 'runback'ed.
  4.     Because stderr is no a longer valid DOS filehandle, If flist
  5.     detects an error and try's to output an error message to stderr,
  6.     and we are running as a background task, the ouput to stderr will
  7.     crash the machine. This is not user friendly. My solution is to
  8.     open my own filehandle to stderr as a file in RAM:. While this 
  9.     may not be the best solution, it will work in all cases that the
  10.     ramdrive exists. If the ram: device is not available, then the output
  11.     goes to NIL:.
  12.     
  13.     Drawbacks:
  14.         You can never tell when you are run in the background, so you
  15.         have to ALWAYS send output to this file.
  16.  
  17.     Written completely - I stole no code before it's time, by
  18.         Stephen (Raz) Berry 1/2/89
  19.  
  20. */
  21.  
  22. #include <stdio.h>
  23.  
  24. Redirecterror(stderror)
  25. struct FileHandle *stderror;
  26. {
  27.     struct FileHandle *newerror,*newout,*newin;
  28.     
  29.     newerror = freopen("RAM:flist.errors","a",stderr);
  30.     newin = freopen("CON:0/0/1/1/DummyIO","a",stdin);
  31.     newout = freopen("RAM:flist.out","a",stdout);
  32.     
  33.     if (newerror == NULL)
  34.         newerror = freopen("NIL:","a",stderr);
  35.  
  36.     if (newin == NULL)
  37.         newin = freopen("NIL:","a",stdin);
  38.  
  39.     if (newout == NULL)
  40.         newout = freopen("NIL:","a",stdout);
  41. }
  42.