forked from wiedehopf/readsb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.h
89 lines (68 loc) · 1.37 KB
/
api.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
#ifndef API_H
#define API_H
#define API_REQ_PADSTART (192)
struct apiCon {
int fd;
int accept;
struct char_buffer cb;
int cbOffset;
uint32_t events;
struct char_buffer request;
};
struct offset {
int32_t offset;
int32_t len;
};
struct apiEntry {
struct apiEntry *next;
uint32_t addr;
int32_t lat;
int32_t lon;
int32_t alt;
struct offset jsonOffset;
float distance;
char typeCode[4];
uint16_t dbFlags;
unsigned aircraftJson:1;
unsigned padding:15;
int32_t globe_index;
uint64_t pad3;
} __attribute__ ((__packed__));
struct apiCircle {
double lat;
double lon;
double radius; // in meters
bool onlyClosest;
};
struct apiBuffer {
int len;
int alloc;
struct apiEntry *list;
uint64_t timestamp;
char *json;
struct apiEntry **hashList;
uint32_t focus;
int aircraftJsonCount;
};
struct apiThread {
pthread_t thread;
pthread_mutex_t mutex;
int index;
int epfd;
int eventfd;
int openFDs;
};
struct range {
int from; // inclusive
int to; // exclusive
};
void apiLockMutex();
void apiUnlockMutex();
void apiBufferInit();
void apiBufferCleanup();
void apiInit();
void apiCleanup();
int apiUpdate(struct craftArray *ca);
struct char_buffer apiGenerateAircraftJson();
struct char_buffer apiGenerateGlobeJson(int globe_index);
#endif