2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Waits for a character to arrive at a filehandle.
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 /*****************************************************************************
14 #include <proto/dos.h>
15 #include <exec/types.h>
17 AROS_LH2(BOOL
, WaitForChar
,
20 AROS_LHA(BPTR
, file
, D1
),
21 AROS_LHA(LONG
, timeout
, D2
),
24 struct DosLibrary
*, DOSBase
, 34, Dos
)
27 Wait for a character to arrive at a filehandle. The filehandle
28 can be either a console handle, or a regular file. For a regular
29 file most filesystems will return a character immediately, but
30 sometimes (for example a network handler) the character may not
34 file - File to wait for a character on.
35 timeout - Number of microseconds to wait for the character
36 to arrive. A value of 0 says to wait indefinately.
38 != 0 if a character arrived before the timeout expired
39 == 0 if no character arrived
42 Many filesystems do not implement this function.
52 *****************************************************************************/
56 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(file
);
58 /* Get pointer to I/O request. Use stackspace for now. */
59 struct IOFileSys iofs
;
61 /* NULL-pointers are okay. */
65 /* Prepare I/O request. */
66 InitIOFS(&iofs
, FSA_WAIT_CHAR
, DOSBase
);
68 iofs
.IOFS
.io_Device
= fh
->fh_Device
;
69 iofs
.IOFS
.io_Unit
= fh
->fh_Unit
;
71 iofs
.io_Union
.io_WAIT_CHAR
.io_Timeout
= timeout
;
73 /* Send the request. */
76 SetIoErr(iofs
.io_DosError
);
78 if(iofs
.io_DosError
== 0)
79 return iofs
.io_Union
.io_WAIT_CHAR
.io_Success
;