Detabbed
[AROS.git] / rom / dos / lockrecords.c
blobba679b3f8013a7f4e2e8ccc6761b106ccbaa96b8
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
8 #include "dos_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <dos/record.h>
14 #include <proto/dos.h>
16 AROS_LH2(BOOL, LockRecords,
18 /* SYNOPSIS */
19 AROS_LHA(struct RecordLock *, recArray, D1),
20 AROS_LHA(ULONG , timeout, D2),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 46, Dos)
25 /* FUNCTION
27 Lock several records at the same time. The timeout specified is applied
28 to each lock to attempt. The array of RecordLock:s is terminated with
29 an entry where rec_FH is equal to NULL.
31 INPUTS
33 recArray -- array of records to lock
34 timeout -- maximum number of ticks to wait for a lock to be ready
36 RESULT
38 Success/failure indication. In case of a success, all the record locks
39 are locked. In case of failure, no record locks are locked.
41 NOTES
43 A set of records should always be locked in the same order so as to
44 reduce possiblities of deadlock.
46 EXAMPLE
48 BUGS
50 SEE ALSO
52 UnLockRecords()
54 INTERNALS
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct RecordLock *rLock = recArray;
62 while (BADDR(recArray->rec_FH) != NULL)
64 BPTR temp;
66 if (!LockRecord(recArray->rec_FH, recArray->rec_Offset,
67 recArray->rec_Length, recArray->rec_Mode, timeout))
69 temp = recArray->rec_FH;
70 UnLockRecords(rLock);
71 recArray->rec_FH = temp;
73 return DOSFALSE;
76 recArray++;
79 return DOSTRUE;
81 AROS_LIBFUNC_EXIT
82 } /* LockRecords */