aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-07-13 03:02:49 +0200
committerMattias Andrée <maandree@kth.se>2016-07-13 03:02:49 +0200
commit9e04abcf0dae8b35698782c7ccdf20986b313099 (patch)
tree38255403947bd12d855298a87447c00ea3c2f676
parentImplement Lifespan: remove (diff)
downloadcoopgammad-9e04abcf0dae8b35698782c7ccdf20986b313099.tar.gz
coopgammad-9e04abcf0dae8b35698782c7ccdf20986b313099.tar.bz2
coopgammad-9e04abcf0dae8b35698782c7ccdf20986b313099.tar.xz
Implement filter updating
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--src/output.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/output.c b/src/output.c
index 9445e5d..f3259e0 100644
--- a/src/output.c
+++ b/src/output.c
@@ -299,9 +299,22 @@ ssize_t add_filter(struct output* out, struct filter* filter)
size_t i, n = out->table_size;
int r = -1;
+ /* Remove? */
if (filter->lifespan == LIFESPAN_REMOVE)
return remove_filter(out, filter);
+ /* Update? */
+ for (i = 0; i < n; i++)
+ if (!strcmp(filter->class, out->table_filters[i].class))
+ break;
+ if (i != n)
+ {
+ filter_destroy(out->table_filters + i);
+ out->table_filters[i] = *filter;
+ return (ssize_t)i;
+ }
+
+ /* Add! */
for (i = 0; i < n; i++)
if (filter->priority > out->table_filters[i].priority)
break;