aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/utils.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-03-20 14:13:17 +0100
committerThomas White <taw@physics.org>2020-07-29 18:42:57 +0200
commit926267d69531e5d1f936231f4e01971e7f31b8e9 (patch)
treee0c51830aba2b596b6f73d42ace309ce50f75b32 /libcrystfel/src/utils.c
parent5543f048ba45e07238cf5b16bc778305a7db2be1 (diff)
Factorise filename_extension()
Diffstat (limited to 'libcrystfel/src/utils.c')
-rw-r--r--libcrystfel/src/utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c
index 1da0dfca..1e225778 100644
--- a/libcrystfel/src/utils.c
+++ b/libcrystfel/src/utils.c
@@ -612,6 +612,29 @@ void strip_extension(char *bfn)
}
+const char *filename_extension(const char *fn, const char **pext2)
+{
+ const char *ext = NULL;
+ const char *ext2 = NULL;
+ size_t r = strlen(fn)-1;
+
+ while ( r > 0 ) {
+ if ( fn[r] == '.' ) {
+ if ( ext != NULL ) {
+ ext2 = fn+r;
+ break;
+ } else {
+ ext = fn+r;
+ }
+ }
+ r--;
+ }
+
+ if ( pext2 != NULL ) *pext2 = ext2;
+ return ext;
+}
+
+
/* Force the linker to bring in CBLAS to make GSL happy */
void utils_fudge_gslcblas()
{