forked from Kofera/mms_radio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.h
executable file
·90 lines (72 loc) · 1.92 KB
/
common.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef COMMON_H
#define COMMON_H
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <malloc.h>
#include <assert.h>
#ifndef __cplusplus
#include "bool.h"
#endif
#ifndef CT_MSG_H
#include "message.h"
#endif
#ifdef _WIN32
//#include <windows.h>
#include <WinSock2.h>
#pragma comment(lib,"Ws2_32.lib")
typedef SOCKET socket_t;
typedef int socklen_t;
#else
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
typedef int socket_t;
#define closesocket close
#endif
#ifdef _WIN32
#define SOCK_ADDR_IP(sa) (sa).sin_addr.S_un.S_addr
#else
#define SOCK_ADDR_IP(sa) (sa).sin_addr.s_addr
#endif
/* Free and set set the variable to NULL */
#define FREENULL(a) do { free( a ); a = 0; } while(0)
#define PRIu32 "%lu"
#define PRIx32 "%lx"
/* Input */
typedef struct access_t access_t;
typedef struct access_sys_t access_sys_t;
/* Block */
typedef struct block_t block_t;
typedef struct decode_t decode_t;
/******************************************************************
* Error values
*****************************************************************/
#define VLC_SUCCESS -0
#define VLC_ENOMEM -1
#define VLC_ETIMEOUT -3
#define VLC_EGENERIC -666
/* ************************************************************** */
#ifndef __MAX
# define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
#endif
#ifndef __MIN
# define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
#endif
static inline uint16_t GetWLE(const void *_p)
{
const uint8_t *p = (const uint8_t *)_p;
return (((uint16_t)p[1] << 8) | p[0]);
}
static inline uint32_t GetDWLE(const void *_p)
{
const uint8_t *p = (const uint8_t *)_p;
return (((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16)
| ((uint32_t)p[1] << 8) | p[0]);
}
#endif