2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id: /aros/dos/src/rom/dos/open.c 26802 2007-06-11T21:17:31.715385Z rob $
5 Desc: Creates a pair of filehandles connected to each other
8 #include <exec/memory.h>
9 #include <exec/lists.h>
10 #include <proto/exec.h>
11 #include <utility/tagitem.h>
12 #include <dos/dosextens.h>
13 #include <dos/filesystem.h>
14 #include <dos/stdio.h>
15 #include <proto/dos.h>
16 #include <proto/utility.h>
17 #include "dos_intern.h"
19 /*****************************************************************************
22 #include <proto/dos.h>
27 AROS_LHA(CONST_STRPTR
, name
, D1
),
28 AROS_LHA(BPTR
, *reader
, D2
),
29 AROS_LHA(BPTR
, *writer
, D3
),
32 struct DosLibrary
*, DOSBase
, 160, Dos
)
35 Creates a pair of file handles connected to each other
38 name - NULL-terminated name of the file
39 reader - Pointer to BPTR to store read handle in
40 writer - Pointer to BPTR to store write handle in
43 DOSTRUE on success, DOSFALSE on failure. IoErr() gives additional
44 information if the call failed.
56 *****************************************************************************/
60 struct FileHandle
*rfh
, *wfh
;
61 struct IOFileSys iofs
;
64 if ((rfh
= (struct FileHandle
*) AllocDosObject(DOS_FILEHANDLE
, NULL
)) == NULL
) {
67 if ((wfh
= (struct FileHandle
*) AllocDosObject(DOS_FILEHANDLE
, NULL
)) == NULL
) {
71 InitIOFS(&iofs
, FSA_PIPE
, DOSBase
);
72 err
= DoIOFS(&iofs
, NULL
, name
, DOSBase
);
75 FreeDosObject(DOS_FILEHANDLE
, rfh
);
76 FreeDosObject(DOS_FILEHANDLE
, wfh
);
80 rfh
->fh_Device
= iofs
.IOFS
.io_Device
;
81 rfh
->fh_Unit
= iofs
.IOFS
.io_Unit
;
83 wfh
->fh_Device
= iofs
.IOFS
.io_Device
;
84 wfh
->fh_Unit
= iofs
.io_Union
.io_PIPE
.io_Writer
;
86 if (IsInteractive(MKBADDR(rfh
)))
87 SetVBuf(MKBADDR(rfh
), NULL
, BUF_LINE
, -1);
89 if (IsInteractive(MKBADDR(wfh
)))
90 SetVBuf(MKBADDR(wfh
), NULL
, BUF_LINE
, -1);
92 *reader
= MKBADDR(rfh
);
93 *writer
= MKBADDR(wfh
);