home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / PIPE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  754 b   |  32 lines

  1. /* pipe.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <io.h>
  5. #include <errno.h>
  6. #include <fcntl.h>
  7.  
  8. int _fmode_bin;
  9.  
  10. int pipe (int *two_handles)
  11. {
  12.   if (__pipe (two_handles, 8192) != 0)
  13.     return (-1);
  14.   if (two_handles[0] >= _nfiles || two_handles[1] >= _nfiles)
  15.     {
  16.       __close (two_handles[0]);
  17.       __close (two_handles[1]);
  18.       errno = EMFILE;
  19.       return (-1);
  20.     }
  21.   _files[two_handles[0]] = O_RDONLY | F_NPIPE;
  22.   _files[two_handles[1]] = O_WRONLY | F_NPIPE;
  23.   if (_fmode_bin == 0)
  24.     {
  25.       _files[two_handles[0]] |= O_TEXT;
  26.       _files[two_handles[1]] |= O_TEXT;
  27.     }
  28.   _lookahead[two_handles[0]] = -1;
  29.   _lookahead[two_handles[1]] = -1;
  30.   return (0);
  31. }
  32.