From 3bb78a39a53b65659eee40a1e522e18f0423252e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 25 Aug 2020 14:04:25 +0200 Subject: Factor out convert_int --- libcrystfel/src/utils.c | 15 +++++++++++++++ libcrystfel/src/utils.h | 2 ++ src/gui_backend_local.c | 17 ++--------------- src/gui_backend_slurm.c | 2 ++ 4 files changed, 21 insertions(+), 15 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)) diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index 451ca253..dfa208b6 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -31,6 +31,8 @@ #include #include +#include + #include "gui_project.h" @@ -272,21 +274,6 @@ static void cancel_indexing(void *job_priv) } -static 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; - } -} - - static void n_processes_activate_sig(GtkEntry *entry, gpointer data) { struct local_indexing_opts *opts = data; diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c index cb0cee59..91c687a3 100644 --- a/src/gui_backend_slurm.c +++ b/src/gui_backend_slurm.c @@ -31,6 +31,8 @@ #include #include +#include + #include "gui_project.h" -- cgit v1.2.3