ZOO-Project
service.h
Go to the documentation of this file.
1 /*
2  * Author : GĂ©rald FENOY
3  *
4  * Copyright (c) 2009-2024 GeoLabs SARL
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 
30 #include "version.h"
31 #ifdef WIN32
32 #define ZOO_DLL_EXPORT __declspec( dllexport )
33 #else
34 #define ZOO_DLL_EXPORT
35 #endif
36 
37 // ISO8601 compatible date format (RFC 3339)
38 #define zDateFormat "%Y-%m-%dT%H:%M:%SZ"
39 
40 // Debug Messages date format
41 #define zLogDateFormat "%Y-%m-%d %H:%M:%S"
42 
43 #include <sys/time.h>
44  // knut: add bool if necessary
45 #ifndef __cplusplus
46 #ifndef WIN32
47 #include <stdbool.h>
48 #else
49 typedef int bool;
50 #define false 0
51 #define true 1
52 #endif
53 #endif
54 #ifndef __bool_true_false_are_defined
55 #define __bool_true_false_are_defined 1
56 #endif
57 
58 #ifdef WIN32
59 #define strtok_r strtok_s
60 #define strncasecmp _strnicmp
61 #define strcasecmp _stricmp
62 #if defined(_MSC_VER) && _MSC_VER < 1900
63 #define snprintf _snprintf
64 #endif
65 #define zStrdup _strdup
66 #define zMkdir _mkdir
67 #define zGetpid _getpid
68 #define zOpen _open
69 #define zClose _close
70 #define zUnlink _unlink
71 #define zDup _dup
72 #define zDup2 _dup2
73 #define zWrite _write
74 #define zSleep Sleep
75 #define zGetCwd _getcwd
76 #include <sys/timeb.h>
77 
78 struct ztimeval {
79  long tv_sec; /* seconds */
80  long tv_usec; /* and microseconds */
81 };
82 static int zGettimeofday(struct ztimeval* tp, void* tzp)
83 {
84  if (tp == 0) {
85  return -1;
86  }
87 
88  struct _timeb theTime;
89  _ftime(&theTime);
90  tp->tv_sec = theTime.time;
91  tp->tv_usec = theTime.millitm * 1000;
92 
93  return 0; // The gettimeofday() function shall return 0 on success
94 }
95 
96 #define zStatStruct struct _stati64
97 #define zStat _stati64
98 
99 #else
100 #include <sys/stat.h>
104 #define zStrdup strdup
105 
108 static int zMkdir(const char* pccPath){
109  return mkdir(pccPath,0777);
110 }
114 #define zOpen open
115 
118 #define zClose close
119 
122 #define zUnlink unlink
123 
126 #define zDup dup
127 
130 #define zDup2 dup2
131 
134 #define zWrite write
135 #include "unistd.h"
139 static int zSleep(const long millisecond){
140  return usleep(millisecond*1000);
141 }
145 #define zGettimeofday gettimeofday
146 
149 #define ztimeval timeval
150 
153 #define zGetpid getpid
154 
155 #define zStatStruct struct stat64
156 #define zStat stat64
157 
158 #define zGetCwd getcwd
159 
160 #endif
161 
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165 
166 #ifdef WIN32
167 #ifdef USE_MS
168 #include <mapserver.h>
169 #endif
170 #endif
171 #include <stdlib.h>
172 #include <stdarg.h>
173 #include <ctype.h>
174 
175 #include <stdio.h>
176 
177 #include <string.h>
178 #ifndef WIN32
179 #include <ctype.h>
180 #include <stdbool.h>
181 #endif
182 
186 #define SERVICE_ACCEPTED 0
187 
190 #define SERVICE_STARTED 1
191 
194 #define SERVICE_PAUSED 2
195 
198 #define SERVICE_SUCCEEDED 3
199 
202 #define SERVICE_FAILED 4
203 
206 #define SERVICE_DISMISSED 5
207 
210 #define SERVICE_DEPLOYED 6
211 
214 #define SERVICE_UNDEPLOYED 7
215 
219 #define TIME_SIZE 40
220 
224 #define ZOO_DEBUG_LEVEL_TRACE 0
225 
228 #define ZOO_DEBUG_LEVEL_DEBUG 1
229 
232 #define ZOO_DEBUG_LEVEL_INFO 2
233 
236 #define ZOO_DEBUG_LEVEL_SUCCESS 3
237 
240 #define ZOO_DEBUG_LEVEL_WARNING 4
241 
244 #define ZOO_DEBUG_LEVEL_ERROR 5
245 
248 #define ZOO_DEBUG_LEVEL_FATAL 6
249 
253 static const char* pccLogLevel[7]={
254  "TRACE",
255  "DEBUG",
256  "INFO",
257  "SUCCESS",
258  "WARNING",
259  "ERROR",
260  "CRITICAL"
261 };
262 
266 static int iZooLogLevel=1;
267 
271 static int iMinZooLogLevel=0;
272 
295 #define ZOO_DEBUG(message) _ZOO_DEBUG(message,__FILE__,__func__,__LINE__)
296 
328 #define ZOO_COLOR_START "\e[0;"
329 
333 #define ZOO_COLOR_START_BOLD "\e[1;"
334 
338 #define ZOO_COLOR_STANDARD "3"
339 
343 #define ZOO_COLOR_HIGH_INTENSITY "9"
344 
345 #define ZOO_COLOR_BLACK "0m"
346 #define ZOO_COLOR_RED "1m"
347 #define ZOO_COLOR_GREEN "2m"
348 #define ZOO_COLOR_YELLOW "3m"
349 #define ZOO_COLOR_BLUE "4m"
350 #define ZOO_COLOR_MAGENTA "5m"
351 #define ZOO_COLOR_CYAN "6m"
352 #define ZOO_COLOR_WHITE "7m"
353 
354 #define ZOO_COLOR_START_BACKGROUND "\e[4"
355 #define ZOO_COLOR_START_BACKGROUND_HIGH_INTENSITY "\e[0;10"
356 
357 #define ZOO_COLOR_RESET "\e[0m"
358 
359 #include "time.h"
383 #define _ZOO_DEBUG(message,pccFile,pccFunc,iLine) \
384 do {\
385  if(iZooLogLevel<=iMinZooLogLevel)\
386  break;\
387  \
388  int iSaTTY=isatty(2); \
389  const struct tm *pcsTm; \
390  time_t ttNow; \
391  size_t stLen; \
392  struct ztimeval sztv; \
393  ttNow = time ( NULL ); \
394  pcsTm = localtime ( &ttNow ); \
395  char* pcaLocalTime = (char*)malloc((TIME_SIZE+1)*sizeof(char)); \
396  zGettimeofday(&sztv, NULL); \
397  int iMillisec = int(sztv.tv_usec/1000.0); \
398  if (iMillisec>=1000) { \
399  iMillisec -=1000; \
400  sztv.tv_sec++; \
401  } \
402  stLen = strftime ( pcaLocalTime, TIME_SIZE, zLogDateFormat, pcsTm ); \
403  char pcExtra[8]={0}; \
404  int iLength=8; \
405  int iCounter=0; \
406  for(int iCnt=strlen(pccLogLevel[iZooLogLevel]);iCnt<8;iCnt++){ \
407  pcExtra[iCounter]=' '; \
408  iCounter++; \
409  } \
410  char* pcaFormated=NULL; \
411  char acFormated[64]={0}; \
412  char* apcaArgv[7]; \
413  int aiTypes[7]={0,0,0,0,0,0,0}; \
414  int iInternalCnt=0; \
415  for(int iCnt=0;iCnt<strlen(ZOO_LOG_FORMAT);iCnt++){ \
416  if(ZOO_LOG_FORMAT[iCnt]=='%'){ \
417  int iLen=strlen(acFormated); \
418  acFormated[iLen]=ZOO_LOG_FORMAT[iCnt]; \
419  acFormated[iLen+1]='s'; \
420  const char* pcColor="\e[0;97m"; \
421  switch(iZooLogLevel){ \
422  case ZOO_DEBUG_LEVEL_TRACE:\
423  pcColor=ZOO_COLOR_START_BOLD\
424  ZOO_COLOR_STANDARD \
425  ZOO_COLOR_WHITE;\
426  break;\
427  case ZOO_DEBUG_LEVEL_DEBUG:\
428  pcColor=ZOO_COLOR_START_BOLD\
429  ZOO_COLOR_HIGH_INTENSITY\
430  ZOO_COLOR_CYAN;\
431  break;\
432  case ZOO_DEBUG_LEVEL_INFO:\
433  pcColor=ZOO_COLOR_START_BOLD\
434  ZOO_COLOR_HIGH_INTENSITY\
435  ZOO_COLOR_WHITE;\
436  break;\
437  case ZOO_DEBUG_LEVEL_SUCCESS:\
438  pcColor=ZOO_COLOR_START_BOLD\
439  ZOO_COLOR_HIGH_INTENSITY\
440  ZOO_COLOR_GREEN;\
441  break;\
442  case ZOO_DEBUG_LEVEL_WARNING:\
443  pcColor=ZOO_COLOR_START_BOLD\
444  ZOO_COLOR_HIGH_INTENSITY\
445  ZOO_COLOR_YELLOW;\
446  break;\
447  case ZOO_DEBUG_LEVEL_ERROR:\
448  pcColor=ZOO_COLOR_START_BOLD\
449  ZOO_COLOR_HIGH_INTENSITY\
450  ZOO_COLOR_RED;\
451  break;\
452  case ZOO_DEBUG_LEVEL_FATAL:\
453  pcColor=ZOO_COLOR_START_BACKGROUND\
454  ZOO_COLOR_RED\
455  ZOO_COLOR_START_BOLD\
456  ZOO_COLOR_HIGH_INTENSITY\
457  ZOO_COLOR_WHITE;\
458  break;\
459  } \
460  if(ZOO_LOG_FORMAT[iCnt+1]=='d'){ \
461  /* DATE Format: %s.%03d */ \
462  apcaArgv[iInternalCnt]=(char*) malloc(37*sizeof(char)); \
463  if(iSaTTY>0)\
464  sprintf(apcaArgv[iInternalCnt],\
465  ZOO_COLOR_START_BOLD\
466  ZOO_COLOR_STANDARD\
467  ZOO_COLOR_GREEN\
468  "%s.%03d"\
469  ZOO_COLOR_RESET,\
470  pcaLocalTime,iMillisec); \
471  else\
472  sprintf(apcaArgv[iInternalCnt],"%s.%03d",pcaLocalTime,iMillisec); \
473  } \
474  else if(ZOO_LOG_FORMAT[iCnt+1]=='l'){ \
475  /* Debug level: %s %s */ \
476  apcaArgv[iInternalCnt]=(char*) malloc(36*sizeof(char)); \
477  if(iSaTTY>0)\
478  sprintf(apcaArgv[iInternalCnt],\
479  "%s%s%s"\
480  ZOO_COLOR_RESET,\
481  pcColor,\
482  pccLogLevel[iZooLogLevel],\
483  pcExtra); \
484  else\
485  sprintf(apcaArgv[iInternalCnt],"%s %s",pccLogLevel[iZooLogLevel],pcExtra); \
486  } \
487  else if(ZOO_LOG_FORMAT[iCnt+1]=='p'){ \
488  /* Process identifier: %p */ \
489  apcaArgv[iInternalCnt]=(char*) malloc(10*sizeof(char)); \
490  sprintf(apcaArgv[iInternalCnt],"%d",getpid()); \
491  } \
492  else if(ZOO_LOG_FORMAT[iCnt+1]=='f'){ \
493  /* File name: %f */ \
494  apcaArgv[iInternalCnt]=(char*) malloc((strlen(pccFile)+8)*sizeof(char)); \
495  if(iSaTTY>0)\
496  sprintf(apcaArgv[iInternalCnt],\
497  ZOO_COLOR_START\
498  ZOO_COLOR_STANDARD\
499  ZOO_COLOR_CYAN\
500  "%s",\
501  pccFile); \
502  else\
503  sprintf(apcaArgv[iInternalCnt],"%s",pccFile); \
504  } \
505  else if(ZOO_LOG_FORMAT[iCnt+1]=='u'){ \
506  /* Function name: %u */ \
507  apcaArgv[iInternalCnt]=(char*) malloc((strlen(pccFunc)+1)*sizeof(char)); \
508  sprintf(apcaArgv[iInternalCnt],"%s",pccFunc); \
509  } \
510  else if(ZOO_LOG_FORMAT[iCnt+1]=='i'){ \
511  /* Line number: %i */ \
512  apcaArgv[iInternalCnt]=(char*) malloc(14*sizeof(char)); \
513  if(iSaTTY>0)\
514  sprintf(apcaArgv[iInternalCnt],\
515  "%d"\
516  ZOO_COLOR_RESET,\
517  iLine); \
518  else\
519  sprintf(apcaArgv[iInternalCnt],"%d",iLine); \
520  } \
521  else if(ZOO_LOG_FORMAT[iCnt+1]=='m'){ \
522  /* Message: %m */ \
523  apcaArgv[iInternalCnt]=(char*) malloc((strlen(message)+25)*sizeof(char)); \
524  if(iSaTTY>0)\
525  sprintf(apcaArgv[iInternalCnt],\
526  "%s%s"\
527  ZOO_COLOR_RESET,\
528  pcColor,message); \
529  else\
530  sprintf(apcaArgv[iInternalCnt],"%s",message); \
531  } \
532  iInternalCnt++; \
533  iCnt++; \
534  }else{ \
535  int iLen=0; \
536  if(acFormated[0]!=0)\
537  iLen=strlen(acFormated);\
538  acFormated[iLen]=ZOO_LOG_FORMAT[iCnt];\
539  acFormated[iLen+1]=0;\
540  } \
541  } \
542  /* Minimal should be 2 (for the file+line) */ \
543  switch(iInternalCnt) {\
544  case 1: \
545  fprintf(stderr,(char*)acFormated,\
546  apcaArgv[0] \
547  ); \
548  break; \
549  case 2: \
550  fprintf(stderr,(char*)acFormated,\
551  apcaArgv[0], \
552  apcaArgv[1] \
553  ); \
554  break; \
555  case 3: \
556  fprintf(stderr,(char*)acFormated,\
557  apcaArgv[0], \
558  apcaArgv[1], \
559  apcaArgv[2] \
560  ); \
561  break; \
562  case 4: \
563  fprintf(stderr,(char*)acFormated,\
564  apcaArgv[0], \
565  apcaArgv[1], \
566  apcaArgv[2], \
567  apcaArgv[3] \
568  ); \
569  break; \
570  case 5: \
571  fprintf(stderr,(char*)acFormated,\
572  apcaArgv[0], \
573  apcaArgv[1], \
574  apcaArgv[2], \
575  apcaArgv[3], \
576  apcaArgv[4] \
577  ); \
578  break; \
579  case 6: \
580  fprintf(stderr,(char*)acFormated,\
581  apcaArgv[0], \
582  apcaArgv[1], \
583  apcaArgv[2], \
584  apcaArgv[3], \
585  apcaArgv[4], \
586  apcaArgv[5] \
587  ); \
588  break; \
589  default: \
590  fprintf(stderr,(char*)acFormated,\
591  apcaArgv[0], \
592  apcaArgv[1], \
593  apcaArgv[2], \
594  apcaArgv[3], \
595  apcaArgv[4], \
596  apcaArgv[5], \
597  apcaArgv[6] \
598  ); \
599  break; \
600  }\
601  /* myPrint(acFormated,apcaArgv) */ \
602  free(pcaLocalTime); \
603  for(int iCnt=iInternalCnt-1;iCnt>=0;iCnt--){ \
604  free(apcaArgv[iCnt]); \
605  } \
606 } while(0)
607 
611 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*3)+sizeof(char*)+((sizeof(map*) + sizeof(iotype*))*2)+(2*sizeof(elements*)))
612 
615 //#define MAP_SIZE (2*sizeof(char*))+sizeof(NULL) // knut: size of NULL pointer may be different from regular pointer (platform dependent)
616 #define MAP_SIZE (2*sizeof(char*))+sizeof(map*)
617 
620 //#define IOTYPE_SIZE MAP_SIZE+sizeof(NULL)
621 #define IOTYPE_SIZE sizeof(map*) + sizeof(iotype*)
622 
625 //#define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+MAP_SIZE
626 #define MAPS_SIZE sizeof(char*)+sizeof(map*)+(2*sizeof(maps*))
627 
630 //#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
631 #define SERVICE_SIZE sizeof(char*) + 3*sizeof(map*) + 2*sizeof(elements*)
632 
635 //#define SERVICES_SIZE SERVICE_SIZE+sizeof(services*)
636 #define SERVICES_SIZE sizeof(service*)+sizeof(services*)
637 
640 //#define REGISTRY_SIZE SERVICES_SIZE+sizeof(char*)
641 #define REGISTRY_SIZE sizeof(char*)+sizeof(services*)+sizeof(registry*)
642 
643 #define SHMSZ 27
644 
645 #include "version.h"
646 
647 #ifdef DEBUG_STACK
648  void debugStack(const char* file,const int line){
649  int stack;
650  fprintf(stderr,"stack %p (%s: %d) \n",&stack,file,line);
651  }
652 #endif
653 
657  typedef struct map{
658  char* name;
659  char* value;
660  struct map* next;
661  } map;
662 
663 #ifdef WIN32
664 #define NULLMAP ((map*) 0)
665 // knut: see new definition above
666 //#define bool int
667 //#define true 1
668 //#define false 0
669 #else
670 #define NULLMAP NULL
671 #endif
672 
678  typedef struct maps{
679  char* name;
680  struct map* content;
681  struct maps* child;
682  struct maps* next;
683  } maps;
684 
690  typedef struct iotype{
691  struct map* content;
692  struct iotype* next;
693  } iotype;
694 
700  typedef struct elements{
701  char* name;
702  struct map* content;
703  struct map* metadata;
705  char* format;
706  struct iotype* defaults;
707  struct iotype* supported;
708  struct elements* child;
709  struct elements* next;
710  } elements;
711 
715  typedef struct service{
716  char* name;
717  struct map* content;
718  struct map* metadata;
720  struct elements* inputs;
721  struct elements* outputs;
722  } service;
723 
727  typedef struct services{
728  struct service* content;
729  struct services* next;
730  } services;
731 
735  typedef struct registry{
736  char *name;
737  struct services* content;
738  struct registry* next;
739  } registry;
740 
744  static const char* ZOO_STATUS[] = {
745  "SERVICE_ACCEPTED",
746  "SERVICE_STARTED",
747  "SERVICE_PAUSED",
748  "SERVICE_SUCCEEDED",
749  "SERVICE_FAILED",
750  "SERVICE_DISMISSED",
751  "SERVICE_DEPLOYED",
752  "SERVICE_UNDEPLOYED",
753  NULL
754  };
755 
756  // knut
758  /*
759  * StatusOK is not a WPS exception, it is added
760  * here for convenience.
761  */
763  /*
764  * See WPS 1.0 specification, Table 38 and Table 62.
765  */
774  /*
775  * See WPS 2.0 specification, Tables 41, 46, 48, and 50.
776  */
790  };
791 
796  static const char* const WPSExceptionCode[] = {
797  "StatusOK",
798  "MissingParameterValue",
799  "InvalidParameterValue",
800  "NoApplicableCode",
801  "NotEnoughStorage",
802  "ServerBusy",
803  "FileSizeExceeded",
804  "StorageNotSupported",
805  "VersionNegotiationFailed",
806  "NoSuchProcess",
807  "NoSuchMode",
808  "NoSuchInput",
809  "NoSuchOutput",
810  "DataNotAccessible",
811  "SizeExceeded",
812  "TooManyInputs",
813  "TooManyOutputs",
814  "NoSuchFormat",
815  "WrongInputData",
816  "InternalServerError",
817  "NoSuchJob",
818  "ResultNotReady",
819  "InvalidQueryParameterValue",
820  "DuplicatedProcess",
821  "ImmutableProcess",
822  "UnsupportedMediaType",
823  "WorkflowNotFound"
824  };
825 
830  static const int OAPIPCorrespondances[8][2] = {
831  {9,0},
832  {20,1},
833  {21,2},
834  {22,3},
835  {23,4},
836  {24,5},
837  {25,6},
838  {26,7}
839  };
840 
850  static const int OAPIPExceptionLimits[1][2] = {
851  {4,1}
852  };
853 
858  static const char* const OAPIPExceptionCode[] = {
859  "no-such-process",
860  "no-such-job",
861  "result-not-ready",
862  "invalid-query-parameter-value",
863  "duplicated-process",
864  "immutable-process",
865  "unsupported-media-type",
866  "workflow-not-found"
867  };
868 
872  static const char* const OAPIPSupportedContentTypes[] = {
873  "application/json",
874  "application/cwl",
875  "application/cwl+yaml",
876  "application/ogcapppkg+json",
877  NULL
878  };
879 
884  static const char* const WPSExceptionText[] = {
885  "No problem detected",
886  "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.",
887  "Operation request contains an invalid parameter value.",
888  "No other exceptionCode specified by this service and server applies to this exception.",
889  "The server does not have enough space available to store the inputs and outputs associated with the request.",
890  "The server is too busy to accept and queue the request at this time.",
891  "The file size of one of the input parameters was too large for this process to handle.",
892  "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.",
893  "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.",
894  "One of the identifiers passed does not match with any of the processes offered by this server.",
895  "The process does not permit the desired execution mode.",
896  "One or more of the input identifiers passed does not match with any of the input identifiers of this process.",
897  "One or more of the output identifiers passed does not match with any of the input identifiers of this process.",
898  "One of the referenced input data sets was inaccessible.",
899  "The size of one of the input parameters was too large for this process to handle.",
900  "Too many input items have been specified.",
901  "Too many output items have been specified.",
902  "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.",
903  "One or more of inputs for which the service was able to retrieve the data but could not read it.",
904  "",
905  "The JobID from the request does not match any of the Jobs running on this server.",
906  "The result for the requested JobID has not yet been generated."
907  };
908 
909  ZOO_DLL_EXPORT int zooDebugPrint( const char * format, ... );
910  ZOO_DLL_EXPORT void _dumpMap(map*);
911  ZOO_DLL_EXPORT void dumpMap(map*);
912  ZOO_DLL_EXPORT void dumpMaps(maps* m);
913  ZOO_DLL_EXPORT void dumpMapToFile(map*,FILE*); // (used only internally)
914  ZOO_DLL_EXPORT void dumpMapsToFile(maps*,char*,int);
915  ZOO_DLL_EXPORT map* createMap(const char*,const char*);
916  ZOO_DLL_EXPORT maps* createMaps(const char*);
917  ZOO_DLL_EXPORT int count(map*);
919  ZOO_DLL_EXPORT int countMapName(map*,const char*);
920  ZOO_DLL_EXPORT int countMapNameValue(map*,const char*);
921  ZOO_DLL_EXPORT bool hasKey(map*,const char*);
922  ZOO_DLL_EXPORT maps* getMaps(maps*,const char*);
923  ZOO_DLL_EXPORT map* getMap(map*,const char*);
925  ZOO_DLL_EXPORT map* getMapFromMaps(maps*,const char*,const char*);
926  ZOO_DLL_EXPORT void freeMap(map**);
927  ZOO_DLL_EXPORT void freeMaps(maps** mo);
930  ZOO_DLL_EXPORT elements* createElements(const char*);
932  ZOO_DLL_EXPORT bool hasElement(elements*,const char*);
936  ZOO_DLL_EXPORT void setServiceName(service**,char*);
939  ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*);
940  ZOO_DLL_EXPORT void addToMapA(map*,const char*,const char*);
941  ZOO_DLL_EXPORT void addIntToMap(map*,const char*,const int);
942  ZOO_DLL_EXPORT void addIntToMapArray(map*,const char*,int,const unsigned long);
943  ZOO_DLL_EXPORT map* addToMapWithSize(map*,const char*,const char*,int);
946  ZOO_DLL_EXPORT map* getMapOrFill(map**,const char*,const char*);
947  ZOO_DLL_EXPORT bool contains(map*,map*);
949  ZOO_DLL_EXPORT void loadMapBinary(map**,map*,int);
953  ZOO_DLL_EXPORT map* getMapArray(map*,const char*,int);
954  ZOO_DLL_EXPORT char* getMapArrayKey(map*,const char*,int);
955  ZOO_DLL_EXPORT void setMapArray(map*,const char*,int,const char*);
958  ZOO_DLL_EXPORT void setMapInMaps(maps*,const char*,const char*,const char*);
970  ZOO_DLL_EXPORT void inheritMap(map**,map*);
974  ZOO_DLL_EXPORT void mapsToCharXXX(maps*,char***);
975  ZOO_DLL_EXPORT void charxxxToMaps(char***,maps**);
976  // OGC-API - Processes - Part 1: Core processes list restriction
977  ZOO_DLL_EXPORT void updateCnt(maps*, const char*, const char*);
978  ZOO_DLL_EXPORT bool compareCnt(maps*, const char*, const char*);
979 #if defined(_MSC_VER) && _MSC_VER < 1800
980  // snprintf for Visual Studio compiler;
981  // it is also used by services (e.g., GetStatus), therefore exported to shared library
982  ZOO_DLL_EXPORT int snprintf(char *buffer, size_t n, const char *format, ...);
983 #endif
984 
985  // knut: some new utility functions; logMessage is primarily intended for debugging
987  ZOO_DLL_EXPORT bool hasvalue(maps* source, const char* node, const char* key, map** kvp);
988 #ifdef __cplusplus
989  ZOO_DLL_EXPORT void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message = NULL);
990  ZOO_DLL_EXPORT void logMessage(const char* source, const char* function, int line, const char* file = NULL, const char* message = NULL);
991 #endif
992  #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message))
993  #define zooLog logMessage(__FILE__, __func__, __LINE__)
994 
995  // knut : function for pre-allocated memory for a map value;
996  // processing algorithms may be able to write directly to this space, thereby avoiding unneccesary copying of data
997  ZOO_DLL_EXPORT char* allocateMapValue(map* node, size_t num_bytes);
998 
999  ZOO_DLL_EXPORT char* getValueFromMaps(maps*,const char*);
1000  ZOO_DLL_EXPORT void _translateChar (char*, char, char);
1001 #ifdef __cplusplus
1002 }
1003 #endif
1004 
1005 #endif
1006 
1007 #ifdef LOG_CONSOLE_ENABLED
1008  void logConsoleMessage(const char*);
1009 #endif
freeIOType
ZOO_DLL_EXPORT void freeIOType(iotype **)
Free allocated memory of an iotype.
Definition: service.c:471
NoSuchInput
@ NoSuchInput
Definition: service.h:779
services
struct services services
Services chained list.
NoSuchOutput
@ NoSuchOutput
Definition: service.h:780
dupMaps
ZOO_DLL_EXPORT maps * dupMaps(maps **)
Duplicate a Maps.
Definition: service.c:936
addMapToIoType
ZOO_DLL_EXPORT void addMapToIoType(iotype **, map *)
Add a map to iotype.
Definition: service.c:765
NoSuchMode
@ NoSuchMode
Definition: service.h:778
iotype
Not named linked list.
Definition: service.h:690
inheritIOType
ZOO_DLL_EXPORT void inheritIOType(iotype **, iotype *)
Apply inheritance to an out iotype from a reference in iotype.
Definition: service.c:1716
ZOO_STATUS
static const char * ZOO_STATUS[]
Statuses list.
Definition: service.h:744
freeMap
ZOO_DLL_EXPORT void freeMap(map **)
Free allocated memory of a map.
Definition: service.c:385
getLastMap
ZOO_DLL_EXPORT map * getLastMap(map *)
Access the last map.
Definition: service.c:351
FileSizeExceeded
@ FileSizeExceeded
Definition: service.h:771
dumpMapsToFile
ZOO_DLL_EXPORT void dumpMapsToFile(maps *, char *, int)
Dump a maps to a file, see _dumpMapsToFile().
Definition: service.c:147
NotEnoughStorage
@ NotEnoughStorage
Definition: service.h:769
elements::next
struct elements * next
the pointer to the next element if any (or NULL)
Definition: service.h:709
TooManyOutputs
@ TooManyOutputs
Definition: service.h:784
freeMaps
ZOO_DLL_EXPORT void freeMaps(maps **mo)
Free allocated memory of a maps.
Definition: service.c:409
OAPIPExceptionCode
static const char *const OAPIPExceptionCode[]
OGC API - Processes exception codes.
Definition: service.h:858
hasKey
ZOO_DLL_EXPORT bool hasKey(map *, const char *)
Verify if a key exist in a map.
Definition: service.c:295
TooManyInputs
@ TooManyInputs
Definition: service.h:783
n
pair PAIR FOUND n
Definition: service_conf.y:613
elements::content
struct map * content
the content map
Definition: service.h:702
getMapArray
ZOO_DLL_EXPORT map * getMapArray(map *, const char *, int)
Access a specific map array element.
Definition: service.c:998
NoSuchProcess
@ NoSuchProcess
Definition: service.h:777
getMap
ZOO_DLL_EXPORT map * getMap(map *, const char *)
Access a specific map.
Definition: service.c:333
addToElements
ZOO_DLL_EXPORT void addToElements(elements **, elements *)
Add an elements to another elements.
Definition: service.c:1458
inheritElements
ZOO_DLL_EXPORT void inheritElements(elements **, elements *)
Apply inheritance to an out elements from a reference in elements.
Definition: service.c:1739
setServiceName
ZOO_DLL_EXPORT void setServiceName(service **, char *)
Set the name of a service.
Definition: service.c:1473
dumpMapToFile
ZOO_DLL_EXPORT void dumpMapToFile(map *, FILE *)
Dump a map to a file.
Definition: service.c:87
logMessage
void logMessage(const char *pccSource, const char *pccFunction, int iLne, const char *pccFile, const char *pccMessage)
Print debug message.
Definition: service.c:1925
ServerBusy
@ ServerBusy
Definition: service.h:770
map::value
char * value
the value
Definition: service.h:659
ResultNotReady
@ ResultNotReady
Definition: service.h:789
snprintf
snprintf(current_maps->name,(strlen($1)+1),"%s", $1)
addMapsToMaps
ZOO_DLL_EXPORT void addMapsToMaps(maps **, maps *)
Add a maps at the end of another maps.
Definition: service.c:963
dumpMap
ZOO_DLL_EXPORT void dumpMap(map *)
Dump a map on stderr, see _dumpMap()
Definition: service.c:73
service
Metadata information about a full Service.
Definition: service.h:715
services::content
struct service * content
the content service pointer
Definition: service.h:728
elements
Metadata information about input or output.
Definition: service.h:700
service::additional_parameters
struct map * additional_parameters
the additional parameters map
Definition: service.h:719
VersionNegotiationFailed
@ VersionNegotiationFailed
Definition: service.h:773
getMapArrayKey
ZOO_DLL_EXPORT char * getMapArrayKey(map *, const char *, int)
Get the key name for a specific map array element.
Definition: service.c:1025
registry
struct registry registry
Profile registry.
OAPIPExceptionLimits
static const int OAPIPExceptionLimits[1][2]
OGC API - Processes exception limits.
Definition: service.h:850
maps
struct maps maps
linked list of map pointer
ztimeval
#define ztimeval
The crossplatform timeval alias.
Definition: service.h:149
createEmptyElements
ZOO_DLL_EXPORT elements * createEmptyElements()
Create an empty elements.
Definition: service.c:1206
NoSuchFormat
@ NoSuchFormat
Definition: service.h:785
zooDebugPrint
ZOO_DLL_EXPORT int zooDebugPrint(const char *format,...)
StorageNotSupported
@ StorageNotSupported
Definition: service.h:772
pccLogLevel
static const char * pccLogLevel[7]
The global log level names.
Definition: service.h:253
getMapType
ZOO_DLL_EXPORT map * getMapType(map *)
Access the map "type".
Definition: service.c:1098
getMapFromMaps
ZOO_DLL_EXPORT map * getMapFromMaps(maps *, const char *, const char *)
Access a specific map from a maps.
Definition: service.c:370
services::next
struct services * next
the pointer to the next services*
Definition: service.h:729
addServiceToRegistry
ZOO_DLL_EXPORT bool addServiceToRegistry(registry **, char *, service *)
Add a service to the registry.
Definition: service.c:1590
compareCnt
ZOO_DLL_EXPORT bool compareCnt(maps *, const char *, const char *)
Compare a value with conf / lenv / serviceCnt.
Definition: service.c:2179
createIoType
ZOO_DLL_EXPORT iotype * createIoType()
Create a new iotype*.
Definition: service.c:159
elements::supported
struct iotype * supported
the supported iotype
Definition: service.h:707
WrongInputData
@ WrongInputData
Definition: service.h:786
registry::name
char * name
the name
Definition: service.h:736
_dumpMap
ZOO_DLL_EXPORT void _dumpMap(map *)
Dump a map on stderr.
Definition: service.c:58
dumpElementsAsYAML
ZOO_DLL_EXPORT void dumpElementsAsYAML(elements *, int)
Dump an elements on stderr using the YAML syntaxe.
Definition: service.c:1306
contains
ZOO_DLL_EXPORT bool contains(map *, map *)
Verify if a map is contained in another map.
Definition: service.c:807
elements::name
char * name
the name
Definition: service.h:701
service::outputs
struct elements * outputs
the outputs elements
Definition: service.h:721
createMap
ZOO_DLL_EXPORT map * createMap(const char *, const char *)
Create a new map.
Definition: service.c:173
allocateMapValue
ZOO_DLL_EXPORT char * allocateMapValue(map *node, size_t num_bytes)
Definition: service.c:2051
map
struct map map
KVP linked list.
countMapName
ZOO_DLL_EXPORT int countMapName(map *, const char *)
Count number of a specific map in a map.
Definition: service.c:234
OAPIPCorrespondances
static const int OAPIPCorrespondances[8][2]
WPS exception codes to OGC API - Processes ones.
Definition: service.h:830
hasElement
ZOO_DLL_EXPORT bool hasElement(elements *, const char *)
Verify if an elements contains a name equal to the given key.
Definition: service.c:438
WPSExceptionText
static const char *const WPSExceptionText[]
WPS exception text (associated with the exception code)
Definition: service.h:884
addMapToMap
ZOO_DLL_EXPORT void addMapToMap(map **, map *)
Add a map at the end of another map.
Definition: service.c:735
registry::content
struct services * content
the content services pointer
Definition: service.h:737
iotype
struct iotype iotype
Not named linked list.
addIntToMapArray
ZOO_DLL_EXPORT void addIntToMapArray(map *, const char *, int, const unsigned long)
Add a key and an integer value to an existing map array.
Definition: service.c:1085
DataNotAccessible
@ DataNotAccessible
Definition: service.h:781
getServiceFromRegistry
ZOO_DLL_EXPORT service * getServiceFromRegistry(registry *, char *, char *)
Access a service in the registry.
Definition: service.c:1673
countMapNameValue
ZOO_DLL_EXPORT int countMapNameValue(map *, const char *)
Count number of a specific map value in a map.
Definition: service.c:251
dumpService
ZOO_DLL_EXPORT void dumpService(service *)
Dump a service on stderr.
Definition: service.c:1487
maps::next
struct maps * next
the pointer to the next maps if any or NULL
Definition: service.h:682
nonempty
ZOO_DLL_EXPORT bool nonempty(map *map)
Verify that a map has a value.
Definition: service.c:1873
freeRegistry
ZOO_DLL_EXPORT void freeRegistry(registry **)
Free memory allocated for the registry.
Definition: service.c:1647
MissingParameterValue
@ MissingParameterValue
Definition: service.h:766
dumpMaps
ZOO_DLL_EXPORT void dumpMaps(maps *m)
Dump a maps on stderr, see dumpMap().
Definition: service.c:100
zMkdir
static int zMkdir(const char *pccPath)
The crossplatform mkdir alias.
Definition: service.h:108
InvalidParameterValue
@ InvalidParameterValue
Definition: service.h:767
getValueFromMaps
ZOO_DLL_EXPORT char * getValueFromMaps(maps *, const char *)
Definition: service.c:2074
maps
linked list of map pointer
Definition: service.h:678
addToMap
ZOO_DLL_EXPORT void addToMap(map *, const char *, const char *)
Add key value pair to an existing map.
Definition: service.c:578
createMaps
ZOO_DLL_EXPORT maps * createMaps(const char *)
Create a new maps with the given name.
Definition: service.c:187
WPSException
WPSException
Definition: service.h:757
SizeExceeded
@ SizeExceeded
Definition: service.h:782
setErrorMessage
void setErrorMessage(maps *&pmsaConf, const char *pccService, WPSException weExc, const char *pccMessage)
Definition: service.c:1903
getElements
ZOO_DLL_EXPORT elements * getElements(elements *, const char *)
Access a specific elements named key.
Definition: service.c:455
service::inputs
struct elements * inputs
the inputs elements
Definition: service.h:720
createService
ZOO_DLL_EXPORT service * createService()
Allocate memory for a service.
Definition: service.c:531
mapsToCharXXX
ZOO_DLL_EXPORT void mapsToCharXXX(maps *, char ***)
Convert a maps to a char*** (only used for Fortran support)
Definition: service.c:1807
iotype::content
struct map * content
the content map
Definition: service.h:691
services
Services chained list.
Definition: service.h:727
updateCnt
ZOO_DLL_EXPORT void updateCnt(maps *, const char *, const char *)
Update the counter value (in conf / lenv / serviceCnt.
Definition: service.c:2155
countMaps
ZOO_DLL_EXPORT int countMaps(maps *)
Count number of maps in a maps.
Definition: service.c:218
WPSExceptionCode
static const char *const WPSExceptionCode[]
Standard WPS exception codes.
Definition: service.h:796
map
KVP linked list.
Definition: service.h:657
map::name
char * name
the key
Definition: service.h:658
getMaps
ZOO_DLL_EXPORT maps * getMaps(maps *, const char *)
Access a specific maps.
Definition: service.c:315
maps::content
struct map * content
the content map
Definition: service.h:680
addMapsArrayToMaps
ZOO_DLL_EXPORT int addMapsArrayToMaps(maps **, maps *, char *)
Add a Maps containing a MapArray to a Maps.
Definition: service.c:1121
loadMapBinary
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:869
dumpRegistry
ZOO_DLL_EXPORT void dumpRegistry(registry *)
Print the registry on stderr.
Definition: service.c:1569
createElements
ZOO_DLL_EXPORT elements * createElements(const char *)
Create a named elements.
Definition: service.c:1226
elements::additional_parameters
struct map * additional_parameters
the additional parameters map
Definition: service.h:704
getIoTypeFromElement
ZOO_DLL_EXPORT iotype * getIoTypeFromElement(elements *, char *, map *)
Access a specific iotype from an elements.
Definition: service.c:833
iotype::next
struct iotype * next
the pointer to the next iotype if any or NULL
Definition: service.h:692
charxxxToMaps
ZOO_DLL_EXPORT void charxxxToMaps(char ***, maps **)
Convert a char*** to a maps (only used for Fortran support)
Definition: service.c:1843
service
struct service service
Metadata information about a full Service.
dumpServiceAsYAML
ZOO_DLL_EXPORT void dumpServiceAsYAML(service *)
Dump a service on stderr using the YAML syntaxe.
Definition: service.c:1517
registry::next
struct registry * next
the next registry pointer
Definition: service.h:738
map::next
struct map * next
the pointer to the next map if any or NULL
Definition: service.h:660
elements::format
char * format
the format: LiteralData or ComplexData or BoundingBoxData
Definition: service.h:705
addIntToMap
ZOO_DLL_EXPORT void addIntToMap(map *, const char *, const int)
Add a key and an integer value to an existing map.
Definition: service.c:676
dumpElements
ZOO_DLL_EXPORT void dumpElements(elements *)
Dump an elements on stderr.
Definition: service.c:1264
ZOO_DLL_EXPORT
#define ZOO_DLL_EXPORT
Definition: service.h:34
maps::child
struct maps * child
the child maps
Definition: service.h:681
elements::child
struct elements * child
the pointer to the children element if any (or NULL)
Definition: service.h:708
elements
struct elements elements
Metadata information about input or output.
OAPIPSupportedContentTypes
static const char *const OAPIPSupportedContentTypes[]
OGC API - Processes supported Content-Type list.
Definition: service.h:872
iZooLogLevel
static int iZooLogLevel
The global log level.
Definition: service.h:266
dupElements
ZOO_DLL_EXPORT elements * dupElements(elements *)
Duplicate an elements.
Definition: service.c:1390
_translateChar
ZOO_DLL_EXPORT void _translateChar(char *, char, char)
Replace a char by another one in a string.
Definition: service.c:2110
count
ZOO_DLL_EXPORT int count(map *)
Count number of map in a map.
Definition: service.c:202
zSleep
static int zSleep(const long millisecond)
The crossplatform sleep alias.
Definition: service.h:139
NoSuchJob
@ NoSuchJob
Definition: service.h:788
elements::metadata
struct map * metadata
the metadata map
Definition: service.h:703
freeElements
ZOO_DLL_EXPORT void freeElements(elements **)
Free allocated memory of an elements.
Definition: service.c:489
setMapInMaps
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:1177
maps::name
char * name
the maps name
Definition: service.h:679
StatusOK
@ StatusOK
Definition: service.h:762
registry
Profile registry.
Definition: service.h:735
service::metadata
struct map * metadata
the metadata map
Definition: service.h:718
service::content
struct map * content
the content map
Definition: service.h:717
loadMapBinaries
ZOO_DLL_EXPORT void loadMapBinaries(map **, map *)
Load binary values from a map (in) and add them to another map (out).
Definition: service.c:908
getMapOrFill
ZOO_DLL_EXPORT map * getMapOrFill(map **, const char *, const char *)
Access a specific map or set its value.
Definition: service.c:784
service::name
char * name
the name
Definition: service.h:716
freeService
ZOO_DLL_EXPORT void freeService(service **)
Free allocated memory of a service.
Definition: service.c:548
InternalServerError
@ InternalServerError
Definition: service.h:787
iMinZooLogLevel
static int iMinZooLogLevel
The global log level.
Definition: service.h:271
addToMapWithSize
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:703
NoApplicableCode
@ NoApplicableCode
Definition: service.h:768
setElementsName
ZOO_DLL_EXPORT void setElementsName(elements **, char *)
Set the name of an elements.
Definition: service.c:1247
elements::defaults
struct iotype * defaults
the default iotype
Definition: service.h:706
inheritMap
ZOO_DLL_EXPORT void inheritMap(map **, map *)
Apply inheritance to an out map from a reference in map.
Definition: service.c:1696
setMapArray
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:1045
dupService
ZOO_DLL_EXPORT service * dupService(service *)
Duplicate a service.
Definition: service.c:1550
inheritance
ZOO_DLL_EXPORT void inheritance(registry *, service **)
Apply inheritance to a service based on a registry.
Definition: service.c:1771
addToMapA
ZOO_DLL_EXPORT void addToMapA(map *, const char *, const char *)
Add key value pair to an existing map or append the value.
Definition: service.c:604
hasvalue
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:1889
zGettimeofday
#define zGettimeofday
The crossplatform gettimeofday alias.
Definition: service.h:145