ZOO-Project
|
#include <libintl.h>
#include <locale.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <stdio.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include "service.h"
Go to the source code of this file.
Data Structures | |
struct | zooLock |
The lock structure used by the ZOO-Kernel to ensure atomicity of operations. More... | |
Macros | |
#define | DEFAULT_SERVICE_URL "http://www.zoo-project.org/" |
The default service url (overriden by serverAddress) More... | |
#define | TIME_SIZE 40 |
The time size. More... | |
#define | _(String) dgettext ("zoo-kernel",String) |
ZOO-Kernel internal messages translation function. More... | |
#define | _ss(String) dgettext ("zoo-services",String) |
ZOO-Services messages translation function. More... | |
#define | ZOO_LOCK_CREATE_FAILED -4 |
ZOO-Kernel was unable to create a lock. More... | |
#define | ZOO_LOCK_ACQUIRE_FAILED -5 |
ZOO-Kernel was unable to acquire a lock. More... | |
#define | ZOO_LOCK_RELEASE_FAILED -6 |
ZOO-Kernel was unable to release a lock. More... | |
#define | ZOO_LOCK_MAX_RETRY 180 |
Number of time the ZOO-Kernel will try to acquire lock. More... | |
#define | semid int |
Cross platform type used for Lock identifier. More... | |
Typedefs | |
typedef struct zooLock | zooLock |
The lock structure used by the ZOO-Kernel to ensure atomicity of operations. More... | |
Functions | |
ZOO_DLL_EXPORT char * | readVSIFile (maps *, const char *) |
Read a file using the GDAL VSI API. More... | |
ZOO_DLL_EXPORT int | setOutputValue (maps *, const char *, char *, size_t) |
Set an output value. More... | |
ZOO_DLL_EXPORT char * | getInputValue (maps *, const char *, size_t *) |
Access an input value. More... | |
ZOO_DLL_EXPORT struct zooLock * | lockFile (maps *, const char *, const char) |
Lock a file for read, write and upload. More... | |
ZOO_DLL_EXPORT int | unlockFile (maps *, struct zooLock *) |
Remove a lock. More... | |
ZOO_DLL_EXPORT void | unhandleStatus (maps *) |
Stop handling status repport. More... | |
ZOO_DLL_EXPORT int | _updateStatus (maps *) |
Update the current status of the running service. More... | |
ZOO_DLL_EXPORT char * | _getStatus (maps *, char *) |
Get the ongoing status of a running service. More... | |
ZOO_DLL_EXPORT char * | _getStatusFile (maps *, char *) |
Read the cache file of a running service. More... | |
ZOO_DLL_EXPORT char * | getStatus (int) |
Get the current status of the running service. More... | |
ZOO_DLL_EXPORT char * | getStatusId (maps *, char *) |
Read the sid file attached of a service if any. More... | |
ZOO_DLL_EXPORT int | updateStatus (maps *, const int, const char *) |
Update the status of an ongoing service. More... | |
ZOO_DLL_EXPORT int | removeShmLock (maps *, int) |
Try to remove a semaphore set. More... | |
ZOO_DLL_EXPORT semid | acquireLock (maps *) |
Acquire the global lock. More... | |
ZOO_DLL_EXPORT semid | getShmLockId (maps *, int) |
Try to create or access a semaphore set. More... | |
ZOO_DLL_EXPORT int | lockShm (semid) |
ZOO_DLL_EXPORT int | unlockShm (semid) |
ZOO_DLL_EXPORT char * | file_exists (const char *dir, const char *name) |
Check if file exists in specified folder. More... | |
Variables | |
static zooLock ** | zoo_file_locks =NULL |
static int | zoo_file_locks_cnt =0 |
struct zooLock |
#define _ | ( | String | ) | dgettext ("zoo-kernel",String) |
ZOO-Kernel internal messages translation function.
#define _ss | ( | String | ) | dgettext ("zoo-services",String) |
ZOO-Services messages translation function.
#define DEFAULT_SERVICE_URL "http://www.zoo-project.org/" |
The default service url (overriden by serverAddress)
#define semid int |
Cross platform type used for Lock identifier.
#define TIME_SIZE 40 |
The time size.
#define ZOO_LOCK_ACQUIRE_FAILED -5 |
ZOO-Kernel was unable to acquire a lock.
#define ZOO_LOCK_CREATE_FAILED -4 |
ZOO-Kernel was unable to create a lock.
#define ZOO_LOCK_MAX_RETRY 180 |
Number of time the ZOO-Kernel will try to acquire lock.
#define ZOO_LOCK_RELEASE_FAILED -6 |
ZOO-Kernel was unable to release a lock.
The lock structure used by the ZOO-Kernel to ensure atomicity of operations.
ZOO_DLL_EXPORT char* _getStatus | ( | maps * | conf, |
char * | lid | ||
) |
Get the ongoing status of a running service.
conf | the maps containing the setting of the main.cfg file |
pid | the service identifier (usid key from the [lenv] section) |
ZOO_DLL_EXPORT char* _getStatusFile | ( | maps * | conf, |
char * | pid | ||
) |
Read the cache file of a running service.
conf | the maps containing the setting of the main.cfg file |
pid | the service identifier (usid key from the [lenv] section) |
ZOO_DLL_EXPORT int _updateStatus | ( | maps * | conf | ) |
Update the current status of the running service.
conf | the map containing the setting of the main.cfg file |
ZOO_DLL_EXPORT semid acquireLock | ( | maps * | conf | ) |
Acquire the global lock.
conf | the maps containing the setting of the main.cfg file |
ZOO_DLL_EXPORT char* file_exists | ( | const char * | dir, |
const char * | name | ||
) |
Check if file exists in specified folder.
dir | the folder in which to search for file |
name | the name of the file (not full path) |
ZOO_DLL_EXPORT char* getInputValue | ( | maps * | inputs, |
const char * | parameterName, | ||
size_t * | numberOfBytes | ||
) |
Access an input value.
inputs | the maps to search for the input value |
parameterName | the input name to fetch the value |
numberOfBytes | the resulting size of the value to add (for binary values), -1 for basic char* data |
ZOO_DLL_EXPORT semid getShmLockId | ( | maps * | conf, |
int | nsems | ||
) |
Try to create or access a semaphore set.
conf | the map containing the setting of the main.cfg file |
nsems | number of semaphores |
ZOO_DLL_EXPORT char* getStatus | ( | int | pid | ) |
Get the current status of the running service.
pid | the semaphores |
ZOO_DLL_EXPORT char* getStatusId | ( | maps * | conf, |
char * | pid | ||
) |
Read the sid file attached of a service if any.
conf | the maps containing the setting of the main.cfg file |
pid | the service identifier (usid key from the [lenv] section) |
ZOO_DLL_EXPORT struct zooLock* lockFile | ( | maps * | conf, |
const char * | filename, | ||
const char | mode | ||
) |
Lock a file for read, write and upload.
conf | the main configuration maps |
filename | the file to lock |
mode | define access: 'r' for read, 'w' for write |
ZOO_DLL_EXPORT int lockShm | ( | semid | ) |
ZOO_DLL_EXPORT char* readVSIFile | ( | maps * | conf, |
const char * | dataSource | ||
) |
Read a file using the GDAL VSI API.
conf | the maps containing the settings of the main.cfg file |
dataSource | the datasource name to read |
ZOO_DLL_EXPORT int removeShmLock | ( | maps * | conf, |
int | nsems | ||
) |
Try to remove a semaphore set.
conf | the map containing the setting of the main.cfg file |
nsems | number of semaphores |
ZOO_DLL_EXPORT int setOutputValue | ( | maps * | outputs, |
const char * | parameterName, | ||
char * | data, | ||
size_t | numberOfBytes | ||
) |
Set an output value.
outputs | the maps to define the output value |
parameterName | the output name to set the value |
data | the value to set |
numberOfBytes | size of the value to add (for binary values), -1 for basic char* data |
ZOO_DLL_EXPORT void unhandleStatus | ( | maps * | conf | ) |
Stop handling status repport.
conf | the map containing the setting of the main.cfg file |
ZOO_DLL_EXPORT int unlockFile | ( | maps * | conf, |
struct zooLock * | s | ||
) |
Remove a lock.
conf | the main configuration maps |
s | the zooLock structure |
ZOO_DLL_EXPORT int unlockShm | ( | semid | ) |
ZOO_DLL_EXPORT int updateStatus | ( | maps * | conf, |
const int | percentCompleted, | ||
const char * | message | ||
) |
Update the status of an ongoing service.
conf | the maps containing the settings of the main.cfg file |
percentCompleted | percentage of completude of execution of the service |
message | information about the current step executed |
|
static |
|
static |