Statistics
| Branch: | Revision:

grapes / src / int_coding.h @ 07d576c3

History | View | Annotate | Download (382 Bytes)

1 60fa723d Luca Abeni
#ifndef INT_CODING
2
#define INT_CODING
3
4 07d576c3 Luca Abeni
#if defined(_WIN32)
5
#include <winsock2.h>
6
#else
7 e04b9596 Luca Abeni
#include <arpa/inet.h>
8 07d576c3 Luca Abeni
#endif
9 e04b9596 Luca Abeni
10 92775ce4 Luca Abeni
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 60fa723d Luca Abeni
#endif        /* INT_CODING */