]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/thirdparty/curl/tests/libtest/lib578.c
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / thirdparty / curl / tests / libtest / lib578.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2011, 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 http://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 /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
27 static char data[]="this is a short string.\n";
28
29 static size_t data_size = sizeof(data) / sizeof(char);
30
31 static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
32 {
33   FILE *moo = fopen(libtest_arg2, "wb");
34
35   (void)clientp; /* UNUSED */
36   (void)dltotal; /* UNUSED */
37   (void)dlnow; /* UNUSED */
38
39   if(moo) {
40     if ((size_t)ultotal == data_size && (size_t)ulnow == data_size)
41       fprintf(moo, "PASSED, UL data matched data size\n");
42     else
43       fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal);
44     fclose(moo);
45   }
46   return 0;
47 }
48
49 int test(char *URL)
50 {
51   CURL *curl;
52   CURLcode res=CURLE_OK;
53
54   if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
55     fprintf(stderr, "curl_global_init() failed\n");
56     return TEST_ERR_MAJOR_BAD;
57   }
58
59   if ((curl = curl_easy_init()) == NULL) {
60     fprintf(stderr, "curl_easy_init() failed\n");
61     curl_global_cleanup();
62     return TEST_ERR_MAJOR_BAD;
63   }
64
65   /* First set the URL that is about to receive our POST. */
66   test_setopt(curl, CURLOPT_URL, URL);
67
68   /* Now specify we want to POST data */
69   test_setopt(curl, CURLOPT_POST, 1L);
70
71 #ifdef CURL_DOES_CONVERSIONS
72   /* Convert the POST data to ASCII */
73   test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
74 #endif
75
76   /* Set the expected POST size */
77   test_setopt(curl, CURLOPT_POSTFIELDSIZE, data_size);
78   test_setopt(curl, CURLOPT_POSTFIELDS, data);
79
80   /* we want to use our own progress function */
81   test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
82   test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
83
84   /* pointer to pass to our read function */
85
86   /* get verbose debug output please */
87   test_setopt(curl, CURLOPT_VERBOSE, 1L);
88
89   /* include headers in the output */
90   test_setopt(curl, CURLOPT_HEADER, 1L);
91
92   /* Perform the request, res will get the return code */
93   res = curl_easy_perform(curl);
94
95 test_cleanup:
96
97   /* always cleanup */
98   curl_easy_cleanup(curl);
99   curl_global_cleanup();
100
101   return res;
102 }