cURL / Mailing Lists / curl-library / Single Mail

curl-library

FTP over ssl error

From: 黃碩達 <huangsd2001_at_yahoo.com.tw>
Date: Tue, 26 Oct 2004 13:41:43 +0800 (CST)

This is my source code, and I always get error code 60
I have already check out the meaning of error code 60,
but I still have no ideas how to fix it..
------------------------------------------------------

#include "stdafx.h"
#include "curl/curl.h"
#include "curl/types.h"
#include "curl/easy.h"

struct FtpFile {
  char *filename;
  FILE *stream;
};
size_t
write_response(void *ptr, size_t size, size_t nmemb,
void *data)
{
  FILE *writehere = (FILE *)data;
  return fwrite(ptr, size, nmemb, writehere);
}
int my_fwrite(void *buffer, size_t size, size_t nmemb,
void *stream)
{
  struct FtpFile *out=(struct FtpFile *)stream;
  if(out && !out->stream) {
    /* open file for writing */
    out->stream=fopen(out->filename, "wb");
    if(!out->stream)
      return -1; /* failure, can't open file to write
*/
  }
  return fwrite(buffer, size, nmemb, out->stream);
}

int _tmain(int argc, _TCHAR* argv[])
{
  CURL *curl;
  CURLcode res;
  struct FtpFile ftpfile={
    "int15.sys", /* name to store the file as if
succesful */
    NULL
  };

  curl_global_init(CURL_GLOBAL_ALL);
  
  curl = curl_easy_init();
  if(curl) {
    /* Get curl 7.9.2 from sunet.se's FTP site: */
    curl_easy_setopt(curl, CURLOPT_URL,
                     "ftps://10.26.45.16/int15.sys");
        curl_easy_setopt(curl, CURLOPT_USERPWD,
"startss:806625");
    /* Define our callback to get called when there's
data to be written */
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
my_fwrite);
    /* Set a pointer to our struct to pass to the
callback */
    curl_easy_setopt(curl, CURLOPT_WRITEDATA,
&ftpfile);

    /* Switch on full protocol/debug output */
    curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);

    res = curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);

    if(CURLE_OK != res) {
      /* we failed */
      fprintf(stderr, "curl told us %d\n", res);
    }
  }

  if(ftpfile.stream)
    fclose(ftpfile.stream); /* close the local file */

  curl_global_cleanup();

  return 0;
}

=====
國立中山大學資訊工程學系.Huang Shuo-Da(黃碩達)
National Sun Yat-Sen University
Department of Computer Science Engineering
http://huangsd.dormf.nsysu.edu.tw/~startss
E-Mail:huangsd2001_at_yahoo.com.tw Tel:5254333

-----------------------------------------------------------------
Yahoo!奇摩電子信箱
100MB 免費信箱,電子信箱新紀元從這開始!
http://mail.yahoo.com.tw/
Received on 2004-10-26