1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * gsdlconf.h -- system specific includes
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | *********************************************************************/
|
---|
25 |
|
---|
26 |
|
---|
27 | #ifndef GSDLCONF_H
|
---|
28 | #define GSDLCONF_H
|
---|
29 |
|
---|
30 | #if defined(__WIN32__)
|
---|
31 | #include "../win32cfg.h"
|
---|
32 | #else
|
---|
33 | #include "../config.h"
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | // Note: all macros used in the gsdl software (except the _H macros) should
|
---|
37 | // now start with GSDL_
|
---|
38 |
|
---|
39 | // GSDL_NEED_STRINGS_H should be defined if some string functions
|
---|
40 | // needed (like strcasecmp) are in strings.h
|
---|
41 | #if defined(__IBMCPP__)
|
---|
42 | # define GSDL_NEED_STRINGS_H
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | // GSDL_USE_IOS_H should be defined if the .h extension needs to
|
---|
46 | // be used for the io stream headers
|
---|
47 | #if defined(__GNUG__) || defined(__IBMCPP__)
|
---|
48 | # define GSDL_USE_IOS_H 1
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | // GSDL_USE_STL_H should be defined if the .h extension needs to
|
---|
52 | // be used for the stl header files
|
---|
53 | #if defined(__IBMCPP__)
|
---|
54 | # define GSDL_USE_STL_H 1
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | // GSDL_USE_ALGO_H should be defined if algo.h should be used
|
---|
58 | // instead of algorithm.h
|
---|
59 | #if defined(__IBMCPP__)
|
---|
60 | # define GSDL_USE_ALGO_H 1
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | // GSDL_NAMESPACE_BROKEN should be defined if namespaces should
|
---|
64 | // not be used
|
---|
65 | #if defined(__GNUG__) || defined(__IBMCPP__)
|
---|
66 | # define GSDL_NAMESPACE_BROKEN 1
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | // GSDL_USE_OBJECTSPACE should now be used instead of USE_OBJECTSPACE
|
---|
70 | #if defined(USE_OBJECTSPACE)
|
---|
71 | # define GSDL_USE_OBJECTSPACE
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | // GSDL_NEED_DESTROY_USHORT should be defined if the compiler needs
|
---|
75 | // a definition for void destroy(short unsigned int *)
|
---|
76 | #if defined(__IBMCPP__)
|
---|
77 | # define GSDL_NEED_DESTROY_USHORT
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | // mktemp
|
---|
81 |
|
---|
82 | #if !defined(__WIN32__) || defined(__GNUC__)
|
---|
83 | #include <unistd.h>
|
---|
84 | #define GSDL_MKTEMP(str) mktemp(str)
|
---|
85 | #else
|
---|
86 | #include <io.h>
|
---|
87 | #define GSDL_MKTEMP(str) _mktemp(str)
|
---|
88 | #endif
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 | // file locking
|
---|
93 |
|
---|
94 | #if defined(__WIN32__)
|
---|
95 |
|
---|
96 | #if !defined(LK_UNLOCK) && defined(LK_UNLCK)
|
---|
97 | #define LK_UNLOCK LK_UNLCK
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | #if defined (GSDL_USE_IOS_H)
|
---|
101 | #include <io.h>
|
---|
102 | #include <sys/locking.h>
|
---|
103 |
|
---|
104 | #if defined(__GNUC__)
|
---|
105 | #define GSDL_GET_FILEDESC(str) str.filedesc()
|
---|
106 | #else
|
---|
107 | #define GSDL_GET_FILEDESC(str) str.fd()
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | #define GSDL_UNLOCK_FILE(fd) _locking(fd, LK_UNLCK, 200)
|
---|
111 | #define GSDL_LOCK_FILE(fd) lock_val = _locking(fd, LK_NBLCK, 200)
|
---|
112 |
|
---|
113 | #else
|
---|
114 |
|
---|
115 | // when using <fstream> (i.e. VC++ 6.0) I can't work out how
|
---|
116 | // to return a filedesc. File locking won't currently work
|
---|
117 | // for those windows compilers requiring GSDL_USE_IOS_H to
|
---|
118 | // not be set -- Stefan.
|
---|
119 | #define GSDL_GET_FILEDESC(str) 1
|
---|
120 | #define GSDL_LOCK_FILE(fd) lock_val = 0
|
---|
121 | #define GSDL_UNLOCK_FILE(fd) 0
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | #else
|
---|
125 | #define GSDL_GET_FILEDESC(str) str.filedesc()
|
---|
126 |
|
---|
127 | #if GSDL_USE_FLOCK
|
---|
128 | #include <sys/lock.h>
|
---|
129 |
|
---|
130 | #ifndef LOCK_SH
|
---|
131 | #define LOCK_SH 1
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | #ifndef LOCK_EX
|
---|
135 | #define LOCK_EX 2
|
---|
136 | #endif
|
---|
137 |
|
---|
138 | #ifndef LOCK_NB
|
---|
139 | #define LOCK_NB 4
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | #ifndef LOCK_UN
|
---|
143 | #define LOCK_UN 8
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | #define GSDL_UNLOCK_FILE(fd) flock (fd, LOCK_UN)
|
---|
147 | #define GSDL_LOCK_FILE(fd) lock_val = flock (fd, LOCK_EX + LOCK_NB)
|
---|
148 |
|
---|
149 | #else
|
---|
150 | // use fcntl
|
---|
151 | #include <fcntl.h>
|
---|
152 | #define GSDL_UNLOCK_FILE(fd) \
|
---|
153 | { \
|
---|
154 | struct flock flock; \
|
---|
155 | flock.l_type = F_UNLCK; \
|
---|
156 | flock.l_whence = SEEK_SET; \
|
---|
157 | flock.l_start = flock.l_len = 0L; \
|
---|
158 | fcntl (fd, F_SETLK, &flock); \
|
---|
159 | }
|
---|
160 | #define GSDL_LOCK_FILE(fd) \
|
---|
161 | { \
|
---|
162 | struct flock flock; \
|
---|
163 | flock.l_type = F_WRLCK; \
|
---|
164 | flock.l_whence = SEEK_SET; \
|
---|
165 | flock.l_start = flock.l_len = 0L; \
|
---|
166 | lock_val = fcntl (fd, F_SETLK, &flock); \
|
---|
167 | }
|
---|
168 |
|
---|
169 | #endif
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #endif
|
---|