From 8286c2c22fc110dcc58c981eb39dd7bf46ae8aa9 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 17 Mar 2015 16:20:38 -0400 Subject: [PATCH] Save function renamed to tox_get_savedata() --- auto_tests/tox_test.c | 4 ++-- testing/nTox.c | 4 ++-- toxcore/tox.c | 4 ++-- toxcore/tox.h | 13 +++++++------ toxencryptsave/toxencryptsave.c | 10 +++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 31f65505..42ba65c7 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c @@ -305,9 +305,9 @@ START_TEST(test_one) tox_self_set_name(tox1, name, sizeof(name), 0); ck_assert_msg(tox_self_get_name_size(tox1) == sizeof(name), "Can't set name of TOX_MAX_NAME_LENGTH"); - size_t save_size = tox_save_size(tox1); + size_t save_size = tox_get_savedata_size(tox1); uint8_t data[save_size]; - tox_save(tox1, data); + tox_get_savedata(tox1, data); tox_kill(tox2); TOX_ERR_NEW err_n; diff --git a/testing/nTox.c b/testing/nTox.c index a0101b6b..9e114ba5 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -965,9 +965,9 @@ static int save_data(Tox *m) } int res = 1; - size_t size = tox_save_size(m); + size_t size = tox_get_savedata_size(m); uint8_t data[size]; - tox_save(m, data); + tox_get_savedata(m, data); if (fwrite(data, sizeof(uint8_t), size, data_file) != size) { fputs("[!] could not write data file (1)!", stderr); diff --git a/toxcore/tox.c b/toxcore/tox.c index 47f4f6a3..297e7796 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -224,13 +224,13 @@ void tox_kill(Tox *tox) logger_kill_global(); } -size_t tox_save_size(const Tox *tox) +size_t tox_get_savedata_size(const Tox *tox) { const Messenger *m = tox; return messenger_size(m); } -void tox_save(const Tox *tox, uint8_t *data) +void tox_get_savedata(const Tox *tox, uint8_t *data) { if (data) { const Messenger *m = tox; diff --git a/toxcore/tox.h b/toxcore/tox.h index 0b9a63ba..2625040f 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -497,14 +497,14 @@ typedef enum TOX_ERR_NEW { * loop with a new instance will operate correctly. * * If the data parameter is not NULL, this function will load the Tox instance - * from a byte array previously filled by tox_save. + * from a byte array previously filled by tox_get_savedata. * * If loading failed or succeeded only partially, the new or partially loaded * instance is returned and an error code is set. * * @param options An options object as described above. If this parameter is * NULL, the default options are used. - * @param data A byte array containing data previously stored by tox_save. + * @param data A byte array containing data previously stored by tox_get_savedata. * @param length The length of the byte array data. If this parameter is 0, the * data parameter is ignored. * @@ -525,20 +525,21 @@ void tox_kill(Tox *tox); /** * Calculates the number of bytes required to store the tox instance with - * tox_save. This function cannot fail. The result is always greater than 0. + * tox_get_savedata. This function cannot fail. The result is always greater + * than 0. * * @see threading for concurrency implications. */ -size_t tox_save_size(const Tox *tox); +size_t tox_get_savedata_size(const Tox *tox); /** * Store all information associated with the tox instance to a byte array. * * @param data A memory region large enough to store the tox instance data. - * Call tox_save_size to find the number of bytes required. If this parameter + * Call tox_get_savedata_size to find the number of bytes required. If this parameter * is NULL, this function has no effect. */ -void tox_save(const Tox *tox, uint8_t *data); +void tox_get_savedata(const Tox *tox, uint8_t *data); /******************************************************************************* diff --git a/toxencryptsave/toxencryptsave.c b/toxencryptsave/toxencryptsave.c index f9846ac9..587c7048 100644 --- a/toxencryptsave/toxencryptsave.c +++ b/toxencryptsave/toxencryptsave.c @@ -66,7 +66,7 @@ int tox_pass_salt_length() /* return size of the messenger data (for encrypted saving). */ uint32_t tox_encrypted_size(const Tox *tox) { - return tox_save_size(tox) + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; + return tox_get_savedata_size(tox) + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; } /* This retrieves the salt used to encrypt the given data, which can then be passed to @@ -205,9 +205,9 @@ int tox_pass_encrypt(const uint8_t *data, uint32_t data_len, uint8_t *passphrase int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint32_t pplength) { /* first get plain save data */ - uint32_t temp_size = tox_save_size(tox); + uint32_t temp_size = tox_get_savedata_size(tox); uint8_t temp_data[temp_size]; - tox_save(tox, temp_data); + tox_get_savedata(tox, temp_data); /* now encrypt */ return tox_pass_encrypt(temp_data, temp_size, passphrase, pplength, data); @@ -222,9 +222,9 @@ int tox_encrypted_save(const Tox *tox, uint8_t *data, uint8_t *passphrase, uint3 int tox_encrypted_key_save(const Tox *tox, uint8_t *data, uint8_t *key) { /* first get plain save data */ - uint32_t temp_size = tox_save_size(tox); + uint32_t temp_size = tox_get_savedata_size(tox); uint8_t temp_data[temp_size]; - tox_save(tox, temp_data); + tox_get_savedata(tox, temp_data); /* encrypt */ return tox_pass_key_encrypt(temp_data, temp_size, key, data);