~ubuntu-branches/ubuntu/dapper/curl/dapper-security

« back to all changes in this revision

Viewing changes to docs/examples/ftp3rdparty.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2005-07-26 19:03:01 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20050726190301-x2m2vmjgc8fwnic5
Tags: 7.14.0-2ubuntu1
Synchronize with Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
 
 *                                  _   _ ____  _     
3
 
 *  Project                     ___| | | |  _ \| |    
4
 
 *                             / __| | | | |_) | |    
5
 
 *                            | (__| |_| |  _ <| |___ 
 
2
 *                                  _   _ ____  _
 
3
 *  Project                     ___| | | |  _ \| |
 
4
 *                             / __| | | | |_) | |
 
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * $Id: ftp3rdparty.c,v 1.1 2004/06/03 11:15:27 bagder Exp $
 
8
 * $Id: ftp3rdparty.c,v 1.2 2005/01/21 09:32:33 bagder Exp $
9
9
 */
10
10
 
11
11
#include <stdio.h>
16
16
 
17
17
/*
18
18
 * This is an example showing how to transfer a file between two remote hosts.
 
19
 * 7.13.0 or later required.
19
20
 */
20
21
 
21
 
 
22
 
 
23
22
int main(void)
24
23
{
25
24
  CURL *curl;
26
25
  CURLcode res;
27
 
  char sourceFileName[] = "/tmp/file";
28
 
  char targetFileName[] = "/tmp/curlTargetTest.dat";
29
 
  char sourceHost[] = "source";
30
 
  char targetHost[] = "target";
 
26
  char source_url[] = "ftp://remotehost.com/path/to/source";
 
27
  char target_url[] = "ftp://aotherserver.com/path/to/dest";
 
28
 
31
29
  char sourceUserPass[] = "user:pass";
32
30
  char targetUserPass[] = "user:pass";
33
31
  char url[100];
34
 
  
 
32
 
35
33
  struct curl_slist *source_pre_cmd = NULL;
36
34
  struct curl_slist *target_pre_cmd = NULL;
37
35
  struct curl_slist *source_post_cmd = NULL;
39
37
  char cmd[] = "PWD";   /* just to test */
40
38
 
41
39
  curl_global_init(CURL_GLOBAL_DEFAULT);
42
 
  
 
40
 
43
41
  curl = curl_easy_init();
44
42
  if (curl) {
45
 
    sprintf(url, "ftp://%s@%s/%s", targetUserPass, targetHost, targetFileName);
46
 
    printf("%s\n", url);
47
 
    curl_easy_setopt(curl, CURLOPT_URL, url);
48
 
 
49
 
    /* Set a proxy host */
50
 
    curl_easy_setopt(curl, CURLOPT_SOURCE_HOST, sourceHost);
51
 
 
52
 
    /* Set a proxy user and password */
 
43
    /* The ordinary URL is the target when speaking 3rd party transfers */
 
44
    curl_easy_setopt(curl, CURLOPT_URL, target_url);
 
45
 
 
46
    /* Set a source URL */
 
47
    curl_easy_setopt(curl, CURLOPT_SOURCE_URL, source_url);
 
48
 
 
49
    /* Set target user and password */
 
50
    curl_easy_setopt(curl, CURLOPT_USERPWD, targetUserPass);
 
51
 
 
52
    /* Set source user and password */
53
53
    curl_easy_setopt(curl, CURLOPT_SOURCE_USERPWD, sourceUserPass);
54
54
 
55
 
    /* Set a proxy full file name */
56
 
    curl_easy_setopt(curl, CURLOPT_SOURCE_PATH, sourceFileName);
57
 
 
58
 
    /* Set a proxy passive host */
59
 
    curl_easy_setopt(curl, CURLOPT_PASV_HOST, 0);   /* optional */
 
55
#if 0
 
56
    /* FTPPORT enables PORT on the target side, instead of PASV. */
 
57
    curl_easy_setopt(curl, CURLOPT_FTPPORT, "");   /* optional */
 
58
#endif
60
59
 
61
60
    /* build a list of commands to pass to libcurl */
62
61
    source_pre_cmd = curl_slist_append(source_pre_cmd, cmd);
77
76
    target_post_cmd = curl_slist_append(target_post_cmd, cmd);
78
77
    /* Set a post-quote command */
79
78
    curl_easy_setopt(curl, CURLOPT_POSTQUOTE, target_post_cmd);
80
 
    
 
79
 
81
80
    /* Switch on full protocol/debug output */
82
81
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
83
82