source: trunk/gsdl/lib/gsdlconf.h@ 3052

Last change on this file since 3052 was 3052, checked in by sjboddie, 22 years ago

* empty log message *

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
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#define GSDL_VERSION "x.xx"
31
32#if defined(__WIN32__) && !defined(__CYGWIN__)
33#include "../win32cfg.h"
34#else
35#include "../config.h"
36#endif
37
38// Note: all macros used in the gsdl software (except the _H macros) should
39// now start with GSDL_
40
41// GSDL_NEED_STRINGS_H should be defined if some string functions
42// needed (like strcasecmp) are in strings.h
43#if defined(__IBMCPP__)
44# define GSDL_NEED_STRINGS_H
45#endif
46
47// GSDL_USE_IOS_H should be defined if the .h extension needs to
48// be used for the io stream headers
49#if (defined(__GNUG__) && __GNUG__ + 0 < 3) || defined(__IBMCPP__)
50# define GSDL_USE_IOS_H 1
51#endif
52
53// GSDL_USE_STL_H should be defined if the .h extension needs to
54// be used for the stl header files
55#if defined(__IBMCPP__)
56# define GSDL_USE_STL_H 1
57#endif
58
59// GSDL_USE_ALGO_H should be defined if algo.h should be used
60// instead of algorithm.h
61#if defined(__IBMCPP__)
62# define GSDL_USE_ALGO_H 1
63#endif
64
65// GSDL_NAMESPACE_BROKEN should be defined if namespaces should
66// not be used
67#if (defined(__GNUG__) && __GNUG__ + 0 < 3) || defined(__IBMCPP__)
68# define GSDL_NAMESPACE_BROKEN 1
69#endif
70
71// GSDL_USE_OBJECTSPACE should now be used instead of USE_OBJECTSPACE
72#if defined(USE_OBJECTSPACE)
73# define GSDL_USE_OBJECTSPACE
74#endif
75
76// GSDL_NEED_DESTROY_USHORT should be defined if the compiler needs
77// a definition for void destroy(short unsigned int *)
78#if defined(__IBMCPP__)
79# define GSDL_NEED_DESTROY_USHORT
80#endif
81
82// mktemp
83
84#if !defined(__WIN32__) || defined(__GNUC__)
85#include <unistd.h>
86#define GSDL_MKTEMP(str) mktemp(str)
87#else
88#include <io.h>
89#define GSDL_MKTEMP(str) _mktemp(str)
90#endif
91
92
93
94// file locking
95
96#if defined(__WIN32__)
97
98#if !defined(LK_UNLOCK) && defined(LK_UNLCK)
99#define LK_UNLOCK LK_UNLCK
100#endif
101
102#if defined (GSDL_USE_IOS_H)
103#include <io.h>
104#include <sys/locking.h>
105
106#if defined(__GNUC__) /* not gcc >= 3 - this has GSDL_USE_IOS_H */
107#define GSDL_GET_FILEDESC(str) str.filedesc()
108#else
109#define GSDL_GET_FILEDESC(str) str.fd()
110#endif
111
112#define GSDL_UNLOCK_FILE(fd) _locking(fd, LK_UNLCK, 200)
113#define GSDL_LOCK_FILE(fd) lock_val = _locking(fd, LK_NBLCK, 200)
114
115#else /* ifdef GSDL_USE_IOS_H */
116
117// when using <fstream> (i.e. VC++ 6.0) I can't work out how
118// to return a filedesc. File locking won't currently work
119// for those windows compilers requiring GSDL_USE_IOS_H to
120// not be set -- Stefan.
121#define GSDL_GET_FILEDESC(str) 1
122#define GSDL_LOCK_FILE(fd) lock_val = 0
123#define GSDL_UNLOCK_FILE(fd) 0
124#endif
125
126#else /* not WIN32 */
127// darwin (Mac OS X) requires _STREAM_COMPAT to be set when
128// including <fstream.h> for filedesc() to be declared...
129#define GSDL_GET_FILEDESC(str) str.filedesc()
130
131#if GSDL_USE_FLOCK
132#include <sys/lock.h>
133
134#ifndef LOCK_SH
135#define LOCK_SH 1
136#endif
137
138#ifndef LOCK_EX
139#define LOCK_EX 2
140#endif
141
142#ifndef LOCK_NB
143#define LOCK_NB 4
144#endif
145
146#ifndef LOCK_UN
147#define LOCK_UN 8
148#endif
149
150#define GSDL_UNLOCK_FILE(fd) flock (fd, LOCK_UN)
151#define GSDL_LOCK_FILE(fd) lock_val = flock (fd, LOCK_EX + LOCK_NB)
152
153#else /* ! GSDL_USE_FLOCK */
154// use fcntl
155#include <fcntl.h>
156#define GSDL_UNLOCK_FILE(fd) \
157 { \
158 struct flock flock; \
159 flock.l_type = F_UNLCK; \
160 flock.l_whence = SEEK_SET; \
161 flock.l_start = flock.l_len = 0L; \
162 fcntl (fd, F_SETLK, &flock); \
163 }
164#define GSDL_LOCK_FILE(fd) \
165 { \
166 struct flock flock; \
167 flock.l_type = F_WRLCK; \
168 flock.l_whence = SEEK_SET; \
169 flock.l_start = flock.l_len = 0L; \
170 lock_val = fcntl (fd, F_SETLK, &flock); \
171 }
172
173#endif
174#endif
175
176#endif
Note: See TracBrowser for help on using the repository browser.