mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-27 14:13:25 +01:00
create empty config file if none found && make default time 24 hours
This commit is contained in:
parent
5976d33fef
commit
de3a28c6e6
@ -92,7 +92,7 @@ static void update_friend_last_online(int32_t num, uint64_t timestamp)
|
||||
friends[num].last_online.tm = *localtime(×tamp);
|
||||
|
||||
/* if the format changes make sure TIME_STR_SIZE is the correct size */
|
||||
const char *t = user_settings->time == TIME_24 ? "%H:%M" : "%I:%M %p";
|
||||
const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M";
|
||||
strftime(friends[num].last_online.hour_min_str, TIME_STR_SIZE, t,
|
||||
&friends[num].last_online.tm);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool e
|
||||
else
|
||||
snprintf(name_frmt, sizeof(name_frmt), "%s:", name);
|
||||
|
||||
const char *t = user_settings->time == TIME_24 ? "%Y/%m/%d [%H:%M:%S]" : "%Y/%m/%d [%I:%M:%S %p]";
|
||||
const char *t = user_settings->time == TIME_12 ? "%Y/%m/%d [%I:%M:%S %p]" : "%Y/%m/%d [%H:%M:%S]";
|
||||
uint8_t s[MAX_STR_SIZE];
|
||||
strftime(s, MAX_STR_SIZE, t, get_time());
|
||||
fprintf(log->file,"%s %s %s\n", s, name_frmt, msg);
|
||||
|
@ -559,12 +559,12 @@ int main(int argc, char *argv[])
|
||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
if (settings_err == -1) {
|
||||
msg = "Failed to load user settings";
|
||||
line_info_add(prompt, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
sort_friendlist_index();
|
||||
prompt_init_statusbar(prompt, m);
|
||||
|
@ -59,7 +59,7 @@ struct tm *get_time(void)
|
||||
|
||||
void get_time_str(uint8_t *buf)
|
||||
{
|
||||
const char *t = user_settings->time == TIME_24 ? "[%H:%M:%S] " : "[%I:%M:%S %p] ";
|
||||
const char *t = user_settings->time == TIME_12 ? "[%I:%M:%S %p] " : "[%H:%M:%S] ";
|
||||
strftime(buf, TIME_STR_SIZE, t, get_time());
|
||||
}
|
||||
|
||||
|
@ -62,19 +62,21 @@ int settings_load(struct user_settings *s, char *path)
|
||||
{
|
||||
char *user_config_dir = get_user_config_dir();
|
||||
FILE *fp = NULL;
|
||||
char dflt_path[MAX_STR_SIZE];
|
||||
|
||||
if (path) {
|
||||
fp = fopen(path, "r");
|
||||
} else {
|
||||
char dflt_path[MAX_STR_SIZE];
|
||||
snprintf(dflt_path, sizeof(dflt_path), "%s%stoxic.conf", user_config_dir, CONFIGDIR);
|
||||
fp = fopen(dflt_path, "r");
|
||||
}
|
||||
|
||||
free(user_config_dir);
|
||||
|
||||
if (fp == NULL)
|
||||
return -1;
|
||||
if (fp == NULL) {
|
||||
if ((fp = fopen(dflt_path, "w")) == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char line[MAX_STR_SIZE];
|
||||
|
||||
@ -99,5 +101,6 @@ int settings_load(struct user_settings *s, char *path)
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user