Statistics
| Branch: | Revision:

grapes / src / int_coding.h @ 07d576c3

History | View | Annotate | Download (382 Bytes)

1
#ifndef INT_CODING
2
#define INT_CODING
3

    
4
#if defined(_WIN32)
5
#include <winsock2.h>
6
#else
7
#include <arpa/inet.h>
8
#endif
9

    
10
static inline void int_cpy(uint8_t *p, int v)
11
{
12
  uint32_t tmp;
13
  
14
  tmp = htonl(v);
15
  memcpy(p, &tmp, 4);
16
}
17

    
18
static inline uint32_t int_rcpy(const uint8_t *p)
19
{
20
  uint32_t tmp;
21
  
22
  memcpy(&tmp, p, 4);
23
  tmp = ntohl(tmp);
24

    
25
  return tmp;
26
}
27
#endif        /* INT_CODING */