Subject: Re: Visual Studio 6 compilation issues (libssh2 1.2.4)

Re: Visual Studio 6 compilation issues (libssh2 1.2.4)

From: Simon Josefsson <>
Date: Wed, 10 Mar 2010 10:55:14 +0100

Daniel Stenberg <> writes:

> On Wed, 10 Mar 2010, Simon Josefsson wrote:
>> Agreed. Libssh2 is broken here, the Right Thing is to always use
>> size_t for string lengths. This change will break the ABI if we
>> don't rename all the functions though...
> I agree. But we can probably clean up a good deal of internals first
> to use size_t and only do the translations from int or longs to size_t
> until we fix the APIs to use size_t properly (which should be added to
> the TODO).


Once that is done, we can replace all API entry points with small
interface functions that behave like this:

 int libssh2_session_last_error(LIBSSH2_SESSION *session,
                                           char **errmsg,
                                           int *errmsg_len, int want_buf)
   size_t tmp = *errmsg_len
   int ret = libssh2_session_last_error_real(session, errmsg, &tmp,
   *errmsg_len = tmp;
   return ret;

 int libssh2_session_last_error_real(LIBSSH2_SESSION *session,
                                           char **errmsg,
                                           size_t *errmsg_len,
                                           int want_buf);

Or whatever, I'm not even sure the casting is correct, I'm just thinking
generally. Then we could isolate all the broken non-size_t using code
into just one file. The rest of libssh2 could then use size_t

Btw, maybe we can add an libssh2_session_error_last with size_t in the
next version, and deprecate libssh2_session_last_error? Then at least
one interface will be fixed...

Received on 2010-03-10