* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, 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
* KIND, either express or implied.
*
***************************************************************************/
-#include "setup.h"
-
-#include <curl/curl.h>
+#include "tool_setup.h"
#define ENABLE_CURLX_PRINTF
/* use our own printf() functions */
unsigned char *data, size_t size,
void *userdata)
{
- struct Configurable *config = userdata;
+ struct OperationConfig *operation = userdata;
+ struct GlobalConfig *config = operation->global;
FILE *output = config->errors;
const char *text;
struct timeval tv;
output = config->trace_stream;
if(!output) {
- warnf(config, "Failed to create/open output");
+ warnf(operation, "Failed to create/open output");
return 0;
}
switch(type) {
case CURLINFO_HEADER_OUT:
- for(i = 0; i < size - 1; i++) {
- if(data[i] == '\n') { /* LF */
- if(!newl) {
- fprintf(output, "%s%s ", timebuf, s_infotype[type]);
+ if(size > 0) {
+ for(i = 0; i < size - 1; i++) {
+ if(data[i] == '\n') { /* LF */
+ if(!newl) {
+ fprintf(output, "%s%s ", timebuf, s_infotype[type]);
+ }
+ (void)fwrite(data + st, i - st + 1, 1, output);
+ st = i + 1;
+ newl = FALSE;
}
- (void)fwrite(data + st, i - st + 1, 1, output);
- st = i + 1;
- newl = FALSE;
}
+ if(!newl)
+ fprintf(output, "%s%s ", timebuf, s_infotype[type]);
+ (void)fwrite(data + st, i - st + 1, 1, output);
}
- if(!newl)
- fprintf(output, "%s%s ", timebuf, s_infotype[type]);
- (void)fwrite(data + st, i - st + 1, 1, output);
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
traced_data = FALSE;
break;
to stderr or stdout, we don't display the alert about the data not
being shown as the data _is_ shown then just not via this
function */
- if(!config->isatty ||
- ((output != stderr) && (output != stdout))) {
+ if(!config->isatty || ((output != stderr) && (output != stdout))) {
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
- fprintf(output, "[data not shown]\n");
+ fprintf(output, "[%zd bytes data]\n", size);
newl = FALSE;
traced_data = TRUE;
}