summary refs log blame commit diff stats
path: root/doc/c2nim.txt
blob: 4890f38bfa0a67ac7b5381d65ff6073442a86d1e (plain) (tree)
new_log->filename = strdup(filename); new_log->date = now; free(filename); return new_log; } static gboolean _log_roll_needed(struct dated_chat_log *dated_log) { gboolean result = FALSE; GDateTime *now = g_date_time_new_now_local(); if (g_date_time_get_day_of_year(dated_log->date) != g_date_time_get_day_of_year(now)) { result = TRUE; } g_date_time_unref(now); return result; } static void _free_chat_log(struct dated_chat_log *dated_log) { if (dated_log != NULL) { if (dated_log->filename != NULL) { g_free(dated_log->filename); dated_log->filename = NULL; } if (dated_log->date != NULL) { g_date_time_unref(dated_log->date); dated_log->date = NULL; } } dated_log = NULL; } static gboolean _key_equals(void *key1, void *key2) { gchar *str1 = (gchar *) key1; gchar *str2 = (gchar *) key2; return (g_strcmp0(str1, str2) == 0); } static char * _get_log_filename(const char * const other, const char * const login, GDateTime *dt, gboolean create) { gchar *chatlogs_dir = files_get_chatlog_dir(); GString *log_file = g_string_new(chatlogs_dir); g_free(chatlogs_dir); gchar *login_dir = str_replace(login, "@", "_at_"); g_string_append_printf(log_file, "/%s", login_dir); if (create) { create_dir(log_file->str); } free(login_dir); gchar *other_file = str_replace(other, "@", "_at_"); g_string_append_printf(log_file, "/%s", other_file); if (create) { create_dir(log_file->str); } free(other_file); gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log"); g_string_append(log_file, date); char *result = strdup(log_file->str); g_string_free(log_file, TRUE); return result; }