diff options
author | Thomas White <taw27@cam.ac.uk> | 2009-03-04 17:05:42 +0000 |
---|---|---|
committer | Thomas White <taw27@cam.ac.uk> | 2009-03-04 17:05:42 +0000 |
commit | 244303f588f9c4797836e062d0576d85a027ab2a (patch) | |
tree | 250b936e2d82721759aa89d8f2ce35111b81d7e4 /util.c |
Initial import
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -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; +} |