From 04c03416e68fd635a15cae8201872f5c29fdcca8 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sat, 1 Feb 2020 18:55:24 +0100 Subject: writeout: support to generate JSON output This commit adds support to generate JSON via the writeout feature: -w "%{json}" It leverages the existing infrastructure as much as possible. Thus, generating the JSON on STDERR is possible by: -w "%{stderr}%{json}" This implements a variant of https://github.com/curl/curl/wiki/JSON#--write-out-json. Closes #4870 --- lib/version.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/version.c b/lib/version.c index 8170106ee..c7fe42a07 100644 --- a/lib/version.c +++ b/lib/version.c @@ -127,6 +127,16 @@ char *curl_version(void) int i = 0; int j; +#ifdef DEBUGBUILD + /* Override version string when environment variable CURL_VERSION is set */ + const char *debugversion = getenv("CURL_VERSION"); + if(debugversion) { + strncpy(out, debugversion, sizeof(out)-1); + out[sizeof(out)-1] = '\0'; + return out; + } +#endif + src[i++] = LIBCURL_NAME "/" LIBCURL_VERSION; #ifdef USE_SSL Curl_ssl_version(ssl_version, sizeof(ssl_version)); -- cgit v1.2.3