From 825138ad09785e702a363db7c1c7ed9a306162e1 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Sun, 26 Jul 2015 00:02:26 +0500 Subject: [PATCH] Move key format transformation to separate function --- main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 08c832d..8e0b6db 100644 --- a/main.c +++ b/main.c @@ -18,6 +18,8 @@ struct Node { #define NODES_COUNT 26 #define NODES_FILE_NAME "nodes" +static void Key_to_KeyBin(const char *key, uint8_t *key_bin); + static void onFriendRequest( Tox *tox, const uint8_t *key, @@ -82,9 +84,7 @@ int main() struct Node *const node = &nodes[node_index]; uint8_t key_bin[TOX_PUBLIC_KEY_SIZE]; - - for (int i = 0; i < TOX_PUBLIC_KEY_SIZE; ++i) - sscanf(&node->key[i * 2], "%2hhx", &key_bin[i]); + Key_to_KeyBin(node->key, key_bin); TOX_ERR_BOOTSTRAP err; @@ -111,6 +111,12 @@ int main() exit(EXIT_SUCCESS); } +void Key_to_KeyBin(const char *const key, uint8_t *const key_bin) +{ + for (int i = 0; i < TOX_PUBLIC_KEY_SIZE; ++i) + sscanf(&key[i * 2], "%2hhx", &key_bin[i]); +} + void onFriendRequest( Tox *const tox, const uint8_t *const key,