aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-17 12:51:26 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit66dcb61b36bfc1cd6694b4d282034d14c9b830a1 (patch)
treee093445cc53e2b6f4880f7e58256c3a5ec023a98 /libcrystfel/src
parent7c846266ffc0d974b2facad031817534f19a99f3 (diff)
Check that paths for all panels have the same number of placeholders
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/datatemplate.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 5d87aa3b..b48fd7ab 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -711,6 +711,22 @@ static void parse_toplevel(DataTemplate *dt,
}
+static int num_path_placeholders(const char *str)
+{
+ size_t i, len;
+ int n_pl;
+
+ if ( str == NULL ) return 0;
+
+ len = strlen(str);
+ for ( i=0; i<len; i++ ) {
+ if ( str[i] == '%' ) n_pl++;
+ }
+
+ return n_pl;
+}
+
+
DataTemplate *data_template_new_from_string(const char *string_in)
{
DataTemplate *dt;
@@ -726,6 +742,9 @@ DataTemplate *data_template_new_from_string(const char *string_in)
char *string;
char *string_orig;
size_t len;
+ int num_data_pl;
+ int num_mask_pl;
+ int num_satmap_pl;
dt = calloc(1, sizeof(DataTemplate));
if ( dt == NULL ) return NULL;
@@ -892,6 +911,10 @@ DataTemplate *data_template_new_from_string(const char *string_in)
return NULL;
}
+ num_data_pl = num_path_placeholders(dt->panels[i].data);
+ num_mask_pl = num_path_placeholders(dt->panels[i].mask);
+ num_satmap_pl = num_path_placeholders(dt->panels[i].satmap);
+
for ( i=0; i<dt->n_panels; i++ ) {
struct panel_template *p = &dt->panels[i];
@@ -963,6 +986,24 @@ DataTemplate *data_template_new_from_string(const char *string_in)
reject = 1;
}
+ if ( num_path_placeholders(p->data) != num_data_pl ) {
+ ERROR("Data locations for all panels must "
+ "have the same number of placeholders\n");
+ reject = 1;
+ }
+
+ if ( num_path_placeholders(p->mask) != num_mask_pl ) {
+ ERROR("Mask locations for all panels must "
+ "have the same number of placeholders\n");
+ reject = 1;
+ }
+
+ if ( num_path_placeholders(p->satmap) != num_satmap_pl ) {
+ ERROR("Satmap locations for all panels must "
+ "have the same number of placeholders\n");
+ reject = 1;
+ }
+
/* The default rail direction */
if ( isnan(p->rail_x) ) {
p->rail_x = 0.0;