diff options
author | James Booth <boothj5@gmail.com> | 2012-10-21 20:02:20 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-21 20:02:20 +0100 |
commit | 6bad38c2d50a033d8e8a19998cb062e01fe1aa72 (patch) | |
tree | 781461a7d79b6fce56f5ee7f0a012e814cf8771f /src/chat_log.c | |
parent | 382e961563eb9e4d31d3ad111a41569b7fa78fa6 (diff) | |
download | profani-tty-6bad38c2d50a033d8e8a19998cb062e01fe1aa72.tar.gz |
Removed trailing whitespace from src and tests
Diffstat (limited to 'src/chat_log.c')
-rw-r--r-- | src/chat_log.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/chat_log.c b/src/chat_log.c index abf52da9..2e53dfc7 100644 --- a/src/chat_log.c +++ b/src/chat_log.c @@ -1,8 +1,8 @@ -/* +/* * chat_log.c * * Copyright (C) 2012 James Booth <boothj5@gmail.com> - * + * * This file is part of Profanity. * * Profanity is free software: you can redistribute it and/or modify @@ -44,25 +44,25 @@ static gboolean _log_roll_needed(struct dated_chat_log *dated_log); static struct dated_chat_log *_create_log(char *other, const char * const login); static void _free_chat_log(struct dated_chat_log *dated_log); static gboolean _key_equals(void *key1, void *key2); -static char * _get_log_filename(const char * const other, const char * const login, +static char * _get_log_filename(const char * const other, const char * const login, GDateTime *dt, gboolean create); void chat_log_init(void) -{ +{ session_started = g_date_time_new_now_local(); log_info("Initialising chat logs"); - logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, g_free, + logs = g_hash_table_new_full(g_str_hash, (GEqualFunc) _key_equals, g_free, (GDestroyNotify)_free_chat_log); } void -chat_log_chat(const gchar * const login, gchar *other, +chat_log_chat(const gchar * const login, gchar *other, const gchar * const msg, chat_log_direction_t direction) { gchar *other_copy = strdup(other); struct dated_chat_log *dated_log = g_hash_table_lookup(logs, other_copy); - + // no log for user if (dated_log == NULL) { dated_log = _create_log(other_copy, login); @@ -94,24 +94,24 @@ chat_log_chat(const gchar * const login, gchar *other, } GSList * -chat_log_get_previous(const gchar * const login, const gchar * const recipient, +chat_log_get_previous(const gchar * const login, const gchar * const recipient, GSList *history) { GTimeZone *tz = g_time_zone_new_local(); - + GDateTime *now = g_date_time_new_now_local(); - GDateTime *log_date = g_date_time_new(tz, + GDateTime *log_date = g_date_time_new(tz, g_date_time_get_year(session_started), - g_date_time_get_month(session_started), + g_date_time_get_month(session_started), g_date_time_get_day_of_month(session_started), g_date_time_get_hour(session_started), g_date_time_get_minute(session_started), g_date_time_get_second(session_started)); - + // get data from all logs from the day the session was started to today while (g_date_time_get_day_of_year(log_date) <= g_date_time_get_day_of_year(now)) { char *filename = _get_log_filename(recipient, login, log_date, FALSE); - + FILE *logp = fopen(filename, "r"); char *line = NULL; size_t read = 0; @@ -136,10 +136,10 @@ chat_log_get_previous(const gchar * const login, const gchar * const recipient, read = 0; length = getline(&line, &read, logp); } - + fclose(logp); } - + free(filename); GDateTime *next = g_date_time_add_days(log_date, 1); g_date_time_unref(log_date); @@ -208,12 +208,12 @@ 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, +_get_log_filename(const char * const other, const char * const login, GDateTime *dt, gboolean create) { GString *log_file = g_string_new(getenv("HOME")); |