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 |
Data Structure Documentation
struct zooLock |
Macro Definition Documentation
#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.
Typedef Documentation
The lock structure used by the ZOO-Kernel to ensure atomicity of operations.
Function Documentation
ZOO_DLL_EXPORT char* _getStatus | ( | maps * | conf, |
char * | lid | ||
) |
Get the ongoing status of a running service.
- Parameters
-
conf the maps containing the setting of the main.cfg file pid the service identifier (usid key from the [lenv] section)
- Returns
- the reported status char* (MESSAGE|POURCENTAGE)
ZOO_DLL_EXPORT char* _getStatusFile | ( | maps * | conf, |
char * | pid | ||
) |
Read the cache file of a running service.
- Parameters
-
conf the maps containing the setting of the main.cfg file pid the service identifier (usid key from the [lenv] section)
- Returns
- the reported status char* (temporary/final result)
ZOO_DLL_EXPORT int _updateStatus | ( | maps * | conf | ) |
Update the current status of the running service.
- See also
- acquireLock, lockShm
- Parameters
-
conf the map containing the setting of the main.cfg file
- Returns
- 0 on success, -2 if shmget failed, -1 if shmat failed
ZOO_DLL_EXPORT semid acquireLock | ( | maps * | conf | ) |
Acquire the global lock.
- Parameters
-
conf the maps containing the setting of the main.cfg file
- Returns
- a semid
ZOO_DLL_EXPORT char* file_exists | ( | const char * | dir, |
const char * | name | ||
) |
Check if file exists in specified folder.
- Parameters
-
dir the folder in which to search for file name the name of the file (not full path)
- Returns
- a character string with the full path [dir/name], or NULL if the file does not exist
- Attention
- Caller is responsible for applying free() to the returned pointer
ZOO_DLL_EXPORT char* getInputValue | ( | maps * | inputs, |
const char * | parameterName, | ||
size_t * | numberOfBytes | ||
) |
Access an input value.
- Parameters
-
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
- Returns
- a pointer to the input value if found, NULL in other case.
ZOO_DLL_EXPORT semid getShmLockId | ( | maps * | conf, |
int | nsems | ||
) |
Try to create or access a semaphore set.
- See also
- getKeyValue
- Parameters
-
conf the map containing the setting of the main.cfg file nsems number of semaphores
- Returns
- a semaphores set indentifier on success, -1 in other case
ZOO_DLL_EXPORT char* getStatus | ( | int | pid | ) |
Get the current status of the running service.
- See also
- getKeyValue, getShmLockId, lockShm
- Parameters
-
pid the semaphores
- Returns
- 0 on success, -2 if shmget failed, -1 if shmat failed
ZOO_DLL_EXPORT char* getStatusId | ( | maps * | conf, |
char * | pid | ||
) |
Read the sid file attached of a service if any.
- Parameters
-
conf the maps containing the setting of the main.cfg file pid the service identifier (usid key from the [lenv] section)
- Returns
- the reported status char* (temporary/final result)
ZOO_DLL_EXPORT struct zooLock* lockFile | ( | maps * | conf, |
const char * | filename, | ||
const char | mode | ||
) |
Lock a file for read, write and upload.
- Parameters
-
conf the main configuration maps filename the file to lock mode define access: 'r' for read, 'w' for write
- Returns
- a new zooLock structure on sucess, NULL on failure
ZOO_DLL_EXPORT int lockShm | ( | semid | ) |
ZOO_DLL_EXPORT char* readVSIFile | ( | maps * | conf, |
const char * | dataSource | ||
) |
Read a file using the GDAL VSI API.
- Parameters
-
conf the maps containing the settings of the main.cfg file dataSource the datasource name to read
- Warning
- make sure to free resources returned by this function
ZOO_DLL_EXPORT int removeShmLock | ( | maps * | conf, |
int | nsems | ||
) |
Try to remove a semaphore set.
- Parameters
-
conf the map containing the setting of the main.cfg file nsems number of semaphores
- Returns
- 0 if the semaphore can be removed, -1 in other case.
ZOO_DLL_EXPORT int setOutputValue | ( | maps * | outputs, |
const char * | parameterName, | ||
char * | data, | ||
size_t | numberOfBytes | ||
) |
Set an output value.
- Parameters
-
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
- Returns
- 0
ZOO_DLL_EXPORT void unhandleStatus | ( | maps * | conf | ) |
Stop handling status repport.
- Parameters
-
conf the map containing the setting of the main.cfg file
ZOO_DLL_EXPORT int unlockFile | ( | maps * | conf, |
struct zooLock * | s | ||
) |
Remove a lock.
- Parameters
-
conf the main configuration maps s the zooLock structure
- Returns
- 0 on success, -1 on failure.
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.
- Parameters
-
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
- Returns
- the value of _updateStatus
- See also
- _updateStatus
Variable Documentation
|
static |
|
static |
Generated on Wed Apr 2 2025 00:00:02 for ZOO-Project by
