| D O S _ C H E C K D E V I C E ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - DOS_#?
----------------------------------------------------------------------------
NAME
dos_checkdevice() - Allows to check for DOS entry on
the list.
SYNOPSIS
dol = dos_checkdevice(name, type);
struct DosList *dos_checkdevice(UBYTE *, LONG);
FUNCTION
This func. is useful when there is a need to query
the device after it was created in a standalone proc.
INPUTS
name - Standard DOS device name lower or upper case,
with or without the colon(':').
type - Type of entry(DLT_DEVICE, DLT_VOLUME, ...).
Ranges can be formed using upper 16 bits:
'type = (DLT_NONBINDING << 16) | DLT_DEVICE;'
where the range starts at DLT_DEVICE and ends
at DLT_NONBINDING.
RETURNS
Returns DosList pointer or NULL if the device was not
found.
BASES
SysBase, DOSBase
NOTES
You should really brace this function with 'Forbid()'
/ 'Permit()' pair! Functions such as 'LockDosList()'
/ 'UnLockDosList()' can also be used, but only in a
process!
It is best to combine this function in a delay sliced
and time framed loop.
This func. can be called safely from under the task!
SEE ALSO
dos_makedevice(), dos_killdevice()
EXAMPLE
...
#define ONESECOND 50
#define LOOPDELAY 5
#define TIMEOUT \
(ONESECOND / \
LOOPDELAY)
/*
* Argument 'timeout' expresses values in seconds or
* will trigger one time check if 0 is to be passed.
*/
struct DosList *checkdev(UBYTE *name, LONG timeout)
{
struct DosList *dol;
timeout = ((timeout > 0) ?
(timeout * TIMEOUT) : 1);
Forbid();
while (((dol =
dos_checkdevice(name, DLT_DEVICE)) == NULL) &&
(--timeout))
{
/*
* This will break forbidden state temporarily!
*/
Delay(LOOPDELAY);
}
Permit();
return dol;
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |