~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/os/os_seek.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1997-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
 
8
 
#include "db_config.h"
9
 
 
10
 
#ifndef lint
11
 
static const char revid[] = "$Id$";
12
 
#endif /* not lint */
13
 
 
14
 
#ifndef NO_SYSTEM_INCLUDES
15
 
#include <sys/types.h>
16
 
 
17
 
#include <stdlib.h>
18
 
#include <string.h>
19
 
#include <unistd.h>
20
 
#endif
21
 
 
22
 
#include "db_int.h"
23
 
 
24
 
/*
25
 
 * __os_seek --
26
 
 *      Seek to a page/byte offset in the file.
27
 
 *
28
 
 * PUBLIC: int __os_seek __P((DB_ENV *,
29
 
 * PUBLIC:      DB_FH *, size_t, db_pgno_t, u_int32_t, int, DB_OS_SEEK));
30
 
 */
31
 
int
32
 
__os_seek(dbenv, fhp, pgsize, pageno, relative, isrewind, db_whence)
33
 
        DB_ENV *dbenv;
34
 
        DB_FH *fhp;
35
 
        size_t pgsize;
36
 
        db_pgno_t pageno;
37
 
        u_int32_t relative;
38
 
        int isrewind;
39
 
        DB_OS_SEEK db_whence;
40
 
{
41
 
        off_t offset;
42
 
        int ret, whence;
43
 
 
44
 
        switch (db_whence) {
45
 
        case DB_OS_SEEK_CUR:
46
 
                whence = SEEK_CUR;
47
 
                break;
48
 
        case DB_OS_SEEK_END:
49
 
                whence = SEEK_END;
50
 
                break;
51
 
        case DB_OS_SEEK_SET:
52
 
                whence = SEEK_SET;
53
 
                break;
54
 
        default:
55
 
                return (EINVAL);
56
 
        }
57
 
 
58
 
        if (DB_GLOBAL(j_seek) != NULL)
59
 
                ret = DB_GLOBAL(j_seek)(fhp->fd,
60
 
                    pgsize, pageno, relative, isrewind, whence);
61
 
        else {
62
 
                offset = (off_t)pgsize * pageno + relative;
63
 
                if (isrewind)
64
 
                        offset = -offset;
65
 
                do {
66
 
                        ret = lseek(fhp->fd, offset, whence) == -1 ?
67
 
                            __os_get_errno() : 0;
68
 
                } while (ret == EINTR);
69
 
        }
70
 
 
71
 
        if (ret == 0) {
72
 
                fhp->pgsize = pgsize;
73
 
                fhp->pgno = pageno;
74
 
                fhp->offset = relative;
75
 
        } else
76
 
                __db_err(dbenv, "seek: %lu %d %d: %s",
77
 
                    (u_long)pgsize * pageno + relative,
78
 
                    isrewind, db_whence, strerror(ret));
79
 
 
80
 
        return (ret);
81
 
}