Changeset 917
- Timestamp:
- May 7, 2019, 2:17:08 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 67 edited
- 22 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
False
/branches/prototype-v0 merged eligible
-
Property
svn:mergeinfo
set to
False
-
trunk/docs/install/installation.rst
r809 r917 147 147 <http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-kernel/sql/schema.sql#L34>`_. 148 148 149 Metadata Database (Optional) 150 ***************************** 151 152 .. _zoo_create_metadb: 153 154 It is possible to use a PostgreSQL database to store metadata 155 information about WPS Services. This support is optional and require 156 to be activated by using the ``--with-metadb=yes`` option. 157 158 To create the database for storing the metadata informations about the 159 WPS Services, you may use the following command: 160 161 .. code:: 162 163 createdb zoo_metadb 164 psql zoo_metadb -f zoo-project/zoo-kernel/sql/zoo_collectiondb.sql 165 166 In case you want to convert an existing zcfg file then, you can use 167 the ``zcfg2sql`` tool from the command line. It can be found in 168 ``thirds/zcfg2sql`` and can be build simply by running the ``make`` 169 command. After compilation you only need to give it the path of the 170 zcfg file you want to obtain the SQL queries required to store the 171 metadata informations in the database rather than in zcfg file. 172 173 For instance you may use the following command: 174 175 .. code:: 176 177 #Direct import in the zoo_metadb database 178 ./zcfg2sql /Path/To/MyZCFGs/myService.zcfg | psql zoo_metadb 179 #Create a SQL file for a futur import 180 ./zcfg2sql /Path/To/MyZCFGs/myService.zcfg > myService.sql 181 149 182 150 183 … … 154 187 If ``yaml.h`` file is not found in your ``/usr/include`` directory and 155 188 ``libyaml.so`` is not found in ``/usr/lib``, a ``--with-yaml`` option 156 can be used to specify its location. For instance, if the heade er file189 can be used to specify its location. For instance, if the header file 157 190 lies in ``/usr/local/include`` and the shared library is located in 158 191 ``/usr/local/lib``, you may use the following command: -
trunk/docs/kernel/configuration.rst
r817 r917 94 94 service providers, e.g., shared libraries with service implementations 95 95 (the ``serviceProvider`` parameter in the service configuration (.zcfg) file). 96 * ``memory``: (Optional) can take the value ``load`` to ensure that 97 the value field of the inputs data will be filled by the ZOO-Kernel 98 or ``protected`` to have only the ``cache_file`` filled. 99 96 100 97 101 .. warning:: 98 102 The ``libPath`` parameter is currently only recognized by services implemented 99 103 in C/C++ or PHP, and may be moved to another section in future versions. 100 104 105 106 .. warning:: 107 Depending on the ``memory`` parameter the WPS Service will receive 108 different fields (``value`` or ``cache_file``). 109 101 110 In case you have activated the MapServer support, please refer to 102 111 :ref:`this specific section <kernel-mapserver-main.cfg>`. … … 264 273 hosts=localhost,127.0.0.1 265 274 275 Optionaly, you can also define the shared url(s), meaning that even if 276 the ressource requires authentication to be accessed, this 277 authentifcation won't be used to define the name for storing the 278 file. Hence, two user with different authentication will use the same 279 file as it is considerated as shared. You can find bellow a sample 280 security section containing the shared parameter. In this example, 281 every requests to access the coverage using the url defined in the 282 shared parameter (``myHost/cgi-bin/WCS_Server``) will be shared 283 between users. 284 285 .. code:: 286 287 [security] 288 attributes=Authorization,Cookie,User-Agent 289 hosts=localhost,127.0.0.1 290 shared=myHost/cgi-bin/WCS_Server 266 291 267 292 .. _zoo_activate_db_backend: … … 300 325 to setup the database. 301 326 327 328 Database section 329 ............................... 330 331 The database section allows to configure the ZOO-Kernel to access the 332 metadata information about WPS Services by using a PostgreSQL database 333 in addition to the zcfg files. 334 335 .. code-block:: guess 336 337 [metadb] 338 dbname=zoo_metadb 339 port=5432 340 user=username 341 host=127.0.0.1 342 type=PG 343 344 This will generate strings to be passed to GDAL to connect the 345 database server: 346 347 .. code-block:: guess 348 349 <type>:host=<host> port=<port> user=<user> dbname=<dbname> 350 351 352 With the previous database section, it will give the following: 353 354 .. code-block:: guess 355 356 PG:"dbname=zoo_metadb host=127.0.0.1 port=5432 user=username" 357 358 Please refer to this `section <zoo_create_metadb>`_ to learn how 359 to setup the database. 360 302 361 Include section 303 362 ............................... -
trunk/docs/kernel/index.rst
r725 r917 14 14 orfeotoolbox 15 15 sagagis 16 16 hpc -
trunk/docs/kernel/mapserver.rst
r752 r917 73 73 * `MapServer <http://mapserver/org>`__ version >= 6.0.1 74 74 75 First download the lastest zoo-kernel by checking out the svn. Use the following command from do the directory where your previously checked out (in this example we will use `` <PREV_SVN_CO>`` to design this directory).76 77 .. code-block:: guess 78 79 cd <PREV_SVN_CO>80 svn checkout http://svn.zoo-project.org/svn/trunk/zoo-kernel zoo-kernel-ms81 75 First download the lastest zoo-kernel by checking out the svn. Use the following command from do the directory where your previously checked out (in this example we will use ``$PREV_SVN_CO`` to design this directory). 76 77 .. code-block:: guess 78 79 svn checkout http://svn.zoo-project.org/svn/trunk/ $PREV_SVN_CO 80 cd $PREV_SVN_CO 81 82 82 Then uncompress the MapServer archive (ie. ``mapserver-6.0.1.tar.bz2``) into ``/tmp/zoo-ms-src``, and compile it using the following command: 83 83 … … 92 92 cp mapserv /usr/lib/cgi-bin 93 93 94 Once done, compile ZOO-Kernel with MapServer support from the `` <PREV_SVN_CO>`` directory, using the following command:95 96 .. code-block:: guess 97 98 cd zoo-kernel -ms94 Once done, compile ZOO-Kernel with MapServer support from the ``$PREV_SVN_CO`` directory, using the following command: 95 96 .. code-block:: guess 97 98 cd zoo-kernel 99 99 autoconf 100 100 ./configure --with-python --with-mapserver=/tmp/zoo-ms-src/mapserver-6.0.1 101 101 make 102 103 You can then copy the new ZOO-Kernel to ``/usr/lib/cgi-bin`` directory, as follow: 104 105 .. code-block:: guess 106 107 cp zoo_loader.cgi /usr/lib/cgi-bin 102 sudo make install 108 103 109 104 … … 119 114 dataPath = /var/www/temp/ 120 115 mapserverAddress=http://localhost/cgi-bin/mapserv 116 117 You can also add the following lines to the ``[main]`` section, in case 118 you want to use a default style for Polygon, Lines and Points vector 119 layer. 120 121 .. code-block:: guess 122 123 msStylePoly=STYLE COLOR 202 109 19 OUTLINECOLOR 105 105 105 WIDTH 3 END 124 msStyleLine=STYLE OUTLINECOLOR 202 109 19 WIDTH 3 END 125 msStylePoint=STYLE COLOR 202 109 19 OUTLINECOLOR 105 105 105 SYMBOL 0 SIZE 14 END 121 126 122 127 The ``dataPath`` directory is mandatory and must belong to the Apache user. … … 175 180 ************* 176 181 182 You have different options to define the style of the layer created 183 using the data returned by your service. 184 185 msStyle 186 +++++++ 187 177 188 The optional ``msStyle`` parameter can also be used to define a custom MapServer style block (used for vector datasource only), as follow: 178 189 … … 181 192 msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 3 END 182 193 183 If a WPS service outputs a one band raster file, then it is possible to add a ``msClassify`` parameter and set it to ``true`` in the output ComplexData ``<Default>`` or ``<Supported>`` nodes of its ``zcfg`` file. This allows ZOO-Kernel to use its own default style definitions in order to classify the raster using equivalent intervals. 184 185 .. code-block:: guess 186 187 msClassify = .... 194 msClassify 195 ++++++++++ 196 197 If a WPS service outputs a one band raster file, then it is possible 198 to add a ``msClassify`` parameter and set it to ``true`` in the output 199 ComplexData ``<Default>`` or ``<Supported>`` nodes of its zcfg 200 file. This allows ZOO-Kernel to use its own default style definitions 201 in order to classify the raster using equivalent intervals. 202 203 .. code-block:: guess 204 205 msClassify = true 206 207 208 msInclude 209 +++++++++ 210 211 In case you want to use another layer which use the result of your 212 service, for instance to produce a `heatmap 213 <https://mapserver.org/output/kerneldensity.html>`_, then you can use 214 the 215 ``msInclude`` and ``msLayer`` options in the output ``ComplexData`` 216 ``<Default>`` or ``<Supported>`` nodes of its zcfg file. You can see below an 217 example of use of this two options with the associated mapfile. 218 219 .. code-block:: guess 220 221 msInclude = /var/data/template.map 222 msLayer = heatmap 223 224 You can find below a sample ``/var/data/template.map``: 225 226 .. code-block:: guess 227 228 MAP 229 SIZE 1000 500 230 EXTENT -180 -90 180 90 231 NAME "test heat" 232 IMAGETYPE "png" 233 234 WEB 235 METADATA 236 "ows_srs" "epsg:4326 epsg:3857 epsg:900913" 237 "ows_enable_request" "*" 238 END # METADATA 239 END # WEB 240 241 PROJECTION 242 "+init=epsg:4326" 243 END # PROJECTION 244 245 LAYER 246 NAME "heatmap" # Corresponding to the msLayer defined 247 TYPE raster 248 CONNECTIONTYPE kerneldensity 249 CONNECTION "Result" 250 STATUS on 251 PROCESSING "RANGE_COLORSPACE=HSL" 252 PROCESSING "KERNELDENSITY_RADIUS=20" 253 PROCESSING "KERNELDENSITY_COMPUTE_BORDERS=ON" 254 PROCESSING "KERNELDENSITY_NORMALIZATION=AUTO" 255 OFFSITE 0 0 0 256 CLASS 257 STYLE 258 COLORRANGE "#0000ff00" "#0000ffff" 259 DATARANGE 0 32 260 END # STYLE 261 STYLE 262 COLORRANGE "#0000ffff" "#ff0000ff" 263 DATARANGE 32 255 264 END # STYLE 265 END # CLASS 266 END # LAYER 267 268 LAYER 269 NAME "points" 270 STATUS on 271 TYPE POINT 272 #DATA "/Library/WebServer/cache//ef76ee6642c1ea704e847e28120ba1ca.zca" 273 END # LAYER 274 END # MAPFILE 275 276 277 188 278 189 279 Example … … 216 306 useMapserver = true 217 307 asReference = true 218 msClassify = ....308 msClassify = true 219 309 </Supported> 220 310 -
trunk/docs/kernel/sagagis.rst
r725 r917 4 4 ====================== 5 5 6 `SAGA GIS <http:// orfeo-toolbox.org/otb/>`_ provides a comprehensive set of geoscientific methods and spatial algorithms. The optional SAGA GIS support is available since `ZOO-Project 1.5 <http://zoo-project.org>`__. It allows to execute the `SAGA Modules <http://www.saga-gis.org/saga_module_doc/2.1.4/index.html>`_ directly as ZOO WPS Services thanks to a :ref:`kernel_index` specific internal mechanism which is detailed in this section.6 `SAGA GIS <http://www.saga-gis.org/>`_ provides a comprehensive set of geoscientific methods and spatial algorithms. The optional SAGA GIS support is available since `ZOO-Project 1.5 <http://zoo-project.org>`__. It allows to execute the `SAGA Modules <http://www.saga-gis.org/saga_module_doc/2.1.4/index.html>`_ directly as ZOO WPS Services thanks to a :ref:`kernel_index` specific internal mechanism which is detailed in this section. 7 7 8 8 .. note:: 9 9 10 |saga| `SAGA GIS <http s://www.orfeo-toolbox.org>`__ is the System for Automated Geoscientific Analyses. Learn more on official `website <http://www.saga-gis.org/en/index.html>`__.10 |saga| `SAGA GIS <http://www.saga-gis.org/>`__ is the System for Automated Geoscientific Analyses. Learn more on official `website <http://www.saga-gis.org/en/index.html>`__. 11 11 12 12 … … 27 27 28 28 * latest `ZOO-Kernel <http://zoo-project.org/trac/browser/trunk/zoo-project/zoo-kernel>`_ trunk version 29 * SAGA GIS (`SAGA-GIS 2.1.4 <http://saga-gis.org>`_ ) 30 * libLAS-1.2 (`LibLAS-1.2 <https://github.com/libLAS/libLAS-1.2>`_ ) 29 * `SAGA GIS <http://saga-gis.org>`_ (7.2.0) 31 30 32 31 Installation steps 33 32 ........................... 34 33 35 .. Note:: These installation steps were successfully tested on Ubuntu 14.4 LTS 36 37 Download lastest ZOO-Kernel code from SVN. 38 39 .. code-block:: guess 40 41 svn checkout http://svn.zoo-project.org/svn/trunk/zoo-kernel zoo-kernel 42 43 Then compile ZOO-Kernel using the needed configuration options as shown bellow: 34 Compile ZOO-Kernel using the configuration options as shown bellow: 44 35 45 36 .. code-block:: guess … … 47 38 cd zoo-kernel 48 39 autoconf 49 ./configure --with-saga=/usr/local/ 40 ./configure --with-saga=/usr/local/ --with-saga-version=7 50 41 make 51 42 52 And copy the newly created zoo_loader.cgi to ``/usr/lib/cgi-bin`` : 53 43 And copy the newly created zoo_loader.cgi to ``/usr/lib/cgi-bin``. 44 45 .. note:: 46 47 The ``--with-saga-version`` option let you set the major 48 version number of SAGA-GIS. 49 54 50 .. code-block:: guess 55 51 … … 62 58 **************************** 63 59 64 Building the `saga2zcfg 65 <http://zoo-project.org/trac/browser/trunk/thirds/otb2zcfg >`_ utility is required to activate the available SAGA-GIS Modules as WPS Services. This can be done using the following command: 60 Building the 61 `saga2zcfg <http://zoo-project.org/trac/browser/trunk/thirds/saga2zcfg>`_ 62 utility is required to activate the available SAGA-GIS Modules as WPS 63 Services. This can be done using the following command: 66 64 67 65 .. code-block:: guess -
trunk/docs/services/howtos.rst
r794 r917 439 439 } 440 440 441 442 R 443 ---------- 444 445 ZOO API 446 ********* 447 448 For using the R language from the ZOO-Project, you have first to copy 449 ``minimal.r`` in the same directory as the ZOO-Kernel. 450 451 The ZOO-API is available from a R script and provide access to a 452 global zoo environment which contains both static variables and also 453 the dictionaries for outputs and conf: 454 455 :int zoo[["SERVICE_SUCCEEDED"]]: 456 Value to return in case your service end successfully. 457 :int zoo[["SERVICE_FAILED"]]: 458 Value to retrun in case of failure. 459 460 The ZOO-API provides the following functions: 461 462 :string ZOOTranslate(String s): 463 This function call the internal ZOO-Kernel function responsible for 464 searching a translation of ``s`` in the zoo-services dictionary. 465 466 :void ZOOUpdateStatus(ZMaps conf,String pourcent): 467 This function call the updateStatus ZOO-Kernel function responsible 468 for updating the status of the running service (only usefull when 469 the service has been called asynchronously). 470 471 472 R ZCFG requirements 473 ********************************** 474 475 .. Note:: For each Service provided by your ZOO R Services Provider, 476 the ZCFG File must be named the same as the R function name 477 (it is case-sensitive). 478 479 The ZCFG file should contain the following : 480 481 serviceType 482 R 483 serviceProvider 484 The name of the R file to use as a ZOO Service Provider. For instance, if your 485 script, located in the same directory as your ZOO Kernel, was named ``my_module.r`` then 486 you should use ``my_module.r``. 487 488 489 R Data Structure used 490 ******************************** 491 492 The three parameters of the function are passed to the R function as 493 R dictionaries. 494 495 The specificity of the R language make that it was easier to use 496 global variales than passing parameters by reference as we do in 497 other progamming languages. It is the reason why you will have to 498 access outpus by using the global variable as for the main 499 configuration dictionary. 500 501 Sample ZOO R Services Provider 502 ****************************************** 503 504 .. code-block:: javascript 505 506 source("minimal.r") 507 508 hellor <- function(a,b,c) { 509 # Set the result 510 zoo[["outputs"]][["Result"]][["value"]] <<- ZOOTranslate(paste("Hello",b[["S"]][["value"]],"from the R World!",sep=" ")) 511 # Return SERVICE_SUCCEEDEED 512 return(zoo[["SERVICE_SUCCEEDEED"]]) 513 } 514 -
trunk/thirds/otb2zcfg/otb2zcfg.cxx
r783 r917 97 97 std::cout << " </Supported>" << std::endl; 98 98 std::cout << " <Supported>" << std::endl; 99 std::cout << " mimeType = application/json" << std::endl; 100 std::cout << " encoding = utf-8" << std::endl; 101 std::cout << " </Supported>" << std::endl; 102 std::cout << " <Supported>" << std::endl; 99 103 std::cout << " mimeType = application/zip" << std::endl; 100 104 std::cout << " </Supported>" << std::endl; 101 105 } 102 106 103 void printOutputImage( ){107 void printOutputImage(ImagePixelType pt){ 104 108 std::cout << " <LiteralData>" << std::endl; 105 109 std::cout << " dataType = string" << std::endl; 106 110 std::cout << " <Default>" << std::endl; 107 std::cout << " value = float" << std::endl; 108 std::cout << " AllowedValues = uint8,uint16,int16n,int32,int32,float,double" << std::endl; 111 // Check for the default pixel type 112 switch(pt){ 113 case ImagePixelType_uint8: 114 std::cout << " value = uint8" << std::endl; 115 break; 116 case ImagePixelType_int16: 117 std::cout << " value = int16" << std::endl; 118 break; 119 case ImagePixelType_uint16: 120 std::cout << " value = uint16" << std::endl; 121 break; 122 case ImagePixelType_int32: 123 std::cout << " value = int32" << std::endl; 124 break; 125 case ImagePixelType_uint32: 126 std::cout << " value = uint8" << std::endl; 127 break; 128 case ImagePixelType_double: 129 std::cout << " value = uint8" << std::endl; 130 break; 131 default: 132 std::cout << " value = float" << std::endl; 133 break; 134 } 135 std::cout << " AllowedValues = uint8,uint16,int16,int32,int32,float,double" << std::endl; 109 136 std::cout << " </Default>" << std::endl; 110 137 std::cout << " </LiteralData>" << std::endl; 111 138 } 112 139 113 void printOutputComplexImage( ){140 void printOutputComplexImage(ComplexImagePixelType pt){ 114 141 std::cout << " <LiteralData>" << std::endl; 115 142 std::cout << " dataType = string" << std::endl; 116 143 std::cout << " <Default>" << std::endl; 117 std::cout << " value = cfloat" << std::endl; 144 // Check for the default pixel type 145 switch(pt){ 146 case ComplexImagePixelType_double: 147 std::cout << " value = cdouble" << std::endl; 148 break; 149 default: 150 std::cout << " value = cfloat" << std::endl; 151 break; 152 } 118 153 std::cout << " AllowedValues = cfloat,cdouble" << std::endl; 119 154 std::cout << " </Default>" << std::endl; … … 242 277 } 243 278 else{ 244 if(type == ParameterType_OutputImage) 245 printOutputImage(); 279 if(type == ParameterType_OutputImage){ 280 printOutputImage(m_Application->GetParameterOutputImagePixelType(paramKey)); 281 } 246 282 else{ 247 283 if(type == ParameterType_ComplexOutputImage){ 248 printOutputComplexImage( );284 printOutputComplexImage(m_Application->GetParameterComplexOutputImagePixelType(paramKey)); 249 285 }else{ 250 286 std::cout << " <ComplexData>" << std::endl; … … 312 348 std::string s=m_Application->GetParameterDescription(paramKey); 313 349 if(s.length()>0){ 350 s=ReplaceAll(ReplaceAll(s,std::string("\n"),std::string("")),std::string("\t"),std::string("")); 314 351 std::cout << " Title = " << s << std::endl; 315 352 std::cout << " Abstract = " << s << std::endl; -
trunk/thirds/saga2zcfg/saga2zcfg.c
r703 r917 5 5 6 6 #include <api_core.h> 7 #include < module_library.h>7 #include <saga_api.h> 8 8 9 9 int Callback(TSG_UI_Callback_ID ID, CSG_UI_Parameter &Param_1, CSG_UI_Parameter &Param_2){ … … 144 144 static bool g_bShow_Messages = false; 145 145 SG_Set_UI_Callback(Get_Callback()); 146 #if SAGA_MAJOR_VERSION == 2 146 147 int n = SG_Get_Module_Library_Manager().Add_Directory(wxT(MODULE_LIBRARY_PATH),false); 147 if( SG_Get_Module_Library_Manager().Get_Count() <= 0 ){ 148 if( SG_Get_Module_Library_Manager().Get_Count() <= 0 ) 149 #else 150 int n = SG_Get_Tool_Library_Manager().Add_Directory(wxT(MODULE_LIBRARY_PATH),false); 151 if( SG_Get_Tool_Library_Manager().Get_Count() <= 0 ) 152 #endif 153 { 148 154 fprintf(stderr,"could not load any tool library"); 149 155 return -2; 150 156 } 151 157 152 for(int i=0;i<SG_Get_Module_Library_Manager().Get_Count();i++){ 158 #if SAGA_MAJOR_VERSION == 2 159 for(int i=0;i<SG_Get_Module_Library_Manager().Get_Count();i++) 160 #else 161 for(int i=0;i<SG_Get_Tool_Library_Manager().Get_Count();i++) 162 #endif 163 { 153 164 165 #if SAGA_MAJOR_VERSION == 2 154 166 CSG_Module_Library * library=SG_Get_Module_Library_Manager().Get_Library(i); 167 #else 168 CSG_Tool_Library * library=SG_Get_Tool_Library_Manager().Get_Library(i); 169 #endif 155 170 int lc=library->Get_Count(); 156 171 if(!library->Get_Library_Name().Contains("io_")) { 157 172 158 173 for(int j=0;j<lc;j++){ 174 #if SAGA_MAJOR_VERSION == 2 159 175 CSG_Module * module=library->Get_Module(j); 176 #else 177 CSG_Tool * module=library->Get_Tool(j); 178 #endif 160 179 if(module!=NULL && !module->needs_GUI() /*&& !module->is_Interactive()*/ ){ 161 180 162 181 mkdir(library->Get_Library_Name().b_str(),0755); 163 182 164 183 FILE *stdout1=fopen((library->Get_Library_Name()+"/"+module->Get_ID()+".zcfg").b_str(),"w+"); 165 184 fprintf(stdout1,"[%d]\n",j); … … 203 222 204 223 } 224 else if(CSG_String(param->Get_Type_Identifier()).is_Same_As(CSG_String("date"),true)){ 225 printBasicMetadata(stdout1,param,false,true,true); 226 fprintf(stdout1," <LiteralData>\n"); 227 fprintf(stdout1," dataType = date\n"); 228 fprintf(stdout1," <Default/>\n"); 229 fprintf(stdout1," </LiteralData>\n"); 230 231 } 205 232 else if(CSG_String(param->Get_Type_Identifier()).is_Same_As(CSG_String("range"),true)){ 206 233 … … 212 239 CSG_Parameter_Range *range=param->asRange(); 213 240 fprintf(stdout1," <Default>\n"); 241 #if SAGA_MAJOR_VERSION == 2 214 242 fprintf(stdout1," value = %f\n",((CSG_Parameter_Range*)param->Get_Data())->Get_LoVal()); 243 #else 244 //fprintf(stdout1," value = %f\n",((CSG_Parameter_Range*)param->asDataObject())->Get_Min()); 245 #endif 215 246 fprintf(stdout1," </Default>\n"); 216 247 fprintf(stdout1," </LiteralData>\n"); … … 220 251 fprintf(stdout1," dataType = float\n"); 221 252 fprintf(stdout1," <Default>\n"); 253 #if SAGA_MAJOR_VERSION == 2 222 254 fprintf(stdout1," value = %f\n",((CSG_Parameter_Range*)param->Get_Data())->Get_HiVal()); 255 #else 256 //fprintf(stdout1," value = %f\n",((CSG_Parameter_Range*)param->asDataObject())->Get_Max()); 257 #endif 223 258 fprintf(stdout1," </Default>\n"); 224 259 fprintf(stdout1," </LiteralData>\n"); … … 280 315 fprintf(stdout1," dataType = string\n"); 281 316 fprintf(stdout1," <Default>\n"); 317 #if SAGA_MAJOR_VERSION == 2 282 318 if( !param->Get_Data()->Get_Default().is_Empty() ){ 283 319 fprintf(stdout1," value = %s\n",param->Get_Data()->Get_Default().b_str()); 284 320 } 321 #else 322 if( !param->Get_Default().is_Empty() ){ 323 fprintf(stdout1," value = %s\n",param->Get_Default().b_str()); 324 } 325 #endif 285 326 fprintf(stdout1," </Default>\n"); 286 327 fprintf(stdout1," </LiteralData>\n"); … … 299 340 300 341 fprintf(stdout1," <Default>\n"); 342 #if SAGA_MAJOR_VERSION == 2 301 343 if( !param->Get_Data()->Get_Default().is_Empty() ){ 302 344 fprintf(stdout1," value = %s\n",param->Get_Data()->Get_Default().b_str()); 303 345 } 346 #else 347 if( !param->Get_Default().is_Empty() ){ 348 fprintf(stdout1," value = %s\n",param->Get_Default().b_str()); 349 } 350 #endif 304 351 if(param->asValue()->has_Minimum() && param->asValue()->has_Maximum()){ 305 352 fprintf(stdout1," rangeMin = %f\n",param->asValue()->Get_Minimum()); … … 314 361 fprintf(stdout1," dataType = bool\n"); 315 362 fprintf(stdout1," <Default>\n"); 363 #if SAGA_MAJOR_VERSION == 2 316 364 if( !param->Get_Data()->Get_Default().is_Empty() ){ 317 365 fprintf(stdout1," value = %s\n",(param->Get_Data()->Get_Default().Contains("0")?"false":"true")); 318 366 } 367 #else 368 if( !param->Get_Default().is_Empty() ){ 369 fprintf(stdout1," value = %s\n",(param->Get_Default().Contains("0")?"false":"true")); 370 } 371 #endif 319 372 fprintf(stdout1," </Default>\n"); 320 373 fprintf(stdout1," </LiteralData>\n"); … … 337 390 } 338 391 fprintf(stdout1," <Default>\n"); 392 #if SAGA_MAJOR_VERSION == 2 339 393 if( !param->Get_Data()->Get_Default().is_Empty() ){ 340 394 fprintf(stdout1," value = %s\n",CSG_String(choice->Get_Item(atoi(param->Get_Data()->Get_Default()))).b_str()); 341 395 } 396 #else 397 if( !param->Get_Default().is_Empty() ){ 398 fprintf(stdout1," value = %s\n",CSG_String(choice->Get_Item(atoi(param->Get_Default()))).b_str()); 399 } 400 #endif 342 401 fprintf(stdout1," </Default>\n"); 343 402 fprintf(stdout1," </LiteralData>\n"); -
trunk/zoo-project/HISTORY.txt
r828 r917 1 1 Version 1.7.0-dev 2 * Fix issue with UOM definitions in zcfg2sql 3 * Make callback and HPC support independent from each other 4 * Update SAGA-GIS support to version 7.2.0 5 * Add support for custom MapServer style definition for raster output 6 * Fix returned bbox definition #170 7 * Store semaphore status in lenv section for future deletion 8 * Update Windows support to newer compiler 9 * Fix issue with UpdateStatus function from the Mono ZOO-API 10 * Add logging functionality and other utility functions to the C-API 11 * Return an exception for every output for which nb_pixel or 12 nb_features is 0 13 * Add a shared key to the security section to differentiate the 14 referenced data 15 * Add MapServer output style definition depending on the geometry 16 type 17 * Add ogr.tindex service 18 * Add support for literaldata input arrays and to call services 19 asyncrhonously from the JavaScript ZOO-API 20 * Expose a sleep function to the JavaScript ZOO-API 21 * Provide FinalizeHPC and FinalizeHPC1 services using scontrol and 22 sacct respectively 23 * Store md5sum of the cached file (so, local to the WPS server) to 24 compare before uploading (if different md5sum) on the HPC server 25 * Add support for R language 26 * Add support for using "file://" for referenced data input 27 * Add an optional ecookie key for returning third-party cookies 28 * Fix issue when parsing BoundingBox input #163 29 * Add memory key to the main section to force the ZOO-Kernel to load 30 data into memory or use local file 31 * Add the dialect input to the ogr2ogr service 32 * Store the list of generated mapfiles in a file (cf DeleteData service) 33 * Define the correct MS_IMAGEMODE in the generated mapfile 34 * Option to use MapServer support to publish heatmap 35 * Add status_code key to the lenv for setting Status HTTP response header 36 * Add the Creation Option inputs to the Gdal_Dem service 37 * Add prohibited key in the callback section to define a list of 38 services not requiring any invocation 39 * Produce zcfg for OTB applications using the correct default pixel type 40 * Add asynchronous callback invocation to send information about 41 the ongoing services to a third-party software 42 * Add mapsToJson, mapsToJson, and elementsToJson to the API 43 * Provide a zcfg2sql tool to convert a zcfg metadata file to SQL script 44 * Add support to store service metadata information into a database 45 * Add HPC Support for remote execution of SBATCH scripts through Slurm 46 * Add cookie reference to _HINTERNET 2 47 * Support headers for GET requests from the js ZOO-API 3 48 * Pass all headers listed in the attributes parameter from the -
trunk/zoo-project/zoo-api/js/ZOO-api.js
r828 r917 3686 3686 } 3687 3687 var builder = this.parseData[data.localName().toLowerCase()]; 3688 if (builder) 3688 if (builder){ 3689 3689 res.push(builder.apply(this,[data])); 3690 } 3690 3691 else 3691 3692 res.push(null); 3693 data=null; 3692 3694 } 3693 3695 return res.length>1?res:res[0]; 3694 } else 3695 return null; 3696 } 3697 else{ 3698 var hasPercentCompleted=true; 3699 var status = node.*::Status.*::ProcessStarted; 3700 var msg = node.*::Status.*::ProcessStarted.*::*[0]; 3701 if(!status || !msg){ 3702 status = node.*::Status.*::ProcessAccepted; 3703 msg = node.*::Status.*::ProcessAccepted.*::*[0]; 3704 msg=msg.toString(); 3705 hasPercentCompleted=false; 3706 }else 3707 msg=msg.toString(); 3708 if(status!=null && node.@statusLocation){ 3709 var res={"status": node.@statusLocation.toXMLString(), "message": msg}; 3710 if(hasPercentCompleted) 3711 res["percentCompleted"]=status.@percentCompleted.toXMLString(); 3712 return res; 3713 }else 3714 return null; 3715 } 3696 3716 }, 3697 3717 /** … … 3748 3768 * {Object} A WPS reference response. 3749 3769 */ 3750 'reference': function(node) { 3751 var result = {type:'reference',value:node.@href}; 3770 'reference': function(lnode) { 3771 var lhref=lnode.@href; 3772 var lmimeType=lnode.@mimeType; 3773 var result = {type:'reference',value:lhref.toXMLString(),mimeType:lmimeType.toXMLString()}; 3752 3774 return result; 3753 3775 } … … 6147 6169 identifier: null, 6148 6170 /** 6171 * Property: async 6172 * {Bool} Define if the process should run asyncrhonously (true) or not (false, default). 6173 */ 6174 async: null, 6175 /** 6149 6176 * Constructor: ZOO.Process 6150 6177 * Create a new Process … … 6158 6185 this.url = url; 6159 6186 this.identifier = identifier; 6187 this.async = (arguments.length>2?arguments[2]:false); 6160 6188 }, 6161 6189 /** … … 6173 6201 if (this.identifier == null) 6174 6202 return null; 6175 var body = new XML('<wps:Execute service="WPS" version="1.0.0" xmlns:wps="'+this.namespaces['wps']+'" xmlns:ows="'+this.namespaces['ows']+'" xmlns:xlink="'+this.namespaces['xlink']+'" xmlns:xsi="'+this.namespaces['xsi']+'" xsi:schemaLocation="'+this.schemaLocation+'"><ows:Identifier>'+this.identifier+'</ows:Identifier>'+this.buildDataInputsNode(inputs)+this.buildDataOutputsNode(outputs)+'</wps:Execute>');6203 var body = new XML('<wps:Execute service="WPS" version="1.0.0" xmlns:wps="'+this.namespaces['wps']+'" xmlns:ows="'+this.namespaces['ows']+'" xmlns:xlink="'+this.namespaces['xlink']+'" xmlns:xsi="'+this.namespaces['xsi']+'" xsi:schemaLocation="'+this.schemaLocation+'"><ows:Identifier>'+this.identifier+'</ows:Identifier>'+this.buildDataInputsNode(inputs)+this.buildDataOutputsNode(outputs)+'</wps:Execute>'); 6176 6204 body = body.toXMLString(); 6177 6205 var headers=['Content-Type: text/xml; charset=UTF-8']; 6178 6179 6180 6206 if(arguments.length>2){ 6207 headers[headers.length]=arguments[2]; 6208 } 6181 6209 var response = ZOO.Request.Post(this.url,body,headers); 6182 6210 return response; … … 6195 6223 */ 6196 6224 'ResponseDocument': function(identifier,obj) { 6197 var output = new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'"><wps:ResponseDocument><wps:Output'+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+(obj["asReference"]?' asReference="'+obj["asReference"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:Output></wps:ResponseDocument></wps:ResponseForm>'); 6225 var output = new XML('<wps:Output xmlns:wps="'+this.namespaces['wps']+'" '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+(obj["asReference"]?' asReference="'+obj["asReference"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:Output>'); 6226 output = output.toXMLString(); 6227 return output; 6228 }, 6229 'RawDataOutput': function(identifier,obj) { 6230 var output = new XML('<wps:RawDataOutput xmlns:wps="'+this.namespaces['wps']+'" '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:RawDataOutput>'); 6198 6231 if (obj.encoding) 6199 6232 output.*::Data.*::ComplexData.@encoding = obj.encoding; … … 6202 6235 output = output.toXMLString(); 6203 6236 return output; 6204 },6205 'RawDataOutput': function(identifier,obj) {6206 var output = new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'"><wps:RawDataOutput '+(obj["mimeType"]?' mimeType="'+obj["mimeType"]+'" ':'')+(obj["encoding"]?' encoding="'+obj["encoding"]+'" ':'')+'><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier></wps:RawDataOutput></wps:ResponseForm>');6207 if (obj.encoding)6208 output.*::Data.*::ComplexData.@encoding = obj.encoding;6209 if (obj.schema)6210 output.*::Data.*::ComplexData.@schema = obj.schema;6211 output = output.toXMLString();6212 return output;6213 6237 } 6214 6238 … … 6231 6255 */ 6232 6256 'complex': function(identifier,data) { 6233 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData ><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>');6257 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData '+(data.mimeType?'mimeType="'+data.mimeType+'"':"")+'><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>'); 6234 6258 if(data.xlink) 6235 6259 input.*::Reference.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6236 6260 else 6237 6261 input.*::Data.*::ComplexData.@mimeType = data.mimetype ? data.mimetype : 'application/json'; 6238 6262 if (data.encoding) 6239 6263 input.*::Data.*::ComplexData.@encoding = data.encoding; … … 6241 6265 input.*::Data.*::ComplexData.@schema = data.schema; 6242 6266 input = input.toXMLString(); 6243 return input; 6267 if(data.value) 6268 return (('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier>'+(data.value?'<wps:Data><wps:ComplexData '+(data.mimeType?'mimeType="'+data.mimeType+'"':"")+'><![CDATA['+data.value+']]></wps:ComplexData></wps:Data>':(data.xlink?'<wps:Reference xmlns:xlink="'+this.namespaces['xlink']+'" xlink:href="'+data.xlink+'" mimeType="'+data.mimeType+'" />':''))+'</wps:Input>')); 6269 else 6270 return input; 6244 6271 }, 6245 6272 /** … … 6269 6296 */ 6270 6297 'literal': function(identifier,data) { 6271 if(data && !eval(data["isArray"])){ 6272 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value+'</wps:LiteralData></wps:Data></wps:Input>'); 6273 if (data.type) 6274 input.*::Data.*::LiteralData.@dataType = data.type; 6275 if (data.uom) 6276 input.*::Data.*::LiteralData.@uom = data.uom; 6277 input = input.toXMLString(); 6278 return input; 6279 }else if(data){ 6280 var inputf=""; 6281 for(i=0;i<parseInt(data["length"]);i++){ 6282 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value[i]+'</wps:LiteralData></wps:Data></wps:Input>'); 6283 if (data.type) 6284 input.*::Data.*::LiteralData.@dataType = data.type; 6285 if (data.uom) 6286 input.*::Data.*::LiteralData.@uom = data.uom; 6287 inputf += input.toXMLString(); 6288 } 6289 return inputf; 6298 if(data && !eval(data["isArray"])){ 6299 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value+'</wps:LiteralData></wps:Data></wps:Input>'); 6300 if (data.type) 6301 input.*::Data.*::LiteralData.@dataType = data.type; 6302 if (data.uom) 6303 input.*::Data.*::LiteralData.@uom = data.uom; 6304 input = input.toXMLString(); 6305 return input; 6306 }else if(data){ 6307 var inputf=""; 6308 for(i=0;i<parseInt(data["length"]);i++){ 6309 var input = new XML('<wps:Input xmlns:wps="'+this.namespaces['wps']+'"><ows:Identifier xmlns:ows="'+this.namespaces['ows']+'">'+identifier+'</ows:Identifier><wps:Data><wps:LiteralData>'+data.value[i]+'</wps:LiteralData></wps:Data></wps:Input>'); 6310 if (data.type) 6311 input.*::Data.*::LiteralData.@dataType = data.type; 6312 if (data.uom) 6313 input.*::Data.*::LiteralData.@uom = data.uom; 6314 inputf += input.toXMLString(); 6290 6315 } 6291 6316 return inputf; 6317 } 6292 6318 } 6293 6319 }, … … 6318 6344 6319 6345 buildDataOutputsNode:function(outputs){ 6320 var data, builder, outputsArray=[ ];6346 var data, builder, outputsArray=[[],[]]; 6321 6347 for (var attr in outputs) { 6322 6348 data = outputs[attr]; 6323 6349 builder = this.buildOutput[data.type]; 6324 outputsArray.push(builder.apply(this,[attr,data])); 6325 } 6326 return outputsArray.join('\n'); 6350 if(data.type=="ResponseDocument") 6351 outputsArray[0].push(builder.apply(this,[attr,data])); 6352 else 6353 outputsArray[1].push(builder.apply(this,[attr,data])); 6354 } 6355 var responseDocuments=(outputsArray[0].length>0? 6356 new XML('<wps:ResponseDocument '+(this.async?'storeExecuteResponse="true" status="true"':'')+' xmlns:wps="'+this.namespaces['wps']+'">'+ 6357 outputsArray[0].join('\n')+ 6358 '</wps:ResponseDocument>') 6359 : 6360 null); 6361 var rawDataOutputs=(outputsArray[1].length>0? 6362 outputsArray[1].join('\n') 6363 : 6364 null); 6365 var res=new XML('<wps:ResponseForm xmlns:wps="'+this.namespaces['wps']+'">'+ 6366 (responseDocuments!=null?responseDocuments.toXMLString():"")+ 6367 (rawDataOutputs!=null?rawDataOutputs:"")+ 6368 '</wps:ResponseForm>'); 6369 return res.toXMLString(); 6327 6370 }, 6328 6371 -
trunk/zoo-project/zoo-client/lib/js/wps-client/zoo.js
r719 r917 679 679 680 680 $.ajax({ 681 url: closure.statusLocation[sid] 681 url: closure.statusLocation[sid]+"×tamp="++(new Date()).getTime() 682 682 }) 683 683 .fail( -
trunk/zoo-project/zoo-kernel/Makefile.in
r815 r917 9 9 10 10 service.o: service.c service.h 11 g cc${YAML_CFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service.c11 g++ ${YAML_CFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service.c 12 12 13 13 main_conf_read.tab.c: main_conf_read.y service.h … … 38 38 gcc -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c ulinet.c 39 39 40 sshapi.o: sshapi.c 41 g++ -fPIC ${CFLAGS} -c sshapi.c 42 43 service_json.o: service_json.c 44 g++ -fPIC ${JSON_CFLAGS} ${CFLAGS} -c service_json.c 45 46 service_callback.o: service_callback.c 47 g++ -fPIC ${XML2CFLAGS} ${GDAL_CFLAGS} ${JSON_CFLAGS} ${CFLAGS} -c service_callback.c 48 40 49 request_parser.o: request_parser.c request_parser.h 41 50 g++ -fPIC ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c request_parser.c 42 51 43 52 sqlapi.o: sqlapi.c sqlapi.h 44 g++ -fPIC ${ GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c sqlapi.c53 g++ -fPIC ${METADB_ENABLED} ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c sqlapi.c 45 54 46 55 caching.o: caching.c … … 48 57 49 58 response_print.o: response_print.c response_print.h 50 g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} -c response_print.c59 g++ -fPIC ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${JSCFLAGS} ${JS_ENABLED} ${HPC_ENABLED} -c response_print.c 51 60 52 61 server_internal.o: server_internal.c server_internal.h service.h mimetypes.h 53 g++ ${ GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c server_internal.c62 g++ ${JSON_CFLAGS} ${GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c server_internal.c 54 63 55 64 service_internal.o: service_internal.c service_internal.h service.h 56 gcc ${ GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c65 gcc ${JSON_CFLAGS} ${GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c 57 66 58 67 service_yaml.o: service_yaml.c service.h 59 68 gcc ${YAML_CFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_yaml.c 69 70 meta_sql.o: meta_sql.c meta_sql.h service.h 71 g++ ${METADB_ENABLED} ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} -c meta_sql.c 60 72 61 73 service_internal_ms.o: service_internal_ms.c … … 66 78 g++ ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c service_internal_python.c 67 79 80 service_internal_r.o: service_internal_r.c service.h 81 g++ ${XML2CFLAGS} ${RCFLAGS} ${CFLAGS} -c service_internal_r.c 82 68 83 service_internal_otb.o: service_internal_otb.c service_internal_otb.h service.h 69 84 g++ ${XML2CFLAGS} ${OTBCFLAGS} ${CFLAGS} -c service_internal_otb.c 85 86 service_internal_hpc.o: service_internal_hpc.c service_internal_hpc.h service.h 87 g++ ${JSON_CFLAGS} ${XML2CFLAGS} ${HPCCFLAGS} ${CFLAGS} -c service_internal_hpc.c 70 88 71 89 service_internal_saga.o: service_internal_saga.c service_internal_saga.h service.h … … 99 117 g++ -c ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} service_loader.c 100 118 101 zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${ PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE}102 g++ -g -O2 ${ XML2CFLAGS} ${CFLAGS} ${MONO_CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${MONO_ENABLED}-c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o119 zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${R_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} ${HPC_FILES} ${METADB_FILE} 120 g++ -g -O2 ${JSON_CFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${CFLAGS} ${MONO_CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${RCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${HPC_ENABLED} ${PYTHON_ENABLED} ${R_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${MONO_ENABLED} ${METADB_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o 103 121 104 122 libzoo_service.${EXT}: version.h service_internal.o service.o sqlapi.o 105 g cc -shared ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS} service_internal.o service.o sqlapi.o ${FCGI_LDFLAGS} ${GDAL_LIBS}123 g++ -shared ${GDAL_CFLAGS} ${DEFAULT_OPTS} -fpic -o libzoo_service.${EXT} ${CFLAGS} service_internal.o service.o sqlapi.o ${FCGI_LDFLAGS} ${GDAL_LIBS} ${ZOO_LDFLAGS} ${MACOS_LD_FLAGS} 106 124 107 zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${ SAGA_FILE}108 g++ -g -O2 ${JS CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o109 g++ ${JS CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS}125 zoo_loader.cgi: version.h libzoo_service.${EXT} zoo_loader.c zoo_service_loader.o ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o request_parser.o response_print.o server_internal.o caching.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${R_FILE} ${SAGA_FILE} ${HPC_FILES} ${METADB_FILE} ${JSON_FILE} ${CALLBACK_FILE} 126 g++ -g -O2 ${JSON_CFLAGS} ${JSCFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${RUBYCFLAGS} ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c -fno-common -DPIC -o zoo_loader.o 127 g++ ${JSON_CFLAGS} ${JSCFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o zoo_service_loader.o ${MS_FILE} ${PYTHON_FILE} ${PERL_FILE} ${PHP_FILE} ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE} ${MONO_FILE} ${HPC_FILES} ${METADB_FILE} ${JSON_FILE} ${R_FILE} ${CALLBACK_FILE} response_print.o server_internal.o caching.o request_parser.o ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi -L. ${LDFLAGS} 110 128 111 zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE} 129 zcfg2yaml: zcfg2yaml.c service.h lex.sr.o service_conf.tab.o service_conf.y main_conf_read.tab.o lex.cr.o response_print.o server_internal.o service_internal.o ${MS_FILE} ${YAML_FILE} ${CALLBACK_FILE} 112 130 g++ -g -O2 ${JSCFLAGS} ${RUBYCFLAGS} ${XML2CFLAGS} ${CFLAGS} -c zcfg2yaml.c -fno-common -DPIC -o zcfg2yaml.o 113 g++ ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS}131 g++ ${XML2CFLAGS} ${CFLAGS} zcfg2yaml.o caching.o ulinet.o ${CALLBACK_FILE} server_internal.o service_internal.o ${MS_FILE} response_print.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o ${YAML_FILE} -o zcfg2yaml -L. ${LDFLAGS} 114 132 115 133 install: zoo_loader.cgi -
trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in
r866 r917 30 30 YAML_FILE1=@YAML_FILE1@ 31 31 32 JSON_CFLAGS=@JSON_CPPFLAGS@ 33 JSON_LDFLAGS=@JSON_LDFLAGS@ 34 JSON_FILE=@JSON_FILE@ 35 36 METADB_ENABLED=@METADB@ 37 METADB_FILE=@METADB_FILE@ 38 39 32 40 GDAL_CFLAGS=@GDAL_CFLAGS@ 33 41 GDAL_LIBS=@GDAL_LIBS@ … … 50 58 PYTHON_FILE=@PYTHON_FILE@ 51 59 60 RCFLAGS=@R_CPPFLAGS@ 61 RLDFLAGS=@R_LDFLAGS@ 62 R_ENABLED=@R_ENABLED@ 63 R_FILE=@R_FILE@ 64 52 65 RUBYCFLAGS=@RUBY_CPPFLAGS@ 53 66 RUBYLDFLAGS=@RUBY_LDFLAGS@ … … 68 81 69 82 ZOO_CFLAGS=-I${ZRPATH}/../thirds/cgic206/ -I${ZRPATH}/zoo-kernel/ 70 ZOO_LDFLAGS=@OPENSSL_LDFLAGS@ -luuid83 ZOO_LDFLAGS=@OPENSSL_LDFLAGS@ @UUID_LDFLAGS@ 71 84 72 85 JAVACFLAGS=@JAVA_CPPFLAGS@ … … 80 93 PHP_FILE=@PHP_FILE@ 81 94 82 83 95 PERLCFLAGS=@PERL_CPPFLAGS@ 84 96 PERLLDFLAGS=@PERL_LDFLAGS@ 85 97 PERL_ENABLED=@PERL_ENABLED@ 86 98 PERL_FILE=@PERL_FILE@ 99 100 HPCCFLAGS=@SSH2_CPPFLAGS@ @HPC_CPPFLAGS@ 101 HPCLDFLAGS=@SSH2_LDFLAGS@ @HPC_LDFLAGS@ 102 HPC_ENABLED=@HPC_ENABLED@ 103 HPC_FILES=@HPC_FILES@ 104 105 CALLBACK_FILE=@CALLBACK_FILE@ 106 CALLBACK_USE=@CALLBACK_USE@ 87 107 88 108 OTBCFLAGS=@OTB_CPPFLAGS@ … … 101 121 MONO_FILE=@MONO_FILE@ 102 122 103 CFLAGS= -Wdeclaration-after-statement @RELY_ON_DB@ @DEB_DEF@ -fpic @OPENSSL_CFLAGS@ ${FCGI_CFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF104 LDFLAGS=-lzoo_service @ DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} ${MONO_LDFLAGS}123 CFLAGS=@CALLBACK_USE@ @SSH2_CPPFLAGS@ @PROJ_CPPFLAGS@ @RELY_ON_DB@ @DEB_DEF@ -fpic @OPENSSL_CFLAGS@ @UUID_CFLAGS@ ${FCGI_CFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 124 LDFLAGS=-lzoo_service @SSH2_LDFLAGS@ @PROJ_LDFLAGS@ @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ @UUID_LDFLAGS@ ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS} ${MONO_LDFLAGS} ${RLDFLAGS} @JSON_LDFLAGS@ @XSLT_LDFLAGS@ 105 125 106 126 DATAROOTDIR=@datarootdir@/zoo-project -
trunk/zoo-project/zoo-kernel/caching.c
r837 r917 23 23 */ 24 24 25 #include <openssl/md5.h> 26 #include <openssl/evp.h> 25 27 #include "caching.h" 26 28 #include "service.h" 27 29 #include "service_internal.h" 28 30 #include "response_print.h" 29 #include <openssl/md5.h> 30 #include <openssl/hmac.h> 31 #include <openssl/evp.h> 32 #include <openssl/bio.h> 33 #include <openssl/buffer.h> 34 31 #ifdef MS_FORCE_LOCAL_FILE_USE 32 #include "ogr_api.h" 33 #include "mapserver.h" 34 #endif 35 35 /** 36 36 * Compute md5 … … 41 41 */ 42 42 char* getMd5(char* url){ 43 EVP_MD_CTX md5ctx;43 EVP_MD_CTX *md5ctx=EVP_MD_CTX_create(); 44 44 char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char)); 45 45 unsigned char result[EVP_MAX_MD_SIZE]; 46 46 unsigned int len; 47 EVP_DigestInit( &md5ctx, EVP_md5());48 EVP_DigestUpdate( &md5ctx, url, strlen(url));49 EVP_DigestFinal_ex( &md5ctx,result,&len);50 EVP_MD_CTX_ cleanup(&md5ctx);47 EVP_DigestInit(md5ctx, EVP_md5()); 48 EVP_DigestUpdate(md5ctx, url, strlen(url)); 49 EVP_DigestFinal_ex(md5ctx,result,&len); 50 EVP_MD_CTX_destroy(md5ctx); 51 51 int i; 52 52 for(i = 0; i < len; i++){ 53 53 if(i>0){ 54 char *tmp= strdup(fresult);54 char *tmp=zStrdup(fresult); 55 55 sprintf(fresult,"%s%02x", tmp,result[i]); 56 56 free(tmp); … … 62 62 } 63 63 64 /** 65 * Compute md5 of a file 66 * 67 * @param file the char* 68 * @return a char* representing the md5 of the url 69 * @warning make sure to free resources returned by this function 70 */ 71 char* getMd5f(char* file){ 72 EVP_MD_CTX *md5ctx=EVP_MD_CTX_create(); 73 char* fresult=(char*)malloc((EVP_MAX_MD_SIZE+1)*sizeof(char)); 74 unsigned char result[EVP_MAX_MD_SIZE]; 75 unsigned int len; 76 int bytes; 77 int dlen=65536; 78 unsigned char data[65537]; 79 FILE *inFile = fopen (file, "rb"); 80 EVP_DigestInit(md5ctx, EVP_md5()); 81 while ((bytes = fread (data, sizeof(unsigned char), dlen, inFile)) != 0) 82 EVP_DigestUpdate(md5ctx, data, bytes); 83 EVP_DigestFinal_ex(md5ctx,result,&len); 84 EVP_MD_CTX_destroy(md5ctx); 85 int i; 86 for(i = 0; i < len; i++){ 87 if(i>0){ 88 char *tmp=zStrdup(fresult); 89 sprintf(fresult,"%s%02x", tmp,result[i]); 90 free(tmp); 91 } 92 else 93 sprintf(fresult,"%02x",result[i]); 94 } 95 fclose (inFile); 96 return fresult; 97 } 98 99 100 101 /** 102 * Create a URL by appending every request header listed in the security 103 * section.This imply that the URL will contain any authentication 104 * informations that should be fowarded to the server from which de input 105 * was download. 106 * @param conf the main configuration maps 107 * @param request the URL to transform. 108 * @return a char* that contain the original URL plus potential header (only for 109 * hosts that are not shared). 110 * @warning Be sure to free the memory returned by this function. 111 */ 112 char* getFilenameForRequest(maps* conf, const char* request){ 113 map* passThrough=getMapFromMaps(conf,"security","attributes"); 114 map* targetHosts=getMapFromMaps(conf,"security","hosts"); 115 char* passedHeader[10]; 116 int cnt=0; 117 char *res=zStrdup(request); 118 char *toAppend=NULL; 119 if(passThrough!=NULL && targetHosts!=NULL){ 120 char *tmp=zStrdup(passThrough->value); 121 char *token, *saveptr; 122 token = strtok_r (tmp, ",", &saveptr); 123 int i; 124 if((strstr(targetHosts->value,"*")!=NULL || isProtectedHost(targetHosts->value,request)==1) && strncasecmp(getProvenance(conf,request),"SHARED",6)!=0){ 125 while (token != NULL){ 126 int length=strlen(token)+6; 127 char* tmp1=(char*)malloc(length*sizeof(char)); 128 map* tmpMap; 129 snprintf(tmp1,6,"HTTP_"); 130 int j; 131 for(j=0;token[j]!='\0';j++){ 132 if(token[j]!='-') 133 tmp1[5+j]=toupper(token[j]); 134 else 135 tmp1[5+j]='_'; 136 tmp1[5+j+1]='\0'; 137 } 138 tmpMap = getMapFromMaps(conf,"renv",tmp1); 139 if(tmpMap!=NULL){ 140 if(toAppend==NULL){ 141 toAppend=(char*)malloc((strlen(tmpMap->value)+1)*sizeof(char)); 142 sprintf(toAppend,"%s",tmpMap->value); 143 }else{ 144 char *tmp3=zStrdup(toAppend); 145 toAppend=(char*)realloc(toAppend,(strlen(tmpMap->value)+strlen(tmp3)+2)*sizeof(char)); 146 sprintf(toAppend,"%s,%s",tmp3,tmpMap->value); 147 free(tmp3); 148 } 149 } 150 free(tmp1); 151 cnt+=1; 152 token = strtok_r (NULL, ",", &saveptr); 153 } 154 } 155 free(tmp); 156 } 157 if(toAppend!=NULL){ 158 char *tmp3=zStrdup(res); 159 res=(char*)realloc(res,(strlen(tmp3)+strlen(toAppend)+1)*sizeof(char)); 160 sprintf(res,"%s%s",tmp3,toAppend); 161 free(tmp3); 162 free(toAppend); 163 } 164 return res; 165 } 166 167 /** 168 * Store MD5 of the content of a file 169 * @file char* the full path of the file 170 */ 171 int storeMd5(char* file){ 172 char* storage=zStrdup(file); 173 char* md5fstr=getMd5f(file); 174 storage[strlen(storage)-2]='m'; 175 storage[strlen(storage)-1]='d'; 176 FILE* fo=fopen(storage,"w+"); 177 if(fo==NULL) 178 return 1; 179 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 180 free(md5fstr); 181 free(storage); 182 fclose(fo); 183 return 0; 184 } 64 185 65 186 /** … … 76 197 * @param max_path the size of the allocated filepath buffer 77 198 */ 199 void cacheFile(maps* conf,char* request,char* mimeType,int length,char* filename){ 200 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 201 char contentr[4096]; 202 int cred=0; 203 if(tmp!=NULL){ 204 char* myRequest=getFilenameForRequest(conf,request); 205 char* md5str=getMd5(myRequest); 206 free(myRequest); 207 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 208 // Store md5 209 char* md5fstr=getMd5f(filename); 210 sprintf(fname,"%s/%s.zmd",tmp->value,md5str); 211 FILE* fo=fopen(fname,"w+"); 212 #ifdef DEBUG 213 fprintf(stderr,"filename: %s\n",filename); 214 fprintf(stderr,"MD5: %s\n",md5fstr); 215 #endif 216 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 217 free(md5fstr); 218 fclose(fo); 219 220 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 221 zooLock* lck=lockFile(conf,fname,'w'); 222 if(lck!=NULL){ 223 #ifdef DEBUG 224 fprintf(stderr,"Cache list : %s\n",fname); 225 fflush(stderr); 226 #endif 227 FILE* fi=fopen(filename,"rb"); 228 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 229 fo=fopen(fname,"w+"); 230 if(fo==NULL){ 231 #ifdef DEBUG 232 fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno)); 233 #endif 234 unlockFile(conf,lck); 235 return; 236 } 237 if(fi==NULL){ 238 #ifdef DEBUG 239 fprintf (stderr, "Failed to open %s for reading: %s\n",filename, strerror(errno)); 240 #endif 241 unlockFile(conf,lck); 242 return; 243 } 244 memset(contentr,0,4096); 245 while((cred=fread(contentr,sizeof(char),4096,fi))>0){ 246 fwrite(contentr,sizeof(char),cred,fo); 247 fflush(fo); 248 memset(contentr,0,4096); 249 } 250 unlockFile(conf,lck); 251 fclose(fo); 252 fclose(fi); 253 254 // Store mimeType 255 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); 256 fo=fopen(fname,"w+"); 257 #ifdef DEBUG 258 fprintf(stderr,"MIMETYPE: %s\n",mimeType); 259 #endif 260 fwrite(mimeType,sizeof(char),strlen(mimeType),fo); 261 fclose(fo); 262 263 // Store provenance 264 sprintf(fname,"%s/%s.zcp",tmp->value,md5str); 265 fo=fopen(fname,"w+"); 266 char* origin=getProvenance(conf,request); 267 #ifdef DEBUG 268 fprintf(stderr,"ORIGIN: %s\n",mimeType); 269 #endif 270 fwrite(origin,sizeof(char),strlen(origin),fo); 271 fclose(fo); 272 273 free(md5str); 274 275 } 276 free(fname); 277 } 278 } 279 280 /** 281 * Cache a file for a given request. 282 * For each cached file, the are two files stored, a .zca and a .zcm containing 283 * the downloaded content and the mimeType respectively. 284 * 285 * @param conf the maps containing the settings of the main.cfg file 286 * @param request the url used too fetch the content 287 * @param content the downloaded content 288 * @param mimeType the content mimeType 289 * @param length the content size 290 * @param filepath a buffer for storing the path of the cached file; may be NULL 291 * @param max_path the size of the allocated filepath buffer 292 */ 78 293 void addToCache(maps* conf,char* request,char* content,char* mimeType,int length, 79 294 char* filepath, size_t max_path){ 80 295 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 81 296 if(tmp!=NULL){ 82 char* md5str=getMd5(request); 297 char* myRequest=getFilenameForRequest(conf,request); 298 char* md5str=getMd5(myRequest); 299 free(myRequest); 83 300 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 84 301 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 85 #ifdef DEBUG 86 fprintf(stderr,"Cache list : %s\n",fname); 87 fflush(stderr); 88 #endif 89 FILE* fo=fopen(fname,"w+"); 90 if(fo==NULL){ 91 #ifdef DEBUG 92 fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno)); 93 #endif 94 filepath = NULL; 95 return; 96 } 97 fwrite(content,sizeof(char),length,fo); 98 fclose(fo); 302 zooLock* lck=lockFile(conf,fname,'w'); 303 if(lck!=NULL){ 304 #ifdef DEBUG 305 fprintf(stderr,"Cache list : %s\n",fname); 306 fflush(stderr); 307 #endif 308 FILE* fo=fopen(fname,"w+"); 309 if(fo==NULL){ 310 #ifdef DEBUG 311 fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno)); 312 #endif 313 filepath = NULL; 314 unlockFile(conf,lck); 315 return; 316 } 317 fwrite(content,sizeof(char),length,fo); 318 unlockFile(conf,lck); 319 fclose(fo); 99 320 100 if (filepath != NULL) { 101 strncpy(filepath, fname, max_path); 102 } 103 104 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); 105 fo=fopen(fname,"w+"); 106 #ifdef DEBUG 107 fprintf(stderr,"MIMETYPE: %s\n",mimeType); 108 #endif 109 fwrite(mimeType,sizeof(char),strlen(mimeType),fo); 110 fclose(fo); 111 112 free(md5str); 113 free(fname); 321 if (filepath != NULL) { 322 strncpy(filepath, fname, max_path); 323 } 324 325 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); 326 fo=fopen(fname,"w+"); 327 #ifdef DEBUG 328 fprintf(stderr,"MIMETYPE: %s\n",mimeType); 329 #endif 330 fwrite(mimeType,sizeof(char),strlen(mimeType),fo); 331 fclose(fo); 332 333 sprintf(fname,"%s/%s.zcp",tmp->value,md5str); 334 fo=fopen(fname,"w+"); 335 char* origin=getProvenance(conf,request); 336 #ifdef DEBUG 337 fprintf(stderr,"ORIGIN: %s\n",mimeType); 338 #endif 339 fwrite(origin,sizeof(char),strlen(origin),fo); 340 fclose(fo); 341 342 free(md5str); 343 free(fname); 344 } 114 345 } 115 346 else { 116 347 filepath = NULL; 117 348 } 118 349 } … … 127 358 */ 128 359 char* isInCache(maps* conf,char* request){ 360 map* tmpUrl=getMapFromMaps(conf,"main","tmpUrl"); 129 361 map* tmpM=getMapFromMaps(conf,"main","cacheDir"); 130 if(tmpM!=NULL){ 131 char* md5str=getMd5(request); 362 if(tmpM==NULL) 363 tmpM=getMapFromMaps(conf,"main","tmpPath"); 364 if(strstr(request,tmpUrl->value)!=NULL){ 365 map* tmpPath=getMapFromMaps(conf,"main","tmpPath"); 366 char* tmpStr=strstr(request,tmpUrl->value); 367 char* tmpStr1=zStrdup(tmpStr+strlen(tmpUrl->value)); 368 char* res=(char*) malloc((strlen(tmpPath->value)+strlen(tmpStr1)+2)*sizeof(char)); 369 sprintf(res,"%s/%s",tmpPath->value,tmpStr1); 370 free(tmpStr1); 371 return res; 372 } 373 #ifdef MS_FORCE_LOCAL_FILE_USE 374 map* msUrl=getMapFromMaps(conf,"main","mapserverAddress"); 375 if(msUrl!=NULL && strstr(request,msUrl->value)!=NULL){ 376 char *tmpStr=strstr(request,"?"); 377 char *cursor=zStrdup(tmpStr+1); 378 char *token, *saveptr; 379 token = strtok_r (cursor, "&", &saveptr); 380 while(token!=NULL){ 381 char *token1, *saveptr1; 382 token1 = strtok_r (token, "=", &saveptr1); 383 char *name=NULL; 384 while(token1!=NULL){ 385 if(name==NULL) 386 name=zStrdup(token1); 387 else 388 if(strcasecmp(name,"map")==0){ 389 mapObj *myMap=msLoadMap(token1,NULL); 390 char * res=zStrdup(myMap->layers[0]->data); 391 free(name); 392 free(cursor); 393 msFreeMap(myMap); 394 return res; 395 } 396 token1 = strtok_r (NULL, "=", &saveptr1); 397 } 398 token = strtok_r (NULL, "&", &saveptr); 399 } 400 free(cursor); 401 } 402 #endif 403 if(strncasecmp(request,"file://",7)==0){ 404 char* tmpStr=zStrdup(request+7); 405 fprintf(stderr,"**** %s %d %s \n",__FILE__,__LINE__,tmpStr); 406 return tmpStr; 407 } 408 else{ 409 char* myRequest=getFilenameForRequest(conf,request); 410 char* md5str=getMd5(myRequest); 411 free(myRequest); 132 412 #ifdef DEBUG 133 413 fprintf(stderr,"MD5STR : (%s)\n\n",md5str); … … 135 415 char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+strlen(md5str)+6)); 136 416 sprintf(fname,"%s/%s.zca",tmpM->value,md5str); 137 struct stat f_status;138 int s= stat(fname, &f_status);417 zStatStruct f_status; 418 int s=zStat(fname, &f_status); 139 419 if(s==0 && f_status.st_size>0){ 140 420 free(md5str); … … 158 438 */ 159 439 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){ 440 441 int shouldClean=-1; 160 442 map* tmp1; 161 443 char sindex[5]; 162 444 maps* content=*in; 163 445 map* length=getMap(content->content,"length"); 164 int shouldClean=-1;446 map* memUse=getMapFromMaps(*m,"main","memory"); 165 447 if(length==NULL){ 166 448 length=createMap("length","1"); … … 171 453 char *mimeType=NULL; 172 454 int fsize=0; 455 char oriname[12]; 173 456 char cname[15]; 174 457 char vname[11]; … … 178 461 char icname[14]; 179 462 char xname[16]; 463 char bname[8]; 464 char hname[11]; 180 465 char oname[12]; 466 char ufile[12]; 181 467 if(*index>0) 182 468 sprintf(vname1,"value_%d",*index); … … 185 471 186 472 if(i>0){ 473 sprintf(cname,"cache_file_%d",i); 187 474 tmp1=getMap(content->content,cname); 188 sprintf( cname,"cache_file_%d",i);475 sprintf(oriname,"origin_%d",i); 189 476 sprintf(vname,"value_%d",i); 190 477 sprintf(sname,"size_%d",i); … … 192 479 sprintf(icname,"isCached_%d",i); 193 480 sprintf(xname,"Reference_%d",i); 481 sprintf(bname,"body_%d",i); 482 sprintf(hname,"headers_%d",i); 194 483 sprintf(oname,"Order_%d",i); 484 sprintf(ufile,"use_file_%d",i); 195 485 }else{ 196 486 sprintf(cname,"cache_file"); 487 sprintf(oriname,"origin"); 197 488 sprintf(vname,"value"); 198 489 sprintf(sname,"size"); … … 200 491 sprintf(icname,"isCached"); 201 492 sprintf(xname,"Reference"); 493 sprintf(bname,"body"); 494 sprintf(hname,"headers"); 202 495 sprintf(oname,"Order"); 496 sprintf(ufile,"use_file"); 203 497 } 204 498 … … 206 500 sprintf(sindex,"%d",*index+1); 207 501 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 208 209 if(getMap(content->content,icname)==NULL){ 210 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 211 if(fcontent == NULL){ 212 errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 213 return -1; 502 503 if(getMap(content->content,icname)==NULL) { 504 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 505 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 506 if(fcontent == NULL){ 507 errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 508 return -1; 509 } 510 size_t dwRead; 511 InternetReadFile(hInternet->ihandle[*index], 512 (LPVOID)fcontent, 513 hInternet->ihandle[*index].nDataLen, 514 &dwRead); 515 fcontent[hInternet->ihandle[*index].nDataLen]=0; 214 516 } 215 size_t dwRead;216 InternetReadFile(hInternet->ihandle[*index],217 (LPVOID)fcontent,218 hInternet->ihandle[*index].nDataLen,219 &dwRead);220 fcontent[hInternet->ihandle[*index].nDataLen]=0;221 517 fsize=hInternet->ihandle[*index].nDataLen; 222 518 if(hInternet->ihandle[*index].mimeType==NULL) … … 226 522 227 523 map* tmpMap=getMapOrFill(&(*in)->content,vname,""); 228 free(tmpMap->value); 229 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 230 if(tmpMap->value==NULL){ 231 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 232 } 233 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 524 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 525 free(tmpMap->value); 526 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 527 if(tmpMap->value==NULL){ 528 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 529 } 530 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 531 }else 532 addToMap((*in)->content,ufile,"true"); 234 533 if(hInternet->ihandle[*index].code!=200){ 235 534 const char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d."); … … 255 554 sprintf(ltmp1,"%d",fsize); 256 555 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 556 char *request=NULL; 257 557 if(tmp!=NULL){ 258 char* md5str=getMd5(tmp1->value); 558 map* tmp2; 559 char* md5str=NULL; 560 if((tmp2=getMap(content->content,bname))!=NULL){ 561 char *tmpStr=(char*)malloc((strlen(tmp1->value)+strlen(tmp2->value)+1)*sizeof(char)); 562 sprintf(tmpStr,"%s%s",tmp1->value,tmp2->value); 563 if((tmp2=getMap(content->content,"headers"))!=NULL){ 564 char *tmpStr2=zStrdup(tmpStr); 565 free(tmpStr); 566 tmpStr=(char*)malloc((strlen(tmpStr2)+strlen(tmp2->value)+1)*sizeof(char)); 567 sprintf(tmpStr,"%s%s",tmpStr2,tmp2->value); 568 free(tmpStr2); 569 } 570 md5str=getMd5(tmpStr); 571 request=zStrdup(tmpStr); 572 free(tmpStr); 573 }else{ 574 char *myRequest=getFilenameForRequest(*m,tmp1->value); 575 md5str=getMd5(myRequest); 576 request=zStrdup(tmp1->value); 577 free(myRequest); 578 } 259 579 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 260 580 sprintf(fname,"%s/%s.zca",tmp->value,md5str); … … 264 584 addToMap((*in)->content,sname,ltmp1); 265 585 addToMap((*in)->content,mname,mimeType); 266 addToCache(*m,tmp1->value,fcontent,mimeType,fsize, NULL, 0); 267 free(fcontent); 586 char* origin=getProvenance(*m,request); 587 addToMap((*in)->content,oriname,origin); 588 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 589 addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0); 590 free(fcontent); 591 }else{ 592 addToMap((*in)->content,ufile,"true"); 593 cacheFile(*m,request,mimeType,fsize,hInternet->ihandle[*index].filename); 594 } 268 595 free(mimeType); 269 *index++;270 596 free(request); 597 (*index)++; 271 598 } 272 599 } … … 324 651 */ 325 652 void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){ 326 hInternet->waitingRequests[hInternet->nb]= strdup(url);653 hInternet->waitingRequests[hInternet->nb]=zStrdup(url); 327 654 if(req) 328 InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0 );655 InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0,*m); 329 656 maps *oreq=getMaps(*m,"orequests"); 330 657 if(oreq==NULL){ … … 335 662 free(oreq); 336 663 }else{ 337 setMapArray(oreq->content,"value",hInternet->nb -1,url);664 setMapArray(oreq->content,"value",hInternet->nb,url); 338 665 } 339 666 } … … 352 679 char* cached=isInCache(*m,url); 353 680 char *mimeType=NULL; 354 int fsize=0; 681 char *origin=NULL; 682 long long fsize=0; 683 map* memUse=getMapFromMaps(*m,"main","memory"); 355 684 356 685 map* t=getMap(*content,"xlink:href"); … … 361 690 362 691 if(cached!=NULL){ 363 364 struct stat f_status; 365 int s=stat(cached, &f_status); 692 zStatStruct f_status; 693 int s=zStat(cached, &f_status); 366 694 if(s==0){ 367 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));368 FILE* f=fopen(cached,"rb");369 fread(fcontent,f_status.st_size,1,f);695 zooLock* lck=lockFile(*m,cached,'r'); 696 if(lck==NULL) 697 return -1; 370 698 fsize=f_status.st_size; 371 fcontent[fsize]=0; 372 fclose(f); 699 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 700 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 701 FILE* f=fopen(cached,"rb"); 702 if(f!=NULL){ 703 fread(fcontent,f_status.st_size,1,f); 704 fcontent[fsize]=0; 705 fclose(f); 706 } 707 } 373 708 addToMap(*content,"cache_file",cached); 709 unlockFile(*m,lck); 374 710 } 375 711 cached[strlen(cached)-1]='m'; 376 s= stat(cached, &f_status);712 s=zStat(cached, &f_status); 377 713 if(s==0){ 714 zooLock* lck=lockFile(*m,cached,'r'); 715 if(lck==NULL) 716 return -1; 378 717 mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 379 718 FILE* f=fopen(cached,"rb"); … … 381 720 mimeType[f_status.st_size]=0; 382 721 fclose(f); 383 } 384 722 unlockFile(*m,lck); 723 } 724 cached[strlen(cached)-1]='p'; 725 s=zStat(cached, &f_status); 726 if(s==0){ 727 zooLock* lck=lockFile(*m,cached,'r'); 728 if(lck==NULL) 729 return -1; 730 origin=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 731 FILE* f=fopen(cached,"rb"); 732 fread(origin,f_status.st_size,1,f); 733 mimeType[f_status.st_size]=0; 734 fclose(f); 735 unlockFile(*m,lck); 736 } 385 737 }else{ 386 738 addRequestToQueue(m,hInternet,url,true); … … 393 745 addToMap(*content,"fmimeType",mimeType); 394 746 } 747 if(origin!=NULL){ 748 addToMap(*content,"origin",origin); 749 } 395 750 396 751 map* tmpMap=getMapOrFill(content,"value",""); 397 398 free(tmpMap->value); 399 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 400 if(tmpMap->value==NULL || fcontent == NULL) 401 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 402 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 403 752 if(memUse==NULL || strcasecmp(memUse->value,"load")==0){ 753 free(tmpMap->value); 754 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 755 if(tmpMap->value==NULL || fcontent == NULL) 756 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 757 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 758 } 759 404 760 char ltmp1[256]; 405 sprintf(ltmp1,"% d",fsize);761 sprintf(ltmp1,"%ld",fsize); 406 762 addToMap(*content,"size",ltmp1); 407 763 if(cached==NULL){ 408 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 764 if(memUse==NULL || strcasecmp(memUse->value,"load")==0) 765 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 766 else 767 cacheFile(*m,url,mimeType,fsize,hInternet->ihandle[hInternet->nb-1].filename); 409 768 } 410 769 else{ 411 770 addToMap(*content,"isCached","true"); 412 771 map* tmp=getMapFromMaps(*m,"main","cacheDir"); 413 if(tmp!=NULL){ 772 map* tmp1=getMap((*content),"cache_file"); 773 if(tmp!=NULL && tmp1==NULL){ 414 774 map *c=getMap((*content),"xlink:href"); 415 char* md5str=getMd5(c->value); 416 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 417 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 418 addToMap(*content,"cache_file",fname); 419 free(fname); 420 } 421 } 422 free(fcontent); 423 free(mimeType); 424 free(cached); 775 if(strncasecmp(c->value,"file://",7)!=0){ 776 char *myRequest=getFilenameForRequest(*m,c->value); 777 char* md5str=getMd5(myRequest); 778 free(myRequest); 779 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 780 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 781 addToMap(*content,"cache_file",fname); 782 free(fname); 783 free(md5str); 784 } 785 } 786 } 787 if(fcontent!=NULL) 788 free(fcontent); 789 if(mimeType!=NULL) 790 free(mimeType); 791 if(cached!=NULL) 792 free(cached); 425 793 return 0; 426 794 } -
trunk/zoo-project/zoo-kernel/caching.h
r797 r917 35 35 void addRequestToQueue(maps**,HINTERNET*,const char*,bool); 36 36 int loadRemoteFile(maps**,map**,HINTERNET*,char*); 37 37 char* getMd5f(char*); 38 int storeMd5(char*); 39 38 40 #ifdef __cplusplus 39 41 } -
trunk/zoo-project/zoo-kernel/configure.ac
r817 r917 1 1 AC_INIT([ZOO Kernel], [1.7.0], [bugs@zoo-project.org]) 2 3 AC_CONFIG_MACRO_DIR([macros]) 2 4 3 5 # Checks for programs. … … 12 14 AC_CHECK_LIB([dl], [dlopen,dlsym,dlerror,dlclose]) 13 15 AC_CHECK_LIB([crypto], [EVP_DigestInit,EVP_md5,EVP_DigestUpdate,BIO_f_base64,BIO_new]) 14 AC_CHECK_LIB([uuid], [uuid_generate_time])15 16 16 17 DEFAULT_LIBS="$LIBS" … … 20 21 # Checks for header files. 21 22 AC_FUNC_ALLOCA 22 AC_CHECK_HEADERS([fcntl.h inttypes.h libintl.hmalloc.h stddef.h stdlib.h string.h unistd.h])23 AC_CHECK_HEADERS([fcntl.h inttypes.h malloc.h stddef.h stdlib.h string.h unistd.h]) 23 24 24 25 # Checks for typedefs, structures, and compiler characteristics. … … 38 39 AC_FUNC_REALLOC 39 40 AC_CHECK_FUNCS([dup2 getcwd memset setenv strdup strstr]) 41 42 #============================================================================ 43 # Detect if uuid is available 44 #============================================================================ 45 46 AC_ARG_WITH([uuid], 47 [AS_HELP_STRING([--with-uuid=PATH], [Specifies an alternative location for the ossp-uuid library])], 48 [UUID_DIR="$withval"], [UUID_DIR="/usr/"]) 49 UUID_CFLAGS="-I$UUID_DIR/include" 50 UUID_LDFLAGS="-L$UUID_DIR/lib -luuid" 51 CPPFLAGS_SAVE="$CPPFLAGS" 52 CPPFLAGS="$UUID_CFLAGS" 53 LIBS_SAVE="$LIBS" 54 LIBS="$UUID_LDFLAGS" 55 AC_CHECK_HEADERS([uuid/uuid.h], 56 [], [AC_MSG_ERROR([could not find header file uuid.h])]) 57 AC_CHECK_LIB([uuid], [uuid_generate_time], 58 [], [AC_MSG_ERROR([could not find function in uuid library])]) 59 CPPFLAGS="$CPPFLAGS_SAVE" 60 AC_SUBST([UUID_CFLAGS]) 61 AC_SUBST([UUID_LDFLAGS]) 62 63 #============================================================================ 64 # Detect if json-c is available 65 #============================================================================ 66 67 AC_ARG_WITH([callback], 68 [AS_HELP_STRING([--with-callback=yes], [Activate callback invocation during HPC execution])], 69 [CALLBACK_ACTIVATED="$withval"], [CALLBACK_ACTIVATED="no"]) 70 71 AC_ARG_WITH([json], 72 [AS_HELP_STRING([--with-json=PATH], [Specifies an alternative location for the json-c library])], 73 [JSON_DIR="$withval"], [JSON_DIR="/usr/"]) 74 if test "x$JSON_DIR" != "x" && test "x$CALLBACK_ACTIVATED" == "xyes" 75 then 76 JSON_CPPFLAGS="-I$JSON_DIR/include/json-c/" 77 JSON_LDFLAGS="-L$JSON_DIR/lib -ljson-c" 78 CPPFLAGS_SAVE="$CPPFLAGS" 79 CPPFLAGS="$JSON_CPPFLAGS" 80 LIBS_SAVE="$LIBS" 81 LIBS="$JSON_LDFLAGS" 82 AC_CHECK_HEADERS([json_object.h], 83 [], [AC_MSG_ERROR([could not find header file json_object.h])]) 84 AC_CHECK_LIB([json-c], [json_object_new_object], 85 [], [AC_MSG_ERROR([could not find function in json-c library])]) 86 CPPFLAGS="$CPPFLAGS_SAVE" 87 JSON_FILE="service_json.o" 88 JSON_ENABLED="-DJSON" 89 CALLBACK_FILE="service_callback.o" 90 CALLBACK_USE="-DUSE_CALLBACK" 91 fi 92 AC_SUBST([JSON_CPPFLAGS]) 93 AC_SUBST([JSON_LDFLAGS]) 94 AC_SUBST([JSON_FILE]) 95 AC_SUBST([JSON_ENABLED]) 96 AC_SUBST([CALLBACK_FILE]) 97 AC_SUBST([CALLBACK_USE]) 40 98 41 99 #============================================================================ … … 56 114 AC_CHECK_LIB(crypto, BIO_f_base64, 57 115 [], [AC_MSG_ERROR([could not find $i function in openssl library])]) 116 CPPFLAGS="$CPPFLAGS_SAVE" 58 117 AC_SUBST([OPENSSL_CFLAGS]) 59 118 AC_SUBST([OPENSSL_LDFLAGS]) 119 120 #============================================================================ 121 # Detect if gettext is available 122 #============================================================================ 123 124 #AC_ARG_WITH([gettext], 125 # [AS_HELP_STRING([--with-gettext=PATH], [Specifies an alternative location for the openssl library])], 126 # [GETTEXT_DIR="$withval"], [GETTEXT_DIR="/usr/"]) 127 128 #GETTEXT_CFLAGS="-I$GETTEXT_DIR/include" 129 #GETTEXT_LDFLAGS="-L$GETTEXT_DIR/lib -lintl" 130 #CFLAGS_SAVE="$CFLAGS" 131 #CFLAGS="$GETTEXT_CFLAGS" 132 #LIBS_SAVE="$LIBS" 133 #LIBS="$GETTEXT_LDFLAGS" 134 #AM_GNU_GETTEXT([external], [], []) 135 #AC_CHECK_LIB(intl, 136 # [dgettext], [] , [AC_MSG_ERROR([could not find $i function in gettext library])]) 137 #AC_SUBST([GETTEXT_CFLAGS]) 138 #AC_SUBST([GETTEXT_LDFLAGS]) 60 139 61 140 #============================================================================ … … 145 224 AC_SUBST([FCGI_LDFLAGS]) 146 225 226 AC_ARG_WITH([metadb], 227 [AS_HELP_STRING([--with-metadb=yes], [Activates the metadata database support])], 228 [WITHMETADB="$withval"], [WITHMETADB=""]) 229 230 if test "x$WITHMETADB" = "xyes"; then 231 METADB="-DMETA_DB" 232 METADB_FILE="meta_sql.o sqlapi.o" 233 else 234 METADB="" 235 METADB_FILE="" 236 fi 237 238 AC_SUBST([METADB]) 239 AC_SUBST([METADB_FILE]) 240 241 AC_ARG_WITH([hpc], 242 [AS_HELP_STRING([--with-hpc=yes], [Specifies if you need to activate HPC support])], 243 [HPCWITH="$withval"], [HPCWITH="no"]) 244 245 246 AC_ARG_WITH([ssh2], 247 [AS_HELP_STRING([--with-ssh2=PATH], [Specifies an alternative location for the ssh2 library])], 248 [SSH2PATH="$withval"], [SSH2PATH="/usr"]) 249 250 if test "x$HPCWITH" = "xyes"; then 251 HPC_FILES="service_internal_hpc.o sshapi.o" 252 HPC_ENABLED="-DUSE_HPC" 253 HPC_CPPFLAGS="" 254 HPC_LDFLAGS="" 255 # Extract the linker and include flags 256 SSH2_LDFLAGS="-L$SSH2PATH/lib -lssh2" 257 SSH2_CPPFLAGS="-I$SSH2PATH/include" 258 # Check headers file 259 CPPFLAGS_SAVE="$CPPFLAGS" 260 CPPFLAGS="$SSH2_CPPFLAGS" 261 LIBS_SAVE="$LIBS" 262 LIBS="$SSH2_LDFLAGS" 263 264 AC_CHECK_HEADERS([libssh2.h], 265 [], [AC_MSG_ERROR([could not find headers related to libssh2])]) 266 AC_CHECK_LIB([ssh2], [libssh2_session_init]) 267 268 LIBS="$LIBS_SAVE" 269 fi 270 271 AC_SUBST([HPC_CPPFLAGS]) 272 AC_SUBST([HPC_LDFLAGS]) 273 AC_SUBST([HPC_ENABLED]) 274 AC_SUBST([HPC_FILES]) 275 276 AC_SUBST([SSH2_CPPFLAGS]) 277 AC_SUBST([SSH2_LDFLAGS]) 278 147 279 # =========================================================================== 148 280 # Detect if libxml2 is installed … … 400 532 AC_SUBST([MS_LIBS]) 401 533 AC_SUBST([MS_FILE]) 534 AC_SUBST([MS_VERSION]) 535 536 # =========================================================================== 537 # Detect if R is installed 538 # =========================================================================== 539 540 AC_ARG_WITH([r], 541 [AS_HELP_STRING([--with-r=PATH], [To enable python support or Specifies an alternative directory for R installation, disabled by default])], 542 [R_PATH="$withval"; R_ENABLED="-DUSE_R"], [R_ENABLED=""]) 543 544 if test -z "$R_ENABLED" 545 then 546 R_FILE="" 547 else 548 R_FILE="service_internal_r.o" 549 # Extract the linker and include flags 550 R_LDFLAGS="-L$R_PATH/lib/ -lR" 551 R_CPPFLAGS="-I$R_PATH/include/" 552 553 # Check headers file 554 CPPFLAGS_SAVE="$CPPFLAGS" 555 CPPFLAGS="$R_CPPFLAGS" 556 AC_CHECK_HEADERS([RInternals.h], 557 [], [AC_MSG_ERROR([could not find headers include related to R])]) 558 559 # Ensure we can link against libphp 560 #LIBS_SAVE="$LIBS" 561 #LIBS="$R_LDFLAGS" 562 #AC_CHECK_LIB([$LIBS], [R_tryEval], [], [AC_MSG_ERROR([could not find libR])], []) 563 #LIBS="$LIBS_SAVE" 564 fi 565 566 AC_SUBST([R_CPPFLAGS]) 567 AC_SUBST([R_LDFLAGS]) 568 AC_SUBST([R_ENABLED]) 569 AC_SUBST([R_FILE]) 570 402 571 403 572 # =========================================================================== … … 646 815 647 816 AC_LANG([C++]) 648 echo $JAVA_CPPFLAGS817 #echo $JAVA_CPPFLAGS 649 818 # Check headers file (second time we check that in fact) 650 819 CPPFLAGS_SAVE="$CPPFLAGS" … … 696 865 697 866 AC_LANG([C++]) 698 echo $JAVA_CPPFLAGS867 #echo $JAVA_CPPFLAGS 699 868 # Check headers file (second time we check that in fact) 700 869 CPPFLAGS_SAVE="$CFLAGS" … … 888 1057 [SAGAPATH="$withval"], [SAGAPATH=""]) 889 1058 1059 AC_ARG_WITH([saga-version], 1060 [AS_HELP_STRING([--with-saga-version=VERSION], [Specifies the SAGA-GIS version number])], 1061 [SAGAVERS="$withval"], [SAGAVERS="2"]) 1062 890 1063 if test -z "$SAGAPATH" 891 1064 then … … 903 1076 WX_ISSUE="-D_WX_WXCRTVARARG_H_" 904 1077 SAGA_DEFS="-D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -DMODULE_LIBRARY_PATH=\\\"$SAGAPATH/lib/saga\\\"" 905 SAGA_CPPFLAGS=" -fPIC -I$SAGAPATH/include/saga/saga_core/saga_api/ `$WXCFG --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $SAGA_DEFS $WX_ISSUE"1078 SAGA_CPPFLAGS="-DSAGA_VERSION=${SAGAVERS} -fPIC -I$SAGAPATH/include/saga/saga_core/saga_api/ `$WXCFG --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $SAGA_DEFS $WX_ISSUE" 906 1079 SAGA_LDFLAGS="-fPIC `$WXCFG --unicode=yes --static=no --libs` -lsaga_api" 907 1080 SAGA_ENABLED="-DUSE_SAGA" … … 914 1087 LIBS_SAVE="$LIBS" 915 1088 LIBS="$SAGA_LDFLAGS" 916 AC_CHECK_HEADERS([module_library.h], 917 [], [AC_MSG_ERROR([could not find header file $i related to SAGA-GIS])]) 918 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "module_library.h"],[SG_Get_Module_Library_Manager();]])], 919 [AC_MSG_RESULT([checking for SG_Get_Module_Library_Manager... yes])],[AC_MSG_ERROR([checking for SG_Get_Module_Library_Manager... failed])]) 1089 if test "$SAGAVERS" == "2"; then 1090 AC_CHECK_HEADERS([module_library.h], 1091 [], [AC_MSG_ERROR([could not find header file $i related to SAGA-GIS])]) 1092 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "module_library.h"],[SG_Get_Module_Library_Manager();]])], 1093 [AC_MSG_RESULT([checking for SG_Get_Module_Library_Manager... yes])],[AC_MSG_ERROR([checking for SG_Get_Module_Library_Manager... failed])]) 1094 else 1095 AC_CHECK_HEADERS([tool_library.h], 1096 [], [AC_MSG_ERROR([could not find header file $i related to SAGA-GIS])]) 1097 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "tool_library.h"],[SG_Get_Tool_Library_Manager();]])], 1098 [AC_MSG_RESULT([checking for SG_Get_Tool_Library_Manager... yes])],[AC_MSG_ERROR([checking for SG_Get_Tool_Library_Manager... failed])]) 1099 fi 1100 920 1101 LIBS="$LIBS_SAVE" 921 1102 AC_LANG_POP([C++]) -
trunk/zoo-project/zoo-kernel/main_conf_read.y
r790 r917 87 87 ; 88 88 89 pair: PAIR { curr_key=zStrdup($1);}89 pair: PAIR {if(curr_key!=NULL) free(curr_key);curr_key=zStrdup($1);} 90 90 | EPAIR { 91 91 if(current_content==NULL) … … 99 99 } 100 100 free(curr_key); 101 curr_key=NULL; 101 102 } 102 | SPAIR { curr_key=zStrdup($1);if(debug) printf("SPAIR FOUND !!\n"); }103 | SPAIR {if(curr_key!=NULL) free(curr_key);curr_key=zStrdup($1);if(debug) printf("SPAIR FOUND !!\n"); } 103 104 ; 104 105 … … 162 163 free(current_content); 163 164 } 165 if(curr_key!=NULL){ 166 free(curr_key); 167 } 164 168 165 169 fclose(crin); -
trunk/zoo-project/zoo-kernel/makefile.vc
r788 r917 50 50 $(CPP) $(CFLAGS) /c caching.c 51 51 52 service_json.obj: service_json.c service_json.h 53 $(CPP) $(CFLAGS) /c service_json.c 54 52 55 request_parser.obj: request_parser.c request_parser.h 53 56 $(CPP) $(CFLAGS) /c request_parser.c … … 71 74 $(CPP) /c $(CFLAGS) service_internal_ruby.c 72 75 76 service_internal_mono.obj: service_internal_mono.c service_internal_mono.h service.h 77 $(CPP) /c $(MONO_CLAGS) $(CFLAGS) service_internal_mono.c 78 73 79 service_internal_python.obj: service_internal_python.c service.h 74 80 $(CPP) /c $(CFLAGS) service_internal_python.c … … 89 95 $(CPP) /c $(CFLAGS) $(PHP_CFLAGS) service_internal_php.c 90 96 97 service_callback.obj: service_callback.c service_callback.h service.h 98 $(CPP) /c $(CFLAGS) service_callback.c 99 91 100 service_internal_php7.obj: service_internal_php7.c service_internal_php.h service.h 92 101 $(CPP) /c $(CFLAGS) $(PHP_CFLAGS) service_internal_php7.c … … 95 104 link /dll /out:$(LIBZOO_SERVICE) ./service.obj ./service_internal.obj ./sqlapi.obj $(LDFLAGS) /FORCE:MULTIPLE 96 105 97 $(PROGRAMNAME): version.h $(LIBZOO_SERVICE) zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $( RUBY_FILE) $(PHP_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj request_parser.obj response_print.obj server_internal.obj caching.obj98 link zoo_loader.obj request_parser.obj response_print.obj server_internal.obj caching.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj ./libzoo_service.lib /out:$(PROGRAMNAME) $(LDFLAGS) $(LDFLAGSCGI)106 $(PROGRAMNAME): version.h $(LIBZOO_SERVICE) zoo_loader.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(MONO_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj request_parser.obj response_print.obj server_internal.obj caching.obj service_json.obj service_callback.obj 107 link zoo_loader.obj request_parser.obj response_print.obj server_internal.obj caching.obj service_json.obj service_callback.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(MONO_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj zoo_service_loader.obj ./libzoo_service.lib /out:$(PROGRAMNAME) $(LDFLAGS) $(LDFLAGSCGI) $(JSONC_LIB) $(PTHREADS_LIB) $(XSLT_LIB) 99 108 100 zcfg2yaml: version.h zcfg2yaml.obj zoo_service_loader.obj service_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj101 link zcfg2yaml.obj server_internal.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj response_print.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj ./libzoo_service.lib /out:zcfg2yaml.exe $(LDFLAGS) $(LDFLAGSCGI)109 zcfg2yaml: version.h zcfg2yaml.obj zoo_service_loader.obj service_internal.obj caching.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(MONO_FILE) $(RUBY_FILE) ulinet.obj lex.cr.obj lex.sr.obj service_conf.tab.obj main_conf_read.tab.obj 110 link zcfg2yaml.obj server_internal.obj caching.obj $(PY_FILE) $(JAVA_FILE) $(MS_FILE) $(JS_FILE) $(MONO_FILE) $(RUBY_FILE) $(PHP_FILE) ulinet.obj response_print.obj main_conf_read.tab.obj lex.cr.obj service_conf.tab.obj lex.sr.obj ./libzoo_service.lib /out:zcfg2yaml.exe $(LDFLAGS) $(LDFLAGSCGI) 102 111 103 112 clean: … … 105 114 106 115 embed-manifest: zoo_loader.cgi 107 mt.exe -manifest zoo_loader.cgi.manifest -outputresource:zoo_loader.cgi; 1116 mt.exe -manifest zoo_loader.cgi.manifest -outputresource:zoo_loader.cgi; -
trunk/zoo-project/zoo-kernel/mimetypes.h
r601 r917 180 180 { "application/vnd.dece.unspecified", "uvx" }, 181 181 { "application/vnd.dece.zip", "uvz" }, 182 { "application/vnd.denovo.fcselayout-link", "fe_launch" }, 182 { "application/vnd.denovo.fcselayout-link", "fe_launch" }, 183 183 { "application/vnd.dna", "dna" }, 184 184 { "application/vnd.dolby.mlp", "mlp" }, … … 818 818 */ 819 819 static map* getFileExtensionMap(const char* mimeType, bool* hasExt) { 820 map* ext = createMap("extension", "txt"); 821 *hasExt = false; 822 823 if (mimeType != NULL) { 824 for (int i = 0; i < NUM_MIME_TYPES; i++) { 825 if(strncmp(mimeType, MIME[i][M_Type], strlen(MIME[i][M_Type])) == 0) { 826 free(ext->value); 827 ext->value = zStrdup(MIME[i][M_Extension]); 828 *hasExt = true; 829 break; 830 } 831 } 832 if (*hasExt == false && strncmp(mimeType, "image/", 6) == 0) { 833 free(ext->value); 834 ext->value = zStrdup(strstr(mimeType, "/") + 1); 835 } 836 } 837 return ext; 838 } 820 839 821 map* ext = createMap("extension", "txt"); 822 *hasExt = false; 823 824 if (mimeType != NULL) { 825 for (int i = 0; i < NUM_MIME_TYPES; i++) { 826 if (strncmp(mimeType, MIME[i][M_Type], strlen(MIME[i][M_Type])) == 0) { 827 ext->value = zStrdup(MIME[i][M_Extension]); 828 *hasExt = true; 829 break; 830 } 831 } 832 if (*hasExt == false && strncmp(mimeType, "image/", 6) == 0) { 833 ext->value = zStrdup(strstr(mimeType, "/") + 1); 834 } 835 } 836 return ext; 840 static int isGeographic(const char* mimeType){ 841 char* imageMimeType[4]={ 842 "image/tiff", 843 "image/png", 844 "image/jpeg", 845 "application/vnd.google-earth.kmz" 846 }; 847 char* vectorMimeType[5]={ 848 "text/xml", 849 "application/json", 850 "application/gml+xml", 851 "application/zip", 852 "application/vnd.google-earth.kml+xml" 853 }; 854 int i=0; 855 for(;i<4;i++){ 856 if(strncmp(imageMimeType[i],mimeType,strlen(imageMimeType[i]))==0) 857 return 1; 858 } 859 i=0; 860 for(;i<5;i++){ 861 if(strncmp(vectorMimeType[i],mimeType,strlen(vectorMimeType[i]))==0) 862 return 2; 863 } 864 return -1; 837 865 } -
trunk/zoo-project/zoo-kernel/nmake.opt
r788 r917 87 87 !ENDIF 88 88 89 !IFDEF MONO_DIR 90 MONO_CFLAGS=-DUSE_MONO -I"$(MONO_DIR)"\msvc -I"$(MONO_DIR)"\msvc\include -I"$(MONO_DIR)" 91 MONO_LDFLAGS=/LIBPATH:"$(MONO_DIR)/msvc/build/sgen/x64/lib/Release" mono-2.0-sgen.lib 92 MONO_FILE=service_internal_mono.obj 93 !ENDIF 94 89 95 !IFNDEF ZOOK_DIR 90 96 ZOOK_DIR=. … … 100 106 !ENDIF 101 107 102 CFLAGS= $(DB_FLAGS) $(MS_DEFS) $(INCLUDES) $(CFLAGS1) /nologo /MD /W3 /EHsc /Ox /D_CRT_SECURE_NO_WARNINGS /DWIN32 /DPROGRAMNAME=\"$(PROGRAMNAME)\" $(CJFLAGS) -I$(ZOOK_DIR) $(RUBY_CFLAGS) -I./ $(JAVA_CFLAGS) $(MS_CFLAGS) -I$(TROOT)\..\..\thirds\dirent-win32 -I$(INTL_DIR) -I$(CURL_DIR)\include -I$(XML2_DIR)\include -I$(GDAL_DIR)\port $(JS_CFLAGS) -I$(GDAL_DIR)\ogr -I$(GDAL_DIR)\gcore -I$(GD_DIR) -I$(ICONV_DIR) -I$(TROOT)\..\..\thirds\include -I$(TROOT)\..\..\thirds\cgic206 -I$(PYTHON_CPATH)\include -I$(SSL_DIR)/inc32 -I$(FCGI_DIR)\include $(PY_CFLAGS) $(PHP_CFLAGS) -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 108 !IFDEF WIN32_DEBUG 109 WIN32_DBG=-DWIN32_DEBUG 110 !ENDIF 111 112 CFLAGS=$(MONO_CFLAGS) $(WIN32_DBG) $(DB_FLAGS) $(MS_DEFS) $(INCLUDES) $(CFLAGS1) /nologo /MD /W3 /EHsc /Ox /D_CRT_SECURE_NO_WARNINGS /DWIN32 /DPROGRAMNAME=\"$(PROGRAMNAME)\" $(CJFLAGS) -I$(ZOOK_DIR) $(RUBY_CFLAGS) -I./ $(JAVA_CFLAGS) $(MS_CFLAGS) -I$(TROOT)\..\..\thirds\dirent-win32 -I$(INTL_DIR) -I$(CURL_DIR)\include -I$(XML2_DIR)\include -I$(GDAL_DIR)\port $(JS_CFLAGS) -I$(GDAL_DIR)\ogr -I$(GDAL_DIR)\gcore -I$(GD_DIR) -I$(ICONV_DIR) -I$(TROOT)\..\..\thirds\include -I$(TROOT)\..\..\thirds\cgic206 -I$(PYTHON_CPATH)\include -I$(SSL_DIR)/inc32 -I$(FCGI_DIR)\include $(PY_CFLAGS) $(PHP_CFLAGS) -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF 103 113 104 114 LDFLAGSCGI=$(TROOT)/../../thirds/cgic206/libcgic.lib 105 LDFLAGS=$( FCGI_DIR)/libfcgi/Release/libfcgi.lib $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(SSL_DIR)/out32dll/libeay32.lib $(JAVA_LDFLAGS) $(SSL_DIR)/out32dll/ssleay32.lib $(MS_LDFLAGS) $(INTL_DIR)/intl.lib $(XML2_DIR)/win32/bin.msvc/libxml2.lib $(GDAL_DIR)/gdal_i.lib $(CURL_DIR)/lib/libcurl.lib $(JS_LDFLAGS) $(RUBY_LDFLAGS) $(PHP_LDFLAGS) /machine:i386115 LDFLAGS=$(MONO_LDFLAGS) $(FCGI_DIR)/libfcgi/Release/libfcgi.lib $(CURL_LIBRARY) $(PY_LDFLAGS) $(XML2_LIBRARY) $(SSL_DIR)/out32dll/libeay32.lib $(JAVA_LDFLAGS) $(SSL_DIR)/out32dll/ssleay32.lib $(MS_LDFLAGS) $(INTL_DIR)/intl.lib $(XML2_DIR)/win32/bin.msvc/libxml2.lib $(GDAL_DIR)/gdal_i.lib $(CURL_DIR)/lib/libcurl.lib $(JS_LDFLAGS) $(RUBY_LDFLAGS) $(PHP_LDFLAGS) /machine:i386 -
trunk/zoo-project/zoo-kernel/request_parser.c
r889 r917 28 28 #include "response_print.h" 29 29 #include "caching.h" 30 #include "cgic.h" 30 31 31 32 /** … … 154 155 addToMap(cursor->content,"base64_value",tmp->value); 155 156 int size=0; 156 char *s= strdup(tmp->value);157 char *s=zStrdup(tmp->value); 157 158 free(tmp->value); 158 159 tmp->value=base64d(s,strlen(s),&size); … … 174 175 addToMap(cursor->content,key,tmp->value); 175 176 int size=0; 176 char *s= strdup(tmp->value);177 char *s=zStrdup(tmp->value); 177 178 free(tmp->value); 178 179 tmp->value=base64d(s,strlen(s),&size); … … 521 522 int l = 0; 522 523 map* version=getMapFromMaps(*main_conf,"main","rversion"); 524 map* memory=getMapFromMaps(*main_conf,"main","memory"); 523 525 int vid=getVersionId(version->value); 524 526 for (k=0; k < nodes->nodeNr; k++) … … 533 535 xmlChar *val = xmlGetProp (cur, BAD_CAST "id"); 534 536 tmpmaps = createMaps((char *) val); 537 xmlFree(val); 535 538 } 536 539 … … 624 627 tmpmaps->content = 625 628 createMap (refs[l], (char *) val); 626 627 629 map *ltmp = getMap (tmpmaps->content, "method"); 628 630 if (l == 4 ) 629 631 { 630 if ((ltmp==NULL || strncasecmp (ltmp->value, "POST",4) != 0)) // 631 //if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 632 if ((ltmp==NULL || strncmp (ltmp->value, "POST",4) != 0)) 632 633 { 633 634 if (loadRemoteFile … … 751 752 map *btmp = 752 753 getMap (tmpmaps->content, "Reference"); 754 addToMap (tmpmaps->content, "Body", tmp); 753 755 if (btmp != NULL) 754 756 { … … 759 761 xmlStrlen(btmps), 760 762 INTERNET_FLAG_NO_CACHE_WRITE, 761 0); 763 0, 764 *main_conf); 762 765 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 763 766 } … … 778 781 xmlGetProp (cur3, BAD_CAST "href"); 779 782 HINTERNET bInternet, res1, res; 783 maps *tmpConf=createMaps("main"); 784 tmpConf->content=createMap("memory","load"); 780 785 bInternet = InternetOpen ( 781 786 #ifndef WIN32 … … 785 790 INTERNET_OPEN_TYPE_PRECONFIG, 786 791 NULL, NULL, 0); 792 #ifndef WIN32 787 793 if (!CHECK_INET_HANDLE (bInternet)) 788 794 fprintf (stderr, 789 795 "WARNING : bInternet handle failed to initialize"); 796 #endif 790 797 bInternet.waitingRequests[0] = 791 strdup ((char *) val);798 zStrdup ((char *) val); 792 799 res1 = 793 800 InternetOpenUrl (&bInternet, … … 795 802 [0], NULL, 0, 796 803 INTERNET_FLAG_NO_CACHE_WRITE, 797 0); 804 0, 805 tmpConf); 798 806 processDownloads (&bInternet); 807 freeMaps(&tmpConf); 808 free(tmpConf); 799 809 char *tmp = 800 810 (char *) … … 816 826 &bRead); 817 827 tmp[bInternet.ihandle[0].nDataLen] = 0; 818 InternetCloseHandle (&bInternet); 828 InternetCloseHandle(&bInternet); 829 addToMap (tmpmaps->content, "Body", tmp); 819 830 map *btmp = 820 831 getMap (tmpmaps->content, "href"); … … 829 840 strlen(tmp), 830 841 INTERNET_FLAG_NO_CACHE_WRITE, 831 0); 842 0, 843 *main_conf); 832 844 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 833 845 } 834 846 free (tmp); 847 xmlFree (val); 835 848 } 836 849 } … … 895 908 } 896 909 } 897 898 910 899 911 while (cur4 != NULL) … … 967 979 968 980 map *test = getMap (tmpmaps->content, "encoding"); 969 970 981 if (test == NULL) 971 { 982 { 972 983 if (tmpmaps->content != NULL) 973 984 addToMap (tmpmaps->content, "encoding", … … 979 990 } 980 991 981 if (getMap(tmpmaps->content,"dataType")==NULL && strcasecmp (test->value, "base64") != 0) 982 { 983 xmlChar *mv = xmlNodeListGetString (doc, 984 cur4->xmlChildrenNode, 985 1); 992 if (getMap(tmpmaps->content,"dataType")==NULL && test!=NULL && strcasecmp (test->value, "base64") != 0) 993 { 994 xmlChar *mv = NULL; 995 /*if(cur4!=NULL && cur4->xmlChildrenNode!=NULL) 996 xmlChar *mv = xmlNodeListGetString (doc, 997 cur4->xmlChildrenNode, 998 1);*/ 986 999 map *ltmp = 987 1000 getMap (tmpmaps->content, "mimeType"); 988 if ( mv == NULL989 || 1001 if (/*mv == NULL 1002 ||*/ 990 1003 (xmlStrcasecmp 991 1004 (cur4->name, BAD_CAST "ComplexData") == 0 … … 1025 1038 buffersize); 1026 1039 }else{ 1040 1027 1041 if(xmlStrcasecmp 1028 1042 (cur4->name, BAD_CAST "BoundingBoxData") == 0){ … … 1039 1053 xmlNodePtr cur5 = cur4->children; 1040 1054 while (cur5 != NULL 1055 && cur5->type != XML_ELEMENT_NODE 1056 && cur5->type != XML_TEXT_NODE 1041 1057 && cur5->type != XML_CDATA_SECTION_NODE) 1042 1058 cur5 = cur5->next; 1043 1059 if (cur5 != NULL 1044 && cur5->type == XML_CDATA_SECTION_NODE){ 1045 if(mv!=NULL) 1046 xmlFree(mv); 1047 mv=xmlStrdup(cur5->content); 1060 && cur5->type != XML_CDATA_SECTION_NODE 1061 && cur5->type != XML_TEXT_NODE) 1062 { 1063 xmlDocPtr doc1 = xmlNewDoc (BAD_CAST "1.0"); 1064 int buffersize; 1065 xmlDocSetRootElement (doc1, cur5); 1066 xmlDocDumpFormatMemoryEnc (doc1, &mv, 1067 &buffersize, 1068 "utf-8", 0); 1069 addIntToMap (tmpmaps->content, "size", 1070 buffersize); 1071 } 1072 else if (cur5 != NULL)/* 1073 && cur5->type == XML_CDATA_SECTION_NODE)*/{ 1074 xmlFree(mv); 1075 if(cur5->content!=NULL){ 1076 mv=xmlStrdup(cur5->content); 1077 } 1048 1078 } 1049 1079 } … … 1088 1118 cur2 = cur2->next; 1089 1119 } 1120 } 1121 if(memory!=NULL && strncasecmp(memory->value,"load",4)!=0) 1122 if(getMap(tmpmaps->content,"to_load")==NULL){ 1123 addToMap(tmpmaps->content,"to_load","false"); 1090 1124 } 1091 1125 { … … 1123 1157 } 1124 1158 } 1125 else 1159 else{ 1126 1160 addMapsToMaps (request_output, tmpmaps); 1161 } 1127 1162 } 1128 1163 freeMaps (&tmpmaps); … … 1198 1233 const char ress[4][13] = 1199 1234 { "mimeType", "encoding", "schema", "transmission" }; 1235 xmlFree (val); 1200 1236 for (l = 0; l < 4; l++){ 1201 1237 val = xmlGetProp (cur, BAD_CAST ress[l]); … … 1217 1253 while (ccur != NULL){ 1218 1254 if(ccur->type == XML_ELEMENT_NODE){ 1219 char *xpathExpr=(char*)malloc(6 5+strlen(tmpmaps->name));1220 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1255 char *xpathExpr=(char*)malloc(66+strlen(tmpmaps->name)); 1256 sprintf(xpathExpr,"/*/*[local-name()='Output' and @id='%s']/*[local-name()='Output']",tmpmaps->name); 1221 1257 xmlXPathObjectPtr tmpsptr = extractFromDoc (doc, xpathExpr); 1222 1258 xmlNodeSet* cnodes = tmpsptr->nodesetval; 1223 1259 xmlParseOutputs2(main_conf,request_inputs,&tmpmaps->child,doc,cnodes); 1260 xmlXPathFreeObject (tmpsptr); 1261 free(xpathExpr); 1224 1262 break; 1225 1263 } … … 1470 1508 1471 1509 xmlInitParser (); 1472 //xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1473 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER | XML_PARSE_HUGE); // 1510 xmlDocPtr doc = xmlReadMemory (post, cgiContentLength, "input_request.xml", NULL, XML_PARSE_RECOVER); 1474 1511 1475 1512 /** … … 1503 1540 else 1504 1541 addToMap(*request_inputs,"mode","auto"); 1542 xmlFree(val); 1505 1543 val = xmlGetProp (cur, BAD_CAST "response"); 1506 1544 if(val!=NULL){ … … 1515 1553 addToMap(*request_inputs,"ResponseDocument",""); 1516 1554 } 1555 xmlFree(val); 1517 1556 } 1518 1557 } … … 1768 1807 #endif 1769 1808 targetFile = 1770 open (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC,1809 zOpen (storageNameOnServer, O_RDWR | O_CREAT | O_TRUNC, 1771 1810 S_IRWXU | S_IRGRP | S_IROTH); 1772 1811 if (targetFile < 0) … … 1788 1827 addToMap (tmpReqI->content, "lref", storageNameOnServer); 1789 1828 cgiFormFileClose (file); 1790 close (targetFile);1829 zClose (targetFile); 1791 1830 free(fileNameOnServer); 1792 1831 free(storageNameOnServer); … … 1820 1859 if (r_inputs == NULL){ 1821 1860 if(mandatory>0){ 1822 c onst char *replace=_("Mandatory parameter <%s> was not specified");1861 char *replace=_("Mandatory parameter <%s> was not specified"); 1823 1862 char *message=(char*)malloc((strlen(replace)+strlen(toCheck)+1)*sizeof(char)); 1824 1863 sprintf(message,replace,toCheck); … … 1869 1908 } 1870 1909 if(hasValidValue<0){ 1871 c onst char *replace=_("The value <%s> was not recognized, %s %s the only acceptable value.");1910 char *replace=_("The value <%s> was not recognized, %s %s the only acceptable value."); 1872 1911 nb=0; 1873 1912 char *vvalues=NULL; 1874 c onst char* num=_("is");1913 char* num=_("is"); 1875 1914 while(avalues[nb]!=NULL){ 1876 1915 char *tvalues; … … 1920 1959 } 1921 1960 } 1961 1962 /** 1963 * Parse cookie contained in request headers. 1964 * 1965 * @param conf the conf maps containinfg the main.cfg 1966 * @param cookie the 1967 */ 1968 void parseCookie(maps** conf,const char* cookie){ 1969 char* tcook=zStrdup(cookie); 1970 char *token, *saveptr; 1971 token = strtok_r (tcook, "; ", &saveptr); 1972 maps* res=createMaps("cookies"); 1973 while (token != NULL){ 1974 char *token1, *saveptr1, *name; 1975 int i=0; 1976 token1 = strtok_r (token, "=", &saveptr1); 1977 while (token1 != NULL){ 1978 if(i==0){ 1979 name=zStrdup(token1); 1980 i++; 1981 } 1982 else{ 1983 if(res->content==NULL) 1984 res->content=createMap(name,token1); 1985 else 1986 addToMap(res->content,name,token1); 1987 free(name); 1988 name=NULL; 1989 i=0; 1990 } 1991 token1 = strtok_r (NULL, "=", &saveptr1); 1992 } 1993 if(name!=NULL) 1994 free(name); 1995 token = strtok_r (NULL, "; ", &saveptr); 1996 } 1997 addMapsToMaps(conf,res); 1998 freeMaps(&res); 1999 free(res); 2000 free(tcook); 2001 } -
trunk/zoo-project/zoo-kernel/request_parser.h
r866 r917 45 45 int kvpParseOutputs(maps**,map *,maps**); 46 46 int xmlParseInputs(maps**,service*,maps**,xmlDocPtr,xmlNodeSet*,HINTERNET*); 47 int xmlParseBoundingBox(maps** main_conf,map** current_input,xmlDocPtr doc); 47 48 int xmlParseOutputs(maps**,map**,maps**,xmlDocPtr,xmlNodePtr,bool); 48 49 int xmlParseRequest(maps**,const char*,map**,service*,maps**,maps**,HINTERNET*); … … 50 51 void checkValidValue(map*,map**,const char*,const char**,int); 51 52 int validateRequest(maps**,service*,map*,maps**,maps**,HINTERNET*); 52 53 void parseCookie(maps**,const char*); 54 53 55 #ifdef __cplusplus 54 56 } -
trunk/zoo-project/zoo-kernel/response_print.c
r889 r917 23 23 */ 24 24 25 #include "service.h" 25 26 #include "response_print.h" 26 27 #include "request_parser.h" … … 31 32 #else 32 33 #include "cpl_vsi.h" 34 #endif 35 #ifdef USE_CALLBACK 36 #include "service_callback.h" 33 37 #endif 34 38 … … 75 79 } 76 80 if(prefix!=NULL){ 77 char* tmp0= strdup(serv->name);81 char* tmp0=zStrdup(serv->name); 78 82 free(serv->name); 79 83 serv->name=(char*)malloc((strlen(prefix)+strlen(tmp0)+1)*sizeof(char)); … … 179 183 nbNs++; 180 184 currId=0; 181 nsName[currId]= strdup(name);185 nsName[currId]=zStrdup(name); 182 186 usedNs[currId]=xmlNewNs(nr,BAD_CAST url,BAD_CAST name); 183 187 }else{ … … 186 190 nbNs++; 187 191 currId=nbNs-1; 188 nsName[currId]= strdup(name);192 nsName[currId]=zStrdup(name); 189 193 usedNs[currId]=xmlNewNs(nr,BAD_CAST url,BAD_CAST name); 190 194 } … … 251 255 if(soap!=NULL && strcasecmp(soap->value,"true")==0){ 252 256 int lNbNs=nbNs; 253 nsName[lNbNs]= strdup("soap");257 nsName[lNbNs]=zStrdup("soap"); 254 258 usedNs[lNbNs]=xmlNewNs(NULL,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap"); 255 259 nbNs++; 256 260 xmlNodePtr nr = xmlNewNode(usedNs[lNbNs], BAD_CAST "Envelope"); 257 nsName[nbNs]= strdup("soap");261 nsName[nbNs]=zStrdup("soap"); 258 262 usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap"); 259 263 nbNs++; 260 nsName[nbNs]= strdup("xsi");264 nsName[nbNs]=zStrdup("xsi"); 261 265 usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi"); 262 266 nbNs++; … … 338 342 } 339 343 else{ 340 nc4 = xmlNewNode(ns_ows, BAD_CAST "Language");341 xmlAddChild(nc4,xmlNewText(BAD_CAST buff));342 344 if(dcount==0){ 343 345 if(vid==0){ 346 nc4 = xmlNewNode(ns_ows, BAD_CAST "Language"); 347 xmlAddChild(nc4,xmlNewText(BAD_CAST buff)); 344 348 xmlAddChild(nc2,nc4); 345 349 xmlAddChild(nc1,nc2); … … 361 365 nc4 = xmlNewNode(ns_ows, BAD_CAST "Language"); 362 366 xmlAddChild(nc4,xmlNewText(BAD_CAST buff)); 363 364 365 366 367 if(vid==0) 368 xmlAddChild(nc3,nc4); 369 else 370 xmlAddChild(nc1,nc4); 367 371 } 368 372 } … … 590 594 map* tmp=getMap(toto1->content,"serverAddress"); 591 595 if(tmp!=NULL){ 592 SERVICE_URL = strdup(tmp->value);596 SERVICE_URL = zStrdup(tmp->value); 593 597 } 594 598 else 595 SERVICE_URL = strdup("not_defined");599 SERVICE_URL = zStrdup("not_defined"); 596 600 } 597 601 else 598 SERVICE_URL = strdup("not_defined");602 SERVICE_URL = zStrdup("not_defined"); 599 603 600 604 for(j=0;j<nbSupportedRequests;j++){ … … 644 648 * @return the generated wps:ProcessOfferings xmlNodePtr 645 649 */ 646 void printGetCapabilitiesForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){650 void printGetCapabilitiesForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 647 651 xmlNsPtr ns,ns_ows,ns_xml,ns_xlink; 648 xmlNodePtr n=NULL,nc1,nc2 ;652 xmlNodePtr n=NULL,nc1,nc2,nc3; 649 653 map* version=getMapFromMaps(m,"main","rversion"); 650 654 int vid=getVersionId(version->value); … … 667 671 limit=7; 668 672 } 673 nc3=NULL; 674 map* sType=getMap(serv->content,"serviceType"); 669 675 for(;i<limit;i+=2){ 670 676 if(capabilities[vid][i]==NULL) … … 682 688 xmlNewNsProp(nc1,ns,BAD_CAST capabilities[vid][i],BAD_CAST tmp1->value); 683 689 } 684 else 685 xmlNewNsProp(nc1,ns,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]); 690 else{ 691 if(i==3 && vid==1 && sType!=NULL && strstr(sType->value,"HPC")!=NULL) 692 xmlNewNsProp(nc1,ns,BAD_CAST capabilities[vid][i],BAD_CAST "async-execute dismiss"); 693 else 694 xmlNewNsProp(nc1,ns,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]); 695 } 686 696 } 687 697 } … … 690 700 printDescription(nc1,ns_ows,serv->name,serv->content,vid); 691 701 tmp1=serv->metadata; 692 while(tmp1!=NULL){ 693 nc2 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 694 xmlNewNsProp(nc2,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 695 xmlAddChild(nc1,nc2); 696 tmp1=tmp1->next; 697 } 698 702 703 addMetadata(tmp1,doc,nc1,ns_ows,ns_xlink,vid); 704 tmp1=serv->additional_parameters; 705 int fromDb=-1; 706 map* test=getMap(serv->content,"fromDb"); 707 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 708 fromDb=1; 709 addAdditionalParameters(tmp1,doc,nc1,ns_ows,ns_xlink,fromDb); 710 711 if(nc3!=NULL) 712 xmlAddChild(nc1,nc3); 699 713 xmlAddChild(nc,nc1); 700 714 } 715 701 716 } 702 717 … … 708 723 * @param content the servive main content created from the zcfg file 709 724 * @param vid the version identifier (0 for 1.0.0 and 1 for 2.0.0) 710 */ 711 void attachAttributes(xmlNodePtr n,xmlNsPtr ns,map* content,int vid){ 725 * @param serviceType string containing the current service type 726 */ 727 void attachAttributes(xmlNodePtr n,xmlNsPtr ns,map* content,int vid,map* serviceType){ 712 728 int limit=7; 713 729 for(int i=1;i<limit;i+=2){ … … 728 744 } 729 745 else{ 730 if( vid==0 && i>=2)731 xmlNew Prop(n,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]);746 if(i==3 && vid==1 && serviceType!=NULL && strstr(serviceType->value,"HPC")!=NULL) 747 xmlNewNsProp(n,ns,BAD_CAST capabilities[vid][i],BAD_CAST "async-execute dismiss"); 732 748 else 733 xmlNewNsProp(n,ns,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]); 734 } 749 if(vid==0 && i>=2) 750 xmlNewProp(n,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]); 751 else 752 xmlNewNsProp(n,ns,BAD_CAST capabilities[vid][i],BAD_CAST capabilities[vid][i+1]); 753 } 754 } 755 } 756 757 /** 758 * Add a Metadata node to any existing node. 759 * @param meta the map defining the additional parameters 760 * @param doc the XML document used 761 * @param nb the node to add the additional parameters 762 * @param ns_ows the OWS namespace 763 * @param ns_xlink the xlink namespace 764 * @param vid the version of WPS to use (0 for 1.0.0 and 1 for 2.0) 765 */ 766 void addMetadata(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int vid){ 767 int hasTitle=-1; 768 int hasValue=-1; 769 xmlNodePtr nc1; 770 map* oMeta=meta; 771 int isAdditionalParameters=-1; 772 int level=0; 773 map* test=getMap(meta,"title"); 774 if(test!=NULL) 775 level+=1; 776 test=getMap(meta,"href"); 777 if(test!=NULL) 778 level+=1; 779 test=getMap(meta,"role"); 780 if(test!=NULL) 781 level+=1; 782 if(count(oMeta)>level+1) 783 isAdditionalParameters=1; 784 char *ctitle=NULL; 785 while(meta!=NULL){ 786 if(hasTitle<0) 787 if(isAdditionalParameters<0) 788 nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 789 else 790 if(hasValue<0) 791 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 792 if(strncasecmp(meta->name,"title",5)==0 || 793 strcasecmp(meta->name,"href")==0 || 794 strcasecmp(meta->name,"role")==0 ){ 795 int index=5; 796 if(strncasecmp(meta->name,"title",5)==0){ 797 index=6; 798 hasTitle=1; 799 if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){ 800 xmlAddChild(nc,nc1); 801 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 802 free(ctitle); 803 ctitle=NULL; 804 } 805 if(ctitle==NULL){ 806 char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char)); 807 snprintf(tmp,index,"%s",meta->name); 808 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value); 809 free(tmp); 810 } 811 if(ctitle!=NULL) 812 free(ctitle); 813 ctitle=zStrdup(meta->value); 814 } 815 }else{ 816 xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 817 xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name"); 818 xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name)); 819 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 820 xmlAddChild(nc4,xmlNewText(BAD_CAST meta->value)); 821 xmlAddChild(nc2,nc3); 822 xmlAddChild(nc2,nc4); 823 xmlAddChild(nc1,nc2); 824 hasTitle=-1; 825 } 826 meta=meta->next; 827 if(hasTitle<0){ 828 hasValue=1; 829 if(isAdditionalParameters){ 830 if(vid==0){ 831 meta=NULL; 832 break; 833 }else 834 xmlAddChild(nc,nc1); 835 } 836 } 837 } 838 if(oMeta!=NULL && hasValue<0 && nc1!=NULL){ 839 xmlAddChild(nc,nc1); 840 } 841 } 842 843 /** 844 * Add AdditionalParameters nodes to any existing node. 845 * @param meta the map defining the additional parameters 846 * @param doc the XML document used 847 * @param nb the node to add the additional parameters 848 * @param ns_ows the OWS namespace 849 * @param ns_xlink the xlink namespace 850 * @param fromDb 1 if the metadata has been extracted from the metadb, 851 * 0 otherwise 852 */ 853 void addAdditionalParameters(map* meta,xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,int fromDb){ 854 int hasTitle=-1; 855 int hasValue=-1; 856 int toAddAtEnd=-1; 857 int cnt=0; 858 xmlNodePtr* ncr=NULL; 859 xmlNodePtr nc1; 860 map* oMeta=meta; 861 int isAdditionalParameters=-1; 862 int level=0; 863 map* test=getMap(meta,"title"); 864 map* otitle=getMap(meta,"title"); 865 map* length=getMap(meta,"length"); 866 int len=0; 867 char *ctitle=NULL; 868 869 if(test!=NULL) 870 level+=1; 871 test=getMap(meta,"href"); 872 if(test!=NULL) 873 level+=1; 874 test=getMap(meta,"role"); 875 if(test!=NULL) 876 level+=1; 877 if(count(oMeta)>level+1) 878 isAdditionalParameters=1; 879 880 while(meta!=NULL){ 881 if(hasTitle<0 && hasValue<0){ 882 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 883 } 884 if(strncasecmp(meta->name,"title",5)==0 || 885 strcasecmp(meta->name,"href")==0 || 886 strcasecmp(meta->name,"role")==0 ){ 887 int index=5; 888 if(strncasecmp(meta->name,"title",5)==0){ 889 index=6; 890 hasTitle=1; 891 if(ctitle!=NULL && strcasecmp(meta->value,ctitle)!=0){ 892 xmlNodePtr ncTmp = xmlDocCopyNodeList(doc,nc1); 893 xmlAddChild(nc,ncTmp); 894 xmlFreeNode(nc1); 895 toAddAtEnd=1; 896 cnt++; 897 nc1 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameters"); 898 free(ctitle); 899 ctitle=NULL; 900 } 901 if(ctitle==NULL){ 902 char *tmp=(char*)malloc((strlen(meta->name)+1)*sizeof(char)); 903 snprintf(tmp,index,"%s",meta->name); 904 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp,BAD_CAST meta->value); 905 free(tmp); 906 } 907 if(ctitle!=NULL) 908 free(ctitle); 909 ctitle=zStrdup(meta->value); 910 }else{ 911 xmlNewNsProp(nc1,ns_xlink,BAD_CAST meta->name,BAD_CAST meta->value); 912 } 913 }else{ 914 if(strncasecmp(meta->name,"length",6)!=0 && strncasecmp(meta->name,"fromDb",6)!=0){ 915 xmlNodePtr nc2 = xmlNewNode(ns_ows, BAD_CAST "AdditionalParameter"); 916 xmlNodePtr nc3 = xmlNewNode(ns_ows, BAD_CAST "Name"); 917 xmlAddChild(nc3,xmlNewText(BAD_CAST meta->name)); 918 xmlAddChild(nc2,nc3); 919 if(fromDb<0){ 920 char *mptr; 921 char* meta_values=strtok_r(meta->value,",",&mptr); 922 while(meta_values!=NULL){ 923 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 924 xmlAddChild(nc4,xmlNewText(BAD_CAST meta_values)); 925 xmlAddChild(nc2,nc4); 926 meta_values=strtok_r(NULL,",",&mptr); 927 } 928 }else{ 929 xmlNodePtr nc4 = xmlNewNode(ns_ows, BAD_CAST "Value"); 930 xmlAddChild(nc4,xmlNewCDataBlock(doc,BAD_CAST meta->value,strlen(meta->value))); 931 xmlAddChild(nc2,nc4); 932 } 933 xmlAddChild(nc1,nc2); 934 } 935 hasTitle=-1; 936 } 937 meta=meta->next; 938 if(hasTitle<0){ 939 //xmlAddChild(nc,nc1); 940 hasValue=1; 941 }/*else 942 if(ctitle!=NULL) 943 free(ctitle);*/ 944 } 945 if(length!=NULL) 946 len=atoi(length->value); 947 if(otitle!=NULL) 948 len=1; 949 if(cnt<len){ 950 xmlAddChild(nc,nc1); 951 free(ctitle); 735 952 } 736 953 } … … 792 1009 * @return the generated wps:ProcessOfferings xmlNodePtr 793 1010 */ 794 void printDescribeProcessForProcess(registry *reg, maps* m,xml NodePtr nc,service* serv){1011 void printDescribeProcessForProcess(registry *reg, maps* m,xmlDocPtr doc,xmlNodePtr nc,service* serv){ 795 1012 xmlNsPtr ns,ns_ows,ns_xlink; 796 1013 xmlNodePtr n,nc1; … … 798 1015 map* version=getMapFromMaps(m,"main","rversion"); 799 1016 int vid=getVersionId(version->value); 1017 int fromDb=-1; 1018 map* serviceType=getMap(serv->content,"serviceType"); 1019 map* test=getMap(serv->content,"fromDb"); 1020 if(test!=NULL && strncasecmp(test->value,"true",4)==0) 1021 fromDb=1; 800 1022 801 1023 n=nc; … … 811 1033 if(vid==0){ 812 1034 nc = xmlNewNode(NULL, BAD_CAST "ProcessDescription"); 813 attachAttributes(nc,ns,serv->content,vid );1035 attachAttributes(nc,ns,serv->content,vid,NULL); 814 1036 } 815 1037 else{ … … 828 1050 } 829 1051 } 830 attachAttributes(nc2,NULL,serv->content,vid );1052 attachAttributes(nc2,NULL,serv->content,vid,serviceType); 831 1053 map* level=getMap(serv->content,"level"); 832 1054 if(level!=NULL && strcasecmp(level->value,"generic")==0) … … 843 1065 tmp1=serv->metadata; 844 1066 while(tmp1!=NULL){ 845 nc1 = xmlNewNode(ns_ows, BAD_CAST "Metadata"); 846 xmlNewNsProp(nc1,ns_xlink,BAD_CAST tmp1->name,BAD_CAST tmp1->value); 847 xmlAddChild(nc,nc1); 1067 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink,vid); 848 1068 tmp1=tmp1->next; 849 1069 } … … 855 1075 } 856 1076 }else{ 1077 tmp1=serv->metadata; 1078 addMetadata(tmp1,doc,nc,ns_ows,ns_xlink,vid); 857 1079 addInheritedMetadata(nc,ns_ows,ns_xlink,reg,m,serv); 1080 tmp1=serv->additional_parameters; 1081 if(vid!=0) 1082 addAdditionalParameters(tmp1,doc,nc,ns_ows,ns_xlink,fromDb); 858 1083 } 859 1084 … … 862 1087 if(vid==0){ 863 1088 nc1 = xmlNewNode(NULL, BAD_CAST "DataInputs"); 864 printFullDescription( 1,e,"Input",ns,ns_ows,nc1,vid);1089 printFullDescription(doc,1,e,"Input",ns,ns_ows,nc1,vid,fromDb,NULL); 865 1090 xmlAddChild(nc,nc1); 866 1091 } 867 1092 else{ 868 printFullDescription( 1,e,"wps:Input",ns,ns_ows,nc,vid);1093 printFullDescription(doc,1,e,"wps:Input",ns,ns_ows,nc,vid,fromDb,NULL); 869 1094 } 870 1095 } … … 873 1098 if(vid==0){ 874 1099 nc1 = xmlNewNode(NULL, BAD_CAST "ProcessOutputs"); 875 printFullDescription( 0,e,"Output",ns,ns_ows,nc1,vid);1100 printFullDescription(doc,0,e,"Output",ns,ns_ows,nc1,vid,fromDb,NULL); 876 1101 xmlAddChild(nc,nc1); 877 1102 } 878 1103 else{ 879 printFullDescription( 0,e,"wps:Output",ns,ns_ows,nc,vid);1104 printFullDescription(doc,0,e,"wps:Output",ns,ns_ows,nc,vid,fromDb,serviceType); 880 1105 } 881 1106 if(vid==0) … … 899 1124 * @param nc1 the XML node to use to add the created tree 900 1125 * @param vid the WPS version id (0 for 1.0.0, 1 for 2.0.0) 901 */ 902 void printFullDescription(int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid){ 1126 * @param fromDb 1 in case the metadata comes from the DB, -1 in other cases 1127 * @param serviceType the serviceType found in the ZCFG file or the DB 1128 */ 1129 void printFullDescription(xmlDocPtr doc,int in,elements *elem,const char* type,xmlNsPtr ns,xmlNsPtr ns_ows,xmlNodePtr nc1,int vid,int fromDb,const map* serviceType){ 903 1130 xmlNsPtr ns1=NULL; 904 1131 if(vid==1) … … 913 1140 int isAnyValue=1; 914 1141 nc2 = xmlNewNode(NULL, BAD_CAST type); 1142 // Extract min/max Occurence information 915 1143 if(strstr(type,"Input")!=NULL){ 916 1144 tmp1=getMap(e->content,"minOccurs"); … … 935 1163 936 1164 if(e->format!=NULL){ 1165 #ifdef USE_HPC 1166 DEFAULT_OUT: 1167 #endif 937 1168 const char orderedFields[13][14]={ 938 1169 "mimeType", … … 952 1183 //Build the (Literal/Complex/BoundingBox)Data node 953 1184 if(strncmp(type,"Output",6)==0){ 954 if(strncasecmp(e->format,"LITERAL DATA",strlen(e->format))==0)1185 if(strncasecmp(e->format,"LITERAL",7)==0) 955 1186 nc3 = xmlNewNode(ns1, BAD_CAST "LiteralOutput"); 956 1187 else if(strncasecmp(e->format,"COMPLEXDATA",strlen(e->format))==0) … … 998 1229 strcmp(e->format,"BoundingBoxData")==0){ 999 1230 datatype=2; 1000 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 1231 if(vid==0) 1232 nc5 = xmlNewNode(NULL, BAD_CAST "Default"); 1233 else{ 1234 xmlNodePtr nc6 = xmlNewNode(ns1, BAD_CAST "Format"); 1235 xmlNewProp(nc6,BAD_CAST "mimeType",BAD_CAST "text/xml"); 1236 xmlNewProp(nc6,BAD_CAST "default",BAD_CAST "true"); 1237 xmlAddChild(nc3,nc6); 1238 nc5 = xmlNewNode(NULL, BAD_CAST "SupportedCRS"); 1239 } 1001 1240 } 1002 1241 else{ … … 1039 1278 while(token!=NULL){ 1040 1279 nc7 = xmlNewNode(ns_ows, BAD_CAST "Value"); 1041 char *tmps= strdup(token);1280 char *tmps=zStrdup(token); 1042 1281 tmps[strlen(tmps)]=0; 1043 xmlAddChild(nc7,xmlNewText(BAD_CAST tmps)); 1282 nc8 = xmlNewText(BAD_CAST tmps); 1283 xmlAddChild(nc7,nc8); 1044 1284 free(tmps); 1045 1285 xmlAddChild(nc6,nc7); … … 1207 1447 strncasecmp(tmp1->name,"range",5)!=0){ 1208 1448 if(datatype!=1){ 1209 char *tmp2=zCapitalize1(tmp1->name); 1210 nc9 = xmlNewNode(NULL, BAD_CAST tmp2); 1211 free(tmp2); 1449 if(datatype==2 && vid==1){ 1450 nc9 = xmlNewNode(ns, BAD_CAST "SupportedCRS"); 1451 xmlNewProp(nc9,BAD_CAST "default",BAD_CAST "true"); 1452 } 1453 else{ 1454 char *tmp2=zCapitalize1(tmp1->name); 1455 nc9 = xmlNewNode(NULL, BAD_CAST tmp2); 1456 free(tmp2); 1457 } 1212 1458 } 1213 1459 else{ … … 1218 1464 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value)); 1219 1465 if(vid==0 || oI>=3){ 1220 if(vid==0 || oI!=4) 1221 xmlAddChild(nc5,nc9); 1466 if(vid==0 || oI!=4){ 1467 if(datatype==2 && vid==1) 1468 xmlAddChild(nc3,nc9); 1469 else 1470 xmlAddChild(nc5,nc9); 1471 } 1222 1472 if(oI==4 && vid==1){ 1223 1473 xmlNewProp(nc9,BAD_CAST "default",BAD_CAST "true"); 1224 1474 } 1225 1475 } 1226 else 1227 xmlFree(nc9); 1476 else{ 1477 xmlFreeNode(nc9); 1478 } 1228 1479 if(strcasecmp(tmp1->name,"uom")==0) 1229 1480 hasUOM1=true; 1230 1481 hasUOM=true; 1231 }else 1232 tmp1=tmp1->next; 1482 } 1233 1483 } 1234 1484 } … … 1245 1495 }else{ 1246 1496 if(hasUOM1==false && vid==0){ 1247 xmlFreeNode(nc5); 1248 if(datatype==1) 1497 if(nc5!=NULL) 1498 xmlFreeNode(nc5); 1499 if(datatype==1){ 1249 1500 xmlFreeNode(nc4); 1501 } 1250 1502 } 1251 else 1503 else{ 1252 1504 xmlAddChild(nc3,nc5); 1505 } 1253 1506 } 1254 1507 }else{ 1255 xmlAddChild(nc3,nc5); 1508 if(vid==0) 1509 xmlAddChild(nc3,nc5); 1510 else 1511 xmlFreeNode(nc5); 1256 1512 } 1257 1513 1258 if(datatype !=1&& default1<0){1514 if(datatype==0 && default1<0){ 1259 1515 xmlFreeNode(nc5); 1260 if(datatype!=2) 1516 if(datatype!=2){ 1261 1517 xmlFreeNode(nc4); 1518 } 1262 1519 } 1263 1520 … … 1310 1567 nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2); 1311 1568 free(tmp2); 1312 //xmlNewProp(nc9, BAD_CAST "default", BAD_CAST "true");1313 1569 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value)); 1314 1570 xmlAddChild(nc5,nc9); 1315 /*struct iotype * _ltmp=e->supported;1316 while(_ltmp!=NULL){1317 tmp1=getMap(_ltmp->content,"uom");1318 if(tmp1!=NULL){1319 char *tmp2=zCapitalize(tmp1->name);1320 nc9 = xmlNewNode(ns_ows, BAD_CAST tmp2);1321 free(tmp2);1322 xmlAddChild(nc9,xmlNewText(BAD_CAST tmp1->value));1323 xmlAddChild(nc5,nc9);1324 }1325 _ltmp=_ltmp->next;1326 }*/1327 1328 1571 } 1329 1572 } … … 1340 1583 xmlNsPtr ns_xlink=usedNs[xlinkId]; 1341 1584 1342 while(metadata!=NULL){ 1343 nc6=xmlNewNode(ns_ows, BAD_CAST "Metadata"); 1344 xmlNewNsProp(nc6,ns_xlink,BAD_CAST metadata->name,BAD_CAST metadata->value); 1345 xmlAddChild(nc2,nc6); 1346 metadata=metadata->next; 1347 } 1585 addMetadata(metadata,doc,nc2,ns_ows,ns_xlink,vid); 1586 if(vid!=0) 1587 addAdditionalParameters(e->additional_parameters,doc,nc2,ns_ows,ns_xlink,fromDb); 1348 1588 1349 1589 } 1350 1590 1351 1591 _tmp=e->supported; 1352 if(_tmp==NULL && datatype !=1)1592 if(_tmp==NULL && datatype==0) 1353 1593 _tmp=e->defaults; 1354 1594 … … 1396 1636 strcasecmp(tmp1->name,"extension")!=0){ 1397 1637 if(datatype!=1){ 1398 char *tmp2=zCapitalize1(tmp1->name); 1399 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 1400 free(tmp2); 1638 if(datatype==2 && vid==1){ 1639 nc6 = xmlNewNode(ns, BAD_CAST "SupportedCRS"); 1640 } 1641 else{ 1642 char *tmp2=zCapitalize1(tmp1->name); 1643 nc6 = xmlNewNode(NULL, BAD_CAST tmp2); 1644 free(tmp2); 1645 } 1401 1646 } 1402 1647 else{ … … 1422 1667 } 1423 1668 if(vid==0 || oI>=3){ 1424 if(vid==0 || oI!=4) 1425 xmlAddChild(nc5,nc6); 1426 else 1427 xmlFree(nc6); 1669 if(vid==0 || oI!=4){ 1670 if(datatype==2 && vid==1) 1671 xmlAddChild(nc3,nc6); 1672 else 1673 xmlAddChild(nc5,nc6); 1674 } 1675 else{ 1676 xmlFreeNode(nc6); 1677 } 1428 1678 } 1429 else 1430 xmlFree(nc6); 1679 else{ 1680 xmlFreeNode(nc6); 1681 } 1431 1682 } 1432 1683 tmp1=tmp1->next; … … 1439 1690 } 1440 1691 else{ 1441 xmlAddChild(nc3,nc5); 1692 if(datatype!=2) 1693 xmlAddChild(nc3,nc5); 1442 1694 } 1443 1695 1444 1696 }else{ 1445 if(datatype !=1)1697 if(datatype==2 && vid==0) 1446 1698 xmlAddChild(nc3,nc5); 1447 1699 } … … 1459 1711 } 1460 1712 else 1461 if(datatype!=1) 1713 if(datatype==0){ 1714 xmlFreeNode(nc4); 1462 1715 xmlAddChild(nc3,nc5); 1716 } 1463 1717 1464 1718 _tmp=_tmp->next; … … 1466 1720 1467 1721 if(hasSupported==0){ 1468 if(datatype==0 && vid!=0) 1722 if(datatype==0 && vid!=0){ 1469 1723 xmlFreeNode(nc4); 1724 } 1470 1725 xmlFreeNode(nc5); 1471 1726 } … … 1478 1733 } 1479 1734 else{ 1735 xmlFreeNode(nc4); 1480 1736 xmlAddChild(nc3,nc5); 1481 1737 } … … 1491 1747 }else{ 1492 1748 if(e->child!=NULL && vid!=0){ 1493 printFullDescription(in,e->child,type,ns,ns_ows,nc2,vid); 1494 } 1495 } 1496 1749 printFullDescription(doc,in,e->child,type,ns,ns_ows,nc2,vid,fromDb,NULL); 1750 } 1751 } 1497 1752 if(e->child!=NULL && vid==0){ 1498 1753 elements* children=dupElements(e->child); 1499 1754 elements* cursor=children; 1500 1755 while(cursor!=NULL){ 1501 char* tmp=strdup(cursor->name); 1502 free(cursor->name); 1503 cursor->name=(char*)malloc((strlen(cursor->name)+strlen(e->name)+2)*sizeof(char)); 1504 sprintf(cursor->name,"%s.%s",e->name,tmp); 1756 elements* ccursor=cursor; 1757 char* tmp=zStrdup(ccursor->name); 1758 free(ccursor->name); 1759 ccursor->name=(char*)malloc((strlen(tmp)+strlen(e->name)+2)*sizeof(char)); 1760 sprintf(ccursor->name,"%s.%s",e->name,tmp); 1505 1761 cursor=cursor->next; 1506 1762 } 1507 printFullDescription(in,children,type,ns,ns_ows,nc2,vid); 1508 xmlAddChild(nc1,nc2); 1763 printFullDescription(doc,in,children,type,ns,ns_ows,nc1,vid,fromDb,serviceType); 1509 1764 freeElements(&children); 1510 1765 free(children); 1511 }else 1512 xmlAddChild(nc1,nc2); 1513 1766 }else{ 1767 if(nc2!=NULL){ 1768 xmlAddChild(nc1,nc2); 1769 } 1770 } 1514 1771 e=e->next; 1515 1772 } … … 1528 1785 * @param outputs the outputs generated by the service 1529 1786 */ 1530 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){ 1787 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){ 1531 1788 xmlNsPtr ns,ns_ows,ns_xlink; 1532 1789 xmlNodePtr nr,n,nc,nc1=NULL,nc3; … … 1549 1806 char stored_path[1024]; 1550 1807 memset(stored_path,0,1024); 1551 1808 1552 1809 if(vid==0){ 1553 1810 char tmp[256]; … … 1734 1991 } 1735 1992 } 1736 1993 1737 1994 /** 1738 1995 * Display the process output only when requested ! … … 1744 2001 maps* mcursor=outputs; 1745 2002 elements* scursor=serv->outputs; 1746 map* testResponse=getMap(request,"RawDataOutput"); 2003 map* testResponse=getMap(request,"RawDataOutput"); 1747 2004 if(testResponse==NULL) 1748 2005 testResponse=getMap(request,"ResponseDocument"); 1749 while(mcursor!=NULL){ 2006 while(mcursor!=NULL){ 1750 2007 map* tmp0=getMap(mcursor->content,"inRequest"); 1751 scursor=getElements(serv->outputs,mcursor->name); 1752 if(scursor!=NULL){ 1753 if(testResponse==NULL || tmp0==NULL){ 2008 scursor=getElements(serv->outputs,mcursor->name); 2009 if(scursor!=NULL){ 2010 if(testResponse==NULL || tmp0==NULL){ 1754 2011 if(vid==0) 1755 2012 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); … … 1758 2015 } 1759 2016 else 1760 1761 if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){ 2017 if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){ 1762 2018 if(vid==0) 1763 2019 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1764 2020 else 1765 2021 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1766 } 2022 } 1767 2023 }else 1768 2024 /** … … 1775 2031 printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid); 1776 2032 mcursor=mcursor->next; 1777 } 2033 } 1778 2034 if(vid==0) 1779 2035 xmlAddChild(n,nc); 1780 } 1781 2036 } 1782 2037 if(vid==0 && 1783 2038 hasStoredExecuteResponse==true … … 1834 2089 #endif 1835 2090 } 2091 1836 2092 printDocument(m,doc,pid); 1837 2093 … … 1891 2147 else{ 1892 2148 /* 1893 dumpElements(e);2149 dumpElements(e); 1894 2150 */ 1895 2151 return; … … 1900 2156 || strncasecmp(tmp->name,"SCHEMA",strlen(tmp->name))==0 1901 2157 || strncasecmp(tmp->name,"UOM",strlen(tmp->name))==0) 1902 xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value);2158 xmlNewProp(nc1,BAD_CAST tmp->name,BAD_CAST tmp->value); 1903 2159 tmp=tmp->next; 1904 2160 } … … 1927 2183 * @param type the type 1928 2184 */ 1929 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type,int vid){ 1930 2185 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type,int vid){ 1931 2186 xmlNodePtr nc1,nc2,nc3; 1932 2187 nc1=xmlNewNode(ns_wps, BAD_CAST type); … … 1935 2190 tmp=e->content; 1936 2191 else 1937 tmp=m->content; 1938 2192 tmp=m->content; 1939 2193 if(vid==0){ 1940 2194 nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier"); … … 1976 2230 xmlNewProp(nc1,BAD_CAST "id",BAD_CAST (e!=NULL?e->name:m->name)); 1977 2231 } 1978 2232 1979 2233 // IO type nested outputs 1980 if(m->child!=NULL){ 2234 if(m->child!=NULL){ 1981 2235 maps* curs=m->child; 1982 2236 elements* ecurs=getElements(e,(e!=NULL?e->name:m->name)); 1983 2237 ecurs=ecurs->child; 1984 while(curs!=NULL ){2238 while(curs!=NULL/* && ecurs!=NULL*/){ 1985 2239 ecurs=getElements(ecurs,(curs->name)); 1986 2240 map* inRequest=getMap(curs->content,"inRequest"); … … 1992 2246 } 1993 2247 } 1994 else{ 2248 else{ 1995 2249 map *tmpMap=getMap(m->content,"Reference"); 1996 if(tmpMap==NULL){ 2250 if(tmpMap==NULL){ 1997 2251 nc2=xmlNewNode(ns_wps, BAD_CAST "Data"); 1998 if(e!=NULL && e->format!=NULL){ 1999 if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0)2000 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData");2252 if(e!=NULL && e->format!=NULL){ 2253 if (strncasecmp(e->format, "LiteralOutput", strlen(e->format)) == 0) 2254 nc3 = xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2001 2255 else 2002 2256 if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0) … … 2005 2259 nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData"); 2006 2260 else 2007 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 2008 } 2009 else { 2010 map* tmpV=getMapFromMaps(m,"format","value"); 2261 nc3=xmlNewNode(ns_wps, BAD_CAST e->format); 2262 } 2263 else { 2264 map* tmpV=getMapFromMaps(m,"format","value"); 2011 2265 if(tmpV!=NULL) 2012 2266 nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value); … … 2014 2268 nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData"); 2015 2269 } 2016 tmp=m->content; 2017 2270 tmp=m->content; 2271 2018 2272 while(tmp!=NULL){ 2019 2273 if(strcasecmp(tmp->name,"mimeType")==0 || … … 2021 2275 strcasecmp(tmp->name,"schema")==0 || 2022 2276 strcasecmp(tmp->name,"datatype")==0 || 2023 strcasecmp(tmp->name,"uom")==0) { 2024 2277 strcasecmp(tmp->name,"uom")==0) { 2025 2278 if(vid==0) 2026 2279 xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value); … … 2033 2286 } 2034 2287 } 2288 2035 2289 if(vid==0) 2036 2290 xmlAddChild(nc2,nc3); 2037 tmp=tmp->next; 2291 tmp=tmp->next; 2038 2292 } 2039 2293 if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) { … … 2046 2300 } 2047 2301 } 2048 else { 2049 if(e!=NULL) 2050 tmp=getMap(e->defaults->content,"mimeType"); 2302 else { 2303 //if (e != NULL) { 2304 if (e != NULL && e->defaults != NULL) { // knut: add extra NULL pointer check in case user omits <Default> block in config file 2305 tmp = getMap(e->defaults->content, "mimeType"); 2306 } 2051 2307 else 2052 tmp=NULL; 2053 2308 tmp=NULL; 2054 2309 map* tmp1=getMap(m->content,"encoding"); 2055 2310 map* tmp2=getMap(m->content,"mimeType"); … … 2106 2361 strstr(tmp2->value, "json") != NULL || // (will not be parsed by XML reader) 2107 2362 strstr(tmp2->value, "ecmascript") != NULL 2108 ) {2363 ) { 2109 2364 xmlAddChild((vid==0?nc3:nc2),xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value))); 2110 2365 } … … 2112 2367 if (strstr(tmp2->value, "xml") != NULL || // if XML-based format 2113 2368 // include for backwards compatibility, 2114 2369 // although correct mime type is ...kml+xml: 2115 2370 strstr(tmp2->value, "google-earth.kml") != NULL 2116 2371 ) { … … 2241 2496 else 2242 2497 exceptionCode="501 Internal Server Error"; 2243 2498 tmp=getMapFromMaps(m,"lenv","status_code"); 2499 if(tmp!=NULL) 2500 exceptionCode=tmp->value; 2244 2501 if(m!=NULL){ 2245 2502 map *tmpSid=getMapFromMaps(m,"lenv","sid"); … … 2332 2589 2333 2590 tmp=getMapArray(s,"text",cnt); 2591 if(tmp==NULL) 2592 tmp=getMapArray(s,"message",cnt); 2334 2593 nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText"); 2335 2594 if(tmp!=NULL){ 2336 2595 xmlNodePtr txt=xmlNewText(BAD_CAST tmp->value); 2337 2596 xmlAddChild(nc1,txt); 2597 if(cnt==0) 2598 setMapInMaps(m,"lenv","message",tmp->value); 2338 2599 } 2339 2600 else{ … … 2381 2642 void outputResponse(service* s,maps* request_inputs,maps* request_outputs, 2382 2643 map* request_inputs1,int cpid,maps* m,int res){ 2383 2384 2644 #ifdef DEBUG 2385 2645 dumpMaps(request_inputs); 2386 2646 dumpMaps(request_outputs); 2387 2647 fprintf(stderr,"printProcessResponse\n"); 2388 #endif 2648 #endif 2389 2649 map* toto=getMap(request_inputs1,"RawDataOutput"); 2390 2650 int asRaw=0; … … 2396 2656 if(tmpSess!=NULL){ 2397 2657 map *_tmp=getMapFromMaps(m,"lenv","cookie"); 2658 maps *tmps=getMaps(m,"senv"); 2398 2659 char* sessId=NULL; 2399 2660 if(_tmp!=NULL){ 2400 2661 printf("Set-Cookie: %s; HttpOnly\r\n",_tmp->value); 2662 map *_tmp1=getMapFromMaps(m,"senv","ecookie_length"); 2663 if(_tmp1!=NULL){ 2664 int len=atoi(_tmp1->value); 2665 int cnt=0; 2666 for(cnt=0;cnt<len;cnt++){ 2667 map* _tmp2=getMapArray(tmps->content,"ecookie",cnt); 2668 if(_tmp2!=NULL) 2669 printf("Set-Cookie: %s; HttpOnly\r\n",_tmp2->value); 2670 } 2671 } 2401 2672 printf("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"\r\n"); 2402 2673 char session_file_path[100]; … … 2406 2677 else 2407 2678 sprintf(session_file_path,"%s",strstr(_tmp->value,"=")+1); 2408 sessId= strdup(session_file_path);2679 sessId=zStrdup(session_file_path); 2409 2680 }else{ 2410 2681 maps* t=getMaps(m,"senv"); … … 2412 2683 while(p!=NULL){ 2413 2684 if(strstr(p->name,"ID")!=NULL){ 2414 sessId= strdup(p->value);2685 sessId=zStrdup(p->value); 2415 2686 break; 2416 2687 } … … 2435 2706 } 2436 2707 } 2437 2438 2708 if(res==SERVICE_FAILED){ 2439 2709 map *lenv; … … 2462 2732 return; 2463 2733 } 2464 2734 2735 if(res!=SERVICE_SUCCEEDED){ 2736 printProcessResponse(m,request_inputs1,cpid, 2737 s, s->name,res, // replace serviceProvider with serviceName in stored response file name 2738 request_inputs, 2739 request_outputs); 2740 return; 2741 } 2742 2465 2743 map *tmp1=getMapFromMaps(m,"main","tmpPath"); 2466 2744 if(asRaw==0){ … … 2473 2751 map* usid=getMapFromMaps(m,"lenv","usid"); 2474 2752 int itn=0; 2753 int error=-1; 2475 2754 NESTED0: 2476 2755 while(tmpI!=NULL){ … … 2483 2762 #endif 2484 2763 map *gfile=getMap(tmpI->content,"generated_file"); 2485 char *file_name ;2764 char *file_name=NULL; 2486 2765 if(gfile!=NULL){ 2487 2766 gfile=getMap(tmpI->content,"expected_generated_file"); … … 2491 2770 readGeneratedFile(m,tmpI->content,gfile->value); 2492 2771 file_name=zStrdup((gfile->value)+strlen(tmp1->value)); 2493 } 2494 2772 } 2495 2773 toto=getMap(tmpI->content,"asReference"); 2496 2774 #ifdef USE_MS 2497 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && testMap==NULL) 2775 map* geodatatype=getMap(tmpI->content,"geodatatype"); 2776 if(toto!=NULL && strcasecmp(toto->value,"true")==0 && 2777 (testMap==NULL || 2778 strncasecmp(testMap->value,"true",4)!=0 || 2779 (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0) ) ) 2498 2780 #else 2499 2781 if(toto!=NULL && strcasecmp(toto->value,"true")==0) 2500 2782 #endif 2501 { 2502 elements* in=getElements(s->outputs,tmpI->name); 2503 if(in==NULL && s->outputs->child!=NULL){ 2504 in=getElements(s->outputs->child,tmpI->name); 2783 { 2784 elements* in=getElements(s->outputs,tmpI->name); 2785 if(in==NULL && s->outputs->child!=NULL){ 2786 in=getElements(s->outputs->child,tmpI->name); 2787 } 2788 char *format=NULL; 2789 if(in!=NULL && in->format!=NULL){ 2790 format=in->format; 2791 }else 2792 format=(char*)"LiteralData"; 2793 if(format!=NULL && strcasecmp(format,"BoundingBoxData")==0){ 2794 addToMap(tmpI->content,"extension","xml"); 2795 addToMap(tmpI->content,"mimeType","text/xml"); 2796 addToMap(tmpI->content,"encoding","UTF-8"); 2797 addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 2798 } 2799 char *file_path=NULL; 2800 if(gfile==NULL) { 2801 map *ext=getMap(tmpI->content,"extension"); 2802 char file_ext[32]; 2803 2804 if( ext != NULL && ext->value != NULL) { 2805 strncpy(file_ext, ext->value, 32); 2806 } 2807 else { 2808 // Obtain default file extension (see mimetypes.h). 2809 // If the MIME type is not recognized, txt is used as the default extension 2810 map* mtype=getMap(tmpI->content,"mimeType"); 2811 getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32); 2812 } 2813 if(file_name!=NULL) 2814 free(file_name); 2815 file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char)); 2816 sprintf(file_name,"ZOO_DATA_%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext); 2817 itn++; 2818 file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char)); 2819 sprintf(file_path,"%s/%s",tmp1->value,file_name); 2820 2821 FILE *ofile=fopen(file_path,"wb"); 2822 if(ofile==NULL){ 2823 char tmpMsg[1024]; 2824 sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the %s final result."),file_name,tmpI->name); 2825 errorException(m,tmpMsg,"InternalError",NULL); 2826 free(file_name); 2827 free(file_path); 2828 return; 2829 } 2830 2831 toto=getMap(tmpI->content,"value"); 2832 if(toto==NULL){ 2833 char tmpMsg[1024]; 2834 sprintf(tmpMsg,_("No value found for the requested output %s."),tmpI->name); 2835 errorException(m,tmpMsg,"InternalError",NULL); 2836 fclose(ofile); 2837 free(file_name); 2838 free(file_path); 2839 return; 2840 } 2841 if(strcasecmp(format,"BoundingBoxData")!=0){ 2842 map* size=getMap(tmpI->content,"size"); 2843 if(size!=NULL && toto!=NULL) 2844 fwrite(toto->value,1,(atoi(size->value))*sizeof(char),ofile); 2845 else 2846 if(toto!=NULL && toto->value!=NULL) 2847 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 2848 }else{ 2849 printBoundingBoxDocument(m,tmpI,ofile); 2850 } 2851 fclose(ofile); 2852 } 2853 2854 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 2855 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2856 char *file_url=NULL; 2857 if(strncasecmp(tmp2->value,"http://",7)==0 || 2858 strncasecmp(tmp2->value,"https://",8)==0){ 2859 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char)); 2860 sprintf(file_url,"%s/%s",tmp2->value,file_name); 2861 }else{ 2862 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char)); 2863 sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name); 2864 } 2865 addToMap(tmpI->content,"Reference",file_url); 2866 if(file_name!=NULL) 2867 free(file_name); 2868 if(file_url!=NULL) 2869 free(file_url); 2870 file_name=NULL; 2505 2871 } 2506 char *format=NULL; 2507 if(in!=NULL && in->format!=NULL){ 2508 format=in->format; 2509 }else 2510 format=(char*)"LiteralData"; 2511 if(format!=NULL && strcasecmp(format,"BoundingBoxData")==0){ 2512 addToMap(tmpI->content,"extension","xml"); 2513 addToMap(tmpI->content,"mimeType","text/xml"); 2514 addToMap(tmpI->content,"encoding","UTF-8"); 2515 addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd"); 2872 #ifdef USE_MS 2873 else{ 2874 if(testMap!=NULL){ 2875 map* nbFeatures; 2876 setMapInMaps(m,"lenv","state","out"); 2877 setReferenceUrl(m,tmpI); 2878 nbFeatures=getMap(tmpI->content,"nb_features"); 2879 geodatatype=getMap(tmpI->content,"geodatatype"); 2880 if((nbFeatures!=NULL && atoi(nbFeatures->value)==0) || 2881 (geodatatype!=NULL && strcasecmp(geodatatype->value,"other")==0)){ 2882 error=1; 2883 res=SERVICE_FAILED; 2884 } 2516 2885 } 2517 2518 if(gfile==NULL) { 2519 map *ext=getMap(tmpI->content,"extension"); 2520 char *file_path; 2521 char file_ext[32]; 2522 2523 if( ext != NULL && ext->value != NULL) { 2524 strncpy(file_ext, ext->value, 32); 2525 } 2526 else { 2527 // Obtain default file extension (see mimetypes.h). 2528 // If the MIME type is not recognized, txt is used as the default extension 2529 map* mtype=getMap(tmpI->content,"mimeType"); 2530 getFileExtension(mtype != NULL ? mtype->value : NULL, file_ext, 32); 2531 } 2532 2533 file_name=(char*)malloc((strlen(s->name)+strlen(usid->value)+strlen(file_ext)+strlen(tmpI->name)+45)*sizeof(char)); 2534 sprintf(file_name,"%s_%s_%s_%d.%s",s->name,tmpI->name,usid->value,itn,file_ext); 2535 itn++; 2536 file_path=(char*)malloc((strlen(tmp1->value)+strlen(file_name)+2)*sizeof(char)); 2537 sprintf(file_path,"%s/%s",tmp1->value,file_name); 2538 2539 FILE *ofile=fopen(file_path,"wb"); 2540 if(ofile==NULL){ 2541 char tmpMsg[1024]; 2542 sprintf(tmpMsg,_("Unable to create the file \"%s\" for storing the %s final result."),file_name,tmpI->name); 2543 errorException(m,tmpMsg,"InternalError",NULL); 2544 free(file_name); 2545 free(file_path); 2546 return; 2547 } 2548 free(file_path); 2549 2550 toto=getMap(tmpI->content,"value"); 2551 if(strcasecmp(format,"BoundingBoxData")!=0){ 2552 map* size=getMap(tmpI->content,"size"); 2553 if(size!=NULL && toto!=NULL) 2554 fwrite(toto->value,1,(atoi(size->value))*sizeof(char),ofile); 2555 else 2556 if(toto!=NULL && toto->value!=NULL) 2557 fwrite(toto->value,1,strlen(toto->value)*sizeof(char),ofile); 2558 }else{ 2559 printBoundingBoxDocument(m,tmpI,ofile); 2560 } 2561 fclose(ofile); 2562 2563 } 2564 2565 map *tmp2=getMapFromMaps(m,"main","tmpUrl"); 2566 map *tmp3=getMapFromMaps(m,"main","serverAddress"); 2567 char *file_url; 2568 if(strncasecmp(tmp2->value,"http://",7)==0 || 2569 strncasecmp(tmp2->value,"https://",8)==0){ 2570 file_url=(char*)malloc((strlen(tmp2->value)+strlen(file_name)+2)*sizeof(char)); 2571 sprintf(file_url,"%s/%s",tmp2->value,file_name); 2572 }else{ 2573 file_url=(char*)malloc((strlen(tmp3->value)+strlen(tmp2->value)+strlen(file_name)+3)*sizeof(char)); 2574 sprintf(file_url,"%s/%s/%s",tmp3->value,tmp2->value,file_name); 2575 } 2576 addToMap(tmpI->content,"Reference",file_url); 2577 free(file_name); 2578 free(file_url); 2579 2580 } 2581 #ifdef USE_MS 2582 else{ 2583 if(testMap!=NULL){ 2584 setReferenceUrl(m,tmpI); 2585 } 2586 } 2587 #endif 2886 } 2887 #endif 2888 if(file_name!=NULL){ 2889 free(file_name); 2890 file_name=NULL; 2891 } 2588 2892 tmpI=tmpI->next; 2589 2893 } … … 2593 2897 if(tmpI!=NULL) 2594 2898 goto NESTED0; 2595 } 2899 } 2596 2900 #ifdef DEBUG 2597 2901 fprintf(stderr,"SERVICE : %s\n",s->name); 2598 2902 dumpMaps(m); 2903 #endif 2904 if(error<0) 2905 printProcessResponse(m,request_inputs1,cpid, 2906 s, s->name,res, // replace serviceProvider with serviceName in stored response file name 2907 request_inputs, 2908 request_outputs); 2909 else{ 2910 maps* tmpMaps=getMaps(m,"lenv"); 2911 #ifdef USE_CALLBACK 2912 invokeCallback(m,NULL,NULL,7,0); 2599 2913 #endif 2600 printProcessResponse(m,request_inputs1,cpid, 2601 s, s->name,res, // replace serviceProvider with serviceName in stored response file name 2602 request_inputs, 2603 request_outputs); 2914 printExceptionReportResponse(m,tmpMaps->content); 2915 } 2604 2916 } 2605 2917 else{ -
trunk/zoo-project/zoo-kernel/response_print.h
r785 r917 39 39 #include <libintl.h> 40 40 #include <locale.h> 41 41 42 /** 42 43 * ZOO-Kernel internal messages translation function … … 63 64 #include <sys/stat.h> 64 65 #include <sys/types.h> 65 #include "cgic.h"66 66 #ifndef WIN32 67 67 #include <sys/ipc.h> … … 80 80 #endif 81 81 #ifndef WIN32 82 #include <xlocale.h> 82 //#include <locale.h> 83 #include <locale.h> // knut: this appears to be a non-standard header file that has been removed in newer versions of glibc; it may be sufficient to include <locale.h> (see above) 83 84 #endif 84 85 #include "ulinet.h" … … 94 95 #include <libxml/parser.h> 95 96 #include <libxml/xpath.h> 97 98 #include "cgic.h" 96 99 97 100 #ifdef __cplusplus … … 209 212 xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*,const char*,int); 210 213 xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*,const char*); 211 void printGetCapabilitiesForProcess(registry*,maps*,xml NodePtr,service*);212 void printDescribeProcessForProcess(registry*,maps*,xml NodePtr,service*);213 void printFullDescription( int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int);214 void printGetCapabilitiesForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*); 215 void printDescribeProcessForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*); 216 void printFullDescription(xmlDocPtr,int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int,int,const map*); 214 217 void printDocument(maps*,xmlDocPtr,int); 215 218 void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int); … … 220 223 void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*); 221 224 void printStatusInfo(maps*,map*,char*); 225 void addAdditionalParameters(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int); 226 void addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int); 222 227 223 228 void outputResponse(service*,maps*,maps*,map*,int,maps*,int); -
trunk/zoo-project/zoo-kernel/server_internal.c
r889 r917 26 26 #include "service_internal.h" 27 27 #include "response_print.h" 28 //#include "service_callback.h" 28 29 #include "mimetypes.h" 29 30 #ifndef WIN32 … … 366 367 */ 367 368 void readGeneratedFile(maps* m,map* content,char* filename){ 369 char rsize[1024]; 368 370 FILE * file=fopen(filename,"rb"); 369 371 if(file==NULL){ 370 fprintf(stderr,"Failed to open file %s for reading purpose.\n",filename);371 372 setMapInMaps(m,"lenv","message","Unable to read produced file. Please try again later"); 372 373 return ; 373 374 } 374 375 fseek(file, 0, SEEK_END); 375 long count = ftell(file); 376 zStatStruct f_status; 377 int s=zStat(filename, &f_status); 378 sprintf(rsize,"%lld",f_status.st_size); 376 379 rewind(file); 377 struct stat file_status; 378 stat(filename, &file_status); 379 map* tmpMap1=getMap(content,"value"); 380 if(tmpMap1==NULL){ 381 addToMap(content,"value",""); 382 tmpMap1=getMap(content,"value"); 383 } 384 free(tmpMap1->value); 385 tmpMap1->value=(char*) malloc((count+1)*sizeof(char)); 386 fread(tmpMap1->value,1,count,file); 387 tmpMap1->value[count]=0; 388 fclose(file); 389 char rsize[1000]; 390 sprintf(rsize,"%ld",count); 380 if(getMap(content,"storage")==NULL){ 381 map* memUse=getMapFromMaps(m,"main","memory"); 382 if(memUse==NULL || strncmp(memUse->value,"load",4)==0){ 383 map* tmpMap1=getMap(content,"value"); 384 if(tmpMap1==NULL){ 385 addToMap(content,"value",""); 386 tmpMap1=getMap(content,"value"); 387 } 388 free(tmpMap1->value); 389 tmpMap1->value=(char*) malloc((f_status.st_size+1)*sizeof(char)); 390 if(tmpMap1->value==NULL){ 391 setMapInMaps(m,"lenv","message","Unable to allocate the memory required to read the produced file."); 392 } 393 fread(&tmpMap1->value,1,f_status.st_size,file); 394 tmpMap1->value[f_status.st_size]=0; 395 } 396 } 397 fclose(file); 391 398 addToMap(content,"size",rsize); 392 399 } … … 423 430 void dumpMapsValuesToFiles(maps** main_conf,maps** in){ 424 431 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); 432 map* tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl"); 425 433 map* tmpSid=getMapFromMaps(*main_conf,"lenv","usid"); 426 434 maps* inputs=*in; … … 445 453 if(cSize!=NULL){ 446 454 length=atoi(cSize->value); 447 } 455 }else 456 length=strlen(cValue->value); 448 457 writeFile(val,cValue->value,length); 449 458 setMapArray(cMap,"cache_file",k,val); 459 free(val); 460 val=(char*)malloc((strlen(tmpUrl->value)+strlen(inputs->name)+strlen(tmpSid->value)+strlen(file_ext)+16)*sizeof(char)); 461 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpUrl->value,inputs->name,tmpSid->value,k,file_ext); 462 setMapArray(cMap,"cache_url",k,val); 463 setMapArray(cMap,"byValue",k,"true"); 450 464 free(val); 451 465 } … … 461 475 if(cSize!=NULL){ 462 476 length=atoi(cSize->value); 463 } 477 }else 478 length=strlen(cValue->value); 464 479 writeFile(val,cValue->value,length); 465 480 addToMap(cMap,"cache_file",val); 481 free(val); 482 val=(char*)malloc((strlen(tmpUrl->value)+strlen(inputs->name)+strlen(tmpSid->value)+strlen(file_ext)+16)*sizeof(char)); 483 sprintf(val,"%s/Input_%s_%s_%d.%s",tmpUrl->value,inputs->name,tmpSid->value,0,file_ext); 484 addToMap(cMap,"cache_url",val); 485 addToMap(cMap,"byValue",val); 466 486 free(val); 467 487 } … … 638 658 } 639 659 if(res==NULL){ 660 map* tmpMaxO0=getMap(tmpInputs->content,"useMapserver"); 661 if(tmpMaxO0!=NULL){ 662 if(tmpMaps2->content==NULL) 663 tmpMaps2->content=createMap("useMapserver",tmpMaxO0->value); 664 else 665 addToMap(tmpMaps2->content,"useMapserver",tmpMaxO0->value); 666 } 640 667 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 641 668 if(tmpMaxO!=NULL){ … … 701 728 } 702 729 } 703 else {730 else /*toto*/{ 704 731 iotype* tmpIoType=NULL; 705 732 if(tmpMaps->content!=NULL){ … … 711 738 * content map. 712 739 */ 713 map* tmpMap1=getMap(tmpInputs->content,"minOccurs"); 714 if(tmpMap1!=NULL){ 715 if(tmpMaps->content==NULL) 716 tmpMaps->content=createMap("minOccurs",tmpMap1->value); 717 else 718 addToMap(tmpMaps->content,"minOccurs",tmpMap1->value); 719 } 720 map* tmpMaxO=getMap(tmpInputs->content,"maxOccurs"); 721 if(tmpMaxO!=NULL){ 722 if(tmpMaps->content==NULL) 723 tmpMaps->content=createMap("maxOccurs",tmpMaxO->value); 724 else 725 addToMap(tmpMaps->content,"maxOccurs",tmpMaxO->value); 726 } 727 map* tmpMaxMB=getMap(tmpInputs->content,"maximumMegabytes"); 728 if(tmpMaxMB!=NULL){ 729 if(tmpMaps->content==NULL) 730 tmpMaps->content=createMap("maximumMegabytes",tmpMaxMB->value); 731 else 732 addToMap(tmpMaps->content,"maximumMegabytes",tmpMaxMB->value); 740 char* keys[4]={ 741 "minOccurs", 742 "maxOccurs", 743 "maximumMegabytes", 744 "useMapserver" 745 }; 746 int i=0; 747 for(i=0;i<4;i++){ 748 map* tmpMap1=getMap(tmpInputs->content,keys[i]); 749 if(tmpMap1!=NULL){ 750 addToMap(tmpMaps->content,keys[i],tmpMap1->value); 751 } 733 752 } 734 753 /** … … 743 762 map* tmpV=getMap(tmpI->content,"value"); 744 763 if(tmpV!=NULL){ 745 char *tmpVS= strdup(tmpV->value);764 char *tmpVS=zStrdup(tmpV->value); 746 765 map* tmp=parseBoundingBox(tmpVS); 747 766 free(tmpVS); … … 780 799 map* length=getMap(tmpMaps->content,"length"); 781 800 int i; 782 char *tcn= strdup(tmpContent->name);801 char *tcn=zStrdup(tmpContent->name); 783 802 for(i=1;i<atoi(length->value);i++){ 784 803 #ifdef DEBUG … … 806 825 */ 807 826 if(tmpIoType!=NULL){ 808 map* tmpCheck=getMap(tmpIoType->content,"useMap Server");809 if(tmpCheck!=NULL ){827 map* tmpCheck=getMap(tmpIoType->content,"useMapserver"); 828 if(tmpCheck!=NULL && strncasecmp(tmpCheck->value,"true",4)==0){ 810 829 // Get the default value 830 addToMap(tmpMaps->content,"useMapserver","true"); 811 831 tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,NULL); 812 832 tmpCheck=getMap(tmpMaps->content,"mimeType"); … … 834 854 addToMap(tmpMaps->content,"inRequest","true"); 835 855 elements* tmpElements=getElements(in,tmpMaps->name); 836 if( tmpElements!=NULL && tmpElements->child!=NULL){856 if(/*tmpMaps->child!=NULL && */tmpElements!=NULL && tmpElements->child!=NULL){ 837 857 char *res=addDefaultValues(&tmpMaps->child,tmpElements->child,m,type,err); 838 858 if(strlen(res)>0){ 839 859 return res; 840 860 } 861 } 862 } 863 if(tmpInputs->child!=NULL){ 864 tmpInputss=tmpInputs->next; 865 tmpInputs=tmpInputs->child; 866 if(tmpMaps!=NULL){ 867 out1=tmpMaps->child; 868 out1s=tmpMaps; 841 869 } 842 870 } … … 972 1000 if(isRunning(conf,pid)>0){ 973 1001 if(strncasecmp(req,"GetResult",strlen(req))==0){ 974 errorException (conf, _("The result for the requested JobID has not yet been generated. "),1002 errorException (conf, _("The result for the requested JobID has not yet been generated. The service is currently running."), 975 1003 "ResultNotReady", pid); 976 1004 return; … … 981 1009 char* tmpStr=_getStatus(conf,pid); 982 1010 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ 983 char *tmpStr1= strdup(tmpStr);984 char *tmpStr0= strdup(strstr(tmpStr,"|")+1);1011 char *tmpStr1=zStrdup(tmpStr); 1012 char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1); 985 1013 free(tmpStr); 986 1014 tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0'; … … 1000 1028 printf("%s",result); 1001 1029 fflush(stdout); 1030 free(sid); 1002 1031 freeMap(&statusInfo); 1003 1032 free(statusInfo); 1033 free(result); 1004 1034 return; 1005 1035 }else{ 1006 errorException (conf, _("The result for the requested JobID has not yet been generated. "),1036 errorException (conf, _("The result for the requested JobID has not yet been generated. The service ends but it still needs to produce the outputs."), 1007 1037 "ResultNotReady", pid); 1008 1038 freeMap(&statusInfo); … … 1015 1045 char* tmpStr=_getStatus(conf,pid); 1016 1046 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ 1017 char *tmpStr1= strdup(tmpStr);1018 char *tmpStr0= strdup(strstr(tmpStr,"|")+1);1047 char *tmpStr1=zStrdup(tmpStr); 1048 char *tmpStr0=zStrdup(strstr(tmpStr,"|")+1); 1019 1049 free(tmpStr); 1020 1050 tmpStr1[strlen(tmpStr1)-strlen(tmpStr0)-1]='\0'; … … 1026 1056 } 1027 1057 } 1058 free(sid); 1028 1059 printStatusInfo(conf,statusInfo,req); 1029 1060 freeMap(&statusInfo); … … 1083 1114 if(strstr(dp->d_name,pid)!=0){ 1084 1115 sprintf(fileName,"%s/%s",r_inputs->value,dp->d_name); 1085 if( unlink(fileName)!=0){1116 if(zUnlink(fileName)!=0){ 1086 1117 errorException (conf, 1087 1118 _("The job cannot be removed, a file cannot be removed"), … … 1095 1126 removeService(conf,pid); 1096 1127 #endif 1128 /* No need to call 7_1 when an execution is dismissed. 1129 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1130 invokeCallback(conf,NULL,NULL,7,1); 1131 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1132 */ 1097 1133 map* statusInfo=createMap("JobID",pid); 1098 1134 addToMap(statusInfo,"Status","Dismissed"); -
trunk/zoo-project/zoo-kernel/service.c
r889 r917 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2015 GeoLabs SARL4 * Copyright (c) 2015-2019 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 28 28 #include <ctime> 29 29 #include <chrono> 30 #ifdef WIN32 30 31 #include <process.h> 32 #endif 31 33 32 34 #if defined(_MSC_VER) && _MSC_VER < 1800 … … 102 104 fprintf(stderr," * CONTENT [%s] \n",tmp->name); 103 105 dumpMap(tmp->content); 104 fprintf(stderr," * CHILD [%s] \n",tmp->name); 105 dumpMaps(tmp->child); 106 if(tmp->child!=NULL){ 107 fprintf(stderr," * CHILD [%s] \n",tmp->name); 108 dumpMaps(tmp->child); 109 fprintf(stderr," * /CHILD [%s] \n",tmp->name); 110 } 106 111 tmp=tmp->next; 107 112 } … … 125 130 fflush(file); 126 131 tmp=tmp->next; 127 cnt++;128 132 if(limit>=0 && cnt==limit) 129 133 tmp=NULL; 134 cnt++; 130 135 } 131 136 fflush(file); … … 144 149 fflush(file); 145 150 fclose(file); 151 } 152 153 /** 154 * Create a new iotype* 155 * 156 * @return a pointer to the allocated iotype 157 */ 158 iotype* createIoType(){ 159 iotype* io=(iotype*)malloc(IOTYPE_SIZE); 160 io->content=NULL; 161 io->next=NULL; 162 return io; 146 163 } 147 164 … … 179 196 * Count number of map in a map 180 197 * 181 * @param m the map sto count198 * @param m the map to count 182 199 * @return number of map in a map 183 200 */ 184 201 int count(map* m){ 185 202 map* tmp=m; 203 int c=0; 204 while(tmp!=NULL){ 205 c++; 206 tmp=tmp->next; 207 } 208 return c; 209 } 210 211 /** 212 * Count number of maps in a maps 213 * 214 * @param m the maps to count 215 * @return number of maps in a maps 216 */ 217 int maps_length(maps* m){ 218 maps* tmp=m; 186 219 int c=0; 187 220 while(tmp!=NULL){ … … 401 434 if(tmp->metadata!=NULL) 402 435 free(tmp->metadata); 436 freeMap(&tmp->additional_parameters); 437 if(tmp->additional_parameters!=NULL) 438 free(tmp->additional_parameters); 403 439 if(tmp->format!=NULL) 404 440 free(tmp->format); 441 freeElements(&tmp->child); 405 442 if(tmp->child!=NULL){ 406 freeElements(&tmp->child);407 443 free(tmp->child); 408 444 } 409 freeIOType(&tmp->defaults);410 if(tmp->defaults!=NULL)445 if(tmp->defaults!=NULL){ 446 freeIOType(&tmp->defaults); 411 447 free(tmp->defaults); 412 freeIOType(&tmp->supported);448 } 413 449 if(tmp->supported!=NULL){ 450 freeIOType(&tmp->supported); 414 451 free(tmp->supported); 415 452 } 416 freeElements(&tmp->next);417 if(tmp->next!=NULL)453 if(tmp->next!=NULL){ 454 freeElements(&tmp->next); 418 455 free(tmp->next); 419 } 456 } 457 } 458 } 459 460 461 /** 462 * Allocate memory for a service. 463 * Require to call free after calling this function. 464 * 465 * @return the service 466 */ 467 service* createService(){ 468 service *s1 = (service *) malloc (SERVICE_SIZE); 469 s1->name=NULL; 470 s1->content=NULL; 471 s1->metadata=NULL; 472 s1->additional_parameters=NULL; 473 s1->inputs=NULL; 474 s1->outputs=NULL; 475 return s1; 420 476 } 421 477 422 478 /** 423 479 * Free allocated memory of a service. 424 * Require to call free on e after calling this function.480 * Require to be invoked for every createService call. 425 481 * 426 482 * @param s the service to free … … 437 493 if(tmp->metadata!=NULL) 438 494 free(tmp->metadata); 495 freeMap(&tmp->additional_parameters); 496 if(tmp->additional_parameters!=NULL) 497 free(tmp->additional_parameters); 439 498 freeElements(&tmp->inputs); 440 499 if(tmp->inputs!=NULL) … … 454 513 */ 455 514 void addToMap(map* m,const char* n,const char* v){ 456 if (m != NULL) { // knut: add NULL-pointer check457 if(hasKey(m,n)==false){458 map* _cursor=m;459 while(_cursor->next!=NULL){460 _cursor=_cursor->next;461 }462 _cursor->next=createMap(n,v);463 }464 else{465 map *tmp=getMap(m,n);466 if(tmp->value!=NULL)467 free(tmp->value);468 tmp->value=zStrdup(v);469 }470 }515 if (m != NULL) { // knut: add NULL-pointer check 516 if (hasKey(m, n) == false) { 517 map* _cursor = m; 518 while (_cursor->next != NULL) { 519 _cursor = _cursor->next; 520 } 521 _cursor->next = createMap(n, v); 522 } 523 else { 524 map *tmp = getMap(m, n); 525 if (tmp->value != NULL) 526 free(tmp->value); 527 tmp->value = zStrdup(v); 528 } 529 } 471 530 } 472 531 … … 506 565 */ 507 566 map* addToMapWithSize(map* m,const char* n,const char* v,int size){ 567 char sin[128]; 568 char sname[10]="size"; 569 map *tmp; 508 570 if(hasKey(m,n)==false){ 509 571 map* _cursor=m; … … 514 576 } 515 577 } 516 char sname[10]="size";517 578 if(strlen(n)>5) 518 579 sprintf(sname,"size_%s",n+6); 519 map *tmp=getMap(m,n);580 tmp=getMap(m,n); 520 581 if(tmp->value!=NULL) 521 582 free(tmp->value); … … 524 585 memmove(tmp->value,v,size*sizeof(char)); 525 586 tmp->value[size]=0; 526 char sin[128];527 587 sprintf(sin,"%d",size); 528 588 addToMap(m,sname,sin); … … 545 605 } 546 606 else{ 547 #ifdef DEBUG548 fprintf(stderr,"_CURSOR\n");549 dumpMap(_cursor);550 #endif551 while(_cursor->next!=NULL)552 _cursor=_cursor->next;553 607 map* tmp1=getMap(*mo,tmp->name); 554 608 if(tmp1==NULL){ 609 while(_cursor->next!=NULL) 610 _cursor=_cursor->next; 555 611 _cursor->next=createMap(tmp->name,tmp->value); 556 612 } … … 561 617 _cursor=*mo; 562 618 tmp=tmp->next; 563 #ifdef DEBUG564 fprintf(stderr,"MO\n");565 dumpMap(*mo);566 #endif567 619 } 568 620 } … … 678 730 map* size=getMap(in,"size"); 679 731 map *lout=*out; 732 map *tmpVin,*tmpVout; 680 733 if(size!=NULL && pos>0){ 681 734 char tmp[11]; … … 683 736 size=getMap(in,tmp); 684 737 sprintf(tmp,"value_%d",pos); 685 map*tmpVin=getMap(in,tmp);686 map*tmpVout=getMap(lout,tmp);738 tmpVin=getMap(in,tmp); 739 tmpVout=getMap(lout,tmp); 687 740 free(tmpVout->value); 688 741 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 691 744 }else{ 692 745 if(size!=NULL){ 693 map*tmpVin=getMap(in,"value");694 map*tmpVout=getMap(lout,"value");746 tmpVin=getMap(in,"value"); 747 tmpVout=getMap(lout,"value"); 695 748 free(tmpVout->value); 696 749 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 712 765 map* size=getMap(in,"size"); 713 766 map* length=getMap(in,"length"); 767 map* toload=getMap(in,"to_load"); 768 if(toload!=NULL && strcasecmp(toload->value,"false")==0){ 769 #ifdef DEBUG 770 fprintf(stderr,"NO LOAD %s %d \n",__FILE__,__LINE__); 771 #endif 772 return ; 773 } 714 774 if(length!=NULL){ 715 775 int len=atoi(length->value); … … 734 794 maps* res=NULL; 735 795 if(_cursor!=NULL){ 796 map* mc=_cursor->content; 797 maps* mcs=_cursor->child; 736 798 res=createMaps(_cursor->name); 737 map* mc=_cursor->content;738 799 if(mc!=NULL){ 739 800 addMapToMap(&res->content,mc); 740 801 loadMapBinaries(&res->content,mc); 741 802 } 742 maps* mcs=_cursor->child;743 803 if(mcs!=NULL){ 744 804 res->child=dupMaps(&mcs); … … 764 824 } 765 825 else{ 826 maps* tmp1=getMaps(*mo,tmp->name); 766 827 while(_cursor->next!=NULL) 767 828 _cursor=_cursor->next; 768 maps* tmp1=getMaps(*mo,tmp->name);769 829 if(tmp1==NULL){ 770 830 _cursor->next=dupMaps(&tmp); … … 797 857 map* getMapArray(map* m,const char* key,int index){ 798 858 char tmp[1024]; 859 map* tmpMap; 799 860 if(index>0) 800 861 sprintf(tmp,"%s_%d",key,index); … … 804 865 fprintf(stderr,"** KEY %s\n",tmp); 805 866 #endif 806 map*tmpMap=getMap(m,tmp);867 tmpMap=getMap(m,tmp); 807 868 #ifdef DEBUG 808 869 if(tmpMap!=NULL) … … 823 884 void setMapArray(map* m,const char* key,int index,const char* value){ 824 885 char tmp[1024]; 886 map* tmpSize; 825 887 if(index>0){ 888 map* len=getMap(m,"length"); 826 889 sprintf(tmp,"%s_%d",key,index); 827 map* len=getMap(m,"length");828 890 if((len!=NULL && atoi(len->value)<index+1) || len==NULL){ 829 891 char tmp0[5]; … … 832 894 } 833 895 } 834 else 896 else{ 835 897 sprintf(tmp,"%s",key); 836 map* tmpSize=getMapArray(m,"size",index); 898 addToMap(m,"length","1"); 899 } 900 tmpSize=getMapArray(m,"size",index); 837 901 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 902 map* ptr=getMapOrFill(&m,tmp,(char *)""); 838 903 #ifdef DEBUG 839 904 fprintf(stderr,"%s\n",tmpSize->value); 840 905 #endif 841 map* ptr=getMapOrFill(&m,tmp,(char *)"");842 906 free(ptr->value); 843 907 ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char)); … … 846 910 else 847 911 addToMap(m,tmp,value); 912 } 913 914 /** 915 * Add a key and an integer value to an existing map array. 916 * 917 * @param m the map to add the KVP 918 * @param n the key to add 919 * @param index the index of the MapArray 920 * @param v the corresponding value to add 921 */ 922 void addIntToMapArray(map* m,const char* n,int index,const int v){ 923 char svalue[10]; 924 sprintf(svalue,"%d",v); 925 setMapArray(m,n,index,svalue); 848 926 } 849 927 … … 881 959 maps* tmp=mi; 882 960 maps* _cursor=getMaps(*mo,tmp->name); 883 884 if(_cursor==NULL)885 return -1;886 887 map* tmpLength=getMap(_cursor->content,"length");888 961 char tmpLen[10]; 889 962 int len=1; 890 if(tmpLength!=NULL){891 len=atoi(tmpLength->value);892 }893 894 963 char *tmpV[14]={ 895 964 (char*)"size", … … 906 975 (char*)"isCached", 907 976 (char*)"LowerCorner", 908 (char*)"UpperCorner" 977 (char*)"UpperCorner" 909 978 }; 979 int i=0; 980 map* tmpLength; 981 982 if(_cursor==NULL) 983 return -1; 984 985 tmpLength=getMap(_cursor->content,"length"); 986 if(tmpLength!=NULL){ 987 len=atoi(tmpLength->value); 988 } 989 910 990 sprintf(tmpLen,"%d",len+1); 911 991 addToMap(_cursor->content,"length",tmpLen); 912 int i=0;913 992 for(i=0;i<14;i++){ 914 993 map* tmpVI=getMap(tmp->content,tmpV[i]); … … 967 1046 res->content=NULL; 968 1047 res->metadata=NULL; 1048 res->additional_parameters=NULL; 969 1049 res->format=NULL; 970 1050 res->defaults=NULL; … … 981 1061 * @return a pointer to the allocated elements 982 1062 */ 983 elements* createElements(c har* name){1063 elements* createElements(const char* name){ 984 1064 elements* res=(elements*)malloc(ELEMENTS_SIZE); 985 1065 res->name=zStrdup(name); 986 1066 res->content=NULL; 987 1067 res->metadata=NULL; 1068 res->additional_parameters=NULL; 988 1069 res->format=NULL; 989 1070 res->defaults=NULL; … … 1020 1101 elements* tmp=e; 1021 1102 while(tmp!=NULL){ 1103 iotype* tmpio=tmp->defaults; 1104 int ioc=0; 1022 1105 fprintf(stderr,"ELEMENT [%s]\n",tmp->name); 1023 1106 fprintf(stderr," > CONTENT [%s]\n",tmp->name); … … 1025 1108 fprintf(stderr," > METADATA [%s]\n",tmp->name); 1026 1109 dumpMap(tmp->metadata); 1110 fprintf(stderr," > ADDITIONAL PARAMETERS [%s]\n",tmp->name); 1111 dumpMap(tmp->additional_parameters); 1027 1112 fprintf(stderr," > FORMAT [%s]\n",tmp->format); 1028 iotype* tmpio=tmp->defaults;1029 int ioc=0;1030 1113 while(tmpio!=NULL){ 1031 1114 fprintf(stderr," > DEFAULTS [%s] (%i)\n",tmp->name,ioc); … … 1060 1143 int i; 1061 1144 while(tmp!=NULL){ 1145 map* mcurs=tmp->content; 1146 int ioc=0; 1147 iotype* tmpio; 1062 1148 for(i=0;i<2+(4*level);i++) 1063 1149 fprintf(stderr," "); 1064 1150 fprintf(stderr,"%s:\n",tmp->name); 1065 map* mcurs=tmp->content;1066 1151 while(mcurs!=NULL){ 1067 1152 for(i=0;i<4+(4*level);i++) … … 1091 1176 dumpElementsAsYAML(tmp->child,level+1); 1092 1177 } 1093 iotype* tmpio=tmp->defaults; 1094 int ioc=0; 1178 tmpio=tmp->defaults; 1095 1179 while(tmpio!=NULL){ 1096 1180 for(i=0;i<6+(4*level);i++) … … 1142 1226 elements* cursor=e; 1143 1227 elements* tmp=NULL; 1144 if(cursor!=NULL ){1228 if(cursor!=NULL && cursor->name!=NULL){ 1145 1229 #ifdef DEBUG 1146 1230 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); … … 1149 1233 #endif 1150 1234 tmp=(elements*)malloc(ELEMENTS_SIZE); 1151 tmp->name=zStrdup( e->name);1235 tmp->name=zStrdup(cursor->name); 1152 1236 tmp->content=NULL; 1153 addMapToMap(&tmp->content, e->content);1237 addMapToMap(&tmp->content,cursor->content); 1154 1238 tmp->metadata=NULL; 1155 addMapToMap(&tmp->metadata,e->metadata); 1156 if(e->format!=NULL) 1157 tmp->format=zStrdup(e->format); 1239 addMapToMap(&tmp->metadata,cursor->metadata); 1240 tmp->additional_parameters=NULL; 1241 addMapToMap(&tmp->additional_parameters,cursor->additional_parameters); 1242 if(cursor->format!=NULL) 1243 tmp->format=zStrdup(cursor->format); 1158 1244 else 1159 1245 tmp->format=NULL; 1160 if( e->defaults!=NULL){1246 if(cursor->defaults!=NULL){ 1161 1247 tmp->defaults=(iotype*)malloc(IOTYPE_SIZE); 1162 1248 tmp->defaults->content=NULL; 1163 addMapToMap(&tmp->defaults->content, e->defaults->content);1249 addMapToMap(&tmp->defaults->content,cursor->defaults->content); 1164 1250 tmp->defaults->next=NULL; 1165 1251 #ifdef DEBUG … … 1169 1255 }else 1170 1256 tmp->defaults=NULL; 1171 if(e->supported!=NULL){ 1257 if(cursor->supported!=NULL && cursor->supported->content!=NULL){ 1258 iotype *tmp2=cursor->supported->next; 1172 1259 tmp->supported=(iotype*)malloc(IOTYPE_SIZE); 1173 1260 tmp->supported->content=NULL; 1174 addMapToMap(&tmp->supported->content, e->supported->content);1261 addMapToMap(&tmp->supported->content,cursor->supported->content); 1175 1262 tmp->supported->next=NULL; 1176 iotype *tmp2=e->supported->next; 1177 while(tmp2!=NULL){ 1263 while(tmp2!=NULL){ 1178 1264 addMapToIoType(&tmp->supported,tmp2->content); 1179 1265 #ifdef DEBUG … … 1190 1276 else 1191 1277 tmp->child=NULL; 1192 tmp->next=dupElements(cursor->next); 1278 if(cursor->next!=NULL) 1279 tmp->next=dupElements(cursor->next); 1280 else 1281 tmp->next=NULL; 1193 1282 } 1194 1283 return tmp; … … 1205 1294 elements* tmp=e; 1206 1295 if(*m==NULL){ 1207 *m=dupElements(tmp);1296 (*m)=dupElements(tmp); 1208 1297 }else{ 1209 1298 addToElements(&(*m)->next,tmp); … … 1237 1326 fprintf(stderr,"CONTENT MAP\n"); 1238 1327 dumpMap(s->content); 1239 fprintf(stderr,"CONTENT METADATA\n"); 1328 if(s->metadata!=NULL) 1329 fprintf(stderr,"CONTENT METADATA\n"); 1240 1330 dumpMap(s->metadata); 1331 if(s->additional_parameters!=NULL) 1332 fprintf(stderr,"CONTENT AdditionalParameters\n"); 1333 dumpMap(s->additional_parameters); 1241 1334 } 1242 1335 if(s->inputs!=NULL){ … … 1296 1389 res->metadata=NULL; 1297 1390 addMapToMap(&res->metadata,s->metadata); 1391 res->additional_parameters=NULL; 1392 addMapToMap(&res->additional_parameters,s->additional_parameters); 1298 1393 res->inputs=dupElements(s->inputs); 1299 1394 res->outputs=dupElements(s->outputs); … … 1309 1404 registry* p=r; 1310 1405 while(p!=NULL){ 1406 services* s=p->content; 1311 1407 fprintf(stderr,"%s \n",p->name); 1312 services* s=p->content;1313 1408 s=p->content; 1314 1409 while(s!=NULL){ … … 1509 1604 */ 1510 1605 void inheritance(registry *r,service** s){ 1606 service* ls=*s; 1607 map *profile,*level; 1511 1608 if(r==NULL) 1512 1609 return; 1513 service* ls=*s; 1514 if(ls->content==NULL) 1610 if(ls==NULL || ls->content==NULL) 1515 1611 return; 1516 map*profile=getMap(ls->content,"extend");1517 map*level=getMap(ls->content,"level");1612 profile=getMap(ls->content,"extend"); 1613 level=getMap(ls->content,"level"); 1518 1614 if(profile!=NULL&&level!=NULL){ 1519 1615 service* s1; … … 1550 1646 memset(tmp,0,1024*10*10); 1551 1647 while(tm!=NULL){ 1648 map* tc=tm->content; 1552 1649 if(i>=10) 1553 1650 break; … … 1556 1653 strcpy(tmp[i][j],tm->name); 1557 1654 j++; 1558 map* tc=tm->content;1559 1655 while(tc!=NULL){ 1560 1656 if(j>=30) … … 1609 1705 * @return true if map has a value or false if value is missing/empty/NULL 1610 1706 */ 1611 bool nonempty( map* map) {1612 return ( map != NULL && map->value != NULL && strlen(map->value) > 0 && strcmp(map->value, "NULL") != 0);1613 } 1614 1615 /** 1616 * Verify that a particular map value exists in a maps 1707 bool nonempty(map* map) { 1708 return (map != NULL && map->value != NULL && strlen(map->value) > 0 && strcmp(map->value, "NULL") != 0); 1709 } 1710 1711 /** 1712 * Verify that a particular map value exists in a maps 1617 1713 * data structure, and obtain that value 1618 1714 * … … 1620 1716 * @param node name of maps node to search 1621 1717 * @param key name of map node to find 1622 * @param address to the map* if it exists, otherwise NULL1718 * @param kvp address to the map* if it exists, otherwise NULL 1623 1719 * @return true if map has a value or false if value is missing/NULL 1624 */ 1625 bool hasvalue( maps* source, const char* node, const char* key, map** kvp ) { 1626 *kvp = getMapFromMaps(source, node, key); 1627 return ( *kvp != NULL && (*kvp)->value != NULL && 1628 strlen((*kvp)->value) > 0 && strcmp((*kvp)->value, "NULL") != 0 ); 1720 * 1721 * @note The map assigned to kvp is owned by the source maps 1722 */ 1723 bool hasvalue(maps* source, const char* node, const char* key, map** kvp) { 1724 *kvp = getMapFromMaps(source, node, key); 1725 return (*kvp != NULL && (*kvp)->value != NULL && 1726 strlen((*kvp)->value) > 0 && strcmp((*kvp)->value, "NULL") != 0); 1629 1727 } 1630 1728 … … 1633 1731 * 1634 1732 * @param conf reference to configuration maps 1635 * @param service name of service 1733 * @param service name of service 1636 1734 * @param exc WPSException code 1637 1735 * @param message exception text (default: exception text in WPS specification) 1638 1736 */ 1639 void setErrorMessage( maps*& conf, const char* service, WPSException exc, const char* message) {1640 1641 1642 1643 } 1644 1645 size_t len = strlen( service ) + strlen(": ") + strlen( message) + strlen(": ") + strlen(WPSExceptionCode[exc]) + 16;1646 char* msg = (char*) malloc( len * sizeof(char));1737 void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message) { 1738 1739 if (message == NULL) { 1740 message = WPSExceptionText[exc]; 1741 } 1742 1743 size_t len = strlen(service) + strlen(": ") + strlen(message) + strlen(": ") + strlen(WPSExceptionCode[exc]) + 16; 1744 char* msg = (char*)malloc(len * sizeof(char)); 1647 1745 1648 1746 if (msg != NULL) { 1649 snprintf( msg, len*sizeof(char), "\n%s: %s: %s\n", service, message, WPSExceptionCode[exc]);1650 setMapInMaps( conf, "lenv", "message", msg);1651 free( msg);1652 } 1747 snprintf(msg, len * sizeof(char), "\n%s: %s: %s\n", service, message, WPSExceptionCode[exc]); 1748 setMapInMaps(conf, "lenv", "message", msg); 1749 free(msg); 1750 } 1653 1751 } 1654 1752 1655 1753 void logMessage(const char* source, const char* function, int line, const char* file, const char* message) { //, const char* source, const char* function, int line) { 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 std::time_t now_t = std::chrono::system_clock::to_time_t( now);1672 std::tm* tm = localtime( &now_t);1754 1755 size_t msglen = 512; 1756 const char empty[] = ""; 1757 1758 FILE* log; 1759 1760 // system time, process time [nanoseconds] 1761 unsigned long long sys_t, proc_t; 1762 1763 // processor time consumed by the program: 1764 clock_t t = clock(); 1765 1766 // system time: 1767 std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); 1768 1769 std::time_t now_t = std::chrono::system_clock::to_time_t(now); 1770 std::tm* tm = localtime(&now_t); 1673 1771 char* str = asctime(tm); 1674 str[strlen(str)-1] = '\0'; // remove newline1675 1676 1677 1678 1679 1680 if ( message != NULL) {1681 1682 } 1683 1684 1685 1686 1687 char* text = (char*) malloc( sizeof(char)*msglen);1688 1689 snprintf( text, msglen, "pid: %d %s line %d %s() %s systime: %lld ns ticks: %lld %s\n", 1690 _getpid(), source, line, function, str, sys_t, proc_t, message); // __FILE__ __LINE__ __func__ //1691 1692 if ( file != NULL && (log = fopen( file, "a+" )) != NULL) {1693 fputs( text, log);1694 fclose( log);1695 1696 1697 1698 if ( (log = fopen( MSG_LOG_FILE, "a+" )) != NULL) {1699 fputs( text, log);1700 fclose( log);1701 } 1702 1703 1704 1705 if ( text != NULL ) free( text);1772 str[strlen(str) - 1] = '\0'; // remove newline 1773 1774 sys_t = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count(); 1775 //proc_t = (unsigned long long)(1.0e9*t/CLOCKS_PER_SEC); 1776 proc_t = t; 1777 1778 if (message != NULL) { 1779 msglen += strlen(message); 1780 } 1781 else { 1782 message = empty; 1783 } 1784 //getLastErrorMessage(); // cgiScriptName 1785 char* text = (char*)malloc(sizeof(char)*msglen); 1786 1787 snprintf(text, msglen, "pid: %d %s line %d %s() %s systime: %lld ns ticks: %lld %s\n", 1788 zGetpid(), source, line, function, str, sys_t, proc_t, message); // __FILE__ __LINE__ __func__ // 1789 1790 if (file != NULL && (log = fopen(file, "a+")) != NULL) { 1791 fputs(text, log); 1792 fclose(log); 1793 } 1794 else { 1795 #ifdef MSG_LOG_FILE 1796 if ((log = fopen(MSG_LOG_FILE, "a+")) != NULL) { 1797 fputs(text, log); 1798 fclose(log); 1799 } 1800 #endif 1801 } 1802 1803 if (text != NULL) free(text); 1706 1804 } 1707 1805 … … 1710 1808 // zooLog; 1711 1809 // zooLogMsg(NULL, getLastErrorMessage()); 1712 // zooLogMsg(log.txt, getLastErrorMessage()); 1713 1714 #ifdef WIN32 1715 #ifndef USE_MS 1716 char *strcasestr (char const *a, char const *b) 1717 { 1718 char *x = zStrdup (a); 1719 char *y = zStrdup (b); 1720 1721 x = _strlwr (x); 1722 y = _strlwr (y); 1723 char *pos = strstr (x, y); 1724 char *ret = pos == NULL ? NULL : (char *) (a + (pos - x)); 1725 free (x); 1726 free (y); 1727 return ret; 1728 }; 1729 #else 1730 ; 1731 #endif 1732 #endif 1810 // zooLogMsg("log.txt", getLastErrorMessage()); -
trunk/zoo-project/zoo-kernel/service.h
r889 r917 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 5GeoLabs SARL4 * Copyright (c) 2009-2019 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 34 34 #endif 35 35 36 // knut: add bool if necessary 37 #ifndef __cplusplus 38 #ifndef WIN32 39 #include <stdbool.h> 40 #else 41 typedef 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 36 50 #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 57 52 #define strncasecmp _strnicmp 58 53 #define strcasecmp _stricmp 59 #define strtok_r strtok_s60 54 #if defined(_MSC_VER) && _MSC_VER < 1900 61 55 #define snprintf _snprintf 62 56 #endif 63 /* knut: see new definition of bool above64 #if defined(_MSC_VER) && _MSC_VER < 180065 #define false 066 #define true 167 #define bool int68 #endif69 */70 57 #define zStrdup _strdup 71 58 #define zMkdir _mkdir 59 #define zGetpid _getpid 72 60 #define zOpen _open 61 #define zClose _close 62 #define zUnlink _unlink 63 #define zDup _dup 64 #define zDup2 _dup2 73 65 #define zWrite _write 74 66 #define zSleep Sleep … … 80 72 static int zGettimeofday(struct ztimeval* tp, void* tzp) 81 73 { 82 struct _timeb theTime;83 74 if (tp == 0) { 84 75