aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-08-16 10:24:57 +0200
committerThomas White <taw@physics.org>2016-08-16 10:28:45 +0200
commita7f52bf15d5d44b45f8dba7ab28038c5f9dee372 (patch)
tree4ae7a96bf5821dc19bb50ae13e2449ce714a25fd /libcrystfel
parent92762e7f596072c4ee73b138853f442ccc3b8243 (diff)
Add reflist_add_command_and_version()
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/reflist-utils.c41
-rw-r--r--libcrystfel/src/reflist-utils.h7
2 files changed, 46 insertions, 2 deletions
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 38290847..4621f4f4 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -40,6 +40,7 @@
#include "utils.h"
#include "reflist-utils.h"
#include "symmetry.h"
+#include "version.h"
/**
@@ -627,3 +628,43 @@ RefList *copy_reflist(RefList *list)
return new;
}
+
+
+static char *full_command_line(int argc, char *argv[])
+{
+ int i;
+ size_t len = 0;
+ char *cl;
+
+ if ( argc == 0 ) return strdup("");
+ for ( i=0; i<argc; i++ ) {
+ len += strlen(argv[i]) + 1;
+ }
+
+ cl = malloc(len);
+ if ( cl == NULL ) return strdup("");
+
+ cl[0] = '\0';
+ for ( i=0; i<argc; i++ ) {
+ if ( i > 0 ) strcat(cl, " ");
+ strcat(cl, argv[i]);
+ }
+
+ return cl;
+}
+
+
+void reflist_add_command_and_version(RefList *list, int argc, char *argv[])
+{
+ char *tmp;
+ char vers[128];
+
+ vers[0] = '\0';
+ strcat(vers, "Generated by CrystFEL ");
+ strncat(vers, CRYSTFEL_VERSIONSTRING, 100);
+ reflist_add_notes(list, vers);
+
+ tmp = full_command_line(argc, argv);
+ reflist_add_notes(list, tmp);
+ free(tmp);
+}
diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h
index cd0f657d..d86eb398 100644
--- a/libcrystfel/src/reflist-utils.h
+++ b/libcrystfel/src/reflist-utils.h
@@ -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.
@@ -71,6 +71,9 @@ extern RefList *res_cutoff(RefList *list, UnitCell *cell,
extern RefList *copy_reflist(RefList *list);
+extern void reflist_add_command_and_version(RefList *list,
+ int argcv, char *argv[]);
+
#ifdef __cplusplus
}
#endif