Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / waitforchar.c
blobf1048adbcb33f8c82431d3f9633c7b656394ebdc
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Waits for a character to arrive at a filehandle.
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/dos.h>
15 #include <exec/types.h>
17 AROS_LH2(BOOL, WaitForChar,
19 /* SYNOPSIS */
20 AROS_LHA(BPTR, file, D1),
21 AROS_LHA(LONG, timeout, D2),
23 /* LOCATION */
24 struct DosLibrary *, DOSBase, 34, Dos)
26 /* FUNCTION
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
31 have arrived.
33 INPUTS
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.
37 RESULT
38 != 0 if a character arrived before the timeout expired
39 == 0 if no character arrived
41 NOTES
42 Many filesystems do not implement this function.
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
57 struct FileHandle *fh = (struct FileHandle *)BADDR(file);
59 /* Get pointer to I/O request. Use stackspace for now. */
60 struct IOFileSys iofs;
62 /* NULL-pointers are okay. */
63 if(file == NULL)
64 return 0;
66 /* Prepare I/O request. */
67 InitIOFS(&iofs, FSA_WAIT_CHAR, DOSBase);
69 iofs.IOFS.io_Device = fh->fh_Device;
70 iofs.IOFS.io_Unit = fh->fh_Unit;
72 iofs.io_Union.io_WAIT_CHAR.io_Timeout = timeout;
74 /* Send the request. */
75 DosDoIO(&iofs.IOFS);
77 SetIoErr(iofs.io_DosError);
79 if(iofs.io_DosError == 0)
80 return iofs.io_Union.io_WAIT_CHAR.io_Success;
81 else
82 return DOSFALSE;
84 AROS_LIBFUNC_EXIT
85 } /* WaitForChar */