2 Copyright © 1995-2013, 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
76 /* Get the next pipe number */
81 snprintf(pipe_name
, sizeof(pipe_name
), "PIPE:cpipe-%08x-%d",
82 (unsigned long)getpid(), pipeno
);
83 pipe_name
[sizeof(pipe_name
)-1] = 0;
85 writer
= Open(pipe_name
, MODE_NEWFILE
);
88 reader
= Open(pipe_name
, MODE_OLDFILE
);
91 DeleteFile(pipe_name
);
99 errno
= __arosc_ioerr2errno(IoErr());
105 pipedes
[0] = __getfdslot(__getfirstfd(0));
108 rdesc
->fcb
->fh
= reader
;
109 rdesc
->fcb
->flags
= O_RDONLY
;
110 rdesc
->fcb
->opencount
= 1;
111 __setfdesc(pipedes
[0], rdesc
);
113 pipedes
[1] = __getfdslot(__getfirstfd(pipedes
[0]));
116 wdesc
->fcb
->fh
= writer
;
117 wdesc
->fcb
->flags
= O_WRONLY
;
118 wdesc
->fcb
->opencount
= 1;
119 __setfdesc(pipedes
[1], wdesc
);