From 1dbd121ea879d86a2cea82e7a8c0f03acfe71e8e Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 22 Jul 2013 01:52:02 +0100 Subject: moved saving to nTox.c --- testing/nTox.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/testing/nTox.c b/testing/nTox.c index 693e64aa..199835a6 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -221,6 +221,25 @@ int main(int argc, char *argv[]) int c; int on = 0; initMessenger(); + FILE *data_file = NULL; + //if keyfiles exist + if ((data_file = fopen("data","r"))) { + //load keys + fseek(data_file, 0, SEEK_END); + int size = ftell(data_file); + fseek(data_file, 0, SEEK_SET); + uint8_t data[size]; + fread(data, sizeof(uint8_t), size, data_file); + Messenger_load(data, size); + } else { + //else save new keys + int size = Messenger_size(); + uint8_t data[size]; + Messenger_save(data); + data_file = fopen("data","w"); + fwrite(data, sizeof(uint8_t), size, data_file); + } + fclose(data_file); m_callback_friendrequest(print_request); m_callback_friendmessage(print_message); m_callback_namechange(print_nickchange); -- cgit v1.2.3 From 98c59506fada423fa102835d129c0dff929edafd Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Mon, 22 Jul 2013 02:15:34 +0100 Subject: added data file to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0b178e8e..73c7919e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ CMakeFiles Makefile cmake_install.cmake install_manifest.txt + +testing/data -- cgit v1.2.3