summaryrefslogtreecommitdiff
path: root/toxcore/tox.c
diff options
context:
space:
mode:
authorDubslow <bunslow@gmail.com>2015-02-13 22:24:39 -0600
committerDubslow <bunslow@gmail.com>2015-02-18 17:41:26 -0600
commitaca41475fa1d2f7ebcc76d84b3dfcbf3c694fb30 (patch)
tree749c36a8b5206398bac2282b334157ea43b25966 /toxcore/tox.c
parent52a0753e52cb9095075c6fcc3538de965132e5b8 (diff)
Put const adjective before type nouns
(Done with two applications of "sed -i -r "s/(\\w+) const\\b/const \\1/g" toxcore/tox.*" ) Conflicts: toxcore/tox.c
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r--toxcore/tox.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index a9c7d4dd..43a2c0d9 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -88,7 +88,7 @@ void tox_options_free(struct Tox_Options *options)
88 free(options); 88 free(options);
89} 89}
90 90
91Tox *tox_new(struct Tox_Options const *options, uint8_t const *data, size_t length, TOX_ERR_NEW *error) 91Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t length, TOX_ERR_NEW *error)
92{ 92{
93 if (!logger_get_global()) 93 if (!logger_get_global())
94 logger_set_global(logger_new(LOGGER_OUTPUT_FILE, LOGGER_LEVEL, "toxcore")); 94 logger_set_global(logger_new(LOGGER_OUTPUT_FILE, LOGGER_LEVEL, "toxcore"));
@@ -177,13 +177,13 @@ void tox_kill(Tox *tox)
177 logger_kill_global(); 177 logger_kill_global();
178} 178}
179 179
180size_t tox_save_size(Tox const *tox) 180size_t tox_save_size(const Tox *tox)
181{ 181{
182 const Messenger *m = tox; 182 const Messenger *m = tox;
183 return messenger_size(m); 183 return messenger_size(m);
184} 184}
185 185
186void tox_save(Tox const *tox, uint8_t *data) 186void tox_save(const Tox *tox, uint8_t *data)
187{ 187{
188 if (data) { 188 if (data) {
189 const Messenger *m = tox; 189 const Messenger *m = tox;
@@ -191,7 +191,7 @@ void tox_save(Tox const *tox, uint8_t *data)
191 } 191 }
192} 192}
193 193
194static int address_to_ip(Messenger *m, char const *address, IP_Port *ip_port, IP_Port *ip_port_v4) 194static int address_to_ip(Messenger *m, const char *address, IP_Port *ip_port, IP_Port *ip_port_v4)
195{ 195{
196 if (!addr_parse_ip(address, &ip_port->ip)) { 196 if (!addr_parse_ip(address, &ip_port->ip)) {
197 if (m->options.udp_disabled) { /* Disable DNS when udp is disabled. */ 197 if (m->options.udp_disabled) { /* Disable DNS when udp is disabled. */
@@ -216,7 +216,7 @@ static int address_to_ip(Messenger *m, char const *address, IP_Port *ip_port, IP
216 return 0; 216 return 0;
217} 217}
218 218
219bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, TOX_ERR_BOOTSTRAP *error) 219bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error)
220{ 220{
221 if (!address || !public_key) { 221 if (!address || !public_key) {
222 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL); 222 SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
@@ -243,7 +243,7 @@ bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *
243 } 243 }
244} 244}
245 245
246bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, 246bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key,
247 TOX_ERR_BOOTSTRAP *error) 247 TOX_ERR_BOOTSTRAP *error)
248{ 248{
249 if (!address || !public_key) { 249 if (!address || !public_key) {
@@ -272,7 +272,7 @@ bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t con
272 return 1; 272 return 1;
273} 273}
274 274
275TOX_CONNECTION tox_get_connection_status(Tox const *tox) 275TOX_CONNECTION tox_get_connection_status(const Tox *tox)
276{ 276{
277 const Messenger *m = tox; 277 const Messenger *m = tox;
278 278
@@ -293,7 +293,7 @@ void tox_callback_connection_status(Tox *tox, tox_connection_status_cb *function
293 //TODO 293 //TODO
294} 294}
295 295
296uint32_t tox_iteration_interval(Tox const *tox) 296uint32_t tox_iteration_interval(const Tox *tox)
297{ 297{
298 const Messenger *m = tox; 298 const Messenger *m = tox;
299 return messenger_run_interval(m); 299 return messenger_run_interval(m);
@@ -306,7 +306,7 @@ void tox_iteration(Tox *tox)
306 do_groupchats(m->group_chat_object); 306 do_groupchats(m->group_chat_object);
307} 307}
308 308
309void tox_self_get_address(Tox const *tox, uint8_t *address) 309void tox_self_get_address(const Tox *tox, uint8_t *address)
310{ 310{
311 if (address) { 311 if (address) {
312 const Messenger *m = tox; 312 const Messenger *m = tox;
@@ -320,13 +320,13 @@ void tox_self_set_nospam(Tox *tox, uint32_t nospam)
320 set_nospam(&(m->fr), nospam); 320 set_nospam(&(m->fr), nospam);
321} 321}
322 322
323uint32_t tox_self_get_nospam(Tox const *tox) 323uint32_t tox_self_get_nospam(const Tox *tox)
324{ 324{
325 const Messenger *m = tox; 325 const Messenger *m = tox;
326 return get_nospam(&(m->fr)); 326 return get_nospam(&(m->fr));
327} 327}
328 328
329void tox_self_get_public_key(Tox const *tox, uint8_t *public_key) 329void tox_self_get_public_key(const Tox *tox, uint8_t *public_key)
330{ 330{
331 const Messenger *m = tox; 331 const Messenger *m = tox;
332 332
@@ -334,7 +334,7 @@ void tox_self_get_public_key(Tox const *tox, uint8_t *public_key)
334 memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES); 334 memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES);
335} 335}
336 336
337void tox_self_get_private_key(Tox const *tox, uint8_t *private_key) 337void tox_self_get_private_key(const Tox *tox, uint8_t *private_key)
338{ 338{
339 const Messenger *m = tox; 339 const Messenger *m = tox;
340 340
@@ -342,7 +342,7 @@ void tox_self_get_private_key(Tox const *tox, uint8_t *private_key)
342 memcpy(private_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES); 342 memcpy(private_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES);
343} 343}
344 344
345bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET_INFO *error) 345bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET_INFO *error)
346{ 346{
347 if (!name && length != 0) { 347 if (!name && length != 0) {
348 SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL); 348 SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
@@ -362,13 +362,13 @@ bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET
362 } 362 }
363} 363}
364 364
365size_t tox_self_get_name_size(Tox const *tox) 365size_t tox_self_get_name_size(const Tox *tox)
366{ 366{
367 const Messenger *m = tox; 367 const Messenger *m = tox;
368 return m_get_self_name_size(m); 368 return m_get_self_name_size(m);
369} 369}
370 370
371void tox_self_get_name(Tox const *tox, uint8_t *name) 371void tox_self_get_name(const Tox *tox, uint8_t *name)
372{ 372{
373 if (name) { 373 if (name) {
374 const Messenger *m = tox; 374 const Messenger *m = tox;
@@ -376,7 +376,7 @@ void tox_self_get_name(Tox const *tox, uint8_t *name)
376 } 376 }
377} 377}
378 378
379bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length, TOX_ERR_SET_INFO *error) 379bool tox_self_set_status_message(Tox *tox, const uint8_t *status, size_t length, TOX_ERR_SET_INFO *error)
380{ 380{
381 if (!status && length != 0) { 381 if (!status && length != 0) {
382 SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL); 382 SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
@@ -394,13 +394,13 @@ bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length,
394 } 394 }
395} 395}
396 396
397size_t tox_self_get_status_message_size(Tox const *tox) 397size_t tox_self_get_status_message_size(const Tox *tox)
398{ 398{
399 const Messenger *m = tox; 399 const Messenger *m = tox;
400 return m_get_self_statusmessage_size(m); 400 return m_get_self_statusmessage_size(m);
401} 401}
402 402
403void tox_self_get_status_message(Tox const *tox, uint8_t *status) 403void tox_self_get_status_message(const Tox *tox, uint8_t *status)
404{ 404{
405 if (status) { 405 if (status) {
406 const Messenger *m = tox; 406 const Messenger *m = tox;
@@ -414,7 +414,7 @@ void tox_self_set_status(Tox *tox, TOX_STATUS user_status)
414 m_set_userstatus(m, user_status); 414 m_set_userstatus(m, user_status);
415} 415}
416 416
417TOX_STATUS tox_self_get_status(Tox const *tox) 417TOX_STATUS tox_self_get_status(const Tox *tox)
418{ 418{
419 const Messenger *m = tox; 419 const Messenger *m = tox;
420 return m_get_self_userstatus(m); 420 return m_get_self_userstatus(m);
@@ -454,7 +454,7 @@ static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error)
454 } 454 }
455} 455}
456 456
457uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message, size_t length, 457uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length,
458 TOX_ERR_FRIEND_ADD *error) 458 TOX_ERR_FRIEND_ADD *error)
459{ 459{
460 if (!address || !message) { 460 if (!address || !message) {
@@ -474,7 +474,7 @@ uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message
474 return UINT32_MAX; 474 return UINT32_MAX;
475} 475}
476 476
477uint32_t tox_friend_add_norequest(Tox *tox, uint8_t const *public_key, TOX_ERR_FRIEND_ADD *error) 477uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error)
478{ 478{
479 if (!public_key) { 479 if (!public_key) {
480 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL); 480 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL);
@@ -508,7 +508,7 @@ bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_DELETE *
508 return 1; 508 return 1;
509} 509}
510 510
511uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error) 511uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error)
512{ 512{
513 if (!public_key) { 513 if (!public_key) {
514 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL); 514 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL);
@@ -527,7 +527,7 @@ uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX
527 return ret; 527 return ret;
528} 528}
529 529
530bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *public_key, 530bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *public_key,
531 TOX_ERR_FRIEND_GET_PUBLIC_KEY *error) 531 TOX_ERR_FRIEND_GET_PUBLIC_KEY *error)
532{ 532{
533 if (!public_key) { 533 if (!public_key) {
@@ -546,19 +546,19 @@ bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *
546 return 1; 546 return 1;
547} 547}
548 548
549bool tox_friend_exists(Tox const *tox, uint32_t friend_number) 549bool tox_friend_exists(const Tox *tox, uint32_t friend_number)
550{ 550{
551 const Messenger *m = tox; 551 const Messenger *m = tox;
552 return m_friend_exists(m, friend_number); 552 return m_friend_exists(m, friend_number);
553} 553}
554 554
555size_t tox_friend_list_size(Tox const *tox) 555size_t tox_friend_list_size(const Tox *tox)
556{ 556{
557 const Messenger *m = tox; 557 const Messenger *m = tox;
558 return count_friendlist(m); 558 return count_friendlist(m);
559} 559}
560 560
561void tox_friend_list(Tox const *tox, uint32_t *list) 561void tox_friend_list(const Tox *tox, uint32_t *list)
562{ 562{
563 if (list) { 563 if (list) {
564 const Messenger *m = tox; 564 const Messenger *m = tox;
@@ -567,7 +567,7 @@ void tox_friend_list(Tox const *tox, uint32_t *list)
567 } 567 }
568} 568}
569 569
570size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) 570size_t tox_friend_get_name_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
571{ 571{
572 const Messenger *m = tox; 572 const Messenger *m = tox;
573 int ret = m_get_name_size(m, friend_number); 573 int ret = m_get_name_size(m, friend_number);
@@ -581,7 +581,7 @@ size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_
581 return ret; 581 return ret;
582} 582}
583 583
584bool tox_friend_get_name(Tox const *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error) 584bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error)
585{ 585{
586 if (!name) { 586 if (!name) {
587 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL); 587 SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL);
@@ -606,7 +606,7 @@ void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *function, void *user
606 m_callback_friendmessage(m, function, user_data); 606 m_callback_friendmessage(m, function, user_data);
607} 607}
608 608
609size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) 609size_t tox_friend_get_status_message_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
610{ 610{
611 const Messenger *m = tox; 611 const Messenger *m = tox;
612 int ret = m_get_statusmessage_size(m, friend_number); 612 int ret = m_get_statusmessage_size(m, friend_number);
@@ -620,7 +620,7 @@ size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number
620 return ret; 620 return ret;
621} 621}
622 622
623bool tox_friend_get_status_message(Tox const *tox, uint32_t friend_number, uint8_t *message, 623bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_number, uint8_t *message,
624 TOX_ERR_FRIEND_QUERY *error) 624 TOX_ERR_FRIEND_QUERY *error)
625{ 625{
626 if (!message) { 626 if (!message) {