aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/reflist-utils.c
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/src/reflist-utils.c
parent92762e7f596072c4ee73b138853f442ccc3b8243 (diff)
Add reflist_add_command_and_version()
Diffstat (limited to 'libcrystfel/src/reflist-utils.c')
-rw-r--r--libcrystfel/src/reflist-utils.c41
1 files changed, 41 insertions, 0 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);
+}