lib599.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at https://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 #include "test.h"
23 
24 #include "memdebug.h"
25 
26 static int progress_callback(void *clientp, double dltotal,
27  double dlnow, double ultotal, double ulnow)
28 {
29  (void)clientp;
30  (void)ulnow;
31  (void)ultotal;
32 
33  if((dltotal > 0.0) && (dlnow > dltotal)) {
34  /* this should not happen with test case 599 */
35  printf("%.0f > %.0f !!\n", dltotal, dlnow);
36  return -1;
37  }
38 
39  return 0;
40 }
41 
42 int test(char *URL)
43 {
44  CURL *curl;
46  double content_length = 0.0;
47 
49  fprintf(stderr, "curl_global_init() failed\n");
50  return TEST_ERR_MAJOR_BAD;
51  }
52 
53  curl = curl_easy_init();
54  if(!curl) {
55  fprintf(stderr, "curl_easy_init() failed\n");
57  return TEST_ERR_MAJOR_BAD;
58  }
59 
60  /* First set the URL that is about to receive our POST. */
61  test_setopt(curl, CURLOPT_URL, URL);
62 
63  /* we want to use our own progress function */
64  test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
65  test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
66 
67  /* get verbose debug output please */
68  test_setopt(curl, CURLOPT_VERBOSE, 1L);
69 
70  /* follow redirects */
71  test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
72 
73  /* include headers in the output */
74  test_setopt(curl, CURLOPT_HEADER, 1L);
75 
76  /* Perform the request, res will get the return code */
77  res = curl_easy_perform(curl);
78 
79  if(!res) {
80  FILE *moo;
82  &content_length);
83  moo = fopen(libtest_arg2, "wb");
84  if(moo) {
85  fprintf(moo, "CL: %.0f\n", content_length);
86  fclose(moo);
87  }
88  }
89 
90 test_cleanup:
91 
92  /* always cleanup */
93  curl_easy_cleanup(curl);
95 
96  return res;
97 }
#define test_setopt(A, B, C)
Definition: test.h:47
CURLcode
Definition: curl.h:454
static int res
#define TEST_ERR_MAJOR_BAD
Definition: test.h:85
char * libtest_arg2
Definition: first.c:75
#define curl_easy_getinfo(handle, info, arg)
#define printf
Definition: curl_printf.h:40
CURL_EXTERN CURL * curl_easy_init(void)
Definition: easy.c:343
CURL_EXTERN void curl_easy_cleanup(CURL *curl)
Definition: curl.h:455
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
Definition: lib599.c:26
int test(char *URL)
Definition: lib599.c:42
CURL_EXTERN CURLcode curl_global_init(long flags)
curl_global_init() globally initializes curl given a bitwise set of the different features of what to...
Definition: easy.c:271
void CURL
Definition: curl.h:102
#define fprintf
Definition: curl_printf.h:41
CURL_EXTERN void curl_global_cleanup(void)
curl_global_cleanup() globally cleanups curl, uses the value of "init_flags" to determine what needs ...
Definition: easy.c:312
#define CURL_GLOBAL_ALL
Definition: curl.h:2519
static CURL * curl
Definition: sessioninfo.c:35
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl)


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:15