diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/toxic/main.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 73a903d6..04f6c4fd 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -27,6 +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[31]; | ||
30 | 31 | ||
31 | void on_window_resize(int sig) | 32 | void on_window_resize(int sig) |
32 | { | 33 | { |
@@ -35,6 +36,17 @@ void on_window_resize(int sig) | |||
35 | clear(); | 36 | clear(); |
36 | } | 37 | } |
37 | 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 | |||
38 | static void init_term() | 50 | static void init_term() |
39 | { | 51 | { |
40 | /* Setup terminal */ | 52 | /* Setup terminal */ |
@@ -72,15 +84,15 @@ static Messenger *init_tox() | |||
72 | m_callback_namechange(m, on_nickchange, NULL); | 84 | m_callback_namechange(m, on_nickchange, NULL); |
73 | m_callback_statusmessage(m, on_statuschange, NULL); | 85 | m_callback_statusmessage(m, on_statuschange, NULL); |
74 | m_callback_action(m, on_action, NULL); | 86 | m_callback_action(m, on_action, NULL); |
75 | #ifdef __linux__ | 87 | #ifdef __linux__ |
76 | setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); | 88 | setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy")); |
77 | #elif win32 | 89 | #elif defined(WIN32) |
78 | setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); | 90 | setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux")); |
79 | #elif MAC_OSX | 91 | #elif defined(MAC_OSX) |
80 | setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters | 92 | setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters |
81 | #else | 93 | #else |
82 | setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4")); | 94 | setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4")); |
83 | #endif | 95 | #endif |
84 | return m; | 96 | return m; |
85 | } | 97 | } |
86 | 98 | ||
@@ -94,13 +106,13 @@ int init_connection(void) | |||
94 | if (DHT_isconnected()) | 106 | if (DHT_isconnected()) |
95 | return 0; | 107 | return 0; |
96 | 108 | ||
97 | #if win32 | 109 | #if WIN32 |
98 | FILE *fp = fopen("%appdata%/.tox/DHTservers", "r"); | 110 | FILE *fp = fopen("%appdata%/.tox/DHTservers", "r"); |
99 | #elif MAC_OSX | 111 | #elif MAC_OSX |
100 | FILE *fp = fopen("~/Library/Application Support/.tox/DHTservers", "r"); | 112 | FILE *fp = fopen("~/Library/Application Support/.tox/DHTservers", "r"); |
101 | #else | 113 | #else |
102 | FILE *fp = fopen("~/.tox/DHTservers", "r"); | 114 | FILE *fp = fopen("~/.tox/DHTservers", "r"); |
103 | #endif | 115 | #endif |
104 | 116 | ||
105 | if (!fp) | 117 | if (!fp) |
106 | return 1; | 118 | return 1; |
@@ -267,6 +279,7 @@ static void load_data(Messenger *m, char *path) | |||
267 | 279 | ||
268 | int main(int argc, char *argv[]) | 280 | int main(int argc, char *argv[]) |
269 | { | 281 | { |
282 | setdir(); | ||
270 | char *user_config_dir = get_user_config_dir(); | 283 | char *user_config_dir = get_user_config_dir(); |
271 | int config_err = 0; | 284 | int config_err = 0; |
272 | 285 | ||
@@ -293,24 +306,16 @@ int main(int argc, char *argv[]) | |||
293 | config_err = create_user_config_dir(user_config_dir); | 306 | config_err = create_user_config_dir(user_config_dir); |
294 | 307 | ||
295 | if (config_err) { | 308 | if (config_err) { |
296 | #if WIN32 | 309 | strcat(DATA_FILE, dir); |
297 | DATA_FILE = strdup("%appdata/.tox/data"); | 310 | DATA_FILE = strdup("data"); |
298 | #elif MAC_OSX | 311 | |
299 | DATA_FILE = strdup("~Library/Application Support/data"); | 312 | |
300 | #else | ||
301 | DATA_FILE = strdup("~/.tox/data"); | ||
302 | #endif | ||
303 | } else { | 313 | } else { |
304 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); | 314 | DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); |
305 | strcpy(DATA_FILE, user_config_dir); | 315 | strcpy(DATA_FILE, user_config_dir); |
306 | strcat(DATA_FILE, CONFIGDIR); | 316 | strcat(DATA_FILE, CONFIGDIR); |
307 | #if WIN32 | 317 | strcat(DATA_FILE, dir); |
308 | DATA_FILE = strdup("%appdata/.tox/data"); | 318 | DATA_FILE = strdup("data"); |
309 | #elif MAC_OSX | ||
310 | DATA_FILE = strdup("~Library/Application Support/data"); | ||
311 | #else | ||
312 | DATA_FILE = strdup("~/.tox/data"); | ||
313 | #endif | ||
314 | } | 319 | } |
315 | } | 320 | } |
316 | 321 | ||