source: branches/prototype-v0/zoo-project/zoo-kernel/service_internal.h @ 933

Last change on this file since 933 was 933, checked in by knut, 3 years ago

Resolve certain string-related type conflicts, e.g., char* vs. const char* or char[N], that may cause errors in some build environments. Resolve a problem with the include order of fcgi_stdio.h (note: should verify that this harmonizes with resolution of same problem in trunk).

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 4.6 KB
Line 
1/*
2 * Author : Gérald FENOY
3 *
4 * Copyright (c) 2009-2013 GeoLabs SARL
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#ifndef ZOO_SERVICE_INTERNAL_H
26#define ZOO_SERVICE_INTERNAL_H 1
27
28#pragma once
29
30/**
31 * The default service url (overriden by serverAddress)
32 */
33#define DEFAULT_SERVICE_URL "http://www.zoo-project.org/"
34/**
35 * The time size
36 */
37#define TIME_SIZE 40
38
39#include <libintl.h>
40#include <locale.h>
41/**
42 * ZOO-Kernel internal messages translation function
43 */
44#define _(String) dgettext ("zoo-kernel",String)
45/**
46 * ZOO-Services messages translation function
47 */
48#define _ss(String) dgettext ("zoo-services",String)
49
50/**
51 * ZOO-Kernel was unable to create a lock
52 */
53#define ZOO_LOCK_CREATE_FAILED -4
54/**
55 * ZOO-Kernel was unable to acquire a lock
56 */
57#define ZOO_LOCK_ACQUIRE_FAILED -5
58/**
59 * ZOO-Kernel was unable to release a lock
60 */
61#define ZOO_LOCK_RELEASE_FAILED -6
62/**
63 * Number of time the ZOO-Kernel will try to acquire lock
64 */
65#define ZOO_LOCK_MAX_RETRY 180
66
67#include <sys/stat.h>
68#include <sys/types.h>
69#include "cgic.h"
70#ifndef WIN32
71#include <sys/ipc.h>
72#include <sys/shm.h>
73#include <sys/sem.h>
74#else
75#include <direct.h>
76#endif
77#include <stdio.h>
78#include <time.h>
79#include <ctype.h>
80#ifndef USE_RUBY
81#include <unistd.h>
82#endif
83#ifndef WIN32
84#include <locale.h>
85#endif
86
87#include <fcntl.h>
88 
89#include "service.h"
90
91#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
92
93#include <CoreServices/CoreServices.h>
94#include <SystemConfiguration/SystemConfiguration.h>
95
96#endif
97
98#ifdef WIN32
99// fcntl flock definitions
100#define F_SETLK  8   // Non-Blocking set or clear a lock
101#define F_SETLKW 9   // Blocking set or clear a lock
102#define F_GETLK 10
103#define F_RDLCK  1   // read lock
104#define F_WRLCK  2   // write lock
105#define F_UNLCK  3   // remove lock
106struct flock {
107    short l_type;   // F_RDLCK, F_WRLCK, or F_UNLCK
108    short l_whence; // flag to choose starting offset, must be SEEK_SET
109    long  l_start;  // relative offset, in bytes, must be 0
110    long  l_len;    // length, in bytes; 0 means lock to EOF, must be 0
111    short l_pid;    // unused (returned with the unsupported F_GETLK)
112    short l_xxx;    // reserved for future use
113};
114#endif
115
116/**
117 * The lock structure used by the ZOO-Kernel to ensure atomicity of operations
118 *
119 */ 
120typedef struct zooLock{
121  struct flock lock; //!< The lock
122  FILE* lockfile;    //!< The pointer to the lock file
123  char* filename;    //!< The filename to lock
124} zooLock;
125
126static zooLock** zoo_file_locks=NULL;
127static int zoo_file_locks_cnt=0;
128
129#ifdef __cplusplus
130extern "C" {
131#endif
132
133 
134  ZOO_DLL_EXPORT char *readVSIFile(maps*,const char*);
135  ZOO_DLL_EXPORT int  setOutputValue( maps*, const char*, char*, size_t);
136  ZOO_DLL_EXPORT char* getInputValue( maps*,const char*,size_t*);
137
138  ZOO_DLL_EXPORT struct zooLock* lockFile(maps*,const char*,const char);
139  ZOO_DLL_EXPORT int unlockFile(maps*,struct zooLock*);
140
141  ZOO_DLL_EXPORT void unhandleStatus(maps*);
142  ZOO_DLL_EXPORT int _updateStatus(maps*);
143  ZOO_DLL_EXPORT char* _getStatus(maps*,char*);
144  ZOO_DLL_EXPORT char* _getStatusFile(maps*,char*);
145  ZOO_DLL_EXPORT char* getStatus(int);
146  ZOO_DLL_EXPORT char* getStatusId(maps*,char*);
147
148  ZOO_DLL_EXPORT int updateStatus( maps*,const int,const char*);
149  ZOO_DLL_EXPORT int removeShmLock(maps*, int);
150  /**
151   * Cross platform type used for Lock identifier
152   */
153#ifndef WIN32
154#define semid int
155#else
156#include <windows.h>
157#define semid HANDLE
158#endif
159  ZOO_DLL_EXPORT semid acquireLock(maps*);
160  ZOO_DLL_EXPORT semid getShmLockId(maps*,int);
161  ZOO_DLL_EXPORT int lockShm(semid);
162  ZOO_DLL_EXPORT int unlockShm(semid);
163
164  ZOO_DLL_EXPORT char* file_exists(const char* dir, const char* name); 
165
166#ifdef __cplusplus
167}
168#endif
169
170#endif
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png