aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-16 12:02:11 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-16 12:02:11 -0500
commit9fa9ac4391c73c58e9cb8e683c6acbc5cae59a5b (patch)
tree283abc6b9b100049d4414000937d1746d6b9cd9b
parentae7be6735ae6ceaffb001cc39d3f833d34cb5255 (diff)
parse-events: Add pevent_filter_remove_event()
Create the function pevent_filter_remove_event() that takes an filter and an event id as its parameters and removes the event from the given filter. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--parse-filter.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/parse-filter.c b/parse-filter.c
index aab642c..d2f5c3b 100644
--- a/parse-filter.c
+++ b/parse-filter.c
@@ -768,6 +768,46 @@ static void free_filter_type(struct filter_type *filter_type)
768 free_arg(filter_type->filter); 768 free_arg(filter_type->filter);
769} 769}
770 770
771/**
772 * pevent_filter_remove_event - remove a filter for an event
773 * @filter: the event filter to remove from
774 * @event_id: the event to remove a filter for
775 *
776 * Removes the filter saved for an event defined by @event_id
777 * from the @filter.
778 *
779 * Returns 1: if an event was removed
780 * 0: if the event was not found
781 */
782int pevent_filter_remove_event(struct event_filter *filter,
783 int event_id)
784{
785 struct filter_type *filter_type;
786 unsigned long len;
787
788 if (!filter->filters)
789 return 0;
790
791 filter_type = find_filter_type(filter, event_id);
792
793 if (!filter_type)
794 return 0;
795
796 free_filter_type(filter_type);
797
798 /* The filter_type points into the event_filters array */
799 len = (unsigned long)(filter->event_filters + filter->filters) -
800 (unsigned long)(filter_type + 1);
801
802 memmove(filter_type, filter_type + 1, len);
803 filter->filters--;
804
805 memset(&filter->event_filters[filter->filters], 0,
806 sizeof(*filter_type));
807
808 return 1;
809}
810
771void pevent_filter_free(struct event_filter *filter) 811void pevent_filter_free(struct event_filter *filter)
772{ 812{
773 int i; 813 int i;