/* initialize curl for each host */
static int init_host (apache_t *st) /* {{{ */
{
- static char credentials[1024];
-
assert (st->url != NULL);
/* (Assured by `config_add') */
if (st->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (st->curl, CURLOPT_USERNAME, st->user);
+ curl_easy_setopt (st->curl, CURLOPT_PASSWORD,
+ (st->pass == NULL) ? "" : st->pass);
+#else
+ static char credentials[1024];
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (st->curl, CURLOPT_USERPWD, credentials);
+#endif
}
curl_easy_setopt (st->curl, CURLOPT_URL, st->url);
static int ascent_init (void) /* {{{ */
{
- static char credentials[1024];
-
if (url == NULL)
{
WARNING ("ascent plugin: ascent_init: No URL configured, "
if (user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (curl, CURLOPT_USERNAME, user);
+ curl_easy_setopt (curl, CURLOPT_PASSWORD, (pass == NULL) ? "" : pass);
+#else
+ static char credentials[1024];
int status;
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
+#endif
}
curl_easy_setopt (curl, CURLOPT_URL, url);
static int init (void)
{
- static char credentials[1024];
-
if (curl != NULL)
curl_easy_cleanup (curl);
if (user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (curl, CURLOPT_USERNAME, user);
+ curl_easy_setopt (curl, CURLOPT_PASSWORD, (pass == NULL) ? "" : pass);
+#else
+ static char credentials[1024];
int status = ssnprintf (credentials, sizeof (credentials),
"%s:%s", user, pass == NULL ? "" : pass);
if ((status < 0) || ((size_t) status >= sizeof (credentials)))
}
curl_easy_setopt (curl, CURLOPT_USERPWD, credentials);
+#endif
}
if (url != NULL)
if (cb->user != NULL)
{
+#ifdef HAVE_CURLOPT_USERNAME
+ curl_easy_setopt (cb->curl, CURLOPT_USERNAME, cb->user);
+ curl_easy_setopt (cb->curl, CURLOPT_PASSWORD,
+ (cb->pass == NULL) ? "" : cb->pass);
+#else
size_t credentials_size;
credentials_size = strlen (cb->user) + 2;
ssnprintf (cb->credentials, credentials_size, "%s:%s",
cb->user, (cb->pass == NULL) ? "" : cb->pass);
curl_easy_setopt (cb->curl, CURLOPT_USERPWD, cb->credentials);
+#endif
curl_easy_setopt (cb->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
}