aboutsummaryrefslogtreecommitdiff
path: root/src/tool_writeout.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-03-04 23:07:03 +0000
committerDaniel Stenberg <daniel@haxx.se>2012-04-01 23:52:05 +0200
commitddfe821bcf9522247cd057b12b8a1b0af01f2d37 (patch)
treebd91e6acfeced5bcf9306bb11cedb630df4d819e /src/tool_writeout.c
parent54866b68cd71070a62f517ec6722dc60384b4b5f (diff)
curl tool: add filename_effective token for --write-out
By modifying the parameter list for ourWriteOut() and passing the OutStruct that collects data in tool_operate, we get access to the remote name that we're writing to. Shell scripters should find this useful when used in conjuntion with the --remote-header-name option.
Diffstat (limited to 'src/tool_writeout.c')
-rw-r--r--src/tool_writeout.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 1ea1c9881..361f3657e 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -26,6 +26,7 @@
#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
#include <curl/mprintf.h>
+#include "tool_cfgable.h"
#include "tool_writeout.h"
#include "memdebug.h" /* keep this as LAST include */
@@ -54,6 +55,7 @@ typedef enum {
VAR_FTP_ENTRY_PATH,
VAR_REDIRECT_URL,
VAR_SSL_VERIFY_RESULT,
+ VAR_EFFECTIVE_FILENAME,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@@ -87,10 +89,11 @@ static const struct variable replacements[]={
{"ftp_entry_path", VAR_FTP_ENTRY_PATH},
{"redirect_url", VAR_REDIRECT_URL},
{"ssl_verify_result", VAR_SSL_VERIFY_RESULT},
+ {"filename_effective", VAR_EFFECTIVE_FILENAME},
{NULL, VAR_NONE}
};
-void ourWriteOut(CURL *curl, const char *writeinfo)
+void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
{
FILE *stream = stdout;
const char *ptr = writeinfo;
@@ -242,6 +245,10 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
&longinfo))
fprintf(stream, "%ld", longinfo);
break;
+ case VAR_EFFECTIVE_FILENAME:
+ if(outs->filename)
+ fprintf(stream, "%s", outs->filename);
+ break;
default:
break;
}