aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-16 16:25:20 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit9d958b9db93e2009f403ad81fc7846036914f8fe (patch)
treebe210d70f13488710a445bf7a398167239d13fa2 /src
parent43dca1cd95610a2c736e53160ecdbfb04f7a2c1e (diff)
Remove events.c, part 2
New event parsing, done at the last minute in image-hdf5.c
Diffstat (limited to 'src')
-rw-r--r--src/crystfel_gui.c12
-rw-r--r--src/im-sandbox.c57
-rw-r--r--src/partialator.c2
3 files changed, 39 insertions, 32 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 87f57e7c..77a064f3 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -138,19 +138,21 @@ static void add_all_events(struct crystfelproject *proj,
const char *filename,
const DataTemplate *dtempl)
{
- struct event_list *events;
+ char **events;
int i;
+ int n_events;
- events = image_expand_frames(dtempl, filename);
+ events = image_expand_frames(dtempl, filename, &n_events);
if ( events == NULL ) {
ERROR("Couldn't expand event list\n");
return;
}
- for ( i=0; i<events->num_events; i++ ) {
- add_file_to_project(proj, filename,
- get_event_string(events->events[i]));
+ for ( i=0; i<n_events; i++ ) {
+ add_file_to_project(proj, filename, events[i]);
+ free(events[i]);
}
+ free(events);
}
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 753ceb82..d03a1f87 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -112,7 +112,8 @@ struct get_pattern_ctx
const DataTemplate *dtempl;
const char *prefix;
char *filename;
- struct event_list *events; /* FIXME: Deprecated */
+ char **events;
+ int n_events;
int event_index;
};
@@ -184,11 +185,12 @@ static void check_hung_workers(struct sandbox *sb)
}
-static char *read_prefixed_filename(struct get_pattern_ctx *gpctx, char **event)
+static char *read_prefixed_filename(struct get_pattern_ctx *gpctx,
+ char **event)
{
char* line;
- if ( event != NULL ) *event = NULL;
+ *event = NULL;
line = malloc(1024);
if ( line == NULL ) return NULL;
@@ -206,20 +208,18 @@ static char *read_prefixed_filename(struct get_pattern_ctx *gpctx, char **event)
} while ( line[0] == '\0' );
- /* Chop off event ID if requested */
- if ( event != NULL ) {
- size_t n = strlen(line);
- while ( line[n] != ' ' && n > 2 ) n--;
- if ( n != 2 ) {
- /* Event descriptor must contain "//".
- * If it doesn't, assume the filename just contains a
- * space. */
- if ( strstr(&line[n], "//") != NULL ) {
- line[n] = '\0';
- *event = strdup(&line[n+1]);
- }
- } /* else no spaces at all */
- }
+ /* Chop off event ID */
+ size_t n = strlen(line);
+ while ( line[n] != ' ' && n > 2 ) n--;
+ if ( n != 2 ) {
+ /* Event descriptor must contain "//".
+ * If it doesn't, assume the filename just contains a
+ * space. */
+ if ( strstr(&line[n], "//") != NULL ) {
+ line[n] = '\0';
+ *event = strdup(&line[n+1]);
+ }
+ } /* else no spaces at all */
if ( gpctx->use_basename ) {
char *tmp;
@@ -256,10 +256,10 @@ static int get_pattern(struct get_pattern_ctx *gpctx,
/* Is an event available already? */
if ( (gpctx->events != NULL)
- && (gpctx->event_index < gpctx->events->num_events) )
+ && (gpctx->event_index < gpctx->n_events) )
{
- *pfilename = strdup(gpctx->filename);
- *pevent = get_event_string(gpctx->events->events[gpctx->event_index++]);
+ *pfilename = gpctx->filename;
+ *pevent = gpctx->events[gpctx->event_index++];
return 1;
}
@@ -272,13 +272,17 @@ static int get_pattern(struct get_pattern_ctx *gpctx,
/* Does the line from the input file contain an event ID?
* If so, just send it straight back. */
if ( evstr != NULL ) {
- *pfilename = strdup(filename);
- *pevent = strdup(evstr);
+ *pfilename = filename;
+ *pevent = evstr;
return 1;
}
- free_event_list(gpctx->events);
- gpctx->events = image_expand_frames(gpctx->dtempl, filename);
+ /* We got a filename, but no event. Attempt to expand... */
+ free(gpctx->events); /* Free the old list.
+ * NB The actual strings were freed
+ * by fill_queue */
+ gpctx->events = image_expand_frames(gpctx->dtempl, filename,
+ &gpctx->n_events);
if ( gpctx->events == NULL ) {
ERROR("Failed to get event list.\n");
return 0;
@@ -289,8 +293,8 @@ static int get_pattern(struct get_pattern_ctx *gpctx,
gpctx->filename = filename;
gpctx->event_index = 0;
- *pfilename = strdup(gpctx->filename);
- *pevent = get_event_string(gpctx->events->events[gpctx->event_index++]);
+ *pfilename = gpctx->filename;
+ *pevent = gpctx->events[gpctx->event_index++];
return 1;
}
@@ -788,6 +792,7 @@ static int fill_queue(struct get_pattern_ctx *gpctx, struct sandbox *sb)
snprintf(sb->shared->queue[sb->shared->n_events++], MAX_EV_LEN,
"%s %s %i", filename, evstr, sb->serial++);
sem_post(sb->queue_sem);
+ free(evstr);
}
return 0;
diff --git a/src/partialator.c b/src/partialator.c
index 11005555..1126095a 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -484,7 +484,7 @@ static struct custom_split *load_custom_split(const char *filename)
ds = bits[2];
} else {
fn = bits[0];
- evs = get_event_string(NULL);
+ evs = strdup("(none)");
ds = bits[1];
}
free(bits);