static void do_toxic(Tox *m, ToxWindow *prompt) { pthread_mutex_lock(&Winthread.lock); do_connection(m, prompt); do_file_senders(m); tox_do(m); /* main tox-core loop */ pthread_mutex_unlock(&Winthread.lock); }
static void do_toxic(Tox *m, ToxWindow *prompt) { do_connection(m, prompt); draw_active_window(m); do_file_senders(m); /* main tox-core loop */ tox_do(m); }
int main(int argc, char *argv[]) { char *user_config_dir = get_user_config_dir(); int config_err = 0; f_loadfromfile = 1; int f_flag = 0; int i = 0; for (i = 0; i < argc; ++i) { if (argv[i] == NULL) break; else if (argv[i][0] == '-') { if (argv[i][1] == 'f') { if (argv[i + 1] != NULL) DATA_FILE = strdup(argv[i + 1]); else f_flag = -1; } else if (argv[i][1] == 'n') { f_loadfromfile = 0; } } } config_err = create_user_config_dir(user_config_dir); if (DATA_FILE == NULL ) { if (config_err) { DATA_FILE = strdup("data"); } else { DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); if (DATA_FILE != NULL) { strcpy(DATA_FILE, user_config_dir); strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, "data"); } else { endwin(); fprintf(stderr, "malloc() failed. Aborting...\n"); exit(EXIT_FAILURE); } } } if (config_err) { SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers"); } else { SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); if (SRVLIST_FILE != NULL) { strcpy(SRVLIST_FILE, user_config_dir); strcat(SRVLIST_FILE, CONFIGDIR); strcat(SRVLIST_FILE, "DHTservers"); } else { endwin(); fprintf(stderr, "malloc() failed. Aborting...\n"); exit(EXIT_FAILURE); } } free(user_config_dir); init_term(); Tox *m = init_tox(); if (m == NULL) { endwin(); fprintf(stderr, "Failed to initialize network. Aborting...\n"); exit(EXIT_FAILURE); } prompt = init_windows(m); if (f_loadfromfile) load_data(m, DATA_FILE); if (f_flag == -1) { attron(COLOR_PAIR(RED) | A_BOLD); wprintw(prompt->window, "You passed '-f' without giving an argument.\n" "defaulting to 'data' for a keyfile...\n"); attroff(COLOR_PAIR(RED) | A_BOLD); } if (config_err) { attron(COLOR_PAIR(RED) | A_BOLD); wprintw(prompt->window, "Unable to determine configuration directory.\n" "defaulting to 'data' for a keyfile...\n"); attroff(COLOR_PAIR(RED) | A_BOLD); } prompt_init_statusbar(prompt, m); while (true) { do_tox(m, prompt); do_file_senders(m); draw_active_window(m); } exit_toxic(m); return 0; }