Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / clib / seekdir.c
blob0d2338cf6787a07658db5edf095805498f23a6eb
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <dos/dos.h>
7 #include <proto/dos.h>
8 #include "__open.h"
10 /*****************************************************************************
12 NAME */
14 #include <dirent.h>
16 void seekdir(
18 /* SYNOPSIS */
19 DIR *dir,
20 off_t offset)
22 /* FUNCTION
24 INPUTS
26 RESULT
28 NOTES
30 EXAMPLE
32 BUGS
34 SEE ALSO
36 INTERNALS
38 ******************************************************************************/
40 int pos = offset;
41 fdesc *desc = __getfdesc(dir->fd);
42 if (!desc)
43 return;
45 if (!ExamineFH(desc->fcb->fh, dir->priv))
46 return;
48 if (offset > 1)
49 for
51 pos = 2;
52 (pos <= offset) && ExNext(desc->fcb->fh, dir->priv);
53 pos++
55 dir->pos = pos;