8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / db / os / os_seek.c
blobae5272bd1c72ac5f70e3e2461a653f1740aaa01a
1 /*-
2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997, 1998
5 * Sleepycat Software. All rights reserved.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "@(#)os_seek.c 10.11 (Sleepycat) 10/12/98";
12 #endif /* not lint */
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #endif
21 #include "db_int.h"
22 #include "os_jump.h"
25 * __os_seek --
26 * Seek to a page/byte offset in the file.
28 * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int));
30 int
31 __os_seek(fd, pgsize, pageno, relative, isrewind, whence)
32 int fd;
33 size_t pgsize;
34 db_pgno_t pageno;
35 u_int32_t relative;
36 int isrewind, whence;
38 off_t offset;
39 int ret;
41 if (__db_jump.j_seek != NULL)
42 ret = __db_jump.j_seek(fd,
43 pgsize, pageno, relative, isrewind, whence);
44 else {
45 offset = (off_t)pgsize * pageno + relative;
46 if (isrewind)
47 offset = -offset;
49 ret = lseek(fd, offset, whence);
51 return (ret == -1 ? errno : 0);