fitsTcl/ 0000755 0002307 0000036 00000000000 11222720662 011060 5 ustar chai lhea fitsTcl/fvTcl.c 0000644 0002307 0000036 00000033354 11222720662 012312 0 ustar chai lhea /************************************************************
*
* fvTcl.c
*
* This holds all the fv-specific Tcl commands
*
***********************************************************/
#include "fitsTclInt.h"
/*
* ------------------------------------------------------------
*
* isFitsCmd
* check for fits file
* usage : isFits filename (1 is, 0 no)
*
* ------------------------------------------------------------
*/
int isFitsCmd( ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[])
{
char simple[10];
int i;
FILE *fitsPtr;
if( argc != 2 ) {
Tcl_SetResult(interp, "Usage: isFits filename", TCL_STATIC);
return TCL_ERROR;
}
/* check if it's a remote file */
if ( !strncmp(argv[1], "ftp://", 6)
|| !strncmp(argv[1], "http://", 7) ) {
Tcl_SetResult(interp, "2", TCL_STATIC);
return TCL_OK;
}
/* also pass if it's a fv script file */
if( strstr(argv[1], ".fv") ) {
Tcl_SetResult(interp, "3", TCL_STATIC);
return TCL_OK;
}
/* skip IRAF files end with .imh */
if( strstr(argv[1], ".imh") ) {
Tcl_SetResult(interp, "4", TCL_STATIC);
return TCL_OK;
}
if( (fitsPtr = fopen(argv[1], "r")) == NULL ) {
Tcl_AppendResult(interp, "File not found: ", argv[1], (char*)NULL );
return TCL_ERROR;
}
fgets(simple, 7, fitsPtr);
/* to catch a zero length file */
/* if( strlen(simple) < 6 ) { */
if( strlen(simple) <= 0 ) {
Tcl_SetResult(interp, "0", TCL_STATIC);
/* real FITS file */
} else if( !strcmp(simple, "SIMPLE") ) {
for ( i = 0; i< 100; i++) {
if ( (fgetc(fitsPtr) == '\n') || (fgetc(fitsPtr) == '\r') ) {
Tcl_SetResult(interp, "0", TCL_STATIC);
break;
}
Tcl_SetResult(interp, "1", TCL_STATIC);
}
/* compressed file. should check if its FITS */
} else if( strncmp(simple, "\037\036", 2) == 0 ||
strncmp(simple, "\037\213", 2) == 0 ||
strncmp(simple, "\037\240", 2) == 0 ||
strncmp(simple, "\037\235", 2) == 0 ||
strncmp(simple, "\120\113", 2) == 0 ) {
/* return 2 if the file is compressed files */
Tcl_SetResult(interp, "2", TCL_STATIC);
} else {
Tcl_SetResult(interp, "0", TCL_STATIC);
}
fclose(fitsPtr);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* getMaxCmd
* pick out the maximum
*
* ------------------------------------------------------------
*/
int getMaxCmd( ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[] )
{
int i, numCount, j;
char **arrayPtr;
double theMax, tmp;
char theMaxStr[40];
if( argc == 1 ) {
Tcl_SetResult(interp, "getmax list ?list? ...", TCL_STATIC);
return TCL_OK;
}
theMaxStr[39]='\0';
for (i=1; i theMax ) {
theMax = tmp;
strncpy(theMaxStr, arrayPtr[j], 39);
}
}
ckfree((char *) arrayPtr);
}
Tcl_SetResult(interp, theMaxStr, TCL_VOLATILE);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* getMinCmd
* pick out the minimum
*
* ------------------------------------------------------------
*/
int getMinCmd( ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[] )
{
int i, numCount, j;
char **arrayPtr;
double theMin, tmp;
char theMinStr[40];
if( argc == 1 ) {
Tcl_SetResult(interp, "getmin list", TCL_STATIC);
return TCL_OK;
}
theMinStr[39] = '\0';
for (i=1; i tmpWidth ) {
Tcl_SetVar2Ex(interp, "_numEntry", index1,
overflowObj, TCL_NAMESPACE_ONLY);
} else {
Tcl_SetVar2Ex(interp, "_numEntry", index1,
valObj, TCL_NAMESPACE_ONLY);
}
}
}
return TCL_OK;
}
fitsTcl/fitstcl.dsw 0000644 0002307 0000036 00000001031 11222720662 013242 0 ustar chai lhea Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "fitstcl"=.\fitstcl.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
fitsTcl/Makefile.in 0000644 0002307 0000036 00000023561 11222720662 013134 0 ustar chai lhea # FITS TCL makefile.in
# $Id: Makefile.in,v 1.17 2006/09/25 15:27:02 irby Exp $
#----------------------------------------------------------------------------
# Definitions:
#----------------------------------------------------------------------------
LIBRARY = fitstcl
CFILES = fitsInit.c fitsUtils.c fitsTcl.c fitsCmds.c fitsIO.c fvTcl.c
SHARED_CFILE = tclShared.c
OBJECTS = ${CFILES:.c=.o}
LOCAL_OBJ = ${OBJECTS} ${SHARED_CFILE:.c=.o}
SHARED_OBJ = ${LOCAL_OBJ} ${CFITSIO_DIR}/*.o
STATIC_LIB = lib${LIBRARY}.a
SHARED_LIB = lib${LIBRARY}${SHLIB_SUFFIX}
IFLAGS = -I${CFITSIO_DIR} -I${TCL_INC_PATH}
#----------------------------------------------------------------------------
# Configurable macros:
#----------------------------------------------------------------------------
INSTALLDIR = @prefix@
CC = @CC@
RANLIB = @RANLIB@
CFLAGS = @CFLAGS@
DEFS = @DEFS@
C_LIB_OPTION = @C_LIB_OPTION@
SHLIB_SUFFIX = @SHLIB_SUFFIX@
SHLIB_LD = @SHLIB_LD@
LD_FLAGS = @LD_FLAGS@
TCL_INC_PATH = @TCL_INC_PATH@
TCL_LIB_PATH = @TCL_PATH@
TCL_LIB = @TCL_LIB@
CFITSIO_DIR = @CFITSIODIR@
SHLIB_LD_LIBS = @LIBS@ @SHLIB_LD_LIBS@
#----------------------------------------------------------------------------
# Targets:
#----------------------------------------------------------------------------
all: ${C_LIB_OPTION}
static: ${STATIC_LIB}
shared: ${SHARED_LIB}
${STATIC_LIB}: ${OBJECTS}
rm -f ${STATIC_LIB}
ar cr ${STATIC_LIB} ${OBJECTS}
${RANLIB} ${STATIC_LIB}
${SHARED_LIB}: build-cfitsio ${LOCAL_OBJ}
@if [ "x${TCL_LIB_PATH}" = x -o "x${TCL_LIB}" = x ]; then \
echo "${SHLIB_LD} ${LD_FLAGS} ${SHARED_OBJ} ${SHLIB_LD_LIBS} -o ${SHARED_LIB}"; \
${SHLIB_LD} ${LD_FLAGS} ${SHARED_OBJ} ${SHLIB_LD_LIBS} \
-o ${SHARED_LIB}; \
else \
echo "${SHLIB_LD} ${LD_FLAGS} ${SHARED_OBJ} ${SHLIB_LD_LIBS} -L${TCL_LIB_PATH} -l${TCL_LIB} -o ${SHARED_LIB}"; \
${SHLIB_LD} ${LD_FLAGS} ${SHARED_OBJ} ${SHLIB_LD_LIBS} \
-L${TCL_LIB_PATH} -l${TCL_LIB} -o ${SHARED_LIB}; \
fi
build-cfitsio:
@if [ "x${CFITSIO_DIR}" != x ]; then \
if [ -d "${CFITSIO_DIR}" ]; then \
if [ ! -f ${CFITSIO_DIR}/f77_wrap4.o ]; then \
echo "Configuring and building in ${CFITSIO_DIR}"; \
cd ${CFITSIO_DIR}; ./configure; \
${MAKE} stand_alone "CC=${CC}" "CFLAGS=${CFLAGS}" \
"FITSIO_OBJ=" "FITSIO_SRC="; \
fi; \
else \
echo "CFITSIO_DIR='${CFITSIO_DIR}' does not exist!"; \
exit 1; \
fi; \
else \
echo "CFITSIO_DIR was not set!"; \
exit 1; \
fi
install: all
@if [ "x${C_LIB_OPTION}" = xstatic ]; then \
echo "cp ${STATIC_LIB} ${INSTALLDIR}/lib/"; \
cp ${STATIC_LIB} ${INSTALLDIR}/lib/; \
else \
echo "cp ${SHARED_LIB} ${INSTALLDIR}/lib/"; \
cp ${SHARED_LIB} ${INSTALLDIR}/lib/; \
fi
clean:
-rm -rf *.o *~ ${STATIC_LIB} ${SHARED_LIB}
distclean: clean
-rm -f config.cache config.status config.log Makefile so_locations
#----------------------------------------------------------------------------
# Make target which outputs the list of the .o contained in the fitsTcl lib
# useful to build a single big shared library containing Tcl/Tk and other
# extensions. used for the Tcl Plugin.
#----------------------------------------------------------------------------
fitstclLibObjs:
@echo ${OBJECTS}
.c.o:
${CC} -c ${CFLAGS} ${DEFS} ${IFLAGS} $<
#
# $Log: Makefile.in,v $
# Revision 1.17 2006/09/25 15:27:02 irby
# Do not remove wcssub.o prior to creating libfitstcl. As of cfitsio
# v3.004 the wcssub routine is needed by fitsTcl.
#
# Revision 1.16 2004/04/28 17:16:12 irby
# Use C_LIB_OPTION instead of LIB_OPTION so that the shared/static
# option doesn't get trumped by the BUILD_DIR/Makefile LIB_OPTION macro
# which will force fitsTcl, pow, and powclient to be built static (only)
# under Darwin.
#
# Revision 1.15 2004/04/19 17:34:00 irby
# Break ${CFITSIO_DIR}/*.o out of dependencies since we check the cfitsio
# status independently.
#
# Revision 1.14 2004/04/14 19:03:15 irby
# Add some echoes, and rm so_locations when cleaning.
#
# Revision 1.13 2004/03/12 19:50:44 irby
# Add cfitsio target appropriate for fitsTcl standalone users.
#
# Revision 1.12 2004/03/11 20:59:28 irby
# Tidy up a couple of things, and add some echoes for the shared library
# build.
#
# Revision 1.11 2004/03/10 19:42:06 irby
# Another round of cleaning up the fitsTcl/pow/powclient/xdf Makefiles.
#
# The fitsTcl configure has been reinstated since we need it for
# standalone fitsTcl distribution. It and the tcltk2/configure (which
# configures fitsTcl, pow, powclient, and xdf in the full HEAsoft build
# context) now need a --with-tcl-includes flag.
#
# Revision 1.10 2003/08/18 21:11:43 irby
# Remove redundant copy of cfitsio. CFITSIO is now located via a
# --with-cfitsio flag given to the tcltk2/configure.
#
# Uncertain about the necessity of the "rm -f cfitsio/wcssub.o" command in
# the previous Makefile - may have to replace it.
#
# Revision 1.9 2003/07/02 19:43:58 irby
# Macro-ize tcl/tk library names (i.e. tcl8._, tk8._) so we don't have to
# change the Makefiles every time we upgrade tcl/tk versions. The
# tcltk2/configure sorts it out based on information provided by the
# --with-tcl and --with-tk options.
#
# Revision 1.8 2002/12/04 21:28:46 irby
# Add tcl/tk libraries/paths to SHLIB_LD_LIBS.
#
# Revision 1.7 2002/04/15 16:35:45 irby
# New (cleaner) configure script (and modified Makefile.in) based on lheasoft
# master (BUILD_DIR) configure.
#
# Revision 1.6 2002/02/11 22:33:57 irby
# Change non-existent macro SH_LD_LIBS to SHLIB_LD_LIBS.
#
# Revision 1.5 2001/01/04 16:55:42 irby
# Changed 'make' to ${MAKE} in clean/distclean
#
# Revision 1.4 1999/07/28 17:38:05 elwin
# Removed junk line.
#
# Revision 1.3 1999/07/28 17:26:28 elwin
# Changes for the plugin.
#
# Revision 1.2 1999/07/20 21:45:44 pwilson
# Cleanup some configure/make details
#
# Revision 1.1 1999/06/16 17:02:54 pwilson
# Commiting fitsTcl2.0
#
# Revision 1.34 1998/12/01 20:11:58 pwilson
# Add @CFLAGS@ to CFLAGS line (adds optimization)
# Remove fitsExpr from build... use CFITSIO's parser instead
#
# Revision 1.33 1998/10/21 22:00:22 pwilson
# Clean up makefiles... Makefile.in -> call cfitsio's make clean
# makefile.bc5-> suppress many many warnings
#
# Revision 1.32 1998/09/30 14:20:21 peachey
# Set FTOOLS using configure's prefix; this will still be overridden if
# fitsTcl is built from within the ftools/tcltk2 Makefile
#
# Revision 1.31 1998/09/21 16:36:43 pwilson
# Make build more portable for new tcl/tk versions
#
# Revision 1.30 1998/09/16 16:08:14 jxu
# point to tcl8.0.3
#
# Revision 1.29 1998/08/27 21:40:30 peachey
# Umm... remove wcssub.o, but don't fall down if you can't
#
# Revision 1.28 1998/08/07 17:32:29 elwin
# Hack to remove wcssub.o from cfitsio before making shared lib.
#
# Revision 1.27 1998/08/05 20:34:31 elwin
# Quick temporary fixes on the road to itcl3.0 integration.
#
# Revision 1.26 1998/06/04 12:38:55 peachey
# Fix libcfitsio make so it doesn't delete object files, and it excludes the
# Fortran wrappers, which are not necessary for this copy of libcfitsio.a
#
# Revision 1.25 1998/06/03 14:13:41 peachey
# Fixed typos from last commit
#
# Revision 1.24 1998/06/02 19:38:09 peachey
# Use cfitsio's native configure and Makefile rather than compile objects
# here explicitly.
#
# Revision 1.23 1997/11/24 20:46:32 elwin
# Added compress.c to the cfitsio build stuff
#
# Revision 1.22 1997/08/27 17:01:08 oneel
# cfitsio 1.26b5
#
# Revision 1.21 1997/07/11 15:26:03 jxu
# add in the new file.
#
# Revision 1.20 1997/04/04 18:31:13 jxu
# add command
# get imgwcs
# to calculate the world coordinate system parameter for image
#
# Revision 1.19 1997/03/28 20:14:01 oneel
# cfitsio 1.21 update
#
# Revision 1.18 1997/01/24 19:32:50 oneel
# itcl 2.2 changes
#
# Revision 1.17 1996/12/05 21:45:03 oneel
# More fixes to make the new regime work
#
# Revision 1.16 1996/12/05 21:15:05 oneel
# More fixes to make the new regime work
#
# Revision 1.15 1996/12/05 20:24:54 oneel
# More fixes to make the new regiem work
#
# Revision 1.14 1996/11/04 19:13:59 oneel
# AUTHORIZED CHANGES: Opps, screwed up my list of files to build.
#
# Revision 1.13 1996/11/01 20:26:59 oneel
# cfitsio beta update
#
# Revision 1.12 1996/08/22 17:40:46 oneel
# Put back in the shared cflags so that shared libraries build on SunOS
# and Solaris
#
# Revision 1.11 1996/08/22 12:14:24 oneel
# Don't require an install on itcl2.1 to build fitsTcl
#
# Revision 1.10 1996/08/19 21:01:08 jxu
# On the ALPHAs, if cfitsio functions are compiled with "gcc -O", then
# some column in bin table will give floating exception error. Take "-O" out
# for now.
#
# Revision 1.9 1996/08/19 20:58:08 jxu
# On the ALPHAS, long != int. VISU can not hadle long type image, while
# most of the images in fits are long type. Simply convert the long to
# int in fitstcl. VISU is happy
#
# Revision 1.8 1996/08/07 16:30:00 oneel
# build fixes
#
# Revision 1.5 1996/07/19 14:41:40 oneel
# fitstcl Shared libraries
#
# Revision 1.4 1996/07/19 13:58:51 oneel
# fitstcl Shared libraries
#
# Revision 1.3 1996/07/18 18:43:36 oneel
# itcl 2.1 updates
#
# Revision 1.2 1996/06/14 14:41:07 oneel
# itcl2 updates, both for SunOS 4 and to resync with orig tcltk
#
# Revision 1.1 1996/06/13 14:00:17 oneel
# itcl2 additions
#
# Revision 3.6 1996/04/23 18:22:52 oneel
# Converting to /ftools/vc cvs root
#
# Revision 1.2 1996/04/04 16:22:14 oneel
# Fitstcl Updates, newewst from Jianjun, plus makefile changes to let
# irix buildok.
#
# ftools_query fixes.
#
# Revision 1.1.1.1 1996/02/20 20:22:10 oneel
# tcltk directory import
#
# Revision 1.5 1996/02/12 18:04:49 oneel
# Added CFLAGS to cfitsio compile
#
# Revision 1.4 1995/10/20 16:18:35 oneel
# Changed to not set CFLAGS
#
# Revision 1.3 1995/08/24 21:52:31 oneel
# Changed to use passed in FORTRANLIB
#
# Revision 1.2 1995/08/18 18:54:29 oneel
# Some include and library fixes
#
# Revision 1.1 1995/08/16 19:30:44 oneel
# Initial revision
#
#
fitsTcl/README 0000644 0002307 0000036 00000013317 11222720662 011745 0 ustar chai lhea
fitsTcl 2.1.1 Installation Guide
fitsTcl is a TCL interface to the CFITSIO astronomical library
which provides access to FITS data files. It can be used either by
itself within the standard tcl/tk applications tclsh and wish, or
within the fv software package also distributed by the HEASARC at
NASA Goddard.
The fitsTcl User's Guide is located in the fitsTcl.html file
distributed with fitsTcl2.1.1 and located on the web at:
http://heasarc.gsfc.nasa.gov/ftools/fv/fitsTcl.html
Send any bug reports to ftoolshelp@athena.gsfc.nasa.gov.
fitsTcl can be built under Unix/Linux (PowerPC or Intel), MacOS,
and Windows. You will need a version of Tcl8.x, available either
from Scriptics (www.scriptics.com) or HEASARC as part of the fv
distribution (heasarc.gsfc.nasa.gov/ftools/fv). Read the following
for instructions for building on each platform.
********************************************************************************
UNIX (including Mac OS X)
********************************************************************************
To build the fitsTcl shared library do the following:
1. Unpack the compressed fitsTcl tar file and enter the fitsTcl2.1.1
directory.
2. Download the latest version of the cfitsio source code (for UNIX)
from:
http://heasarc.gsfc.nasa.gov/docs/software/lheasoft/fitsio/fitsio.html
and unpack the source tar file.
3. Configure fitsTcl for your system with the command
./configure [optional arguments]
where the optional arguments are:
--prefix=DIR1 --with-cfitsio=DIR2 --with-tcl-includes=DIR3
DIR1 is the installation path (default is /usr/local)
DIR2 is the path to the cfitsio source directory
(default is ./cfitsio)
DIR3 is the path to the location of the tcl.h header file
(default is $prefix/include or /usr/include).
These may be considered optional only if the defaults are valid
for your system/setup.
The final library will be installed in the directory DIR1/lib
which must exist. Note that the library itself does not depend
on the value of DIR1, only the installation step in the Makefile.
4. Build fitsTcl with the command
make
5. Install fitsTcl either with the command
make install
which will place it in the DIR1/lib directory, or move the
library (libfitstcl.so, or libfitstcl.dylib under Mac OS X)
manually to where you want it.
To use fitsTcl, startup tclsh or wish and type the command
load libfitstcl.so (libfitstcl.dylib on Mac OS X)
You may need to specify an explicit path to the library or set
the LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Mac OS X) to its location.
********************************************************************************
MacOS
********************************************************************************
To build fitsTcl extension do the following:
1. Download and build the Mac TCL software available from
Scriptics (www.scriptics.com).
2. Download and expand the fitsTcl distribution, which will
create a fitsTcl2.1.1 subdirectory.
3. Download the latest version of the cfitsio source code from:
http://heasarc.gsfc.nasa.gov/docs/software/lheasoft/fitsio/fitsio.html
and untar it under the fitsTcl2.1.1 directory (i.e. such that
you have a fitsTcl2.1.1/cfitsio directory).
4. Debinhex and expand the file fitsTcl.sit.hqx, creating
a fitsTcl folder containing a Codewarrior 5 project file,
fitsTcl.p.
5. Open the new project file and update the Access Paths to
point to your TCL source tree.
6. Build the 'fitsTcl DLL' target. This will create a file
fitsTcl.dll in the fitsTcl directory. Move it to where ever
is convenient and use 'load fitsTcl.dll' to load it into
tclsh or wish.
(Note: We do not distribute a binary version of the plugin since it
is dependent on the major TCL version -- 8.0, 8.1, etc -- used in
building it. We may distribute one, though, if there is sufficient
demand for use with a particular TCL release.)
********************************************************************************
MS Windows
********************************************************************************
Building fitsTcl requires Microsoft Visual C++. A Borland C v5
makefile is also included, although it has not been updated since
the last release.
To build fitsTcl DLL do the following:
1. Download and build the Windows TCL software available from
Scriptics (www.scriptics.com).
2. Download and expand the fitsTcl distribution, which will
create a fitsTcl2.1.1 subdirectory.
3. Download the latest version of the cfitsio source code from:
http://heasarc.gsfc.nasa.gov/docs/software/lheasoft/fitsio/fitsio.html
and untar it under the fitsTcl2.1.1 directory (i.e. such that
you have a fitsTcl2.1.1/cfitsio directory).
4. Edit the file makefile.vc (or makefile.bc5) and update the
paths for your specific setup. We have our source tree at
D:\FV_SRC. Replace this and the TCL8.2.2 references as
appropriate.
5. Type the command 'nmake -f makefile.vc'. This will build
a fitstcl.dll file. Move it to where ever is convenient and
use 'load fitstcl.dll' to load it into tclsh or wish.
fitsTcl/configure 0000755 0002307 0000036 00000536703 11222720662 013005 0 ustar chai lhea #! /bin/sh
# From configure.in Revision: 1.16 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59.
#
# Copyright (C) 2003 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
DUALCASE=1; export DUALCASE # for MKS sh
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# Work around bugs in pre-3.0 UWIN ksh.
$as_unset ENV MAIL MAILPATH
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
for as_var in \
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME
do
if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
eval $as_var=C; export $as_var
else
$as_unset $as_var
fi
done
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)$' \| \
. : '\(.\)' 2>/dev/null ||
echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
/^X\/\(\/\/\)$/{ s//\1/; q; }
/^X\/\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
# PATH needs CR, and LINENO needs CR and PATH.
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" || {
# Find who we are. Look in the path if we contain no path at all
# relative or not.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
{ echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
{ (exit 1); exit 1; }; }
fi
case $CONFIG_SHELL in
'')
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for as_base in sh bash ksh sh5; do
case $as_dir in
/*)
if ("$as_dir/$as_base" -c '
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
$as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
$as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
CONFIG_SHELL=$as_dir/$as_base
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$0" ${1+"$@"}
fi;;
esac
done
done
;;
esac
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line before each line; the second 'sed' does the real
# work. The second script uses 'N' to pair each line-number line
# with the numbered line, and appends trailing '-' during
# substitution so that $LINENO is not a special case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
sed '=' <$as_myself |
sed '
N
s,$,-,
: loop
s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
t loop
s,-$,,
s,^['$as_cr_digits']*\n,,
' >$as_me.lineno &&
chmod +x $as_me.lineno ||
{ echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensible to this).
. ./$as_me.lineno
# Exit status is that of the last command.
exit
}
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
*c*,-n*) ECHO_N= ECHO_C='
' ECHO_T=' ' ;;
*c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
*) ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
# We could just check for DJGPP; but this test a) works b) is more generic
# and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
if test -f conf$$.exe; then
# Don't use ln at all; we don't have any links
as_ln_s='cp -p'
else
as_ln_s='ln -s'
fi
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
as_executable_p="test -f"
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" $as_nl"
# CDPATH.
$as_unset CDPATH
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
exec 6>&1
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_config_libobj_dir=.
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
# This variable seems obsolete. It should probably be removed, and
# only ac_max_sed_lines should be used.
: ${ac_max_here_lines=38}
# Identity of this package.
PACKAGE_NAME=
PACKAGE_TARNAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_BUGREPORT=
ac_unique_file="Makefile.in"
# Factoring default headers for most tests.
ac_includes_default="\
#include
#if HAVE_SYS_TYPES_H
# include
#endif
#if HAVE_SYS_STAT_H
# include
#endif
#if STDC_HEADERS
# include
# include
#else
# if HAVE_STDLIB_H
# include
# endif
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include
# endif
# include
#endif
#if HAVE_STRINGS_H
# include
#endif
#if HAVE_INTTYPES_H
# include
#else
# if HAVE_STDINT_H
# include
# endif
#endif
#if HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TCL_LIB TK_LIB CFITSIODIR C_LIB_OPTION UNAME BINDIR BIN_EXT EXT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT RANLIB ac_ct_RANLIB CPP USE_X XINCLUDES XLIBPTH XLIBS EGREP ALLOCA LD_FLAGS SHLIB_LD SHLIB_LD_LIBS SHLIB_SUFFIX LIBOBJS TCL_PATH TCL_INC_PATH ITCL_PATH TK_PATH TK_INC_PATH LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
ac_prev=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval "$ac_prev=\$ac_option"
ac_prev=
continue
fi
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_option in
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir=$ac_optarg ;;
-disable-* | --disable-*)
ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid feature name: $ac_feature" >&2
{ (exit 1); exit 1; }; }
ac_feature=`echo $ac_feature | sed 's/-/_/g'`
eval "enable_$ac_feature=no" ;;
-enable-* | --enable-*)
ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid feature name: $ac_feature" >&2
{ (exit 1); exit 1; }; }
ac_feature=`echo $ac_feature | sed 's/-/_/g'`
case $ac_option in
*=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
*) ac_optarg=yes ;;
esac
eval "enable_$ac_feature='$ac_optarg'" ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid package name: $ac_package" >&2
{ (exit 1); exit 1; }; }
ac_package=`echo $ac_package| sed 's/-/_/g'`
case $ac_option in
*=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
*) ac_optarg=yes ;;
esac
eval "with_$ac_package='$ac_optarg'" ;;
-without-* | --without-*)
ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid package name: $ac_package" >&2
{ (exit 1); exit 1; }; }
ac_package=`echo $ac_package | sed 's/-/_/g'`
eval "with_$ac_package=no" ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) { echo "$as_me: error: unrecognized option: $ac_option
Try \`$0 --help' for more information." >&2
{ (exit 1); exit 1; }; }
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
{ echo "$as_me: error: invalid variable name: $ac_envvar" >&2
{ (exit 1); exit 1; }; }
ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
eval "$ac_envvar='$ac_optarg'"
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
{ echo "$as_me: error: missing argument to $ac_option" >&2
{ (exit 1); exit 1; }; }
fi
# Be sure to have absolute paths.
for ac_var in exec_prefix prefix
do
eval ac_val=$`echo $ac_var`
case $ac_val in
[\\/$]* | ?:[\\/]* | NONE | '' ) ;;
*) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; };;
esac
done
# Be sure to have absolute paths.
for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
localstatedir libdir includedir oldincludedir infodir mandir
do
eval ac_val=$`echo $ac_var`
case $ac_val in
[\\/$]* | ?:[\\/]* ) ;;
*) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
{ (exit 1); exit 1; }; };;
esac
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used." >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then its parent.
ac_confdir=`(dirname "$0") 2>/dev/null ||
$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$0" : 'X\(//\)[^/]' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$0" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
{ (exit 1); exit 1; }; }
else
{ echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
{ (exit 1); exit 1; }; }
fi
fi
(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
{ echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
{ (exit 1); exit 1; }; }
srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
ac_env_build_alias_set=${build_alias+set}
ac_env_build_alias_value=$build_alias
ac_cv_env_build_alias_set=${build_alias+set}
ac_cv_env_build_alias_value=$build_alias
ac_env_host_alias_set=${host_alias+set}
ac_env_host_alias_value=$host_alias
ac_cv_env_host_alias_set=${host_alias+set}
ac_cv_env_host_alias_value=$host_alias
ac_env_target_alias_set=${target_alias+set}
ac_env_target_alias_value=$target_alias
ac_cv_env_target_alias_set=${target_alias+set}
ac_cv_env_target_alias_value=$target_alias
ac_env_CC_set=${CC+set}
ac_env_CC_value=$CC
ac_cv_env_CC_set=${CC+set}
ac_cv_env_CC_value=$CC
ac_env_CFLAGS_set=${CFLAGS+set}
ac_env_CFLAGS_value=$CFLAGS
ac_cv_env_CFLAGS_set=${CFLAGS+set}
ac_cv_env_CFLAGS_value=$CFLAGS
ac_env_LDFLAGS_set=${LDFLAGS+set}
ac_env_LDFLAGS_value=$LDFLAGS
ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
ac_cv_env_LDFLAGS_value=$LDFLAGS
ac_env_CPPFLAGS_set=${CPPFLAGS+set}
ac_env_CPPFLAGS_value=$CPPFLAGS
ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
ac_cv_env_CPPFLAGS_value=$CPPFLAGS
ac_env_CPP_set=${CPP+set}
ac_env_CPP_value=$CPP
ac_cv_env_CPP_set=${CPP+set}
ac_cv_env_CPP_value=$CPP
#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print \`checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
_ACEOF
cat <<_ACEOF
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--infodir=DIR info documentation [PREFIX/info]
--mandir=DIR man documentation [PREFIX/man]
_ACEOF
cat <<\_ACEOF
X features:
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
_ACEOF
fi
if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-shared Produce static binaries
--enable-static Produce static binaries
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-tcl Path to tcl library
--with-tcl-includes Path to tcl include files
--with-tk Path to tk library
--with-tk-includes Path to tk include files
--with-itcl Path to itcl source
--with-cfitsio Path to cfitsio source
--with-x use the X Window System
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have
headers in a nonstandard directory
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
_ACEOF
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
ac_popdir=`pwd`
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d $ac_dir || continue
ac_builddir=.
if test "$ac_dir" != .; then
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
# A "../" for each directory in $ac_dir_suffix.
ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
else
ac_dir_suffix= ac_top_builddir=
fi
case $srcdir in
.) # No --srcdir option. We are building in place.
ac_srcdir=.
if test -z "$ac_top_builddir"; then
ac_top_srcdir=.
else
ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
fi ;;
[\\/]* | ?:[\\/]* ) # Absolute path.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir ;;
*) # Relative path.
ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_builddir$srcdir ;;
esac
# Do not use `cd foo && pwd` to compute absolute paths, because
# the directories may not exist.
case `pwd` in
.) ac_abs_builddir="$ac_dir";;
*)
case "$ac_dir" in
.) ac_abs_builddir=`pwd`;;
[\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
*) ac_abs_builddir=`pwd`/"$ac_dir";;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_builddir=${ac_top_builddir}.;;
*)
case ${ac_top_builddir}. in
.) ac_abs_top_builddir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
*) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_srcdir=$ac_srcdir;;
*)
case $ac_srcdir in
.) ac_abs_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
*) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_srcdir=$ac_top_srcdir;;
*)
case $ac_top_srcdir in
.) ac_abs_top_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
*) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
esac;;
esac
cd $ac_dir
# Check for guested configure; otherwise get Cygnus style configure.
if test -f $ac_srcdir/configure.gnu; then
echo
$SHELL $ac_srcdir/configure.gnu --help=recursive
elif test -f $ac_srcdir/configure; then
echo
$SHELL $ac_srcdir/configure --help=recursive
elif test -f $ac_srcdir/configure.ac ||
test -f $ac_srcdir/configure.in; then
echo
$ac_configure --help
else
echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi
cd $ac_popdir
done
fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
Copyright (C) 2003 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit 0
fi
exec 5>config.log
cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
_ACEOF
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
echo "PATH: $as_dir"
done
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_sep=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
2)
ac_configure_args1="$ac_configure_args1 '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
# Get rid of the leading space.
ac_sep=" "
;;
esac
done
done
$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Be sure not to use single quotes in there, as some shells,
# such as our DU 5.0 friend, will then `close' the trap.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
cat <<\_ASBOX
## ---------------- ##
## Cache variables. ##
## ---------------- ##
_ASBOX
echo
# The following way of writing the cache mishandles newlines in values,
{
(set) 2>&1 |
case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
*ac_space=\ *)
sed -n \
"s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
;;
*)
sed -n \
"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
;;
esac;
}
echo
cat <<\_ASBOX
## ----------------- ##
## Output variables. ##
## ----------------- ##
_ASBOX
echo
for ac_var in $ac_subst_vars
do
eval ac_val=$`echo $ac_var`
echo "$ac_var='"'"'$ac_val'"'"'"
done | sort
echo
if test -n "$ac_subst_files"; then
cat <<\_ASBOX
## ------------- ##
## Output files. ##
## ------------- ##
_ASBOX
echo
for ac_var in $ac_subst_files
do
eval ac_val=$`echo $ac_var`
echo "$ac_var='"'"'$ac_val'"'"'"
done | sort
echo
fi
if test -s confdefs.h; then
cat <<\_ASBOX
## ----------- ##
## confdefs.h. ##
## ----------- ##
_ASBOX
echo
sed "/^$/d" confdefs.h | sort
echo
fi
test "$ac_signal" != 0 &&
echo "$as_me: caught signal $ac_signal"
echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core &&
rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo >confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
if test "x$prefix" != xNONE; then
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
else
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
fi
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
{ echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special
# files actually), so we avoid doing that.
if test -f "$cache_file"; then
{ echo "$as_me:$LINENO: loading cache $cache_file" >&5
echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . $cache_file;;
*) . ./$cache_file;;
esac
fi
else
{ echo "$as_me:$LINENO: creating cache $cache_file" >&5
echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in `(set) 2>&1 |
sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val="\$ac_cv_env_${ac_var}_value"
eval ac_new_val="\$ac_env_${ac_var}_value"
case $ac_old_set,$ac_new_set in
set,)
{ echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
{ echo "$as_me:$LINENO: former value: $ac_old_val" >&5
echo "$as_me: former value: $ac_old_val" >&2;}
{ echo "$as_me:$LINENO: current value: $ac_new_val" >&5
echo "$as_me: current value: $ac_new_val" >&2;}
ac_cache_corrupted=:
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
echo "$as_me: error: changes in the environment can compromise the build" >&2;}
{ { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test $cache_file = ./config.cache; then
cache_file=`pwd`/config.cache
fi
# Check whether --with-tcl or --without-tcl was given.
if test "${with_tcl+set}" = set; then
withval="$with_tcl"
TCL_PATH=$withval
fi;
# Check whether --with-tcl-includes or --without-tcl-includes was given.
if test "${with_tcl_includes+set}" = set; then
withval="$with_tcl_includes"
TCL_INCLUDES=$withval
fi;
# Make sure we have tcl.h before proceeding:
#-------------------------------------------
echo "$as_me:$LINENO: checking for tcl header file" >&5
echo $ECHO_N "checking for tcl header file... $ECHO_C" >&6
TCL_INC_PATH=
for dir in $TCL_INCLUDES $prefix/include /usr/include ; do
if test -r $dir/tcl.h; then
TCL_INC_PATH=$dir
echo "$as_me:$LINENO: result: $dir" >&5
echo "${ECHO_T}$dir" >&6
break
fi
done
if test -z "$TCL_INC_PATH"; then
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
{ { echo "$as_me:$LINENO: error: Can't find Tcl header. Use --with-tcl-includes to specify the location of tcl.h on your system." >&5
echo "$as_me: error: Can't find Tcl header. Use --with-tcl-includes to specify the location of tcl.h on your system." >&2;}
{ (exit 1); exit 1; }; }
fi
#-------------------------------------------
# Check whether --with-tk or --without-tk was given.
if test "${with_tk+set}" = set; then
withval="$with_tk"
TK_PATH=$withval
fi;
# Check whether --with-tk-includes or --without-tk-includes was given.
if test "${with_tk_includes+set}" = set; then
withval="$with_tk_includes"
TK_INC_PATH=$withval
fi;
# Check whether --with-itcl or --without-itcl was given.
if test "${with_itcl+set}" = set; then
withval="$with_itcl"
ITCL_PATH=$withval
fi;
# Check whether --with-cfitsio or --without-cfitsio was given.
if test "${with_cfitsio+set}" = set; then
withval="$with_cfitsio"
CFITSIO=$withval
fi;
# Make sure we have cfitsio before proceeding:
#-------------------------------------------
echo "$as_me:$LINENO: checking for cfitsio source directory" >&5
echo $ECHO_N "checking for cfitsio source directory... $ECHO_C" >&6
CFITSIODIR=
for dir in $CFITSIO ./cfitsio ; do
if test -r $dir/eval_defs.h; then
CFITSIODIR=$dir
echo "$as_me:$LINENO: result: $dir" >&5
echo "${ECHO_T}$dir" >&6
break
fi
done
if test -z "$CFITSIODIR"; then
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
{ { echo "$as_me:$LINENO: error: Can't find cfitsio. Use --with-cfitsio to specify the location of the cfitsio source code." >&5
echo "$as_me: error: Can't find cfitsio. Use --with-cfitsio to specify the location of the cfitsio source code." >&2;}
{ (exit 1); exit 1; }; }
fi
#-------------------------------------------
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
enableval="$enable_shared"
lhea_shared=$enableval
else
lhea_shared=yes
fi;
# Check whether --enable-static or --disable-static was given.
if test "${enable_static+set}" = set; then
enableval="$enable_static"
if test $enableval = yes; then lhea_shared=no; fi
fi;
TCL_LIB=`echo $TCL_PATH | sed 's:.*tcl8:tcl8:' | sed 's:.[0-9]/unix$::'`
TK_LIB=`echo $TK_PATH | sed 's:.*tk8:tk8:' | sed 's:.[0-9]/unix$::'`
if test $lhea_shared = yes; then
C_LIB_OPTION=shared
else
C_LIB_OPTION=static
fi
#-------------------------------------------------------------------------------
# Determine system type
#-------------------------------------------------------------------------------
BIN_EXT=
if test "x$EXT" = x; then EXT=lnx; fi
if test "x$BINDIR" = x; then
# Extract the first word of "uname", so it can be a program name with args.
set dummy uname; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_UNAME+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$UNAME"; then
ac_cv_prog_UNAME="$UNAME" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_UNAME="uname"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
test -z "$ac_cv_prog_UNAME" && ac_cv_prog_UNAME="nouname"
fi
fi
UNAME=$ac_cv_prog_UNAME
if test -n "$UNAME"; then
echo "$as_me:$LINENO: result: $UNAME" >&5
echo "${ECHO_T}$UNAME" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
if test $UNAME = nouname; then
{ { echo "$as_me:$LINENO: error: HEAsoft: Unable to guess system type. Please set it using --with-bindir option" >&5
echo "$as_me: error: HEAsoft: Unable to guess system type. Please set it using --with-bindir option" >&2;}
{ (exit 1); exit 1; }; }
fi
BINDIR=`$UNAME -s 2> /dev/null`_`$UNAME -r 2> /dev/null | sed 's:[^0-9]*\([0-9][0-9]*\.[0-9]*\).*:\1:'`
lhea_machine=`$UNAME -m 2> /dev/null`
BIN_EXT=
case $BINDIR in
CYGWIN*)
BINDIR=CYGWIN32_`$UNAME -a 2> /dev/null | awk '{ print $4 }'`
lhea_machine=
BIN_EXT=".exe"
EXT=lnx
;;
IRIX*)
{ echo "$as_me:$LINENO: WARNING: IRIX support is marginal" >&5
echo "$as_me: WARNING: IRIX support is marginal" >&2;}
EXT=sgi
;;
HP-UX*)
{ echo "$as_me:$LINENO: WARNING: HP-UX support is marginal" >&5
echo "$as_me: WARNING: HP-UX support is marginal" >&2;}
EXT=hpu
lhea_machine=`$UNAME -m 2> /dev/null | tr '/' ' ' | awk '{ print $2 }'`
;;
Linux*)
EXT=lnx
;;
OSF1*)
EXT=osf
;;
SunOS_4*)
{ echo "$as_me:$LINENO: WARNING: SunOS 4.x is not supported!" >&5
echo "$as_me: WARNING: SunOS 4.x is not supported!" >&2;}
{ echo "$as_me:$LINENO: WARNING: PROCEED AT YOUR OWN RISK!" >&5
echo "$as_me: WARNING: PROCEED AT YOUR OWN RISK!" >&2;}
EXT=sun
lhea_machine=sparc
;;
SunOS_5*)
EXT=sol
lhea_machine=`$UNAME -p`
;;
Darwin_*)
EXT=darwin
lhea_machine=`$UNAME -p`
;;
*)
{ { echo "$as_me:$LINENO: error: Unable to recognize your system. Please make sure this platform is supported." >&5
echo "$as_me: error: Unable to recognize your system. Please make sure this platform is supported." >&2;}
{ (exit 1); exit 1; }; }
;;
esac
if test x$lhea_machine != x; then
BINDIR=$BINDIR"_"$lhea_machine
fi
fi
#-------------------------------------------------------------------------------
# Checks for programs.
#-------------------------------------------------------------------------------
# Try first to find a proprietary C compiler, then gcc
if test "x$CC" = x; then
for ac_prog in cc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$CC" && break
done
fi
# Set up flags to use the selected compiler
#
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
CC=$ac_ct_CC
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
CC=$ac_ct_CC
else
CC="$ac_cv_prog_CC"
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$ac_ct_CC" && break
done
CC=$ac_ct_CC
fi
fi
test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&5
echo "$as_me: error: no acceptable C compiler found in \$PATH
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
# Provide some information about the compiler.
echo "$as_me:$LINENO:" \
"checking for C compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5
(eval $ac_compiler --version &5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5
(eval $ac_compiler -v &5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5
(eval $ac_compiler -V &5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
(eval $ac_link_default) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# Find the output, starting from the most likely. This scheme is
# not robust to junk in `.', hence go to wildcards (a.*) only as a last
# resort.
# Be careful to initialize this variable, since it used to be cached.
# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
ac_cv_exeext=
# b.out is created by i960 compilers.
for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
;;
conftest.$ac_ext )
# This is the source file.
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
# FIXME: I believe we export ac_cv_exeext for Libtool,
# but it would be cool to find out if it's true. Does anybody
# maintain Libtool? --akim.
export ac_cv_exeext
break;;
* )
break;;
esac
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
See \`config.log' for more details." >&5
echo "$as_me: error: C compiler cannot create executables
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
fi
ac_exeext=$ac_cv_exeext
echo "$as_me:$LINENO: result: $ac_file" >&5
echo "${ECHO_T}$ac_file" >&6
# Check the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
echo "$as_me:$LINENO: checking whether the C compiler works" >&5
echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
if { ac_try='./$ac_file'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&5
echo "$as_me: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
fi
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
rm -f a.out a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
# Check the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
echo "$as_me:$LINENO: result: $cross_compiling" >&5
echo "${ECHO_T}$cross_compiling" >&6
echo "$as_me:$LINENO: checking for suffix of executables" >&5
echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
export ac_cv_exeext
break;;
* ) break;;
esac
done
else
{ { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest$ac_cv_exeext
echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
echo "${ECHO_T}$ac_cv_exeext" >&6
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
echo "$as_me:$LINENO: checking for suffix of object files" >&5
echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
if test "${ac_cv_objext+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute suffix of object files: cannot compile
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
echo "${ECHO_T}$ac_cv_objext" >&6
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
if test "${ac_cv_c_compiler_gnu+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_compiler_gnu=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
GCC=`test $ac_compiler_gnu = yes && echo yes`
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
CFLAGS="-g"
echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
if test "${ac_cv_prog_cc_g+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_prog_cc_g=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_prog_cc_g=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
if test "${ac_cv_prog_cc_stdc+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_prog_cc_stdc=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std1 is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std1. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX -qlanglvl=ansi
# Ultrix and OSF/1 -std1
# HP-UX 10.20 and later -Ae
# HP-UX older versions -Aa -D_HPUX_SOURCE
# SVR4 -Xc -D__EXTENSIONS__
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_prog_cc_stdc=$ac_arg
break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext
done
rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
fi
case "x$ac_cv_prog_cc_stdc" in
x|xno)
echo "$as_me:$LINENO: result: none needed" >&5
echo "${ECHO_T}none needed" >&6 ;;
*)
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
CC="$CC $ac_cv_prog_cc_stdc" ;;
esac
# Some people use a C++ compiler to compile C. Since we use `exit',
# in C++ we need to declare it. In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
# the declaration of exit, since it's the most demanding environment.
cat >conftest.$ac_ext <<_ACEOF
#ifndef __cplusplus
choke me
#endif
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
for ac_declaration in \
'' \
'extern "C" void std::exit (int) throw (); using std::exit;' \
'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \
'extern "C" void exit (int);' \
'void exit (int);'
do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_declaration
#include
int
main ()
{
exit (42);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
:
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
continue
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_declaration
int
main ()
{
exit (42);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
done
rm -f conftest*
if test -n "$ac_declaration"; then
echo '#ifdef __cplusplus' >>confdefs.h
echo $ac_declaration >>confdefs.h
echo '#endif' >>confdefs.h
fi
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "$cross_compiling" = yes; then
{ echo "$as_me:$LINENO: WARNING: Cannot run a simple C executable on your system:" >&5
echo "$as_me: WARNING: Cannot run a simple C executable on your system:" >&2;}
{ echo "$as_me:$LINENO: WARNING: There may be something wrong with your compiler" >&5
echo "$as_me: WARNING: There may be something wrong with your compiler" >&2;}
{ echo "$as_me:$LINENO: WARNING: or perhaps you're trying to cross-compile?" >&5
echo "$as_me: WARNING: or perhaps you're trying to cross-compile?" >&2;}
{ echo "$as_me:$LINENO: WARNING: Cross-compiling is not supported within HEAsoft." >&5
echo "$as_me: WARNING: Cross-compiling is not supported within HEAsoft." >&2;}
{ echo "$as_me:$LINENO: WARNING: Please make sure your compiler is working." >&5
echo "$as_me: WARNING: Please make sure your compiler is working." >&2;}
{ echo "$as_me:$LINENO: WARNING: Contact the FTOOLS help desk for further assistance." >&5
echo "$as_me: WARNING: Contact the FTOOLS help desk for further assistance." >&2;}
{ { echo "$as_me:$LINENO: error: Cross-compiling is not allowed." >&5
echo "$as_me: error: Cross-compiling is not allowed." >&2;}
{ (exit 1); exit 1; }; }
fi
if test "x$GCC" = x; then
GCC=no
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_RANLIB+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
echo "$as_me:$LINENO: result: $RANLIB" >&5
echo "${ECHO_T}$RANLIB" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$ac_cv_prog_RANLIB"; then
ac_ct_RANLIB=$RANLIB
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_RANLIB"; then
ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
echo "${ECHO_T}$ac_ct_RANLIB" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
RANLIB=$ac_ct_RANLIB
else
RANLIB="$ac_cv_prog_RANLIB"
fi
if test $EXT = darwin; then
RANLIB="$RANLIB -cs"
fi
# RANLIB on IRIX is flaky
if test $EXT = sgi; then
RANLIB=:
fi
#-------------------------------------------------------------------------------
# Checks for libraries.
#-------------------------------------------------------------------------------
# X
XLIBS=
XLIBPTH=
XINCLUDES=
# socket and nsl libraries -- only if needed
echo "$as_me:$LINENO: checking for gethostbyname" >&5
echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
if test "${ac_cv_func_gethostbyname+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define gethostbyname to an innocuous variant, in case declares gethostbyname.
For example, HP-UX 11i declares gettimeofday. */
#define gethostbyname innocuous_gethostbyname
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gethostbyname (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef gethostbyname
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char gethostbyname ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
choke me
#else
char (*f) () = gethostbyname;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != gethostbyname;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_gethostbyname=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_gethostbyname=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
if test $ac_cv_func_gethostbyname = yes; then
:
else
echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char gethostbyname ();
int
main ()
{
gethostbyname ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_nsl_gethostbyname=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_nsl_gethostbyname=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
if test $ac_cv_lib_nsl_gethostbyname = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBNSL 1
_ACEOF
LIBS="-lnsl $LIBS"
fi
fi
for ac_func in connect accept
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case declares $ac_func.
For example, HP-UX 11i declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
else
echo "$as_me:$LINENO: checking for main in -lsocket" >&5
echo $ECHO_N "checking for main in -lsocket... $ECHO_C" >&6
if test "${ac_cv_lib_socket_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $XLIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
main ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_socket_main=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_socket_main=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_socket_main" >&5
echo "${ECHO_T}$ac_cv_lib_socket_main" >&6
if test $ac_cv_lib_socket_main = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSOCKET 1
_ACEOF
LIBS="-lsocket $LIBS"
fi
fi
done
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
:
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether non-existent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
# Broken: success on invalid input.
continue
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
echo "$as_me:$LINENO: result: $CPP" >&5
echo "${ECHO_T}$CPP" >&6
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
:
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether non-existent headers
# can be detected and how.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
# Broken: success on invalid input.
continue
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
:
else
{ { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&5
echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
echo "$as_me:$LINENO: checking for X" >&5
echo $ECHO_N "checking for X... $ECHO_C" >&6
# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
withval="$with_x"
fi;
# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
if test "x$with_x" = xno; then
# The user explicitly disabled X.
have_x=disabled
else
if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
# Both variables are already set.
have_x=yes
else
if test "${ac_cv_have_x+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
# One or both of the vars are not set, and there is no cached value.
ac_x_includes=no ac_x_libraries=no
rm -fr conftest.dir
if mkdir conftest.dir; then
cd conftest.dir
# Make sure to not put "make" in the Imakefile rules, since we grep it out.
cat >Imakefile <<'_ACEOF'
acfindx:
@echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
_ACEOF
if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
# Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
for ac_extension in a so sl; do
if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
test -f $ac_im_libdir/libX11.$ac_extension; then
ac_im_usrlibdir=$ac_im_libdir; break
fi
done
# Screen out bogus values from the imake configuration. They are
# bogus both because they are the default anyway, and because
# using them would break gcc on systems where it needs fixed includes.
case $ac_im_incroot in
/usr/include) ;;
*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
esac
case $ac_im_usrlibdir in
/usr/lib | /lib) ;;
*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
esac
fi
cd ..
rm -fr conftest.dir
fi
# Standard set of common directories for X headers.
# Check X11 before X11Rn because it is often a symlink to the current release.
ac_x_header_dirs='
/usr/X11/include
/usr/X11R6/include
/usr/X11R5/include
/usr/X11R4/include
/usr/include/X11
/usr/include/X11R6
/usr/include/X11R5
/usr/include/X11R4
/usr/local/X11/include
/usr/local/X11R6/include
/usr/local/X11R5/include
/usr/local/X11R4/include
/usr/local/include/X11
/usr/local/include/X11R6
/usr/local/include/X11R5
/usr/local/include/X11R4
/usr/X386/include
/usr/x386/include
/usr/XFree86/include/X11
/usr/include
/usr/local/include
/usr/unsupported/include
/usr/athena/include
/usr/local/x11r5/include
/usr/lpp/Xamples/include
/usr/openwin/include
/usr/openwin/share/include'
if test "$ac_x_includes" = no; then
# Guess where to find include files, by looking for Intrinsic.h.
# First, try using that file with no special directory specified.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
# We can compile using X headers with no special include directory.
ac_x_includes=
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
for ac_dir in $ac_x_header_dirs; do
if test -r "$ac_dir/X11/Intrinsic.h"; then
ac_x_includes=$ac_dir
break
fi
done
fi
rm -f conftest.err conftest.$ac_ext
fi # $ac_x_includes = no
if test "$ac_x_libraries" = no; then
# Check for the libraries.
# See if we find them without any special options.
# Don't add to $LIBS permanently.
ac_save_LIBS=$LIBS
LIBS="-lXt $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
int
main ()
{
XtMalloc (0)
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
LIBS=$ac_save_LIBS
# We can link X programs with no special library path.
ac_x_libraries=
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
LIBS=$ac_save_LIBS
for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
do
# Don't even attempt the hair of trying to link an X program!
for ac_extension in a so sl; do
if test -r $ac_dir/libXt.$ac_extension; then
ac_x_libraries=$ac_dir
break 2
fi
done
done
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi # $ac_x_libraries = no
if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
# Didn't find X anywhere. Cache the known absence of X.
ac_cv_have_x="have_x=no"
else
# Record where we found X for the cache.
ac_cv_have_x="have_x=yes \
ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
fi
fi
fi
eval "$ac_cv_have_x"
fi # $with_x != no
if test "$have_x" != yes; then
echo "$as_me:$LINENO: result: $have_x" >&5
echo "${ECHO_T}$have_x" >&6
no_x=yes
else
# If each of the values was on the command line, it overrides each guess.
test "x$x_includes" = xNONE && x_includes=$ac_x_includes
test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
# Update the cache value to reflect the command line values.
ac_cv_have_x="have_x=yes \
ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
fi
if test "x$no_x" != xyes; then
USE_X=yes
no_x=no
if test `echo $x_includes | grep -c /` -ne 0; then
XINCLUDES="-I$x_includes"
fi
if test `echo $x_libraries | grep -c /` -ne 0; then
XLIBPTH="-L$x_libraries "
fi
XLIBS="$XLIBPTH-lX11"
if test -f $x_libraries/libXt.a; then
XLIBS="$XLIBS -lXt"
fi
# dnet_stub
echo "$as_me:$LINENO: checking for getnodebyname in -ldnet_stub" >&5
echo $ECHO_N "checking for getnodebyname in -ldnet_stub... $ECHO_C" >&6
if test "${ac_cv_lib_dnet_stub_getnodebyname+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldnet_stub $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char getnodebyname ();
int
main ()
{
getnodebyname ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_dnet_stub_getnodebyname=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_dnet_stub_getnodebyname=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_getnodebyname" >&5
echo "${ECHO_T}$ac_cv_lib_dnet_stub_getnodebyname" >&6
if test $ac_cv_lib_dnet_stub_getnodebyname = yes; then
XLIBS="$XLIBS -ldnet_stub"
fi
else
USE_X=no
fi
# dl
echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
if test "${ac_cv_lib_dl_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char dlopen ();
int
main ()
{
dlopen ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_dl_dlopen=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_dl_dlopen=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
if test $ac_cv_lib_dl_dlopen = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBDL 1
_ACEOF
LIBS="-ldl $LIBS"
fi
if test `echo $LIBS | grep -c '\-ldl'` -eq 0; then
echo "$as_me:$LINENO: checking for dlopen in -ldld" >&5
echo $ECHO_N "checking for dlopen in -ldld... $ECHO_C" >&6
if test "${ac_cv_lib_dld_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldld $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char dlopen ();
int
main ()
{
dlopen ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_dld_dlopen=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_dld_dlopen=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dlopen" >&5
echo "${ECHO_T}$ac_cv_lib_dld_dlopen" >&6
if test $ac_cv_lib_dld_dlopen = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBDLD 1
_ACEOF
LIBS="-ldld $LIBS"
fi
fi
#-------------------------------------------------------------------------------
# Checks for header files.
#-------------------------------------------------------------------------------
echo "$as_me:$LINENO: checking for egrep" >&5
echo $ECHO_N "checking for egrep... $ECHO_C" >&6
if test "${ac_cv_prog_egrep+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if echo a | (grep -E '(a|b)') >/dev/null 2>&1
then ac_cv_prog_egrep='grep -E'
else ac_cv_prog_egrep='egrep'
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
echo "${ECHO_T}$ac_cv_prog_egrep" >&6
EGREP=$ac_cv_prog_egrep
echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_stdc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_stdc=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then
:
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then
:
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
exit(2);
exit (0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
:
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_header_stdc=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
echo "${ECHO_T}$ac_cv_header_stdc" >&6
if test $ac_cv_header_stdc = yes; then
cat >>confdefs.h <<\_ACEOF
#define STDC_HEADERS 1
_ACEOF
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_Header=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in dirent.h fcntl.h limits.h malloc.h string.h sys/time.h unistd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
## ------------------------------------------ ##
## Report this to the AC_PACKAGE_NAME lists. ##
## ------------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
if test "${ac_cv_header_time+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#include
int
main ()
{
if ((struct tm *) 0)
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_header_time=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_header_time=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
echo "${ECHO_T}$ac_cv_header_time" >&6
if test $ac_cv_header_time = yes; then
cat >>confdefs.h <<\_ACEOF
#define TIME_WITH_SYS_TIME 1
_ACEOF
fi
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo "$as_me:$LINENO: checking for working alloca.h" >&5
echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6
if test "${ac_cv_working_alloca_h+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
int
main ()
{
char *p = (char *) alloca (2 * sizeof (int));
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_working_alloca_h=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_working_alloca_h=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
echo "${ECHO_T}$ac_cv_working_alloca_h" >&6
if test $ac_cv_working_alloca_h = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ALLOCA_H 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for alloca" >&5
echo $ECHO_N "checking for alloca... $ECHO_C" >&6
if test "${ac_cv_func_alloca_works+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
# ifdef _MSC_VER
# include
# define alloca _alloca
# else
# if HAVE_ALLOCA_H
# include
# else
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# endif
# endif
# endif
#endif
int
main ()
{
char *p = (char *) alloca (1);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_alloca_works=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_func_alloca_works=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
echo "${ECHO_T}$ac_cv_func_alloca_works" >&6
if test $ac_cv_func_alloca_works = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ALLOCA 1
_ACEOF
else
# The SVR3 libPW and SVR4 libucb both contain incompatible functions
# that cause trouble. Some versions do not even contain alloca or
# contain a buggy version. If you still want to use their alloca,
# use ar to extract alloca.o from them instead of compiling alloca.c.
ALLOCA=alloca.$ac_objext
cat >>confdefs.h <<\_ACEOF
#define C_ALLOCA 1
_ACEOF
echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6
if test "${ac_cv_os_cray+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if defined(CRAY) && ! defined(CRAY2)
webecray
#else
wenotbecray
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "webecray" >/dev/null 2>&1; then
ac_cv_os_cray=yes
else
ac_cv_os_cray=no
fi
rm -f conftest*
fi
echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
echo "${ECHO_T}$ac_cv_os_cray" >&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case declares $ac_func.
For example, HP-UX 11i declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define CRAY_STACKSEG_END $ac_func
_ACEOF
break
fi
done
fi
echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6
if test "${ac_cv_c_stack_direction+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
ac_cv_c_stack_direction=0
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
find_stack_direction ()
{
static char *addr = 0;
auto char dummy;
if (addr == 0)
{
addr = &dummy;
return find_stack_direction ();
}
else
return (&dummy > addr) ? 1 : -1;
}
int
main ()
{
exit (find_stack_direction () < 0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_c_stack_direction=1
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_c_stack_direction=-1
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
echo "${ECHO_T}$ac_cv_c_stack_direction" >&6
cat >>confdefs.h <<_ACEOF
#define STACK_DIRECTION $ac_cv_c_stack_direction
_ACEOF
fi
#-------------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#-------------------------------------------------------------------------------
echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
if test "${ac_cv_c_const+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
/* FIXME: Include the comments suggested by Paul. */
#ifndef __cplusplus
/* Ultrix mips cc rejects this. */
typedef int charset[2];
const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in
an arm of an if-expression whose if-part is not a constant
expression */
const char *g = "string";
ccp = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++ccp;
p = (char**) ccp;
ccp = (char const *const *) p;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
}
#endif
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_c_const=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_c_const=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
echo "${ECHO_T}$ac_cv_c_const" >&6
if test $ac_cv_c_const = no; then
cat >>confdefs.h <<\_ACEOF
#define const
_ACEOF
fi
echo "$as_me:$LINENO: checking for mode_t" >&5
echo $ECHO_N "checking for mode_t... $ECHO_C" >&6
if test "${ac_cv_type_mode_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
if ((mode_t *) 0)
return 0;
if (sizeof (mode_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_mode_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_mode_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
echo "${ECHO_T}$ac_cv_type_mode_t" >&6
if test $ac_cv_type_mode_t = yes; then
:
else
cat >>confdefs.h <<_ACEOF
#define mode_t int
_ACEOF
fi
echo "$as_me:$LINENO: checking for size_t" >&5
echo $ECHO_N "checking for size_t... $ECHO_C" >&6
if test "${ac_cv_type_size_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
if ((size_t *) 0)
return 0;
if (sizeof (size_t))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_size_t=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_size_t=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
echo "${ECHO_T}$ac_cv_type_size_t" >&6
if test $ac_cv_type_size_t = yes; then
:
else
cat >>confdefs.h <<_ACEOF
#define size_t unsigned
_ACEOF
fi
echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6
if test "${ac_cv_struct_tm+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
int
main ()
{
struct tm *tp; tp->tm_sec;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_struct_tm=time.h
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_struct_tm=sys/time.h
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
echo "${ECHO_T}$ac_cv_struct_tm" >&6
if test $ac_cv_struct_tm = sys/time.h; then
cat >>confdefs.h <<\_ACEOF
#define TM_IN_SYS_TIME 1
_ACEOF
fi
#-------------------------------------------------------------------------------
# Tweak compiler flags as needed
#-------------------------------------------------------------------------------
case $EXT in
darwin)
CFLAGS="$CFLAGS -Dunix"
;;
lnx)
;;
osf)
if test $GCC = yes; then
# Remove optimization on DEC systems
CFLAGS=`echo $CFLAGS | sed 's:-O[0-9]* *::g'`
else
# Standard DEC cc behavior is *STILL* K&R -- force ANSI compliance
CFLAGS="$CFLAGS -std1 -Dunix"
fi
;;
sgi)
cat >>confdefs.h <<\_ACEOF
#define HAVE_POSIX_SIGNALS 1
_ACEOF
;;
sol)
cat >>confdefs.h <<\_ACEOF
#define HAVE_POSIX_SIGNALS 1
_ACEOF
;;
*)
;;
esac
# Remove optimization on all systems for all older gcc
if test $GCC = yes; then
if test `$CC -v 2> /dev/null | grep -c 'version 2\.45678'` -ne 0; then
CFLAGS=`echo $CFLAGS | sed 's:-O0-9* *::g'`
fi
fi
#-------------------------------------------------------------------------------
# Shared library section
#-------------------------------------------------------------------------------
LD_FLAGS=
SHLIB_SUFFIX=".so"
SHLIB_LD_LIBS=""
lhea_shlib_cflags=
lhea_shlib_fflags=
if test $lhea_shared = yes; then
case $EXT in
darwin)
SHLIB_LD="$CC -dynamiclib -flat_namespace -undefined suppress"
SHLIB_SUFFIX=".dylib"
lhea_shlib_cflags='-fPIC -fno-common'
lhea_shlib_fflags='-fPIC -fno-common'
;;
hpu)
SHLIB_LD="ld -b"
SHLIB_LD_LIBS='${LIBS}'
SHLIB_SUFFIX=".sl"
;;
lnx)
SHLIB_LD=":"
;;
osf)
SHLIB_LD="ld -shared -expect_unresolved '*'"
;;
sol)
SHLIB_LD="/usr/ccs/bin/ld -G"
SHLIB_LD_LIBS='${LIBS}'
lhea_shlib_cflags="-KPIC"
lhea_shlib_fflags="-KPIC"
;;
sgi)
SHLIB_LD="ld -shared -rdata_shared"
;;
win)
SHLIB_LD="$CC -shared"
SHLIB_SUFFIX=".dll"
;;
*)
{ echo "$as_me:$LINENO: WARNING: Unable to determine how to make a shared library" >&5
echo "$as_me: WARNING: Unable to determine how to make a shared library" >&2;}
;;
esac
# Darwin uses gcc, but uses -dynamiclib flag
if test $GCC = yes -a $EXT != darwin; then
SHLIB_LD="$CC -shared"
lhea_shlib_cflags='-fPIC'
fi
if test "x$lhea_shlib_cflags" != x; then
CFLAGS="$CFLAGS $lhea_shlib_cflags"
fi
else
SHLIB_LD=:
fi
#-------------------------------------------------------------------------------
# Checks for library functions.
#-------------------------------------------------------------------------------
echo "$as_me:$LINENO: checking for working memcmp" >&5
echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6
if test "${ac_cv_func_memcmp_working+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
ac_cv_func_memcmp_working=no
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
/* Some versions of memcmp are not 8-bit clean. */
char c0 = 0x40, c1 = 0x80, c2 = 0x81;
if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
exit (1);
/* The Next x86 OpenStep bug shows up only when comparing 16 bytes
or more and with at least one buffer not starting on a 4-byte boundary.
William Lewis provided this test program. */
{
char foo[21];
char bar[21];
int i;
for (i = 0; i < 4; i++)
{
char *a = foo + i;
char *b = bar + i;
strcpy (a, "--------01111111");
strcpy (b, "--------10000000");
if (memcmp (a, b, 16) >= 0)
exit (1);
}
exit (0);
}
;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_func_memcmp_working=yes
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
ac_cv_func_memcmp_working=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5
echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6
test $ac_cv_func_memcmp_working = no && case $LIBOBJS in
"memcmp.$ac_objext" | \
*" memcmp.$ac_objext" | \
"memcmp.$ac_objext "* | \
*" memcmp.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;;
esac
echo "$as_me:$LINENO: checking return type of signal handlers" >&5
echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
if test "${ac_cv_type_signal+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include
#include
#ifdef signal
# undef signal
#endif
#ifdef __cplusplus
extern "C" void (*signal (int, void (*)(int)))(int);
#else
void (*signal ()) ();
#endif
int
main ()
{
int i;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_type_signal=void
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type_signal=int
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
echo "${ECHO_T}$ac_cv_type_signal" >&6
cat >>confdefs.h <<_ACEOF
#define RETSIGTYPE $ac_cv_type_signal
_ACEOF
for ac_func in strftime
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case declares $ac_func.
For example, HP-UX 11i declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
else
# strftime is in -lintl on SCO UNIX.
echo "$as_me:$LINENO: checking for strftime in -lintl" >&5
echo $ECHO_N "checking for strftime in -lintl... $ECHO_C" >&6
if test "${ac_cv_lib_intl_strftime+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lintl $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char strftime ();
int
main ()
{
strftime ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_intl_strftime=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_intl_strftime=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_intl_strftime" >&5
echo "${ECHO_T}$ac_cv_lib_intl_strftime" >&6
if test $ac_cv_lib_intl_strftime = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_STRFTIME 1
_ACEOF
LIBS="-lintl $LIBS"
fi
fi
done
for ac_func in getcwd socket strcspn strspn strstr strtod strtol
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case declares $ac_func.
For example, HP-UX 11i declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
#-------------------------------------------------------------------------------
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
{
(set) 2>&1 |
case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \).
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n \
"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
;;
esac;
} |
sed '
t clear
: clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
/^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
: end' >>confcache
if diff $cache_file confcache >/dev/null 2>&1; then :; else
if test -w $cache_file; then
test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
cat confcache >$cache_file
else
echo "not updating unwritable cache $cache_file"
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/;
s/:*\${srcdir}:*/:/;
s/:*@srcdir@:*/:/;
s/^\([^=]*=[ ]*\):*/\1/;
s/:*$//;
s/^[^=]*=[ ]*$//;
}'
fi
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
#
# If the first sed substitution is executed (which looks for macros that
# take arguments), then we branch to the quote section. Otherwise,
# look for a macro that doesn't take arguments.
cat >confdef2opt.sed <<\_ACEOF
t clear
: clear
s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
t quote
s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
t quote
d
: quote
s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
s,\[,\\&,g
s,\],\\&,g
s,\$,$$,g
p
_ACEOF
# We use echo to avoid assuming a particular line-breaking character.
# The extra dot is to prevent the shell from consuming trailing
# line-breaks from the sub-command output. A line-break within
# single-quotes doesn't work because, if this script is created in a
# platform that uses two characters for line-breaks (e.g., DOS), tr
# would break.
ac_LF_and_DOT=`echo; echo .`
DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
rm -f confdef2opt.sed
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_i=`echo "$ac_i" |
sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
# 2. Add them.
ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
## --------------------- ##
## M4sh Initialization. ##
## --------------------- ##
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
DUALCASE=1; export DUALCASE # for MKS sh
# Support unset when possible.
if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
as_unset=unset
else
as_unset=false
fi
# Work around bugs in pre-3.0 UWIN ksh.
$as_unset ENV MAIL MAILPATH
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
for as_var in \
LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
LC_TELEPHONE LC_TIME
do
if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
eval $as_var=C; export $as_var
else
$as_unset $as_var
fi
done
# Required to use basename.
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
# Name of the executable.
as_me=`$as_basename "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)$' \| \
. : '\(.\)' 2>/dev/null ||
echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
/^X\/\(\/\/\)$/{ s//\1/; q; }
/^X\/\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
# PATH needs CR, and LINENO needs CR and PATH.
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
echo "#! /bin/sh" >conf$$.sh
echo "exit 0" >>conf$$.sh
chmod +x conf$$.sh
if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
PATH_SEPARATOR=';'
else
PATH_SEPARATOR=:
fi
rm -f conf$$.sh
fi
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" || {
# Find who we are. Look in the path if we contain no path at all
# relative or not.
case $0 in
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
{ { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
{ (exit 1); exit 1; }; }
fi
case $CONFIG_SHELL in
'')
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for as_base in sh bash ksh sh5; do
case $as_dir in
/*)
if ("$as_dir/$as_base" -c '
as_lineno_1=$LINENO
as_lineno_2=$LINENO
as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
test "x$as_lineno_1" != "x$as_lineno_2" &&
test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
$as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
$as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
CONFIG_SHELL=$as_dir/$as_base
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$0" ${1+"$@"}
fi;;
esac
done
done
;;
esac
# Create $as_me.lineno as a copy of $as_myself, but with $LINENO
# uniformly replaced by the line number. The first 'sed' inserts a
# line-number line before each line; the second 'sed' does the real
# work. The second script uses 'N' to pair each line-number line
# with the numbered line, and appends trailing '-' during
# substitution so that $LINENO is not a special case at line end.
# (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
# second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
sed '=' <$as_myself |
sed '
N
s,$,-,
: loop
s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
t loop
s,-$,,
s,^['$as_cr_digits']*\n,,
' >$as_me.lineno &&
chmod +x $as_me.lineno ||
{ { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
{ (exit 1); exit 1; }; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensible to this).
. ./$as_me.lineno
# Exit status is that of the last command.
exit
}
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
*c*,-n*) ECHO_N= ECHO_C='
' ECHO_T=' ' ;;
*c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
*) ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac
if expr a : '\(a\)' >/dev/null 2>&1; then
as_expr=expr
else
as_expr=false
fi
rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
# We could just check for DJGPP; but this test a) works b) is more generic
# and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
if test -f conf$$.exe; then
# Don't use ln at all; we don't have any links
as_ln_s='cp -p'
else
as_ln_s='ln -s'
fi
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file
if mkdir -p . 2>/dev/null; then
as_mkdir_p=:
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
as_executable_p="test -f"
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" $as_nl"
# CDPATH.
$as_unset CDPATH
exec 6>&1
# Open the log real soon, to keep \$[0] and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. Logging --version etc. is OK.
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by $as_me, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
_CSEOF
echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
echo >&5
_ACEOF
# Files that config.status was made for.
if test -n "$ac_config_files"; then
echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
fi
if test -n "$ac_config_headers"; then
echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
fi
if test -n "$ac_config_links"; then
echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
fi
if test -n "$ac_config_commands"; then
echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
fi
cat >>$CONFIG_STATUS <<\_ACEOF
ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.
Usage: $0 [OPTIONS] [FILE]...
-h, --help print this help, then exit
-V, --version print version number, then exit
-q, --quiet do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
Configuration files:
$config_files
Report bugs to ."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
config.status
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
Copyright (C) 2003 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
srcdir=$srcdir
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
# If no file are specified by the user, then we need to provide default
# value. By we need to know if files were specified by the user.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "x$1" : 'x\([^=]*\)='`
ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
ac_shift=:
;;
-*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
*) # This is not an option, so the user has probably given explicit
# arguments.
ac_option=$1
ac_need_defaults=false;;
esac
case $ac_option in
# Handling of the options.
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --vers* | -V )
echo "$ac_cs_version"; exit 0 ;;
--he | --h)
# Conflict between --help and --header
{ { echo "$as_me:$LINENO: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; };;
--help | --hel | -h )
echo "$ac_cs_usage"; exit 0 ;;
--debug | --d* | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
CONFIG_FILES="$CONFIG_FILES $ac_optarg"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
ac_need_defaults=false;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
{ (exit 1); exit 1; }; } ;;
*) ac_config_targets="$ac_config_targets $1" ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
if \$ac_cs_recheck; then
echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
for ac_config_target in $ac_config_targets
do
case "$ac_config_target" in
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason to put it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
trap '{ (exit 1); exit 1; }' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./confstat$$-$RANDOM
(umask 077 && mkdir $tmp)
} ||
{
echo "$me: cannot create a temporary directory in ." >&2
{ (exit 1); exit 1; }
}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
#
# CONFIG_FILES section.
#
# No need to generate the scripts if there are no CONFIG_FILES.
# This happens for instance when ./config.status config.h
if test -n "\$CONFIG_FILES"; then
# Protect against being on the right side of a sed subst in config.status.
sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
s,@SHELL@,$SHELL,;t t
s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
s,@exec_prefix@,$exec_prefix,;t t
s,@prefix@,$prefix,;t t
s,@program_transform_name@,$program_transform_name,;t t
s,@bindir@,$bindir,;t t
s,@sbindir@,$sbindir,;t t
s,@libexecdir@,$libexecdir,;t t
s,@datadir@,$datadir,;t t
s,@sysconfdir@,$sysconfdir,;t t
s,@sharedstatedir@,$sharedstatedir,;t t
s,@localstatedir@,$localstatedir,;t t
s,@libdir@,$libdir,;t t
s,@includedir@,$includedir,;t t
s,@oldincludedir@,$oldincludedir,;t t
s,@infodir@,$infodir,;t t
s,@mandir@,$mandir,;t t
s,@build_alias@,$build_alias,;t t
s,@host_alias@,$host_alias,;t t
s,@target_alias@,$target_alias,;t t
s,@DEFS@,$DEFS,;t t
s,@ECHO_C@,$ECHO_C,;t t
s,@ECHO_N@,$ECHO_N,;t t
s,@ECHO_T@,$ECHO_T,;t t
s,@LIBS@,$LIBS,;t t
s,@TCL_LIB@,$TCL_LIB,;t t
s,@TK_LIB@,$TK_LIB,;t t
s,@CFITSIODIR@,$CFITSIODIR,;t t
s,@C_LIB_OPTION@,$C_LIB_OPTION,;t t
s,@UNAME@,$UNAME,;t t
s,@BINDIR@,$BINDIR,;t t
s,@BIN_EXT@,$BIN_EXT,;t t
s,@EXT@,$EXT,;t t
s,@CC@,$CC,;t t
s,@CFLAGS@,$CFLAGS,;t t
s,@LDFLAGS@,$LDFLAGS,;t t
s,@CPPFLAGS@,$CPPFLAGS,;t t
s,@ac_ct_CC@,$ac_ct_CC,;t t
s,@EXEEXT@,$EXEEXT,;t t
s,@OBJEXT@,$OBJEXT,;t t
s,@RANLIB@,$RANLIB,;t t
s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@CPP@,$CPP,;t t
s,@USE_X@,$USE_X,;t t
s,@XINCLUDES@,$XINCLUDES,;t t
s,@XLIBPTH@,$XLIBPTH,;t t
s,@XLIBS@,$XLIBS,;t t
s,@EGREP@,$EGREP,;t t
s,@ALLOCA@,$ALLOCA,;t t
s,@LD_FLAGS@,$LD_FLAGS,;t t
s,@SHLIB_LD@,$SHLIB_LD,;t t
s,@SHLIB_LD_LIBS@,$SHLIB_LD_LIBS,;t t
s,@SHLIB_SUFFIX@,$SHLIB_SUFFIX,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@TCL_PATH@,$TCL_PATH,;t t
s,@TCL_INC_PATH@,$TCL_INC_PATH,;t t
s,@ITCL_PATH@,$ITCL_PATH,;t t
s,@TK_PATH@,$TK_PATH,;t t
s,@TK_INC_PATH@,$TK_INC_PATH,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_lines=48
ac_sed_frag=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_lines # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
else
sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
fi
if test ! -s $tmp/subs.frag; then
ac_more_lines=false
else
# The purpose of the label and of the branching condition is to
# speed up the sed processing (if there are no `@' at all, there
# is no need to browse any of the substitutions).
# These are the two extra sed commands mentioned above.
(echo ':t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
else
ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
fi
ac_sed_frag=`expr $ac_sed_frag + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_lines`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
fi # test -n "$CONFIG_FILES"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case $ac_file in
- | *:- | *:-:* ) # input from stdin
cat >$tmp/stdin
ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
*:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
* ) ac_file_in=$ac_file.in ;;
esac
# Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
ac_dir=`(dirname "$ac_file") 2>/dev/null ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
{ if $as_mkdir_p; then
mkdir -p "$ac_dir"
else
as_dir="$ac_dir"
as_dirs=
while test ! -d "$as_dir"; do
as_dirs="$as_dir $as_dirs"
as_dir=`(dirname "$as_dir") 2>/dev/null ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
/^X\(\/\/\)[^/].*/{ s//\1/; q; }
/^X\(\/\/\)$/{ s//\1/; q; }
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
done
test ! -n "$as_dirs" || mkdir $as_dirs
fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
{ (exit 1); exit 1; }; }; }
ac_builddir=.
if test "$ac_dir" != .; then
ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
# A "../" for each directory in $ac_dir_suffix.
ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
else
ac_dir_suffix= ac_top_builddir=
fi
case $srcdir in
.) # No --srcdir option. We are building in place.
ac_srcdir=.
if test -z "$ac_top_builddir"; then
ac_top_srcdir=.
else
ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
fi ;;
[\\/]* | ?:[\\/]* ) # Absolute path.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir ;;
*) # Relative path.
ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_builddir$srcdir ;;
esac
# Do not use `cd foo && pwd` to compute absolute paths, because
# the directories may not exist.
case `pwd` in
.) ac_abs_builddir="$ac_dir";;
*)
case "$ac_dir" in
.) ac_abs_builddir=`pwd`;;
[\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
*) ac_abs_builddir=`pwd`/"$ac_dir";;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_builddir=${ac_top_builddir}.;;
*)
case ${ac_top_builddir}. in
.) ac_abs_top_builddir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
*) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_srcdir=$ac_srcdir;;
*)
case $ac_srcdir in
.) ac_abs_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
*) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
esac;;
esac
case $ac_abs_builddir in
.) ac_abs_top_srcdir=$ac_top_srcdir;;
*)
case $ac_top_srcdir in
.) ac_abs_top_srcdir=$ac_abs_builddir;;
[\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
*) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
esac;;
esac
if test x"$ac_file" != x-; then
{ echo "$as_me:$LINENO: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
rm -f "$ac_file"
fi
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
if test x"$ac_file" = x-; then
configure_input=
else
configure_input="$ac_file. "
fi
configure_input=$configure_input"Generated from `echo $ac_file_in |
sed 's,.*/,,'` by configure."
# First look for the input files in the build tree, otherwise in the
# src tree.
ac_file_inputs=`IFS=:
for f in $ac_file_in; do
case $f in
-) echo $tmp/stdin ;;
[\\/$]*)
# Absolute (can't be DOS-style, as IFS=:)
test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
echo "$f";;
*) # Relative
if test -f "$f"; then
# Build tree
echo "$f"
elif test -f "$srcdir/$f"; then
# Source tree
echo "$srcdir/$f"
else
# /dev/null tree
{ { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
{ (exit 1); exit 1; }; }
fi;;
esac
done` || { (exit 1); exit 1; }
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
sed "$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s,@configure_input@,$configure_input,;t t
s,@srcdir@,$ac_srcdir,;t t
s,@abs_srcdir@,$ac_abs_srcdir,;t t
s,@top_srcdir@,$ac_top_srcdir,;t t
s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
s,@builddir@,$ac_builddir,;t t
s,@abs_builddir@,$ac_abs_builddir,;t t
s,@top_builddir@,$ac_top_builddir,;t t
s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
rm -f $tmp/stdin
if test x"$ac_file" != x-; then
mv $tmp/out $ac_file
else
cat $tmp/out
rm -f $tmp/out
fi
done
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF
{ (exit 0); exit 0; }
_ACEOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
fitsTcl/fitsTcl.sit.hqx 0000644 0002307 0000036 00000041755 11222720662 014024 0 ustar chai lhea (This file must be converted with BinHex 4.0)
:#fCTG(08Bf`ZFfPd!&0*9%46593K!*!%-LF!N!58B&0*9#%!!3!!-LGb6'&e!SF
!N!-@rrmJ)!GQDA4c9'0X!*!B1'8*KJ'5!3%#E!+9!*!$!3#3$iB!!!%1rj!%!q#
dAbiHY*C6G`#3"3'5%J#3"M'Krr(rr!!!`d!!!,BT!!d*CQPdFe4ME#kj!*!@"d)
*KJ#3$aB!!$'h!*!$&J#3!`&069"b3eG*43%!VhJcrE542$d!N!8"NK)!N!B``3!
!N!$8!*!'Xhd'q+TEp-U,IahKK%GZ)3YCqA+F,1afI$RD9X)@ci846Rl6eUjZjDI
T`Maq(PR),B3ZH1V*2$`6haR"Ib`hfppaXT!!a8%[@3J[XMaC"Q6a*,XRQpa#IV%
MYj!!@dk,,dmQR%b@)i[N0PR)mT,Pb#,C(IQ&,-FAb8)@[T!!@miN#aFV[%"XlFV
IPbRC%AjZGJZHc$CCb'fbN!$EC#',NB8XI#@h!UaR%jDGRAQpParPRYHCSlbfH9%
qLAe[6[*kVl14@qffANrlc3EP0mp"ANjFG$'fNfbEa'rKc6*l'r!kVc-R6Ic-(*!
!jFLf"MD`Nb`6XTbG!&J!!H0lVl2139kY$IV1&Phdb#B,ZBAXcXX(B![qJ22cr+j
qRQG4&1f*SYDqU2AfMd@YGmj&dGIH5XbYVEN@4rGEPJq5%h&4T(R4lKAjkD4I6@0
Y+Cpk2rB$8A6JEk2SS2f4a5Ldb%UI,m5q"k[cT*q,SPFT4[[[2h,qr2HYV2keh2F
[bDFG+H`FTG9fIh4M&2h!HF8A6kQjU%8+TFpi5'N#b#`"jNXTRLcQ6T')a*&[r%*
"Mkf6U1M9Tp+UA1YR$b6a)#RqVI4$-I&`691$5(4$&0hbB(`QlQ4a@5EPr1Ri-aH
jZYYV,jriRTj[C-SNkFr'2K%)!SEk#EJ+ZejCBNTb*jkTf,G56lice5[k1bZd9q5
lSPI@jcl(RqhiRlErR1KVk[1j9*c[2-F[mhQ`Kj2eqD+k3b24rFjcXHqcSMl("Bj
5a["cmc6!**HfN!#0`-HVGGd1m@*!k+!CGFZCe230"DC)&)kLTE%da6&BQS6#(iH
GJJAD6h",RBLGKTf123Pl-[B8l!cX61bT@!"NGY6DV4+ZD&0NVp4CQ2$Kj0ABef"
IKEfREYG)p$2BPf"IKVdAqc2BYrR'#l&0f2QZ,I8$Khm5Z`Vl1Q`2GM'f&pZ0lF3
#(kr!rMMfVKSq)Y'Gf!@Z"Me!lh4J,kYK"-J!,L,4+KBJfS"pHpfA`*!!#eKAB+r
%EX4H*Ac6pKVXYGMVX0GM0f'I9%18@r8hB'r!VXEHMAdc&KUa(rX6f$8e$%@LGf2
IK,d%fej$9L4k(lB0ZaREMpf#hBTp-[C'l$EXGZa0f*Zad,S"l!lX6Z`Zim&6X1p
dAjq2"DM"%($JTl#[ajjKR*KYh0KM['NePS!0i-TFBm52'PYDX20%Dl4Y0XkFCR`
#Bm!RF1D*f#A'+E$Q(GLABqr$[K+lY)ER526k'Qk"D*GDA@5-@Sk&Iql$hSTp+[B
fl1hB1l"2`ciGq`cX-m@MY(dfpMRBGf'IDjbm'2YZl21`Em&feE3L%Vd$qb)X01h
(X*!!PKGLAibp&2Yml!Z-PIrp*HZHbh1V%XdDM!5VkTNX+TpZJI4b8Q`QlCA*IdX
4jr-YkI@1eK6&@6akrmRqGMU3!,Taj@U[mhRH$4@CG'cPf-,bd[c55@(5d!Hm'Ec
N)1F0VFGE0mm*Q$)9c(DapN!C4[Pk1QVGX9S0fTef*aq9HCDd1dH@hh$[GR[aU2M
%YbSHD6ef%ShLKarhb6J(+daPJ9dAVb"[0S"[4#F*e!qlJ,VK1Si,cK,KVpf+[*V
m"0V)(DQS@2#KMDaFH%58b08H,'rIQYAZdQhG8C88Sk4U,jdGChRaHHLUIbZ5N!#
f+cNVNF$+pN&!$2F-Jq`[hkEeG*4@DCbPjli#MC[@bbSZ[MVqX'NGC"p)4h(e2mJ
-"pf2[40l2IDef2AB+GJ0XMU(d@F4YE3bHSL#2JB5$NPLGD+M#!6#kX`%B+G4C(9
h'ZL(RmL)mAJqIdPIINMVP6[ehh9BS`f-RhMM-qLRXA,V*SdB-#VLl%Nrq4(1M#c
%AlN`d*J(BaQ*AMV5H-VlXFQiPf[8ir2Be(+hjT(rM%eAaa0'0C4',5BY*b2')j4
'1BkT8)be$eSi'CHZTp*Sb,&jQ6"QS65qF9bDCI)aLM0PG5YRT%)pMHri"p)"pe0
rMZq%jI`-[UKU0rAqT#*I91-H*q,5YBPU6'2DZD6$Z%P8Bbl6Xe5eL@UmiL6RBic
Pj+Uc4[fL[iR[P#TlK&c42m3h)aeeU%hd@A`c1eA'Z%T-)b5RCT1%8C'BaRYQC6H
[FUHB4Q0QVb8Pq@)DHCQc@-5-`F3dTR(D@K%c)K261&(6U`M82[T'paekG1b2m6'
kSQPal&1Fjhh`l"+M1Sl'14KES3dCp@'F"4pM3)`Gi@2N4%D(()fU-"+$Ma%@4T6
`r6B(4RA`r3d(4RKSCheI-fD%MhXbRS32hCI4%hbk$QCd#4mM,Bc!i'0%L2VMqf8
1M$MKq`)(4Tl`r3X(4U)S,A-%p$iq4PUS*cl'9aL"`XGS%,(i'$PL6!NIBeH-3H(
l+!I'RI$p'3G'Si!JaPFBNF+(XXq)%Ml'GQ3Q)+Na*B12fXG)$AA'akJA1)M[`ac
)LHp21B!K`"SS,Z-9+I8BScri'2h"iJ-$'H(""iBa+S32eB-a+Rbr`B(a-(c-AmU
S4&TM6)aEiD2(`"0mM2aJm6(fj-iV4Qj@Vp-lq"K*!i[aIB`$q)$[,cN`,JEm-QS
&hZ)$#aJA`dGG'"[$"fic2SB2h'+-$"mMCSb6iIX3"mE+m(f*!q0P3$Vp`F`)2V#
$F60mh"N-`FFS&*`#(f0GB$+qAq2!'"Qq[q"!Rd)0U"Pm!aph%L)q@69Pc!`IGf,
F$"mMDibGi316k%GmAqB!*N-a'"0M(!dI1-9B'Mlk!3k#Ma%YX!JI)h+-Uq'lRi-
)9FGqJJ1MDe!9F&6NKH28@r3T2RT9Z0TaLJ'Vm6(kajJB2MJ(if,i2XF"M-A("!R
MBp!IaYHS-cl`5*MF&0@GX6*mM#JbASD2%6*UL1p6jQlirT'$QAr40)Ua0FE2m)'
cM+$KScrK4rL)Cl3-(q0rM*MKqbd1i#Fq2AeX4Y(dGi)`J$%eI(!*aY2`J9q-8H+
M6m"'I)a"J[2ik!0UL1q,("Kcdpp889K'mI$"HFL*$k`%!r(4UiaYiZ-qM(,LJ`-
aESR[pcM3GrMqRJ1MR[Sl8H0qM'(LJeH!)IM!0IJD2RU*X8jmM%M#II$"&4Mca%F
I`)[e0ddF%Ac$"rq"Bq)$Bm!6I23U)jIib-AB*6kQS1JeI1!@ppAIG2@@88qe$li
(*Z-$[q%[q-!bq$)qHSD49Ab-LX+Km-&V'@[%pkmFi!lk1dND!(R``ArS(AcJ*Z1
Cq1KEaKAaF6G`"KqFJbPcI2$,R`fqNp8(ll82[[GcpX%ahQFI'2IcpY&Ai!!qX2B
AlD-2i-[k1dAMKVpN(c`@R-G(Erf+IH$@VpT(IEN,[NpbN!!TXe08HhL(rQD)9rq
kI@$f"qfMRq!lq-!qZ"XqqKBY!Kqe!!I`JE9J)lkrjI#4i*XTEJG[aFGGk4GmF-k
2f`IRqB4pB$fF(4qipM[fdCpS-ILi*jL'$pl`qrEp(3IUV,p603*,6I#K"G$lq1#
PIf!I(1`cpR&[Y!Kmi10RlD1(rmJqkX9pmF(9d(cd0d[i"2I("jD!iIMJr'Jeq-$
X2lB2r[BRpX&2i&2i`&Pi*6i`j3(lU#NiJ!rmKT[VElBi)MS!2V5I2lF2ENppm)(
PCYH"pP&MH$%qD[aApS&PB$JqqJdF`mIjUm%h4b1kp$8q-*KH``F'ImdqqKLp#"m
B6kh`8GGrX!qmJi[KSjrqb6jUM@kQ[p2%Hp##m+&RS+AJ!c2!,Rc8pH[f`5(rc6j
iMYlfB(aJVTP*e$jG9dr52)fkHT1$6H#d0drI"(p9(J9Z3LY4(YPTJ[qVX(FJdTD
1jqi`L,6KBmSM&dhJN`Sl#L*Y-&&TR"UIlMeP&I4dXTCr&T2UI#cS6)REUVZ`m
KFLGkJG+B0cl0GC9`$*rZ)D8aF(bkKj6i"6k0$8VMprKd(bU0d1Y[,M&+Bq6i0"m
e1L3qM80+Bpri0)GAiX,i0,p4(U'H#lp5iSEi0!G3'M((Th&+DF3FRqj9jIRBHHS
KaY2aD5e-LE2MdpaADH3FRqDqbP1Rmq#k5ML*6h-T*Id2RmCe*4c$Tr&,@IpVTJq
9pEpQBT6e[fEd*QApVaN04@p0FAfD9bRVIme`B'ApVaRqTUcr0B-pb[TIXhT8p,m
@qPaCrf[K$XVkAi[k4[5r&V3(CIf["He!@IpVd9B5dIpDi&h+qPm,(-"S[rJd6LR
VIr2T+fApEciDRl,q0aq059RrQbrY9r5rqI"cCIe[2Ra2@IqE$fp4e[rQJlR+qYm
#X%"CreZJ[K6pE`%F5&Rr@`"Q+qYr#q"jb[VI!RLiX[kh3(JQqYm#q)QbrNHl+HY
rVI5fX[lAbRf8pEp@Y$"PrDm9VU1XrlA#lCAe[eEeLZKrVI!aCIf[&5kKV2mY"2Z
8pEq&`M24raCb"fApEb(kPl,qYe!B)rVI3VL8dG[aDCkTV2mY&-D)rYFQE"EpVih
q9pErfVLEX[lA*UeHp,mfH)DbrYF'9eI@rpVJIXVkAaXm4&RrD`IAP2@rGY9-p,p
fp$KPrDpG'#ckAcXDK,,qe`lA9GErfZ&Xb[TI"la#@IrV!*Z8pEm1e8cd[`iiRl,
qeb%1)ITI"paG@IrV%$k*rYFTr"2pVa2-9GEr1ZPKCIf[8h-0S[pe`Y'9pEp1e8c
d[dii[,,qe`Q(90ErZY6(S[peJCA+qPmAIDZXrh@KkbRVIehS2XVkAjHiL1KrAI"
&CId2L&E@rlVK,FVkAcHBUkcrGBZ,L2lA,C`3rDmEM8pCrqY'fe$@rlV9dk,rGD-
A+1YrhI"9CIe[%6a0@IpE*$iRqYmLX&9CreX%4LMVIi[S*62IJ3qX&Ie[NE"@p,p
&`RA4raDK+5MVIi[JcmVkAirZ,ITIMcLVk(mpiN1Lrr@!0FVkA`qpSDcrpD#h+HY
r2I"MCIf["le'@IrV3CY3e[pki0l+qPq[q)6SIlh#50(rHZ%$b[TIVlL4k(qpp)1
brYI,@9Rrka9r&If[&dh(E'qb+hh`%2L(Yli'(J02mGIB`(2J-I!,Ikh,iG8fF!2
i%,`!2Z#YKr&@bAJVC1#Tm&$i*$`5rJL2KDI#(lee2r!e1#6F%Fi)9i3M`JhKK("
"1#$F$liEVJ*#Zd'cm9BbHH2BrQSQ2V5IlkaS3N2+VfPbjjI3,G!Vd#R32p!h)-l
S%qJ5k#2S(qJ5k"(S%1J2N!!Dp!Cd"[3&G!Ad"(3%p!0d!r3#G"5d!M3#Y!'Y#F"
Ri$(`&hJ,I!@Z""H#Vm"6i#G`+AJ3[!M1"%q"Rm",i#2`%2J([!1q!Fq!Am!Vi"2
`#2J$[!'q!,l$`q!,m!6i!E`!2J!2J#2$MH(%F'%i-2`EIJd(K[[#HH(RF'Zi0M`
FlJ[RKH[#FH'fF&Ui,"`@lJTRKD[#8H'QF&+i+"`8AJrrK(I#0q'Cm%Yi*CS,@JX
D#pS+QJTk$RS0QJTD#KS+HJpD$GS0ZJjD#KS+fJQD#9S*'JRD#*S)@JJD#0S(QJG
D"aS(fJDD"[`(V3K0!bd$$32Y!Xd#V3)G$rd1h3kp$Td1M4!0%*d1I3jG$Jd4r3m
p%+d3I3jG$Md1(3lp$Gd0[3fG$Ad0A3dp$4d0r3cG$,d-R3cY%Bd-E3a0$#d-$Fa
SAfMkD2PSq'LhD2E-#c!2J'D2GSa'cc`"'Mfc!F`0S0@MdD0MSmQMaD2"SlfMZD1
eSl'MVD1TSk@MSD1GSjNcKi"HMNk12Sj@M"k1$ZjTe'M6D0*SdHMJk0aSd@M3D-r
Sj'MFD0lSi@M3D-pScQM0D-aSbfM+D-PSb&SlPY8c4L0''dB60PS`fT(Q&1Lrk,l
S[HLm4Yq&rm*lQFq!mm*eiG"`C,JZ-bl-YX#aQG9JlJ-ZcF`(Fbl-E+#6-kr"V!X
c,Xbf-!ILV@*MMSAj$ZBLQ2eJCS9C&@C8d21C(i#V-ir#$!1c'XamS)NcIi*'kkh
K3[p!pd"R36Y"5r(@DU&eS-@JYD#PS(HJFk"[S'ZJCk"MS&qJ@k"AS&1J6k",S%H
J3k$ES%'J2D!jL0CJBrL@(&[Y6VFfkC90N50T89EYe@4cQ$#0faH'M&HR'qhZF*`
A&6P@4FZp%aIG5q-Xbr04qi%N'dI,*pUGrCfll`k*VQchiV)IClAhXZ4Fe&XkFM&
ehjAlQq[ULpb5RmL,E$$ICi4rGEXc6l+Q)r'qJqRk[B2Ac9-20klplXp&hP"YFFi
%GPp-HGPN9+A$K'$*eEqb1Tmjq2,ZbX-RG5-6Qbr1ZPkR,NiBj$F(lN`$L&-D!+q
f5mTKG,+cFQ6D"5BZfa3QU95@'fFURI'DE3C2M[[*EURpb[TChATk%9,2S(K$)GR
VXVkVF$-[j(*G@q,#hY*jG2A)0(4MXa1X'XBGPSc(&km9hL#h@'aj2'5JH`Xa1dG
RNS+ZL"c*NV-XJGdk,[*q8TCj%4e15j!!+3MTZl5Uc,Ym*DU3!#ahIFR3p(b#b+(
RXDZ2%Zk1Lc3T$lQShTN,p[eVEah+'(E)dR48aq9k&P!c*9bGMVETLf@6XXU(lBH
50cqD&i-b@ZLV&c3dlGdUSl@BAA9!rYiU(@f@-!"Gk$AaH&alPdl5E-$QM,e&A%D
,bFCNFc-TfL&R*!$GXR`i*UHqTR(VCE`l`NA@plMLML5,ZXIE+f-UT[IDl)i-L*Q
XiXqNT@ldpI*N&*TXHkRG-!-EGE*X8A&Tj(62X[MA49LjYHBEZ9[U,-ZcI)1ECNX
K'pLk"PN@(EVSa,H#A6bkKld`el1K5V-5hpjq4Kp+#ZfmI#XZ%VAmhZfGZ-f68kH
53ZRk6e'%lENmfj,qGMNCbU9VXjXqe+iYaCP#+F3eN!!S(SpH@b+H25&Skb#YqVR
+J@IEB#,2VA'fIZU#`m6LZ&de1r10kim@mILHA9q[DpQ[T5Ep%BhXAXKeE*jk++I
VbDEC2[AF02AF229NEd&4AFqqRC6lGR,ZFp+E%eATaL+IM1[cVVJSN`,AYK6)dZI
Y4Aa+aG+ZJA`3dZfDZ'+ZJiUj(LVQHULBkq(kVSIEZaiZlhUbYq#'VSH@%NmfZDQ
GZ#5p@icGb@DDMh#!BMXQpBfHfLr,LFUL(IY!$1h4%0)TI)CUVYrHFI9RpmkrIVl
FbK5@FI8GkSlBjA4,&PGF,S!QS2k#)JGMI"EJCG$Ci359p1iYql-TaqMk8$3Hphm
Tq'q2$PdX%S(DEiLH[P$q4RlC0#(+h`!DEkU3!-qbD[FkEU4K8kY#[05SUCG00Y2
4#aA-&+FBi+A2+SZFi`N!"AqB9ceb!(!@rG3I9P`i(Dhk$qfKh-EeTmmbJHTRh
GbSYaYc9fMIYE1ePJMcXR46pTVa8*Hdib0%Nk9&FcB"U$j3`kchM2QMm3DNFIAPj
00UD9l42Gd!%QPmFK0KNMGf9TVKL3!(0JPf!mC4*6LMX%Ll[6IZ)8PVM2Qr-`jrH
qjcjdrPl2AZD6@1#qT"Il4lkkTp#X+2cZRN+cSM$b[hX+5p[aXa[rr@Ab",T66me
qES+1$h!`F`9j&F#F*Jm6A#pYmM#apI+G2*@GpMUFUE4,Gr)%LmVmqc"eF+pf)qB
Mc5I6RbD-+BcA0r9KQZ+q'qYHdV@UhiG*MlFhHCL1Z,ZT)a-8EjaGQdGr%)@h6*r
R`1GZ,lcRearr000mThXlMkAYHphdU4CCA,Jhi-+PXpc%`(LdjjBVJR6Kic8&`BX
+l!QIfVheYalhSBH3!+dbNU@mZH@4rXNPpTjb`Sk!F(H!MH!j*qiX,RX!f!r!2$r
l!0J6%1i2m2F'I'GI3'&AJ,Fhe"6m41`dl(6X$1a-l+RB@GMCf$RBdl&cXI1`cGJ
@E#Yf)EB0filY`(CLZl$Gf%AB(Q`[GM(fFGJcX)r(RSNp#rX%E"rfE1`jf(1ajf(
2ar)HQ5ABTGKPf!Z`&f)[`Ll(ASaGJ9f*AB9GMEd'Hbhf1Zcef#GKEm"Za[D(U2p
k+8hUFaLE0*H`[F#YpH!&)*D-,K!9ff!%3r"Qm53EPE`-D,lhiGh2ScBb3GiBIcD
6@6"RA,*fcLEh!4X$-I1#PU,24V(h2XU')c1RBi0j,mDd[Cf9aD@plEf,#fX,(0G
e1fXAASjN4rPX##5lp")L#C!!jDE)@jkJKQ39fbacLDG)92Uj"2eL[8K1m&XZ`DS
[@CGUeR4j,p4JL-YEaB9`NRjY@'V,qM!0RTXejXDkQ@-'5rAp@"dcH4#UcJSG@CG
U9Z,)ZP5c@QM+Faq[ejLakZIiMG0bQ9UH%,e@@iM-+PCCPfV@PjiBR6q[06p)CY2
b1U&CJ5RV8XeU59QADPBjDKR2j'2Pf5R41e8EXqC`aVLZM9N6+1Y5cISp@CHUY1j
R9XB1%qeM)%A,IZGUR4@VIZEF(YfUq4A@*Cd@GV!UV80UiU+XH@*PN6bA`,5HV%Z
05Q+8GDP4iL0hIDKHN!!FPHcA8Y9b9&4Ve1E[HFm2XdSSUTjE-#`VZ'08+pfdR"K
M68p8UhX@4[Z'V-Z+DPf4V%Z0DQ93Hrk@R08p8DehkSLHH!YVZk*DbD4PabKbShN
H![+MPMTMkLeCPaU6P#RV8Q15'f9GDNa#QUa,MDNHXLie*Yb3!(@T-Df2NR@T-Df
+NR@T-5'%V%Z0DAf6M1`k`LaCPqUS*f4GUU1HN!"eUBjU*1Y5(DfG%pR6d5Sj@CI
UD!fH51q19Z$*ZP5([[#H5q"S6C+X5h8dS#6#P+0e6l)ZeG%+*PQAkUL(C&fUSe9
CXLl9dDSX@CIUD1@9V%YeY,CCeU8k@N%Pke,MkLeCPaUAP#cV8Z2#!PQA'TFF,1Y
5iqS0@CFD9beNA@Vm`USmI+cSNh@TFDhjNh@TFDh[Nh@TFDepNR@TFDeqNR@TF3P
CXLieVY99XLie[[YFJVM@8-Qke,Mk30DPaV8560DPaS8VXLieVR9JXLie,Sb4GDP
aiCqX5ieVACF-Db68pc,%Nj!!rV8K2#DaQ663L(C&eU3VJQke)6`KTCPjT3rmZ
ke)4k8YDP*Y3RXLieSGU*`*[3(@4GDN+#X@Ja#Dh0NR@T#Dh0NR@T#Dh&NR@T#3f
ELXLFd&S`@CHDN!!'+*`ZS49GXLieSI9JXLieSC9UXLieSA9UXLie)Ib3!(@T#@'
NV%Y0D#@DV%Y0D,fCV%Y0DUa"eU8QaCeNA@T5e%2@T5E&+f4GDP,B+B1VbGhR%L5
&Jl)Z05QFNR@T5H'&V%Y0UTpPA@T525EV8T1UVka,6HUHXLieU99LXLieU69KXLi
e+FiNke+6kJ0CPjV8'MPCPjV8kMGCPkVI(j9j,N&+A&(@TDE%c@4GDNVDJDa,63R
(C9eU5KJUke*6kRYCPfUH1#(V8P2U59PKPP,YC&eU5M'b,M@P&@kb,M@PQXQke*4
@hXQke*6k9GDPTV6+6YDPTY5[XLie,G)Rke,08bPNA@TD1#I2*8J,fq5j"'Ra((N
Z39Ti*XmP5![6jEN%D@'L2*FJ,Gb4ja+NeD[bA)+dqN'H5j!!eThPZ34TpD)mPb#
Y&AAbA)+df+FmPb#Y9AlbA)+de[(*F`R5iSZfMB&-QH5f[haa9K[Q9VVN&SCP2X3
PXm$&[[$j-h19!'+bVR!&AppRYS@B,eBFASF*pB-8&q`9Ja20Ji9SaQUjqh(D`
F(+`,+fH3!2eKj9K[NGKJ8q4AR9AM-d[-"Z20VU2"Z'!e@M'DH5cd6EeYUKTF+jL
*[Q,jXi(ZGMKA1R8AT496K#[DKK28bqd[F5X(MlCTEXeE1CDpEjA!iAB)0X-9Si0
9FFAS+hRJ$Z8FMVrYhMImHl%*(LiPX9l&j0a8Sq0UYTm90df1!M-*kX"-G!1B56!
#c)6AJCRS'M"l`I@1pc+8fX5,,6HfDBS4B-l'9j!!bX32!60aG@!QZJE-QH"D`FV
!61!B-*1L!Fbj"29bei$C#ajYdf&JpQ+,`*`*('k(1M!6A3GQSJm!-r%eB2D#Kd[
T!r2JXY)U%)p$m5%`RS$MF8!HJq6$S$`+bf2!I"#D$i*c(Cl(!IT"1$d%U)FJG3a
8$m2U+,#131XBZ)l$kcM!MK'GFDSc3RB1J[FBI)m#q#-3MPCh#-C0QM%S0cN1`VP
*-`lT*XNBV*XFSp#H56''1TNmY6E+C"K[TA'Scf8C39)hbc$NQqJaf$Fj$N1r5A3
3r[ddii8ET3'C&)HEXN%(-KNUP#!E2YUcBp6!j"LM"bE("*!!QbbMB*j*-9Vd3k!
q5PLb+3jI3a1AmPV`)R1SC!Q)3b9&b"XU@I+dSC)MB!h9&1ibG02[eBZD"HSM#Ac
H8Fm3)&`pMI4k2B(ASp8Qc(11!dNbb&e0iM+15R"!1#STI-`Cb6"DcP(%'D3dP6`
KSfPN'@X,Rmr8-aaUpKbEU5H!c)a%0hSRS$+9&!'6UD3S%*P+%Tr(e$-dUKh)rU9
R""6j459,`#mU+8*q8FQ5jaH9(!'rU+6`b8%p3h'IIb90EXYr*F&B"qA*`B%N`FX
$KT+ij+!5R(rC3$Q&6`j'-Sb@db-(PHK"FP$*8hak`B%XBfe4I+C"1F1KCLmmkD#
5`([S36@kd6X"1DLN+$i9B6"&J4a8N[MNS*kK8Hf$j-"J`HTiY$Q*0j-AFS3[GDM
LIZD&$[@EAT!!plpB$bTfiGPq!JlUL-D&`1hL+acUIAdN9A(IrNMIk!BHL%F$p@!
MM`ZTBlb*bKpi9%54arQa!A[c!d21jXIQQCSI'I!c2c#%JR+XecPqX%rR`VJ!em2
J4N[NZ&dBjX&-d%&j(MFBQU%T3DM,fB,1b@#G(c@)#FAS$0)@)`XB8B`AdPH-+p8
jK&SrGT!!h[R42K%,ifTY1[iF$Tq9K@&`X@,-80N#hZ8("Qc,$ba`,$r8CeCKA*&
mK!NDPFiaXM!XV+TjA880e0hS-UblSF2!lNCAS0f0,B1l'cS-liAS%1$Gm",%Cb2
,k*%0Vh990N@KVl+"eFkUJ,dIA)4l#Fi$[R48%I,GZ$VSjq+,X*q,V3*r,N-"qR1
4PFS2`lmEA5F!ERb*!Q3M4pUi331b+FTY(&+"A&5jL'8ki)D@#B%E@U8%ER#*&'3
MDl3JQf+XpN28)"YBU,+mA'5B(AMK*AVJa9EjJ4GH*JKHF)NKH,&9LP!-,h!%,hk
)*2LK*AMaiiGlc-q4Ec)rFVM,bN`K(ae5K8ad`"8bh4@5"5q`aKD#"#&G#))VI#&
)N5F-3@Le"DU8`3Z[F3B[`4"Tm%-2Y28"fZ$RU,4eJ6J%BC9DPUL$&e[L$PjXK6a
id82X`3mGTJpqM[%Q'#33IQ4BEARL5ie#H2&P$Z%&$j-),ll#)VcS-Sh`JSGj4$%
q*"*HJK+6m'2,Q1-RU2@ERk63F(jSVH-UG#)IAZ36QI!mSFKd@T&4H*&e5K&N+(+
+),T++S)F"9B4a!lh`M#[m1,Va-,,8')@IQbMc4[F`Np5EI13!&d%FG@5P[Q&&e`
Q'&j`P@&ii5@+iFI@1)DIC+)EKPL'(aT@2IHUS4V9m(18kBDIB*Kbq$NUY-228+B
HIS*KqP(1%9)32dQ*KS6aCB`+Np3k-da8k-i`[0'K&@SbQ+*)6i)8HBS5G'D4T[M
4GDT5c&+N+m8-9FT5c&1J,FAi!rdb6&rm((8+ifFTdCJ`IJ)Q'R3Q6$3#%b'Y+FD
1P,Y-Er`%CBVM*kM5($p&LHU%m6@k%bCkX'1'D%mBAZb+SGPp2lC#GBEQp2hB+V8
*Cr,p`"U9m@1,&+B`Iar'9E")JZXGP4r'$m2+(95P*)2MpN&SJB,31B28`aZ%Ve!
1,hU3!'TiNF-8Sc#PAi`VeEP'*FVcq(jdQ6U8jZA$i%DEPLK#ERLq'$08YJS9#-I
MrF"Kk#q-`SGaGDLA")e+Pk#p-$M[a`@[,`XPN!!Jf%lc6@BED#`ml83[q6i1VrI
'BJ[FajTBr55!Ep6,hm%&Da``H,LJMc`53q1#pkBpfaY!j(!Kc[-FP"kQf4FpQK6
E*DX6Y*jc3b&*4`C*p%X@pFXmHBZJPKDfm(j8RPCS+313!"b2R"4``CATpShekP@
E'fI)i8+XaJ@,'a,N[a`Z('0p3Epk8lq*Xfmc'5@mB02D"K3jA%#ecZ(#3$bl$4-
+Z(#XAXa6I!'aGI8,Rm0VBIQXFV-UjR[dfB1fXXp`JZ"CdCHR`c'cfqZhfr[+VHr
JTFfm*p'5pKh9R-bm"Up`Y+YmpVQC9r[YZlQ6G!(`Z'Np(D99'QHXSAhX#T[@Q5D
1k,$l+fq3!0kdAL9&I4K)4h(ejHZlm*ik[V,Le`UlArcqi`rlZF14QelcfA%MmPl
82DT(ieqrQbVfLV!UPbfj5FG2mrP%Rkreq6UITrYmMFkk'2jpR&IdaFQhkaA!Mh1
H'6l2p2P8RfIj20[R16kIl[0FRqIjh1acLmqY2LrdZFhRGTmlI1ldZF[RETmAqGc
MFkr2LhhfkRH'cirhq8bIcr,j#6lhqAbfcqIiI+l2jrPm[Xp2p(Q*cdYpAZEc"6j
Ik20&2Lrhq@+I9rLmdZG92YrJmfDIqheqNXqVGrY@[4ST85E@YYGSi,LlTrLm`HI
e2Vpf0h[m9N5BENEUr3[%R'LMcrYp[R0IeqpDMVcTKYFpq8`derVHk1[RRTil&l9
Zf(GIliCp$rdGMql9lkR@llrqaR1$Lr%kCUSI%bhChlYeZek,l),2`MIjaF!MRhe
q+d3kDYeakFPfjY%#0hp*8mkm+9kr8(fMhJ2pJbpiZr''eZ1YQqImLQh[ibAXS[2
a[QmE`-H,Z2-hY-*!`hG&)XRr2b+4j2pIN5M6aUN,,pVh[k3(*k``6CljGTH&hp*
Hrr5,'4VaRV$4eFpild-pcjS6E6mdB[5qAHG5[k(pZrH``d#j,HqE2SA+D0565Q4
qkmXhE@pRCA&TEh[[iX,D!XGehFkD(Sj[8IQdBQc6T9!fZ@p)GV5hI)Bq(K`mUV2
-SmF%rKQ0EMU@mcLX!epXHENh!f!4$SYJebqGA*[riSL-qhMZhFQib2@+X*eA,Xk
FPVR(f$jqHDChl5,F`hd&emLHRj2#%0Vh2dCBPSc(-`"'JlM(XT9hEer,)b-XM4c
,XKH(DEjjMj@RLe2cf1r9pIMkVXX@C`2daf@VacZc!HjK%'EceP@%dE1Z1m'BLj2
X#b0&jKihATe*@Ki2%cd!M((*@j1##E9mI!BjYeA$Pd(%h11QUeepZ1mY!dJqm(r
`NDh('%FC(cA,h--+`#bZl[DZMj'1paPpIh8kRNlRIkpIYq6pbFXp"LiH(ZNlI!q
q)b0p%rI4H2Crl*3q-rGiD$4`Y"I0qVMF5r$#VfRf"+0FXhcdm,8mHJP&8hHSKEZ
8YPVjG8H[)p@$pl!'--'eKarm$`4HGq*k2GBGc6GQ!p6$8X&-al"F)jll&-&DGhM
hD,pl9X!p4J[bcAXdJ2`rlc(1#"kkapDc9`Ybk,-0+!RIlhX8'mZ!!M$@(ESHmTc
kHU1jpp![K,3%h+2rT3iClipXAIZhAN6'EpjMed[XIEbZQA[B!a552FRQM!!mX`)
S,IB*C8-rEAU#,qTh4Nl`cMh9C%E!2ILkD*,[eGAE5YAerdeLp)EXNbmV55E0RP"
),#HDXMf!`9NPY&Hl!T)IrLC@5XqCqD%*kY*@+rqS*PLrKpeN1Z4K$Dl@(BpTF"2
h1+,"6GcML!Chm"i2DA$Mpl"hD($9ZYSF0,KkScfU`BhIiiJ'9lh'Yc@iLAXmV-&
9,Q)Md1"'FlK[e$ed$bX!iplB@ER1mmL48DZU[@Epd2*UJ2DBPMI#C'`"@YkDDkp
EQ0Sjq[$Ubad%dl&26"IC!kD#E#I6-lGFCA"kX5H6HpRR,1Hr$01a6dcKE%PQ!!b
DZ[Ii2J*RQ2ZB![!IpE$I6-rXR3A`BQRpIZ[&"pUl$kS1[fRrb3Md44SGr6!MQ,M
(%8B`FBmM5(l`(JmKqIJpl!&)EPr3mUTeY6PSHI9'Hj34M0rM##1SAZ2EM'$L(Jp
VHC@,C1ia*M2THjL(RdrJd1kVMbVR%PY,La)(lQ%&d2,i,!,cBVHN,qPH1F9Q"2(
e2ACZR(la(QXh6Pqr4hDaEjA#6Il5ETA'HZ"(GUXdlR&i@ZA`qQ6,`,6+$hD3!'5
BcN-l5"VpB3p3darCe9'Vaf1l1KTeYCLXc6lk6&MlHY5C`)Gi)*%qVTN,T%Jr&
J4aQRcX06GLjTmNcRZ,E*-i2Mj8fHQ4cA0hP1jELKb61,ia90RYNFVfcbc1'iXFP
c1XGVQMac19lEj*R(mESQ6c2(kjXm,4`h0APD1@jZm[$fR2iQ6a[(,8dHCP#f0RN
k1$kjbG2*mFBQ6aI(E8fHESlEQcb,10l8j1RKH(16TjIM,8fHa4`(QMb2ilLMbA-
'aje0(QC$GM9jcZ6iP#E2@4ah0hQH`(&2NiH(aqeYmTc0F9q6jab1YcCjcZAie#E
2H4a[Dr,`f*lEQcb-6Gc4j&R#m@P0(QE0RplNBDlQ'8dHYXimXmPc)FGR0AQB$hP
fNfFjaqFdH5lQq0`Qc`U1cf[bV16ir#B2mlB[D2+`eHK(QMcAF(a$NqGDMRFhHDl
Mq-BQcr8FhpcNBCcQR8dH4TVHeH4K+ZlG64kQDGjc,Bpf20KRpS%m0T[2%[,-*6[
[)iH1(K2'H6)m+2hJiA`b'V#BY*,)2-b1T3#Tm!cIEj`rd6ff1*TN-fBHdQCeqp"
H&8mUY-"pDeDl5lGe4`Ll1j+U[A4fR1A&PjmR[B)GZ+69Zh#h4[q9hK,flAZ`qr`
cCbeYAl5P6f3DQ)Ap$4#f9GAid2lpfXV998j'mlaeZ*XPF9XQrDVFIhU`[IqHqA[
fXa9ZcrjiR'Ukf$lbf@XHp4Q2pYcL,ZKN,h9TSamDE[$!9R[#ThC[ECGlAU3c%`!
$S[#"56-#UN%Yp+DR5FG@MLdX,md[RAb"E*YR+*PAiqU$R!HIUQZA`cRjMQSKpZC
FcE&P*dmJXIYjVZ,iQKZ*d,k0Pj@Yjq`Qj%dL,lPf(qeJ!Ifk'5TlFil'-DDYMjU
-ATemP0M`kZ4)2p9#p)'bZYbe*m2QTbZZ!#dGa#89Yq05R0,@r&ELp(hmEc(j*[Y
qXErDLG[iNfcNPI[jFFkMq19qIYc5(b,fAF1URUE,E3Z1IC!!`fh%d9'j128a$Nh
$UVbF6iN)5Chmqje2RD,I2KbAPq1@XbhH16LX0LrA5Cd9G1Tl8qrFr8li$3kcKP@
@AiVl"+m2L,'jBJpNm51r6m"Tc[GPYI+Z![9%2I6Mq0MDVlqTE#GhZR9FG%ieCNX
rr8'GRC!!lh22i*-0D&2ebSAQ%2F!ZFh@Gq,B1MmTa(eDY@I,Zrj1qK%1V`TaAp#
QE,DkdrHm(Q&PL2YVeC!!,Hlk1dDX8HS8qb5q$BjlaE41kT%E#EJLa%hjNjdkEAd
I[L[GVhGa5)@kI[9hm$h,FH5B(1)qS"S*mBfGQFCGN[`&[VFklVlTr5jj8N6UAYH
$eaDF&H,fkq8+j#(IFcNF'q)Q+HjYMRZjkM%!emVM9[3A1G`jM+p-Eelkfaa@$FX
VICp@2hPiNefpVEk*Hdk+M&[CZ-MbpbZpi&BZ,USkHEL5LlZ%I*&RM#Zj128Z$M0
$hecd+rKj,B(qlL,rm4m*FC[qNMKH4k#rHhJe31)E3YaG(b#1ea$Slb[`VEBXa'h
q2H*irB$qNVq',aRL,[d%2Z(bPl%(10B1F9rMVNSiSlph,01@ac[ZEZ*ic3"eHL-
(ZIHjlm#[kf$LhMI&TpK"m%`CYp6[lZ$",6q"Ah",8C[)ei@ier`FIX'Yp#rM5i5
i$rmM2X%YpFmFcJ[hDck*RpF'd'I84HkaK-hZbQpPQI*RiJjZh&DiS`UVL05h8CI
B`4$h*AT3#@2eX41H%MHH[IqY"-KXcCI83fiIa,lP$r#jZS%k!*l&HL(I9q!FbP1
dDmAPHN2Fep(19GL$UElcDIT9mYh2LbK8i,2U[YZjap33ppD2%m"fIk$X&cKX$R%
I!qH8Y[N$'G6ElErBhVF6arCqqJ!HirCIp,e`*U9Yr8!VM`9aqbpfi1q*%cerL6M
+Kd+q6kUZ-L@pP[j@Gi5i6h`V2Sd$I+Z%cIH%Z&IS6FqAq(lJNFXRSKqiMELe)Hi
+AZ%4GGr[J#XC[UDr"rk8`p`3pbCk5AfhH53Em!9Ap[-5$(AFqIjp"aH[SNH9CkI
kkA829`E!E"8fd+V$rc$P3p&h+FlP0kS$9JNILLiV6[K0p'I90jT(dVFj(M$T9kI
hGTjkPP#0#Ac[iGk#amiF2D$H&Z)q#0m62(Bq,$`'jrAafTqDiV'cK3DQc*0ZJ$F
,(MY[r4Ym`T-q!Ki*(MZEe&6jC3#r#rXA2(CZim8"5[`#[169)A,[&kPIRqHq4!*
bmF"j#QkNi0dQ(q+'fcI1A@#5!N0-[6mka9(R#ILa8VrSle2`'X&MjjZ&Zbpd[Mq
FiV(64M-`r!AHT[(-ZmFc9EmAKlK2Sjm+(MZ[B6f&%Xr5hfIT6m(Mf%IKK1T(3pb
AljMLXA2k&iKlDBKE$Bi,(MYhrMbqPi8q@`Xh%MafjZ#ekXIFhq#XLmI1Bm)KH#)
`S[Q5i,&c$UkXi,r%A8@I#"l(R[d`!Dm-peMhj"52RDGiZ)`5IZT[UA"%qZm&kUG
A1`j99IV[0rq&1-ep6"`LXr6IiNm4Th'!lq2U9aH2R3H%$4Shq$i$hJNH1ir"5C4
i0k9ih452RIFMrDQIGRpSRq"al*mq6GaV3pcRk82"BkIl@m5"Hr!*F02&BqHJq*2
QBSB[D[h'UqYFY!fPqa*(I`SZRJb(9[5JLA[,$Xpi!1e%[6I%E4"1ZAJFqkM`!(d
!(1*e)5iH1cr)h)&k)X4pNGV(hGm2U(kDHp+AdqKrLBZr$8jVH+Mq6[JMiFe!INQ
[qRmK)3GQDA4c9'0X!*!D#BB"NJ%"!Q`#P3#3!`%!N!1'!*!(&J#3!iB!!!%1rj!
%!q#dAbiHY*C6G`#3"3'5%J#3"M%arr(rr!!!`d!!!#)X#5B!!!:
fitsTcl/fitsUtils.c 0000644 0002307 0000036 00000127766 11222720662 013235 0 ustar chai lhea /*
* fitsUtils.c --
*
* This is a collection of utility routines for fitsTcl.
*
*/
/*
*------------------------------------------------------------
*
* MODIFICATION HISTORY:
* 2007-01-24 Pan Chai
* rewrite sort routine - use standard qsort routine
* 2004-02-06 Ziqin Pan
* Add the following routines:
* 1. fitsParseRangeNum
*
*------------------------------------------------------------
*/
#include "fitsTclInt.h"
#include
/* on some systems, e.g. linux, SUNs DBL_MAX is in float.h */
#ifndef DBL_MAX
# include
#endif
#ifndef DBL_MIN
# include
#endif
/*
* ------------------------------------------------------------
*
* dumpFitsErrStack --
*
* Dumps the FITSIO internal error stack onto the interp result
*
* ------------------------------------------------------------
*/
void dumpFitsErrStack( Tcl_Interp *interp, int status )
{
Tcl_DString stack;
char *res;
long len;
res = Tcl_GetStringResult( interp );
len = strlen( res );
if( len>0 && res[len-1]!='\n' )
Tcl_AppendResult( interp, "\n", (char*)NULL );
dumpFitsErrStackToDString( &stack, status );
Tcl_AppendResult( interp, Tcl_DStringValue(&stack), (char*)NULL );
Tcl_DStringFree(&stack);
}
/*
* ------------------------------------------------------------
*
* dumpFitsErrStackToDString --
*
* Dumps the FITSIO internal error stack to a Tcl_DString
*
* ------------------------------------------------------------
*/
void dumpFitsErrStackToDString( Tcl_DString *stack, int status )
{
char buffer[100];
Tcl_DStringInit(stack);
ffgerr(status, buffer);
Tcl_DStringAppend(stack, buffer, -1);
sprintf(buffer, ". (CFITSIO error status was %d)\n", status);
Tcl_DStringAppend(stack, buffer, -1);
/* get error stack messages */
while( ffgmsg(buffer) ) {
strcat(buffer, "\n");
Tcl_DStringAppend(stack, buffer, -1);
}
return;
}
/*
* ------------------------------------------------------------
*
* fitsMakeRegExp --
*
* Takes the argc - argv pair, and a pointer to a DString, and
* gobbles them into a regexp. If caseSen = 0, expression is case
* sensitive, if = 1 UC, if = -1 LC...
*
* Results:
* Fills the DString
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
int fitsMakeRegExp( Tcl_Interp *interp,
int argc,
char *const argv[],
Tcl_DString *regExp,
int caseSen )
{
char **list;
int numElem,i;
char *p,*pattern;
Tcl_DStringInit(regExp);
while ( argc-- ) {
if( Tcl_SplitList(interp,*argv,&numElem,&list) != TCL_OK ) {
Tcl_AppendResult(interp,"Error parsing argument: ",argv,
" as a Tcl list.",(char *) NULL);
ckfree((char *) list);
return TCL_ERROR;
}
for ( i = 0; i < numElem; i++ ) {
Tcl_DStringAppend(regExp,list[i],-1);
Tcl_DStringAppend(regExp,"|",-1);
}
ckfree((char *) list);
argv++;
}
/* Strip off final "|" */
Tcl_DStringTrunc(regExp,Tcl_DStringLength(regExp) - 1);
/* Make the match CASE INSENSITIVE -- All Keywds are UPPER CASE: */
if( caseSen == 1 ) {
pattern = Tcl_DStringValue(regExp);
for (p = pattern; *p ; p++ ) {
if( islower((unsigned char) *p) ) {
*p = toupper(*p);
}
}
} else if ( caseSen == -1 ) {
pattern = Tcl_DStringValue(regExp);
for (p = pattern; *p ; p++ ) {
if( isupper((unsigned char) *p) ) {
*p = tolower(*p);
}
}
}
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsParseRange --
*
* This parses a list, and passes back a 2-d array of the ranges.
* Returns TCL_OK for success.
*
* Results:
* Sets numInt to the number of intervals found.
* Fills range with the ranges...
*
* Side effects:
* None
*
* ------------------------------------------------------------
*/
int fitsParseRangeNum(char *rangeStr) {
char *delim = ",";
int count=0;
char* strtmp=NULL;
strtmp=strdup(rangeStr);
if (strtok(strtmp,delim) !=NULL) {
count++;
while ( strtok(NULL,delim) !=NULL ) {
count++;
}
}
if(strtmp) free(strtmp);
return count;
}
int fitsParseRange( char *rangeStr,
int *numInt,
int *range,
int maxInt,
int minval,
int maxval,
char *errMsg )
{
char *delim = ",";
char *tok,*strptr,*tokstore;
int result,count,tmpVal[2],**tmpArray,i,j;
char *rangeCpy;
if( *rangeStr=='\0' || !strcmp(rangeStr,"-") || !strcmp(rangeStr,"*") ) {
*numInt = 1;
range[0] = minval;
range[1] = maxval;
return TCL_OK;
}
rangeCpy = (char *)ckalloc( (strlen(rangeStr)+1) * sizeof(char) );
strcpy(rangeCpy,rangeStr);
tok = (char *) strtok(rangeCpy,delim);
if ( ! tok ) {
sprintf(errMsg,"No tokens found");
return TCL_ERROR;
}
tmpArray = (int **) ckalloc( (maxInt+1) * sizeof(int *) );
tmpArray[0] = (int *) ckalloc( 2 * (maxInt+1) * sizeof(int) );
for(i = 1; i <= maxInt; i++ ) {
tmpArray[i] = tmpArray[i-1] + 2;
}
/*
* This will be the sentinal...
*/
tmpArray[0][0] = minval - 1;
count = 1;
do {
while ( *tok == ' ') tok++;
if ( *tok == '\0' ) {
sprintf(errMsg,"Null token in range");
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
tokstore = tok;
strptr = (char *) strchr(tok,'-');
/* This translates the first token */
if ( NULL == strptr ) {
result = sscanf( tok, "%d", &(tmpArray[count][0]) );
if ( 1 != result ) {
sprintf(errMsg,"Error converting token %s in element %s",
tok,tokstore);
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
if ( tmpArray[count][0] > maxval ) {
tmpArray[count][0] = maxval;
}
if ( tmpArray[count][0] < minval ) {
tmpArray[count][0] = minval;
}
tmpArray[count][1] = tmpArray[count][0];
(count)++;
continue;
} else if (tok == strptr) {
tmpArray[count][0] = minval;
} else {
result = sscanf(tok,"%d",&(tmpArray[count][0]));
if ( result != 1 ) {
sprintf(errMsg,"Error converting token %s in element %s",
tok,tokstore);
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
}
/* This translates the second token */
while (' ' == *(++strptr) ) ;
if ( '\0' == *strptr ) {
tmpArray[count][1] = maxval;
} else {
result = sscanf(strptr,"%d",&(tmpArray[count][1]));
if ( result != 1 ) {
sprintf(errMsg,"Error converting token %s in element %s",
strptr,tokstore);
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
}
/* Test for the sanity of the range... */
if ( tmpArray[count][0] > tmpArray[count][1] ) {
sprintf(errMsg,"Range out of order in element %s",tokstore);
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
if ( tmpArray[count][0] < minval ) {
tmpArray[count][0] = minval;
}
if ( tmpArray[count][0] > maxval ) {
tmpArray[count][0] = maxval;
}
if ( tmpArray[count][1] < minval ) {
tmpArray[count][1] = minval;
}
if ( tmpArray[count][1] > maxval ) {
tmpArray[count][1] = maxval;
}
(count)++;
} while((tok = (char *) strtok(NULL,delim)) && count <= maxInt) ;
if ( tok != NULL ) {
sprintf(errMsg,"Too many ranges, maximum is %d",maxInt);
ckfree( (char*)rangeCpy );
return TCL_ERROR;
}
if ( count == 2 ) {
*numInt = 1;
range[0] = tmpArray[1][0];
range[1] = tmpArray[1][1];
ckfree( (char*)rangeCpy );
return TCL_OK;
}
/*
* Now sort: an insert sort is fine, there will never be that many,
* and they should be almost in order...
*/
for ( i = 1; i< count; i++ ) {
tmpVal[0] = tmpArray[i][0];
tmpVal[1] = tmpArray[i][1];
j = i;
while(tmpArray[j-1][0] > tmpVal[0]) {
tmpArray[j][0] = tmpArray[j-1][0];
tmpArray[j][1] = tmpArray[j-1][1];
j--;
}
tmpArray[j][0] = tmpVal[0];
tmpArray[j][1] = tmpVal[1];
}
/*
* Now merge the ranges, and shift down to remove the sentinal...
*/
*numInt = 0;
range[0] = tmpArray[1][0];
range[1] = tmpArray[1][1];
for ( i = 2; i < count; i++) {
if ( tmpArray[i][0] <= range[(*numInt)*2+1] ) {
if ( range[(*numInt)*2+1] < tmpArray[i][1] )
range[(*numInt)*2+1] = tmpArray[i][1];
} else {
(*numInt)++;
range[(*numInt)*2] = tmpArray[i][0];
range[(*numInt)*2+1] = tmpArray[i][1];
}
}
/*
* Remember to return number of elements, not index of the last element...
*/
(*numInt)++;
ckfree((char*)tmpArray[0]);
ckfree((char*)tmpArray);
ckfree((char*)rangeCpy);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* makeContigArray --
*
* Allocates a contiguous array of type type {c,i,l,f,d}.
*
* For 'c' type, returns a char ** pointing to 1-D string array of
* nrows strings of length ncols.
*
* For 'i' returns an int ** pointing to the 2-d array, or an int*
* pointing to 1-d array if ncols == 1. The same holds for f & d.
*
* Results:
* Allocates Memory for the array
*
* Side effects:
* None
*
* ------------------------------------------------------------
*/
void *makeContigArray( int nrows, int ncols, char type )
{
int i;
char *ctmpPtr, **ctmpHandle;
int *itmpPtr, **itmpHandle;
long *ltmpPtr, **ltmpHandle;
float *ftmpPtr, **ftmpHandle;
double *dtmpPtr, **dtmpHandle;
if ( type == 'c' ) {
ctmpHandle = (char **) ckalloc(nrows*sizeof(char *));
if (ctmpHandle == NULL ) {
return (void *) NULL;
}
ctmpHandle[0] = (char *) ckalloc(nrows * ncols * sizeof(char));
if (ctmpHandle[0] == NULL ) {
ckfree((char *)ctmpHandle);
return (void *) NULL;
}
ctmpPtr = ctmpHandle[0];
for ( i = 1; iCHDUInfo.table.numCols;i++)
colTotSize += strlen(curFile->CHDUInfo.table.colName[i])+1;
colArray = (char **) ckalloc( (unsigned)curFile->CHDUInfo.table.numCols
* sizeof(char *) + colTotSize );
colArray[0] = (char*)(colArray+curFile->CHDUInfo.table.numCols);
for ( i = 0; i < curFile->CHDUInfo.table.numCols ; i++ ) {
colNums[i] = i;
if( i )
colArray[i] = colArray[i-1] + strlen(colArray[i-1]) + 1;
strToUpper( curFile->CHDUInfo.table.colName[i], &tmpstr);
strcpy( colArray[i], tmpstr );
ckfree((char *) tmpstr);
}
*numCols = curFile->CHDUInfo.table.numCols;
} else {
/* Get the column list, -> UPC, match & translate to column number */
strToUpper( colStr, &pattern );
if( Tcl_SplitList(curFile->interp,pattern,numCols,&colArray) != TCL_OK ) {
Tcl_SetResult(curFile->interp,"Error parsing column list",TCL_STATIC);
ckfree(pattern);
return TCL_ERROR;
}
ckfree(pattern);
if( *numCols >= FITS_COLMAX ) {
Tcl_SetResult(curFile->interp,"Too many columns in list",TCL_STATIC);
ckfree((char*)colArray);
return TCL_ERROR;
}
}
for ( i = 0; i < *numCols; i++ ) {
foundIt = 0;
for ( j = 0; j < curFile->CHDUInfo.table.numCols; j++) {
if( !strcasecmp(colArray[i], curFile->CHDUInfo.table.colName[j]) ) {
colNums[i] = j+1;
colTypes[i] = curFile->CHDUInfo.table.colDataType[j];
strSize[i] = curFile->CHDUInfo.table.strSize[j];
foundIt = 1;
break;
}
}
if ( ! foundIt ) {
if( i==0 ) {
/* See if original colStr matches anything */
for ( j = 0; j < curFile->CHDUInfo.table.numCols; j++) {
if( !strcasecmp(colStr, curFile->CHDUInfo.table.colName[j]) ) {
colNums[0] = j+1;
colTypes[0] = curFile->CHDUInfo.table.colDataType[j];
strSize[0] = curFile->CHDUInfo.table.strSize[j];
foundIt = 1;
break;
}
}
if( foundIt ) {
*numCols = 1;
break;
}
}
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,
"Column name was not found: ",colArray[i],
(char*)NULL);
ckfree((char*)colArray);
return TCL_ERROR;
}
}
ckfree((char*)colArray);
return TCL_OK;
}
int strToUpper( char *inStr, char **outStr )
{
char *ptr;
*outStr = (char *) ckalloc ( strlen(inStr) +1 );
strcpy( *outStr, inStr);
for ( ptr=*outStr; *ptr; ptr++ ) {
if ( islower((unsigned char) *ptr) ) {
*ptr = toupper(*ptr);
}
}
return TCL_OK;
}
int tdispGetFormat( FitsFD *curFile,
int colnum )
{
int w;
char *tokenPtr;
char *TDispKey;
char tmp[80];
char rtFormat[80];
int isDisp;
int i, idx;
/* make a copy of the display format */
if ( strcmp(curFile->CHDUInfo.table.colDisp[colnum]," ") != 0 ) {
strcpy(tmp, curFile->CHDUInfo.table.colDisp[colnum]);
isDisp = 1; /* TDISP exists, use for format */
} else {
strcpy(tmp, curFile->CHDUInfo.table.colType[colnum]);
if( curFile->hduType == ASCII_TBL )
{
isDisp = 1; /* Treat TFORM as TDISP for ASCII Tables */
}
else
{
isDisp = 0; /* TDISP does not exist, use default format */
}
}
/* take out the 's and spaces */
if((TDispKey = strtok(tmp,"' "))==NULL) TDispKey = curFile->CHDUInfo.table.colType[colnum];
if ( strpbrk(TDispKey, "Aa") ) {
/* ASCII column , consider wA and Aw type */
tokenPtr = strtok(TDispKey, "PApa");
sprintf(rtFormat,"%%s");
if( tokenPtr )
curFile->CHDUInfo.table.colWidth[colnum] = atoi(tokenPtr);
else
curFile->CHDUInfo.table.colWidth[colnum] = 8;
if (curFile->CHDUInfo.table.colWidth[colnum] == 1) {
curFile->CHDUInfo.table.colWidth[colnum] = 8;
}
} else if ( strpbrk(TDispKey, "Ll") ) {
/* Logic type */
sprintf(rtFormat,"%%s");
if ( !isDisp || atoi(TDispKey) != 0 ) {
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
tokenPtr = strtok(TDispKey, "PLpl");
if ( tokenPtr == NULL ) {
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
curFile->CHDUInfo.table.colWidth[colnum] = atoi(tokenPtr);
}
}
} else if ( strpbrk(TDispKey, "Bb") ) {
/* Byte */
if ( (strcmp(curFile->CHDUInfo.table.colDisp[colnum], " ") ==0 ) &&
( (curFile->CHDUInfo.table.colTzflag[colnum]==1) ||
(curFile->CHDUInfo.table.colTsflag[colnum]==1)) ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
sprintf(rtFormat,"%%.8G");
} else {
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%u");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
tokenPtr = strtok(TDispKey, "PBpb");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%u");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
w = atoi(tokenPtr);
sprintf(rtFormat,"%%%su", tokenPtr);
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Kk") ) {
/* Short Integer */
if ( (strcmp(curFile->CHDUInfo.table.colDisp[colnum], " ") ==0 ) &&
( (curFile->CHDUInfo.table.colTzflag[colnum]==1) ||
(curFile->CHDUInfo.table.colTsflag[colnum]==1)) ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
sprintf(rtFormat,"%%.8G");
} else {
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%d");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
tokenPtr = strtok(TDispKey, "PKpk");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%d");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
w = atoi (tokenPtr);
sprintf(rtFormat,"%%%sd", tokenPtr);
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Ii") ) {
/* Integer type */
if ( (strcmp(curFile->CHDUInfo.table.colDisp[colnum], " ") ==0 ) &&
( (curFile->CHDUInfo.table.colTzflag[colnum]==1) ||
(curFile->CHDUInfo.table.colTsflag[colnum]==1)) ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
sprintf(rtFormat,"%%.8G");
} else {
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%d");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
tokenPtr = strtok(TDispKey, "PIpi");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%d");
curFile->CHDUInfo.table.colWidth[colnum] = 6;
} else {
w = atoi (tokenPtr);
sprintf(rtFormat,"%%%sd", tokenPtr);
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Jj") ) {
/* Long Integer */
if ( (strcmp(curFile->CHDUInfo.table.colDisp[colnum], " ") ==0 ) &&
( (curFile->CHDUInfo.table.colTzflag[colnum]==1) ||
(curFile->CHDUInfo.table.colTsflag[colnum]==1)) ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
sprintf(rtFormat,"%%.8G");
} else {
sprintf(rtFormat,"%%ld");
curFile->CHDUInfo.table.colWidth[colnum] = 11;
}
} else if ( strpbrk(TDispKey, "E") ) {
/* Real */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%#.6E");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
tokenPtr = strtok(TDispKey, "PENSpens");
if (tokenPtr == NULL ) {
sprintf(rtFormat,"%%#.6E");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
sprintf(rtFormat,"%%%sE", tokenPtr);
w = atoi(tokenPtr);
if ( w == 0 ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Ff") ) {
/* 4-byte real */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%#.6f");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
tokenPtr = strtok(TDispKey, "PFpf");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%#.6f");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
w = atoi(tokenPtr);
sprintf(rtFormat,"%%%sf", tokenPtr);
if ( w == 0 ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Dd") ) {
/* 8-byte Real */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%.12E");
curFile->CHDUInfo.table.colWidth[colnum] = 19;
} else {
tokenPtr = strtok(TDispKey, "PDEpde");
if (tokenPtr == NULL ) {
sprintf(rtFormat, "%%.12E");
curFile->CHDUInfo.table.colWidth[colnum] = 19;
} else {
sprintf(rtFormat,"%%%sf", tokenPtr);
w = atoi(tokenPtr);
if ( w == 0 ) {
curFile->CHDUInfo.table.colWidth[colnum] = 19;
} else {
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Gg") ) {
/* Real */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%.6G");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
tokenPtr = strtok(TDispKey, "PGEpge");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%.6G");
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
sprintf(rtFormat,"%%%sG", tokenPtr);
w = atoi(tokenPtr);
if ( w == 0 ) {
curFile->CHDUInfo.table.colWidth[colnum] = 13;
} else {
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
}
} else if ( strpbrk(TDispKey, "Cc") ) {
/* 4-byte Complex */
sprintf(rtFormat,"%%#.6G");
curFile->CHDUInfo.table.colWidth[colnum] = 30;
} else if ( strpbrk(TDispKey, "Mm") ) {
/* 8-byte Complex */
sprintf(rtFormat,"%%#.12G");
curFile->CHDUInfo.table.colWidth[colnum] = 36;
} else if ( strpbrk(TDispKey, "Oo") ) {
/* Octal? */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%#o");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
tokenPtr = strtok(TDispKey, "POpo");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%#o");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
w = atoi(tokenPtr);
sprintf(rtFormat,"%%%so", tokenPtr);
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
} else if ( strpbrk(TDispKey, "Zz") ) {
/* ? */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%#x");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
tokenPtr = strtok(TDispKey, "PZpz");
if ( tokenPtr == NULL ) {
sprintf(rtFormat,"%%#x");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
w = atoi(tokenPtr);
sprintf(rtFormat,"%%%sx", tokenPtr);
curFile->CHDUInfo.table.colWidth[colnum] = w;
}
}
} else if ( strpbrk(TDispKey, "Xx") ) {
/* ? */
if ( !isDisp || atoi(TDispKey) != 0 ) {
sprintf(rtFormat,"%%#u");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
tokenPtr = strtok(TDispKey, "PXpx");
if (tokenPtr == NULL ) {
sprintf(rtFormat,"%%#u");
curFile->CHDUInfo.table.colWidth[colnum] = 8;
} else {
sprintf(rtFormat,"%%#u");
curFile->CHDUInfo.table.colWidth[colnum] = atoi(tokenPtr);
}
}
} else {
/* ERROR */
if (strlen(TDispKey) == 0) {
return TCL_OK;
}
for (i=0; i= '0' && TDispKey[i] <= '9') ||
(TDispKey[i] >= 'A' && TDispKey[i] <= 'Z') ||
(TDispKey[i] >= 'a' && TDispKey[i] <= 'z'))
{
/* check No.1 the TDIM keyword is a string */
continue;
} else {
/* illegal TDISP keyword, ignored */
return TCL_OK;
}
}
/* check No.2 the TDISP keyword starts with A, L, I, B, O, Z, E, EN, ES, G or D */
if ((TDispKey[0] == 'A') ||
(TDispKey[0] == 'L') ||
(TDispKey[0] == 'I') ||
(TDispKey[0] == 'B') ||
(TDispKey[0] == 'O') ||
(TDispKey[0] == 'Z') ||
(TDispKey[0] == 'F') ||
(TDispKey[0] == 'E') ||
(TDispKey[0] == 'G') ||
(TDispKey[0] == 'D'))
{
/* check No.3 follow by a decimal digit */
idx = 1;
if ((TDispKey[0] == 'E' && TDispKey[1] == 'N') ||
(TDispKey[0] == 'E' && TDispKey[1] == 'S'))
{
idx = 2;
}
if (TDispKey[idx] >= '0' && TDispKey[idx] <= '9')
{
/* legal TDISP keyword */
strcpy(curFile->CHDUInfo.table.colFormat[colnum], rtFormat);
return TCL_OK;
}
}
/* illegal TDISP keyword, ignored */
return TCL_OK;
}
strcpy(curFile->CHDUInfo.table.colFormat[colnum], rtFormat);
return TCL_OK;
}
void fitsSwap(colData *p, colData *q)
{
colData temp;
temp = *p;
*p = *q;
*q = temp;
}
void fitsQSsetFlag(colData a[], int dataType, int strSize, int left, int right)
{
/* dataType: 0: TSTRING */
/* 1: TSHORT, TINT, TBYTE, TLONG, TBIT, TLOGICAL */
/* 2: TFLOAT, TDOUBLE */
/* 3: TLONGLONG */
LONGLONG checkLongLong;
long checkInt;
double checkDbl;
char *checkStr;
int i;
checkStr = (char *) ckalloc (strSize *sizeof(char ) + 1);
for (i=left; i<=right; i++) {
switch (dataType) {
case 0 :
if (i == left) {
strcpy(checkStr, a[i].strData);
a[i].flag = 0;
} else {
if (strcmp(checkStr, a[i].strData) == 0) {
a[i].flag = 1;
} else {
strcpy(checkStr, a[i].strData);
a[i].flag = 0;
}
}
break;
case 1 :
if (i == left) {
checkInt = a[i].intData;
} else {
if (checkInt == a[i].intData) {
a[i].flag = 1;
} else {
checkInt = a[i].intData;
a[i].flag = 0;
}
}
break;
case 2 :
if (i == left) {
checkDbl = a[i].dblData;
} else {
if (checkDbl == a[i].dblData) {
a[i].flag = 1;
} else {
checkDbl = a[i].dblData;
a[i].flag = 0;
}
}
break;
case 3 :
if (i == left) {
checkLongLong = a[i].longlongData;
} else {
if (checkLongLong == a[i].longlongData) {
a[i].flag = 1;
} else {
checkLongLong = a[i].longlongData;
a[i].flag = 0;
}
}
break;
default :
break;
}
}
ckfree((char *)checkStr);
}
void fitsQuickSort(colData a[], int dataType, int strSize,
int left, int right, int isAscend)
{
int pivot;
pivot = fitsSplit(a, dataType, strSize, left, right, isAscend, &left, &right);
if (left < pivot)
fitsQuickSort(a, dataType, strSize, left, pivot - 1, isAscend);
if (right > pivot)
fitsQuickSort(a, dataType, strSize, pivot + 1, right, isAscend);
}
/*
* Split array in the following fashion:
* the left subarray has all the values less than the divider
* the right subarray has all the values greater than the divider
*/
int fitsSplit(colData a[], int dataType, int strSize,
int left, int right, int isAscend,int *r_left, int *r_right)
{
colData tmpData;
int nullset = 0;
int l_hold = left;
int r_hold = right;
if ( isAscend == 1) {
/* push all the smaller values to the left */
switch (dataType) {
case 0:
/* 0: TSTRING */
tmpData = a[left];
while ( left < right ) {
while ((strcmp(a[right].strData,tmpData.strData) >= 0) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((strcmp(a[left].strData,tmpData.strData) <= 0) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 1:
/* 1: TSHORT, TINT, TBYTE, TLONG, TBIT, TLOGICAL */
tmpData = a[left];
while ( left < right ) {
while ((a[right].intData >= tmpData.intData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].intData <= tmpData.intData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 2:
/* 2: TFLOAT, TDOUBLE */
tmpData = a[left];
while ( left < right ) {
while ((a[right].dblData >= tmpData.dblData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].dblData <= tmpData.dblData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 3:
/* 3: TLONGLONG */
tmpData = a[left];
while ( left < right ) {
while ((a[right].longlongData >= tmpData.longlongData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].longlongData <= tmpData.longlongData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
}
} else {
/* push all the smaller values to the RIGHT */
switch (dataType) {
case 0:
/* 0: TSTRING */
tmpData = a[left];
while ( left < right ) {
while ((strcmp(a[right].strData,tmpData.strData) >= 0) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((strcmp(a[left].strData,tmpData.strData) <= 0) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 1:
/* 1: TSHORT, TINT, TBYTE, TLONG, TBIT, TLOGICAL */
tmpData = a[left];
while ( left < right ) {
while ((a[right].intData <= tmpData.intData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].intData >= tmpData.intData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 2:
/* 2: TFLOAT, TDOUBLE */
tmpData = a[left];
while ( left < right ) {
while ((a[right].dblData <= tmpData.dblData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].dblData >= tmpData.dblData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
case 3:
/* 3: TLONGLONG */
tmpData = a[left];
while ( left < right ) {
while ((a[right].longlongData <= tmpData.longlongData) && (left < right))
right--;
if (left != right) {
a[left] = a[right];
left++;
}
while ((a[left].longlongData >= tmpData.longlongData) && (left < right))
left++;
if (left != right) {
a[right] = a[left];
right--;
}
}
a[left] = tmpData;
break;
}
}
*r_left = l_hold;
*r_right = r_hold;
return(left);
}
void fitsFreeRawColData( colData columndata[], long numRows )
{
long i;
for(i=0; i= '0' && *inputStr <= '9')
#ifdef __WIN32__
ig = ig * 10I64 + *inputStr++ - '0';
#else
ig = ig * 10LL + *inputStr++ - '0';
#endif
else
inputStr++;
return (ig * (LONGLONG)sign);
}
fitsTcl/ReleaseNotes 0000644 0002307 0000036 00000017034 11222720662 013401 0 ustar chai lhea July, 2009: Release of fitsTcl v2.3 (part of fv5.3)
* Fix large FITS file crashing and displaying summary/header issue.
* Fix opening FITS files in read-only mode issue.
=====================================================================
September, 2007: Release of fitsTcl v2.2 (part of fv5.0)
* Allow Long Long type (64 bits integer) in Windows.
* Allow the switching of different set of WCS (WCSn, where n is a, b, c..) information.
* Add routines to extract WCS header information.
=====================================================================
July, 2006: Release of fitsTcl v2.1.5 (part of fv4.4)
* Fix incorrect calculation of Table array size of a FITS file.
=====================================================================
March, 2006: Release of fitsTcl v.2.1.4 (part of fv4.3)
* Add region statistical calculation
=====================================================================
April 5th, 2005: Release of fitsTcl v.2.1.3 (part of fv4.2)
* Change calling routine parameters to cfitsio
* Fix TSTRING column length calculation (previous set to 80)
=====================================================================
August 9, 2004: Release of fitsTcl v.2.1.2 (part of fv4.1.4)
* Fix CAR projection
=====================================================================
April 19, 2004: Release of fitsTcl v.2.1.1 (part of fv4.1.2)
* Seperate cfitsio package from fitsTcl package.
=====================================================================
November 9, 2000: Release of fitsTcl v2.1 (part of fv3.0)
* Added smooth command. Currently only supports a boxcar filter.
* Added range command. Currently only has a "count" option which
takes a range string (eg, 1-4,7,9-) and counts how many rows are
included.
* Added -rows parameter to "load expr". This allows calculations to
be performed on a subset of rows.
* Replace fitsTcl's histogramming code with call to CFITSIO's
better implementation. Add new command 'histogram' which replaces
the 'create 1dhisto' and 'create 2dhisto' and deprecate the latter.
New command supports up to 4D histograms and inverse weighting.
* Convert fitsObjn entry point to use Tcl_Objs instead of strings.
Was able to get full precision data, but lost it when putting it.
About half of file commands converted, rest have all parameters
converted to strings in fitsDispatch.
* Dropped/Ignore numElem parameter to 'put image'. Can get number
of elements from data list.
* When "put"ting data to a complex column, single numbers will be
interpretted as real only... imaginary part is zero
* Added an optional rowList parameter to "get vtable"
* Added -noformat option to "load tblock", "get table", and "get vtable"
so that one can obtain raw values, not formatted strings.
* Modified "get image" and "load iblock" routines so that they use
native Tcl_Obj's instead of DString's for return values... allows
full precision instead of truncated formats in real values->string
conversion.
* Revised wcs code to support CD matrix keywords and be more general.
"-m" flag to 'get wcs' command will return WCS information as...
{refVals} {refPix} {matrix} {types} {projections}
Old-style keywords will be converted to this. New-style will be
converted to old-style in absence of "-m". New-style not limited
to 2D images or only 2 columns... can be 1 thru N-dimensions.
========================================================================
February 7, 2000: Release of fitsTcl v2.002 (part of fv2.6 and FTOOLS 5.0)
* Modified histogram code so that it writes the column names into
the CTYPEn keywords if the columns did not have TCTYPn keywords.
* Add optional wcsSwap to return list of 'get wcs' command to flag
whether the RA and Dec WCS keywords are swapped with regard to X
and Y. Use 'fits option wcsSwap 1|0' to toggle this parameter on
or off. (Default: off... old behavior)
* Add new 'fits option' command which allows one to alter fitsTcl's
default behaviors.
* Cast all argv's to "char *const[]" to protect them from accidental
modification.
* Modify 'load image' to conform to vtable/column's default NULL
handling... NULLS are converted to datatype_MAX. Formerly converted
to -1.
* Modify 'load vtable' to accept a default Null parameter. This breaks
backwards compatibility (it used to take a vector column width at
the same position, but ignored in v2.0).
* Modify 'get wcs' defaults to match CFITSIO's new implementation of
them: 1.0 for xinc/yinc and 0.0 for all others. Keep ctype='none',
although CFITSIO uses a null string.
========================================================================
July 28, 1999: Release of fitsTcl v2.0
* Major rewrite of internal code, while keeping as backwards
compatible as possible with last fv release. Update
documentation and create this Release Notes document.
* Change method of passing address pointers... Instead of using %ld
to read and write addresses to/from strings, use the much more
appropriate %p format. NOTE: This is *NOT* compatible with %ld
formats. You must change any code dependent on fitsTcl in this
regard! (Or change all '%p' strings in fitsTcl back to '%ld'.)
* Drop 'get imageblock' which was actually identical to 'load iblock'.
'get' commands should return lists of data, which 'get imageblock'
did not. (Still exists for backwards compatibility, but removed from
docs.)
* Add new 'get image' command which returns list of data from an image
array.
* Rename 'put ihd/ahd/bhd' to 'insert image/table' which makes
more sense. New version drops the numCols parameter and allows some
parameters to be empty. (Again, old commands still exist but
undocumented.)
* Make many more trailing parameters optional
* Convert some series of parameters to lists (eg,
'get keyword keyName ...' becomes 'get keyword keyList')
* Add/improve support for long keywords using new HIERARCH notation.
* Eliminate (ignore if present) the object type parameter from the
'free' command and accept a list of addresses to free.
* Add general 'fits free addList' command to replace the
fitsObj-dependent free command.
* Add 'fits version' command to get fitsTcl and cfitsio version numbers.
* Replace 'get imgwcs' and 'get colwcs' with a single 'get wcs'
command which behaves appropriately based on the CHDU type.
Error-handling behavior (ie, use of default values) is consistent,
unlike the separate versions. (Old commands exist, but undocumntd.)
* Add 2 new commands for creating/reading 'load'ed data: lst2ptr and
ptr2lst. The former takes a TCL list and creates a pointer able to
be passed to C code (eg, POW). The latter reverses the conversion,
taking a pointer and producing a TCL list.
* Add new vector math command: vexpr. It takes a C-style arithmetic
expression and evaluates it in the context of TCL lists (or fitsTcl
pointers). Returns results as either a TCL list or fitsTcl pointer.
========================================================================
Apr 30, 1999: Release of fv v2.5 (unnumbered fitsTcl included)
========================================================================
NovDec, 1998: Release of FTOOLS v4.2 and fv v2.4 (unnumbered fitsTcl included)
========================================================================
??? ??, 1997: Release of fitsTcl v1.0
fitsTcl/fitsTcl.html 0000644 0002307 0000036 00000103134 11222720662 013360 0 ustar chai lhea
fitsTcl 2.1.1 User's Guide
fitsTcl 2.1.1 User's Guide
FITS (Flexible Image Transport System) file format is widely used in the
astronomical community. But its complexity makes it very difficult for
general users to interact with data in FITS format.
Current FORTRAN and C interfaces to FITS -- FITSIO/CFITSIO, developed by
the HEASARC (High Energy Astrophysics Science Archive Research Center) at
the NASA Goddard Space Flight Center -- provide very powerful and robust
functions to interact with FITS files. However, utilizing FITSIO/CFITSIO
requires some basic FORTRAN/C programming skills, and this low level
library often is more powerful, and hence more complex, than the general
user needs.
To provide general users with a simple interface to read/write FITS
file, we developed fitsTcl, an extension to the simple but powerful
script language TCL/TK,
which uses the CFITSIO library. fitsTcl was developed for the
fv project and is distributed as part of fv, which can
be obtained by visiting the fv
website. fitsTcl can also be downloaded separately from the fitsTcl
web page. fitsTcl runs under Unix, Windows, and Mac OS.
fitsTcl is compiled as a dynamic library which can be loaded as a TCL
extension. To load fitsTcl, type the following command in a Tcl shell
(running on UNIX)
% load libfitstcl.so
(Under Mac OS and Windows, the library is instead named
fitstcl.dll.) If the library is not found you may need to
set the environment variable LD_LIBRARY_PATH (Unix only) to the
directory containing libfitstcl.so or include an explicit path to the
file.
In fitsTcl, every FITS file is treated as a FitsFile object. The
following sections describe how to create FitsFile objects and all
the methods in a FitsFile object.
Handling FitsFile objects
- fits open fileName mode ?objName?
- Create a FitsFile object, open the file and read the
header of the current HDU. (Read the CFITSIO web pages
or documentation to learn about its "Extended File Name Syntax".)
mode can be 0 (read only) or 1 (read and write). If no
objName is given, a name will be automatically assigned. A
new empty FITS file can be created by setting mode to 2. In
this case, if the named file exists, then it will be
overwritten. Returns objName which will be used in most of
the methods as the handle to the object.
- fits info ?objName ...?
- Return a list of all the existing objects, or the named objects
(supports regular expressions), with the following information:
{objName fileName mode CHDU hduType}
where CHDU is the current HDU (1-primary array, 2-the first extension
...) and hduType is the type of the HDU (0-image, 1-ASCII table,
2-Binary table).
- objName move ?+/-?n
- If n has ``+/-'' sign, then move n units relative to the
CHDU, otherwise move to the nth HDU. Return the extension type of
the new HDU: 0-image, 1-ASCII table, 2-Binary Table.
- objName close
- Delete object objName.
- fits close
- Delete all the existing objects.
Getting information about the CHDU
- objName info chdu
- Return the CHDU. 1=primary, 2=first extension, etc.
- objName info filesize
- Return the size of the file (in units of 2880 bytes).
- objName info hdutype
- Return ``Primary array'', ``Image extension'', ``Binary Table'',
or ``ASCII Table''.
- objName info imgType
- Return the type of the image if the CHDU is an image extension.
- objName info imgdim
- Return the dimensions of the image if the CHDU is an image extension.
- objName info ncols
- Return the number of columns in the table if the CHDU is a table
extension.
- objName info nrows
- Return the number of rows in the table if the CHDU is a table extension.
- objName info nkwds
- Return the number of keywords in the header of the CHDU.
- objName info column ?-exact? ?colList?
- Without any arguments, return a list of all the column names
in the table if the CHDU is a table extension. If colList
is present, detailed information about the listed columns, using
regular expression name comparisons, is returned in the form of:
{Name Type Unit DisplayFormat DefaultFormat ColumnWidth isOffset
isScaled defaultNull}
where
|
Name |
name of the column (TTYPE keyword) |
Type |
type of the column (TFORM keyword) |
Unit |
unit of the column (TUNIT keyword) |
DisplayFormat |
format for display (TDISP keyword) |
DefaultFormat |
default format for display (if TDISP keyword is absent) |
ColumnWidth |
the width of the column (in units of characters). |
isOffset |
0 = no offset (no TZERO keyword), 1 = offset. |
isScaled |
0 = not scaled (no TSCALE keyword), 1 = scaled. |
defaultNull |
default NULL value (TNULL keyword) |
The -exact option turns off the regular expression matching.
Reading data from a FITS file
- objName dump ?-s/-e/-l?
- Return all the keyword records in the current header. The
following options control how the information is formatted:
|
none |
return list of all cards in header |
-s |
return three lists: {keywords} {values}
{comments} |
-e |
return a single string containing a newline-separated list
of all header records |
-l |
return all the keyword names |
- objName get keyword ?keyList?
- Return a list of {keyword value comment} for all the
keywords in keyList (supports regular expressions). If no
keyList is given, return a list of entries for all the keywords
in the CHDU. The order in which keywords are listed is
undefined. (HISTORY and COMMENT keywords are never returned.)
- objName get keyword -num n
- Return a list of {keyword value comment} of the nth
keyword.
- objName get wcs ?RAcol DecCol?
- Return a list of the WCS parameters -- {xrval yrval xrpix yrpix xinc
yinc rot ctype} -- for the CHDU. If the current HDU is a table,
supply the RAcol and DecCol parameters specifying the two
columns (as names or column numbers) containing WCS data. Use defaults for
any missing WCS keywords: 1.0 for xinc/yinc; ``none'' for
ctype; and 0.0 or all others. If the RA/Dec identity of the
columns (or image axes) are not known, an extra WCS parameter --
wcsSwap --
can be obtained which, when on, indicates that the X parameters are
for Dec instead of RA. Turn this option on with
fits option wcsSwap 1.
- objName get wcs -m ?Col1 ...?
- Similar to above, but information is returned in new-style format,
allowing arbitrary matrix transforms. Return value is
{refVals refPix matrix types projections}
where each item (except matrix) contains a list of the given information
for each image dimension or table column; matrix is the rotation,
scale, skew, NxN transformation matrix given as {cd11 .. cd1N
cd21 .. cd2N .. cdNN}. The wcsSwap option has no effect
on this command; one must check the types values to see if the RA
and Dec transforms are backwards.
- objName get image ?firstElem? ?numElem?
- Read data elements from the current IMAGE extension and return
them in a list. Without any parameters, the entire image will be returned.
If only firstElem is given, return just one element.
- objName get table ?-c? ?-noformat?
?colList? ?rows?
- Read a block of a table and return list(s) of data. The block range is
set in
|
colList |
a list of all the columns one wants to read. Read all
columns if missing or is ``*''. |
rows |
a comma-separated list of row ranges of the form
start-end (eg, ``3-5,7,9-'') |
-c |
return data from each column as a separate list |
-noformat |
do not format results according to a TDISPn, or default,
format |
- objName get vtable ?-noformat? colName n
?rows?
- Return a list of data in the nth vector element in column
colName of the given rows. The -noformat option
turns off any TDISPn formatting.
Loading data into memory or to a TCL array
When loading data into memory, fitsTcl will normally return
address dataType numElements where these are:
|
address |
Memory address of the data. Can be recovered in C by
sscanf(address, "%p", &databuff);
with void *databuff |
dataType |
|
|
|
0 - BYTE_DATA | 1 byte data |
1 - SHORTINT_DATA | 2 byte integer |
2 - INT_DATA | 4 byte integer |
3 - FLOAT_DATA | 4 byte floating point |
4 - DOUBLE_DATA | 8 byte floating point |
|
numElement |
Number of data elements in the array |
- objName load image ?slice? ?rotate?
- Load a full 2D image in the CHDU into memory and return the address
address (see above). slice indicates which frame to use
if image is 3D. rotate indicates how many 90-degree
counter-clockwise rotations to perform on the image (0-3).
- objName load iblock arrayName firstRow numRows
firstCol numCols ?slice?
- Load a block (start from firstCol, firstRow with size
numCols x numRows) of image data to a 2-D TCL array
arrayName or to memory if arrayName is ``--''. The
indices of the array variable are (firstCol-1 ...
firstCol+numCols-1, firstRow-1 ... firstRow+numRows-1).
A 1D image will be treated as either a single row or column, depending
on the row/column parameters supplied. For a 3D image, slice
indicates which frame to use.
If arrayName is ``--'', read the data block into memory and
return the pointer information: address dataType numElements.
- objName load irows firstRow lastRow ?slice?
- objName load icols firstCol lastCol ?slice?
- Read and average together a range of rows or columns of an image.
Returns address dataType numElements. dataType will be
3 for all image data types except for double for which dataType
is 4.
- objName load column colName ?defaultNull?
?firstElement?
- Load a column of a table into memory and return address dataType
numElements. Use the value of defaultNull for NULL values, or
internal defaults (normally the data type's maximum value) if ``NULL''
or absent. If colName is a vector column, read the
firstElement-th element. One can only load numerical columns.
- objName load arrayRow colName rowNumber numberElement
?defaultNull? ?firstElement?
- Load a row of a table into memory and return address dataType
numElements. Use the value of defaultNull for NULL values, or
internal defaults (normally the data type's maximum value) if ``NULL''
or absent. If colName is a vector column, read the
firstElement-th element. rowNumber is the row number intended.
numberElement is the number of elements in a row to extract (use the
length of a row as the default value). One can only load numerical columns.
- objName load vtable colName
- Load all elements of the vector column colName and return
address dataType numElements.
- objName load tblock ?-noformat? arrayName colList
firstRow numRows colIndex ?firstElem?
- Load a block of table data to a 2-D TCL array arrayName.
colIndex is (almost) the column index of the array to use for
the first column read. The first data index is actually (as for images)
(colIndex-1,firstRow-1). For
scaler columns, firstElem = 1. Without the -noformat flag,
values will be returned as strings formatted according to a TDISP keyword
or default format based on data type.
- objName load expr ?-rows rows?
expression ?defaultNull?
- Evaluate the arithmetic expression on each row (or a
subset of rows given by rows) of the CHDU's table and
return address dataType numElements, using
defaultNull as the null value of any NULL results.
- objName load keyword
- Load keywords into fitsTcl's internal hash table. One usually will
not need to call this routine.
- objName load chdu
- Reload the information about the current HDU. One usually will not
need to call this routine.
Writing to a FITS file
- objName insert image bitpix naxis naxesList
- objName insert image -p ?bitpix naxis naxesList?
- Insert an empty image HDU (primary header with -p) after the
current HDU (or, at start of file for primary array). The image parameters
-- bitpix naxis naxesList -- can be left off if
creating a zero-length primary array.
- objName insert table numRows {colNames}
{colFormats} ?{colUnits} extensionName?
- objName insert table -ascii numRows {colNames}
{colFormats} ?{colUnits} {colPosition} extensionName rowWidth?
- Insert an empty BINARY (default) or ASCII (with -ascii
flag) table HDU after the current HDU. The colNames and
colFormats lists must be of equal length (possibly both
empty). The optional parameters can each be empty if one wants to
use default/empty values.
- objName insert keyword index record ?formatFlag?
- Insert a new record at the index-th keyword. If
formatFlag is 0, write the record exactly as passed, otherwise
parse it as a free form keyname value comment and reformat it into a
standardized KEYNAME = VALUE / COMMENT (default).
- objName put keyword ?-num index? record
?formatFlag?
- Write a keyword record either at position index; the position
of a pre-existing keyword with the same name; or append it if no such
keyword exists. See above for format/meaning of record and
formatFlag.
- objName put history historyStr
- Write a HISTORY keyword with content historyStr
- objName insert column index colName colFormat
- Insert an empty column with format colFormat before the
index-th column. colFormat specifies the column format
as, for example:
ASCII Table: A15, I10, E12.5, D20.10, F14.6 ...
BINARY Table: 15A, 1I, 1J, 1E, 1D, 1L, 1X, 1B, 1C, 1M
- objName add column colName colFormat ?expression?
- Without an expression, append an empty column to the
CHDU table; return nothing. Given an arithmetic
expression, though, the indicated column (new or old) will
be filled in with the results of the expression evaluated for each
row of the table. If colName does not exist in the current
table extension, a new one will be created with format
colFormat (see above). If colFormat is ``default'',
the column will be created based on the data type of the result.
Return 1 or 0 to indicate whether a new column was created (1) or
not (0). expression can be in either C or Fortran format
with table columns and keywords referenced by their names. Here
are some expression samples:
|
Expression |
Result |
|
17.2 |
17.2 for every row |
17 + 4*(PHI > 32) |
17 or 21, depending on
whether that row of the PHI column is greater than
32 |
sqrt( (X-X0)^2 + (Y-Y0)^2 ) |
Distance of the (X,Y) column coordinates from the (X0,Y0)
keyword values |
See the CFITSIO
web pages and documentation for more details.
- objName insert row index numRows
- Insert number of numRows rows after the index-th row.
- objName add row numRows
- Add numRows rows at the end of the CHDU table.
- objName put image firstElem listOfData
- Write a block of data to the CHDU image. The first pixel of an
image has firstElem = 1, not zero.
- objName put table colName firstElem
rowSpan listOfData
- Write a list of data to the firstElem-th element of column
colName in the CHDU table. (For scalar columns firstElem
is 1.)
rowSpan is a single row range of form start-end with ``-''
indicating all rows.
Deleting data from a FITS file
- objName delete keyword keyList
- Delete listed keywords, where the keyList can be the mix of
keyword names and index numbers. Keywords are deleted individually
in sequence, causing keyword positions to change after each deletion,
so be careful when deleting multiple keywords by index.
- objName delete cols colList
- Delete listed columns in a table extension.
- objName delete rows firstRow numRows
- Delete a block of rows.
- objName delete rows -expr expression
- Delete rows using expression which must evaluate to a boolean
value. Rows for which expression evaluates to TRUE get deleted.
- objName delete chdu
- Delete the current HDU. The HDU immediately following the one deleted
(or the preceeding one if the current HDU is the last one of the file) will
become the new current HDU. Returns extension type of new HDU:
0-image, 1-ASCII table, 2-Binary Table.
Analyzing FITS data
- objName sort ?-merge? colList ?ascendFlags?
- Sort table rows using columns in colList. When -merge
is present, if multiple rows have identical sort keys all but one of the
rows will be deleted. If present, ascendFlags contains a list of
1s and 0s indicating whether that column will be sorted in ascending
(1, the default) or descending (0) order.
- objName column -stat colName ?firstElem? ?rows?
- Return statistics on the firstElem-th
element (1 for scalar columns) of column colName in the order
min firstMinRow max firstMaxRow mean stdDev numData.
- objName column -minmax colName ?firstElem?
?rows?
- Returns minimum and maximum values of the firstElem-th
element (1 for scalar columns) of column colName.
- objName histogram ?-weight colName|value?
?-inverse? ?-rows rows?
filename {binAxis1} ?{binAxis2} ...?
- Create a 1D - 4D histogram from columns in the current table.
The binning parameters are given by the binAxisN parameters which
are lists of the form colName min max binSize where the last 3
elements can each be ``-'', indicating default values. If TLMINn,
TLMAXn, and/or TDBINn exist, those values will be used for
defaults. Otherwise, for min and max the defaults
are the actual min/max values of the data; for binSize the
smaller of one-tenth the data span or 1.0 will be selected. A weighting
value can be indicated with the -weight option. This can be
either another column or a numerical constant. The -inverse
option indicates the weight should be 1.0/weight instead of the weighting
value itself. The histogram can be restricted to certain row ranges using
the -rows option.
- objName smooth {width height} outfile ?inPrimary?
- Smooth the current image extension with a boxcar function of
dimensions width by height pixels. The dimensions
must be odd integers. The resulting image will be placed in
a new extension appended to the file outfile. If
outfile does not exist, the image will be placed either
in the primary or in the first extension, depending on the
value of the inPrimary flag; the default is to place it in
an extension.
List/Pointer Manipulation
- lst2ptr dataList ?dataType? ?naxesList?
- Convert a TCL list into a memory-resident array. Returns
address dataType naxesList (see the load
commands above). The TCL list will be cast as double values
in the absence of the dataType paramter. The parameter
naxesList gives the vector dimensions of the list. It
can be a single number indicating the length of the list (the
default value when absent) or a list of numbers which must
multiply together to be the list length. If a list entry
contains the string "NULL", the maximum value of the given
dataType will be inserted.
- ptr2lst address dataType naxesList
- Convert a memory pointer into a TCL list. Returns dataList
dataType naxesList (see lst2ptr). If an array element
contains the maximum value for the given dataType, the
string "NULL" will be inserted into the list.
- vexpr ?-ptr? ?-use getDataCallback? expression
- Perform a vector calculation using lists or arrays where
expression is a C-style arithmetic expression.
(Ie, do not use $var notation unless you explicitly want
variable substitution before passing expression to
vexpr.) Without any of the options, variable
references within expression will be interpretted as
local TCL lists (or scalars) containing double data and the
result will itself be a simple TCL list. With the -ptr option
set, the answer instead will be returned as a pointer to a
memory-resident array. With either option set, two additional
parameters will be returned in a list of the form dataList
dataType naxesList or address dataType naxesList.
The -use option provides a "callback" routine which is
to be used for supplying the variable data. It gets called
when a variable is encountered in the expression and
will be passed a single argument containing the name of the
variable. The callback routine should return either
"dataList dataType naxesList" or "-ptr address
dataType naxesList". If the callback routine doesn't
recognize the variable, it should return an empty string. The
parser will then try to find the variable in the local
namespace, as when no callback is supplied. If this fallback behavior
is not desired, raise an error instead. The callback function
can itself check for local variables using the TCL command
upvar 1 $varName localName. The following code
snippet provides a sample callback function which assumes the
expression contains variables storing the results of a load
or lst2ptr command (ie, address dataType naxesList):
proc getPtrData { varName } {
upvar $varName myName
if [info exists myName] {
return [eval list -ptr $myName]
} else {
error "Variable doesn't exist"
}
}
then the following code would calculate the average value of a table
column:
set myCol [objName load column X]
vexpr -use getPtrData "sum( (double)myCol ) / nelem( myCol )"
By default, a vector with a single-valued naxesList is
interpretted as a single vector containing n elements such
that the above "sum" function sums all of the elements. In the
context of loading a column, though, one actually has an
array of n rows with each row containing 1 (or perhaps more)
elements. To handle this case, one must use the callback
function to provide an naxisList of "1 n" (or "2 m",
etc) instead of merely "n". In that case each row will be
calculated separately and have its own result. When
naxesList has multiple elements, the final element
specifies the number of rows.
See the CFITSIO web
pages and documentation for details on expression
syntax. One can also read the fv online help file on expression
syntax, noting that vexpr can only handle numerical
input and output.
- fits free addressList
- Free the memory occupied by the data generated by one of the
load, lst2ptr, and vexpr commands.
Other commands
- objName copy filename
- Copy the CHDU to a new FITS file. If the CHDU is not an image array,
then an empty primary array is inserted.
- objName sascii table filename fileMode firstRow
numRows colList widthList
- Write the listed columns into an ASCII file. In the output file, each
column has the width listed in widthList. fileMode indicates
how to write the data to filename: 0-create new file and write
column headings; 1-append to old file and write column headings;
2-append to old file, but don't write any headings.
- objName sascii image filename fileMode firstRow
numRows firstCol numCols cellSize ?slice?
- Write a block of the image data to an ASCII file. In the output file,
the data has width of cellSize. Use frame slice for 3D
image data.
- objName flush ?clear?
- Flush any dirty buffers to the disk. With clear, free the
buffers, too.
- objName append filename
- Append current HDU to another FITS file.
- objName checksum update|verify
- Update or Verify the checksum keywords in the current HDU. If
none exist, update will create them. For verify,
the return values are 1 for valid values, 0 if either keyword
(CHECKSUM or DATASUM) is missing, and -1 for invalid values.
- objName info expr expression
- Get information on the result of the supplied arithmetic
expression. Return value is cDataType numElements
{naxesList} where cDataType is the CFITSIO datatype (not
fitsTcl's): TDOUBLE, TSTRING, etc; numElements is the number
of elements
in the result; and naxesList contains the vector dimensions
of the result ({1} for scalar result). An expression which
evaluates to a constant (no dependency on the contents of the
table) will be indicated by a negative number of elements.
- range count rangeStr maxElem
- Count the number of elements (esp. rows) contained within the
comma-separated list of ranges in rangeStr (eg, 1-4,5,7-).
To support ranges of the form "7-" which specifies a range from
element 7 through the final element, maxElem is passed with
the maximum element number.
- fits option ?option? ?value?
- Modify fitsTcl's default behavior. With no options, this returns
a list of all the current fitsTcl options and their values. With
the option parameter, return the value of that parameter. When
both option and value are supplied, set the parameter
to the given value. Current options: wcsSwap (0).
- fits version
- Get version numbers for fitsTcl and underlying cfitsio.
Lawrence
Brown and Peter
Wilson
Last modified: Thu Jul 22 09:42:41 EDT 1999
fitsTcl/fitsTcl.h 0000644 0002307 0000036 00000004402 11222720662 012641 0 ustar chai lhea /*
* fitsTcl.h --
*
* This header file describes the externally visible
* calls in the Tcl wrapping for Fitsio.
*
*/
#ifndef FITSTCL
#define FITSTCL
#define FITSTCL_VERSION "2.3"
#define FITSTCL_MAJOR_VERSION 2
#define FITSTCL_MINOR_VERSION 3
#define FITSTCL_SERIAL 0
#include
/* Sun4s do not support %p, so switch to %lx */
#ifdef HEX_PTRFORMAT
#define PTRFORMAT "%lx"
#else
#define PTRFORMAT "%p"
#endif
EXTERN int Fits_Init (Tcl_Interp *interp);
EXTERN int Fits_MainCommand (ClientData clientData,
Tcl_Interp *interp, int argc,
Tcl_Obj *const argv[]);
EXTERN int fitsDispatch (ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
EXTERN int fitsLst2Ptr (ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
EXTERN int fitsPtr2Lst (ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
EXTERN int fitsExpr (ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
EXTERN int fitsRange(ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
EXTERN int getMaxCmd (ClientData clientData,
Tcl_Interp *interp, int argc, char *const argv[]);
EXTERN int getMinCmd (ClientData clientData,
Tcl_Interp *interp, int argc, char *const argv[]);
EXTERN int isFitsCmd (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int updateFirst (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int dataBlockToVar (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int setArray (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int searchArray (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int Table_calAbsXPos (ClientData clientData,
Tcl_Interp *interp,
int argc,
char *const argv[]);
EXTERN int Table_updateCell ( ClientData clientData,
Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] );
#endif
fitsTcl/tclShared.c 0000644 0002307 0000036 00000000531 11222720662 013134 0 ustar chai lhea
#include
#ifdef macintosh
#pragma export on
#endif
#ifdef __WIN32__
int _export Fitstcl_Init (Tcl_Interp *interp);
#else
int Fitstcl_Init (Tcl_Interp *interp);
#endif
#ifdef macintosh
#pragma export reset
#endif
int Fitstcl_Init (interp)
Tcl_Interp *interp; /* Interpreter for application. */
{
return Fits_Init(interp);
}
fitsTcl/makefile.bc5 0000644 0002307 0000036 00000027377 11222720662 013250 0 ustar chai lhea #
# Borland C++ IDE generated makefile
# Generated 10/15/98 at 10:52:55 AM
#
.AUTODEPEND
#
# Borland C++ tools
#
IMPLIB = Implib
BCC32 = Bcc32 +BccW32.cfg
BCC32I = Bcc32i +BccW32.cfg
TLINK32 = TLink32
TLIB = TLib
BRC32 = Brc32
TASM32 = Tasm32
#
# IDE macros
#
#
# Options
#
IDE_LinkFLAGS32 = -LD:\BC5\LIB
LinkerLocalOptsAtC32_fitstcldlib = -Tpd -ap -c /w-inq
ResLocalOptsAtC32_fitstcldlib =
BLocalOptsAtC32_fitstcldlib =
CompInheritOptsAt_fitstcldlib = -ID:\BC5\INCLUDE;C:\FV_SRC\TCL8.0.4\GENERIC;C:\FV_SRC\FITSTCL\CFITSIO -D_RTLDLL;_BIDSDLL; -w-sig -w-stu -w-par -w-use -w-aus
LinkerInheritOptsAt_fitstcldlib = -x
LinkerOptsAt_fitstcldlib = $(LinkerLocalOptsAtC32_fitstcldlib)
ResOptsAt_fitstcldlib = $(ResLocalOptsAtC32_fitstcldlib)
BOptsAt_fitstcldlib = $(BLocalOptsAtC32_fitstcldlib)
CompLocalOptsAtC32_cfitsiodlib = -w-sig -w-stu -w-par -w-use -w-aus
LinkerLocalOptsAtC32_cfitsiodlib = -Tpd -aa -V4.0 -c
ResLocalOptsAtC32_cfitsiodlib =
BLocalOptsAtC32_cfitsiodlib = /P32
CompOptsAt_cfitsiodlib = $(CompOptsAt_fitstcldlib) $(CompLocalOptsAtC32_cfitsiodlib)
CompInheritOptsAt_cfitsiodlib = -ID:\BC5\INCLUDE;C:\FV_SRC\TCL8.0.4\GENERIC;C:\FV_SRC\FITSTCL\CFITSIO -D_RTLDLL;_RTLDLL;_BIDSDLL;
LinkerInheritOptsAt_cfitsiodlib = -x
LinkerOptsAt_cfitsiodlib = $(LinkerOptsAt_fitstcldlib) $(LinkerLocalOptsAtC32_cfitsiodlib)
ResOptsAt_cfitsiodlib = $(ResOptsAt_fitstcldlib) $(ResLocalOptsAtC32_cfitsiodlib)
BOptsAt_cfitsiodlib = $(BOptsAt_fitstcldlib) $(BLocalOptsAtC32_cfitsiodlib)
#
# Dependency List
#
Dep_fitstcl = \
fitstcl.lib
fitstcl : BccW32.cfg $(Dep_fitstcl)
echo MakeNode
fitstcl.lib : fitstcl.dll
$(IMPLIB) $@ fitstcl.dll
Dep_fitstclddll = \
cfitsio.lib\
..\tcl8.0.4\win\tcl80.lib\
tclshared.obj\
fitsinit.obj\
fitsutils.obj\
fitstcl.obj\
fitscmds.obj\
fitsio.obj\
fvtcl.obj
fitstcl.dll : $(Dep_fitstclddll) fitstcl.def
$(TLINK32) @&&|
/v $(IDE_LinkFLAGS32) $(LinkerOptsAt_fitstcldlib) $(LinkerInheritOptsAt_fitstcldlib) +
D:\BC5\LIB\c0d32.obj+
tclshared.obj+
fitsinit.obj+
fitsutils.obj+
fitstcl.obj+
fitscmds.obj+
fitsio.obj+
fvtcl.obj
$<,$*
cfitsio.lib+
..\tcl8.0.4\win\tcl80.lib+
D:\BC5\LIB\bidsfi.lib+
D:\BC5\LIB\import32.lib+
D:\BC5\LIB\cw32i.lib, fitstcl.def
|
Dep_cfitsiodlib = \
putcols.obj\
putcolui.obj\
putcoluj.obj\
putcoluk.obj\
putcolu.obj\
putkey.obj\
region.obj\
swapproc.obj\
scalnull.obj\
wcsutil.obj\
putcolk.obj\
putcolj.obj\
putcoli.obj\
putcole.obj\
putcold.obj\
putcolb.obj\
putcol.obj\
modkey.obj\
listhead.obj\
putcoll.obj\
getcolj.obj\
iraffits.obj\
histo.obj\
group.obj\
grparser.obj\
getkey.obj\
getcoluk.obj\
getcoluj.obj\
getcolui.obj\
getcols.obj\
getcoll.obj\
getcolk.obj\
eval_f.obj\
getcole.obj\
getcold.obj\
getcolb.obj\
getcol.obj\
fitscore.obj\
eval_y.obj\
eval_l.obj\
getcoli.obj\
buffers.obj\
editcol.obj\
drvrmem.obj\
drvrfile.obj\
compress.obj\
checksum.obj\
cfileio.obj\
edithdu.obj
cfitsio.lib : $(Dep_cfitsiodlib)
$(TLIB) $< $(IDE_BFLAGS) $(BOptsAt_cfitsiodlib) @&&|
-+putcols.obj &
-+putcolui.obj &
-+putcoluj.obj &
-+putcoluk.obj &
-+putcolu.obj &
-+putkey.obj &
-+region.obj &
-+swapproc.obj &
-+scalnull.obj &
-+wcsutil.obj &
-+putcolk.obj &
-+putcolj.obj &
-+putcoli.obj &
-+putcole.obj &
-+putcold.obj &
-+putcolb.obj &
-+putcol.obj &
-+modkey.obj &
-+listhead.obj &
-+putcoll.obj &
-+getcolj.obj &
-+iraffits.obj &
-+histo.obj &
-+group.obj &
-+grparser.obj &
-+getkey.obj &
-+getcoluk.obj &
-+getcoluj.obj &
-+getcolui.obj &
-+getcols.obj &
-+getcoll.obj &
-+getcolk.obj &
-+eval_f.obj &
-+getcole.obj &
-+getcold.obj &
-+getcolb.obj &
-+getcol.obj &
-+fitscore.obj &
-+eval_y.obj &
-+eval_l.obj &
-+getcoli.obj &
-+buffers.obj &
-+editcol.obj &
-+drvrmem.obj &
-+drvrfile.obj &
-+compress.obj &
-+checksum.obj &
-+cfileio.obj &
-+edithdu.obj
|
putcols.obj : cfitsio\putcols.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcols.c
|
putcolui.obj : cfitsio\putcolui.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolui.c
|
putcoluj.obj : cfitsio\putcoluj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoluj.c
|
putcoluk.obj : cfitsio\putcoluk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoluk.c
|
putcolu.obj : cfitsio\putcolu.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolu.c
|
putkey.obj : cfitsio\putkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putkey.c
|
region.obj : cfitsio\region.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\region.c
|
swapproc.obj : cfitsio\swapproc.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\swapproc.c
|
scalnull.obj : cfitsio\scalnull.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\scalnull.c
|
wcsutil.obj : cfitsio\wcsutil.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\wcsutil.c
|
putcolk.obj : cfitsio\putcolk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolk.c
|
putcolj.obj : cfitsio\putcolj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolj.c
|
putcoli.obj : cfitsio\putcoli.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoli.c
|
putcole.obj : cfitsio\putcole.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcole.c
|
putcold.obj : cfitsio\putcold.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcold.c
|
putcolb.obj : cfitsio\putcolb.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolb.c
|
putcol.obj : cfitsio\putcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcol.c
|
modkey.obj : cfitsio\modkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\modkey.c
|
listhead.obj : cfitsio\listhead.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\listhead.c
|
putcoll.obj : cfitsio\putcoll.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoll.c
|
getcolj.obj : cfitsio\getcolj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolj.c
|
iraffits.obj : cfitsio\iraffits.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\iraffits.c
|
histo.obj : cfitsio\histo.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\histo.c
|
group.obj : cfitsio\group.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\group.c
|
grparser.obj : cfitsio\grparser.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\grparser.c
|
getkey.obj : cfitsio\getkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getkey.c
|
getcoluk.obj : cfitsio\getcoluk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoluk.c
|
getcoluj.obj : cfitsio\getcoluj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoluj.c
|
getcolui.obj : cfitsio\getcolui.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolui.c
|
getcols.obj : cfitsio\getcols.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcols.c
|
getcoll.obj : cfitsio\getcoll.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoll.c
|
getcolk.obj : cfitsio\getcolk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolk.c
|
eval_f.obj : cfitsio\eval_f.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_f.c
|
getcole.obj : cfitsio\getcole.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcole.c
|
getcold.obj : cfitsio\getcold.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcold.c
|
getcolb.obj : cfitsio\getcolb.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolb.c
|
getcol.obj : cfitsio\getcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcol.c
|
fitscore.obj : cfitsio\fitscore.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\fitscore.c
|
eval_y.obj : cfitsio\eval_y.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_y.c
|
eval_l.obj : cfitsio\eval_l.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_l.c
|
getcoli.obj : cfitsio\getcoli.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoli.c
|
buffers.obj : cfitsio\buffers.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\buffers.c
|
editcol.obj : cfitsio\editcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\editcol.c
|
drvrmem.obj : cfitsio\drvrmem.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\drvrmem.c
|
drvrfile.obj : cfitsio\drvrfile.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\drvrfile.c
|
compress.obj : cfitsio\compress.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\compress.c
|
checksum.obj : cfitsio\checksum.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\checksum.c
|
cfileio.obj : cfitsio\cfileio.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\cfileio.c
|
edithdu.obj : cfitsio\edithdu.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\edithdu.c
|
tclshared.obj : tclshared.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ tclshared.c
|
fitscmds.obj : fitscmds.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitscmds.c
|
fitsio.obj : fitsio.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsio.c
|
fvtcl.obj : fvtcl.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fvtcl.c
|
fitsutils.obj : fitsutils.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsutils.c
|
fitstcl.obj : fitstcl.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitstcl.c
|
fitsinit.obj : fitsinit.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsinit.c
|
vcclib: fitstcl.def
lib/def:fitstcl.def
fitstcl.def:
..\tcl8.0.4\win\DUMPEXTS -o fitstcl.def fitstcl.dll @&&|
$(Dep_fitstclddll)
|
# Compiler configuration file
BccW32.cfg :
Copy &&|
-w
-R
-v
-vi
-H
-H=fitstcl.csm
-g255
-WCD
| $@
fitsTcl/fitsTcl.c 0000644 0002307 0000036 00000105611 11222720662 012640 0 ustar chai lhea /*
* fitsTcl.c --
*
* This is the main file for defining the Fits objects in fitsTcl...
* > fits open, close, info
*
*/
#include "fitsTclInt.h"
#include
/* on some systems, e.g. linux, SUNs DBL_MAX is in float.h */
#ifndef DBL_MAX
# include
#endif
#ifndef DBL_MIN
# include
#endif
#define LONGLONGDATA 257
/*
* ------------------------------------------------------------
*
* Fits_MainCommand --
*
* This dispatches all the fits ... commands
*
* Results:
* Depends on command line arguments
*
* Side Effects:
* Ditto
*
* ------------------------------------------------------------
*
*/
int Fits_MainCommand( ClientData clientData,
Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] )
{
static char *infoString =
"\n"
"open - opens a Fits file\n"
"close - closes ALL open Fits files\n"
"info - reports on open Fits files: {Handle Filename RWmode CHDU Hdutype}\n"
"option - manipulate behavior of fitsTcl\n"
"version - reports the fitsTcl and cfitsio version numbers\n"
"free - free one or more pointers allocated (via load) by fitsTcl\n"
;
int i;
char *cmdStr;
if ( argc == 1 ) {
Tcl_SetResult(interp,infoString,TCL_STATIC);
return TCL_OK;
}
cmdStr = Tcl_GetStringFromObj( argv[1], NULL );
if( !strcmp(cmdStr,"info") ) {
/*
* ******************* INFO *******************
*/
return FitsInfo(interp,argc,argv);
} else if( !strcmp(cmdStr,"open") ) {
/*
* ******************* OPEN ********************
*/
return FitsCreateObject(interp,argc,argv);
} else if( !strcmp(cmdStr,"close") ) {
/*
* ******************* CLOSE ********************
*/
for ( i = 0; i < FITS_MAX_OPEN_FILES ; i++ ) {
if( FitsOpenFiles[i].fptr ) {
if( TCL_OK !=
Tcl_DeleteCommand(interp,FitsOpenFiles[i].handleName) ) {
return TCL_ERROR;
}
FitsOpenFiles[i].fptr = NULL;
FitsOpenFiles[i].handleName = NULL;
}
}
} else if( !strcmp(cmdStr,"option") ) {
/*
* ******************* OPTION *****************
*/
int val;
char *optStr;
Tcl_Obj *opt[2],*res;
if( argc > 4 ) {
Tcl_SetResult(interp, "option ?opt? ?value?", TCL_STATIC);
return TCL_ERROR;
}
if( argc == 2 ) {
/* Return a list of all current options and values */
res = Tcl_NewListObj(0,NULL);
/* Repeat these 3 lines for each new option added */
opt[0] = Tcl_NewStringObj("wcsSwap", -1);
opt[1] = Tcl_NewBooleanObj( userOptions.wcsSwap );
Tcl_ListObjAppendElement(interp, res, Tcl_NewListObj(2,opt));
Tcl_SetObjResult(interp, res);
} else if( argc==3 ) {
/* Return single option value */
optStr = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp(optStr,"wcsSwap") ) {
res = Tcl_NewBooleanObj( userOptions.wcsSwap );
} else {
Tcl_SetResult(interp,"Unknown fits option",TCL_STATIC);
return TCL_ERROR;
}
Tcl_SetObjResult(interp, res);
} else {
/* Set an option */
optStr = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp(optStr,"wcsSwap") ) {
Tcl_GetBooleanFromObj(interp, argv[3], &userOptions.wcsSwap);
} else {
Tcl_SetResult(interp,"Unknown fits option",TCL_STATIC);
return TCL_ERROR;
}
}
} else if( !strcmp(cmdStr,"version") ) {
/*
* ******************* VERSION *****************
*/
float cfitsioVersion;
char buffer[32];
ffvers(&cfitsioVersion);
sprintf(buffer,"%s %5.3f", FITSTCL_VERSION, cfitsioVersion);
Tcl_SetResult(interp, buffer, TCL_VOLATILE);
} else if( !strcmp(cmdStr,"free") ) {
/*
* ******************* FREE *****************
*/
Tcl_Obj **addList;
void *databuff;
int nAdd;
if( argc == 2 ) {
Tcl_SetResult(interp, "free addressList", TCL_STATIC);
return TCL_OK;
}
if( argc>3 ) {
Tcl_SetResult(interp, "Too many arguments to free", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_ListObjGetElements(interp, argv[2], &nAdd, &addList)
!= TCL_OK ) {
Tcl_SetResult(interp, "Cannot parse the address list", TCL_STATIC);
return TCL_ERROR;
}
while( nAdd-- ) {
databuff = fitsTcl_ReadPtrStr( addList[nAdd] );
if( !databuff ) {
Tcl_SetResult(interp,
"Error interpretting pointer address", TCL_STATIC);
return TCL_ERROR;
}
ckfree( (char *) databuff);
}
} else {
Tcl_SetResult(interp, "Unknown argument to fits command", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* FitsCreateObject --
*
* This opens a new Fits file, and creates the associated command
*
* Results:
* A Fits file argv[2] is opened with rwmode argv[3]. If argv[4]
* is provided, then an associated object is created named argv[4]
* otherwise the object is called fitsFile#, where # is incremented.
*
* Side effects:
* Creates a new command, allocates the FPTR, opens the file
*
* ------------------------------------------------------------
*/
int FitsCreateObject( Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] )
{
FitsFD *newFile;
int status,rwmode,i;
int isConflict;
char *objName,tmpStr[16],varHandle[255], *filename;
fitsfile *fptr;
static char *argList = "fits open filename ?rwmode? ?objName? ";
static int objCounter=0;
/* Deal with wrong # of arguments */
if( argc==2 ) {
Tcl_SetResult(interp, argList, TCL_STATIC);
return TCL_OK;
} else if( argc > 5 ) {
Tcl_AppendResult(interp,"Wrong number of Arguments: expected ",
argList, (char *) NULL);
return TCL_ERROR;
}
filename = Tcl_GetStringFromObj( argv[2], NULL );
/* Convert the rwmode, or set to default */
if ( 3 == argc ) {
rwmode = READWRITE; /* 1 */
} else if ( 4 <= argc ) {
if( Tcl_GetIntFromObj(interp,argv[3],&rwmode) != TCL_OK ) {
Tcl_AppendResult(interp,"\nWrong type for rwmode",(char *) NULL);
return TCL_ERROR;
}
}
/*
* Generate an automatic name if one was not given.
* Check for conflicts...
*/
do {
if( argc == 5 ) {
objName = Tcl_GetStringFromObj(argv[4],NULL);
} else {
sprintf(tmpStr,"fitsObj%d",objCounter++);
objName = tmpStr;
}
isConflict = 0;
for( i = 0; i < FITS_MAX_OPEN_FILES; i++ ) {
if( FitsOpenFiles[i].handleName &&
!strcmp(FitsOpenFiles[i].handleName,objName) ) {
isConflict = 1;
break;
}
}
if( isConflict && argc==5 ) {
Tcl_AppendResult(interp, "Error: Fits Handle: ",
Tcl_GetStringFromObj(argv[4],NULL),
" already used.", (char*)NULL);
return TCL_ERROR;
}
} while( isConflict );
/* Get a file pointer, and try to FFOPEN the file: */
status = 0;
if( rwmode==2 ) {
/* if file exists, remove it */
remove( filename );
/* Get a file pointer for an empty fits file */
ffinit(&fptr, filename, &status);
if ( status ) {
dumpFitsErrStack(interp, status);
return TCL_ERROR;
}
} else {
/* Get a file pointer, if the fits file exists */
ffopen(&fptr, filename, rwmode, &status);
if ( status ) {
dumpFitsErrStack(interp, status);
return TCL_ERROR;
}
}
/* If we succeeded, then write the new FitsFD structure */
i = 0;
while( i= FITS_MAX_OPEN_FILES ) {
Tcl_SetResult(interp, "Too many open files. Max is ", TCL_STATIC);
sprintf(tmpStr,"%d", FITS_MAX_OPEN_FILES);
Tcl_AppendResult(interp, tmpStr, (char*)NULL);
ffclos(fptr,&status);
return TCL_ERROR;
}
newFile = &FitsOpenFiles[i] ;
newFile->fileNum = i;
newFile->fileName = (char *) ckalloc(strlen(filename)+1);
if( NULL == newFile->fileName ) {
Tcl_SetResult(interp,"Error malloc'ing space for fileName",TCL_STATIC);
return TCL_ERROR;
}
strcpy(newFile->fileName, filename);
newFile->handleName = (char *) ckalloc( strlen(objName) + 1 );
if ( NULL == newFile->handleName ) {
Tcl_SetResult(interp,
"Error Malloc'ing space for Handle Name", TCL_STATIC);
ckfree( (char*)newFile->fileName );
return TCL_ERROR;
}
strcpy(newFile->handleName,objName);
newFile->interp = interp;
newFile->fptr = fptr;
newFile->rwmode = rwmode;
newFile->chdu = 1;
newFile->hduType = NOHDU;
newFile->CHDUInfo.table.loadStatus = 0;
/*
* Initialize the hash table for the keywords
*/
Tcl_InitHashTable(newFile->kwds,TCL_STRING_KEYS);
/*
* Load the current extension by moving relative 0 HDUs
*/
if( rwmode != 2 ) {
if( fitsMoveHDU(newFile,0,1) != TCL_OK ) {
fitsCloseFile((ClientData) newFile);
return TCL_ERROR;
}
}
/* Now create the new Tcl command for this object */
Tcl_CreateObjCommand( interp,
newFile->handleName,
(Tcl_ObjCmdProc*)fitsDispatch,
(ClientData) newFile,
fitsCloseFile );
Tcl_SetResult(interp, newFile->handleName, TCL_STATIC);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsCloseFile --
*
* This is the delete procedure for a Fits file object.
*
* Results:
* It closes the file, unallocates the FPTR, and frees the FitsFD struc
*
* Side Effects:
* The whole file is removed from Tcl.
*
* ------------------------------------------------------------
*
*/
void fitsCloseFile(ClientData clientData)
{
int status;
FitsFD *curFile = (FitsFD *) clientData;
char result[256];
/* Pan Chai, we already free this.. no need to do it again */
if (curFile->fptr == NULL && curFile->handleName == NULL) return;
status = 0;
/* Flush the altered keywords */
fitsFlushKeywords(curFile);
/* now close the File */
ffclos(curFile->fptr,&status);
if ( status ) {
sprintf(result, "Error closing Fits file %s\n", curFile->fileName);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
}
ckfree((char *) curFile->fileName);
ckfree((char *) curFile->handleName);
curFile->fptr = NULL;
curFile->handleName = NULL;
deleteFitsCardList(curFile->comHead);
deleteFitsCardList(curFile->hisHead);
freeCHDUInfo(curFile);
}
/*
* ------------------------------------------------------------
*
* FitsInfo --
*
* This gives info on the open FITS files - the command fits info...
*
* Results:
* For each file - HANDLE FILENAME RWMODE CHDU HDUTYPE
*
* Side Effects:
* Ditto
*
* ------------------------------------------------------------
*
*/
int FitsInfo( Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] )
{
int i, gotit = 0;
int argc2;
char **argv2;
char strBuff[16];
Tcl_DString resultStr,regExpStr;
Tcl_DStringInit(®ExpStr);
if( argc != 2 ) {
argc2 = argc-2;
argv2 = (char **) ckalloc( argc2 * sizeof( char *) );
for( i=0; i 4 ) {
Tcl_SetResult(interp, "lst2ptr dataList ?dataType? ?naxes?",
TCL_STATIC);
return TCL_ERROR;
}
if( argc>2 )
Tcl_GetIntFromObj( interp, argv[2], &dataType );
else
dataType = DOUBLE_DATA;
dataPtr = fitsTcl_Lst2Ptr( interp, argv[1], dataType, &ntodo, NULL );
if( argc>3 ) {
fitsTcl_GetDims( interp, argv[3], &nelem, &naxis, naxes );
if( ntodo != nelem ) {
Tcl_SetResult(interp, "List dimensions not same size as list",
TCL_STATIC);
ckfree( (char *)dataPtr );
return TCL_ERROR;
}
} else {
nelem = ntodo;
naxis = 1;
naxes[0] = ntodo;
}
sprintf(ptrStr, PTRFORMAT, dataPtr);
resElem[0] = Tcl_NewStringObj( ptrStr, -1 );
resElem[1] = Tcl_NewIntObj( dataType );
fitsTcl_SetDims( interp, resElem+2, naxis, naxes );
res = Tcl_NewListObj( 3, resElem );
Tcl_SetObjResult(interp, res);
return TCL_OK;
}
/***********************************************************************
* Implement some utility routines
***********************************************************************/
int fitsRange( ClientData clientData,
Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] )
{
char *rangeStr, errMsg[256], *opt;
int numInt, *range, maxInt, i;
long numElem;
if( argc==2 ) {
Tcl_SetResult( interp, "Usage: range count ranges maxValue",
TCL_STATIC );
return TCL_OK;
}
opt = Tcl_GetStringFromObj( argv[1], NULL );
if( !strcmp( "count", opt ) ) {
if( argc!=4 ) {
Tcl_SetResult( interp, "Usage: range count ranges maxValue",
TCL_STATIC );
return TCL_ERROR;
}
rangeStr = Tcl_GetStringFromObj( argv[2], NULL );
if( Tcl_GetIntFromObj( interp, argv[3], &maxInt )
!= TCL_OK ) {
Tcl_AppendResult( interp,
"Unable to read maxValue parameter",
(char *)NULL );
return TCL_ERROR;
}
numInt = fitsParseRangeNum(rangeStr)+1;
range = (int *) malloc (numInt*2*sizeof(int));
if( fitsParseRange( rangeStr, &numInt, range, numInt,
1, maxInt, errMsg )
!= TCL_OK ) {
Tcl_SetResult(interp, "Error parsing range:\n", TCL_STATIC);
Tcl_AppendResult(interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
numElem = 0;
for( i=0; i argc ) {
Tcl_SetResult(interp,"usage: vexpr ?-ptr? ?-use dataFctn? expression",
TCL_STATIC);
return TCL_ERROR;
}
/*******************************/
/* Read-in the expression */
/*******************************/
Tcl_DStringInit ( &expr );
Tcl_DStringAppend( &expr, strArg, -1 );
while( argPosoperation==CONST_OP ) {
constant = 1;
ntodo = 1;
dims = Tcl_NewIntObj( 1 );
} else {
constant = 0;
ntodo = result->value.nelem * vexprInfo.nrows;
fitsTcl_SetDims( interp, &dims,
result->value.naxis, result->value.naxes );
if( vexprInfo.nrows>1 )
Tcl_ListObjAppendElement( interp, dims,
Tcl_NewIntObj( vexprInfo.nrows ) );
}
/* Identify the fitsTcl DataType of result */
switch( result->type ) {
case LONGLONGDATA:
dataType = LONGLONG_DATA;
break;
case DOUBLE:
dataType = DOUBLE_DATA;
break;
case LONG:
dataType = INT_DATA;
if( !constant && sizeof(int) != sizeof(long) ) {
/* Demote long array to int */
long *lPtr;
lPtr = (long *)result->value.data.ptr;
ptr.Int = (int *)result->value.data.ptr;
for( i=0; ivalue.data.str, -1) );
break;
case DOUBLE_DATA:
Tcl_ListObjAppendElement( interp, answer,
Tcl_NewDoubleObj( result->value.data.dbl ) );
break;
case INT_DATA:
Tcl_ListObjAppendElement( interp, answer,
Tcl_NewIntObj( (int)result->value.data.lng ) );
break;
case BYTE_DATA:
Tcl_ListObjAppendElement( interp, answer,
Tcl_NewIntObj( (int)result->value.data.log ) );
break;
}
} else {
answer = fitsTcl_Ptr2Lst( interp, result->value.data.ptr,
result->value.undef, dataType, ntodo );
}
} else {
undef = result->value.undef;
ptr.Dbl = result->value.data.dblptr;
switch( dataType ) {
case LONGLONG_DATA:
ptr2.Llong = (LONGLONG *) ckalloc( ntodo * sizeof(LONGLONG) );
if( constant )
ptr2.Llong[0] = fitsTcl_atoll(result->value.data.str);
else
for( i=0; ivalue.data.dbl;
else
for( i=0; ivalue.data.lng;
else
for( i=0; ivalue.data.log;
else
for( i=0; ioperation>0 ) {
free( result->value.data.ptr );
}
fitsExprCleanup();
if( vexprInfo.callback || !returnList ) {
res = Tcl_NewListObj( 0, NULL );
Tcl_ListObjAppendElement( interp, res, answer );
Tcl_ListObjAppendElement( interp, res, type );
Tcl_ListObjAppendElement( interp, res, dims );
} else {
res = answer;
}
Tcl_SetObjResult(interp,res);
return TCL_OK;
}
static void fitsExprCleanup( void )
{
int i;
for( i=0; istr, "%I64d", ptrs.llong[0]);
#else
sprintf(thelval->str, "%lld", ptrs.llong[0]);
#endif
type = LONGLONGDATA;
break;
case DOUBLE_DATA:
thelval->dbl = ptrs.dbl[0];
type = DOUBLE;
break;
case FLOAT_DATA:
thelval->dbl = ptrs.flt[0];
type = DOUBLE;
break;
case INT_DATA:
thelval->lng = ptrs.iptr[0];
type = LONG;
break;
case SHORTINT_DATA:
thelval->lng = ptrs.shrt[0];
type = LONG;
break;
case BYTE_DATA:
thelval->lng = ptrs.byte[0];
type = LONG;
break;
}
if( !isPtr )
ckfree( (char *)ptrs.ptr );
ckfree( (char *)undef );
} else {
/* Received a VECTOR */
if( vexprInfo.nrows==0 ) {
vexprInfo.nrows = nrows;
} else if( nrows != vexprInfo.nrows ) {
Tcl_SetResult( interp, "Vectors of incompatible lengths", TCL_STATIC);
gParse.status = PARSE_SYNTAX_ERR;
return pERROR;
}
/* Allocate an entry for this variable */
nCol = ++gParse.nCols;
if( gParse.varData ) {
gParse.varData = (DataInfo *) ckrealloc( (char *)gParse.varData,
nCol*sizeof(DataInfo) );
} else {
gParse.varData = (DataInfo *) ckalloc ( nCol*sizeof(DataInfo) );
}
/* Initialize Data Array for this variable */
variable = gParse.varData+(nCol-1);
strncpy( variable->name, dataName, MAXVARNAME );
variable->name[MAXVARNAME] = '\0';
variable->nelem = nelem;
variable->naxis = naxis;
for( i=0; inaxes[i] = naxes[i];
variable->undef = undef;
variable->data = ptrs.ptr;
thelval->lng = nCol - 1;
switch( datatype ) {
case LONGLONG_DATA:
variable->type = LONGLONGDATA;
type = COLUMN;
if( isPtr ) { /* Must make copy and define undef */
LONGLONG *llong = ptrs.llong;
ptrs.llong = (LONGLONG *)ckalloc( ntodo * sizeof(LONGLONG) );
for( i=0; idata = ptrs.ptr;
}
break;
case DOUBLE_DATA:
variable->type = DOUBLE;
type = COLUMN;
if( isPtr ) { /* Must make copy and define undef */
double *dbl = ptrs.dbl;
ptrs.dbl = (double *)ckalloc( ntodo * sizeof(double) );
for( i=0; idata = ptrs.ptr;
}
break;
case FLOAT_DATA:
variable->type = DOUBLE;
type = COLUMN;
do { /* Promote array to double */
float *flt = (float *)ptrs.ptr;
ptrs.dbl = (double *)ckalloc( ntodo * sizeof(double) );
if( isPtr ) {
for( i=0; idata );
}
variable->data = ptrs.ptr;
} while( 0 );
break;
case INT_DATA:
variable->type = LONG;
type = COLUMN;
if( sizeof(int)!=sizeof(long) || isPtr ) {
/* Promote array to long */
int *iPtr = (int *)ptrs.ptr;
ptrs.lng = (long *)ckalloc( ntodo * sizeof(long) );
if( isPtr ) {
for( i=0; idata );
}
variable->data = ptrs.ptr;
}
break;
case SHORTINT_DATA:
variable->type = LONG;
type = COLUMN;
do { /* Promote array to long */
short *sPtr = (short*)ptrs.ptr;
ptrs.lng = (long *)ckalloc( ntodo * sizeof(long) );
if( isPtr ) {
for( i=0; idata );
}
variable->data = ptrs.ptr;
} while( 0 );
break;
case BYTE_DATA:
variable->type = LONG;
type = COLUMN;
do { /* Promote array to long */
unsigned char *bPtr;
bPtr = (unsigned char *)ptrs.ptr;
ptrs.lng = (long *)ckalloc( ntodo * sizeof(long) );
if( isPtr ) {
for( i=0; idata );
}
variable->data = ptrs.ptr;
} while( 0 );
break;
}
}
Tcl_ResetResult( interp );
return type;
}
static int fitsGetDataCallback( char *dataName, int *argc, Tcl_Obj ***argv)
{
Tcl_Obj *res, *cmd;
res = NULL;
if( vexprInfo.callback ) {
cmd = Tcl_NewStringObj(vexprInfo.callback, -1);
Tcl_AppendToObj( cmd, " ", -1 );
Tcl_AppendToObj( cmd, dataName, -1 );
if( Tcl_EvalObj( vexprInfo.interp, cmd ) != TCL_OK ) {
gParse.status = PARSE_SYNTAX_ERR;
return TCL_ERROR;
}
res = Tcl_GetObjResult( vexprInfo.interp );
Tcl_ListObjGetElements( vexprInfo.interp, res, argc, argv );
if( *argc==0 ) res=NULL;
}
if( res==NULL ) {
res = fitsGetTclData( dataName );
if( res==NULL )
return TCL_ERROR;
Tcl_ListObjGetElements( vexprInfo.interp, res, argc, argv );
}
if( (*argc < 3 || *argc > 4) ||
(*argc == 4 && strcmp(Tcl_GetStringFromObj((*argv)[0],NULL),"-ptr") ) ) {
gParse.status = PARSE_SYNTAX_ERR;
Tcl_SetResult( vexprInfo.interp, "Bad callback function results",
TCL_STATIC );
return TCL_ERROR;
}
return TCL_OK;
}
static Tcl_Obj *fitsGetTclData( char *dataName )
{
/* Locates TCL variable and returns "data dType dims" */
/* ... dims is just the length of the list, though */
Tcl_Interp *interp;
Tcl_Obj *var, *name, *res;
int nelem;
interp = vexprInfo.interp;
name = Tcl_NewStringObj( dataName, -1 );
var = Tcl_ObjGetVar2( interp, name, NULL, 0 );
if( var==NULL ) {
Tcl_SetResult( interp, "Unable to locate variable: ", TCL_STATIC);
Tcl_AppendResult(interp, dataName, "\n", NULL);
gParse.status = PARSE_SYNTAX_ERR;
return NULL;
}
res = Tcl_NewListObj(1,&var);
Tcl_ListObjLength(interp, var, &nelem);
Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(DOUBLE_DATA));
Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(nelem));
return res;
}
fitsTcl/fitsInit.c 0000644 0002307 0000036 00000005744 11222720662 013027 0 ustar chai lhea /*
* fits_Init.c --
*
* This is the setup routine for the Fits extended Tcl.
*
*/
#include "fitsTclInt.h"
FitsFD FitsOpenFiles[FITS_MAX_OPEN_FILES];
Tcl_HashTable *FitsDataStore;
int FitsDS_numElems = 0;
int FitsDS_curAccess = 0;
fitsTclOptions userOptions;
int
Fits_Init (interp)
Tcl_Interp *interp; /* The Tcl Interpreter to initialize */
{
static Tcl_HashTable FitsOpenKwds[FITS_MAX_OPEN_FILES];
static FitsCardList hisCardList[FITS_MAX_OPEN_FILES];
static FitsCardList comCardList[FITS_MAX_OPEN_FILES];
int i;
for ( i = 0; i < FITS_MAX_OPEN_FILES; i++) {
FitsOpenFiles[i].fptr = NULL;
FitsOpenFiles[i].kwds = FitsOpenKwds + i;
FitsOpenFiles[i].hisHead = hisCardList + i;
FitsOpenFiles[i].hisHead->next = (FitsCardList *) NULL;
FitsOpenFiles[i].hisHead->pos = -1;
FitsOpenFiles[i].comHead = comCardList + i;
FitsOpenFiles[i].comHead->next = (FitsCardList *) NULL;
FitsOpenFiles[i].comHead->pos = -1;
FitsOpenFiles[i].handleName = NULL;
}
userOptions.wcsSwap = 0;
FitsDataStore = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(FitsDataStore,3);
Tcl_CreateObjCommand(interp, "fits", Fits_MainCommand,( ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "lst2ptr", fitsLst2Ptr, (ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "ptr2lst", fitsPtr2Lst, (ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand(interp, "vexpr", fitsExpr, (ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand( interp, "range", fitsRange,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
/*
* Remaining commands are special commands used by fv.
* They are all located in fvTcl.c.
*/
Tcl_CreateCommand(interp,"isFits",(Tcl_CmdProc*)isFitsCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"getmax",(Tcl_CmdProc*)getMaxCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"getmin",(Tcl_CmdProc*)getMinCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"setarray",(Tcl_CmdProc*)setArray,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"sarray",(Tcl_CmdProc*)searchArray,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"updateFirst",(Tcl_CmdProc*)updateFirst,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp,"calAbsXPos",(Tcl_CmdProc*)Table_calAbsXPos,
(ClientData) NULL,
(Tcl_CmdDeleteProc *) NULL);
Tcl_CreateObjCommand( interp, "updateCell",
(Tcl_ObjCmdProc*)Table_updateCell,
(ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
return TCL_OK;
}
fitsTcl/install-sh 0000755 0002307 0000036 00000004212 11222720662 013063 0 ustar chai lhea #!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5; it is not part of GNU.
#
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
instcmd="$mvprog"
chmodcmd=""
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
fi
# Make a temp file name in the proper directory.
dstdir=`dirname $dst`
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp
# and set any options; do chmod last to preserve setuid bits
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
# Now rename the file to the real destination.
$doit $rmcmd $dst
$doit $mvcmd $dsttmp $dst
exit 0
fitsTcl/makefile_plugin.bc5 0000644 0002307 0000036 00000027405 11222720662 014616 0 ustar chai lhea #
# Borland C++ IDE generated makefile
# Generated 10/15/98 at 10:52:55 AM
#
.AUTODEPEND
#
# Borland C++ tools
#
IMPLIB = Implib
BCC32 = Bcc32 +BccW32.cfg
BCC32I = Bcc32i +BccW32.cfg
TLINK32 = TLink32
TLIB = TLib
BRC32 = Brc32
TASM32 = Tasm32
#
# IDE macros
#
#
# Options
#
IDE_LinkFLAGS32 = -LD:\BC5\LIB
LinkerLocalOptsAtC32_fitstcldlib = -Tpd -ap -c /w-inq
ResLocalOptsAtC32_fitstcldlib =
BLocalOptsAtC32_fitstcldlib =
CompInheritOptsAt_fitstcldlib = -ID:\BC5\INCLUDE;C:\lheaplugin\tcl8.0\GENERIC;C:\lheaplugin\FITSTCL\CFITSIO -D_RTLDLL;_BIDSDLL; -w-sig -w-stu -w-par -w-use -w-aus
LinkerInheritOptsAt_fitstcldlib = -x
LinkerOptsAt_fitstcldlib = $(LinkerLocalOptsAtC32_fitstcldlib)
ResOptsAt_fitstcldlib = $(ResLocalOptsAtC32_fitstcldlib)
BOptsAt_fitstcldlib = $(BLocalOptsAtC32_fitstcldlib)
CompLocalOptsAtC32_cfitsiodlib = -w-sig -w-stu -w-par -w-use -w-aus
LinkerLocalOptsAtC32_cfitsiodlib = -Tpd -aa -V4.0 -c
ResLocalOptsAtC32_cfitsiodlib =
BLocalOptsAtC32_cfitsiodlib = /P32
CompOptsAt_cfitsiodlib = $(CompOptsAt_fitstcldlib) $(CompLocalOptsAtC32_cfitsiodlib)
CompInheritOptsAt_cfitsiodlib = -ID:\BC5\INCLUDE;C:\lheaplugin\TCL8.0\GENERIC;C:\lheaplugin\FITSTCL\CFITSIO -D_RTLDLL;_RTLDLL;_BIDSDLL;
LinkerInheritOptsAt_cfitsiodlib = -x
LinkerOptsAt_cfitsiodlib = $(LinkerOptsAt_fitstcldlib) $(LinkerLocalOptsAtC32_cfitsiodlib)
ResOptsAt_cfitsiodlib = $(ResOptsAt_fitstcldlib) $(ResLocalOptsAtC32_cfitsiodlib)
BOptsAt_cfitsiodlib = $(BOptsAt_fitstcldlib) $(BLocalOptsAtC32_cfitsiodlib)
#
# Dependency List
#
Dep_fitstcl = \
fitstcl.lib
fitstcl : BccW32.cfg $(Dep_fitstcl)
echo MakeNode
fitstcl.lib : fitstcl.dll
$(IMPLIB) $@ fitstcl.dll
Dep_fitstclddll = \
cfitsio.lib\
..\tcl8.0\win\tcl80.lib\
tclshared.obj\
fitsinit.obj\
fitsutils.obj\
fitstcl.obj\
fitscmds.obj\
fitsio.obj\
fvtcl.obj
fitstcl.dll : $(Dep_fitstclddll) fitstcl.def
$(TLINK32) @&&|
/v $(IDE_LinkFLAGS32) $(LinkerOptsAt_fitstcldlib) $(LinkerInheritOptsAt_fitstcldlib) +
D:\BC5\LIB\c0d32.obj+
tclshared.obj+
fitsinit.obj+
fitsutils.obj+
fitstcl.obj+
fitscmds.obj+
fitsio.obj+
fvtcl.obj
$<,$*
cfitsio.lib+
..\tcl8.0\win\tcl80.lib+
D:\BC5\LIB\bidsfi.lib+
D:\BC5\LIB\import32.lib+
D:\BC5\LIB\cw32i.lib, fitstcl.def
|
Dep_cfitsiodlib = \
putcols.obj\
putcolui.obj\
putcoluj.obj\
putcoluk.obj\
putcolu.obj\
putkey.obj\
region.obj\
swapproc.obj\
scalnull.obj\
wcsutil.obj\
putcolk.obj\
putcolj.obj\
putcoli.obj\
putcole.obj\
putcold.obj\
putcolb.obj\
putcol.obj\
modkey.obj\
listhead.obj\
putcoll.obj\
getcolj.obj\
iraffits.obj\
histo.obj\
group.obj\
grparser.obj\
getkey.obj\
getcoluk.obj\
getcoluj.obj\
getcolui.obj\
getcols.obj\
getcoll.obj\
getcolk.obj\
eval_f.obj\
getcole.obj\
getcold.obj\
getcolb.obj\
getcol.obj\
fitscore.obj\
eval_y.obj\
eval_l.obj\
getcoli.obj\
buffers.obj\
editcol.obj\
drvrmem.obj\
drvrfile.obj\
compress.obj\
checksum.obj\
cfileio.obj\
edithdu.obj
cfitsio.lib : $(Dep_cfitsiodlib)
$(TLIB) $< $(IDE_BFLAGS) $(BOptsAt_cfitsiodlib) @&&|
-+putcols.obj &
-+putcolui.obj &
-+putcoluj.obj &
-+putcoluk.obj &
-+putcolu.obj &
-+putkey.obj &
-+region.obj &
-+swapproc.obj &
-+scalnull.obj &
-+wcsutil.obj &
-+putcolk.obj &
-+putcolj.obj &
-+putcoli.obj &
-+putcole.obj &
-+putcold.obj &
-+putcolb.obj &
-+putcol.obj &
-+modkey.obj &
-+listhead.obj &
-+putcoll.obj &
-+getcolj.obj &
-+iraffits.obj &
-+histo.obj &
-+group.obj &
-+grparser.obj &
-+getkey.obj &
-+getcoluk.obj &
-+getcoluj.obj &
-+getcolui.obj &
-+getcols.obj &
-+getcoll.obj &
-+getcolk.obj &
-+eval_f.obj &
-+getcole.obj &
-+getcold.obj &
-+getcolb.obj &
-+getcol.obj &
-+fitscore.obj &
-+eval_y.obj &
-+eval_l.obj &
-+getcoli.obj &
-+buffers.obj &
-+editcol.obj &
-+drvrmem.obj &
-+drvrfile.obj &
-+compress.obj &
-+checksum.obj &
-+cfileio.obj &
-+edithdu.obj
|
putcols.obj : cfitsio\putcols.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcols.c
|
putcolui.obj : cfitsio\putcolui.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolui.c
|
putcoluj.obj : cfitsio\putcoluj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoluj.c
|
putcoluk.obj : cfitsio\putcoluk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoluk.c
|
putcolu.obj : cfitsio\putcolu.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolu.c
|
putkey.obj : cfitsio\putkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putkey.c
|
region.obj : cfitsio\region.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\region.c
|
swapproc.obj : cfitsio\swapproc.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\swapproc.c
|
scalnull.obj : cfitsio\scalnull.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\scalnull.c
|
wcsutil.obj : cfitsio\wcsutil.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\wcsutil.c
|
putcolk.obj : cfitsio\putcolk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolk.c
|
putcolj.obj : cfitsio\putcolj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolj.c
|
putcoli.obj : cfitsio\putcoli.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoli.c
|
putcole.obj : cfitsio\putcole.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcole.c
|
putcold.obj : cfitsio\putcold.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcold.c
|
putcolb.obj : cfitsio\putcolb.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcolb.c
|
putcol.obj : cfitsio\putcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcol.c
|
modkey.obj : cfitsio\modkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\modkey.c
|
listhead.obj : cfitsio\listhead.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\listhead.c
|
putcoll.obj : cfitsio\putcoll.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\putcoll.c
|
getcolj.obj : cfitsio\getcolj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolj.c
|
iraffits.obj : cfitsio\iraffits.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\iraffits.c
|
histo.obj : cfitsio\histo.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\histo.c
|
group.obj : cfitsio\group.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\group.c
|
grparser.obj : cfitsio\grparser.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\grparser.c
|
getkey.obj : cfitsio\getkey.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getkey.c
|
getcoluk.obj : cfitsio\getcoluk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoluk.c
|
getcoluj.obj : cfitsio\getcoluj.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoluj.c
|
getcolui.obj : cfitsio\getcolui.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolui.c
|
getcols.obj : cfitsio\getcols.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcols.c
|
getcoll.obj : cfitsio\getcoll.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoll.c
|
getcolk.obj : cfitsio\getcolk.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolk.c
|
eval_f.obj : cfitsio\eval_f.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_f.c
|
getcole.obj : cfitsio\getcole.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcole.c
|
getcold.obj : cfitsio\getcold.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcold.c
|
getcolb.obj : cfitsio\getcolb.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcolb.c
|
getcol.obj : cfitsio\getcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcol.c
|
fitscore.obj : cfitsio\fitscore.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\fitscore.c
|
eval_y.obj : cfitsio\eval_y.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_y.c
|
eval_l.obj : cfitsio\eval_l.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\eval_l.c
|
getcoli.obj : cfitsio\getcoli.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\getcoli.c
|
buffers.obj : cfitsio\buffers.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\buffers.c
|
editcol.obj : cfitsio\editcol.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\editcol.c
|
drvrmem.obj : cfitsio\drvrmem.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\drvrmem.c
|
drvrfile.obj : cfitsio\drvrfile.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\drvrfile.c
|
compress.obj : cfitsio\compress.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\compress.c
|
checksum.obj : cfitsio\checksum.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\checksum.c
|
cfileio.obj : cfitsio\cfileio.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\cfileio.c
|
edithdu.obj : cfitsio\edithdu.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_cfitsiodlib) $(CompInheritOptsAt_cfitsiodlib) -o$@ cfitsio\edithdu.c
|
tclshared.obj : tclshared.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ tclshared.c
|
fitscmds.obj : fitscmds.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitscmds.c
|
fitsio.obj : fitsio.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsio.c
|
fvtcl.obj : fvtcl.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fvtcl.c
|
fitsutils.obj : fitsutils.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsutils.c
|
fitstcl.obj : fitstcl.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitstcl.c
|
fitsinit.obj : fitsinit.c
$(BCC32) -P- -c @&&|
$(CompOptsAt_fitstcldlib) $(CompInheritOptsAt_fitstcldlib) -o$@ fitsinit.c
|
vcclib: fitstcl.def
lib/def:fitstcl.def
fitstcl.def:
..\tcl8.0\win\DUMPEXTS -o fitstcl.def fitstcl.dll @&&|
$(Dep_fitstclddll)
|
# Compiler configuration file
BccW32.cfg :
Copy &&|
-w
-R
-v
-vi
-H
-H=fitstcl.csm
-g255
-WCD
| $@
fitsTcl/fitsCmds.c 0000644 0002307 0000036 00000341455 11222720662 013014 0 ustar chai lhea /*
* fitsCmds.c --
*
* This holds the handlers for all of the fitsObj commands
*
*/
/*
* ------------------------------------------------------------
* MODIFICATION HISTORY:
* 2004-02-05 Ziqin Pan:
* Add the following commands:
* 1. delete row -rowrange rangelist
* 2. add column colName colForm ?expr? ?rowrange?
* 3. select rows -expr expression firstrow nrow
*
*
*/
#include "fitsTclInt.h"
#define ARGV_STR(x) Tcl_GetStringFromObj(argv[x],NULL)
/*
* ------------------------------------------------------------
*
* fitsDispatch --
*
* This is the dispatch routine for the Fits objects
*
* Results:
* Depends on argv[1].
*
* Side Effects:
* Depends on argv[1].
*
* ------------------------------------------------------------
*
*/
int fitsDispatch( ClientData clientData,
Tcl_Interp *interp,
int argc,
Tcl_Obj *const argv[] )
{
static char *commandList =
"Available commands:\n"
"close - close the file and delete this object\n"
"move ?+/-?n - move to HDU #n or forward/backward +/-n HDUs\n"
"dump ?-s/-e/-l? - return contents of the CHDU's header in various formats\n"
"info - get information about the CHDU \n"
"get - get various data from CHDU\n"
"put - change contents of CHDU: keywords or extension data\n"
"insert- insert KEYWORDs, COLUMNs, ROWs, or HDUs \n"
"delete- delete KEYWORDs, COLUMNs, ROWs, or HDUs \n"
"select- select ROWs \n"
"load - load image and table data into variables or pointers \n"
"free - free loaded data. **If the address is not the right one\n"
" returned from \"load xxx\", a core dump will occur** \n"
"flush ?clear? - flush dirty buffers to disk (also clear buffer contents?) \n"
"copy filename - copy the CHDU to a new file\n"
"sascii- save extension contents to an ascii file \n"
"sort - sort the CHDU according to supplied parameters \n"
"add - Append new columns and rows to table. Column may be filled\n"
" with the results of a supplied arithmetic expression\n"
"append filename - Append current HDU to indicated fits file\n"
"histogram - Create N-D histogram from table columns\n"
"smooth - Create a smoothed image from the original image.\n"
"checksum update|verify - Update or verify checksum keywords of the\n"
" current HDU. Verify: 1=good, -1=bad, 0=none\n"
;
int i, j, status;
FitsFD *curFile = (FitsFD *) clientData;
struct {
char *cmd;
int tclObjs;
int (*fct)(FitsFD*,int,Tcl_Obj*const[]);
} cmdLookup[] = {
{ "close", 1, fitsTcl_close },
{ "move", 1, fitsTcl_move },
{ "dump", 1, fitsTcl_dump },
{ "info", 0, fitsTcl_info },
{ "get", 0, fitsTcl_get },
{ "put", 1, fitsTcl_put },
{ "insert", 0, fitsTcl_insert },
{ "delete", 0, fitsTcl_delete },
{ "select", 0, fitsTcl_select },
{ "load", 0, fitsTcl_load },
{ "free", 1, fitsTcl_free },
{ "flush", 1, fitsTcl_flush },
{ "copy", 1, fitsTcl_copy },
{ "sascii", 0, fitsTcl_sascii },
{ "sort", 0, fitsTcl_sort },
{ "add", 0, fitsTcl_add },
{ "append", 1, fitsTcl_append },
{ "histogram",1, fitsTcl_histo },
{ "create", 1, fitsTcl_create },
{ "smooth", 1, fitsTcl_smooth },
{ "checksum", 1, fitsTcl_checksum },
{ "", 0, NULL }
};
char *cmd, **args;
/*
* If there are no arguments, return the help string
*/
if( argc==1 ) {
Tcl_SetResult(interp,commandList,TCL_STATIC);
return TCL_OK;
}
/*
* Search for the command and call its handler
*/
cmd = Tcl_GetStringFromObj( argv[1], NULL );
for( i=0; cmdLookup[i].cmd[0]; i++ ) {
if( !strcmp( cmdLookup[i].cmd, cmd ) ) {
if( cmdLookup[i].tclObjs ) {
status = (*cmdLookup[i].fct)(curFile, argc, argv);
} else {
/*
* Convert TCL_OBJs to strings
*/
args = (char **) ckalloc( argc * sizeof(char *) );
for( j=0; jinterp,
"Wrong number of args: expected fits close",TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_DeleteCommand( curFile->interp, curFile->handleName ) != TCL_OK ) {
return TCL_ERROR;
}
curFile->fptr = NULL;
curFile->handleName = NULL;
return TCL_OK;
}
/******************************************************************
* Move
******************************************************************/
int fitsTcl_move( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *moveList = "\n"
"move nmove - moves the CHDU: \n"
" nmove = +- -> relative move, otherwise absolute\n"
" returns hdutype\n";
char *pStr;
int nmove;
int mSilent=0;
int status=0;
if ( 3 > argc ) {
Tcl_SetResult(curFile->interp, moveList, TCL_STATIC);
return TCL_OK;
}
/* Convert the nmove argument */
if( Tcl_GetIntFromObj(curFile->interp,argv[2],&nmove) != TCL_OK ) {
Tcl_SetResult(curFile->interp,"Wrong type for nmove",TCL_STATIC);
return TCL_ERROR;
}
if( argc == 4 ) {
pStr = Tcl_GetStringFromObj( argv[3], NULL );
if( !strcmp(pStr, "-s") ) {
mSilent = 1;
} else {
Tcl_SetResult(curFile->interp, "fitsTcl Error: "
"unkown option: -s for load without read header", TCL_STATIC);
return TCL_ERROR;
}
}
pStr = Tcl_GetStringFromObj( argv[2], NULL );
if( mSilent ) {
if ( strchr(pStr,'+') ) {
status = fitsJustMoveHDU(curFile, nmove, 1);
} else if ( strchr(pStr,'-') ) {
status = fitsJustMoveHDU(curFile, nmove,-1);
} else {
status = fitsJustMoveHDU(curFile, nmove, 0);
}
} else {
if ( strchr(pStr,'+') ) {
status = fitsMoveHDU(curFile, nmove, 1);
} else if ( strchr(pStr,'-') ) {
status = fitsMoveHDU(curFile, nmove,-1);
} else {
status = fitsMoveHDU(curFile, nmove, 0);
}
}
if ( status ) {
return TCL_ERROR;
}
/* Return the hdutype */
Tcl_SetObjResult(curFile->interp,
Tcl_NewIntObj( curFile->hduType ) );
return TCL_OK;
}
/******************************************************************
* Dump
******************************************************************/
int fitsTcl_dump( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
int status;
char *option;
if( argc == 2 ) {
status = fitsDumpHeader(curFile);
} else {
option = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp("-l",option) ) {
status = fitsDumpKwdsToList(curFile);
} else if( !strcmp("-s",option) ) {
status = fitsDumpHeaderToKV(curFile);
} else if( !strcmp("-e",option) ) {
status = fitsDumpHeaderToCard(curFile);
} else {
Tcl_SetResult(curFile->interp,
"Usage: fitsFile dump ?-s/-e/-l?", TCL_STATIC);
return TCL_ERROR;
}
}
return status;
}
/******************************************************************
* Info
******************************************************************/
int fitsTcl_info( FitsFD *curFile, int argc, char *const argv[] )
{
static char *infoList = "\n"
"Available Commands:\n"
"\n"
"info chdu - returns the CHDU\n"
"info nhdu - returns the total number of hdu in the file\n"
"info filesize- returns the size of the file(in unit of 2880 byte)\n"
"info hdutype - returns the type of the CHDU\n"
"info imgType - returns the image type of the CHDU \n"
"info imgdim - returns the image dimension of the CHDU \n"
"info ncols - returns the number of columns in the CHDU\n"
"info nrows - returns the number of rows in the CHDU\n"
"info nkwds - returns the number of keywords in the CHDU\n"
"info column ?-exact? ?colNames? \n"
" with no argument, lists the columns,\n"
" otherwise gives more info about columns in colName\n"
" ?-minmax? colName firstElement ?rowRange? \n"
" min and max\n"
" ?-stat? colName firstElement ?rowRange? \n"
" statistics about the indicated column\n"
"\n";
int i, j, felem, numRange, *range=NULL;
int numCols, colTypes[FITS_COLMAX], colNums[FITS_COLMAX], strSize[FITS_COLMAX];
int status = 0;
char result[32];
char tmpStr[3][FLEN_VALUE]; /* Some general purpose string buffers */
char *mrgList[9], *pattern, *tmpStrPtr;
char errMsg[256], **colList;
Tcl_DString concatList;
if( argc < 3 ) {
Tcl_SetResult(curFile->interp, infoList, TCL_STATIC);
return TCL_OK;
}
/* check if the chdu has been loaded or not */
if( curFile->CHDUInfo.table.loadStatus != 1 ) {
Tcl_SetResult(curFile->interp,
"You need to load the CHDU first", TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp("chdu",argv[2] ) ) {
sprintf(result,"%d",curFile->chdu);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
} else if( !strcmp("imgType",argv[2]) ) {
int bitpix = 0;
int naxis = 0;
long naxes[9];
fits_get_img_dim(curFile->fptr, &naxis, &status);
status = 0;
fits_get_img_size(curFile->fptr, naxis, naxes, &status);
status = 0;
fits_get_img_type(curFile->fptr, &bitpix, &status);
sprintf(result,"%d", bitpix);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
} else if( !strcmp("filesize",argv[2]) ) {
sprintf(result,"%ld",curFile->fptr->Fptr->filesize/2880);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
} else if( !strcmp("hdutype",argv[2]) ) {
switch ( curFile->hduType ) {
case IMAGE_HDU:
if( curFile->chdu )
tmpStrPtr = "Image extension";
else
tmpStrPtr = "Primary array";
break;
case ASCII_TBL:
tmpStrPtr = "ASCII Table";
break;
case BINARY_TBL:
tmpStrPtr = "Binary Table";
break;
default:
Tcl_SetResult(curFile->interp, "Unsupported hdu type", TCL_STATIC);
return TCL_ERROR;
}
Tcl_SetResult(curFile->interp, tmpStrPtr, TCL_STATIC);
} else if( !strcmp("nhdu", argv[2]) ) {
int nhdu;
ffthdu(curFile->fptr, &nhdu, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
sprintf(result, "%d", nhdu);
Tcl_SetResult( curFile->interp, result, TCL_VOLATILE );
} else if( !strcmp("nkwds",argv[2] ) ) {
sprintf(result, "%-d", curFile->numKwds);
Tcl_SetResult( curFile->interp, result, TCL_VOLATILE );
} else if( !strcmp("ncols",argv[2] ) ) {
if (curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult( curFile->interp,
"No columns for an Image extension", TCL_STATIC);
return TCL_ERROR;
}
sprintf(result, "%d", curFile->CHDUInfo.table.numCols);
Tcl_SetResult( curFile->interp, result, TCL_VOLATILE );
} else if( !strcmp("nrows",argv[2] ) ) {
if (curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult( curFile->interp,
"No rows for an Image extension", TCL_STATIC );
return TCL_ERROR;
}
sprintf(result,"%lld",curFile->CHDUInfo.table.numRows);
Tcl_SetResult( curFile->interp, result, TCL_VOLATILE );
} else if( !strcmp("column",argv[2] ) ) {
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult( curFile->interp,
"No Columns in an image extension", TCL_STATIC );
return TCL_ERROR;
}
if( argc == 3 ) {
/***********************************
* Return a list of column names *
***********************************/
for ( i = 0; i < curFile->CHDUInfo.table.numCols; i++ ) {
Tcl_AppendElement(curFile->interp,
curFile->CHDUInfo.table.colName[i]);
}
} else {
/*******************************************
* Return info about one or more columns *
*******************************************/
if( !strcmp(argv[3], "-stat") ) {
if ( argc < 5 ) {
Tcl_SetResult(curFile->interp,
"Usage: info column -stat columnName ?felem? ?rows?",
TCL_STATIC);
return TCL_ERROR;
}
if( argc == 5 ) {
felem = 1;
} else if( Tcl_GetInt(curFile->interp, argv[5], &felem)
!= TCL_OK ) {
return TCL_ERROR;
}
if( argc >= 7 ) {
numRange = fitsParseRangeNum(argv[6])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange(argv[6],&numRange,range,numRange,
1, curFile->CHDUInfo.table.numRows,errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
} else {
numRange = 1;
range = (int*) malloc(numRange*2*sizeof(int));
range[0] = 1;
range[1] = curFile->CHDUInfo.table.numRows ;
}
if( fitsTransColList( curFile, argv[4], &numCols,
colNums, colTypes, strSize) != TCL_OK )
return TCL_ERROR;
if( fitsColumnStatistics(curFile,colNums[0],felem,
numRange,range) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp(argv[3], "-minmax") ) {
if ( argc < 5 ) {
Tcl_SetResult(curFile->interp,
"Usage: info column -minmax "
"columnName ?felem? ?rows?", TCL_STATIC);
return TCL_ERROR;
}
if( argc == 5 ) {
felem = 1;
} else if( Tcl_GetInt(curFile->interp, argv[5], &felem)
!= TCL_OK ) {
return TCL_ERROR;
}
if( argc >= 7 ) {
numRange = fitsParseRangeNum(argv[6])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange(argv[6],&numRange,range,numRange,
1, curFile->CHDUInfo.table.numRows,errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
} else {
numRange = 1;
range = (int*) malloc(numRange*2*sizeof(int));
range[0] = 1;
range[1] = curFile->CHDUInfo.table.numRows ;
}
for ( i = 0; i < curFile->CHDUInfo.table.numCols; i++) {
if( !strcasecmp(argv[4],curFile->CHDUInfo.table.colName[i]) ) {
if( fitsColumnMinMax(curFile, i+1, felem, numRange, range)
!= TCL_OK ) {
return TCL_ERROR;
}
break;
}
}
} else if( !strcmp(argv[3], "-exact") ) {
/*************************************************************
* Return Info about Columns matching an exact column name *
*************************************************************/
if( argc != 5 ) {
Tcl_SetResult(curFile->interp,
"Usage: info column -exact columnNames",
TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile, argv[4], &numCols,
colNums, colTypes, strSize) != TCL_OK )
return TCL_ERROR;
for ( i = 0; i < numCols; i++ ) {
j = colNums[i]-1;
mrgList[0] = curFile->CHDUInfo.table.colName[j];
mrgList[1] = curFile->CHDUInfo.table.colType[j];
mrgList[2] = curFile->CHDUInfo.table.colUnit[j];
mrgList[3] = curFile->CHDUInfo.table.colDisp[j];
mrgList[4] = curFile->CHDUInfo.table.colFormat[j];
sprintf(tmpStr[0], "%d",
curFile->CHDUInfo.table.colWidth[j]);
mrgList[5] = tmpStr[0];
sprintf(tmpStr[1], "%d",
curFile->CHDUInfo.table.colTzflag[j]);
mrgList[6] = tmpStr[1];
sprintf(tmpStr[2], "%d",
curFile->CHDUInfo.table.colTsflag[j]);
mrgList[7] = tmpStr[2];
mrgList[8] = curFile->CHDUInfo.table.colNull[j];
Tcl_AppendElement(curFile->interp,Tcl_Merge(9,mrgList));
}
} else if( argc==4 ) {
/***********************************************************
* Return Info about Columns matching regular expression *
***********************************************************/
Tcl_DStringInit(&concatList);
if( Tcl_SplitList(curFile->interp, argv[3], &numCols,
&colList) != TCL_OK ) {
return TCL_ERROR;
}
if( fitsMakeRegExp(curFile->interp, numCols, colList,
&concatList, 1)
== TCL_ERROR ) {
Tcl_SetResult(curFile->interp,
"Error making up reg expr", TCL_STATIC);
Tcl_DStringFree(&concatList);
ckfree((char*)colList);
return TCL_ERROR;
}
ckfree((char*)colList);
pattern = Tcl_DStringValue(&concatList);
for ( i = 0; i < curFile->CHDUInfo.table.numCols; i++) {
strToUpper(curFile->CHDUInfo.table.colName[i], &tmpStrPtr);
status = Tcl_RegExpMatch(curFile->interp, tmpStrPtr, pattern);
ckfree( (char*)tmpStrPtr );
if( status == 1 ) {
mrgList[0] = curFile->CHDUInfo.table.colName[i];
mrgList[1] = curFile->CHDUInfo.table.colType[i];
mrgList[2] = curFile->CHDUInfo.table.colUnit[i];
mrgList[3] = curFile->CHDUInfo.table.colDisp[i];
mrgList[4] = curFile->CHDUInfo.table.colFormat[i];
sprintf(tmpStr[0], "%d",
curFile->CHDUInfo.table.colWidth[i]);
mrgList[5] = tmpStr[0];
sprintf(tmpStr[1], "%d",
curFile->CHDUInfo.table.colTzflag[i]);
mrgList[6] = tmpStr[1];
sprintf(tmpStr[2], "%d",
curFile->CHDUInfo.table.colTsflag[i]);
mrgList[7] = tmpStr[2];
mrgList[8] = curFile->CHDUInfo.table.colNull[i];
Tcl_AppendElement(curFile->interp,Tcl_Merge(9,mrgList));
} else if( status == -1 ) {
Tcl_AppendResult(curFile->interp,"Error, ", pattern,
" not a Regular Expression.",
(char *) NULL);
Tcl_DStringFree(&concatList);
return TCL_ERROR;
}
}
Tcl_DStringFree(&concatList);
} else {
Tcl_SetResult(curFile->interp,
"Usage:\n"
" info column ?-exact? colNames \n"
" -minmax colName firstElement ?rowRange? \n"
" -stat colName firstElement ?rowRange? \n",
TCL_STATIC);
return TCL_ERROR;
}
}
/* End of 'info column' */
} else if( !strcmp("expr", argv[2]) ) {
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,"Not a table extension", TCL_STATIC);
return TCL_ERROR;
}
if( argc != 4 ) {
Tcl_SetResult(curFile->interp,
"Usage: info expr exprStr", TCL_STATIC);
return TCL_ERROR;
}
if( exprGetInfo( curFile, argv[3] ) ) {
return TCL_ERROR;
}
} else if( !strcmp("imgdim", argv[2]) ) {
if ( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
Tcl_ResetResult(curFile->interp);
for (i=0; i < curFile->CHDUInfo.image.naxes; i++) {
sprintf(tmpStr[0], "%lld", curFile->CHDUInfo.image.naxisn[i]);
Tcl_AppendElement(curFile->interp, tmpStr[0]);
}
} else {
Tcl_SetResult(curFile->interp,
"Unrecognized option to info", TCL_STATIC);
return TCL_ERROR;
}
if (range) free(range);
return TCL_OK;
}
/******************************************************************
* Get
******************************************************************/
int fitsTcl_get( FitsFD *curFile, int argc, char *const argv[] )
{
static char *getList = "\n"
"Available Commands:\n"
"get keyword ?keyName? - displays the keyword(s) keyname\n"
" - keywords are specified by reg. expression\n"
"get keyword -num keyNum - displays the num th keyword in the CHDU\n"
"get wcs ?RAcol DECcol?\n"
" - return a list of the WCS parameters for either a table or image:\n"
" {xrval yrval xrpix yrpix xinc yinc rot ctype}\n"
" For a table, supply RAcol and DECcol which are column names or \n"
" numbers of the RA column and DEC column\n"
"get header2str - get header and construct it into a string\n"
"get translatedKeywords - translated header keyword to normal one.\n"
"get dummy2str - create dummy fits image file and get header and construct it into a string\n"
"get image ?firstElem? ?numElem?\n"
" - return elements of an image\n"
"get table ?-c? ?-noformat? ?colList? ?rowList?\n"
" - return the elements rowList from list colList\n"
" - if no rowList is provided, give all rows\n"
" - if no colList is provided, give all columns\n"
" - use colList = * for all columns\n"
" - -c means return each column as a seperate list.\n"
"get vtable ?-noformat? colname firstelement ?rowList?\n"
" - get the firstelement-th vector element\n"
"\n";
char Comment[FLEN_COMMENT], Name[FLEN_KEYWORD], Value[FLEN_VALUE];
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int numRange, *range=NULL;
Tcl_HashEntry *newEntry;
Tcl_HashSearch search;
Tcl_DString concatList, regExpList;
Tcl_DString ** colDString;
FitsCardList *curCard;
Keyword *newKwd;
char errMsg[256];
int nmove,i,k,l,n;
int bycol,niters,fRow;
int ntodo,felem;
char ***strValArray;
char *pattern;
int status = 0;
char *header;
int nkeys;
Tcl_Obj *resObj, **valArray, *listObj, **listArray, *valObj;
listObj = Tcl_NewObj();
if ( argc == 2 ) {
Tcl_SetResult(curFile->interp, getList, TCL_STATIC);
return TCL_OK;
}
if( !strcmp("keyword", argv[2]) ) {
/* GET KEYWORD */
if( argc == 3 ) {
Tcl_DStringInit(&concatList);
newEntry = Tcl_FirstHashEntry(curFile->kwds,&search);
while ( newEntry ) {
newKwd = (Keyword *) Tcl_GetHashValue(newEntry);
Tcl_DStringStartSublist(&concatList);
Tcl_DStringAppendElement(&concatList,newKwd->name);
Tcl_DStringAppendElement(&concatList,newKwd->value);
Tcl_DStringAppendElement(&concatList,newKwd->comment);
Tcl_DStringEndSublist(&concatList);
newEntry = Tcl_NextHashEntry(&search);
}
Tcl_DStringResult(curFile->interp,&concatList);
} else if( !strcmp(argv[3],"-num") ) {
if ( 5 != argc ) {
Tcl_SetResult(curFile->interp,
"Wrong number of args, expected get keyword "
"-num number", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp,argv[4],&nmove) != TCL_OK ) {
Tcl_AppendResult(curFile->interp,
"\nWrong type for nmove",(char *) NULL);
return TCL_ERROR;
}
/*
* First look through the comments and the history cards:
* remember the first card is always a dummy...
*/
curCard = (curFile->hisHead)->next;
while( curCard ) {
if ( curCard->pos == nmove ) {
Tcl_AppendElement(curFile->interp,"HISTORY");
Tcl_AppendElement(curFile->interp," ");
Tcl_AppendElement(curFile->interp,curCard->value);
return TCL_OK;
}
curCard = curCard->next;
}
curCard = (curFile->comHead)->next;
while( curCard ) {
if ( curCard->pos == nmove ) {
Tcl_AppendElement(curFile->interp,"COMMENT");
Tcl_AppendElement(curFile->interp," ");
Tcl_AppendElement(curFile->interp,curCard->value);
return TCL_OK;
}
curCard = curCard->next;
}
newEntry = Tcl_FirstHashEntry(curFile->kwds,&search);
while( newEntry ) {
newKwd = (Keyword *) Tcl_GetHashValue(newEntry);
if ( newKwd->pos == nmove ) {
Tcl_AppendElement(curFile->interp,newKwd->name);
Tcl_AppendElement(curFile->interp,newKwd->value);
Tcl_AppendElement(curFile->interp,newKwd->comment);
return TCL_OK;
}
newEntry = Tcl_NextHashEntry(&search);
}
/* The Hashes all failed (maybe duplicate keys in header. */
/* Go directly to file. */
ffgkyn( curFile->fptr, nmove, Name, Value, Comment, &status);
if( status ) {
dumpFitsErrStack(curFile->interp,status);
return TCL_ERROR;
}
Tcl_AppendElement(curFile->interp,Name);
Tcl_AppendElement(curFile->interp,Value);
Tcl_AppendElement(curFile->interp,Comment);
} else {
Tcl_DStringInit(®ExpList);
if( fitsMakeRegExp(curFile->interp, argc-3, argv+3, ®ExpList, 1)
== TCL_ERROR ) {
Tcl_SetResult(curFile->interp,
"Error building regular expression", TCL_STATIC);
Tcl_DStringFree(®ExpList);
return TCL_ERROR;
}
pattern = Tcl_DStringValue(®ExpList);
Tcl_DStringInit(&concatList);
niters = 0;
newEntry = Tcl_FirstHashEntry(curFile->kwds,&search);
while ( NULL != newEntry ) {
newKwd = (Keyword *) Tcl_GetHashValue(newEntry);
status = Tcl_RegExpMatch(curFile->interp,newKwd->name,pattern);
if ( status == 1 ) {
niters = 1;
Tcl_DStringStartSublist(&concatList);
Tcl_DStringAppendElement(&concatList,newKwd->name);
Tcl_DStringAppendElement(&concatList,newKwd->value);
Tcl_DStringAppendElement(&concatList,newKwd->comment);
Tcl_DStringEndSublist(&concatList);
newEntry = Tcl_NextHashEntry(&search);
} else if ( status == -1 ) {
Tcl_AppendResult(curFile->interp,"The Pattern: ",pattern,
" is not a regular expression."
,(char *) NULL);
Tcl_DStringFree(&concatList);
Tcl_DStringFree(®ExpList);
return TCL_ERROR;
} else {
newEntry = Tcl_NextHashEntry(&search);
}
}
if( !niters ) {
Tcl_SetResult(curFile->interp,
"No matching keywords found/or keyword not loaded",
TCL_STATIC);
Tcl_DStringFree(&concatList);
return TCL_ERROR;
}
Tcl_DStringResult(curFile->interp,&concatList);
}
} else if( !strcmp("wcs", argv[2]) ) {
/* Get WCS */
if ( curFile->hduType == IMAGE_HDU ) {
/* Get WCS from Image extension */
if( argc < 4 || argc > 5 ) {
Tcl_SetResult(curFile->interp,
"For image extension use, get wcs", TCL_STATIC);
return TCL_ERROR;
}
if ( argc == 5 && !strcmp("-m", argv[3]) ) {
if( fitsGetWcsMatrix(curFile, 0, NULL, argv[4][0]) != TCL_OK ) {
return TCL_ERROR;
}
} else {
if( fitsGetWcsPair(curFile,0,0, '\0') != TCL_OK ) {
return TCL_ERROR;
}
}
} else {
/* Get WCS from Table extension */
int i,j;
int nCols = 0;
int getMatrix = 0;
int columns[FITS_MAXDIMS];
if( argc>4 && !strcmp("-m", argv[3]) ) {
getMatrix = 1;
nCols = argc - 5;
if( nCols<1 ) {
Tcl_SetResult(curFile->interp,
"For table extension use, "
"get wcs -m dest Col1 ?Col2 ...?",
TCL_STATIC);
return TCL_ERROR;
} else if( nCols > FITS_MAXDIMS ) {
Tcl_SetResult(curFile->interp,
"Too many columns to obtain WCS information",
TCL_STATIC);
return TCL_ERROR;
}
} else {
nCols = 2;
if( argc != 7 ) {
Tcl_SetResult(curFile->interp,
"For table extension use, get wcs -m dest RAcol DecCol",
TCL_STATIC);
return TCL_ERROR;
}
}
for( j=0, i=argc-nCols; iinterp, argv[i], columns+j) != TCL_OK ) {
Tcl_ResetResult(curFile->interp);
if( fitsTransColList( curFile, argv[i],
&numCols, colNums, colTypes, strSize)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Unable to read column specifier", TCL_STATIC);
return TCL_ERROR;
}
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only have column value", TCL_STATIC);
return TCL_ERROR;
}
columns[j] = colNums[0];
}
}
if( getMatrix ) {
if( fitsGetWcsMatrix(curFile, nCols, columns, argv[4][0]) != TCL_OK ) {
return TCL_ERROR;
}
} else {
if( fitsGetWcsPair(curFile, columns[0], columns[1], argv[4][0]) != TCL_OK ) {
return TCL_ERROR;
}
}
}
} else if( !strcmp("dummy2str", argv[2]) ) {
fitsfile *dummyptr;
int status = 0;
int bitpix = 8;
int naxis = 2;
long naxes[2];
int columns[FITS_MAXDIMS];
int *nkeys;
char **header;
int i,j;
/* Pan Chai: there is only 2 columns */
int nCols = 2;
Tcl_Obj *data[5];
naxes[0] = 10;
naxes[1] = 10;
for( j=0, i=argc-nCols; iinterp, argv[i], columns+j) != TCL_OK ) {
Tcl_ResetResult(curFile->interp);
if( fitsTransColList( curFile, argv[i],
&numCols, colNums, colTypes, strSize)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Unable to read column specifier", TCL_STATIC);
return TCL_ERROR;
}
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only have column value", TCL_STATIC);
return TCL_ERROR;
}
columns[j] = colNums[0];
}
}
/* size of histogram is now known, so create temp output file */
if (ffinit(&dummyptr, "mem://", &status) > 0)
{
ffpmsg("failed to create temp output file for dummy fits file");
return(status);
}
status = 0;
/* create output FITS image HDU */
if (ffcrim(dummyptr, bitpix, naxis, naxes, &status) > 0)
{
ffpmsg("failed to create output dummy FITS image");
return(status);
}
status = 0;
/* copy header keywords, converting pixel list WCS keywords to image WCS form */
if (fits_copy_pixlist2image(curFile->fptr, dummyptr, 9, naxis, columns, &status) > 0)
{
ffpmsg("failed to copy pixel list keywords to new dummy header");
return(status);
}
status = 0;
if ( ffhdr2str(dummyptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
return TCL_ERROR;
}
/* since this is a dummy header, all relative reference starts with 1 */
for (i = 0; i < naxis; i++) {
columns[i] = i + 1;
}
fitsFileGetWcsMatrix( curFile, dummyptr, naxis, columns, argv[3][0], data);
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewStringObj(header, -1));
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewIntObj( nkeys ) );
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewListObj(5,data) );
Tcl_SetObjResult(curFile->interp, listObj);
ckfree( (char*) header);
return TCL_OK;
} else if( !strcmp("translatedKeywords", argv[2]) ) {
char outfile[FLEN_FILENAME];
int status = 0;
long rownum;
fitsfile *newptr;
strcpy(outfile, "mem://_1");
/* Copy the image into new primary array and open it as the current */
/* fptr. This will close the table that contains the original image. */
/* create new empty file to hold copy of the image */
if (ffinit(&newptr, outfile, &status) > 0)
{
ffpmsg("failed to create file for copy of image in table cell:");
ffpmsg(outfile);
return(status);
}
rownum = atol(argv[4]);
status = 0;
if (fits_copy_cell2image(curFile->fptr, newptr, argv[3], rownum, &status) > 0)
{
ffpmsg("Failed to copy table cell to new primary array:");
ffclos(curFile->fptr, status);
curFile->fptr = 0; /* return null file pointer */
return(status);
}
if ( ffhdr2str(newptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
return TCL_ERROR;
}
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewStringObj(header, -1));
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewIntObj( nkeys ) );
if ( fitsGetWcsMatrixAlt(curFile, newptr, listObj, 0, NULL, '\0') > 0 ) {
Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
return TCL_ERROR;
}
/*
if ( fitsGetWcsPairAlt(curFile, newptr, listObj, 0, 0, '\0') > 0 ) {
Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
return TCL_ERROR;
}
Tcl_SetObjResult(curFile->interp, listObj);
*/
ckfree( (char*) header);
return TCL_OK;
} else if( !strcmp("header2str", argv[2]) ) {
/* int ffhdr2str( fitsfile *fptr, I - FITS file pointer */
/* int exclude_comm, I - if TRUE, exclude commentary keywords */
/* char **exclist, I - list of excluded keyword names */
/* int nexc, I - number of names in exclist */
/* char **header, O - returned header string */
/* int *nkeys, O - returned number of 80-char keywords */
/* int *status) IO - error status */
if ( ffhdr2str(curFile->fptr, 1, (char *)NULL, 0, &header, &nkeys, &status) > 0 ) {
Tcl_SetResult(curFile->interp, "Failed to collect all the headers.", TCL_STATIC);
return TCL_ERROR;
}
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewStringObj(header, -1));
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewIntObj( nkeys ) );
Tcl_SetObjResult(curFile->interp, listObj);
ckfree( (char*) header);
return TCL_OK;
} else if( !strcmp("imgwcs", argv[2]) ) {
/* Get IMGWCS */
if ( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
if( fitsGetWcsPair(curFile,0,0,'\0') != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("colwcs", argv[2]) ) {
/* Get COLWCS */
int ranum = 0;
int decnum = 0;
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( argc != 5 ) {
Tcl_SetResult(curFile->interp,
"get colwcs RAcol DECcol", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[3], &ranum) != TCL_OK ) {
Tcl_ResetResult(curFile->interp);
if( fitsTransColList( curFile, argv[3],
&numCols, colNums, colTypes, strSize)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Unable to read RAcol", TCL_STATIC);
return TCL_ERROR;
}
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only have 1 RAcol value", TCL_STATIC);
return TCL_ERROR;
}
ranum = colNums[0];
}
if( Tcl_GetInt(curFile->interp, argv[4], &decnum) != TCL_OK ) {
Tcl_ResetResult(curFile->interp);
if( fitsTransColList( curFile, argv[4],
&numCols, colNums, colTypes, strSize)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Unable to read DecCol", TCL_STATIC);
return TCL_ERROR;
}
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only have 1 DecCol value", TCL_STATIC);
return TCL_ERROR;
}
decnum = colNums[0];
}
if( fitsTableGetWcsOld(curFile, ranum, decnum) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("image", argv[2]) ) {
long fElem, nElem;
if( argc < 3 || argc > 5 ) {
Tcl_SetResult(curFile->interp,
"get image firstElem numElem", TCL_STATIC);
return TCL_ERROR;
}
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( argc>3 ) {
fElem = atol( argv[3] );
if( argc>4 ) {
nElem = atol( argv[4] );
} else {
nElem = 1;
}
} else {
fElem = 1;
nElem = 1;
i = curFile->CHDUInfo.image.naxes;
while( i-- )
nElem *= curFile->CHDUInfo.image.naxisn[i];
}
if( imageBlockLoad_1D(curFile, fElem, nElem) != TCL_OK ) {
return TCL_ERROR;
}
} else if ( !strcmp("imageblock", argv[2]) ) {
/* GET IMAGE in blocks */
long slice = 1;
long cslice = 1;
if( argc < 8 || argc > 10 ) {
Tcl_SetResult(curFile->interp,
"FitsHandle get imageblock arrayName firstRow "
"numRows firstCol numCols ?2D image slice? ?cube slice?", TCL_STATIC);
return TCL_ERROR;
}
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image.", TCL_STATIC);
return TCL_ERROR;
}
if( argc > 8 )
slice = atol(argv[8]);
if( argc > 9 )
cslice = atol(argv[9]);
if( imageBlockLoad(curFile, argv[3], atoll(argv[4]), atoll(argv[5]),
atoll(argv[6]), atoll(argv[7]), slice, cslice )
!= TCL_OK ) {
return TCL_ERROR; /* Sets own error message */
}
} else if( !strcmp("table",argv[2] ) ) {
int idx, format;
/* GET TABLE */
if ( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( curFile->CHDUInfo.table.loadStatus != 1 ) {
Tcl_SetResult(curFile->interp,
"Need to load the hdu first", TCL_STATIC);
return TCL_ERROR;
}
/*
* Strip off the "-c" flag if present...
*/
bycol = 0;
format = 1;
idx = 3;
while( idx < argc && argv[idx][0]=='-' ) {
if( !strcmp(argv[idx],"-c") ) {
bycol = 1;
} else if( !strcmp(argv[idx],"-noformat") ) {
format = 0;
} else {
break;
}
idx++;
}
if( argc-idx > 2 ) {
Tcl_SetResult(curFile->interp,
"Wrong number of arguments, need "
"'get table ?-c? ?-noformat? ?columns? ?rows?'",
TCL_STATIC);
return TCL_ERROR;
}
/* If no colList is given, or it is "*", use all the columns... */
if( TCL_OK !=
fitsTransColList( curFile, ( argc==idx ? "*" : argv[idx] ),
&numCols, colNums, colTypes, strSize) )
return TCL_ERROR;
/*
* Get the Row range parameter
*/
idx++;
if( argc <= idx ) {
numRange = 1;
range = (int*) malloc(numRange*2*sizeof(int));
range[0] = 1;
range[1] = curFile->CHDUInfo.table.numRows;
} else {
numRange =fitsParseRangeNum(argv[idx])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange( argv[idx], &numRange, range, numRange,
1, curFile->CHDUInfo.table.numRows, errMsg )
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
}
/* Now get the rows... */
if ( bycol ) {
listArray = (Tcl_Obj**) ckalloc( numCols * sizeof(Tcl_Obj*) );
for( k=0; kFITS_CHUNKSIZE ) ntodo = FITS_CHUNKSIZE;
status = tableBlockLoad( curFile, "", 1, fRow, ntodo,
-99, numCols, colNums, format );
if( status != TCL_OK )
break;
fRow += ntodo;
resObj = Tcl_GetObjResult( curFile->interp );
if ( bycol ) {
for( k = 0; k < numCols; k++) {
Tcl_ListObjIndex( curFile->interp, resObj,
k, &listObj );
Tcl_ListObjAppendList( curFile->interp,
listArray[k],
listObj );
}
} else {
Tcl_ListObjGetElements( curFile->interp, resObj,
&n, &listArray );
for ( l = 0; l < ntodo; l++) {
for( k = 0; k < numCols; k++) {
Tcl_ListObjIndex( curFile->interp, listArray[k], l,
valArray+k );
}
Tcl_ListObjAppendElement( curFile->interp, listObj,
Tcl_NewListObj(numCols, valArray) );
}
}
}
}
if( status ) {
if ( bycol ) {
ckfree( (char*) listArray );
} else {
ckfree( (char*) valArray );
}
} else {
if ( bycol ) {
Tcl_SetObjResult( curFile->interp,
Tcl_NewListObj( numCols, listArray ) );
} else {
Tcl_SetObjResult( curFile->interp, listObj );
}
}
if( status ) return TCL_ERROR;
} else if( !strcmp("vtable",argv[2]) ) {
int idx, format;
/* GET vector from the TABLE */
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( curFile->CHDUInfo.table.loadStatus != 1 ){
Tcl_SetResult(curFile->interp,
"Need to load the hdu first", TCL_STATIC);
return TCL_ERROR;
}
idx = 3;
format = 1;
if( idxinterp,
"Wrong number of arguments, need "
"'get vtable ?-noformat? column felem ?rowList?'",
TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile, argv[idx++],
&numCols, colNums, colTypes, strSize )
!= TCL_OK )
return TCL_ERROR;
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only read one vector column of a table at a time",
TCL_STATIC);
return TCL_ERROR;
}
felem = atoi(argv[idx++]);
/*
* Get the Row range parameter
*/
if( argc <= idx ) {
numRange = 1;
range = (int*) malloc(numRange*2*sizeof(int));
range[0] = 1;
range[1] = curFile->CHDUInfo.table.numRows;
} else {
numRange = fitsParseRangeNum(argv[idx])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange( argv[idx++], &numRange, range, numRange,
1, curFile->CHDUInfo.table.numRows, errMsg )
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
}
/* Now get the rows... */
listObj = Tcl_NewListObj( 0, NULL );
for (i = 0; i < numRange; i++ ) {
fRow = range[i*2];
while( fRow <= range[i*2+1] ) {
ntodo = range[i*2+1] - fRow + 1;
if( ntodo>FITS_CHUNKSIZE ) ntodo = FITS_CHUNKSIZE;
if( tableBlockLoad( curFile, "", felem, fRow, ntodo,
-99, numCols, colNums, format ) != TCL_OK )
return TCL_ERROR;
fRow += ntodo;
if( Tcl_ListObjIndex( curFile->interp,
Tcl_GetObjResult( curFile->interp ), 0,
&resObj )
!= TCL_OK )
return TCL_ERROR;
if( Tcl_ListObjAppendList( curFile->interp, listObj, resObj )
!= TCL_OK )
return TCL_ERROR;
}
}
Tcl_SetObjResult( curFile->interp, listObj );
} else {
Tcl_SetResult(curFile->interp,
"ERROR: unrecognized command to get", TCL_STATIC);
return TCL_ERROR;
}
if (range) free(range);
return TCL_OK;
}
/******************************************************************
* Put
******************************************************************/
int fitsTcl_put( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *putKeyList = "put keyword ?-num n? card ?formatFlag?";
static char *putHisList = "put history string";
static char *putTabList =
"put table colName firstElem rowSpan listOfData\n";
static char *putImgList = "put image firstElem listOfData\n";
static char *putIhdList =
"put ihd ?-p? ?bitpix naxis naxesList? \n"
" - -p primary extension \n";
static char *putAhdList =
"put ahd numRows numCols {colName} {colType} {colUnit} {tbCol}\n"
" extname rowLength\n"
" - colType: L(logical), X(bit), I(16 bit integer), "
"J(32 bit integer)\n"
" An(n Character), En(Single with n format), \n"
" Dn(Double with n format), B(Unsigned) \n"
" C(Complex), M(Double complex) ";
static char *putBhdList =
"put bhd numRows numCols {colName} {colType} {colUnit} extname \n"
" - colType: nL(logical),nX(bit), nI(16 bit integer), "
"nJ(32 bit integer)\n"
" nA(Character), nE(Single), nD(Double), nB(Unsigned) \n"
" nC(Complex), M(Double complex) ";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int numRange, *range=NULL;
char errMsg[256], *argStr, *cmd, **args;
int i;
if ( argc == 2 ) {
Tcl_SetResult(curFile->interp,"Available Commands:\n",TCL_STATIC);
Tcl_AppendResult(curFile->interp, putKeyList,"\n", (char *)NULL);
Tcl_AppendResult(curFile->interp, putTabList,"\n", (char *)NULL);
Tcl_AppendResult(curFile->interp, putIhdList,"\n", (char *)NULL);
Tcl_AppendResult(curFile->interp, putAhdList,"\n", (char *)NULL);
Tcl_AppendResult(curFile->interp, putBhdList,"\n", (char *)NULL);
return TCL_OK;
}
cmd = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp( "keyword", cmd ) ) {
/* Write Keyword */
int format, cardNum=0, recLoc=3;
if( argc < 4 || argc > 7 ) {
Tcl_SetResult(curFile->interp, putKeyList, TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp(Tcl_GetStringFromObj(argv[3],NULL), "-num") ) {
if( argc < 6 ) {
Tcl_SetResult(curFile->interp, putKeyList, TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(curFile->interp, argv[4], &cardNum) != TCL_OK ) {
return TCL_ERROR;
}
recLoc += 2;
}
if( recLoc+1 < argc ) {
if( Tcl_GetIntFromObj(curFile->interp, argv[recLoc+1], &format)
!= TCL_OK ) {
return TCL_ERROR;
}
} else {
format = 1;
}
if( fitsPutKwds(curFile, cardNum,
Tcl_GetStringFromObj(argv[recLoc],NULL),
format)
!= TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "history", cmd ) ) {
/* Write History */
if( argc != 4 ) {
Tcl_SetResult(curFile->interp, putHisList, TCL_STATIC);
return TCL_ERROR;
}
if( fitsPutHisKwd(curFile, Tcl_GetStringFromObj(argv[3],NULL) )
!= TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp ( "image", cmd ) ) {
/* Write Image */
int nElem;
long fElem;
Tcl_Obj **dataList;
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 5 || argc > 6 ) {
Tcl_SetResult(curFile->interp, putImgList, TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetLongFromObj(curFile->interp, argv[3], &fElem) != TCL_OK ) {
return TCL_ERROR;
}
/* Skip to last argument... can get nElem directly from data list */
if( Tcl_ListObjGetElements( curFile->interp, argv[argc-1],
&nElem, &dataList ) != TCL_OK ) {
return TCL_ERROR;
}
if( varSaveToImage( curFile, fElem, (long)nElem, dataList ) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "table", cmd ) ) {
/* Write Table */
int nElem;
long fElem;
Tcl_Obj **dataElems;
if ( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if ( argc != 7 ) {
Tcl_SetResult(curFile->interp, putTabList, TCL_STATIC);
return TCL_ERROR;
}
/* parse the column name */
if( fitsTransColList(curFile, Tcl_GetStringFromObj(argv[3],NULL),
&numCols,colNums,colTypes,strSize) != TCL_OK ) {
return TCL_ERROR;
}
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only write one column at a time", TCL_STATIC);
return TCL_ERROR;
}
/*
* Get the Row range parameter
*/
argStr = Tcl_GetStringFromObj( argv[5], NULL );
numRange =fitsParseRangeNum(argStr)+1;
range =(int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange(argStr,&numRange,range,numRange,
1, curFile->CHDUInfo.table.numRows,errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
if( numRange != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only write one row range at a time", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetLongFromObj(curFile->interp,argv[4],&fElem) != TCL_OK ) {
return TCL_ERROR;
}
if ( Tcl_ListObjGetElements( curFile->interp, argv[6],
&nElem, &dataElems ) != TCL_OK ) {
return TCL_ERROR;
}
if( varSaveToTable(curFile,
colNums[0],
range[0],
fElem,
range[1]-range[0]+1,
(long)nElem,
dataElems ) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "ihd", cmd ) ) {
/* Write Image Header */
int isPrimary;
if ( argc < 4 || argc > 7 ) {
Tcl_SetResult(curFile->interp, putIhdList, TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp( ARGV_STR(3), "-p" ) ) {
isPrimary = 1;
} else {
isPrimary = 0;
}
args = (char **) ckalloc( argc * sizeof(char *) );
for( i=0; iinterp, putAhdList, TCL_STATIC);
return TCL_ERROR;
}
/* Strip out the numCols[4] parameter... use colNames length instead */
for( j=0,i=3; i<11; i++ ) {
if( i!=4 )
newArg[j++] = ARGV_STR(i);
}
if( fitsPutReqKwds(curFile, 0, ASCII_TBL, 7, (char **)newArg)
!= TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "bhd", cmd ) ) {
/* Write Binary Table Header */
char const *newArg[5];
int j;
if( argc != 9 ) {
Tcl_SetResult(curFile->interp, putBhdList, TCL_STATIC);
return TCL_ERROR;
}
/* Strip out the numCols[4] parameter... use colNames length instead */
for( j=0,i=3; i<9; i++ ) {
if( i!=4 )
newArg[j++] = ARGV_STR(i);
}
if( fitsPutReqKwds(curFile, 0, BINARY_TBL, 5, (char **)newArg)
!= TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "Unknown put function", TCL_STATIC);
return TCL_ERROR;
}
if (range) free(range);
return TCL_OK;
}
/******************************************************************
* Insert
******************************************************************/
int fitsTcl_insert( FitsFD *curFile, int argc, char *const argv[] )
{
static char *insertList[] = {
"insert keyword index record ?formatflag?",
"insert column index colName colForm",
"insert row index numRows",
"insert image ?-p? ?bitpix naxis naxesList? \n"
" - -p primary extension, keywords optional if empty array",
"insert table numRows {colNames} {colForms} ?{colUnits} extname?\n"
" - colForm: nL(logical),nX(bit), nI(16 bit integer), "
"nJ(32 bit integer)\n"
" nA(Character), nE(Single), nD(Double), nB(Unsigned) \n"
" nC(Complex), M(Double complex) \n"
"insert table -ascii numRows {colNames} {colForms} ?{colUnits}\n"
" {tbCols} extname rowWidth?\n"
" - colForm: L(logical), X(bit), I(16 bit integer), "
"J(32 bit integer)\n"
" An(n Character), En(Single with n format), \n"
" Dn(Double with n format), B(Unsigned) \n"
" C(Complex), M(Double complex) " };
int index, format, numRows, i;
if( argc == 2 ) {
Tcl_AppendResult(curFile->interp,
"Available commands:\n",
insertList[0], "\n",
insertList[1], "\n",
insertList[2], "\n",
insertList[3], "\n",
insertList[4], "\n",
(char *)NULL);
return TCL_ERROR;
}
if( !strcmp( "keyword", argv[2] ) ) {
if( argc < 5 || argc > 6 ) {
Tcl_SetResult(curFile->interp, insertList[0], TCL_STATIC);
return TCL_OK;
}
if( Tcl_GetInt(curFile->interp, argv[3], &index) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get integer index", TCL_STATIC);
return TCL_ERROR;
}
if( argc==6 ) {
if ( Tcl_GetInt(curFile->interp, argv[5], &format) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get integer format flag", TCL_STATIC);
return TCL_ERROR;
}
} else {
format = 1;
}
if( fitsInsertKwds(curFile, index, argv[4], format) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "column", argv[2] ) ) {
if (argc != 6 ) {
Tcl_SetResult(curFile->interp, insertList[1], TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[3], &index) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get integer index", TCL_STATIC);
return TCL_ERROR;
}
if( addColToTable(curFile,index,argv[4],argv[5]) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "row", argv[2] ) ) {
if( argc != 5 ) {
Tcl_SetResult(curFile->interp, insertList[2], TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[3], &index) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get integer index", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[4], &numRows) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get integer numRows", TCL_STATIC);
return TCL_ERROR;
}
if( addRowToTable(curFile,index-1,numRows) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "image", argv[2] ) ) {
/* Write Image Header */
int isPrimary;
if ( argc < 4 || argc > 7 ) {
Tcl_SetResult(curFile->interp, insertList[3], TCL_STATIC);
return TCL_ERROR;
}
/*
* Strip off the "-p" flag if present...
*/
if( !strcmp(argv[3],"-p") ) {
isPrimary = 1;
} else {
isPrimary = 0;
}
if( fitsPutReqKwds(curFile, isPrimary, IMAGE_HDU,
argc-3-isPrimary, argv+3+isPrimary)
!=TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp( "table", argv[2] ) ) {
/* Write Table Header */
int tabType;
if( argc>3 && !strcmp( "-ascii", argv[3] ) ) {
tabType = ASCII_TBL;
if( argc < 7 || argc > 11 ) {
Tcl_SetResult(curFile->interp, insertList[4], TCL_STATIC);
return TCL_ERROR;
}
} else {
tabType = BINARY_TBL;
if( argc < 6 || argc > 8 ) {
Tcl_SetResult(curFile->interp, insertList[4], TCL_STATIC);
return TCL_ERROR;
}
}
if( fitsPutReqKwds(curFile, 0, tabType,
argc-3-(tabType==ASCII_TBL?1:0),
argv+3+(tabType==ASCII_TBL?1:0))
!= TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "No such insert command", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Select
******************************************************************/
int fitsTcl_select( FitsFD *curFile, int argc, char *const argv[] )
{
static char *selRowList =
"select rows -expr expression firstrow nrow\n ";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int fRow, nRows;
char * row_status;
long n_good_rows;
int i;
char result[32];
Tcl_Obj *valObj, *listObj;
if( argc == 2 ) {
Tcl_AppendResult(curFile->interp, selRowList,(char *) NULL);
return TCL_OK;
}
if( !strcmp("rows", argv[2]) ) {
if( argc != 7 ) {
Tcl_SetResult(curFile->interp, selRowList, TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp("-expr", argv[3]) ) {
if( Tcl_GetInt(curFile->interp, argv[5], &fRow) != TCL_OK ) {
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[6], &nRows) != TCL_OK ) {
return TCL_ERROR;
}
row_status = (char*) malloc((nRows+1)*sizeof(char));
listObj = Tcl_NewObj();
if( fitsSelectRowsExpr(curFile, argv[4], fRow,nRows, &n_good_rows,row_status) == TCL_OK ) {
/* for ( i=0 ; i< nRows; i++ ) {
# if ( row_status[i] == 1 ) {
# sprintf(result,"%d",i+fRow);
# Tcl_AppendElement(curFile->interp,result);
# }
# }*/
if (n_good_rows ) {
for (i=0; i < nRows; i++) {
if ( row_status[i] == 1 ) {
valObj = Tcl_NewLongObj( i+fRow );
Tcl_ListObjAppendElement( curFile->interp, listObj, valObj);
}
}
Tcl_SetObjResult( curFile->interp, listObj);
}
}
else {
if(row_status) free(row_status);
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, selRowList, TCL_STATIC);
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp,
"Unrecognized option to select", TCL_STATIC);
return TCL_ERROR;
}
if(row_status) free(row_status);
return TCL_OK;
}
/******************************************************************
* Delete
******************************************************************/
int fitsTcl_delete( FitsFD *curFile, int argc, char *const argv[] )
{
static char *delKeyList =
"delete keyword KeyList\n"
" (KeyList can be a mix of keyword names and keyword numbers\n";
static char *delHduList =
"delete chdu\n";
static char *delTabList =
"delete cols colList\n ";
static char *delRowList =
"delete rows -expr expression\n "
"delete rows -range rangelist\n "
"delete rows firstRow numRows\n ";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int fRow, nRows;
if( argc == 2 ) {
Tcl_AppendResult(curFile->interp, delKeyList, delHduList, delTabList,
delRowList, (char *) NULL);
return TCL_OK;
}
if( !strcmp("keyword", argv[2]) ) {
if( argc != 4 ) {
Tcl_SetResult(curFile->interp, delKeyList, TCL_STATIC);
return TCL_ERROR;
}
if( fitsDeleteKwds(curFile, argv[3] ) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("cols", argv[2]) ) {
if( argc != 4 ) {
Tcl_SetResult(curFile->interp, delTabList, TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile,argv[3],
&numCols,colNums,colTypes,strSize) != TCL_OK )
return TCL_ERROR;
if( fitsDeleteCols(curFile, colNums, numCols) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("rows", argv[2]) ) {
if( argc != 5 ) {
Tcl_SetResult(curFile->interp, delRowList, TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp("-expr", argv[3]) ) {
if( fitsDeleteRowsExpr(curFile, argv[4]) != TCL_OK ) {
return TCL_ERROR;
}
} else if (!strcmp("-range", argv[3]) ) {
if( fitsDeleteRowsRange(curFile, argv[4]) != TCL_OK ) {
return TCL_ERROR;
}
}
else {
if( Tcl_GetInt(curFile->interp, argv[3], &fRow) != TCL_OK ) {
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[4], &nRows) != TCL_OK ) {
return TCL_ERROR;
}
if( fitsDeleteRows(curFile, fRow, nRows) != TCL_OK ) {
return TCL_ERROR;
}
}
} else if( !strcmp("chdu", argv[2]) ) {
if( argc != 3 ) {
Tcl_SetResult(curFile->interp, delHduList, TCL_STATIC);
return TCL_ERROR;
}
if( fitsDeleteCHdu(curFile) != TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp,
"Unrecognized option to delete", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Load
******************************************************************/
int fitsTcl_load( FitsFD *curFile, int argc, char *const argv[] )
{
static char *loadList = "\n"
"load arrayRow colName ?defaultNull? ?firstElement? - Load a row\n"
"load column colName ?defaultNull? ?firstElement? - Load a column\n"
"load vtable colName - Load all elements of a vector column into memory\n"
"load tblock arrayName colList firstRow numRows colIndex ?felem?\n"
" - load a chunk of table and set up an array \"arrayName\"\n"
" with indices of (colIndex-1,firstRow-1), etc \n"
"load copyto filename taget\n"
"load image ?slice? ?rotate? - Load a 2D slice of an image into memory\n"
" (rotate: number of 90deg ccw rotations to perform)\n"
"load irows firstRow lastRow ?slice? - load mean value of rows\n"
"load icols firstCol lastCol ?slice? - load mean value of columns\n"
"load iblock arrayName firstRow numRows fitsCol numCols ?slice?\n"
" - load 2d image slice into an array or memory\n"
" if arrayName is --, then a pointer is returned\n"
"load expr expression ?defaultNull?\n"
"load keyword - load the header of CHDU into a hash table \n"
"load chdu - load the CHDU (useful if you move to the CHDU with -s,\n"
" which does't load the HDUInfo) \n";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int fRow, nRows;
int fCol, felem=1;
fitsfile *infptr, *outfptr; /* FITS file pointers defined in fitsio.h */
int status = 0, ii = 1, iteration = 0, single = 0, hdupos;
int hdutype, bitpix, bytepix, naxis = 0, nkeys, datatype = 0, anynul;
long naxes[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
long first, totpix = 0, npix;
double *array, bscale = 1.0, bzero = 0.0, nulval = 0.;
char card[81];
int i, j;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, loadList, TCL_STATIC);
return TCL_OK;
}
if( !strcmp("keyword", argv[2]) ) {
/* Now LOAD the kwds hash table... */
if( fitsLoadKwds(curFile) != TCL_OK ) {
fitsCloseFile((ClientData) curFile);
return TCL_ERROR;
}
} else if( !strcmp("irows", argv[2]) ) {
long slice;
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 5 ) {
Tcl_SetResult(curFile->interp,
"FitsHandle load irows firstRow lastRows ?slice?",
TCL_STATIC);
return TCL_ERROR;
}
if( argc == 5 ) {
slice = 1;
} else {
slice = atol(argv[5]);
}
if( imageRowsMeanToPtr(curFile,
atol(argv[3]), /* first row */
atol(argv[4]), /* last row*/
slice ) != TCL_OK ) {
Tcl_AppendResult(curFile->interp,
"fitsTcl Error: cannot load irows", NULL);
return TCL_ERROR;
}
} else if( !strcmp("icols", argv[2]) ) {
long slice;
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 5 ) {
Tcl_SetResult(curFile->interp,
"FitsHandle load icols firstCol lastCols ?slice?",
TCL_STATIC);
return TCL_ERROR;
}
if( argc == 5 ) {
slice = 1;
} else {
slice = atol(argv[5]);
}
if( imageColsMeanToPtr(curFile, atol(argv[3]),
atol(argv[4]), slice) != TCL_OK ) {
Tcl_AppendResult(curFile->interp,
"\nfitsTcl Error: cannot load icols",
NULL);
return TCL_ERROR;
}
} else if( !strcmp("iblock", argv[2]) ) {
char *varName="\0";
LONGLONG slice = 1;
LONGLONG cslice = 1;
if ( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 8 || argc > 10 ) {
Tcl_SetResult(curFile->interp,
"FitsHandle load iblock varName firstRow numRows "
"firstCol numCols ?slice?", TCL_STATIC);
return TCL_ERROR;
}
if( argc > 8 )
slice = atoll(argv[8]);
if( argc > 9 )
cslice = atoll(argv[9]);
if( strcmp( argv[3], "--" ) )
varName = argv[3];
if( imageBlockLoad(curFile, varName, atoll(argv[4]),
atoll(argv[5]), atoll(argv[6]),
atoll(argv[7]), slice, cslice )
!= TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("tblock", argv[2]) ) {
int format=1;
int idx;
int varIdx;
if ( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if (argc < 8 || argc > 11) {
Tcl_SetResult(curFile->interp,
"Usage: load tblock ?-noformat? arrayName colList "
"firstRow numRows firstCol ?felem?", TCL_STATIC);
return TCL_ERROR;
}
idx = 3;
if( !strcmp("-noformat", argv[idx]) ) {
idx++;
format=0;
}
varIdx = idx++;
/* parse column list */
if( fitsTransColList( curFile,argv[idx++],
&numCols,colNums,colTypes,strSize) != TCL_OK )
return TCL_ERROR;
/* get the firstRow and numRows */
if( Tcl_GetInt(curFile->interp, argv[idx++], &fRow) != TCL_OK )
return TCL_ERROR;
if( Tcl_GetInt(curFile->interp, argv[idx++], &nRows) != TCL_OK )
return TCL_ERROR;
if( Tcl_GetInt(curFile->interp, argv[idx++], &fCol) != TCL_OK )
return TCL_ERROR;
/* Skip a possible obsolete value between fCol and last argument */
if( argc>idx ) { /* Read felem from very last argument */
if( Tcl_GetInt(curFile->interp, argv[argc-1], &felem) != TCL_OK )
return TCL_ERROR;
}
if( tableBlockLoad(curFile, argv[varIdx], felem, fRow, nRows,
fCol, numCols, colNums, format) != TCL_OK )
return TCL_ERROR;
} else if( !strcmp("image", argv[2]) ) {
long slice = 1;
int rotate = 0;
if ( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not an image", TCL_STATIC);
return TCL_ERROR;
}
/* starting element, increment of naxisn[0] x naxisn[1]
to get different frames of a 3d image */
if( argc == 3 ) {
; /* default to the first frame to allow backward compatible */
} else if( curFile->CHDUInfo.image.naxes <= 2 ) {
; /* two-d image */
} else {
slice = atol(argv[3]);
if( slice < 1 ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: slice starts at 1", TCL_STATIC);
return TCL_ERROR;
}
/*
if( slice > curFile->CHDUInfo.image.naxisn[2] ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: slice exceeds the 3rd dim",
TCL_STATIC);
return TCL_ERROR;
}
*/
if( argc == 5 ) {
rotate = atoi(argv[4]);
if( rotate<0 || rotate>3 ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Illegal rotate value",
TCL_STATIC);
return TCL_ERROR;
}
}
}
if( imageGetToPtr(curFile, slice, rotate) != TCL_OK ) {
return TCL_ERROR;
}
} else if( !strcmp("copyto", argv[2]) ) {
/* Open the input file and create output file */
fits_open_file(&infptr, argv[3], READONLY, &status);
fits_create_file(&outfptr, argv[4], &status);
if (status != 0) {
fits_report_error(stderr, status);
return(status);
}
fits_get_hdu_num(infptr, &hdupos); /* Get the current HDU position */
/* Copy only a single HDU if a specific extension was given */
if (hdupos != 1 || strchr(argv[3], '[')) single = 1;
for (; !status; hdupos++) /* Main loop through each extension */
{
fits_get_hdu_type(infptr, &hdutype, &status);
if (hdutype == IMAGE_HDU) {
/* get image dimensions and total number of pixels in image */
for (ii = 0; ii < 9; ii++)
naxes[ii] = 1;
fits_get_img_param(infptr, 9, &bitpix, &naxis, naxes, &status);
totpix = naxes[0] * naxes[1] * naxes[2] * naxes[3] * naxes[4]
* naxes[5] * naxes[6] * naxes[7] * naxes[8];
}
if (hdutype != IMAGE_HDU || naxis == 0 || totpix == 0) {
/* just copy tables and null images */
fits_copy_hdu(infptr, outfptr, 0, &status);
} else {
/* Explicitly create new image, to support compression */
fits_create_img(outfptr, bitpix, naxis, naxes, &status);
/* copy all the user keywords (not the structural keywords) */
fits_get_hdrspace(infptr, &nkeys, NULL, &status);
for (ii = 1; ii <= nkeys; ii++) {
fits_read_record(infptr, ii, card, &status);
if (fits_get_keyclass(card) > TYP_CMPRS_KEY)
fits_write_record(outfptr, card, &status);
}
switch(bitpix) {
case BYTE_IMG:
datatype = TBYTE;
break;
case SHORT_IMG:
datatype = TSHORT;
break;
case LONG_IMG:
datatype = TLONG;
break;
case FLOAT_IMG:
datatype = TFLOAT;
break;
case DOUBLE_IMG:
datatype = TDOUBLE;
break;
case LONGLONG_IMG:
datatype = TLONGLONG;
break;
}
bytepix = abs(bitpix) / 8;
npix = totpix;
iteration = 0;
/* try to allocate memory for the entire image */
/* use double type to force memory alignment */
array = (double *) calloc(npix, bytepix);
/* if allocation failed, divide size by 2 and try again */
while (!array && iteration < 10) {
iteration++;
npix = npix / 2;
array = (double *) calloc(npix, bytepix);
}
if (!array) {
fprintf(stdout,"Memory allocation error\n");
return(0);
}
/* turn off any scaling so that we copy the raw pixel values */
fits_set_bscale(infptr, bscale, bzero, &status);
fits_set_bscale(outfptr, bscale, bzero, &status);
first = 1;
while (totpix > 0 && !status)
{
/* read all or part of image then write it back to the output file */
fits_read_img(infptr, datatype, first, npix,
&nulval, array, &anynul, &status);
fits_write_img(outfptr, datatype, first, npix, array, &status);
totpix = totpix - npix;
first = first + npix;
}
free(array);
}
if (single) break; /* quit if only copying a single HDU */
fits_movrel_hdu(infptr, 1, NULL, &status); /* try to move to next HDU */
}
if (status == END_OF_FILE) status = 0; /* Reset after normal error */
fits_close_file(outfptr, &status);
fits_close_file(infptr, &status);
} else if( !strcmp("arrayRow", argv[2]) ) {
char *nullPtr = "NULL";
long rowNum;
long nelem;
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 4 || argc > 8 ) {
Tcl_SetResult(curFile->interp,
"fitsObj load arrayRow colName rowNumber numElement ?nulValue? ?firstelem?",
TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile, argv[3],
&numCols, colNums, colTypes, strSize ) != TCL_OK )
return TCL_ERROR;
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only load one column at a time", TCL_STATIC);
return TCL_ERROR;
}
rowNum = atol(argv[4]);
nelem = atol(argv[5]);
if( argc>6 )
nullPtr = argv[6];
if( argc>7 )
felem = atol(argv[7]);
if( tableRowGetToPtr(curFile, rowNum, colNums[0], nelem, nullPtr, felem) ) {
return TCL_ERROR;
}
} else if( !strcmp("column", argv[2]) ) {
char *nullPtr = "NULL";
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 4 || argc > 6 ) {
Tcl_SetResult(curFile->interp,
"load column colName ?nulValue? ?firstelem?",
TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile, argv[3],
&numCols, colNums, colTypes, strSize ) != TCL_OK )
return TCL_ERROR;
if( numCols != 1 ) {
Tcl_SetResult(curFile->interp,
"Can only load one column at a time", TCL_STATIC);
return TCL_ERROR;
}
if( argc>4 )
nullPtr = argv[4];
if( argc>5 )
felem = atol(argv[5]);
if( tableGetToPtr(curFile, colNums[0], nullPtr, felem) ) {
return TCL_ERROR;
}
} else if( !strcmp("vtable", argv[2]) ) {
char *nullPtr = "NULL";
if ( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( argc < 4 || argc > 5 ) {
/* For backwards compatibility, allow for one extra parameter */
/* ... formerly the vector size of column */
/* PDW 12/06/99: Sacrifice backwards compat for adding defNull*/
Tcl_SetResult(curFile->interp,
"load vtable colName ?nulValue?", TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile,argv[3],
&numCols,colNums,colTypes,strSize) != TCL_OK )
return TCL_ERROR;
if( numCols != 1 ) {
Tcl_SetResult( curFile->interp,
"Can only load one column at a time", TCL_STATIC );
return TCL_ERROR;
}
if( argc>4 )
nullPtr = argv[4];
if( vtableGetToPtr(curFile, colNums[0], nullPtr) ) {
return TCL_ERROR;
}
} else if( !strcmp("expr", argv[2]) ) {
char *nullPtr = "NULL", errMsg[256];
int numRange, *range=NULL;
int argOff=0;
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp,
"Current extension is not a table", TCL_STATIC);
return TCL_ERROR;
}
if( !strcmp("-rows", argv[3]) && argc>4 ) {
numRange = fitsParseRangeNum(argv[4])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange(argv[4],&numRange,range,numRange,
1, curFile->CHDUInfo.table.numRows,errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
argOff = 2;
} else {
numRange = 1;
range = (int*) malloc(numRange*2*sizeof(int));
range[0] = 1;
range[1] = curFile->CHDUInfo.table.numRows;
}
if( argc < 4+argOff || argc-argOff > 5+argOff ) {
Tcl_SetResult(curFile->interp,
"Usage: load expr ?-rows range? exprStr ?nullVal?",
TCL_STATIC);
return TCL_ERROR;
}
if( argc > 4+argOff )
nullPtr = argv[4+argOff];
if( exprGetToPtr( curFile, argv[3+argOff], nullPtr, numRange, range ) ) {
return TCL_ERROR;
}
} else if( !strcmp("all", argv[2]) || !strcmp("chdu", argv[2]) ) {
/* load the current hdu */
if( fitsUpdateCHDU(curFile, curFile->hduType) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot update current HDU",
TCL_STATIC);
return TCL_ERROR;
}
if( fitsLoadHDU(curFile) != TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp,
"Error in fitsTcl: unknown load function", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Free
******************************************************************/
int fitsTcl_free( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
void *databuff;
Tcl_Obj **addList;
char *addStr;
int nAdd;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp,
"free addressList",
TCL_STATIC);
return TCL_OK;
}
if( argc>4 ) {
Tcl_SetResult(curFile->interp, "Too many arguments to free",
TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_ListObjGetElements(curFile->interp, argv[argc-1], &nAdd, &addList)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot parse the address list", TCL_STATIC);
return TCL_ERROR;
}
while( nAdd-- ) {
databuff = NULL;
addStr = Tcl_GetStringFromObj( addList[nAdd], NULL );
sscanf(addStr,PTRFORMAT,&databuff);
if ( databuff == NULL) {
Tcl_SetResult(curFile->interp,
"Error interpretting pointer address", TCL_STATIC);
return TCL_ERROR;
}
ckfree( (char *) databuff);
}
return TCL_OK;
}
/******************************************************************
* Flush
******************************************************************/
int fitsTcl_flush( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
int status = 0;
if ( argc == 2 ) {
ffflsh(curFile->fptr, 0, &status);
} else if( argc == 3 ) {
char *opt;
opt = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp(opt, "clear") ) {
ffflsh(curFile->fptr, 1, &status);
} else {
Tcl_SetResult(curFile->interp, "fitsFile flush ?clear?", TCL_STATIC);
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "fitsFile flush ?clear?", TCL_STATIC);
return TCL_ERROR;
}
if( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot flush file\n", TCL_STATIC);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Copy
******************************************************************/
int fitsTcl_copy( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *copyList = "\n"
"copy filename\n";
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, copyList, TCL_STATIC);
return TCL_OK;
}
if( fitsCopyCHduToFile(curFile, Tcl_GetStringFromObj( argv[2], NULL ) )
!= TCL_OK ) {
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Sascii
******************************************************************/
int fitsTcl_sascii( FitsFD *curFile, int argc, char *const argv[] )
{
static char *sasciiList =
"sascii table filename fileMode firstRow numRows colList widthList\n"
" ifFixedFormat ifCSV ifPrintRow sepString\n"
"sascii image filename fileMode firstRow numRows firstCol\n"
" numCols cellSize ifCSV ifPrintRow sepString ?slice?\n";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int fRow, nRows;
int fCol, nCols, nWdths;
int cellSize, i, baseColNum, ifVariableVec;
int ifCSV, ifPrintRow, ifFixedFormat;
char *sepString;
char **listWid;
char *errMsg;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, sasciiList, TCL_STATIC);
return TCL_OK;
}
if( !strcmp("table", argv[2]) ){
if( argc < 13 || argc > 14 ) {
Tcl_SetResult(curFile->interp,
"Wrong # of args to 'sascii table'", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[5], &fRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot get first row", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[6], &nRows) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot get number of rows", TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile,argv[7],
&numCols,colNums,colTypes,strSize) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot parse the column list", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_SplitList(curFile->interp, argv[8], &nWdths, &listWid)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot parse the width list", TCL_STATIC);
ckfree( (char*)listWid );
return TCL_ERROR;
}
if( nWdths != numCols ) {
Tcl_SetResult(curFile->interp, "Cell width array and Column list have different sizes", TCL_STATIC);
ckfree( (char*)listWid );
return TCL_ERROR;
}
for( i=0; i< numCols; i++ ) {
if( Tcl_GetInt(curFile->interp, listWid[i], strSize+i) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Unable to parse the width list", TCL_STATIC);
ckfree( (char*)listWid );
return TCL_ERROR;
}
}
ckfree( (char*)listWid );
if( Tcl_GetInt(curFile->interp, argv[9], &ifFixedFormat) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot get ifFixedFormat", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[10], &ifCSV) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot get ifCSV", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[11], &ifPrintRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot get ifPrintRow", TCL_STATIC);
return TCL_ERROR;
}
if( saveTableToAscii( curFile, argv[3], argv[4], 1, fRow, nRows,
numCols, colTypes, colNums, strSize,
ifFixedFormat, ifCSV, ifPrintRow, argv[12]) )
return TCL_ERROR;
} else if( !strcmp("image", argv[2]) ) {
long slice = 1;
if( argc < 13 || argc > 14 ) {
Tcl_SetResult(curFile->interp,
"Wrong # of args to 'sascii image'", TCL_STATIC);
return TCL_ERROR;
}
if( argc == 14 )
slice = atol(argv[13]);
if( Tcl_GetInt(curFile->interp, argv[5], &fRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get first row", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[6], &nRows) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get number of rows", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[7], &fCol) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get first column", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[8], &nCols) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get number of columns", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[9], &cellSize) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get cellSize", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[10], &ifCSV) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get ifCSV", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[11], &ifPrintRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get ifPrintRow", TCL_STATIC);
return TCL_ERROR;
}
/*
do error checking later
sepString = argv[12];
*/
if( saveImageToAscii( curFile, argv[3], argv[4], fRow, nRows,
fCol, nCols, cellSize,
ifCSV, ifPrintRow, argv[12], slice ) )
return TCL_ERROR;
} else if( !strcmp("vector", argv[2]) ) {
ifVariableVec = atol(argv[13]);
if( Tcl_GetInt(curFile->interp, argv[5], &fRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get first row", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[6], &nRows) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get number of rows", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[7], &fCol) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get first column", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[8], &nCols) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get number of columns", TCL_STATIC);
return TCL_ERROR;
}
if( fitsTransColList( curFile,argv[9],
&numCols,colNums,colTypes,strSize) != TCL_OK ) {
Tcl_SetResult(curFile->interp, "Cannot parse the column list", TCL_STATIC);
return TCL_ERROR;
}
/* 1-based */
baseColNum = colNums[0];
if( Tcl_GetInt(curFile->interp, argv[10], &ifCSV) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get ifCSV", TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[11], &ifPrintRow) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot get ifPrintRow", TCL_STATIC);
return TCL_ERROR;
}
/*
do error checking later
sepString = argv[12];
*/
if( saveVectorTableToAscii( curFile, argv[3], argv[4], fRow, nRows,
fCol, nCols, baseColNum,
ifCSV, ifPrintRow, argv[12], ifVariableVec ) )
return TCL_ERROR;
} else {
Tcl_SetResult(curFile->interp,
"Unknown sascii command", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Sort
******************************************************************/
int fitsTcl_sort( FitsFD *curFile, int argc, char *const argv[] )
{
static char *sortList =
"sort ?-merge? colNameList ?isAscendFlagList? \n";
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int i;
int *isAscend;
char *const *argPtr;
char **listPtr;
int listNum;
int isMerge = 0;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, sortList, TCL_STATIC);
return TCL_OK;
}
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp, "Cannot sort an image", TCL_STATIC);
return TCL_ERROR;
}
argc -= 2;
argPtr = argv + 2;
if( !strcmp(argPtr[0], "-merge") ) {
isMerge = 1;
argc --;
argPtr ++;
}
if( fitsTransColList( curFile,argPtr[0],
&numCols,colNums,colTypes,strSize) != TCL_OK ) {
return TCL_ERROR;
}
isAscend = (int *) ckalloc(numCols*sizeof(int));
/* if no isAscend specified, set as default ascend */
if (argc == 1) {
for (i=0; i < numCols; i++)
isAscend[i] = 1;
} else {
if( Tcl_SplitList(curFile->interp, argPtr[1],
&listNum, &listPtr) != TCL_OK ) {
ckfree((char *) isAscend);
return TCL_ERROR;
}
if( listNum != numCols ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: number of flags and columns don't match",
TCL_STATIC);
ckfree((char *) isAscend);
ckfree((char *) listPtr);
return TCL_ERROR;
}
for (i=0; i< listNum; i++) {
if( Tcl_GetInt(curFile->interp, listPtr[i], &isAscend[i]) != TCL_OK ) {
ckfree((char*) isAscend);
ckfree((char*) listPtr);
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot parse sort flag", TCL_STATIC);
return TCL_ERROR;
}
}
ckfree((char *) listPtr);
}
if( fitsSortTable(curFile, numCols, colNums,
strSize, isAscend, isMerge) != TCL_OK ) {
ckfree ((char *) isAscend);
return TCL_ERROR;
}
ckfree ((char *) isAscend);
return TCL_OK;
}
/******************************************************************
* Add
******************************************************************/
int fitsTcl_add( FitsFD *curFile, int argc, char *const argv[] )
{
static char *addColList =
"add column colName colForm ?expr?\n"
"add column colName colForm ?expr? ?rowrange?\n"
" colForm: e.g.\n"
" ASCII Table: A15, I10, E12.5, D20.10, F14.6 ... \n"
" BINARY Table: 15A, 1I, 1J, 1E, 1D, 1L, 1X, 1B, 1C, 1M\n";
static char *addRowList = "add row numRows\n";
char result[16];
int numCols,colNums[FITS_COLMAX],colTypes[FITS_COLMAX],strSize[FITS_COLMAX];
int numRange,rangeBlock, *range=NULL;
char errMsg[256];
int i,j;
/* range = (int*) malloc(FITS_MAXRANGE*2*sizeof(int)); */
if( argc == 2 ) {
Tcl_AppendResult(curFile->interp, addColList, addRowList, (char*)NULL);
return TCL_OK;
}
if( !strcmp(argv[2], "column") ) {
if( argc == 5 ) {
if( addColToTable(curFile, FITS_COLMAX, argv[3], argv[4])
!= TCL_OK ) {
return TCL_ERROR;
}
} else if( argc >= 6 ) {
char *tmpColName;
int isNew;
strToUpper(argv[3], &tmpColName);
if( fitsTransColList(curFile,tmpColName,
&numCols,colNums,colTypes,strSize) != TCL_OK ) {
/* column name doesn't exist, add a new column*/
isNew = 1;
} else if( numCols == 1 ) {
isNew = 0;
} else {
Tcl_SetResult(curFile->interp,
"Can only add one column at a time", TCL_STATIC);
ckfree((char *) tmpColName);
return TCL_ERROR;
}
ckfree((char *) tmpColName);
/* Feb 2004, Ziqin Pan add */
if( argc >= 7 ) {
numRange = fitsParseRangeNum(argv[6])+1;
range = (int*) malloc(numRange*2*sizeof(int));
if ( fitsParseRange(argv[6],&numRange,range,numRange, 1, curFile->CHDUInfo.table.numRows,errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
return TCL_ERROR;
}
if ( fitsCalculaterngColumn(curFile, argv[3], ( strcmp(argv[4],"default") ? argv[4] : NULL ),
argv[5],numRange,range) != TCL_OK ) {
return TCL_ERROR;
}
} else {
if ( fitsCalculateColumn(curFile, argv[3], ( strcmp(argv[4],"default") ? argv[4] : NULL ),
argv[5]) != TCL_OK ) {
return TCL_ERROR;
}
}
sprintf(result,"%d",isNew);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
} else {
Tcl_SetResult(curFile->interp, addColList, TCL_STATIC);
return TCL_ERROR;
}
} else if( !strcmp(argv[2], "row") ) {
int numRows;
if( argc != 4 ) {
Tcl_SetResult(curFile->interp, addRowList, TCL_STATIC);
return TCL_ERROR;
}
if( Tcl_GetInt(curFile->interp, argv[3], &numRows) != TCL_OK) {
Tcl_SetResult(curFile->interp,
"Failed to get numRows parameter", TCL_STATIC);
return TCL_ERROR;
}
if( addRowToTable(curFile, curFile->CHDUInfo.table.numRows,
numRows) != TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "Unknown add command", TCL_STATIC);
return TCL_ERROR;
}
if (range) free(range);
return TCL_OK;
}
/******************************************************************
* Append
******************************************************************/
int fitsTcl_append( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *appendList = "\n"
"append filename \n"
" -- append the chdu to another file\n";
if( argc < 3 ) {
Tcl_SetResult(curFile->interp, appendList, TCL_STATIC);
return TCL_OK;
}
if( fitsAppendCHduToFile(curFile, Tcl_GetStringFromObj( argv[2], NULL ) )
!= TCL_OK ) {
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Histogram
******************************************************************/
int fitsTcl_histo( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *histoList = "\n"
"histogram ?-weight w? ?-rows rowSpan? filename {col min max bin} ... \n";
int i, j, argNum, nRows;
char *opt;
int numRange, *range=NULL;
char errMsg[256];
Tcl_Obj **binList;
/* Args to ffhist */
fitsfile *fptr;
char *outfile;
int imagetype = TINT;
int naxis;
char colname[4][FLEN_VALUE];
double minin[4];
double maxin[4];
double binsizein[4];
char minname[4][FLEN_VALUE];
char maxname[4][FLEN_VALUE];
char binname[4][FLEN_VALUE];
double weightin;
char wtcol[FLEN_VALUE];
int recip=0;
char *selectrow=NULL;
int status=0;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, histoList, TCL_STATIC);
return TCL_OK;
}
if( curFile->hduType == IMAGE_HDU ) {
Tcl_SetResult(curFile->interp, "Cannot histogram an image", TCL_STATIC);
return TCL_ERROR;
}
/* Zero out all the parameters */
for( i=0; i<4; i++ ) {
colname[i][0] = '\0';
minname[i][0] = '\0'; minin[i] = DOUBLENULLVALUE;
maxname[i][0] = '\0'; maxin[i] = DOUBLENULLVALUE;
binname[i][0] = '\0'; binsizein[i] = DOUBLENULLVALUE;
}
wtcol[0] = '\0';
/* Search for histogram options */
weightin = 1.0;
nRows = curFile->CHDUInfo.table.numRows;
argNum = 2;
do { /* argc guaranteed to be at least 3 */
opt = Tcl_GetStringFromObj( argv[argNum++], NULL );
if( opt[0]!='-' ) break;
if( !strcmp(opt,"-weight") ) {
if( argNum == argc ) {
Tcl_SetResult(curFile->interp, histoList, TCL_STATIC);
if( selectrow ) ckfree( (char*)selectrow );
return TCL_ERROR;
}
if( Tcl_GetDoubleFromObj( curFile->interp, argv[argNum], &weightin )
!= TCL_OK ) {
strcpy( wtcol, Tcl_GetStringFromObj( argv[argNum], NULL ) );
}
imagetype = TFLOAT;
argNum++;
} else if( !strcmp(opt,"-inverse") ) {
recip = 1;
} else if( !strcmp(opt,"-rows") ) {
if( argNum == argc ) {
Tcl_SetResult(curFile->interp, histoList, TCL_STATIC);
if( selectrow ) ckfree( (char*)selectrow );
return TCL_ERROR;
}
opt = Tcl_GetStringFromObj( argv[argNum++], NULL );
numRange = fitsParseRangeNum(opt)+1;
range = (int*) malloc(numRange*2*sizeof(int));
if( fitsParseRange( opt, &numRange, range, numRange,
1, nRows, errMsg)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Error parsing row range:\n", TCL_STATIC);
Tcl_AppendResult(curFile->interp, errMsg, (char*)NULL);
if( selectrow ) ckfree( (char*)selectrow );
return TCL_ERROR;
}
if( numRange>1 || range[0]!=1 || range[1]!=nRows ) {
if( selectrow==NULL ) {
selectrow = (char *)ckalloc( nRows * sizeof(char) );
if( !selectrow ) {
Tcl_SetResult( curFile->interp,
"Unable to allocate row-selection array",
TCL_STATIC );
return TCL_ERROR;
}
for( i=0; i= argc ) {
/* Need at least a filename parameter */
Tcl_SetResult( curFile->interp, histoList, TCL_STATIC );
if( selectrow ) ckfree( (char*)selectrow );
return TCL_ERROR;
}
} while( 1 ); /* Exit by one of breaks... found non option */
/* opt should be pointing to the file name */
outfile = opt;
naxis = argc - argNum;
if( naxis < 1 ) {
if( selectrow ) ckfree( (char*)selectrow );
Tcl_SetResult( curFile->interp, "Missing binning arguments",
TCL_STATIC );
return TCL_ERROR;
}
if( naxis > 4 ) {
if( selectrow ) ckfree( (char*)selectrow );
Tcl_SetResult( curFile->interp, "Histograms are limited to 4 dimensions",
TCL_STATIC );
return TCL_ERROR;
}
/* Parse each of the binning lists */
for( i=0; iinterp, argv[argNum], &j, &binList)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot parse the column binning parameters",
TCL_STATIC);
return TCL_ERROR;
}
if( j!=4 ) {
if( selectrow ) ckfree( (char*)selectrow );
Tcl_SetResult( curFile->interp,
"Binning list should be {colName min max binsize}",
TCL_STATIC );
return TCL_ERROR;
}
/* Get column name */
opt = Tcl_GetStringFromObj( binList[0], &j );
if( jinterp, binList[1], minin+i )
!= TCL_OK ) {
opt = Tcl_GetStringFromObj( binList[1], &j );
if( strcmp(opt,"-") ) {
/* Use supplied keyword name */
if( jinterp, binList[2], maxin+i )
!= TCL_OK ) {
opt = Tcl_GetStringFromObj( binList[2], &j );
if( strcmp(opt,"-") ) {
/* Use supplied keyword name */
if( jinterp, binList[3], binsizein+i )
!= TCL_OK ) {
opt = Tcl_GetStringFromObj( binList[3], &j );
if( strcmp(opt,"-") ) {
/* Use supplied keyword name */
if( jfptr, &fptr, &status );
ffmahd( fptr, curFile->chdu, &j, &status );
ffhist2( &fptr,
outfile,
imagetype,
naxis,
colname,
minin,
maxin,
binsizein,
minname,
maxname,
binname,
weightin,
wtcol,
recip,
selectrow,
&status );
ffclos( fptr, &status );
if (range) free(range);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
Tcl_ResetResult(curFile->interp);
return TCL_OK;
}
/******************************************************************
* Create
******************************************************************/
int fitsTcl_create( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *createList= "\n"
"create 2dhisto filename {colList} {xmin xmax xbin} {ymin ymax ybin} ?rows?\n"
" 1dhisto filename {colList} {xmin xmax xbin} ?row?\n"
" (DEPRECATED) Use 'objName histogram' command instead\n";
Tcl_Obj *newCmd[10];
int newArgc, nelem, naxes, i;
char *opt;
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, createList, TCL_STATIC);
return TCL_OK;
}
opt = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp("dhisto", opt+1) ) {
naxes = *opt - '0';
if( argc < 5 + naxes ) {
Tcl_SetResult(curFile->interp, "Wrong # of args to 'create ndhisto'",
TCL_STATIC);
return TCL_ERROR;
}
newArgc=0;
newCmd[newArgc++] = argv[0];
newCmd[newArgc++] = Tcl_NewStringObj("histogram",-1);
/* Look for a row span */
if ( argc > 5 + naxes) {
newCmd[newArgc++] = Tcl_NewStringObj("-rows",-1);
newCmd[newArgc++] = argv[argc-1];
}
/* Look for a weight argument */
Tcl_ListObjLength( curFile->interp, argv[4], &nelem );
if( nelemnaxes+1 ) {
Tcl_SetResult(curFile->interp, "Need 2-3 columns to produce histogram",
TCL_STATIC);
return TCL_ERROR;
}
if( nelem==naxes+1 ) {
newCmd[newArgc++] = Tcl_NewStringObj("-weight",-1);
Tcl_ListObjIndex( curFile->interp, argv[4], naxes, newCmd+newArgc );
newArgc++;
}
/* Grab filename argument */
newCmd[newArgc++] = argv[3];
/* Build axes bin parameter */
for( i=0; iinterp, argv[5+i], &nelem );
if( nelem != 3 ) {
Tcl_SetResult(curFile->interp,
"Incorrect axis binning parameters",
TCL_STATIC);
return TCL_ERROR;
}
Tcl_ListObjIndex( curFile->interp, argv[4], i, newCmd+newArgc );
newCmd[newArgc] = Tcl_NewListObj(1,newCmd+newArgc);
Tcl_ListObjAppendList( curFile->interp, newCmd[newArgc], argv[5+i] );
newArgc++;
}
if( fitsTcl_histo( curFile, newArgc, newCmd ) != TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "Unknown 'create' command", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Checksum
******************************************************************/
int fitsTcl_checksum( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *checksumList="\n"
"checksum verify\n"
"checksum update\n";
char result[16], *opt;
int datastatus = 0;
int hdustatus = 0;
int status = 0;
if( argc < 3 ) {
Tcl_SetResult(curFile->interp, checksumList, TCL_STATIC);
return TCL_OK;
}
opt = Tcl_GetStringFromObj( argv[2], NULL );
if( !strcmp("verify", opt) ) {
/* verify the checksum keyword. */
/* return 1 OK, 0 checksum keyword not present, -1 wrong */
if( ffvcks(curFile->fptr, &datastatus, &hdustatus, &status) ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
/* Return "minimum" checksum status */
Tcl_SetObjResult(curFile->interp,
Tcl_NewIntObj( hdustatusfptr, &status) ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
if( fitsUpdateFile(curFile) != TCL_OK ) {
return TCL_ERROR;
}
} else {
Tcl_SetResult(curFile->interp, "Unknown checksum option", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/******************************************************************
* Smooth
******************************************************************/
int fitsTcl_smooth( FitsFD *curFile, int argc, Tcl_Obj *const argv[] )
{
static char *smoothList= "\n"
"smooth {width height} filename ?inPrimary? \n";
char *opt;
int status = 0;
int i,j,k,l;
int xwin, ywin;
Tcl_Obj **winList;
int nwin,len;
fitsfile *infptr;
fitsfile *outfptr;
int xd,yd;
int xl,yl,xh,yh;
char outfile[FLEN_FILENAME];
float *data; /* original data */
float *sdata; /* smoothed data */
int ndim;
float nullval = -999; /* null value */
int anynul = 0 ;
int id;
float sum;
int npix;
int bitpix, naxis;
int maxaxis = 4;
long naxes[999];
int canprimary = 0;
int hdunum, hdutype;
char strtemp[FLEN_FILENAME];
/* help */
if( argc == 2 ) {
Tcl_SetResult(curFile->interp, smoothList, TCL_STATIC);
return TCL_OK;
}
if( argc < 4 ) {
Tcl_SetResult(curFile->interp, "Wrong # of args to 'smooth'",
TCL_STATIC);
return TCL_ERROR;
}
if( curFile->hduType != IMAGE_HDU ) {
Tcl_SetResult(curFile->interp, "Cannot smooth a table", TCL_STATIC);
return TCL_ERROR;
}
/* Get the width and height parameters */
if( Tcl_ListObjGetElements(curFile->interp, argv[2], &nwin, &winList)
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot parse the window parameters",
TCL_STATIC);
return TCL_ERROR;
}
if( nwin!=2 ) {
Tcl_SetResult( curFile->interp,
"Window list should be {xwin ywin}",
TCL_STATIC );
return TCL_ERROR;
}
/* Get the width/height parameters */
if( Tcl_GetIntFromObj( curFile->interp, winList[0], &xwin)
!= TCL_OK ) {
Tcl_SetResult( curFile->interp,
"Error reading the width parameter",
TCL_STATIC );
return TCL_ERROR;
}
if (xwin%2 == 0) {
Tcl_SetResult( curFile->interp,
"The width must be a odd number",
TCL_STATIC );
return TCL_ERROR;
}
if( Tcl_GetIntFromObj( curFile->interp, winList[1], &ywin)
!= TCL_OK ) {
Tcl_SetResult( curFile->interp,
"Error reading the height parameter",
TCL_STATIC );
return TCL_ERROR;
}
if (ywin%2 == 0) {
Tcl_SetResult( curFile->interp,
"The height must be a odd number",
TCL_STATIC );
return TCL_ERROR;
}
/* Get the image output file name */
opt = Tcl_GetStringFromObj( argv[3], NULL );
len = strlen(opt);
if( len < FLEN_FILENAME ) {
strcpy(outfile, opt );
} else {
Tcl_SetResult( curFile->interp,
"The length of filename is too long. ",
TCL_STATIC );
return TCL_ERROR;
}
if( argc == 5 ) {
if ( Tcl_GetBooleanFromObj( curFile->interp, argv[4], &canprimary )
!= TCL_OK )
return TCL_ERROR;
}
/* open the input file */
ffreopen( curFile->fptr, &infptr, &status );
ffmahd( infptr, curFile->chdu, &j, &status );
/*get the image parameter */
ffgipr(infptr, maxaxis, &bitpix, &naxis, naxes, &status);
if (naxis < 2 ) {
Tcl_SetResult( curFile->interp,
"The smooth algorithm only supports 2-d images.",
TCL_STATIC );
return TCL_ERROR;
}
for (i = 2; i < naxis; i++) {
if (naxes[i] > 1 ) {
Tcl_SetResult( curFile->interp,
"The smooth algorithm only supports 2-d images.",
TCL_STATIC );
return TCL_ERROR;
}
}
ndim = (int)(naxes[0]*naxes[1]);
data = (float *) ckalloc(ndim*sizeof(float ));
sdata = (float *) ckalloc(ndim*sizeof(float ));
ffgpv(infptr,TFLOAT,1, naxes[0]*naxes[1],&nullval, data, &anynul, &status);
xd = xwin / 2;
yd = ywin / 2;
/* iterate over y */
yl = 0;
yh = yd;
for (i=0; i < naxes[1]; i++) {
/* initialize the kernal for this row */
sum = 0;
npix = 0;
xl = 0;
xh = xd;
for (k = yl; k <= yh; k++) {
for ( l = xl; l <= xh; l++) {
id = k * naxes[0] + l;
if(data[id]!=nullval) {
npix++;
sum += data[id];
}
}
}
/* iterate over x */
for (j = 0; j < naxes[0]; j++) {
id = i*naxes[0]+j;
if(npix == 0) {
sdata[id] = nullval;
} else {
sdata[id] = sum/(float )npix;
}
/* increase the x by 1 */
if(j - xl == xd ) {
for ( k = yl; k <= yh; k++) {
id = k*naxes[0]+xl;
if(data[id]!=nullval) {
npix--;
sum -= data[id];
}
}
xl++;
}
if(xh + 1< naxes[0] ) {
xh++;
for ( k = yl; k <= yh; k++) {
id = k*naxes[0]+xh;
if(data[id]!=nullval) {
npix++;
sum += data[id];
}
}
}
}
/* increase the y by 1 */
if (i - yl == yd ) yl++;
if (yh + 1 < naxes[1]) yh++;
}
/* open the output file */
ffopen(&outfptr, outfile,READWRITE, &status);
if(status == FILE_NOT_OPENED) {
status = 0;
ffinit(&outfptr,outfile,&status);
if(!canprimary)
ffcrim(outfptr,FLOAT_IMG,0,NULL,&status);
} else if (status) {
strcpy(strtemp,"Error opening output file: ");
strcat(strtemp,curFile->fileName);
Tcl_SetResult( curFile->interp,
strtemp,
TCL_STATIC );
return TCL_ERROR;
}
/* ffcrim(outfptr,FLOAT_IMG, naxis, naxes, &status); */
ffcphd(infptr,outfptr,&status);
/* Update keywords */
ffghdn(outfptr, &hdunum);
i = FLOAT_IMG;
ffuky(outfptr,TINT, "BITPIX",&i, NULL, &status);
ffpky(outfptr,TINT, "XWIN",&xwin,"x-width of the smoothing window", &status);
ffpky(outfptr,TINT, "YWIN",&ywin,"y-width of the smoothing window", &status);
strcpy(strtemp,"Smoothed output of the image file: ");
strcat(strtemp,curFile->fileName);
ffpcom(outfptr,strtemp, &status);
/* write data*/
ffppn(outfptr,TFLOAT,1,naxes[0]*naxes[1],sdata,&nullval,&status);
ckfree(data);
ckfree(sdata);
/* close file */
ffclos(infptr,&status);
ffclos(outfptr,&status);
return TCL_OK;
}
fitsTcl/fitsIO.c 0000644 0002307 0000036 00000626660 11222720662 012441 0 ustar chai lhea /*
* fitsIO.c --
*
* This is the file-handling routines which use CFITSIO
*
*/
/*
*------------------------------------------------------------
*
* MODIFICATION HISTORY:
* 2004-02-06 Ziqin Pan:
* Added the following routines:
* 1. fitsSelectRowsExpr
* 2. fitsCalculaterngColumn
* 3. fitsDeleteRowsRange
* 4. fitsDeleteRowlist
* Updated the following routines:
* 1. fitsSortTable:
* return a list of row index which represents
* pre-sorted table row
*
*
*/
#include "fitsTclInt.h"
#include "wcslib/wcstrig.h"
#include
/* on some systems, e.g. linux, SUNs DBL_MAX is in float.h */
#ifndef DBL_MAX
# include
#endif
#ifndef DBL_MIN
# include
#endif
/* ------------------------------------------------------------
*
* fitsMoveHDU --
*
* Given a FitsHD, move nmove.
* If direction = 1, move forward
* = -1, move backwards
* = 0, move absolute
* If there is an error, then exit with status != 0
* (>0 => FITSIO err stat...)
*
* Results:
* Alters the CHDU
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*/
int fitsMoveHDU( FitsFD *curFile,
int nmove,
int direction )
{
if( fitsJustMoveHDU(curFile, nmove, direction) != TCL_OK ) {
return TCL_ERROR;
}
if( fitsLoadHDU(curFile) != TCL_OK ) {
return TCL_ERROR;
}
return TCL_OK;
}
/**************************************************************
* load the table and the rest
**************************************************************/
int fitsLoadHDU( FitsFD *curFile )
{
int i,status=0;
int simple,extend;
long pcount, gcount, rowlen, varidat;
LONGLONG tbcol[FITS_COLMAX];
char tmpStr[80];
char tmpKey[FLEN_KEYWORD];
Tcl_HashEntry *thisEntry;
Keyword *tmpKwd;
char testChar[1024];
char numChar[1024];
char *p, *n;
long len;
/* Now get the Header info for the CHDU */
switch( curFile->hduType ) {
case IMAGE_HDU:
ffghprll(curFile->fptr,
FITS_MAXDIMS,
&simple,
&curFile->CHDUInfo.image.bitpix,
&curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
&pcount, &gcount, &extend, &status);
strcpy(curFile->extname ,"Image");
break;
case ASCII_TBL:
ffghtbll(curFile->fptr,
FITS_COLMAX,
&curFile->CHDUInfo.table.rowLen,
&curFile->CHDUInfo.table.numRows,
&curFile->CHDUInfo.table.numCols,
curFile->CHDUInfo.table.colName,
tbcol,
curFile->CHDUInfo.table.colType,
curFile->CHDUInfo.table.colUnit,
curFile->extname, &status);
break;
case BINARY_TBL:
ffghbnll(curFile->fptr,
FITS_COLMAX,
&curFile->CHDUInfo.table.numRows,
&curFile->CHDUInfo.table.numCols,
curFile->CHDUInfo.table.colName,
curFile->CHDUInfo.table.colType,
curFile->CHDUInfo.table.colUnit,
curFile->extname,
&varidat, &status);
ffgkyj(curFile->fptr,"NAXIS1",&rowlen,
NULL,&status);
curFile->CHDUInfo.table.rowLen = rowlen;
break;
default:
sprintf(tmpStr, "Unrecognized Extension type: %d", curFile->hduType);
Tcl_SetResult(curFile->interp, tmpStr, TCL_VOLATILE);
return TCL_ERROR;
}
/* Now LOAD the kwds hash table... */
if( TCL_OK != fitsLoadKwds(curFile) ) {
fitsCloseFile((ClientData) curFile);
return TCL_ERROR;
}
/*
* Also, search BZERO and BSCALE from keyword hash table for speed
*/
if ( IMAGE_HDU == curFile->hduType ) {
thisEntry = Tcl_FindHashEntry(curFile->kwds, "BZERO");
if ( NULL == thisEntry ) {
curFile->CHDUInfo.image.bzero = 0.0;
curFile->CHDUInfo.image.bzflag = 0;
} else {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
curFile->CHDUInfo.image.bzero = atof( tmpKwd->value );
curFile->CHDUInfo.image.bzflag = 1;
}
thisEntry = Tcl_FindHashEntry(curFile->kwds, "BSCALE");
if ( NULL == thisEntry ) {
curFile->CHDUInfo.image.bscale = 1.0;
curFile->CHDUInfo.image.bsflag = 0;
} else if (status == 0) {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
curFile->CHDUInfo.image.bscale = atof( tmpKwd->value );
curFile->CHDUInfo.image.bsflag = 1;
}
thisEntry = Tcl_FindHashEntry(curFile->kwds, "BLANK");
if ( NULL == thisEntry ) {
strcpy(curFile->CHDUInfo.image.blank, " ");
} else if (status == 0) {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
strcpy(curFile->CHDUInfo.image.blank, tmpKwd->value);
}
} else { /* Table */
for (i=0; i < curFile->CHDUInfo.table.numCols; i++) {
sprintf(tmpKey,"TZERO%d",i+1);
thisEntry = Tcl_FindHashEntry(curFile->kwds, tmpKey);
if ( thisEntry == NULL ) {
curFile->CHDUInfo.table.colTzero[i] = 0.0;
curFile->CHDUInfo.table.colTzflag[i] = 0;
} else {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
curFile->CHDUInfo.table.colTzero[i] = atof(tmpKwd->value);
curFile->CHDUInfo.table.colTzflag[i] = 1;
}
sprintf(tmpKey,"TSCAL%d",i+1);
thisEntry = Tcl_FindHashEntry(curFile->kwds, tmpKey);
if ( thisEntry == NULL ) {
curFile->CHDUInfo.table.colTscale[i] = 1.0;
curFile->CHDUInfo.table.colTsflag[i] = 0;
} else {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
curFile->CHDUInfo.table.colTscale[i] = atof(tmpKwd->value );
curFile->CHDUInfo.table.colTsflag[i] = 1;
}
sprintf(tmpKey,"TDISP%d",i+1);
thisEntry = Tcl_FindHashEntry(curFile->kwds, tmpKey);
if ( thisEntry == NULL ) {
strcpy(curFile->CHDUInfo.table.colDisp[i], " ");
} else {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
strcpy(curFile->CHDUInfo.table.colDisp[i], tmpKwd->value);
}
sprintf(tmpKey,"TNULL%d",i+1);
thisEntry = Tcl_FindHashEntry(curFile->kwds, tmpKey);
if ( thisEntry == NULL ) {
strcpy(curFile->CHDUInfo.table.colNull[i], "NULL");
} else {
tmpKwd = (Keyword *) Tcl_GetHashValue(thisEntry);
strcpy(curFile->CHDUInfo.table.colNull[i], tmpKwd->value);
}
}
}
/* Finally fill the dataType with the translation of the TTYPE keywords...
* and set the variable traces on the columns...
*/
if( IMAGE_HDU == curFile->hduType ) {
switch ( curFile->CHDUInfo.image.bitpix ) {
case 8:
curFile->CHDUInfo.image.dataType = TBYTE;
break;
case 16:
curFile->CHDUInfo.image.dataType = TSHORT;
break;
case 32:
curFile->CHDUInfo.image.dataType = TINT;
break;
case 64:
/* 11/01/2006: added to handle 64 bits fits file */
curFile->CHDUInfo.image.dataType = TLONGLONG;
break;
case -32:
curFile->CHDUInfo.image.dataType = TFLOAT;
break;
case -64:
curFile->CHDUInfo.image.dataType = TDOUBLE;
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: unknown image type", TCL_STATIC);
return TCL_ERROR;
break;
}
/* if BSCALE or BZERO exists, set type to double */
if( curFile->CHDUInfo.image.bzflag ||
curFile->CHDUInfo.image.bsflag ) {
curFile->CHDUInfo.image.dataType = TDOUBLE;
}
} else { /* Table */
for (i = 0; i < curFile->CHDUInfo.table.numCols; i++ ) {
/* judging for TDISP or TTYPE, load the column width and display format
*/
if ( TCL_ERROR == tdispGetFormat(curFile, i) ) {
return TCL_ERROR;
}
/* See if it's a vector column */
if (BINARY_TBL == curFile->hduType) {
if (strchr(curFile->CHDUInfo.table.colType[i],'P')) {
/* need to find the vector size */
curFile->CHDUInfo.table.vecSize[i] = -1;
p = strchr(curFile->CHDUInfo.table.colType[i],'P');
strcpy(testChar, p);
/* find the number after xPA(nnnnnnn) */
n = strpbrk(testChar, "0123456789");
if ( n != (char *)NULL ) {
len = strspn(n, "0123456789");
memset (numChar, '\0', 1024);
strncpy(numChar, n, len);
sscanf (numChar, "%ld", &(curFile->CHDUInfo.table.vecSize[i]));
} else {
curFile->CHDUInfo.table.vecSize[i] = -1;
}
} else {
long tmp=0;
tmp = atol(curFile->CHDUInfo.table.colType[i]);
if (tmp < 1) {
if( curFile->CHDUInfo.table.colType[i][0]=='0' )
curFile->CHDUInfo.table.vecSize[i] = 0;
else
curFile->CHDUInfo.table.vecSize[i] = 1;
} else {
curFile->CHDUInfo.table.vecSize[i] = tmp;
}
}
} else {
curFile->CHDUInfo.table.vecSize[i] = 1;
}
/* init colMin and colMax */
curFile->CHDUInfo.table.colMin[i] = DBL_MIN;
curFile->CHDUInfo.table.colMax[i] = DBL_MAX;
/*
* Now ascertain the colDataType
*/
if ( strchr(curFile->CHDUInfo.table.colType[i],'A')) {
curFile->CHDUInfo.table.colDataType[i] = TSTRING;
} else if (strchr(curFile->CHDUInfo.table.colType[i],'I')) {
if( curFile->CHDUInfo.table.colTzflag[i] ||
curFile->CHDUInfo.table.colTsflag[i] ) {
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else {
/* in an ASCII table, an integer could be a long int */
if ( curFile->hduType == ASCII_TBL ) {
curFile->CHDUInfo.table.colDataType[i] = TLONG;
} else {
curFile->CHDUInfo.table.colDataType[i] = TSHORT;
}
}
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'K')) {
if( curFile->CHDUInfo.table.colTzflag[i] ||
curFile->CHDUInfo.table.colTsflag[i] ) {
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else {
curFile->CHDUInfo.table.colDataType[i] = TLONGLONG;
}
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'J')) {
if( curFile->CHDUInfo.table.colTzflag[i] ||
curFile->CHDUInfo.table.colTsflag[i] ) {
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else {
curFile->CHDUInfo.table.colDataType[i] = TLONG;
}
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'X')) {
curFile->CHDUInfo.table.colDataType[i] = TBIT;
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'L')) {
curFile->CHDUInfo.table.colDataType[i] = TLOGICAL;
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'B')){
if( curFile->CHDUInfo.table.colTzflag[i] ||
curFile->CHDUInfo.table.colTsflag[i] ) {
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else {
curFile->CHDUInfo.table.colDataType[i] = TBYTE;
}
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'E') ||
strchr(curFile->CHDUInfo.table.colType[i],'F') ) {
/* in an ASCII table , a float could be a double */
if ( curFile->hduType == ASCII_TBL ) {
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else {
curFile->CHDUInfo.table.colDataType[i] = TFLOAT;
}
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'D')){
curFile->CHDUInfo.table.colDataType[i] = TDOUBLE;
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'C')){
curFile->CHDUInfo.table.colDataType[i] = TCOMPLEX;
} else if ( strchr(curFile->CHDUInfo.table.colType[i],'M')){
curFile->CHDUInfo.table.colDataType[i] = TDBLCOMPLEX;
} else {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,
"Unknown or unsupported TFORM: ",
curFile->CHDUInfo.table.colType[i],
" for column ",
curFile->CHDUInfo.table.colName[i],
(char*)NULL);
return TCL_ERROR;
}
/*
* Now ascertain the default strSize's of the column
* (Use minimum of 4 to handle "NULL" values)
*/
if( curFile->hduType == BINARY_TBL ) {
switch( curFile->CHDUInfo.table.colDataType[i] ) {
case TSTRING:
/* If it's a variable size vector, it's
format could be 1PA, but it takes more than 1 */
if( strchr(curFile->CHDUInfo.table.colType[i],'P') ) {
p = strchr(curFile->CHDUInfo.table.colType[i],'P');
strcpy(testChar, p);
/* find the number after xPA(nnnnnnn) */
n = strpbrk(testChar, "0123456789");
len = strspn(n, "0123456789");
if ( n != (char *)NULL ) {
memset (numChar, '\0', 1024);
strncpy(numChar, n, len);
sscanf (numChar, "%d", &(curFile->CHDUInfo.table.strSize[i]));
} else {
curFile->CHDUInfo.table.strSize[i] = 80;
}
} else {
sscanf(curFile->CHDUInfo.table.colType[i],
"%dA",&(curFile->CHDUInfo.table.strSize[i]));
if( curFile->CHDUInfo.table.strSize[i] < 4 )
curFile->CHDUInfo.table.strSize[i] = 4;
}
break;
case TLOGICAL:
curFile->CHDUInfo.table.strSize[i] = 4;
break;
case TBIT:
curFile->CHDUInfo.table.strSize[i] = 4;
break;
case TBYTE:
curFile->CHDUInfo.table.strSize[i] = 4;
break;
case TSHORT:
curFile->CHDUInfo.table.strSize[i] = 8;
break;
case TINT:
curFile->CHDUInfo.table.strSize[i] = 12;
break;
case TLONG:
curFile->CHDUInfo.table.strSize[i] = 16;
break;
case TFLOAT:
curFile->CHDUInfo.table.strSize[i] = 16;
break;
case TLONGLONG:
curFile->CHDUInfo.table.strSize[i] = 24;
break;
case TDOUBLE:
curFile->CHDUInfo.table.strSize[i] = 24;
break;
case TCOMPLEX:
curFile->CHDUInfo.table.strSize[i] = 36;
break;
case TDBLCOMPLEX:
curFile->CHDUInfo.table.strSize[i] = 52;
break;
default:
curFile->CHDUInfo.table.strSize[i] = 24;
break;
}
} else { /* ASCII Table... Use actual column width */
if( i+1 < curFile->CHDUInfo.table.numCols )
curFile->CHDUInfo.table.strSize[i] = tbcol[i+1] - tbcol[i];
else
curFile->CHDUInfo.table.strSize[i] =
curFile->CHDUInfo.table.rowLen - tbcol[i] + 1;
if( curFile->CHDUInfo.table.strSize[i] < 4 )
curFile->CHDUInfo.table.strSize[i] = 4;
}
}
}
/* now set the hdu status */
curFile->CHDUInfo.table.loadStatus = 1;
return TCL_OK;
}
/* just move the keyword and clean up all the data struct */
int fitsJustMoveHDU( FitsFD *curFile,
int nmove,
int direction )
{
int status=0;
int newHduType;
char errMsg[80];
/* move to the right hdu */
if ( 1 == direction || -1 == direction ) {
ffmrhd(curFile->fptr,nmove,&newHduType,&status);
} else {
ffmahd(curFile->fptr,nmove,&newHduType,&status);
}
if ( curFile->CHDUInfo.table.loadStatus > 0 ) {
/* clean up the old keywords hash table in the old header */
if ( fitsFlushKeywords(curFile) ) {
Tcl_SetResult(curFile->interp,
"Error dumping altered keywords, proceed with caution",
TCL_STATIC);
}
}
if( status ) {
dumpFitsErrStack(curFile->interp,status);
return TCL_ERROR;
}
/* Should check here to see if you need
to expand the column info blocks... */
if( newHduType != IMAGE_HDU ) {
if( curFile->CHDUInfo.table.numCols > FITS_COLMAX ) {
sprintf(errMsg,"Too many columns in Fits file, MAX is %d",
FITS_COLMAX);
Tcl_SetResult(curFile->interp, errMsg, TCL_VOLATILE);
return TCL_ERROR;
}
}
if( fitsUpdateCHDU(curFile, newHduType) != TCL_OK ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot update CHDU", TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
}
/*
* Update the CHDU
*/
int fitsUpdateCHDU( FitsFD *curFile, int newHduType)
{
/*
* Allocate space for the new CHDUInfo
*/
if(makeNewCHDUInfo(curFile,newHduType) != TCL_OK ) {
return TCL_ERROR;
}
/* reset the load status */
curFile->CHDUInfo.table.loadStatus = 0;
/* Reset the CHDU field */
ffghdn(curFile->fptr,&curFile->chdu);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsLoadKwds --
*
* Loads the keywords from a FitsFD struct.
*
* Results:
* Creates the Hash Table... curFile->kwds
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
int fitsLoadKwds( FitsFD *curFile )
{
int status=0,i,new,nkwds;
Keyword *newKwd;
Tcl_HashEntry *newEntry;
Tcl_HashSearch search;
FitsCardList *comCard,*hisCard;
char Comment[FLEN_COMMENT], Name[FLEN_KEYWORD], Value[FLEN_VALUE];
/* Delete the previous hash Table */
newEntry = Tcl_FirstHashEntry(curFile->kwds,&search);
while ( NULL != newEntry ) {
ckfree((char *) Tcl_GetHashValue(newEntry));
Tcl_DeleteHashEntry(newEntry);
newEntry = Tcl_NextHashEntry(&search);
}
/* Now load the Current one */
if( curFile->CHDUInfo.table.loadStatus != 1 )
curFile->CHDUInfo.table.loadStatus = 2;
curFile->numCom = 0;
curFile->numHis = 0;
hisCard = curFile->hisHead;
comCard = curFile->comHead;
ffghsp(curFile->fptr,&nkwds,&i,&status);
if ( status ) {
dumpFitsErrStack(curFile->interp,status);
return TCL_ERROR;
}
for (i = 1;i <= nkwds; i++ ) {
ffgkyn( curFile->fptr, i, Name, Value, Comment, &status);
if( status ) {
dumpFitsErrStack(curFile->interp,status);
return TCL_ERROR;
}
if( !strcmp(Name,"HISTORY") ) {
if (hisCard->next == NULL ) {
hisCard->next = (FitsCardList *) ckalloc( sizeof (FitsCardList));
if ( hisCard->next == NULL ) {
Tcl_SetResult(curFile->interp,
"Error mallocing space for history card\n",
TCL_STATIC);
fitsCloseFile((ClientData)curFile);
return TCL_ERROR;
}
hisCard = hisCard->next;
hisCard->next = (FitsCardList *) NULL;
hisCard->pos = i;
strcpy(hisCard->value,Comment);
} else {
hisCard = hisCard->next;
hisCard->pos = i;
strcpy(hisCard->value,Comment);
}
curFile->numHis++;
} else if( !strcmp(Name,"COMMENT") ) {
if (comCard->next == NULL ) {
comCard->next = (FitsCardList *) ckalloc( sizeof (FitsCardList));
if ( comCard->next == NULL ) {
Tcl_SetResult(curFile->interp,
"Error mallocing space for comment card\n",
TCL_STATIC);
fitsCloseFile((ClientData)curFile);
return TCL_ERROR;
}
comCard = comCard->next;
comCard->next = (FitsCardList *) NULL;
comCard->pos = i;
strcpy(comCard->value,Comment);
} else {
comCard = comCard->next;
comCard->pos = i;
strcpy(comCard->value,Comment);
}
curFile->numCom++;
} else if( !strcmp(Name, "CONTINUE" ) ) {
} else if( !strcmp(Name, "REFERENC" ) ) {
} else if( !strcmp(Name,"") ) {
} else {
newEntry = Tcl_CreateHashEntry(curFile->kwds,Name,&new);
newKwd = (Keyword *) ckalloc(sizeof(Keyword));
strcpy(newKwd->name,Name);
strcpy(newKwd->value,Value);
strcpy(newKwd->comment,Comment);
newKwd->pos = i;
Tcl_SetHashValue(newEntry,(ClientData) newKwd);
}
}
curFile->numKwds = i;
/*
* Now clean up the remaining comment and history records...
*/
deleteFitsCardList(comCard);
deleteFitsCardList(hisCard);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* deleteFitsCardList --
*
* Takes an element in a Fits Card list, and deletes the rest of the list
* From this element on.
*
* Results:
* Kills the rest of the string, and sets the next of comCard to NULL.
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
void deleteFitsCardList( FitsCardList *comCard )
{
FitsCardList *tmpCard1,*tmpCard2;
tmpCard1 = comCard->next;
comCard->next = (FitsCardList *) NULL;
while ( tmpCard1 ) {
tmpCard2 = tmpCard1->next;
ckfree( (char*)tmpCard1 );
tmpCard1 = tmpCard2;
}
return;
}
/*
* ------------------------------------------------------------
*
* fitsDumpHeader --
*
* Dump the header into a list of strings
*
* Results:
* Returns the result
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
int fitsDumpHeader( FitsFD *curFile )
{
int status,i,nkwds;
char record[FLEN_CARD];
status = 0;
ffghsp(curFile->fptr,&nkwds,&i,&status);
for ( i = 1; i <= nkwds ; i++) {
if( ffgrec(curFile->fptr,i,record,&status) ) {
sprintf(record,"Error dumping header: card #%d\n",i);
Tcl_SetResult(curFile->interp,record,TCL_VOLATILE);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
Tcl_AppendElement(curFile->interp,record);
}
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsDumpHeaderToKV --
*
* Dump the header into a list of keyword and a list to value
*
* Results:
* Returns the result
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
int fitsDumpHeaderToKV( FitsFD *curFile )
{
int status,i,nkwds;
char key[FLEN_KEYWORD];
char val[FLEN_VALUE];
char com[FLEN_COMMENT];
Tcl_DString kList;
Tcl_DString vList;
Tcl_DString cList;
Tcl_DString theList;
Tcl_DStringInit(&theList);
Tcl_DStringInit(&kList);
Tcl_DStringInit(&vList);
Tcl_DStringInit(&cList);
status = 0;
ffghsp(curFile->fptr, &nkwds, &i, &status);
for ( i = 1; i <= nkwds ; i++) {
if( ffgkyn( curFile->fptr, i, key, val, com, &status) ) {
sprintf(key,"Error dumping header: card #%d\n",i);
Tcl_SetResult(curFile->interp, key, TCL_VOLATILE);
dumpFitsErrStack(curFile->interp, status);
Tcl_DStringFree(&kList);
Tcl_DStringFree(&vList);
Tcl_DStringFree(&cList);
return TCL_ERROR;
}
Tcl_DStringAppendElement(&kList, key);
Tcl_DStringAppendElement(&vList, val);
Tcl_DStringAppendElement(&cList, com);
}
Tcl_DStringAppendElement(&theList, Tcl_DStringValue(&kList));
Tcl_DStringAppendElement(&theList, Tcl_DStringValue(&vList));
Tcl_DStringAppendElement(&theList, Tcl_DStringValue(&cList));
Tcl_DStringFree(&kList);
Tcl_DStringFree(&vList);
Tcl_DStringFree(&cList);
Tcl_DStringResult(curFile->interp, &theList);
return TCL_OK;
}
/*
* Just dump the keywords to a TCL list
*/
int fitsDumpKwdsToList( FitsFD *curFile )
{
int status;
int i,nkwds;
char key[FLEN_KEYWORD];
char val[FLEN_VALUE];
Tcl_DString kList;
Tcl_DStringInit(&kList);
status = 0;
ffghsp(curFile->fptr,&nkwds,&i,&status);
for ( i = 1; i <= nkwds ; i++) {
if( ffgkyn( curFile->fptr, i, key, val, NULL, &status) ) {
sprintf(val,"Error dumping header: card #%d\n",i);
Tcl_SetResult(curFile->interp, val, TCL_VOLATILE);
dumpFitsErrStack(curFile->interp, status);
Tcl_DStringFree(&kList);
return TCL_ERROR;
}
Tcl_DStringAppendElement(&kList, key);
}
Tcl_DStringResult(curFile->interp, &kList);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsDumpHeaderToCard --
*
* Dump the header into a list of keyword ended with a new line
*
* Results:
* Returns the result
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*
*/
int fitsDumpHeaderToCard( FitsFD *curFile )
{
int status,i,nkwds;
char record[FLEN_CARD+1];
Tcl_DString theList;
Tcl_DStringInit(&theList);
status = 0;
ffghsp(curFile->fptr,&nkwds,&i,&status);
for ( i = 1; i <= nkwds ; i++ ) {
if( ffgrec(curFile->fptr, i, record, &status) ) {
sprintf(record,"Error dumping header: card #%d\n",i);
Tcl_SetResult(curFile->interp, record, TCL_VOLATILE);
dumpFitsErrStack(curFile->interp, status);
Tcl_DStringFree(&theList);
return TCL_ERROR;
}
strcat(record, "\n");
Tcl_DStringAppend(&theList, record, -1);
}
Tcl_DStringResult(curFile->interp, &theList);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* makeNewCHDUInfo--
*
* This removes the current CHDU structure and replaces it with one
* suitable for an extension of type newHduType. Returns TCL_OK for
* success. If the old CHDUInfo is of the same type as newHduType,
* just return.
*
* Results:
* Deallocates the memory for the previous header type, allocates memory
* for the new type.
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*/
int makeNewCHDUInfo( FitsFD *curFile,
int newHduType )
{
/*
* If the new and old files have the same HDUTYPE, no need to do anything
*/
if(curFile->hduType == newHduType ) {
return TCL_OK;
/*
* If going from IMAGE to anything, wipe all the space, and start over:
* If going from nothing to BINARY or ASCII, skip the freeing:
*/
} else if ( curFile->hduType == IMAGE_HDU ||
(curFile->hduType == NOHDU && newHduType != IMAGE_HDU)) {
/*
* First release the space from the previous header...
*/
if( curFile->hduType != NOHDU ) {
freeCHDUInfo(curFile);
}
curFile->CHDUInfo.table.colName =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colName ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colName", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colType =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colType ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colType", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colDataType =
(int *) makeContigArray(FITS_COLMAX,1,'i');
if( NULL == curFile->CHDUInfo.table.colDataType ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colDataType", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colWidth =
(int *) makeContigArray(FITS_COLMAX,1,'i');
if( NULL == curFile->CHDUInfo.table.colWidth ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colWidth", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colUnit =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colUnit ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colUnit", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colFormat =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colFormat ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colFormat", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colDisp =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colDisp ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colDisp", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colNull =
(char **) makeContigArray(FITS_COLMAX,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.table.colNull ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colNull", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.vecSize =
(long *) makeContigArray(FITS_COLMAX,1,'l');
if( NULL == curFile->CHDUInfo.table.vecSize ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for vecSize", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colTscale =
(double *) makeContigArray(FITS_COLMAX,1,'d');
if( NULL == curFile->CHDUInfo.table.colTscale ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colTscale", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colTzero =
(double *) makeContigArray(FITS_COLMAX,1,'d');
if( NULL == curFile->CHDUInfo.table.colTzero ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colTzero", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colTzflag =
(int *) makeContigArray(FITS_COLMAX,1,'i');
if( NULL == curFile->CHDUInfo.table.colTzflag ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colTzflag", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colTsflag =
(int *) makeContigArray(FITS_COLMAX,1,'i');
if( NULL == curFile->CHDUInfo.table.colTsflag ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colTsflag", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colMin =
(double *) makeContigArray(FITS_COLMAX,1,'d');
if( NULL == curFile->CHDUInfo.table.colMin ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colMin", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.colMax =
(double *) makeContigArray(FITS_COLMAX,1,'d');
if( NULL == curFile->CHDUInfo.table.colMax ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for colMax", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.table.strSize =
(int *) makeContigArray(FITS_COLMAX,1,'i');
if( NULL == curFile->CHDUInfo.table.strSize ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for strSize", TCL_STATIC);
return TCL_ERROR;
}
/*
* If you are going to Image HDU, then also wipe everything,
* and start over:
*/
} else if ( newHduType == IMAGE_HDU ) {
if (curFile->hduType != NOHDU ) {
freeCHDUInfo(curFile);
}
curFile->CHDUInfo.image.naxisn =
(long *) makeContigArray(FITS_MAXDIMS,1,'l');
if( NULL == curFile->CHDUInfo.image.naxisn ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for naxisn", TCL_STATIC);
return TCL_ERROR;
}
curFile->CHDUInfo.image.axisUnit =
(char **) makeContigArray(FITS_MAXDIMS,FLEN_VALUE,'c');
if( NULL == curFile->CHDUInfo.image.axisUnit ) {
Tcl_SetResult(curFile->interp,
"Error malloc'ing space for axisUnit", TCL_STATIC);
return TCL_ERROR;
}
} else if ( newHduType == ASCII_TBL || newHduType == BINARY_TBL ) {
/* Do Nothing */
} else {
Tcl_SetResult(curFile->interp,
"In makeNewCHDUInfo - You should not get here...",
TCL_STATIC);
return TCL_ERROR;
}
curFile->hduType = newHduType;
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* freeCHDUInfo --
*
* This removes the current CHDU structure
*
* Results:
* Deallocates the memory for the previous header type.
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*/
int freeCHDUInfo( FitsFD * curFile )
{
if (curFile->hduType == IMAGE_HDU ) {
ckfree((char *) curFile->CHDUInfo.image.naxisn);
ckfree((char *) curFile->CHDUInfo.image.axisUnit[0]);
ckfree((char *) curFile->CHDUInfo.image.axisUnit);
} else if (curFile->hduType == ASCII_TBL || curFile->hduType == BINARY_TBL) {
ckfree((char *) curFile->CHDUInfo.table.colName[0]);
ckfree((char *) curFile->CHDUInfo.table.colType[0]);
ckfree((char *) curFile->CHDUInfo.table.colUnit[0]);
ckfree((char *) curFile->CHDUInfo.table.colDisp[0]);
ckfree((char *) curFile->CHDUInfo.table.colNull[0]);
ckfree((char *) curFile->CHDUInfo.table.colFormat[0]);
ckfree((char *) curFile->CHDUInfo.table.colDataType);
ckfree((char *) curFile->CHDUInfo.table.colWidth);
ckfree((char *) curFile->CHDUInfo.table.colName);
ckfree((char *) curFile->CHDUInfo.table.colUnit);
ckfree((char *) curFile->CHDUInfo.table.colType);
ckfree((char *) curFile->CHDUInfo.table.colDisp);
ckfree((char *) curFile->CHDUInfo.table.colNull);
ckfree((char *) curFile->CHDUInfo.table.vecSize);
ckfree((char *) curFile->CHDUInfo.table.colFormat);
ckfree((char *) curFile->CHDUInfo.table.colMin);
ckfree((char *) curFile->CHDUInfo.table.colMax);
ckfree((char *) curFile->CHDUInfo.table.colTzero);
ckfree((char *) curFile->CHDUInfo.table.colTscale);
ckfree((char *) curFile->CHDUInfo.table.colTzflag);
ckfree((char *) curFile->CHDUInfo.table.colTsflag);
ckfree((char *) curFile->CHDUInfo.table.strSize);
} else {
char errMsg[80];
sprintf(errMsg,"Unknown HDU Type: %d\n",curFile->hduType);
Tcl_SetResult(curFile->interp,errMsg,TCL_VOLATILE);
return TCL_ERROR;
}
return TCL_OK;
}
int imageRowsMeanToPtr( FitsFD *curFile,
long fRow,
long lRow,
long slice )
{
long fCol = 1;
long nRows;
long nCols;
void *databuffer;
int dataType;
int dataLength;
long tmpL;
int i,j, offset;
unsigned char *byteData;
short *shortData;
int *intData;
float *floatData;
float *floatBack;
double *dblData;
double *dblBack;
LONGLONG *longlongData;
LONGLONG *longlongBack;
void *backPtr;
char result[80];
nCols = curFile->CHDUInfo.image.naxisn[0];
if ( fRow > lRow) {
tmpL = lRow;
lRow = fRow;
fRow = tmpL;
}
if( fRow < 1 )
fRow = 1;
if( lRow < 1 )
lRow = 1;
if( curFile->CHDUInfo.image.naxes == 1 ) {
nRows = 1;
} else {
nRows = curFile->CHDUInfo.image.naxisn[1];
}
if( lRow > nRows )
lRow = nRows;
if( fRow > nRows )
fRow = nRows;
nRows = lRow - fRow + 1;
if ( TCL_OK != imageBlockLoad(curFile,"",fRow,nRows,fCol,nCols,slice,1) ) {
return TCL_ERROR;
}
sscanf( Tcl_GetStringResult(curFile->interp),
PTRFORMAT " %d %d", &databuffer, &dataType, &dataLength);
Tcl_ResetResult(curFile->interp);
if ( dataLength != nRows*nCols ) {
ckfree( (char*)databuffer );
Tcl_SetResult(curFile->interp,
"fitsTcl Error: data lengths don't match", TCL_STATIC);
return TCL_ERROR;
}
switch( dataType ) {
case BYTE_DATA:
byteData = (unsigned char *) databuffer;
floatBack = (float *) ckalloc( nCols * sizeof(float) );
for (i=0; i< nCols; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
floatBack[i] += byteData[offset];
}
floatBack[i] /= nRows;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nCols);
break;
case SHORTINT_DATA:
shortData = (short *) databuffer;
floatBack = (float *) ckalloc( nCols * sizeof(float) );
for (i=0; i< nCols; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
floatBack[i] += shortData[offset];
}
floatBack[i] /= nRows;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nCols);
break;
case INT_DATA:
intData = (int *) databuffer;
floatBack = (float *) ckalloc( nCols * sizeof(float) );
for (i=0; i< nCols; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
floatBack[i] += intData[offset];
}
floatBack[i] /= nRows;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nCols);
break;
case FLOAT_DATA:
floatData = (float *) databuffer;
floatBack = (float *) ckalloc( nCols * sizeof(float) );
for (i=0; i< nCols; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
floatBack[i] += floatData[offset];
}
floatBack[i] /= nRows;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nCols);
break;
case DOUBLE_DATA:
dblData = (double *) databuffer;
dblBack = (double *) ckalloc( nCols * sizeof(double) );
for (i=0; i< nCols; i++ ) {
dblBack[i] = 0.0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
dblBack[i] += dblData[offset];
}
dblBack[i] /= nRows;
}
backPtr = dblBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, DOUBLE_DATA, nCols);
break;
case LONGLONG_DATA:
longlongData = (LONGLONG *) databuffer;
longlongBack = (LONGLONG *) ckalloc( nCols * sizeof(LONGLONG) );
for (i=0; i< nCols; i++ ) {
longlongBack[i] = 0;
for ( j=0; j < nRows; j++) {
offset = i + j*nCols;
longlongBack[i] += longlongData[offset];
}
longlongBack[i] /= nRows;
}
backPtr = longlongBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, LONGLONG_DATA, nCols);
break;
default:
ckfree((char *) databuffer);
Tcl_SetResult(curFile->interp,
"fitsTcl Error:unknown data type in irows", TCL_STATIC);
return TCL_ERROR;
}
ckfree((char *) databuffer);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
return TCL_OK;
}
int imageColsMeanToPtr( FitsFD *curFile,
long fCol,
long lCol,
long slice )
{
long fRow = 1;
long nRows;
long nCols;
void *databuffer;
int dataType;
int dataLength;
long tmpL;
int i,j, offset;
unsigned char *byteData;
short *shortData;
int *intData;
float *floatData;
float *floatBack;
double *dblData;
double *dblBack;
LONGLONG *longlongData;
LONGLONG *longlongBack;
void *backPtr;
char result[80];
if( curFile->CHDUInfo.image.naxes == 1 )
nRows = 1;
else
nRows = curFile->CHDUInfo.image.naxisn[1];
if ( fCol > lCol) {
tmpL = lCol;
lCol = fCol;
fCol = tmpL;
}
if (fCol < 1) fCol = 1;
if ( lCol > curFile->CHDUInfo.image.naxisn[0])
lCol = curFile->CHDUInfo.image.naxisn[0];
nCols = lCol-fCol + 1;
if ( TCL_OK != imageBlockLoad(curFile,"",fRow,nRows,fCol,nCols,slice,1) ) {
return TCL_ERROR;
}
sscanf( Tcl_GetStringResult(curFile->interp),
PTRFORMAT " %d %d", &databuffer, &dataType, &dataLength);
Tcl_ResetResult(curFile->interp);
if ( dataLength != nRows*nCols ) {
ckfree( (char*) databuffer );
Tcl_SetResult(curFile->interp,
"fitsTcl Error: data lengths don't match", TCL_STATIC);
return TCL_ERROR;
}
switch (dataType) {
case BYTE_DATA:
byteData = (unsigned char *) databuffer;
floatBack = (float *) ckalloc( nRows * sizeof(float));
for (i=0; i< nRows; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
floatBack[i] += byteData[offset];
}
floatBack[i] /= nCols;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nRows);
break;
case SHORTINT_DATA:
shortData = (short *) databuffer;
floatBack = (float *) ckalloc( nRows * sizeof(float) );
for (i=0; i< nRows; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
floatBack[i] += shortData[offset];
}
floatBack[i] /= nCols;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nRows);
break;
case INT_DATA:
intData = (int *) databuffer;
floatBack = (float *) ckalloc( nRows * sizeof(float) );
for (i=0; i< nRows; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
floatBack[i] += intData[offset];
}
floatBack[i] /= nCols;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nRows);
break;
case FLOAT_DATA:
floatData = (float *) databuffer;
floatBack = (float *) ckalloc( nRows * sizeof(float) );
for (i=0; i< nRows; i++ ) {
floatBack[i] = 0.0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
floatBack[i] += floatData[offset];
}
floatBack[i] /= nCols;
}
backPtr = floatBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, FLOAT_DATA, nRows);
break;
case DOUBLE_DATA:
dblData = (double *) databuffer;
dblBack = (double *) ckalloc( nRows * sizeof(double) );
for (i=0; i< nRows; i++ ) {
dblBack[i] = 0.0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
dblBack[i] += dblData[offset];
}
dblBack[i] /= nCols;
}
backPtr = dblBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, DOUBLE_DATA, nRows);
break;
case LONGLONG_DATA:
longlongData = (LONGLONG *) databuffer;
longlongBack = (LONGLONG *) ckalloc( nRows * sizeof(LONGLONG) );
for (i=0; i< nRows; i++ ) {
longlongBack[i] = 0;
for ( j=0; j < nCols; j++) {
offset = j + i*nCols;
longlongBack[i] += longlongData[offset];
}
longlongBack[i] /= nCols;
}
backPtr = longlongBack;
sprintf(result, PTRFORMAT " %d %ld", backPtr, LONGLONG_DATA, nCols);
break;
default:
ckfree((char *) databuffer);
Tcl_SetResult(curFile->interp,
"fitsTcl Error: unknown data type in irows", TCL_STATIC);
return TCL_ERROR;
}
ckfree((char *) databuffer);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
return TCL_OK;
}
/*
* imageBlockLoad_1D
* assign a block of the image data to varName variable or return a pointer
*/
int imageBlockLoad_1D( FitsFD *curFile,
long fElem,
long nElem )
{
long i;
int anyNul, status;
char *nullArray, tmpStr[80];
void *imgData;
Tcl_Obj *valObj, *nullObj, *listObj;
listObj = Tcl_NewObj();
nullObj = Tcl_NewStringObj( "NULL", -1 );
status = 0;
nullArray = (char *) ckalloc(nElem*sizeof(char));
switch ( curFile->CHDUInfo.image.dataType ) {
case TDOUBLE:
case TFLOAT:
imgData = (double *) ckalloc(nElem*sizeof(double));
ffgpfd(curFile->fptr,
1,
fElem,
nElem,
imgData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) imgData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
for ( i=0; i< nElem; i++ ) {
if ( nullArray[i] ) {
valObj = nullObj;
} else {
valObj = Tcl_NewDoubleObj( ((double*)imgData)[i] );
}
Tcl_ListObjAppendElement( curFile->interp, listObj, valObj );
}
break;
case TLONGLONG:
imgData = (LONGLONG *) ckalloc(nElem*sizeof(LONGLONG));
ffgpfjj(curFile->fptr,
1,
fElem,
nElem,
imgData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) imgData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
for ( i=0; i< nElem; i++ ) {
if ( nullArray[i] ) {
valObj = nullObj;
} else {
#ifdef __WIN32__
sprintf(tmpStr, "%I64d", ((LONGLONG *)imgData)[i]);
#else
sprintf(tmpStr, "%lld", ((LONGLONG *)imgData)[i]);
#endif
valObj = Tcl_NewStringObj( tmpStr, -1 );
}
Tcl_ListObjAppendElement( curFile->interp, listObj, valObj );
}
break;
case TLONG:
case TINT:
case TSHORT:
case TBYTE:
imgData = (long *) ckalloc(nElem*sizeof(long));
ffgpfj(curFile->fptr,
1,
fElem,
nElem,
imgData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) imgData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
for ( i=0; i< nElem; i++ ) {
if ( nullArray[i] ) {
valObj = nullObj;
} else {
valObj = Tcl_NewLongObj( ((long*)imgData)[i] );
}
Tcl_ListObjAppendElement( curFile->interp, listObj, valObj );
}
break;
default:
Tcl_SetResult(curFile->interp, "Unknown image type", TCL_STATIC);
ckfree( (char *) nullArray );
return TCL_ERROR;
}
ckfree( (char *) imgData );
ckfree( (char *) nullArray);
Tcl_SetObjResult(curFile->interp,listObj);
return TCL_OK;
}
/*
* imageBlockLoad
* assign a block of the image data to varName variable or return a pointer
*/
int imageBlockLoad( FitsFD *curFile,
char *varName,
LONGLONG fRow,
LONGLONG nRow,
LONGLONG fCol,
LONGLONG nCol,
long slice,
long cslice)
{
unsigned char *byteData;
short *shortData;
int *intData;
float *floatData;
double *dblData;
LONGLONG *longlongData;
char *nullArray;
double defaultDouble = 0.0;
int ptrFlag, status;
LONGLONG tmpIndex, i,j;
char tmpStr[80];
char varIndex[80];
int anyNul;
LONGLONG blc[FITS_MAXDIMS], trc[FITS_MAXDIMS];
long blc_l[FITS_MAXDIMS], trc_l[FITS_MAXDIMS];
long incrc[FITS_MAXDIMS];
int naxes, flip=0;
LONGLONG xDim, yDim;
char result[80];
char colFormat[80];
Tcl_Obj *valObj;
naxes = curFile->CHDUInfo.image.naxes;
/*
if( naxes > 3 ) {
for (i = 3; i < naxes; i++) {
if (curFile->CHDUInfo.image.naxisn[i] != 1) {
Tcl_SetResult(curFile->interp,
"Can only read L X M X N X 1 ... images",
TCL_STATIC);
return TCL_ERROR;
}
}
}
*/
if( naxes > FITS_MAXDIMS ) {
sprintf(result,"Image exceeds %d dimensions", FITS_MAXDIMS);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return TCL_ERROR;
}
xDim = curFile->CHDUInfo.image.naxisn[0];
if( naxes>1 ) {
yDim = curFile->CHDUInfo.image.naxisn[1];
} else {
yDim = 1;
if( (fCol>1 && fRow>1) || (nRow>1 && nCol>1) ) {
Tcl_SetResult(curFile->interp,
"Cannot read 2D block from a 1D image",
TCL_STATIC);
return TCL_ERROR;
}
if( fRow>2 || nRow>2 ) {
/* Interpret 1D image as a column */
flip = 1;
yDim = xDim; xDim = 1;
}
}
if ( fRow+nRow-1 > yDim ) {
nRow = yDim - fRow +1;
}
if ( fCol+nCol-1 > xDim ) {
nCol = xDim - fCol +1;
}
for (i=0; i < naxes; i++) {
blc[i] = 1;
trc[i] = 1;
incrc[i] = 1;
blc_l[i] = (long) blc[i];
trc_l[i] = (long) trc[i];
}
if( flip ) {
blc[0] = fRow;
trc[0] = fRow+nRow-1;
incrc[0] = 1;
} else {
blc[0] = fCol;
trc[0] = fCol+nCol-1;
incrc[0] = 1;
}
blc_l[0] = (long) blc[0];
trc_l[0] = (long) trc[0];
if( naxes>1 ) {
if( flip ) {
blc[1] = fCol;
trc[1] = fCol+nCol-1;
incrc[1] = 1;
} else {
blc[1] = fRow;
trc[1] = fRow+nRow-1;
incrc[1] = 1;
}
/*
blc[1] = fRow;
trc[1] = fRow+nRow-1;
incrc[1] = 1;
*/
blc_l[1] = (long) blc[1];
trc_l[1] = (long) trc[1];
if( naxes>2 ) {
blc[2] = slice;
trc[2] = slice;
incrc[2] = 1;
blc_l[2] = (long) blc[2];
trc_l[2] = (long) trc[2];
if ( cslice > 1 ) {
blc[3] = cslice;
trc[3] = cslice;
incrc[i] = 1;
blc_l[3] = (long) blc[2];
trc_l[3] = (long) trc[2];
}
}
}
if( varName[0] == '\0' ) {
ptrFlag=1;
} else {
ptrFlag=0;
}
status = 0;
nullArray = (char *) ckalloc(nCol*nRow*sizeof(char));
/*
fprintf(stdout, "case: <%d>\n", curFile->CHDUInfo.image.dataType);
fflush(stdout);
*/
switch ( curFile->CHDUInfo.image.dataType ) {
case TDOUBLE:
dblData = (double *) ckalloc(nCol*nRow*sizeof(double));
memset (dblData, NULL, nCol*nRow*sizeof(double));
ffgsfd(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
dblData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) dblData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", dblData, 4, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
valObj = Tcl_NewDoubleObj( dblData[tmpIndex] );
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) dblData);
}
break;
case TLONGLONG:
longlongData = (LONGLONG *) ckalloc(nCol*nRow*sizeof(LONGLONG));
memset (longlongData, NULL, nCol*nRow*sizeof(LONGLONG));
ffgsfjj(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
longlongData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) longlongData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", longlongData, 4, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
#ifdef __WIN32__
sprintf(tmpStr, "%I64d", longlongData[tmpIndex]);
#else
sprintf(tmpStr, "%lld", longlongData[tmpIndex]);
#endif
valObj = Tcl_NewStringObj( tmpStr, -1 );
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) longlongData);
}
break;
case TFLOAT:
floatData = (float *) ckalloc(nCol*nRow*sizeof(float));
memset (floatData, NULL, nCol*nRow*sizeof(float));
ffgsfe(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
floatData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) floatData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", floatData, 3, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
valObj = Tcl_NewDoubleObj( (double)floatData[tmpIndex] );
/* sprintf(tmpStr,"%#.5f", floatData[tmpIndex]); */
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) floatData);
}
break;
case TLONG:
case TINT:
intData = (int *) ckalloc(nRow*nCol*sizeof(int));
memset (intData, NULL, nCol*nRow*sizeof(int));
ffgsfk(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
intData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) intData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", intData, 2, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
valObj = Tcl_NewLongObj( (long)intData[tmpIndex] );
/* sprintf(tmpStr,"%d", intData[tmpIndex]); */
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) intData);
}
break;
case TSHORT:
shortData = (short *) ckalloc(nCol*nRow*sizeof(short));
memset (shortData, NULL, nCol*nRow*sizeof(short));
ffgsfi(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
shortData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) shortData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", shortData, 1, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
valObj = Tcl_NewLongObj( (long)shortData[tmpIndex] );
/* sprintf(tmpStr,"%d", shortData[tmpIndex]); */
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) shortData);
}
break;
case TBYTE:
byteData = (unsigned char *) ckalloc(nCol*nRow*sizeof(unsigned char));
memset (byteData, NULL, nCol*nRow*sizeof(unsigned char));
ffgsfb(curFile->fptr,
1,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc_l,
trc_l,
incrc,
byteData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,"Error reading image\n",TCL_VOLATILE);
dumpFitsErrStack(curFile->interp,status);
ckfree( (char *) byteData );
ckfree( (char *) nullArray );
return TCL_ERROR;
}
if( ptrFlag ) {
sprintf(result, PTRFORMAT " %d %lld", byteData, 0, nCol*nRow);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
} else {
for ( i=0; i< nCol; i++ ) {
for ( j=0; j< nRow; j++ ) {
tmpIndex = j*nCol + i;
sprintf(varIndex,"%lld,%lld", fCol+i-1, fRow+j-1);
if ( nullArray[tmpIndex] ) {
valObj = Tcl_NewStringObj("NULL",-1);
} else {
valObj = Tcl_NewLongObj( (long)byteData[tmpIndex] );
/* sprintf(tmpStr,"%u", byteData[tmpIndex]); */
}
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) byteData);
}
break;
default:
Tcl_SetResult(curFile->interp, "Unknown image type", TCL_STATIC);
ckfree( (char *) nullArray );
return TCL_ERROR;
}
ckfree( (char *) nullArray );
return TCL_OK;
}
/*
* imageGetToPtr
*/
int imageGetToPtr( FitsFD *curFile,
long slice,
int rotate )
{
void *backPtr;
long i, j;
int anynul, status=0;
double *dblValArray;
double *dblTmpArray;
LONGLONG *longlongValArray;
LONGLONG *longlongTmpArray;
float *floatValArray;
float *floatTmpArray;
short *shortValArray;
short *shortTmpArray;
int *intValArray;
int *intTmpArray;
unsigned char *byteValArray;
unsigned char *byteTmpArray;
char result[80];
long tmpIndex;
long offset;
long naxis1, naxis2, felem, nelem;
naxis1 = curFile->CHDUInfo.image.naxisn[0];
naxis2 = curFile->CHDUInfo.image.naxisn[1];
if( curFile->CHDUInfo.image.naxes==1 || naxis2 < 1 ) naxis2 = 1;
nelem = naxis1 * naxis2;
felem = (slice-1) * nelem + 1;
switch ( curFile->CHDUInfo.image.dataType ) {
case TDOUBLE:
dblValArray = (double *) ckalloc( nelem*sizeof(double) );
ffgpvd(curFile->fptr,
1L,
felem,
nelem,
DBL_MAX,
dblValArray,
&anynul,
&status);
if( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree((char *) dblValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = dblValArray;
} else {
dblTmpArray = (double *) ckalloc( nelem*sizeof(double) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
dblTmpArray[offset] = dblValArray[tmpIndex];
}
}
ckfree ((char *) dblValArray);
backPtr = dblTmpArray;
}
break;
case TLONGLONG:
longlongValArray = (LONGLONG *) ckalloc( nelem*sizeof(LONGLONG) );
ffgpvjj(curFile->fptr,
1L,
felem,
nelem,
(LONGLONG)NULL,
longlongValArray,
&anynul,
&status);
if( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree((char *) longlongValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = longlongValArray;
} else {
longlongTmpArray = (LONGLONG *) ckalloc( nelem*sizeof(LONGLONG) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
longlongTmpArray[offset] = longlongValArray[tmpIndex];
}
}
ckfree ((char *) longlongValArray);
backPtr = longlongTmpArray;
}
break;
case TFLOAT:
floatValArray = (float *) ckalloc( nelem*sizeof(float) );
ffgpve(curFile->fptr,
1L,
felem,
nelem,
FLT_MAX,
floatValArray,
&anynul,
&status);
if ( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) floatValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = floatValArray;
} else {
floatTmpArray = (float *) ckalloc( nelem*sizeof(float) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
floatTmpArray[offset] = floatValArray[tmpIndex];
}
}
ckfree ((char *) floatValArray);
backPtr = floatTmpArray;
}
break;
case TINT:
intValArray = (int *) ckalloc( nelem*sizeof(int) );
ffgpvk(curFile->fptr,
1L,
felem,
nelem,
INT_MAX,
intValArray,
&anynul,
&status);
if ( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) intValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = intValArray;
} else {
intTmpArray = (int *) ckalloc(nelem*sizeof(int) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
intTmpArray[offset] = intValArray[tmpIndex];
}
}
ckfree ((char *) intValArray);
backPtr = intTmpArray;
}
break;
case TSHORT:
shortValArray = (short *) ckalloc( nelem*sizeof(short) );
ffgpvi(curFile->fptr,
1L,
felem,
nelem,
SHRT_MAX,
shortValArray,
&anynul,
&status);
if ( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) shortValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = shortValArray;
} else {
shortTmpArray = (short *) ckalloc( nelem*sizeof(short) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
shortTmpArray[offset] = shortValArray[tmpIndex];
}
}
ckfree ((char *) shortValArray);
backPtr = shortTmpArray;
}
break;
case TBYTE:
byteValArray = (unsigned char *) ckalloc( nelem*sizeof(unsigned char) );
ffgpvb(curFile->fptr,
1L,
felem,
nelem,
UCHAR_MAX,
byteValArray,
&anynul,
&status);
if ( status ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Cannot get image", TCL_STATIC);
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) byteValArray);
return TCL_ERROR;
}
if (rotate == 0) {
backPtr = byteValArray;
} else {
byteTmpArray = (unsigned char *) ckalloc(nelem*sizeof(unsigned char) );
for (i=0; i < naxis1; i ++) {
for (j=0; j < naxis2; j ++) {
tmpIndex = j*naxis1 + i;
switch (rotate) {
case 1: /* 90 degree */
offset = (i+1)*naxis2 -j-1;
break;
case 2:
offset = (naxis2-j-1)*naxis1 +(naxis1-i-1);
break;
case 3:
offset = (naxis1-i-1)*naxis2 + j;
break;
default:
offset = tmpIndex;
break;
}
byteTmpArray[offset] = byteValArray[tmpIndex];
}
}
ckfree ((char *) byteValArray);
backPtr = byteTmpArray;
}
break;
default:
Tcl_SetResult(curFile->interp, "Unknown image type", TCL_STATIC);
return TCL_ERROR;
}
sprintf(result, PTRFORMAT, backPtr);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
return TCL_OK;
}
/*
* vtableGetToPtr
* return "address dataType numberElements"
*
*/
int vtableGetToPtr( FitsFD *curFile,
long colNum,
char *nulStr)
{
void *backPtr;
int retnType;
int dataType;
long numRows;
int anynul;
long dataSize, vecSize;
char result[80];
int status = 0;
int useDefNull;
double dblNul;
LONGLONG longlongNul;
float fltNul;
int intNul;
short shtNul;
unsigned char bytNul;
void *defNul;
vecSize = curFile->CHDUInfo.table.vecSize[ colNum-1 ];
numRows = curFile->CHDUInfo.table.numRows;
dataSize = numRows * vecSize;
dataType = curFile->CHDUInfo.table.colDataType[ colNum-1 ];
useDefNull = !strcmp(nulStr,"NULL");
switch ( dataType ) {
case TBYTE: case TBIT:
retnType = BYTE_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(unsigned char));
if( useDefNull ) {
bytNul = UCHAR_MAX;
} else {
bytNul = atoi(nulStr);
}
defNul = &bytNul;
break;
case TSHORT:
retnType = SHORTINT_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(short));
if( useDefNull ) {
shtNul = SHRT_MAX;
} else {
shtNul = atoi(nulStr);
}
defNul = &shtNul;
break;
case TINT: case TLONG:
dataType = TINT; /* Cast TLONG to TINT */
retnType = INT_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(int));
if( useDefNull ) {
intNul = INT_MAX;
} else {
intNul = atoi(nulStr);
}
defNul = &intNul;
break;
case TFLOAT:
retnType = FLOAT_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(float));
if( useDefNull ) {
fltNul = FLT_MAX;
} else {
fltNul = atof(nulStr);
}
defNul = &fltNul;
break;
case TDOUBLE:
retnType = DOUBLE_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(double));
if( useDefNull ) {
dblNul = DBL_MAX;
} else {
dblNul = atof(nulStr);
}
defNul = &dblNul;
break;
case TLONGLONG:
retnType = LONGLONG_DATA;
backPtr = (void *) ckalloc (dataSize * sizeof(LONGLONG));
if( useDefNull ) {
longlongNul = (LONGLONG)NULL;
} else {
longlongNul = atof(nulStr);
}
defNul = &longlongNul;
break;
default:
Tcl_SetResult(curFile->interp,
"The data type is not suitable for making an image",
TCL_STATIC);
return TCL_ERROR;
break;
}
ffgcv( curFile->fptr,
dataType,
colNum,
1,
1,
dataSize,
defNul,
backPtr,
&anynul,
&status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree( (char *) backPtr);
return TCL_ERROR;
}
sprintf(result, PTRFORMAT " %d %ld", backPtr, retnType, dataSize);
Tcl_SetResult(curFile->interp,result,TCL_VOLATILE);
return TCL_OK;
}
/*
* tableGetToPtr
* return : "address dataType numberElements"
* address can be recovered using sscanf(address, PTRFORMAT, &dataArray)
* where void *dataArray
* dataType : 0 byte(unsigned char) , 1 short int, 2 int , 3 float , 4 double
* numberElements : dimension of the array
*
*/
int tableGetToPtr( FitsFD *curFile,
long colNum,
char *nulStr,
long firstelem )
{
void *backPtr;
LONGLONG *longlongArray;
double *dblArray;
float *fltArray;
long *lngArray;
short *shtArray;
int *intArray;
unsigned char *bytArray;
LONGLONG longlongNul;
double dblNul;
float fltNul;
int intNul;
short shtNul;
unsigned char bytNul;
char result[80];
long numRows, vecSize, i;
int anynul, dataType, colDataType;
int status=0;
numRows = curFile->CHDUInfo.table.numRows;
vecSize = curFile->CHDUInfo.table.vecSize[colNum-1];
colDataType = curFile->CHDUInfo.table.colDataType[colNum-1];
switch ( colDataType ) {
case TSTRING:
Tcl_SetResult(curFile->interp, "Cannot load string array", TCL_STATIC);
return TCL_ERROR;
case TBYTE:
if( !strcmp(nulStr, "NULL") ) {
bytNul = UCHAR_MAX;
} else {
bytNul = atoi(nulStr);
}
bytArray = (unsigned char *) ckalloc(numRows*sizeof(unsigned char));
ffgclb(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
bytNul,
bytArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) bytArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = BYTE_DATA;
backPtr = bytArray;
break;
case TSHORT:
if( !strcmp(nulStr, "NULL") ) {
shtNul = SHRT_MAX;
} else {
shtNul = atoi(nulStr);
}
shtArray = (short *) ckalloc(numRows*sizeof(short));
ffgcli(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
shtNul,
shtArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) shtArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = SHORTINT_DATA;
backPtr = shtArray;
break;
case TINT: case TLONG:
if( !strcmp(nulStr, "NULL") ) {
intNul = INT_MAX;
} else {
intNul = atoi(nulStr);
}
intArray = (int *) ckalloc(numRows*sizeof(int));
ffgclk(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
intNul,
intArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) intArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = INT_DATA;
backPtr = intArray;
break;
case TFLOAT:
if( !strcmp(nulStr, "NULL") ) {
fltNul = FLT_MAX;
} else {
fltNul = atof(nulStr);
}
fltArray = (float *) ckalloc(numRows*sizeof(float));
ffgcle(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
fltNul,
fltArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) fltArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = FLOAT_DATA;
backPtr = fltArray;
break;
case TDOUBLE:
if( !strcmp(nulStr, "NULL") ) {
dblNul = DBL_MAX;
} else {
dblNul = atof(nulStr);
}
dblArray = (double *) ckalloc(numRows*sizeof(double));
ffgcld(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
dblNul,
dblArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) dblArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = DOUBLE_DATA;
backPtr = dblArray;
break;
case TLONGLONG:
if( !strcmp(nulStr, "NULL") ) {
longlongNul = (LONGLONG)NULL;
} else {
longlongNul = atof(nulStr);
}
longlongArray = (LONGLONG *) ckalloc(numRows*sizeof(LONGLONG));
ffgcljj(curFile->fptr,
colNum,
1,
firstelem,
numRows,
vecSize,
1,
longlongNul,
longlongArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) longlongArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = LONGLONG_DATA;
backPtr = longlongArray;
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot load this type of column",
TCL_STATIC);
return TCL_ERROR;
}
sprintf(result, PTRFORMAT " %d %ld", backPtr, dataType, numRows);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return TCL_OK;
}
/*
* tableRowGetToPtr
* return : "address dataType numberElements"
* address can be recovered using sscanf(address, PTRFORMAT, &dataArray)
* where void *dataArray
* dataType : 0 byte(unsigned char) , 1 short int, 2 int , 3 float , 4 double
* numberElements : dimension of the array
*
*/
int tableRowGetToPtr( FitsFD *curFile,
long rowNum,
long colNum,
long vecSize,
char *nulStr,
long firstelem )
{
void *backPtr;
LONGLONG *longlongArray;
double *dblArray;
float *fltArray;
long *lngArray;
short *shtArray;
int *intArray;
unsigned char *bytArray;
LONGLONG longlongNul;
double dblNul;
float fltNul;
int intNul;
short shtNul;
unsigned char bytNul;
char result[80];
long numRows, i;
int anynul, dataType, colDataType;
int status=0;
numRows = curFile->CHDUInfo.table.numRows;
/* vecSize = curFile->CHDUInfo.table.vecSize[colNum-1]; */
colDataType = curFile->CHDUInfo.table.colDataType[colNum-1];
switch ( colDataType ) {
case TSTRING:
Tcl_SetResult(curFile->interp, "Cannot load string array", TCL_STATIC);
return TCL_ERROR;
case TBYTE:
if( !strcmp(nulStr, "NULL") ) {
bytNul = UCHAR_MAX;
} else {
bytNul = atoi(nulStr);
}
bytArray = (unsigned char *) ckalloc(vecSize*sizeof(unsigned char));
ffgclb(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
bytNul,
bytArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) bytArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = BYTE_DATA;
backPtr = bytArray;
break;
case TSHORT:
if( !strcmp(nulStr, "NULL") ) {
shtNul = SHRT_MAX;
} else {
shtNul = atoi(nulStr);
}
/* fprintf(stdout, "shtArray size: %ld\n", vecSize*sizeof(short)); */
/* fprintf(stdout, "vecSize size: %ld\n", vecSize); */
/* fprintf(stdout, "short size: %ld\n", sizeof(short)); */
shtArray = (short *) ckalloc(vecSize*sizeof(short));
ffgcli(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
shtNul,
shtArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) shtArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = SHORTINT_DATA;
backPtr = shtArray;
break;
case TINT: case TLONG:
if( !strcmp(nulStr, "NULL") ) {
intNul = INT_MAX;
} else {
intNul = atoi(nulStr);
}
intArray = (int *) ckalloc(vecSize*sizeof(int));
ffgclk(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
intNul,
intArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) intArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = INT_DATA;
backPtr = intArray;
break;
case TFLOAT:
if( !strcmp(nulStr, "NULL") ) {
fltNul = FLT_MAX;
} else {
fltNul = atof(nulStr);
}
fltArray = (float *) ckalloc(vecSize*sizeof(float));
ffgcle(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
fltNul,
fltArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) fltArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = FLOAT_DATA;
backPtr = fltArray;
break;
case TDOUBLE:
if( !strcmp(nulStr, "NULL") ) {
dblNul = DBL_MAX;
} else {
dblNul = atof(nulStr);
}
dblArray = (double *) ckalloc(vecSize*sizeof(double));
ffgcld(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
dblNul,
dblArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) dblArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = DOUBLE_DATA;
backPtr = dblArray;
break;
case TLONGLONG:
if( !strcmp(nulStr, "NULL") ) {
longlongNul = (LONGLONG)NULL;
} else {
longlongNul = atof(nulStr);
}
longlongArray = (LONGLONG *) ckalloc(vecSize*sizeof(LONGLONG));
ffgcljj(curFile->fptr,
colNum,
rowNum,
firstelem,
vecSize,
1,
1,
longlongNul,
longlongArray,
(char*) NULL,
&anynul,
&status);
if ( status ) {
ckfree((char *) longlongArray);
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
dataType = LONGLONG_DATA;
backPtr = longlongArray;
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot load this type of column",
TCL_STATIC);
return TCL_ERROR;
}
sprintf(result, PTRFORMAT " %d %ld", backPtr, dataType, numRows);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* tableBlockLoad --
* a block of table is either set to an 2-D array varName(i_j)
* or placed within a TCL list and returned
*
* ------------------------------------------------------------
*/
int tableBlockLoad( FitsFD *curFile,
char *varName,
int felem,
int fRow,
int nRows,
int fCol,
int nCols,
int colNums[],
int format )
{
int k,m;
int anyf;
char **cValue;
short shtValue[1];
int intValue[1];
long longValue[1];
double dblValue[2];
float fValue[1];
char xValue[1];
double dblComplex[2];
float fltComplex[2];
char nullArray[1];
char strNullVal[]="NULL";
unsigned char binValue[1];
char lValue[1];
char colFormat[80];
char cplxFormat[80];
char tmpStr[80];
char checkStr1[80];
char checkStr2[80];
int tmpInt;
char varIndex[80];
int dataType;
int status=0;
char errMsg[160];
int listFlag=0;
Tcl_Obj *valObj, **colData, *valObj2[2];
Tcl_Obj *cnstObj[5];
int naxis;
long naxes[3];
char result1[80];
char result2[80];
LONGLONG longlongValue[1];
enum { cnstNullObj=0, cnstTrueObj, cnstFalseObj, cnstUndefObj, cnstBlnkObj };
if( varName[0] == '\0' ) {
listFlag = 1;
colData = (Tcl_Obj**) ckalloc( nCols * sizeof( Tcl_Obj* ) );
}
cnstObj[cnstNullObj] = Tcl_NewStringObj( "NULL", -1 );
cnstObj[cnstTrueObj] = Tcl_NewStringObj( "T", -1 );
cnstObj[cnstFalseObj] = Tcl_NewStringObj( "F", -1 );
cnstObj[cnstUndefObj] = Tcl_NewStringObj( "U", -1 );
cnstObj[cnstBlnkObj] = Tcl_NewStringObj( " ", -1 );
for ( k = 0; k < nCols; k++ ) {
if( listFlag )
colData[k] = Tcl_NewObj();
strcpy(colFormat, curFile->CHDUInfo.table.colFormat[colNums[k]-1]);
dataType = curFile->CHDUInfo.table.colDataType[colNums[k]-1];
if( curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ]==0 ) {
valObj = cnstObj[ cnstBlnkObj ];
for (m=fRow; m < (fRow+nRows); m++ ) {
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
continue;
}
switch ( dataType ) {
case TSTRING:
tmpInt = curFile->CHDUInfo.table.strSize[ colNums[k]-1 ]+1;
cValue = (char **) makeContigArray(2, tmpInt, 'c');
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcls(curFile->fptr,
colNums[k],
m,
felem,
1,
1,
strNullVal,
cValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( format ) {
sprintf(cValue[1], colFormat, cValue[0]);
valObj = Tcl_NewStringObj(cValue[1], -1);
} else {
valObj = Tcl_NewStringObj(cValue[0], -1);
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
ckfree( (char *) cValue[0]);
ckfree( (char *) cValue);
break;
case TLOGICAL:
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcfl(curFile->fptr,
colNums[k],
m,
felem,
1,
lValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( anyf ) {
valObj = cnstObj[ cnstUndefObj ];
} else {
if (lValue[0] == 1) {
valObj = cnstObj[ cnstTrueObj ];
} else {
valObj = cnstObj[ cnstFalseObj ];
}
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
case TBIT:
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcx(curFile->fptr,
colNums[k],
m,
felem,
1,
xValue,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( format ) {
sprintf(tmpStr,colFormat,xValue[0]);
valObj = Tcl_NewStringObj( tmpStr, -1 );
} else {
valObj = Tcl_NewLongObj( (long)xValue[0] );
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
case TBYTE:
case TSHORT:
case TINT:
case TLONG:
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcfj(curFile->fptr,
colNums[k],
m,
felem,
1,
longValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( anyf ) {
valObj = cnstObj[ cnstNullObj ];
} else if( format ) {
sprintf(tmpStr,colFormat,longValue[0]);
valObj = Tcl_NewStringObj( tmpStr, -1 );
} else {
valObj = Tcl_NewLongObj( longValue[0] );
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
case TFLOAT:
case TDOUBLE:
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcfd(curFile->fptr,
colNums[k],
m,
felem,
1,
dblValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( anyf ) {
valObj = cnstObj[ cnstNullObj ];
} else if( format ) {
if( strchr(colFormat,'d') ) {
sprintf(tmpStr, "%.0f", dblValue[0]);
tmpInt = atoi(tmpStr);
sprintf(tmpStr,colFormat,tmpInt);
} else if( strchr(colFormat,'s') ) {
sprintf(tmpStr, "%f", dblValue[0]);
sprintf(tmpStr,colFormat,tmpStr);
} else {
sprintf(tmpStr,colFormat,dblValue[0]);
}
valObj = Tcl_NewStringObj( tmpStr, -1 );
} else {
valObj = Tcl_NewDoubleObj( dblValue[0] );
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
case TLONGLONG:
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcfjj(curFile->fptr,
colNums[k],
m,
felem,
1,
longlongValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( anyf ) {
valObj = cnstObj[ cnstNullObj ];
} else {
#ifdef __WIN32__
sprintf(tmpStr, "%I64d", longlongValue[0]);
#else
sprintf(tmpStr, "%lld", longlongValue[0]);
#endif
valObj = Tcl_NewStringObj( tmpStr, -1 );
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
case TCOMPLEX:
case TDBLCOMPLEX:
if( format ) {
sprintf(cplxFormat,"%s, %s",colFormat,colFormat);
}
for (m=fRow; m < (fRow+nRows); m++ ) {
ffgcfm(curFile->fptr,
colNums[k],
m,
felem,
1,
dblComplex,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
valObj = cnstObj[ cnstBlnkObj ];
status = 0;
ffcmsg();
} else if( anyf ) {
if( format ) {
valObj = Tcl_NewStringObj( "NULL, NULL", -1 );
} else {
valObj = cnstObj[ cnstNullObj ];
}
} else if( format ) {
sprintf(tmpStr,cplxFormat,dblComplex[0],dblComplex[1]);
valObj = Tcl_NewStringObj( tmpStr, -1 );
} else {
valObj2[0] = Tcl_NewDoubleObj( dblComplex[0] );
valObj2[1] = Tcl_NewDoubleObj( dblComplex[1] );
valObj = Tcl_NewListObj(2, valObj2);
}
if( listFlag ) {
Tcl_ListObjAppendElement(curFile->interp, colData[k], valObj);
} else {
sprintf(varIndex,"%d,%d", fCol-1+k, m-1);
Tcl_SetVar2Ex(curFile->interp, varName, varIndex, valObj, 0);
}
}
break;
default:
sprintf(errMsg,"Unrecognized colType: %d for column %d",
dataType,colNums[k]);
Tcl_SetResult(curFile->interp,errMsg,TCL_VOLATILE);
if( listFlag ) {
ckfree( (char*)colData );
}
return TCL_ERROR;
}
}
if( listFlag ) {
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(nCols, colData) );
ckfree( (char *)colData );
}
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsFlushKeywords --
*
* Flushes the header of the CHDU to the output file.
*
* Results:
*
* Side Effects:
* None
*
* ------------------------------------------------------------
*/
int fitsFlushKeywords( FitsFD *curFile )
{
Tcl_HashEntry *newEntry;
Tcl_HashSearch search;
/* clean up the keyword hash table */
newEntry = Tcl_FirstHashEntry(curFile->kwds,&search);
while ( NULL != newEntry ) {
ckfree((char *) Tcl_GetHashValue(newEntry));
Tcl_DeleteHashEntry(newEntry);
newEntry = Tcl_NextHashEntry(&search);
}
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* fitsPutReqKwds
*
*
* ERROR Returns through elem:
*
* Results:
* Side Effects:
*
* ------------------------------------------------------------
*/
int fitsPutReqKwds( FitsFD *curFile,
int isPrImg,
int hduType,
int argc,
char *const argv[] )
{
int nRows, nCols;
int nElement, tmpInt, rowLen;
char **cName, **cType, **cUnit, **cDims;
char **cPost, *extname;
long *tbcol;
int status = 0;
long *naxes;
int i;
int dataType, naxe;
if ( hduType != IMAGE_HDU ) {
/* parse the arg */
if ( Tcl_GetInt(curFile->interp, argv[0], &nRows) != TCL_OK) {
Tcl_SetResult(curFile->interp, "Error getting nRows", TCL_STATIC);
return TCL_ERROR;
}
/* col Name */
if (TCL_OK != Tcl_SplitList(curFile->interp,
argv[1], &nCols, &cName) ){
Tcl_SetResult(curFile->interp, "cannot split colName list",
TCL_STATIC);
return TCL_ERROR;
}
/* col Type */
if (TCL_OK != Tcl_SplitList(curFile->interp,
argv[2], &nElement, &cType) ){
Tcl_SetResult(curFile->interp, "cannot split colType list",
TCL_STATIC);
return TCL_ERROR;
}
if ( nElement != nCols ) {
Tcl_SetResult(curFile->interp, "colType list doesn't match nCols",
TCL_STATIC);
return TCL_ERROR;
}
/* col Unit */
if( argc>3 ) {
if (TCL_OK != Tcl_SplitList(curFile->interp,
argv[3], &nElement, &cUnit)) {
Tcl_SetResult(curFile->interp,
"cannot split colUnit list", TCL_STATIC);
return TCL_ERROR;
}
if( nElement>0 && nElement != nCols ) {
Tcl_SetResult(curFile->interp,
"colUnit list doesn't match nCols", TCL_STATIC);
return TCL_ERROR;
}
} else {
cUnit = NULL;
}
}
switch ( hduType ) {
case IMAGE_HDU:
if( isPrImg && argc == 0 ) {
/*
Write an empty primary array
*/
ffphpr(curFile->fptr, 1, 16, 0, NULL, 0, 1, 1, &status);
} else {
char *const *argvPtr; /* Use this preserve argv's const status */
if( argc == 1 ) {
if ( Tcl_SplitList(curFile->interp, argv[0], &nElement, &cPost )
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"Cannot split image parameter list",
TCL_STATIC);
return TCL_ERROR;
}
if ( nElement != 3 ) {
ckfree( (char*)cPost );
Tcl_SetResult(curFile->interp,
"Wrong number of parameter list", TCL_STATIC);
return TCL_ERROR;
}
argvPtr = cPost;
} else if( argc == 3 ) {
argvPtr = argv;
} else {
Tcl_SetResult(curFile->interp,
"Wrong number of parameter list", TCL_STATIC);
return TCL_ERROR;
}
if ( TCL_OK != Tcl_GetInt(curFile->interp, argvPtr[0], &dataType)) {
if( argc==1 ) ckfree( (char*)cPost );
Tcl_SetResult(curFile->interp,
"The image data type is not an integer", TCL_STATIC);
return TCL_ERROR;
}
if ( TCL_OK != Tcl_GetInt(curFile->interp, argvPtr[1], &naxe)) {
if( argc==1 ) ckfree( (char*)cPost );
Tcl_SetResult(curFile->interp,
"The image dimension is not an integer", TCL_STATIC);
return TCL_ERROR;
}
if ( Tcl_SplitList(curFile->interp, argvPtr[2],
&nElement, &cDims )
!= TCL_OK ) {
if( argc==1 ) ckfree( (char*)cPost );
Tcl_SetResult(curFile->interp,
"Cannot split image dimension list", TCL_STATIC);
return TCL_ERROR;
}
if( argc==1 ) ckfree( (char*)cPost );
if ( nElement != naxe ) {
ckfree( (char*)cDims );
Tcl_SetResult(curFile->interp,
"The number of elements in the list "
"does not match naxes", TCL_STATIC);
return TCL_ERROR;
}
naxes = (long *)ckalloc(naxe * sizeof(long));
for ( i =0; i < nElement; i++) {
naxes[i] = atol(cDims[i]);
}
if( isPrImg )
ffphpr(curFile->fptr, 1, dataType, naxe, naxes, 0, 1, 1, &status);
else
ffiimg(curFile->fptr, dataType, naxe, naxes, &status);
ckfree( (char *)naxes);
ckfree( (char *)cDims );
}
break;
case ASCII_TBL:
/* get tbcol */
if( argc>4 ) {
if ( Tcl_SplitList(curFile->interp, argv[4], &nElement, &cPost )
!= TCL_OK ) {
Tcl_SetResult(curFile->interp,
"cannot split tbcol list\n", TCL_STATIC);
return TCL_ERROR;
}
if( nElement>0 && nElement != nCols ) {
ckfree( (char *) cPost);
ckfree( (char *) cName);
ckfree( (char *) cType);
if( cUnit ) ckfree( (char *) cUnit);
Tcl_SetResult(curFile->interp,
"tbcol list doesn't match nCols", TCL_STATIC);
return TCL_ERROR;
}
if( nElement ) {
tbcol = (long *) ckalloc( nCols*sizeof(long) );
for (i=0; i < nCols; i++) {
if( Tcl_GetInt(curFile->interp, cPost[i], &tmpInt) != TCL_OK ) {
ckfree( (char *) cPost);
ckfree( (char *) cName);
ckfree( (char *) cType);
if( cUnit ) ckfree( (char *) cUnit);
Tcl_SetResult(curFile->interp,
"Cannot get colPosition", TCL_STATIC);
return TCL_ERROR;
}
tbcol[i] = tmpInt;
}
} else {
tbcol = NULL;
}
ckfree( (char *) cPost );
} else {
tbcol = NULL;
}
if( argc>5 )
extname = argv[5];
else
extname = "";
if( argc>6 )
Tcl_GetInt(curFile->interp, argv[6], &rowLen );
else
rowLen = 0;
ffitab(curFile->fptr, rowLen, nRows, nCols, cName, tbcol, cType,
cUnit, extname, &status);
ckfree( (char *) cName);
ckfree( (char *) cType);
if( cUnit ) ckfree( (char *) cUnit);
if( tbcol ) ckfree( (char *) tbcol);
break;
case BINARY_TBL:
if( argc>4 )
extname = argv[4];
else
extname = "";
ffibin(curFile->fptr, nRows, nCols, cName, cType, cUnit,
extname, 0, &status);
ckfree( (char *) cName);
ckfree( (char *) cType);
if( cUnit ) ckfree( (char *) cUnit);
break;
default:
Tcl_SetResult(curFile->interp, "Unknown Type", TCL_STATIC);
return TCL_ERROR;
}
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
/* now update */
if ( TCL_OK != fitsUpdateCHDU(curFile, hduType) ) return TCL_ERROR;
if ( TCL_OK != fitsLoadHDU(curFile) ) return TCL_ERROR;
return TCL_OK;
}
/*
* Function for deleting keywords
*
*/
int fitsDeleteKwds( FitsFD *curFile,
char *keyList )
{
char *tokptr;
int status = 0;
char *keyName;
int tmpInt;
/* get the keywords from the list */
tokptr = strtok(keyList, " ");
while ( tokptr ) {
if (TCL_OK == Tcl_GetInt(curFile->interp, tokptr, &tmpInt) ) {
ffdrec(curFile->fptr, tmpInt, &status);
} else {
Tcl_ResetResult(curFile->interp);
strToUpper(tokptr, &keyName);
ffdkey(curFile->fptr, keyName, &status);
ckfree((char *) keyName);
}
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
tokptr = strtok(NULL, " ");
}
return fitsUpdateFile(curFile);
}
int fitsPutKwds( FitsFD *curFile,
int nkey,
char *inCard,
int ifFormat )
{
char card[FLEN_CARD],orig[FLEN_CARD];
char keyName[FLEN_KEYWORD];
char keyword[FLEN_KEYWORD];
char val[FLEN_VALUE];
char comm[FLEN_COMMENT];
int i, hdtype;
int status = 0;
if ( ifFormat == 1 ) {
if( !strncmp(inCard,"HIERARCH ",9) ) inCard+=9;
ffgthd(inCard, card, &hdtype, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
} else {
strncpy(keyword, inCard, 8);
keyword[8] = '\0';
fftkey(keyword, &status);
strncpy(card, inCard, 80);
card[80] = '\0';
ffpsvc(card, val, comm, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
}
if ( nkey ) {
ffgrec(curFile->fptr, nkey, orig, &status);
ffmrec(curFile->fptr, nkey, card, &status);
} else {
for (i=0; i<8; i++) {
if ( card[i] == ' ' ) break;
keyName[i] = card[i];
}
keyName[i] = '\0';
ffgcrd(curFile->fptr, keyName, orig, &status);
if( status==KEY_NO_EXIST ) {
orig[0]='\0';
status=0;
ffcmsg();
}
ffucrd(curFile->fptr, keyName, card, &status);
}
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
Tcl_SetResult(curFile->interp, card, TCL_VOLATILE);
if( fitsUpdateFile(curFile)==TCL_ERROR ) {
if( nkey )
ffmrec(curFile->fptr, nkey, orig, &status);
else {
/* Reset location to start of header */
ffgrec(curFile->fptr, 0, card, &status);
if( *orig )
ffucrd(curFile->fptr, keyName, orig, &status);
else
ffdkey(curFile->fptr, keyName, &status);
}
ffrhdu(curFile->fptr, &hdtype, &status);
fitsUpdateFile(curFile);
return TCL_ERROR;
}
return TCL_OK;
}
int fitsInsertKwds( FitsFD *curFile,
int index,
char *inCard,
int ifFormat )
{
char card[FLEN_CARD];
char keyword[FLEN_KEYWORD];
char val[FLEN_VALUE];
char comm[FLEN_COMMENT];
long headend;
int hdtype;
int status = 0;
if ( ifFormat == 1 ) {
/* from the templet, get the card */
if( strncmp(inCard,"HIERARCH ",9)==0 ) inCard+=9;
ffgthd(inCard, card, &hdtype, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
} else {
strncpy(keyword, inCard, 8);
keyword[8] = '\0';
fftkey(keyword, &status);
ffpsvc(inCard, val, comm, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
strcpy(card, inCard);
}
Tcl_SetResult(curFile->interp, card, TCL_VOLATILE);
/* insert */
ffirec(curFile->fptr, index, card, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
headend = curFile->fptr->Fptr->headend;
if( fitsUpdateFile(curFile)==TCL_ERROR ) {
/* Error recovery */
curFile->fptr->Fptr->headend = headend;
ffdrec(curFile->fptr, index, &status);
ffrhdu(curFile->fptr, &hdtype, &status);
fitsUpdateFile(curFile);
return TCL_ERROR;
}
return TCL_OK;
}
/**********/
int fitsDeleteCols( FitsFD *curFile,
int *colList,
int numCols )
{
int status = 0;
int i,j,tmp;
/* Need to make sure colList is sorted, then delete in reverse */
for ( i = 1; i tmp ) {
colList[j] = colList[j-1];
j--;
}
colList[j] = tmp;
}
while( numCols-- ) {
ffdcol(curFile->fptr, colList[numCols], &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
}
return fitsUpdateFile(curFile);
}
/**********/
int fitsDeleteRowlist ( FitsFD *curFile,
long* rowlist,
int numRows )
{
int status = 0;
ffdrws(curFile->fptr, rowlist, numRows, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/**********/
int fitsDeleteRowsRange( FitsFD *curFile,
char * rangelist)
{
int status = 0;
ffdrrg(curFile->fptr, rangelist, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/**********/
int fitsDeleteRows( FitsFD *curFile,
int firstRow,
int numRows )
{
int status = 0;
ffdrow(curFile->fptr, firstRow, numRows, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/***************/
int fitsDeleteCHdu( FitsFD *curFile )
{
int status = 0;
int newHduType;
char result[80];
ffdhdu(curFile->fptr, &newHduType, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
sprintf(result, "%d", newHduType);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return fitsUpdateFile(curFile);
}
/* all numbers are 1-based, including baseColNum */
int saveVectorTableToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int baseColNum,
int ifCSV,
int ifPrintRow,
char *sepString,
int ifVariableVec)
{
FILE *fPtr;
char outFStr[80];
LONGLONG k,m;
int anyf;
char **cValue;
short shtValue[1];
int intValue[1];
long longValue[1];
LONGLONG longlongValue[1];
double dblValue[1];
float fValue[1];
char xValue[1];
double dblComplex[2];
float fltComplex[2];
char nullArray[1];
char strNullVal[]="NULL";
unsigned char binValue[1];
char lValue[1];
char colFormat[80];
char cplxFormat[80];
char outputStr[80];
int tmpInt;
char varIndex[80];
int dataType;
int status=0;
char errMsg[160];
int naxis;
long naxes[3];
if ( ifCSV == 1) {
sepString = (char *) ckalloc(4);
strcpy(sepString,"\",\"");
}
if( !strcmp(fileStatus,"0") ) { /* Create new file */
if ( ( fPtr = fopen(filename, "w")) == NULL ) {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,"Cannot open file ", filename,
(char*)NULL);
return TCL_ERROR;
}
} else { /* Append data only to file */
if ( ( fPtr = fopen(filename, "a")) == NULL ) {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,"Cannot open file ", filename,
(char*)NULL);
return TCL_ERROR;
}
}
strcpy(colFormat, curFile->CHDUInfo.table.colFormat[baseColNum-1]);
dataType = curFile->CHDUInfo.table.colDataType[baseColNum-1];
for (m=fRow; m < (fRow+nRows); m++ ) {
if ( ifCSV == 1 )
fprintf(fPtr, "\"");
if ( ifPrintRow == 1 ) {
sprintf(outputStr, "%d", m);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
saveVectorTableRowToAscii(curFile, filename, fileStatus, m, 1, fCol, nCols, baseColNum, ifCSV,
ifPrintRow, sepString, ifVariableVec, colFormat, dataType, fPtr, 0);
if ( ifCSV == 1)
fprintf(fPtr, "\"");
fprintf(fPtr,"\n");
}
fclose(fPtr);
return TCL_OK;
}
int saveVectorTableRowToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int baseColNum,
int ifCSV,
int ifPrintRow,
char *sepString,
int ifVariableVec,
char *colFormat,
int dataType,
FILE *fPtr,
int ifFixedFormat)
{
char outFStr[80];
LONGLONG k,m;
int anyf;
char **cValue;
short shtValue[1];
int intValue[1];
long longValue[1];
LONGLONG longlongValue[1];
double dblValue[1];
float fValue[1];
char xValue[1];
double dblComplex[2];
float fltComplex[2];
char nullArray[1];
char strNullVal[]="NULL";
unsigned char binValue[1];
char lValue[1];
char cplxFormat[80];
char outputStr[80];
int tmpInt;
char varIndex[80];
int status=0;
char errMsg[160];
int naxis;
long naxes[3];
for ( k = fCol; k <= (fCol+nCols-1); k++ ) {
switch ( dataType ) {
case TSTRING:
tmpInt = curFile->CHDUInfo.table.strSize[ baseColNum-1 ]+1;
cValue = (char **) makeContigArray(2, tmpInt, 'c');
ffgcls(curFile->fptr,
baseColNum,
fRow,
k,
1,
1,
strNullVal,
cValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else {
sprintf(outputStr, colFormat, cValue[0]);
}
ckfree( (char *) cValue[0]);
ckfree( (char *) cValue);
break;
/* not implemented yet */
case TLOGICAL:
ffgcfl(curFile->fptr,
baseColNum,
fRow,
k,
1,
lValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
/* valObj = cnstObj[ cnstUndefObj ]; */
} else {
if (lValue[0] == 1) {
/* valObj = cnstObj[ cnstTrueObj ]; */
} else {
/* valObj = cnstObj[ cnstFalseObj ]; */
}
}
break;
case TBIT:
ffgcx(curFile->fptr,
baseColNum,
fRow,
k,
1,
xValue,
&status);
if ( status > 0 ) {
status = 0;
ffcmsg();
} else {
sprintf(outputStr,colFormat,xValue[0]);
}
break;
case TBYTE:
case TSHORT:
case TINT:
case TLONG:
ffgcfj(curFile->fptr,
baseColNum,
fRow,
k,
1,
longValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if ( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFormat,longValue[0]);
}
break;
case TFLOAT:
case TDOUBLE:
ffgcfd(curFile->fptr,
baseColNum,
fRow,
k,
1,
dblValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
/* */
} else {
if( strchr(colFormat,'d') ) {
sprintf(outputStr, "%.0f", dblValue[0]);
tmpInt = atoi(outputStr);
sprintf(outputStr,colFormat,tmpInt);
} else if( strchr(colFormat,'s') ) {
sprintf(outputStr, "%f", dblValue[0]);
sprintf(outputStr,colFormat,outputStr);
} else {
sprintf(outputStr,colFormat,dblValue[0]);
}
}
break;
case TLONGLONG:
ffgcfjj(curFile->fptr,
baseColNum,
fRow,
k,
1,
longlongValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
/* */
} else {
strcpy(outputStr,longlongValue[0]);
}
break;
default:
sprintf(errMsg,"ERROR");
Tcl_SetResult(curFile->interp,errMsg,TCL_VOLATILE);
return TCL_ERROR;
}
fprintf(fPtr, outputStr);
if ( k != (fCol+nCols-1) )
fprintf(fPtr, sepString);
}
return TCL_OK;
}
/***************/
/*
* save current table to an ascii file
*/
int saveTableToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int felem,
int fRow,
int nRows,
int nCols,
int colTypes[],
int colNums[],
int strSize[],
int ifFixedFormat,
int ifCSV,
int ifPrintRow,
char *sepString)
{
FILE *fPtr;
int m, j, k;
char rowFormatStr[10];
char **outFStr;
char **tmpFStr;
char **colFStr;
char **cValue;
short shtValue[1];
int intValue[1];
long longValue[1];
LONGLONG longlongValue[1];
double dblValue[1];
float fValue[1];
double dblComplex[2];
float fltComplex[2];
char nullArray[1];
char strNullVal[]="NULL";
unsigned char binValue[1];
char lValue[1];
char *outputStr;
char errMsg[80];
long tmplong[1];
int tmpInt;
int anyf;
int cnt;
int status=0;
/* create a minimum large enough to encompass the row string */
int maxWidth = 8;
char colFormat[80];
int dataType;
int ifVariableVec;
if ( ifCSV == 1) {
sepString = (char *) ckalloc(4);
strcpy(sepString,"\",\"");
}
/* outFStr pads columns with extra spaces in Fixed Format */
outFStr = (char **) makeContigArray(nCols, 80, 'c');
tmpFStr = (char **) makeContigArray(nCols, 80, 'c');
colFStr = (char **) makeContigArray(nCols, 80, 'c');
for (k=0; k< nCols; k++) {
if ( ifFixedFormat == 1) {
sprintf(outFStr[k]," %%%ds", strSize[k]);
sprintf(rowFormatStr," %%%ds", 8);
} else {
strcpy(outFStr[k],"%s");
strcpy(rowFormatStr,"%s");
}
strcpy(colFStr[k], curFile->CHDUInfo.table.colFormat[colNums[k]-1]);
if( strSize[k] > maxWidth ) maxWidth = strSize[k];
}
cValue = (char **) makeContigArray(1, maxWidth+1, 'c');
outputStr = (char *) ckalloc( (maxWidth+1) * sizeof(char) );
if( !strcmp(fileStatus,"0") ) { /* Create new file */
if ( ( fPtr = fopen(filename, "w")) == NULL ) {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,"Cannot open file ", filename,
(char*)NULL);
return TCL_ERROR;
}
/* Don't print column names until we decide format */
if ( ifFixedFormat == 1 ) {
if ( ifPrintRow == 1 ) {
strcpy(outputStr,"Row");
fprintf(fPtr,rowFormatStr,outputStr);
}
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colName[colNums[k]-1]);
}
fprintf(fPtr,"\n");
if ( ifPrintRow == 1 ) {
strcpy(outputStr," ");
fprintf(fPtr,rowFormatStr,outputStr);
}
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colType[colNums[k]-1]);
}
fprintf(fPtr,"\n");
if ( ifPrintRow == 1 ) {
strcpy(outputStr," ");
fprintf(fPtr,rowFormatStr,outputStr);
}
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colUnit[colNums[k]-1]);
}
fprintf(fPtr,"\n");
}
} else if( !strcmp(fileStatus,"1") ) { /* Append to file with header */
if ( ( fPtr = fopen(filename, "a")) == NULL ) {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,"Cannot open file ", filename,
(char*)NULL);
return TCL_ERROR;
}
fprintf(fPtr,"\n");
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colName[colNums[k]-1]);
}
fprintf(fPtr,"\n");
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colType[colNums[k]-1]);
}
fprintf(fPtr,"\n");
for (k=0; k< nCols; k++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[k]-1 ];
if ( tmpInt != 1 ) {
if ( ifFixedFormat == 1 ) {
sprintf(outFStr[k]," %%%ds", strSize[k] * tmpInt - (tmpInt - 1));
}
}
fprintf(fPtr,outFStr[k],curFile->CHDUInfo.table.colUnit[colNums[k]-1]);
}
fprintf(fPtr,"\n");
} else { /* Append data only to file */
if ( ( fPtr = fopen(filename, "a")) == NULL ) {
Tcl_ResetResult(curFile->interp);
Tcl_AppendResult(curFile->interp,"Cannot open file ", filename,
(char*)NULL);
return TCL_ERROR;
}
}
for (m= 0; m < nRows; m++ ) {
if ( ifCSV == 1 )
fprintf(fPtr, "\"");
if ( ifPrintRow == 1 ) {
int rowNum = fRow + m;
sprintf(outputStr, "%d", rowNum);
if ( ifFixedFormat == 1 ) {
/* pad the row number with blank spaces */
fprintf(fPtr, rowFormatStr, outputStr);
} else {
/* don't pad */
fprintf(fPtr, outputStr);
}
fprintf(fPtr, sepString);
}
for (j=0; j< nCols; j++) {
tmpInt = curFile->CHDUInfo.table.vecSize[ colNums[j]-1 ];
if ( tmpInt != 1 ) {
dataType = curFile->CHDUInfo.table.colDataType[colNums[j]-1];
ifVariableVec = 0;
if ( ifFixedFormat == 1 ) {
fprintf(fPtr,"%3s"," ");
}
saveVectorTableRowToAscii(curFile, filename, fileStatus, m+1, 1, 1, tmpInt, colNums[j], ifCSV,
0, sepString, ifVariableVec, colFStr[j], dataType, fPtr, ifFixedFormat);
if ( ifFixedFormat == 0 ) {
if ( j < nCols-1 ) {
fprintf(fPtr,sepString);
}
}
} else {
switch (curFile->CHDUInfo.table.colDataType[colNums[j]-1]) {
case TSTRING:
ffgcls(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
1,
strNullVal,
cValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else {
sprintf(outputStr,colFStr[j],cValue[0]);
}
break;
case TLOGICAL:
ffgcfl(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
lValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
sprintf(outputStr,colFStr[j],"U");
} else {
if( lValue[0] ) {
sprintf(outputStr,colFStr[j],"T");
} else {
sprintf(outputStr,colFStr[j],"F");
}
}
break;
case TBIT:
ffgcfb(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
binValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],binValue[0]);
}
break;
case TBYTE:
ffgcfb(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
binValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],binValue[0]);
}
break;
case TSHORT:
ffgcfi(curFile->fptr,
colNums[j],
m+fRow,
1,
1,
shtValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],shtValue[0]);
}
break;
case TINT:
ffgcfk(curFile->fptr,
colNums[j],
m+fRow,
1,
1,
intValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],intValue[0]);
}
break;
case TLONG:
ffgcfj(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
longValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],longValue[0]);
}
break;
case TFLOAT:
ffgcfe(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
fValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
sprintf(outputStr,colFStr[j],fValue[0]);
}
break;
case TDOUBLE:
ffgcfd(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
dblValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
if (strchr(colFStr[j],'d') !=NULL) {
sprintf(outputStr, "%.0f", dblValue[0]);
tmpInt = atoi(outputStr);
sprintf(outputStr,colFStr[j],tmpInt);
} else {
sprintf(outputStr,colFStr[j],dblValue[0]);
}
}
break;
case TLONGLONG:
ffgcfjj(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
longlongValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL");
} else {
#ifdef __WIN32__
sprintf(outputStr,"%I64d",longlongValue[0]);
#else
sprintf(outputStr,"%lld",longlongValue[0]);
#endif
/* strcpy(outputStr,longlongValue[0]); */
}
break;
case TCOMPLEX:
ffgcfc(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
fltComplex,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL, NULL");
} else {
sprintf(outputStr,"%.5f, %.5f",fltComplex[0],fltComplex[1]);
}
break;
case TDBLCOMPLEX:
ffgcfm(curFile->fptr,
colNums[j],
m+fRow,
felem,
1,
dblComplex,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
strcpy(outputStr," ");
status = 0;
ffcmsg();
} else if( anyf ) {
strcpy(outputStr,"NULL, NULL");
} else {
sprintf(outputStr,"%.8f, %.8f",dblComplex[0],
dblComplex[1]);
}
break;
default:
sprintf(errMsg,"Unrecognized colType: %d for column %d\n",
colTypes[j],colNums[j]);
Tcl_SetResult(curFile->interp,errMsg,TCL_VOLATILE);
ckfree( (char *) outFStr[0]);
ckfree( (char *) colFStr[0]);
ckfree( (char *) outFStr);
ckfree( (char *) colFStr);
ckfree( (char *) cValue[0]);
ckfree( (char *) cValue);
ckfree( (char *) outputStr );
fclose(fPtr);
return TCL_ERROR;
}
fprintf(fPtr, outFStr[j], outputStr);
if ( ifFixedFormat == 0 ) {
if ( j != nCols-1 )
/* print sepString if we're not on last column */
fprintf(fPtr, sepString);
}
}
}
if (ifCSV == 1) {
fprintf(fPtr,"\"");
}
fprintf(fPtr,"\n");
}
fclose(fPtr);
ckfree( (char *) outFStr[0]);
ckfree( (char *) outFStr);
ckfree( (char *) colFStr[0]);
ckfree( (char *) colFStr);
ckfree( (char *) cValue[0]);
ckfree( (char *) cValue);
ckfree( (char *) outputStr );
return TCL_OK;
}
/* save image table to an ascii file */
int saveImageToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int cellSize,
int ifCSV,
int ifPrintRow,
char *sepString,
long slice )
{
FILE *fPtr;
char outFStr[80];
int i,j;
unsigned char *byteData;
short *shortData;
int *intData;
float *floatData;
double *dblData;
LONGLONG *longlongData;
char *nullArray;
long tmpIndex;
char outputStr[1024];
long blc[FITS_MAXDIMS], trc[FITS_MAXDIMS], incrc[FITS_MAXDIMS];
int anyNul;
int naxes, flip=0;
int xDim, yDim;
char result[80];
int status=0;
naxes = curFile->CHDUInfo.image.naxes;
if( naxes > 3 ) {
for (i = 3; i < naxes; i++) {
if (curFile->CHDUInfo.image.naxisn[i] != 1) {
Tcl_SetResult(curFile->interp,
"Can only read L X M X N X 1 ... images",
TCL_STATIC);
return TCL_ERROR;
}
}
}
if( naxes > FITS_MAXDIMS ) {
sprintf(result,"Image exceeds %d dimensions", FITS_MAXDIMS);
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return TCL_ERROR;
}
xDim = curFile->CHDUInfo.image.naxisn[0];
if( naxes>1 ) {
yDim = curFile->CHDUInfo.image.naxisn[1];
} else {
yDim = 1;
if( (fCol>1 && fRow>1) || (nRows>1 && nCols>1) ) {
Tcl_SetResult(curFile->interp,
"Cannot read 2D block from a 1D image",
TCL_STATIC);
return TCL_ERROR;
}
if( fRow>2 || nRows>2 ) {
/* Interpret 1D image as a column */
flip = 1;
yDim = xDim; xDim = 1;
}
}
if ( fRow+nRows > yDim ) {
nRows = yDim - fRow +1;
}
if ( fCol+nCols > xDim ) {
nCols = xDim - fCol +1;
}
if( flip ) {
blc[0] = fRow;
trc[0] = fRow+nRows-1;
incrc[0] = 1;
} else {
blc[0] = fCol;
trc[0] = fCol+nCols-1;
incrc[0] = 1;
}
if( naxes>1 ) {
blc[1] = fRow;
trc[1] = fRow+nRows-1;
incrc[1] = 1;
if( naxes>2 ) {
blc[2] = slice;
trc[2] = slice;
incrc[2] = 1;
for (i=3; i < naxes; i++) {
blc[i] = 1;
trc[i] = 1;
incrc[i] = 1;
}
}
}
if( !strcmp(fileStatus,"0") ) {
if ( ( fPtr = fopen(filename, "w")) == NULL ) {
Tcl_SetResult(curFile->interp, "Cannot open file ", TCL_STATIC);
Tcl_AppendResult(curFile->interp, filename, (char*)NULL);
return TCL_ERROR;
}
} else {
if ( ( fPtr = fopen(filename, "a")) == NULL ) {
Tcl_SetResult(curFile->interp, "Cannot open file ", TCL_STATIC);
Tcl_AppendResult(curFile->interp, filename, (char*)NULL);
return TCL_ERROR;
}
}
/* not used, we aren't using fixed format that uses padded spaces */
sprintf(outFStr, "%%%ds", cellSize);
nullArray = (char *) ckalloc(nCols*nRows*sizeof(char));
if ( ifCSV == 1) {
sepString = (char *) ckalloc(4);
strcpy(sepString,"\",\"");
}
if( !strcmp(fileStatus,"0") ) {
/* print columns, appropriately formatted */
}
switch( curFile->CHDUInfo.image.dataType ) {
case TDOUBLE:
dblData = (double *) ckalloc(nCols*nRows*sizeof(double));
memset (dblData, NULL, nCols*nRows*sizeof(double));
ffgsfd(curFile->fptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
dblData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) dblData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1 )
fprintf(fPtr, "\"");
if ( ifPrintRow == 1 ) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; ifptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
longlongData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) longlongData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1 )
fprintf(fPtr, "\"");
if ( ifPrintRow == 1 ) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; ifptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
floatData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) floatData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1)
fprintf(fPtr, "\"");
if ( ifPrintRow == 1) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; ifptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
intData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) intData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1)
fprintf(fPtr, "\"");
if ( ifPrintRow == 1) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; ifptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
shortData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) shortData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1)
fprintf(fPtr, "\"");
if ( ifPrintRow == 1) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; ifptr,
0,
curFile->CHDUInfo.image.naxes,
curFile->CHDUInfo.image.naxisn,
blc,
trc,
incrc,
byteData,
nullArray,
&anyNul,
&status);
if ( status > 0 ) {
Tcl_SetResult(curFile->interp,
"Error reading image\n", TCL_STATIC);
dumpFitsErrStack( curFile->interp, status );
ckfree( (char *) byteData);
return TCL_ERROR;
}
for (j=0; j < nRows; j++ ) {
/*
for (j=nRows-1; j>=0; j-- ) {
*/
if ( ifCSV == 1)
fprintf(fPtr, "\"");
if ( ifPrintRow == 1) {
int rowNum = fRow + j;
sprintf(outputStr, "%d", rowNum);
fprintf(fPtr, outputStr);
fprintf(fPtr, sepString);
}
for (i=0; iinterp, "Unknown image type", TCL_STATIC);
fclose(fPtr);
return TCL_ERROR;
}
ckfree((char *)nullArray);
fclose(fPtr);
return TCL_OK;
}
/* save a column in memory to a table */
int varSaveToTable( FitsFD *curFile,
int colNum,
long firstRow,
long firstElem,
long numRows,
long numElem,
Tcl_Obj **dataElems )
{
int status = 0;
int colDataType, colVecSize;
int i;
void *dataArray;
char **strArray;
char *bitArray;
long *lngArray;
double *dblArray;
LONGLONG *longlongArray;
char *tokenPtr;
char *strPtr;
char *nulFlag;
int iVal;
long lVal;
double dVal;
Tcl_Obj **cpxList;
int nCpx;
/* check the number of the input array and the number specified */
colDataType = curFile->CHDUInfo.table.colDataType[colNum-1];
colVecSize = curFile->CHDUInfo.table.vecSize[colNum-1];
if( colVecSize == 0 ) return TCL_OK;
if( colVecSize == 1 || colDataType == TSTRING ) {
/* this is not a vector column, do as usual */
if ( numRows != numElem ) {
Tcl_SetResult(curFile->interp, "fitsTcl Error: "
"the number of the elements in the input "
"array does not match the specified row range.",
TCL_STATIC);
return TCL_ERROR;
}
} else { /* this is a vector column, write to the vector element */
numRows = numElem;
}
nulFlag = (char *) ckalloc(numRows*sizeof(char));
switch ( colDataType ) {
case TSTRING:
strArray = (char **) ckalloc(numRows * sizeof(char*));
dataArray = strArray;
for ( i = 0; i < numRows; i++ ) {
strArray[i] = Tcl_GetStringFromObj( dataElems[i], NULL );
if( !strcmp("NULL",strArray[i]) ) {
nulFlag[i] = 1;
} else {
nulFlag[i] = 0;
}
}
break;
case TLOGICAL:
bitArray = (char *) ckalloc(numRows * sizeof(char));
dataArray = bitArray;
for ( i= 0; i < numRows; i++ ) {
if( Tcl_GetBooleanFromObj( curFile->interp, dataElems[i], &iVal )
!= TCL_OK ) {
bitArray[i] = 0;
nulFlag[i] = 1;
} else {
bitArray[i] = iVal;
nulFlag[i] = 0;
}
}
break;
case TBIT:
bitArray = (char *) ckalloc(numRows * sizeof(char));
dataArray = bitArray;
for ( i= 0; i < numRows; i++ ) {
if( Tcl_GetLongFromObj( curFile->interp, dataElems[i], &lVal )
!= TCL_OK ) {
strPtr = Tcl_GetStringFromObj( dataElems[i], NULL );
if( !strcmp(strPtr,"NULL") ) {
bitArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
} else {
bitArray[i] = lVal;
nulFlag[i] = 0;
}
}
break;
case TBYTE:
case TSHORT:
case TINT:
colDataType = TLONG;
/* Fallthrough */
case TLONG:
lngArray = (long *) ckalloc(numRows * sizeof(long));
dataArray = lngArray;
for ( i= 0; i < numRows; i++ ) {
if( Tcl_GetLongFromObj( curFile->interp, dataElems[i], &lVal )
!= TCL_OK ) {
if( Tcl_GetDoubleFromObj( curFile->interp, dataElems[i], &dVal )
!= TCL_OK ) {
strPtr = Tcl_GetStringFromObj( dataElems[i], NULL );
if( !strcmp(strPtr,"NULL") ) {
lngArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
} else {
lngArray[i] = dVal;
nulFlag[i] = 0;
}
} else {
lngArray[i] = lVal;
nulFlag[i] = 0;
}
}
break;
case TFLOAT:
colDataType = TDOUBLE;
/* Fallthrough */
case TDOUBLE:
dblArray = (double *) ckalloc(numRows * sizeof(double));
dataArray = dblArray;
for ( i= 0; i < numRows; i++ ) {
if( Tcl_GetDoubleFromObj( curFile->interp, dataElems[i], &dVal )
!= TCL_OK ) {
strPtr = Tcl_GetStringFromObj( dataElems[i], NULL );
if( !strcmp(strPtr,"NULL") ) {
dblArray[i] = 0.0;
nulFlag[i] = 1;
} else {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
} else {
dblArray[i] = dVal;
nulFlag[i] = 0;
}
}
break;
case TLONGLONG:
longlongArray = (LONGLONG *) ckalloc(numRows * sizeof(LONGLONG));
dataArray = longlongArray;
for ( i= 0; i < numRows; i++ ) {
strPtr = Tcl_GetStringFromObj( dataElems[i], NULL );
if ( !strcmp(strPtr,"NULL") ) {
nulFlag[i] = 1;
} else {
nulFlag[i] = 0;
}
longlongArray[i] = fitsTcl_atoll(strPtr);
}
break;
case TCOMPLEX:
colDataType = TDBLCOMPLEX;
/* Fallthrough */
case TDBLCOMPLEX:
dblArray = (double *) ckalloc(2 * numRows * sizeof(double));
dataArray = dblArray;
for ( i= 0; i < numRows; i++ ) {
if( Tcl_ListObjGetElements( curFile->interp, dataElems[i],
&nCpx, &cpxList )
!= TCL_OK ) {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
if( nCpx < 0 || nCpx > 2 ) {
Tcl_SetResult( curFile->interp, "Complex element did not contain "
"1 or 2 values", TCL_STATIC );
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
if( Tcl_GetDoubleFromObj( curFile->interp, cpxList[0], &dVal )
!= TCL_OK ) {
strPtr = Tcl_GetStringFromObj( cpxList[0], NULL );
if( !strncmp(strPtr,"NULL",4) ) {
dblArray[i+i] = 0.0;
nulFlag[i] = 1;
nCpx = 1;
} else if( strchr(strPtr, ',') ) {
dblArray[i+i] = atof(strPtr);
if( nCpx==1 ) {
strPtr = strchr(strPtr, ',') + 1;
dblArray[i+i+1] = atof(strPtr);
nCpx = 0;
}
nulFlag[i] = 0;
} else {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
}
} else {
dblArray[i+i] = dVal;
nulFlag[i] = 0;
}
if( nCpx == 2 ) {
if( Tcl_GetDoubleFromObj( curFile->interp, cpxList[1], &dVal )
!= TCL_OK ) {
ckfree( (char*)nulFlag );
ckfree( (char*)dataArray );
return TCL_ERROR;
} else {
dblArray[i+i+1] = dVal;
}
} else if( nCpx == 1 ) { /* Make explicit to allow fallthrough */
dblArray[i+i+1] = 0.0;
}
}
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: unknown column type", TCL_STATIC);
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
/* Write Data */
ffpcl(curFile->fptr, colDataType, colNum, firstRow,
firstElem, numRows, dataArray, &status);
ckfree( (char*)dataArray );
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
/* Flag Nulls */
if ( colVecSize == 1 || colDataType == TSTRING ) {
for (i=0; i< numRows; i++) {
if ( nulFlag[i] ) {
ffpclu(curFile->fptr, colNum, firstRow+i, firstElem, 1, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
}
}
} else {
for (i=0; i< numRows; i++) {
if ( nulFlag[i] ) {
ffpclu(curFile->fptr, colNum, firstRow, firstElem+i, 1, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
}
}
}
ckfree((char *) nulFlag);
return fitsUpdateFile(curFile);
}
int addColToTable( FitsFD *curFile,
int colNum,
char *ttype,
char *tform )
{
int status = 0;
fficol(curFile->fptr, colNum, ttype, tform, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
int addRowToTable( FitsFD *curFile,
int rowNum,
int nRows )
{
int status = 0;
ffirow(curFile->fptr, rowNum, nRows, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/* save to an image */
int varSaveToImage( FitsFD *curFile,
long firstElem,
long numElem,
Tcl_Obj **listArray )
{
int status = 0, i;
void *dataArray;
unsigned char *bytArray;
short *shtArray;
int *intArray;
long *lngArray;
float *fltArray;
double *dblArray;
LONGLONG *longlongArray;
char *strPtr;
char *nulFlag;
char *objStr;
long longVal;
double dblVal;
nulFlag = (char *) ckalloc(numElem*sizeof(char));
switch ( curFile->CHDUInfo.image.dataType ) {
case TBYTE:
bytArray = (unsigned char *) ckalloc(numElem * sizeof(unsigned char));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetLongFromObj( curFile->interp, *listArray, &longVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
bytArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)bytArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
bytArray[i] = longVal;
nulFlag[i] = 0;
}
}
dataArray = bytArray;
break;
case TSHORT:
shtArray = (short *) ckalloc(numElem * sizeof(short));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetLongFromObj( curFile->interp, *listArray, &longVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
shtArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)shtArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
shtArray[i] = longVal;
nulFlag[i] = 0;
}
}
dataArray = shtArray;
break;
case TINT:
intArray = (int *) ckalloc(numElem* sizeof(int));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetLongFromObj( curFile->interp, *listArray, &longVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
intArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)intArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
intArray[i] = longVal;
nulFlag[i] = 0;
}
}
dataArray = intArray;
break;
case TLONG:
lngArray = (long *) ckalloc(numElem* sizeof(long));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetLongFromObj( curFile->interp, *listArray, &longVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
lngArray[i] = 0;
nulFlag[i] = 1;
} else {
ckfree( (char*)lngArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
lngArray[i] = longVal;
nulFlag[i] = 0;
}
}
dataArray = lngArray;
break;
case TFLOAT:
fltArray = (float *) ckalloc(numElem* sizeof(float));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetDoubleFromObj( curFile->interp, *listArray, &dblVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
fltArray[i] = 0.0;
nulFlag[i] = 1;
} else {
ckfree( (char*)fltArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
fltArray[i] = dblVal;
nulFlag[i] = 0;
}
}
dataArray = fltArray;
break;
case TDOUBLE:
dblArray = (double *) ckalloc(numElem* sizeof(double));
for ( i= 0; i < numElem; i++, listArray++ ) {
if( Tcl_GetDoubleFromObj( curFile->interp, *listArray, &dblVal )
!= TCL_OK ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if( !strcmp(objStr, "NULL") ) {
dblArray[i] = 0.0;
nulFlag[i] = 1;
} else {
ckfree( (char*)dblArray );
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
} else {
dblArray[i] = dblVal;
nulFlag[i] = 0;
}
}
dataArray = dblArray;
break;
case TLONGLONG:
longlongArray = (LONGLONG *) ckalloc(numElem* sizeof(LONGLONG));
for ( i= 0; i < numElem; i++, listArray++ ) {
objStr = Tcl_GetStringFromObj( *listArray, NULL );
if ( !strcmp(objStr, "NULL") ) {
nulFlag[i] = 1;
} else {
nulFlag[i] = 0;
}
longlongArray[i] = fitsTcl_atoll(objStr);
}
dataArray = longlongArray;
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: unknown image type", TCL_STATIC);
ckfree( (char*)nulFlag );
return TCL_ERROR;
}
/* Write Data */
ffppr(curFile->fptr, curFile->CHDUInfo.image.dataType,
firstElem, numElem, dataArray, &status);
ckfree((char *) dataArray);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) nulFlag);
return TCL_ERROR;
}
/* Flag Nulls */
for (i=0;ifptr, 1, firstElem+i, 1, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
ckfree((char *) nulFlag);
return TCL_ERROR;
}
}
}
ckfree((char *) nulFlag);
return fitsUpdateFile(curFile);
}
int fitsCopyCHduToFile( FitsFD *curFile,
char *newfilename )
{
fitsfile *newFptr;
int status = 0;
remove(newfilename);
ffinit(&newFptr, newfilename, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
if ( curFile->hduType != IMAGE_HDU ) {
ffphpr(newFptr, 1, 32, 0, NULL, 0, 1, 1, &status);
ffcrhd(newFptr, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
}
ffcopy(curFile->fptr, newFptr, 0, &status);
ffclos(newFptr, &status) ;
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return TCL_OK;
}
int fitsAppendCHduToFile( FitsFD *curFile, char *targetfilename )
{
fitsfile *targFptr;
int status = 0;
int nhdu, hdutype;
/* Do everything... then check status */
ffopen(&targFptr, targetfilename, 1, &status);
ffthdu(targFptr, &nhdu, &status);
ffmahd(targFptr, nhdu, &hdutype, &status);
ffcrhd(targFptr, &status);
ffcopy(curFile->fptr, targFptr, 0, &status);
ffclos(targFptr, &status) ;
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return TCL_OK;
}
int fitsPutHisKwd( FitsFD *curFile, char *his )
{
int status = 0;
ffphis(curFile->fptr, his, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/*********************************************************************/
/* W C S */
/* */
/* extract the world coordinate from a header, return in Matrix form */
/* */
/*********************************************************************/
int fitsFileGetWcsMatrix( FitsFD *curFile, fitsfile *dummyFile, int naxis, int axes[], char dest, Tcl_Obj *data[])
{
int status = 0;
int foundCD= 0;
int foundTp= 0;
int foundBK= 0;
int endBK= 0;
int i = 0;
double refVal[FITS_MAXDIMS], refPix[FITS_MAXDIMS];
double delt[FITS_MAXDIMS], rot, tmp;
double matrix[FITS_MAXDIMS][FITS_MAXDIMS];
int row, col, axisNum[FITS_MAXDIMS];
char keyword[FLEN_VALUE];
char axisType[FITS_MAXDIMS][FLEN_VALUE];
int isImage;
static char *Keys[2][7] = {
{ "TCTYP", "TCUNI", "TCRVL", "TCRPX", "TCD", "TCDLT", "TCROT" },
{ "CTYPE", "CUNIT", "CRVAL", "CRPIX", "CD", "CDELT", "CROTA" }
};
enum { cType=0, cUnit, cRefVal, cRefPix, cMatrix, cDelta, cRota };
/* Init Variables */
if( naxis ) {
isImage = 1;
for( row=0; row1 ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[1], dest);
ffgkyd(dummyFile, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
/* Try other column */
status = 0;
if( !isImage ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[0], dest);
ffgkyd(dummyFile, keyword, &rot,NULL, &status);
if( status==KEY_NO_EXIST ) status=0; else rot = -rot;
}
}
rot *= 1.745329252e-2;
}
for( col=0; colinterp, data[0],
Tcl_NewDoubleObj(refVal[row]) );
Tcl_ListObjAppendElement(curFile->interp, data[1],
Tcl_NewDoubleObj(refPix[row]) );
for( col=0; colinterp, data[2],
Tcl_NewDoubleObj(matrix[row][col]) );
/* if( foundTp == naxis ) { */
if( foundTp > 0 ) {
/* Pan: find out where the break point "-" is */
foundBK = 0;
endBK = -1;
for ( i=0; i< strlen(axisType[row]); i++) {
if (foundBK == 0 && axisType[row][i] == '-')
{
foundBK = 1;
}
if ( foundBK == 1 && axisType[row][i] != '-' ) {
endBK = i - 1;
break;
}
}
if ( endBK >= 0 ) {
Tcl_ListObjAppendElement(curFile->interp, data[4],
Tcl_NewStringObj(axisType[row]+endBK,-1) );
} else {
Tcl_ListObjAppendElement(curFile->interp, data[4], Tcl_NewListObj(0,NULL));
}
for( col=endBK; col>0 && axisType[row][col]=='-'; )
axisType[row][col--] = '\0';
}
Tcl_ListObjAppendElement(curFile->interp, data[3],
Tcl_NewStringObj(axisType[row],-1) );
}
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(5,data) );
return TCL_OK;
}
int fitsGetWcsMatrix( FitsFD *curFile, int naxis, int axes[], char dest )
{
int status = 0;
int foundCD= 0;
int foundTp= 0;
int foundBK= 0;
int endBK= 0;
int i = 0;
double refVal[FITS_MAXDIMS], refPix[FITS_MAXDIMS];
double delt[FITS_MAXDIMS], rot, tmp;
double matrix[FITS_MAXDIMS][FITS_MAXDIMS];
int row, col, axisNum[FITS_MAXDIMS];
char keyword[FLEN_VALUE];
char axisType[FITS_MAXDIMS][FLEN_VALUE];
Tcl_Obj *data[5];
int isImage;
static char *Keys[2][7] = {
{ "TCTYP", "TCUNI", "TCRVL", "TCRPX", "TCD", "TCDLT", "TCROT" },
{ "CTYPE", "CUNIT", "CRVAL", "CRPIX", "CD", "CDELT", "CROTA" }
};
enum { cType=0, cUnit, cRefVal, cRefPix, cMatrix, cDelta, cRota };
/* Init Variables */
if( naxis ) {
isImage = 0;
for( row=0; rowCHDUInfo.image.naxes;
for( row=0; rowfptr, keyword, refVal+row, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefPix], axisNum[row], dest);
ffgkyd(curFile->fptr, keyword, refPix+row, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cType], axisNum[row], dest);
axisType[row][0] = '\0';
ffgkys(curFile->fptr, keyword, axisType[row], NULL, &status);
if( status==KEY_NO_EXIST ) {
status = 0;
memset(axisType[row], '\0', FITS_MAXDIMS * FITS_MAXDIMS );
foundTp++;
} else if( !status ) {
/* Pan: find out if a break point "-" exist */
foundBK = 0;
for ( i=0; i< strlen(axisType[row]); i++) {
if (axisType[row][i] == '-')
{
foundBK = 1;
break;
}
}
/* Pan: if( strlen(axisType[row])==8 && axisType[row][4]=='-' ) */
/* if( strlen(axisType[row])==8 && foundBK == 1) */
if( foundBK == 1)
foundTp++;
}
for( col=0; colfptr, keyword, &matrix[row][col], NULL, &status);
if( status==0 )
foundCD = 1;
else if( status==KEY_NO_EXIST )
status = 0;
}
}
if( !foundCD ) {
rot = 0.0;
if( naxis>1 ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[1], dest);
ffgkyd(curFile->fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
/* Try other column */
status = 0;
if( !isImage ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[0], dest);
ffgkyd(curFile->fptr, keyword, &rot,NULL, &status);
if( status==KEY_NO_EXIST ) status=0; else rot = -rot;
}
}
rot *= 1.745329252e-2;
}
for( col=0; colfptr, keyword, delt+col, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
if( col<2 ) {
for( row=0; rowinterp, data[0],
Tcl_NewDoubleObj(refVal[row]) );
Tcl_ListObjAppendElement(curFile->interp, data[1],
Tcl_NewDoubleObj(refPix[row]) );
for( col=0; colinterp, data[2],
Tcl_NewDoubleObj(matrix[row][col]) );
/* if( foundTp == naxis ) { */
if( foundTp > 0 ) {
/* Pan: find out where the break point "-" is */
foundBK = 0;
endBK = -1;
for ( i=0; i< strlen(axisType[row]); i++) {
if (foundBK == 0 && axisType[row][i] == '-')
{
foundBK = 1;
}
if ( foundBK == 1 && axisType[row][i] != '-' ) {
endBK = i - 1;
break;
}
}
/* Tcl_ListObjAppendElement(curFile->interp, data[4],
Tcl_NewStringObj(axisType[row]+endBK,-1) ); */
if ( endBK >= 0 ) {
Tcl_ListObjAppendElement(curFile->interp, data[4],
Tcl_NewStringObj(axisType[row]+endBK,-1) );
} else {
Tcl_ListObjAppendElement(curFile->interp, data[4], Tcl_NewListObj(0,NULL));
}
for( col=endBK; col>0 && axisType[row][col]=='-'; )
axisType[row][col--] = '\0';
}
Tcl_ListObjAppendElement(curFile->interp, data[3],
Tcl_NewStringObj(axisType[row],-1) );
}
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(5,data) );
ffcmsg();
return TCL_OK;
}
int fitsGetWcsMatrixAlt( FitsFD *curFile, fitsfile *fptr, Tcl_Obj *listObj, int naxis, int axes[], char dest )
{
int status = 0;
int foundCD= 0;
int foundTp= 0;
int foundBK= 0;
int endBK= 0;
int i = 0;
double refVal[FITS_MAXDIMS], refPix[FITS_MAXDIMS];
double delt[FITS_MAXDIMS], rot, tmp;
double matrix[FITS_MAXDIMS][FITS_MAXDIMS];
int row, col, axisNum[FITS_MAXDIMS];
char keyword[FLEN_VALUE];
char axisType[FITS_MAXDIMS][FLEN_VALUE];
Tcl_Obj *data[5];
int isImage;
static char *Keys[2][7] = {
{ "TCTYP", "TCUNI", "TCRVL", "TCRPX", "TCD", "TCDLT", "TCROT" },
{ "CTYPE", "CUNIT", "CRVAL", "CRPIX", "CD", "CDELT", "CROTA" }
};
enum { cType=0, cUnit, cRefVal, cRefPix, cMatrix, cDelta, cRota };
/* Init Variables */
if( naxis ) {
isImage = 0;
for( row=0; row1 ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[1], dest);
ffgkyd(fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
/* Try other column */
status = 0;
if( !isImage ) {
sprintf(keyword,"%s%d%c", Keys[isImage][cRota], axisNum[0], dest);
ffgkyd(fptr, keyword, &rot,NULL, &status);
if( status==KEY_NO_EXIST ) status=0; else rot = -rot;
}
}
rot *= 1.745329252e-2;
}
for( col=0; colinterp, data[0],
Tcl_NewDoubleObj(refVal[row]) );
Tcl_ListObjAppendElement(curFile->interp, data[1],
Tcl_NewDoubleObj(refPix[row]) );
for( col=0; colinterp, data[2],
Tcl_NewDoubleObj(matrix[row][col]) );
/* if( foundTp == naxis ) { */
if( foundTp > 0 ) {
/* Pan: find out where the break point "-" is */
foundBK = 0;
endBK = -1;
for ( i=0; i< strlen(axisType[row]); i++) {
if (foundBK == 0 && axisType[row][i] == '-')
{
foundBK = 1;
}
if ( foundBK == 1 && axisType[row][i] != '-' ) {
endBK = i - 1;
break;
}
}
/* Tcl_ListObjAppendElement(curFile->interp, data[4],
Tcl_NewStringObj(axisType[row]+endBK,-1) ); */
if ( endBK >= 0 ) {
Tcl_ListObjAppendElement(curFile->interp, data[4],
Tcl_NewStringObj(axisType[row]+endBK,-1) );
} else {
Tcl_ListObjAppendElement(curFile->interp, data[4], Tcl_NewListObj(0,NULL));
}
for( col=endBK; col>0 && axisType[row][col]=='-'; )
axisType[row][col--] = '\0';
}
Tcl_ListObjAppendElement(curFile->interp, data[3],
Tcl_NewStringObj(axisType[row],-1) );
}
Tcl_ListObjAppendElement( curFile->interp, listObj, Tcl_NewListObj(5,data) );
Tcl_SetObjResult(curFile->interp, listObj);
ffcmsg();
return TCL_OK;
}
int fitsGetWcsPairAlt( FitsFD *curFile, fitsfile *fptr, Tcl_Obj *listObj, int Col1, int Col2, char dest )
{
int status = 0;
int swap = 0;
double
xrval = 0.0,
yrval = 0.0,
xrpix = 0.0,
yrpix = 0.0,
xinc = 1.0,
yinc = 1.0,
rot = 0.0;
char ctype[FLEN_VALUE], ctemp[FLEN_VALUE];
char keyword[FLEN_VALUE];
double matrix[FITS_MAXDIMS][FITS_MAXDIMS],temp;
int anyKeysFnd;
Tcl_Obj *data[9];
int isImage;
static char *Keys[2][7] = {
{ "TCTYP", "TCUNI", "TCRVL", "TCRPX", "TCD", "TCDLT", "TCROT" },
{ "CTYPE", "CUNIT", "CRVAL", "CRPIX", "CD", "CDELT", "CROTA" }
};
enum { cType=0, cUnit, cRefVal, cRefPix, cMatrix, cDelta, cRota };
if( Col1 && Col2 ) {
isImage = 0;
} else {
isImage = 1;
Col1 = 1;
Col2 = 2;
}
/* Grab any existing WCS keywords. Use defaults for missing values */
sprintf(keyword, "%s%d%c", Keys[isImage][cRefVal], Col1, dest);
ffgkyd(fptr, keyword, &xrval, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefVal], Col2, dest);
ffgkyd(fptr, keyword, &yrval, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefPix], Col1, dest);
ffgkyd(fptr, keyword, &xrpix, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefPix], Col2, dest);
ffgkyd(fptr, keyword, &yrpix, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
anyKeysFnd = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cDelta], Col1, dest);
ffgkyd(fptr, keyword, &xinc, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
sprintf(keyword, "%s%d%c", Keys[isImage][cDelta], Col2, dest);
ffgkyd(fptr, keyword, &yinc, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
sprintf(keyword, "%s%d%c", Keys[isImage][cRota], Col2, dest);
ffgkyd(fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
/* Try other column */
status = 0;
if( !isImage ) {
sprintf(keyword, "%s%d%c", Keys[isImage][cRota], Col1, dest);
ffgkyd(fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
status=0;
} else {
rot = -rot;
anyKeysFnd++;
}
}
} else
anyKeysFnd++;
if( ! anyKeysFnd ) { /* Couldn't find old-style keys; look for new-style */
anyKeysFnd = 0;
matrix[0][0] = 1.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col1, Col1, dest);
ffgkyd(fptr, keyword, &matrix[0][0], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[1][1] = 1.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col2, Col2, dest);
ffgkyd(fptr, keyword, &matrix[1][1], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[0][1] = 0.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col1, Col2, dest);
ffgkyd(fptr, keyword, &matrix[0][1], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[1][0] = 0.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col2, Col1, dest);
ffgkyd(fptr, keyword, &matrix[1][0], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
if( anyKeysFnd ) {
/* Modified from CFITSIO... compute old-style from new-style */
double phia, phib;
double pi = 3.1415926535897932;
/* there are 2 ways to compute the angle: */
phia = atan2d( matrix[1][0], matrix[0][0]);
phib = atan2d(-matrix[0][1], matrix[1][1]);
/* ensure that phia <= phib */
temp = minvalue(phia, phib);
phib = maxvalue(phia, phib);
phia = temp;
/* there is a possible 180 degree ambiguity in the angles */
/* so add 180 degress to the smaller value if the values */
/* differ by more than 90 degrees = pi/2 radians. */
/* (Later, we may decide to take the other solution by */
/* subtracting 180 degrees from the larger value). */
if( (phib - phia) > (pi * 0.5) )
phia += pi;
if( fabs(phia - phib) > 0.0002 ) {
/* angles don't agree, so looks like there is some skewness */
/* between the axes. Return with an error to be safe. */
/* PDW: Lets just ignore this and give the best estimate we can.
status = APPROX_WCS_KEY; */
}
phia = (phia + phib) * 0.5; /* use the average of the 2 values */
temp = cosd(phia);
if( fabs(temp)<0.1 ) {
temp = sind(phia);
xinc = matrix[1][0] / temp;
yinc =-matrix[0][1] / temp;
} else {
xinc = matrix[0][0] / temp;
yinc = matrix[1][1] / temp;
}
rot = phia * 180. / pi;
/* common usage is to have a positive yinc value. If it is */
/* negative, then subtract 180 degrees from rot and negate */
/* both xinc and yinc. */
if( yinc < 0 ) {
xinc = -xinc;
yinc = -yinc;
rot -= 180.0;
}
} /* else keep default delt/rot = 1/0 */
}
/* Read both RA and DEC CTYPs to check that they both exist and agree */
sprintf(keyword, "%s%d%c", Keys[isImage][cType], Col1, dest);
ffgkys(fptr, keyword, ctype, NULL, &status);
sprintf(keyword, "%s%d%c", Keys[isImage][cType], Col2, dest);
ffgkys(fptr, keyword, ctemp, NULL, &status);
if( status || strlen(ctype)<5 || strlen(ctemp)<5
|| strcmp(ctype+4,ctemp+4) ) {
strcpy(ctype,"none"); status = 0;
} else {
if( !strncmp(ctype, "DEC-", 4) || !strncmp(ctype+1, "LAT", 3) ) {
/* RA/Dec are swapped!!! */
swap = 1;
}
/* copy the projection type string */
strncpy(ctype, &ctype[4], 4);
ctype[4] = '\0';
}
data[0] = Tcl_NewDoubleObj(xrval);
data[1] = Tcl_NewDoubleObj(yrval);
data[2] = Tcl_NewDoubleObj(xrpix);
data[3] = Tcl_NewDoubleObj(yrpix);
data[4] = Tcl_NewDoubleObj(xinc);
data[5] = Tcl_NewDoubleObj(yinc);
data[6] = Tcl_NewDoubleObj(rot);
data[7] = Tcl_NewStringObj(ctype,-1);
/*
fprintf(stdout, "xrval: %20.15f, yrval: %20.15f, xrpix: %20.15f, yrpix: %20.15f, xinc: %20.15f, yinc: %20.15f, rot: %20.15f: %20.15f\n", xrval, yrval, xrpix, yrpix, xinc, yinc, rot);
fflush(stdout);
*/
if( userOptions.wcsSwap ) {
data[8] = Tcl_NewBooleanObj( swap );
Tcl_ListObjAppendElement(curFile->interp, listObj, Tcl_NewListObj(9,data) );
} else {
Tcl_ListObjAppendElement(curFile->interp, listObj, Tcl_NewListObj(8,data) );
}
ffcmsg();
Tcl_SetObjResult(curFile->interp, listObj);
return TCL_OK;
}
/* extract the world coordinate from a table */
/* (Old behavior... deprecated) */
/* extract the world coordinate from an image header */
int fitsGetWcsPair( FitsFD *curFile, int Col1, int Col2, char dest )
{
int status = 0;
int swap = 0;
double
xrval = 0.0,
yrval = 0.0,
xrpix = 0.0,
yrpix = 0.0,
xinc = 1.0,
yinc = 1.0,
rot = 0.0;
char ctype[FLEN_VALUE], ctemp[FLEN_VALUE];
char keyword[FLEN_VALUE];
double matrix[FITS_MAXDIMS][FITS_MAXDIMS],temp;
int anyKeysFnd;
Tcl_Obj *data[9];
int isImage;
static char *Keys[2][7] = {
{ "TCTYP", "TCUNI", "TCRVL", "TCRPX", "TCD", "TCDLT", "TCROT" },
{ "CTYPE", "CUNIT", "CRVAL", "CRPIX", "CD", "CDELT", "CROTA" }
};
enum { cType=0, cUnit, cRefVal, cRefPix, cMatrix, cDelta, cRota };
if( Col1 && Col2 ) {
isImage = 0;
} else {
isImage = 1;
Col1 = 1;
Col2 = 2;
}
/* Grab any existing WCS keywords. Use defaults for missing values */
sprintf(keyword, "%s%d%c", Keys[isImage][cRefVal], Col1, dest);
ffgkyd(curFile->fptr, keyword, &xrval, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefVal], Col2, dest);
ffgkyd(curFile->fptr, keyword, &yrval, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefPix], Col1, dest);
ffgkyd(curFile->fptr, keyword, &xrpix, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cRefPix], Col2, dest);
ffgkyd(curFile->fptr, keyword, &yrpix, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0;
anyKeysFnd = 0;
sprintf(keyword, "%s%d%c", Keys[isImage][cDelta], Col1, dest);
ffgkyd(curFile->fptr, keyword, &xinc, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
sprintf(keyword, "%s%d%c", Keys[isImage][cDelta], Col2, dest);
ffgkyd(curFile->fptr, keyword, &yinc, NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
sprintf(keyword, "%s%d%c", Keys[isImage][cRota], Col2, dest);
ffgkyd(curFile->fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
/* Try other column */
status = 0;
if( !isImage ) {
sprintf(keyword, "%s%d%c", Keys[isImage][cRota], Col1, dest);
ffgkyd(curFile->fptr, keyword, &rot, NULL, &status);
if( status==KEY_NO_EXIST ) {
status=0;
} else {
rot = -rot;
anyKeysFnd++;
}
}
} else
anyKeysFnd++;
if( ! anyKeysFnd ) { /* Couldn't find old-style keys; look for new-style */
anyKeysFnd = 0;
matrix[0][0] = 1.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col1, Col1, dest);
ffgkyd(curFile->fptr, keyword, &matrix[0][0], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[1][1] = 1.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col2, Col2, dest);
ffgkyd(curFile->fptr, keyword, &matrix[1][1], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[0][1] = 0.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col1, Col2, dest);
ffgkyd(curFile->fptr, keyword, &matrix[0][1], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
matrix[1][0] = 0.0;
sprintf(keyword, "%s%d_%d%c", Keys[isImage][cMatrix], Col2, Col1, dest);
ffgkyd(curFile->fptr, keyword, &matrix[1][0], NULL, &status);
if( status==KEY_NO_EXIST ) status = 0; else anyKeysFnd++;
if( anyKeysFnd ) {
/* Modified from CFITSIO... compute old-style from new-style */
double phia, phib;
double pi = 3.1415926535897932;
/* there are 2 ways to compute the angle: */
phia = atan2d( matrix[1][0], matrix[0][0]);
phib = atan2d(-matrix[0][1], matrix[1][1]);
/* ensure that phia <= phib */
temp = minvalue(phia, phib);
phib = maxvalue(phia, phib);
phia = temp;
/* there is a possible 180 degree ambiguity in the angles */
/* so add 180 degress to the smaller value if the values */
/* differ by more than 90 degrees = pi/2 radians. */
/* (Later, we may decide to take the other solution by */
/* subtracting 180 degrees from the larger value). */
if( (phib - phia) > (pi * 0.5) )
phia += pi;
if( fabs(phia - phib) > 0.0002 ) {
/* angles don't agree, so looks like there is some skewness */
/* between the axes. Return with an error to be safe. */
/* PDW: Lets just ignore this and give the best estimate we can.
status = APPROX_WCS_KEY; */
}
phia = (phia + phib) * 0.5; /* use the average of the 2 values */
temp = cosd(phia);
if( fabs(temp)<0.1 ) {
temp = sind(phia);
xinc = matrix[1][0] / temp;
yinc =-matrix[0][1] / temp;
} else {
xinc = matrix[0][0] / temp;
yinc = matrix[1][1] / temp;
}
rot = phia * 180. / pi;
/* common usage is to have a positive yinc value. If it is */
/* negative, then subtract 180 degrees from rot and negate */
/* both xinc and yinc. */
if( yinc < 0 ) {
xinc = -xinc;
yinc = -yinc;
rot -= 180.0;
}
} /* else keep default delt/rot = 1/0 */
}
/* Read both RA and DEC CTYPs to check that they both exist and agree */
sprintf(keyword, "%s%d%c", Keys[isImage][cType], Col1, dest);
ffgkys(curFile->fptr, keyword, ctype, NULL, &status);
sprintf(keyword, "%s%d%c", Keys[isImage][cType], Col2, dest);
ffgkys(curFile->fptr, keyword, ctemp, NULL, &status);
if( status || strlen(ctype)<5 || strlen(ctemp)<5
|| strcmp(ctype+4,ctemp+4) ) {
strcpy(ctype,"none"); status = 0;
} else {
if( !strncmp(ctype, "DEC-", 4) || !strncmp(ctype+1, "LAT", 3) ) {
/* RA/Dec are swapped!!! */
swap = 1;
}
/* copy the projection type string */
strncpy(ctype, &ctype[4], 4);
ctype[4] = '\0';
}
data[0] = Tcl_NewDoubleObj(xrval);
data[1] = Tcl_NewDoubleObj(yrval);
data[2] = Tcl_NewDoubleObj(xrpix);
data[3] = Tcl_NewDoubleObj(yrpix);
data[4] = Tcl_NewDoubleObj(xinc);
data[5] = Tcl_NewDoubleObj(yinc);
data[6] = Tcl_NewDoubleObj(rot);
data[7] = Tcl_NewStringObj(ctype,-1);
if( userOptions.wcsSwap ) {
data[8] = Tcl_NewBooleanObj( swap );
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(9,data) );
} else {
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(8,data) );
}
ffcmsg();
return TCL_OK;
}
/* extract the world coordinate from a table */
/* (Old behavior... deprecated) */
int fitsTableGetWcsOld( FitsFD *curFile,
int RAColNum,
int DecColNum )
{
int status = 0;
double xrval, yrval, xrpix, yrpix, xinc, yinc, rot;
char ctype[5];
Tcl_Obj *data[8];
ffgtcs(curFile->fptr,
RAColNum,
DecColNum,
&xrval,
&yrval,
&xrpix,
&yrpix,
&xinc,
&yinc,
&rot,
ctype,
&status);
if ( status ) {
/* if there is no wcs info , keep silent */
Tcl_SetResult(curFile->interp, "", TCL_STATIC);
ffcmsg();
return TCL_OK;
}
data[0] = Tcl_NewDoubleObj(xrval);
data[1] = Tcl_NewDoubleObj(yrval);
data[2] = Tcl_NewDoubleObj(xrpix);
data[3] = Tcl_NewDoubleObj(yrpix);
data[4] = Tcl_NewDoubleObj(xinc);
data[5] = Tcl_NewDoubleObj(yinc);
data[6] = Tcl_NewDoubleObj(rot);
data[7] = Tcl_NewStringObj(ctype,-1);
Tcl_SetObjResult(curFile->interp, Tcl_NewListObj(8,data) );
return TCL_OK;
}
/***********************************************************************/
/* */
/* End of WCS Routines */
/***********************************************************************/
int fitsReadColData( FitsFD *curFile,
int colNum,
int strSize,
colData columndata[],
int *dataType )
{
long numRows, i, vecSize;
int status = 0;
char **tmpPtr;
char *nullArray=NULL;
int anyf;
int colType;
double *tmpDbl;
LONGLONG *tmpLonglong;
long *tmpLong;
char *tmpChar;
char *cPtr;
colType = curFile->CHDUInfo.table.colDataType[colNum-1];
vecSize = curFile->CHDUInfo.table.vecSize[colNum-1];
numRows = curFile->CHDUInfo.table.numRows;
nullArray = (char *) ckalloc(numRows*sizeof(char));
switch ( colType ) {
case TSTRING:
tmpPtr = (char **) makeContigArray(1, strSize+1, 'c');
for (i=0;ifptr,
colNum,
i+1,
1,
1,
1,
"NULL",
tmpPtr,
nullArray,
&anyf,
&status);
if ( status ) {
status = 0;
strcpy(tmpPtr[0], "");
ffcmsg();
}
columndata[i].strData = (char *)ckalloc( (strSize+1)*sizeof(char) );
cPtr = tmpPtr[0];
while ( *cPtr == ' ') cPtr++;
strcpy(columndata[i].strData, cPtr);
}
ckfree((char *) tmpPtr[0]);
ckfree((char *) tmpPtr);
*dataType = 0;
break;
case TSHORT:
case TINT:
case TBYTE:
case TLONG:
tmpLong = (long *) ckalloc(numRows*sizeof(long));
ffgclj(curFile->fptr,
colNum,
1,
1,
numRows,
vecSize,
1,
LONG_MAX,
tmpLong,
nullArray,
&anyf,
&status);
for (i=0; i< numRows; i++)
columndata[i].intData = tmpLong[i];
*dataType = 1;
ckfree((char *)tmpLong);
break;
case TBIT:
tmpChar = (char *) ckalloc(1*sizeof(char));
for (i=0;ifptr,
colNum,
i+1,
1,
1,
tmpChar,
&status);
columndata[i].intData = tmpChar[0];
}
*dataType = 1;
ckfree((char *)tmpChar);
break;
case TLOGICAL:
tmpChar = (char *) ckalloc(numRows*sizeof(char));
ffgcfl(curFile->fptr,
colNum,
1,
1,
numRows,
tmpChar,
nullArray,
&anyf,
&status);
for (i=0; i< numRows; i++) {
if ( nullArray[i] ) {
columndata[i].intData = 2;
} else {
columndata[i].intData = tmpChar[i];
}
}
*dataType = 1;
ckfree((char *)tmpChar );
break;
case TFLOAT:
case TDOUBLE:
tmpDbl = (double *) ckalloc(numRows*sizeof(double));
ffgcld(curFile->fptr,
colNum,
1,
1,
numRows,
vecSize,
1,
DBL_MAX,
tmpDbl,
nullArray,
&anyf,
&status);
for (i = 0; i < numRows; i++ )
columndata[i].dblData = tmpDbl[i];
*dataType = 2;
ckfree((char *) tmpDbl);
break;
case TLONGLONG:
tmpLonglong = (LONGLONG *) ckalloc(numRows*sizeof(LONGLONG));
ffgcljj(curFile->fptr,
colNum,
1,
1,
numRows,
vecSize,
1,
(LONGLONG)NULL,
tmpLonglong,
nullArray,
&anyf,
&status);
for (i = 0; i < numRows; i++ )
columndata[i].longlongData = tmpLonglong[i];
*dataType = 3;
ckfree((char *) tmpLonglong);
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl ERROR: unknown column type", TCL_STATIC);
return TCL_ERROR;
}
ckfree((char *)nullArray);
return TCL_OK;
}
int fitsReadRawColData( FitsFD *curFile,
colData columndata[],
LONGLONG *rowSize )
{
long numRows, i;
int status = 0;
long *tbcol;
numRows = curFile->CHDUInfo.table.numRows;
if ( ASCII_TBL == curFile->hduType ) {
/*
tbcol = (long *) ckalloc(curFile->CHDUInfo.table.numCols*sizeof(long));
ffgabc(curFile->CHDUInfo.table.numCols,
curFile->CHDUInfo.table.colType,
1,
rowSize,
tbcol,
&status);
*/
*rowSize =curFile->CHDUInfo.table.rowLen;
} else if ( BINARY_TBL == curFile->hduType) {
/*
ffgtbc(curFile->fptr, rowSize, &status);
*/
*rowSize =curFile->CHDUInfo.table.rowLen;
} else {
Tcl_SetResult(curFile->interp,
"fitsTcl ERROR:unknown table type", TCL_STATIC);
return TCL_ERROR;
}
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
for (i = 0; i < numRows; i++ ) {
columndata[i].rowindex = i+1;
columndata[i].colBuffer = (unsigned char *)
ckalloc( *rowSize * sizeof(unsigned char) );
ffgtbb(curFile->fptr, i+1, 1, *rowSize, columndata[i].colBuffer, &status);
if ( status ) {
status = 0;
ffcmsg();
}
columndata[i].flag = 0; /* Init flag values */
}
return TCL_OK;
}
int fitsSortTable( FitsFD *curFile,
int numCols,
int *colNum,
int *strSize,
int *isAscend,
int isMerge )
{
int result, i, j, k;
colData *columndata;
int dataType;
long *bottom;
long *top;
long nrange=0, numRows, uniqueNum;
LONGLONG rowSize;
char ** rowlist;
numRows = curFile->CHDUInfo.table.numRows;
columndata = (colData *) ckalloc(numRows*sizeof(colData));
/* read in raw table data in rows */
result = fitsReadRawColData(curFile, columndata, &rowSize);
if (result != TCL_OK) {
ckfree((char *) columndata);
return TCL_ERROR;
}
rowlist = (char **) ckalloc(numRows*sizeof(char*));
for (i=0; i0 ; i++ ) {
result = fitsReadColData(curFile, colNum[i], strSize[i],
columndata, &dataType);
if (result != TCL_OK) {
fitsFreeRawColData( columndata, numRows );
ckfree((char *) columndata);
return TCL_ERROR;
}
/* allocate top and bottom */
top = (long *)ckalloc(nrange*sizeof(long));
bottom = (long *)ckalloc(nrange*sizeof(long));
if( i ) {
fitsGetSortRange(columndata, numRows, top, bottom);
} else {
fitsRandomizeColData( columndata, numRows );
top[0] = numRows-1;
bottom[0] = 0;
}
/* do sorting when there are identical keys */
for ( j=0; j < nrange; j++ ) {
for ( k=bottom[j]; k<=top[j]; k++ ) {
if (dataType == 0 && (strcmp(columndata[k].strData,"NULL") == 0)) {
strcpy(columndata[k].strData, "\0");
} else {
columndata[k].flag = 0;
}
}
fitsQuickSort(columndata, dataType, strSize[i], bottom[j], top[j], isAscend[i]);
fitsQSsetFlag(columndata, dataType, strSize[i], bottom[j], top[j]);
}
ckfree((char *) top);
ckfree((char *) bottom);
if (dataType == 0)
for ( j=0; j< numRows; j++)
ckfree((char *) columndata[j].strData);
/* before read more keys, write the sorted buffer to file */
result = fitsWriteRowsToFile(curFile, rowSize, columndata,
( i+1 == numCols ? isMerge : 0 ) );
if (result != TCL_OK) {
fitsFreeRawColData( columndata, numRows );
ckfree((char *) columndata);
return TCL_ERROR;
}
/* prepare for the next key */
fitsGetSortRangeNum(columndata, numRows, &nrange);
}
/* numRows = curFile->CHDUInfo.table.numRows; */
uniqueNum = 0;
if (isMerge == 0 ) {
for (i=0; iinterp,Tcl_Merge(uniqueNum,rowlist));
} else {
Tcl_AppendElement(curFile->interp,Tcl_Merge(numRows,rowlist));
}
for ( i=0; iCHDUInfo.table.numRows ;
long uniqNum = 0;
/* write the buffer to file */
if( isMerge ) {
for (i=0; i< numRows; i++) {
if ( columndata[i].flag == 0) {
uniqNum++;
ffptbb(curFile->fptr, uniqNum, 1, rowSize,
columndata[i].colBuffer, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
}
}
if ( uniqNum != numRows) {
ffdrow(curFile->fptr, uniqNum+1, numRows-uniqNum, &status);
}
} else {
for (i=0; i< numRows; i++) {
ffptbb(curFile->fptr, i+1, 1, rowSize,
columndata[i].colBuffer, &status);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
}
}
return fitsUpdateFile(curFile);
}
void fitsGetSortRangeNum( colData a[],
long n,
long *nr )
{
long i, count = 0;
unsigned char flag = 0;
/* an identical key start with sequence of "0 1 1 1 ... 1" */
for (i=0; ifptr, 0, &status);
ffchdu(curFile->fptr, &status);
ffrdef(curFile->fptr, &status);
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
/* reload info */
if ( TCL_OK != fitsUpdateCHDU(curFile, curFile->hduType) ) {
Tcl_SetResult(curFile->interp,
"Cannot update current HDU", TCL_STATIC);
return TCL_ERROR;
}
/* reload the hdu */
return fitsLoadHDU(curFile);
}
int fitsColumnStatistics( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2] )
{
colStat colstat;
char tmpStr[80];
int statFlag = 1;
if ( TCL_OK != fitsColumnStatToPtr(curFile, colNum, felem, numrange,
range, &colstat, statFlag) )
return TCL_ERROR;
Tcl_ResetResult(curFile->interp);
if (colstat.min < 0.000000100 || colstat.min > 999999999) {
sprintf(tmpStr, "%16.8g", colstat.min);
} else {
sprintf(tmpStr, "%.10f", colstat.min);
}
Tcl_AppendElement(curFile->interp, tmpStr);
sprintf(tmpStr, "%ld", colstat.fmin);
Tcl_AppendElement(curFile->interp, tmpStr);
if (colstat.max < 0.000000100 || colstat.max > 999999999) {
sprintf(tmpStr, "%16.8g", colstat.max);
} else {
sprintf(tmpStr, "%.10f", colstat.max);
}
Tcl_AppendElement(curFile->interp, tmpStr);
sprintf(tmpStr, "%ld", colstat.fmax);
Tcl_AppendElement(curFile->interp, tmpStr);
if (colstat.mean < 0.000000100 || colstat.mean > 999999999) {
sprintf(tmpStr, "%16.8g", colstat.mean);
} else {
sprintf(tmpStr, "%.10f", colstat.mean);
}
Tcl_AppendElement(curFile->interp, tmpStr);
if (colstat.stdiv < 0.000000100 || colstat.stdiv > 999999999) {
sprintf(tmpStr, "%16.8g", colstat.stdiv);
} else {
sprintf(tmpStr, "%.10f", colstat.stdiv);
}
Tcl_AppendElement(curFile->interp, tmpStr);
sprintf(tmpStr, "%ld", colstat.numData);
Tcl_AppendElement(curFile->interp, tmpStr);
return TCL_OK;
}
int fitsColumnMinMax( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2] )
{
colStat colstat;
char tmpStr[80];
int statFlag = 0;
if ( TCL_OK != fitsColumnStatToPtr(curFile, colNum, felem, numrange,
range, &colstat, statFlag) )
return TCL_ERROR;
sprintf(tmpStr, "%.10f", colstat.min);
Tcl_SetResult(curFile->interp, tmpStr, TCL_VOLATILE);
sprintf(tmpStr, "%.10f", colstat.max);
Tcl_AppendElement(curFile->interp, tmpStr);
return TCL_OK;
}
int fitsColumnMinMaxToPtr( FitsFD *curFile,
int colNum,
int felem,
int fRow,
int lRow,
double *min,
double *max )
{
colStat colstat;
int statFlag = 0;
int range[1][2];
range[0][0] = fRow;
range[0][1] = lRow;
if ( TCL_OK != fitsColumnStatToPtr(curFile, colNum, felem, 1,
range, &colstat, statFlag) )
return TCL_ERROR;
*min = colstat.min;
*max = colstat.max;
return TCL_OK;
}
int fitsColumnStatToPtr( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2],
colStat *colstat,
int statFlag )
{
int m;
int nRows, numRows;
double *array;
char *flagArray;
int colType;
int n;
long fRow, lRow;
double min = DBL_MAX;
double max = -DBL_MAX;
double d_total = 0.0;
double s_total = 0.0;
long l_count = 0;
colType = curFile->CHDUInfo.table.colDataType[colNum-1];
if ( colType == TSTRING || colType == TLOGICAL || colType == TCOMPLEX
|| colType == TDBLCOMPLEX || (colType == TBIT && statFlag) ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot work on this type of column",
TCL_STATIC);
return TCL_ERROR;
}
nRows = curFile->CHDUInfo.table.numRows;
/* check if is a vector column */
if ( felem > curFile->CHDUInfo.table.vecSize[colNum-1] ) {
Tcl_SetResult(curFile->interp,
"fitsTcl Error: vector out of bound", TCL_STATIC);
return TCL_ERROR;
}
/* if not a vector and colMin and colMax are loaded then skip calculation */
if ( !statFlag ) {
if ( curFile->CHDUInfo.table.vecSize[colNum-1] <= 1 &&
(curFile->CHDUInfo.table.colMin[colNum-1] != DBL_MIN ||
curFile->CHDUInfo.table.colMax[colNum-1] != DBL_MAX )) {
if ( range[0][0] == 1L && (range[0][1] == nRows) ) {
min = curFile->CHDUInfo.table.colMin[colNum-1] ;
max = curFile->CHDUInfo.table.colMax[colNum-1] ;
colstat->min = min;
colstat->max = max;
return TCL_OK;
}
}
}
for (n=0; n < numrange; n++) {
fRow = range[n][0];
lRow = range[n][1];
numRows = lRow - fRow + 1;
array = (double *) ckalloc(numRows*sizeof(double));
flagArray = (char *) ckalloc(numRows*sizeof(char));
if ( fitsColumnGetToArray(curFile, colNum, felem, fRow, lRow,
array, flagArray) != TCL_OK) {
ckfree((char *) array);
ckfree((char *) flagArray);
return TCL_ERROR;
}
if ( statFlag ) {
for (m=0; m < numRows; m++ ) {
if ( !flagArray[m] ) {
d_total += array[m];
s_total += array[m] * array[m];
l_count ++;
if (max < array[m]) {
max = array[m];
colstat->fmax = fRow + m;
}
if (min > array[m]) {
min = array[m];
colstat->fmin = fRow + m;
}
}
}
} else {
for (m=0; m < numRows; m++ ) {
if ( !flagArray[m] ) {
if (max < array[m]) max = array[m];
if (min > array[m]) min = array[m];
}
}
}
if ( fRow == 1 && lRow == nRows ) {
/* update curFile info */
curFile->CHDUInfo.table.colMin[colNum-1] = min;
curFile->CHDUInfo.table.colMax[colNum-1] = max;
}
ckfree((char *)array);
ckfree((char *)flagArray);
}
colstat->min = min;
colstat->max = max;
if ( statFlag ) {
colstat->mean = d_total/l_count;
colstat->numData = l_count;
if ( l_count-1 <= 0 ) {
colstat->stdiv = 0;
} else {
s_total -= l_count * colstat->mean * colstat->mean;
colstat->stdiv = sqrt(s_total/(l_count-1));
}
}
return TCL_OK;
}
int fitsColumnGetToArray( FitsFD *curFile,
int colNum,
int felem,
long fRow,
long lRow,
double *array,
char *flagArray )
{
int status = 0;
long nRows, m;
char cValue[1];
double dblValue[1];
LONGLONG longlongValue[1];
int dataType;
char nullArray[1];
int anyf = 0;
/* check the row range */
if ( lRow > curFile->CHDUInfo.table.numRows)
lRow = curFile->CHDUInfo.table.numRows;
if ( fRow < 1) fRow = 1;
if ( lRow < 1) lRow = 1;
nRows = lRow - fRow +1;
dataType = curFile->CHDUInfo.table.colDataType[colNum-1];
switch ( dataType ) {
case TBIT:
for (m=0; m < nRows; m++ ) {
ffgcfl(curFile->fptr,
colNum,
fRow+m,
felem,
1,
cValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
flagArray[m] = 2;
array[m] = 0;
status = 0;
ffcmsg();
} else if ( nullArray[0] ) {
flagArray[m] = 1;
array[m] = 0;
} else {
flagArray[m] = 0;
array[m] = cValue[0];
}
}
break;
case TBYTE: /* CFITSIO does automatic type conversion for columns */
case TSHORT: /* Don't know about the TBIT -> TDOUBLE conversion? */
case TINT:
case TLONG:
case TFLOAT:
case TDOUBLE:
for (m=0; m < nRows; m++ ) {
ffgcfd(curFile->fptr,
colNum,
fRow+m,
felem,
1,
dblValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
flagArray[m] = 2;
array[m] = 0;
status = 0;
ffcmsg();
} else if ( nullArray[0] ) {
flagArray[m] = 1;
array[m] = 0;
} else {
flagArray[m] = 0;
array[m] = dblValue[0];
}
}
break;
case TLONGLONG:
for (m=0; m < nRows; m++ ) {
ffgcfjj(curFile->fptr,
colNum,
fRow+m,
felem,
1,
longlongValue,
nullArray,
&anyf,
&status);
if ( status > 0 ) {
flagArray[m] = 2;
array[m] = 0;
status = 0;
ffcmsg();
} else if ( nullArray[0] ) {
flagArray[m] = 1;
array[m] = 0;
} else {
flagArray[m] = 0;
array[m] = longlongValue[0];
}
}
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: Not a numerical column", TCL_STATIC);
ckfree ((char *) flagArray);
return TCL_ERROR;
}
return TCL_OK;
}
int fitsCalculaterngColumn( FitsFD *curFile,
char *colName,
char *colForm,
char *expr ,
int numrange, int range[][2] )
{
int status=0;
int i;
long * firstrow;
long * lastrow;
firstrow = (long *) malloc(numrange*sizeof(long));
lastrow = (long *) malloc(numrange*sizeof(long));
for (i=0; ifptr, expr, curFile->fptr, colName, colForm, numrange,
firstrow,lastrow, &status );
free(firstrow);
free(lastrow);
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
int fitsCalculateColumn( FitsFD *curFile,
char *colName,
char *colForm,
char *expr )
{
int status=0;
ffcalc( curFile->fptr, expr, curFile->fptr, colName, colForm, &status );
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
int fitsSelectRowsExpr (FitsFD *curFile,
char *expr,
long firstrow,
long nrows,
long * n_good_rows,
char * row_status)
{
int status=0;
int i;
fffrow( curFile->fptr, expr, firstrow, nrows,
n_good_rows, row_status,&status );
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return TCL_OK;
}
int fitsDeleteRowsExpr( FitsFD *curFile,
char *expr )
{
int status=0;
char *negExpr;
negExpr = (char*)ckalloc((strlen(expr)+15)*sizeof(char));
sprintf(negExpr,"DEFNULL(!(%s),T)",expr);
ffsrow( curFile->fptr, curFile->fptr, negExpr, &status );
ckfree( negExpr );
if( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
return fitsUpdateFile(curFile);
}
/*
* ------------------------------------------------------------
*
* exprGetToPtr
*
* return : "address dataType numberElements"
* address can be recovered using sscanf(address, PTRFORMAT, &dataArray)
* where void *dataArray
* dataType : 0 uchar, 2 int, 4 double (No others allowed)
* numberElements : dimension of the array
*
* ------------------------------------------------------------
*/
int exprGetToPtr( FitsFD *curFile, char *expr, char *nulStr,
int numrange, int range[][2] )
{
void *backPtr;
LONGLONG *longlongArray;
double *dblArray;
int *intArray;
unsigned char *bytArray;
LONGLONG longlongNul;
double dblNul;
int intNul;
unsigned char bytNul;
long numRows;
int anynul=0;
int dataType, naxis;
long nelem, naxes[5], offset=0, ntodo;
char result[80];
int status = 0;
int rngCnt;
fftexp( curFile->fptr,
expr,
5,
&dataType,
&nelem,
&naxis,
naxes,
&status );
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
if( nelem < 0 ) nelem = -nelem; /* Flags a constant result */
/* Count the number of rows */
numRows = 0;
for( rngCnt=0; rngCntfptr,
TLOGICAL,
expr,
(long)range[rngCnt][0],
(long)nelem*ntodo,
&intNul,
bytArray+offset,
&anynul,
&status );
offset += nelem*ntodo;
}
dataType = BYTE_DATA;
backPtr = bytArray;
break;
case TLONG:
if( !strcmp(nulStr, "NULL") ) {
intNul = INT_MAX;
} else {
intNul = atol(nulStr);
}
/* pow/visu donot like long type array. convert to int */
intArray = (int *) ckalloc(numRows*nelem*sizeof(int));
for( rngCnt=0; rngCntfptr,
TINT,
expr,
(long)range[rngCnt][0],
(long)nelem*ntodo,
&intNul,
intArray+offset,
&anynul,
&status );
offset += nelem*ntodo;
}
dataType = INT_DATA;
backPtr = intArray;
break;
case TDOUBLE:
if( !strcmp(nulStr, "NULL") ) {
dblNul = DBL_MAX;
} else {
dblNul = atof(nulStr);
}
dblArray = (double *) ckalloc(numRows*nelem*sizeof(double));
for( rngCnt=0; rngCntfptr,
TDOUBLE,
expr,
(long)range[rngCnt][0],
(long)nelem*ntodo,
&dblNul,
dblArray+offset,
&anynul,
&status );
offset += nelem*ntodo;
}
dataType = DOUBLE_DATA;
backPtr = dblArray;
break;
case TLONGLONG:
if( !strcmp(nulStr, "NULL") ) {
longlongNul = (LONGLONG)NULL;
} else {
longlongNul = atof(nulStr);
}
longlongArray = (LONGLONG *) ckalloc(numRows*nelem*sizeof(LONGLONG));
for( rngCnt=0; rngCntfptr,
TLONGLONG,
expr,
(long)range[rngCnt][0],
(long)nelem*ntodo,
&longlongNul,
longlongArray+offset,
&anynul,
&status );
offset += nelem*ntodo;
}
dataType = LONGLONG_DATA;
backPtr = longlongArray;
break;
default:
Tcl_SetResult(curFile->interp,
"fitsTcl Error: cannot load this type of expression",
TCL_STATIC);
return TCL_ERROR;
}
if ( status ) {
ckfree( (char *)backPtr );
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
sprintf( result, PTRFORMAT " %d %ld",
backPtr, dataType, numRows*nelem );
Tcl_SetResult(curFile->interp, result, TCL_VOLATILE);
return TCL_OK;
}
/*
* ------------------------------------------------------------
*
* exprGetInfo
*
* return : "dataType numberElements naxes"
* address can be recovered using sscanf(address, PTRFORMAT, &dataArray)
* where void *dataArray
* dataType : CFITSIO datatype... TDOUBLE, TSTRING, etc
*
* ------------------------------------------------------------
*/
int exprGetInfo( FitsFD *curFile, char *expr )
{
long i;
char tmpStr[32];
int dataType, naxis;
long nelem, naxes[5];
int status = 0;
Tcl_ResetResult(curFile->interp);
fftexp( curFile->fptr,
expr,
5,
&dataType,
&nelem,
&naxis,
naxes,
&status );
if ( status ) {
dumpFitsErrStack(curFile->interp, status);
return TCL_ERROR;
}
sprintf( tmpStr, "%d %ld {", dataType, nelem );
Tcl_AppendResult( curFile->interp, tmpStr, (char*)NULL );
for( i=0; iinterp, tmpStr, (char *)NULL );
}
Tcl_AppendResult( curFile->interp, "}", (char *)NULL );
return TCL_OK;
}
fitsTcl/Makefile 0000644 0002307 0000036 00000002432 11222720662 012521 0 ustar chai lhea HD_COMPONENT_NAME = ftools
HD_COMPONENT_VERS =
HD_LIBRARY_ROOT = fitstcl
HD_LIBRARY_SRC_c = fitsCmds.c fitsInit.c fitsIO.c fitsTcl.c \
fitsUtils.c fvTcl.c tclShared.c
HD_CFLAGS = -I${CFITSIO_DIR} ${HD_STD_CFLAGS}
HD_INSTALL_LIBRARIES = ${HD_LIBRARY_ROOT}
HD_INSTALL_HEADERS = fitsTcl.h fitsTclInt.h
HD_INSTALL_HELP = fitsTcl.html
default: build-libfitstcl
all: default publish
include ${HD_STD_MAKEFILE}
# Get cfitsio source files and prepend ${CFITSIO_DIR} prefix to each filename.
CFITSIO_OBJ_TMP = ${shell ${MAKE} -f ${CFITSIO_DIR}/Makefile cfitsioLibObjs | grep buffers}
CFITSIO_OBJ = ${shell echo ${CFITSIO_OBJ_TMP} | sed "s: : ../../../heacore/cfitsio/:g" | sed "s:^:../../../heacore/cfitsio/:"}
${CFITSIO_OBJ}:
@for file in ${CFITSIO_OBJ}; do \
if [ ! -f $$file ]; then \
echo "Cannot find CFITSIO object $$file"; exit 1; \
fi; \
done
WCSLIB_OBJ = ../../../heacore/wcslib/C/wcstrig.o
${WCSLIB_OBJ}:
@for file in ${WCSLIB_OBJ}; do \
if [ ! -f $$file ]; then \
echo "Cannot find WCS object $$file"; exit 1; \
fi; \
done
build-libfitstcl:
@if [ "x${CFITSIO_OBJ}" = x ]; then \
echo "CFITSIO_OBJ macro is empty"; exit 1; \
fi
${HD_MAKE} fitstcl HD_LIBRARY_ROOT=fitstcl \
HD_LIBRARY_OBJ="${HD_LIBRARY_SRC_c:.c=.${OSUF}} ${CFITSIO_OBJ} ${WCSLIB_OBJ}"
fitsTcl/makefile.vc 0000644 0002307 0000036 00000045644 11222720662 013204 0 ustar chai lhea # Microsoft Developer Studio Generated NMAKE File, Based on fitstcl.dsp
!IF "$(CFG)" == ""
CFG=fitstcl - Win32 Debug
!MESSAGE No configuration specified. Defaulting to fitstcl - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "fitstcl - Win32 Release" && "$(CFG)" != "fitstcl - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "fitstcl.mak" CFG="fitstcl - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "fitstcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "fitstcl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "fitstcl - Win32 Release"
OUTDIR=.
INTDIR=.
# Begin Custom Macros
OutDir=.
# End Custom Macros
ALL : "$(OUTDIR)\fitstcl.dll"
CLEAN :
-@erase "$(INTDIR)\buffers.obj"
-@erase "$(INTDIR)\cfileio.obj"
-@erase "$(INTDIR)\checksum.obj"
-@erase "$(INTDIR)\compress.obj"
-@erase "$(INTDIR)\drvrfile.obj"
-@erase "$(INTDIR)\drvrmem.obj"
-@erase "$(INTDIR)\editcol.obj"
-@erase "$(INTDIR)\edithdu.obj"
-@erase "$(INTDIR)\eval_f.obj"
-@erase "$(INTDIR)\eval_l.obj"
-@erase "$(INTDIR)\eval_y.obj"
-@erase "$(INTDIR)\fitsCmds.obj"
-@erase "$(INTDIR)\fitscore.obj"
-@erase "$(INTDIR)\fitsInit.obj"
-@erase "$(INTDIR)\fitsIO.obj"
-@erase "$(INTDIR)\fitsTcl.obj"
-@erase "$(INTDIR)\fitsUtils.obj"
-@erase "$(INTDIR)\fvTcl.obj"
-@erase "$(INTDIR)\getcol.obj"
-@erase "$(INTDIR)\getcolb.obj"
-@erase "$(INTDIR)\getcold.obj"
-@erase "$(INTDIR)\getcole.obj"
-@erase "$(INTDIR)\getcoli.obj"
-@erase "$(INTDIR)\getcolj.obj"
-@erase "$(INTDIR)\getcolk.obj"
-@erase "$(INTDIR)\getcoll.obj"
-@erase "$(INTDIR)\getcols.obj"
-@erase "$(INTDIR)\getcolui.obj"
-@erase "$(INTDIR)\getcoluj.obj"
-@erase "$(INTDIR)\getcoluk.obj"
-@erase "$(INTDIR)\getkey.obj"
-@erase "$(INTDIR)\group.obj"
-@erase "$(INTDIR)\grparser.obj"
-@erase "$(INTDIR)\histo.obj"
-@erase "$(INTDIR)\iraffits.obj"
-@erase "$(INTDIR)\listhead.obj"
-@erase "$(INTDIR)\modkey.obj"
-@erase "$(INTDIR)\putcol.obj"
-@erase "$(INTDIR)\putcolb.obj"
-@erase "$(INTDIR)\putcold.obj"
-@erase "$(INTDIR)\putcole.obj"
-@erase "$(INTDIR)\putcoli.obj"
-@erase "$(INTDIR)\putcolj.obj"
-@erase "$(INTDIR)\putcolk.obj"
-@erase "$(INTDIR)\putcoll.obj"
-@erase "$(INTDIR)\putcols.obj"
-@erase "$(INTDIR)\putcolu.obj"
-@erase "$(INTDIR)\putcolui.obj"
-@erase "$(INTDIR)\putcoluj.obj"
-@erase "$(INTDIR)\putcoluk.obj"
-@erase "$(INTDIR)\putkey.obj"
-@erase "$(INTDIR)\region.obj"
-@erase "$(INTDIR)\scalnull.obj"
-@erase "$(INTDIR)\swapproc.obj"
-@erase "$(INTDIR)\tclShared.obj"
-@erase "$(INTDIR)\imcompress.obj"
-@erase "$(INTDIR)\ricecomp.obj"
-@erase "$(INTDIR)\quantize.obj"
-@erase "$(INTDIR)\pliocomp.obj"
-@erase "$(INTDIR)\drvrnet.obj"
-@erase "$(INTDIR)\drvrsmem.obj"
-@erase "$(INTDIR)\getcolsb.obj"
-@erase "$(INTDIR)\putcolsb.obj"
-@erase "$(INTDIR)\wcssub.obj"
-@erase "$(INTDIR)\wcsutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\wcsutil.obj"
-@erase "$(OUTDIR)\fitstcl.dll"
-@erase "$(OUTDIR)\fitstcl.exp"
-@erase "$(OUTDIR)\fitstcl.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "__WIN32__" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /Fp"$(INTDIR)\fitstcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\fitstcl.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\fitstcl.pdb" /machine:I386 /def:"fitstcl.def" /out:"$(OUTDIR)\fitstcl.dll" /implib:"$(OUTDIR)\fitstcl.lib"
DEF_FILE= \
"fitstcl.def"
LINK32_OBJS= \
"$(INTDIR)\fitsCmds.obj" \
"$(INTDIR)\fitsInit.obj" \
"$(INTDIR)\fitsIO.obj" \
"$(INTDIR)\fitsTcl.obj" \
"$(INTDIR)\fitsUtils.obj" \
"$(INTDIR)\fvTcl.obj" \
"$(INTDIR)\tclShared.obj" \
"$(INTDIR)\imcompress.obj" \
"$(INTDIR)\ricecomp.obj" \
"$(INTDIR)\quantize.obj" \
"$(INTDIR)\pliocomp.obj" \
"$(INTDIR)\wcsutil.obj" \
"$(INTDIR)\cfileio.obj" \
"$(INTDIR)\checksum.obj" \
"$(INTDIR)\compress.obj" \
"$(INTDIR)\drvrfile.obj" \
"$(INTDIR)\drvrmem.obj" \
"$(INTDIR)\editcol.obj" \
"$(INTDIR)\edithdu.obj" \
"$(INTDIR)\eval_f.obj" \
"$(INTDIR)\eval_l.obj" \
"$(INTDIR)\eval_y.obj" \
"$(INTDIR)\fitscore.obj" \
"$(INTDIR)\getcol.obj" \
"$(INTDIR)\getcolb.obj" \
"$(INTDIR)\getcold.obj" \
"$(INTDIR)\getcole.obj" \
"$(INTDIR)\getcoli.obj" \
"$(INTDIR)\getcolj.obj" \
"$(INTDIR)\getcolk.obj" \
"$(INTDIR)\getcoll.obj" \
"$(INTDIR)\getcols.obj" \
"$(INTDIR)\getcolui.obj" \
"$(INTDIR)\getcoluj.obj" \
"$(INTDIR)\getcoluk.obj" \
"$(INTDIR)\getkey.obj" \
"$(INTDIR)\group.obj" \
"$(INTDIR)\grparser.obj" \
"$(INTDIR)\histo.obj" \
"$(INTDIR)\iraffits.obj" \
"$(INTDIR)\listhead.obj" \
"$(INTDIR)\modkey.obj" \
"$(INTDIR)\putcol.obj" \
"$(INTDIR)\putcolb.obj" \
"$(INTDIR)\putcold.obj" \
"$(INTDIR)\putcole.obj" \
"$(INTDIR)\putcoli.obj" \
"$(INTDIR)\putcolj.obj" \
"$(INTDIR)\putcolk.obj" \
"$(INTDIR)\putcoll.obj" \
"$(INTDIR)\putcols.obj" \
"$(INTDIR)\putcolu.obj" \
"$(INTDIR)\putcolui.obj" \
"$(INTDIR)\putcoluj.obj" \
"$(INTDIR)\putcoluk.obj" \
"$(INTDIR)\putkey.obj" \
"$(INTDIR)\region.obj" \
"$(INTDIR)\scalnull.obj" \
"$(INTDIR)\swapproc.obj" \
"$(INTDIR)\drvrnet.obj" \
"$(INTDIR)\drvrsmem.obj" \
"$(INTDIR)\getcolsb.obj" \
"$(INTDIR)\putcolsb.obj" \
"$(INTDIR)\wcssub.obj" \
"$(INTDIR)\wcsutil.obj" \
"$(INTDIR)\buffers.obj"
"$(OUTDIR)\fitstcl.dll" : "$(OUTDIR)" $(LINK32_OBJS) $(DEF_FILE)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
$(DEF_FILE):
..\tcl8.2.2\win\Release\DUMPEXTS -o $(DEF_FILE) fitstcl.dll $(LINK32_OBJS)
!ELSEIF "$(CFG)" == "fitstcl - Win32 Debug"
OUTDIR=.
INTDIR=.
# Begin Custom Macros
OutDir=.
# End Custom Macros
ALL : "$(OUTDIR)\fitstcl.dll"
CLEAN :
-@erase "$(INTDIR)\buffers.obj"
-@erase "$(INTDIR)\cfileio.obj"
-@erase "$(INTDIR)\checksum.obj"
-@erase "$(INTDIR)\compress.obj"
-@erase "$(INTDIR)\drvrfile.obj"
-@erase "$(INTDIR)\drvrmem.obj"
-@erase "$(INTDIR)\editcol.obj"
-@erase "$(INTDIR)\edithdu.obj"
-@erase "$(INTDIR)\eval_f.obj"
-@erase "$(INTDIR)\eval_l.obj"
-@erase "$(INTDIR)\eval_y.obj"
-@erase "$(INTDIR)\fitsCmds.obj"
-@erase "$(INTDIR)\fitscore.obj"
-@erase "$(INTDIR)\fitsInit.obj"
-@erase "$(INTDIR)\fitsIO.obj"
-@erase "$(INTDIR)\fitsTcl.obj"
-@erase "$(INTDIR)\fitsUtils.obj"
-@erase "$(INTDIR)\fvTcl.obj"
-@erase "$(INTDIR)\getcol.obj"
-@erase "$(INTDIR)\getcolb.obj"
-@erase "$(INTDIR)\getcold.obj"
-@erase "$(INTDIR)\getcole.obj"
-@erase "$(INTDIR)\getcoli.obj"
-@erase "$(INTDIR)\getcolj.obj"
-@erase "$(INTDIR)\getcolk.obj"
-@erase "$(INTDIR)\getcoll.obj"
-@erase "$(INTDIR)\getcols.obj"
-@erase "$(INTDIR)\getcolui.obj"
-@erase "$(INTDIR)\getcoluj.obj"
-@erase "$(INTDIR)\getcoluk.obj"
-@erase "$(INTDIR)\getkey.obj"
-@erase "$(INTDIR)\group.obj"
-@erase "$(INTDIR)\grparser.obj"
-@erase "$(INTDIR)\histo.obj"
-@erase "$(INTDIR)\iraffits.obj"
-@erase "$(INTDIR)\listhead.obj"
-@erase "$(INTDIR)\modkey.obj"
-@erase "$(INTDIR)\putcol.obj"
-@erase "$(INTDIR)\putcolb.obj"
-@erase "$(INTDIR)\putcold.obj"
-@erase "$(INTDIR)\putcole.obj"
-@erase "$(INTDIR)\putcoli.obj"
-@erase "$(INTDIR)\putcolj.obj"
-@erase "$(INTDIR)\putcolk.obj"
-@erase "$(INTDIR)\putcoll.obj"
-@erase "$(INTDIR)\putcols.obj"
-@erase "$(INTDIR)\putcolu.obj"
-@erase "$(INTDIR)\putcolui.obj"
-@erase "$(INTDIR)\putcoluj.obj"
-@erase "$(INTDIR)\putcoluk.obj"
-@erase "$(INTDIR)\putkey.obj"
-@erase "$(INTDIR)\region.obj"
-@erase "$(INTDIR)\scalnull.obj"
-@erase "$(INTDIR)\swapproc.obj"
-@erase "$(INTDIR)\tclShared.obj"
-@erase "$(INTDIR)\imcompress.obj"
-@erase "$(INTDIR)\ricecomp.obj"
-@erase "$(INTDIR)\quantize.obj"
-@erase "$(INTDIR)\pliocomp.obj"
-@erase "$(INTDIR)\drvrnet.obj"
-@erase "$(INTDIR)\drvrsmem.obj"
-@erase "$(INTDIR)\getcolsb.obj"
-@erase "$(INTDIR)\putcolsb.obj"
-@erase "$(INTDIR)\wcssub.obj"
-@erase "$(INTDIR)\wcsutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\wcsutil.obj"
-@erase "$(OUTDIR)\fitstcl.dll"
-@erase "$(OUTDIR)\fitstcl.exp"
-@erase "$(OUTDIR)\fitstcl.ilk"
-@erase "$(OUTDIR)\fitstcl.lib"
-@erase "$(OUTDIR)\fitstcl.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /I "d:\fv_src\tcl8.2.2\generic" /I "d:\fv_src\tk8.2.2\generic" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /Fp"$(INTDIR)\fitstcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\fitstcl.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib d:\fv_src\tk8.2.2\win\Release\tk82.lib d:\fv_src\tcl8.2.2\win\Release\tcl82.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\fitstcl.pdb" /debug /machine:I386 /def:"fitstcl.def" /out:"$(OUTDIR)\fitstcl.dll" /implib:"$(OUTDIR)\fitstcl.lib" /pdbtype:sept
DEF_FILE= \
"fitstcl.def"
LINK32_OBJS= \
"$(INTDIR)\fitsCmds.obj" \
"$(INTDIR)\fitsInit.obj" \
"$(INTDIR)\fitsIO.obj" \
"$(INTDIR)\fitsTcl.obj" \
"$(INTDIR)\fitsUtils.obj" \
"$(INTDIR)\fvTcl.obj" \
"$(INTDIR)\tclShared.obj" \
"$(INTDIR)\imcompress.obj" \
"$(INTDIR)\ricecomp.obj" \
"$(INTDIR)\quantize.obj" \
"$(INTDIR)\pliocomp.obj" \
"$(INTDIR)\wcsutil.obj" \
"$(INTDIR)\cfileio.obj" \
"$(INTDIR)\checksum.obj" \
"$(INTDIR)\compress.obj" \
"$(INTDIR)\drvrfile.obj" \
"$(INTDIR)\drvrmem.obj" \
"$(INTDIR)\editcol.obj" \
"$(INTDIR)\edithdu.obj" \
"$(INTDIR)\eval_f.obj" \
"$(INTDIR)\eval_l.obj" \
"$(INTDIR)\eval_y.obj" \
"$(INTDIR)\fitscore.obj" \
"$(INTDIR)\getcol.obj" \
"$(INTDIR)\getcolb.obj" \
"$(INTDIR)\getcold.obj" \
"$(INTDIR)\getcole.obj" \
"$(INTDIR)\getcoli.obj" \
"$(INTDIR)\getcolj.obj" \
"$(INTDIR)\getcolk.obj" \
"$(INTDIR)\getcoll.obj" \
"$(INTDIR)\getcols.obj" \
"$(INTDIR)\getcolui.obj" \
"$(INTDIR)\getcoluj.obj" \
"$(INTDIR)\getcoluk.obj" \
"$(INTDIR)\getkey.obj" \
"$(INTDIR)\group.obj" \
"$(INTDIR)\grparser.obj" \
"$(INTDIR)\histo.obj" \
"$(INTDIR)\iraffits.obj" \
"$(INTDIR)\listhead.obj" \
"$(INTDIR)\modkey.obj" \
"$(INTDIR)\putcol.obj" \
"$(INTDIR)\putcolb.obj" \
"$(INTDIR)\putcold.obj" \
"$(INTDIR)\putcole.obj" \
"$(INTDIR)\putcoli.obj" \
"$(INTDIR)\putcolj.obj" \
"$(INTDIR)\putcolk.obj" \
"$(INTDIR)\putcoll.obj" \
"$(INTDIR)\putcols.obj" \
"$(INTDIR)\putcolu.obj" \
"$(INTDIR)\putcolui.obj" \
"$(INTDIR)\putcoluj.obj" \
"$(INTDIR)\putcoluk.obj" \
"$(INTDIR)\putkey.obj" \
"$(INTDIR)\region.obj" \
"$(INTDIR)\drvrnet.obj" \
"$(INTDIR)\drvrsmem.obj" \
"$(INTDIR)\getcolsb.obj" \
"$(INTDIR)\putcolsb.obj" \
"$(INTDIR)\wcssub.obj" \
"$(INTDIR)\wcsutil.obj" \
"$(INTDIR)\scalnull.obj" \
"$(INTDIR)\swapproc.obj" \
"$(INTDIR)\buffers.obj"
"$(OUTDIR)\fitstcl.dll" : "$(OUTDIR)" $(LINK32_OBJS) $(DEF_FILE)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
$(DEF_FILE):
..\tcl8.2.2\win\Release\DUMPEXTS -o $(DEF_FILE) fitstcl.dll $(LINK32_OBJS)
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("fitstcl.dep")
!INCLUDE "fitstcl.dep"
!ELSE
!MESSAGE Warning: cannot find "fitstcl.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "fitstcl - Win32 Release" || "$(CFG)" == "fitstcl - Win32 Debug"
SOURCE=cfitsio\buffers.c
"$(INTDIR)\buffers.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\cfileio.c
"$(INTDIR)\cfileio.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\checksum.c
"$(INTDIR)\checksum.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\compress.c
"$(INTDIR)\compress.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\drvrfile.c
"$(INTDIR)\drvrfile.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\drvrmem.c
"$(INTDIR)\drvrmem.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\editcol.c
"$(INTDIR)\editcol.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\edithdu.c
"$(INTDIR)\edithdu.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\eval_f.c
"$(INTDIR)\eval_f.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\eval_l.c
"$(INTDIR)\eval_l.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\eval_y.c
"$(INTDIR)\eval_y.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fitsCmds.c
"$(INTDIR)\fitsCmds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\fitscore.c
"$(INTDIR)\fitscore.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fitsInit.c
"$(INTDIR)\fitsInit.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fitsIO.c
"$(INTDIR)\fitsIO.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fitsTcl.c
"$(INTDIR)\fitsTcl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fitsUtils.c
"$(INTDIR)\fitsUtils.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=fvTcl.c
"$(INTDIR)\fvTcl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcol.c
"$(INTDIR)\getcol.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcolb.c
"$(INTDIR)\getcolb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcold.c
"$(INTDIR)\getcold.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcole.c
"$(INTDIR)\getcole.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcoli.c
"$(INTDIR)\getcoli.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcolj.c
"$(INTDIR)\getcolj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcolk.c
"$(INTDIR)\getcolk.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcoll.c
"$(INTDIR)\getcoll.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcols.c
"$(INTDIR)\getcols.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcolui.c
"$(INTDIR)\getcolui.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcoluj.c
"$(INTDIR)\getcoluj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcoluk.c
"$(INTDIR)\getcoluk.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getkey.c
"$(INTDIR)\getkey.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\group.c
"$(INTDIR)\group.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\grparser.c
"$(INTDIR)\grparser.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\histo.c
"$(INTDIR)\histo.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\iraffits.c
"$(INTDIR)\iraffits.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\listhead.c
"$(INTDIR)\listhead.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\modkey.c
"$(INTDIR)\modkey.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcol.c
"$(INTDIR)\putcol.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolb.c
"$(INTDIR)\putcolb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcold.c
"$(INTDIR)\putcold.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcole.c
"$(INTDIR)\putcole.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcoli.c
"$(INTDIR)\putcoli.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolj.c
"$(INTDIR)\putcolj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolk.c
"$(INTDIR)\putcolk.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcoll.c
"$(INTDIR)\putcoll.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcols.c
"$(INTDIR)\putcols.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolu.c
"$(INTDIR)\putcolu.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolui.c
"$(INTDIR)\putcolui.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcoluj.c
"$(INTDIR)\putcoluj.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcoluk.c
"$(INTDIR)\putcoluk.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putkey.c
"$(INTDIR)\putkey.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\region.c
"$(INTDIR)\region.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\scalnull.c
"$(INTDIR)\scalnull.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\swapproc.c
"$(INTDIR)\swapproc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=tclShared.c
"$(INTDIR)\tclShared.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\wcsutil.c
"$(INTDIR)\wcsutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\imcompress.c
"$(INTDIR)\imcompress.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\ricecomp.c
"$(INTDIR)\ricecomp.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\quantize.c
"$(INTDIR)\quantize.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\pliocomp.c
"$(INTDIR)\pliocomp.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\drvrnet.c
"$(INTDIR)\drvrnet.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\drvrsmem.c
"$(INTDIR)\drvrsmem.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\getcolsb.c
"$(INTDIR)\getcolsb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\putcolsb.c
"$(INTDIR)\putcolsb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=cfitsio\wcssub.c
"$(INTDIR)\wcssub.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
fitsTcl/configure.in 0000644 0002307 0000036 00000023355 11222720662 013401 0 ustar chai lhea dnl Process this file with autoconf to produce a configure script.
dnl disable caching to avoid sticky mistakes
dnl ----------------------------------------------------------------------------
dnl define([AC_CACHE_LOAD], )
dnl define([AC_CACHE_SAVE], )
dnl ----------------------------------------------------------------------------
AC_INIT
AC_CONFIG_SRCDIR([Makefile.in])
AC_REVISION($Revision: 1.16 $)
AC_PREREQ(2.59)
if test $cache_file = ./config.cache; then
cache_file=`pwd`/config.cache
fi
AC_ARG_WITH(
tcl,
[ --with-tcl Path to tcl library ],
TCL_PATH=$withval
)
AC_ARG_WITH(
tcl-includes,
[ --with-tcl-includes Path to tcl include files ],
TCL_INCLUDES=$withval
)
# Make sure we have tcl.h before proceeding:
#-------------------------------------------
AC_MSG_CHECKING([for tcl header file])
TCL_INC_PATH=
for dir in $TCL_INCLUDES $prefix/include /usr/include ; do
if test -r $dir/tcl.h; then
TCL_INC_PATH=$dir
AC_MSG_RESULT($dir)
break
fi
done
if test -z "$TCL_INC_PATH"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR(Can't find Tcl header. Use --with-tcl-includes to specify the location of tcl.h on your system.)
fi
#-------------------------------------------
AC_ARG_WITH(
tk,
[ --with-tk Path to tk library ],
TK_PATH=$withval
)
AC_ARG_WITH(
tk-includes,
[ --with-tk-includes Path to tk include files ],
TK_INC_PATH=$withval
)
AC_ARG_WITH(
itcl,
[ --with-itcl Path to itcl source ],
ITCL_PATH=$withval
)
AC_ARG_WITH(
cfitsio,
[ --with-cfitsio Path to cfitsio source ],
CFITSIO=$withval
)
# Make sure we have cfitsio before proceeding:
#-------------------------------------------
AC_MSG_CHECKING([for cfitsio source directory])
CFITSIODIR=
for dir in $CFITSIO ./cfitsio ; do
if test -r $dir/eval_defs.h; then
CFITSIODIR=$dir
AC_MSG_RESULT($dir)
break
fi
done
if test -z "$CFITSIODIR"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR(Can't find cfitsio. Use --with-cfitsio to specify the location of the cfitsio source code.)
fi
#-------------------------------------------
AC_ARG_ENABLE(
shared,
[ --disable-shared Produce static binaries ],
lhea_shared=$enableval,
lhea_shared=yes,
lhea_shared=no
)
AC_ARG_ENABLE(
static,
[ --enable-static Produce static binaries ],
[ if test $enableval = yes; then lhea_shared=no; fi ]
)
changequote(,)
TCL_LIB=`echo $TCL_PATH | sed 's:.*tcl8:tcl8:' | sed 's:.[0-9]/unix$::'`
TK_LIB=`echo $TK_PATH | sed 's:.*tk8:tk8:' | sed 's:.[0-9]/unix$::'`
changequote([,])
AC_SUBST(TCL_LIB)
AC_SUBST(TK_LIB)
AC_SUBST(CFITSIODIR)
if test $lhea_shared = yes; then
C_LIB_OPTION=shared
else
C_LIB_OPTION=static
fi
AC_SUBST(C_LIB_OPTION)
#-------------------------------------------------------------------------------
# Determine system type
#-------------------------------------------------------------------------------
BIN_EXT=
if test "x$EXT" = x; then EXT=lnx; fi
if test "x$BINDIR" = x; then
AC_CHECK_PROG(UNAME, uname, uname, nouname)
if test $UNAME = nouname; then
AC_MSG_ERROR(HEAsoft: Unable to guess system type. Please set it using --with-bindir option)
fi
changequote(,)
BINDIR=`$UNAME -s 2> /dev/null`_`$UNAME -r 2> /dev/null | sed 's:[^0-9]*\([0-9][0-9]*\.[0-9]*\).*:\1:'`
changequote([,])
lhea_machine=`$UNAME -m 2> /dev/null`
BIN_EXT=
case $BINDIR in
CYGWIN*)
BINDIR=CYGWIN32_`$UNAME -a 2> /dev/null | awk '{ print $4 }'`
lhea_machine=
BIN_EXT=".exe"
EXT=lnx
;;
IRIX*)
AC_MSG_WARN(IRIX support is marginal)
EXT=sgi
;;
HP-UX*)
AC_MSG_WARN(HP-UX support is marginal)
EXT=hpu
lhea_machine=`$UNAME -m 2> /dev/null | tr '/' ' ' | awk '{ print $2 }'`
;;
Linux*)
EXT=lnx
;;
OSF1*)
EXT=osf
;;
SunOS_4*)
AC_MSG_WARN(SunOS 4.x is not supported!)
AC_MSG_WARN(PROCEED AT YOUR OWN RISK!)
EXT=sun
lhea_machine=sparc
;;
SunOS_5*)
EXT=sol
lhea_machine=`$UNAME -p`
;;
Darwin_*)
EXT=darwin
lhea_machine=`$UNAME -p`
;;
*)
AC_MSG_ERROR(Unable to recognize your system. Please make sure this platform is supported.)
;;
esac
if test x$lhea_machine != x; then
BINDIR=$BINDIR"_"$lhea_machine
fi
fi
AC_SUBST(BINDIR)
AC_SUBST(BIN_EXT)
AC_SUBST(EXT)
#-------------------------------------------------------------------------------
# Checks for programs.
#-------------------------------------------------------------------------------
# Try first to find a proprietary C compiler, then gcc
if test "x$CC" = x; then
AC_CHECK_PROGS(CC, cc)
fi
# Set up flags to use the selected compiler
#
AC_PROG_CC
if test "$cross_compiling" = yes; then
AC_MSG_WARN(Cannot run a simple C executable on your system:)
AC_MSG_WARN(There may be something wrong with your compiler,)
AC_MSG_WARN(or perhaps you're trying to cross-compile?)
AC_MSG_WARN(Cross-compiling is not supported within HEAsoft.)
AC_MSG_WARN(Please make sure your compiler is working.)
AC_MSG_WARN(Contact the FTOOLS help desk for further assistance.)
AC_MSG_ERROR(Cross-compiling is not allowed.)
fi
if test "x$GCC" = x; then
GCC=no
fi
AC_PROG_RANLIB
if test $EXT = darwin; then
RANLIB="$RANLIB -cs"
fi
# RANLIB on IRIX is flaky
if test $EXT = sgi; then
RANLIB=:
fi
#-------------------------------------------------------------------------------
# Checks for libraries.
#-------------------------------------------------------------------------------
# X
XLIBS=
XLIBPTH=
XINCLUDES=
# socket and nsl libraries -- only if needed
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
AC_CHECK_FUNCS(
connect accept,
,
AC_CHECK_LIB(socket, main, , , [ $XLIBS ])
)
AC_PATH_X
if test "x$no_x" != xyes; then
USE_X=yes
no_x=no
if test `echo $x_includes | grep -c /` -ne 0; then
XINCLUDES="-I$x_includes"
fi
if test `echo $x_libraries | grep -c /` -ne 0; then
XLIBPTH="-L$x_libraries "
fi
XLIBS="$XLIBPTH-lX11"
dnl xpa sometimes needs Xt
dnl this doesn't work at the moment:
dnl AC_CHECK_LIB(Xt, main, XLIBS="$XLIBS -lXt")
if test -f $x_libraries/libXt.a; then
XLIBS="$XLIBS -lXt"
fi
# dnet_stub
AC_CHECK_LIB(dnet_stub, getnodebyname, XLIBS="$XLIBS -ldnet_stub")
else
USE_X=no
fi
AC_SUBST(USE_X)
AC_SUBST(XINCLUDES)
AC_SUBST(XLIBPTH)
AC_SUBST(XLIBS)
# dl
AC_CHECK_LIB(dl, dlopen)
if test `echo $LIBS | grep -c '\-ldl'` -eq 0; then
AC_CHECK_LIB(dld, dlopen)
fi
#-------------------------------------------------------------------------------
# Checks for header files.
#-------------------------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS(
dirent.h fcntl.h limits.h malloc.h string.h sys/time.h unistd.h
)
AC_HEADER_TIME
AC_FUNC_ALLOCA
#-------------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#-------------------------------------------------------------------------------
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
#-------------------------------------------------------------------------------
# Tweak compiler flags as needed
#-------------------------------------------------------------------------------
case $EXT in
darwin)
CFLAGS="$CFLAGS -Dunix"
;;
lnx)
;;
osf)
changequote(,)
if test $GCC = yes; then
# Remove optimization on DEC systems
CFLAGS=`echo $CFLAGS | sed 's:-O[0-9]* *::g'`
else
# Standard DEC cc behavior is *STILL* K&R -- force ANSI compliance
CFLAGS="$CFLAGS -std1 -Dunix"
fi
changequote([,])
;;
sgi)
AC_DEFINE(HAVE_POSIX_SIGNALS)
;;
sol)
AC_DEFINE(HAVE_POSIX_SIGNALS)
;;
*)
;;
esac
# Remove optimization on all systems for all older gcc
if test $GCC = yes; then
if test `$CC -v 2> /dev/null | grep -c 'version 2\.[45678]'` -ne 0; then
CFLAGS=`echo $CFLAGS | sed 's:-O[0-9]* *::g'`
fi
fi
#-------------------------------------------------------------------------------
# Shared library section
#-------------------------------------------------------------------------------
LD_FLAGS=
SHLIB_SUFFIX=".so"
SHLIB_LD_LIBS=""
lhea_shlib_cflags=
lhea_shlib_fflags=
if test $lhea_shared = yes; then
case $EXT in
darwin)
SHLIB_LD="$CC -dynamiclib -flat_namespace -undefined suppress"
SHLIB_SUFFIX=".dylib"
lhea_shlib_cflags='-fPIC -fno-common'
lhea_shlib_fflags='-fPIC -fno-common'
;;
hpu)
SHLIB_LD="ld -b"
SHLIB_LD_LIBS='${LIBS}'
SHLIB_SUFFIX=".sl"
;;
lnx)
SHLIB_LD=":"
;;
osf)
SHLIB_LD="ld -shared -expect_unresolved '*'"
;;
sol)
SHLIB_LD="/usr/ccs/bin/ld -G"
SHLIB_LD_LIBS='${LIBS}'
lhea_shlib_cflags="-KPIC"
lhea_shlib_fflags="-KPIC"
;;
sgi)
SHLIB_LD="ld -shared -rdata_shared"
;;
win)
SHLIB_LD="$CC -shared"
SHLIB_SUFFIX=".dll"
;;
*)
AC_MSG_WARN(Unable to determine how to make a shared library)
;;
esac
# Darwin uses gcc, but uses -dynamiclib flag
if test $GCC = yes -a $EXT != darwin; then
SHLIB_LD="$CC -shared"
lhea_shlib_cflags='-fPIC'
fi
if test "x$lhea_shlib_cflags" != x; then
CFLAGS="$CFLAGS $lhea_shlib_cflags"
fi
else
SHLIB_LD=:
fi
AC_SUBST(LD_FLAGS)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_SUFFIX)
#-------------------------------------------------------------------------------
# Checks for library functions.
#-------------------------------------------------------------------------------
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(getcwd socket strcspn strspn strstr strtod strtol)
#-------------------------------------------------------------------------------
AC_SUBST(TCL_PATH)
AC_SUBST(TCL_INC_PATH)
AC_SUBST(ITCL_PATH)
AC_SUBST(TK_PATH)
AC_SUBST(TK_INC_PATH)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
fitsTcl/fitsTclHeader.pch 0000755 0002307 0000036 00000000170 11222720662 014276 0 ustar chai lhea #pragma precompile_target "fitsTclHeader"
#define MAC_TCL
#pragma export on
#include "fitsTcl.h"
#pragma export reset
fitsTcl/fitstcl.def 0000644 0002307 0000036 00000025217 11222720662 013217 0 ustar chai lhea LIBRARY fitstcl.dll
EXETYPE WINDOWS
EXPORTS
fitsDispatch
fitsTcl_close
fitsTcl_move
fitsTcl_dump
fitsTcl_info
fitsTcl_get
fitsTcl_put
fitsTcl_insert
fitsTcl_delete
fitsTcl_load
fitsTcl_free
fitsTcl_flush
fitsTcl_copy
fitsTcl_sascii
fitsTcl_sort
fitsTcl_add
fitsTcl_append
fitsTcl_histo
fitsTcl_create
fitsTcl_checksum
fitsTcl_smooth
Fits_Init
fitsMoveHDU
fitsLoadHDU
fitsJustMoveHDU
fitsUpdateCHDU
fitsLoadKwds
deleteFitsCardList
fitsDumpHeader
fitsDumpHeaderToKV
fitsDumpKwdsToList
fitsDumpHeaderToCard
makeNewCHDUInfo
freeCHDUInfo
imageRowsMeanToPtr
imageColsMeanToPtr
imageBlockLoad_1D
imageBlockLoad
imageGetToPtr
vtableGetToPtr
tableGetToPtr
tableBlockLoad
fitsFlushKeywords
fitsPutReqKwds
fitsDeleteKwds
fitsPutKwds
fitsInsertKwds
fitsDeleteCols
fitsDeleteRows
fitsDeleteCHdu
saveTableToAscii
saveImageToAscii
varSaveToTable
addColToTable
addRowToTable
varSaveToImage
fitsCopyCHduToFile
fitsAppendCHduToFile
fitsPutHisKwd
fitsGetWcsMatrix
fitsGetWcsPair
fitsTableGetWcsOld
fitsReadColData
fitsReadRawColData
fitsSortTable
fitsWriteRowsToFile
fitsGetSortRangeNum
fitsGetSortRange
fitsUpdateFile
fitsColumnStatistics
fitsColumnMinMax
fitsColumnMinMaxToPtr
fitsColumnStatToPtr
fitsColumnGetToArray
fitsCalculateColumn
fitsDeleteRowsExpr
exprGetToPtr
exprGetInfo
Fits_MainCommand
FitsCreateObject
fitsCloseFile
FitsInfo
fitsPtr2Lst
fitsLst2Ptr
fitsRange
fitsExpr
dumpFitsErrStack
dumpFitsErrStackToDString
fitsMakeRegExp
fitsParseRange
makeContigArray
fitsTransColList
strToUpper
tdispGetFormat
fitsSwap
fitsQuickSort
fitsSplit
fitsFreeRawColData
fitsRandomizeColData
fitsTcl_Ptr2Lst
fitsTcl_Lst2Ptr
fitsTcl_SetDims
fitsTcl_GetDims
fitsTcl_ReadPtrStr
isFitsCmd
getMaxCmd
getMinCmd
setArray
searchArray
updateFirst
Table_calAbsXPos
Table_updateCell
fits_comp_img
imcomp_init_table
imcomp_calc_max_elem
imcomp_compress_image
imcomp_compress_tile
fits_decomp_img
fits_read_compressed_img
fits_read_compressed_pixels
fits_read_compressed_img_plane
imcomp_get_compressed_image_par
imcomp_copy_imheader
imcomp_decompress_tile
imcomp_copy_overlap
fits_rcomp
fits_rdecomp
fits_quantize_float
fits_quantize_double
pl_p2li
pl_l2pi
ffgics
ffgtcs
ffwldp
ffxypx
ffomem
ffopen
ffreopen
fits_already_open
fits_is_this_a_copy
ffedit_columns
fits_select_image_section
fits_get_section_range
ffselect_table
ffinit
ffimem
fits_init_cfitsio
fits_register_driver
ffiurl
ffrtnm
ffourl
ffexts
ffextn
ffurlt
ffimport_file
fits_get_token
urltype2driver
ffclos
ffdelt
fftrun
ffflushx
ffseek
ffwrite
ffread
fftplt
ffoptplt
ffrprt
ffcsum
ffesum
ffdsum
ffpcks
ffupck
ffvcks
ffgcks
uncompress2mem
uncompress2mem_from_mem
uncompress2file
compress2mem_from_mem
longest_match
file_init
file_setoptions
file_getoptions
file_getversion
file_shutdown
file_open
file_openfile
file_create
file_truncate
file_size
file_close
file_remove
file_flush
file_seek
file_read
file_write
file_compress_open
file_is_compressed
file_checkfile
mem_init
mem_setoptions
mem_getoptions
mem_getversion
mem_shutdown
mem_create
mem_openmem
mem_createmem
mem_truncate
stdin_checkfile
stdin_open
stdin2mem
stdin2file
stdout_close
mem_compress_open
mem_iraf_open
mem_rawfile_open
mem_uncompress2mem
mem_size
mem_close_free
mem_close_keep
mem_seek
mem_read
mem_write
ffrsim
ffirow
ffdrow
ffdrws
fficol
fficls
ffmvec
ffcpcl
ffcpky
ffdcol
ffcins
ffcdel
ffkshf
ffshft
ffcopy
ffcphd
ffcpdt
ffiimg
ffitab
ffibin
ffdhdu
fffrow
ffsrow
ffcrow
ffcalc
ffcalc_rng
fftexp
ffiprs
ffcprs
parse_data
ffcvtn
fffrwc
uncompress_hkdata
ffffrw
ffffrw_work
fflex
ffrestart
ff_switch_to_buffer
ff_load_buffer_state
ff_create_buffer
ff_delete_buffer
ff_init_buffer
ff_flush_buffer
ff_scan_buffer
ff_scan_string
ff_scan_bytes
ffwrap
ffGetVariable
strcasecmp
strncasecmp
ffparse
Evaluate_Parser
ffvers
ffflnm
ffflmd
ffgerr
ffpmsg
ffgmsg
ffcmsg
ffxmsg
ffpxsz
fftkey
fftrec
ffupch
ffmkky
ffmkey
ffkeyn
ffnkey
ffpsvc
ffgthd
ffasfm
ffbnfm
ffcfmt
ffcdsp
ffgcno
ffgcnn
ffcmps
ffgtcl
ffgncl
ffgnrw
ffgacl
ffgbcl
ffghdn
ffghof
ffghad
ffrhdu
ffpinit
ffainit
ffbinit
ffgabc
ffgtbc
ffgtbp
ffgcprll
ffgdes
ffgdess
ffpdes
ffchdu
ffuptf
ffrdef
ffhdef
ffwend
ffpdfl
ffchfl
ffcdfl
ffcrhd
ffdblk
ffghdt
fits_is_compressed_image
ffgipr
ffgidt
ffgidm
ffgisz
ffmahd
ffmrhd
ffmnhd
ffthdu
ffgext
ffiblk
ffgkcl
ffdtyp
ffc2x
ffc2i
ffc2l
ffc2r
ffc2d
ffc2ii
ffc2ll
ffc2s
ffc2rr
ffc2dd
ffgpxv
ffgpxf
ffgsv
ffgpv
ffgpf
ffgcv
ffgcf
ffgpvb
ffgpfb
ffg2db
ffg3db
ffgsvb
ffgsfb
ffggpb
ffgcvb
ffgcfb
ffgclb
fffi1i1
fffi2i1
fffi4i1
fffr4i1
fffr8i1
fffstri1
ffgpvd
ffgpfd
ffg2dd
ffg3dd
ffgsvd
ffgsfd
ffggpd
ffgcvd
ffgcvm
ffgcfd
ffgcfm
ffgcld
fffi1r8
fffi2r8
fffi4r8
fffr4r8
fffr8r8
fffstrr8
ffgpve
ffgpfe
ffg2de
ffg3de
ffgsve
ffgsfe
ffggpe
ffgcve
ffgcvc
ffgcfe
ffgcfc
ffgcle
fffi1r4
fffi2r4
fffi4r4
fffr4r4
fffr8r4
fffstrr4
ffgpvi
ffgpfi
ffg2di
ffg3di
ffgsvi
ffgsfi
ffggpi
ffgcvi
ffgcfi
ffgcli
fffi1i2
fffi2i2
fffi4i2
fffr4i2
fffr8i2
fffstri2
ffgpvj
ffgpfj
ffg2dj
ffg3dj
ffgsvj
ffgsfj
ffggpj
ffgcvj
ffgcfj
ffgclj
fffi1i4
fffi2i4
fffi4i4
fffr4i4
fffr8i4
fffstri4
ffgpvk
ffgpfk
ffg2dk
ffg3dk
ffgsvk
ffgsfk
ffggpk
ffgcvk
ffgcfk
ffgclk
fffi1int
fffi2int
fffi4int
fffr4int
fffr8int
fffstrint
ffgcvl
ffgcl
ffgcfl
ffgcll
ffgcx
ffgcxui
ffgcxuk
ffgcvs
ffgcfs
ffgcls
ffgcdw
ffgcls2
ffgpvui
ffgpfui
ffg2dui
ffg3dui
ffgsvui
ffgsfui
ffggpui
ffgcvui
ffgcfui
ffgclui
fffi1u2
fffi2u2
fffi4u2
fffr4u2
fffr8u2
fffstru2
ffgpvuj
ffgpfuj
ffg2duj
ffg3duj
ffgsvuj
ffgsfuj
ffggpuj
ffgcvuj
ffgcfuj
ffgcluj
fffi1u4
fffi2u4
fffi4u4
fffr4u4
fffr8u4
fffstru4
ffgpvuk
ffgpfuk
ffg2duk
ffg3duk
ffgsvuk
ffgsfuk
ffggpuk
ffgcvuk
ffgcfuk
ffgcluk
fffi1uint
fffi2uint
fffi4uint
fffr4uint
fffr8uint
fffstruint
ffghsp
ffghps
ffnchk
ffmaky
ffmrky
ffgnky
ffgnxk
ffgky
ffgkey
ffgrec
ffgcrd
ffgknm
ffgunt
ffgkys
ffgkls
ffgcnt
ffgkyl
ffgkyj
ffgkye
ffgkyd
ffgkyc
ffgkym
ffgkyt
ffgkyn
ffgkns
ffgknl
ffgknj
ffgkne
ffgknd
ffgtdm
ffdtdm
ffghpr
ffghtb
ffghbn
ffgphd
ffgttb
ffgtkn
fftkyn
ffh2st
ffgtcr
ffgtis
ffgtch
ffgtrm
ffgtcp
ffgtmg
ffgtcm
ffgtvf
ffgtop
ffgtam
ffgtnm
ffgmng
ffgmop
ffgmcp
ffgmtf
ffgmrm
ffgtgc
ffgtdc
ffgmul
ffgmf
ffgtrmr
ffgtcpr
fftsad
fftsud
prepare_keyvalue
fits_path2url
fits_url2path
fits_get_cwd
fits_get_url
fits_clean_url
fits_url2relurl
fits_relurl2url
fits_encode_url
fits_unencode_url
fits_is_url_absolute
ngp_get_extver
ngp_set_extver
ngp_delete_extver_tab
ngp_strcasecmp
ngp_line_from_file
ngp_free_line
ngp_free_prevline
ngp_read_line_buffered
ngp_unread_line
ngp_extract_tokens
ngp_include_file
ngp_read_line
ngp_keyword_is_write
ngp_keyword_all_write
ngp_hdu_init
ngp_hdu_clear
ngp_hdu_insert_token
ngp_append_columns
ngp_read_xtension
ngp_read_group
fits_execute_template
ffbins
ffbinr
ffhist
fits_get_col_minmax
ffwritehisto
ffcalchist
iraf2mem
main
ffuky
ffukyu
ffukys
ffukls
ffukyl
ffukyj
ffukyf
ffukye
ffukyg
ffukyd
ffukfc
ffukyc
ffukfm
ffukym
ffucrd
ffmrec
ffmcrd
ffmnam
ffmcom
ffpunt
ffmkyu
ffmkys
ffmkls
ffmkyl
ffmkyj
ffmkyf
ffmkye
ffmkyg
ffmkyd
ffmkfc
ffmkyc
ffmkfm
ffmkym
ffikyu
ffikys
ffikls
ffikyl
ffikyj
ffikyf
ffikye
ffikyg
ffikyd
ffikfc
ffikyc
ffikfm
ffikym
ffirec
ffikey
ffdkey
ffdrec
ffppx
ffppxn
ffppr
ffppn
ffpcl
ffpcn
fits_iter_set_by_name
fits_iter_set_by_num
fits_iter_set_file
fits_iter_set_colname
fits_iter_set_colnum
fits_iter_set_datatype
fits_iter_set_iotype
fits_iter_get_file
fits_iter_get_colname
fits_iter_get_colnum
fits_iter_get_datatype
fits_iter_get_iotype
fits_iter_get_array
fits_iter_get_tlmin
fits_iter_get_tlmax
fits_iter_get_repeat
fits_iter_get_tunit
fits_iter_get_tdisp
ffiter
ffpprb
ffppnb
ffp2db
ffp3db
ffpssb
ffpgpb
ffpclb
ffpcnb
ffi1fi1
ffi1fi2
ffi1fi4
ffi1fr4
ffi1fr8
ffi1fstr
ffpprd
ffppnd
ffp2dd
ffp3dd
ffpssd
ffpgpd
ffpcld
ffpclm
ffpcnd
ffr8fi1
ffr8fi2
ffr8fi4
ffr8fr4
ffr8fr8
ffr8fstr
ffppre
ffppne
ffp2de
ffp3de
ffpsse
ffpgpe
ffpcle
ffpclc
ffpcne
ffr4fi1
ffr4fi2
ffr4fi4
ffr4fr4
ffr4fr8
ffr4fstr
ffppri
ffppni
ffp2di
ffp3di
ffpssi
ffpgpi
ffpcli
ffpcni
ffi2fi1
ffi2fi2
ffi2fi4
ffi2fr4
ffi2fr8
ffi2fstr
ffpprj
ffppnj
ffp2dj
ffp3dj
ffpssj
ffpgpj
ffpclj
ffpcnj
ffi4fi1
ffi4fi2
ffi4fi4
ffi4fr4
ffi4fr8
ffi4fstr
ffpprk
ffppnk
ffp2dk
ffp3dk
ffpssk
ffpgpk
ffpclk
ffpcnk
ffintfi1
ffintfi2
ffintfi4
ffintfr4
ffintfr8
ffintfstr
ffpcll
ffpcnl
ffpclx
ffpcls
ffpcns
ffppru
ffpprn
ffpclu
ffpprui
ffppnui
ffp2dui
ffp3dui
ffpssui
ffpgpui
ffpclui
ffpcnui
ffu2fi1
ffu2fi2
ffu2fi4
ffu2fr4
ffu2fr8
ffu2fstr
ffppruj
ffppnuj
ffp2duj
ffp3duj
ffpssuj
ffpgpuj
ffpcluj
ffpcnuj
ffu4fi1
ffu4fi2
ffu4fi4
ffu4fr4
ffu4fr8
ffu4fstr
ffppruk
ffppnuk
ffp2duk
ffp3duk
ffpssuk
ffpgpuk
ffpcluk
ffpcnuk
ffuintfi1
ffuintfi2
ffuintfi4
ffuintfr4
ffuintfr8
ffuintfstr
ffcrim
ffcrtb
ffpktp
ffpky
ffprec
ffpkyu
ffpkys
ffpkls
ffplsw
ffpkyl
ffpkyj
ffpkyf
ffpkye
ffpkyg
ffpkyd
ffpkyc
ffpkym
ffpkfc
ffpkfm
ffpkyt
ffpcom
ffphis
ffpdat
ffgstm
ffdt2s
ffs2dt
fftm2s
ffs2tm
ffgsdt
ffpkns
ffpknl
ffpknj
ffpknf
ffpkne
ffpkng
ffpknd
ffptdm
ffphps
ffphpr
ffphtb
ffphbn
ffi2c
ffl2c
ffs2c
ffr2f
ffr2e
ffd2f
ffd2e
ffrrgn
fftrgn
fffrgn
ffpthp
ffpscl
ffpnul
fftscl
fftnul
ffsnul
ffswap2
ffswap4
ffswap8
ffmbyt
ffpbyt
ffpbytoff
ffgbyt
ffgbytoff
ffldrc
ffwhbf
ffflus
ffflsh
ffbfeof
ffbfwt
ffgrsz
fits_get_num_files
ffgtbb
ffgi1b
ffgi2b
ffgi4b
ffgr4b
ffgr8b
ffptbb
ffpi1b
ffpi2b
ffpi4b
ffpr4b
ffpr8b
fitsTcl/fitstcl.dsp 0000644 0002307 0000036 00000023364 11222720662 013250 0 ustar chai lhea # Microsoft Developer Studio Project File - Name="fitstcl" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=fitstcl - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "fitstcl.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "fitstcl.mak" CFG="fitstcl - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "fitstcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "fitstcl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "fitstcl - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /compile_only /include:"Release/" /dll /nologo /warn:nofileopt
# ADD F90 /compile_only /include:"Release/" /dll /nologo /warn:nofileopt
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /D "__WIN32__" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tcl83.lib /nologo /dll /machine:I386 /out:"fitstcl.dll"
!ELSEIF "$(CFG)" == "fitstcl - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
F90=df.exe
# ADD BASE F90 /check:bounds /compile_only /debug:full /include:"Debug/" /dll /nologo /traceback /warn:argument_checking /warn:nofileopt
# ADD F90 /browser /check:bounds /compile_only /debug:full /include:"Debug/" /dll /nologo /traceback /warn:argument_checking /warn:nofileopt
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FITSTCL_EXPORTS" /D "__WIN32__" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo /o"fitstcl.bsc"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tcl83d.lib /nologo /dll /debug /machine:I386 /out:"fitstcl.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "fitstcl - Win32 Release"
# Name "fitstcl - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;f90;for;f;fpp"
# Begin Source File
SOURCE=.\cfitsio\buffers.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\cfileio.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\checksum.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\compress.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\drvrfile.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\drvrmem.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\editcol.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\edithdu.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\eval_f.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\eval_l.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\eval_y.c
# End Source File
# Begin Source File
SOURCE=.\fitsCmds.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\fitscore.c
# End Source File
# Begin Source File
SOURCE=.\fitsInit.c
# End Source File
# Begin Source File
SOURCE=.\fitsIO.c
# End Source File
# Begin Source File
SOURCE=.\fitsTcl.c
# End Source File
# Begin Source File
SOURCE=.\fitstcl.def
# End Source File
# Begin Source File
SOURCE=.\fitsUtils.c
# End Source File
# Begin Source File
SOURCE=.\fvTcl.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcol.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcolb.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcold.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcole.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcoli.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcolj.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcolk.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcoll.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcols.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcolui.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcoluj.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getcoluk.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\getkey.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\group.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\grparser.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\histo.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\imcompress.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\iraffits.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\listhead.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\modkey.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\pliocomp.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcol.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcolb.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcold.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcole.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcoli.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcolj.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcolk.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcoll.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcols.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcolu.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcolui.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcoluj.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putcoluk.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\putkey.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\quantize.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\region.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\ricecomp.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\scalnull.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\swapproc.c
# End Source File
# Begin Source File
SOURCE=.\cfitsio\wcsutil.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\cfitsio\cfortran.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\compress.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\drvrsmem.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\eval_defs.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\eval_tab.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\f77_wrap.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\fitsio.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\fitsio2.h
# End Source File
# Begin Source File
SOURCE=.\fitsTcl.h
# End Source File
# Begin Source File
SOURCE=.\fitsTclInt.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\group.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\grparser.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\imcompress.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\longnam.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\pctype.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\region.h
# End Source File
# Begin Source File
SOURCE=.\cfitsio\ricecomp.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
fitsTcl/config.guess 0000755 0002307 0000036 00000130611 11222720662 013402 0 ustar chai lhea #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
# Free Software Foundation, Inc.
timestamp='2008-11-15'
# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner .
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
exit ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
*:SolidBSD:*:*)
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if echo '\n#ifdef __amd64\nIS_64BIT_ARCH\n#endif' | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c &&
dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`$dummy $dummyarg` &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos${UNAME_RELEASE}
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
then
echo "$SYSTEM_NAME"
else
echo rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[456])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
eval $set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:[3456]*)
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
EM64T | authenticamd | genuineintel)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i586-pc-interix
exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
mips:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit ;;
"")
# Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help.
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
exit ;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^LIBC/{
s: ::g
p
}'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
}
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
echo ${UNAME_MACHINE}-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit ;;
SX-7:SUPER-UX:*:*)
echo sx7-nec-superux${UNAME_RELEASE}
exit ;;
SX-8:SUPER-UX:*:*)
echo sx8-nec-superux${UNAME_RELEASE}
exit ;;
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
exit ;;
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <
# include
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
exit ;;
esac
fi
cat >&2 < in order to provide the needed
information to handle your system.
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = ${UNAME_MACHINE}
UNAME_RELEASE = ${UNAME_RELEASE}
UNAME_SYSTEM = ${UNAME_SYSTEM}
UNAME_VERSION = ${UNAME_VERSION}
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
fitsTcl/fitsTclInt.h 0000644 0002307 0000036 00000036472 11222720662 013330 0 ustar chai lhea /*
* fitsTclInt.h -
*
* This header file contains the definitions, structures, and
* function prototypes for fitsTcl's internal use.
*/
/*
*-----------------------------------------------------------------
* MODIFICATION HISTORY
* 2004-02-06 Ziqin Pan
* 1. Add long rowindex to colData structure
*
*----------------------------------------------------------------
*/
#ifndef FITSTCLINT
#define FITSTCLINT
#ifndef macintosh
#include
#endif
#include
#include
#include
#include
#include
#include
#ifdef HAVE_ALLOCA_H
#include
#endif
#include "fitsTcl.h"
#include "fitsio2.h"
#define FITS_COLMAX 999
#define FITS_MAXDIMS 15
#define FITS_MAXRANGE 30
#define FITS_CHUNKSIZE 100
#define BYTE_DATA 0
#define SHORTINT_DATA 1
#define INT_DATA 2
#define FLOAT_DATA 3
#define DOUBLE_DATA 4
#define LONGLONG_DATA 5
#define NOHDU -1
typedef struct {
int numCols;
LONGLONG numRows;
LONGLONG rowLen;
char **colName;
char **colType;
int *colDataType;
char **colUnit;
char **colDisp;
char **colNull;
long *vecSize;
double *colTzero;
double *colTscale;
int *colTzflag;
int *colTsflag;
int *strSize;
int loadStatus;
int *colWidth;
char **colFormat;
double *colMin;
double *colMax;
} TableHDUInfo;
typedef struct {
int bitpix;
int naxes;
LONGLONG *naxisn;
char **axisUnit;
double bscale;
double bzero;
long bsflag;
long bzflag;
char blank[80];
int dataType;
} ImageHDUInfo;
typedef union {
TableHDUInfo table;
ImageHDUInfo image;
} HDUInfo;
typedef struct {
char name[FLEN_KEYWORD];
char value[FLEN_VALUE];
char comment[FLEN_COMMENT];
int pos;
} Keyword;
typedef struct FitsCardStruct{
int pos;
char value[FLEN_CARD];
struct FitsCardStruct * next;
} FitsCardList;
typedef struct {
Tcl_Interp *interp;
fitsfile *fptr;
int fileNum;
char* fileName;
char* handleName;
int rwmode;
int chdu;
int hduType;
char extname[FLEN_VALUE];
int numKwds;
int numHis;
int numCom;
Tcl_HashTable *kwds;
FitsCardList *hisHead;
FitsCardList *comHead;
HDUInfo CHDUInfo;
} FitsFD;
typedef struct {
LONGLONG longlongData;
double dblData;
long intData;
char *strData;
char flag;
long rowindex;
unsigned char *colBuffer;
} colData;
typedef struct {
double min;
double max;
double mean;
long fmin;
long fmax;
double stdiv;
long numData;
} colStat;
/*
* These are the function Prototypes:
*/
EXTERN void fitsCloseFile (ClientData clientData);
EXTERN void dumpFitsErrStackToDString( Tcl_DString *stack, int status );
EXTERN void dumpFitsErrStack ( Tcl_Interp *interp, int status );
EXTERN int fitsMoveHDU (FitsFD *curFile, int nmove,
int direction);
EXTERN int FitsCreateObject (Tcl_Interp *interp,
int argc, Tcl_Obj *const argv[]);
EXTERN int FitsInfo (Tcl_Interp *interp,
int argc, Tcl_Obj *const argv[]);
EXTERN int fitsLoadKwds (FitsFD *curFile);
EXTERN int fitsLoadHDU (FitsFD *curFile);
EXTERN int fitsMakeRegExp (Tcl_Interp *interp,
int argc, char *const argv[],
Tcl_DString *concatList,
int caseSen );
EXTERN int fitsDumpHeader (FitsFD *curFile);
EXTERN int fitsParseRangeNum (char* rangeStr);
EXTERN int fitsParseRange (char* rangeStr, int *numInt,
int *range,
int maxInt,
int minval, int maxval,
char *errMsg);
EXTERN void *makeContigArray (int nrows, int ncols, char type);
EXTERN int freeCHDUInfo (FitsFD * curFile);
EXTERN int makeNewCHDUInfo (FitsFD * curFile, int newHduType);
EXTERN int tableBlockLoad ( FitsFD * curFile,
char *varName,
int felem,
int fRow,
int nRows,
int fCol,
int nCols,
int colNums[],
int format);
EXTERN int freeDataPtr (FitsFD * curFile, char ptrAddress[]);
EXTERN int tableGetToPtr (FitsFD * curFile,
long colNum,
char *nulStr,
long firstelem);
EXTERN int tableRowGetToPtr (FitsFD * curFile,
long rowNum,
long colNum,
long vecSize,
char *nulStr,
long firstelem);
EXTERN int vtableGetToPtr (FitsFD *curFile,
long colNum,
char *nulStr);
EXTERN void deleteFitsCardList ( FitsCardList *comCard);
EXTERN int fitsTransColList (FitsFD *curFile,
char *colStr,
int *numCols,
int colNums[],
int colTypes[],
int strSize[]);
EXTERN int fitsFlushKeywords (FitsFD *curFile);
EXTERN int strToUpper (char *inStr,
char **outStr);
EXTERN int fitsInsertKwds (FitsFD *curFile,
int index,
char *inCard,
int ifFormat);
EXTERN int fitsPutKwds (FitsFD *curFile,
int nkey,
char *inCard,
int ifFormat);
EXTERN int fitsPutHisKwd ( FitsFD *curFile,
char *his);
EXTERN int fitsDeleteKwds (FitsFD *curFile,
char *keyList);
EXTERN int fitsDeleteCols (FitsFD *curFile,
int *colList,
int numCols);
EXTERN int fitsDeleteRows (FitsFD *curFile,
int firstRow,
int numRows);
EXTERN int fitsDeleteCHdu (FitsFD *curFile);
EXTERN int tdispGetFormat (FitsFD *curFile, int colnum);
EXTERN int saveTableToAscii (FitsFD *curFile,
char *filename,
char *fileStatus,
int felem,
int fRow,
int nRows,
int nCols,
int colTypes[],
int colNums[],
int strSize[],
int ifFixedFormat,
int ifCSV,
int ifPrintRow,
char *sepString);
EXTERN int saveImageToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int cellSize,
int ifCSV,
int ifPrintRow,
char *sepString,
long slice );
EXTERN int saveVectorTableToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int baseColNum,
int ifCSV,
int ifPrintRow,
char *sepString,
int ifVariableVec);
EXTERN int saveVectorTableRowToAscii( FitsFD *curFile,
char *filename,
char *fileStatus,
int fRow,
int nRows,
int fCol,
int nCols,
int baseColNum,
int ifCSV,
int ifPrintRow,
char *sepString,
int ifVariableVec,
char *colFormat,
int dataType,
FILE *fPtr,
int ifFixedFormat);
EXTERN int varSaveToTable (FitsFD *curFile,
int colNum,
long firstRow,
long firstElem,
long numRows,
long numElem,
Tcl_Obj **listArray);
EXTERN int varSaveToImage (FitsFD *curFile,
long firstElem,
long numElem,
Tcl_Obj **listArray);
EXTERN int addColToTable (FitsFD *curFile,
int colNum,
char *ttype,
char *tform);
EXTERN int addRowToTable (FitsFD *curFile,
int rowNum,
int nRows);
EXTERN int fitsCopyCHduToFile (FitsFD *curFile,
char *newfilename);
EXTERN void fitsQSsetFlag (colData a[],
int dataType,
int strSize,
int fst,
int lst);
EXTERN void fitsQuickSort (colData a[],
int dataType,
int strSize,
int fst,
int lst,
int isAscend);
/*
EXTERN int fitsSplit (colData a[],
int dataType,
int strSize,
int f,
int l,
int isAscend);
*/
EXTERN int fitsSplit (colData a[],
int dataType,
int strSize,
int f,
int l,
int isAscend,
int * sp1,
int * sp2);
EXTERN void fitsSwap (colData *p,
colData *q);
EXTERN int fitsUpdateFile (FitsFD *curFile);
EXTERN void fitsGetSortRange (colData a[],
long n,
long *t,
long *b);
EXTERN void fitsGetSortRangeNum (colData a[],
long n,
long *nr);
EXTERN int fitsWriteRowsToFile (FitsFD *curFile,
long rowSize,
colData columndata[],
int isMerge);
EXTERN int fitsCalculateColumn (FitsFD *curFile,
char *colName,
char *colForm,
char *expr);
EXTERN int fitsCalculaterngColumn ( FitsFD *curFile,
char *colName,
char *colForm,
char *expr,
int numrange,
int range[][2]);
EXTERN int fitsDeleteRowsExpr (FitsFD *curFile,
char *expr);
EXTERN int exprGetInfo ( FitsFD *curFile,
char *expr );
EXTERN int exprGetToPtr ( FitsFD *curFile,
char *expr,
char *nulStr,
int numrange,
int range[][2]);
EXTERN int fitsColumnGetToArray ( FitsFD *curFile,
int colNum,
int felem,
long fRow,
long lRow,
double *array,
char *flagArray);
EXTERN int fitsJustMoveHDU ( FitsFD *curFile,
int nmove,
int direction);
EXTERN int fitsUpdateCHDU( FitsFD *curFile, int newHduType);
EXTERN int fitsDumpHeaderToKV ( FitsFD *curFile );
EXTERN int fitsDumpHeaderToCard( FitsFD *curFile );
EXTERN int fitsDumpKwdsToList ( FitsFD *curFile );
EXTERN int imageRowsMeanToPtr( FitsFD *curFile,
long fRow,
long lRow,
long slice );
EXTERN int imageColsMeanToPtr( FitsFD *curFile,
long fCol,
long lCol,
long slice );
EXTERN int imageBlockLoad_1D( FitsFD *curFile,
long fElem,
long nElem );
EXTERN int imageBlockLoad( FitsFD *curFile,
char *varName,
LONGLONG fRow,
LONGLONG nRow,
LONGLONG fCol,
LONGLONG nCol,
long slice,
long cslice);
EXTERN int imageGetToPtr( FitsFD *curFile,
long slice,
int rotate );
EXTERN int fitsPutReqKwds( FitsFD *curFile,
int isPrImg,
int hduType,
int argc,
char *const argv[] );
EXTERN int fitsAppendCHduToFile( FitsFD *curFile,
char *targetfilename );
EXTERN int fitsGetWcsMatrix( FitsFD *curFile,
int nDims,
int cols[],
char dest );
EXTERN int fitsGetWcsMatrixAlt( FitsFD *curFile,
fitsfile *fptr,
Tcl_Obj *listObj,
int nDims,
int cols[],
char dest );
EXTERN int fitsFileGetWcsMatrix( FitsFD *curFile,
fitsfile *dummyFile,
int nDims,
int cols[],
char dest, Tcl_Obj *data[]);
EXTERN int fitsGetWcsPair( FitsFD *curFile,
int Col1,
int Col2,
char dest );
EXTERN int fitsGetWcsPairAlt( FitsFD *curFile,
fitsfile *fptr,
Tcl_Obj *listObj,
int Col1,
int Col2,
char dest );
EXTERN int fitsTableGetWcsOld( FitsFD *curFile,
int RAColNum,
int DecColNum );
EXTERN int fitsReadColData( FitsFD *curFile,
int colNum,
int strSize,
colData columndata[],
int *dataType );
EXTERN int fitsReadRawColData( FitsFD *curFile,
colData columndata[],
LONGLONG *rowSize );
EXTERN int fitsSortTable( FitsFD *curFile,
int numCols,
int *colNum,
int *strSize,
int *isAscend,
int isMerge );
EXTERN int fitsColumnStatistics( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2] );
EXTERN int fitsColumnMinMax( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2] );
EXTERN int fitsColumnMinMaxToPtr( FitsFD *curFile,
int colNum,
int felem,
int fRow,
int lRow,
double *min,
double *max );
EXTERN int fitsColumnStatToPtr( FitsFD *curFile,
int colNum,
int felem,
int numrange,
int range[][2],
colStat *colstat,
int statFlag );
EXTERN void fitsRandomizeColData( colData columndata[], long numRows );
EXTERN void fitsFreeRawColData ( colData columndata[], long numRows );
EXTERN Tcl_Obj *fitsTcl_Ptr2Lst( Tcl_Interp *interp, void *thePtr, char *undef,
int dataType, long nelem );
EXTERN void *fitsTcl_Lst2Ptr( Tcl_Interp *interp, Tcl_Obj *dataLst,
int dataType, long *nelem, char **undef );
EXTERN int fitsTcl_SetDims( Tcl_Interp *interp, Tcl_Obj **dimObj,
int naxis, long naxes[] );
EXTERN int fitsTcl_GetDims( Tcl_Interp *interp, Tcl_Obj *dimObj,
long *nelem, int *naxis, long naxes[] );
EXTERN void *fitsTcl_ReadPtrStr( Tcl_Obj *ptrObj );
/* Feb 18, 2004, Ziqin Pan add to support row selection */
EXTERN int fitsDeleteRowlist(FitsFD *curFile,long* rowlist,int numRows );
EXTERN int fitsDeleteRowsRange( FitsFD *curFile,char * rangelist);
EXTERN int fitsCalculaterngColumn( FitsFD *curFile,char *colName,char *colForm, char *expr, int numrange,
int range[][2] );
EXTERN int fitsSelectRowsExpr (FitsFD *curFile,char *expr,long firstrow,long nrows,
long * n_good_rows,char * row_status);
EXTERN LONGLONG fitsTcl_atoll (char *inputStr);
/**********************************
* fitsTcl command handlers *
**********************************/
int fitsTcl_close ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_move ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_dump ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_info ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_get ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_put ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_insert ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_delete ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_select ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_load ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_free ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_flush ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_copy ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_sascii ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_sort ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_add ( FitsFD *curFile, int argc, char *const argv[] );
int fitsTcl_append ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_histo ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_create ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_smooth ( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
int fitsTcl_checksum( FitsFD *curFile, int argc, Tcl_Obj *const argv[] );
#define FITS_MAX_OPEN_FILES NIOBUF /* Set by CFITSIO */
/*
* This is the list of open Fits Files...
*/
EXTERN FitsFD FitsOpenFiles[FITS_MAX_OPEN_FILES];
typedef struct {
int wcsSwap;
} fitsTclOptions;
EXTERN fitsTclOptions userOptions;
#endif
fitsTcl/config.sub 0000755 0002307 0000036 00000101756 11222720662 013055 0 ustar chai lhea #! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
# Free Software Foundation, Inc.
timestamp='2008-09-08'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| mt \
| msp430 \
| nios | nios2 \
| ns16k | ns32k \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
openrisc | openrisc-*)
basic_machine=or32-unknown
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mep-*)
os=-elf
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End: