There is no scp.c in curl package 7.36.0. I haven't got the chance to review 
the source code of 7.51.0 version. Do we have to rewrite our application code 
for using the new curl library? Here is our application code for getting a file 
using scp via curl library. 

GsStatus
xftp_get_file_e(XftpParams *pXftpParams, Boolean bUseRetries,
                char *stderrStr, int stderrSize)
{
   CURL        *curl;
   CURLcode     res = CURLE_FAILED_INIT;
   char         remotePath[4096]; /* Have big enough buffer to construct remote
                                     server name, userid, passwd, filename & 
path */
   char         err[4096];
   int          attempt = 1;
   int          retries;
   int          retryInterval;
   XftpCurlFile xftpLocalfile = { pXftpParams->localFileName, NULL};
  retries       = bUseRetries ? 1 : 0;   
   retryInterval = 15;

   curl_global_init(CURL_GLOBAL_DEFAULT);
   do
   {
      if (attempt > 1)
         delay(retryInterval * 1000);
      curl = curl_easy_init();
      if (curl)
      {
         // Build TFTP/FTP/SFTP string required for CURL
         if (xftpURLGet(curl, remotePath, sizeof(remotePath),
                        pXftpParams->hostname, pXftpParams->username,
                        pXftpParams->password,
                        pXftpParams->remoteFileName,
                        pXftpParams->hostmode) == False)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         if (curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT,
                              pXftpParams->hostmode == XftpMode_Sftp ?
                              XFTP_DEFAULT_SFTP_TIMEOUT :
                              XFTP_DEFAULT_FTP_TIMEOUT) != CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         if (curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT,  
XFTP_DEFAULT_LOW_SPEED_LIMIT) != CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         if (curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME , 
XFTP_DEFAULT_LOW_SPEED_TIME) != CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         if (curl_easy_setopt(curl, CURLOPT_URL, remotePath) != CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         /* Define our callback to get called when there's data to be written */
         if (curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite) != 
CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         /* Set a pointer to our struct to pass to the callback */
         if (curl_easy_setopt(curl, CURLOPT_WRITEDATA, &xftpLocalfile) != 
CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }

         /* Set transfer mode to Binary (0 == BIN) */
         if (curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 0) != CURLE_OK)
         {
            curl_easy_cleanup(curl);
            curl_global_cleanup();
            return XftpStatus_CurlInitFailed;
         }
         /* Switch on full protocol/debug output */
         curl_easy_setopt(curl, CURLOPT_VERBOSE, XFTP_VERBOSE_LEVEL);
         /* Switch on full protocol/debug output */
         curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, err);
         res = curl_easy_perform(curl);
         /* always cleanup */
         curl_easy_cleanup(curl);

         if (xftpLocalfile.stream)
         {
            fclose(xftpLocalfile.stream); /* close the local file */
         }
      }
   } while ((res != CURLE_OK) && (attempt++ <= retries));
    curl_global_cleanup();
    return xftpCurlResultToGsStatus(res);
}  /* xftp_get_file_e */


-----Original Message-----
From: curl-library [mailto:curl-library-boun...@cool.haxx.se] On Behalf Of 
Daniel Stenberg
Sent: Wednesday, October 19, 2016 7:07 PM
To: libcurl development <curl-library@cool.haxx.se>
Subject: RE: curl library 7.36.0: curl_easy_perform() function call failed when 
used for getting a file from Window's machine to my linux box

On Wed, 19 Oct 2016, Zhao, Joe wrote:

> * Authentication complete
> * SSH CONNECT phase done
> * Failed reading SCP response

This last message is the error string from libssh2 (the src/scp.c:scp_recv 
function to be exact). So I maintain that you need to try to use libssh2 
directly and see what you can figure out. And make sure you try this with the 
latest libssh2 first before you spend a lot of time on it.

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to