diff options
author | charmlesscoin <charmlesscoin@gmail.com> | 2013-08-03 15:12:02 -0400 |
---|---|---|
committer | charmlesscoin <charmlesscoin@gmail.com> | 2013-08-03 15:12:02 -0400 |
commit | d34e4a3408a176525bedfad87cfc996afbe21b66 (patch) | |
tree | a7da05454469a9dda857dfd7bcffe3f1d6ffbc85 /testing | |
parent | 7b84aaaac8005a6bf2a1243a2fb027f6d9a8cf9d (diff) |
added the -f flag for toxic
Diffstat (limited to 'testing')
-rw-r--r-- | testing/toxic/main.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index 391b0b39..001d3382 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,11 +282,25 @@ 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 | char *filename = "data"; | ||
285 | ToxWindow* a; | 287 | ToxWindow* a; |
286 | 288 | ||
289 | for(i = 0; i < argc; i++) { | ||
290 | if(argv[i][0] == '-') { | ||
291 | if(argv[i][1] == 'f') { | ||
292 | if(argv[i + 1] != NULL) | ||
293 | filename = argv[i + 1]; | ||
294 | else { | ||
295 | fputs("[!] you passed '-f' without giving an argument!\n", stderr); | ||
296 | } | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | |||
287 | init_term(); | 301 | init_term(); |
288 | init_tox(); | 302 | init_tox(); |
289 | load_data(); | 303 | load_data(filename); |
290 | init_windows(); | 304 | init_windows(); |
291 | 305 | ||
292 | while(true) { | 306 | while(true) { |