diff options
author | Ansa89 <ansalonistefano@gmail.com> | 2016-12-16 11:56:51 +0100 |
---|---|---|
committer | Ansa89 <ansalonistefano@gmail.com> | 2017-04-01 17:47:34 +0200 |
commit | 5ff099763b1f56414572e1c12eb2f003117db5a0 (patch) | |
tree | 300a850c82970ec9462fa43d346a3e7f799de186 /toxcore/TCP_connection.c | |
parent | 200ee1cace2f17537e6982ac447ea65d7c7a00b3 (diff) |
Implement tox_loop
Diffstat (limited to 'toxcore/TCP_connection.c')
-rw-r--r-- | toxcore/TCP_connection.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 18c1e76e..9b51443d 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c | |||
@@ -67,6 +67,37 @@ const uint8_t *tcp_connections_public_key(const TCP_Connections *tcp_c) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | /** | ||
71 | * Return number of elements of TCP connection array. | ||
72 | * | ||
73 | * @param tcp_c struct containing TCP_con array | ||
74 | * | ||
75 | * @return number of elements of TCP connection array | ||
76 | */ | ||
77 | uint32_t tcp_connections_length(const TCP_Connections *tcp_c) | ||
78 | { | ||
79 | return tcp_c->tcp_connections_length; | ||
80 | } | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Return TCP connection stored at "idx" position. | ||
85 | * | ||
86 | * @param tcp_c struct containing TCP_con array | ||
87 | * @param idx index of TCP connection to return (values from 0 to tcp_connections_length() - 1) | ||
88 | * | ||
89 | * @return TCP connection stored at "idx" position, or NULL if errors occurred | ||
90 | */ | ||
91 | const TCP_con *tcp_connections_connection_at(const TCP_Connections *tcp_c, uint32_t idx) | ||
92 | { | ||
93 | if (idx >= tcp_c->tcp_connections_length) { | ||
94 | return NULL; | ||
95 | } | ||
96 | |||
97 | return &tcp_c->tcp_connections[idx]; | ||
98 | } | ||
99 | |||
100 | |||
70 | /* Set the size of the array to num. | 101 | /* Set the size of the array to num. |
71 | * | 102 | * |
72 | * return -1 if realloc fails. | 103 | * return -1 if realloc fails. |