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
27#include "test.h"
28
29#include <unistd.h>
30#include <sys/stat.h>
31
32int test(char *URL)
33{
34  CURLMcode retVal;
35  int stillRunning;
36  CURLM* multiHandle;
37  CURL* curl;
38  int res;
39
40  curl_global_init(CURL_GLOBAL_ALL);
41
42  multiHandle = curl_multi_init();
43  curl = curl_easy_init();
44
45  test_setopt(curl, CURLOPT_USERPWD, libtest_arg2);
46  test_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub");
47  test_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key");
48
49  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
50  curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
51
52  curl_easy_setopt(curl, CURLOPT_URL, URL);
53  curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long)5);
54
55  curl_multi_add_handle(multiHandle, curl);
56  retVal = curl_multi_perform(multiHandle, &stillRunning);
57  if (retVal != CURLM_OK)
58    fprintf(stderr, "curl_multi_perform() failed!n");
59
60  fprintf(stderr, "curl_multi_remove_handle()!\n");
61  retVal = curl_multi_remove_handle(multiHandle, curl);
62  if (retVal == CURLM_OK)
63    fprintf(stderr, "curl_multi_remove_handle() was successful!\n");
64  else
65    fprintf(stderr, "curl_multi_remove_handle() failed\n");
66
67test_cleanup:
68
69  curl_easy_cleanup(curl);
70  curl_multi_cleanup(multiHandle);
71
72  return res;
73}
74