Subject: Re: [PATCH] Support for exit-signal messages

Re: [PATCH] Support for exit-signal messages

From: Tommy Lindgren <tommy.lindgren_at_gmail.com>
Date: Mon, 04 Oct 2010 16:31:42 +0200

On 2010-10-03 21:50, Simon Josefsson wrote:
>
> Thus, I would suggest something like this:
>
> /* Get exit signal (without leading "SIG"), error message, and language
> tag into newly allocated buffers of indicated length. Caller can
> use NULL pointers to indicate that the value should not be set. The
> *_len variables are set if they are non-NULL even if the
> corresponding string parameter is NULL. Returns LIBSSH2_ERROR_NONE
> on success, or an API error code. */
> LIBSSH2_API int
> libssh2_channel_get_exit_signal(LIBSSH2_CHANNEL *channel,
> char **exitsignal,
> size_t *exitsignal_len
> char **errmsg,
> size_t *errmsg_len,
> char **langtag,
> size_t *langtag_len)
>
> There is precedent for libssh2 functions to allocate memory (e.g.,
> libssh2_base64_decode), but we could also consider an interface that
> doesn't allocate memory. I find that alternative more difficult to use
> from an application, though.

Thanks! Attached new patch with suggested change above.

The function is always returning LIBSSH2_ERROR_NONE. I'm not sure if it
should returning anything else? (Perhaps if the malloc fails? Other API
functions don't seem to do this though.)

Added a man page too. It should perhaps mention that errmsg/langtag
aren't populated yet..

I'm slightly confused about returning pointers to allocated buffers
though. The man page for libssh2_base64_decode says that the calling
function can't free the memory in a reliable way. Why is that?

Regards,
Tommy

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Received on 2010-10-04