ZOO-Project: ulinet.c File Reference
ZOO-Project
ulinet.c File Reference
#include "ulinet.h"
#include "server_internal.h"
#include <assert.h>
#include <ctype.h>

Macros

#define _ULINET
 
#define MAX_WAIT_MSECS   180*1000 /* Wait max. 180 seconds */
 

Functions

size_t write_data_into (void *buffer, size_t size, size_t nmemb, void *data)
 Write the downloaded content to a _HINTERNET structure. More...
 
size_t write_data_into_file (void *buffer, size_t size, size_t nmemb, void *data)
 Write the downloaded content in the file pouted by the _HINTERNET structure. More...
 
size_t header_write_data (void *buffer, size_t size, size_t nmemb, void *data)
 In case of presence of "Set-Cookie" in the headers red, store the cookie identifier in cookie. More...
 
void setProxy (CURL *handle, char *host, long port)
 Define the proxy to use for a CURL handler. More...
 
int setProxiesForProtcol (CURL *handle, const char *proto)
 MACOSX. More...
 
HINTERNET InternetOpen (char *lpszAgent, int dwAccessType, char *lpszProxyName, char *lpszProxyBypass, int dwFlags)
 Create a HINTERNET. More...
 
char * getProvenance (maps *conf, const char *url)
 Verify if the URL should use a shared cache or not. More...
 
int AddMissingHeaderEntry (_HINTERNET *handle, const char *key, const char *value)
 Add missing headers to an existing _HINTERNET. More...
 
int isProtectedHost (const char *protectedHosts, const char *url)
 Verify if a host is protected (appear in [security] > hosts) More...
 
void AddHeaderEntries (HINTERNET *handle, maps *conf)
 Add headers defined in [security] > attributes to an existing HINTERNET. More...
 
void InternetCloseHandle (HINTERNET *handle0)
 Close a HINTERNET connection and free allocated resources. More...
 
HINTERNET InternetOpenUrl (HINTERNET *hInternet, LPCTSTR lpszUrl, LPCTSTR lpszHeaders, size_t dwHeadersLength, size_t dwFlags, size_t dwContext, const maps *conf)
 Create a new element in the download queue. More...
 
int processDownloads (HINTERNET *hInternet)
 Download all opened urls in the queue. More...
 
int freeCookieList (HINTERNET hInternet)
 Initialize the cookie for a specific index (hInternet.nb) More...
 
int InternetReadFile (_HINTERNET hInternet, LPVOID lpBuffer, int dwNumberOfBytesToRead, size_t *lpdwNumberOfBytesRead)
 Copy a downloaded content. More...
 
int setBasicAuth (HINTERNET hInternet, char *login, char *passwd)
 Use basic authentication for accessing a resource. More...
 

Macro Definition Documentation

#define _ULINET
#define MAX_WAIT_MSECS   180*1000 /* Wait max. 180 seconds */

Function Documentation

void AddHeaderEntries ( HINTERNET handle,
maps conf 
)

Add headers defined in [security] > attributes to an existing HINTERNET.

See also
isProtectedHost, AddMissingHeaderEntry
Parameters
handlethe _HINTERNET pointer
confthe header parameter name
valuethe header parameter value
Returns
0 if the operation succeeded, -1 in other case.
int AddMissingHeaderEntry ( _HINTERNET handle,
const char *  key,
const char *  value 
)

Add missing headers to an existing _HINTERNET.

Parameters
handlethe _HINTERNET pointer
keythe header parameter name
valuethe header parameter value
Returns
0 if the operation succeeded, -1 in other case.
int freeCookieList ( HINTERNET  hInternet)

Initialize the cookie for a specific index (hInternet.nb)

Parameters
hInternetthe HINTERNET structure to know the cookie index to reset
Returns
1
See also
HINTERNET
char* getProvenance ( maps conf,
const char *  url 
)

Verify if the URL should use a shared cache or not.

In case the security section contains a key named "shared", then if the domain listed in the shared key are contained in the url given as parameter then it return "SHARED" in other cases, it returns "OTHER".

Parameters
confthe main configuration file maps
urlthe URL to evaluate
Returns
a string "SHARED" in case the host is in a domain listed in the shared key, "OTHER" in other cases.
size_t header_write_data ( void *  buffer,
size_t  size,
size_t  nmemb,
void *  data 
)

