atobnet 3.2.0
ATOMAS atobnet
Methods

Functions

ATO_BNET_EXPORT void ato_bnet_setcurloptfn (ato_curloptfunction curloptfunction)
 Use this to set additional options for CURL that may be required for particular circumstances. More...
 
ATO_BNET_EXPORT const char * ato_bnet_curl_version (void)
 The version number of the network library libcurl. More...
 
ATO_BNET_EXPORT unsigned int ato_bnet_debugflag (void)
 The current debug flags. More...
 
ATO_BNET_EXPORT void ato_bnet_setdebugflag (unsigned int flag)
 The debug flags to set. More...
 
ATO_BNET_EXPORT unsigned int ato_bnet_names2flag (const char *names)
 Convert the set of lower-case names, comma delimited, representing flag names to the int equivalent. More...
 

Detailed Description

Function Documentation

◆ ato_bnet_setcurloptfn()

ATO_BNET_EXPORT void ato_bnet_setcurloptfn ( ato_curloptfunction  curloptfunction)

Use this to set additional options for CURL that may be required for particular circumstances.

An example of such a function would be:

static int curloptfunction(void *curl) {
CURLcode rc = CURLE_OK;
if (curl == NULL) { return rc; }
if (arg_sslversion != NULL) {
// Some servers (VANguard) will negotiate TLS1.2 but some proxies do not properly support it.
// If this is the case, try another protocol.
char *urlp = NULL;
rc = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &urlp);
if (rc != CURLE_OK) { return rc; }
if (urlp != NULL && strstr(urlp, "authentication.business.gov.au") != NULL) {
// only do this when connecting to VANguard
printf("Setting CURLOPT_SSLVERSION to '%s'\n", arg_sslversion);
if (_streqi(arg_sslversion, "default")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_DEFAULT);
} else if (_streqi(arg_sslversion, "tlsv1")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
} else if (_streqi(arg_sslversion, "sslv2")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv2);
} else if (_streqi(arg_sslversion, "sslv3")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
} else if (_streqi(arg_sslversion, "tlsv1_0")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_0);
} else if (_streqi(arg_sslversion, "tlsv1_1")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_1);
} else if (_streqi(arg_sslversion, "tlsv1_2")) {
rc = curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
} else {
printf("***Setting CURLOPT_SSLVERSION FAILED (ignoring)***");
}
}
}
if (arg_sslcainfo != NULL) {
// careful - we're not catering to platform independence here
// so the arg_sslcainfo path is OS specific.
// Don't bother setting if the file doesn't exist
struct stat sb;
if (stat(arg_sslcainfo, &sb) == 0) {
rc = curl_easy_setopt(curl, CURLOPT_CAINFO, arg_sslcainfo);
}
}
return rc;
}

where _streqi is:

static bool _streqi(const char *src, const char *src2) {
if (src == NULL && src2 == NULL) { return TRUE; }
if ((src == NULL && src2 != NULL) || (src != NULL && src2 == NULL)) { return FALSE; }
if (strlen(src) != strlen(src2)) { return FALSE; }
while (*src2 != '\0') {
if (tolower((int)*src) != tolower((int)*src2)) { return FALSE; }
src++; src2++;
}
return TRUE;
}
Parameters
curloptfunctionthe global function to use

◆ ato_bnet_curl_version()

ATO_BNET_EXPORT const char * ato_bnet_curl_version ( void  )

The version number of the network library libcurl.

Returns
The version number of the network library libcurl.

◆ ato_bnet_debugflag()

ATO_BNET_EXPORT unsigned int ato_bnet_debugflag ( void  )

The current debug flags.

Returns
The current debug flags.

◆ ato_bnet_setdebugflag()

ATO_BNET_EXPORT void ato_bnet_setdebugflag ( unsigned int  flag)

The debug flags to set.

Parameters
flagSee defines for values - default is ATO_BNET_DEBUG_FLAG_TEXT

◆ ato_bnet_names2flag()

ATO_BNET_EXPORT unsigned int ato_bnet_names2flag ( const char *  names)

Convert the set of lower-case names, comma delimited, representing flag names to the int equivalent.

Names must be comma-delimited and lower-case. They can appear multiple times in any combination - "off" has precedence, then "all". Unrecognised names will be ignored.

Parameters
namesthe flag name(s) as a comma delimited string. NULL or empty string is equivalent to a string containing "off".
Returns
the flag int