diff options
Diffstat (limited to 'testing/toxic')
-rw-r--r-- | testing/toxic/configdir.h | 4 | ||||
-rw-r--r-- | testing/toxic/main.c | 35 |
2 files changed, 14 insertions, 25 deletions
diff --git a/testing/toxic/configdir.h b/testing/toxic/configdir.h index 17d95107..e886e53a 100644 --- a/testing/toxic/configdir.h +++ b/testing/toxic/configdir.h | |||
@@ -19,9 +19,9 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifdef _win32 | 21 | #ifdef _win32 |
22 | #define CONFIGDIR "\\toxic\\" | 22 | #define CONFIGDIR "\\tox\\" |
23 | #else | 23 | #else |
24 | #define CONFIGDIR "/toxic/" | 24 | #define CONFIGDIR "/tox/" |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #ifndef S_ISDIR | 27 | #ifndef S_ISDIR |
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 72d8633b..3ed2fa5e 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | /* Export for use in Callbacks */ | 28 | /* Export for use in Callbacks */ |
29 | char *DATA_FILE = NULL; | 29 | char *DATA_FILE = NULL; |
30 | char dir[256]; | 30 | char *SRVLIST_FILE = NULL; |
31 | 31 | ||
32 | void on_window_resize(int sig) | 32 | void on_window_resize(int sig) |
33 | { | 33 | { |
@@ -36,17 +36,6 @@ void on_window_resize(int sig) | |||
36 | clear(); | 36 | clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void setdir() | ||
40 | { | ||
41 | #ifdef WIN32 | ||
42 | strcpy(dir, "%appdata%/.tox/"); | ||
43 | #elif defined(MAC_OSX) | ||
44 | strcpy(dir, "~/Library/Application Support/.tox/"); | ||
45 | #elif defined(linux) | ||
46 | strcpy(dir, "~/.tox/"); | ||
47 | #endif | ||
48 | } | ||
49 | |||
50 | static void init_term() | 39 | static void init_term() |
51 | { | 40 | { |
52 | /* Setup terminal */ | 41 | /* Setup terminal */ |
@@ -103,16 +92,12 @@ static Messenger *init_tox() | |||
103 | /* Connects to a random DHT server listed in the DHTservers file */ | 92 | /* Connects to a random DHT server listed in the DHTservers file */ |
104 | int init_connection(void) | 93 | int init_connection(void) |
105 | { | 94 | { |
95 | FILE *fp = NULL; | ||
96 | |||
106 | if (DHT_isconnected()) | 97 | if (DHT_isconnected()) |
107 | return 0; | 98 | return 0; |
108 | 99 | ||
109 | #if WIN32 | 100 | fp = fopen(SRVLIST_FILE, "r"); |
110 | FILE *fp = fopen("%appdata%/.tox/DHTservers", "r"); | ||
111 | #elif MAC_OSX | ||
112 | FILE *fp = fopen("~/Library/Application Support/.tox/DHTservers", "r"); | ||
113 | #else | ||
114 | FILE *fp = fopen("~/.tox/DHTservers", "r"); | ||
115 | #endif | ||
116 | 101 | ||
117 | if (!fp) | 102 | if (!fp) |
118 | return 1; | 103 | return 1; |
@@ -279,7 +264,6 @@ static void load_data(Messenger *m, char *path) | |||
279 | 264 | ||
280 | int main(int argc, char *argv[]) | 265 | int main(int argc, char *argv[]) |
281 | { | 266 | { |
282 | setdir(); | ||
283 | char *user_config_dir = get_user_config_dir(); | 267 | char *user_config_dir = get_user_config_dir(); |
284 | int config_err = 0; | 268 | int config_err = 0; |
285 | 269 | ||
@@ -306,16 +290,20 @@ int main(int argc, char *argv[]) | |||
306 | config_err = create_user_config_dir(user_config_dir); | 290 | config_err = create_user_config_dir(user_config_dir); |
307 | 291 | ||
308 | if (config_err) { | 292 | if (config_err) { |
309 | strcat(DATA_FILE, dir); | ||
310 | DATA_FILE = strdup("data"); | 293 | DATA_FILE = strdup("data"); |
294 | SRVLIST_FILE = strdup("../../other/DHTservers"); | ||
311 | 295 | ||
312 | 296 | ||
313 | } else { | 297 | } else { |
314 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); | 298 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); |
315 | strcpy(DATA_FILE, user_config_dir); | 299 | strcpy(DATA_FILE, user_config_dir); |
316 | strcat(DATA_FILE, CONFIGDIR); | 300 | strcat(DATA_FILE, CONFIGDIR); |
317 | strcat(DATA_FILE, dir); | 301 | strcat(DATA_FILE, "data"); |
318 | DATA_FILE = strdup("data"); | 302 | |
303 | SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); | ||
304 | strcpy(SRVLIST_FILE, user_config_dir); | ||
305 | strcat(SRVLIST_FILE, CONFIGDIR); | ||
306 | strcat(SRVLIST_FILE, "DHTservers"); | ||
319 | } | 307 | } |
320 | } | 308 | } |
321 | 309 | ||
@@ -352,5 +340,6 @@ int main(int argc, char *argv[]) | |||
352 | 340 | ||
353 | cleanupMessenger(m); | 341 | cleanupMessenger(m); |
354 | free(DATA_FILE); | 342 | free(DATA_FILE); |
343 | free(SRVLIST_FILE); | ||
355 | return 0; | 344 | return 0; |
356 | } | 345 | } |