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: Wrapper function for curl_easy_setopt()
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Vladimir Levijev via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 24 Oct 2023 15:18:23 +0300
> 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!
Cheers,
VL
Date: Tue, 24 Oct 2023 15:18:23 +0300
> 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!
Cheers,
VL
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-10-24