aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-04-01 17:42:13 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-04-01 17:42:13 +0000
commit63affa283744195cd6bd3de6b9c45b2362b8b1b9 (patch)
tree07485f750f11a1d03db81b43b265fd596a376046
parent3a6347591e01e019d25df3faf274152cb97edb1d (diff)
(Slightly) More advanced detection of input file type
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@21 bf6ca9ba-c028-0410-8290-897cf20841d1
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac2
-rw-r--r--src/cache.c27
-rw-r--r--src/cache.h1
-rw-r--r--src/main.c17
-rw-r--r--src/mrc.c12
-rw-r--r--src/mrc.h1
-rw-r--r--src/qdrp.c10
-rw-r--r--src/qdrp.h1
9 files changed, 80 insertions, 11 deletions
diff --git a/configure b/configure
index e8a7cff..a490489 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.60 for dtr 1.0.4.
+# Generated by GNU Autoconf 2.60 for dtr 1.0.5.
#
# Report bugs to <taw27@cam.ac.uk>.
#
@@ -559,8 +559,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='dtr'
PACKAGE_TARNAME='dtr'
-PACKAGE_VERSION='1.0.4'
-PACKAGE_STRING='dtr 1.0.4'
+PACKAGE_VERSION='1.0.5'
+PACKAGE_STRING='dtr 1.0.5'
PACKAGE_BUGREPORT='taw27@cam.ac.uk'
# Factoring default headers for most tests.
@@ -1195,7 +1195,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dtr 1.0.4 to adapt to many kinds of systems.
+\`configure' configures dtr 1.0.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1261,7 +1261,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dtr 1.0.4:";;
+ short | recursive ) echo "Configuration of dtr 1.0.5:";;
esac
cat <<\_ACEOF
@@ -1346,7 +1346,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dtr configure 1.0.4
+dtr configure 1.0.5
generated by GNU Autoconf 2.60
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1360,7 +1360,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dtr $as_me 1.0.4, which was
+It was created by dtr $as_me 1.0.5, which was
generated by GNU Autoconf 2.60. Invocation command line was
$ $0 $@
@@ -1713,7 +1713,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-VERSION=1.0.4
+VERSION=1.0.5
ac_config_headers="$ac_config_headers config.h"
@@ -7470,7 +7470,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dtr $as_me 1.0.4, which was
+This file was extended by dtr $as_me 1.0.5, which was
generated by GNU Autoconf 2.60. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7523,7 +7523,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-dtr config.status 1.0.4
+dtr config.status 1.0.5
configured by $0, generated by GNU Autoconf 2.60,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 4725129..81dc2c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(dtr, 1.0.4, taw27@cam.ac.uk)
+AC_INIT(dtr, 1.0.5, taw27@cam.ac.uk)
VERSION=AC_PACKAGE_VERSION
AM_CONFIG_HEADER(config.h)
diff --git a/src/cache.c b/src/cache.c
index 61fe4bd..f1998b7 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -90,3 +90,30 @@ int cache_save(const char *filename, ReflectionContext *rctx) {
return 0;
}
+
+unsigned int cache_is_cachefile(const char *filename) {
+
+ FILE *fh;
+ CacheHeader ch;
+ size_t nread;
+
+ fh = fopen(filename, "rb");
+ nread = fread(&ch, sizeof(CacheHeader), 1, fh);
+ fclose(fh);
+
+ if ( nread != 1 ) {
+ return 0;
+ }
+
+ if ( strncmp(ch.top, "DTRCACHE", 8) == 0 ) {
+ return 1;
+ }
+
+ /* Backwards compatability */
+ if ( strncmp(ch.top, "DTR-CACHE", 9) == 0 ) {
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/src/cache.h b/src/cache.h
index 92145fb..fe61c3c 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -25,5 +25,6 @@ typedef struct struct_cacheheader {
extern ReflectionContext *cache_load(const char *filename);
extern int cache_save(const char *filename, ReflectionContext *rctx);
+extern unsigned int cache_is_cachefile(const char *filename);
#endif /*CACHE_H_*/
diff --git a/src/main.c b/src/main.c
index cc302bb..681165a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -175,6 +175,21 @@ int main(int argc, char *argv[]) {
ctx = malloc(sizeof(ControlContext));
type = INPUT_NONE;
+ if ( qdrp_is_qdrprc(filename) ) {
+ printf("QDRP input file detected.\n");
+ ctx->inputfiletype = INPUT_QDRP;
+ } else if ( mrc_is_mrcfile(filename) ) {
+ printf("MRC tomography file detected.\n");
+ ctx->inputfiletype = INPUT_MRC;
+ } else if ( cache_is_cachefile(filename) ) {
+ printf("reflect.cache detected.\n");
+ ctx->inputfiletype = INPUT_CACHE;
+ } else {
+ fprintf(stderr, "Unrecognised input file type\n");
+ return 1;
+ }
+
+ #if 0
if ( strcmp(filename, "qdrp.rc") == 0 ) {
printf("QDRP input file detected.\n");
ctx->inputfiletype = INPUT_QDRP;
@@ -188,6 +203,8 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Unrecognised input file type\n");
return 1;
}
+ #endif
+
ctx->filename = strdup(argv[1]);
ctx->max_d = 0;
diff --git a/src/mrc.c b/src/mrc.c
index f09c79e..b9b6efc 100644
--- a/src/mrc.c
+++ b/src/mrc.c
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <string.h>
#include "mrc.h"
#include "control.h"
@@ -139,3 +140,14 @@ int mrc_read(ControlContext *ctx) {
return 0;
}
+
+unsigned int mrc_is_mrcfile(const char *filename) {
+
+ if ( strcmp(filename+(strlen(filename)-4), ".mrc") == 0 ) {
+ return 1;
+ }
+
+ return 0;
+
+}
+
diff --git a/src/mrc.h b/src/mrc.h
index bdef3f8..ff5f0f7 100644
--- a/src/mrc.h
+++ b/src/mrc.h
@@ -118,5 +118,6 @@ typedef struct struct_mrcextheader {
} MRCExtHeader;
extern int mrc_read(ControlContext *ctx);
+extern unsigned int mrc_is_mrcfile(const char *filename);
#endif /* MRC_H */
diff --git a/src/qdrp.c b/src/qdrp.c
index 42be13f..6579369 100644
--- a/src/qdrp.c
+++ b/src/qdrp.c
@@ -252,3 +252,13 @@ int qdrp_read(ControlContext *ctx) {
return 0; /* Success */
}
+
+unsigned int qdrp_is_qdrprc(const char *filename) {
+
+ if ( strcmp(filename, "qdrp.rc") == 0 ) {
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/src/qdrp.h b/src/qdrp.h
index 3bbfaa0..7987f6d 100644
--- a/src/qdrp.h
+++ b/src/qdrp.h
@@ -18,5 +18,6 @@
#include "control.h"
extern int qdrp_read(ControlContext *ctx);
+extern unsigned int qdrp_is_qdrprc(const char *filename);
#endif /* QDRP_H */