summaryrefslogtreecommitdiff
path: root/toxcore/ping_array.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-26 09:42:08 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-26 17:32:19 +0000
commita1035cf81494c3ab22c49b01788ca8ad933c5eb0 (patch)
treefee86f8751cc93eca9702fd50c3380483ff0f86a /toxcore/ping_array.h
parent64ddb7fff21e8cfcd197ba31bbb08ee6d3964c54 (diff)
Add some tests for `ping_array`.
No timeout test here yet, because we don't yet have the ability to manipulate time at will, so we would have to actually sleep.
Diffstat (limited to 'toxcore/ping_array.h')
-rw-r--r--toxcore/ping_array.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/toxcore/ping_array.h b/toxcore/ping_array.h
index cfa9bfcc..7bc95a42 100644
--- a/toxcore/ping_array.h
+++ b/toxcore/ping_array.h
@@ -21,10 +21,15 @@
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 22 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
23 */ 23 */
24#ifndef PING_ARRAY_H 24#ifndef C_TOXCORE_TOXCORE_PING_ARRAY_H
25#define PING_ARRAY_H 25#define C_TOXCORE_TOXCORE_PING_ARRAY_H
26 26
27#include "network.h" 27#include <stddef.h>
28#include <stdint.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
28 33
29#ifndef MONO_TIME_DEFINED 34#ifndef MONO_TIME_DEFINED
30#define MONO_TIME_DEFINED 35#define MONO_TIME_DEFINED
@@ -38,11 +43,11 @@ typedef struct Ping_Array Ping_Array;
38 43
39/** 44/**
40 * Initialize a Ping_Array. 45 * Initialize a Ping_Array.
41 * size represents the total size of the array and should be a power of 2.
42 * timeout represents the maximum timeout in seconds for the entry.
43 * 46 *
44 * return 0 on success. 47 * @param size represents the total size of the array and should be a power of 2.
45 * return -1 on failure. 48 * @param timeout represents the maximum timeout in seconds for the entry.
49 *
50 * @return 0 on success, -1 on failure.
46 */ 51 */
47struct Ping_Array *ping_array_new(uint32_t size, uint32_t timeout); 52struct Ping_Array *ping_array_new(uint32_t size, uint32_t timeout);
48 53
@@ -54,8 +59,7 @@ void ping_array_kill(struct Ping_Array *_array);
54/** 59/**
55 * Add a data with length to the Ping_Array list and return a ping_id. 60 * Add a data with length to the Ping_Array list and return a ping_id.
56 * 61 *
57 * return ping_id on success. 62 * @return ping_id on success, 0 on failure.
58 * return 0 on failure.
59 */ 63 */
60uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_time, const uint8_t *data, 64uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_time, const uint8_t *data,
61 uint32_t length); 65 uint32_t length);
@@ -65,10 +69,13 @@ uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_
65 * 69 *
66 * On success, copies the data into data of length, 70 * On success, copies the data into data of length,
67 * 71 *
68 * return length of data copied on success. 72 * @return length of data copied on success, -1 on failure.
69 * return -1 on failure.
70 */ 73 */
71int32_t ping_array_check(struct Ping_Array *_array, const struct Mono_Time *mono_time, uint8_t *data, size_t length, 74int32_t ping_array_check(struct Ping_Array *_array, const struct Mono_Time *mono_time, uint8_t *data, size_t length,
72 uint64_t ping_id); 75 uint64_t ping_id);
73 76
77#ifdef __cplusplus
78} // extern "C"
74#endif 79#endif
80
81#endif // C_TOXCORE_TOXCORE_PING_ARRAY_H