summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/Messenger.c38
-rw-r--r--toxcore/tox.c10
-rw-r--r--toxcore/tox.h10
3 files changed, 29 insertions, 29 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 5e9758dd..954b31dd 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -1185,28 +1185,28 @@ int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *f
1185/* Send a file control request. 1185/* Send a file control request.
1186 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. 1186 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.
1187 * 1187 *
1188 * return 1 on success 1188 * return 0 on success
1189 * return 0 on failure 1189 * return -1 on failure
1190 */ 1190 */
1191int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 1191int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
1192 uint8_t *data, uint16_t length) 1192 uint8_t *data, uint16_t length)
1193{ 1193{
1194 if (length > MAX_DATA_SIZE - 3) 1194 if (length > MAX_DATA_SIZE - 3)
1195 return 0; 1195 return -1;
1196 1196
1197 if (friend_not_valid(m, friendnumber)) 1197 if (friend_not_valid(m, friendnumber))
1198 return 0; 1198 return -1;
1199 1199
1200 if (send_receive == 1) { 1200 if (send_receive == 1) {
1201 if (m->friendlist[friendnumber].file_receiving[filenumber].status == FILESTATUS_NONE) 1201 if (m->friendlist[friendnumber].file_receiving[filenumber].status == FILESTATUS_NONE)
1202 return 0; 1202 return -1;
1203 } else { 1203 } else {
1204 if (m->friendlist[friendnumber].file_sending[filenumber].status == FILESTATUS_NONE) 1204 if (m->friendlist[friendnumber].file_sending[filenumber].status == FILESTATUS_NONE)
1205 return 0; 1205 return -1;
1206 } 1206 }
1207 1207
1208 if (send_receive > 1) 1208 if (send_receive > 1)
1209 return 0; 1209 return -1;
1210 1210
1211 uint8_t packet[MAX_DATA_SIZE]; 1211 uint8_t packet[MAX_DATA_SIZE];
1212 packet[0] = send_receive; 1212 packet[0] = send_receive;
@@ -1216,7 +1216,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f
1216 1216
1217 if (message_id == FILECONTROL_RESUME_BROKEN) { 1217 if (message_id == FILECONTROL_RESUME_BROKEN) {
1218 if (length != sizeof(uint64_t)) 1218 if (length != sizeof(uint64_t))
1219 return 0; 1219 return -1;
1220 1220
1221 uint8_t remaining[sizeof(uint64_t)]; 1221 uint8_t remaining[sizeof(uint64_t)];
1222 memcpy(remaining, data, sizeof(uint64_t)); 1222 memcpy(remaining, data, sizeof(uint64_t));
@@ -1264,32 +1264,32 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f
1264 break; 1264 break;
1265 } 1265 }
1266 1266
1267 return 1;
1268 } else {
1269 return 0; 1267 return 0;
1268 } else {
1269 return -1;
1270 } 1270 }
1271} 1271}
1272 1272
1273#define MIN_SLOTS_FREE 4 1273#define MIN_SLOTS_FREE 4
1274/* Send file data. 1274/* Send file data.
1275 * 1275 *
1276 * return 1 on success 1276 * return 0 on success
1277 * return 0 on failure 1277 * return -1 on failure
1278 */ 1278 */
1279int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) 1279int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
1280{ 1280{
1281 if (length > MAX_DATA_SIZE - 1) 1281 if (length > MAX_DATA_SIZE - 1)
1282 return 0; 1282 return -1;
1283 1283
1284 if (friend_not_valid(m, friendnumber)) 1284 if (friend_not_valid(m, friendnumber))
1285 return 0; 1285 return -1;
1286 1286
1287 if (m->friendlist[friendnumber].file_sending[filenumber].status != FILESTATUS_TRANSFERRING) 1287 if (m->friendlist[friendnumber].file_sending[filenumber].status != FILESTATUS_TRANSFERRING)
1288 return 0; 1288 return -1;
1289 1289
1290 /* Prevent file sending from filling up the entire buffer preventing messages from being sent. */ 1290 /* Prevent file sending from filling up the entire buffer preventing messages from being sent. */
1291 if (crypto_num_free_sendqueue_slots(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id) < MIN_SLOTS_FREE) 1291 if (crypto_num_free_sendqueue_slots(m->net_crypto, m->friendlist[friendnumber].crypt_connection_id) < MIN_SLOTS_FREE)
1292 return 0; 1292 return -1;
1293 1293
1294 uint8_t packet[MAX_DATA_SIZE]; 1294 uint8_t packet[MAX_DATA_SIZE];
1295 packet[0] = filenumber; 1295 packet[0] = filenumber;
@@ -1297,10 +1297,10 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data,
1297 1297
1298 if (write_cryptpacket_id(m, friendnumber, PACKET_ID_FILE_DATA, packet, length + 1)) { 1298 if (write_cryptpacket_id(m, friendnumber, PACKET_ID_FILE_DATA, packet, length + 1)) {
1299 m->friendlist[friendnumber].file_sending[filenumber].transferred += length; 1299 m->friendlist[friendnumber].file_sending[filenumber].transferred += length;
1300 return 1; 1300 return 0;
1301 } 1301 }
1302 1302
1303 return 0; 1303 return -1;
1304 1304
1305} 1305}
1306 1306
@@ -1309,7 +1309,7 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data,
1309 * send_receive is 0 if we want the sending files, 1 if we want the receiving. 1309 * send_receive is 0 if we want the sending files, 1 if we want the receiving.
1310 * 1310 *
1311 * return number of bytes remaining to be sent/received on success 1311 * return number of bytes remaining to be sent/received on success
1312 * return 0 on failure 1312 * return -1 on failure
1313 */ 1313 */
1314uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive) 1314uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive)
1315{ 1315{
diff --git a/toxcore/tox.c b/toxcore/tox.c
index d5bc1c35..f4e65ec8 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -585,8 +585,8 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f
585/* Send a file control request. 585/* Send a file control request.
586 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. 586 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.
587 * 587 *
588 * return 1 on success 588 * return 0 on success
589 * return 0 on failure 589 * return -1 on failure
590 */ 590 */
591int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 591int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
592 uint8_t *data, uint16_t length) 592 uint8_t *data, uint16_t length)
@@ -596,8 +596,8 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8
596} 596}
597/* Send file data. 597/* Send file data.
598 * 598 *
599 * return 1 on success 599 * return 0 on success
600 * return 0 on failure 600 * return -1 on failure
601 */ 601 */
602int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) 602int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
603{ 603{
@@ -608,7 +608,7 @@ int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *d
608/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() 608/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata()
609 * 609 *
610 * return size on success 610 * return size on success
611 * return 0 on failure (currently will never return 0) 611 * return -1 on failure (currently will never return -1)
612 */ 612 */
613int tox_filedata_size(Tox *tox, int friendnumber) 613int tox_filedata_size(Tox *tox, int friendnumber)
614{ 614{
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 469a1f78..ea373488 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -519,23 +519,23 @@ int tox_new_filesender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *f
519 * send_receive is 0 if we want the control packet to target a file we are currently sending, 519 * send_receive is 0 if we want the control packet to target a file we are currently sending,
520 * 1 if it targets a file we are currently receiving. 520 * 1 if it targets a file we are currently receiving.
521 * 521 *
522 * return 1 on success 522 * return 0 on success
523 * return 0 on failure 523 * return -1 on failure
524 */ 524 */
525int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 525int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
526 uint8_t *data, uint16_t length); 526 uint8_t *data, uint16_t length);
527 527
528/* Send file data. 528/* Send file data.
529 * 529 *
530 * return 1 on success 530 * return 0 on success
531 * return 0 on failure 531 * return -1 on failure
532 */ 532 */
533int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); 533int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
534 534
535/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata() 535/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata()
536 * 536 *
537 * return size on success 537 * return size on success
538 * return 0 on failure (currently will never return 0) 538 * return -1 on failure (currently will never return -1)
539 */ 539 */
540int tox_filedata_size(Tox *tox, int friendnumber); 540int tox_filedata_size(Tox *tox, int friendnumber);
541 541