diff options
author | Mathias Gumz <mg@2hoch5.com> | 2020-02-01 18:55:24 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-03-17 15:01:28 +0100 |
commit | 04c03416e68fd635a15cae8201872f5c29fdcca8 (patch) | |
tree | 6b10d49ed62cd8a23b4a254e144c9b90321cfc7b /src/tool_writeout.h | |
parent | d83402813b624d9067416bea2e7feb70a358cf65 (diff) | |
download | curl-04c03416e68fd635a15cae8201872f5c29fdcca8.tar.gz |
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
Diffstat (limited to 'src/tool_writeout.h')
-rw-r--r-- | src/tool_writeout.h | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/tool_writeout.h b/src/tool_writeout.h index ee8990f77..64d759575 100644 --- a/src/tool_writeout.h +++ b/src/tool_writeout.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,61 @@ ***************************************************************************/ #include "tool_setup.h" +typedef enum { + VAR_NONE, /* must be the first */ + VAR_TOTAL_TIME, + VAR_NAMELOOKUP_TIME, + VAR_CONNECT_TIME, + VAR_APPCONNECT_TIME, + VAR_PRETRANSFER_TIME, + VAR_STARTTRANSFER_TIME, + VAR_SIZE_DOWNLOAD, + VAR_SIZE_UPLOAD, + VAR_SPEED_DOWNLOAD, + VAR_SPEED_UPLOAD, + VAR_HTTP_CODE, + VAR_HTTP_CODE_PROXY, + VAR_HEADER_SIZE, + VAR_REQUEST_SIZE, + VAR_EFFECTIVE_URL, + VAR_CONTENT_TYPE, + VAR_NUM_CONNECTS, + VAR_REDIRECT_TIME, + VAR_REDIRECT_COUNT, + VAR_FTP_ENTRY_PATH, + VAR_REDIRECT_URL, + VAR_SSL_VERIFY_RESULT, + VAR_PROXY_SSL_VERIFY_RESULT, + VAR_EFFECTIVE_FILENAME, + VAR_PRIMARY_IP, + VAR_PRIMARY_PORT, + VAR_LOCAL_IP, + VAR_LOCAL_PORT, + VAR_HTTP_VERSION, + VAR_SCHEME, + VAR_STDOUT, + VAR_STDERR, + VAR_JSON, + VAR_NUM_OF_VARS /* must be the last */ +} writeoutid; + +typedef enum { + JSON_NONE, + JSON_STRING, + JSON_LONG, + JSON_TIME, + JSON_VERSION, + JSON_FILENAME +} jsontype; + +struct writeoutvar { + const char *name; + writeoutid id; + int is_ctrl; + CURLINFO cinfo; + jsontype jsontype; +}; + void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo); #endif /* HEADER_CURL_TOOL_WRITEOUT_H */ |