aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/events.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-07-06 17:22:11 +0200
committerThomas White <taw@physics.org>2017-07-06 17:24:59 +0200
commit5292f57d4434c7267e8d945871513d742ff42427 (patch)
treed460aa5cef5a501516876850ef243cfc27313d5a /libcrystfel/src/events.c
parent48d4a6b8e82cce81222ec58fdfb488ed79ce0bcf (diff)
parentdc3395900fc3ce0d3961757628ff83ad6456be19 (diff)
Merge branch 'master' into taketwo
Diffstat (limited to 'libcrystfel/src/events.c')
-rw-r--r--libcrystfel/src/events.c57
1 files changed, 24 insertions, 33 deletions
diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c
index 25771a69..8e4eb861 100644
--- a/libcrystfel/src/events.c
+++ b/libcrystfel/src/events.c
@@ -3,10 +3,11 @@
*
* Event properties
*
- * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
+ * 2017 Thomas White
* 2014 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -26,10 +27,8 @@
*
*/
-#define _ISOC99_SOURCE
-#define _GNU_SOURCE
-
#include "events.h"
+#include "utils.h"
#include <hdf5.h>
#include <string.h>
@@ -585,46 +584,38 @@ char *retrieve_full_path(struct event *ev, const char *data)
{
int ei ;
char *return_value;
+ char *pholder;
return_value = strdup(data);
+ pholder = strstr(return_value,"%");
+ ei = 0;
- for ( ei=0; ei<ev->path_length; ei++ ) {
+ while ( pholder != NULL ) {
char *tmp;
- tmp = event_path_placeholder_subst(ev->path_entries[ei],
- return_value);
- free(return_value);
- return_value = tmp;
-
- }
-
- return return_value;
-
-}
-
-
-char *partial_event_substitution(struct event *ev, const char *data)
-{
- int ei ;
- char *return_value;
- char *pholder;
-
- return_value = strdup(data);
- pholder = strstr(return_value,"%");
- ei = 0;
+ /* Check we have enough things to put in the placeholders */
+ if ( ei >= ev->path_length ) {
+ ERROR("Too many placeholders ('%%') in location.\n");
+ return NULL;
+ }
- while( pholder != NULL) {
+ /* Substitute one placeholder */
+ tmp = event_path_placeholder_subst(ev->path_entries[ei++],
+ return_value);
- char *tmp_subst_data;
+ if ( tmp == NULL ) {
+ ERROR("Couldn't substitute placeholder\n");
+ return NULL;
+ }
- tmp_subst_data = event_path_placeholder_subst(ev->path_entries[ei],
- return_value);
+ /* Next time, we will substitute the next part of the path into
+ * the partially substituted string */
free(return_value);
- return_value = strdup(tmp_subst_data);
- free(tmp_subst_data);
+ return_value = tmp;
+
pholder = strstr(return_value, "%");
- ei += 1;
+
}
return return_value;