cURL / Mailing Lists / curl-users / Single Mail

curl-users

Malformed URL Error

From: Jim Owen <jimo_at_earthlink.net>
Date: Sun, 3 Jul 2005 11:21:20 -0700

I've been writing a very simply C program to make a ftp transfer from one
machine to another and am getting an error 3 returned no mater what options
I enable. Here' s the code executing:
 
 
##########################################
 // init curl
 curl_global_init(CURL_GLOBAL_ALL);
 
 // Get a handle
 curl = curl_easy_init();
 if ( !curl )
  return an error.
 
 /* get the file size of the local file */
 hd = open(putfile_name, O_RDONLY) ;
 fstat(hd, &file_info);
 close(hd) ;
 
 // Open the file to transfer
 putfile = fopen( putfile_name, "rb");
 if ( putfile == NULL )
  return an error.
 
 // Create the command for curl
 strcpy( cmd_buf, "RNFR ");
 strcat( cmd_buf, putfile_name );
 
 headerlist = curl_slist_append( headerlist, cmd_buf );
 // Enable upload
 curl_easy_setopt( curl, CURLOPT_UPLOAD, TRUE );
 // Create target
 sprintf(ftp_target, "ftp://%s%s", ftp_site, putfile_dir );
 
 curl_easy_setopt( curl, CURLOPT_READDATA, putfile );
 // Set size of upload
 curl_easy_setopt( curl, CURLOPT_INFILESIZE_LARGE,
           (curl_off_t)file_info.st_size );
 // Set username and password
 sprintf(user_pwd, "%s:%s", ftp_uid, ftp_pwd);
 curl_easy_setopt(curl, CURLOPT_USERPWD, user_pwd);
 
 // set verbose on if debug
 if ( bDebugMode )
 {
  curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE );
  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &errBuf );
  curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, TRUE );
 }
 
 // Now Do it
 res = curl_easy_perform( curl );
 if ( res != CURLE_OK )
 {
  retValue = res;
 }
 // Clean up list
 curl_slist_free_all( headerlist );
 // Clean up easy
 curl_easy_cleanup(curl);
 // Close file
 fclose( putfile );
 // Global close
 curl_global_cleanup();
##############################################
 
When I look at printf values from debug I put in, all looks fine.
 
RedHat linux. gcc compiler.
 
Any suggestions?
 
TIA,
 
Jim
 
 
 
Received on 2005-07-03