Xgit v0.1.4 Xgit.Util.NB View Source

Conversion utilities for network byte order handling.

Link to this section Summary

Functions

Parses a sequence of 4 bytes (network byte order) as a signed integer.

Parses a sequence of 2 bytes (network byte order) as an unsigned integer.

Parses a sequence of 4 bytes (network byte order) as an unsigned integer.

Convert a 16-bit integer to a sequence of two bytes in network byte order.

Convert a 32-bit integer to a sequence of four bytes in network byte order.

Link to this section Functions

Link to this function

decode_int32(intbuf)

View Source
decode_int32(intbuf :: [byte()]) :: {integer(), [byte()]}

Parses a sequence of 4 bytes (network byte order) as a signed integer.

Reads the first four bytes from intbuf and returns {value, buf} where value is the integer value from the first four bytes at intbuf and buf is the remainder of the byte array after those bytes.

Link to this function

decode_uint16(intbuf)

View Source
decode_uint16(intbuf :: [byte()]) :: {integer(), [byte()]}

Parses a sequence of 2 bytes (network byte order) as an unsigned integer.

Reads the first four bytes from intbuf and returns {value, buf} where value is the unsigned integer value from the first two bytes at intbuf and buf is the remainder of the byte array after those bytes.

Link to this function

decode_uint32(intbuf)

View Source
decode_uint32(intbuf :: [byte()]) :: {integer(), [byte()]}

Parses a sequence of 4 bytes (network byte order) as an unsigned integer.

Reads the first four bytes from intbuf and returns {value, buf} where value is the unsigned integer value from the first four bytes at intbuf and buf is the remainder of the byte array after those bytes.

Link to this function

encode_int16(v)

View Source
encode_int16(v :: integer()) :: [byte()]

Convert a 16-bit integer to a sequence of two bytes in network byte order.

Link to this function

encode_int32(v)

View Source
encode_int32(v :: integer()) :: [byte()]

Convert a 32-bit integer to a sequence of four bytes in network byte order.