Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
Re: [External] : Re: Wrapper function for curl_easy_setopt()
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Marc Alff via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 24 Oct 2023 14:55:40 +0200
On 10/24/23 14:18, Vladimir Levijev via curl-library wrote:
>
>> On 24 Oct 2023, at 13:55, Patrick Schlangen <patrick_at_schlangen.me> wrote:
>>
>> Hi,
>>
>>> Am 24.10.2023 um 12:24 schrieb Vladimir Levijev via curl-library <curl-library_at_lists.haxx.se>:
>>>
>>> So I tried it with #define but then you deal with static name of the error buffer and the GOTO label (in some parts we use it, but not everythere).
>>
>> not exactly nice, but this might do the trick:
>>
>> #define my_setopt(handle, option, ...) (last_option = #option, curl_easy_setopt(handle, option, __VA_ARGS__))
>>
>> void foo() {
>> const char *last_option = "none";
>>
>> // ...
>>
>> if (!my_setopt(e, CURLOPT_FOO, 123)) {
>> printf("Error in %s!\n", last_option);
>> }
>> }
>>
>
> Thanks a lot! That works, definitely will consider this one!
>
There is also:
curl_easy_setopt(e, CURLOPT_ERRORBUFFER, curl_error_message);
I did not try, but I would expect curl to complain that option 123 is
not supported in this case.
Regards,
-- Marc
Date: Tue, 24 Oct 2023 14:55:40 +0200
On 10/24/23 14:18, Vladimir Levijev via curl-library wrote:
>
>> On 24 Oct 2023, at 13:55, Patrick Schlangen <patrick_at_schlangen.me> wrote:
>>
>> Hi,
>>
>>> Am 24.10.2023 um 12:24 schrieb Vladimir Levijev via curl-library <curl-library_at_lists.haxx.se>:
>>>
>>> So I tried it with #define but then you deal with static name of the error buffer and the GOTO label (in some parts we use it, but not everythere).
>>
>> not exactly nice, but this might do the trick:
>>
>> #define my_setopt(handle, option, ...) (last_option = #option, curl_easy_setopt(handle, option, __VA_ARGS__))
>>
>> void foo() {
>> const char *last_option = "none";
>>
>> // ...
>>
>> if (!my_setopt(e, CURLOPT_FOO, 123)) {
>> printf("Error in %s!\n", last_option);
>> }
>> }
>>
>
> Thanks a lot! That works, definitely will consider this one!
>
There is also:
curl_easy_setopt(e, CURLOPT_ERRORBUFFER, curl_error_message);
I did not try, but I would expect curl to complain that option 123 is
not supported in this case.
Regards,
-- Marc
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-10-24