Changeset 863 for branches


Ignore:
Timestamp:
Feb 5, 2018, 1:19:13 PM (6 years ago)
Author:
djay
Message:

Change the default ZOO-Kernel behavior, if an input has been passed by reference, the ZOO-Service will receive a cache_file map rather than the value field which was usually returned, same for array value apply. To use the previous behavior, one can add "memory=load" to the main section of the main.cfg file. Update ZOO-Services for using this new field if available.

Location:
branches/prototype-v0/zoo-project
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/caching.c

    r862 r863  
    142142 * @param max_path the size of the allocated filepath buffer 
    143143 */
     144void 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 */
    144222void addToCache(maps* conf,char* request,char* content,char* mimeType,int length,
    145223                char* filepath, size_t max_path){
     
    243321int readCurrentInput(maps** m,maps** in,int* index,HINTERNET* hInternet,map** error){
    244322 
     323  int shouldClean=-1;
    245324  map* tmp1;
    246325  char sindex[5];
    247326  maps* content=*in;
    248327  map* length=getMap(content->content,"length");
    249   int shouldClean=-1;
     328  map* memUse=getMapFromMaps(*m,"main","memory");
    250329  if(length==NULL){
    251330    length=createMap("length","1");
     
    266345    char hname[11];
    267346    char oname[12];
     347    char ufile[12];   
    268348    if(*index>0)
    269349      sprintf(vname1,"value_%d",*index);
     
    282362      sprintf(hname,"headers_%d",i);
    283363      sprintf(oname,"Order_%d",i);
     364      sprintf(ufile,"use_file_%d",i);
    284365    }else{
    285366      sprintf(cname,"cache_file");
     
    292373      sprintf(hname,"headers");
    293374      sprintf(oname,"Order");
     375      sprintf(ufile,"use_file");
    294376    }
    295377   
     
    298380    if((tmp1=getMap(content->content,xname))!=NULL && tmap!=NULL && strcasecmp(tmap->value,sindex)==0){
    299381
    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        }
    312396        fsize=hInternet->ihandle[*index].nDataLen;
    313397        if(hInternet->ihandle[*index].mimeType==NULL)
     
    317401       
    318402        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");
    325412        if(hInternet->ihandle[*index].code!=200){
    326413          char *error_rep_str=_("Unable to download the file for the input <%s>, response code was : %d.");
     
    376463        addToMap((*in)->content,sname,ltmp1);
    377464        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        }
    380472        free(mimeType);
    381473        free(request);
     
    388480    free(length);
    389481  }
     482  dumpMaps(*in);
    390483  return 0;
    391484}
     
    438531  hInternet->waitingRequests[hInternet->nb]=strdup(url);
    439532  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);
    441534  maps *oreq=getMaps(*m,"orequests");
    442535  if(oreq==NULL){
     
    465558  char *mimeType=NULL;
    466559  int fsize=0;
     560  map* memUse=getMapFromMaps(*m,"main","memory");
    467561
    468562  map* t=getMap(*content,"xlink:href");
     
    479573      if(lck==NULL)
    480574        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);
    484575      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      }
    487585      addToMap(*content,"cache_file",cached);
    488586      unlockFile(*m,lck);
     
    513611
    514612  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 
    521621  char ltmp1[256];
    522622  sprintf(ltmp1,"%d",fsize);
    523623  addToMap(*content,"size",ltmp1);
    524624  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);
    526629  }
    527630  else{
  • branches/prototype-v0/zoo-project/zoo-kernel/request_parser.c

    r854 r863  
    759759                                                           xmlStrlen(btmps),
    760760                                                           INTERNET_FLAG_NO_CACHE_WRITE,
    761                                                            0);
     761                                                           0,
     762                                                           *main_conf);
    762763                                          addIntToMap (tmpmaps->content, "Order", hInternet->nb);
    763764                                        }
     
    795796                                                   [0], NULL, 0,
    796797                                                   INTERNET_FLAG_NO_CACHE_WRITE,
    797                                                    0);
     798                                                   0,
     799                                                   *main_conf);
    798800                                processDownloads (&bInternet);
    799801                                char *tmp =
     
    830832                                                       strlen(tmp),
    831833                                                       INTERNET_FLAG_NO_CACHE_WRITE,
    832                                                        0);
     834                                                       0,
     835                                                       *main_conf);
    833836                                    addIntToMap (tmpmaps->content, "Order", hInternet->nb);
    834837                                  }
  • branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c

    r862 r863  
    125125    char *tmp1;
    126126    map *tmpStatus;
     127    maps* tmpConf=createMaps("main");
     128    tmpConf->content=createMap("memory","load");
    127129    hInternet=InternetOpen("ZooWPSClient\0",
    128130                           INTERNET_OPEN_TYPE_PRECONFIG,
     
    178180                            (char*)jsonStr, strlen(jsonStr),
    179181                            INTERNET_FLAG_NO_CACHE_WRITE,
    180                             0);
     182                            0,tmpConf);
    181183    AddHeaderEntries(&hInternet,arg->conf);
    182184    //curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_VERBOSE, 1);x
    183185    processDownloads(&hInternet);
     186    freeMaps(&tmpConf);
     187    free(tmpConf);
    184188    now = time ( NULL );
    185189    tm = localtime ( &now );
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_java.c

    r790 r863  
    427427#endif
    428428      map* sizeV=getMap(tmp1,"size");
     429      map* useFile=getMap(tmp1,"use_file");
     430      map* cacheFile=getMap(tmp1,"cache_file");
    429431      map* isArray=getMap(tmp1,"isArray");
    430432      map* alen=getMap(tmp1,"length");
     
    432434        if(strcmp(tmp1->name,"value")==0){
    433435          if(isArray==NULL){
    434             if(sizeV!=NULL && strcmp(tmp1->name,"value")==0){
     436            if(sizeV!=NULL && strcmp(tmp1->name,"value")==0 && useFile==NULL){
    435437#ifdef JAVA7
    436438              jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
     
    448450              (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), (*env)->NewStringUTF(env,tmp1->value));
    449451#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             
    450459          }
    451460          else{
     
    455464            jclass scArrayListClass,scArrayList_class;
    456465            jmethodID scArrayList_constructor;
    457             jobject scObject2;
     466            jobject scObject2,scObject3;
    458467#ifdef JAVA7
    459468            scArrayListClass = (*env).FindClass("java/util/ArrayList");
     
    462471            jmethodID add_mid = 0;
    463472            scObject2 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
     473            scObject3 = (*env).NewObject(scArrayList_class, scArrayList_constructor);
    464474
    465475            add_mid = (*env).GetMethodID(scArrayListClass,
     
    471481            jmethodID add_mid = 0;
    472482            scObject2 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
     483            scObject3 = (*env)->NewObject(env, scArrayList_class, scArrayList_constructor);
    473484
    474485            add_mid = (*env)->GetMethodID(env,scArrayListClass,
     
    478489           
    479490            for(i=0;i<alen1;i++){
     491              map* cMap=getMapArray(tmp->content,"cache_file",i);
     492              map* uMap=getMapArray(tmp->content,"use_file",i);
    480493              map* vMap=getMapArray(tmp->content,"value",i);
    481494              map* sMap=getMapArray(tmp->content,"size",i);
    482495              map* mMap=getMapArray(tmp->content,tmap->value,i);
    483496             
    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){
    485498#ifdef JAVA7
    486499                jbyteArray tmpData=(*env).NewByteArray(atoi(sMap->value));
     
    501514#endif
    502515              }
    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              }
    504527            }
    505528
    506529#ifdef JAVA7
    507530            (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), scObject2);
     531            (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF("cache_file"), scObject3);
    508532#else       
    509533            (*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);
    510535#endif
    511536
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_js.c

    r839 r863  
    901901  char* tmpValue;
    902902  size_t dwRead;
     903  maps *tmpConf=createMaps("main");
     904  tmpConf->content=createMap("memory","load");
    903905  JS_MaybeGC(cx);
    904906  hInternet=InternetOpen("ZooWPSClient\0",
     
    929931#endif
    930932    InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
    931                     INTERNET_FLAG_NO_CACHE_WRITE,0);   
     933                    INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);   
    932934    processDownloads(&hInternet);
    933935    free(body);
     
    940942        }
    941943        InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
    942                         INTERNET_FLAG_NO_CACHE_WRITE,0);
     944                        INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
    943945        processDownloads(&hInternet);
    944946      }else{
    945947        char *body=JSValToChar(cx,&argv[2]);
    946948        InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],body,strlen(body),
    947                         INTERNET_FLAG_NO_CACHE_WRITE,0);
     949                        INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
    948950        processDownloads(&hInternet);
    949951        free(body);
     
    951953    }else{
    952954      InternetOpenUrl(&hInternet,hInternet.waitingRequests[hInternet.nb],NULL,0,
    953                       INTERNET_FLAG_NO_CACHE_WRITE,0);
     955                      INTERNET_FLAG_NO_CACHE_WRITE,0,tmpConf);
    954956      processDownloads(&hInternet);
    955957    }
     
    972974  if(argc>=2)
    973975    free(method);
     976  freeMaps(&tmpConf);
     977  free(tmpConf);
    974978  InternetCloseHandle(&hInternet);
    975979  JS_MaybeGC(cx);
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_python.c

    r854 r863  
    425425  map* isArray=getMap(tmp,"isArray");
    426426  map* size=getMap(tmp,"size");
     427  map* useFile=getMap(tmp,"use_file");
     428  map* cacheFile=getMap(tmp,"cache_file");
    427429  map* tmap=getMapType(tmp);
    428430  while(tmp!=NULL){
     
    435437        PyObject* mvalue=PyList_New(cnt);
    436438        PyObject* svalue=PyList_New(cnt);
     439        PyObject* cvalue=PyList_New(cnt);
    437440
    438441        for(int i=0;i<cnt;i++){
    439442         
    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);
    442447
    443448          if(vMap!=NULL){
     
    445450            PyObject* lvalue;
    446451            PyObject* lsvalue;
    447             if(sMap==NULL){
     452            PyObject* lcvalue;
     453            if(sMap==NULL || uMap!=NULL){
    448454              lvalue=PyString_FromString(vMap->value);
    449               lsvalue=Py_None;
    450455            }
    451456            else{   
    452457              lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value));
     458            }
     459            if(sMap!=NULL){
    453460              lsvalue=PyString_FromString(sMap->value);
    454461              hasSize=1;
    455462            }
     463            else
     464              lsvalue=Py_None;
     465            if(uMap!=NULL){
     466              lcvalue=PyString_FromString(cMap->value);;
     467            }else
     468              lcvalue=Py_None;
    456469
    457470            if(PyList_SetItem(value,i,lvalue)<0){
     
    463476              return NULL;
    464477            }
     478            if(PyList_SetItem(cvalue,i,lcvalue)<0){
     479              fprintf(stderr,"Unable to set key value pair...");
     480              return NULL;
     481            }
    465482          }
    466483         
     484          PyObject* lmvalue;
    467485          map* mMap=getMapArray(tmp,tmap->name,i);
    468           PyObject* lmvalue;
    469486          if(mMap!=NULL){
    470487            lmvalue=PyString_FromString(mMap->value);
     
    487504          return NULL;
    488505        }
     506        if(PyDict_SetItem(res,PyString_FromString("cache_file"),cvalue)<0){
     507          fprintf(stderr,"Unable to set key value pair...");
     508          return NULL;
     509        }
    489510        if(hasSize>0)
    490511          if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){
     
    493514          }
    494515      }
    495       else if(size!=NULL){
     516      else if(size!=NULL && useFile==NULL){
    496517        PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value));
    497518        if(PyDict_SetItem(res,name,value)<0){
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ruby.c

    r790 r863  
    260260  int hasSize=0;
    261261  map* isArray=getMap(tmp,"isArray");
     262  map* useFile=getMap(tmp,"use_file");
    262263  map* size=getMap(tmp,"size");
    263264  map* tmap=getMapType(tmp);
     
    271272        VALUE mvalue=rb_ary_new2(cnt);
    272273        VALUE svalue=rb_ary_new2(cnt);
     274        VALUE cvalue=rb_ary_new2(cnt);
    273275
    274276        for(int i=0;i<cnt;i++){
     
    276278          map* vMap=getMapArray(tmp,"value",i);     
    277279          map* sMap=getMapArray(tmp,"size",i);
     280          map* uMap=getMapArray(tmp,"use_file",i);
     281          map* cMap=getMapArray(tmp,"cache_file",i);
    278282
    279283          if(vMap!=NULL){
     
    281285            VALUE lvalue;
    282286            VALUE lsvalue;
    283             if(sMap==NULL){
     287            VALUE lcvalue;
     288            if(sMap==NULL || uMap==NULL){
    284289              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);
    286294            }
    287295            else{
     
    290298              hasSize=1;
    291299            }
     300            if(uMap!=NULL)
     301              lcvalue=rb_str_new2(cMap->value);
     302            else
     303              lcvalue=Qnil;
    292304
    293305            rb_ary_push(value,lvalue);
    294306            rb_ary_push(svalue,lsvalue);
     307            rb_ary_push(cvalue,lcvalue);
    295308          }
    296309         
     
    308321        rb_hash_aset(res, name, mvalue);
    309322        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);
    310325     
    311326        if(hasSize>0){
  • branches/prototype-v0/zoo-project/zoo-kernel/sqlapi.c

    r860 r863  
    379379  char *sqlQuery=(char*)malloc((strlen(schema->value)+strlen(msg->value)+strlen(p->value)+strlen(sid->value)+64+1)*sizeof(char));
    380380  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 ){
    388382    init_sql(conf);
    389383    zoo_ds_nb++;
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c

    r862 r863  
    7070
    7171/**
    72  * Write the downloaded content to a _HINTERNET structure
     72 * Write the downloaded content in the file pouted by the _HINTERNET structure
    7373 *
    7474 * @param buffer the buffer to read
     
    8989   psInternet=(_HINTERNET *)data;
    9090   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
    9694   buffer=NULL;
    9795   return realsize;
     
    443441 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file)
    444442 * @param dwContext not used
     443 * @param conf the main configuration file maps pointer
    445444 * @return the updated HINTERNET
    446445 */
    447 HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
     446HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext,const maps* conf){
    448447
    449448  char filename[255];
     449  int ldwFlags=INTERNET_FLAG_NEED_FILE;
    450450  struct MemoryStruct header;
     451  map* memUse=getMapFromMaps(conf,"main","memory");
    451452
    452453  hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
     
    480481  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1);
    481482#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)
    484488    {
    485489    case INTERNET_FLAG_NO_CACHE_WRITE:
     
    491495      memset(filename,0,255);
    492496      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);
    494507      free(tmpUuid);
    495508      hInternet->ihandle[hInternet->nb].filename=strdup(filename);
  • branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h

    r854 r863  
    100100  size_t write_data_into(void*,size_t,size_t,void*);
    101101
     102  size_t write_data_into_file(void*,size_t,size_t,void*);
     103
    102104  size_t header_write_data(void*,size_t,size_t,void*);
    103105
     
    158160#  define CHECK_INET_HANDLE(h) (h.handle != 0)
    159161
    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*);
    161163
    162164  int processDownloads(HINTERNET*);
  • branches/prototype-v0/zoo-project/zoo-services/cgal/cgal_service.c

    r862 r863  
    2626int parseInput(maps* conf,maps* inputs, std::vector<Pointz>* points,char* filename){
    2727  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");
    3129#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;
    3631#else
    37   OGRDataSource* ipoDS = OGRSFDriverRegistrar::Open(filename,FALSE);
     32  OGRDataSource* ipoDS;
    3833#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   
    3954  if( ipoDS == NULL )
    4055    {
  • branches/prototype-v0/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py

    r465 r863  
    9595
    9696def 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   
    97115    if obj["mimeType"]=="application/json":
    98116        return createLayerFromJson(conf,obj["value"])
  • branches/prototype-v0/zoo-project/zoo-services/ogr/ogr2ogr/service.c

    r862 r863  
    366366          dfMaxSegmentLength = atof(tmpMap->value);
    367367    }
    368 
    369     /*tmpMap=NULL;
    370     tmpMap=getMapFromMaps(inputs,"segmentize","value");
    371     if(tmpMap!=NULL){
    372           dfMaxSegmentLength = atof(tmpMap->value);
    373     }*/
    374 
    375368   
    376369    tmpMap=NULL;
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