summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--testing/nTox.c19
2 files changed, 21 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 0b178e8e..73c7919e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ CMakeFiles
9Makefile 9Makefile
10cmake_install.cmake 10cmake_install.cmake
11install_manifest.txt 11install_manifest.txt
12
13testing/data
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[])
221 int c; 221 int c;
222 int on = 0; 222 int on = 0;
223 initMessenger(); 223 initMessenger();
224 FILE *data_file = NULL;
225 //if keyfiles exist
226 if ((data_file = fopen("data","r"))) {
227 //load keys
228 fseek(data_file, 0, SEEK_END);
229 int size = ftell(data_file);
230 fseek(data_file, 0, SEEK_SET);
231 uint8_t data[size];
232 fread(data, sizeof(uint8_t), size, data_file);
233 Messenger_load(data, size);
234 } else {
235 //else save new keys
236 int size = Messenger_size();
237 uint8_t data[size];
238 Messenger_save(data);
239 data_file = fopen("data","w");
240 fwrite(data, sizeof(uint8_t), size, data_file);
241 }
242 fclose(data_file);
224 m_callback_friendrequest(print_request); 243 m_callback_friendrequest(print_request);
225 m_callback_friendmessage(print_message); 244 m_callback_friendmessage(print_message);
226 m_callback_namechange(print_nickchange); 245 m_callback_namechange(print_nickchange);