ffi-tox 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/ProjectTox-Core/AUTHORS +0 -0
  3. data/ProjectTox-Core/ChangeLog +0 -0
  4. data/ProjectTox-Core/INSTALL +370 -0
  5. data/ProjectTox-Core/INSTALL.md +455 -56
  6. data/ProjectTox-Core/Makefile.am +35 -0
  7. data/ProjectTox-Core/NEWS +0 -0
  8. data/ProjectTox-Core/README +43 -0
  9. data/ProjectTox-Core/README.md +34 -44
  10. data/ProjectTox-Core/auto_tests/Makefile.inc +110 -0
  11. data/ProjectTox-Core/auto_tests/TCP_test.c +519 -0
  12. data/ProjectTox-Core/auto_tests/assoc_test.c +160 -0
  13. data/ProjectTox-Core/auto_tests/crypto_test.c +302 -0
  14. data/ProjectTox-Core/auto_tests/dht_test.c +362 -0
  15. data/ProjectTox-Core/auto_tests/encryptsave_test.c +104 -0
  16. data/ProjectTox-Core/auto_tests/friends_test.c +238 -0
  17. data/ProjectTox-Core/auto_tests/helpers.h +15 -0
  18. data/ProjectTox-Core/auto_tests/messenger_test.c +365 -0
  19. data/ProjectTox-Core/auto_tests/network_test.c +171 -0
  20. data/ProjectTox-Core/auto_tests/onion_test.c +363 -0
  21. data/ProjectTox-Core/auto_tests/skeleton_test.c +49 -0
  22. data/ProjectTox-Core/auto_tests/tox_test.c +454 -0
  23. data/ProjectTox-Core/auto_tests/toxav_basic_test.c +597 -0
  24. data/ProjectTox-Core/auto_tests/toxav_many_test.c +402 -0
  25. data/ProjectTox-Core/autogen.sh +6 -0
  26. data/ProjectTox-Core/build/Makefile.am +14 -0
  27. data/ProjectTox-Core/configure.ac +694 -0
  28. data/ProjectTox-Core/dist-build/android-arm.sh +3 -0
  29. data/ProjectTox-Core/dist-build/android-armv7.sh +3 -0
  30. data/ProjectTox-Core/dist-build/android-build.sh +59 -0
  31. data/ProjectTox-Core/dist-build/android-mips.sh +3 -0
  32. data/ProjectTox-Core/dist-build/android-x86.sh +3 -0
  33. data/ProjectTox-Core/docs/Group-Chats.md +71 -0
  34. data/ProjectTox-Core/docs/Hardening.txt +60 -0
  35. data/ProjectTox-Core/docs/Hardening_docs.txt +30 -0
  36. data/ProjectTox-Core/docs/Prevent_Tracking.txt +160 -0
  37. data/ProjectTox-Core/docs/TCP_Network.txt +154 -0
  38. data/ProjectTox-Core/docs/TODO +62 -0
  39. data/ProjectTox-Core/docs/Tox_middle_level_network_protocol.txt +120 -0
  40. data/ProjectTox-Core/docs/av_api.md +194 -0
  41. data/ProjectTox-Core/libtoxav.pc.in +11 -0
  42. data/ProjectTox-Core/libtoxcore.pc.in +11 -0
  43. data/ProjectTox-Core/m4/ax_have_epoll.m4 +104 -0
  44. data/ProjectTox-Core/m4/ax_pthread.m4 +317 -0
  45. data/ProjectTox-Core/m4/pkg.m4 +199 -0
  46. data/ProjectTox-Core/other/DHT_bootstrap.c +121 -58
  47. data/ProjectTox-Core/other/DHTnodes +3 -0
  48. data/ProjectTox-Core/other/Makefile.inc +20 -0
  49. data/ProjectTox-Core/other/bootstrap_node_packets.c +65 -0
  50. data/ProjectTox-Core/other/tox.png +0 -0
  51. data/ProjectTox-Core/testing/DHT_test.c +170 -98
  52. data/ProjectTox-Core/testing/Makefile.inc +112 -0
  53. data/ProjectTox-Core/testing/Messenger_test.c +133 -69
  54. data/ProjectTox-Core/testing/dns3_test.c +115 -0
  55. data/ProjectTox-Core/testing/misc_tools.c +59 -13
  56. data/ProjectTox-Core/testing/nTox.c +1127 -264
  57. data/ProjectTox-Core/testing/nTox.h +10 -19
  58. data/ProjectTox-Core/testing/tox_shell.c +159 -0
  59. data/ProjectTox-Core/testing/tox_sync.c +299 -0
  60. data/ProjectTox-Core/tools/README +11 -0
  61. data/ProjectTox-Core/tools/astylerc +11 -0
  62. data/ProjectTox-Core/tools/pre-commit +17 -0
  63. data/ProjectTox-Core/toxav/Makefile.inc +36 -0
  64. data/ProjectTox-Core/toxav/codec.c +357 -0
  65. data/ProjectTox-Core/toxav/codec.h +116 -0
  66. data/ProjectTox-Core/toxav/msi.c +1949 -0
  67. data/ProjectTox-Core/toxav/msi.h +267 -0
  68. data/ProjectTox-Core/toxav/rtp.c +600 -0
  69. data/ProjectTox-Core/toxav/rtp.h +196 -0
  70. data/ProjectTox-Core/toxav/toxav.c +1148 -0
  71. data/ProjectTox-Core/toxav/toxav.h +389 -0
  72. data/ProjectTox-Core/toxcore/DHT.c +2521 -0
  73. data/ProjectTox-Core/toxcore/DHT.h +412 -0
  74. data/ProjectTox-Core/toxcore/LAN_discovery.c +322 -0
  75. data/ProjectTox-Core/{core → toxcore}/LAN_discovery.h +17 -12
  76. data/ProjectTox-Core/toxcore/Makefile.inc +67 -0
  77. data/ProjectTox-Core/toxcore/Messenger.c +3006 -0
  78. data/ProjectTox-Core/toxcore/Messenger.h +818 -0
  79. data/ProjectTox-Core/toxcore/TCP_client.c +858 -0
  80. data/ProjectTox-Core/toxcore/TCP_client.h +156 -0
  81. data/ProjectTox-Core/toxcore/TCP_server.c +1332 -0
  82. data/ProjectTox-Core/toxcore/TCP_server.h +181 -0
  83. data/ProjectTox-Core/toxcore/assoc.c +1033 -0
  84. data/ProjectTox-Core/toxcore/assoc.h +104 -0
  85. data/ProjectTox-Core/toxcore/crypto_core.c +278 -0
  86. data/ProjectTox-Core/toxcore/crypto_core.h +151 -0
  87. data/ProjectTox-Core/toxcore/friend_requests.c +175 -0
  88. data/ProjectTox-Core/toxcore/friend_requests.h +83 -0
  89. data/ProjectTox-Core/toxcore/group_chats.c +837 -0
  90. data/ProjectTox-Core/toxcore/group_chats.h +199 -0
  91. data/ProjectTox-Core/toxcore/list.c +256 -0
  92. data/ProjectTox-Core/toxcore/list.h +85 -0
  93. data/ProjectTox-Core/toxcore/logger.c +153 -0
  94. data/ProjectTox-Core/toxcore/logger.h +84 -0
  95. data/ProjectTox-Core/toxcore/misc_tools.h +70 -0
  96. data/ProjectTox-Core/toxcore/net_crypto.c +2753 -0
  97. data/ProjectTox-Core/toxcore/net_crypto.h +410 -0
  98. data/ProjectTox-Core/toxcore/network.c +979 -0
  99. data/ProjectTox-Core/toxcore/network.h +367 -0
  100. data/ProjectTox-Core/toxcore/onion.c +540 -0
  101. data/ProjectTox-Core/toxcore/onion.h +150 -0
  102. data/ProjectTox-Core/toxcore/onion_announce.c +433 -0
  103. data/ProjectTox-Core/toxcore/onion_announce.h +139 -0
  104. data/ProjectTox-Core/toxcore/onion_client.c +1347 -0
  105. data/ProjectTox-Core/toxcore/onion_client.h +253 -0
  106. data/ProjectTox-Core/toxcore/ping.c +346 -0
  107. data/ProjectTox-Core/toxcore/ping.h +47 -0
  108. data/ProjectTox-Core/toxcore/ping_array.c +162 -0
  109. data/ProjectTox-Core/toxcore/ping_array.h +75 -0
  110. data/ProjectTox-Core/toxcore/tox.c +940 -0
  111. data/ProjectTox-Core/toxcore/tox.h +734 -0
  112. data/ProjectTox-Core/toxcore/util.c +193 -0
  113. data/ProjectTox-Core/toxcore/util.h +63 -0
  114. data/ProjectTox-Core/toxdns/Makefile.inc +29 -0
  115. data/ProjectTox-Core/toxdns/toxdns.c +238 -0
  116. data/ProjectTox-Core/toxdns/toxdns.h +88 -0
  117. data/ProjectTox-Core/toxencryptsave/Makefile.inc +45 -0
  118. data/ProjectTox-Core/toxencryptsave/toxencryptsave.c +179 -0
  119. data/ProjectTox-Core/toxencryptsave/toxencryptsave.h +74 -0
  120. data/interfaces/libtox.i +2 -6
  121. data/lib/ffi-tox/libtox.rb +406 -28
  122. metadata +124 -46
  123. data/ProjectTox-Core/CMakeLists.txt +0 -50
  124. data/ProjectTox-Core/cmake/FindLIBCONFIG.cmake +0 -15
  125. data/ProjectTox-Core/cmake/FindNaCl.cmake +0 -17
  126. data/ProjectTox-Core/cmake/FindSODIUM.cmake +0 -15
  127. data/ProjectTox-Core/core/CMakeLists.txt +0 -19
  128. data/ProjectTox-Core/core/DHT.c +0 -1104
  129. data/ProjectTox-Core/core/DHT.h +0 -111
  130. data/ProjectTox-Core/core/LAN_discovery.c +0 -79
  131. data/ProjectTox-Core/core/Lossless_UDP.c +0 -755
  132. data/ProjectTox-Core/core/Lossless_UDP.h +0 -106
  133. data/ProjectTox-Core/core/Messenger.c +0 -596
  134. data/ProjectTox-Core/core/Messenger.h +0 -165
  135. data/ProjectTox-Core/core/friend_requests.c +0 -131
  136. data/ProjectTox-Core/core/friend_requests.h +0 -51
  137. data/ProjectTox-Core/core/net_crypto.c +0 -575
  138. data/ProjectTox-Core/core/net_crypto.h +0 -134
  139. data/ProjectTox-Core/core/network.c +0 -205
  140. data/ProjectTox-Core/core/network.h +0 -134
  141. data/ProjectTox-Core/docs/commands.md +0 -25
  142. data/ProjectTox-Core/docs/start_guide.de.md +0 -40
  143. data/ProjectTox-Core/docs/start_guide.md +0 -38
  144. data/ProjectTox-Core/other/CMakeLists.txt +0 -9
  145. data/ProjectTox-Core/testing/CMakeLists.txt +0 -18
  146. data/ProjectTox-Core/testing/DHT_cryptosendfiletest.c +0 -228
  147. data/ProjectTox-Core/testing/DHT_sendfiletest.c +0 -176
  148. data/ProjectTox-Core/testing/Lossless_UDP_testclient.c +0 -214
  149. data/ProjectTox-Core/testing/Lossless_UDP_testserver.c +0 -201
  150. data/ProjectTox-Core/testing/misc_tools.h +0 -29
  151. data/ProjectTox-Core/testing/nTox_win32.c +0 -387
  152. data/ProjectTox-Core/testing/nTox_win32.h +0 -40
  153. data/ProjectTox-Core/testing/rect.py +0 -45
