2002-09-03 07:52:59 -04:00
|
|
|
/***************************************************************************
|
2004-07-26 05:09:26 -04:00
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
2000-10-02 02:30:40 -04:00
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2018-10-08 17:54:01 -04:00
|
|
|
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2000-10-02 02:30:40 -04:00
|
|
|
*
|
2002-09-03 07:52:59 -04:00
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2016-02-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2004-07-26 05:09:26 -04:00
|
|
|
*
|
2001-01-03 04:29:33 -05:00
|
|
|
* 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
|
2002-09-03 07:52:59 -04:00
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
2000-10-02 02:30:40 -04:00
|
|
|
*
|
2001-01-03 04:29:33 -05:00
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
2000-10-02 02:30:40 -04:00
|
|
|
*
|
2002-09-03 07:52:59 -04:00
|
|
|
***************************************************************************/
|
2012-04-06 17:35:15 -04:00
|
|
|
#include "tool_setup.h"
|
2015-03-03 17:08:02 -05:00
|
|
|
#define ENABLE_CURLX_PRINTF
|
|
|
|
/* use our own printf() functions */
|
|
|
|
#include "curlx.h"
|
2012-03-04 18:07:03 -05:00
|
|
|
#include "tool_cfgable.h"
|
2011-10-06 11:39:00 -04:00
|
|
|
#include "tool_writeout.h"
|
2000-10-02 02:30:40 -04:00
|
|
|
|
2013-01-03 20:50:28 -05:00
|
|
|
#include "memdebug.h" /* keep this as LAST include */
|
2011-09-14 05:27:12 -04:00
|
|
|
|
2000-10-02 02:30:40 -04:00
|
|
|
typedef enum {
|
|
|
|
VAR_NONE, /* must be the first */
|
|
|
|
VAR_TOTAL_TIME,
|
|
|
|
VAR_NAMELOOKUP_TIME,
|
|
|
|
VAR_CONNECT_TIME,
|
2008-07-03 02:56:03 -04:00
|
|
|
VAR_APPCONNECT_TIME,
|
2000-10-02 02:30:40 -04:00
|
|
|
VAR_PRETRANSFER_TIME,
|
2001-11-20 10:00:50 -05:00
|
|
|
VAR_STARTTRANSFER_TIME,
|
2000-10-02 02:30:40 -04:00
|
|
|
VAR_SIZE_DOWNLOAD,
|
|
|
|
VAR_SIZE_UPLOAD,
|
|
|
|
VAR_SPEED_DOWNLOAD,
|
|
|
|
VAR_SPEED_UPLOAD,
|
|
|
|
VAR_HTTP_CODE,
|
2004-12-21 14:59:35 -05:00
|
|
|
VAR_HTTP_CODE_PROXY,
|
2000-10-04 09:08:17 -04:00
|
|
|
VAR_HEADER_SIZE,
|
|
|
|
VAR_REQUEST_SIZE,
|
2000-10-02 02:30:40 -04:00
|
|
|
VAR_EFFECTIVE_URL,
|
2002-02-25 02:40:49 -05:00
|
|
|
VAR_CONTENT_TYPE,
|
2004-10-19 11:30:08 -04:00
|
|
|
VAR_NUM_CONNECTS,
|
2004-11-15 06:25:39 -05:00
|
|
|
VAR_REDIRECT_TIME,
|
|
|
|
VAR_REDIRECT_COUNT,
|
2006-03-21 17:30:03 -05:00
|
|
|
VAR_FTP_ENTRY_PATH,
|
2008-04-30 17:20:08 -04:00
|
|
|
VAR_REDIRECT_URL,
|
2008-07-30 17:24:19 -04:00
|
|
|
VAR_SSL_VERIFY_RESULT,
|
2016-11-16 12:49:15 -05:00
|
|
|
VAR_PROXY_SSL_VERIFY_RESULT,
|
2012-03-04 18:07:03 -05:00
|
|
|
VAR_EFFECTIVE_FILENAME,
|
2012-11-07 17:30:25 -05:00
|
|
|
VAR_PRIMARY_IP,
|
|
|
|
VAR_PRIMARY_PORT,
|
|
|
|
VAR_LOCAL_IP,
|
|
|
|
VAR_LOCAL_PORT,
|
2016-05-11 08:23:37 -04:00
|
|
|
VAR_HTTP_VERSION,
|
2016-11-23 04:44:18 -05:00
|
|
|
VAR_SCHEME,
|
2018-10-08 17:54:01 -04:00
|
|
|
VAR_STDOUT,
|
|
|
|
VAR_STDERR,
|
2000-10-02 02:30:40 -04:00
|
|
|
VAR_NUM_OF_VARS /* must be the last */
|
|
|
|
} replaceid;
|
|
|
|
|
|
|
|
struct variable {
|
2001-08-14 05:16:46 -04:00
|
|
|
const char *name;
|
2000-10-02 02:30:40 -04:00
|
|
|
replaceid id;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-12-14 20:38:25 -05:00
|
|
|
static const struct variable replacements[]={
|
2000-10-02 02:30:40 -04:00
|
|
|
{"url_effective", VAR_EFFECTIVE_URL},
|
|
|
|
{"http_code", VAR_HTTP_CODE},
|
2008-04-30 17:20:08 -04:00
|
|
|
{"response_code", VAR_HTTP_CODE},
|
2004-12-21 14:59:35 -05:00
|
|
|
{"http_connect", VAR_HTTP_CODE_PROXY},
|
2000-10-02 02:30:40 -04:00
|
|
|
{"time_total", VAR_TOTAL_TIME},
|
|
|
|
{"time_namelookup", VAR_NAMELOOKUP_TIME},
|
|
|
|
{"time_connect", VAR_CONNECT_TIME},
|
2008-07-03 02:56:03 -04:00
|
|
|
{"time_appconnect", VAR_APPCONNECT_TIME},
|
2000-10-02 02:30:40 -04:00
|
|
|
{"time_pretransfer", VAR_PRETRANSFER_TIME},
|
2001-11-20 10:00:50 -05:00
|
|
|
{"time_starttransfer", VAR_STARTTRANSFER_TIME},
|
2000-10-04 09:08:17 -04:00
|
|
|
{"size_header", VAR_HEADER_SIZE},
|
|
|
|
{"size_request", VAR_REQUEST_SIZE},
|
2000-10-02 02:30:40 -04:00
|
|
|
{"size_download", VAR_SIZE_DOWNLOAD},
|
|
|
|
{"size_upload", VAR_SIZE_UPLOAD},
|
|
|
|
{"speed_download", VAR_SPEED_DOWNLOAD},
|
|
|
|
{"speed_upload", VAR_SPEED_UPLOAD},
|
2002-02-25 02:40:49 -05:00
|
|
|
{"content_type", VAR_CONTENT_TYPE},
|
2004-10-19 11:30:08 -04:00
|
|
|
{"num_connects", VAR_NUM_CONNECTS},
|
2004-11-15 06:25:39 -05:00
|
|
|
{"time_redirect", VAR_REDIRECT_TIME},
|
|
|
|
{"num_redirects", VAR_REDIRECT_COUNT},
|
2006-03-21 17:30:03 -05:00
|
|
|
{"ftp_entry_path", VAR_FTP_ENTRY_PATH},
|
2008-04-30 17:20:08 -04:00
|
|
|
{"redirect_url", VAR_REDIRECT_URL},
|
2008-07-30 17:24:19 -04:00
|
|
|
{"ssl_verify_result", VAR_SSL_VERIFY_RESULT},
|
2016-11-16 12:49:15 -05:00
|
|
|
{"proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT},
|
2012-03-04 18:07:03 -05:00
|
|
|
{"filename_effective", VAR_EFFECTIVE_FILENAME},
|
2012-11-07 17:30:25 -05:00
|
|
|
{"remote_ip", VAR_PRIMARY_IP},
|
|
|
|
{"remote_port", VAR_PRIMARY_PORT},
|
|
|
|
{"local_ip", VAR_LOCAL_IP},
|
|
|
|
{"local_port", VAR_LOCAL_PORT},
|
2016-05-11 08:23:37 -04:00
|
|
|
{"http_version", VAR_HTTP_VERSION},
|
2016-11-23 04:44:18 -05:00
|
|
|
{"scheme", VAR_SCHEME},
|
2018-10-08 17:54:01 -04:00
|
|
|
{"stdout", VAR_STDOUT},
|
|
|
|
{"stderr", VAR_STDERR},
|
2004-02-09 03:29:09 -05:00
|
|
|
{NULL, VAR_NONE}
|
2000-10-02 02:30:40 -04:00
|
|
|
};
|
|
|
|
|
2012-03-04 18:07:03 -05:00
|
|
|
void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
|
2000-10-02 02:30:40 -04:00
|
|
|
{
|
|
|
|
FILE *stream = stdout;
|
2011-10-06 11:39:00 -04:00
|
|
|
const char *ptr = writeinfo;
|
2014-04-18 18:24:25 -04:00
|
|
|
char *stringp = NULL;
|
2000-10-02 02:30:40 -04:00
|
|
|
long longinfo;
|
|
|
|
double doubleinfo;
|
|
|
|
|
2009-09-16 12:49:02 -04:00
|
|
|
while(ptr && *ptr) {
|
2017-03-11 04:59:34 -05:00
|
|
|
if('%' == *ptr && ptr[1]) {
|
2000-10-02 02:30:40 -04:00
|
|
|
if('%' == ptr[1]) {
|
|
|
|
/* an escaped %-letter */
|
|
|
|
fputc('%', stream);
|
2011-10-06 11:39:00 -04:00
|
|
|
ptr += 2;
|
2000-10-02 02:30:40 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* this is meant as a variable to output */
|
|
|
|
char *end;
|
2016-12-13 19:29:44 -05:00
|
|
|
if('{' == ptr[1]) {
|
2018-06-02 16:52:56 -04:00
|
|
|
char keepit;
|
|
|
|
int i;
|
2005-09-06 09:27:18 -04:00
|
|
|
bool match = FALSE;
|
2016-12-13 19:29:44 -05:00
|
|
|
end = strchr(ptr, '}');
|
2011-10-06 11:39:00 -04:00
|
|
|
ptr += 2; /* pass the % and the { */
|
2016-12-13 19:29:44 -05:00
|
|
|
if(!end) {
|
|
|
|
fputs("%{", stream);
|
|
|
|
continue;
|
|
|
|
}
|
2011-10-06 11:39:00 -04:00
|
|
|
keepit = *end;
|
|
|
|
*end = 0; /* zero terminate */
|
|
|
|
for(i = 0; replacements[i].name; i++) {
|
2016-10-31 04:45:17 -04:00
|
|
|
if(curl_strequal(ptr, replacements[i].name)) {
|
2005-09-06 09:27:18 -04:00
|
|
|
match = TRUE;
|
2000-10-02 02:30:40 -04:00
|
|
|
switch(replacements[i].id) {
|
|
|
|
case VAR_EFFECTIVE_URL:
|
2002-07-30 07:07:59 -04:00
|
|
|
if((CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &stringp))
|
|
|
|
&& stringp)
|
2000-10-02 02:30:40 -04:00
|
|
|
fputs(stringp, stream);
|
|
|
|
break;
|
|
|
|
case VAR_HTTP_CODE:
|
|
|
|
if(CURLE_OK ==
|
2003-08-20 11:42:24 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &longinfo))
|
2004-02-25 10:41:36 -05:00
|
|
|
fprintf(stream, "%03ld", longinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
2004-12-21 14:59:35 -05:00
|
|
|
case VAR_HTTP_CODE_PROXY:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE,
|
|
|
|
&longinfo))
|
|
|
|
fprintf(stream, "%03ld", longinfo);
|
|
|
|
break;
|
2000-10-04 09:08:17 -04:00
|
|
|
case VAR_HEADER_SIZE:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &longinfo))
|
2004-02-25 10:41:36 -05:00
|
|
|
fprintf(stream, "%ld", longinfo);
|
2000-10-04 09:08:17 -04:00
|
|
|
break;
|
|
|
|
case VAR_REQUEST_SIZE:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo))
|
2004-02-25 10:41:36 -05:00
|
|
|
fprintf(stream, "%ld", longinfo);
|
2000-10-04 09:08:17 -04:00
|
|
|
break;
|
2004-10-19 11:30:08 -04:00
|
|
|
case VAR_NUM_CONNECTS:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &longinfo))
|
|
|
|
fprintf(stream, "%ld", longinfo);
|
|
|
|
break;
|
2004-11-15 06:25:39 -05:00
|
|
|
case VAR_REDIRECT_COUNT:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &longinfo))
|
|
|
|
fprintf(stream, "%ld", longinfo);
|
|
|
|
break;
|
|
|
|
case VAR_REDIRECT_TIME:
|
|
|
|
if(CURLE_OK ==
|
2011-04-25 16:44:39 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME,
|
|
|
|
&doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2004-11-15 06:25:39 -05:00
|
|
|
break;
|
2000-10-02 02:30:40 -04:00
|
|
|
case VAR_TOTAL_TIME:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
|
|
|
case VAR_NAMELOOKUP_TIME:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME,
|
|
|
|
&doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
|
|
|
case VAR_CONNECT_TIME:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
2008-07-03 02:56:03 -04:00
|
|
|
case VAR_APPCONNECT_TIME:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME,
|
|
|
|
&doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2008-07-03 02:56:03 -04:00
|
|
|
break;
|
2000-10-02 02:30:40 -04:00
|
|
|
case VAR_PRETRANSFER_TIME:
|
|
|
|
if(CURLE_OK ==
|
2008-07-03 02:56:03 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME,
|
|
|
|
&doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
2001-11-20 10:00:50 -05:00
|
|
|
case VAR_STARTTRANSFER_TIME:
|
|
|
|
if(CURLE_OK ==
|
2008-07-03 02:56:03 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME,
|
|
|
|
&doubleinfo))
|
2016-11-04 10:45:49 -04:00
|
|
|
fprintf(stream, "%.6f", doubleinfo);
|
2001-11-20 10:00:50 -05:00
|
|
|
break;
|
2000-10-02 02:30:40 -04:00
|
|
|
case VAR_SIZE_UPLOAD:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &doubleinfo))
|
2001-04-19 07:24:29 -04:00
|
|
|
fprintf(stream, "%.0f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
|
|
|
case VAR_SIZE_DOWNLOAD:
|
|
|
|
if(CURLE_OK ==
|
2011-04-25 16:44:39 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD,
|
|
|
|
&doubleinfo))
|
2001-04-19 07:24:29 -04:00
|
|
|
fprintf(stream, "%.0f", doubleinfo);
|
2000-10-02 02:30:40 -04:00
|
|
|
break;
|
|
|
|
case VAR_SPEED_DOWNLOAD:
|
|
|
|
if(CURLE_OK ==
|
2011-04-25 16:44:39 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD,
|
|
|
|
&doubleinfo))
|
2000-10-02 02:30:40 -04:00
|
|
|
fprintf(stream, "%.3f", doubleinfo);
|
|
|
|
break;
|
|
|
|
case VAR_SPEED_UPLOAD:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &doubleinfo))
|
|
|
|
fprintf(stream, "%.3f", doubleinfo);
|
|
|
|
break;
|
2002-02-25 02:40:49 -05:00
|
|
|
case VAR_CONTENT_TYPE:
|
2002-07-30 07:07:59 -04:00
|
|
|
if((CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &stringp))
|
|
|
|
&& stringp)
|
|
|
|
fputs(stringp, stream);
|
2006-03-21 17:30:03 -05:00
|
|
|
break;
|
|
|
|
case VAR_FTP_ENTRY_PATH:
|
|
|
|
if((CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &stringp))
|
|
|
|
&& stringp)
|
2008-04-30 17:20:08 -04:00
|
|
|
fputs(stringp, stream);
|
|
|
|
break;
|
|
|
|
case VAR_REDIRECT_URL:
|
|
|
|
if((CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &stringp))
|
|
|
|
&& stringp)
|
2006-03-21 17:30:03 -05:00
|
|
|
fputs(stringp, stream);
|
|
|
|
break;
|
2008-07-30 17:24:19 -04:00
|
|
|
case VAR_SSL_VERIFY_RESULT:
|
|
|
|
if(CURLE_OK ==
|
2011-04-25 16:44:39 -04:00
|
|
|
curl_easy_getinfo(curl, CURLINFO_SSL_VERIFYRESULT,
|
|
|
|
&longinfo))
|
2008-07-30 17:24:19 -04:00
|
|
|
fprintf(stream, "%ld", longinfo);
|
|
|
|
break;
|
2016-11-16 12:49:15 -05:00
|
|
|
case VAR_PROXY_SSL_VERIFY_RESULT:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_PROXY_SSL_VERIFYRESULT,
|
|
|
|
&longinfo))
|
|
|
|
fprintf(stream, "%ld", longinfo);
|
|
|
|
break;
|
2012-03-04 18:07:03 -05:00
|
|
|
case VAR_EFFECTIVE_FILENAME:
|
|
|
|
if(outs->filename)
|
|
|
|
fprintf(stream, "%s", outs->filename);
|
|
|
|
break;
|
2012-11-07 17:30:25 -05:00
|
|
|
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;
|
2016-05-11 08:23:37 -04:00
|
|
|
case VAR_HTTP_VERSION:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_HTTP_VERSION,
|
|
|
|
&longinfo)) {
|
|
|
|
const char *version = "0";
|
2016-12-13 17:34:59 -05:00
|
|
|
switch(longinfo) {
|
2016-05-11 08:23:37 -04:00
|
|
|
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;
|
2016-11-23 04:44:18 -05:00
|
|
|
case VAR_SCHEME:
|
|
|
|
if(CURLE_OK ==
|
|
|
|
curl_easy_getinfo(curl, CURLINFO_SCHEME,
|
|
|
|
&stringp))
|
|
|
|
fprintf(stream, "%s", stringp);
|
2018-10-08 17:54:01 -04:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case VAR_STDOUT:
|
|
|
|
stream = stdout;
|
|
|
|
break;
|
|
|
|
case VAR_STDERR:
|
|
|
|
stream = stderr;
|
2016-11-23 04:44:18 -05:00
|
|
|
break;
|
2000-11-21 04:38:41 -05:00
|
|
|
default:
|
|
|
|
break;
|
2000-10-02 02:30:40 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-09-05 14:46:09 -04:00
|
|
|
if(!match) {
|
2006-02-23 16:33:02 -05:00
|
|
|
fprintf(stderr, "curl: unknown --write-out variable: '%s'\n", ptr);
|
2005-09-06 09:27:18 -04:00
|
|
|
}
|
2011-10-06 11:39:00 -04:00
|
|
|
ptr = end + 1; /* pass the end */
|
2000-10-02 02:30:40 -04:00
|
|
|
*end = keepit;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* illegal syntax, then just output the characters that are used */
|
|
|
|
fputc('%', stream);
|
|
|
|
fputc(ptr[1], stream);
|
2011-10-06 11:39:00 -04:00
|
|
|
ptr += 2;
|
2000-10-02 02:30:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-24 05:14:21 -04:00
|
|
|
else if('\\' == *ptr && ptr[1]) {
|
2000-10-02 02:30:40 -04:00
|
|
|
switch(ptr[1]) {
|
|
|
|
case 'r':
|
|
|
|
fputc('\r', stream);
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
fputc('\n', stream);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
fputc('\t', stream);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* unknown, just output this */
|
|
|
|
fputc(*ptr, stream);
|
|
|
|
fputc(ptr[1], stream);
|
|
|
|
break;
|
|
|
|
}
|
2011-10-06 11:39:00 -04:00
|
|
|
ptr += 2;
|
2000-10-02 02:30:40 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputc(*ptr, stream);
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
2004-07-26 05:09:26 -04:00
|
|
|
|
2000-10-02 02:30:40 -04:00
|
|
|
}
|