Ignore:
Timestamp:
Mar 30, 2015, 2:42:31 PM (9 years ago)
Author:
djay
Message:

Fix issue with OTB multiple inputs potentially encoded in base64.

File:
1 edited

Legend:

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

    r618 r619  
    9595    }
    9696    return str;
     97}
     98
     99/**
     100 * Write a file from value and length
     101 *
     102 * @param fname the file name
     103 * @param val the value
     104 * @param length the value length
     105 */
     106int writeFile(char* fname,char* val,int length){
     107  FILE* of=fopen(fname,"wb");
     108  if(of==NULL){
     109    return -1;
     110  }
     111  size_t ret=fwrite(val,sizeof(char),length,of);
     112  if(ret<length){
     113    fprintf(stderr,"Write error occured!\n");
     114    fclose(of);
     115    return -1;
     116  }
     117  fclose(of);
     118  return 1;
    97119}
    98120
     
    191213                    dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
    192214                  }else{
     215                    map* tmpPath=getMapFromMaps(m,"main","tmpPath");
     216                    map* tmpSid=getMapFromMaps(m,"lenv","sid");
    193217                    map* tmpVal=getMapFromMaps(inputs,paramKey.c_str(),"mimeType");
    194218                    char file_ext[32];
    195219                    getFileExtension(tmpVal != NULL ? tmpVal->value : NULL, file_ext, 32);
    196220                    if(type == ParameterType_InputImageList){
    197                       values.push_back(test->value);
     221                      char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
     222                      sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,0,file_ext);
     223                      int length=0;
     224                      map* tmpSize=getMap(test,"size");
     225                      if(tmpSize!=NULL){
     226                        length=atoi(tmpSize->value);
     227                      }
     228                      writeFile(val,test->value,length);
     229                      values.push_back(val);
     230                      free(val);
    198231                      map* tmpLength=getMapFromMaps(inputs,paramKey.c_str(),"length");
    199232                      if(tmpLength!=NULL){
    200233                        int len=atoi(tmpLength->value);
     234                        maps* tmpI=getMaps(inputs,paramKey.c_str());
    201235                        for(int k=1;k<len;k++){
    202                           char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
     236                          val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
    203237                          sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,k,file_ext);
    204                           FILE* of=fopen(val,"wb");
    205                           int length=0;
    206                           map* tmpSize=getMap(test,"size");
     238                          length=0;
     239                          map* tmpV=getMapArray(tmpI->content,"value",k);
     240                          tmpSize=getMapArray(tmpI->content,"size",k);
    207241                          if(tmpSize!=NULL){
    208242                            length=atoi(tmpSize->value);
    209243                          }
    210                           fwrite(test->value,sizeof(char),length,of);
    211                           fclose(of);
     244                          writeFile(val,tmpV->value,length);
    212245                          values.push_back(val);
    213246                          free(val);
     
    220253                           || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData
    221254                           || type == ParameterType_InputFilename){
    222                         map* tmpPath=getMapFromMaps(m,"main","tmpPath");
    223                         map* tmpSid=getMapFromMaps(m,"lenv","sid");
    224255                        char tmp[1024];
    225256                        char* ext="json";
     
    227258                          char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+10)*sizeof(char));
    228259                          sprintf(val,"%s/Input_%s_%s.%s",tmpPath->value,s->name,tmpSid->value,file_ext);
    229                           FILE* of=fopen(val,"wb");
    230260                          int length=0;
    231261                          map* tmpSize=getMap(test,"size");
     
    233263                            length=atoi(tmpSize->value);
    234264                          }
    235                           fwrite(test->value,sizeof(char),length,of);
    236                           fclose(of);
     265                          writeFile(val,test->value,length);
    237266
    238267                          if(strncasecmp(tmpVal->value,"application/zip",14)==0){
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