diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/toxic/main.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 391b0b39..3b45a89f 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -170,12 +170,12 @@ static void do_tox() { | |||
170 | doMessenger(); | 170 | doMessenger(); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void load_data() { | 173 | static void load_data(char *path) { |
174 | FILE* fd; | 174 | FILE* fd; |
175 | size_t len; | 175 | size_t len; |
176 | uint8_t* buf; | 176 | uint8_t* buf; |
177 | 177 | ||
178 | if((fd = fopen("data", "r")) != NULL) { | 178 | if((fd = fopen(path, "r")) != NULL) { |
179 | fseek(fd, 0, SEEK_END); | 179 | fseek(fd, 0, SEEK_END); |
180 | len = ftell(fd); | 180 | len = ftell(fd); |
181 | fseek(fd, 0, SEEK_SET); | 181 | fseek(fd, 0, SEEK_SET); |
@@ -213,7 +213,7 @@ static void load_data() { | |||
213 | 213 | ||
214 | Messenger_save(buf); | 214 | Messenger_save(buf); |
215 | 215 | ||
216 | fd = fopen("data", "w"); | 216 | fd = fopen(path, "w"); |
217 | if(fd == NULL) { | 217 | if(fd == NULL) { |
218 | fprintf(stderr, "fopen() failed.\n"); | 218 | fprintf(stderr, "fopen() failed.\n"); |
219 | 219 | ||
@@ -282,13 +282,36 @@ void prepare_window(WINDOW* w) { | |||
282 | 282 | ||
283 | int main(int argc, char* argv[]) { | 283 | int main(int argc, char* argv[]) { |
284 | int ch; | 284 | int ch; |
285 | int i = 0; | ||
286 | int f_flag = 0; | ||
287 | char *filename = "data"; | ||
285 | ToxWindow* a; | 288 | ToxWindow* a; |
286 | 289 | ||
290 | for(i = 0; i < argc; i++) { | ||
291 | if(argv[i][0] == '-') { | ||
292 | if(argv[i][1] == 'f') { | ||
293 | if(argv[i + 1] != NULL) | ||
294 | filename = argv[i + 1]; | ||
295 | else { | ||
296 | f_flag = -1; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | |||
287 | init_term(); | 302 | init_term(); |
288 | init_tox(); | 303 | init_tox(); |
289 | load_data(); | 304 | load_data(filename); |
290 | init_windows(); | 305 | init_windows(); |
291 | 306 | ||
307 | if(f_flag == -1) { | ||
308 | attron(COLOR_PAIR(3) | A_BOLD); | ||
309 | wprintw(prompt->window, "You passed '-f' without giving an argument!\n" | ||
310 | "defaulting to 'data' for a keyfile...\n"); | ||
311 | attroff(COLOR_PAIR(3) | A_BOLD); | ||
312 | } | ||
313 | |||
314 | |||
292 | while(true) { | 315 | while(true) { |
293 | // Update tox. | 316 | // Update tox. |
294 | do_tox(); | 317 | do_tox(); |