Pigeoneer C SDK
common.h
1 #pragma once
2 
3 #include <stdint.h>
4 #include <stddef.h>
5 #if EMSCRIPTEN
6  #include <emscripten.h>
7 #endif
8 
9 #if defined(_WIN32)
10  #define PGNR_API __declspec(dllexport)
11 #elif defined(__GNUC__)
12  #define PGNR_API __attribute__((visibility("default")))
13 #else
14  #define PGNR_API
15 #endif
16 
17 #if EMSCRIPTEN
18  #define PGNR_KEEPALIVE EMSCRIPTEN_KEEPALIVE
19 #else
20  #define PGNR_KEEPALIVE
21 #endif
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef int32_t PGNRResult;
28 enum {
29  PGNR_RESULT_OK = 0,
30  PGNR_RESULT_SENT_RELIABLY = 1,
31  PGNR_RESULT_TCP_ONLY = 2,
32 
33  PGNR_RESULT_ERROR = -1,
34  PGNR_RESULT_FAILED_TO_LISTEN = -2,
35  PGNR_RESULT_SSL_FAILURE = -3,
36  PGNR_RESULT_ALREADY_CLOSED = -4,
37  PGNR_RESULT_ONLY_SECURELY = -5
38 };
39 
40 #ifdef __cplusplus
41 inline
42 #else
43 static
44 #endif
45 bool pgnr_result_is_error(PGNRResult result) {
46  return result < 0;
47 }
48 
49 typedef int32_t PGNRSendMode;
50 enum {
51  PGNR_SEND_MODE_UNRELIABLE = 0,
52  PGNR_SEND_MODE_RELIABLE_ORDERED = 1,
53 };
54 
55 #ifdef __cplusplus
56 }
57 #endif