Changeset 619 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Mar 30, 2015, 2:42:31 PM (10 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r618 r619 3017 3017 addToMap(cursor->content,"size",sizes); 3018 3018 } 3019 map* length=getMap(cursor->content,"length"); 3020 if(length!=NULL){ 3021 int len=atoi(length->value); 3022 for(int i=1;i<len;i++){ 3023 tmp=getMapArray(cursor->content,"encoding",i); 3024 if(tmp!=NULL && strncasecmp(tmp->value,"base64",6)==0){ 3025 char key[17]; 3026 sprintf(key,"base64_value_%d",i); 3027 tmp=getMapArray(cursor->content,"value",i); 3028 addToMap(cursor->content,key,tmp->value); 3029 int size=0; 3030 char *s=strdup(tmp->value); 3031 free(tmp->value); 3032 tmp->value=base64d(s,strlen(s),&size); 3033 free(s); 3034 char sizes[1024]; 3035 sprintf(sizes,"%d",size); 3036 sprintf(key,"size_%d",i); 3037 addToMap(cursor->content,key,sizes); 3038 } 3039 } 3040 } 3019 3041 cursor=cursor->next; 3020 3042 } -
trunk/zoo-project/zoo-kernel/service_internal_otb.c
r618 r619 95 95 } 96 96 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 */ 106 int 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; 97 119 } 98 120 … … 191 213 dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType); 192 214 }else{ 215 map* tmpPath=getMapFromMaps(m,"main","tmpPath"); 216 map* tmpSid=getMapFromMaps(m,"lenv","sid"); 193 217 map* tmpVal=getMapFromMaps(inputs,paramKey.c_str(),"mimeType"); 194 218 char file_ext[32]; 195 219 getFileExtension(tmpVal != NULL ? tmpVal->value : NULL, file_ext, 32); 196 220 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); 198 231 map* tmpLength=getMapFromMaps(inputs,paramKey.c_str(),"length"); 199 232 if(tmpLength!=NULL){ 200 233 int len=atoi(tmpLength->value); 234 maps* tmpI=getMaps(inputs,paramKey.c_str()); 201 235 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)); 203 237 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); 207 241 if(tmpSize!=NULL){ 208 242 length=atoi(tmpSize->value); 209 243 } 210 fwrite(test->value,sizeof(char),length,of); 211 fclose(of); 244 writeFile(val,tmpV->value,length); 212 245 values.push_back(val); 213 246 free(val); … … 220 253 || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData 221 254 || type == ParameterType_InputFilename){ 222 map* tmpPath=getMapFromMaps(m,"main","tmpPath");223 map* tmpSid=getMapFromMaps(m,"lenv","sid");224 255 char tmp[1024]; 225 256 char* ext="json"; … … 227 258 char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+10)*sizeof(char)); 228 259 sprintf(val,"%s/Input_%s_%s.%s",tmpPath->value,s->name,tmpSid->value,file_ext); 229 FILE* of=fopen(val,"wb");230 260 int length=0; 231 261 map* tmpSize=getMap(test,"size"); … … 233 263 length=atoi(tmpSize->value); 234 264 } 235 fwrite(test->value,sizeof(char),length,of); 236 fclose(of); 265 writeFile(val,test->value,length); 237 266 238 267 if(strncasecmp(tmpVal->value,"application/zip",14)==0){
Note: See TracChangeset
for help on using the changeset viewer.