2 #include "curl_debug_gcal.h"
4 /* Coments: this came straight from libcurl examples directory and
5 * will print information to stderr when executing curl_easy_perform.
6 * I'm not completely sure about its author, but I'm assuming that it uses
7 * the same license as curl itself (X11/MIT).
9 * I made only small changes in space and formating.
11 * Adenilson Cavalcanti
14 /*****************************************************************************
16 * Project ___| | | | _ \| |
18 * | (__| |_| | _ <| |___
19 * \___|\___/|_| \_\_____|
21 * $Id: debug.c,v 1.2 2006-10-20 21:26:10 bagder Exp $
25 static void curl_debug_dump(const char *text
,
26 FILE *stream
, unsigned char *ptr
, size_t size
,
32 unsigned int width
=0x10;
34 /* without the hex output, we can fit more on screen */
38 fprintf(stream
, "%s, %zd bytes (0x%zx)\n", text
, size
, size
);
40 for (i
= 0; i
< size
; i
+= width
) {
42 fprintf(stream
, "%04zx: ", i
);
45 /* hex not disabled, show it */
46 for(c
= 0; c
< width
; c
++)
48 fprintf(stream
, "%02x ", ptr
[i
+c
]);
53 for(c
= 0; (c
< width
) && (i
+c
< size
); c
++) {
54 /* check for 0D0A; if found, skip past and start
55 * a new line of output
57 if (nohex
&& (i
+c
+1 < size
) &&
58 ptr
[i
+c
]==0x0D && ptr
[i
+c
+1]==0x0A) {
65 (ptr
[i
+c
]<0x80)?ptr
[i
+c
]:'.');
67 /* check again for 0D0A, to avoid an extra
70 if (nohex
&& (i
+c
+2 < size
) &&
71 ptr
[i
+c
+1]==0x0D && ptr
[i
+c
+2]==0x0A) {
77 fputc('\n', stream
); /* newline */
83 int curl_debug_gcal_trace(CURL
*handle
, curl_infotype type
,
84 unsigned char *data
, size_t size
,
87 struct data_curl_debug
*config
= (struct data_curl_debug
*)userp
;
89 (void)handle
; /* prevent compiler warning */
93 fprintf(stderr
, "== Info: %s", data
);
94 default: /* in case a new one is introduced to shock us */
97 case CURLINFO_HEADER_OUT
:
98 text
= "=> Send header";
100 case CURLINFO_DATA_OUT
:
101 text
= "=> Send data";
103 case CURLINFO_SSL_DATA_OUT
:
104 text
= "=> Send SSL data";
106 case CURLINFO_HEADER_IN
:
107 text
= "<= Recv header";
109 case CURLINFO_DATA_IN
:
110 text
= "<= Recv data";
112 case CURLINFO_SSL_DATA_IN
:
113 text
= "<= Recv SSL data";
117 curl_debug_dump(text
, stderr
, data
, size
, config
->trace_ascii
);