1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-03 19:27:45 +02: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); print_help(ctx);
else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) { else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit") || !strcmp(cmd, "/q")) {
endwin(); exit_toxic(m);
store_data(m, DATA_FILE);
free(DATA_FILE);
tox_kill(m);
exit(0);
} }
else if (!strncmp(cmd, "/me ", strlen("/me "))) { 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[]) int main(int argc, char *argv[])
{ {
char *user_config_dir = get_user_config_dir(); char *user_config_dir = get_user_config_dir();
@ -441,8 +456,6 @@ int main(int argc, char *argv[])
draw_active_window(m); draw_active_window(m);
} }
tox_kill(m); exit_toxic(m);
free(DATA_FILE);
free(SRVLIST_FILE);
return 0; 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) void cmd_quit(ToxWindow *self, Tox *m, int argc, char **argv)
{ {
endwin(); exit_toxic(m);
store_data(m, DATA_FILE);
free(DATA_FILE);
tox_kill(m);
exit(EXIT_SUCCESS);
} }
void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv) void cmd_help(ToxWindow *self, Tox *m, int argc, char **argv)