summaryrefslogtreecommitdiff
path: root/src/tool_writeout.h
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2021-01-28 18:56:50 -0500
committerJay Satiro <raysatiro@yahoo.com>2021-02-09 02:48:27 -0500
commit65ca2294619f865362332ceddc622db92d0f50a6 (patch)
treea1f2575bd296da4eee3c1dd4cc3552ab2b625010 /src/tool_writeout.h
parentb9f11ae87564447e61533eeafea9a1caa4cfa31d (diff)
downloadcurl-65ca2294619f865362332ceddc622db92d0f50a6.tar.gz
tool_writeout: refactor write-out and write-out json
- Deduplicate the logic used by write-out and write-out json. Rather than have separate writeLong, writeString, etc, logic for each of write-out and write-out json instead have respective shared functions that can output either format and a 'use_json' parameter to indicate whether it is json that is output. This will make it easier to maintain. Rather than have to go through two sets of logic now we only have to go through one. - Support write-out %{errormsg} and %{exitcode} in json. - Clarify in the doc that %{exitcode} is the exit code of the transfer. Prior to this change it just said "The numerical exitcode" which implies it's the exit code of the tool, and it's not necessarily that. Closes https://github.com/curl/curl/pull/6544
Diffstat (limited to 'src/tool_writeout.h')
-rw-r--r--src/tool_writeout.h21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/tool_writeout.h b/src/tool_writeout.h
index 02858d8c1..2cf7d012a 100644
--- a/src/tool_writeout.h
+++ b/src/tool_writeout.h
@@ -69,25 +69,16 @@ typedef enum {
VAR_NUM_OF_VARS /* must be the last */
} writeoutid;
-typedef enum {
- JSON_NONE,
- JSON_STRING,
- JSON_LONG,
- JSON_OFFSET,
- JSON_TIME,
- JSON_VERSION,
- JSON_FILENAME
-} jsontype;
-
struct writeoutvar {
const char *name;
writeoutid id;
- int is_ctrl;
- CURLINFO cinfo;
- jsontype jsontype;
+ CURLINFO ci;
+ int (*writefunc)(FILE *stream, const struct writeoutvar *wovar,
+ struct per_transfer *per, CURLcode per_result,
+ bool use_json);
};
-void ourWriteOut(CURL *curl, struct per_transfer *per, const char *writeinfo,
- CURLcode exitcode);
+void ourWriteOut(const char *writeinfo, struct per_transfer *per,
+ CURLcode per_result);
#endif /* HEADER_CURL_TOOL_WRITEOUT_H */