Ignore:
Timestamp:
Feb 12, 2014, 3:25:15 PM (10 years ago)
Author:
djay
Message:

Add the optional Ruby Language Support to the ZOO-Kernel with an API similar to the Python ZOO-API. Small rewrite of Python support. Fix issue #86 and #87. Add usid in [lenv] section, this value is used to generate an unique identifier based on time and the process identifier. This usid is now used to name the stored result or the mapfile generated. Remove *some* warning messages displayed at compilation time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r452 r453  
    6464#endif
    6565
     66#ifdef USE_RUBY
     67#include "service_internal_ruby.h"
     68#endif
     69
    6670#ifdef USE_PERL
    6771#include "service_internal_perl.h"
     
    9195#ifndef USE_MS
    9296 {
    93   char *x=_strdup(a);
    94   char *y=_strdup(b);
     97  char *x=_zStrdup(a);
     98  char *y=_zStrdup(b);
    9599 
    96100  x=_strlwr(x);
     
    250254    else
    251255      sprintf(tmps1,"%s/",ntmp);
    252     char *altPath=strdup(tmps1);
     256    char *altPath=zStrdup(tmps1);
    253257    r_inputs=getMap(s1->content,"ServiceProvider");
    254258    sprintf(tmps1,"%s/%s",altPath,r_inputs->value);
     
    419423            else
    420424#endif
     425
     426#ifdef USE_RUBY
     427          if(strncasecmp(r_inputs->value,"Ruby",4)==0){
     428            *eres=zoo_ruby_support(&m,request_inputs,s1,&request_input_real_format,&request_output_real_format);
     429          }
     430          else
     431#endif
     432
    421433              {
    422434                char tmpv[1024];
     
    479491    free(r_inputs1);
    480492  }
    481   char *tmp1=strdup(tmp);
     493  char *tmp1=zStrdup(tmp);
    482494  sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
    483495 
     
    594606    r_inputs=getMapFromMaps(m,"main","language");
    595607  if(r_inputs!=NULL){
    596     char *tmp=strdup(r_inputs->value);
     608    char *tmp=zStrdup(r_inputs->value);
    597609    setMapInMaps(m,"main","language",tmp);
    598610    translateChar(tmp,'-','_');
     
    650662  }
    651663  else{
    652     REQUEST=strdup(r_inputs->value);
     664    REQUEST=zStrdup(r_inputs->value);
    653665    if(strncasecmp(r_inputs->value,"GetCapabilities",15)!=0
    654666       && strncasecmp(r_inputs->value,"DescribeProcess",15)!=0
     
    689701  map* tmpm=getMapFromMaps(m,"main","serverAddress");
    690702  if(tmpm!=NULL)
    691     SERVICE_URL=strdup(tmpm->value);
     703    SERVICE_URL=zStrdup(tmpm->value);
    692704  else
    693     SERVICE_URL=strdup(DEFAULT_SERVICE_URL);
     705    SERVICE_URL=zStrdup(DEFAULT_SERVICE_URL);
    694706
    695707  service* s1;
     
    883895    snprintf(tmps1,1024,"%s/",ntmp);
    884896  r_inputs=getMap(request_inputs,"Identifier");
    885   char *ttmp=strdup(tmps1);
     897  char *ttmp=zStrdup(tmps1);
    886898  snprintf(tmps1,1024,"%s/%s.zcfg",ttmp,r_inputs->value);
    887899  free(ttmp);
     
    956968#endif
    957969      char cursor_output[10240];
    958       char *cotmp=strdup(r_inputs->value);
     970      char *cotmp=zStrdup(r_inputs->value);
    959971      snprintf(cursor_output,10240,"%s",cotmp);
    960972      free(cotmp);
     
    9901002      }
    9911003      for(j=0;j<i;j++){
    992         char *tmp=strdup(outputs_as_text[j]);
     1004        char *tmp=zStrdup(outputs_as_text[j]);
    9931005        free(outputs_as_text[j]);
    9941006        char *tmpc;
     
    10021014                return errorException(m, _("Unable to allocate memory."), "InternalError");
    10031015              }
    1004               tmp_output->name=strdup(tmpc);
     1016              tmp_output->name=zStrdup(tmpc);
    10051017              tmp_output->content=NULL;
    10061018              tmp_output->next=NULL;
     
    10721084     * Put each DataInputs into the inputs_as_text array
    10731085     */
    1074     char *tmp1=strdup(cursor_input);
     1086    char *tmp1=zStrdup(cursor_input);
    10751087    char * pToken;
    10761088    pToken=strtok(cursor_input,";");
     
    11061118
    11071119    for(j=0;j<i;j++){
    1108       char *tmp=strdup(inputs_as_text[j]);
     1120      char *tmp=zStrdup(inputs_as_text[j]);
    11091121      free(inputs_as_text[j]);
    11101122      char *tmpc;
     
    11331145            return errorException(m, _("Unable to allocate memory."), "InternalError");
    11341146          }
    1135           tmpmaps->name=strdup(tmpn);
     1147          tmpmaps->name=zStrdup(tmpn);
    11361148          if(tmpv!=NULL){
    11371149            char *tmpvf=url_decode(tmpv+1);
     
    11661178            sprintf(tmpValue,"%s@%s",tmpv+1,tmpc);
    11671179            free(lmap->value);
    1168             lmap->value=strdup(tmpValue);
     1180            lmap->value=zStrdup(tmpValue);
    11691181            free(tmpValue);
    11701182            tmpc=strtok(NULL,"@");
     
    11811193              char *tmpx2=url_decode(tmpv1+1);
    11821194              if(strncasecmp(tmpx2,"http://",7)!=0 &&
    1183                  strncasecmp(tmpx2,"ftp://",6)!=0){
     1195                 strncasecmp(tmpx2,"ftp://",6)!=0 &&
     1196                 strncasecmp(tmpx2,"https://",8)!=0){
    11841197                char emsg[1024];
    11851198                sprintf(emsg,_("Unable to find a valid protocol to download the remote file %s"),tmpv1+1);
     
    13031316                return errorException(m, _("Unable to allocate memory."), "InternalError");
    13041317              }
    1305               tmpmaps->name=strdup((char*)val);
     1318              tmpmaps->name=zStrdup((char*)val);
    13061319              tmpmaps->content=NULL;
    13071320              tmpmaps->next=NULL;
     
    13211334                return errorException(m, _("Unable to allocate memory."), "InternalError");
    13221335              }
    1323               tmpmaps->name=strdup("missingIndetifier");
     1336              tmpmaps->name=zStrdup("missingIndetifier");
    13241337              tmpmaps->content=createMap((char*)cur2->name,(char*)val);
    13251338              tmpmaps->next=NULL;
     
    15631576                 */
    15641577                char *list[2];
    1565                 list[0]=strdup("dataType");
    1566                 list[1]=strdup("uom");
     1578                list[0]=zStrdup("dataType");
     1579                list[1]=zStrdup("uom");
    15671580                for(int l=0;l<2;l++){
    15681581#ifdef DEBUG
     
    16561669                }
    16571670                free(tmpv->value);
    1658                 tmpv->value=strdup(res);
     1671                tmpv->value=zStrdup(res);
    16591672                free(res);
    16601673                xmlFree(tmp);
     
    17411754            return errorException(m, _("Unable to allocate memory."), "InternalError");
    17421755          }
    1743           tmpmaps->name=strdup("unknownIdentifier");
     1756          tmpmaps->name=zStrdup("unknownIdentifier");
    17441757          tmpmaps->content=NULL;
    17451758          tmpmaps->next=NULL;
     
    17831796                return errorException(m, _("Unable to allocate memory."), "InternalError");
    17841797              }
    1785               tmpmaps->name=strdup((char*)val);
     1798              tmpmaps->name=zStrdup((char*)val);
    17861799              tmpmaps->content=NULL;
    17871800              tmpmaps->next=NULL;
     
    17891802            else{
    17901803              //free(tmpmaps->name);
    1791               tmpmaps->name=strdup((char*)val);
     1804              tmpmaps->name=zStrdup((char*)val);
    17921805            }
    17931806            if(asRaw==true)
     
    17981811              else{
    17991812                map* tt=getMap(request_inputs,"ResponseDocument");
    1800                 char* tmp=strdup(tt->value);
     1813                char* tmp=zStrdup(tt->value);
    18011814                free(tt->value);
    18021815                tt->value=(char*)malloc((strlen(tmp)+strlen((char*)val)+1)*sizeof(char));
     
    18201833                return errorException(m, _("Unable to allocate memory."), "InternalError");
    18211834              }
    1822               tmpmaps->name=strdup("missingIndetifier");
     1835              tmpmaps->name=zStrdup("missingIndetifier");
    18231836              tmpmaps->content=createMap((char*)cur1->name,(char*)val);
    18241837              tmpmaps->next=NULL;
     
    18691882                    return errorException(m, _("Unable to allocate memory."), "InternalError");
    18701883                  }
    1871                   tmpmaps->name=strdup((char*)val);
     1884                  tmpmaps->name=zStrdup((char*)val);
    18721885                  tmpmaps->content=NULL;
    18731886                  tmpmaps->next=NULL;
     
    18761889                  if(tmpmaps->name!=NULL)
    18771890                    free(tmpmaps->name);
    1878                   tmpmaps->name=strdup((char*)val);;
     1891                  tmpmaps->name=zStrdup((char*)val);;
    18791892                }
    18801893                xmlFree(val);
     
    18921905                    return errorException(m, _("Unable to allocate memory."), "InternalError");
    18931906                  }
    1894                   tmpmaps->name=strdup("missingIndetifier");
     1907                  tmpmaps->name=zStrdup("missingIndetifier");
    18951908                  tmpmaps->content=createMap((char*)cur2->name,(char*)val);
    18961909                  tmpmaps->next=NULL;
     
    21252138  int cpid=getpid();
    21262139
     2140  /**
     2141   * Initialize the specific [lenv] section which contains runtime variables:
     2142   *
     2143   *  - usid : it is an unique identification number
     2144   *  - sid : it is the process idenfitication number (OS)
     2145   *  - status : value between 0 and 100 to express the  completude of
     2146   * the operations of the running service
     2147   *  - message : is a string where you can store error messages, in case
     2148   * service is failing, or o provide details on the ongoing operation.
     2149   *  - cwd : is the current working directory
     2150   *  - soap : is a boolean value, true if the request was contained in a SOAP
     2151   * Envelop
     2152   *  - sessid : string storing the session identifier (only when cookie is
     2153   * used)
     2154   *  - cgiSid : only defined on Window platforms (for being able to identify
     2155   * the created process)
     2156   *
     2157   */
    21272158  maps *_tmpMaps=(maps*)malloc(MAPS_SIZE);
    2128   _tmpMaps->name=strdup("lenv");
     2159  _tmpMaps->name=zStrdup("lenv");
    21292160  char tmpBuff[100];
     2161  sprintf(tmpBuff,"%i",(cpid+(int)time(NULL)));
     2162  _tmpMaps->content=createMap("usid",tmpBuff);
     2163  _tmpMaps->next=NULL;
    21302164  sprintf(tmpBuff,"%i",cpid);
    2131   _tmpMaps->content=createMap("sid",tmpBuff);
    2132   _tmpMaps->next=NULL;
     2165  addToMap(_tmpMaps->content,"sid",tmpBuff);
    21332166  addToMap(_tmpMaps->content,"status","0");
     2167  addToMap(_tmpMaps->content,"message",_("No message provided"));
    21342168  addToMap(_tmpMaps->content,"cwd",ntmp);
    21352169  map* ltmp=getMap(request_inputs,"soap");
     
    21402174  if(cgiCookie!=NULL && strlen(cgiCookie)>0){
    21412175    int hasValidCookie=-1;
    2142     char *tcook=strdup(cgiCookie);
     2176    char *tcook=zStrdup(cgiCookie);
    21432177    char *tmp=NULL;
    21442178    int hasVal=-1;
    21452179    map* testing=getMapFromMaps(m,"main","cookiePrefix");
    21462180    if(testing==NULL){
    2147       tmp=strdup("ID=");
     2181      tmp=zStrdup("ID=");
    21482182    }else{
    21492183      tmp=(char*)malloc((strlen(testing->value)+2)*sizeof(char));
     
    21582192          if(tcook!=NULL)
    21592193            free(tcook);
    2160           tcook=strdup(token);
     2194          tcook=zStrdup(token);
    21612195          hasValidCookie=1;
    21622196        }
     
    21652199    }else{
    21662200      if(strstr(cgiCookie,"=")!=NULL && strcasestr(cgiCookie,tmp)!=NULL){
    2167         tcook=strdup(cgiCookie);
     2201        tcook=zStrdup(cgiCookie);
    21682202        hasValidCookie=1;
    21692203      }
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