diff options
author | Thomas White <taw@physics.org> | 2013-02-05 16:21:40 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-02-05 16:21:40 +0100 |
commit | 2ce85a95d86e350b785d206405e97d7317672188 (patch) | |
tree | 5cecce161733acf1a276e5a0b55e5c22f5ffb20d /libcrystfel | |
parent | 29cca07716b48f9e433087f5dbb202165b1897e1 (diff) |
Indexing pipeline - "done"!
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/index.c | 5 | ||||
-rw-r--r-- | libcrystfel/src/index.h | 2 | ||||
-rw-r--r-- | libcrystfel/src/stream.c | 24 | ||||
-rw-r--r-- | libcrystfel/src/stream.h | 2 |
4 files changed, 26 insertions, 7 deletions
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 <stdio.h> #include <string.h> #include <assert.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #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, |