|
Revision 9989, 2.2 kB
(checked in by olly, 12 months ago)
|
|
backends/flint/flint_lock.cc,backends/flint/flint_lock.h,
bin/xapian-check.cc: Apply tweaked version of patch for OS/2 support
by Yuri Dario.
AUTHORS: Add Yuri Dario.
PLATFORMS: Mention OS/2.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #ifndef XAPIAN_INCLUDED_FLINT_LOCK_H |
|---|
| 22 | #define XAPIAN_INCLUDED_FLINT_LOCK_H |
|---|
| 23 | |
|---|
| 24 | #include <string> |
|---|
| 25 | |
|---|
| 26 | #if defined __CYGWIN__ || defined __WIN32__ |
|---|
| 27 | # include "safewindows.h" |
|---|
| 28 | #elif defined __EMX__ |
|---|
| 29 | # define INCL_DOS |
|---|
| 30 | # define INCL_DOSERRORS |
|---|
| 31 | # include <os2.h> |
|---|
| 32 | #else |
|---|
| 33 | # include <sys/types.h> |
|---|
| 34 | #endif |
|---|
| 35 | |
|---|
| 36 | class FlintLock { |
|---|
| 37 | std::string filename; |
|---|
| 38 | #if defined __CYGWIN__ || defined __WIN32__ |
|---|
| 39 | HANDLE hFile; |
|---|
| 40 | #elif defined __EMX__ |
|---|
| 41 | HFILE hFile; |
|---|
| 42 | #else |
|---|
| 43 | int fd; |
|---|
| 44 | pid_t pid; |
|---|
| 45 | #endif |
|---|
| 46 | |
|---|
| 47 | public: |
|---|
| 48 | typedef enum { |
|---|
| 49 | SUCCESS, |
|---|
| 50 | INUSE, |
|---|
| 51 | UNSUPPORTED, |
|---|
| 52 | UNKNOWN |
|---|
| 53 | } reason; |
|---|
| 54 | #if defined __CYGWIN__ || defined __WIN32__ |
|---|
| 55 | FlintLock(const std::string &filename_) |
|---|
| 56 | : filename(filename_), hFile(INVALID_HANDLE_VALUE) { } |
|---|
| 57 | operator bool() { return hFile != INVALID_HANDLE_VALUE; } |
|---|
| 58 | #elif defined __EMX__ |
|---|
| 59 | FlintLock(const std::string &filename_) |
|---|
| 60 | : filename(filename_), hFile(NULLHANDLE) { } |
|---|
| 61 | operator bool() { return hFile != NULLHANDLE; } |
|---|
| 62 | #else |
|---|
| 63 | FlintLock(const std::string &filename_) : filename(filename_), fd(-1) { } |
|---|
| 64 | operator bool() { return fd != -1; } |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | ~FlintLock() { release(); } |
|---|
| 68 | |
|---|
| 69 | reason lock(bool exclusive); |
|---|
| 70 | void release(); |
|---|
| 71 | }; |
|---|
| 72 | |
|---|
| 73 | #endif // XAPIAN_INCLUDED_FLINT_LOCK_H |
|---|