cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Error codes from SFTP

From: Sam Deane <sam_at_elegantchaos.com>
Date: Thu, 11 Apr 2013 17:03:58 +0100

On 10 Apr 2013, at 23:30, Dan Fandrich <dan_at_coneharvesters.com> wrote:

> That's what's returned by CURLINFO_RESPONSE_CODE, which is already used for
> non-HTTP protocols, so it sounds like a reasonable extension to me. Please also
> document this use in curl_easy_getinfo.3 Ideally, the response code for all
> SFTP operations would be stored, not just failures in quoted commands. And
> httpcode must be 0 in all cases when the command succeeds.

Here's another patch which is a more comprehensive stab at the task, although it should still be regarded as work in progress.

I've attempted to replace manual setting of conn->proto.sshc.actualcode with a function that also sets the httpCode.

Unfortunately there was an awful lot of repeated code in ssh.c relating to error reporting and/or failure. I've attempted to replace the most obvious blocks of repeated code with functions, but there's still a lot of repetition or nearly-but-not-quite-the-same code.

Some of this refactoring worried me a little bit - since the likelihood is high that somewhere in this process a small mistake will have crept in - but it was the only sane way that I could see to approach the job.

I suspect that there are still quite a few places where the code could be generalised further, allowing me to remove some of the variants of my error/failure functions.

For example, there are lots of places in the code where the last ssh error wasn't checked. I've used LIBSSH2_ERROR_NONE for the ssh error in these cases, because I wasn't sure it if would always be safe to call sftp_libssh2_last_error in places where it wasn't being called before.

Someone who is more familiar with this code should probably review my changes. You will probably also be able to suggest some further improvements or simplifications - feel free to do so and I'll try to apply them.

Haven't updated the docs yet, but I will do so once we're fairly sure it's working.

- Sam -

sam deane / @samdeane | elegantchaos.com / @elegantchaoscom | mac and ios software development

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

Received on 2013-04-11