diff --git a/src/log.c b/src/log.c index 77b76e7..40a36c0 100644 --- a/src/log.c +++ b/src/log.c @@ -100,10 +100,10 @@ void write_to_log(uint8_t *msg, uint8_t *name, struct chatlog *log, bool event) uint64_t curtime = (uint64_t) time(NULL); - if (timed_out(log->lastflush, curtime, LOG_FLUSH_LIMIT)) + if (timed_out(log->lastwrite, curtime, LOG_FLUSH_LIMIT)) fflush(log->file); - log->lastflush = curtime; + log->lastwrite = curtime; } diff --git a/src/main.c b/src/main.c index 5b71c3a..849408c 100644 --- a/src/main.c +++ b/src/main.c @@ -64,8 +64,6 @@ /* Export for use in Callbacks */ char *DATA_FILE = NULL; -char *SRVLIST_FILE = NULL; - ToxWindow *prompt = NULL; static int f_loadfromfile; /* 1 if we want to load from/save the data file, 0 otherwise */ @@ -167,14 +165,12 @@ static char nodes[MAXNODES][NODELEN]; static uint16_t ports[MAXNODES]; static uint8_t keys[MAXNODES][TOX_CLIENT_ID_SIZE]; -static int nodelist_load(const char *filename) +static int nodelist_load(char *filename) { - FILE *fp = NULL; - if (!filename) return 1; - fp = fopen(filename, "r"); + FILE *fp = fopen(filename, "r"); if (fp == NULL) return 1; @@ -239,19 +235,10 @@ int init_connection(Tox *m) */ if (!srvlist_loaded) { srvlist_loaded = true; - int res = nodelist_load(SRVLIST_FILE); + int res = nodelist_load(PACKAGE_DATADIR "/DHTnodes"); - if (res) { - /* Fallback on the provided DHTServers in /usr/share or /usr/local/share, - so new starts of toxic will connect to the DHT. */ - res = nodelist_load(PACKAGE_DATADIR "/DHTnodes"); - - if (res) - return res; - } - - if (!linecnt) - return 2; + if (linecnt < 1) + return res; res = 3; int i; @@ -477,7 +464,6 @@ void exit_toxic(Tox *m) kill_all_windows(); free(DATA_FILE); - free(SRVLIST_FILE); free(prompt->stb); log_disable(prompt->promptbuf->log); free(prompt->promptbuf->log); @@ -536,7 +522,7 @@ int main(int argc, char *argv[]) if (DATA_FILE != NULL) { strcpy(DATA_FILE, user_config_dir); strcat(DATA_FILE, CONFIGDIR); - strcat(DATA_FILE, "data"); + strcat(DATA_FILE, "data"); } else { endwin(); fprintf(stderr, "malloc() failed. Aborting...\n"); @@ -545,17 +531,6 @@ int main(int argc, char *argv[]) } } - SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTnodes") + 1); - if (SRVLIST_FILE != NULL) { - strcpy(SRVLIST_FILE, user_config_dir); - strcat(SRVLIST_FILE, CONFIGDIR); - strcat(SRVLIST_FILE, "DHTnodes"); - } else { - endwin(); - fprintf(stderr, "malloc() failed. Aborting...\n"); - exit(EXIT_FAILURE); - } - free(user_config_dir); init_term(); diff --git a/src/toxic_windows.h b/src/toxic_windows.h index 1e01527..9f87880 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -142,7 +142,7 @@ struct StatusBar { struct chatlog { FILE *file; - uint64_t lastflush; + uint64_t lastwrite; int pos; bool log_on; /* specific to current chat window */ };