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

Last change on this file since 878 was 609, checked in by sjboddie, 25 years ago

tidied up file locking stuff

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 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 * $Id: gsdlconf.h 609 1999-09-21 11:36:42Z sjboddie $
25 *
26 *********************************************************************/
27
28
29#ifndef GSDLCONF_H
30#define GSDLCONF_H
31
32
33// Note: all macros used in the gsdl software (except the _H macros) should
34// now start with GSDL_
35
36// GSDL_NEED_STRINGS_H should be defined if some string functions
37// needed (like strcasecmp) are in strings.h
38#if defined(__IBMCPP__)
39# define GSDL_NEED_STRINGS_H
40#endif
41
42// GSDL_USE_IOS_H should be defined if the .h extension needs to
43// be used for the io stream headers
44#if defined(__GNUG__) || defined(__IBMCPP__)
45# define GSDL_USE_IOS_H 1
46#endif
47
48// GSDL_USE_STL_H should be defined if the .h extension needs to
49// be used for the stl header files
50#if defined(__IBMCPP__)
51# define GSDL_USE_STL_H 1
52#endif
53
54// GSDL_USE_ALGO_H should be defined if algo.h should be used
55// instead of algorithm.h
56#if defined(__IBMCPP__)
57# define GSDL_USE_ALGO_H 1
58#endif
59
60// GSDL_NAMESPACE_BROKEN should be defined if namespaces should
61// not be used
62#if defined(__GNUG__) || defined(__IBMCPP__)
63# define GSDL_NAMESPACE_BROKEN 1
64#endif
65
66// GSDL_USE_OBJECTSPACE should now be used instead of USE_OBJECTSPACE
67#if defined(USE_OBJECTSPACE)
68# define GSDL_USE_OBJECTSPACE
69#endif
70
71// GSDL_NEED_DESTROY_USHORT should be defined if the compiler needs
72// a definition for void destroy(short unsigned int *)
73#if defined(__IBMCPP__)
74# define GSDL_NEED_DESTROY_USHORT
75#endif
76
77
78// file locking
79
80#if defined(__WIN32__)
81#include <io.h>
82#include <sys/locking.h>
83#define GSDL_GET_FILEDESC(str) str.fd()
84#define GSDL_UNLOCK_FILE(fd) _locking(fd, LK_UNLCK, 200)
85#define GSDL_LOCK_FILE(fd) lock_val = _locking(fd, LK_NBLCK, 200)
86
87#else
88#define GSDL_GET_FILEDESC(str) str.filedesc()
89
90#if GSDL_USE_FLOCK
91#include <sys/lock.h>
92
93#ifndef LOCK_SH
94#define LOCK_SH 1
95#endif
96
97#ifndef LOCK_EX
98#define LOCK_EX 2
99#endif
100
101#ifndef LOCK_NB
102#define LOCK_NB 4
103#endif
104
105#ifndef LOCK_UN
106#define LOCK_UN 8
107#endif
108
109#define GSDL_UNLOCK_FILE(fd) flock (fd, LOCK_UN)
110#define GSDL_LOCK_FILE(fd) lock_val = flock (fd, LOCK_EX + LOCK_NB)
111
112#else
113// use fcntl
114#include <fcntl.h>
115#define GSDL_UNLOCK_FILE(fd) \
116 { \
117 struct flock flock; \
118 flock.l_type = F_UNLCK; \
119 flock.l_whence = SEEK_SET; \
120 flock.l_start = flock.l_len = 0L; \
121 fcntl (fd, F_SETLK, &flock); \
122 }
123#define GSDL_LOCK_FILE(fd) \
124 { \
125 struct flock flock; \
126 flock.l_type = F_WRLCK; \
127 flock.l_whence = SEEK_SET; \
128 flock.l_start = flock.l_len = 0L; \
129 lock_val = fcntl (fd, F_SETLK, &flock); \
130 }
131
132#endif
133#endif
134
135#endif
Note: See TracBrowser for help on using the repository browser.