Ignore:
Timestamp:
May 7, 2019, 2:17:08 PM (5 years ago)
Author:
djay
Message:

Merge prototype-v0 branch in trunk

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/zoo-project/zoo-kernel/service.h

    r889 r917  
    22 * Author : Gérald FENOY
    33 *
    4  * Copyright (c) 2009-2015 GeoLabs SARL
     4 * Copyright (c) 2009-2019 GeoLabs SARL
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a copy
     
    3434#endif
    3535
     36 // knut: add bool if necessary
     37#ifndef __cplusplus
     38#ifndef WIN32
     39#include <stdbool.h>
     40#else
     41typedef int bool;
     42#define false 0
     43#define true 1 
     44#endif
     45#endif
     46#ifndef __bool_true_false_are_defined
     47#define __bool_true_false_are_defined 1
     48#endif
     49
    3650#ifdef WIN32
    37 #ifndef USE_MS
    38 ZOO_DLL_EXPORT char *strcasestr (char const *,char const *);
    39 #endif
    40 #endif
    41 
    42 // knut: add bool if necessary
    43 #ifndef __cplusplus
    44   #ifndef WIN32
    45     #include <stdbool.h>
    46   #else
    47     typedef int bool;
    48     #define false 0
    49     #define true 1     
    50   #endif
    51 #endif
    52 #ifndef __bool_true_false_are_defined
    53   #define __bool_true_false_are_defined 1
    54 #endif
    55 
    56 #ifdef WIN32
     51#define strtok_r strtok_s
    5752#define strncasecmp _strnicmp
    5853#define strcasecmp _stricmp
    59 #define strtok_r strtok_s
    6054#if defined(_MSC_VER) && _MSC_VER < 1900
    6155#define snprintf _snprintf
    6256#endif
    63 /* knut: see new definition of bool above
    64 #if defined(_MSC_VER) && _MSC_VER < 1800
    65 #define false 0
    66 #define true 1
    67 #define bool int
    68 #endif
    69 */
    7057#define zStrdup _strdup
    7158#define zMkdir _mkdir
     59#define zGetpid _getpid
    7260#define zOpen _open
     61#define zClose _close
     62#define zUnlink _unlink
     63#define zDup _dup
     64#define zDup2 _dup2
    7365#define zWrite _write
    7466#define zSleep Sleep
     
    8072static int zGettimeofday(struct ztimeval* tp, void* tzp)
    8173{
    82   struct _timeb theTime;       
    8374  if (tp == 0) {
    8475    return -1;
    8576  }
    8677 
     78  struct _timeb theTime;
    8779  _ftime(&theTime);
    8880  tp->tv_sec = theTime.time;
     
    9284}
    9385
     86#define zStatStruct struct _stati64
     87#define zStat _stati64
     88
    9489#else
    9590/**
     
    106101#define zOpen open
    107102/**
     103 * The crossplatform close alias
     104 */
     105#define zClose close
     106/**
     107 * The crossplatform unlink alias
     108 */
     109#define zUnlink unlink
     110/**
     111 * The crossplatform dup alias
     112 */
     113#define zDup dup
     114/**
     115 * The crossplatform dup2 alias
     116 */
     117#define zDup2 dup2
     118/**
    108119 * The crossplatform write alias
    109120 */
    110121#define zWrite write
     122#include "unistd.h"
    111123/**
    112124 * The crossplatform sleep alias
    113125 */
    114 #define zSleep sleep
     126static int zSleep(const long millisecond){
     127  return usleep(millisecond*1000);
     128}
    115129/**
    116130 * The crossplatform gettimeofday alias
     
    121135 */
    122136#define ztimeval timeval
     137/**
     138 * The crossplatform getpid alias
     139 */
     140#define zGetpid getpid
     141
     142#define zStatStruct struct stat64
     143#define zStat stat64
     144
    123145#endif
    124146
     
    140162#ifndef WIN32
    141163#include <ctype.h>
    142 //#include <stdbool.h> // knut: see new definition of bool above
     164#include <stdbool.h>
    143165#endif
    144166
     
    167189 * The memory size to create an elements
    168190 */
    169 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+(2*sizeof(elements*)))
     191#define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*3)+sizeof(char*)+((sizeof(map*) + sizeof(iotype*))*2)+(2*sizeof(elements*)))
    170192/**
    171193 * The memory size to create a map
     
    187209 */
    188210//#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
    189 #define SERVICE_SIZE sizeof(char*) + 2*sizeof(map*) + 2*sizeof(elements*)
     211#define SERVICE_SIZE sizeof(char*) + 3*sizeof(map*) + 2*sizeof(elements*)
    190212/**
    191213 * The memory size to create a services
     
    221243#ifdef WIN32
    222244#define NULLMAP ((map*) 0)
     245// knut: see new definition above
     246//#define bool int
     247//#define true 1
     248//#define false 0
    223249#else
    224250#define NULLMAP NULL
     
    256282    struct map* content; //!< the content map
    257283    struct map* metadata; //!< the metadata map
     284    struct map* additional_parameters; //!< the additional parameters map
    258285    char* format; //!< the format: LiteralData or ComplexData or BoundingBoxData
    259286    struct iotype* defaults; //!< the default iotype
     
    270297    struct map* content; //!< the content map
    271298    struct map* metadata; //!< the metadata map
     299    struct map* additional_parameters; //!< the additional parameters map
    272300    struct elements* inputs; //!< the inputs elements
    273301    struct elements* outputs; //!< the outputs elements
     
    290318    struct registry* next; //!< the next registry pointer
    291319  } registry;
    292  
     320
    293321  // knut
    294322  enum WPSException {
    295     /*
    296     * StatusOK is not a WPS exception, it is added
    297     * here for convenience.
    298     */     
    299     StatusOK,                 
    300     /*
    301     * See WPS 1.0 specification, Table 38 and Table 62.
    302     */
    303     MissingParameterValue,   
    304     InvalidParameterValue,
    305     NoApplicableCode,
    306     NotEnoughStorage,
    307     ServerBusy,
    308     FileSizeExceeded,
    309     StorageNotSupported,
    310     VersionNegotiationFailed,
    311     /*
    312     * See WPS 2.0 specification, Tables 41, 46, 48, and 50.
    313     */
    314     NoSuchProcess,
    315     NoSuchMode,
    316     NoSuchInput,
    317     NoSuchOutput,
    318     DataNotAccessible,
    319     SizeExceeded,
    320     TooManyInputs,
    321     TooManyOutputs,
    322     NoSuchFormat,
    323     WrongInputData,
    324     InternalServerError,
    325     NoSuchJob,
    326     ResultNotReady
    327   }; 
    328  
     323          /*
     324          * StatusOK is not a WPS exception, it is added
     325          * here for convenience.
     326          */
     327          StatusOK,
     328          /*
     329          * See WPS 1.0 specification, Table 38 and Table 62.
     330          */
     331          MissingParameterValue,
     332          InvalidParameterValue,
     333          NoApplicableCode,
     334          NotEnoughStorage,
     335          ServerBusy,
     336          FileSizeExceeded,
     337          StorageNotSupported,
     338          VersionNegotiationFailed,
     339          /*
     340          * See WPS 2.0 specification, Tables 41, 46, 48, and 50.
     341          */
     342          NoSuchProcess,
     343          NoSuchMode,
     344          NoSuchInput,
     345          NoSuchOutput,
     346          DataNotAccessible,
     347          SizeExceeded,
     348          TooManyInputs,
     349          TooManyOutputs,
     350          NoSuchFormat,
     351          WrongInputData,
     352          InternalServerError,
     353          NoSuchJob,
     354          ResultNotReady
     355  };
     356
    329357  static const char* const WPSExceptionCode[] = {
    330     "StatusOK",
    331     "MissingParameterValue",
    332     "InvalidParameterValue",
    333     "NoApplicableCode",
    334     "NotEnoughStorage",
    335     "ServerBusy",
    336     "FileSizeExceeded",
    337     "StorageNotSupported",
    338     "VersionNegotiationFailed",
    339     "NoSuchProcess",
    340     "NoSuchMode",
    341     "NoSuchInput",
    342     "NoSuchOutput",
    343     "DataNotAccessible",
    344     "SizeExceeded",
    345     "TooManyInputs",
    346     "TooManyOutputs",
    347     "NoSuchFormat",
    348     "WrongInputData",
    349     "InternalServerError",
    350     "NoSuchJob",
    351     "ResultNotReady"   
    352   };     
     358        "StatusOK",
     359        "MissingParameterValue",
     360        "InvalidParameterValue",
     361        "NoApplicableCode",
     362        "NotEnoughStorage",
     363        "ServerBusy",
     364        "FileSizeExceeded",
     365        "StorageNotSupported",
     366        "VersionNegotiationFailed",
     367        "NoSuchProcess",
     368        "NoSuchMode",
     369        "NoSuchInput",
     370        "NoSuchOutput",
     371        "DataNotAccessible",
     372        "SizeExceeded",
     373        "TooManyInputs",
     374        "TooManyOutputs",
     375        "NoSuchFormat",
     376        "WrongInputData",
     377        "InternalServerError",
     378        "NoSuchJob",
     379        "ResultNotReady"
     380  };
    353381
    354382  static const char* const WPSExceptionText[] = {
    355     "No problem detected",
    356     "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.",
    357     "Operation request contains an invalid parameter value.",
    358     "No other exceptionCode specified by this service and server applies to this exception.",
    359     "The server does not have enough space available to store the inputs and outputs associated with the request.",
    360     "The server is too busy to accept and queue the request at this time.",
    361     "The file size of one of the input parameters was too large for this process to handle.",
    362     "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.",
    363     "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.",
    364     "One of the identifiers passed does not match with any of the processes offered by this server.",
    365     "The process does not permit the desired execution mode.",
    366     "One or more of the input identifiers passed does not match with any of the input identifiers of this process.",
    367     "One or more of the output identifiers passed does not match with any of the input identifiers of this process.",
    368     "One of the referenced input data sets was inaccessible.",
    369     "The size of one of the input parameters was too large for this process to handle.",
    370     "Too many input items have been specified.",
    371     "Too many output items have been specified.",
    372     "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.",
    373     "One or more of inputs for which the service was able to retrieve the data but could not read it.",
    374     "",
    375     "The JobID from the request does not match any of the Jobs running on this server.",
    376     "The result for the requested JobID has not yet been generated."
     383        "No problem detected",
     384        "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.",
     385        "Operation request contains an invalid parameter value.",
     386        "No other exceptionCode specified by this service and server applies to this exception.",
     387        "The server does not have enough space available to store the inputs and outputs associated with the request.",
     388        "The server is too busy to accept and queue the request at this time.",
     389        "The file size of one of the input parameters was too large for this process to handle.",
     390        "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.",
     391        "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.",
     392        "One of the identifiers passed does not match with any of the processes offered by this server.",
     393        "The process does not permit the desired execution mode.",
     394        "One or more of the input identifiers passed does not match with any of the input identifiers of this process.",
     395        "One or more of the output identifiers passed does not match with any of the input identifiers of this process.",
     396        "One of the referenced input data sets was inaccessible.",
     397        "The size of one of the input parameters was too large for this process to handle.",
     398        "Too many input items have been specified.",
     399        "Too many output items have been specified.",
     400        "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.",
     401        "One or more of inputs for which the service was able to retrieve the data but could not read it.",
     402        "",
     403        "The JobID from the request does not match any of the Jobs running on this server.",
     404        "The result for the requested JobID has not yet been generated."
    377405  };
    378406
     
    392420  ZOO_DLL_EXPORT void freeMap(map**);
    393421  ZOO_DLL_EXPORT void freeMaps(maps** mo);
    394  
    395 
     422  ZOO_DLL_EXPORT iotype* createIoType();
    396423  ZOO_DLL_EXPORT elements* createEmptyElements();
    397   ZOO_DLL_EXPORT elements* createElements(char*);
     424  ZOO_DLL_EXPORT elements* createElements(const char*);
    398425  ZOO_DLL_EXPORT void setElementsName(elements**,char*);
    399426  ZOO_DLL_EXPORT bool hasElement(elements*,const char*);
     
    402429  ZOO_DLL_EXPORT void freeElements(elements**);
    403430  ZOO_DLL_EXPORT void setServiceName(service**,char*);
     431  ZOO_DLL_EXPORT service* createService();
    404432  ZOO_DLL_EXPORT void freeService(service**);
    405433  ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*);
    406434  ZOO_DLL_EXPORT void addIntToMap(map*,const char*,const int);
     435  ZOO_DLL_EXPORT void addIntToMapArray(map*,const char*,int,const int);
    407436  ZOO_DLL_EXPORT map* addToMapWithSize(map*,const char*,const char*,int);
    408437  ZOO_DLL_EXPORT void addMapToMap(map**,map*);
     
    446475  ZOO_DLL_EXPORT bool nonempty(map* map);
    447476  ZOO_DLL_EXPORT bool hasvalue(maps* source, const char* node, const char* key, map** kvp);
     477#ifdef __cplusplus
    448478  ZOO_DLL_EXPORT void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message = NULL);
    449   ZOO_DLL_EXPORT void logMessage(const char* source, const char* function, int line, const char* file = NULL, const char* message = NULL); 
     479  ZOO_DLL_EXPORT void logMessage(const char* source, const char* function, int line, const char* file = NULL, const char* message = NULL);
     480#endif
    450481  #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message))
    451482  #define zooLog logMessage(__FILE__, __func__, __LINE__) 
    452  
     483
    453484#ifdef __cplusplus
    454485}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

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