From 2ce85a95d86e350b785d206405e97d7317672188 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 5 Feb 2013 16:21:40 +0100 Subject: Indexing pipeline - "done"! --- libcrystfel/src/index.c | 5 +---- libcrystfel/src/index.h | 2 +- libcrystfel/src/stream.c | 24 ++++++++++++++++++++++-- libcrystfel/src/stream.h | 2 ++ 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 2370e26e..821be39a 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -241,7 +241,7 @@ static IndexingMethod set_axes(IndexingMethod a) } -IndexingMethod *build_indexer_list(const char *str, int *need_cell) +IndexingMethod *build_indexer_list(const char *str) { int n, i; char **methods; @@ -249,9 +249,6 @@ IndexingMethod *build_indexer_list(const char *str, int *need_cell) int tmp; int nmeth = 0; - if ( need_cell == NULL ) need_cell = &tmp; - *need_cell = 0; - n = assplode(str, ",-", &methods, ASSPLODE_NONE); list = malloc((n+1)*sizeof(IndexingMethod)); diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index e0dcb8e0..093e4ad6 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -82,7 +82,7 @@ typedef enum { **/ typedef void *IndexingPrivate; -extern IndexingMethod *build_indexer_list(const char *str, int *need_cell); +extern IndexingMethod *build_indexer_list(const char *str); extern IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, const char *filename, diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 31fb8527..113dc359 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -38,6 +38,9 @@ #include #include #include +#include +#include +#include #include "cell.h" #include "utils.h" @@ -236,6 +239,8 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, } fprintf(st->fh, CHUNK_END_MARKER"\n\n"); + + fflush(st->fh); } @@ -497,14 +502,14 @@ Stream *open_stream_for_read(const char *filename) } -Stream *open_stream_for_write(const char *filename) +Stream *open_stream_fd_for_write(int fd) { Stream *st; st = malloc(sizeof(struct _stream)); if ( st == NULL ) return NULL; - st->fh = fopen(filename, "w"); + st->fh = fdopen(fd, "w"); if ( st->fh == NULL ) { free(st); return NULL; @@ -520,6 +525,21 @@ Stream *open_stream_for_write(const char *filename) } + +Stream *open_stream_for_write(const char *filename) +{ + int fd; + + fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR); + if ( fd == -1 ) { + ERROR("Failed to open stream.\n"); + return NULL; + } + + return open_stream_fd_for_write(fd); +} + + void close_stream(Stream *st) { fclose(st->fh); diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h index 9340ca0d..4d561cd2 100644 --- a/libcrystfel/src/stream.h +++ b/libcrystfel/src/stream.h @@ -42,6 +42,8 @@ typedef struct _stream Stream; extern Stream *open_stream_for_read(const char *filename); extern Stream *open_stream_for_write(const char *filename); +extern Stream *open_stream_fd_for_write(int fd); + extern void close_stream(Stream *st); extern void write_chunk(Stream *st, struct image *image, struct hdfile *hdfile, -- cgit v1.2.3