- r = curl_easy_setopt (curl, CURLOPT_URL, url);
- if (r != CURLE_OK) {
- fprintf (stderr, "curl_easy_setopt CURLOPT_URL failed with code %d\n", r);
- exit (1);
- }
-
- r = curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_fn);
- if (r != CURLE_OK) {
- fprintf (stderr, "curl_easy_setopt CURLOPT_WRITEFUNCTION failed with code %d\n", r);
- exit (1);
- }
-
- r = curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, header_fn);
- if (r != CURLE_OK) {
- fprintf (stderr, "curl_easy_setopt CURLOPT_HEADERFUNCTION failed with code %d\n", r);
- exit (1);
- }
-
+ CHECK_ERROR (curl_easy_setopt, (curl, CURLOPT_URL, url));
+ CHECK_ERROR (curl_easy_setopt, (curl, CURLOPT_CAINFO, cainfo));
+ CHECK_ERROR (curl_easy_setopt, (curl, CURLOPT_WRITEFUNCTION, write_fn));
+ CHECK_ERROR (curl_easy_setopt, (curl, CURLOPT_HEADERFUNCTION, header_fn));
+ /* This enables error messages in curl_easy_perform: */
+ CHECK_ERROR (curl_easy_setopt, (curl, CURLOPT_ERRORBUFFER, error));