fujuntang
2021-11-30 490948a0d52a3ad7b3f94525a982fc7012d06011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __NET_MODE_SOCKET_IO_H__
#define __NET_MODE_SOCKET_IO_H__
#include "socket_io.h"
#include "usg_common.h"
 
#define PKG_SEP "\r\n\r\n"
 
ssize_t rio_read_until_sep(rio_t *rp, char *usrbuf, size_t maxlen, char * sep);
int is_little_endian();
void swap_bytes(void *pv, size_t n);
uint16_t swap_uint16( uint16_t val ) ;
int16_t swap_int16( int16_t val ) ;
uint32_t swap_uint32( uint32_t val );
int32_t swap_int32( int32_t val );
int64_t swap_int64( int64_t val );
uint64_t swap_uint64( uint64_t val );
 
#define SWAP_BYTES(x) swap_bytes(&x, sizeof(x))
 
 
 
 
// #include <endian.h>
// uint16_t htobe16(uint16_t host_16bits);
// uint16_t htole16(uint16_t host_16bits);
// uint16_t be16toh(uint16_t big_endian_16bits);
// uint16_t le16toh(uint16_t little_endian_16bits);
 
// uint32_t htobe32(uint32_t host_32bits);
// uint32_t htole32(uint32_t host_32bits);
// uint32_t be32toh(uint32_t big_endian_32bits);
// uint32_t le32toh(uint32_t little_endian_32bits);
 
// uint64_t htobe64(uint64_t host_64bits);
// uint64_t htole64(uint64_t host_64bits);
// uint64_t be64toh(uint64_t big_endian_64bits);
// uint64_t le64toh(uint64_t little_endian_64bits);
 
 
 
 
// #include <arpa/inet.h>
 
// uint32_t htonl(uint32_t hostlong);
 
// uint16_t htons(uint16_t hostshort);
 
// uint32_t ntohl(uint32_t netlong);
 
// uint16_t ntohs(uint16_t netshort);
#endif