diff options
author | Michael Rose <michael_rose@gmx.de> | 2013-08-19 14:40:15 +0200 |
---|---|---|
committer | Michael Rose <michael_rose@gmx.de> | 2013-08-19 14:40:15 +0200 |
commit | 0aabb5bc49eb86c4168bbf4f369f72fa97d50c53 (patch) | |
tree | 7f68fd93e728f7de5f350ad1bc9e4f6a467cd08a /testing/toxic/main.c | |
parent | d6ae8dce983925a3f1462d111b5243fff3be31ec (diff) | |
parent | 4b480381ee7e1b5bbf3c253c0c4bf045e43f0a0e (diff) |
Merge with upstream
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r-- | testing/toxic/main.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index c4c84eaf..9abe8de4 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(__APPLE__) | ||
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 defined(__APPLE__) | ||
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 | ||
@@ -307,11 +291,17 @@ int main(int argc, char *argv[]) | |||
307 | 291 | ||
308 | if (config_err) { | 292 | if (config_err) { |
309 | DATA_FILE = strdup("data"); | 293 | DATA_FILE = strdup("data"); |
294 | SRVLIST_FILE = strdup("../../other/DHTservers"); | ||
310 | } else { | 295 | } else { |
311 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); | 296 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); |
312 | strcpy(DATA_FILE, user_config_dir); | 297 | strcpy(DATA_FILE, user_config_dir); |
313 | strcat(DATA_FILE, CONFIGDIR); | 298 | strcat(DATA_FILE, CONFIGDIR); |
314 | strcat(DATA_FILE, "data"); | 299 | strcat(DATA_FILE, "data"); |
300 | |||
301 | SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); | ||
302 | strcpy(SRVLIST_FILE, user_config_dir); | ||
303 | strcat(SRVLIST_FILE, CONFIGDIR); | ||
304 | strcat(SRVLIST_FILE, "DHTservers"); | ||
315 | } | 305 | } |
316 | } | 306 | } |
317 | 307 | ||
@@ -348,5 +338,6 @@ int main(int argc, char *argv[]) | |||
348 | 338 | ||
349 | cleanupMessenger(m); | 339 | cleanupMessenger(m); |
350 | free(DATA_FILE); | 340 | free(DATA_FILE); |
341 | free(SRVLIST_FILE); | ||
351 | return 0; | 342 | return 0; |
352 | } | 343 | } |