1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 16:13:24 +01:00

added exit_toxic function (for real this time)

This commit is contained in:
Jfreegman 2013-09-11 00:12:03 -04:00
parent 40dcfc82d2
commit f004a4ba82
3 changed files with 18 additions and 13 deletions

View File

@ -203,11 +203,7 @@ static void execute(ToxWindow *self, ChatContext *ctx, StatusBar *statusbar, Tox
print_help(ctx);
else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) {
endwin();
store_data(m, DATA_FILE);
free(DATA_FILE);
tox_kill(m);
exit(0);
exit_toxic(m);
}
else if (!strncmp(cmd, "/me ", strlen("/me "))) {

View File

@ -354,6 +354,21 @@ static void load_data(Tox *m, char *path)
}
}
void exit_toxic(Tox *m)
{
store_data(m, DATA_FILE);
if (DATA_FILE != NULL)
free(DATA_FILE);
if (SRVLIST_FILE != NULL)
free(SRVLIST_FILE);
tox_kill(m);
endwin();
exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
char *user_config_dir = get_user_config_dir();
@ -441,8 +456,6 @@ int main(int argc, char *argv[])
draw_active_window(m);
}
tox_kill(m);
free(DATA_FILE);
free(SRVLIST_FILE);
exit_toxic(m);
return 0;
}

View File

@ -292,11 +292,7 @@ void cmd_connect(ToxWindow *self, Tox *m, int argc, char **argv)
void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
{
endwin();
store_data(m, DATA_FILE);
free(DATA_FILE);
tox_kill(m);
exit(EXIT_SUCCESS);
exit_toxic(m);
}
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)