home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / pipe.dos.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  2.3 KB  |  107 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.1
  10. date    92.05.14.19.55.40;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @old pipe(2) implementation using __pipe() with BPTRs
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/*
  26.  *  This file is part of ixemul.library for the Amiga.
  27.  *  Copyright (C) 1991, 1992  Markus M. Wild
  28.  *
  29.  *  This library is free software; you can redistribute it and/or
  30.  *  modify it under the terms of the GNU Library General Public
  31.  *  License as published by the Free Software Foundation; either
  32.  *  version 2 of the License, or (at your option) any later version.
  33.  *
  34.  *  This library is distributed in the hope that it will be useful,
  35.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  36.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  37.  *  Library General Public License for more details.
  38.  *
  39.  *  You should have received a copy of the GNU Library General Public
  40.  *  License along with this library; if not, write to the Free
  41.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  42.  *
  43.  *  $Id$
  44.  *
  45.  *  $Log$
  46.  */
  47.  
  48. #define KERNEL
  49. #include "ixemul.h"
  50.  
  51. extern int __read(), __write(), __ioctl(), __fselect(), __close();
  52.  
  53. int
  54. pipe (int pv[2])
  55. {
  56.   BPTR bpv[2];
  57.   struct file *f1, *f2;
  58.   int res, err, omask;
  59.   
  60.   omask = syscall (SYS_sigsetmask, ~0);
  61.   res = -1; 
  62.   err = EMFILE;
  63.   if (__pipe (bpv))
  64.     {
  65.       if (! falloc (&f1, pv))
  66.         {
  67.           if (! falloc (&f2, pv+1))
  68.             {
  69.               f1->f_fh = BTOCPTR (bpv[0]);
  70.           __init_std_packet (& f1->f_sp);
  71.           __fstat (f1);
  72.           f1->f_flags  = FREAD;
  73.           f1->f_type   = DTYPE_FILE;
  74.           f1->f_read   = __read;
  75.           f1->f_write  = 0;
  76.           f1->f_ioctl  = __ioctl;
  77.           f1->f_close  = __close;
  78.           f1->f_select = __fselect;
  79.  
  80.               f2->f_fh = BTOCPTR (bpv[1]);
  81.           __init_std_packet (& f2->f_sp);
  82.           __fstat (f2);
  83.           f2->f_flags  = FWRITE;
  84.           f2->f_type   = DTYPE_FILE;
  85.           f2->f_read   = 0;
  86.           f2->f_write  = __write;
  87.           f2->f_ioctl  = __ioctl;
  88.           f2->f_close  = __close;
  89.           f2->f_select = __fselect;
  90.  
  91.           res = err =0;
  92.           goto ret;
  93.         }
  94.       f1->f_count = 0;
  95.     }
  96.       __Close (bpv[0]);
  97.       __Close (bpv[1]);
  98.     }
  99.  
  100. ret:
  101.   syscall (SYS_sigsetmask, omask);
  102.  
  103.   errno = err;
  104.   return res;
  105. }
  106. @
  107.