ZOO-Project
|
#include <stdlib.h>
#include <fcntl.h>
#include <curl/curl.h>
#include <curl/curlver.h>
#include "service.h"
#include <unistd.h>
#include <string.h>
#include "time.h"
Go to the source code of this file.
Data Structures | |
struct | MemoryStruct |
Headers storage. More... | |
struct | _HINTERNET |
Individual CURL handler. More... | |
struct | HINTERNET |
Multiple CURL handlers. More... | |
Macros | |
#define | MAX_REQ 50 |
#define | INTERNET_OPEN_TYPE_DIRECT 0 |
#define | INTERNET_OPEN_TYPE_PRECONFIG 1 |
#define | INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 2 |
#define | INTERNET_OPEN_TYPE_PROXY 3 |
#define | INTERNET_FLAG_EXISTING_CONNECT 0 |
#define | INTERNET_FLAG_HYPERLINK 1 |
#define | INTERNET_FLAG_IGNORE_CERT_CN_INVALID 2 |
#define | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 3 |
#define | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 4 |
#define | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 5 |
#define | INTERNET_FLAG_KEEP_CONNECTION 6 |
#define | INTERNET_FLAG_NEED_FILE 7 |
#define | INTERNET_FLAG_NO_AUTH 8 |
#define | INTERNET_FLAG_NO_AUTO_REDIRECT 9 |
#define | INTERNET_FLAG_NO_CACHE_WRITE 10 |
#define | CHECK_INET_HANDLE(h) (h.handle != 0) |
Typedefs | |
typedef char * | LPCTSTR |
typedef void * | LPVOID |
typedef void * | LPTSTR |
typedef size_t * | LPDWORD |
Functions | |
size_t | write_data_into (void *, size_t, size_t, void *) |
Write the downloaded content to a _HINTERNET structure. More... | |
size_t | write_data_into_file (void *, size_t, size_t, void *) |
Write the downloaded content in the file pouted by the _HINTERNET structure. More... | |
size_t | header_write_data (void *, size_t, size_t, void *) |
In case of presence of "Set-Cookie" in the headers red, store the cookie identifier in cookie. More... | |
void | setProxy (CURL *, char *, long) |
Define the proxy to use for a CURL handler. More... | |
int | setProxiesForProtcol (CURL *, const char *) |
MACOSX. More... | |
HINTERNET | InternetOpen (char *, int, char *, char *, int) |
Create a HINTERNET. More... | |
char * | getProvenance (maps *, const char *) |
Verify if the URL should use a shared cache or not. More... | |
int | isProtectedHost (const char *, const char *) |
Verify if a host is protected (appear in [security] > hosts) More... | |
int | AddMissingHeaderEntry (_HINTERNET *, const char *, const char *) |
Add missing headers to an existing _HINTERNET. More... | |
void | AddHeaderEntries (HINTERNET *, maps *) |
Add headers defined in [security] > attributes to an existing HINTERNET. More... | |
void | InternetCloseHandle (HINTERNET *) |
Close a HINTERNET connection and free allocated resources. More... | |
HINTERNET | InternetOpenUrl (HINTERNET *, LPCTSTR, LPCTSTR, size_t, size_t, size_t, const maps *) |
Create a new element in the download queue. More... | |
int | processDownloads (HINTERNET *) |
Download all opened urls in the queue. More... | |
int | freeCookieList (HINTERNET) |
Initialize the cookie for a specific index (hInternet.nb) More... | |
int | InternetReadFile (_HINTERNET, LPVOID, int, size_t *) |
Copy a downloaded content. More... | |
int | setBasicAuth (HINTERNET, char *, char *) |
Use basic authentication for accessing a resource. More... | |
Data Structure Documentation
struct MemoryStruct |
Headers storage.
- See also
- header_write_data
Data Fields | ||
---|---|---|
char * | memory | the memory space to store data |
size_t | size | size of the memory space |
struct _HINTERNET |
Individual CURL handler.
struct HINTERNET |
Multiple CURL handlers.
Data Fields | ||
---|---|---|
char * | agent | The User-Agent to use for HTTP request. |
CURLM * | handle | the CURLM handler |
_HINTERNET | ihandle[MAX_REQ] | individual handlers in the queue |
int | nb | number of element in the queue |
char * | waitingRequests[MAX_REQ] | request in the queue |
Macro Definition Documentation
#define CHECK_INET_HANDLE | ( | h | ) | (h.handle != 0) |
#define INTERNET_FLAG_EXISTING_CONNECT 0 |
#define INTERNET_FLAG_HYPERLINK 1 |
#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID 2 |
#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 3 |
#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP 4 |
#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 5 |
#define INTERNET_FLAG_KEEP_CONNECTION 6 |
#define INTERNET_FLAG_NEED_FILE 7 |
#define INTERNET_FLAG_NO_AUTH 8 |
#define INTERNET_FLAG_NO_AUTO_REDIRECT 9 |
#define INTERNET_FLAG_NO_CACHE_WRITE 10 |
#define INTERNET_OPEN_TYPE_DIRECT 0 |
#define INTERNET_OPEN_TYPE_PRECONFIG 1 |
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 2 |
#define INTERNET_OPEN_TYPE_PROXY 3 |
#define MAX_REQ 50 |
Typedef Documentation
typedef char* LPCTSTR |
typedef size_t* LPDWORD |
typedef void* LPTSTR |
typedef void* LPVOID |
Function Documentation
Add headers defined in [security] > attributes to an existing HINTERNET.
- See also
- isProtectedHost, AddMissingHeaderEntry
- Parameters
-
handle the _HINTERNET pointer conf the header parameter name value the 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
-
handle the _HINTERNET pointer key the header parameter name value the header parameter value
- Returns
- 0 if the operation succeeded, -1 in other case.
int freeCookieList | ( | HINTERNET | 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
-
conf the main configuration file maps url the 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
-
buffer the buffer to read size size of each member nmemb number of element to read data the _HINTERNET structure to write in
- Returns
- the size red, -1 if buffer is NULL
- See also
- cookie
void InternetCloseHandle | ( | HINTERNET * | handle0 | ) |
HINTERNET InternetOpen | ( | char * | lpszAgent, |
int | dwAccessType, | ||
char * | lpszProxyName, | ||
char * | lpszProxyBypass, | ||
int | dwFlags | ||
) |
Create a HINTERNET.
- Parameters
-
lpszAgent the HTPP User-Agent to use to send requests dwAccessType type of access required lpszProxyName the name of the proxy server(s) to use lpszProxyBypass ip address or host names which should not be routed through the proxy dwFlags Options (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
-
hInternet the HINTERNET connection to add the download link lpszUrl the url to download lpszHeaders the additional headers to be sent to the HTTP server dwHeadersLength the size of the additional headers dwFlags desired download mode (INTERNET_FLAG_NO_CACHE_WRITE for not using cache file) dwContext not used conf the 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
-
hInternet the _HINTERNET structure lpBuffer the memory space to copy the downloaded content dwNumberOfBytesToRead the size of lpBuffer lpdwNumberOfBytesRead number 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
-
protectedHosts string containing all the protected hosts (coma separated) url string 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
-
hInternet the HINTERNET structure containing the queue
- Returns
- 0
int setBasicAuth | ( | HINTERNET | hInternet, |
char * | login, | ||
char * | passwd | ||
) |
Use basic authentication for accessing a resource.
- Parameters
-
hInternet the _HINTERNET structure login the login to use to authenticate passwd the password to use to authenticate
int setProxiesForProtcol | ( | CURL * | handle, |
const char * | proto | ||
) |
MACOSX.
Should autodetect the proxy configuration (do nothing on linux)
- Parameters
-
handle a CURL handle proto the 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
-
handle the CURL handler host the proxy host (including http://) port the 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
-
buffer the buffer to read size size of each member nmemb number of element to read data the _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
-
buffer the buffer to read size size of each member nmemb number of element to read data the _HINTERNET structure to write in
- Returns
- the size red, -1 if buffer is NULL
Generated on Wed Apr 2 2025 00:00:02 for ZOO-Project by
