lib1555.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 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. #include "test.h"
  28. #include "memdebug.h"
  29. static CURL *curl;
  30. static int progressCallback(void *arg,
  31. double dltotal,
  32. double dlnow,
  33. double ultotal,
  34. double ulnow)
  35. {
  36. CURLcode res = CURLE_OK;
  37. char buffer[256];
  38. size_t n = 0;
  39. (void)arg;
  40. (void)dltotal;
  41. (void)dlnow;
  42. (void)ultotal;
  43. (void)ulnow;
  44. res = curl_easy_recv(curl, buffer, 256, &n);
  45. printf("curl_easy_recv returned %d\n", res);
  46. res = curl_easy_send(curl, buffer, n, &n);
  47. printf("curl_easy_send returned %d\n", res);
  48. return 1;
  49. }
  50. int test(char *URL)
  51. {
  52. int res = 0;
  53. global_init(CURL_GLOBAL_ALL);
  54. easy_init(curl);
  55. easy_setopt(curl, CURLOPT_URL, URL);
  56. easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
  57. easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
  58. CURL_IGNORE_DEPRECATION(
  59. easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
  60. easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
  61. )
  62. easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
  63. res = curl_easy_perform(curl);
  64. test_cleanup:
  65. /* undocumented cleanup sequence - type UA */
  66. curl_easy_cleanup(curl);
  67. curl_global_cleanup();
  68. return res;
  69. }