Changeset 579 for trunk/zoo-project/zoo-kernel/ulinet.c
- Timestamp:
- Feb 12, 2015, 5:01:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/ulinet.c
r539 r579 1 /* *1 /* 2 2 * ulinet.c 3 3 * 4 4 * Author : Gérald FENOY 5 5 * 6 * Copyright (c) 2008-201 0GeoLabs SARL6 * Copyright (c) 2008-2015 GeoLabs SARL 7 7 * 8 8 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 30 30 #include "ulinet.h" 31 31 #include <assert.h> 32 32 33 /** 34 * Write the downloaded content to a _HINTERNET structure 35 * 36 * @param buffer the buffer to read 37 * @param size size of each member 38 * @param nmemb number of element to read 39 * @param data the _HINTERNET structure to write in 40 * @return the size red, -1 if buffer is NULL 41 */ 33 42 size_t write_data_into(void *buffer, size_t size, size_t nmemb, void *data){ 34 43 size_t realsize = size * nmemb; … … 58 67 } 59 68 69 /** 70 * In case of presence of "Set-Cookie" in the headers red, store the cookie 71 * identifier in CCookie 72 * 73 * @param buffer the buffer to read 74 * @param size size of each member 75 * @param nmemb number of element to read 76 * @param data the _HINTERNET structure to write in 77 * @return the size red, -1 if buffer is NULL 78 * @see CCookie 79 */ 60 80 size_t header_write_data(void *buffer, size_t size, size_t nmemb, void *data){ 61 81 if(strncmp("Set-Cookie: ",(char*)buffer,12)==0){ … … 82 102 }; 83 103 84 104 /** 105 * Define the proxy to use for a CURL handler 106 * 107 * @param handle the CURL handler 108 * @param host the proxy host (including http://) 109 * @param port the proxy port 110 */ 85 111 void setProxy(CURL* handle,char* host,long port){ 112 char* proxyDef=(char*)malloc((strlen(host)+10+2)*sizeof(char)); 113 sprintf(proxyDef,"%s:%ld",host,port); 114 curl_easy_setopt(handle,CURLOPT_PROXY,proxyDef); 115 free(proxyDef); 86 116 } 87 117 … … 154 184 #else 155 185 /** 156 * Linux (Gnome) 186 * Should autodetect the proxy configuration (do nothing on linux) 187 * 188 * @param handle a CURL handle 189 * @param proto the protocol requiring the use of a proxy 157 190 */ 158 191 bool setProxiesForProtcol(CURL* handle,const char *proto){ … … 164 197 #endif 165 198 199 /** 200 * Create a HINTERNET 201 * 202 * @param lpszAgent the HTPP User-Agent to use to send requests 203 * @param dwAccessType type of access required 204 * @param lpszProxyName the name of the proxy server(s) to use 205 * @param lpszProxyBypass ip address or host names which should not be routed 206 * through the proxy 207 * @param dwFlags Options (INTERNET_FLAG_ASYNC,INTERNET_FLAG_FROM_CACHE,INTERNET_FLAG_OFFLINE) 208 * @return the created HINTERNET 209 */ 166 210 HINTERNET InternetOpen(char* lpszAgent,int dwAccessType,char* lpszProxyName,char* lpszProxyBypass,int dwFlags){ 167 211 HINTERNET ret; … … 173 217 } 174 218 219 /** 220 * Close a HINTERNET connection and free allocated ressources 221 * 222 * @param handle0 the HINTERNET connection to close 223 */ 175 224 void InternetCloseHandle(HINTERNET* handle0){ 176 225 int i=0; … … 200 249 } 201 250 251 /** 252 * Create a new element in the download queue 253 * 254 * @param hInternet the HINTERNET connection to add the download link 255 * @param lpszUrl the url to download 256 * @param lpszHeaders the additional headers to be sent to the HTTP server 257 * @param dwHeadersLength the size of the additional headers 258 * @param dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file) 259 * @param dwContext not used 260 */ 202 261 HINTERNET InternetOpenUrl(HINTERNET* hInternet,LPCTSTR lpszUrl,LPCTSTR lpszHeaders,size_t dwHeadersLength,size_t dwFlags,size_t dwContext){ 203 262 … … 289 348 }; 290 349 350 /** 351 * Download all opened urls in the queue 352 * 353 * @param hInternet the HINTERNET structure containing the queue 354 * @return 0 355 */ 291 356 int processDownloads(HINTERNET* hInternet){ 292 357 int still_running=0; … … 307 372 } 308 373 374 /** 375 * Initialize the CCookie for a specific index (hInternet.nb) 376 * 377 * @param hInternet the HINTERNET structure to know the CCookie index to reset 378 * @return 1 379 * @see HINTERNET 380 */ 309 381 int freeCookieList(HINTERNET hInternet){ 310 382 memset(&CCookie[hInternet.nb][0],0,1024); … … 315 387 } 316 388 389 /** 390 * Copy a downloaded content 391 * 392 * @param hInternet the _HINTERNET structure 393 * @param lpBuffer the memory space to copy the downloaded content 394 * @param dwNumberOfBytesToRead the size of lpBuffer 395 * @param lpdwNumberOfBytesRead number of bytes red 396 * @return 1 on success, 0 if failure 397 */ 317 398 int InternetReadFile(_HINTERNET hInternet,LPVOID lpBuffer,int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead){ 318 399 int dwDataSize;
Note: See TracChangeset
for help on using the changeset viewer.