blob: eb39e96e64b5b8cc2d2f5b8e9244e6c4cca72e44 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) 1998 - 2022, 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.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 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24/*
25 * Verify that some API functions are locked from being called inside callback
26 */
27
28#include "test.h"
29
30#include "memdebug.h"
31
32static CURL *curl;
33
34static int progressCallback(void *arg,
35 double dltotal,
36 double dlnow,
37 double ultotal,
38 double ulnow)
39{
40 CURLcode res = CURLE_OK;
41 char buffer[256];
42 size_t n = 0;
43 (void)arg;
44 (void)dltotal;
45 (void)dlnow;
46 (void)ultotal;
47 (void)ulnow;
48 res = curl_easy_recv(curl, buffer, 256, &n);
49 printf("curl_easy_recv returned %d\n", res);
50 res = curl_easy_send(curl, buffer, n, &n);
51 printf("curl_easy_send returned %d\n", res);
52
53 return 1;
54}
55
56int test(char *URL)
57{
58 int res = 0;
59
60 global_init(CURL_GLOBAL_ALL);
61
62 easy_init(curl);
63
64 easy_setopt(curl, CURLOPT_URL, URL);
65 easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
66 easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
67 easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
68 easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
69 easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
70
71 res = curl_easy_perform(curl);
72
73test_cleanup:
74
75 /* undocumented cleanup sequence - type UA */
76
77 curl_easy_cleanup(curl);
78 curl_global_cleanup();
79
80 return res;
81}