home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4294 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  49 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: chang.unx.sas.com!walker
  3. From: walker@chang.unx.sas.com (Doug Walker)
  4. Subject: Re: Get file handle from file descriptor? (SAS/C)
  5. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  6. Message-ID: <DnEsBw.o0@unx.sas.com>
  7. Date: Tue, 27 Feb 1996 00:35:56 GMT
  8. X-Nntp-Posting-Host: chang.unx.sas.com
  9. References: <67478443@porky.apl.s.shuttle.de>
  10. Organization: SAS Institute Inc.
  11.  
  12. In article <67478443@porky.apl.s.shuttle.de>,
  13. Andreas Voegele <andreas@porky.apl.s.shuttle.de> wrote:
  14. >How can I get the AmigaDOS file handle that is associated with a file
  15. >descriptor? I need to Examine() a file opened with open().
  16.  
  17.    __chkufb(fd)
  18.  
  19. or if you have a file opened with fopen()
  20.  
  21.    __chkufb(fileno(fp))
  22.  
  23. >BTW, why does open("plainfile", 0) return 0 when using SAS/C?
  24. >Aren't the descriptors 0, 1 and 2 reserved for standard input,
  25. >standard output and standard error?
  26.  
  27. 0, 1, and 2 are stdin, stdout and stderr if and only if you 
  28. actually USE stdin, stdout, or stderr.  If you do not use them 
  29. by name, only by number, we cannot tell that you want them and
  30. we don't allocate them for you.  
  31.  
  32. The easiest way to force us to include stdin, stdout, and stderr
  33. is to include the following declaration somewhere in your code
  34. (either as an extern or as a global):
  35.  
  36.    FILE *dummy = stdin;
  37.  
  38. This will generate a reference to stdin and pull in the 
  39. autoinitializers for stdin, stdout, and stderr.
  40.  
  41. -- 
  42.   *****                    / walker@unx.sas.com
  43.  *|_o_o|\\     Doug Walker<  BIX, Portal: djwalker
  44.  *|. o.| ||                \ AOL: weissblau
  45.   | o  |//     
  46.   ====== 
  47. Any opinions expressed are mine, not those of SAS Institute, Inc.
  48.  
  49.