On Thu, Nov 27, 2008 at 03:51, Francis Giraldeau
<[EMAIL PROTECTED]> wrote:

> /* {{{ libssh2_htonu32
>  */
> void
> libssh2_htonu32(unsigned char *buf, unsigned long value)
> {
>    buf[0] = (value >> 24) & 0xFF;
>    buf[1] = (value >> 16) & 0xFF;
>    buf[2] = (value >> 8) & 0xFF;
>    buf[3] = value & 0xFF;
> }
>
> Does it means that the code will not work on other architectures?

It looks correct to me. The implementation is endian agnostic because
it converts a host-order input (value) to a network-order (buf) output
by doing the conversion with shift: It always puts the most signficant
byte into buf[0], the next-most significant byte into buf[1] and so
on. It doesn't matter which endianity 'value' is, the >>24 operation
will always return the most significant byte.

So, looks fine to me, if I've understood it correctly that 'buf' is
always meant  to contain integer values in network order (big endian)
format.

-Tor

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to