From 761026b65852d3ce1af632d2514b939f78170262 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 10 Jun 2020 12:01:35 +0200 Subject: Add data_template_panel_name_to_number and rename data_template_panel_name --- libcrystfel/src/datatemplate.c | 17 +++++++++++++++++ libcrystfel/src/datatemplate.h | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 2593a7f9..7117a62e 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -1303,6 +1303,23 @@ const char *data_template_panel_name(const DataTemplate *dt, int pn) } +int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn) +{ + if ( panel_name == NULL ) return 1; + + for ( i=0; in_panels; i++ ) { + if ( strcmp(panel_name, dt->panels[i].name) == 0 ) { + *pn = i; + return 0; + } + } + + return 1; +} + + void data_template_add_copy_header(DataTemplate *dt, const char *header) { diff --git a/libcrystfel/src/datatemplate.h b/libcrystfel/src/datatemplate.h index 9cb60bf1..a4520ba2 100644 --- a/libcrystfel/src/datatemplate.h +++ b/libcrystfel/src/datatemplate.h @@ -54,8 +54,12 @@ extern "C" { extern DataTemplate *data_template_new_from_file(const char *filename); extern void data_template_free(DataTemplate *dt); -extern const char *data_template_panel_name(const DataTemplate *dt, - int pn); +extern const char *data_template_panel_number_to_name(const DataTemplate *dt, + int pn); + +extern int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn); extern int data_template_file_to_panel_coords(const DataTemplate *dt, float *pfs, float *pss, -- cgit v1.2.3