diff options
author | Alexander Færøy <ahf@irssi.org> | 2009-02-07 23:03:24 +0000 |
---|---|---|
committer | ahf <ahf@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2009-02-07 23:03:24 +0000 |
commit | 32e01a5a06e35c98c478413fb6c86818dd930ff3 (patch) | |
tree | 3356ca844164a8fc9b61e6f349e07bd26f4cb37d | |
parent | b12bd857a5d5e7561463a7eca76d07925c70a11b (diff) | |
download | irssi-32e01a5a06e35c98c478413fb6c86818dd930ff3.zip |
Add strarray_find_dest(). Useful for checking whether a server_tag/target or target is found in a vector of strings.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5002 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-common/core/fe-common-core.c | 17 | ||||
-rw-r--r-- | src/fe-common/core/fe-common-core.h | 4 | ||||
-rw-r--r-- | src/fe-common/core/window-activity.c | 11 |
3 files changed, 23 insertions, 9 deletions
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index 88841f37..2b88b946 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -463,3 +463,20 @@ void fe_common_core_finish_init(void) autorun_startup(); autoconnect_servers(); } + +gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest) +{ + g_return_val_if_fail(array != NULL, FALSE); + + if (strarray_find(array, dest->target) != -1) + return TRUE; + + if (dest->server_tag != NULL) { + char *tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target); + int ret = strarray_find(array, tagtarget); + g_free(tagtarget); + if (ret != -1) + return TRUE; + } + return FALSE; +} diff --git a/src/fe-common/core/fe-common-core.h b/src/fe-common/core/fe-common-core.h index 7f3078de..88b2e94b 100644 --- a/src/fe-common/core/fe-common-core.h +++ b/src/fe-common/core/fe-common-core.h @@ -6,4 +6,8 @@ void fe_common_core_init(void); void fe_common_core_deinit(void); void fe_common_core_finish_init(void); +/* Returns TRUE if "dest->target" or "dest->server_tag/dest->target" is found in + * array, otherwise FALSE. */ +gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest); + #endif diff --git a/src/fe-common/core/window-activity.c b/src/fe-common/core/window-activity.c index 4c3fea78..3be30ae7 100644 --- a/src/fe-common/core/window-activity.c +++ b/src/fe-common/core/window-activity.c @@ -31,6 +31,7 @@ #include "nicklist.h" #include "hilight-text.h" #include "formats.h" +#include "fe-common-core.h" static char **hide_targets; static int hide_level, msg_level, hilight_level; @@ -86,16 +87,8 @@ static void sig_hilight_text(TEXT_DEST_REC *dest, const char *msg) if (hide_targets != NULL && (dest->level & MSGLEVEL_HILIGHT) == 0 && dest->target != NULL) { /* check for both target and tag/target */ - if (strarray_find(hide_targets, dest->target) != -1) + if (strarray_find_dest(hide_targets, dest)) return; - - if (dest->server_tag != NULL) { - char *tagtarget = g_strdup_printf("%s/%s", dest->server_tag, dest->target); - int ret = strarray_find(hide_targets, tagtarget); - g_free(tagtarget); - if (ret != -1) - return; - } } if (dest->target != NULL) { |