* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, 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
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
*
***************************************************************************/
#include "tool_setup.h"
-
-#include <curl/curl.h>
-
-#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
-#include <curl/mprintf.h>
-
+#define ENABLE_CURLX_PRINTF
+/* use our own printf() functions */
+#include "curlx.h"
#include "tool_cfgable.h"
#include "tool_writeout.h"
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_NUM_OF_VARS /* must be the last */
} replaceid;
{"ftp_entry_path", VAR_FTP_ENTRY_PATH},
{"redirect_url", VAR_REDIRECT_URL},
{"ssl_verify_result", VAR_SSL_VERIFY_RESULT},
+ {"proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT},
{"filename_effective", VAR_EFFECTIVE_FILENAME},
+ {"remote_ip", VAR_PRIMARY_IP},
+ {"remote_port", VAR_PRIMARY_PORT},
+ {"local_ip", VAR_LOCAL_IP},
+ {"local_port", VAR_LOCAL_PORT},
+ {"http_version", VAR_HTTP_VERSION},
+ {"scheme", VAR_SCHEME},
{NULL, VAR_NONE}
};
{
FILE *stream = stdout;
const char *ptr = writeinfo;
- char *stringp;
+ char *stringp = NULL;
long longinfo;
double doubleinfo;
while(ptr && *ptr) {
- if('%' == *ptr) {
+ if('%' == *ptr && ptr[1]) {
if('%' == ptr[1]) {
/* an escaped %-letter */
fputc('%', stream);
char *end;
char keepit;
int i;
- if(('{' == ptr[1]) && ((end = strchr(ptr, '}')) != NULL)) {
+ if('{' == ptr[1]) {
bool match = FALSE;
+ end = strchr(ptr, '}');
ptr += 2; /* pass the % and the { */
+ if(!end) {
+ fputs("%{", stream);
+ continue;
+ }
keepit = *end;
*end = 0; /* zero terminate */
for(i = 0; replacements[i].name; i++) {
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME,
&doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_TOTAL_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_NAMELOOKUP_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME,
&doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_CONNECT_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_APPCONNECT_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME,
&doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_PRETRANSFER_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME,
&doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_STARTTRANSFER_TIME:
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
&doubleinfo))
- fprintf(stream, "%.3f", doubleinfo);
+ fprintf(stream, "%.6f", doubleinfo);
break;
case VAR_SIZE_UPLOAD:
if(CURLE_OK ==
&longinfo))
fprintf(stream, "%ld", longinfo);
break;
+ case VAR_PROXY_SSL_VERIFY_RESULT:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT,
+ &longinfo))
+ fprintf(stream, "%ld", longinfo);
+ break;
case VAR_EFFECTIVE_FILENAME:
if(outs->filename)
fprintf(stream, "%s", outs->filename);
break;
+ case VAR_PRIMARY_IP:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP,
+ &stringp))
+ fprintf(stream, "%s", stringp);
+ break;
+ case VAR_PRIMARY_PORT:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT,
+ &longinfo))
+ fprintf(stream, "%ld", longinfo);
+ break;
+ case VAR_LOCAL_IP:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_LOCAL_IP,
+ &stringp))
+ fprintf(stream, "%s", stringp);
+ break;
+ case VAR_LOCAL_PORT:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT,
+ &longinfo))
+ fprintf(stream, "%ld", longinfo);
+ break;
+ case VAR_HTTP_VERSION:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION,
+ &longinfo)) {
+ const char *version = "0";
+ switch(longinfo) {
+ case CURL_HTTP_VERSION_1_0:
+ version = "1.0";
+ break;
+ case CURL_HTTP_VERSION_1_1:
+ version = "1.1";
+ break;
+ case CURL_HTTP_VERSION_2_0:
+ version = "2";
+ break;
+ }
+
+ fprintf(stream, version);
+ }
+ break;
+ case VAR_SCHEME:
+ if(CURLE_OK ==
+ curl_easy_getinfo(curl, CURLINFO_SCHEME,
+ &stringp))
+ fprintf(stream, "%s", stringp);
+ break;
default:
break;
}
}
}
}
- else if('\\' == *ptr) {
+ else if('\\' == *ptr && ptr[1]) {
switch(ptr[1]) {
case 'r':
fputc('\r', stream);