2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
12 #include <stdio.h> /* For snprintf */
17 /*****************************************************************************
43 ******************************************************************************/
46 fcb
*rfcb
= NULL
, *wfcb
= NULL
;
47 fdesc
*rdesc
= NULL
, *wdesc
= NULL
;
48 /* PIPE:cpipe-%08x-%d, where %x is the getpid(), %d is the nth pipe */
49 char pipe_name
[5 + 6 + 8 + 1 + 16 + 1];
50 static int pipeno
= 0;
60 (rfcb
= AllocVec(sizeof(fcb
), MEMF_ANY
| MEMF_CLEAR
)) == NULL
||
61 (rdesc
= __alloc_fdesc()) == NULL
||
62 (wfcb
= AllocVec(sizeof(fcb
), MEMF_ANY
| MEMF_CLEAR
)) == NULL
||
63 (wdesc
= __alloc_fdesc()) == NULL
78 /* Get the next pipe number */
83 snprintf(pipe_name
, sizeof(pipe_name
), "PIPE:cpipe-%08x-%d",
84 (unsigned long)getpid(), pipeno
);
85 pipe_name
[sizeof(pipe_name
)-1] = 0;
87 writer
= Open(pipe_name
, MODE_NEWFILE
);
90 reader
= Open(pipe_name
, MODE_OLDFILE
);
93 DeleteFile(pipe_name
);
101 errno
= __arosc_ioerr2errno(IoErr());
107 pipedes
[0] = __getfdslot(__getfirstfd(0));
110 rdesc
->fcb
->fh
= reader
;
111 rdesc
->fcb
->flags
= O_RDONLY
;
112 rdesc
->fcb
->opencount
= 1;
113 __setfdesc(pipedes
[0], rdesc
);
115 pipedes
[1] = __getfdslot(__getfirstfd(pipedes
[0]));
118 wdesc
->fcb
->fh
= writer
;
119 wdesc
->fcb
->flags
= O_WRONLY
;
120 wdesc
->fcb
->opencount
= 1;
121 __setfdesc(pipedes
[1], wdesc
);