aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-08-16 10:16:34 +0200
committerThomas White <taw@physics.org>2016-08-16 10:28:45 +0200
commit92762e7f596072c4ee73b138853f442ccc3b8243 (patch)
treed9ace79549e7bacd9ee00ec2ec98f4bb1457dc51 /libcrystfel
parent9990ed2bdf0e043b60d8450466404b8f98fa29ad (diff)
Read and write RefList notes to reflection list files
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/reflist-utils.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 82943158..38290847 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -3,11 +3,11 @@
*
* Utilities to complement the core reflist.c
*
- * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2011-2014 Thomas White <taw@physics.org>
+ * 2011-2016 Thomas White <taw@physics.org>
* 2014 Valerio Mariani
*
* This file is part of CrystFEL.
@@ -249,6 +249,10 @@ int write_reflist_2(const char *filename, RefList *list, SymOpList *sym)
write_reflections_to_file(fh, list);
fprintf(fh, REFLECTION_END_MARKER"\n");
+ if ( reflist_get_notes(list) != NULL ) {
+ fprintf(fh, "%s\n", reflist_get_notes(list));
+ }
+
fclose(fh);
return 0;
@@ -338,7 +342,7 @@ RefList *read_reflections_from_file(FILE *fh)
if ( rval == NULL ) continue;
chomp(line);
- if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) return out;
+ if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) break;
if ( major_version >= 2 ) {
@@ -402,8 +406,22 @@ RefList *read_reflections_from_file(FILE *fh)
} while ( rval != NULL );
- /* Got read error of some kind before finding PEAK_LIST_END_MARKER */
- return NULL;
+ if ( strcmp(line, REFLECTION_END_MARKER) != 0 ) {
+ /* Got read error of some kind before finding
+ * PEAK_LIST_END_MARKER */
+ return NULL;
+ }
+
+ /* We are now in the notes region */
+ do {
+ char line[1024];
+ rval = fgets(line, 1023, fh);
+ if ( rval == NULL ) continue;
+ chomp(line);
+ reflist_add_notes(out, line);
+ } while ( rval != NULL );
+
+ return out;
}