From a9912013b4436b2668ed9a3ca6dd21acabafccf5 Mon Sep 17 00:00:00 2001 From: "Gyula I. G. Jozsa" Date: Fri, 17 Mar 2017 15:36:46 +0200 Subject: [PATCH] Changing version, no effective changes --- settings | 53 +- xmemory/Makefile.am | 45 -- xmemory/Makefile.in | 548 --------------- xmemory/qfits.h | 21 - xmemory/qfits_header.c | 1127 ------------------------------ xmemory/qfits_header.h | 91 --- xmemory/qfits_image.c | 1491 ---------------------------------------- xmemory/qfits_image.h | 274 -------- xmemory/qfits_memory.c | 112 --- xmemory/qfits_memory.h | 69 -- 10 files changed, 10 insertions(+), 3821 deletions(-) delete mode 100644 xmemory/Makefile.am delete mode 100644 xmemory/Makefile.in delete mode 100644 xmemory/qfits.h delete mode 100644 xmemory/qfits_header.c delete mode 100644 xmemory/qfits_header.h delete mode 100644 xmemory/qfits_image.c delete mode 100644 xmemory/qfits_image.h delete mode 100644 xmemory/qfits_memory.c delete mode 100644 xmemory/qfits_memory.h diff --git a/settings b/settings index fef40fd..cef0098 100644 --- a/settings +++ b/settings @@ -4,10 +4,6 @@ # such that you can easily install them. We leave it to you to install # the libraries in a convenient form. -# The version number -VERSIONNUM = 2.2.5 -PUBDIR = /Users/jozsa/Software/tirific - # Default number of disks, can be changed at runtime by the user NDISKS = 2 @@ -17,10 +13,7 @@ PBCORR = YES # CC is the compiler to use CC = gcc # CFLAGS is the flags to use the compiler with -# CFLAGS = -ggdb -Wall -O0 -pedantic -I/usr/include/malloc CFLAGS = -Wall -pedantic -O4 -I/usr/include/malloc -# CFLAGS = -Wall -pedantic -Os -march=x86-64 -I/usr/include/malloc -# -I/usr/include/mach # The operating system (At the moment chose between MAC_OS_X and LINUX OS = LINUX @@ -37,64 +30,38 @@ OPENMPLIB = -fopenmp # This is the standard include STDDIR = /usr/include/ -# directory containing the gipsy include files (obsolete) -GIPDIR = /home/jozsa/software/gipsy/inc/ - -# This is the math library include file and most probably at this -# location +# This is the math library include file and most probably at this location MATHDIR = /usr/include/ -#/opt/local/include/ # This is the fftw include directory. It should contain the file fftw3.h -FFTWDIR = /usr/include/ +FFTWDIR = /usr/include/ # This is the position of the parent directory of the gsl directory GSLDIR = /Users/jozsa/Software/gsl/gsl-1.15/ -# This is the directory in which the g2c include file resides, most probably at this location -G2CDIR = /usr/include/ - # This is the directory in which the wcs include files reside -WCSDIR = /usr/include/wcslib/ +WCSDIR = /usr/include/wcslib -# external libraries +# Pgplot directory +PGPDIR = /usr/include/ -# The gipsy library (obsolete) -GIPLIB = /home/jozsa/software/gipsy/lib/linux64/giplib.a -lgfortran +# external libraries # The math library MATHLIB = -lm # The fftw3f library, alternatively # -Ldirectory_in_which_the_file_libfftw3f.a_is -lfftw3f -FFTWLIB = -L/Users/jozsa/Software/fftw/fftw/lib/ -lfftw3f -lfftw3 +FFTWLIB = -lfftw3f -lfftw3 # The gsl library linker flags-, alternatively -# -Ldirectory_in_which_the_library_is -lgsl -lgslcblas -#GSLLIB = -L/opt/local/lib -lgsl -lgslcblas -GSLLIB = -L/Users/jozsa/Software/gsl/gsl/lib -lgsl -lgslcblas - -# The g2c library, alternatively -# -Ldirectory_in_which_the_library_is -lgsl -lgslcblas -G2CLIB = -# G2CLIB = -L/usr/local/lib/gcc/i686-apple-darwin11/4.2.1 -lgfortran -# G2CLIB = -L/sw/lib -lg2c +GSLLIB = -lgsl -lgslcblas # The wcs library WCSLIB = -lwcs -# Pgplot directory -PGPDIR = /usr/include/ - # Pgplot linker flags, for Mac OS, maybe -L$(PGPDIR) -lcpgplot -lpgplot $(X11LIB) -lpng -laquaterm -Wl,-framework -Wl,Foundation -W1,-AppKit -PGPLIB = -lcpgplot -lpgplot -lpng - -# This is the directory in which the gft include file resides -# GFTDIR = /Users/jozsa/Software/gft/ -# GFTDIR2 = ../gft - -# gft library linker flags -# GFTLIB = -lgsl -lgslcblas -L/Users/jozsa/Software/gft -lgft +PGPLIB = -lcpgplot -lpgplot -lX11 # Readline library -READLINELIB= -lreadline \ No newline at end of file +READLINELIB= -lreadline diff --git a/xmemory/Makefile.am b/xmemory/Makefile.am deleted file mode 100644 index 6d9ef54..0000000 --- a/xmemory/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -AUTOMAKE_OPTIONS = 1.8 foreign -DISTCLEANFILES = *~ - -INCLUDES = -I$(top_srcdir)/src - -AM_CFLAGS = $(QFITS_CFLAGS) - -lib_LTLIBRARIES = libqfits.la - -libqfits_la_SOURCES = qfits_byteswap.c \ - qfits_cache.c \ - qfits_card.c \ - qfits_error.c \ - qfits_filename.c \ - qfits_float.c \ - qfits_header.c \ - qfits_image.c \ - qfits_memory.c \ - qfits_md5.c \ - qfits_rw.c \ - qfits_table.c \ - qfits_time.c \ - qfits_tools.c \ - md5.c - -include_HEADERS = qfits_cache.h \ - qfits_filename.h \ - qfits_header.h \ - qfits_image.h \ - qfits_memory.h \ - qfits_md5.h \ - qfits_rw.h \ - qfits_std.h \ - qfits_table.h \ - qfits_time.h \ - qfits_tools.h \ - qfits_card.h - -noinst_HEADERS = qfits_byteswap.h \ - qfits_error.h \ - qfits_float.h \ - md5.h - -libqfits_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -libqfits_la_LIBADD = -lm diff --git a/xmemory/Makefile.in b/xmemory/Makefile.in deleted file mode 100644 index b1a67e6..0000000 --- a/xmemory/Makefile.in +++ /dev/null @@ -1,548 +0,0 @@ -# Makefile.in generated by automake 1.8.5 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - - -SOURCES = $(libqfits_la_SOURCES) - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = .. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_triplet = @host@ -subdir = src -DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) \ - $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4macros/eso.m4 \ - $(top_srcdir)/m4macros/qfits_memory.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(mkdir_p) -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" -libLTLIBRARIES_INSTALL = $(INSTALL) -LTLIBRARIES = $(lib_LTLIBRARIES) -libqfits_la_DEPENDENCIES = -am_libqfits_la_OBJECTS = qfits_byteswap.lo qfits_cache.lo \ - qfits_card.lo qfits_error.lo qfits_filename.lo qfits_float.lo \ - qfits_header.lo qfits_image.lo qfits_memory.lo qfits_md5.lo \ - qfits_rw.lo qfits_table.lo qfits_time.lo qfits_tools.lo md5.lo -libqfits_la_OBJECTS = $(am_libqfits_la_OBJECTS) -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/admin/depcomp -am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/md5.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_byteswap.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_cache.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_card.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_error.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_filename.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_float.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_header.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_image.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_md5.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_memory.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_rw.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_table.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_time.Plo \ -@AMDEP_TRUE@ ./$(DEPDIR)/qfits_tools.Plo -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libqfits_la_SOURCES) -DIST_SOURCES = $(libqfits_la_SOURCES) -includeHEADERS_INSTALL = $(INSTALL_HEADER) -HEADERS = $(include_HEADERS) $(noinst_HEADERS) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DOXYGEN = @DOXYGEN@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LATEX = @LATEX@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIBTOOL_DEPS = @LIBTOOL_DEPS@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_REVISION = @LT_REVISION@ -MAKEINFO = @MAKEINFO@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -QFITS_CFLAGS = @QFITS_CFLAGS@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ -am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -AUTOMAKE_OPTIONS = 1.8 foreign -DISTCLEANFILES = *~ -INCLUDES = -I$(top_srcdir)/src -AM_CFLAGS = $(QFITS_CFLAGS) -lib_LTLIBRARIES = libqfits.la -libqfits_la_SOURCES = qfits_byteswap.c \ - qfits_cache.c \ - qfits_card.c \ - qfits_error.c \ - qfits_filename.c \ - qfits_float.c \ - qfits_header.c \ - qfits_image.c \ - qfits_memory.c \ - qfits_md5.c \ - qfits_rw.c \ - qfits_table.c \ - qfits_time.c \ - qfits_tools.c \ - md5.c - -include_HEADERS = qfits_cache.h \ - qfits_filename.h \ - qfits_header.h \ - qfits_image.h \ - qfits_memory.h \ - qfits_md5.h \ - qfits_rw.h \ - qfits_std.h \ - qfits_table.h \ - qfits_time.h \ - qfits_card.h \ - qfits_tools.h - -noinst_HEADERS = qfits_byteswap.h \ - qfits_error.h \ - qfits_float.h \ - md5.h - -libqfits_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -libqfits_la_LIBADD = -lm -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign src/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)" - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - p="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ - $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libqfits.la: $(libqfits_la_OBJECTS) $(libqfits_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libqfits_la_LDFLAGS) $(libqfits_la_OBJECTS) $(libqfits_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_byteswap.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_cache.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_card.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_error.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_filename.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_float.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_header.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_image.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_md5.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_memory.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_rw.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_table.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_time.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qfits_tools.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" - @list='$(include_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ - $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; for p in $$list; do \ - f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ - rm -f "$(DESTDIR)$(includedir)/$$f"; \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -rm -f $(CONFIG_CLEAN_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: install-includeHEADERS - -install-exec-am: install-libLTLIBRARIES - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-includeHEADERS uninstall-info-am \ - uninstall-libLTLIBRARIES - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-exec \ - install-exec-am install-includeHEADERS install-info \ - install-info-am install-libLTLIBRARIES install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-includeHEADERS uninstall-info-am \ - uninstall-libLTLIBRARIES - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/xmemory/qfits.h b/xmemory/qfits.h deleted file mode 100644 index 5898671..0000000 --- a/xmemory/qfits.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifdef __cplusplus -extern "C" { -#endif - -#include "qfits_cache.h" -#include "qfits_filename.h" -#include "qfits_header.h" -#include "qfits_image.h" -#include "qfits_md5.h" -#include "qfits_rw.h" -#include "qfits_std.h" -#include "qfits_table.h" -#include "qfits_time.h" -#include "qfits_tools.h" -#include "qfits_memory.h" -#include "qfits_card.h" - -#ifdef __cplusplus -} -#endif - diff --git a/xmemory/qfits_header.c b/xmemory/qfits_header.c deleted file mode 100644 index 8131ba3..0000000 --- a/xmemory/qfits_header.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* $Id: qfits_header.c,v 1.10 2006/11/22 13:33:42 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/11/22 13:33:42 $ - * $Revision: 1.10 $ - * $Name: qfits-6_2_0 $ - */ - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include "qfits_header.h" - -#include "qfits_tools.h" -#include "qfits_card.h" -#include "qfits_error.h" -#include "qfits_memory.h" - -/*----------------------------------------------------------------------------*/ -/* - @brief keytuple object (internal) - - This structure represents a FITS card (key, val, comment) in memory. - A FITS header is a list of such structs. Although the struct is here - made public for convenience, it is not supposed to be directly used. - High-level FITS routines should do the job just fine, without need - to know about this struct. - */ -/*----------------------------------------------------------------------------*/ -typedef struct _keytuple_ { - - char * key ; /** Key: unique string in a list */ - char * val ; /** Value, always as a string */ - char * com ; /** Comment associated to key */ - char * lin ; /** Initial line in FITS header if applicable */ - int typ ; /** Key type */ - - /** Implemented as a doubly-linked list */ - struct _keytuple_ * next ; - struct _keytuple_ * prev ; -} keytuple ; - -/*----------------------------------------------------------------------------*/ -/** - @enum keytype - @brief Possible key types - - This enum stores all possible types for a FITS keyword. These determine - the order of appearance in a header, they are a crucial point for - DICB (ESO) compatibility. This classification is internal to this - module. - */ -/*----------------------------------------------------------------------------*/ -typedef enum _keytype_ { - keytype_undef =0, - - keytype_top =1, - - /* Mandatory keywords */ - /* All FITS files */ - keytype_bitpix =2, - keytype_naxis =3, - - keytype_naxis1 =11, - keytype_naxis2 =12, - keytype_naxis3 =13, - keytype_naxis4 =14, - keytype_naxisi =20, - /* Random groups only */ - keytype_group =30, - /* Extensions */ - keytype_pcount =31, - keytype_gcount =32, - /* Main header */ - keytype_extend =33, - /* Images */ - keytype_bscale =34, - keytype_bzero =35, - /* Tables */ - keytype_tfields =36, - keytype_tbcoli =40, - keytype_tformi =41, - - /* Other primary keywords */ - keytype_primary =100, - - /* HIERARCH ESO keywords ordered according to DICB */ - keytype_hierarch_dpr =200, - keytype_hierarch_obs =201, - keytype_hierarch_tpl =202, - keytype_hierarch_gen =203, - keytype_hierarch_tel =204, - keytype_hierarch_ins =205, - keytype_hierarch_det =206, - keytype_hierarch_log =207, - keytype_hierarch_pro =208, - /* Other HIERARCH keywords */ - keytype_hierarch =300, - - /* HISTORY and COMMENT */ - keytype_history =400, - keytype_comment =500, - /* END */ - keytype_end =1000 -} keytype ; - -/*----------------------------------------------------------------------------- - Private to this module - -----------------------------------------------------------------------------*/ - -static keytuple * keytuple_new(const char *, const char *, const char *, - const char *); -static void keytuple_del(keytuple *); -static void keytuple_dmp(const keytuple *); -static keytype keytuple_type(const char *); -static int qfits_header_makeline(char *, const keytuple *, int) ; - -/*----------------------------------------------------------------------------*/ -/** - * @defgroup qfits_header FITS header handling - * - * This file contains definition and related methods for the FITS header - * structure. This structure is meant to remain opaque to the user, who - * only accesses it through the dedicated functions. - * - * The 'keytuple' type is strictly internal to this module. - * It describes FITS cards as tuples (key,value,comment,line), where key - * is always a non-NULL character string, value and comment are - * allowed to be NULL. 'line' is a string containing the line as it - * has been read from the input FITS file (raw). It is set to NULL if - * the card is modified later. This allows in output two options: - * either reconstruct the FITS lines by printing key = value / comment - * in a FITS-compliant way, or output the lines as they were found in - * input, except for the modified ones. - * - * The following functions are associated methods - * to this data structure: - * - * - keytuple_new() constructor - * - keytuple_del() destructor - * - keytuple_dmp() dumps a keytuple to stdout - * - */ -/*----------------------------------------------------------------------------*/ -/**@{*/ - -/*----------------------------------------------------------------------------- - Public functions - -----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief FITS header constructor - @return 1 newly allocated (empty) qfits_header object. - - This is the main constructor for a qfits_header object. It returns - an allocated linked-list handler with an empty card list. - */ -/*----------------------------------------------------------------------------*/ -qfits_header * qfits_header_new(void) -{ - qfits_header * h ; - h = qfits_malloc(sizeof(qfits_header)); - h->first = NULL ; - h->last = NULL ; - h->n = 0 ; - - h->current = NULL ; - h->current_idx = -1 ; - - return h; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief FITS header default constructor. - @return 1 newly allocated qfits_header object. - - This is a secondary constructor for a qfits_header object. It returns - an allocated linked-list handler containing two cards: the first one - (SIMPLE=T) and the last one (END). - - */ -/*----------------------------------------------------------------------------*/ -qfits_header * qfits_header_default(void) -{ - qfits_header * h ; - h = qfits_header_new() ; - qfits_header_append(h, "SIMPLE", "T", "Fits format", NULL); - qfits_header_append(h, "END", NULL, NULL, NULL); - return h; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Add a new card to a FITS header - @param hdr qfits_header object to modify - @param key FITS key - @param val FITS value - @param com FITS comment - @param lin FITS original line if exists - @return void - - This function adds a new card into a header, at the one-before-last - position, i.e. the entry just before the END entry if it is there. - The key must always be a non-NULL string, all other input parameters - are allowed to get NULL values. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_add( - qfits_header * hdr, - const char * key, - const char * val, - const char * com, - const char * lin) -{ - keytuple * k ; - keytuple * kbf ; - keytuple * first ; - keytuple * last ; - - if (hdr==NULL || key==NULL) return ; - if (hdr->n<2) return ; - - first = (keytuple*)hdr->first ; - last = (keytuple*)hdr->last ; - - if (((keytype)first->typ != keytype_top) || - ((keytype)last->typ != keytype_end)) return ; - - /* Create new key tuple */ - k = keytuple_new(key, val, com, lin); - - /* Find the last keytuple with same key type */ - kbf = first ; - while (kbf!=NULL) { - if ((k->typ>=kbf->typ) && (k->typnext->typ)) break ; - kbf = kbf->next ; - } - if (kbf==NULL) kbf = last->prev ; - - /* Hook it into list */ - k->next = kbf->next ; - (kbf->next)->prev = k ; - kbf->next = k ; - k->prev = kbf ; - - hdr->n ++ ; - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief add a new card to a FITS header - @param hdr qfits_header object to modify - @param after Key to specify insertion place - @param key FITS key - @param val FITS value - @param com FITS comment - @param lin FITS original line if exists - @return void - - Adds a new card to a FITS header, after the specified key. Nothing - happens if the specified key is not found in the header. All fields - can be NULL, except after and key. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_add_after( - qfits_header * hdr, - const char * after, - const char * key, - const char * val, - const char * com, - const char * lin) -{ - keytuple * kreq; - keytuple * k; - char * exp_after ; - - if (hdr==NULL || after==NULL || key==NULL) return ; - - exp_after = qfits_expand_keyword(after); - /* Locate where the entry is requested */ - kreq = (keytuple*)(hdr->first) ; - while (kreq!=NULL) { - if (!strcmp(kreq->key, exp_after)) break ; - kreq = kreq->next ; - } - if (kreq==NULL) return ; - k = keytuple_new(key, val, com, lin); - - k->next = kreq->next ; - kreq->next->prev = k ; - kreq->next = k ; - k->prev = kreq ; - hdr->n ++ ; - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Append a new card to a FITS header. - @param hdr qfits_header object to modify - @param key FITS key - @param val FITS value - @param com FITS comment - @param lin FITS original line if exists - @return void - - Adds a new card in a FITS header as the last one. All fields can be - NULL except key. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_append( - qfits_header * hdr, - const char * key, - const char * val, - const char * com, - const char * lin) -{ - keytuple * k; - keytuple * last ; - - if (hdr==NULL || key==NULL) return ; - - k = keytuple_new(key, val, com, lin); - if (hdr->n==0) { - hdr->first = hdr->last = k ; - hdr->n = 1 ; - return ; - } - last = (keytuple*)hdr->last ; - last->next = k ; - k->prev = last ; - hdr->last = k ; - hdr->n++ ; - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Delete a card in a FITS header. - @param hdr qfits_header to modify - @param key specifies which card to remove - @return void - - Removes a card from a FITS header. The first found card that matches - the key is removed. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_del(qfits_header * hdr, const char * key) -{ - keytuple * k ; - char * xkey ; - - if (hdr==NULL || key==NULL) return ; - - xkey = qfits_expand_keyword(key); - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strcmp(k->key, xkey)) break ; - k = k->next ; - } - if (k==NULL) - return ; - if(k == hdr->first) { - hdr->first = k->next ; - } else { - k->prev->next = k->next ; - k->next->prev = k->prev ; - } - keytuple_del(k); - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Modifies a FITS card. - @param hdr qfits_header to modify - @param key FITS key - @param val FITS value - @param com FITS comment - @return void - - Finds the first card in the header matching 'key', and replaces its - value and comment fields by the provided values. The initial FITS - line is set to NULL in the card. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_mod( - qfits_header * hdr, - const char * key, - const char * val, - const char * com) -{ - keytuple * k ; - char * xkey ; - - if (hdr==NULL || key==NULL) return ; - - xkey = qfits_expand_keyword(key); - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strcmp(k->key, xkey)) break ; - k=k->next ; - } - if (k==NULL) return ; - - if (k->val) qfits_free(k->val); - if (k->com) qfits_free(k->com); - if (k->lin) qfits_free(k->lin); - k->val = NULL ; - k->com = NULL ; - k->lin = NULL ; - if (val) { - if (strlen(val)>0) k->val = qfits_strdup(val); - } - if (com) { - if (strlen(com)>0) k->com = qfits_strdup(com); - } - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Sort a FITS header - @param hdr Header to sort (modified) - @return -1 in error case, 0 otherwise - */ -/*----------------------------------------------------------------------------*/ -int qfits_header_sort(qfits_header ** hdr) -{ - qfits_header * sorted ; - keytuple * k ; - keytuple * kbf ; - keytuple * next ; - keytuple * last ; - - /* Test entries */ - if (hdr == NULL) return -1 ; - if (*hdr == NULL) return -1 ; - if ((*hdr)->n < 2) return 0 ; - - /* Create the new FITS header */ - sorted = qfits_header_new() ; - - /* Move the first keytuple to the sorted empty header */ - k = (keytuple*)(*hdr)->first ; - next = k->next ; - sorted->first = sorted->last = k ; - k->next = k->prev = NULL ; - sorted->n = 1 ; - - /* Loop over the other tuples */ - while (next != NULL) { - k = next ; - next = k->next ; - - /* Find k's place in sorted */ - kbf = (keytuple*)sorted->first ; - while (kbf!=NULL) { - if (k->typ < kbf->typ) break ; - kbf = kbf->next ; - } - - /* Hook k into sorted list */ - if (kbf == NULL) { - /* k is last in sorted */ - last = sorted->last ; - sorted->last = k ; - k->next = NULL ; - k->prev = last ; - last->next = k ; - } else { - /* k goes just before kbf */ - k->next = kbf ; - k->prev = kbf->prev ; - if (kbf->prev != NULL) (kbf->prev)->next = k ; - else sorted->first = k ; - kbf->prev = k ; - } - (sorted->n) ++ ; - } - - /* Replace the input header by the sorted one */ - (*hdr)->first = (*hdr)->last = NULL ; - qfits_header_destroy(*hdr) ; - *hdr = sorted ; - - return 0 ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Copy a FITS header - @param src Header to replicate - @return Pointer to newly allocated qfits_header object. - - Makes a strict copy of all information contained in the source - header. The returned header must be freed using qfits_header_destroy. - */ -/*----------------------------------------------------------------------------*/ -qfits_header * qfits_header_copy(const qfits_header * src) -{ - qfits_header * fh_copy ; - keytuple * k ; - - if (src==NULL) return NULL ; - - fh_copy = qfits_header_new(); - k = (keytuple*)src->first ; - while (k!=NULL) { - qfits_header_append(fh_copy, k->key, k->val, k->com, k->lin) ; - k = k->next ; - } - return fh_copy ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief qfits_header destructor - @param hdr qfits_header to deallocate - @return void - - Frees all memory associated to a given qfits_header object. - */ -/*----------------------------------------------------------------------------*/ -void qfits_header_destroy(qfits_header * hdr) -{ - keytuple * k ; - keytuple * kn ; - - if (hdr==NULL) return ; - - k = (keytuple*)hdr->first ; - while (k!=NULL) { - kn = k->next ; - keytuple_del(k); - k = kn ; - } - qfits_free(hdr); - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the value associated to a key, as a string - @param hdr qfits_header to parse - @param key key to find - @return pointer to statically allocated string - - Finds the value associated to the given key and return it as a - string. The returned pointer is statically allocated, so do not - modify its contents or try to free it. - - Returns NULL if no matching key is found or no value is attached. - */ -/*----------------------------------------------------------------------------*/ -char * qfits_header_getstr(const qfits_header * hdr, const char * key) -{ - keytuple * k ; - char * xkey ; - - if (hdr==NULL || key==NULL) return NULL ; - - xkey = qfits_expand_keyword(key); - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strcmp(k->key, xkey)) break ; - k=k->next ; - } - if (k==NULL) return NULL ; - return k->val ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the i-th key/val/com/line tuple in a header. - @param hdr Header to consider - @param idx Index of the requested card - @param key Output key - @param val Output value - @param com Output comment - @param lin Output initial line - @return int 0 if Ok, -1 if error occurred. - - This function is useful to browse a FITS header object card by card. - By iterating on the number of cards (available in the 'n' field of - the qfits_header struct), you can retrieve the FITS lines and their - components one by one. Indexes run from 0 to n-1. You can pass NULL - values for key, val, com or lin if you are not interested in a - given field. - - @code - int i ; - char key[FITS_LINESZ+1] ; - char val[FITS_LINESZ+1] ; - char com[FITS_LINESZ+1] ; - char lin[FITS_LINESZ+1] ; - - for (i=0 ; in ; i++) { - qfits_header_getitem(hdr, i, key, val, com, lin); - printf("card[%d] key[%s] val[%s] com[%s]\n", i, key, val, com); - } - @endcode - - This function has primarily been written to interface a qfits_header - object to other languages (C++/Python). If you are working within a - C program, you should use the other header manipulation routines - available in this module. - */ -/*----------------------------------------------------------------------------*/ -int qfits_header_getitem( - const qfits_header * hdr, - int idx, - char * key, - char * val, - char * com, - char * lin) -{ - keytuple * k ; - int count ; - - if (hdr==NULL) return -1 ; - if (key==NULL && val==NULL && com==NULL && lin==NULL) return 0 ; - if (idx<0 || idx>hdr->n) return -1 ; - - /* Get pointer to keytuple */ - if (idx == 0) { - ((qfits_header *)hdr)->current_idx = 0 ; - ((qfits_header *)hdr)->current = hdr->first ; - k = hdr->current ; - } else if (idx == hdr->current_idx + 1) { - ((qfits_header *)hdr)->current = ((keytuple*) (hdr->current))->next ; - ((qfits_header *)hdr)->current_idx++ ; - k = hdr->current ; - } else { - count=0 ; - k = (keytuple*)hdr->first ; - while (countnext ; - count++ ; - } - } - - /* Fill return values */ - if (key!=NULL) strcpy(key, k->key); - if (val!=NULL) { - if (k->val!=NULL) strcpy(val, k->val); - else val[0]=0 ; - } - if (com!=NULL) { - if (k->com!=NULL) strcpy(com, k->com); - else com[0]=0 ; - } - if (lin!=NULL) { - if (k->lin!=NULL) strcpy(lin, k->lin); - else lin[0]=0 ; - } - return 0 ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the comment associated to a key, as a string - @param hdr qfits_header to parse - @param key key to find - @return pointer to statically allocated string - - Finds the comment associated to the given key and return it as a - string. The returned pointer is statically allocated, so do not - modify its contents or try to free it. - - Returns NULL if no matching key is found or no comment is attached. - */ -/*----------------------------------------------------------------------------*/ -char * qfits_header_getcom(const qfits_header * hdr, const char * key) -{ - keytuple * k ; - char * xkey ; - - if (hdr==NULL || key==NULL) return NULL ; - - xkey = qfits_expand_keyword(key); - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strcmp(k->key, xkey)) break ; - k=k->next ; - } - if (k==NULL) return NULL ; - return k->com ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the value associated to a key, as an int - @param hdr qfits_header to parse - @param key key to find - @param errval default value to return if nothing is found - @return int - - Finds the value associated to the given key and return it as an - int. Returns errval if no matching key is found or no value is - attached. - */ -/*----------------------------------------------------------------------------*/ -int qfits_header_getint( - const qfits_header * hdr, - const char * key, - int errval) -{ - char * c ; - int d ; - - if (hdr==NULL || key==NULL) return errval ; - - c = qfits_header_getstr(hdr, key); - if (c==NULL) return errval ; - if (sscanf(c, "%d", &d)!=1) return errval ; - return d ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the value associated to a key, as a double - @param hdr qfits_header to parse - @param key key to find - @param errval default value to return if nothing is found - @return double - - Finds the value associated to the given key and return it as a - double. Returns errval if no matching key is found or no value is - attached. - */ -/*----------------------------------------------------------------------------*/ -double qfits_header_getdouble( - const qfits_header * hdr, - const char * key, - double errval) -{ - char * c ; - - if (hdr==NULL || key==NULL) return errval ; - - c = qfits_header_getstr(hdr, key); - if (c==NULL) return errval ; - return atof(c); -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the value associated to a key, as a boolean (int). - @param hdr qfits_header to parse - @param key key to find - @param errval default value to return if nothing is found - @return int - - Finds the value associated to the given key and return it as a - boolean. Returns errval if no matching key is found or no value is - attached. A boolean is here understood as an int taking the value 0 - or 1. errval can be set to any other integer value to reflect that - nothing was found. - - errval is returned if no matching key is found or no value is - attached. - - A true value is any character string beginning with a 'y' (yes), a - 't' (true) or the digit '1'. A false value is any character string - beginning with a 'n' (no), a 'f' (false) or the digit '0'. - */ -/*----------------------------------------------------------------------------*/ -int qfits_header_getboolean( - const qfits_header * hdr, - const char * key, - int errval) -{ - char * c ; - int ret ; - - if (hdr==NULL || key==NULL) return errval ; - - c = qfits_header_getstr(hdr, key); - if (c==NULL) return errval ; - if (strlen(c)<1) return errval ; - - if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') { - ret = 1 ; - } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') { - ret = 0 ; - } else { - ret = errval ; - } - return ret; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Dump a FITS header to an opened file. - @param hdr FITS header to dump - @param out Opened file pointer - @return int 0 if Ok, -1 otherwise - Dumps a FITS header to an opened file pointer. - */ -/*----------------------------------------------------------------------------*/ -int qfits_header_dump( - const qfits_header * hdr, - FILE * out) -{ - keytuple * k ; - char line[81]; - int n_out ; - - if (hdr==NULL) return -1 ; - if (out==NULL) out=stdout ; - - k = (keytuple*)hdr->first ; - n_out = 0 ; - while (k!=NULL) { - /* Make line from information in the node */ - qfits_header_makeline(line, k, 1); - if ((fwrite(line, 1, 80, out))!=80) { - fprintf(stderr, "error dumping FITS header"); - return -1 ; - } - n_out ++; - k=k->next; - } - /* If printing out to a regular file, blank pad */ - if (out!=stdout && out!=stderr) { - /* Blank-pad the output */ - memset(line, ' ', 80); - while (n_out % 36) { - fwrite(line, 1, 80, out); - n_out++ ; - } - } - return 0 ; -} - -/**@}*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief keytuple constructor - @param key Key associated to key tuple (cannot be NULL). - @param val Value associated to key tuple. - @param com Comment associated to key tuple. - @param lin Initial line read from FITS header (if applicable). - @return 1 pointer to newly allocated keytuple. - - This function is a keytuple creator. NULL values and zero-length strings - are valid parameters for all but the key field. The returned object must - be deallocated using keytuple_del(). - - */ -/*----------------------------------------------------------------------------*/ -static keytuple * keytuple_new( - const char * key, - const char * val, - const char * com, - const char * lin) -{ - keytuple * k ; - - if (key==NULL) return NULL ; - - /* Allocate space for new structure */ - k = qfits_malloc(sizeof(keytuple)); - /* Hook a copy of the new key */ - k->key = qfits_strdup(qfits_expand_keyword(key)) ; - /* Hook a copy of the value if defined */ - k->val = NULL ; - if (val!=NULL) { - if (strlen(val)>0) k->val = qfits_strdup(val); - } - /* Hook a copy of the comment if defined */ - k->com = NULL ; - if (com!=NULL) { - if (strlen(com)>0) k->com = qfits_strdup(com) ; - } - /* Hook a copy of the initial line if defined */ - k->lin = NULL ; - if (lin!=NULL) { - if (strlen(lin)>0) k->lin = qfits_strdup(lin); - } - k->next = NULL ; - k->prev = NULL ; - k->typ = keytuple_type(key); - - return k; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief keytuple type identification routine - @param key String representing a FITS keyword. - @return A key type (see keytype enum) - - This function identifies the type of a FITS keyword when given the - keyword as a string. Keywords are expected literally as they are - found in a FITS header on disk. - - */ -/*----------------------------------------------------------------------------*/ -static keytype keytuple_type(const char * key) -{ - keytype kt ; - - kt = keytype_undef ; - /* Assign type to key tuple */ - if (!strcmp(key, "SIMPLE") || !strcmp(key, "XTENSION")) kt = keytype_top ; - else if (!strcmp(key, "END")) kt = keytype_end ; - else if (!strcmp(key, "BITPIX")) kt = keytype_bitpix ; - else if (!strcmp(key, "NAXIS")) kt = keytype_naxis ; - else if (!strcmp(key, "NAXIS1")) kt = keytype_naxis1 ; - else if (!strcmp(key, "NAXIS2")) kt = keytype_naxis2 ; - else if (!strcmp(key, "NAXIS3")) kt = keytype_naxis3 ; - else if (!strcmp(key, "NAXIS4")) kt = keytype_naxis4 ; - else if (!strncmp(key, "NAXIS", 5)) kt = keytype_naxisi ; - else if (!strcmp(key, "GROUP")) kt = keytype_group ; - else if (!strcmp(key, "PCOUNT")) kt = keytype_pcount ; - else if (!strcmp(key, "GCOUNT")) kt = keytype_gcount ; - else if (!strcmp(key, "EXTEND")) kt = keytype_extend ; - else if (!strcmp(key, "BSCALE")) kt = keytype_bscale ; - else if (!strcmp(key, "BZERO")) kt = keytype_bzero ; - else if (!strcmp(key, "TFIELDS")) kt = keytype_tfields ; - else if (!strncmp(key, "TBCOL", 5)) kt = keytype_tbcoli ; - else if (!strncmp(key, "TFORM", 5)) kt = keytype_tformi ; - else if (!strncmp(key, "HIERARCH ESO DPR", 16)) kt = keytype_hierarch_dpr ; - else if (!strncmp(key, "HIERARCH ESO OBS", 16)) kt = keytype_hierarch_obs ; - else if (!strncmp(key, "HIERARCH ESO TPL", 16)) kt = keytype_hierarch_tpl ; - else if (!strncmp(key, "HIERARCH ESO GEN", 16)) kt = keytype_hierarch_gen ; - else if (!strncmp(key, "HIERARCH ESO TEL", 16)) kt = keytype_hierarch_tel ; - else if (!strncmp(key, "HIERARCH ESO INS", 16)) kt = keytype_hierarch_ins ; - else if (!strncmp(key, "HIERARCH ESO LOG", 16)) kt = keytype_hierarch_log ; - else if (!strncmp(key, "HIERARCH ESO PRO", 16)) kt = keytype_hierarch_pro ; - else if (!strncmp(key, "HIERARCH", 8)) kt = keytype_hierarch ; - else if (!strcmp(key, "HISTORY")) kt = keytype_history ; - else if (!strcmp(key, "COMMENT")) kt = keytype_comment ; - else if ((int)strlen(key)<9) kt = keytype_primary ; - return kt ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Keytuple destructor. - @param k Keytuple to deallocate. - @return void - Keytuple destructor. - */ -/*----------------------------------------------------------------------------*/ -static void keytuple_del(keytuple * k) -{ - if (k==NULL) return ; - if (k->key) qfits_free(k->key); - if (k->val) qfits_free(k->val); - if (k->com) qfits_free(k->com); - if (k->lin) qfits_free(k->lin); - qfits_free(k); -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Keytuple dumper. - @param k Keytuple to dump - @return void - - This function dumps a key tuple to stdout. It is meant for debugging - purposes only. - */ -/*----------------------------------------------------------------------------*/ -static void keytuple_dmp(const keytuple * k) -{ - if (!k) return ; - printf("[%s]=[", k->key); - if (k->val) printf("%s", k->val); - printf("]"); - if (k->com) printf("/[%s]", k->com); - printf("\n"); - return ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Build a FITS line from the information contained in a card. - @param line pointer to allocated string to be filled - @param node pointer to card node in qfits_header linked-list - @param conservative flag to indicate conservative behaviour - @return int 0 if Ok, anything else otherwise - - Build a FITS line (80 chars) from the information contained in a - node of a qfits_header linked-list. If the mode is set to - conservative, the original FITS line will be used wherever present. - If conservative is set to 0, a new line will be formatted. - */ -/*----------------------------------------------------------------------------*/ -static int qfits_header_makeline( - char * line, - const keytuple * k, - int conservative) -{ - char blankline[81]; - int i ; - - if (line==NULL || k==NULL) return -1 ; - - /* If a previous line information is there, use it as is */ - if (conservative) { - if (k->lin != NULL) { - memcpy(line, k->lin, 80); - line[80]=(char)0; - return 0 ; - } - } - /* Got to build keyword from scratch */ - memset(blankline, 0, 81); - qfits_card_build(blankline, k->key, k->val, k->com); - memset(line, ' ', 80); - i=0 ; - while (blankline[i] != (char)0) { - line[i] = blankline[i] ; - i++ ; - } - line[80]=(char)0; - return 0; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Return the FITS line associated to a key, as a string - @param hdr qfits_header to parse - @param key key to find - @return pointer to statically allocated string - - Finds the FITS line associated to the given key and return it as a - string. The returned pointer is statically allocated, so do not - modify its contents or try to free it. - - Returns NULL if no matching key is found or no line is attached. - */ -/*----------------------------------------------------------------------------*/ -char * qfits_header_getline(qfits_header * hdr, char * key) -{ - keytuple * k ; - char * xkey ; - - if (hdr==NULL || key==NULL) { - return NULL;} - - xkey = qfits_expand_keyword(key); - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strcmp(k->key, xkey)) break ; - k=k->next ; - } - if (k==NULL) { - return NULL ; - } - - /* GJ This is cheating; we recreate lin on the spot (on the other hand, I would not know where the harm is) */ - if (k -> lin == NULL) { - k->lin = (char *) malloc(81*sizeof(char)); - } - memset(k -> lin, 0, 81); - memset(k -> lin, ' ', 80); - - qfits_header_makeline(k -> lin, k, 0); - - return k->lin ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Find a matching key in a header. - @param hdr qfits_header to parse - @param key Key prefix to match - @return pointer to statically allocated string. - - This function finds the first keyword in the given header for - which the given 'key' is a prefix, and returns the full name - of the matching key (NOT ITS VALUE). This is useful to locate - any keyword starting with a given prefix. Careful with HIERARCH - keywords, the shortFITS notation is not likely to be accepted here. - - Examples: - - @verbatim - s = qfits_header_findmatch(hdr, "SIMP") returns "SIMPLE" - s = qfits_header_findmatch(hdr, "HIERARCH ESO DET") returns - the first detector keyword among the HIERACH keys. - @endverbatim - */ -/*----------------------------------------------------------------------------*/ -char * qfits_header_findmatch(qfits_header * hdr, char * key) -{ - keytuple * k ; - - if (hdr==NULL || key==NULL) return NULL ; - - k = (keytuple*)hdr->first ; - while (k!=NULL) { - if (!strncmp(k->key, key, (int)strlen(key))) break ; - k=k->next ; - } - if (k==NULL) return NULL ; - return k->key ; -} diff --git a/xmemory/qfits_header.h b/xmemory/qfits_header.h deleted file mode 100644 index 148c17e..0000000 --- a/xmemory/qfits_header.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: qfits_header.h,v 1.8 2006/11/22 13:33:42 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/11/22 13:33:42 $ - * $Revision: 1.8 $ - * $Name: qfits-6_2_0 $ - */ - -#ifndef QFITS_HEADER_H -#define QFITS_HEADER_H - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -/*----------------------------------------------------------------------------- - New types - -----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief FITS header object - - This structure represents a FITS header in memory. It is actually no - more than a thin layer on top of the keytuple object. No field in this - structure should be directly modifiable by the user, only through - accessor functions. - */ -/*----------------------------------------------------------------------------*/ -typedef struct qfits_header { - void * first ; /* Pointer to list start */ - void * last ; /* Pointer to list end */ - int n ; /* Number of cards in list */ - /* For efficient looping internally */ - void * current ; - int current_idx ; -} qfits_header ; - -/*----------------------------------------------------------------------------- - Function ANSI prototypes - -----------------------------------------------------------------------------*/ - -qfits_header * qfits_header_new(void) ; -qfits_header * qfits_header_default(void) ; -void qfits_header_add(qfits_header *, const char *, const char *, const char *, - const char *) ; -void qfits_header_add_after(qfits_header *, const char *, const char *, - const char *, const char *, const char *) ; -void qfits_header_append(qfits_header *, const char *, const char *, - const char *, const char *) ; -void qfits_header_del(qfits_header *, const char *) ; -int qfits_header_sort(qfits_header **) ; -qfits_header * qfits_header_copy(const qfits_header *) ; -void qfits_header_mod(qfits_header *, const char *, const char *, const char *); -void qfits_header_destroy(qfits_header *) ; -char * qfits_header_getstr(const qfits_header *, const char *) ; -int qfits_header_getitem(const qfits_header *, int, char *, char *, char *, - char *) ; -char * qfits_header_getcom(const qfits_header *, const char *) ; -int qfits_header_getint(const qfits_header *, const char *, int) ; -double qfits_header_getdouble(const qfits_header *, const char *, double) ; -int qfits_header_getboolean(const qfits_header *, const char *, int) ; -int qfits_header_dump(const qfits_header *, FILE *) ; -char * qfits_header_getline(qfits_header * hdr, char * key) ; -char * qfits_header_findmatch(qfits_header * hdr, char * key) ; - -#endif diff --git a/xmemory/qfits_image.c b/xmemory/qfits_image.c deleted file mode 100644 index d0dbc2a..0000000 --- a/xmemory/qfits_image.c +++ /dev/null @@ -1,1491 +0,0 @@ -/* $Id: qfits_image.c,v 1.12 2006/02/23 11:25:25 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/02/23 11:25:25 $ - * $Revision: 1.12 $ - * $Name: qfits-6_2_0 $ - */ - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include -#include -#include -#include -#include -#include - -#include "config.h" - -#include "qfits_image.h" - -#include "qfits_rw.h" -#include "qfits_header.h" -#include "qfits_byteswap.h" -#include "qfits_tools.h" -#include "qfits_error.h" -#include "qfits_memory.h" - -/*----------------------------------------------------------------------------- - Defines - -----------------------------------------------------------------------------*/ - -#define QFITSLOADERINIT_MAGIC 0xcafe -/* Compute the number of bytes per pixel for a given BITPIX value */ -#define BYTESPERPIXEL(x) ( ((x) == BPP_8_UNSIGNED) ? 1 : \ - ((x) == BPP_16_SIGNED) ? 2 : \ - ((x) == BPP_32_SIGNED) ? 4 : \ - ((x) == BPP_IEEE_FLOAT) ? 4 : \ - ((x) == BPP_IEEE_DOUBLE) ? 8 : 0 ) - -/*----------------------------------------------------------------------------- - Function prototypes - -----------------------------------------------------------------------------*/ - -/* static float * qfits_pixin_float(byte *, int, int, double, double) ; */ -static int * qfits_pixin_int(byte *, int, int, double, double) ; -/* static double * qfits_pixin_double(byte *, int, int, double, double) ; */ -/* static byte * qfits_pixdump_float(float *, int, int) ; */ -/* static byte * qfits_pixdump_int(int *, int, int) ; */ -/* static byte * qfits_pixdump_double(double *, int, int) ; */ - -/*----------------------------------------------------------------------------*/ -/** - * @defgroup qfits_image Pixel loader for FITS images. - */ -/*----------------------------------------------------------------------------*/ -/**@{*/ - -/*----------------------------------------------------------------------------- - Function codes - -----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief Initialize a qfitsloader control object. - @param ql qfitsloader object to initialize. - @return int 0 if Ok, -1 if error occurred. - - This function expects a qfitsloader object with a number of input - fields correctly filled in. The minimum fields to set are: - - - filename: Name of the file to examine. - - xtnum: Extension number to examine (0 for main section). - - pnum: Plane number in the requested extension. - - map : loading mode - flag to know if the file has to be mapped - - You can go ahead with these fields only if you only want to get - file information for this plane in this extension. If you want - to later load the plane, you must additionally fill the 'ptype' - field to a correct value (PTYPE_INT, PTYPE_FLOAT, PTYPE_DOUBLE) - before calling qfits_loadpix() so that it knows which conversion - to perform. - - This function is basically a probe sent on a FITS file to ask - qfits if loading these data would be Ok or not. The actual loading - is performed by qfits_loadpix() afterwards. - */ -/*----------------------------------------------------------------------------*/ -int qfitsloader_init(qfitsloader * ql) -{ - qfits_header * fh ; - - int n_ext ; - int seg_start ; - int seg_size ; - int bitpix, naxis, naxis1, naxis2, naxis3 ; - char * xt_type ; - char * sval ; - struct stat sta ; - - /* Check passed object is allocated */ - if (ql==NULL) { - qfits_error("pixio: NULL loader"); - return -1 ; - } - /* Object must contain a filename */ - if (ql->filename == NULL) { - qfits_error("pixio: NULL filename in loader"); - return -1 ; - } - /* Check requested file exists and contains data */ - if (stat(ql->filename, &sta)!=0) { - qfits_error("no such file: %s", ql->filename); - return -1 ; - } - if (sta.st_size<1) { - qfits_error("empty file: %s", ql->filename); - return -1 ; - } - - /* Requested extension number must be positive */ - if (ql->xtnum<0) { - qfits_error("pixio: negative xtnum in loader"); - return -1 ; - } - /* Requested returned pixel type must be legal */ - if ((ql->ptype!=PTYPE_INT) && - (ql->ptype!=PTYPE_FLOAT) && - (ql->ptype!=PTYPE_DOUBLE)) { - qfits_error("pixio: invalid ptype in loader"); - return -1 ; - } - /* Check requested file is FITS */ - if (qfits_is_fits(ql->filename)!=1) { - qfits_error("pixio: not a FITS file: %s", ql->filename); - return -1 ; - } - /* Get number of extensions for this file */ - n_ext = qfits_query_n_ext(ql->filename); - if (n_ext==-1) { - qfits_error("pixio: cannot get number of extensions in %s", - ql->filename); - return -1 ; - } - /* Check requested extension falls within range */ - if (ql->xtnum > n_ext) { - qfits_error("pixio: requested extension %d but file %s has %d\n", - ql->xtnum, - ql->filename, - n_ext); - return -1 ; - } - ql->exts = n_ext ; - /* Get segment offset and size for the requested buffer */ - if (qfits_get_datinfo(ql->filename, - ql->xtnum, - &seg_start, - &seg_size)!=0) { - qfits_error("pixio: cannot get seginfo for %s extension %d", - ql->filename, - ql->xtnum); - return -1 ; - } - /* Check segment size is consistent with file size */ - if (sta.st_size < (seg_start+seg_size)) { - return -1 ; - } - ql->seg_start = seg_start ; - ql->seg_size = seg_size ; - - /* Get file header */ - fh = qfits_header_readext(ql->filename, ql->xtnum); - if (fh==NULL) { - qfits_error("pixio: cannot read header from ext %d in %s", - ql->xtnum, - ql->filename); - return -1 ; - } - /* If the requested image is within an extension */ - if (ql->xtnum>0) { - /* Check extension is an image */ - xt_type = qfits_header_getstr(fh, "XTENSION"); - if (xt_type==NULL) { - qfits_error("pixio: cannot read extension type for ext %d in %s", - ql->xtnum, - ql->filename); - qfits_header_destroy(fh); - return -1 ; - } - xt_type = qfits_pretty_string(xt_type); - if (strcmp(xt_type, "IMAGE")) { - qfits_error( - "pixio: not an image -- extension %d in %s has type [%s]", - ql->xtnum, - ql->filename, - xt_type); - qfits_header_destroy(fh); - return -1 ; - } - } - - /* Get file root informations */ - bitpix = qfits_header_getint(fh, "BITPIX", -1); - naxis = qfits_header_getint(fh, "NAXIS", -1); - naxis1 = qfits_header_getint(fh, "NAXIS1", -1); - naxis2 = qfits_header_getint(fh, "NAXIS2", -1); - naxis3 = qfits_header_getint(fh, "NAXIS3", -1); - - /* Get BSCALE and BZERO if available */ - sval = qfits_header_getstr(fh, "BSCALE"); - if (sval==NULL) { - ql->bscale = 1.0 ; - } else { - ql->bscale = atof(sval); - } - sval = qfits_header_getstr(fh, "BZERO"); - if (sval==NULL) { - ql->bzero = 0.0 ; - } else { - ql->bzero = atof(sval); - } - - /* Destroy header */ - qfits_header_destroy(fh); - - /* Check BITPIX is present */ - if (bitpix==-1) { - qfits_error("pixio: missing BITPIX in file %s", ql->filename); - return -1 ; - } - /* Check BITPIX is valid */ - if ((bitpix!= 8) && - (bitpix!= 16) && - (bitpix!= 32) && - (bitpix!= -32) && - (bitpix!= -64)) { - qfits_error("pixio: invalid BITPIX (%d) in file %s", - bitpix, - ql->filename); - return -1 ; - } - ql->bitpix = bitpix ; - - /* Check NAXIS is present and valid */ - if (naxis<0) { - qfits_error("pixio: no NAXIS in file %s", ql->filename); - return -1 ; - } - if (naxis==0) { - qfits_error("pixio: no pixel in ext %d of file %s", - ql->xtnum, - ql->filename); - return -1 ; - } - if (naxis>3) { - qfits_error("pixio: NAXIS>3 (%d) unsupported", naxis); - return -1 ; - } - /* NAXIS1 must always be present */ - if (naxis1<0) { - qfits_error("pixio: no NAXIS1 in file %s", ql->filename); - return -1 ; - } - /* Update dimension fields in loader struct */ - ql->lx = 1 ; - ql->ly = 1 ; - ql->np = 1 ; - - switch (naxis) { - case 1: - ql->lx = naxis1 ; - break ; - - case 3: - if (naxis3<0) { - qfits_error("pixio: no NAXIS3 in file %s", ql->filename); - return -1 ; - } - ql->np = naxis3 ; - /* No break statement: intended to go through next case */ - - case 2: - if (naxis2<0) { - qfits_error("pixio: no NAXIS2 in file %s", ql->filename); - return -1 ; - } - ql->ly = naxis2 ; - ql->lx = naxis1 ; - break ; - } - /* Check that requested plane number falls within range */ - if (ql->pnum >= ql->np) { - qfits_error("pixio: requested plane %d but NAXIS3=%d", - ql->pnum, - ql->np); - return -1 ; - } - - /* Everything Ok, fields have been filled along. */ - /* Mark the structure as initialized */ - ql->_init = QFITSLOADERINIT_MAGIC ; - return 0 ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Load a pixel buffer for one complete image. - @param ql Allocated and initialized qfitsloader control object. - @return int 0 if Ok, -1 if error occurred. - @see qfits_loadpix_window -*/ -/*----------------------------------------------------------------------------*/ -int qfits_loadpix(qfitsloader * ql) -{ - if (ql==NULL) return -1 ; - return qfits_loadpix_window(ql, 1, 1, ql->lx, ql->ly) ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Load a pixel buffer for one image window - @param ql Allocated and initialized qfitsloader control object. - @param llx - @param lly Position of the window (start with (1,1)) - @param urx - @param ury - @return int 0 if Ok, -1 if error occurred. - - This function performs a load of a pixel buffer into memory. It - expects an allocated and initialized qfitsloader object in input. - See qfitsloader_init() about initializing the object. - - This function will fill up the ibuf/fbuf/dbuf field, depending - on the requested pixel type (resp. int, float or double). - - If llx lly urx and ury do not specify the whole image, ql->map must be 0, - we do not want to mmap a file an load only a part of it. - */ -/*----------------------------------------------------------------------------*/ -int qfits_loadpix_window( - qfitsloader * ql, - int llx, - int lly, - int urx, - int ury) -{ - byte * fptr ; - size_t fsize ; - int datastart ; - int imagesize, window_size, linesize ; - FILE * lfile ; - int dataread ; - int nx, ny ; - int i ; - - /* Check inputs */ - if (ql==NULL) return -1 ; - if (ql->_init != QFITSLOADERINIT_MAGIC) { - qfits_error("pixio: called with unitialized obj"); - return -1 ; - } - if (llx>urx || lly>ury || llx<1 || lly<1 || urx>ql->lx || ury>ql->ly) { - qfits_error("pixio: invalid window specification"); - return -1 ; - } - - /* No map if only a zone is specified */ - if (llx != 1 || lly != 1 || urx != ql->lx || ury != ql->ly) { - if (ql->map == 1) { - qfits_error("pixio: cannot mmap for a part of the image"); - return -1 ; - } - } - - /* Initialise */ - nx = urx-llx+1 ; - ny = ury-lly+1 ; - imagesize = ql->lx * ql->ly * BYTESPERPIXEL(ql->bitpix); - window_size = nx * ny * BYTESPERPIXEL(ql->bitpix); - linesize = nx * BYTESPERPIXEL(ql->bitpix); - datastart = ql->seg_start + ql->pnum * imagesize ; - - /* Check loading mode */ - if (ql->map) { - /* Map the file in */ - fptr = (byte*)qfits_falloc(ql->filename, datastart, &fsize); - if (fptr==NULL) { - qfits_error("pixio: cannot falloc(%s)", ql->filename); - return -1 ; - } - } else { - /* Open the file */ - if ((lfile=fopen(ql->filename, "r"))==NULL) { - qfits_error("pixio: cannot open %s", ql->filename); - return -1 ; - } - /* Go to the start of the image */ - if (fseek(lfile, datastart, SEEK_SET)!=0) { - qfits_error("pixio: cannot seek %s", ql->filename); - fclose(lfile); - return -1 ; - } - /* Go to the start of the zone */ - if (fseek(lfile, (llx-1+(lly-1)*ql->lx)*BYTESPERPIXEL(ql->bitpix), - SEEK_CUR)!=0) { - qfits_error("pixio: cannot seek %s", ql->filename); - fclose(lfile); - return -1 ; - } - - fptr = (byte*)qfits_malloc(window_size) ; - - /* Only a window is specified */ - if (llx != 1 || lly != 1 || urx != ql->lx || ury != ql->ly) { - /* Loop on the lines */ - for (i=0 ; ifilename); - return -1 ; - } - /* Go to the next line */ - if (fseek(lfile,ql->lx*BYTESPERPIXEL(ql->bitpix)-linesize, - SEEK_CUR)!=0){ - qfits_error("pixio: cannot seek %s", ql->filename); - fclose(lfile); - return -1 ; - } - } - fclose(lfile); - } else { - /* The whole image is specified */ - dataread = fread(fptr, sizeof(byte), window_size, lfile); - fclose(lfile); - if (dataread!=window_size) { - qfits_free(fptr) ; - qfits_error("pixio: cannot read from %s", ql->filename); - return -1 ; - } - } - } - - /* Initialize buffer pointers */ - ql->ibuf = NULL ; - ql->fbuf = NULL ; - ql->dbuf = NULL ; - - /* - * Special cases: mapped file is identical to requested format. - * This is only possible on big-endian machines, since FITS is - * big-endian only. - */ -#ifdef WORDS_BIGENDIAN - if (ql->ptype==PTYPE_FLOAT && ql->bitpix==-32) { - ql->fbuf = (float*)fptr ; - return 0 ; - } - if (ql->ptype==PTYPE_DOUBLE && ql->bitpix==-64) { - ql->dbuf = (double*)fptr ; - return 0 ; - } - if (ql->ptype==PTYPE_INT && ql->bitpix==32) { - ql->ibuf = (int*)fptr ; - return 0 ; - } -#endif - - /* General case: fallback to dedicated conversion function */ - switch (ql->ptype) { - case PTYPE_FLOAT: - ql->fbuf = qfits_pixin_float( fptr, - nx * ny, - ql->bitpix, - ql->bscale, - ql->bzero); - break ; - - case PTYPE_INT: - ql->ibuf = qfits_pixin_int( fptr, - nx * ny, - ql->bitpix, - ql->bscale, - ql->bzero); - break ; - - case PTYPE_DOUBLE: - ql->dbuf = qfits_pixin_double( fptr, - nx * ny, - ql->bitpix, - ql->bscale, - ql->bzero); - break ; - } - - if (ql->map) { - qfits_fdealloc((char*)fptr, datastart, fsize) ; - } else { - qfits_free(fptr); - } - - if (ql->ibuf==NULL && ql->fbuf==NULL && ql->dbuf==NULL) { - qfits_error("pixio: error during conversion"); - return -1 ; - } - return 0 ; -} - -/*----------------------------------------------------------------------------*/ -/** - @brief Dump a pixel buffer to an output FITS file in append mode. - @param qd qfitsdumper control object. - @return int 0 if Ok, -1 otherwise. - - This function takes in input a qfitsdumper control object. This object - must be allocated beforehand and contain valid references to the data - to save, and how to save it. - - The minimum fields to fill are: - - - filename: Name of the FITS file to dump to. - - npix: Number of pixels in the buffer to be dumped. - - ptype: Type of the passed buffer (PTYPE_FLOAT, PTYPE_INT, PTYPE_DOUBLE) - - out_ptype: Requested FITS BITPIX for the output. - - One of the following fields must point to the corresponding pixel - buffer: - - - ibuf for an int pixel buffer (ptype=PTYPE_INT) - - fbuf for a float pixel buffer (ptype=PTYPE_FLOAT) - - dbuf for a double pixel buffer (ptype=PTYPE_DOUBLE) - - This is a fairly low-level function, in the sense that it does not - check that the output file already contains a proper header or even - that the file it is appending to is indeed a FITS file. It will - convert the pixel buffer to the requested BITPIX type and append - the data to the file, without padding with zeros. See qfits_zeropad() - about padding. - - If the given output file name is "STDOUT" (all caps), the dump - will be performed to stdout. - */ -/*----------------------------------------------------------------------------*/ -int qfits_pixdump(qfitsdumper * qd) -{ - FILE * f_out ; - byte * buf_out ; - int buf_free ; - int buf_sz ; - - /* Check inputs */ - if (qd==NULL) return -1 ; - if (qd->filename==NULL) return -1 ; - switch (qd->ptype) { - case PTYPE_FLOAT: - if (qd->fbuf==NULL) return -1 ; - break ; - - case PTYPE_DOUBLE: - if (qd->dbuf==NULL) return -1 ; - break ; - - case PTYPE_INT: - if (qd->ibuf==NULL) return -1 ; - break ; - - default: - return -1 ; - } - if (qd->npix <= 0) { - qfits_error("Negative or NULL number of pixels specified"); - return -1 ; - } - - /* - * Special cases: input buffer is identical to requested format. - * This is only possible on big-endian machines, since FITS is - * big-endian only. - */ - buf_out = NULL ; - buf_free = 1 ; -#ifdef WORDS_BIGENDIAN - if (qd->ptype==PTYPE_FLOAT && qd->out_ptype==-32) { - buf_out = (byte*)qd->fbuf ; - buf_free=0 ; - } else if (qd->ptype==PTYPE_DOUBLE && qd->out_ptype==-64) { - buf_out = (byte*)qd->dbuf ; - buf_free=0 ; - } else if (qd->ptype==PTYPE_INT && qd->out_ptype==32) { - buf_out = (byte*)qd->ibuf ; - buf_free=0 ; - } -#endif - buf_sz = qd->npix * BYTESPERPIXEL(qd->out_ptype); - - /* General case */ - if (buf_out==NULL) { - switch (qd->ptype) { - /* Convert buffer */ - case PTYPE_FLOAT: - buf_out = qfits_pixdump_float( qd->fbuf, - qd->npix, - qd->out_ptype); - break ; - - /* Convert buffer */ - case PTYPE_INT: - buf_out = qfits_pixdump_int( qd->ibuf, - qd->npix, - qd->out_ptype); - break ; - - /* Convert buffer */ - case PTYPE_DOUBLE: - buf_out = qfits_pixdump_double( qd->dbuf, - qd->npix, - qd->out_ptype); - break ; - } - } - if (buf_out==NULL) { - qfits_error("cannot dump pixel buffer"); - return -1 ; - } - - /* Dump buffer */ - if (!strncmp(qd->filename, "STDOUT", 6)) { - f_out = stdout ; - } else { - f_out = fopen(qd->filename, "a"); - } - if (f_out==NULL) { - qfits_free(buf_out); - return -1 ; - } - fwrite(buf_out, buf_sz, 1, f_out); - if (buf_free) { - qfits_free(buf_out); - } - if (f_out!=stdout) { - fclose(f_out); - } - return 0 ; -} - -/**@}*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief Convert a float pixel buffer to a byte buffer. - @param buf Input float buffer. - @param npix Number of pixels in the input buffer. - @param ptype Requested output BITPIX type. - @return 1 pointer to a newly allocated byte buffer. - - This function converts the given float buffer to a buffer of bytes - suitable for dumping to a FITS file (i.e. big-endian, in the - requested pixel type). The returned pointer must be deallocated - using the qfits_free() function. - */ -/*----------------------------------------------------------------------------*/ -byte * qfits_pixdump_float(float * buf, int npix, int ptype) -{ - byte * buf_out ; - register byte * op ; - int i ; - int lpix ; - short spix ; - double dpix ; - - buf_out = qfits_malloc(npix * BYTESPERPIXEL(ptype)); - op = buf_out ; - switch (ptype) { - case 8: - /* Convert from float to 8 bits */ - for (i=0 ; i255.0) { - *op++ = (byte)0xff ; - } else if (buf[i]<0.0) { - *op++ = (byte)0x00 ; - } else { - *op++ = (byte)buf[i]; - } - } - break ; - - case 16: - /* Convert from float to 16 bits */ - for (i=0 ; i32767.0) { - *op++ = (byte)0x7f ; - *op++ = (byte)0xff ; - } else if (buf[i]<-32768.0) { - *op++ = (byte)0x80 ; - *op++ = 0x00 ; - } else { - spix = (short)buf[i]; - *op++ = (spix >> 8) ; - *op++ = (spix & (byte)0xff) ; - } - } - break ; - - case 32: - /* Convert from float to 32 bits */ - for (i=0 ; i 2147483647.0) { - *op++ = (byte)0x7f ; - *op++ = (byte)0xff ; - *op++ = (byte)0xff ; - *op++ = (byte)0xff ; - } else if (buf[i]<-2147483648.0) { - *op++ = (byte)0x80 ; - *op++ = (byte)0x00 ; - *op++ = (byte)0x00 ; - *op++ = (byte)0x00 ; - } else { - lpix = (int)buf[i] ; - *op++ = (byte)(lpix >> 24) ; - *op++ = (byte)(lpix >> 16) & 0xff ; - *op++ = (byte)(lpix >> 8 ) & 0xff ; - *op++ = (byte)(lpix) & 0xff ; - } - } - break ; - - case -32: - /* Convert from float to float */ - memcpy(op, buf, npix * sizeof(float)); -#ifndef WORDS_BIGENDIAN - for (i=0 ; i255) { - *op++ = (byte)0xff ; - } else if (buf[i]<0) { - *op++ = (byte)0x00 ; - } else { - *op++ = (byte)buf[i] ; - } - } - break ; - - case 16: - /* Convert from int32 to 16 bits */ - for (i=0 ; i32767) { - spix = 32767 ; - } else if (buf[i]<-32768) { - spix = -32768 ; - } else { - spix = (short)buf[i] ; - } -#ifndef WORDS_BIGENDIAN - qfits_swap_bytes(&spix, 2); -#endif - memcpy(op, &spix, 2); - op += 2 ; - } - break ; - - case 32: - /* Convert from int32 to 32 bits */ - memcpy(op, buf, npix * sizeof(int)); -#ifndef WORDS_BIGENDIAN - for (i=0 ; i255.0) { - *op++ = (byte)0xff ; - } else if (buf[i]<0.0) { - *op++ = (byte)0x00 ; - } else { - *op++ = (byte)buf[i] ; - } - } - break ; - - case 16: - /* Convert from double to 16 bits */ - for (i=0 ; i32767.0) { - spix = 32767 ; - } else if (buf[i]<-32768.0) { - spix = -32768 ; - } else { - spix = (short)buf[i] ; - } -#ifndef WORDS_BIGENDIAN - qfits_swap_bytes(&spix, 2); -#endif - memcpy(op, &spix, 2); - op += 2 ; - } - break ; - - case 32: - /* Convert from double to 32 bits */ - for (i=0 ; i 2147483647.0) { - lpix = 2147483647 ; - } else if (buf[i] < -2147483648.0) { - lpix = -2147483647 ; - } else { - lpix = (int)buf[i]; - } -#ifndef WORDS_BIGENDIAN - qfits_swap_bytes(&lpix, 4); -#endif - memcpy(op, &lpix, 4); - op += 4 ; - } - break ; - - case -32: - /* Convert from double to float */ - for (i=0 ; ifilename, - ql->xtnum, - ql->pnum, - ql->ptype, - ql->lx, - ql->ly, - ql->np, - ql->bitpix, - ql->seg_start, - ql->bscale, - ql->bzero, - ql->ibuf, - ql->fbuf, - ql->dbuf); -} - -int main (int argc, char * argv[]) -{ - qfitsloader ql ; - - if (argc<2) { - printf("use: %s \n", argv[0]); - return 1 ; - } - - ql.filename = argv[1] ; - ql.xtnum = 0 ; - ql.pnum = 0 ; - ql.ptype = PTYPE_FLOAT ; - - if (qfits_loadpix(&ql)!=0) { - printf("error occurred during loading: abort\n"); - return -1 ; - } - qfitsloader_dump(&ql); - printf("pix[0]=%g\n" - "pix[100]=%g\n" - "pix[10000]=%g\n", - ql.fbuf[0], - ql.fbuf[100], - ql.fbuf[10000]); - qfits_free(ql.fbuf); - - ql.ptype = PTYPE_INT ; - if (qfits_loadpix(&ql)!=0) { - printf("error occurred during loading: abort\n"); - return -1 ; - } - qfitsloader_dump(&ql); - printf("pix[0]=%d\n" - "pix[100]=%d\n" - "pix[10000]=%d\n", - ql.ibuf[0], - ql.ibuf[100], - ql.ibuf[10000]); - qfits_free(ql.ibuf); - - - ql.ptype = PTYPE_DOUBLE ; - if (qfits_loadpix(&ql)!=0) { - printf("error occurred during loading: abort\n"); - return -1 ; - } - qfitsloader_dump(&ql); - printf("pix[0]=%g\n" - "pix[100]=%g\n" - "pix[10000]=%g\n", - ql.dbuf[0], - ql.dbuf[100], - ql.dbuf[10000]); - qfits_free(ql.dbuf); - - return 0 ; -} -#endif diff --git a/xmemory/qfits_image.h b/xmemory/qfits_image.h deleted file mode 100644 index e053615..0000000 --- a/xmemory/qfits_image.h +++ /dev/null @@ -1,274 +0,0 @@ -/* $Id: qfits_image.h,v 1.9 2006/02/23 11:04:17 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/02/23 11:04:17 $ - * $Revision: 1.9 $ - * $Name: qfits-6_2_0 $ - */ - -#ifndef QFITS_IMAGE_H -#define QFITS_IMAGE_H - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include -#include -#include -#include - -/*----------------------------------------------------------------------------- - Defines - -----------------------------------------------------------------------------*/ - -/** Symbol to set returned pixel type to float */ -#define PTYPE_FLOAT 0 -/** Symbol to set returned pixel type to int */ -#define PTYPE_INT 1 -/** Symbol to set returned pixel type to double */ -#define PTYPE_DOUBLE 2 - -/* FITS pixel depths */ -/* FITS BITPIX=8 */ -#define BPP_8_UNSIGNED (8) -/* FITS BITPIX=16 */ -#define BPP_16_SIGNED (16) -/* FITS BITPIX=32 */ -#define BPP_32_SIGNED (32) -/* FITS BITPIX=-32 */ -#define BPP_IEEE_FLOAT (-32) -/* FITS BITPIX=-64 */ -#define BPP_IEEE_DOUBLE (-64) -/* Default BITPIX for output */ -#define BPP_DEFAULT BPP_IEEE_FLOAT - -/*----------------------------------------------------------------------------- - New types - -----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/** - @brief Alias for unsigned char - - A 'byte' is just an alias for an unsigned char. It is only defined - for readability. - */ -/*----------------------------------------------------------------------------*/ -typedef unsigned char byte ; - -/*----------------------------------------------------------------------------*/ -/** - @brief qfits loader control object - - This structure serves two purposes: input and output for the qfits - pixel loading facility. To request pixels from a FITS file, you - need to allocate (statically or dynamically) such a structure and - fill up the input fields (filename, xtension number, etc.) to specify - the pixels you want from the file. - - Before performing the actual load, you must pass the initialized - structure to qfitsloader_init() which will check whether the operation - is feasible or not (check its returned value). - - If the operation was deemed feasible, you can proceed to load the pixels, - passing the same structure to qfits_loadpix() which will fill up the - output fields of the struct. Notice that a pixel buffer will have been - allocated (through malloc or mmap) and placed into the structure. You - need to call free() on this pointer when you are done with it, - typically in the image or cube destructor. - - The qfitsloader_init() function is also useful to probe a FITS file - for useful informations, like getting the size of images in the file, - the pixel depth, or data offset. - - Example of a code that prints out various informations about - a plane to load, without actually loading it: - - @code -int main(int argc, char * argv[]) -{ - qfitsloader ql ; - - ql.filename = argv[1] ; - ql.xtnum = 0 ; - ql.pnum = 0 ; - - if (qfitsloader_init(&ql)!=0) { - printf("cannot read info about %s\n", argv[1]); - return -1 ; - } - - printf( "file : %s\n" - "xtnum : %d\n" - "pnum : %d\n" - "# xtensions : %d\n" - "size X : %d\n" - "size Y : %d\n" - "planes : %d\n" - "bitpix : %d\n" - "datastart : %d\n" - "datasize : %d\n" - "bscale : %g\n" - "bzero : %g\n", - ql.filename, - ql.xtnum, - ql.pnum, - ql.exts, - ql.lx, - ql.ly, - ql.np, - ql.bitpix, - ql.seg_start, - ql.seg_size, - ql.bscale, - ql.bzero); - return 0 ; -} - @endcode - */ -/*----------------------------------------------------------------------------*/ -typedef struct qfitsloader { - - /** Private field to see if structure has been initialized */ - int _init ; - - /** input: Name of the file you want to read pixels from */ - char * filename ; - /** input: xtension number you want to read */ - int xtnum ; - /** input: Index of the plane you want, from 0 to np-1 */ - int pnum ; - /** input: Pixel type you want (PTYPE_FLOAT, PTYPE_INT or PTYPE_DOUBLE) */ - int ptype ; - /** input: Guarantee file copy or allow file mapping */ - int map ; - - /** output: Total number of extensions found in file */ - int exts ; - /** output: Size in X of the requested plane */ - int lx ; - /** output: Size in Y of the requested plane */ - int ly ; - /** output: Number of planes present in this extension */ - int np ; - /** output: BITPIX for this extension */ - int bitpix ; - /** output: Start of the data segment (in bytes) for your request */ - int seg_start ; - /** output: Size of the data segment (in bytes) for your request */ - int seg_size ; - /** output: BSCALE found for this extension */ - double bscale ; - /** output: BZERO found for this extension */ - double bzero ; - - /** output: Pointer to pixel buffer loaded as integer values */ - int * ibuf ; - /** output: Pointer to pixel buffer loaded as float values */ - float * fbuf ; - /** output: Pointer to pixel buffer loaded as double values */ - double * dbuf ; - -} qfitsloader ; - - -/*----------------------------------------------------------------------------*/ -/** - @brief qfits dumper control object - - This structure offers various control parameters to dump a pixel - buffer to a FITS file. The buffer will be dumped as requested - to the requested file in append mode. Of course, the requested file - must be writeable for the operation to succeed. - - The following example demonstrates how to save a linear ramp sized - 100x100 to a FITS file with BITPIX=16. Notice that this code only - dumps the pixel buffer, no header information is provided in this - case. - - @code - int i, j ; - int * ibuf ; - qfitsdumper qd ; - - // Fill a buffer with 100x100 int pixels - ibuf = malloc(100 * 100 * sizeof(int)); - for (j=0 ; j<100 ; j++) { - for (i=0 ; i<100 ; i++) { - ibuf[i+j*100] = i+j ; - } - } - - qd.filename = "out.fits" ; // Output file name - qd.npix = 100 * 100 ; // Number of pixels - qd.ptype = PTYPE_INT ; // Input buffer type - qd.ibuf = ibuf ; // Set buffer pointer - qd.out_ptype = BPP_16_SIGNED ; // Save with BITPIX=16 - - // Dump buffer to file (error checking omitted for clarity) - qfits_pixdump(&qd); - - free(ibuf); - @endcode - - If the provided output file name is "STDOUT" (all capitals), the - function will dump the pixels to the stdout steam (usually the console, - could have been re-directed). - */ -/*----------------------------------------------------------------------------*/ -typedef struct qfitsdumper { - - /** Name of the file to dump to, "STDOUT" to dump to stdout */ - char * filename ; - /** Number of pixels in the buffer to dump */ - int npix ; - /** Buffer type: PTYPE_FLOAT, PTYPE_INT or PTYPE_DOUBLE */ - int ptype ; - - /** Pointer to input integer pixel buffer */ - int * ibuf ; - /** Pointer to input float pixel buffer */ - float * fbuf ; - /** Pointer to input double pixel buffer */ - double * dbuf ; - - /** Requested BITPIX in output FITS file */ - int out_ptype ; -} qfitsdumper ; - -/*----------------------------------------------------------------------------- - Function prototypes - -----------------------------------------------------------------------------*/ - -int qfitsloader_init(qfitsloader *) ; -int qfits_loadpix(qfitsloader *) ; -int qfits_loadpix_window(qfitsloader *, int, int, int, int) ; -int qfits_pixdump(qfitsdumper *) ; -double * qfits_pixin_double(byte *, int, int, double, double) ; -byte * qfits_pixdump_double(double *, int, int) ; -byte * qfits_pixdump_int(int *, int, int) ; -float * qfits_pixin_float(byte *, int, int, double, double) ; -int qfits_pixin_floatbuf(byte *, int, int, double, double, float *) ; -byte * qfits_pixdump_float(float *, int, int) ; - -#endif diff --git a/xmemory/qfits_memory.c b/xmemory/qfits_memory.c deleted file mode 100644 index 55c3420..0000000 --- a/xmemory/qfits_memory.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $Id: qfits_memory.c,v 1.4 2006/08/24 15:01:56 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/08/24 15:01:56 $ - * $Revision: 1.4 $ - * $Name: qfits-6_2_0 $ - */ - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include -#include -#include -/* #include -#include -#include -#include -#include -#include */ - -/*----------------------------------------------------------------------------*/ -/** - @brief Map a file's contents to memory as a char pointer. - @param name Name of the file to map - @param offs Offset to the first mapped byte in file. - @param size Returned size of the mapped file in bytes. - @param srcname Name of the source file making the call. - @param srclin Line # where the call was made. - @return A pointer to char, to be freed using qfits_memory_free(). - - This function takes in input the name of a file. It tries to map the file - into memory and if it succeeds, returns the file's contents as a char pointer. - It also modifies the input size variable to be the size of the mapped file in - bytes. This function is normally never directly called but through the - falloc() macro. - - The offset indicates the starting point for the mapping, i.e. if you are not - interested in mapping the whole file but only from a given place. - - The returned pointer ptr must be deallocated with qfits_memory_fdealloc(ptr) - */ -/*----------------------------------------------------------------------------*/ -char * qfits_memory_falloc( - char * name, - size_t offs, - size_t * size, - const char * srcname, - int srclin) -{ - char *t; - struct stat sta; - FILE *thefile; - - if (stat(name, &sta)==-1) { - return NULL; - } - if ((t = (char *) malloc((sta.st_size-offs+1)*sizeof(char)))) { - if ((thefile = fopen(name, "r"))) { - fseek(thefile, offs, SEEK_SET); - fread(t, sizeof(char), sta.st_size-offs+1, thefile); - fclose(thefile); - if (size!=NULL) { - (*size) = sta.st_size ; - } - } - } - return t; -} - - -/*----------------------------------------------------------------------------*/ -/** - @brief Free memory that has been allocated with falloc - @param ptr Pointer to free. - @param offs Offset to the first mapped byte in file. - @param size size to unmap - @param filename Name of the file where the dealloc took place. - @param lineno Line number in the file. - @return void - */ -/*----------------------------------------------------------------------------*/ -void qfits_memory_fdealloc( - void * ptr, - size_t offs, - size_t size, - const char * filename, - int lineno) -{ - free(ptr); -} - diff --git a/xmemory/qfits_memory.h b/xmemory/qfits_memory.h deleted file mode 100644 index 7a3c393..0000000 --- a/xmemory/qfits_memory.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $Id: qfits_memory.h,v 1.3 2006/02/23 14:15:13 yjung Exp $ - * - * This file is part of the ESO QFITS Library - * Copyright (C) 2001-2004 European Southern Observatory - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * $Author: yjung $ - * $Date: 2006/02/23 14:15:13 $ - * $Revision: 1.3 $ - * $Name: qfits-6_2_0 $ - */ - -#ifndef QFITS_MEMORY_H -#define QFITS_MEMORY_H - -/*----------------------------------------------------------------------------- - Includes - -----------------------------------------------------------------------------*/ - -#include -#include -#include - -/*----------------------------------------------------------------------------- - Defines - -----------------------------------------------------------------------------*/ - -#define qfits_malloc(s) malloc(s) -#define qfits_calloc(n,s) calloc(n,s) -#define qfits_realloc(p,s) realloc(p,s) -#define qfits_free(p) free(p) -#define qfits_strdup(s) strdup(s) -#define qfits_falloc(f,o,s) qfits_memory_falloc(f,o,s, __FILE__,__LINE__) -#define qfits_fdealloc(f,o,s) qfits_memory_fdealloc(f,o,s,__FILE__,__LINE__) - -/*----------------------------------------------------------------------------- - Function prototypes - -----------------------------------------------------------------------------*/ - -/* *********************************************************************** */ -/* These functions have to be called by the assiciated macro defined above */ -/* void * qfits_memory_malloc(size_t, const char *, int) ; -void * qfits_memory_calloc(size_t, size_t, const char *, int) ; -void * qfits_memory_realloc(void *, size_t, const char *, int) ; -void qfits_memory_free(void *, const char *, int) ; -char * qfits_memory_strdup(const char *, const char *, int) ; */ -char * qfits_memory_falloc(char *, size_t, size_t *, const char *, int) ; -void qfits_memory_fdealloc(void *, size_t, size_t, const char *, int) ; -/* *********************************************************************** */ - -/* void qfits_memory_status(void) ; - int qfits_memory_is_empty(void) ; */ - -#endif