diff options
author | Thomas White <taw@physics.org> | 2014-12-14 15:15:14 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-12-14 15:15:26 +0100 |
commit | a365b27b2186dfd7b3e7f9c10dac5144addd290e (patch) | |
tree | 06ad6dab7c09e57f64332a90fae44ec60672227c /libcrystfel | |
parent | 96dba6ec96dc90bd5795b9ca0517c82fa5aad2c6 (diff) |
hdfsee: Select the correct event at the start
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/events.c | 40 | ||||
-rw-r--r-- | libcrystfel/src/events.h | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c index d431a851..93d67a68 100644 --- a/libcrystfel/src/events.c +++ b/libcrystfel/src/events.c @@ -206,6 +206,46 @@ struct event_list *copy_event_list(struct event_list *el) } +static int events_equal(struct event *ev1, struct event *ev2) +{ + int i; + + if ( ev1->path_length != ev2->path_length ) return 0; + if ( ev1->dim_length != ev2->dim_length ) return 0; + + for ( i=0; i<ev1->path_length; i++ ) { + if ( strcmp(ev1->path_entries[i], ev2->path_entries[i]) != 0 ) { + return 0; + } + } + + for ( i=0; i<ev1->dim_length; i++ ) { + if ( ev1->dim_entries[i] != ev2->dim_entries[i] ) return 0; + } + + return 1; +} + + +/** + * find_event: + * @ev: An event structure + * @el: An event list + * + * Returns: the indexing into @el of the event matching @ev, of el->num_events + * if no such event is found. + **/ +int find_event(struct event *ev, struct event_list *el) +{ + int i; + + for ( i=0; i<el->num_events; i++ ) { + if ( events_equal(ev, el->events[i]) ) return i; + } + + return i; +} + void free_event(struct event *ev) { diff --git a/libcrystfel/src/events.h b/libcrystfel/src/events.h index 3dfaf0ec..ff4cf1fb 100644 --- a/libcrystfel/src/events.h +++ b/libcrystfel/src/events.h @@ -92,6 +92,7 @@ extern int append_event_to_event_list(struct event_list *ev_list, int add_non_existing_event_to_event_list(struct event_list *ev_list, struct event *ev); extern struct event_list *copy_event_list(struct event_list *el); +extern int find_event(struct event *ev, struct event_list *el); extern void free_event_list(struct event_list *el); |