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

Last change on this file since 880 was 880, checked in by djay, 6 years ago

Modify memory configuration option gesture. Now, in case you don't have setup memory option in the main section your main.cfg file then, the ZOO-Kernel will load everything in memory and will also store the file containing the input. In case you want the old mode, you have to set memory option to 'load' in your main.cfg file. Fix issue with loading R ZOO-Service located in a subdirectory. Support for XML Execute request containing TEXT_NODE when CDATA_NODE should be used.

  • 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 <xlocale.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 <xlocale.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
115#endif
116
117/**
118 * The lock structure used by the ZOO-Kernel to ensure atomicity of operations
119 *
120 */ 
121typedef struct zooLock{
122  struct flock lock; //!< The lock
123  FILE* lockfile;    //!< The pointer to the lock file
124  char* filename;    //!< The filename to lock
125} zooLock;
126
127static zooLock** zoo_file_locks=NULL;
128static int zoo_file_locks_cnt=0;
129
130#ifdef __cplusplus
131extern "C" {
132#endif
133
134 
135  ZOO_DLL_EXPORT char *readVSIFile(maps*,const char*);
136  ZOO_DLL_EXPORT int  setOutputValue( maps*, const char*, char*, size_t);
137  ZOO_DLL_EXPORT char* getInputValue( maps*,const char*,size_t*);
138
139  ZOO_DLL_EXPORT struct zooLock* lockFile(maps*,const char*,const char);
140  ZOO_DLL_EXPORT int unlockFile(maps*,struct zooLock*);
141
142  ZOO_DLL_EXPORT void unhandleStatus(maps*);
143  ZOO_DLL_EXPORT int _updateStatus(maps*);
144  ZOO_DLL_EXPORT char* _getStatus(maps*,char*);
145  ZOO_DLL_EXPORT char* _getStatusFile(maps*,char*);
146  ZOO_DLL_EXPORT char* getStatus(int);
147  ZOO_DLL_EXPORT char* getStatusId(maps*,char*);
148
149  ZOO_DLL_EXPORT int updateStatus( maps*,const int,const char*);
150  ZOO_DLL_EXPORT int removeShmLock(maps*, int);
151  /**
152   * Cross platform type used for Lock identifier
153   */
154#ifndef WIN32
155#define semid int
156#else
157#include <windows.h>
158#define semid HANDLE
159#endif
160  ZOO_DLL_EXPORT semid acquireLock(maps*);
161  ZOO_DLL_EXPORT semid getShmLockId(maps*,int);
162  ZOO_DLL_EXPORT int lockShm(semid);
163  ZOO_DLL_EXPORT int unlockShm(semid);
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif
Note: See TracBrowser for help on using the repository browser.

Search

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