Ignore:
Timestamp:
Nov 21, 2017, 10:24:14 AM (6 years ago)
Author:
djay
Message:

HPC support update. Add inputs for create options in Gdal_Dem.

File:
1 edited

Legend:

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

    r851 r854  
    211211  ret.agent=strdup(lpszAgent);
    212212  ret.nb=0;
     213  ret.waitingRequests[ret.nb] = NULL;
    213214  ret.ihandle[ret.nb].header=NULL;
     215  ret.ihandle[ret.nb].handle=NULL;
     216  ret.ihandle[ret.nb].hasCacheFile=0;
     217  ret.ihandle[ret.nb].nDataAlloc = 0;
     218  ret.ihandle[ret.nb].url = NULL;
     219  ret.ihandle[ret.nb].mimeType = NULL;
     220  ret.ihandle[ret.nb].cookie = NULL;
     221  ret.ihandle[ret.nb].nDataLen = 0;
     222  ret.ihandle[ret.nb].nDataAlloc = 0;
     223  ret.ihandle[ret.nb].pabyData = NULL;
     224  ret.ihandle[ret.nb].post = NULL;
    214225  return ret;
     226}
     227
     228/**
     229 * Verify if the URL should use a shared cache or not.
     230 *
     231 * In case the security section contains a key named "shared", then if the
     232 * domain listed in the shared key are contained in the url given as parameter
     233 * then it return "SHARED" in other cases, it returns "OTHER".
     234 *
     235 * @param conf the main configuration file maps
     236 * @param url the URL to evaluate
     237 * @return a string "SHARED" in case the host is in a domain listed in the
     238 * shared key, "OTHER" in other cases.
     239 */
     240char* getProvenance(maps* conf,const char* url){
     241  map* sharedCache=getMapFromMaps(conf,"security","shared");
     242  if(sharedCache!=NULL){
     243    char *res=NULL;
     244    char *hosts=sharedCache->value;
     245    char *curs=strtok(hosts,",");
     246    while(curs!=NULL){
     247      fprintf(stderr,"### %s %d %s \n",__FILE__,__LINE__,strstr(url,curs));
     248      fflush(stderr);
     249      if(strstr(url,curs)==NULL)
     250        res="OTHER";
     251      else{
     252        res="SHARED";
     253        fprintf(stderr,"### %s %d %s \n",__FILE__,__LINE__,"SHARED");
     254        fflush(stderr);
     255        return res;
     256      }
     257      curs=strtok(NULL,",");
     258    }
     259    return res;
     260  }
     261  return "OTHER";
    215262}
    216263
     
    282329    int i;
    283330    for(i=0;i<handle->nb;i++){
    284       if(targetHosts->value[0]=='*' || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){
     331      if(strstr(targetHosts->value,"*")!=NULL || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){
    285332        while (token != NULL){
    286333          int length=strlen(token)+6;
     
    297344          }
    298345          fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,tmp1);
    299           if(strncmp(tmp1,"HTTP_COOKIE",11)!=0){           
    300             tmpMap = getMapFromMaps(conf,"renv",tmp1);
    301             if(tmpMap!=NULL)
    302               AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value);
     346          //dumpMaps(conf);
     347          tmpMap = getMapFromMaps(conf,"renv",tmp1);
     348          if(tmpMap!=NULL){
     349            fprintf(stderr,"add header %s %s\n",token,tmpMap->value);
     350            fflush(stderr);
     351            AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value);
    303352          }
    304353          free(tmp1);
     
    321370void InternetCloseHandle(HINTERNET* handle0){
    322371  int i=0;
    323   for(i=0;i<handle0->nb;i++){
    324     _HINTERNET handle=handle0->ihandle[i];
    325     if(handle.hasCacheFile>0){
    326       fclose(handle.file);
    327       unlink(handle.filename);
    328     }
    329     else{
    330       handle.pabyData = NULL;
    331       handle.nDataAlloc = handle.nDataLen = 0;
    332     }
    333     if(handle0->ihandle[i].header!=NULL){
    334       curl_slist_free_all(handle0->ihandle[i].header);
    335       handle0->ihandle[i].header=NULL;
    336     }
    337     if(handle.post!=NULL)
    338       free(handle.post);
    339     if(handle.url!=NULL)
    340       free(handle.url);
    341     if(handle.mimeType!=NULL)
    342       free(handle.mimeType);
    343     if(handle.cookie!=NULL)
    344       free(handle.cookie);
    345   }
    346   fprintf(stderr,"%s%d\n",__FILE__,__LINE__);
    347   fflush(stderr);
    348   if(handle0->handle)
    349     curl_multi_cleanup(handle0->handle);
    350   fprintf(stderr,"%s%d\n",__FILE__,__LINE__);
    351   fflush(stderr);
    352   free(handle0->agent);
    353   fprintf(stderr,"%s%d\n",__FILE__,__LINE__);
    354   fflush(stderr);
    355   for(i=handle0->nb-1;i>=0;i--){
    356     fprintf(stderr,"%s%d\n",__FILE__,__LINE__);
    357     fflush(stderr);
    358     free(handle0->waitingRequests[i]);
    359       fprintf(stderr,"%s%d\n",__FILE__,__LINE__);
    360       fflush(stderr);
     372  if(handle0!=NULL){
     373    for(i=0;i<handle0->nb;i++){
     374      _HINTERNET handle=handle0->ihandle[i];
     375      if(handle.hasCacheFile>0){
     376        fclose(handle.file);
     377        unlink(handle.filename);
     378      }
     379      else{
     380        handle.pabyData = NULL;
     381        handle.nDataAlloc = handle.nDataLen = 0;
     382      }
     383      if(handle.header!=NULL){
     384        curl_slist_free_all(handle.header);
     385        handle.header=NULL;
     386      }
     387      if(handle.post!=NULL){
     388        free(handle.post);
     389        handle.post=NULL;
     390      }
     391      if(handle.url!=NULL){
     392        free(handle.url);
     393        handle.url=NULL;
     394      }
     395      if(handle.mimeType!=NULL){
     396        free(handle.mimeType);
     397        handle.mimeType=NULL;
     398      }
     399      if(handle.cookie!=NULL){
     400        free(handle.cookie);
     401        handle.cookie=NULL;
     402      }
     403      if(handle0->waitingRequests[i]!=NULL){
     404        free(handle0->waitingRequests[i]);
     405        handle0->waitingRequests[i]=NULL;
     406      }
     407    }
     408    if(handle0->handle)
     409      curl_multi_cleanup(handle0->handle);
     410    if(handle0->agent!=NULL){
     411      free(handle0->agent);
     412      handle0->agent=NULL;
     413    }
    361414  }
    362415}
     
    377430  struct MemoryStruct header;
    378431
     432  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     433  fflush(stderr);
    379434  hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
     435  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     436  fflush(stderr);
    380437  hInternet->ihandle[hInternet->nb].hasCacheFile=0;
     438  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     439  fflush(stderr);
    381440  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
     441  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     442  fflush(stderr);
    382443  hInternet->ihandle[hInternet->nb].url = NULL;
     444  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     445  fflush(stderr);
    383446  hInternet->ihandle[hInternet->nb].mimeType = NULL;
     447  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     448  fflush(stderr);
    384449  hInternet->ihandle[hInternet->nb].cookie = NULL;
     450  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     451  fflush(stderr);
    385452  hInternet->ihandle[hInternet->nb].nDataLen = 0;
     453  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     454  fflush(stderr);
    386455  hInternet->ihandle[hInternet->nb].id = hInternet->nb;
     456  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     457  fflush(stderr);
    387458  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
     459  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     460  fflush(stderr);
    388461  hInternet->ihandle[hInternet->nb].pabyData = NULL;
     462  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     463  fflush(stderr);
    389464  hInternet->ihandle[hInternet->nb].post = NULL;
     465  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     466  fflush(stderr);
    390467 
    391468  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
     469  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     470  fflush(stderr);
    392471#ifndef TIGER
    393472  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIELIST, "ALL");
    394473#endif
    395474  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_USERAGENT, hInternet->agent);
     475  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     476  fflush(stderr);
    396477 
    397478  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_FOLLOWLOCATION,1);
     479  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     480  fflush(stderr);
    398481  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_MAXREDIRS,3);
     482  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     483  fflush(stderr);
    399484 
    400485  header.memory=NULL;
     
    402487
    403488  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_HEADERFUNCTION, header_write_data);
     489  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     490  fflush(stderr);
    404491  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEHEADER, (void *)&header);
     492  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     493  fflush(stderr);
    405494
    406495#ifdef MSG_LAF_VERBOSE
     
    431520      break;
    432521    }
     522  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     523  fflush(stderr);
    433524#ifdef ULINET_DEBUG
    434525  fprintf(stderr,"URL (%s)\nBODY (%s)\n",lpszUrl,lpszHeaders);
     
    448539    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,(long)dwHeadersLength);
    449540  }
     541  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     542  fflush(stderr);
    450543  if(hInternet->ihandle[hInternet->nb].header!=NULL)
    451544    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_HTTPHEADER,hInternet->ihandle[hInternet->nb].header);
    452545
     546  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     547  fflush(stderr);
    453548  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_URL,lpszUrl);
    454549  hInternet->ihandle[hInternet->nb].url = zStrdup(lpszUrl);
     550  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     551  fflush(stderr);
    455552
    456553  curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
     554  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     555  fflush(stderr);
    457556 
    458557  hInternet->ihandle[hInternet->nb].header=NULL;
     558  fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     559  fflush(stderr);
    459560  ++hInternet->nb;
     561  hInternet->ihandle[hInternet->nb].header=NULL;
    460562
    461563#ifdef ULINET_DEBUG
     
    481583  for(i=0;i<hInternet->nb;i++){
    482584    char *tmp;
     585    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    483586    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_CONTENT_TYPE,&tmp);
     587    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    484588    if(tmp!=NULL)
    485589      hInternet->ihandle[i].mimeType=strdup(tmp);
     590    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    486591    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_RESPONSE_CODE,&hInternet->ihandle[i].code);
     592    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    487593    curl_multi_remove_handle(hInternet->handle, hInternet->ihandle[i].handle);
     594    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    488595    curl_easy_cleanup(hInternet->ihandle[i].handle);
     596    fprintf(stderr," *** %s %d %d \n",__FILE__,__LINE__,i);
    489597    //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].mimeType);
    490598    //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].pabyData);
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