26 #define ZOO_SERVICE_H 1
31 #define ZOO_DLL_EXPORT __declspec( dllexport )
33 #define ZOO_DLL_EXPORT
46 #ifndef __bool_true_false_are_defined
47 #define __bool_true_false_are_defined 1
51 #define strtok_r strtok_s
52 #define strncasecmp _strnicmp
53 #define strcasecmp _stricmp
54 #if defined(_MSC_VER) && _MSC_VER < 1900
55 #define snprintf _snprintf
57 #define zStrdup _strdup
59 #define zGetpid _getpid
62 #define zUnlink _unlink
67 #include <sys/timeb.h>
78 struct _timeb theTime;
80 tp->tv_sec = theTime.time;
81 tp->tv_usec = theTime.millitm * 1000;
86 #define zStatStruct struct _stati64
87 #define zStat _stati64
94 #define zStrdup strdup
98 static int zMkdir(
const char* pccPath){
99 return mkdir(pccPath,0777);
112 #define zUnlink unlink
129 static int zSleep(
const long millisecond){
130 return usleep(millisecond*1000);
135 #define zGettimeofday gettimeofday
139 #define ztimeval timeval
143 #define zGetpid getpid
145 #define zStatStruct struct stat64
156 #include <mapserver.h>
173 #define SERVICE_ACCEPTED 0
177 #define SERVICE_STARTED 1
181 #define SERVICE_PAUSED 2
185 #define SERVICE_SUCCEEDED 3
189 #define SERVICE_FAILED 4
193 #define SERVICE_DISMISSED 5
198 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*3)+sizeof(char*)+((sizeof(map*) + sizeof(iotype*))*2)+(2*sizeof(elements*)))
203 #define MAP_SIZE (2*sizeof(char*))+sizeof(map*)
208 #define IOTYPE_SIZE sizeof(map*) + sizeof(iotype*)
213 #define MAPS_SIZE sizeof(char*)+sizeof(map*)+(2*sizeof(maps*))
218 #define SERVICE_SIZE sizeof(char*) + 3*sizeof(map*) + 2*sizeof(elements*)
223 #define SERVICES_SIZE sizeof(service*)+sizeof(services*)
228 #define REGISTRY_SIZE sizeof(char*)+sizeof(services*)+sizeof(registry*)
235 void debugStack(
const char* file,
const int line){
237 fprintf(stderr,
"stack %p (%s: %d) \n",&stack,file,line);
251 #define NULLMAP ((map*) 0)
366 "MissingParameterValue",
367 "InvalidParameterValue",
372 "StorageNotSupported",
373 "VersionNegotiationFailed",
384 "InternalServerError",
390 "No problem detected",
391 "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.",
392 "Operation request contains an invalid parameter value.",
393 "No other exceptionCode specified by this service and server applies to this exception.",
394 "The server does not have enough space available to store the inputs and outputs associated with the request.",
395 "The server is too busy to accept and queue the request at this time.",
396 "The file size of one of the input parameters was too large for this process to handle.",
397 "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.",
398 "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.",
399 "One of the identifiers passed does not match with any of the processes offered by this server.",
400 "The process does not permit the desired execution mode.",
401 "One or more of the input identifiers passed does not match with any of the input identifiers of this process.",
402 "One or more of the output identifiers passed does not match with any of the input identifiers of this process.",
403 "One of the referenced input data sets was inaccessible.",
404 "The size of one of the input parameters was too large for this process to handle.",
405 "Too many input items have been specified.",
406 "Too many output items have been specified.",
407 "One or more of the input or output formats specified in the request did not match with any of the formats defined for that particular input or output.",
408 "One or more of inputs for which the service was able to retrieve the data but could not read it.",
410 "The JobID from the request does not match any of the Jobs running on this server.",
411 "The result for the requested JobID has not yet been generated."
475 #if defined(_MSC_VER) && _MSC_VER < 1800
486 ZOO_DLL_EXPORT void logMessage(
const char* source,
const char*
function,
int line,
const char* file = NULL,
const char* message = NULL);
488 #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message))
489 #define zooLog logMessage(__FILE__, __func__, __LINE__)
ZOO_DLL_EXPORT void freeMap(map **)
Free allocated memory of a map.
Definition: service.c:325
ZOO_DLL_EXPORT void inheritance(registry *, service **)
Apply inheritance to a service based on a registry.
Definition: service.c:1614
ZOO_DLL_EXPORT void freeMaps(maps **mo)
Free allocated memory of a maps.
Definition: service.c:349
struct registry registry
Profile registry.
ZOO_DLL_EXPORT void dumpMapsToFile(maps *, char *, int)
Dump a maps to a file, see _dumpMapsToFile().
Definition: service.c:147
Definition: service.h:356
void logMessage(const char *pccSource, const char *pccFunction, int iLne, const char *pccFile, const char *pccMessage)
Print debug message.
Definition: service.c:1768
struct maps maps
linked list of map pointer
char * name
the maps name
Definition: main_conf_read.y:293
ZOO_DLL_EXPORT void freeIOType(iotype **)
Free allocated memory of an iotype.
Definition: service.c:411
char * format
the format: LiteralData or ComplexData or BoundingBoxData
Definition: main_conf_read.y:319
ZOO_DLL_EXPORT void dumpMap(map *)
Dump a map on stderr, see _dumpMap()
Definition: service.c:73
ZOO_DLL_EXPORT bool hasKey(map *, const char *)
Verify if a key exist in a map.
Definition: service.c:235
Definition: service.h:339
ZOO_DLL_EXPORT void addMapToIoType(iotype **, map *)
Add a map to iotype.
Definition: service.c:632
ZOO_DLL_EXPORT void setElementsName(elements **, char *)
Set the name of an elements.
Definition: service.c:1090
ZOO_DLL_EXPORT map * getMapArray(map *, const char *, int)
Access a specific map array element.
Definition: service.c:863
Definition: service.h:338
ZOO_DLL_EXPORT void inheritElements(elements **, elements *)
Apply inheritance to an out elements from a reference in elements.
Definition: service.c:1582
struct service * content
the content service pointer
Definition: main_conf_read.y:342
struct map * content
the content map
Definition: main_conf_read.y:305
#define ztimeval
The crossplatform timeval alias.
Definition: service.h:139
ZOO_DLL_EXPORT void addToElements(elements **, elements *)
Add an elements to another elements.
Definition: service.c:1301
ZOO_DLL_EXPORT void setServiceName(service **, char *)
Set the name of a service.
Definition: service.c:1316
Definition: service.h:360
ZOO_DLL_EXPORT map * getMap(map *, const char *)
Access a specific map.
Definition: service.c:273
ZOO_DLL_EXPORT bool hasvalue(maps *source, const char *node, const char *key, map **kvp)
Verify that a particular map value exists in a maps data structure, and obtain that value...
Definition: service.c:1732
Definition: service.h:334
ZOO_DLL_EXPORT map * getMapType(map *)
Access the map "type".
Definition: service.c:941
struct iotype * next
the pointer to the next iotype if any or NULL
Definition: main_conf_read.y:306
Definition: service.h:342
Definition: service.h:340
ZOO_DLL_EXPORT map * getMapFromMaps(maps *, const char *, const char *)
Access a specific map from a maps.
Definition: service.c:310
struct elements * inputs
the inputs elements
Definition: main_conf_read.y:334
struct map * metadata
the metadata map
Definition: main_conf_read.y:317
ZOO_DLL_EXPORT void dumpElementsAsYAML(elements *, int)
Dump an elements on stderr using the YAML syntaxe.
Definition: service.c:1149
ZOO_DLL_EXPORT bool contains(map *, map *)
Verify if a map is contained in another map.
Definition: service.c:672
char * value
the value
Definition: service.h:246
Definition: service.h:351
ZOO_DLL_EXPORT elements * createEmptyElements()
Create an empty elements.
Definition: service.c:1049
snprintf(current_maps->name,(strlen($1)+1),"%s", $1)
struct iotype * supported
the supported iotype
Definition: main_conf_read.y:321
ZOO_DLL_EXPORT void addMapsToMaps(maps **, maps *)
Add a maps at the end of another maps.
Definition: service.c:823
ZOO_DLL_EXPORT void _dumpMap(map *)
Dump a map on stderr.
Definition: service.c:58
ZOO_DLL_EXPORT iotype * createIoType()
Create a new iotype*.
Definition: service.c:159
struct registry * next
the next registry pointer
Definition: main_conf_read.y:352
ZOO_DLL_EXPORT service * getServiceFromRegistry(registry *, char *, char *)
Access a service in the registry.
Definition: service.c:1516
Definition: service.h:353
struct map map
KVP linked list.
Definition: service.h:344
ZOO_DLL_EXPORT void dumpMapToFile(map *, FILE *)
Dump a map to a file.
Definition: service.c:87
ZOO_DLL_EXPORT map * createMap(const char *, const char *)
Create a new map.
Definition: service.c:173
static const char *const WPSExceptionText[]
Definition: service.h:389
Definition: service.h:350
struct map * content
the content map
Definition: main_conf_read.y:294
struct elements * outputs
the outputs elements
Definition: main_conf_read.y:335
ZOO_DLL_EXPORT maps * createMaps(const char *)
Create a new maps with the given name.
Definition: service.c:187
ZOO_DLL_EXPORT elements * getElements(elements *, const char *)
Access a specific elements named key.
Definition: service.c:395
ZOO_DLL_EXPORT void addToMap(map *, const char *, const char *)
Add key value pair to an existing map.
Definition: service.c:518
Definition: service.h:361
Definition: service.h:349
ZOO_DLL_EXPORT bool nonempty(map *map)
Verify that a map has a value.
Definition: service.c:1716
Definition: service.h:359
linked list of map pointer
Definition: main_conf_read.y:292
ZOO_DLL_EXPORT void mapsToCharXXX(maps *, char ***)
Convert a maps to a char*** (only used for Fortran support)
Definition: service.c:1650
char * name
the name
Definition: main_conf_read.y:315
struct services services
Services chained list.
ZOO_DLL_EXPORT service * createService()
Allocate memory for a service.
Definition: service.c:471
ZOO_DLL_EXPORT char * allocateMapValue(map *node, size_t num_bytes)
Definition: service.c:1857
struct map * metadata
the metadata map
Definition: main_conf_read.y:332
ZOO_DLL_EXPORT bool hasElement(elements *, const char *)
Verify if an elements contains a name equal to the given key.
Definition: service.c:378
ZOO_DLL_EXPORT void addMapToMap(map **, map *)
Add a map at the end of another map.
Definition: service.c:602
ZOO_DLL_EXPORT bool addServiceToRegistry(registry **, char *, service *)
Add a service to the registry.
Definition: service.c:1433
ZOO_DLL_EXPORT maps * getMaps(maps *, const char *)
Access a specific maps.
Definition: service.c:255
char * name
the name
Definition: main_conf_read.y:350
struct service service
Metadata information about a full Service.
void setErrorMessage(maps *&pmsaConf, const char *pccService, WPSException weExc, const char *pccMessage)
Definition: service.c:1746
ZOO_DLL_EXPORT void dumpService(service *)
Dump a service on stderr.
Definition: service.c:1330
ZOO_DLL_EXPORT void dumpMaps(maps *m)
Dump a maps on stderr, see dumpMap().
Definition: service.c:100
KVP linked list.
Definition: service.h:244
ZOO_DLL_EXPORT void dumpRegistry(registry *)
Print the registry on stderr.
Definition: service.c:1412
ZOO_DLL_EXPORT void dumpElements(elements *)
Dump an elements on stderr.
Definition: service.c:1107
Definition: service.h:352
ZOO_DLL_EXPORT void freeRegistry(registry **)
Free memory allocated for the registry.
Definition: service.c:1490
ZOO_DLL_EXPORT void loadMapBinary(map **, map *, int)
Load binary values from a map (in) and add them to another map (out)
Definition: service.c:734
static int zMkdir(const char *pccPath)
The crossplatform mkdir alias.
Definition: service.h:98
ZOO_DLL_EXPORT void addIntToMap(map *, const char *, const int)
Add a key and an integer value to an existing map.
Definition: service.c:543
Definition: service.h:355
Metadata information about a full Service.
Definition: main_conf_read.y:329
struct services * content
the content services pointer
Definition: main_conf_read.y:351
struct elements elements
Metadata information about input or output.
Definition: service.h:345
ZOO_DLL_EXPORT elements * dupElements(elements *)
Duplicate an elements.
Definition: service.c:1233
ZOO_DLL_EXPORT void charxxxToMaps(char ***, maps **)
Convert a char*** to a maps (only used for Fortran support)
Definition: service.c:1686
ZOO_DLL_EXPORT void dumpServiceAsYAML(service *)
Dump a service on stderr using the YAML syntaxe.
Definition: service.c:1360
char * name
the key
Definition: service.h:245
Profile registry.
Definition: main_conf_read.y:349
Not named linked list.
Definition: main_conf_read.y:304
struct maps * next
the pointer to the next maps if any or NULL
Definition: main_conf_read.y:296
struct maps * child
the child maps
Definition: main_conf_read.y:295
Definition: service.h:341
static const char *const WPSExceptionCode[]
Definition: service.h:364
struct map * additional_parameters
the additional parameters map
Definition: main_conf_read.y:333
ZOO_DLL_EXPORT int addMapsArrayToMaps(maps **, maps *, char *)
Add a Maps containing a MapArray to a Maps.
Definition: service.c:964
Definition: service.h:343
ZOO_DLL_EXPORT map * getMapOrFill(map **, const char *, const char *)
Access a specific map or set its value.
Definition: service.c:651
struct map * next
the pointer to the next map if any or NULL
Definition: service.h:247
ZOO_DLL_EXPORT map * addToMapWithSize(map *, const char *, const char *, int)
Add a key and a binary value to an existing map.
Definition: service.c:570
ZOO_DLL_EXPORT void inheritMap(map **, map *)
Apply inheritance to an out map from a reference in map.
Definition: service.c:1539
struct iotype * defaults
the default iotype
Definition: main_conf_read.y:320
ZOO_DLL_EXPORT void freeService(service **)
Free allocated memory of a service.
Definition: service.c:488
struct elements * next
the pointer to the next element if any (or NULL)
Definition: main_conf_read.y:323
struct iotype iotype
Not named linked list.
#define ZOO_DLL_EXPORT
Definition: service.h:33
ZOO_DLL_EXPORT void setMapArray(map *, const char *, int, const char *)
Add a key value in a MapArray for a specific index.
Definition: service.c:890
#define zGettimeofday
The crossplatform gettimeofday alias.
Definition: service.h:135
Metadata information about input or output.
Definition: main_conf_read.y:314
struct map * content
the content map
Definition: main_conf_read.y:316
ZOO_DLL_EXPORT void addIntToMapArray(map *, const char *, int, const int)
Add a key and an integer value to an existing map array.
Definition: service.c:928
ZOO_DLL_EXPORT int count(map *)
Count number of map in a map.
Definition: service.c:202
ZOO_DLL_EXPORT elements * createElements(const char *)
Create a named elements.
Definition: service.c:1069
ZOO_DLL_EXPORT iotype * getIoTypeFromElement(elements *, char *, map *)
Access a specific iotype from an elements.
Definition: service.c:698
ZOO_DLL_EXPORT void setMapInMaps(maps *, const char *, const char *, const char *)
Set a key value pair to a map contained in a Maps.
Definition: service.c:1020
Definition: service.h:357
char * name
the name
Definition: main_conf_read.y:330
ZOO_DLL_EXPORT void inheritIOType(iotype **, iotype *)
Apply inheritance to an out iotype from a reference in iotype.
Definition: service.c:1559
ZOO_DLL_EXPORT map * getLastMap(map *)
Access the last map.
Definition: service.c:291
ZOO_DLL_EXPORT void loadMapBinaries(map **, map *)
Load binary values from a map (in) and add them to another map (out).
Definition: service.c:769
WPSException
Definition: main_conf_read.y:356
struct elements * child
the pointer to the children element if any (or NULL)
Definition: main_conf_read.y:322
ZOO_DLL_EXPORT service * dupService(service *)
Duplicate a service.
Definition: service.c:1393
Definition: service.h:354
struct map * content
the content map
Definition: main_conf_read.y:331
struct map * additional_parameters
the additional parameters map
Definition: main_conf_read.y:318
struct services * next
the pointer to the next services*
Definition: main_conf_read.y:343
static int zSleep(const long millisecond)
The crossplatform sleep alias.
Definition: service.h:129
ZOO_DLL_EXPORT void freeElements(elements **)
Free allocated memory of an elements.
Definition: service.c:429
Definition: service.h:358
Services chained list.
Definition: main_conf_read.y:341
ZOO_DLL_EXPORT maps * dupMaps(maps **)
Duplicate a Maps.
Definition: service.c:797
pair PAIR FOUND n
Definition: service_conf.y:1113