DDNet documentation
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef BASE_TYPES_H
2#define BASE_TYPES_H
3
4#include <base/detect.h>
5
6#include <cstdint>
7#include <ctime>
8#include <functional>
9
10#if defined(CONF_FAMILY_UNIX)
11#include <sys/types.h> // pid_t
12#endif
13
14enum class TRISTATE
15{
19};
20
26typedef void *IOHANDLE;
27
33typedef struct ASYNCIO ASYNCIO;
34
35typedef int (*FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user);
36
37typedef struct
38{
39 const char *m_pName;
40 time_t m_TimeCreated; // seconds since UNIX Epoch
41 time_t m_TimeModified; // seconds since UNIX Epoch
43
44typedef int (*FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user);
45
49inline constexpr auto UTF8_BYTE_LENGTH = 4;
50
51inline constexpr auto IO_MAX_PATH_LENGTH = 512;
52
57
61inline constexpr auto NETTYPE_INVALID = 0;
62
66inline constexpr auto NETTYPE_IPV4 = 1 << 0;
67
71inline constexpr auto NETTYPE_IPV6 = 1 << 1;
72
76inline constexpr auto NETTYPE_WEBSOCKET_IPV4 = 1 << 2;
77
81inline constexpr auto NETTYPE_WEBSOCKET_IPV6 = 1 << 3;
82
86inline constexpr auto NETTYPE_LINK_BROADCAST = 1 << 4;
93inline constexpr auto NETTYPE_TW7 = 1 << 5;
94
99
104
108inline constexpr auto NETADDR_MAXSTRSIZE = 1 + (8 * 4 + 7) + 1 + 1 + 5 + 1; // [XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX]:XXXXX
109
113typedef struct NETADDR
114{
115 unsigned int type;
116 unsigned char ip[16];
117 unsigned short port;
118
119 bool operator==(const NETADDR &other) const;
120 bool operator!=(const NETADDR &other) const;
121 bool operator<(const NETADDR &other) const;
123
124template<>
125struct std::hash<NETADDR>
126{
127 size_t operator()(const NETADDR &Addr) const noexcept;
128};
129
133typedef struct NETSTATS
134{
135 uint64_t sent_packets;
136 uint64_t sent_bytes;
137 uint64_t recv_packets;
138 uint64_t recv_bytes;
140
141#if defined(CONF_FAMILY_WINDOWS)
147typedef void *PROCESS;
153constexpr PROCESS INVALID_PROCESS = nullptr; // NOLINT(misc-misplaced-const)
154#else
160typedef pid_t PROCESS;
167#endif
168
169#endif // BASE_TYPES_H
constexpr auto NETADDR_MAXSTRSIZE
Definition types.h:108
constexpr auto NETTYPE_TW7
Definition types.h:93
constexpr auto NETTYPE_WEBSOCKET_IPV6
Definition types.h:81
constexpr auto NETTYPE_LINK_BROADCAST
Definition types.h:86
constexpr auto NETTYPE_INVALID
Definition types.h:61
constexpr auto NETTYPE_IPV6
Definition types.h:71
constexpr auto NETTYPE_IPV4
Definition types.h:66
constexpr auto NETTYPE_ALL
Definition types.h:98
constexpr auto NETTYPE_WEBSOCKET_IPV4
Definition types.h:76
struct NETSOCKET_INTERNAL * NETSOCKET
Definition types.h:56
constexpr auto NETTYPE_MASK
Definition types.h:103
constexpr PROCESS INVALID_PROCESS
Definition types.h:166
pid_t PROCESS
Definition types.h:160
void * IOHANDLE
Definition logger.h:12
Definition aio.cpp:15
Definition types.h:38
time_t m_TimeCreated
Definition types.h:40
time_t m_TimeModified
Definition types.h:41
const char * m_pName
Definition types.h:39
Definition types.h:114
bool operator<(const NETADDR &other) const
Definition net.cpp:185
bool operator==(const NETADDR &other) const
Definition net.cpp:175
unsigned char ip[16]
Definition types.h:116
bool operator!=(const NETADDR &other) const
Definition net.cpp:180
unsigned short port
Definition types.h:117
unsigned int type
Definition types.h:115
Definition net.cpp:104
Definition types.h:134
uint64_t recv_packets
Definition types.h:137
uint64_t recv_bytes
Definition types.h:138
uint64_t sent_packets
Definition types.h:135
uint64_t sent_bytes
Definition types.h:136
size_t operator()(const NETADDR &Addr) const noexcept
Definition net.cpp:190
TRISTATE
Definition types.h:15
@ ALL
Definition types.h:18
@ SOME
Definition types.h:17
@ NONE
Definition types.h:16
constexpr auto UTF8_BYTE_LENGTH
Definition types.h:49
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:51
int(* FS_LISTDIR_CALLBACK_FILEINFO)(const CFsFileInfo *info, int is_dir, int dir_type, void *user)
Definition types.h:44
int(* FS_LISTDIR_CALLBACK)(const char *name, int is_dir, int dir_type, void *user)
Definition types.h:35