From 0ef010d21121365ca901881de40d5daf6bf4f07a Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 6 Dec 2005 18:20:59 +0000 Subject: added /upgrade command, added ETA for DCC files --- src/common/history.c | 88 ++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 40 deletions(-) (limited to 'src/common/history.c') diff --git a/src/common/history.c b/src/common/history.c index 4f1113eec..266ab0a06 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -66,55 +66,18 @@ history_hide_password (char *string) } /* - * history_add: add a text/command to history + * history_buffer_add: add a text/command to buffer's history */ void -history_add (void *buffer, char *string) +history_buffer_add (void *buffer, char *string) { t_history *new_history, *ptr_history; - - if ( !history_global - || ( history_global - && ascii_strcasecmp (history_global->text, string) != 0)) - { - /* add history to global history */ - new_history = (t_history *)malloc (sizeof (t_history)); - if (new_history) - { - new_history->text = strdup (string); - if (cfg_log_hide_nickserv_pwd) - history_hide_password (new_history->text); - - if (history_global) - history_global->prev_history = new_history; - else - history_global_last = new_history; - new_history->next_history = history_global; - new_history->prev_history = NULL; - history_global = new_history; - num_history_global++; - - /* remove one command if necessary */ - if ((cfg_history_max_commands > 0) - && (num_history_global > cfg_history_max_commands)) - { - ptr_history = history_global_last->prev_history; - history_global_last->prev_history->next_history = NULL; - if (history_global_last->text) - free (history_global_last->text); - free (history_global_last); - history_global_last = ptr_history; - num_history_global--; - } - } - } if ( !((t_gui_buffer *)(buffer))->history || ( ((t_gui_buffer *)(buffer))->history && ascii_strcasecmp (((t_gui_buffer *)(buffer))->history->text, string) != 0)) { - /* add history to local history */ new_history = (t_history *)malloc (sizeof (t_history)); if (new_history) { @@ -129,7 +92,7 @@ history_add (void *buffer, char *string) new_history->next_history = ((t_gui_buffer *)(buffer))->history; new_history->prev_history = NULL; ((t_gui_buffer *)buffer)->history = new_history; - ((t_gui_buffer *)(buffer))->num_history++; + ((t_gui_buffer *)buffer)->num_history++; /* remove one command if necessary */ if ((cfg_history_max_commands > 0) @@ -147,6 +110,51 @@ history_add (void *buffer, char *string) } } +/* + * history_global_add: add a text/command to buffer's history + */ + +void +history_global_add (char *string) +{ + t_history *new_history, *ptr_history; + + if (!history_global + || (history_global + && ascii_strcasecmp (history_global->text, string) != 0)) + { + new_history = (t_history *)malloc (sizeof (t_history)); + if (new_history) + { + new_history->text = strdup (string); + if (cfg_log_hide_nickserv_pwd) + history_hide_password (new_history->text); + + if (history_global) + history_global->prev_history = new_history; + else + history_global_last = new_history; + new_history->next_history = history_global; + new_history->prev_history = NULL; + history_global = new_history; + num_history_global++; + + /* remove one command if necessary */ + if ((cfg_history_max_commands > 0) + && (num_history_global > cfg_history_max_commands)) + { + ptr_history = history_global_last->prev_history; + history_global_last->prev_history->next_history = NULL; + if (history_global_last->text) + free (history_global_last->text); + free (history_global_last); + history_global_last = ptr_history; + num_history_global--; + } + } + } +} + /* * history_global_free: free global history */ -- cgit v1.2.3