Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Add typedefs for public API int identifiers. #2518

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions toxcore/tox.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@

static m_friend_request_cb tox_friend_request_handler;
non_null(1, 2, 3) nullable(5)
static void tox_friend_request_handler(Messenger *m, const uint8_t *public_key, const uint8_t *message, size_t length,
static void tox_friend_request_handler(Messenger *m, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], const uint8_t *message, size_t length,
void *user_data)
{
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;
Expand Down Expand Up @@ -1013,7 +1013,7 @@
}

non_null(5) nullable(1, 2, 4, 6)
static int32_t resolve_bootstrap_node(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key,
static int32_t resolve_bootstrap_node(Tox *tox, const char *host, uint16_t port, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
IP_Port **root, Tox_Err_Bootstrap *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -1042,7 +1042,7 @@
return count;
}

bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key, Tox_Err_Bootstrap *error)
bool tox_bootstrap(Tox *tox, const char *host, uint16_t port, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Bootstrap *error)
{
IP_Port *root;
const int32_t count = resolve_bootstrap_node(tox, host, port, public_key, &root, error);
Expand Down Expand Up @@ -1093,7 +1093,7 @@
return true;
}

bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t *public_key,
bool tox_add_tcp_relay(Tox *tox, const char *host, uint16_t port, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
Tox_Err_Bootstrap *error)
{
IP_Port *root;
Expand Down Expand Up @@ -1182,7 +1182,7 @@
tox_unlock(tox);
}

void tox_self_get_address(const Tox *tox, uint8_t *address)
void tox_self_get_address(const Tox *tox, uint8_t address[TOX_ADDRESS_SIZE])
{
assert(tox != nullptr);

Expand Down Expand Up @@ -1210,7 +1210,7 @@
return ret;
}

void tox_self_get_public_key(const Tox *tox, uint8_t *public_key)
void tox_self_get_public_key(const Tox *tox, uint8_t public_key[TOX_PUBLIC_KEY_SIZE])
{
assert(tox != nullptr);

Expand All @@ -1221,7 +1221,7 @@
}
}

void tox_self_get_secret_key(const Tox *tox, uint8_t *secret_key)
void tox_self_get_secret_key(const Tox *tox, uint8_t secret_key[TOX_SECRET_KEY_SIZE])
{
assert(tox != nullptr);

Expand Down Expand Up @@ -1382,7 +1382,7 @@
}
}

uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length,
uint32_t tox_friend_add(Tox *tox, const uint8_t address[TOX_ADDRESS_SIZE], const uint8_t *message, size_t length,
Tox_Err_Friend_Add *error)
{
assert(tox != nullptr);
Expand All @@ -1406,7 +1406,7 @@
return UINT32_MAX;
}

uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, Tox_Err_Friend_Add *error)
uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Friend_Add *error)
{
assert(tox != nullptr);

Expand Down Expand Up @@ -1446,7 +1446,7 @@
return true;
}

uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, Tox_Err_Friend_By_Public_Key *error)
uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Friend_By_Public_Key *error)

Check warning on line 1449 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L1449

Added line #L1449 was not covered by tests
{
assert(tox != nullptr);

Expand All @@ -1469,7 +1469,7 @@
return (uint32_t)ret;
}

bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *public_key,
bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
Tox_Err_Friend_Get_Public_Key *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -1795,7 +1795,7 @@
tox->friend_message_callback = callback;
}

bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length)
bool tox_hash(uint8_t hash[TOX_HASH_LENGTH], const uint8_t *data, size_t length)

Check warning on line 1798 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L1798

Added line #L1798 was not covered by tests
{
if (hash == nullptr || (data == nullptr && length != 0)) {
return false;
Expand Down Expand Up @@ -1925,7 +1925,7 @@
tox->file_recv_control_callback = callback;
}

bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id,
bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t file_id[TOX_FILE_ID_LENGTH],
Tox_Err_File_Get *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -1953,7 +1953,7 @@
return false;
}

uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *file_id,
uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t file_id[TOX_FILE_ID_LENGTH],
const uint8_t *filename, size_t filename_length, Tox_Err_File_Send *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -2215,7 +2215,7 @@
}

