-/*****************************************************************************
+/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
- * argv1 = URL
+ * 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 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
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+/* argv1 = URL
* argv2 = proxy with embedded user+password
*/
#include "test.h"
+#include "warnless.h"
#include "memdebug.h"
struct data {
for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
- if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
+ if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width);
break;
}
fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
- if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
+ if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width);
break;
}
const char *text;
(void)handle; /* prevent compiler warning */
- switch (type) {
+ switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "== Info: %s", (char *)data);
default: /* in case a new one is introduced to shock us */
static size_t current_offset = 0;
-static char databuf[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */
+static char databuf[70000]; /* MUST be more than 64k OR
+ MAX_INITIAL_POST_SIZE */
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
- size_t available = sizeof(databuf) - current_offset; /* What we have to give */
+ size_t available = sizeof(databuf) - current_offset; /* What we have to
+ give */
size_t given = amount < available ? amount : available; /* What is given */
(void)stream;
memcpy(ptr, databuf + current_offset, given);
}
-static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream)
+static size_t write_callback(void *ptr, size_t size, size_t nmemb,
+ void *stream)
{
- printf("%.*s", (int)(size * nmemb), (char *)ptr);
+ int amount = curlx_uztosi(size * nmemb);
+ printf("%.*s", amount, (char *)ptr);
(void)stream;
return size * nmemb;
}
-static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp)
+static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
{
(void)clientp;
- if (cmd == CURLIOCMD_RESTARTREAD ) {
- printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n");
+ if(cmd == CURLIOCMD_RESTARTREAD) {
+ printf("APPLICATION: received a CURLIOCMD_RESTARTREAD request\n");
printf("APPLICATION: ** REWINDING! **\n");
current_offset = 0;
return CURLIOE_OK;
config.trace_ascii = 1; /* enable ascii tracing */
- if((curl = curl_easy_init()) == NULL) {
+ curl = curl_easy_init();
+ if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* setup repeated data string */
- for (i=0; i < sizeof(databuf); ++i)
+ for(i=0; i < sizeof(databuf); ++i)
databuf[i] = fill[i % sizeof fill];
/* Post */
test_setopt(curl, CURLOPT_URL, URL);
- /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */
+ /* Accept any auth. But for this bug configure proxy with DIGEST, basic
+ might work too, not NTLM */
test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
res = curl_easy_perform(curl);