Merge pull request #305 from CharmlessCoin/toxic

Toxic -f Flag
This commit is contained in:
irungentoo 2013-08-03 13:31:46 -07:00
commit 0c3cd5d7fb

View File

@ -170,12 +170,12 @@ static void do_tox() {
doMessenger(); doMessenger();
} }
static void load_data() { static void load_data(char *path) {
FILE* fd; FILE* fd;
size_t len; size_t len;
uint8_t* buf; uint8_t* buf;
if((fd = fopen("data", "r")) != NULL) { if((fd = fopen(path, "r")) != NULL) {
fseek(fd, 0, SEEK_END); fseek(fd, 0, SEEK_END);
len = ftell(fd); len = ftell(fd);
fseek(fd, 0, SEEK_SET); fseek(fd, 0, SEEK_SET);
@ -213,7 +213,7 @@ static void load_data() {
Messenger_save(buf); Messenger_save(buf);
fd = fopen("data", "w"); fd = fopen(path, "w");
if(fd == NULL) { if(fd == NULL) {
fprintf(stderr, "fopen() failed.\n"); fprintf(stderr, "fopen() failed.\n");
@ -282,13 +282,36 @@ void prepare_window(WINDOW* w) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int ch; int ch;
int i = 0;
int f_flag = 0;
char *filename = "data";
ToxWindow* a; ToxWindow* a;
for(i = 0; i < argc; i++) {
if(argv[i][0] == '-') {
if(argv[i][1] == 'f') {
if(argv[i + 1] != NULL)
filename = argv[i + 1];
else {
f_flag = -1;
}
}
}
}
init_term(); init_term();
init_tox(); init_tox();
load_data(); load_data(filename);
init_windows(); init_windows();
if(f_flag == -1) {
attron(COLOR_PAIR(3) | A_BOLD);
wprintw(prompt->window, "You passed '-f' without giving an argument!\n"
"defaulting to 'data' for a keyfile...\n");
attroff(COLOR_PAIR(3) | A_BOLD);
}
while(true) { while(true) {
// Update tox. // Update tox.
do_tox(); do_tox();