home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / pipes ƒ / pipes.doc < prev   
Encoding:
Text File  |  1997-01-03  |  1.2 KB  |  20 lines  |  [TEXT/R*ch]

  1. Pipes for the MacOS
  2. -------------------
  3.  
  4. Brian Connors
  5. 30 December 1996
  6.  
  7. This is a very, very simple implementation of pipes for the Mac. Terribly simple. It provides a simple layer over the fopen and fclose functions in stdio.h that allows you to write pipe-dependent code; it may or may not be of any use to you and in any case was written as a quick and dirty hack. I know it compiles under CW9; other than that, I can guarantee nothing.
  8.  
  9. It consists of two functions: 
  10.  
  11. FILE popen(const char *fn, const char *mode);
  12.  
  13. Opens a pipe by the name of fn and returns a file pointer to it. It is read and written with fprintf and fscanf just like any other file; this behavior is probably different from the UNIX implementation (which I haven't really used), but I wasn't sure whether or not to use freopen() (I didn't; if anyone wants to use this code and feels I should have done it differently, tell me how). 
  14.  
  15. int pclose(FILE *pf);
  16.  
  17. Passes in the file pointer referring to the pipe you wish to close and closes the file associated with it. 
  18.  
  19. ©1997 Duchesne Brick and Block. You may use this for any purpose, as long as you arrange to provide DB&B with either a copy of or equivalent monetary compensation to the product in which you use this code. 
  20.