mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-29 21:36:46 +02:00
Cleanup code around tox ID/pk conversion functions
This commit is contained in:
@ -53,30 +53,43 @@ void clear_screen(void);
|
||||
void hst_to_net(uint8_t *num, uint16_t numbytes);
|
||||
|
||||
/*
|
||||
* Converts a hexidecimal string of length hex_len to binary format and puts the result in output.
|
||||
* output_size must be exactly half of hex_len.
|
||||
* Converts a hexidecimal string representation of a Tox public key to binary format and puts
|
||||
* the result in output.
|
||||
*
|
||||
* `hex_len` must be exactly TOX_PUBLIC_KEY_SIZE * 2, and `output_size` must have room
|
||||
* for TOX_PUBLIC_KEY_SIZE bytes.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
int hex_string_to_bin(const char *hex_string, size_t hex_len, char *output, size_t output_size);
|
||||
int tox_pk_string_to_bytes(const char *hex_string, size_t hex_len, char *output, size_t output_size);
|
||||
|
||||
/* convert a hex string to bytes. returns 0 on success, -1 on failure */
|
||||
/* Converts a binary representation of a Tox public key into a string.
|
||||
*
|
||||
* `bin_pubkey_size` must be exactly TOX_PUBLIC_KEY_SIZE bytes in size, and
|
||||
* `output_size` must be at least TOX_PUBLIC_KEY_SIZE * 2 + 1.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
int tox_pk_bytes_to_str(const uint8_t *bin_pubkey, size_t bin_pubkey_size, char *output, size_t output_size);
|
||||
|
||||
/* Convert a hexadecimcal string of length `size` to bytes and puts the result in `keystr`.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
int hex_string_to_bytes(char *buf, int size, const char *keystr);
|
||||
|
||||
/* Converts a binary representation of a Tox ID into a string.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
int bin_id_to_string(const char *bin_id, size_t bin_id_size, char *output, size_t output_size);
|
||||
|
||||
/* Converts a binary representation of a Tox public key into a string.
|
||||
* `bin_id_size` must be exactly TOX_ADDRESS_SIZE bytes in length, and
|
||||
* `output_size` must be at least TOX_ADDRESS_SIZE * 2 + 1.
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
int bin_pubkey_to_string(const uint8_t *bin_pubkey, size_t bin_pubkey_size, char *output, size_t output_size);
|
||||
int tox_id_bytes_to_str(const char *bin_id, size_t bin_id_size, char *output, size_t output_size);
|
||||
|
||||
/* get the current unix time (not thread safe) */
|
||||
time_t get_unix_time(void);
|
||||
|
Reference in New Issue
Block a user