diff options
author | Thomas White <taw@physics.org> | 2024-09-18 16:44:41 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-10-14 10:30:26 +0200 |
commit | 0066866b6e3f7e55c1067131350caa6201e316da (patch) | |
tree | bd333004df59ae434f4d4d296a9bb6ce7bbfd51e /libcrystfel/src/crystfel-mille.c | |
parent | 903f361141511476cd5b53addbae026465e16edd (diff) |
indexamajig: New memory-based data pump
This simplifies the code somewhat, removes some old cruft, and allows
most of the same pump code to be used for Mille data as well as stream
data.
Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/92
Diffstat (limited to 'libcrystfel/src/crystfel-mille.c')
-rw-r--r-- | libcrystfel/src/crystfel-mille.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libcrystfel/src/crystfel-mille.c b/libcrystfel/src/crystfel-mille.c index c2fe2a57..a62bf7b2 100644 --- a/libcrystfel/src/crystfel-mille.c +++ b/libcrystfel/src/crystfel-mille.c @@ -297,7 +297,7 @@ void write_mille(Mille *mille, int n, UnitCell *cell, } -Mille *crystfel_mille_new(const char *outFileName) +static Mille *mille_new() { Mille *m; @@ -311,6 +311,15 @@ Mille *crystfel_mille_new(const char *outFileName) m->have_local = NULL; m->n_local = 0; + return m; +} + + +Mille *crystfel_mille_new(const char *outFileName) +{ + Mille *m = mille_new(); + if ( m == NULL ) return NULL; + m->fh = fopen(outFileName, "wb"); if ( m->fh == NULL ) { ERROR("Failed to open Mille file '%s'\n", outFileName); @@ -318,6 +327,21 @@ Mille *crystfel_mille_new(const char *outFileName) return NULL; } + return m; +} + + +Mille *crystfel_mille_new_fd(int fd) +{ + Mille *m = mille_new(); + if ( m == NULL ) return NULL; + + m->fh = fdopen(fd, "wb"); + if ( m->fh == NULL ) { + ERROR("Failed to open Mille FD %i\n", fd); + cffree(m); + return NULL; + } return m; } |