source: trunk/zoo-project/zoo-kernel/service.h @ 767

Last change on this file since 767 was 767, checked in by djay, 8 years ago

Fix issue with headers located in extern C. Define java.library.path at runtime to search for libZOO.so from the Java zoo-api.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 9.3 KB
RevLine 
[579]1/*
[1]2 * Author : Gérald FENOY
3 *
[576]4 * Copyright (c) 2009-2015 GeoLabs SARL
[1]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_H
26#define ZOO_SERVICE_H 1
27
28#pragma once
29
[216]30#ifdef WIN32
[680]31#define ZOO_DLL_EXPORT __declspec( dllexport )
32#else
33#define ZOO_DLL_EXPORT
34#endif
35
36#ifdef WIN32
[375]37#define strncasecmp _strnicmp
38#define strcasecmp _stricmp
[757]39#if defined(_MSC_VER) && _MSC_VER < 1900
40#define snprintf _snprintf
[453]41#endif
42#define zStrdup _strdup
43#define zMkdir _mkdir
44#define zOpen _open
45#define zWrite _write
[507]46#define zSleep Sleep
[514]47#include <sys/timeb.h>
48struct ztimeval {
49  long tv_sec; /* seconds */
50  long tv_usec; /* and microseconds */
51};
[554]52static int zGettimeofday(struct ztimeval* tp, void* tzp)
[514]53{
[554]54  if (tp == 0) {
55    return -1;
56  }
57 
[514]58  struct _timeb theTime;
59  _ftime(&theTime);
60  tp->tv_sec = theTime.time;
61  tp->tv_usec = theTime.millitm * 1000;
[554]62 
63  return 0; // The gettimeofday() function shall return 0 on success
[514]64}
[712]65
[379]66#else
[579]67/**
68 * The crossplatform strdup alias
69 */
[453]70#define zStrdup strdup
[579]71/**
72 * The crossplatform mkdir alias
73 */
[453]74#define zMkdir mkdir
[579]75/**
76 * The crossplatform open alias
77 */
[454]78#define zOpen open
[579]79/**
80 * The crossplatform write alias
81 */
[454]82#define zWrite write
[579]83/**
84 * The crossplatform sleep alias
85 */
[507]86#define zSleep sleep
[579]87/**
88 * The crossplatform gettimeofday alias
89 */
[514]90#define zGettimeofday gettimeofday
[579]91/**
92 * The crossplatform timeval alias
93 */
[514]94#define ztimeval timeval
[216]95#endif
96
[1]97#ifdef __cplusplus
98extern "C" {
99#endif
100
[444]101#ifdef WIN32
102#ifdef USE_MS
103#include <mapserver.h>
104#endif
105#endif
[1]106#include <stdlib.h>
107#include <ctype.h>
[712]108
[1]109#include <stdio.h>
[712]110
[1]111#include <string.h>
[364]112#ifndef WIN32
[618]113#include <ctype.h>
[767]114#include <stdbool.h>
[490]115#endif
[9]116
[579]117/**
118 * The global accepted status for a service
119 */
[1]120#define SERVICE_ACCEPTED 0
[579]121/**
122 * The global started status for a service
123 */
[1]124#define SERVICE_STARTED 1
[579]125/**
126 * The global paused status for a service
127 */
[1]128#define SERVICE_PAUSED 2
[579]129/**
130 * The global succeeded status for a service
131 */
[1]132#define SERVICE_SUCCEEDED 3
[579]133/**
134 * The global failed status for a service
135 */
[1]136#define SERVICE_FAILED 4
[9]137
[579]138/**
139 * The memory size to create an elements
140 */
[640]141#define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+(2*sizeof(elements*)))
[579]142/**
143 * The memory size to create a map
144 */
[9]145#define MAP_SIZE (2*sizeof(char*))+sizeof(NULL)
[579]146/**
147 * The memory size to create an iotype
148 */
[9]149#define IOTYPE_SIZE MAP_SIZE+sizeof(NULL)
[579]150/**
151 * The memory size to create a maps
152 */
[9]153#define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+MAP_SIZE
[579]154/**
155 * The memory size to create a service
156 */
[9]157#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
[607]158/**
159 * The memory size to create a services
160 */
161#define SERVICES_SIZE SERVICE_SIZE+sizeof(services*)
162/**
163 * The memory size to create a registry
164 */
165#define REGISTRY_SIZE SERVICES_SIZE+sizeof(char*)
[1]166
[26]167#define SHMSZ     27
[1]168
[465]169#include "version.h"
[1]170
[375]171#ifdef DEBUG_STACK
172  void debugStack(const char* file,const int line){
173    int stack;
174    fprintf(stderr,"stack %p (%s: %d) \n",&stack,file,line);
175  }
176#endif
177
[9]178  /**
[579]179   * KVP linked list
[9]180   */
[1]181  typedef struct map{
[607]182    char* name; //!< the key
183    char* value; //!< the value
184    struct map* next; //!< the pointer to the next map if any or NULL
[1]185  } map;
186
187#ifdef WIN32
188#define NULLMAP ((map*) 0)
189#else
190#define NULLMAP NULL
191#endif
192
[114]193  /**
[579]194   * linked list of map pointer
[114]195   *
196   * Small object to store WPS KVP set.
197   */
198  typedef struct maps{
[607]199    char* name; //!< the maps name
200    struct map* content; //!< the content map
201    struct maps* next; //!< the pointer to the next maps if any or NULL
[114]202  } maps;
[601]203 
[579]204  /**
205   * Not named linked list
[114]206   *
207   * Used to store informations about formats, such as mimeType, encoding ...
208   */
[1]209  typedef struct iotype{
[607]210    struct map* content; //!< the content map
211    struct iotype* next; //!< the pointer to the next iotype if any or NULL
[1]212  } iotype;
213
[114]214  /**
[579]215   * Metadata information about input or output.
[114]216   *
217   * The elements are used to store metadata informations defined in the ZCFG.
218   */
[1]219  typedef struct elements{
[607]220    char* name; //!< the name
221    struct map* content; //!< the content map
222    struct map* metadata; //!< the metadata map
223    char* format; //!< the format: LiteralData or ComplexData or BoundingBoxData
224    struct iotype* defaults; //!< the default iotype
225    struct iotype* supported; //!< the supported iotype
[640]226    struct elements* child; //!< the pointer to the children element if any (or NULL)
[607]227    struct elements* next; //!< the pointer to the next element if any (or NULL)
[1]228  } elements;
229
[579]230  /**
231   * Metadata informations about a full Service.
232   */
[1]233  typedef struct service{
[607]234    char* name; //!< the name
235    struct map* content; //!< the content map
236    struct map* metadata; //!< the metadata map
237    struct elements* inputs; //!< the inputs elements
238    struct elements* outputs; //!< the outputs elements
[1]239  } service;
240
[579]241  /**
[607]242   * Services chained list.
[579]243   */
[1]244  typedef struct services{
[607]245    struct service* content; //!< the content service pointer
246    struct services* next; //!< the pointer to the next services*
[1]247  } services;
248
[579]249  /**
[607]250   * Profile registry.
251   */
252  typedef struct registry{
253    char *name; //!< the name
254    struct services* content; //!< the content services pointer
255    struct registry* next; //!< the next registry pointer
256  } registry;
257
[680]258  ZOO_DLL_EXPORT void _dumpMap(map*);
259  ZOO_DLL_EXPORT void dumpMap(map*);
260  ZOO_DLL_EXPORT void dumpMaps(maps* m);
[682]261  ZOO_DLL_EXPORT void dumpMapToFile(map*,FILE*); // (used only internally)
262  ZOO_DLL_EXPORT void dumpMapsToFile(maps*,char*,int);
[680]263  ZOO_DLL_EXPORT map* createMap(const char*,const char*);
264  ZOO_DLL_EXPORT int count(map*);
265  ZOO_DLL_EXPORT bool hasKey(map*,const char*);
266  ZOO_DLL_EXPORT maps* getMaps(maps*,const char*);
267  ZOO_DLL_EXPORT map* getMap(map*,const char*);
268  ZOO_DLL_EXPORT map* getLastMap(map*);
269  ZOO_DLL_EXPORT map* getMapFromMaps(maps*,const char*,const char*);
270  ZOO_DLL_EXPORT void freeMap(map**);
271  ZOO_DLL_EXPORT void freeMaps(maps** mo);
[550]272 
273
[680]274  ZOO_DLL_EXPORT bool hasElement(elements*,const char*);
275  ZOO_DLL_EXPORT elements* getElements(elements*,char*);
276  ZOO_DLL_EXPORT void freeIOType(iotype**);
277  ZOO_DLL_EXPORT void freeElements(elements**);
278  ZOO_DLL_EXPORT void freeService(service**);
279  ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*);
280  ZOO_DLL_EXPORT void addIntToMap(map*,const char*,const int);
[738]281  ZOO_DLL_EXPORT map* addToMapWithSize(map*,const char*,const char*,int);
[680]282  ZOO_DLL_EXPORT void addMapToMap(map**,map*);
283  ZOO_DLL_EXPORT void addMapToIoType(iotype**,map*);
284  ZOO_DLL_EXPORT map* getMapOrFill(map**,const char*,const char*);
285  ZOO_DLL_EXPORT bool contains(map*,map*);
286  ZOO_DLL_EXPORT iotype* getIoTypeFromElement(elements*,char*, map*);
287  ZOO_DLL_EXPORT void loadMapBinary(map**,map*,int);
288  ZOO_DLL_EXPORT void loadMapBinaries(map**,map*);
289  ZOO_DLL_EXPORT maps* dupMaps(maps**);
290  ZOO_DLL_EXPORT void addMapsToMaps(maps**,maps*);
291  ZOO_DLL_EXPORT map* getMapArray(map*,const char*,int);
292  ZOO_DLL_EXPORT void setMapArray(map*,const char*,int,const char*);
293  ZOO_DLL_EXPORT map* getMapType(map*);
294  ZOO_DLL_EXPORT int addMapsArrayToMaps(maps**,maps*,char*);
295  ZOO_DLL_EXPORT void setMapInMaps(maps*,const char*,const char*,const char*);
296  ZOO_DLL_EXPORT void dumpElements(elements*);
297  ZOO_DLL_EXPORT void dumpElementsAsYAML(elements*);
298  ZOO_DLL_EXPORT elements* dupElements(elements*);
299  ZOO_DLL_EXPORT void addToElements(elements**,elements*);
300  ZOO_DLL_EXPORT void dumpService(service*);
301  ZOO_DLL_EXPORT void dumpServiceAsYAML(service*);
302  ZOO_DLL_EXPORT service* dupService(service*);
303  ZOO_DLL_EXPORT void dumpRegistry(registry*);
304  ZOO_DLL_EXPORT bool addServiceToRegistry(registry**,char*,service*);
305  ZOO_DLL_EXPORT void freeRegistry(registry**);
306  ZOO_DLL_EXPORT service* getServiceFromRegistry(registry*,char*,char*);
307  ZOO_DLL_EXPORT void inheritMap(map**,map*);
308  ZOO_DLL_EXPORT void inheritIOType(iotype**,iotype*);
309  ZOO_DLL_EXPORT void inheritElements(elements**,elements*);
310  ZOO_DLL_EXPORT void inheritance(registry*,service**);
311  ZOO_DLL_EXPORT void mapsToCharXXX(maps*,char***);
312  ZOO_DLL_EXPORT void charxxxToMaps(char***,maps**);
[757]313#if defined(_MSC_VER) && _MSC_VER < 1800
[712]314  // snprintf for Visual Studio compiler;
315  // it is also used by services (e.g., GetStatus), therefore exported to shared library
316  ZOO_DLL_EXPORT int snprintf(char *buffer, size_t n, const char *format, ...);
[757]317#endif
[1]318#ifdef __cplusplus
319}
320#endif
321
322#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