bool tox_conference_peer_get_public_key(const Tox *tox, uint32_t conference_number, uint32_t peer_number,
uint8_t *public_key, Tox_Err_Conference_Peer_Query *error)
uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error)
{
assert(tox != nullptr);
tox_lock(tox);
Expand Down Expand Up @@ -2336,7 +2336,7 @@

bool tox_conference_offline_peer_get_public_key(const Tox *tox, uint32_t conference_number,
uint32_t offline_peer_number,
uint8_t *public_key, Tox_Err_Conference_Peer_Query *error)
uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error)
{
assert(tox != nullptr);
tox_lock(tox);
Expand Down Expand Up @@ -2629,7 +2629,7 @@
return (Tox_Conference_Type)ret;
}

bool tox_conference_get_id(const Tox *tox, uint32_t conference_number, uint8_t *id)
bool tox_conference_get_id(const Tox *tox, uint32_t conference_number, uint8_t id[TOX_CONFERENCE_ID_SIZE])

Check warning on line 2632 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L2632

Added line #L2632 was not covered by tests
{
assert(tox != nullptr);
tox_lock(tox);
Expand All @@ -2639,13 +2639,13 @@
}

// TODO(iphydf): Delete in 0.3.0.
bool tox_conference_get_uid(const Tox *tox, uint32_t conference_number, uint8_t *uid)
bool tox_conference_get_uid(const Tox *tox, uint32_t conference_number, uint8_t uid[TOX_CONFERENCE_UID_SIZE])

Check warning on line 2642 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L2642

Added line #L2642 was not covered by tests
{
assert(tox != nullptr);
return tox_conference_get_id(tox, conference_number, uid);
}

uint32_t tox_conference_by_id(const Tox *tox, const uint8_t *id, Tox_Err_Conference_By_Id *error)
uint32_t tox_conference_by_id(const Tox *tox, const uint8_t id[TOX_CONFERENCE_ID_SIZE], Tox_Err_Conference_By_Id *error)

Check warning on line 2648 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L2648

Added line #L2648 was not covered by tests
{
assert(tox != nullptr);

Expand All @@ -2669,7 +2669,7 @@
}

// TODO(iphydf): Delete in 0.3.0.
uint32_t tox_conference_by_uid(const Tox *tox, const uint8_t *uid, Tox_Err_Conference_By_Uid *error)
uint32_t tox_conference_by_uid(const Tox *tox, const uint8_t uid[TOX_CONFERENCE_UID_SIZE], Tox_Err_Conference_By_Uid *error)

Check warning on line 2672 in toxcore/tox.c

View check run for this annotation

Codecov / codecov/patch

toxcore/tox.c#L2672

Added line #L2672 was not covered by tests
{
assert(tox != nullptr);
Tox_Err_Conference_By_Id id_error;
Expand Down Expand Up @@ -2805,7 +2805,7 @@
}
}

void tox_self_get_dht_id(const Tox *tox, uint8_t *dht_id)
void tox_self_get_dht_id(const Tox *tox, uint8_t dht_id[TOX_PUBLIC_KEY_SIZE])
{
assert(tox != nullptr);

Expand Down Expand Up @@ -3007,7 +3007,7 @@
return UINT32_MAX;
}

uint32_t tox_group_join(Tox *tox, const uint8_t *chat_id, const uint8_t *name, size_t name_length,
uint32_t tox_group_join(Tox *tox, const uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], const uint8_t *name, size_t name_length,
const uint8_t *password, size_t password_length, Tox_Err_Group_Join *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -3372,7 +3372,7 @@
return ret;
}

bool tox_group_self_get_public_key(const Tox *tox, uint32_t group_number, uint8_t *public_key,
bool tox_group_self_get_public_key(const Tox *tox, uint32_t group_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
Tox_Err_Group_Self_Query *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -3498,7 +3498,7 @@
return (Tox_Group_Role)ret;
}

bool tox_group_peer_get_public_key(const Tox *tox, uint32_t group_number, uint32_t peer_id, uint8_t *public_key,
bool tox_group_peer_get_public_key(const Tox *tox, uint32_t group_number, uint32_t peer_id, uint8_t public_key[TOX_PUBLIC_KEY_SIZE],
Tox_Err_Group_Peer_Query *error)
{
assert(tox != nullptr);
Expand Down Expand Up @@ -3689,7 +3689,7 @@
return true;
}

bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t *chat_id, Tox_Err_Group_State_Queries *error)
bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], Tox_Err_Group_State_Queries *error)
{
assert(tox != nullptr);

Expand Down
Loading
Loading