cURL / Mailing Lists / curl-users / Single Mail

curl-users

curl set option return tests

From: Peter Sylvester <Peter.Sylvester_at_edelweb.fr>
Date: Wed, 29 Sep 2004 19:51:55 +0200 (MEST)

I would to like to share a simple method to enhance
some existing programs (including the cutm main).

The problem is that historically seting easy option
does not really return any code excpt success,
thus one has programs that do not test this at all.

Adding some if's etc may make the programs somewhat
unreadable.

A simple technique is to define a macro like

#define curl_easy_setopt(c,o,p) \
do { if (CURLE_OK != (res = curl_easy_setopt(c,o,p))) \
{ curl_easy_setopt_line = __LINE__ ;goto curl_easy_setopt_error; } while (0)

with some obvious declarations elsewhere.

Have fun.
Received on 2004-09-29