aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-25 14:04:25 +0200
committerThomas White <taw@physics.org>2020-08-25 14:04:25 +0200
commit3bb78a39a53b65659eee40a1e522e18f0423252e (patch)
tree1ec5021e75c98d3f19e425b8dcfe6d822fca4852 /libcrystfel
parent262639d5ce246e94aeab96260d6c0d2fa5f9fdc0 (diff)
Factor out convert_int
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/utils.c15
-rw-r--r--libcrystfel/src/utils.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c
index 8391fe95..ef0eb014 100644
--- a/libcrystfel/src/utils.c
+++ b/libcrystfel/src/utils.c
@@ -307,6 +307,21 @@ void ERROR(const char *format, ...)
/* ------------------------------ Useful functions ---------------------------- */
+int convert_int(const char *str, int *pval)
+{
+ int val;
+ char *rval;
+
+ val = strtod(str, &rval);
+ if ( *rval != '\0' ) {
+ return 1;
+ } else {
+ *pval = val;
+ return 0;
+ }
+}
+
+
size_t notrail(char *s)
{
ssize_t i;
diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h
index 51158e8b..95b455a2 100644
--- a/libcrystfel/src/utils.h
+++ b/libcrystfel/src/utils.h
@@ -76,7 +76,9 @@ extern void show_matrix_eqn(gsl_matrix *M, gsl_vector *v);
extern void show_matrix(gsl_matrix *M);
extern gsl_vector *solve_svd(gsl_vector *v, gsl_matrix *M, int *n_filt,
int verbose);
+
extern size_t notrail(char *s);
+extern int convert_int(const char *str, int *pval);
extern void chomp(char *s);
#define CLEAR_BIT(val, bit) (((val) | (bit)) ^ (bit))