source: branches/prototype-v0/zoo-project/zoo-kernel/ulinet.c @ 839

Last change on this file since 839 was 839, checked in by djay, 7 years ago

Update the source code for HPC support. Automatically adding nested outputs for the HPC support (should this be available for every support?). Add capability to store the metadata in the Collection DataBase?. Addition of the zcfg2sql to import any existing ZCFG file into the Collection DB. Add the support to invoke a callback (for history purpose) in case a [callback] section contains at least one parameter defined (url). Add support to convert maps and map to JSON (for callback use only by now). Fix some memory leaks (some are still there).

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc
File size: 18.1 KB
Line 
1/*
2 *  ulinet.c
3 *
4 * Author : Gérald FENOY
5 *
6 * Copyright (c) 2008-2015 GeoLabs SARL
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27
28#define _ULINET
29#define MAX_WAIT_MSECS 180*1000 /* Wait max. 180 seconds */
30#include "ulinet.h"
31#include <assert.h>
32#include <ctype.h>
33
34/**
35 * Write the downloaded content to a _HINTERNET structure
36 *
37 * @param buffer the buffer to read
38 * @param size size of each member
39 * @param nmemb number of element to read
40 * @param data the _HINTERNET structure to write in
41 * @return the size red, -1 if buffer is NULL
42 */
43size_t write_data_into(void *buffer, size_t size, size_t nmemb, void *data){
44  size_t realsize = size * nmemb;
45  _HINTERNET *psInternet;
46  if(buffer==NULL){
47    buffer=NULL;
48    return -1;
49  }
50  psInternet=(_HINTERNET *)data;
51  if(psInternet->pabyData){
52    psInternet->pabyData=(unsigned char*)realloc(psInternet->pabyData,psInternet->nDataLen+realsize+1);
53    psInternet->nDataAlloc+=psInternet->nDataLen+realsize+1;
54  }
55  else{
56    psInternet->pabyData=(unsigned char*)malloc(psInternet->nDataLen+realsize+1);
57    psInternet->nDataAlloc=realsize+1;
58  }
59
60  if (psInternet->pabyData) {
61    memcpy( psInternet->pabyData + psInternet->nDataLen, buffer, realsize);
62    psInternet->nDataLen += realsize;
63    psInternet->pabyData[psInternet->nDataLen] = 0;
64  }
65
66  buffer=NULL;
67  return realsize;
68}
69
70/**
71 * In case of presence of "Set-Cookie" in the headers red, store the cookie
72 * identifier in cookie
73 *
74 * @param buffer the buffer to read
75 * @param size size of each member
76 * @param nmemb number of element to read
77 * @param data the _HINTERNET structure to write in
78 * @return the size red, -1 if buffer is NULL
79 * @see cookie
80 */
81size_t header_write_data(void *buffer, size_t size, size_t nmemb, void *data){
82  if(strncmp("Set-Cookie: ",(char*)buffer,12)==0){
83    int i;
84    char* tmp;
85    for(i=0;i<12;i++)
86#ifndef WIN32
87      buffer++;
88#else
89        ;
90#endif
91    tmp=strtok(buffer,";");
92    int cnt=0;
93    _HINTERNET *psInternet=(_HINTERNET *)data;
94    if(tmp!=NULL && psInternet!=NULL){
95      psInternet->cookie=(char*)malloc(sizeof(char)*(strlen(tmp)+1));
96      sprintf(psInternet->cookie,"%s",tmp);
97    }
98  }
99  return size * nmemb;//write_data_into(buffer,size,nmemb,data,HEADER);
100};
101
102/**
103 * Define the proxy to use for a CURL handler
104 *
105 * @param handle the CURL handler
106 * @param host the proxy host (including http://)
107 * @param port the proxy port
108 */
109void setProxy(CURL* handle,char* host,long port){
110  char* proxyDef=(char*)malloc((strlen(host)+10+2)*sizeof(char));
111  sprintf(proxyDef,"%s:%ld",host,port);
112  curl_easy_setopt(handle,CURLOPT_PROXY,proxyDef);
113  free(proxyDef);
114}
115
116/**
117 * MACOSX
118 */
119#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
120
121
122char* CFStringToCString(CFStringRef dest,char *buffer){
123  CFStringEncoding encoding = kCFStringEncodingUTF8;
124  Boolean bool2 = CFStringGetCString(dest,buffer,1024,encoding);
125  if(bool2){
126    printf("Loaded into local_buffer");
127    return buffer;
128  }
129  return NULL;
130}
131
132OSStatus setProxiesForProtcol(CURL* handle,const char *proto){
133  OSStatus              err;
134  CFDictionaryRef proxyDict;
135  CFArrayRef            proxies;
136 
137  CFStringRef key_enabled = NULL;
138  CFStringRef key_host = NULL;
139  CFStringRef key_port = NULL;
140 
141  bool proxy_enabled;
142  char *proxy_host;
143  long proxy_port;
144 
145  proxyDict = NULL;
146  proxies = NULL;
147
148  err = noErr;
149  proxyDict = SCDynamicStoreCopyProxies(NULL);
150
151  if(strncmp(proto,"http",4)==0){
152      key_enabled=kSCPropNetProxiesHTTPEnable;
153      key_host=kSCPropNetProxiesHTTPProxy;
154      key_port=kSCPropNetProxiesHTTPPort;
155  }
156  else
157    if(strncmp(proto,"https",5)==0){
158      key_enabled=kSCPropNetProxiesHTTPSEnable;
159      key_host=kSCPropNetProxiesHTTPSProxy;
160      key_port=kSCPropNetProxiesHTTPSPort;
161    }
162
163  CFNumberGetValue(CFDictionaryGetValue(proxyDict,key_enabled),kCFNumberIntType,&proxy_enabled);
164  if(proxy_enabled){
165    CFNumberGetValue(CFDictionaryGetValue(proxyDict,key_port),CFNumberGetType(CFDictionaryGetValue(proxyDict,key_port)),&proxy_port);
166    char buffer[1024];
167    CFStringToCString(CFDictionaryGetValue(proxyDict,key_host),buffer);
168    proxy_host=buffer;
169
170#ifdef MSG_LAF_VERBOSE
171    printf("\n**[PROXY SETTINGS DETECTION %s (%d) %s:%li (%s)]**\n",proto,proxy_enabled,(char*)proxy_host,proxy_port,buffer);
172#endif
173
174    if (proxyDict == NULL) {
175      err = coreFoundationUnknownErr;
176    }
177
178    setProxy(handle,proxy_host,proxy_port);
179  }
180  return err;
181}
182#else
183/**
184 * Should autodetect the proxy configuration (do nothing on linux)
185 *
186 * @param handle a CURL handle
187 * @param proto the protocol requiring the use of a proxy
188 */
189int setProxiesForProtcol(CURL* handle,const char *proto){
190#ifdef MSG_LAF_VERBOSE
191  fprintf( stderr, "setProxiesForProtocol (do nothing) ...\n" );
192#endif
193  return 0;
194}
195#endif
196
197/**
198 * Create a HINTERNET
199 *
200 * @param lpszAgent the HTPP User-Agent to use to send requests
201 * @param  dwAccessType type of access required
202 * @param  lpszProxyName the name of the proxy server(s) to use
203 * @param  lpszProxyBypass ip address or host names which should not be routed
204 *  through the proxy
205 * @param  dwFlags Options (INTERNET_FLAG_ASYNC,INTERNET_FLAG_FROM_CACHE,INTERNET_FLAG_OFFLINE)
206 * @return the created HINTERNET
207 */
208HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){
209  HINTERNET ret;
210  ret.handle=curl_multi_init();
211  ret.agent=strdup(lpszAgent);
212  ret.nb=0;
213  ret.ihandle[ret.nb].header=NULL;
214  return ret;
215}
216
217/**
218 * Add missing headers to an existing _HINTERNET
219 *
220 *
221 * @param handle the _HINTERNET pointer
222 * @param key the header parameter name
223 * @param value the header parameter value
224 * @return 0 if the operation succeeded, -1 in other case.
225 */
226int AddMissingHeaderEntry(_HINTERNET* handle,const char* key,const char* value){
227  int length=strlen(key)+strlen(value)+3;
228  char *entry=(char*)malloc((length)*sizeof(char));
229  if(entry==NULL)
230    return -1;
231  snprintf (entry, length, "%s: %s", key, value);
232  handle->header = curl_slist_append (handle->header, entry);
233  free(entry);
234  return 0;
235}
236
237/**
238 * Verify if a host is protected (appear in [security] > hosts)
239 *
240 * @param protectedHosts string containing all the protected hosts (coma separated)
241 * @param url string used to extract the host from
242 * @return 1 if the host is listed as protected, 0 in other case
243 */
244int isProtectedHost(const char* protectedHosts,const char* url){
245  char *token, *saveptr;
246  token = strtok_r (url, "//", &saveptr);
247  int cnt=0;
248  char* host;
249  while(token!=NULL && cnt<=1){
250    fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,token);
251    if(cnt==1)
252      fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,strstr(protectedHosts,token));
253    fflush(stderr);
254    if(cnt==1 && strstr(protectedHosts,token)!=NULL){
255      fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,strstr(protectedHosts,token));
256      return 1;
257    }
258    token = strtok_r (NULL, "/", &saveptr);
259    cnt+=1;
260  }
261  return 0;
262}
263
264/**
265 * Add headers defined in [security] > attributes to an existing HINTERNET
266 * @see isProtectedHost, AddMissingHeaderEntry
267 *
268 * @param handle the _HINTERNET pointer
269 * @param conf the header parameter name
270 * @param value the header parameter value
271 * @return 0 if the operation succeeded, -1 in other case.
272 */
273void AddHeaderEntries(HINTERNET* handle,maps* conf){
274  map* passThrough=getMapFromMaps(conf,"security","attributes");
275  map* targetHosts=getMapFromMaps(conf,"security","hosts");
276  char* passedHeader[10];
277  int cnt=0;
278  if(passThrough!=NULL && targetHosts!=NULL){
279    char *tmp=zStrdup(passThrough->value);
280    char *token, *saveptr;
281    token = strtok_r (tmp, ",", &saveptr);
282    int i;
283    for(i=0;i<handle->nb;i++){
284      if(targetHosts->value[0]=='*' || isProtectedHost(targetHosts->value,handle->ihandle[i].url)==1){
285        while (token != NULL){
286          int length=strlen(token)+6;
287          char* tmp1=(char*)malloc(length*sizeof(char));
288          snprintf(tmp1,6,"HTTP_");
289          int j;
290          for(j=0;token[j]!='\0';j++){
291            if(token[j]!='-')
292              tmp1[5+j]=toupper(token[i]);
293            else
294              tmp1[5+j]='_';
295            tmp1[5+j+1]='\0';
296          }
297          fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,tmp1);
298          map* tmpMap = getMapFromMaps(conf,"renv",tmp1);
299          if(tmpMap!=NULL)         
300            AddMissingHeaderEntry(&handle->ihandle[i],token,tmpMap->value);
301          free(tmp1);
302          if(handle->ihandle[i].header!=NULL)
303            curl_easy_setopt(handle->ihandle[i].handle,CURLOPT_HTTPHEADER,handle->ihandle[i].header);
304          cnt+=1;
305          token = strtok_r (NULL, ",", &saveptr);
306        }
307      }
308    }
309    free(tmp);
310  }
311}
312
313/**
314 * Close a HINTERNET connection and free allocated resources
315 *
316 * @param handle0 the HINTERNET connection to close
317 */
318void InternetCloseHandle(HINTERNET* handle0){
319  int i=0;
320  for(i=0;i<handle0->nb;i++){
321    _HINTERNET handle=handle0->ihandle[i];
322    if(handle.hasCacheFile>0){
323      fclose(handle.file);
324      unlink(handle.filename);
325    }
326    else{
327      handle.pabyData = NULL;
328      handle.nDataAlloc = handle.nDataLen = 0;
329    }
330    if(handle0->ihandle[i].header!=NULL){
331      curl_slist_free_all(handle0->ihandle[i].header);
332      handle0->ihandle[i].header=NULL;
333    }
334    if(handle.post!=NULL)
335      free(handle.post);
336    if(handle.url!=NULL)
337      free(handle.url);
338    if(handle.mimeType!=NULL)
339      free(handle.mimeType);
340    if(handle.cookie!=NULL)
341      free(handle.cookie);
342  }
343  if(handle0->handle)
344    curl_multi_cleanup(handle0->handle);
345  free(handle0->agent);
346  for(i=handle0->nb-1;i>=0;i--){
347    free(handle0->waitingRequests[i]);
348  }
349}
350
351/**
352 * Create a new element in the download queue
353 *
354 * @param hInternet the HINTERNET connection to add the download link
355 * @param lpszUrl the url to download
356 * @param lpszHeaders the additional headers to be sent to the HTTP server
357 * @param dwHeadersLength the size of the additional headers
358 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file)
359 * @param dwContext not used
360 */
361HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){
362
363  char filename[255];
364  struct MemoryStruct header;
365
366  hInternet->ihandle[hInternet->nb].handle=curl_easy_init( );
367  hInternet->ihandle[hInternet->nb].hasCacheFile=0;
368  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
369  hInternet->ihandle[hInternet->nb].url = NULL;
370  hInternet->ihandle[hInternet->nb].mimeType = NULL;
371  hInternet->ihandle[hInternet->nb].cookie = NULL;
372  hInternet->ihandle[hInternet->nb].nDataLen = 0;
373  hInternet->ihandle[hInternet->nb].id = hInternet->nb;
374  hInternet->ihandle[hInternet->nb].nDataAlloc = 0;
375  hInternet->ihandle[hInternet->nb].pabyData = NULL;
376  hInternet->ihandle[hInternet->nb].post = NULL;
377 
378  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIEFILE, "ALL");
379#ifndef TIGER
380  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_COOKIELIST, "ALL");
381#endif
382  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_USERAGENT, hInternet->agent);
383 
384  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_FOLLOWLOCATION,1);
385  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_MAXREDIRS,3);
386 
387  header.memory=NULL;
388  header.size = 0;
389
390  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_HEADERFUNCTION, header_write_data);
391  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEHEADER, (void *)&header);
392
393#ifdef MSG_LAF_VERBOSE
394  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_VERBOSE, 1);
395#endif
396
397     
398  switch(dwFlags)
399    {
400    case INTERNET_FLAG_NO_CACHE_WRITE:
401      hInternet->ihandle[hInternet->nb].hasCacheFile=-1;
402      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, write_data_into);
403      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, (void*)&hInternet->ihandle[hInternet->nb]);
404      break;
405    default:
406      sprintf(hInternet->ihandle[hInternet->nb].filename,"/tmp/ZOO_Cache%d",(int)time(NULL));
407      hInternet->ihandle[hInternet->nb].filename[24]=0;
408#ifdef MSG_LAF_VERBOSE
409      fprintf(stderr,"file=%s",hInternet->ihandle[hInternet->nb].filename);
410#endif
411      hInternet->ihandle[hInternet->nb].filename=filename;
412      hInternet->ihandle[hInternet->nb].file=fopen(hInternet->ihandle[hInternet->nb].filename,"w+");
413   
414      hInternet->ihandle[hInternet->nb].hasCacheFile=1;
415      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEFUNCTION, NULL);
416      curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle, CURLOPT_WRITEDATA, hInternet->ihandle[hInternet->nb].file);
417      hInternet->ihandle[hInternet->nb].nDataLen=0;
418      break;
419    }
420#ifdef ULINET_DEBUG
421  fprintf(stderr,"URL (%s)\nBODY (%s)\n",lpszUrl,lpszHeaders);
422#endif
423  if(lpszHeaders!=NULL && strlen(lpszHeaders)>0){
424#ifdef MSG_LAF_VERBOSE
425    fprintf(stderr,"FROM ULINET !!");
426    fprintf(stderr,"HEADER : [%s] %d\n",lpszHeaders,dwHeadersLength);
427#endif
428    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POST,1);
429#ifdef ULINET_DEBUG
430    fprintf(stderr,"** (%s) %d **\n",lpszHeaders,dwHeadersLength);
431    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_VERBOSE,1);
432#endif
433    hInternet->ihandle[hInternet->nb].post=strdup(lpszHeaders);
434    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDS,hInternet->ihandle[hInternet->nb].post);
435    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_POSTFIELDSIZE,(long)dwHeadersLength);
436  }
437  if(hInternet->ihandle[hInternet->nb].header!=NULL)
438    curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_HTTPHEADER,hInternet->ihandle[hInternet->nb].header);
439
440  curl_easy_setopt(hInternet->ihandle[hInternet->nb].handle,CURLOPT_URL,lpszUrl);
441  hInternet->ihandle[hInternet->nb].url = zStrdup(lpszUrl);
442
443  curl_multi_add_handle(hInternet->handle,hInternet->ihandle[hInternet->nb].handle);
444 
445  hInternet->ihandle[hInternet->nb].header=NULL;
446  ++hInternet->nb;
447
448#ifdef ULINET_DEBUG
449  fprintf(stderr,"DEBUG MIMETYPE: %s\n",hInternet.mimeType);
450  fflush(stderr);
451#endif
452  return *hInternet;
453};
454
455/**
456 * Download all opened urls in the queue
457 *
458 * @param hInternet the HINTERNET structure containing the queue
459 * @return 0
460 */
461int processDownloads(HINTERNET* hInternet){
462  int still_running=0;
463  int msgs_left=0;
464  int i=0;
465  do{
466    curl_multi_perform(hInternet->handle, &still_running);
467  }while(still_running); 
468  for(i=0;i<hInternet->nb;i++){
469    char *tmp;
470    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_CONTENT_TYPE,&tmp);
471    if(tmp!=NULL)
472      hInternet->ihandle[i].mimeType=strdup(tmp);
473    curl_easy_getinfo(hInternet->ihandle[i].handle,CURLINFO_RESPONSE_CODE,&hInternet->ihandle[i].code);
474    curl_multi_remove_handle(hInternet->handle, hInternet->ihandle[i].handle);
475    curl_easy_cleanup(hInternet->ihandle[i].handle);
476    //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].mimeType);
477    //fprintf(stderr,"%s %d %s \n",__FILE__,__LINE__,hInternet->ihandle[i].pabyData);
478  }
479  return 0;
480}
481
482/**
483 * Initialize the cookie for a specific index (hInternet.nb)
484 *
485 * @param hInternet the HINTERNET structure to know the cookie index to reset
486 * @return 1
487 * @see HINTERNET
488 */
489int freeCookieList(HINTERNET hInternet){
490  hInternet.ihandle[hInternet.nb].cookie=strdup("");
491#ifndef TIGER
492  curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_COOKIELIST, "ALL");
493#endif
494  return 1;
495}
496
497/**
498 * Copy a downloaded content
499 *
500 * @param hInternet the _HINTERNET structure
501 * @param lpBuffer the memory space to copy the downloaded content
502 * @param dwNumberOfBytesToRead the size of lpBuffer
503 * @param lpdwNumberOfBytesRead number of bytes red
504 * @return 1 on success, 0 if failure
505 */
506int InternetReadFile(_HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead){
507  int dwDataSize;
508
509  if(hInternet.hasCacheFile>0){
510    fseek (hInternet.file , 0 , SEEK_END);
511    dwDataSize=ftell(hInternet.file); //taille du ficher
512    rewind (hInternet.file);
513  }
514  else{
515    memset(lpBuffer,0,hInternet.nDataLen+1);
516    memcpy(lpBuffer, hInternet.pabyData, hInternet.nDataLen );
517    dwDataSize=hInternet.nDataLen;
518    free( hInternet.pabyData );
519    hInternet.pabyData=NULL;
520  }
521
522  if( dwNumberOfBytesToRead /* buffer size */ < dwDataSize )
523    return 0;
524
525#ifdef MSG_LAF_VERBOSE
526  printf("\nfile size : %dko\n",dwDataSize/1024);
527#endif
528
529  if(hInternet.hasCacheFile>0){
530    *lpdwNumberOfBytesRead = fread(lpBuffer,1,dwDataSize,hInternet.file); 
531  }
532  else{
533    *lpdwNumberOfBytesRead = hInternet.nDataLen;
534    free( hInternet.pabyData );
535    hInternet.pabyData = NULL;
536    hInternet.nDataAlloc = hInternet.nDataLen = 0;
537  }
538
539  if( *lpdwNumberOfBytesRead < dwDataSize )
540      return 0;
541  else
542      return 1; // TRUE
543}
544
545
546/**
547 * Use basic authentication for accessing a resource
548 *
549 * @param hInternet the _HINTERNET structure
550 * @param login the login to use to authenticate
551 * @param passwd the password to use to authenticate
552 */
553int setBasicAuth(HINTERNET hInternet,char* login,char* passwd){
554  char *tmp;
555  tmp=(char*)malloc((strlen(login)+strlen(passwd)+2)*sizeof(char));
556  sprintf(tmp,"%s:%s",login,passwd);
557  if(curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle,CURLOPT_USERPWD,tmp)==CURLE_OUT_OF_MEMORY){
558    free(tmp);
559    return -1;
560  }
561  curl_easy_setopt(hInternet.ihandle[hInternet.nb].handle, CURLOPT_HTTPAUTH,CURLAUTH_ANY);
562  free(tmp);
563  return 0;
564}
Note: See TracBrowser for help on using the repository browser.

Search

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