add uint16_read API like uint32_read
parent
44a5e65081
commit
eb31b3eb62
@ -0,0 +1,16 @@
|
||||
.TH uint16_read 3
|
||||
.SH NAME
|
||||
uint16_read \- read an unsigned little-endian 16-bit integer
|
||||
.SH SYNTAX
|
||||
.B #include <uint16.h>
|
||||
|
||||
uint16 \fBuint16_read\fP(const char \fIs\fR[4]);
|
||||
.SH DESCRIPTION
|
||||
uint16 is a 16-bit unsigned integer type, normally either unsigned int
|
||||
or unsigned long.
|
||||
|
||||
uint16_read portably reads a uint16 as stored on a little-endian
|
||||
architecture from \fIs\fR and returns it.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
uint16_unpack(3), uint16_unpack_big(3)
|
@ -0,0 +1,6 @@
|
||||
#define NO_UINT16_MACROS
|
||||
#include "uint16.h"
|
||||
|
||||
uint16 uint16_read(const char *in) {
|
||||
return ((unsigned short)((unsigned char) in[1]) << 8) + (unsigned char)in[0];
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
.TH uint16_read_big 3
|
||||
.SH NAME
|
||||
uint16_read_big \- read an unsigned big-endian 16-bit integer
|
||||
.SH SYNTAX
|
||||
.B #include <uint16.h>
|
||||
|
||||
uint16 \fBuint16_read_big\fP(const char \fIs\fR[4]);
|
||||
.SH DESCRIPTION
|
||||
uint16 is a 16-bit unsigned integer type, normally either unsigned int
|
||||
or unsigned long.
|
||||
|
||||
uint16_read_big portably reads a uint16 as stored on a big-endian
|
||||
architecture from \fIs\fR and returns it.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
uint16_unpack(3), uint16_unpack_big(3)
|
@ -0,0 +1,6 @@
|
||||
#define NO_UINT16_MACROS
|
||||
#include "uint16.h"
|
||||
|
||||
uint16 uint16_read_big(const char *in) {
|
||||
return ((unsigned short)((unsigned char) in[0]) << 8) + (unsigned char)in[1];
|
||||
}
|
Loading…
Reference in New Issue