Changeset 863 for branches/prototype-v0
- Timestamp:
- Feb 5, 2018, 1:19:13 PM (7 years ago)
- Location:
- branches/prototype-v0/zoo-project
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r862 r863 142 142 * @param max_path the size of the allocated filepath buffer 143 143 */ 144 void cacheFile(maps* conf,char* request,char* mimeType,int length,char* filename){ 145 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 146 char contentr[4096]; 147 int cred=0; 148 if(tmp!=NULL){ 149 char* myRequest=getFilenameForRequest(conf,request); 150 char* md5str=getMd5(myRequest); 151 free(myRequest); 152 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+strlen(md5str)+6)); 153 sprintf(fname,"%s/%s.zca",tmp->value,md5str); 154 zooLock* lck=lockFile(conf,fname,'w'); 155 if(lck!=NULL){ 156 #ifdef DEBUG 157 fprintf(stderr,"Cache list : %s\n",fname); 158 fflush(stderr); 159 #endif 160 FILE* fi=fopen(filename,"rb"); 161 FILE* fo=fopen(fname,"w+"); 162 if(fo==NULL){ 163 #ifdef DEBUG 164 fprintf (stderr, "Failed to open %s for writing: %s\n",fname, strerror(errno)); 165 #endif 166 unlockFile(conf,lck); 167 return; 168 } 169 if(fi==NULL){ 170 #ifdef DEBUG 171 fprintf (stderr, "Failed to open %s for reading: %s\n",filename, strerror(errno)); 172 #endif 173 unlockFile(conf,lck); 174 return; 175 } 176 memset(contentr,0,4096); 177 while((cred=fread(contentr,sizeof(char),4096,fi))>0){ 178 fwrite(contentr,sizeof(char),cred,fo); 179 fflush(fo); 180 memset(contentr,0,4096); 181 } 182 unlockFile(conf,lck); 183 fclose(fo); 184 fclose(fi); 185 186 sprintf(fname,"%s/%s.zcm",tmp->value,md5str); 187 fo=fopen(fname,"w+"); 188 #ifdef DEBUG 189 fprintf(stderr,"MIMETYPE: %s\n",mimeType); 190 #endif 191 fwrite(mimeType,sizeof(char),strlen(mimeType),fo); 192 fclose(fo); 193 194 sprintf(fname,"%s/%s.zcp",tmp->value,md5str); 195 fo=fopen(fname,"w+"); 196 char* origin=getProvenance(conf,request); 197 #ifdef DEBUG 198 fprintf(stderr,"ORIGIN: %s\n",mimeType); 199 #endif 200 fwrite(origin,sizeof(char),strlen(origin),fo); 201 fclose(fo); 202 203 free(md5str); 204 free(fname); 205 } 206 } 207 } 208 209 /** 210 * Cache a file for a given request. 211 * For each cached file, the are two files stored, a .zca and a .zcm containing 212 * the downloaded content and the mimeType respectively. 213 * 214 * @param conf the maps containing the settings of the main.cfg file 215 * @param request the url used too fetch the content 216 * @param content the downloaded content 217 * @param mimeType the content mimeType 218 * @param length the content size 219 * @param filepath a buffer for storing the path of the cached file; may be NULL 220 * @param max_path the size of the allocated filepath buffer 221 */ 144 222 void addToCache(maps* conf,char* request,char* content,char* mimeType,int length, 145 223 char* filepath, size_t max_path){ … … 243 321 int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){ 244 322 323 int shouldClean=-1; 245 324 map* tmp1; 246 325 char sindex[5]; 247 326 maps* content=*in; 248 327 map* length=getMap(content->content,"length"); 249 int shouldClean=-1;328 map* memUse=getMapFromMaps(*m,"main","memory"); 250 329 if(length==NULL){ 251 330 length=createMap("length","1"); … … 266 345 char hname[11]; 267 346 char oname[12]; 347 char ufile[12]; 268 348 if(*index>0) 269 349 sprintf(vname1,"value_%d",*index); … … 282 362 sprintf(hname,"headers_%d",i); 283 363 sprintf(oname,"Order_%d",i); 364 sprintf(ufile,"use_file_%d",i); 284 365 }else{ 285 366 sprintf(cname,"cache_file"); … … 292 373 sprintf(hname,"headers"); 293 374 sprintf(oname,"Order"); 375 sprintf(ufile,"use_file"); 294 376 } 295 377 … … 298 380 if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){ 299 381 300 if(getMap(content->content,icname)==NULL){ 301 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 302 if(fcontent == NULL){ 303 errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 304 return -1; 305 } 306 size_t dwRead; 307 InternetReadFile(hInternet->ihandle[*index], 308 (LPVOID)fcontent, 309 hInternet->ihandle[*index].nDataLen, 310 &dwRead); 311 fcontent[hInternet->ihandle[*index].nDataLen]=0; 382 if(getMap(content->content,icname)==NULL) { 383 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){ 384 fcontent=(char*)malloc((hInternet->ihandle[*index].nDataLen+1)*sizeof(char)); 385 if(fcontent == NULL){ 386 errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 387 return -1; 388 } 389 size_t dwRead; 390 InternetReadFile(hInternet->ihandle[*index], 391 (LPVOID)fcontent, 392 hInternet->ihandle[*index].nDataLen, 393 &dwRead); 394 fcontent[hInternet->ihandle[*index].nDataLen]=0; 395 } 312 396 fsize=hInternet->ihandle[*index].nDataLen; 313 397 if(hInternet->ihandle[*index].mimeType==NULL) … … 317 401 318 402 map* tmpMap=getMapOrFill(&(*in)->content,vname,""); 319 free(tmpMap->value); 320 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 321 if(tmpMap->value==NULL){ 322 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 323 } 324 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 403 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){ 404 free(tmpMap->value); 405 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 406 if(tmpMap->value==NULL){ 407 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 408 } 409 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 410 }else 411 addToMap((*in)->content,ufile,"true"); 325 412 if(hInternet->ihandle[*index].code!=200){ 326 413 char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d."); … … 376 463 addToMap((*in)->content,sname,ltmp1); 377 464 addToMap((*in)->content,mname,mimeType); 378 addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0); 379 free(fcontent); 465 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){ 466 addToCache(*m,request,fcontent,mimeType,fsize, NULL, 0); 467 free(fcontent); 468 }else{ 469 addToMap((*in)->content,ufile,"true"); 470 cacheFile(*m,request,mimeType,fsize,hInternet->ihandle[*index].filename); 471 } 380 472 free(mimeType); 381 473 free(request); … … 388 480 free(length); 389 481 } 482 dumpMaps(*in); 390 483 return 0; 391 484 } … … 438 531 hInternet->waitingRequests[hInternet->nb]=strdup(url); 439 532 if(req) 440 InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0 );533 InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0,*m); 441 534 maps *oreq=getMaps(*m,"orequests"); 442 535 if(oreq==NULL){ … … 465 558 char *mimeType=NULL; 466 559 int fsize=0; 560 map* memUse=getMapFromMaps(*m,"main","memory"); 467 561 468 562 map* t=getMap(*content,"xlink:href"); … … 479 573 if(lck==NULL) 480 574 return -1; 481 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));482 FILE* f=fopen(cached,"rb");483 fread(fcontent,f_status.st_size,1,f);484 575 fsize=f_status.st_size; 485 fcontent[fsize]=0; 486 fclose(f); 576 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){ 577 fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 578 FILE* f=fopen(cached,"rb"); 579 if(f!=NULL){ 580 fread(fcontent,f_status.st_size,1,f); 581 fcontent[fsize]=0; 582 fclose(f); 583 } 584 } 487 585 addToMap(*content,"cache_file",cached); 488 586 unlockFile(*m,lck); … … 513 611 514 612 map* tmpMap=getMapOrFill(content,"value",""); 515 free(tmpMap->value); 516 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 517 if(tmpMap->value==NULL || fcontent == NULL) 518 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 519 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 520 613 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0){ 614 free(tmpMap->value); 615 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 616 if(tmpMap->value==NULL || fcontent == NULL) 617 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 618 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); 619 } 620 521 621 char ltmp1[256]; 522 622 sprintf(ltmp1,"%d",fsize); 523 623 addToMap(*content,"size",ltmp1); 524 624 if(cached==NULL){ 525 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 625 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0) 626 addToCache(*m,url,fcontent,mimeType,fsize, NULL, 0); 627 else 628 cacheFile(*m,url,mimeType,fsize,hInternet->ihandle[hInternet->nb-1].filename); 526 629 } 527 630 else{ -
branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c
r854 r863 759 759 xmlStrlen(btmps), 760 760 INTERNET_FLAG_NO_CACHE_WRITE, 761 0); 761 0, 762 *main_conf); 762 763 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 763 764 } … … 795 796 [0], NULL, 0, 796 797 INTERNET_FLAG_NO_CACHE_WRITE, 797 0); 798 0, 799 *main_conf); 798 800 processDownloads (&bInternet); 799 801 char *tmp = … … 830 832 strlen(tmp), 831 833 INTERNET_FLAG_NO_CACHE_WRITE, 832 0); 834 0, 835 *main_conf); 833 836 addIntToMap (tmpmaps->content, "Order", hInternet->nb); 834 837 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r862 r863 125 125 char *tmp1; 126 126 map *tmpStatus; 127 maps* tmpConf=createMaps("main"); 128 tmpConf->content=createMap("memory","load"); 127 129 hInternet=InternetOpen("ZooWPSClient\0", 128 130 INTERNET_OPEN_TYPE_PRECONFIG, … … 178 180 (char*)jsonStr, strlen(jsonStr), 179 181 INTERNET_FLAG_NO_CACHE_WRITE, 180 0 );182 0,tmpConf); 181 183 AddHeaderEntries(&hInternet,arg->conf); 182 184 //curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_VERBOSE, 1);x 183 185 processDownloads(&hInternet); 186 freeMaps(&tmpConf); 187 free(tmpConf); 184 188 now = time ( NULL ); 185 189 tm = localtime ( &now ); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c
r790 r863 427 427 #endif 428 428 map* sizeV=getMap(tmp1,"size"); 429 map* useFile=getMap(tmp1,"use_file"); 430 map* cacheFile=getMap(tmp1,"cache_file"); 429 431 map* isArray=getMap(tmp1,"isArray"); 430 432 map* alen=getMap(tmp1,"length"); … … 432 434 if(strcmp(tmp1->name,"value")==0){ 433 435 if(isArray==NULL){ 434 if(sizeV!=NULL && strcmp(tmp1->name,"value")==0 ){436 if(sizeV!=NULL && strcmp(tmp1->name,"value")==0 && useFile==NULL){ 435 437 #ifdef JAVA7 436 438 jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value)); … … 448 450 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value)); 449 451 #endif 452 if(useFile!=NULL) 453 #ifdef JAVA7 454 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF("cache_file"), (*env).NewStringUTF(cacheFile->value)); 455 #else 456 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,"cache_file"), (*env)->NewStringUTF(env,cacheFile->value)); 457 #endif 458 450 459 } 451 460 else{ … … 455 464 jclass scArrayListClass,scArrayList_class; 456 465 jmethodID scArrayList_constructor; 457 jobject scObject2 ;466 jobject scObject2,scObject3; 458 467 #ifdef JAVA7 459 468 scArrayListClass = (*env).FindClass("java/util/ArrayList"); … … 462 471 jmethodID add_mid = 0; 463 472 scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 473 scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor); 464 474 465 475 add_mid = (*env).GetMethodID(scArrayListClass, … … 471 481 jmethodID add_mid = 0; 472 482 scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor); 483 scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor); 473 484 474 485 add_mid = (*env)->GetMethodID(env,scArrayListClass, … … 478 489 479 490 for(i=0;i<alen1;i++){ 491 map* cMap=getMapArray(tmp->content,"cache_file",i); 492 map* uMap=getMapArray(tmp->content,"use_file",i); 480 493 map* vMap=getMapArray(tmp->content,"value",i); 481 494 map* sMap=getMapArray(tmp->content,"size",i); 482 495 map* mMap=getMapArray(tmp->content,tmap->value,i); 483 496 484 if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0 ){497 if(sMap!=NULL && vMap!=NULL && strncmp(vMap->name,"value",5)==0 && uMap==NULL){ 485 498 #ifdef JAVA7 486 499 jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value)); … … 501 514 #endif 502 515 } 503 516 517 if(cMap!=NULL){ 518 #ifdef JAVA7 519 jobject tmpData=(*env).NewStringUTF(cMap->value); 520 (*env).CallObjectMethod(scObject3, add_mid, tmpData); 521 #else 522 jobject tmpData=(*env)->NewStringUTF(env,cMap->value); 523 (*env)->CallObjectMethod(env,scObject3, add_mid, tmpData); 524 #endif 525 526 } 504 527 } 505 528 506 529 #ifdef JAVA7 507 530 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2); 531 (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF("cache_file"), scObject3); 508 532 #else 509 533 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), scObject2); 534 (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,"cache_file"), scObject3); 510 535 #endif 511 536 -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c
r839 r863 901 901 char* tmpValue; 902 902 size_t dwRead; 903 maps *tmpConf=createMaps("main"); 904 tmpConf->content=createMap("memory","load"); 903 905 JS_MaybeGC(cx); 904 906 hInternet=InternetOpen("ZooWPSClient\0", … … 929 931 #endif 930 932 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body), 931 INTERNET_FLAG_NO_CACHE_WRITE,0 );933 INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf); 932 934 processDownloads(&hInternet); 933 935 free(body); … … 940 942 } 941 943 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0, 942 INTERNET_FLAG_NO_CACHE_WRITE,0 );944 INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf); 943 945 processDownloads(&hInternet); 944 946 }else{ 945 947 char *body=JSValToChar(cx,&argv[2]); 946 948 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body), 947 INTERNET_FLAG_NO_CACHE_WRITE,0 );949 INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf); 948 950 processDownloads(&hInternet); 949 951 free(body); … … 951 953 }else{ 952 954 InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0, 953 INTERNET_FLAG_NO_CACHE_WRITE,0 );955 INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf); 954 956 processDownloads(&hInternet); 955 957 } … … 972 974 if(argc>=2) 973 975 free(method); 976 freeMaps(&tmpConf); 977 free(tmpConf); 974 978 InternetCloseHandle(&hInternet); 975 979 JS_MaybeGC(cx); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c
r854 r863 425 425 map* isArray=getMap(tmp,"isArray"); 426 426 map* size=getMap(tmp,"size"); 427 map* useFile=getMap(tmp,"use_file"); 428 map* cacheFile=getMap(tmp,"cache_file"); 427 429 map* tmap=getMapType(tmp); 428 430 while(tmp!=NULL){ … … 435 437 PyObject* mvalue=PyList_New(cnt); 436 438 PyObject* svalue=PyList_New(cnt); 439 PyObject* cvalue=PyList_New(cnt); 437 440 438 441 for(int i=0;i<cnt;i++){ 439 442 440 map* vMap=getMapArray(tmp,"value",i); 441 map* sMap=getMapArray(tmp,"size",i); 443 map* vMap=getMapArray(t,"value",i); 444 map* uMap=getMapArray(t,"use_file",i); 445 map* sMap=getMapArray(t,"size",i); 446 map* cMap=getMapArray(t,"cache_file",i); 442 447 443 448 if(vMap!=NULL){ … … 445 450 PyObject* lvalue; 446 451 PyObject* lsvalue; 447 if(sMap==NULL){ 452 PyObject* lcvalue; 453 if(sMap==NULL || uMap!=NULL){ 448 454 lvalue=PyString_FromString(vMap->value); 449 lsvalue=Py_None;450 455 } 451 456 else{ 452 457 lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value)); 458 } 459 if(sMap!=NULL){ 453 460 lsvalue=PyString_FromString(sMap->value); 454 461 hasSize=1; 455 462 } 463 else 464 lsvalue=Py_None; 465 if(uMap!=NULL){ 466 lcvalue=PyString_FromString(cMap->value);; 467 }else 468 lcvalue=Py_None; 456 469 457 470 if(PyList_SetItem(value,i,lvalue)<0){ … … 463 476 return NULL; 464 477 } 478 if(PyList_SetItem(cvalue,i,lcvalue)<0){ 479 fprintf(stderr,"Unable to set key value pair..."); 480 return NULL; 481 } 465 482 } 466 483 484 PyObject* lmvalue; 467 485 map* mMap=getMapArray(tmp,tmap->name,i); 468 PyObject* lmvalue;469 486 if(mMap!=NULL){ 470 487 lmvalue=PyString_FromString(mMap->value); … … 487 504 return NULL; 488 505 } 506 if(PyDict_SetItem(res,PyString_FromString("cache_file"),cvalue)<0){ 507 fprintf(stderr,"Unable to set key value pair..."); 508 return NULL; 509 } 489 510 if(hasSize>0) 490 511 if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){ … … 493 514 } 494 515 } 495 else if(size!=NULL ){516 else if(size!=NULL && useFile==NULL){ 496 517 PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value)); 497 518 if(PyDict_SetItem(res,name,value)<0){ -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ruby.c
r790 r863 260 260 int hasSize=0; 261 261 map* isArray=getMap(tmp,"isArray"); 262 map* useFile=getMap(tmp,"use_file"); 262 263 map* size=getMap(tmp,"size"); 263 264 map* tmap=getMapType(tmp); … … 271 272 VALUE mvalue=rb_ary_new2(cnt); 272 273 VALUE svalue=rb_ary_new2(cnt); 274 VALUE cvalue=rb_ary_new2(cnt); 273 275 274 276 for(int i=0;i<cnt;i++){ … … 276 278 map* vMap=getMapArray(tmp,"value",i); 277 279 map* sMap=getMapArray(tmp,"size",i); 280 map* uMap=getMapArray(tmp,"use_file",i); 281 map* cMap=getMapArray(tmp,"cache_file",i); 278 282 279 283 if(vMap!=NULL){ … … 281 285 VALUE lvalue; 282 286 VALUE lsvalue; 283 if(sMap==NULL){ 287 VALUE lcvalue; 288 if(sMap==NULL || uMap==NULL){ 284 289 lvalue=rb_str_new2(vMap->value); 285 lsvalue=Qnil; 290 if(sMap==NULL) 291 lsvalue=Qnil; 292 else 293 lsvalue=rb_str_new2(sMap->value); 286 294 } 287 295 else{ … … 290 298 hasSize=1; 291 299 } 300 if(uMap!=NULL) 301 lcvalue=rb_str_new2(cMap->value); 302 else 303 lcvalue=Qnil; 292 304 293 305 rb_ary_push(value,lvalue); 294 306 rb_ary_push(svalue,lsvalue); 307 rb_ary_push(cvalue,lcvalue); 295 308 } 296 309 … … 308 321 rb_hash_aset(res, name, mvalue); 309 322 rb_hash_aset(res, rb_str_new2(tmap->name), mvalue); 323 VALUE lname0=rb_str_new2("cache_size"); 324 rb_hash_aset(res, lname0, value); 310 325 311 326 if(hasSize>0){ -
branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c
r860 r863 379 379 char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char)); 380 380 sprintf(sqlQuery,"UPDATE %s.services set status=$$%s$$,message=$$%s$$ where uuid=$$%s$$;",schema->value,p->value,msg->value,sid->value); 381 if( zoo_ds_nb== 382 #ifdef META_DB 383 1 384 #else 385 0 386 #endif 387 ){ 381 if( zoo_ds_nb == 0 ){ 388 382 init_sql(conf); 389 383 zoo_ds_nb++; -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c
r862 r863 70 70 71 71 /** 72 * Write the downloaded content to a_HINTERNET structure72 * Write the downloaded content in the file pouted by the _HINTERNET structure 73 73 * 74 74 * @param buffer the buffer to read … … 89 89 psInternet=(_HINTERNET *)data; 90 90 writen+=fwrite(buffer, size, nmemb, psInternet->file); 91 if(psInternet->nDataLen>0){ 92 psInternet->nDataAlloc+=psInternet->nDataLen+writen+1; 93 psInternet->nDataLen += realsize; 94 }else 95 psInternet->nDataLen=realsize+1; 91 fflush(psInternet->file); 92 psInternet->nDataLen += realsize; 93 96 94 buffer=NULL; 97 95 return realsize; … … 443 441 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file) 444 442 * @param dwContext not used 443 * @param conf the main configuration file maps pointer 445 444 * @return the updated HINTERNET 446 445 */ 447 HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext ){446 HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext,const maps* conf){ 448 447 449 448 char filename[255]; 449 int ldwFlags=INTERNET_FLAG_NEED_FILE; 450 450 struct MemoryStruct header; 451 map* memUse=getMapFromMaps(conf,"main","memory"); 451 452 452 453 hInternet->ihandle[hInternet->nb].handle=curl_easy_init( ); … … 480 481 curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1); 481 482 #endif 482 483 switch(dwFlags) 483 484 if(memUse!=NULL && strcasecmp(memUse->value,"load")==0) 485 ldwFlags=INTERNET_FLAG_NO_CACHE_WRITE; 486 487 switch(ldwFlags) 484 488 { 485 489 case INTERNET_FLAG_NO_CACHE_WRITE: … … 491 495 memset(filename,0,255); 492 496 char* tmpUuid=get_uuid(); 493 sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid); 497 map* tmpPath=NULL; 498 if(conf!=NULL){ 499 tmpPath=getMapFromMaps(conf,"main","tmpPath"); 500 } 501 if(tmpPath==NULL) 502 sprintf(filename,"/tmp/ZOO_Cache%s", tmpUuid); 503 else 504 sprintf(filename,"/%s/ZOO_Cache%s", tmpPath->value,tmpUuid); 505 fprintf(stderr," *** %s %d %s",__FILE__,__LINE__,filename); 506 fflush(stderr); 494 507 free(tmpUuid); 495 508 hInternet->ihandle[hInternet->nb].filename=strdup(filename); -
branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h
r854 r863 100 100 size_t write_data_into(void*,size_t,size_t,void*); 101 101 102 size_t write_data_into_file(void*,size_t,size_t,void*); 103 102 104 size_t header_write_data(void*,size_t,size_t,void*); 103 105 … … 158 160 # define CHECK_INET_HANDLE(h) (h.handle != 0) 159 161 160 HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t );162 HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t,const maps*); 161 163 162 164 int processDownloads(HINTERNET*); -
branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c
r862 r863 26 26 int parseInput(maps* conf,maps* inputs, std::vector<Pointz>* points,char* filename){ 27 27 map* tmpm=NULL; 28 tmpm=getMapFromMaps(inputs,"InputPoints","value"); 29 VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmpm->value,strlen(tmpm->value),FALSE); 30 VSIFCloseL(ifile); 28 tmpm=getMapFromMaps(inputs,"InputPoints","cache_file"); 31 29 #if GDAL_VERSION_MAJOR >= 2 32 GDALDataset *ipoDS = 33 (GDALDataset*) GDALOpenEx( filename, 34 GDAL_OF_READONLY | GDAL_OF_VECTOR, 35 NULL, NULL, NULL ); 30 GDALDataset *ipoDS; 36 31 #else 37 OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);32 OGRDataSource* ipoDS; 38 33 #endif 34 if(tmpm==NULL){ 35 tmpm=getMapFromMaps(inputs,"InputPoints","value"); 36 VSILFILE *ifile=VSIFileFromMemBuffer(filename,(GByte*)tmpm->value,strlen(tmpm->value),FALSE); 37 VSIFCloseL(ifile); 38 #if GDAL_VERSION_MAJOR >= 2 39 ipoDS = (GDALDataset*) GDALOpenEx( filename, 40 GDAL_OF_READONLY | GDAL_OF_VECTOR, 41 NULL, NULL, NULL ); 42 #else 43 ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE); 44 #endif 45 }else 46 #if GDAL_VERSION_MAJOR >= 2 47 ipoDS = (GDALDataset*) GDALOpenEx( tmpm->value, 48 GDAL_OF_READONLY | GDAL_OF_VECTOR, 49 NULL, NULL, NULL ); 50 #else 51 ipoDS = OGRSFDriverRegistrar::Open(tmpm->value,FALSE); 52 #endif 53 39 54 if( ipoDS == NULL ) 40 55 { -
branches/prototype-v0/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py
r465 r863 95 95 96 96 def extractInputs(conf,obj): 97 if obj.keys().count("cache_file"): 98 print >> sys.stderr,obj 99 geometry=[] 100 ds = osgeo.ogr.Open(obj["cache_file"]) 101 if sql is not None: 102 if sql.count("from")==0: 103 layerName=ds.GetLayerByIndex(0).GetName() 104 sql+=" from "+layerName 105 lyr=ds.ExecuteSQL( sql, None, None ) 106 else: 107 lyr = ds.GetLayer(0) 108 feat = lyr.GetNextFeature() 109 while feat is not None: 110 geometry+=[feat.Clone()] 111 feat.Destroy() 112 feat = lyr.GetNextFeature() 113 ds.Destroy() 114 return geometry 97 115 if obj["mimeType"]=="application/json": 98 116 return createLayerFromJson(conf,obj["value"]) -
branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c
r862 r863 366 366 dfMaxSegmentLength = atof(tmpMap->value); 367 367 } 368 369 /*tmpMap=NULL;370 tmpMap=getMapFromMaps(inputs,"segmentize","value");371 if(tmpMap!=NULL){372 dfMaxSegmentLength = atof(tmpMap->value);373 }*/374 375 368 376 369 tmpMap=NULL;
Note: See TracChangeset
for help on using the changeset viewer.