aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-04-25 17:08:38 +0200
committerThomas White <taw@physics.org>2018-04-25 17:09:29 +0200
commit56df3b6d76247b41de02bcd02c0c46d09eaeee0b (patch)
treeca6c4cdbea1ef4b472ab6708edad73c8101795bc
parentf0336b8dfa3682408ae2a92141a0899f7ca20547 (diff)
ambigator: Add own audit information to stream
-rw-r--r--src/ambigator.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/ambigator.c b/src/ambigator.c
index 3df66f3b..bf733c24 100644
--- a/src/ambigator.c
+++ b/src/ambigator.c
@@ -675,7 +675,8 @@ static void reindex_reflections(FILE *fh, FILE *ofh, int assignment,
/* This is nasty, but means the output includes absolutely everything in the
* input, even stuff ignored by read_chunk() */
static void write_reindexed_stream(const char *infile, const char *outfile,
- int *assignments, SymOpList *amb)
+ int *assignments, SymOpList *amb,
+ int argc, char *argv[])
{
FILE *fh;
FILE *ofh;
@@ -684,6 +685,7 @@ static void write_reindexed_stream(const char *infile, const char *outfile,
int have_as = 0;
int have_bs = 0;
int have_cs = 0;
+ int done = 0;
fh = fopen(infile, "r");
if ( fh == NULL ) {
@@ -697,6 +699,38 @@ static void write_reindexed_stream(const char *infile, const char *outfile,
return;
}
+ /* Copy the header */
+ do {
+
+ char line[1024];
+ char *rval;
+
+ rval = fgets(line, 1023, fh);
+ if ( rval == NULL ) {
+ ERROR("Failed to read stream audit info.\n");
+ return;
+ }
+
+ if ( strncmp(line, "-----", 5) == 0 ) {
+
+ done = 1;
+
+ /* Add our own header */
+ fprintf(ofh, "Re-indexed by ambigator "CRYSTFEL_VERSIONSTRING"\n");
+ if ( argc > 0 ) {
+ for ( i=0; i<argc; i++ ) {
+ if ( i > 0 ) fprintf(ofh, " ");
+ fprintf(ofh, "%s", argv[i]);
+ }
+ fprintf(ofh, "\n");
+ }
+
+ }
+
+ fputs(line, ofh);
+
+ } while ( !done );
+
i = 0;
do {
@@ -1360,7 +1394,8 @@ int main(int argc, char *argv[])
n_dif);
if ( (outfile != NULL) && (amb != NULL) ) {
- write_reindexed_stream(infile, outfile, assignments, amb);
+ write_reindexed_stream(infile, outfile, assignments, amb,
+ argc, argv);
} else if ( outfile != NULL ) {
ERROR("Can only write stream with known ambiguity operator.\n");
ERROR("Try again with -w or --operator.\n");