summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorThomas White <taw27@cam.ac.uk>2009-03-04 17:05:42 +0000
committerThomas White <taw27@cam.ac.uk>2009-03-04 17:05:42 +0000
commit244303f588f9c4797836e062d0576d85a027ab2a (patch)
tree250b936e2d82721759aa89d8f2ce35111b81d7e4 /util.c
Initial import
Diffstat (limited to 'util.c')
-rw-r--r--util.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..11b1bcf
--- /dev/null
+++ b/util.c
@@ -0,0 +1,39 @@
+/*
+ * util.c
+ *
+ * Utility stuff
+ *
+ * (c) 2009 Thomas White <taw27@cam.ac.uk>
+ *
+ * Triclinator - solve nasty triclinic unit cells
+ *
+ */
+
+#include <stdio.h>
+
+#include "util.h"
+
+double read_value(const char *text)
+{
+ while ( 1 ) {
+
+ float d;
+ char buf[64];
+
+ printf("%s", text);
+ if ( fgets(buf, 63, stdin) != buf ) {
+ fprintf(stderr, "Error reading from input\n");
+ }
+ if ( sscanf(buf, "%f", &d) != 1 ) {
+ printf("Invalid input, try again.\n");
+ } else {
+ return d;
+ }
+ }
+}
+
+int is_dspacing(MVal val)
+{
+ if ( (val.h2 == 0) && (val.k2 == 0) && (val.l2 == 0) ) return 1;
+ return 0;
+}