void stream_write_uint16( stream_t* stream, uint16_t data ) { if( stream_is_binary( stream ) ) { if( stream && stream->swap ) data = byteorder_swap16( data ); stream_write( stream, &data, 2 ); } else stream_write_string( stream, string_from_uint_static( data, false, 0, 0 ) ); }
void stream_write_uint16(stream_t* stream, uint16_t data) { if (stream_is_binary(stream)) { if (stream->swap) data = byteorder_swap16(data); stream_write(stream, &data, 2); } else { string_const_t value = string_from_uint_static(data, false, 0, 0); stream_write_string(stream, value.str, value.length); } }
uint16_t stream_read_uint16(stream_t* stream) { uint16_t value = 0; if (stream_is_binary(stream)) { stream_read(stream, &value, 2); if (stream->swap) value = byteorder_swap16(value); } else { char buffer[8] = {0}; string_t str = stream_read_string_buffer(stream, buffer, 8); value = (uint16_t)string_to_uint(str.str, str.length, false); } return value; }
uint16_t stream_read_uint16( stream_t* stream ) { uint16_t value = 0; if( stream_is_binary( stream ) ) { stream_read( stream, &value, 2 ); if( stream && stream->swap ) value = byteorder_swap16( value ); } else { char* str = stream_read_string( stream ); value = (uint16_t)string_to_uint( str, false ); string_deallocate( str ); } return value; }