@@ -0,0 +1,402 @@
1
+ #ifdef HAVE_CONFIG_H
2
+ #include "config.h"
3
+ #endif
4
+
5
+ #include <sys/types.h>
6
+ #include <stdint.h>
7
+ #include <string.h>
8
+ #include <stdio.h>
9
+ #include <check.h>
10
+ #include <stdlib.h>
11
+ #include <time.h>
12
+ #include <assert.h>
13
+
14
+ #include "../toxcore/tox.h"
15
+ #include "../toxcore/logger.h"
16
+ #include "../toxcore/crypto_core.h"
17
+ #include "../toxav/toxav.h"
18
+
19
+ #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
20
+ #define c_sleep(x) Sleep(1*x)
21
+ #else
22
+ #include <unistd.h>
23
+ #include <pthread.h>
24
+ #define c_sleep(x) usleep(1000*x)
25
+ #endif
26
+
27
+ pthread_mutex_t muhmutex;
28
+
29
+ typedef enum _CallStatus {
30
+ none,
31
+ InCall,
32
+ Ringing,
33
+ Ended,
34
+ Rejected,
35
+ Cancel
36
+
37
+ } CallStatus;
38
+
39
+ typedef struct _Party {
40
+ CallStatus status;
41
+ ToxAv *av;
42
+ int id;
43
+ } Party;
44
+
45
+ typedef struct _ACall {
46
+ pthread_t tid;
47
+ int idx;
48
+
49
+ Party Caller;
50
+ Party Callee;
51
+ } ACall;
52
+
53
+ typedef struct _Status {
54
+ ACall calls[3]; /* Make 3 calls for this test */
55
+ } Status;
56
+
57
+ Status status_control;
58
+
59
+ void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
60
+ {
61
+ if (length == 7 && memcmp("gentoo", data, 7) == 0) {
62
+ tox_add_friend_norequest(m, public_key);
63
+ }
64
+ }
65
+
66
+
67
+ /******************************************************************************/
68
+ void callback_recv_invite ( void *av, int32_t call_index, void *_arg )
69
+ {
70
+ /*
71
+ Status *cast = _arg;
72
+
73
+ cast->calls[call_index].Callee.status = Ringing;*/
74
+ }
75
+ void callback_recv_ringing ( void *av, int32_t call_index, void *_arg )
76
+ {
77
+ Status *cast = _arg;
78
+ cast->calls[call_index].Caller.status = Ringing;
79
+ }
80
+ void callback_recv_starting ( void *av, int32_t call_index, void *_arg )
81
+ {
82
+ Status *cast = _arg;
83
+ cast->calls[call_index].Caller.status = InCall;
84
+ }
85
+ void callback_recv_ending ( void *av, int32_t call_index, void *_arg )
86
+ {
87
+ Status *cast = _arg;
88
+ cast->calls[call_index].Caller.status = Ended;
89
+ }
90
+
91
+ void callback_call_started ( void *av, int32_t call_index, void *_arg )
92
+ {
93
+ /*
94
+ Status *cast = _arg;
95
+
96
+ cast->calls[call_index].Callee.status = InCall;*/
97
+ }
98
+ void callback_call_canceled ( void *av, int32_t call_index, void *_arg )
99
+ {
100
+ /*
101
+ Status *cast = _arg;
102
+
103
+ cast->calls[call_index].Callee.status = Cancel;*/
104
+ }
105
+ void callback_call_rejected ( void *av, int32_t call_index, void *_arg )
106
+ {
107
+ Status *cast = _arg;
108
+ cast->calls[call_index].Caller.status = Rejected;
109
+ }
110
+ void callback_call_ended ( void *av, int32_t call_index, void *_arg )
111
+ {
112
+ /*
113
+ Status *cast = _arg;
114
+
115
+ cast->calls[call_index].Callee.status = Ended;*/
116
+ }
117
+
118
+ void callback_requ_timeout ( void *av, int32_t call_index, void *_arg )
119
+ {
120
+ //ck_assert_msg(0, "No answer!");
121
+ }
122
+
123
+ static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length, void *userdata)
124
+ {
125
+ }
126
+
127
+ static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img, void *userdata)
128
+ {
129
+ }
130
+
131
+ void register_callbacks(ToxAv *av, void *data)
132
+ {
133
+ toxav_register_callstate_callback(av, callback_call_started, av_OnStart, data);
134
+ toxav_register_callstate_callback(av, callback_call_canceled, av_OnCancel, data);
135
+ toxav_register_callstate_callback(av, callback_call_rejected, av_OnReject, data);
136
+ toxav_register_callstate_callback(av, callback_call_ended, av_OnEnd, data);
137
+ toxav_register_callstate_callback(av, callback_recv_invite, av_OnInvite, data);
138
+
139
+ toxav_register_callstate_callback(av, callback_recv_ringing, av_OnRinging, data);
140
+ toxav_register_callstate_callback(av, callback_recv_starting, av_OnStarting, data);
141
+ toxav_register_callstate_callback(av, callback_recv_ending, av_OnEnding, data);
142
+
143
+ toxav_register_callstate_callback(av, callback_requ_timeout, av_OnRequestTimeout, data);
144
+
145
+
146
+ toxav_register_audio_recv_callback(av, callback_audio, NULL);
147
+ toxav_register_video_recv_callback(av, callback_video, NULL);
148
+ }
149
+ /*************************************************************************************************/
150
+
151
+ int call_running[3];
152
+
153
+ void *in_thread_call (void *arg)
154
+ {
155
+ #define call_print(call, what, args...) printf("[%d] " what "\n", call, ##args)
156
+
157
+ ACall *this_call = arg;
158
+ uint64_t start = 0;
159
+ int step = 0;
160
+ int call_idx;
161
+
162
+ call_running[this_call->idx] = 1;
163
+
164
+ const int frame_size = (av_DefaultSettings.audio_sample_rate * av_DefaultSettings.audio_frame_duration / 1000);
165
+ int16_t sample_payload[frame_size];
166
+ randombytes((uint8_t *)sample_payload, sizeof(int16_t) * frame_size);
167
+
168
+ uint8_t prepared_payload[RTP_PAYLOAD_SIZE];
169
+
170
+ register_callbacks(this_call->Caller.av, &status_control);
171
+ register_callbacks(this_call->Callee.av, arg);
172
+
173
+ /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */
174
+ while (call_running[this_call->idx]) {
175
+
176
+ switch ( step ) {
177
+ case 0: /* CALLER */
178
+ toxav_call(this_call->Caller.av, &call_idx, this_call->Callee.id, &av_DefaultSettings, 10);
179
+ call_print(call_idx, "Calling ...");
180
+ step++;
181
+ break;
182
+
183
+ case 1: /* CALLEE */
184
+ if (this_call->Caller.status == Ringing) {
185
+ call_print(call_idx, "Callee answers ...");
186
+ toxav_answer(this_call->Callee.av, 0, &av_DefaultSettings);
187
+ step++;
188
+ start = time(NULL);
189
+ }
190
+
191
+ break;
192
+
193
+ case 2: /* Rtp transmission */
194
+ if (this_call->Caller.status == InCall) { /* I think this is okay */
195
+ call_print(call_idx, "Sending rtp ...");
196
+
197
+ c_sleep(1000); /* We have race condition here */
198
+ toxav_prepare_transmission(this_call->Callee.av, 0, 3, 0, 1);
199
+ toxav_prepare_transmission(this_call->Caller.av, call_idx, 3, 0, 1);
200
+
201
+ int payload_size = toxav_prepare_audio_frame(this_call->Caller.av, call_idx, prepared_payload, RTP_PAYLOAD_SIZE,
202
+ sample_payload, frame_size);
203
+
204
+ if ( payload_size < 0 ) {
205
+ //ck_assert_msg ( 0, "Failed to encode payload" );
206
+ }
207
+
208
+
209
+ while (time(NULL) - start < 10) { /* 10 seconds */
210
+ /* Both send */
211
+ toxav_send_audio(this_call->Caller.av, call_idx, prepared_payload, payload_size);
212
+
213
+ toxav_send_audio(this_call->Callee.av, 0, prepared_payload, payload_size);
214
+
215
+ /* Both receive */
216
+ int16_t storage[RTP_PAYLOAD_SIZE];
217
+ int recved;
218
+
219
+ c_sleep(20);
220
+ }
221
+
222
+ step++; /* This terminates the loop */
223
+
224
+ pthread_mutex_lock(&muhmutex);
225
+ toxav_kill_transmission(this_call->Callee.av, 0);
226
+ toxav_kill_transmission(this_call->Caller.av, call_idx);
227
+ pthread_mutex_unlock(&muhmutex);
228
+
229
+ /* Call over CALLER hangs up */
230
+ toxav_hangup(this_call->Caller.av, call_idx);
231
+ call_print(call_idx, "Hanging up ...");
232
+ }
233
+
234
+ break;
235
+
236
+ case 3: /* Wait for Both to have status ended */
237
+ if (this_call->Caller.status == Ended) {
238
+ c_sleep(1000); /* race condition */
239
+ this_call->Callee.status = Ended;
240
+ call_running[this_call->idx] = 0;
241
+ }
242
+
243
+ break;
244
+
245
+ }
246
+
247
+ c_sleep(20);
248
+ }
249
+
250
+ call_print(call_idx, "Call ended successfully!");
251
+ pthread_exit(NULL);
252
+ }
253
+
254
+
255
+
256
+
257
+
258
+ // START_TEST(test_AV_three_calls)
259
+ void test_AV_three_calls()
260
+ {
261
+ long long unsigned int cur_time = time(NULL);
262
+ Tox *bootstrap_node = tox_new(0);
263
+ Tox *caller = tox_new(0);
264
+ Tox *callees[3] = {
265
+ tox_new(0),
266
+ tox_new(0),
267
+ tox_new(0),
268
+ };
269
+
270
+
271
+ //ck_assert_msg(bootstrap_node != NULL, "Failed to create bootstrap node");
272
+
273
+ int i = 0;
274
+
275
+ for (; i < 3; i ++) {
276
+ //ck_assert_msg(callees[i] != NULL, "Failed to create 3 tox instances");
277
+ }
278
+
279
+ for ( i = 0; i < 3; i ++ ) {
280
+ uint32_t to_compare = 974536;
281
+ tox_callback_friend_request(callees[i], accept_friend_request, &to_compare);
282
+ uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
283
+ tox_get_address(callees[i], address);
284
+
285
+ int test = tox_add_friend(caller, address, (uint8_t *)"gentoo", 7);
286
+ //ck_assert_msg( test == i, "Failed to add friend error code: %i", test);
287
+ }
288
+
289
+ uint8_t off = 1;
290
+
291
+ while (1) {
292
+ tox_do(bootstrap_node);
293
+ tox_do(caller);
294
+
295
+ for (i = 0; i < 3; i ++) {
296
+ tox_do(callees[i]);
297
+ }
298
+
299
+
300
+ if (tox_isconnected(bootstrap_node) &&
301
+ tox_isconnected(caller) &&
302
+ tox_isconnected(callees[0]) &&
303
+ tox_isconnected(callees[1]) &&
304
+ tox_isconnected(callees[2]) && off) {
305
+ printf("Toxes are online, took %llu seconds\n", time(NULL) - cur_time);
306
+ off = 0;
307
+ }
308
+
309
+
310
+ if (tox_get_friend_connection_status(caller, 0) == 1 &&
311
+ tox_get_friend_connection_status(caller, 1) == 1 &&
312
+ tox_get_friend_connection_status(caller, 2) == 1 )
313
+ break;
314
+
315
+ c_sleep(20);
316
+ }
317
+
318
+ printf("All set after %llu seconds! Starting call...\n", time(NULL) - cur_time);
319
+
320
+ ToxAv *uniqcallerav = toxav_new(caller, 3);
321
+
322
+ for (i = 0; i < 3; i ++) {
323
+ status_control.calls[i].idx = i;
324
+
325
+ status_control.calls[i].Caller.av = uniqcallerav;
326
+ status_control.calls[i].Caller.id = 0;
327
+ status_control.calls[i].Caller.status = none;
328
+
329
+ status_control.calls[i].Callee.av = toxav_new(callees[i], 1);
330
+ status_control.calls[i].Callee.id = i;
331
+ status_control.calls[i].Callee.status = none;
332
+ }
333
+
334
+ pthread_mutex_init(&muhmutex, NULL);
335
+
336
+ for ( i = 0; i < 3; i++ )
337
+ pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]);
338
+
339
+ /* Now start 3 calls and they'll run for 10 s */
340
+
341
+ for ( i = 0; i < 3; i++ )
342
+ pthread_detach(status_control.calls[i].tid);
343
+
344
+ while (call_running[0] || call_running[1] || call_running[2]) {
345
+ pthread_mutex_lock(&muhmutex);
346
+
347
+ tox_do(bootstrap_node);
348
+ tox_do(caller);
349
+ tox_do(callees[0]);
350
+ tox_do(callees[1]);
351
+ tox_do(callees[2]);
352
+
353
+ pthread_mutex_unlock(&muhmutex);
354
+ c_sleep(20);
355
+ }
356
+
357
+ toxav_kill(status_control.calls[0].Caller.av);
358
+ toxav_kill(status_control.calls[0].Callee.av);
359
+ toxav_kill(status_control.calls[1].Callee.av);
360
+ toxav_kill(status_control.calls[2].Callee.av);
361
+
362
+ tox_kill(bootstrap_node);
363
+ tox_kill(caller);
364
+
365
+ for ( i = 0; i < 3; i ++)
366
+ tox_kill(callees[i]);
367
+
368
+ }
369
+ // END_TEST
370
+
371
+
372
+
373
+
374
+ Suite *tox_suite(void)
375
+ {
376
+ Suite *s = suite_create("ToxAV");
377
+
378
+ TCase *tc_av_three_calls = tcase_create("AV_three_calls");
379
+ tcase_add_test(tc_av_three_calls, test_AV_three_calls);
380
+ tcase_set_timeout(tc_av_three_calls, 150);
381
+ suite_add_tcase(s, tc_av_three_calls);
382
+
383
+ return s;
384
+ }
385
+ int main(int argc, char *argv[])
386
+ {
387
+ // Suite *tox = tox_suite();
388
+ // SRunner *test_runner = srunner_create(tox);
389
+ //
390
+ // setbuf(stdout, NULL);
391
+ //
392
+ // srunner_run_all(test_runner, CK_NORMAL);
393
+ // int number_failed = srunner_ntests_failed(test_runner);
394
+ //
395
+ // srunner_free(test_runner);
396
+ //
397
+ // return number_failed;
398
+
399
+ test_AV_three_calls();
400
+
401
+ return 0;
402
+ }
@@ -0,0 +1,6 @@
1
+ #!/bin/sh -e
2
+
3
+ echo 'Running autoreconf -if...'
4
+ (
5
+ autoreconf -if
6
+ )
@@ -0,0 +1,14 @@
1
+ bin_PROGRAMS =
2
+ noinst_PROGRAMS =
3
+ lib_LTLIBRARIES =
4
+ noinst_bindir = $(top_builddir)/build
5
+ EXTRA_DIST=
6
+
7
+ include ../toxcore/Makefile.inc
8
+ include ../toxdns/Makefile.inc
9
+ include ../toxencryptsave/Makefile.inc
10
+ include ../toxav/Makefile.inc
11
+ include ../other/Makefile.inc
12
+ include ../testing/Makefile.inc
13
+ include ../other/bootstrap_daemon/Makefile.inc
14
+ include ../auto_tests/Makefile.inc
@@ -0,0 +1,694 @@
1
+ # -*- Autoconf -*-
2
+ # Process this file with autoconf to produce a configure script.
3
+
4
+ AC_PREREQ([2.65])
5
+ AC_INIT([tox], [0.0.0], [https://tox.im])
6
+ AC_CONFIG_AUX_DIR(configure_aux)
7
+ AC_CONFIG_SRCDIR([toxcore/net_crypto.c])
8
+ AC_CONFIG_HEADERS([config.h])
9
+ AM_INIT_AUTOMAKE([1.10 -Wall subdir-objects])
10
+ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11
+ AC_CONFIG_MACRO_DIR([m4])
12
+
13
+ EXTRA_LT_LDFLAGS=
14
+
15
+ LIBTOXCORE_LT_VERSION=0:0:0
16
+ LIBTOXAV_LT_VERSION=0:0:0
17
+ dnl
18
+ dnl current:revision:age
19
+ dnl
20
+ dnl current: increment if interfaces have been added, removed or changed
21
+ dnl revision: increment if source code has changed, set to zero if current is
22
+ dnl incremented
23
+ dnl age: increment if interfaces have been added, set to zero if
24
+ dnl interfaces have been removed or changed
25
+
26
+ if test "x${prefix}" = "xNONE"; then
27
+ prefix="${ac_default_prefix}"
28
+ fi
29
+
30
+ BUILD_DHT_BOOTSTRAP_DAEMON="no"
31
+ BUILD_NTOX="no"
32
+ BUILD_TESTS="yes"
33
+ BUILD_AV="yes"
34
+ BUILD_TESTING="yes"
35
+
36
+ LOGGING="no"
37
+ LOGGING_OUTNAM="libtoxcore.log"
38
+
39
+ NCURSES_FOUND="no"
40
+ LIBCONFIG_FOUND="no"
41
+ LIBCHECK_FOUND="no"
42
+ WANT_NACL="no"
43
+ ADD_NACL_OBJECTS_TO_PKGCONFIG="yes"
44
+
45
+ TOXCORE_LT_LDFLAGS="-version-info $LIBTOXCORE_LT_VERSION"
46
+ TOXAV_LT_LDFLAGS="-version-info $LIBTOXAV_LT_VERSION"
47
+
48
+ AC_ARG_ENABLE([soname-versions],
49
+ [AC_HELP_STRING([--enable-soname-versions], [enable soname versions (must be disabled for android) (default: enabled)]) ],
50
+ [
51
+ if test "x$enableval" = "xno"; then
52
+ TOXCORE_LT_LDFLAGS="-avoid-version"
53
+ TOXAV_LT_LDFLAGS="-avoid-version"
54
+ fi
55
+ ]
56
+ )
57
+
58
+ AC_SUBST(TOXCORE_LT_LDFLAGS)
59
+ AC_SUBST(TOXAV_LT_LDFLAGS)
60
+
61
+ AC_ARG_ENABLE([nacl],
62
+ [AC_HELP_STRING([--enable-nacl], [use nacl instead of libsodium (default: disabled)]) ],
63
+ [
64
+ if test "x$enableval" = "xno"; then
65
+ WANT_NACL="no"
66
+ elif test "x$enableval" = "xyes"; then
67
+ WANT_NACL="yes"
68
+ fi
69
+ ]
70
+ )
71
+
72
+ AC_ARG_ENABLE([randombytes-stir],
73
+ [AC_HELP_STRING([--enable-randombytes-stir], [use randombytes_stir() instead of sodium_init() for faster startup on android (default: disabled)]) ],
74
+ [
75
+ if test "x$enableval" = "xyes"; then
76
+ if test "x$WANT_NACL" = "xyes"; then
77
+ AC_MSG_WARN([randombytes_stir() is not available with NaCl library])
78
+ else
79
+ AC_DEFINE([USE_RANDOMBYTES_STIR], [1], [randombytes_stir() instead of sodium_init()])
80
+ fi
81
+ fi
82
+ ]
83
+ )
84
+
85
+ AC_ARG_ENABLE([logging],
86
+ [AC_HELP_STRING([--enable-logging], [enable logging (default: auto)]) ],
87
+ [
88
+ if test "x$enableval" = "xyes"; then
89
+ LOGGING="yes"
90
+
91
+ AC_DEFINE([LOGGING], [], [If logging enabled])
92
+ AC_DEFINE([LOGGER_LEVEL], [DEBUG], [LoggerLevel value])
93
+ AC_DEFINE_UNQUOTED([LOGGER_OUTPUT_FILE], ["$LOGGING_OUTNAM"], [Output of logger])
94
+ fi
95
+ ]
96
+ )
97
+
98
+ AC_ARG_WITH(logger-level,
99
+ AC_HELP_STRING([--with-logger-level=LEVEL],
100
+ [Logger levels: INFO; DEBUG; WARNING; ERROR ]),
101
+ [
102
+ if test "x$LOGGING" = "xno"; then
103
+ AC_MSG_WARN([Logging disabled!])
104
+ else
105
+ if test "x$withval" = "xINFO"; then
106
+ AC_DEFINE([LOGGER_LEVEL], [INFO], [LoggerLevel value])
107
+
108
+ elif test "x$withval" = "xDEBUG"; then
109
+ AC_DEFINE([LOGGER_LEVEL], [DEBUG], [LoggerLevel value])
110
+
111
+ elif test "x$withval" = "xWARNING"; then
112
+ AC_DEFINE([LOGGER_LEVEL], [WARNING], [LoggerLevel value])
113
+
114
+ elif test "x$withval" = "xERROR"; then
115
+ AC_DEFINE([LOGGER_LEVEL], [ERROR], [LoggerLevel value])
116
+ else
117
+ AC_MSG_WARN([Invalid logger level: $withval. Using default 'DEBUG'])
118
+ fi
119
+ fi
120
+ ]
121
+ )
122
+
123
+ AC_ARG_WITH(logger-path,
124
+ AC_HELP_STRING([--with-logger-path=DIR],
125
+ [Path of logger output]),
126
+ [
127
+ if test "x$LOGGING" = "xno"; then
128
+ AC_MSG_WARN([Logging disabled!])
129
+ else
130
+ AC_DEFINE_UNQUOTED([LOGGER_OUTPUT_FILE], ["$withval""/""$LOGGING_OUTNAM"], [Output of logger])
131
+ fi
132
+ ]
133
+ )
134
+
135
+ PKG_PROG_PKG_CONFIG
136
+
137
+ AC_ARG_ENABLE([av],
138
+ [AC_HELP_STRING([--disable-av], [build AV support libraries (default: auto)]) ],
139
+ [
140
+ if test "x$enableval" = "xno"; then
141
+ BUILD_AV="no"
142
+ elif test "x$enableval" = "xyes"; then
143
+ BUILD_AV="yes"
144
+ fi
145
+ ]
146
+ )
147
+
148
+ AC_ARG_ENABLE([tests],
149
+ [AC_HELP_STRING([--disable-tests], [build unit tests (default: auto)]) ],
150
+ [
151
+ if test "x$enableval" = "xno"; then
152
+ BUILD_TESTS="no"
153
+ elif test "x$enableval" = "xyes"; then
154
+ BUILD_TESTS="yes"
155
+ fi
156
+ ]
157
+ )
158
+
159
+ AC_ARG_ENABLE([ntox],
160
+ [AC_HELP_STRING([--enable-ntox], [build nTox client (default: auto)]) ],
161
+ [
162
+ if test "x$enableval" = "xno"; then
163
+ BUILD_NTOX="no"
164
+ elif test "x$enableval" = "xyes"; then
165
+ BUILD_NTOX="yes"
166
+ fi
167
+ ]
168
+ )
169
+
170
+ AC_ARG_ENABLE([daemon],
171
+ [AC_HELP_STRING([--enable-daemon], [build DHT bootstrap daemon (default: auto)]) ],
172
+ [
173
+ if test "x$enableval" = "xno"; then
174
+ BUILD_DHT_BOOTSTRAP_DAEMON="no"
175
+ elif test "x$enableval" = "xyes"; then
176
+ BUILD_DHT_BOOTSTRAP_DAEMON="yes"
177
+ fi
178
+ ]
179
+ )
180
+
181
+ AC_ARG_ENABLE([rt],
182
+ [AC_HELP_STRING([--disable-rt], [Disables the librt check (default: auto)]) ],
183
+ [
184
+ if test "x$enableval" = "xno"; then
185
+ DISABLE_RT="yes"
186
+ elif test "x$enableval" = "xyes"; then
187
+ DISABLE_RT="no"
188
+ fi
189
+ ]
190
+ )
191
+
192
+ AC_ARG_ENABLE([testing],
193
+ [AC_HELP_STRING([--disable-testing], [build various testing tools (default: auto)]) ],
194
+ [
195
+ if test "x$enableval" = "xno"; then
196
+ BUILD_TESTING="no"
197
+ elif test "x$enableval" = "xyes"; then
198
+ BUILD_TESTING="yes"
199
+ fi
200
+ ]
201
+ )
202
+
203
+ AC_ARG_ENABLE([[epoll]],
204
+ [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
205
+ [enable_epoll=${enableval}],
206
+ [enable_epoll='auto']
207
+ )
208
+
209
+ AX_HAVE_EPOLL
210
+ if test "$enable_epoll" != "no"; then
211
+ if test "${ax_cv_have_epoll}" = "yes"; then
212
+ AC_DEFINE([TCP_SERVER_USE_EPOLL],[1],[define to 1 to enable epoll support])
213
+ enable_epoll='yes'
214
+ else
215
+ if test "$enable_epoll" = "yes"; then
216
+ AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])
217
+ fi
218
+ enable_epoll='no'
219
+ fi
220
+ fi
221
+
222
+ DEPSEARCH=
223
+ LIBSODIUM_SEARCH_HEADERS=
224
+ LIBSODIUM_SEARCH_LIBS=
225
+ NACL_SEARCH_HEADERS=
226
+ NACL_SEARCH_LIBS=
227
+
228
+ AC_ARG_WITH(dependency-search,
229
+ AC_HELP_STRING([--with-dependency-search=DIR],
230
+ [search for dependencies in DIR, i.e., look for libraries in
231
+ DIR/lib and for headers in DIR/include]),
232
+ [
233
+ DEPSEARCH="$withval"
234
+ ]
235
+ )
236
+
237
+ if test -n "$DEPSEARCH"; then
238
+ CFLAGS="$CFLAGS -I$DEPSEARCH/include"
239
+ CPPFLAGS="$CPPFLAGS -I$DEPSEARCH/include"
240
+ LDFLAGS="$LDFLAGS -L$DEPSEARCH/lib"
241
+ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig
242
+ fi
243
+
244
+ AC_ARG_WITH(nacl-headers,
245
+ AC_HELP_STRING([--with-nacl-headers=DIR],
246
+ [search for nacl<F2> header files in DIR]),
247
+ [
248
+ NACL_SEARCH_HEADERS="$withval"
249
+ AC_MSG_NOTICE([will search for nacl header files in $withval])
250
+ ]
251
+ )
252
+
253
+ AC_ARG_WITH(nacl-libs,
254
+ AC_HELP_STRING([--with-nacl-libs=DIR],
255
+ [search for nacl libraries in DIR]),
256
+ [
257
+ NACL_SEARCH_LIBS="$withval"
258
+ AC_MSG_NOTICE([will search for nacl libraries in $withval])
259
+ ]
260
+ )
261
+
262
+ AC_ARG_WITH(libsodium-headers,
263
+ AC_HELP_STRING([--with-libsodium-headers=DIR],
264
+ [search for libsodium header files in DIR]),
265
+ [
266
+ LIBSODIUM_SEARCH_HEADERS="$withval"
267
+ AC_MSG_NOTICE([will search for libsodium header files in $withval])
268
+ ]
269
+ )
270
+
271
+ AC_ARG_WITH(libsodium-libs,
272
+ AC_HELP_STRING([--with-libsodium-libs=DIR],
273
+ [search for libsodium libraries in DIR]),
274
+ [
275
+ LIBSODIUM_SEARCH_LIBS="$withval"
276
+ AC_MSG_NOTICE([will search for libsodium libraries in $withval])
277
+ ]
278
+ )
279
+
280
+ if test "x$WANT_NACL" = "xyes"; then
281
+ enable_shared=no
282
+ enable_static=yes
283
+ fi
284
+
285
+ # Checks for programs.
286
+ AC_PROG_CC
287
+ AM_PROG_CC_C_O
288
+ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
289
+ AC_LIBTOOL_WIN32_DLL
290
+ AC_PROG_LIBTOOL
291
+
292
+ WIN32=no
293
+ MACH=no
294
+ AC_CANONICAL_HOST
295
+ case $host_os in
296
+ *mingw*)
297
+ WIN32="yes"
298
+ EXTRA_LT_LDFLAGS="$EXTRA_LT_LDFLAGS -no-undefined"
299
+ ;;
300
+ *solaris*)
301
+ LIBS="$LIBS -lssp -lsocket -lnsl"
302
+ ;;
303
+ *qnx*)
304
+ LIBS="$LIBS -lsocket"
305
+ ;;
306
+ *freebsd*|*openbsd*)
307
+ LDFLAGS="$LDFLAGS -L/usr/local/lib"
308
+ CFLAGS="$CFLAGS -I/usr/local/include"
309
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include"
310
+ ADD_NACL_OBJECTS_TO_PKGCONFIG="no"
311
+ ;;
312
+ darwin*)
313
+ MACH=yes
314
+ ;;
315
+ esac
316
+ AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
317
+
318
+ AC_SUBST(EXTRA_LT_LDFLAGS)
319
+
320
+ # Needed math flags for some compilers
321
+
322
+ MATH_LDFLAGS="-lm"
323
+ AC_SUBST(MATH_LDFLAGS)
324
+
325
+ # Checks for libraries.
326
+
327
+ if test "x$WANT_NACL" = "xyes"; then
328
+ NACL_LIBS=
329
+ NACL_LDFLAGS=
330
+ NACL_OBJECTS=
331
+ NACL_OBJECTS_PKGCONFIG=
332
+ LDFLAGS_SAVE="$LDFLAGS"
333
+ if test -n "$NACL_SEARCH_LIBS"; then
334
+ LDFLAGS="-L$NACL_SEARCH_LIBS $LDFLAGS"
335
+ AC_CHECK_LIB(nacl, random,
336
+ [
337
+ NACL_LDFLAGS="-L$NACL_SEARCH_LIBS"
338
+ NACL_LIBS="-lnacl"
339
+ ],
340
+ [
341
+ AC_MSG_ERROR([library nacl was not found in requested location $NACL_SEARCH_LIBS])
342
+ ]
343
+ )
344
+ else
345
+ AC_CHECK_LIB(nacl, random,
346
+ [],
347
+ [
348
+ AC_MSG_ERROR([you enabled nacl support, but library nacl was not found on your system])
349
+ ]
350
+ )
351
+ fi
352
+
353
+ if (test -f "$NACL_SEARCH_LIBS/cpucycles.o") &&
354
+ (test -f "$NACL_SEARCH_LIBS/randombytes.o"); then
355
+ NACL_OBJECTS="$NACL_SEARCH_LIBS/cpucycles.o $NACL_SEARCH_LIBS/randombytes.o"
356
+ if test "x$ADD_NACL_OBJECTS_TO_PKGCONFIG" = "xyes"; then
357
+ NACL_OBJECTS_PKGCONFIG="$NACL_OBJECTS"
358
+ fi
359
+ else
360
+ AC_MSG_ERROR([required NaCl object files cpucycles.o randombytes.o not found, please specify their location using the --with-nacl-libs parameter])
361
+ fi
362
+
363
+ LDFLAGS="$LDFLAGS_SAVE"
364
+ AC_SUBST(NACL_LIBS)
365
+ AC_SUBST(NACL_LDFLAGS)
366
+ AC_SUBST(NACL_OBJECTS)
367
+ AC_SUBST(NACL_OBJECTS_PKGCONFIG)
368
+ else
369
+ LIBSODIUM_LIBS=
370
+ LIBSODIUM_LDFLAGS=
371
+ LDFLAGS_SAVE="$LDFLAGS"
372
+ if test -n "$LIBSODIUM_SEARCH_LIBS"; then
373
+ LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS $LDFLAGS"
374
+ AC_CHECK_LIB(sodium, randombytes_random,
375
+ [
376
+ LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS"
377
+ LIBSODIUM_LIBS="-lsodium"
378
+ ],
379
+ [
380
+ AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
381
+ ]
382
+ )
383
+ else
384
+ AC_CHECK_LIB(sodium, randombytes_random,
385
+ [],
386
+ [
387
+ AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
388
+ ]
389
+ )
390
+ fi
391
+
392
+ LDFLAGS="$LDFLAGS_SAVE"
393
+ AC_SUBST(LIBSODIUM_LIBS)
394
+ AC_SUBST(LIBSODIUM_LDFLAGS)
395
+ fi
396
+
397
+ # Checks for header files.
398
+ AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
399
+
400
+
401
+ if test "x$WANT_NACL" = "xyes"; then
402
+ NACL_CFLAGS=
403
+ CFLAGS_SAVE="$CFLAGS"
404
+ CPPFLAGS_SAVE="$CPPFLAGS"
405
+ if test -n "$NACL_SEARCH_HEADERS"; then
406
+ CFLAGS="-I$NACL_SEARCH_HEADERS $CFLAGS"
407
+ CPPFLAGS="-I$NACL_SEARCH_HEADERS $CPPFLAGS"
408
+ AC_CHECK_HEADER(crypto_box.h,
409
+ [
410
+ NACL_CFLAGS="-I$NACL_SEARCH_HEADERS"
411
+ ],
412
+ [
413
+ AC_MSG_ERROR([header files for library nacl were not found in requested location $NACL_SEARCH_HEADERS])
414
+ ]
415
+ )
416
+ else
417
+ AC_CHECK_HEADER(crypto_box.h,
418
+ [],
419
+ [
420
+ AC_MSG_ERROR([you enabled nacl support, but nacl header files were not found on your system])
421
+ ]
422
+ )
423
+ fi
424
+ CFLAGS="$CFLAGS_SAVE"
425
+ CPPFLAGS="$CPPFLAGS_SAVE"
426
+ AC_SUBST(NACL_CFLAGS)
427
+ AC_DEFINE([VANILLA_NACL], [1], [use nacl instead of libsodium])
428
+ else
429
+ LIBSODIUM_CFLAGS=
430
+ CFLAGS_SAVE="$CFLAGS"
431
+ CPPFLAGS_SAVE="$CPPFLAGS"
432
+ if test -n "$LIBSODIUM_SEARCH_HEADERS"; then
433
+ CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CFLAGS"
434
+ CPPFLAGS="-I$LIBSODIUM_SEARCH_HEADERS $CPPFLAGS"
435
+ AC_CHECK_HEADER(sodium.h,
436
+ [
437
+ LIBSODIUM_CFLAGS="-I$LIBSODIUM_SEARCH_HEADERS"
438
+ ],
439
+ [
440
+ AC_MSG_ERROR([header files for required library libsodium were not found in requested location $LIBSODIUM_SEARCH_HEADERS])
441
+ ]
442
+ )
443
+ else
444
+ AC_CHECK_HEADER(sodium.h,
445
+ [],
446
+ [
447
+ AC_MSG_ERROR([header files for required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
448
+ ]
449
+ )
450
+ fi
451
+ CFLAGS="$CFLAGS_SAVE"
452
+ CPPFLAGS="$CPPFLAGS_SAVE"
453
+ AC_SUBST(LIBSODIUM_CFLAGS)
454
+ fi
455
+
456
+ # Checks for typedefs, structures, and compiler characteristics.
457
+ AC_HEADER_STDBOOL
458
+ AC_TYPE_INT16_T
459
+ AC_TYPE_INT32_T
460
+ AC_TYPE_PID_T
461
+ AC_TYPE_SIZE_T
462
+ AC_TYPE_UINT16_T
463
+ AC_TYPE_UINT32_T
464
+ AC_TYPE_UINT64_T
465
+ AC_TYPE_UINT8_T
466
+ AC_C_BIGENDIAN
467
+
468
+
469
+ # Checks for library functions.
470
+ AC_FUNC_FORK
471
+ AC_CHECK_FUNCS([gettimeofday memset socket strchr malloc])
472
+ if (test "x$WIN32" != "xyes") && (test "x$MACH" != "xyes") && (test "x$DISABLE_RT" != "xyes"); then
473
+ AC_CHECK_LIB(rt, clock_gettime,
474
+ [
475
+ RT_LIBS="-lrt"
476
+ AC_SUBST(RT_LIBS)
477
+ ],
478
+ [
479
+ AC_MSG_ERROR([required library rt was not found on your system])
480
+ ]
481
+ )
482
+ fi
483
+
484
+
485
+ AX_PTHREAD(
486
+ [],
487
+ [
488
+ AC_MSG_ERROR([required library pthread was not found on your system])
489
+ ]
490
+ )
491
+
492
+ if test "x$BUILD_AV" = "xyes"; then
493
+ PKG_CHECK_MODULES([OPUS], [opus],
494
+ [],
495
+ [
496
+ AC_MSG_WARN([disabling AV support $OPUS_PKG_ERRORS])
497
+ BUILD_AV="no"
498
+ ]
499
+ )
500
+ fi
501
+
502
+ if test "x$BUILD_AV" = "xyes"; then
503
+ PKG_CHECK_MODULES([VPX], [vpx],
504
+ [],
505
+ [
506
+ AC_MSG_WARN([disabling AV support $VPX_PKG_ERRORS])
507
+ BUILD_AV="no"
508
+ ]
509
+ )
510
+ fi
511
+
512
+ if test "x$BUILD_AV" = "xyes"; then
513
+ # toxcore lib needs an global?
514
+ # So far this works okay
515
+ ## What about pthread?
516
+ AV_LIBS="$OPUS_LIBS $VPX_LIBS -pthread"
517
+ AC_SUBST(AV_LIBS)
518
+
519
+ AV_CFLAGS="$OPUS_CFLAGS $VPX_CFLAGS"
520
+ AC_SUBST(AV_CFLAGS)
521
+ fi
522
+
523
+ if test -n "$PKG_CONFIG"; then
524
+ if test "x$BUILD_TESTS" = "xyes"; then
525
+ PKG_CHECK_MODULES([CHECK], [check],
526
+ [
527
+ LIBCHECK_FOUND="yes"
528
+ ],
529
+ [
530
+ AC_MSG_WARN([libcheck not found, not building unit tests: $CHECK_PKG_ERRORS])
531
+ BUILD_TESTS="no"
532
+ ])
533
+ fi
534
+
535
+ if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then
536
+ PKG_CHECK_MODULES([LIBCONFIG], [libconfig >= 1.4.6],
537
+ [
538
+ LIBCONFIG_FOUND="yes"
539
+ ],
540
+ [
541
+ AC_MSG_WARN([$LIBCONFIG_PKG_ERRORS])
542
+ AC_MSG_WARN([libconfig not available, will not build DHT bootstrap daemon])
543
+ BUILD_DHT_BOOTSTRAP_DAEMON="no"
544
+ ])
545
+ fi
546
+
547
+ if test "x$BUILD_NTOX" = "xyes"; then
548
+ PKG_CHECK_MODULES([NCURSES], [ncurses],
549
+ [
550
+ NCURSES_FOUND="yes"
551
+ ],
552
+ [
553
+ AC_MSG_WARN([$NCURSES_PKG_ERRORS])
554
+ ])
555
+ fi
556
+ else
557
+ AC_MSG_WARN([pkg-config was not found on your system, will search for libraries manually])
558
+ fi
559
+
560
+ if (test "x$BUILD_NTOX" = "xyes") && (test "x$NCURSES_FOUND" != "xyes"); then
561
+ AC_PATH_PROG([CURSES_CONFIG], [ncurses5-config], [no])
562
+ if test "x$CURSES_CONFIG" != "xno"; then
563
+ AC_MSG_CHECKING(ncurses cflags)
564
+ NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
565
+ AC_MSG_RESULT($NCURSES_CFLAGS)
566
+
567
+ AC_MSG_CHECKING(ncurses libraries)
568
+ NCURSES_LIBS=`${CURSES_CONFIG} --libs`
569
+ AC_MSG_RESULT($NCURSES_LIBS)
570
+
571
+ AC_SUBST(NCURSES_CFLAGS)
572
+ AC_SUBST(NCURSES_LIBS)
573
+ NCURSES_FOUND="yes"
574
+ fi
575
+
576
+ if test "x$NCURSES_FOUND" != "xyes"; then
577
+ AC_CHECK_HEADER([curses.h],
578
+ [],
579
+ [
580
+ AC_MSG_WARN([not building nTox client because headers for the curses library were not found on your system])
581
+ BUILD_NTOX="no"
582
+ ]
583
+ )
584
+ if test "x$BUILD_NTOX" = "xyes"; then
585
+ if test "x$WIN32" = "xyes"; then
586
+ AC_CHECK_LIB([pdcurses], [clear],
587
+ [
588
+ NCURSES_LIBS="-lpdcurses"
589
+ AC_SUBST(NCURSES_LIBS)
590
+ ],
591
+ [
592
+ AC_MSG_ERROR([required library pdcurses was not found on your system])
593
+ BUILD_NTOX="no"
594
+ ]
595
+ )
596
+ else
597
+ AC_CHECK_LIB([ncurses], [clear],
598
+ [
599
+ NCURSES_LIBS="-lncurses"
600
+ AC_SUBST(NCURSES_LIBS)
601
+ ],
602
+ [
603
+ unset ac_cv_lib_ncurses_clear
604
+ AC_CHECK_LIB([ncurses], [clear],
605
+ [
606
+ NCURSES_LIBS="-lncurses -ltinfo"
607
+ AC_SUBST(NCURSES_LIBS)
608
+ ],
609
+ [
610
+ AC_MSG_WARN([not building nTox client because required library ncurses was not found on your system])
611
+ BUILD_NTOX="no"
612
+ ],
613
+ [
614
+ -ltinfo
615
+ ]
616
+ )
617
+ ]
618
+ )
619
+ fi
620
+ fi
621
+ fi
622
+ fi
623
+
624
+ if (test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes") && \
625
+ (test "x$LIBCONFIG_FOUND" = "xno"); then
626
+ AC_CHECK_HEADER(libconfig.h,
627
+ [],
628
+ [
629
+ AC_MSG_WARN([header files for library libconfig was not found on your system, not building DHT bootstrap daemon])
630
+ BUILD_DHT_BOOTSTRAP_DAEMON="no"
631
+ ]
632
+ )
633
+
634
+ if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then
635
+ AC_CHECK_LIB(config, config_read,
636
+ [],
637
+ [
638
+ AC_MSG_WARN([library libconfig was not found on the system])
639
+ BUILD_DHT_BOOTSTRAP_DAEMON="no"
640
+ ]
641
+ )
642
+ fi
643
+ fi
644
+
645
+ if (test "x$BUILD_TESTS" = "xyes") && (test "x$LIBCHECK_FOUND" = "xno"); then
646
+ AC_CHECK_HEADER([check.h],
647
+ [],
648
+ [
649
+ AC_MSG_WARN([header file for check library was not found on your system, unit tests will be disabled])
650
+ BUILD_TESTS="no"
651
+ ]
652
+ )
653
+
654
+ if test "x$BUILD_TESTS" = "xyes"; then
655
+ AC_CHECK_LIB([check], [suite_create],
656
+ [],
657
+ [
658
+ AC_MSG_WARN([library check was not found on the system, unit tests will be disabled])
659
+ BUILD_TESTS="no"
660
+ ]
661
+ )
662
+ fi
663
+ fi
664
+
665
+ if test "x$WIN32" = "xyes"; then
666
+ AC_CHECK_LIB(ws2_32, main,
667
+ [
668
+ WINSOCK2_LIBS="-liphlpapi -lws2_32"
669
+ AC_SUBST(WINSOCK2_LIBS)
670
+ ],
671
+ [
672
+ AC_MSG_ERROR([required library was not found on the system, please check your MinGW installation])
673
+ ]
674
+ )
675
+ fi
676
+
677
+ AM_CONDITIONAL(BUILD_DHT_BOOTSTRAP_DAEMON, test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes")
678
+ AM_CONDITIONAL(BUILD_TESTS, test "x$BUILD_TESTS" = "xyes")
679
+ AM_CONDITIONAL(BUILD_NTOX, test "x$BUILD_NTOX" = "xyes")
680
+ AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
681
+ AM_CONDITIONAL(BUILD_TESTING, test "x$BUILD_TESTING" = "xyes")
682
+ AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes")
683
+
684
+ AC_CONFIG_FILES([Makefile
685
+ build/Makefile
686
+ libtoxcore.pc
687
+ ])
688
+
689
+ AM_COND_IF(BUILD_AV,
690
+ [
691
+ AC_CONFIG_FILES([libtoxav.pc])
692
+ ],)
693
+
694
+ AC_OUTPUT