From 943520e59939ca6eb66299c45d26c06560ed2fe1 Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 3 Apr 2020 11:32:50 -0400 Subject: tclfitsy --- fitsy/file.h | 2 +- fitsy/map.C | 10 +++++----- fitsy/map.h | 4 ++-- fitsy/mapincr.C | 14 +++++++------- fitsy/mapincr.h | 4 ++-- fitsy/strm.C | 10 +++++----- fitsy/strm.h | 4 ++-- tclfitsy/configure | 2 +- tclfitsy/configure.ac | 2 +- tclfitsy/tclfitsy.C | 29 ++++++++++++++++++++++------- tclfitsy/tclfitsy.h | 2 +- 11 files changed, 49 insertions(+), 34 deletions(-) diff --git a/fitsy/file.h b/fitsy/file.h index a8cfc46..5017a46 100644 --- a/fitsy/file.h +++ b/fitsy/file.h @@ -19,7 +19,7 @@ class OutFitsStream; class FitsFile { public: enum FlushMode {NOFLUSH,FLUSH}; - enum ScanMode {RELAX, EXACT}; + enum ScanMode {RELAXIMAGE, EXACTIMAGE, RELAXTABLE, EXACTTABLE}; enum ArchType {NATIVE,BIG,LITTLE}; enum EncodingType {RAW,ASCII,HEX,GZIP,BZ2,BIP,BIL,BSQ}; diff --git a/fitsy/map.C b/fitsy/map.C index 6fd3d3c..ee0b93b 100644 --- a/fitsy/map.C +++ b/fitsy/map.C @@ -59,13 +59,13 @@ FitsFitsMap::FitsFitsMap(ScanMode mode) if (!valid_) return; - if (mode == EXACT || pExt_ || pIndex_>-1) - processExact(); + if (mode == EXACTIMAGE || pExt_ || pIndex_>-1) + processExactImage(); else - processRelax(); + processRelaxImage(); } -void FitsFitsMap::processExact() +void FitsFitsMap::processExactImage() { // find head and data for specified unit char* here = mapdata_; @@ -155,7 +155,7 @@ void FitsFitsMap::processExact() error(); } -void FitsFitsMap::processRelax() +void FitsFitsMap::processRelaxImage() { char* here = mapdata_; size_t size = mapsize_; diff --git a/fitsy/map.h b/fitsy/map.h index 6adae65..b92772e 100644 --- a/fitsy/map.h +++ b/fitsy/map.h @@ -26,8 +26,8 @@ public: class FitsFitsMap : public virtual FitsMap { protected: - void processExact(); - void processRelax(); + void processExactImage(); + void processRelaxImage(); public: FitsFitsMap(ScanMode); diff --git a/fitsy/mapincr.C b/fitsy/mapincr.C index e7d3ef6..3c8365f 100644 --- a/fitsy/mapincr.C +++ b/fitsy/mapincr.C @@ -275,13 +275,13 @@ FitsFitsMapIncr::FitsFitsMapIncr(ScanMode mode) if (!valid_) return; - if (mode == EXACT || pExt_ || pIndex_>-1) - processExact(); + if (mode == EXACTIMAGE || pExt_ || pIndex_>-1) + processExactImage(); else - processRelax(); + processRelaxImage(); } -void FitsFitsMapIncr::processExact() +void FitsFitsMapIncr::processExactImage() { // simple check for fits file if (!(pExt_ || (pIndex_>0))) { @@ -358,7 +358,7 @@ void FitsFitsMapIncr::processExact() error(); } -void FitsFitsMapIncr::processRelax() +void FitsFitsMapIncr::processRelaxImage() { // check to see if there is an image in the primary head_ = headRead(); @@ -590,8 +590,8 @@ char* FitsMapIncr::page(char* ptr, size_t row) void FitsMapIncr::resetpage() {} void FitsMapIncr::error() {} FitsFitsMapIncr::FitsFitsMapIncr(ScanMode mode) {} -void FitsFitsMapIncr::processExact() {} -void FitsFitsMapIncr::processRelax() {} +void FitsFitsMapIncr::processExactImage() {} +void FitsFitsMapIncr::processRelaxImage() {} FitsFitsNextMapIncr::FitsFitsNextMapIncr(FitsFile* p) {} FitsArrMapIncr::FitsArrMapIncr() {} diff --git a/fitsy/mapincr.h b/fitsy/mapincr.h index fcdea15..17ea996 100644 --- a/fitsy/mapincr.h +++ b/fitsy/mapincr.h @@ -36,8 +36,8 @@ public: class FitsFitsMapIncr : public virtual FitsMapIncr { protected: - void processExact(); - void processRelax(); + void processExactImage(); + void processRelaxImage(); public: FitsFitsMapIncr(ScanMode); diff --git a/fitsy/strm.C b/fitsy/strm.C index 9560d5e..5908e8d 100644 --- a/fitsy/strm.C +++ b/fitsy/strm.C @@ -414,13 +414,13 @@ template FitsFitsStream::FitsFitsStream(FitsFile::ScanMode mode, this->flush_ = f; - if (mode == this->EXACT || this->pExt_ || this->pIndex_>-1) - processExact(); + if (mode == this->EXACTIMAGE || this->pExt_ || this->pIndex_>-1) + processExactImage(); else - processRelax(); + processRelaxImage(); } -template void FitsFitsStream::processExact() +template void FitsFitsStream::processExactImage() { if (!(this->pExt_ || (this->pIndex_>0))) { @@ -493,7 +493,7 @@ template void FitsFitsStream::processExact() this->error(); } -template void FitsFitsStream::processRelax() +template void FitsFitsStream::processRelaxImage() { // check to see if there is an image in the primary if (!(this->head_ = this->headRead())) { diff --git a/fitsy/strm.h b/fitsy/strm.h index 22274ed..57f74da 100644 --- a/fitsy/strm.h +++ b/fitsy/strm.h @@ -49,8 +49,8 @@ public: template class FitsFitsStream : public virtual FitsStream { protected: - void processExact(); - void processRelax(); + void processExactImage(); + void processRelaxImage(); public: FitsFitsStream(FitsFile::ScanMode, FitsFile::FlushMode); diff --git a/tclfitsy/configure b/tclfitsy/configure index c6c8ef8..8fdc6fd 100755 --- a/tclfitsy/configure +++ b/tclfitsy/configure @@ -5164,7 +5164,7 @@ fi - vars="" + vars="-I. -I${prefix}/include" for i in $vars; do PKG_INCLUDES="$PKG_INCLUDES $i" done diff --git a/tclfitsy/configure.ac b/tclfitsy/configure.ac index 23c36fa..b722d36 100644 --- a/tclfitsy/configure.ac +++ b/tclfitsy/configure.ac @@ -77,7 +77,7 @@ fi TEA_ADD_SOURCES([tclfitsy.C]) TEA_ADD_HEADERS([]) -TEA_ADD_INCLUDES([]) +TEA_ADD_INCLUDES([-I. -I${prefix}/include]) TEA_ADD_LIBS([]) TEA_ADD_CFLAGS([]) TEA_ADD_STUB_SOURCES([]) diff --git a/tclfitsy/tclfitsy.C b/tclfitsy/tclfitsy.C index d4c0a7a..4a41ac3 100644 --- a/tclfitsy/tclfitsy.C +++ b/tclfitsy/tclfitsy.C @@ -12,6 +12,8 @@ using namespace std; #include #include "tclfitsy.h" +#include "file.h" +#include "mmapincr.h" extern "C" { int Tclfitsy_Init(Tcl_Interp* interp); @@ -40,18 +42,19 @@ int Tclfitsy_Init(Tcl_Interp* interp) { return TCL_ERROR; } -int TclfitsyCmd(ClientData data, Tcl_Interp *interp, int argc, const char* argv[]) +int TclfitsyCmd(ClientData data, Tcl_Interp *interp, + int argc, const char* argv[]) { if (argc>=2) { - if (!strncmp(argv[1], "hello", 4)) - return fitsy->hello(argc, argv); + if (!strncmp(argv[1], "table", 5)) + return fitsy->table(argc, argv); else { Tcl_AppendResult(interp, "fitsy: unknown command: ", argv[1], NULL); return TCL_ERROR; } } else { - Tcl_AppendResult(interp, "usage: fitsy ?hello?", NULL); + Tcl_AppendResult(interp, "usage: fitsy ?table?", NULL); return TCL_ERROR; } } @@ -65,8 +68,20 @@ TclFITSY::~TclFITSY() { } -int TclFITSY::hello(int argc, const char* argv[]) +int TclFITSY::table(int argc, const char* argv[]) { - cout << "world" << endl; - return TCL_OK; + if (argc==4) { + if (argv[2] && *argv[2]) { + FitsFile* fits = new FitsFitsMMapIncr(argv[2], FitsFile::RELAXTABLE); + if (!fits->isValid()) { + cerr << "Bad" << endl; + return TCL_ERROR; + } + cerr << "Good" << endl; + return TCL_OK; + } + } + + Tcl_AppendResult(interp_, "usage: fitsy table ?filename? ?varname?", NULL); + return TCL_ERROR; } diff --git a/tclfitsy/tclfitsy.h b/tclfitsy/tclfitsy.h index 8cd5d52..96d1ce6 100644 --- a/tclfitsy/tclfitsy.h +++ b/tclfitsy/tclfitsy.h @@ -13,7 +13,7 @@ class TclFITSY { TclFITSY(Tcl_Interp*); ~TclFITSY(); - int hello(int, const char*[]); + int table(int, const char*[]); }; extern TclFITSY* tclfitsy; -- cgit v0.12