Changeset 896


Ignore:
Timestamp:
Feb 25, 2019, 1:57:11 PM (3 months ago)
Author:
knut
Message:

Added some recent changes from trunk (r889), including some new utility functions and exception handling and new (conditional) definition of type bool. Added some new logic concerning Python and Mono environment and search paths. Fixed problem with Mono updateStatus function. Changed response_print.h to #include locale.h unconditionally and xlocale.h conditionally; xlocale.h is non-standard and can probably be dropped.

Location:
branches/prototype-v0/zoo-project/zoo-kernel
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/response_print.c

    r890 r896  
    17761776 * @param outputs the outputs generated by the service
    17771777 */
    1778 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){
     1778void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){       
    17791779  xmlNsPtr ns,ns_ows,ns_xlink;
    17801780  xmlNodePtr nr,n,nc,nc1=NULL,nc3;
     
    17971797  char stored_path[1024];
    17981798  memset(stored_path,0,1024);
    1799    
     1799 
    18001800  if(vid==0){
    18011801    char tmp[256];
     
    19821982    }
    19831983  }
    1984 
     1984 
    19851985  /**
    19861986   * Display the process output only when requested !
     
    19931993    maps* mcursor=outputs;
    19941994    elements* scursor=serv->outputs;
    1995     map* testResponse=getMap(request,"RawDataOutput");
     1995    map* testResponse=getMap(request,"RawDataOutput"); 
    19961996    if(testResponse==NULL)
    19971997      testResponse=getMap(request,"ResponseDocument");
    1998     while(mcursor!=NULL){
     1998    while(mcursor!=NULL){               
    19991999      map* tmp0=getMap(mcursor->content,"inRequest");
    2000       scursor=getElements(serv->outputs,mcursor->name);
    2001       if(scursor!=NULL){
    2002         if(testResponse==NULL || tmp0==NULL){
     2000      scursor=getElements(serv->outputs,mcursor->name);   
     2001      if(scursor!=NULL){                 
     2002        if(testResponse==NULL || tmp0==NULL){           
    20032003          if(vid==0)
    20042004            printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
     
    20072007        }
    20082008        else
    2009           if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){
     2009          if(tmp0!=NULL && strncmp(tmp0->value,"true",4)==0){             
    20102010            if(vid==0)
    20112011              printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
    20122012            else
    20132013              printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
    2014           }
     2014          }     
    20152015      }else
    20162016        /**
     
    20232023          printIOType(doc,n,ns,ns_ows,ns_xlink,scursor,mcursor,"Output",vid);
    20242024      mcursor=mcursor->next;
    2025     }
     2025    }   
    20262026    if(vid==0)
    20272027      xmlAddChild(n,nc);
    2028   }
    2029 
     2028  } 
    20302029  if(vid==0 &&
    20312030     hasStoredExecuteResponse==true
     
    21762175 * @param type the type
    21772176 */
    2178 void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type,int vid){
    2179 
     2177void printIOType(xmlDocPtr doc,xmlNodePtr nc,xmlNsPtr ns_wps,xmlNsPtr ns_ows,xmlNsPtr ns_xlink,elements* e,maps* m,const char* type,int vid){   
    21802178  xmlNodePtr nc1,nc2,nc3;
    21812179  nc1=xmlNewNode(ns_wps, BAD_CAST type);
     
    21842182    tmp=e->content;
    21852183  else
    2186     tmp=m->content;
    2187 
     2184    tmp=m->content; 
    21882185  if(vid==0){
    21892186    nc2=xmlNewNode(ns_ows, BAD_CAST "Identifier");
     
    22252222    xmlNewProp(nc1,BAD_CAST "id",BAD_CAST (e!=NULL?e->name:m->name));
    22262223  }
    2227 
     2224 
    22282225  // IO type nested outputs
    2229   if(m->child!=NULL){
     2226  if(m->child!=NULL){     
    22302227    maps* curs=m->child;
    22312228    elements* ecurs=getElements(e,(e!=NULL?e->name:m->name));
     
    22412238    }
    22422239  }
    2243   else{
     2240  else{   
    22442241    map *tmpMap=getMap(m->content,"Reference");
    2245     if(tmpMap==NULL){
     2242    if(tmpMap==NULL){           
    22462243      nc2=xmlNewNode(ns_wps, BAD_CAST "Data");
    2247       if(e!=NULL && e->format!=NULL){
    2248         if(strncasecmp(e->format,"LiteralOutput",strlen(e->format))==0)
    2249           nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData");
     2244      if(e!=NULL && e->format!=NULL){             
     2245                  if (strncasecmp(e->format, "LiteralOutput", strlen(e->format)) == 0)                                   
     2246                          nc3 = xmlNewNode(ns_wps, BAD_CAST "LiteralData");               
    22502247        else
    22512248          if(strncasecmp(e->format,"ComplexOutput",strlen(e->format))==0)
     
    22542251            nc3=xmlNewNode(ns_wps, BAD_CAST "BoundingBoxData");
    22552252          else
    2256             nc3=xmlNewNode(ns_wps, BAD_CAST e->format);
    2257       }
    2258       else {
    2259         map* tmpV=getMapFromMaps(m,"format","value");
     2253            nc3=xmlNewNode(ns_wps, BAD_CAST e->format);           
     2254      }
     2255      else {             
     2256        map* tmpV=getMapFromMaps(m,"format","value");   
    22602257        if(tmpV!=NULL)
    22612258          nc3=xmlNewNode(ns_wps, BAD_CAST tmpV->value);
     
    22632260          nc3=xmlNewNode(ns_wps, BAD_CAST "LiteralData");
    22642261      }
    2265       tmp=m->content;
    2266      
     2262      tmp=m->content;     
     2263
    22672264      while(tmp!=NULL){
    22682265        if(strcasecmp(tmp->name,"mimeType")==0 ||
     
    22702267           strcasecmp(tmp->name,"schema")==0 ||
    22712268           strcasecmp(tmp->name,"datatype")==0 ||
    2272            strcasecmp(tmp->name,"uom")==0) {
    2273          
     2269           strcasecmp(tmp->name,"uom")==0) {   
    22742270          if(vid==0)
    22752271            xmlNewProp(nc3,BAD_CAST tmp->name,BAD_CAST tmp->value);
     
    22822278          }
    22832279        }
     2280
    22842281        if(vid==0)
    22852282          xmlAddChild(nc2,nc3);
    2286         tmp=tmp->next;
     2283        tmp=tmp->next; 
    22872284      }
    22882285      if(e!=NULL && e->format!=NULL && strcasecmp(e->format,"BoundingBoxData")==0) {
     
    22952292        }
    22962293      }
    2297       else {
    2298         if(e!=NULL)
    2299           tmp=getMap(e->defaults->content,"mimeType");
     2294      else {             
     2295                  //if (e != NULL) {
     2296                  if (e != NULL && e->defaults != NULL) { // knut: add extra NULL pointer check in case user omits <Default> block in config file                         
     2297                          tmp = getMap(e->defaults->content, "mimeType");
     2298                  }
    23002299        else
    2301           tmp=NULL;
    2302        
     2300          tmp=NULL;     
    23032301        map* tmp1=getMap(m->content,"encoding");
    23042302        map* tmp2=getMap(m->content,"mimeType");
     
    26402638  dumpMaps(request_outputs);
    26412639  fprintf(stderr,"printProcessResponse\n");
    2642 #endif
     2640#endif 
    26432641  map* toto=getMap(request_inputs1,"RawDataOutput");
    26442642  int asRaw=0;
     
    27272725  }
    27282726
    2729   if(res!=SERVICE_SUCCEEDED){
     2727  if(res!=SERVICE_SUCCEEDED){     
    27302728    printProcessResponse(m,request_inputs1,cpid,
    27312729                         s, s->name,res,  // replace serviceProvider with serviceName in stored response file name
     
    27342732    return;
    27352733  }
    2736    
    2737        
     2734     
    27382735  map *tmp1=getMapFromMaps(m,"main","tmpPath");
    27392736  if(asRaw==0){
     
    27572754#endif
    27582755      map *gfile=getMap(tmpI->content,"generated_file");
    2759       char *file_name=NULL;
     2756      char *file_name=NULL;       
    27602757      if(gfile!=NULL){
    27612758        gfile=getMap(tmpI->content,"expected_generated_file");
     
    27652762        readGeneratedFile(m,tmpI->content,gfile->value);
    27662763        file_name=zStrdup((gfile->value)+strlen(tmp1->value));
    2767       }
     2764      }   
    27682765      toto=getMap(tmpI->content,"asReference");
    27692766#ifdef USE_MS
     
    27762773        if(toto!=NULL && strcasecmp(toto->value,"true")==0)
    27772774#endif
    2778           {
     2775          {             
    27792776            elements* in=getElements(s->outputs,tmpI->name);
    27802777            if(in==NULL && s->outputs->child!=NULL){
     
    27912788              addToMap(tmpI->content,"encoding","UTF-8");
    27922789              addToMap(tmpI->content,"schema","http://schemas.opengis.net/ows/1.1.0/owsCommon.xsd");
    2793             }
    2794 
     2790            }           
    27952791            char *file_path=NULL;
    27962792            if(gfile==NULL) {
     
    28802876          }
    28812877        }
    2882 #endif
     2878#endif 
    28832879      if(file_name!=NULL){
    28842880        free(file_name);
     
    28962892    fprintf(stderr,"SERVICE : %s\n",s->name);
    28972893    dumpMaps(m);
    2898 #endif
     2894#endif 
    28992895    if(error<0)
    29002896      printProcessResponse(m,request_inputs1,cpid,
  • branches/prototype-v0/zoo-project/zoo-kernel/response_print.h

    r880 r896  
    3838
    3939#include <libintl.h>
    40 #include <xlocale.h>
     40//#include <xlocale.h> //#include <xlocale>
     41#include <locale.h>
     42
    4143/**
    4244 * ZOO-Kernel internal messages translation function
     
    8082#endif
    8183#ifndef WIN32
    82 #include <locale.h>
     84//#include <locale.h>
     85#include <xlocale.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)
    8386#endif
    8487#include "ulinet.h"
  • branches/prototype-v0/zoo-project/zoo-kernel/service.c

    r890 r896  
    2525#include "service.h"
    2626
     27 // knut: time utilities required for new log function (logMessage)
     28#include <ctime>
     29#include <chrono>
     30#include <process.h>
    2731
    2832#if defined(_MSC_VER) && _MSC_VER < 1800
     
    507511 */
    508512void addToMap(map* m,const char* n,const char* v){
    509   if(hasKey(m,n)==false){
    510     map* _cursor=m;
    511     while(_cursor->next!=NULL){
    512       _cursor=_cursor->next;
    513     }
    514     _cursor->next=createMap(n,v);
    515   }
    516   else{
    517     map *tmp=getMap(m,n);
    518     if(tmp->value!=NULL)
    519       free(tmp->value);
    520     tmp->value=zStrdup(v);
    521   }
     513    if (m != NULL) { // knut: add NULL-pointer check
     514        if (hasKey(m, n) == false) {
     515            map* _cursor = m;
     516            while (_cursor->next != NULL) {
     517                _cursor = _cursor->next;
     518            }
     519            _cursor->next = createMap(n, v);
     520        }
     521        else {
     522            map *tmp = getMap(m, n);
     523            if (tmp->value != NULL)
     524                free(tmp->value);
     525            tmp->value = zStrdup(v);
     526        }
     527    }
    522528}
    523529
     
    16901696  m=&trorf;
    16911697}
     1698
     1699/**
     1700 * Verify that a map has a value
     1701 *
     1702 * @param map pointer to map that should be checked
     1703 * @return true if map has a value or false if value is missing/empty/NULL
     1704 */
     1705bool nonempty(map* map) {
     1706        return (map != NULL && map->value != NULL && strlen(map->value) > 0 && strcmp(map->value, "NULL") != 0);
     1707}
     1708
     1709/**
     1710 * Verify that a particular map value exists in a maps
     1711 * data structure, and obtain that value
     1712 *
     1713 * @param source pointer to maps structure
     1714 * @param node name of maps node to search
     1715 * @param key name of map node to find
     1716 * @param kvp address to the map* if it exists, otherwise NULL
     1717 * @return true if map has a value or false if value is missing/NULL
     1718 *
     1719 * @note The map assigned to kvp is owned by the source maps
     1720 */
     1721bool hasvalue(maps* source, const char* node, const char* key, map** kvp) {
     1722        *kvp = getMapFromMaps(source, node, key);
     1723        return (*kvp != NULL && (*kvp)->value != NULL &&
     1724                strlen((*kvp)->value) > 0 && strcmp((*kvp)->value, "NULL") != 0);
     1725}
     1726
     1727/*
     1728 * Set error message in configuration maps
     1729 *
     1730 * @param conf reference to configuration maps
     1731 * @param service name of service
     1732 * @param exc WPSException code
     1733 * @param message exception text (default: exception text in WPS specification)
     1734 */
     1735void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message) {
     1736
     1737        if (message == NULL) {
     1738                message = WPSExceptionText[exc];
     1739        }
     1740
     1741        size_t len = strlen(service) + strlen(": ") + strlen(message) + strlen(": ") + strlen(WPSExceptionCode[exc]) + 16;
     1742        char* msg = (char*)malloc(len * sizeof(char));
     1743
     1744        if (msg != NULL) {
     1745                snprintf(msg, len * sizeof(char), "\n%s: %s: %s\n", service, message, WPSExceptionCode[exc]);
     1746                setMapInMaps(conf, "lenv", "message", msg);
     1747                free(msg);
     1748        }
     1749}
     1750
     1751void logMessage(const char* source, const char* function, int line, const char* file, const char* message) { //, const char* source, const char* function, int line) {
     1752
     1753        size_t msglen = 512;
     1754        const char empty[] = "";
     1755
     1756        FILE* log;
     1757
     1758        // system time, process time [nanoseconds]   
     1759        unsigned long long sys_t, proc_t;
     1760
     1761        // processor time consumed by the program:
     1762        clock_t t = clock();
     1763
     1764        // system time:
     1765        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
     1766
     1767        std::time_t now_t = std::chrono::system_clock::to_time_t(now);
     1768        std::tm* tm = localtime(&now_t);
     1769        char* str = asctime(tm);
     1770        str[strlen(str) - 1] = '\0'; // remove newline
     1771
     1772        sys_t = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
     1773        //proc_t = (unsigned long long)(1.0e9*t/CLOCKS_PER_SEC);
     1774        proc_t = t;
     1775
     1776        if (message != NULL) {
     1777                msglen += strlen(message);
     1778        }
     1779        else {
     1780                message = empty;
     1781        }
     1782        //getLastErrorMessage(); // cgiScriptName 
     1783        char* text = (char*)malloc(sizeof(char)*msglen);
     1784
     1785        snprintf(text, msglen, "pid: %d %s line %d %s() %s systime: %lld ns ticks: %lld %s\n",
     1786                _getpid(), source, line, function, str, sys_t, proc_t, message); // __FILE__ __LINE__ __func__ //
     1787
     1788        if (file != NULL && (log = fopen(file, "a+")) != NULL) {
     1789                fputs(text, log);
     1790                fclose(log);
     1791        }
     1792        else {
     1793#ifdef MSG_LOG_FILE
     1794                if ((log = fopen(MSG_LOG_FILE, "a+")) != NULL) {
     1795                        fputs(text, log);
     1796                        fclose(log);
     1797                }
     1798#endif
     1799        }
     1800
     1801        if (text != NULL) free(text);
     1802}
     1803
     1804// knut:
     1805// Example:
     1806// zooLog;
     1807// zooLogMsg(NULL, getLastErrorMessage());
     1808// zooLogMsg("log.txt", getLastErrorMessage());
  • branches/prototype-v0/zoo-project/zoo-kernel/service.h

    r890 r896  
    3232#else
    3333#define ZOO_DLL_EXPORT
     34#endif
     35
     36 // knut: add bool if necessary
     37#ifndef __cplusplus
     38#ifndef WIN32
     39#include <stdbool.h>
     40#else
     41typedef int bool;
     42#define false 0
     43#define true 1 
     44#endif
     45#endif
     46#ifndef __bool_true_false_are_defined
     47#define __bool_true_false_are_defined 1
    3448#endif
    3549
     
    229243#ifdef WIN32
    230244#define NULLMAP ((map*) 0)
    231 #define bool int
    232 #define true 1
    233 #define false 0
     245// knut: see new definition above
     246//#define bool int
     247//#define true 1
     248//#define false 0
    234249#else
    235250#define NULLMAP NULL
     
    303318    struct registry* next; //!< the next registry pointer
    304319  } registry;
     320
     321  // knut
     322  enum WPSException {
     323          /*
     324          * StatusOK is not a WPS exception, it is added
     325          * here for convenience.
     326          */
     327          StatusOK,
     328          /*
     329          * See WPS 1.0 specification, Table 38 and Table 62.
     330          */
     331          MissingParameterValue,
     332          InvalidParameterValue,
     333          NoApplicableCode,
     334          NotEnoughStorage,
     335          ServerBusy,
     336          FileSizeExceeded,
     337          StorageNotSupported,
     338          VersionNegotiationFailed,
     339          /*
     340          * See WPS 2.0 specification, Tables 41, 46, 48, and 50.
     341          */
     342          NoSuchProcess,
     343          NoSuchMode,
     344          NoSuchInput,
     345          NoSuchOutput,
     346          DataNotAccessible,
     347          SizeExceeded,
     348          TooManyInputs,
     349          TooManyOutputs,
     350          NoSuchFormat,
     351          WrongInputData,
     352          InternalServerError,
     353          NoSuchJob,
     354          ResultNotReady
     355  };
     356
     357  static const char* const WPSExceptionCode[] = {
     358        "StatusOK",
     359        "MissingParameterValue",
     360        "InvalidParameterValue",
     361        "NoApplicableCode",
     362        "NotEnoughStorage",
     363        "ServerBusy",
     364        "FileSizeExceeded",
     365        "StorageNotSupported",
     366        "VersionNegotiationFailed",
     367        "NoSuchProcess",
     368        "NoSuchMode",
     369        "NoSuchInput",
     370        "NoSuchOutput",
     371        "DataNotAccessible",
     372        "SizeExceeded",
     373        "TooManyInputs",
     374        "TooManyOutputs",
     375        "NoSuchFormat",
     376        "WrongInputData",
     377        "InternalServerError",
     378        "NoSuchJob",
     379        "ResultNotReady"
     380  };
     381
     382  static const char* const WPSExceptionText[] = {
     383        "No problem detected",
     384        "Operation request does not include a parameter value, and this server did not declare a default value for that parameter.",
     385        "Operation request contains an invalid parameter value.",
     386        "No other exceptionCode specified by this service and server applies to this exception.",
     387        "The server does not have enough space available to store the inputs and outputs associated with the request.",
     388        "The server is too busy to accept and queue the request at this time.",
     389        "The file size of one of the input parameters was too large for this process to handle.",
     390        "Execute operation request included transmission=”reference” for one of the outputs, but storage is not offered by this server.",
     391        "Service version for a ComplexData xlink:href input was not supported by the referenced server, and version negotiation failed.",
     392        "One of the identifiers passed does not match with any of the processes offered by this server.",
     393        "The process does not permit the desired execution mode.",
     394        "One or more of the input identifiers passed does not match with any of the input identifiers of this process.",
     395        "One or more of the output identifiers passed does not match with any of the input identifiers of this process.",
     396        "One of the referenced input data sets was inaccessible.",
     397        "The size of one of the input parameters was too large for this process to handle.",
     398        "Too many input items have been specified.",
     399        "Too many output items have been specified.",
     400        "One or more of the input or output formats specified in the request did not match with any of the formats defined for that particular input or output.",
     401        "One or more of inputs for which the service was able to retrieve the data but could not read it.",
     402        "",
     403        "The JobID from the request does not match any of the Jobs running on this server.",
     404        "The result for the requested JobID has not yet been generated."
     405  };
    305406
    306407  ZOO_DLL_EXPORT void _dumpMap(map*);
     
    370471  ZOO_DLL_EXPORT int snprintf(char *buffer, size_t n, const char *format, ...);
    371472#endif
     473
     474  // knut: some new utility functions; logMessage is primarily intended for debugging   
     475  ZOO_DLL_EXPORT bool nonempty(map* map);
     476  ZOO_DLL_EXPORT bool hasvalue(maps* source, const char* node, const char* key, map** kvp);
     477  ZOO_DLL_EXPORT void setErrorMessage(maps*& conf, const char* service, WPSException exc, const char* message = NULL);
     478  ZOO_DLL_EXPORT void logMessage(const char* source, const char* function, int line, const char* file = NULL, const char* message = NULL);
     479  #define zooLogMsg(file,message) logMessage(__FILE__, __func__, __LINE__, (file), (message))
     480  #define zooLog logMessage(__FILE__, __func__, __LINE__) 
     481
    372482#ifdef __cplusplus
    373483}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c

    r890 r896  
    917917}
    918918
     919/**
     920 * Check if file exists in specified folder
     921 *
     922 * @param dir the folder in which to search for file
     923 * @param name the name of the file (not full path)
     924 * @return a character string with the full path [dir/name], or NULL if the file does not exist
     925 *
     926 * @attention Caller is responsible for applying free() to the returned pointer
     927 */
     928char* file_exists(const char* dir, const char* name) {
     929        char* d = (dir != NULL ? dir : ".");
     930        if (name != NULL) {
     931                size_t length = strlen(d) + strlen(name) + 2; // including file separator and \0 character
     932                char* path = (char*)calloc(length, sizeof(char));
     933                snprintf(path, length, "%s/%s", d, name);
     934
     935                struct stat buffer;
     936                if (stat(path, &buffer) != 0) {
     937                        free(path);
     938                        path = NULL;
     939                }
     940                return path;
     941        }
     942        else {
     943                return NULL;
     944        }
     945}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal.h

    r891 r896  
    3838
    3939#include <libintl.h>
    40 #include <xlocale.h>
     40#include <locale.h>
    4141/**
    4242 * ZOO-Kernel internal messages translation function
     
    162162  ZOO_DLL_EXPORT int unlockShm(semid);
    163163
     164  ZOO_DLL_EXPORT char* file_exists(const char* dir, const char* name);
     165
    164166#ifdef __cplusplus
    165167}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_mono.c

    r794 r896  
    3030#include "response_print.h"
    3131
     32MonoClass *iclasses[4];
     33MonoMethod *imethods[10];
     34
    3235/**
    3336 * Load a Mono dll then run the static public method corresponding to the
     
    6972    mono_config_parse(NULL);
    7073
    71   MonoDomain* monoDomain = mono_jit_init_version("ZOO_Embedded_Domain",
    72                                                  "v4.0.30319");
    73 
    74   map* cwdMap=getMapFromMaps(*main_conf,"main","servicePath");
    75   if(cwdMap==NULL)
    76     cwdMap=getMapFromMaps(*main_conf,"lenv","cwd");
    77  
    78   char *zooAssembly=(char*)malloc((strlen(cwdMap->value)+11)*sizeof(char));
    79   sprintf(zooAssembly,"%s/ZMaps.dll",cwdMap->value);
    80   assembly = mono_domain_assembly_open(monoDomain,zooAssembly);
    81   if(assembly==NULL){
    82     setMapInMaps(*main_conf,"lenv","message",_("The ZMaps.dll assembly cannot be found!"));
    83     return 4;
    84   }
    85   mono_add_internal_call ("ZOO_API::Translate", MonoTranslate);
    86   mono_add_internal_call ("ZOO_API::UpdateStatus", MonoUpdateStatus);
    87 
     74  MonoDomain* monoDomain;
     75  map* mono;
     76  if (hasvalue(*main_conf, "mono", "version", &mono)) {   
     77          monoDomain = mono_jit_init_version("ZOO_Embedded_Domain", mono->value);
     78  }
     79  else {         
     80          monoDomain = mono_jit_init("ZOO_Embedded_Domain"); // use default framework version
     81  }
     82
     83  //MonoDomain* monoDomain = mono_jit_init_version("ZOO_Embedded_Domain", "v4.0.30319");
     84  //MonoDomain* monoDomain = mono_jit_init("ZOO_Embedded_Domain"); 
     85
     86  char* ZMapsLib = "ZMaps.dll";
     87  char *zooAssembly = NULL;
     88 
     89  map* config = NULL, *basedir = NULL;
     90  if (hasvalue(*main_conf, "mono", "configdir", &basedir) && // knut: rename to e.g. "base_dir"?
     91          hasvalue(*main_conf, "mono", "configfile", &config)) {         
     92          mono_domain_set_config(monoDomain, basedir->value, config->value);
     93          zooAssembly = file_exists(basedir->value, ZMapsLib);
     94  }
     95  else {         
     96          mono_domain_set_config(monoDomain, "./", "");
     97  }   
     98
     99  map* cwdMap;
     100  if (! hasvalue(*main_conf, "main", "servicePath", &cwdMap) &&
     101          ! hasvalue(*main_conf, "main", "libPath", &cwdMap) ) {
     102          cwdMap = getMapFromMaps(*main_conf, "lenv", "cwd");
     103  } 
     104
     105  if (zooAssembly != NULL || (zooAssembly = file_exists(cwdMap->value, ZMapsLib)) != NULL) {
     106          assembly = mono_domain_assembly_open(monoDomain, zooAssembly);
     107  }
     108  else {
     109          // try to load from default locations (GAC?)
     110          assembly = mono_domain_assembly_open(monoDomain, ZMapsLib);
     111  } 
     112  free(zooAssembly);
     113
     114  if (assembly == NULL) {
     115          setMapInMaps(*main_conf, "lenv", "message", _("The ZMaps.dll assembly cannot be found!"));
     116          return 4;
     117  }
     118
     119  mono_add_internal_call ("ZOO_API::Translate", MonoTranslate);   
     120  mono_add_internal_call("ZOO_API::UpdateStatus", MonoUpdateStatus);
     121 
    88122  monoImage = mono_assembly_get_image(assembly);
    89123  MonoClass *KeysList = mono_class_from_name(monoImage, "ZooGenerics", "KeysList");
     
    104138  MonoClass *classes[3]={_ZMapsClass,ZMapsClass,ZMapClass};
    105139  MonoMethod *methods[5]={ZMapsAdd,_ZMapsSetContent,_ZMapsSetChild,ZMapAdd,ZMapDisplay};
    106 
     140 
    107141  MonoMethod *ZMapsGetKeys = mono_class_get_method_from_name(ZMapsClass, "getKeys", 0);
     142 
    108143  MonoMethod *ZMapsGetKeysCount = mono_class_get_method_from_name(ZMapsClass, "getKeysCount", 0);
    109144  MonoMethod *ZMapsGetKey = mono_class_get_method_from_name(ZMapsClass, "getKey", 1);
     
    116151  MonoClass *oclasses[4]={_ZMapsClass,ZMapsClass,ZMapClass,KeysList};
    117152  MonoMethod *omethods[10]={ZMapsGetMaps,ZMapsGetKeysCount,ZMapsGetKey,ZMapGetMap,ZMapGetKeysCount,ZMapGetKey,_ZMapsGetContent,_ZMapsGetChild,ZMapGetSize,ZMapGetMapAsBytes};
    118 
     153 
    119154  for(int i=0;i<4;i++){
    120155    iclasses[i]=oclasses[i];
     
    131166
    132167  MonoObject * out=ZMapsFromMaps(monoDomain,classes,methods,&exc,outputs);
    133 
     168 
    134169  args [0] = main;
    135170  args [1] = in;
    136171  args [2] = out;
    137172
    138   tmp=getMap(s->content,"serviceProvider");
    139   char *sName=(char*)malloc((strlen(tmp->value)+strlen(cwdMap->value)+2)*sizeof(char));
    140   sprintf(sName,"%s/%s",cwdMap->value,tmp->value);
    141   MonoAssembly* serviceAssembly = mono_domain_assembly_open(monoDomain,sName);
     173  char* sName = NULL;
     174  MonoAssembly* serviceAssembly = NULL;
     175 
     176  tmp = getMap(s->content, "serviceProvider"); 
     177  char* test = file_exists(NULL, "log.txt");
     178  if ( (sName = file_exists(cwdMap->value, tmp->value)) != NULL ||
     179           (sName = file_exists(".", tmp->value)) != NULL ||  // in case servicePath is defined but serviceProvider is in working directory
     180           (basedir != NULL && (sName = file_exists(basedir->value, tmp->value)) != NULL) ) {
     181
     182           serviceAssembly = mono_domain_assembly_open(monoDomain, sName);
     183  }
     184  else {
     185          // try to open from default locations   
     186          serviceAssembly = mono_domain_assembly_open(monoDomain, tmp->value);
     187  }
     188  free(sName);
     189
     190  //char *sName=(char*)malloc((strlen(tmp->value)+strlen(cwdMap->value)+2)*sizeof(char));
     191  //sprintf(sName,"%s/%s",cwdMap->value,tmp->value);
     192  //MonoAssembly* serviceAssembly = mono_domain_assembly_open(monoDomain,sName);
     193 
    142194  if(serviceAssembly==NULL){
    143195    char *msg=(char*)malloc((strlen(_("Your service assembly: %s cannot be found!"))+strlen(tmp->value)+1)*sizeof(char));
     
    147199    return 4;
    148200  }
    149 
     201 
    150202  MonoImage* serviceImage = mono_assembly_get_image(serviceAssembly);
    151203
    152204  map* tmp1=getMap(s->content,"serviceNameSpace");
     205 
    153206  tmp=getMap(s->content,"serviceClass");
    154207  MonoClass *serviceClass = mono_class_from_name(serviceImage, tmp1->value, tmp->value);
     
    160213    return 4;
    161214  }
     215 
    162216  MonoMethod *serviceFunction = mono_class_get_method_from_name(serviceClass, s->name, 3);
    163217  if(serviceFunction==NULL){
     
    168222    return 4;
    169223  }
     224 
    170225  MonoObject *exception=NULL;
    171226  MonoObject *result = mono_runtime_invoke(serviceFunction,NULL,args,&exception);
     227 
     228  if (exception != NULL) { // knut: add exception handling
     229          MonoString* pMsg = mono_object_to_string(exception, NULL);     
     230          setErrorMessage(*main_conf, s->name, NoApplicableCode, mono_string_to_utf8(pMsg));
     231          return 4;
     232  }
     233
    172234  res=*(int*)mono_object_unbox (result);
     235 
    173236  if(res==3){
    174237    freeMaps(&outputs);
    175238    free(outputs);
    176     outputs=mapsFromZMaps(monoDomain,oclasses,omethods,args[2]);
     239    outputs=mapsFromZMaps(monoDomain,oclasses,omethods,(MonoObject*)args[2]);
    177240    *real_outputs=outputs;
    178241  }
     242 
    179243  freeMaps(&m);
    180244  free(m);
    181   m=mapsFromZMaps(monoDomain,oclasses,omethods,args[0]);
     245  m=mapsFromZMaps(monoDomain,oclasses,omethods,(MonoObject*)args[0]);
    182246  *main_conf=m;
    183   mono_jit_cleanup (monoDomain);
     247  mono_jit_cleanup (monoDomain); 
    184248  return res;
    185249}
     
    288352      values[0]=&i;
    289353      exc=NULL;
    290       MonoObject *okey = (MonoString*) mono_runtime_invoke(methods[2],m,values,&exc);
     354      MonoString *okey = (MonoString*) mono_runtime_invoke(methods[2],m,values,&exc);
    291355      char* key = mono_string_to_utf8(okey);
    292356      maps* tmp=createMaps(key);
    293357      values[0]=mono_string_new (domain, key);
    294       MonoObject *content_ZMaps = (MonoString*) mono_runtime_invoke(methods[0],m,values,&exc);
    295       MonoObject *content = mono_runtime_invoke(methods[6],content_ZMaps,NULL,&exc);
     358      MonoString *content_ZMaps = (MonoString*) mono_runtime_invoke(methods[0],m,values,&exc);
     359      MonoObject *content = mono_runtime_invoke(methods[6],(MonoObject*)content_ZMaps,NULL,&exc);
    296360      tmp->content=mapFromZMap(domain,classes,methods,content);
    297361      MonoObject *childs = mono_runtime_invoke(methods[7],content_ZMaps,NULL,&exc);
     
    329393      values[0]=&i;
    330394      exc=NULL;
    331       MonoObject *okey = (MonoString*) mono_runtime_invoke(methods[5],m,values,&exc);
     395      MonoString *okey = (MonoString*) mono_runtime_invoke(methods[5],m,values,&exc);
    332396      char* key = mono_string_to_utf8(okey);
    333397      values[0]=mono_string_new (domain, key);
    334398      exc=NULL;
    335       MonoObject *ovalue = (MonoString*) mono_runtime_invoke(methods[3],m,values,&exc);
     399      MonoString *ovalue = (MonoString*) mono_runtime_invoke(methods[3],m,values,&exc);
    336400      char* value = mono_string_to_utf8(ovalue);
    337401      if(res==NULL)
     
    350414 */
    351415static MonoString* MonoTranslate(MonoString *str){
    352   return mono_string_new (mono_domain_get(), mono_string_to_utf8(_(str)));
     416  return mono_string_new (mono_domain_get(), _(mono_string_to_utf8(str)));
    353417}
    354418
     
    360424 * @return the translated string
    361425 */
    362 static void MonoUpdateStatus(MonoObject* obj,MonoString *str,int* p){
    363   MonoDomain* domain = mono_object_get_domain (obj);
    364   maps *confMaps=mapsFromZMaps(domain,iclasses,imethods,obj);
    365   setMapInMaps(confMaps,"lenv","message",mono_string_to_utf8(str));
    366   int tmp=p;
    367   if (p < 0 || p > 100){
    368     tmp=-1;
    369   }
    370   char tmpStatus[5];
    371   snprintf(tmpStatus, 4, "%d", tmp);
    372   setMapInMaps(confMaps,"lenv","status",(char*)tmpStatus);
    373   _updateStatus(confMaps);
    374   freeMaps(&confMaps);
    375   free(confMaps);
    376   return;
    377 }
     426static void MonoUpdateStatus(MonoObject* obj, MonoString *str, int p) {
     427        MonoDomain* domain = mono_object_get_domain(obj);       
     428        maps *confMaps = mapsFromZMaps(domain, iclasses, imethods, obj);       
     429        setMapInMaps(confMaps, "lenv", "message", mono_string_to_utf8(str));   
     430        int tmp = p > 100 || p < 0 ? -1 : p;   
     431        char tmpStatus[5];
     432        snprintf(tmpStatus, 4, "%d", tmp);     
     433        setMapInMaps(confMaps, "lenv", "status", (char*)tmpStatus);     
     434        _updateStatus(confMaps);       
     435        freeMaps(&confMaps);   
     436        free(confMaps);
     437        return;
     438}
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_mono.h

    r794 r896  
    4545  map* mapFromZMap(MonoDomain*,MonoClass**,MonoMethod**,MonoObject*);
    4646  static MonoString* MonoTranslate(MonoString*);
    47   static void MonoUpdateStatus(MonoObject*,MonoString*,int*);
    48   MonoClass *iclasses[4];
    49   MonoMethod *imethods[10];
     47  //static void MonoUpdateStatus(MonoObject*,MonoString*,int*);
     48  static void MonoUpdateStatus(MonoObject*, MonoString*, int);
     49  //MonoClass *iclasses[4]; // knut: move declarations to service_internal_mono.c
     50  //MonoMethod *imethods[10];
    5051
    5152#ifdef __cplusplus
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_php7.c

    r796 r896  
    2525#ifdef WIN32
    2626  #define NO_FCGI_DEFINES
     27  #define ZEND_WIN32_KEEP_INLINE
    2728#endif
    2829
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c

    r890 r896  
    146146 */
    147147int zoo_python_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
     148
    148149  char *pythonpath;
    149150  char *python_path;
     151
     152#ifdef WIN32
     153  char* os_pathsep = ";";
     154#else
     155  char* os_pathsep = ":";
     156#endif
     157
    150158  maps* m=*main_conf;
    151159  maps* inputs=*real_inputs;
    152160  maps* outputs=*real_outputs;
    153161  map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd");
    154   char *ntmp=tmp0->value;
     162  char *ntmp=tmp0->value; 
    155163  map* tmp=NULL;
    156164  int hasToClean=0;
    157   tmp=getMapFromMaps(*main_conf,"env","PYTHONPATH");
     165  tmp=getMapFromMaps(*main_conf,"env","PYTHONPATH");
     166
     167  map* kvp = NULL;
     168  char* libPath = NULL;
     169  if (hasvalue(*main_conf, "main", "libPath", &kvp)) {
     170          libPath = kvp->value;
     171  }
     172  else {
     173          libPath = "";
     174  }
     175
    158176#ifdef DEBUG
    159177  fprintf(stderr,"PYTHON SUPPORT \n");
     
    172190      python_path=cwdMap->value;
    173191    else
    174       python_path=(char*)".";
     192      python_path=(char*)".";   
    175193  }
    176194  tmp=NULL;
    177195  tmp=getMap(request,"metapath");
    178196  if(tmp!=NULL && strcmp(tmp->value,"")!=0){
    179     pythonpath=(char*)malloc((4+strlen(python_path)+strlen(ntmp)+strlen(tmp->value))*sizeof(char));
     197    //pythonpath=(char*)malloc((4+strlen(python_path)+strlen(ntmp)+strlen(tmp->value))*sizeof(char));
     198          pythonpath = (char*)malloc((5 + strlen(python_path) + strlen(ntmp) + strlen(tmp->value) + strlen(libPath)) * sizeof(char));
    180199#ifdef WIN32
    181   sprintf(pythonpath,"%s/%s/;%s",ntmp,tmp->value,python_path);
     200  //sprintf(pythonpath,"%s/%s/;%s",ntmp,tmp->value,python_path);
     201        sprintf(pythonpath, "%s/%s/;%s;%s", ntmp, tmp->value, python_path, libPath);
    182202#else
    183   sprintf(pythonpath,"%s/%s/:%s",ntmp,tmp->value,python_path);
     203  //sprintf(pythonpath,"%s/%s/:%s",ntmp,tmp->value,python_path);
     204  sprintf(pythonpath, "%s/%s/:%s:%s", ntmp, tmp->value, python_path, libPath); 
    184205#endif
    185206  }
    186207  else{
    187     pythonpath=(char*)malloc((2+strlen(python_path)+strlen(ntmp))*sizeof(char));
     208    //pythonpath=(char*)malloc((2+strlen(python_path)+strlen(ntmp))*sizeof(char));
     209          pythonpath = (char*)malloc((3 + strlen(python_path) + strlen(ntmp) + strlen(libPath)) * sizeof(char));
    188210#ifdef WIN32
    189     sprintf(pythonpath,"%s;%s",ntmp,python_path);
     211    //sprintf(pythonpath,"%s;%s",ntmp,python_path);
     212        sprintf(pythonpath, "%s;%s;%s", ntmp, python_path, libPath);
    190213#else
    191     sprintf(pythonpath,"%s:%s",ntmp,python_path);
    192 #endif
     214    //sprintf(pythonpath,"%s:%s",ntmp,python_path);
     215        sprintf(pythonpath, "%s:%s:%s", ntmp, python_path, libPath);
     216#endif 
    193217  }
    194218#ifdef DEBUG
    195219    fprintf(stderr,"PYTHONPATH=%s\n",pythonpath);
    196220#endif
    197 #ifndef WIN32
    198   setenv("PYTHONPATH",pythonpath,1);
    199 #else
     221        map* home = NULL;
     222// knut: also set PYTHONHOME environment variable so that Python can load standard modules
     223#ifndef WIN32   
     224  setenv("PYTHONPATH",pythonpath,1); 
     225  //= getMapFromMaps(*main_conf, "env", "PYTHONHOME");
     226  if (hasvalue(*main_conf, "env", "PYTHONHOME", &home)) {
     227          setenv("PYTHONHOME", home->value, 1); // overwrite
     228  }
     229#else   
    200230  SetEnvironmentVariable("PYTHONPATH",pythonpath);
    201231  char* toto=(char*)malloc((strlen(pythonpath)+12)*sizeof(char));
     
    203233  _putenv(toto);
    204234  free(toto);
    205 #endif
     235  if (hasvalue(*main_conf, "env", "PYTHONHOME", &home)) {
     236          SetEnvironmentVariable("PYTHONHOME", home->value);
     237  }
     238  char buffer[128];       
     239#endif 
    206240  if(hasToClean>0)
    207241    free(python_path);
     
    209243
    210244  PyThreadState *mainstate;
    211 #if PY_MAJOR_VERSION >= 3
    212   PyImport_AppendInittab("zoo", init_zoo);
     245#if PY_MAJOR_VERSION >= 3 
     246  PyImport_AppendInittab("zoo", init_zoo); 
    213247#else
    214248  PyEval_InitThreads();
    215 #endif
    216   Py_Initialize();
    217 #if PY_MAJOR_VERSION >= 3
     249#endif 
     250  Py_Initialize(); 
     251#if PY_MAJOR_VERSION >= 3 
    218252  PyEval_InitThreads();
    219   PyImport_ImportModule("zoo");
     253  PyImport_ImportModule("zoo"); 
    220254#else
    221255  init_zoo();
    222 #endif
     256#endif 
    223257  mainstate = PyThreadState_Swap(NULL);
    224258  PyEval_ReleaseLock();
     
    240274      char *mn=(char*)malloc((strlen(mps)+strlen(tmp->value)+2)*sizeof(char));
    241275      sprintf(mn,"%s.%s",mps,tmp->value);
    242       pName = PyString_FromString(mn);
     276      pName = PyString_FromString(mn);   
    243277      free(mn);
    244278      free(mps);
     
    251285    errorException (m, "Unable to parse serviceProvider please check your zcfg file.", "NoApplicableCode", NULL);
    252286    exit(-1);
    253   }
    254   pModule = PyImport_Import(pName);
     287  } 
     288  pModule = PyImport_Import(pName);   
    255289  int res=SERVICE_FAILED;
    256290  if (pModule != NULL) {
     
    267301      PyTuple_SetItem(pArgs, 1, (PyObject *)arg2);
    268302      PyTuple_SetItem(pArgs, 2, (PyObject *)arg3);
    269       pValue = PyObject_CallObject(pFunc, pArgs);
     303      pValue = PyObject_CallObject(pFunc, pArgs);         
    270304      if (pValue != NULL) {
    271305        res=PyInt_AsLong(pValue);
     
    275309        free(*main_conf);
    276310        *main_conf=mapsFromPyDict(arg1);
    277         *real_outputs=mapsFromPyDict(arg3);
     311        *real_outputs=mapsFromPyDict(arg3);     
    278312#ifdef DEBUG
    279313        fprintf(stderr,"Result of call: %i\n", PyInt_AsLong(pValue));
     
    301335#endif
    302336  PyThreadState_Swap(mainstate);
    303   Py_Finalize();
     337  Py_Finalize(); 
    304338  return res;
    305339}
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c

    r891 r896  
    118118        ;
    119119#endif
    120     tmp=strtok(buffer,";");
     120    tmp=strtok((char*) buffer,";"); // knut: added cast to char*
    121121    int cnt=0;
    122122    _HINTERNET *psInternet=(_HINTERNET *)data;
     
    322322 * @return 1 if the host is listed as protected, 0 in other case
    323323 */
    324 int isProtectedHost(const char* protectedHosts,const char* url){
    325   char *token, *saveptr;
    326   token = strtok_r (url, "//", &saveptr);
    327   int cnt=0;
    328   char* host;
    329   while(token!=NULL && cnt<=1){
    330     if(cnt==1 && strstr(protectedHosts,token)!=NULL){
    331       return 1;
    332     }
    333     token = strtok_r (NULL, "/", &saveptr);
    334     cnt+=1;
    335   }
    336   return 0;
     324int isProtectedHost(const char* protectedHosts, const char* url) {
     325        char *token, *saveptr;
     326        int cnt;
     327        char* host;
     328
     329        // knut: make a copy of url since strtok family modifies first argument and cannot be used on constant strings 
     330        char* urlcpy = (char*)malloc(sizeof(char)*(strlen(url) + 1));
     331        urlcpy = strncpy(urlcpy, url, strlen(url) + 1); // since count > strlen(url), a null character is properly appended
     332
     333        //token = strtok_r (url, "//", &saveptr);
     334        token = strtok_r(urlcpy, "//", &saveptr);   // knut
     335        cnt = 0;
     336        while (token != NULL && cnt <= 1) {
     337                fprintf(stderr, "%s %d %s \n", __FILE__, __LINE__, token);
     338                if (cnt == 1)
     339                        fprintf(stderr, "%s %d %s \n", __FILE__, __LINE__, strstr(protectedHosts, token));
     340                fflush(stderr);
     341                if (cnt == 1 && strstr(protectedHosts, token) != NULL) {
     342                        fprintf(stderr, "%s %d %s \n", __FILE__, __LINE__, strstr(protectedHosts, token));
     343                        free(urlcpy);
     344                        return 1;
     345                }
     346                token = strtok_r(NULL, "/", &saveptr);
     347                cnt += 1;
     348        }
     349        free(urlcpy);
     350        return 0;
    337351}
    338352
     
    457471  int ldwFlags=INTERNET_FLAG_NEED_FILE;
    458472  struct MemoryStruct header;
    459   map* memUse=getMapFromMaps(conf,"main","memory");
     473  map* memUse=getMapFromMaps((maps*) conf,"main","memory"); // knut: addad cast to maps*
    460474
    461475  hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
     
    505519      map* tmpPath=NULL;
    506520      if(conf!=NULL){
    507         tmpPath=getMapFromMaps(conf,"main","tmpPath");
     521        tmpPath=getMapFromMaps((maps*) conf,"main","tmpPath"); // knut added cast to maps*
    508522      }
    509523      if(tmpPath==NULL)
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h

    r880 r896  
    4646#endif
    4747#ifndef __cplusplus
    48 #ifndef bool
    49 #define bool int
    50 #endif
    51 #ifndef true
    52 #define true 1
    53 #define false 0
    54 #endif
     48// knut: see new def of bool in service.h
     49//#ifndef bool
     50//#define bool int
     51//#endif
     52//#ifndef true
     53//#define true 1
     54//#define false 0
     55//#endif
    5556#endif
    5657
     
    157158  typedef size_t* LPDWORD;
    158159#endif
    159 #ifndef bool
    160 #define bool int
    161 #endif
     160// knut: see new definition of bool in service.h
     161//#ifndef bool
     162//#define bool int
     163//#endif
    162164
    163165#  define CHECK_INET_HANDLE(h) (h.handle != 0)
  • branches/prototype-v0/zoo-project/zoo-kernel/zoo_loader.c

    r877 r896  
    123123       if(res!=NULL)
    124124         free(res);
    125     }else{
     125    }else{             
    126126      char *buffer=new char[cgiContentLength+1];
    127127      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)>0){
     
    163163    }   
    164164  }
    165   else{
     165  else{   
    166166#ifdef DEBUG
    167167    dumpMap(tmpMap);
     
    187187    cgiStringArrayFree(array);
    188188  }
    189 
     189 
    190190#ifdef WIN32
    191   map *tmpReq=getMap(tmpMap,"rfile");
    192   if(tmpReq!=NULL){
    193     FILE *lf=fopen(tmpReq->value,"r");
     191  map *tmpReq=getMap(tmpMap,"rfile"); 
     192  if(tmpReq!=NULL){               
     193    FILE *lf=fopen(tmpReq->value,"r"); 
    194194    fseek(lf,0,SEEK_END);
    195195    long flen=ftell(lf);
     
    395395    }
    396396  }
    397 
     397 
    398398  if(strncasecmp(cgiContentType,"multipart/form-data",19)==0){
    399399    map* tmp=getMap(tmpMap,"dataInputs");
     
    408408  if(strQuery!=NULL)
    409409    free(strQuery);
    410 
     410 
    411411  runRequest(&tmpMap);
    412412
  • branches/prototype-v0/zoo-project/zoo-kernel/zoo_service_loader.c

    r893 r896  
    229229  fread (tmps1, flen, 1, f2);
    230230#ifdef WIN32
     231  /* knut: I think this block can be dropped; pchr may be NULL if result is not in XML format
    231232  char *pchr=strrchr(tmps1,'>');
    232233  flen=strlen(tmps1)-strlen(pchr)+1;
    233234  tmps1[flen]=0;
     235  */
    234236#endif
    235237  fwrite (tmps1, 1, flen, f3);
     
    483485#endif
    484486
    485   map* libp = getMapFromMaps(m, "main", "libPath");
    486 
     487  map* libp = getMapFromMaps(m, "main", "libPath"); 
    487488  if (strlen (r_inputs->value) == 1
    488489      && strncasecmp (r_inputs->value, "C", 1) == 0)
     
    707708#ifdef USE_PYTHON
    708709  if (strncasecmp (r_inputs->value, "PYTHON", 6) == 0)
    709     {    
     710    {            
    710711      *eres =
    711712        zoo_python_support (&m, request_inputs, s1,
    712713                            &request_input_real_format,
    713                             &request_output_real_format);
     714                            &request_output_real_format);         
    714715    }
    715716  else
     
    798799    }
    799800  *myMap = m;
    800   *ioutputs = request_output_real_format;
     801  *ioutputs = request_output_real_format; 
    801802}
    802803
     
    23592360        dumpMapsValuesToFiles(&m,&request_input_real_format);
    23602361      loadServiceAndRun (&m, s1, request_inputs, &request_input_real_format,
    2361                          &request_output_real_format, &eres);
     2362                         &request_output_real_format, &eres);     
    23622363
    23632364#ifdef META_DB
     
    25932594        }
    25942595    }
    2595 
     2596       
    25962597#ifdef DEBUG
    25972598  fprintf (stderr, "RUN IN BACKGROUND MODE %s %d \n",__FILE__,__LINE__);
     
    26022603  rewind(stdout);
    26032604
    2604   //fprintf(stderr,"%s %d %d\n",__FILE__,__LINE__,eres);
    2605 
     2605  //fprintf(stderr,"%s %d %d\n",__FILE__,__LINE__,eres); 
    26062606  if (eres != -1)
    26072607    outputResponse (s1, request_input_real_format,
     
    26092609                    cpid, m, eres);
    26102610  fflush (stdout);
    2611 
     2611 
    26122612  /**
    26132613   * Ensure that if error occurs when freeing memory, no signal will return
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png