ZOO-Project
service_internal.h
Go to the documentation of this file.
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 
33 #define DEFAULT_SERVICE_URL "http://www.zoo-project.org/"
34 
37 #define TIME_SIZE 40
38 
39 #include <libintl.h>
40 #include <locale.h>
44 #define _(String) dgettext ("zoo-kernel",String)
45 
48 #define _ss(String) dgettext ("zoo-services",String)
49 
53 #define ZOO_LOCK_CREATE_FAILED -4
54 
57 #define ZOO_LOCK_ACQUIRE_FAILED -5
58 
61 #define ZOO_LOCK_RELEASE_FAILED -6
62 
65 #define ZOO_LOCK_MAX_RETRY 10
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 "service.h"
88 
89 #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
90 
91 #include <CoreServices/CoreServices.h>
92 #include <SystemConfiguration/SystemConfiguration.h>
93 
94 #endif
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100  ZOO_DLL_EXPORT char *readVSIFile(maps*,const char*);
101  ZOO_DLL_EXPORT int setOutputValue( maps*, const char*, char*, size_t);
102  ZOO_DLL_EXPORT char* getInputValue( maps*,const char*,size_t*);
103 
106  ZOO_DLL_EXPORT char* _getStatus(maps*,char*);
107  ZOO_DLL_EXPORT char* _getStatusFile(maps*,char*);
108  ZOO_DLL_EXPORT char* getStatus(int);
109  ZOO_DLL_EXPORT char* getStatusId(maps*,char*);
110 
111  ZOO_DLL_EXPORT int updateStatus( maps*,const int,const char*);
112  ZOO_DLL_EXPORT int removeShmLock(maps*, int);
116 #ifndef WIN32
117 #define semid int
118 #else
119 #include <windows.h>
120 #define semid HANDLE
121 #endif
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif
ZOO_DLL_EXPORT char * getStatus(int)
Get the current status of the running service.
Definition: service_internal.c:620
ZOO_DLL_EXPORT semid getShmLockId(maps *, int)
Try to create or access a semaphore set.
Definition: service_internal.c:488
ZOO_DLL_EXPORT int unlockShm(semid)
ZOO_DLL_EXPORT char * _getStatus(maps *, char *)
Get the ongoing status of a running service.
Definition: service_internal.c:186
ZOO_DLL_EXPORT semid acquireLock(maps *)
Acquire the global lock.
Definition: service_internal.c:79
ZOO_DLL_EXPORT int lockShm(semid)
#define ZOO_DLL_EXPORT
ZOO_DLL_EXPORT void unhandleStatus(maps *)
Stop handling status repport.
Definition: service_internal.c:245
linked list of map pointer
Definition: main_conf_read.y:243
ZOO_DLL_EXPORT int _updateStatus(maps *)
Update the current status of the running service.
Definition: service_internal.c:263
ZOO_DLL_EXPORT char * readVSIFile(maps *, const char *)
Read a file using the GDAL VSI API.
Definition: service_internal.c:693
ZOO_DLL_EXPORT char * _getStatusFile(maps *, char *)
Read the cache file of a running service.
Definition: service_internal.c:118
ZOO_DLL_EXPORT char * getInputValue(maps *, const char *, size_t *)
Access an input value.
Definition: service_internal.c:671
ZOO_DLL_EXPORT int setOutputValue(maps *, const char *, char *, size_t)
Set an output value.
Definition: service_internal.c:722
ZOO_DLL_EXPORT int removeShmLock(maps *, int)
Try to remove a semaphore set.
Definition: service_internal.c:558
ZOO_DLL_EXPORT char * getStatusId(maps *, char *)
Read the sid file attached of a service if any.
Definition: service_internal.c:51
ZOO_DLL_EXPORT int updateStatus(maps *, const int, const char *)
Update the status of an ongoing service.
Definition: service_internal.c:654
#define semid
Cross platform type used for Lock identifier.
Definition: service_internal.h:117