lib583.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /*
  23. * This test case is based on the sample code provided by Saqib Ali
  24. * http://curl.haxx.se/mail/lib-2011-03/0066.html
  25. */
  26. #include "test.h"
  27. #include <sys/stat.h>
  28. #include "memdebug.h"
  29. int test(char *URL)
  30. {
  31. int stillRunning;
  32. CURLM* multiHandle = NULL;
  33. CURL* curl = NULL;
  34. int res = 0;
  35. global_init(CURL_GLOBAL_ALL);
  36. multi_init(multiHandle);
  37. easy_init(curl);
  38. easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
  39. easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
  40. easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
  41. easy_setopt(curl, CURLOPT_UPLOAD, 1L);
  42. easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  43. easy_setopt(curl, CURLOPT_URL, URL);
  44. easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
  45. multi_add_handle(multiHandle, curl);
  46. /* this tests if removing an easy handle immediately after multi
  47. perform has been called succeeds or not. */
  48. fprintf(stderr, "curl_multi_perform()...\n");
  49. multi_perform(multiHandle, &stillRunning);
  50. fprintf(stderr, "curl_multi_perform() succeeded\n");
  51. fprintf(stderr, "curl_multi_remove_handle()...\n");
  52. res = (int) curl_multi_remove_handle(multiHandle, curl);
  53. if(res)
  54. fprintf(stderr, "curl_multi_remove_handle() failed, "
  55. "with code %d\n", res);
  56. else
  57. fprintf(stderr, "curl_multi_remove_handle() succeeded\n");
  58. test_cleanup:
  59. /* undocumented cleanup sequence - type UB */
  60. curl_easy_cleanup(curl);
  61. curl_multi_cleanup(multiHandle);
  62. curl_global_cleanup();
  63. return res;
  64. }