In case of presence of "Set-Cookie" in the headers red, store the cookie identifier in cookie.

Parameters
bufferthe buffer to read
sizesize of each member
nmembnumber of element to read
datathe _HINTERNET structure to write in
Returns
the size red, -1 if buffer is NULL
See also
cookie
void InternetCloseHandle ( HINTERNET handle0)

Close a HINTERNET connection and free allocated resources.

Parameters
handle0the HINTERNET connection to close
HINTERNET InternetOpen ( char *  lpszAgent,
int  dwAccessType,
char *  lpszProxyName,
char *  lpszProxyBypass,
int  dwFlags 
)

Create a HINTERNET.

Parameters
lpszAgentthe HTPP User-Agent to use to send requests
dwAccessTypetype of access required
lpszProxyNamethe name of the proxy server(s) to use
lpszProxyBypassip address or host names which should not be routed through the proxy
dwFlagsOptions (INTERNET_FLAG_ASYNC,INTERNET_FLAG_FROM_CACHE,INTERNET_FLAG_OFFLINE)
Returns
the created HINTERNET
HINTERNET InternetOpenUrl ( HINTERNET hInternet,
LPCTSTR  lpszUrl,
LPCTSTR  lpszHeaders,
size_t  dwHeadersLength,
size_t  dwFlags,
size_t  dwContext,
const maps conf 
)

Create a new element in the download queue.

Parameters
hInternetthe HINTERNET connection to add the download link
lpszUrlthe url to download
lpszHeadersthe additional headers to be sent to the HTTP server
dwHeadersLengththe size of the additional headers
dwFlagsdesired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file)
dwContextnot used
confthe main configuration file maps pointer
Returns
the updated HINTERNET
int InternetReadFile ( _HINTERNET  hInternet,
LPVOID  lpBuffer,
int  dwNumberOfBytesToRead,
size_t *  lpdwNumberOfBytesRead 
)

Copy a downloaded content.

Parameters
hInternetthe _HINTERNET structure
lpBufferthe memory space to copy the downloaded content
dwNumberOfBytesToReadthe size of lpBuffer
lpdwNumberOfBytesReadnumber of bytes red
Returns
1 on success, 0 if failure
int isProtectedHost ( const char *  protectedHosts,
const char *  url 
)

Verify if a host is protected (appear in [security] > hosts)

Parameters
protectedHostsstring containing all the protected hosts (coma separated)
urlstring used to extract the host from
Returns
1 if the host is listed as protected, 0 in other case
int processDownloads ( HINTERNET hInternet)

Download all opened urls in the queue.

Parameters
hInternetthe HINTERNET structure containing the queue
Returns
0
int setBasicAuth ( HINTERNET  hInternet,
char *  login,
char *  passwd 
)

Use basic authentication for accessing a resource.

Parameters
hInternetthe _HINTERNET structure
loginthe login to use to authenticate
passwdthe password to use to authenticate
int setProxiesForProtcol ( CURL *  handle,
const char *  proto 
)

MACOSX.

Should autodetect the proxy configuration (do nothing on linux)

Parameters
handlea CURL handle
protothe protocol requiring the use of a proxy
void setProxy ( CURL *  handle,
char *  host,
long  port 
)

Define the proxy to use for a CURL handler.

Parameters
handlethe CURL handler
hostthe proxy host (including http://)
portthe proxy port
size_t write_data_into ( void *  buffer,
size_t  size,
size_t  nmemb,
void *  data 
)

Write the downloaded content to a _HINTERNET structure.

Parameters
bufferthe buffer to read
sizesize of each member
nmembnumber of element to read
datathe _HINTERNET structure to write in
Returns
the size red, -1 if buffer is NULL
size_t write_data_into_file ( void *  buffer,
size_t  size,
size_t  nmemb,
void *  data 
)

Write the downloaded content in the file pouted by the _HINTERNET structure.

Parameters
bufferthe buffer to read
sizesize of each member
nmembnumber of element to read
datathe _HINTERNET structure to write in
Returns
the size red, -1 if buffer is NULL

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