diff options
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r-- | testing/toxic/main.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index d5999eb2..2922456e 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -3,14 +3,23 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <curses.h> | 5 | #include <curses.h> |
6 | #include <errno.h> | ||
6 | #include <stdio.h> | 7 | #include <stdio.h> |
7 | #include <stdlib.h> | 8 | #include <stdlib.h> |
8 | #include <stdbool.h> | 9 | #include <stdbool.h> |
9 | #include <stdint.h> | 10 | #include <stdint.h> |
10 | 11 | ||
12 | #ifdef _win32 | ||
13 | #include <direct.h> | ||
14 | #else | ||
15 | #include <sys/stat.h> | ||
16 | #include <sys/types.h> | ||
17 | #endif | ||
18 | |||
11 | #include "../../core/Messenger.h" | 19 | #include "../../core/Messenger.h" |
12 | #include "../../core/network.h" | 20 | #include "../../core/network.h" |
13 | 21 | ||
22 | #include "configdir.h" | ||
14 | #include "windows.h" | 23 | #include "windows.h" |
15 | 24 | ||
16 | extern ToxWindow new_prompt(); | 25 | extern ToxWindow new_prompt(); |
@@ -342,9 +351,19 @@ int main(int argc, char *argv[]) | |||
342 | { | 351 | { |
343 | int ch; | 352 | int ch; |
344 | int f_flag = 0; | 353 | int f_flag = 0; |
345 | char *filename = "data"; | 354 | char *user_config_dir = get_user_config_dir(); |
355 | char *filename; | ||
356 | int config_err = create_user_config_dir(user_config_dir); | ||
357 | if(config_err) { | ||
358 | filename = "data"; | ||
359 | } else { | ||
360 | filename = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); | ||
361 | strcpy(filename, user_config_dir); | ||
362 | strcat(filename, CONFIGDIR); | ||
363 | strcat(filename, "data"); | ||
364 | } | ||
365 | |||
346 | ToxWindow* a; | 366 | ToxWindow* a; |
347 | |||
348 | int i = 0; | 367 | int i = 0; |
349 | for (i = 0; i < argc; ++i) { | 368 | for (i = 0; i < argc; ++i) { |
350 | if (argv[i] == NULL) | 369 | if (argv[i] == NULL) |
@@ -362,6 +381,7 @@ int main(int argc, char *argv[]) | |||
362 | init_term(); | 381 | init_term(); |
363 | init_tox(); | 382 | init_tox(); |
364 | load_data(filename); | 383 | load_data(filename); |
384 | free(filename); | ||
365 | init_windows(); | 385 | init_windows(); |
366 | init_window_status(); | 386 | init_window_status(); |
367 | 387 | ||
@@ -371,6 +391,13 @@ int main(int argc, char *argv[]) | |||
371 | "defaulting to 'data' for a keyfile...\n"); | 391 | "defaulting to 'data' for a keyfile...\n"); |
372 | attroff(COLOR_PAIR(3) | A_BOLD); | 392 | attroff(COLOR_PAIR(3) | A_BOLD); |
373 | } | 393 | } |
394 | |||
395 | if(config_err) { | ||
396 | attron(COLOR_PAIR(3) | A_BOLD); | ||
397 | wprintw(prompt->window, "Unable to determine configuration directory!\n" | ||
398 | "defaulting to 'data' for a keyfile...\n"); | ||
399 | attroff(COLOR_PAIR(3) | A_BOLD); | ||
400 | } | ||
374 | 401 | ||
375 | while(true) { | 402 | while(true) { |
376 | /* Update tox */ | 403 | /* Update tox */ |