blob: 11b1bcf7058f78829854ba646e48fdd78fc37b83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
|