Ignore:
Timestamp:
Dec 23, 2012, 11:50:33 AM (11 years ago)
Author:
djay
Message:

Fix handling of multiple outputs. Small fix to build with bleeding edge gcc. Add missing copyright in service_internal_ms.c/h. Better gesture of session data. Update HISTORY.txt content.

File:
1 edited

Legend:

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

    r378 r379  
    13471347    maps* mcursor=outputs;
    13481348    elements* scursor=serv->outputs;
     1349    map* testResponse=getMap(request,"RawDataOutput");
     1350    if(testResponse==NULL)
     1351      testResponse=getMap(request,"ResponseDocument");
    13491352    while(mcursor!=NULL){
     1353      map* tmp0=getMap(mcursor->content,"inRequest");
    13501354      scursor=getElements(serv->outputs,mcursor->name);
    13511355      if(scursor!=NULL){
    1352         printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
     1356        if(testResponse==NULL)
     1357          printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
     1358        else
     1359          if(strncmp(tmp0->value,"true",4)==0)
     1360            printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output");
    13531361      }
    13541362      mcursor=mcursor->next;
     
    15991607      map* tmp1=getMap(m->content,"encoding");
    16001608      map* tmp2=getMap(m->content,"mimeType");
    1601       map* toto=getMap(m->content,"value");
     1609      map* tmp3=getMap(m->content,"value");
     1610      int hasValue=1;
     1611      if(tmp3==NULL){
     1612        tmp3=createMap("value","");
     1613        hasValue=-1;
     1614      }
    16021615      if((tmp1!=NULL && strncmp(tmp1->value,"base64",6)==0)
    16031616         || (tmp2!=NULL && (strncmp(tmp2->value,"image/",6)==0 ||
     
    16101623        if(rs==NULL){
    16111624          char tmp1[1024];
    1612           sprintf(tmp1,"%d",strlen(toto->value));
     1625          sprintf(tmp1,"%d",strlen(tmp3->value));
    16131626          rs=createMap("size",tmp1);
    16141627          isSized=false;
    16151628        }
    16161629
    1617         xmlAddChild(nc3,xmlNewText(BAD_CAST base64(toto->value, atoi(rs->value))));
     1630        xmlAddChild(nc3,xmlNewText(BAD_CAST base64(tmp3->value, atoi(rs->value))));
    16181631        if(!isSized){
    16191632          freeMap(&rs);
     
    16241637        if(strncmp(tmp2->value,"text/js",7)==0 ||
    16251638           strncmp(tmp2->value,"application/json",16)==0)
    1626           xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value)));
     1639          xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST tmp3->value,strlen(tmp3->value)));
    16271640        else{
    16281641          if(strncmp(tmp2->value,"text/xml",8)==0 ||
    16291642             strncmp(tmp2->value,"application/vnd.google-earth.kml",32)==0){
    16301643            xmlDocPtr doc =
    1631               xmlParseMemory(toto->value,strlen(toto->value));
     1644              xmlParseMemory(tmp3->value,strlen(tmp3->value));
    16321645            xmlNodePtr ir = xmlDocGetRootElement(doc);
    16331646            xmlAddChild(nc3,ir);
    16341647          }
    16351648          else
    1636             xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
     1649            xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));
    16371650        }
    16381651        xmlAddChild(nc2,nc3);
    16391652      }
    16401653      else{
    1641                   xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value));
    1642           }
     1654        xmlAddChild(nc3,xmlNewText(BAD_CAST tmp3->value));
     1655      }
     1656      if(hasValue<0){
     1657        freeMap(&tmp3);
     1658        free(tmp3);
     1659      }
    16431660    }
    16441661  }
     
    18111828    asRaw=1;
    18121829 
    1813   map *_tmp=getMapFromMaps(m,"lenv","cookie");
    1814   map *_tmp1=getMapFromMaps(m,"lenv","sessid");
    1815   if(_tmp!=NULL){
    1816     printf("Set-Cookie: %s\r\n",_tmp->value);
    1817     printf("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"\r\n");
    1818     maps *tmpSess=getMaps(m,"senv");
    1819     if(tmpSess!=NULL){
    1820       char session_file_path[1024];
    1821       map *tmpPath=getMapFromMaps(m,"main","sessPath");
    1822       if(tmpPath==NULL)
    1823         tmpPath=getMapFromMaps(m,"main","tmpPath");
     1830  maps* tmpSess=getMaps(m,"senv");
     1831  if(tmpSess!=NULL){
     1832    map *_tmp=getMapFromMaps(m,"lenv","cookie");
     1833    char* sessId;
     1834    if(_tmp!=NULL){
     1835      printf("Set-Cookie: %s\r\n",_tmp->value);
     1836      printf("P3P: CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"\r\n");
     1837      char session_file_path[100];
    18241838      char *tmp1=strtok(_tmp->value,";");
    18251839      if(tmp1!=NULL)
    1826         sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(tmp1,"=")+1);
     1840        sprintf(session_file_path,"%s",strstr(tmp1,"=")+1);
    18271841      else
    1828         sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(_tmp->value,"=")+1);
    1829       dumpMapsToFile(tmpSess,session_file_path);
    1830     }
    1831   }
    1832 
     1842        sprintf(session_file_path,"%s",strstr(_tmp->value,"=")+1);
     1843      sessId=strdup(session_file_path);
     1844    }else{
     1845      maps* t=getMaps(m,"senv");
     1846      map*p=t->content;
     1847      while(p!=NULL){
     1848        if(strstr(p->name,"ID")!=NULL){
     1849          sessId=strdup(p->value);
     1850          break;
     1851        }
     1852        p=p->next;
     1853      }
     1854    }
     1855    char session_file_path[1024];
     1856    map *tmpPath=getMapFromMaps(m,"main","sessPath");
     1857    if(tmpPath==NULL)
     1858      tmpPath=getMapFromMaps(m,"main","tmpPath");
     1859    sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,sessId);
     1860    dumpMapsToFile(tmpSess,session_file_path);
     1861  }
     1862 
    18331863  printHeaders(m);
    18341864
     
    24722502    fprintf(stderr,"MD5STR : (%s)\n\n",md5str);
    24732503#endif
    2474     char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+38));
     2504    char* fname=(char*)malloc(sizeof(char)*(strlen(tmpM->value)+50));
    24752505    sprintf(fname,"%s/%s.zca",tmpM->value,md5str);
    24762506    struct stat f_status;
     
    24952525  char* cached=isInCache(m,url);
    24962526  int fsize;
     2527  int hasF=-1;
    24972528  if(cached!=NULL){
    24982529    struct stat f_status;
    24992530    int s=stat(cached, &f_status);
    25002531    if(s==0){
    2501       fprintf(stderr,"FILE SIZE (%d)\n",f_status.st_size/1024);
    25022532      fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
    25032533      FILE* f=fopen(cached,"rb");
    25042534      fread(fcontent,sizeof(char),f_status.st_size,f);
    25052535      fsize=f_status.st_size;
     2536      hasF=1;
    25062537    }
    25072538  }else{
    25082539    res=InternetOpenUrl(hInternet,url,NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0);
    2509     fcontent=(char*)calloc((res.nDataLen+1),sizeof(char));
     2540    fcontent=(char*)malloc((res.nDataLen+1)*sizeof(char));
    25102541    if(fcontent == NULL){
    25112542      return errorException(m, _("Unable to allocate memory."), "InternalError");
    25122543    }
     2544    hasF=1;
    25132545    size_t dwRead;
    25142546    InternetReadFile(res, (LPVOID)fcontent, res.nDataLen, &dwRead);
     
    25242556  free(tmpMap->value);
    25252557  tmpMap->value=(char*)malloc((fsize+1)*sizeof(char));
     2558  if(tmpMap->value==NULL)
     2559    fprintf(stderr,"Unable to allocate memory!\n");
    25262560  memcpy(tmpMap->value,fcontent,(fsize)*sizeof(char));
    2527 
     2561 
    25282562  char ltmp1[256];
    25292563  sprintf(ltmp1,"%d",fsize);
     
    25312565  if(cached==NULL)
    25322566    addToCache(m,url,fcontent,fsize);
    2533   free(fcontent);
    2534   if(cached!=NULL)
     2567  else{
     2568    if(hasF)
     2569      free(fcontent);
    25352570    free(cached);
     2571  }
    25362572  return 0;
    25372573}
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