cdf-to-fits/cdffits.h0000674000077000007660000001740110053160762015022 0ustar davidhcdf00000000000000#if !defined(CDFFITS_INCLUDEd__) #define CDFFITS_INCLUDEd__ #include "cdf.h" #include "fitsio.h" #define Nl '\n' /* Newline. */ #define NUL '\0' /* Null character. */ #define DU_MAX_PATH_LEN 255 #define DU_MAX_DIR_LEN 255 #define DU_MAX_NAME_LEN 127 #define BOO(b,t,f) (b ? t : f) #define EofS(string) &string[strlen(string)] /***************************************************************************** * Minimum/Maximum macros. *****************************************************************************/ #if !defined(MINIMUM) # define MINIMUM(a,b) ((a) < (b) ? (a) : (b)) #endif #if !defined(MAXIMUM) # define MAXIMUM(a,b) ((a) > (b) ? (a) : (b)) #endif #define MINIMUMof3(a,b,c) (MINIMUM(a,MINIMUM(b,c))) #define MAXIMUMof3(a,b,c) (MAXIMUM(a,MAXIMUM(b,c))) /****************************************************************************** * Typedefs. ******************************************************************************/ typedef int Logical; typedef unsigned short uShort; typedef unsigned int uInt; typedef unsigned long uLong; #if defined(alphaosf) || defined(IRIX64bit) /*************************************************************************** * `long' is 64 bits on a DEC Alpha/OSF1 and an SGi/IRIX 6.x using the `-64' * option (64-bit objects). `int' is 32 bits in these cases. ***************************************************************************/ typedef int Int32; typedef uInt uInt32; #else typedef long Int32; typedef uLong uInt32; #endif typedef short Int16; typedef uShort uInt16; #if defined(AIX) || defined(dos) || defined(sgi) || defined(__QNX__) /*************************************************************************** * `char' is unsigned by default under AIX, MS-DOS, IRIX, and QNX... ***************************************************************************/ typedef signed char sChar; #else /*************************************************************************** * ...and signed by default everywhere else. ***************************************************************************/ typedef char sChar; #endif typedef unsigned char uChar; #if !defined(mac) /**************************************************************************** * `Byte' is already defined in `types.h' on a Macintosh (MPW C & Think C). ****************************************************************************/ typedef uChar Byte; #endif typedef uChar uByte; typedef sChar sByte; /***************************************************************************** * TRUE/FALSE (for where they don't exist). *****************************************************************************/ #if !defined(TRUE) # define TRUE 1 #endif #if !defined(FALSE) # define FALSE 0 #endif #define LogicalTRUE ((Logical) TRUE) #define LogicalFALSE ((Logical) FALSE) /***************************************************************************** * Exit macros. *****************************************************************************/ #if defined(vms) # define EXIT_SUCCESS_ SS$_NORMAL # define EXIT_FAILURE_ SS$_ABORT #else # define EXIT_SUCCESS_ 0 # define EXIT_FAILURE_ 1 #endif #define Exit exit(EXIT_SUCCESS_) #define ExitBAD exit(EXIT_FAILURE_) /***************************************************************************** * Matching constants. *****************************************************************************/ #define NOMATCH (-1) #define MATCHES (-2) #define MAX_MESSAGE_TEXT_LEN 80 /***************************************************************************** * QOP constants. *****************************************************************************/ #define QOP_MAX_ARGVs 40 #define QOP_MAX_PARMs 40 #define QOP_MAX_QUALs 30 /***************************************************************************** * QOP structure. *****************************************************************************/ typedef struct QOPstruct { int Nparms; char *parms[QOP_MAX_PARMs]; int qualEntered[QOP_MAX_QUALs]; char *qualOpt[QOP_MAX_QUALs]; } QOP; /****************************************************************************** * QOP constants. ******************************************************************************/ #define CDFPATHparm 0 #define HELPqual 0 #define DELETEqual 1 #define DEFAULTdelete FALSE #define NOHEADERqual 2 #define DEFAULTnoheader FALSE #define SHOWqual 3 #define MAPqual 4 #define DEBUGqual 5 #define DRYRUNqual 6 #define DEFAULTdryrun FALSE #define MULTIqual 7 #define DEFAULTmulti FALSE /****************************************************************************** * Global variables. ******************************************************************************/ #if defined(mac) # define MAX_LINES_WHEN_PAGING 24 #else # define MAX_LINES_WHEN_PAGING 22 #endif #define MAX_PROGRAM_NAME_LEN 25 /****************************************************************************** * Format specifiers. ******************************************************************************/ #if defined(alphaosf) || defined(IRIX64bit) # define Int32FORMAT "%d" # define Int32uFORMAT "%u" # define Int32FORMATmod "" # define Int32hexFORMAT "0x%08X" #else # define Int32FORMAT "%ld" # define Int32uFORMAT "%lu" # define Int32FORMATmod "l" # define Int32hexFORMAT "0x%08lX" #endif #define IMAGE 1 #define BINTABLE 2 #define TABLE 3 #define PRIMARY 1 #define XTENSION 2 #if defined(CDFFITS) QOP *Qop(int, char *[], char *[], int *); void QuitCDF(char *, CDFstatus); void QuitX(char *, char *); void QuitFITS(char *, char *); CDFid OpenCDF(char *); void CloseCDF(CDFid); void GetCDFInfo (CDFid, long *, long *, long *, long *, long *, long *); void GetGlobalAttributeNumbers (CDFid, long, long *); void GetGlobalAttributeInfo (CDFid, long, char *, long *, long *); CDFstatus GetGlobalAttributeEntryInfo (CDFid, long, long, long *, long *); void GetGlobalAttributeEntryData (CDFid, long, long, void *); void GetGlobalAttributeEntries (CDFid, long, long, long *, long *, long *, void **); void GetVarInfo (CDFid, long, char *, long *, long *, long *, long *, long *, long *); int GetVarsRecordNumbers (CDFid, char **, long *, long *, int *); void GetVarAttributes (CDFid, long, long *, char **); void GetVarAttributeInfo (CDFid, long, long, long *, long *); CDFstatus GetVarPadValaue (CDFid, long, void *); CDFstatus GetVarAttributeEntryInfo (CDFid, long, long, long *, long *); void GetVarAttributeEntryData (CDFid, long, long, void *); void GetVarRecordData(CDFid, long, long, long, long, long *, void *); char *DataTypeToken (long); void FatalError PROTOARGs((char *message)); Logical TFqualifier PROTOARGs(( QOP *qop, Logical *variable, int Tx, int Fx, Logical defaultTF, char *conflictText )); void DisplayError PROTOARGs((char *message)); int FindUniqueMatch PROTOARGs((char *target, char *strings[])); int WriteOut PROTOARGs((FILE *, char *)); void WriteStringStdOut (char *, size_t); int strncmpIgCase (char *, char *, size_t); void ReadCharStdIn PROTOARGs((char *key)); void ParseKeyword(char *, long, char *, char *, char *, int *, int *, int *, char *, void *); void DumpAttributeEntry(long, long, void *); void DumpFITSCard(char *, char *, char *, int, int, void *, char *); void PrintFITSerror(int, char *); int ConvertCDFDataType(long); void FirstPass(CDFid, long, long, int *, int *, int *, int *, int *, long *, long *, long *, int *, char **, char **, char **, char *); int GetFITSdataType(char *); #endif #endif cdf-to-fits/CDFfunc.c0000674000077000007660000003527710322750440014653 0ustar davidhcdf00000000000000#include "cdf.h" #include "cdffits.h" /****************************************************************************** * QuitCDF. ******************************************************************************/ void QuitCDF (char *where, CDFstatus status) { char text[CDF_STATUSTEXT_LEN+1]; printf ("ERROR at %s...\n", where); if (status < CDF_OK) { CDFlib (SELECT_, CDF_STATUS_, status, GET_, STATUS_TEXT_, text, NULL_); printf ("%s\n", text); } CDFlib (CLOSE_, CDF_, NULL_); exit(1); } /****************************************************************************** * QuitFITS. ******************************************************************************/ void QuitFITS (char *where, char *text) { printf ("ERROR at %s...\n", where); printf ("FITS: %s\n", text); exit(1); } /****************************************************************************** * QuitX. ******************************************************************************/ void QuitX (char *where, char *msg) { printf ("ERROR at %s...\n", where); printf (" msg: %s\n", msg); exit(1); } /************************************************************************** * Open a CDF. **************************************************************************/ CDFid OpenCDF(char *CDFpath) { CDFstatus status; CDFid id; status = CDFlib (OPEN_, CDF_, CDFpath, &id, SELECT_, CDF_READONLY_MODE_, READONLYon, CDF_zMODE_, zMODEon2, NULL_); if (status < CDF_OK) QuitCDF ("10.0", status); return id; } /************************************************************************** * Close a CDF. **************************************************************************/ void CloseCDF(CDFid id) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, CLOSE_, CDF_, NULL_); if (status < CDF_OK) QuitX ("60.0", "Error... at closing the CDF"); return; } /************************************************************************** * Acquire certain infomation from the CDF, e.g., majority, number of total * attributes, number of global attributes and variable attributes, and * the maximum record number among all variables. **************************************************************************/ void GetCDFInfo (CDFid id, long *majority, long *numAttrs, long *numGattrs, long *numVattrs, long *numZvars, long *maxRecNum) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, GET_, CDF_MAJORITY_, majority, CDF_NUMATTRS_, numAttrs, CDF_NUMgATTRS_, numGattrs, CDF_NUMvATTRS_, numVattrs, CDF_NUMzVARS_, numZvars, zVARs_MAXREC_, maxRecNum, NULL_); if (status < CDF_OK) QuitCDF ("15.0", status); return; } /**************************************************************************** * Acquire a global attribute's entry info, e.g., their entry numbers, * data types, number of elements and data contents. ****************************************************************************/ void GetGlobalAttributeEntries (CDFid id, long gAttrNum, long numEntries, long *entryNums, long *entryDataType, long *entryNumElems, void **entries) { int jj; long kk, status; size_t bufferSize; long maxEntry; long dataType, numElems; status = CDFlib (SELECT_, CDF_, id, ATTR_, gAttrNum, NULL_); kk = 0; /********************************************************************** * Acquire info for each entry. **********************************************************************/ for (jj = 0; jj < numEntries; jj++) { while (TRUE) { /* break it until an entry is found */ status = CDFlib (SELECT_, gENTRY_, (long) kk, GET_, gENTRY_DATATYPE_, &dataType, gENTRY_NUMELEMS_, &numElems, NULL_); if (status == CDF_OK) { entryNums[jj] = kk; entryDataType[jj] = dataType; entryNumElems[jj] = numElems; if (dataType == CDF_CHAR || dataType == CDF_UCHAR) bufferSize = (size_t) (numElems+1); else bufferSize = (size_t)CDFelemSize(dataType)*numElems; entries[jj] = (void *) malloc (bufferSize); status = CDFlib (GET_, gENTRY_DATA_, (void *) entries[jj], NULL_); kk++; break; } kk++; } } return; } /**************************************************************************** * Acquire a global attribute's entry data. ****************************************************************************/ void GetGlobalAttributeEntryData (CDFid id, long gAttrNum, long entryNum, void *entry) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, ATTR_, gAttrNum, gENTRY_, entryNum, GET_, gENTRY_DATA_, entry, NULL_); if (status < CDF_OK) QuitCDF ("20.0", status); return; } /**************************************************************************** * Acquire a global attribute's entry info, e.g., data type, number of * elements, if it exists. ****************************************************************************/ CDFstatus GetGlobalAttributeEntryInfo (CDFid id, long gAttrNum, long entryNum, long *dataType, long *numElems) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, ATTR_, gAttrNum, gENTRY_, entryNum, GET_, gENTRY_DATATYPE_, dataType, gENTRY_NUMELEMS_, numElems, NULL_); return status; } /**************************************************************************** * Acquire a global attribute's info., e.g., its name, number of * entries, and the maximum entry number. ****************************************************************************/ void GetGlobalAttributeInfo (CDFid id, long gAttrNum, char *attr_name, long *numEntries, long *maxEntry) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, ATTR_, gAttrNum, GET_, ATTR_NAME_, attr_name, ATTR_MAXgENTRY_, maxEntry, ATTR_NUMgENTRIES_, numEntries, NULL_); if (status < CDF_OK) QuitCDF("25.0", status); return; } /**************************************************************************** * Acquire global attributes's numbers from the attribute list. ****************************************************************************/ void GetGlobalAttributeNumbers (CDFid id, long numAttrs, long *gAttrNum) { int ii, kk; long scope, status; kk = 0; for (ii = 0; ii < numAttrs; ii++) { status = CDFlib (SELECT_, CDF_, id, ATTR_, (long) ii, GET_, ATTR_SCOPE_, &scope, NULL_); if (status < CDF_OK) QuitCDF ("25.5", status); if (scope == GLOBAL_SCOPE) { gAttrNum[kk] = ii; kk++; } } return; } /**************************************************************************** * Acquire a variable's pad value, if it exists. ****************************************************************************/ CDFstatus GetVarPadValue (CDFid id, long varNum, void *value) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, zVAR_, varNum, CONFIRM_, zVAR_PADVALUE_, NULL_); if (status == NO_PADVALUE_SPECIFIED) return status; else status = CDFlib (GET_, zVAR_PADVALUE_, value, NULL_); return status; } /**************************************************************************** * Acquire a variable attribute's entry data. ****************************************************************************/ void GetVarAttributeEntryData (CDFid id, long zAttrNum, long entryNum, void *entry) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, ATTR_, zAttrNum, zENTRY_, entryNum, GET_, zENTRY_DATA_, entry, NULL_); if (status < CDF_OK) QuitCDF ("30.0", status); return; } /**************************************************************************** * Acquire a variable attribute's entry info, e.g., data type, number of * elements, if it exists. ****************************************************************************/ CDFstatus GetVarAttributeEntryInfo (CDFid id, long zAttrNum, long entryNum, long *dataType, long *numElems) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, ATTR_, zAttrNum, zENTRY_, entryNum, GET_, zENTRY_DATATYPE_, dataType, zENTRY_NUMELEMS_, numElems, NULL_); return status; } /**************************************************************************** * Acquire variable attributes's numbers and names from the attribute list. ***************************************************************************/ void GetVarAttributes (CDFid id, long numAttrs, long *vAttrNum, char **attrNames) { int ii, kk; long scope, status; char name[DU_MAX_PATH_LEN+1]; kk = 0; for (ii = 0; ii < numAttrs; ii++) { status = CDFlib (SELECT_, CDF_, id, ATTR_, (long) ii, GET_, ATTR_SCOPE_, &scope, ATTR_NAME_, name, NULL_); if (status < CDF_OK) QuitCDF ("40.0", status); if (scope == VARIABLE_SCOPE) { vAttrNum[kk] = ii; strcpyX((char *)attrNames[kk], name, 0); kk++; } } return; } /************************************************************************** * Acquire certain information from a variable. **************************************************************************/ void GetVarInfo (CDFid id, long varNum, char *var_name, long *dataType, long *numElems, long *numDims, long *dimSizes, long *recVary, long *maxRec) { CDFstatus status; status = CDFlib (SELECT_, CDF_, id, zVAR_, varNum, GET_, zVAR_NAME_, var_name, zVAR_DATATYPE_, dataType, zVAR_NUMELEMS_, numElems, zVAR_NUMDIMS_, numDims, zVAR_DIMSIZES_, dimSizes, zVAR_RECVARY_, recVary, zVAR_MAXREC_, maxRec, NULL_); if (status < CDF_OK) QuitCDF ("45.0", status); return; } /************************************************************************** * Acquire the variable names and their maximum record numbers in a CDF. * The HDU number and its column where a variable will be written is also * determined. It returns the number of different record numbers. **************************************************************************/ int GetVarsRecordNumbers (CDFid id, char **varNames, long *numRecords, long *hduGroup, int *varColumn) { long numZvars, maxRec; char varName[127]; CDFstatus status; int i, k, group; int *tmp1, *tmp2; Logical found; status = CDFlib (SELECT_, CDF_, id, GET_, CDF_NUMzVARS_, &numZvars, NULL_); if (status < CDF_OK) QuitCDF ("45.2", status); if (numRecords == NULL) numRecords = malloc (sizeof(long) * numZvars); if (varNames == NULL) varNames = malloc (sizeof(char *) * numZvars); for (i = 0; i < numZvars; i++) { status = CDFlib (SELECT_, CDF_, id, zVAR_, (long) i, GET_, zVAR_MAXREC_, &maxRec, zVAR_NAME_, varName, NULL_); if (status < CDF_OK) QuitCDF ("45.5", status); varNames[i] = (char *) strdup(varName); numRecords[i] = maxRec + 1; } tmp1 = malloc(sizeof(int) * numZvars * 2); tmp2 = malloc(sizeof(int) * numZvars); tmp1[0] = numRecords[0]; /* rec num */ tmp1[1] = 1; /* HDU # */ tmp2[0] = 1; /* coulum # in a HDU */ varColumn[0] = 1; group = 1; hduGroup[0] = 1; for (i = 1; i < numZvars; i++) { found = FALSE; for (k = 0; k < group; k++) { if (numRecords[i] == tmp1[2*k]) { found = TRUE; hduGroup[i] = tmp1[2*k+1]; tmp2[k] = tmp2[k] + 1; varColumn[i] = tmp2[k]; break; } } if (!found) { tmp1[2*group] = numRecords[i]; tmp1[2*group+1] = group + 1; hduGroup[i] = group + 1; varColumn[i] = 1; tmp2[group] = 1; group++; } } free (tmp1); free (tmp2); return group; } /**************************************************************************** * Read variable record values. ****************************************************************************/ void GetVarRecordData(CDFid id, long varNum, long startRec, long numRec, long numDims, long *dimSizes, void *outData) { int jk; CDFstatus status; long dimIndices[CDF_MAX_DIMS], dimIntervals[CDF_MAX_DIMS]; if (numDims > 0) { for (jk = 0; jk < numDims; jk++) { dimIndices[jk] = 0L; dimIntervals[jk] = 1L; } } else { dimIndices[0] = 0L; dimSizes[0] = 1L; dimIntervals[0] = 1L; } /**************************************************************************** * Acquire record values. ****************************************************************************/ status = CDFlib (SELECT_, CDF_, id, zVAR_, varNum, zVAR_RECNUMBER_, startRec, zVAR_RECCOUNT_, numRec, zVAR_RECINTERVAL_, 1L, zVAR_DIMINDICES_, dimIndices, zVAR_DIMCOUNTS_, dimSizes, zVAR_DIMINTERVALS_, dimIntervals, GET_, zVAR_HYPERDATA_, outData, NULL_); if (status < CDF_OK) QuitCDF("50.0", status); return; } cdf-to-fits/cdflib.h0000674000077000007660000026534710053160762014641 0ustar davidhcdf00000000000000/****************************************************************************** * * NSSDC/CDF Header file for CDF library. * * Version 3.7e, 18-Nov-97, Hughes STX. * * Modification history: * * V1.0 22-Jan-91, R Kulkarni Original version (for CDF V2.0). * J Love * * V2.0 3-Jun-91, J Love Renamed (was cdf_internal.h). Modified for * CDF V2.1, namely the moving of constant macros * to "cdf.h" for the INTERNAL interface and the * single/multi-file option. Renamed some symbols * for clarity. * V2.1 24-Jun-91, J Love Fixed for SGi port. * V2.2 8-Aug-91, J Love Added 'Eof' (feof). Added some miscellaneous * macro definitions. Renamed (was cdflib.h). * Added support for Cray/UNICOS. Added 'Exit' * and 'ExitBAD'. Added VIO_FOR_STREAM. * Functions in VIO were renamed to avoid * collisions on SGi/IRIX. * V3.0 21-Apr-92, J Love IBM PC & HP-UX port. CDF V2.2. * V3.1 21-Sep-92, J Love CDF V2.3 (shareable/NeXT/zVar). * V3.2 24-Jan-94, J Love CDF V2.4. * V3.2a 8-Feb-94, J Love DEC Alpha/OpenVMS port. * V3.3 15-Dec-94, J Love CDF V2.5. * V3.4 9-Jan-95, J Love Encode/decode changes. More cache-residency. * V3.5 19-Jan-95, J Love IRIX 6.0 (64-bit). * V3.5a 15-Mar-95, J Love Solaris 2.3 IDL i/f. Fixed `recNum' argument * of `LastAllocatedRecord'. * V3.6 28-Mar-95, J Love POSIX. * V3.6a 18-Apr-95, J Love More POSIX. * V3.6b 8-May-95, J Love Virtual memory under Microsoft C 7.00. * V3.6c 13-Jun-95, J Love Linux. * V3.6d 7-Sep-95, J Love Moved `ASSIGNnotNULL' to `cdfdist.h'. * CDFexport-related changes. More virtual * memory (Microsoft C 7.00). * V3.7 5-Sep-96, J Love CDF V2.6. * V3.7a 20-Nov-96, J Love Removed definitions of BIG/LITTLE_ENDIAN which * were no longer used and caused a redefinition * on Linux systems. * V3.7b 21-Feb-97, J Love Removed RICE. * V3.7c 8-Mar-97, J Love Windows NT for MS Visual C/C++ on an IBM PC. * V3.7d 2-Sep-97, J Love Made magic number variables `uInt32'. * V3.7e 18-Nov-97, J Love More Windows NT. * V3.7f 25-May-98, M Liu Add 3 new fields in VarStruct data structure * Add one more parameter in HyperReadDim and * HyperWriteDim proto function. * V3.8 04-May-01, M Liu Add Cygwin port. * ******************************************************************************/ #if !defined(CDFLIBh_INCLUDEd__) # define CDFLIBh_INCLUDEd__ /***************************************************************************** * Include files. *****************************************************************************/ #if !defined(FORJNI) /* It is defined to compiler as -D "FORJNI" */ # define LIBCDF_SOURCE_ #endif #include "cdfdist.h" /***************************************************************************** * V1.x magic number. * This is what a V1 magic number looks like when the bytes are flipped. * The bytes will be flipped on a VAX because the longword was assumed to be * in network order and then flipped to VAX order. The bytes will be flipped * on a Sun, SGi, NeXT, HP, IBM RS, etc. because the longword was assumed to * already be in network order (the same as those machines) but the byte order * in memory is reversed from that of a VAX (where all V1 CDFs were created). *****************************************************************************/ #define V1magicNUMBER_flip 0x0F000000 /***************************************************************************** * V2.x magic numbers. *****************************************************************************/ #define V2magicNUMBER_1pre 0x0000FFFF /* Written at offset 0x00000000 of pre-V2.6 CDFs. */ #define V2magicNUMBER_1 0xCDF26002 /* Written at offset 0x00000000 of V2.6 CDFs. */ #define V2magicNUMBER_2u 0x0000FFFF /* Written at offset 0x00000004 of uncompressed V2.6 CDFs (as well as all pre-V2.6 CDFs). */ #define V2magicNUMBER_2c 0xCCCC0001 /* Written at offset 0x00000004 of compressed V2.6 CDFs. */ #define VALIDid_MAGIC_NUMBER 0x12345678 /* Placed in `CDF' structure (CDFid). Used to check that a valid CDF has been selected by an application. */ #define KILLEDid_MAGIC_NUMBER 0x24682468 /* Placed in `CDF' structure (CDFid) before freeing the structure. This is done in case an application tries to select the CDF again (which might cause some sort of memory violation anyway). */ #define ABORTEDid_MAGIC_NUMBER 0x13571357 /* Placed in `CDF' structure (CDFid) when access to that CDF has been aborted. */ /***************************************************************************** * Virtual memory (Microsoft C 7.00). *****************************************************************************/ #if defined(MICROSOFTC_700) && INCLUDEvMEMORY typedef _vmhnd_t MemHandle; # if defined(CDFLIB) Logical useVmem = DEFAULT_USEvMEM; long vMemSize = DEFAULT_vMEMSIZE; uInt vMemMask = DEFAULT_vMEMMASK; # else extern Logical useVmem; extern long vMemSize; extern uInt vMemMask; # endif #endif /***************************************************************************** * Miscellaneous constants. *****************************************************************************/ #define INT32_ZERO ((Int32) 0) #define INT32_ONE ((Int32) 1) #define NO_BLOCK (-1) #define NO_OFFSET 0xFFFFFFFF #define ZERO_OFFSET 0x00000000 #define ALLrecordsATonce 1 #define ONErecordATaTIME 2 #define ONEvalueATaTIME 3 #define EXT_LEN 3 /* Length of file extensions that are created by the CDF library. This is limited by the 8.3 convention of MS-DOS. */ #define MAX_TMP 99999 #define READ_ONLY 1 #define READ_WRITE 2 #define NUMcacheUNKNOWN 4 /* The number of cache buffers to use for the "working" dotCDF file when the CDF's format is unknown. This is set large enough to prevent any paging while reading the CDF's format (among other things). */ /***************************************************************************** * Variable types. *****************************************************************************/ #define STANDARD_ 1 #define SPARSE_RECORDS_ 2 #define COMPRESSED_ 3 #define SPARSE_COMPRESSED_RECORDS_ 4 #define SPARSE_ARRAYS_ 5 #define SPARSE_RECORDS_AND_ARRAYS_ 6 #define IN_MULTI_ 7 #define SPARSErecords(Var) \ (Var->vType == SPARSE_RECORDS_ || \ Var->vType == SPARSE_COMPRESSED_RECORDS_ || \ Var->vType == SPARSE_RECORDS_AND_ARRAYS_) #define SPARSEarrays(Var) \ (Var->vType == SPARSE_ARRAYS_ || Var->vType == SPARSE_RECORDS_AND_ARRAYS_) #define COMPRESSED(Var) \ (Var->vType == COMPRESSED_ || Var->vType == SPARSE_COMPRESSED_RECORDS_) /***************************************************************************** * Reserved values. *****************************************************************************/ #define RESERVED_ATTROFFSET (-1) /* Indicates that an attribute hasn't been selected yet. */ #define RESERVED_ENTRYNUM (-1L) /* Indicates that a g/r/zEntry number hasn't been selected yet. */ #define RESERVED_ENTRYOFFSET (-1) /* Indicates that the current g/r/zEntry does not exist.*/ #define RESERVED_VARNUM (-1L) /* Indicates that a variable hasn't been selected yet. */ /****************************************************************************** * NETWORKbyteORDERcpu. * network (big-endian)..........Sun, SGi, IBM-RS, HP, NeXT, Macintosh, * PowerPC * non-network (little-endian)...VAX (VMS, POSIX Shell), DECstation, * IBM-PC (MS-DOS and Linux), * DEC Alpha (OSF/1, OpenVMS, POSIX Shell), ******************************************************************************/ #if defined(sun)||defined(MIPSEB)||defined(IBMRS)||defined(HP)||defined(NeXT)||defined(mac)||defined(PPC)||defined(macosX) # define NETWORKbyteORDERcpu #endif /****************************************************************************** * XDRishENCODINGcpu. * xdr...........Sun, SGi, IBM-RS, HP, NeXT, Macintosh, PowerPC * non-xdr.......VAX (VMS, POSIX Shell), DECstation, IBM-PC (MS-DOS and * Linux), DEC Alpha (OSF/1, OpenVMS, POSIX Shell). ******************************************************************************/ #if defined(sun)||defined(MIPSEB)||defined(IBMRS)||defined(HP)||defined(NeXT)||defined(mac)||defined(PPC)||defined(macosX) # define XDRishENCODINGcpu #endif /****************************************************************************** * Constants for `seeking'. ******************************************************************************/ #define vSEEK_SET 0 #define vSEEK_CUR 1 #define vSEEK_END 2 /***************************************************************************** * CDF V2.0+ constants. *****************************************************************************/ #define FIRST_IR_OFFSET ((Int32) 0x00000008) #define V2_MAGIC_OFFSET_1 ((Int32) 0x00000000) #define V2_MAGIC_OFFSET_2 ((Int32) 0x00000004) #define V2_CDR_OFFSET ((Int32) 0x00000008) #define V2_CCR_OFFSET ((Int32) 0x00000008) #define MAGIC_NUMBERS_SIZE 8 #define VDR_WASTED_SIZE 128 #define VARs_INCREMENT 20 #define VSTREAM_MAGIC_NUMBER 0x12345678 /* Used to verify that a VFILE structure has been passed to a function. */ #define DEFAULT_nCACHE_BUFFERs 1 /* Default number of buffers in the cache. */ #define nCACHE_BUFFER_BYTEs 512 /* Size (bytes) of each cache buffer. */ #if defined(vms) # define VMS_DEFAULT_nALLOCATION_BLOCKS 3 /* Allocate only 3 blocks at a time (override VMS default of 128 for fixed record length file [or 200 when file FTPed to VMS]). */ #endif #define vMAX_TRYs 5 /* Maximum number of trys on a read or write operation. */ #define MAX_EPOCH_BINARY 3.15569519999999e14 #define CTIME_STRING_LEN 25 #define MAX_VXR_ENTRIES 10 /* Maximum from this and previous CDF releases. */ #define NUM_VXR_ENTRIES 7 /* For VXRs whose entries point to VVR/CVVRs. */ #define NUM_VXRx_ENTRIES 3 /* For VXRs whose entries point to other VXRs. */ /***************************************************************************** * CDF versions/releases/increments. *****************************************************************************/ #define VERSION_1 1 #define VERSION_2 2 #define RELEASE_0 0 #define RELEASE_1 1 #define RELEASE_2 2 #define RELEASE_3 3 #define RELEASE_4 4 #define RELEASE_5 5 #define RELEASE_6 6 #define INCREMENT_1 1 /***************************************************************************** * File types. *****************************************************************************/ #define CDFt 1 #define Vt 3 #define Zt 4 /***************************************************************************** * AbortAccess macros. *****************************************************************************/ #define UPDATE TRUE #define noUPDATE FALSE #define DELETE TRUE #define noDELETE FALSE /***************************************************************************** * Compression. *****************************************************************************/ #define EMPTY TRUE #define notEMPTY FALSE /***************************************************************************** * Macros for FORTRAN interface(s). *****************************************************************************/ #if defined(vms) || defined(MPW_C) # define Fif_DESCR #endif #if (defined(unix) && !defined(Mach))||defined(SALFORDC)||defined(posixSHELL)\ ||defined(_MSC_VER) # define Fif_GHOSTLEN #endif #if (defined(dos) && !defined(SALFORDC)) || defined(Mach) # define Fif_NOLEN #endif #if defined(unix) && !defined(AIX) && !defined(Mach) && !defined(hpux) # if (defined(linux) || defined(__CYGWIN__)) # define Fif_ENTRYPOINT(ep__,ep_,ep,EP) ep__ # else # define Fif_ENTRYPOINT(ep__,ep_,ep,EP) ep_ # endif #else # if defined(SALFORDC) # define Fif_ENTRYPOINT(ep__,ep_,ep,EP) EP # else # define Fif_ENTRYPOINT(ep__,ep_,ep,EP) ep # endif #endif #if defined(Fif_GHOSTLEN) # if defined(SALFORDC) typedef int *Fif_GHOSTTYPE; # define Fif_GHOSTFETCH(ap) *(va_arg(ap,int *)) # define Fif_GHOSTUSE(l) *l # else typedef int Fif_GHOSTTYPE; # define Fif_GHOSTFETCH(ap) va_arg(ap,int) # define Fif_GHOSTUSE(l) l # endif # define Fif_GHOSTARG(v) ,v # define Fif_GHOSTDEF(v) Fif_GHOSTTYPE v; #else # define Fif_GHOSTARG(v) \ # define Fif_GHOSTDEF(v) \ #endif #if defined(MPW_C) # define Fif_PREFIXa pascal #else # define Fif_PREFIXa \ #endif #if defined(MICROSOFTC) # if defined(MICROSOFTC_600) # define Fif_PREFIXb _cdecl # endif # if defined(MICROSOFTC_700) # define Fif_PREFIXb __cdecl # endif #else # define Fif_PREFIXb \ #endif /****************************************************************************** * Integer orders. ******************************************************************************/ #define LITTLEendianORDER 1 #define BIGendianORDER 2 /****************************************************************************** * Assumed attribute scopes. ******************************************************************************/ #define GLOBALscopeASSUMED 3L #define VARIABLEscopeASSUMED 4L /****************************************************************************** * Floating-point types. ******************************************************************************/ #define FP_1 1 #define FP_2 2 #define FP_3 3 #define FP_4 4 /****************************************************************************** * Floating-point structures. ******************************************************************************/ #if defined(FP1cpu) struct fp1struct4 { uInt s : 1, e1 : 7, e0 : 1, m2 : 7, m1 : 8, m0 : 8; }; struct fp2struct4 { uInt m0 : 8, m1 : 8, e0 : 1, m2 : 7, s : 1, e1 : 7; }; struct fp34struct4 { uInt e0 : 1, m2 : 7, s : 1, e1 : 7, m0 : 8, m1 : 8; }; struct fp1struct8 { uInt s : 1, e1 : 7, e0 : 4, m6 : 4, m5 : 8, m4 : 8, m3 : 8, m2 : 8, m1 : 8, m0 : 8; }; struct fp2struct8 { uInt m0 : 8, m1 : 8, m2 : 8, m3 : 8, m4 : 8, m5 : 8, e0 : 4, m6 : 4, s : 1, e1 : 7; }; struct fp3struct8 { uInt e0 : 1, m6 : 7, s : 1, e1 : 7, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; struct fp4struct8 { uInt e0 : 4, m6 : 4, s : 1, e1 : 7, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; #endif #if defined(FP2cpu) struct fp1struct4 { uInt e1 : 7, s : 1, m2 : 7, e0 : 1, m1 : 8, m0 : 8; }; struct fp2struct4 { uInt m0 : 8, m1 : 8, m2 : 7, e0 : 1, e1 : 7, s : 1; }; struct fp34struct4 { uInt m2 : 7, e0 : 1, e1 : 7, s : 1, m0 : 8, m1 : 8; }; struct fp1struct8 { uInt e1 : 7, s : 1, m6 : 4, e0 : 4, m5 : 8, m4 : 8, m3 : 8, m2 : 8, m1 : 8, m0 : 8; }; struct fp2struct8 { uInt m0 : 8, m1 : 8, m2 : 8, m3 : 8, m4 : 8, m5 : 8, m6 : 4, e0 : 4, e1 : 7, s : 1; }; struct fp3struct8 { uInt m6 : 7, e0 : 1, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; struct fp4struct8 { uInt m6 : 4, e0 : 4, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; #endif #if defined(FP3cpu) struct fp1struct4 { uInt e1 : 7, s : 1, m2 : 7, e0 : 1, m1 : 8, m0 : 8; }; struct fp2struct4 { uInt m0 : 8, m1 : 8, m2 : 7, e0 : 1, e1 : 7, s : 1; }; struct fp34struct4 { uInt m2 : 7, e0 : 1, e1 : 7, s : 1, m0 : 8, m1 : 8; }; struct fp1struct8 { uInt e1 : 7, s : 1, m6 : 4, e0 : 4, m5 : 8, m4 : 8, m3 : 8, m2 : 8, m1 : 8, m0 : 8; }; struct fp2struct8 { uInt m0 : 8, m1 : 8, m2 : 8, m3 : 8, m4 : 8, m5 : 8, m6 : 4, e0 : 4, e1 : 7, s : 1; }; struct fp3struct8 { uInt m6 : 7, e0 : 1, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; struct fp4struct8 { uInt m6 : 4, e0 : 4, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; #endif #if defined(FP4cpu) struct fp1struct4 { uInt e1 : 7, s : 1, m2 : 7, e0 : 1, m1 : 8, m0 : 8; }; struct fp2struct4 { uInt m0 : 8, m1 : 8, m2 : 7, e0 : 1, e1 : 7, s : 1; }; struct fp34struct4 { uInt m2 : 7, e0 : 1, e1 : 7, s : 1, m0 : 8, m1 : 8; }; struct fp1struct8 { uInt e1 : 7, s : 1, m6 : 4, e0 : 4, m5 : 8, m4 : 8, m3 : 8, m2 : 8, m1 : 8, m0 : 8; }; struct fp2struct8 { uInt m0 : 8, m1 : 8, m2 : 8, m3 : 8, m4 : 8, m5 : 8, m6 : 4, e0 : 4, e1 : 7, s : 1; }; struct fp3struct8 { uInt m6 : 7, e0 : 1, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; struct fp4struct8 { uInt m6 : 4, e0 : 4, e1 : 7, s : 1, m4 : 8, m5 : 8, m2 : 8, m3 : 8, m0 : 8, m1 : 8; }; #endif /****************************************************************************** * REVERSE2b. ******************************************************************************/ #define REVERSE2b(buf) { \ Byte *_buf_ = (Byte *) (buf), _temp_; \ _temp_ = _buf_[0]; \ _buf_[0] = _buf_[1]; \ _buf_[1] = _temp_; \ } /****************************************************************************** * REVERSE4b. ******************************************************************************/ #define REVERSE4b(buf) { \ Byte *_buf_ = (Byte *) (buf), _temp_; \ _temp_ = _buf_[0]; \ _buf_[0] = _buf_[3]; \ _buf_[3] = _temp_; \ _temp_ = _buf_[1]; \ _buf_[1] = _buf_[2]; \ _buf_[2] = _temp_; \ } /****************************************************************************** * REVERSE8b. ******************************************************************************/ #define REVERSE8b(buf) { \ Byte *_buf_ = (Byte *) (buf), _temp_; \ _temp_ = _buf_[0]; \ _buf_[0] = _buf_[7]; \ _buf_[7] = _temp_; \ _temp_ = _buf_[1]; \ _buf_[1] = _buf_[6]; \ _buf_[6] = _temp_; \ _temp_ = _buf_[2]; \ _buf_[2] = _buf_[5]; \ _buf_[5] = _temp_; \ _temp_ = _buf_[3]; \ _buf_[3] = _buf_[4]; \ _buf_[4] = _temp_; \ } /****************************************************************************** * REVERSE2bIO. ******************************************************************************/ #define REVERSE2bIO(iPtr,oPtr) \ ((Byte *) (oPtr))[0] = ((Byte *) (iPtr))[1]; \ ((Byte *) (oPtr))[1] = ((Byte *) (iPtr))[0]; /****************************************************************************** * REVERSE4bIO. ******************************************************************************/ #define REVERSE4bIO(iPtr,oPtr) \ ((Byte *) (oPtr))[0] = ((Byte *) (iPtr))[3]; \ ((Byte *) (oPtr))[1] = ((Byte *) (iPtr))[2]; \ ((Byte *) (oPtr))[2] = ((Byte *) (iPtr))[1]; \ ((Byte *) (oPtr))[3] = ((Byte *) (iPtr))[0]; /****************************************************************************** * REVERSE8bIO. ******************************************************************************/ #define REVERSE8bIO(iPtr,oPtr) \ ((Byte *) (oPtr))[0] = ((Byte *) (iPtr))[7]; \ ((Byte *) (oPtr))[1] = ((Byte *) (iPtr))[6]; \ ((Byte *) (oPtr))[2] = ((Byte *) (iPtr))[5]; \ ((Byte *) (oPtr))[3] = ((Byte *) (iPtr))[4]; \ ((Byte *) (oPtr))[4] = ((Byte *) (iPtr))[3]; \ ((Byte *) (oPtr))[5] = ((Byte *) (iPtr))[2]; \ ((Byte *) (oPtr))[6] = ((Byte *) (iPtr))[1]; \ ((Byte *) (oPtr))[7] = ((Byte *) (iPtr))[0]; /****************************************************************************** * LoadCVVRx/LoadVVRx. ******************************************************************************/ #define LoadCVVRx(cvvr,recordsize,csize) \ cvvr.RecordSize = (Int32) (recordsize); \ cvvr.RecordType = CVVR_; \ cvvr.rfuA = (Int32) 0; \ cvvr.cSize = (Int32) (csize); #define LoadVVRx(vvr,recordsize) \ vvr.RecordSize = (Int32) (recordsize); \ vvr.RecordType = VVR_; /****************************************************************************** * LoadAllocCVVR/LoadAllocVVR. ******************************************************************************/ #define LoadAllocCVVR(alloc,firstrec,lastrec,csize,xsize) \ alloc.first = (Int32) (firstrec); \ alloc.last = (Int32) (lastrec); \ alloc.type = (int) CVVR_; \ alloc.cvvr.cSize = (Int32) (csize); \ alloc.cvvr.xSize = (Int32) (xsize); #define LoadAllocVVR(alloc,firstrec,lastrec,newvvr) \ alloc.first = (Int32) (firstrec); \ alloc.last = (Int32) (lastrec); \ alloc.type = (int) VVR_; \ alloc.vvr.new = (Logical) (newvvr); /****************************************************************************** * GLOBALscope/VARIABLEscope/DEFINITEscope. ******************************************************************************/ #define GLOBALscope(scope) \ (scope == GLOBAL_SCOPE || scope == GLOBALscopeASSUMED) #define VARIABLEscope(scope) \ (scope == VARIABLE_SCOPE || scope == VARIABLEscopeASSUMED) #define DEFINITEscope(scope) \ (BOO(scope == GLOBALscopeASSUMED, \ GLOBAL_SCOPE,BOO(scope == VARIABLEscopeASSUMED,VARIABLE_SCOPE,scope))) /****************************************************************************** * FLOAT8dataType. * Macro to check for a double-precision floating-point data type. ******************************************************************************/ #define FLOAT8dataType(dataType) \ (dataType == CDF_REAL8 || dataType == CDF_DOUBLE || dataType == CDF_EPOCH) /****************************************************************************** * Operating system dependent definitions. ******************************************************************************/ #if defined(vms) || defined(dos) || defined(mac) || defined(win32) || \ defined(__CYGWIN__) # define READ_ONLY_a_mode "rb" # define READ_PLUS_a_mode "r+b" # define WRITE_PLUS_a_mode "w+b" #else # define READ_ONLY_a_mode "r" # define READ_PLUS_a_mode "r+" # define WRITE_PLUS_a_mode "w+" #endif /****************************************************************************** * Miscellaneous macros. ******************************************************************************/ #define SEEKv(fp,offset,origin) (V_seek(fp,offset,origin) == 0) #define READv(buffer,size,number,fp) (V_read(buffer,size,number,fp) == number) #define WRITEv(buffer,size,number,fp) (V_write(buffer,size,number,fp)==number) #define CACHEv(fp,nBuffers) (V_setcache(fp,nBuffers) == 0) #define CLEARv(fp) (V_clear(fp) == 0) #define DELETEv(fp,vStats) (V_delete(fp,vStats) == 0) #define CLOSEv(fp,vStats) (V_close(fp,vStats) == 0) #define FLUSHv(fp) (V_flush(fp) == 0) #define MEMMOVE(dst,src,nBytes) if (dst != src) memmove (dst, src, nBytes); #define DECODE(function,buffer,numElems) \ BOO(function == NULL,CDF_OK,function(buffer,numElems)) /****************************************************************************** * CURRENTattrSELECTED. ******************************************************************************/ #define CURRENTattrSELECTED(CDF) (CDF->CURattrOffset != RESERVED_ATTROFFSET) /****************************************************************************** * CURRENTvarSELECTED. ******************************************************************************/ #define CURRENTvarSELECTED(CDF,zOp) \ BOO(zModeON(CDF), \ CDF->CURzVarNum != RESERVED_VARNUM, \ BOO(zOp,CDF->CURzVarNum,CDF->CURrVarNum) != RESERVED_VARNUM) /****************************************************************************** * BADzOP. * Check if an operation is legal while in zMode. ******************************************************************************/ #define BADzOP(CDF,rVar) (zModeON(CDF) && rVar) /****************************************************************************** * EXISTSisBAD. ******************************************************************************/ #define EXISTSisBAD(alloc) BOO((alloc)->type == VVR_,(alloc)->vvr.new,TRUE) /****************************************************************************** * Allocation structures. ******************************************************************************/ struct AllocStruct { Int32 first; /* First record to allocate. */ Int32 last; /* Last record to allocate. */ int type; /* Type of record(s): VVR_ or CVVR_. */ struct { Logical new; /* TRUE: Don't append to an existing VVR (even if possible). CDF_INTERNAL_ERROR if any of the records already exist. */ } vvr; struct { Int32 cSize; /* Size of CVVR compressed data. */ Int32 xSize; /* Size of CVVR extra space. */ } cvvr; }; /****************************************************************************** * vFILE/vCACHE structures. ******************************************************************************/ typedef struct vCACHEstruct { long blockN; /* File block number in this cache buffer. */ struct vCACHEstruct *next; /* Index of next cache buffer (on linked list). */ struct vCACHEstruct *prev; /* Index of previous cache buffer (on linked list). */ Logical modified; /* TRUE if this file block has been modified. */ void *ptr; /* Pointer to cache buffer or virtual memory handle (if Microsoft C 7.00). */ } vCACHE; typedef struct vFILEstruct { uInt32 magic_number; /* Magic number for VFILE structure. */ FILE *fp; /* File pointer. Initially set to NULL if a scratch file (because the scratch file hasn't been created yet). If not a scratch file, set to the file pointer of the created/opened file. */ char *path; /* If a scratch file, initially set to the scratch directory or a NUL-string if the current directory is to be used. This is set to the pathname of the file if this is not a scratch file or if a scratch file for which the file has been created (because a block had to be paged out). */ char scratchExt[EXT_LEN+1]; /* Extension for this scratch file. */ Logical scratch; /* Set TRUE if a scratch file. */ Logical error; /* TRUE if the error indicator is set. No further access to the file is allowed. */ Logical eof; /* TRUE if the EOF indicator is set (after a read is attempted at the EOF). */ vCACHE *cacheHead; /* Head of linked list of cache structures. */ vCACHE *cacheTail; /* Tail of linked list of cache structures. */ int maxBuffers; /* Maximum number of cache buffers to be used. */ int nBuffers; /* Actual number of cache buffers being used. */ long nV_reads; /* Number of calls to `V_read'. */ long nV_writes; /* Number of calls to `V_write'. */ long nBlockReads; /* Number of file blocks which have been read. */ long nBlockWrites; /* Number of file blocks which have been written. */ long nPageIns; /* Number of blocks paged in from the file. */ long nPageOuts; /* Number of blocks paged out to the file. */ long length; /* Length in bytes of the file. This includes what is in the cache but not necessarily what is physically in the file yet). */ long phyLength; /* Physical length of the file in bytes (ignoring what might be in the cache). */ long offset; /* Read/write position (byte offset) in file. */ } vFILE; /****************************************************************************** * CDR flag bit positions (bit 0 is Least Significant Bit). ******************************************************************************/ #define CDR_MAJORITY_BIT 0 /* majority: set = row major, clear = column major */ #define CDR_FORMAT_BIT 1 /* format: set = single file, clear = multi file */ /****************************************************************************** * VDR flag bit positions (bit 0 is Least Significant Bit). These apply to * both rVDRs and zVDRs. Note that the compression and sparse arrays bits * cannot both be set. ******************************************************************************/ #define VDR_RECVARY_BIT 0 /* Record variance... set = VARY, clear = NOVARY. */ #define VDR_PADVALUE_BIT 1 /* Pad value... set = specified, clear = not specified. */ #define VDR_COMPRESSION_BIT 2 /* Variable compression... set = compressed, CPR offset in CPRorSPRoffset field. clear = uncompressed. */ #define VDR_SPARSEARRAYS_BIT 3 /* Sparse arrays... set = sparse, SPR offset in CPRorSPRoffset field. clear = unsparse. */ /****************************************************************************** * Internal record types. ******************************************************************************/ #define UIR_ ((Int32) (-1)) /* Unused Internal Record. */ #define CDR_ ((Int32) 1) /* CDF Descriptor Record. */ #define GDR_ ((Int32) 2) /* Global Descriptor Record. */ #define rVDR_ ((Int32) 3) /* rVariable Descriptor Record. */ #define ADR_ ((Int32) 4) /* Attribute Descriptor Record. */ #define AgrEDR_ ((Int32) 5) /* Attribute g/rEntry Descriptor Record. */ #define VXR_ ((Int32) 6) /* Variable indeX Record. */ #define VVR_ ((Int32) 7) /* Variable Values Record. */ #define zVDR_ ((Int32) 8) /* zVariable Descriptor Record. */ #define AzEDR_ ((Int32) 9) /* Attribute zEntry Descriptor Record. */ #define CCR_ ((Int32) 10) /* Compressed CDF Record. */ #define CPR_ ((Int32) 11) /* Compression Parameters Record. */ #define SPR_ ((Int32) 12) /* Sparseness Parameters Record. */ #define CVVR_ ((Int32) 13) /* Compressed Variable Values Record. */ /****************************************************************************** * Base record sizes (bytes). ******************************************************************************/ #define UUIR_BASE_SIZE 8 #define UIR_BASE_SIZE 16 #define CDR_BASE_SIZE 48 #define GDR_BASE_SIZE 60 #define zVDR_BASE_SIZE (68 + CDF_VAR_NAME_LEN) #define rVDR_BASE_SIZE (64 + CDF_VAR_NAME_LEN) #define VXR_BASE_SIZE (20 + (12 * NUM_VXR_ENTRIES)) #define VXRx_BASE_SIZE (20 + (12 * NUM_VXRx_ENTRIES)) #define VVR_BASE_SIZE 8 #define ADR_BASE_SIZE (52 + CDF_ATTR_NAME_LEN) #define AEDR_BASE_SIZE 48 #define CCR_BASE_SIZE 20 #define CPR_BASE_SIZE 20 #define SPR_BASE_SIZE 20 #define CVVR_BASE_SIZE 16 /****************************************************************************** * CCR structure/fields/offsets - Compressed CDF Record. ******************************************************************************/ struct CCRstruct { Int32 RecordSize; /* Size of record (bytes) */ Int32 RecordType; /* Type of record (ie. CCR) */ Int32 CPRoffset; /* File offset to CPR (bytes). */ Int32 uSize; /* Size of uncompressed CDF's IRs (bytes). This byte count does NOT include the magic numbers. */ Int32 rfuA; /* Reserved for future use. Set to zero. */ }; #define CCR_NULL (-1) #define CCR_RECORD 0 #define CCR_RECORDSIZE 1 #define CCR_RECORDTYPE 2 #define CCR_CPROFFSET 3 #define CCR_USIZE 4 #define CCR_RFUa 5 #define CCR_RECORDSIZE_OFFSET 0 #define CCR_RECORDTYPE_OFFSET 4 #define CCR_CPROFFSET_OFFSET 8 #define CCR_USIZE_OFFSET 12 #define CCR_RFUa_OFFSET 16 /****************************************************************************** * CDR structure/fields/offsets - CDF Descriptor Record. ******************************************************************************/ struct CDRstruct { Int32 RecordSize; /* Size of record (bytes) */ Int32 RecordType; /* Type of record (ie. CDR) */ Int32 GDRoffset; /* File offset to GDR (bytes) */ Int32 Version; /* CDF Version Number */ Int32 Release; /* CDF Release Number */ Int32 Encoding; /* Encoding of CDF File */ Int32 Flags; /* Flags (see bit definitions). */ Int32 rfuA; /* reserved for future use (value = 0) */ Int32 rfuB; /* reserved for future use (value = 0) */ Int32 Increment; /* CDF Increment Number (Vversion.release.increment), always 0 for V2.0 CDFs */ Int32 rfuD; /* reserved for future use (value = -1) */ Int32 rfuE; /* reserved for future use (value = -1) */ }; #define CDR_NULL (-1) #define CDR_RECORD 0 #define CDR_RECORDSIZE 1 #define CDR_RECORDTYPE 2 #define CDR_GDROFFSET 3 #define CDR_VERSION 4 #define CDR_RELEASE 5 #define CDR_ENCODING 6 #define CDR_FLAGS 7 #define CDR_INCREMENT 8 #define CDR_COPYRIGHT 9 #define CDR_RECORDSIZE_OFFSET 0 #define CDR_RECORDTYPE_OFFSET 4 #define CDR_GDROFFSET_OFFSET 8 #define CDR_VERSION_OFFSET 12 #define CDR_RELEASE_OFFSET 16 #define CDR_ENCODING_OFFSET 20 #define CDR_FLAGS_OFFSET 24 #define CDR_RFUa_OFFSET 28 #define CDR_RFUb_OFFSET 32 #define CDR_INCREMENT_OFFSET 36 #define CDR_RFUd_OFFSET 40 #define CDR_RFUe_OFFSET 44 #define CDR_COPYRIGHT_OFFSET 48 /****************************************************************************** * GDR structure/fields/offsets - Global Descriptor Record. * * Note(s): * The Eof field was not maintained for V2.0 CDFs (it will contain a random * value). When a V2.0 CDF is modified, the end-of-file will be determined and * this field will be updated. * Even though CDF_MAX_DIMS elements are allocated for the `rDimSizes' * array, only those sizes which actually exist are written to the CDF file. * ******************************************************************************/ struct GDRstruct { Int32 RecordSize; /* Size of current record (bytes) */ Int32 RecordType; /* Type of record (ie. GDR) */ Int32 rVDRhead; /* File offset to first rVDR (bytes) */ Int32 zVDRhead; /* CDF V2.0, value is undefined (random). CDF V2.1, value = 0. CDF V2.2, File offset to first zVDR (bytes). */ Int32 ADRhead; /* File offset to first ADR (bytes) */ Int32 eof; /* If V2.0 CDF, value is undefined. If V2.1+ CDF, end-of-file (byte offset). */ Int32 NrVars; /* Number of rVariables */ Int32 NumAttr; /* Number of Attributes */ Int32 rMaxRec; /* Maximum rVariable record number written to. */ Int32 rNumDims; /* Number of CDF dimensions (for rVariables). */ Int32 NzVars; /* Number of zVariables. */ Int32 UIRhead; /* File offset to first UIR (bytes). */ Int32 rfuC; /* reserved for future use (value = 0) */ Int32 rfuD; /* reserved for future use (value = -1) */ Int32 rfuE; /* reserved for future use (value = -1) */ Int32 rDimSizes[CDF_MAX_DIMS]; /* Size of each dimension (for rVariables). */ }; #define GDR_NULL (-1) #define GDR_RECORD 0 #define GDR_RECORDSIZE 1 #define GDR_RECORDTYPE 2 #define GDR_rVDRHEAD 3 #define GDR_zVDRHEAD 4 #define GDR_ADRHEAD 5 #define GDR_EOF 6 #define GDR_NrVARS 7 #define GDR_NUMATTR 8 #define GDR_rMAXREC 9 #define GDR_rNUMDIMS 10 #define GDR_NzVARS 11 #define GDR_UIRHEAD 12 #define GDR_rDIMSIZES 13 #define GDR_RECORDSIZE_OFFSET 0 #define GDR_RECORDTYPE_OFFSET 4 #define GDR_rVDRHEAD_OFFSET 8 #define GDR_zVDRHEAD_OFFSET 12 #define GDR_ADRHEAD_OFFSET 16 #define GDR_EOF_OFFSET 20 #define GDR_NrVARS_OFFSET 24 #define GDR_NUMATTR_OFFSET 28 #define GDR_rMAXREC_OFFSET 32 #define GDR_rNUMDIMS_OFFSET 36 #define GDR_NzVARS_OFFSET 40 #define GDR_UIRHEAD_OFFSET 44 #define GDR_RFUc_OFFSET 48 #define GDR_RFUd_OFFSET 52 #define GDR_RFUe_OFFSET 56 #define GDR_rDIMSIZES_OFFSET 60 /****************************************************************************** * rVDR/zVDR structure/fields/offsets - r/zVariable Descriptor Record. ******************************************************************************/ struct VDRstruct { Int32 RecordSize; /* Size of current record (bytes) */ Int32 RecordType; /* Type of record (eg. rVDR/zVDR) */ Int32 VDRnext; /* File offset to next rVDR/zVDR (bytes). Note in V2.0 CDFs this field was not set properly for the last variable (rVariable). */ Int32 DataType; /* Data type of variable */ Int32 MaxRec; /* Maximum record number for variable */ Int32 VXRhead; /* File offset to first VXR (bytes). Value will be 0 if MULTI_FILE format */ Int32 VXRtail; /* File offset to last VXR (bytes). Value will be 0 if MULTI_FILE format */ Int32 Flags; /* Flags (see bit definitions). */ Int32 sRecords; /* Type of sparse records. NO_SPARSERECORDS, PAD_SPARSERECORDS, or PREV_SPARSERECORDS. */ Int32 rfuB; /* reserved for future use (value = 0) */ Int32 rfuC; /* reserved for future use (value = -1) */ Int32 rfuF; /* reserved for future use (value = -1) */ Int32 NumElems; /* Number of elements of DataType (should be 1 if not CDF_CHAR or CDF_UCHAR) */ Int32 Num; /* Variable number */ Int32 CPRorSPRoffset; /* CPR/SPR offset depending on bits set in `Flags'. If neither compression nor sparse arrays, set to 0xFFFFFFFF. */ Int32 blockingFactor; /* If uncompressed/unsparse: Number of records to extend when new allocations are necessary (if 0, use default). For multi-file CDFs, extensions are always one record at a time. For NRV variables this value is n/a (only one record is ever written). If compressed/sparse: Number of (or maximum) records per block... */ char Name[CDF_VAR_NAME_LEN+1]; /* Variable name */ Int32 zNumDims; /* Number of dimensions for zVariable. N/a if an rVariable. */ Int32 zDimSizes[CDF_MAX_DIMS]; /* Dimension sizes for zVariable. N/a if an rVariable. */ Int32 DimVarys[CDF_MAX_DIMS]; /* Dimension variances. */ /* Optional... PadValue with the given DataType. */ }; #define VDR_NULL (-1) #define VDR_RECORD 0 #define VDR_RECORDSIZE 1 #define VDR_RECORDTYPE 2 #define VDR_VDRNEXT 3 #define VDR_DATATYPE 4 #define VDR_MAXREC 5 #define VDR_VXRHEAD 6 #define VDR_VXRTAIL 7 #define VDR_FLAGS 8 #define VDR_sRECORDS 9 #define VDR_NUMELEMS 10 #define VDR_NUM 11 #define VDR_CPRorSPR 12 #define VDR_BLOCKING 13 #define VDR_NAME 14 #define VDR_zNUMDIMS 15 #define VDR_zDIMSIZES 16 #define VDR_DIMVARYS 17 #define VDR_PADVALUE 18 #define VDR_RECORDSIZE_OFFSET 0 #define VDR_RECORDTYPE_OFFSET 4 #define VDR_VDRNEXT_OFFSET 8 #define VDR_DATATYPE_OFFSET 12 #define VDR_MAXREC_OFFSET 16 #define VDR_VXRHEAD_OFFSET 20 #define VDR_VXRTAIL_OFFSET 24 #define VDR_FLAGS_OFFSET 28 #define VDR_sRECORDS_OFFSET 32 #define VDR_RFUb_OFFSET 36 #define VDR_RFUc_OFFSET 40 #define VDR_RFUf_OFFSET 44 #define VDR_NUMELEMS_OFFSET 48 #define VDR_NUM_OFFSET 52 #define VDR_CPRorSPR_OFFSET 56 #define VDR_BLOCKING_OFFSET 60 #define VDR_NAME_OFFSET 64 #define rVDR_DIMVARYS_OFFSET 128 #define rVDR_PADVALUE_OFFSETb 128 /* Offset base (more will be added). */ #define zVDR_zNUMDIMS_OFFSET 128 #define zVDR_zDIMSIZES_OFFSET 132 #define zVDR_DIMVARYS_OFFSETb 132 /* Offset base (more will be added). */ #define zVDR_PADVALUE_OFFSETb 132 /* Offset base (more will be added). */ #define VDR_WASTED_OFFSET 48 /****************************************************************************** * VXR structure/fields/offsets - Variable Index Record. ******************************************************************************/ struct VXRstruct { Int32 RecordSize; /* Size of current record (bytes) */ Int32 RecordType; /* Type of record (ie. VXR) */ Int32 VXRnext; /* File offset to next VXR (bytes) */ Int32 Nentries; /* Number of index entries (entries not being used contain -1 in each field) */ Int32 NusedEntries; /* Number of index entries actually used */ Int32 First[MAX_VXR_ENTRIES]; /* First record number in VVR */ Int32 Last[MAX_VXR_ENTRIES]; /* Last record number in VVR */ Int32 Offset[MAX_VXR_ENTRIES]; /* File offset to VXR/VVR (bytes) */ }; #define VXR_NULL (-1) #define VXR_RECORD 0 #define VXR_RECORDSIZE 1 #define VXR_RECORDTYPE 2 #define VXR_VXRNEXT 3 #define VXR_NENTRIES 4 #define VXR_NUSEDENTRIES 5 #define VXR_FIRSTREC 6 #define VXR_LASTREC 7 #define VXR_OFFSET 8 #define VXR_RECORDSIZE_OFFSET 0 #define VXR_RECORDTYPE_OFFSET 4 #define VXR_VXRNEXT_OFFSET 8 #define VXR_NENTRIES_OFFSET 12 #define VXR_NUSEDENTRIES_OFFSET 16 #define VXR_FIRSTREC_OFFSET 20 /****************************************************************************** * VVR structure/fields/offsets - Variable Values Record. ******************************************************************************/ struct VVRstruct { Int32 RecordSize; /* Size of current record (bytes). */ Int32 RecordType; /* Type of record (ie. VVR). */ /* Bytes... */ }; #define VVR_NULL (-1) #define VVR_RECORDx 0 #define VVR_RECORDSIZE 1 #define VVR_RECORDTYPE 2 #define VVR_RECORDSIZE_OFFSET 0 #define VVR_RECORDTYPE_OFFSET 4 /****************************************************************************** * ADR structure/fields/offsets - Attribute Descriptor Record. ******************************************************************************/ struct ADRstruct { Int32 RecordSize; /* Size of current record (bytes). */ Int32 RecordType; /* Type of record (ie. ADR). */ Int32 ADRnext; /* File offset to next ADR (bytes). Note that in V2.0 CDFs this field was not set properly for the last attribute. */ Int32 AgrEDRhead; /* File offset to first AgrEDR (bytes). */ Int32 Scope; /* Variable or global. */ Int32 Num; /* Attribute id number. */ Int32 NgrEntries; /* Number of attribute gEntries/rEntries. */ Int32 MAXgrEntry; /* Maximum attribute gEntry/rEntry number. */ Int32 rfuA; /* reserved for future use (value = 0). */ Int32 AzEDRhead; /* File offset to first AzEDR (bytes). */ Int32 NzEntries; /* Number of attribute zEntries. */ Int32 MAXzEntry; /* Maximum attribute zEntry number. */ Int32 rfuE; /* Reserved for future use (value = -1). */ char Name[CDF_ATTR_NAME_LEN+1]; /* Attribute name. */ }; #define ADR_NULL (-1) #define ADR_RECORD 0 #define ADR_RECORDSIZE 1 #define ADR_RECORDTYPE 2 #define ADR_ADRNEXT 3 #define ADR_AgrEDRHEAD 4 #define ADR_SCOPE 5 #define ADR_NUM 6 #define ADR_NgrENTRIES 7 #define ADR_MAXgrENTRY 8 #define ADR_AzEDRHEAD 9 #define ADR_NzENTRIES 10 #define ADR_MAXzENTRY 11 #define ADR_NAME 12 #define ADR_RECORDSIZE_OFFSET 0 #define ADR_RECORDTYPE_OFFSET 4 #define ADR_ADRNEXT_OFFSET 8 #define ADR_AgrEDRHEAD_OFFSET 12 #define ADR_SCOPE_OFFSET 16 #define ADR_NUM_OFFSET 20 #define ADR_NgrENTRIES_OFFSET 24 #define ADR_MAXgrENTRY_OFFSET 28 #define ADR_RFUa_OFFSET 32 #define ADR_AzEDRHEAD_OFFSET 36 #define ADR_NzENTRIES_OFFSET 40 #define ADR_MAXzENTRY_OFFSET 44 #define ADR_RFUe_OFFSET 48 #define ADR_NAME_OFFSET 52 /****************************************************************************** * AgrEDR/AzEDR structure/fields/offsets - Attribute g/r/zEntry Descriptor * Record. ******************************************************************************/ struct AEDRstruct { Int32 RecordSize; /* Size of current record (bytes) */ Int32 RecordType; /* Type of record (ie. AgrEDR/AzEDR) */ Int32 AEDRnext; /* File offset to next AgrEDR/AzEDR. Note that in V2.0 CDFs this field was not set properly for the last entry (rEntry). */ Int32 AttrNum; /* Attribute Number */ Int32 DataType; /* Entry Data Type */ Int32 Num; /* Entry number (rVariable/zVariable number or arbitrary global `entry' [gEntry] number) */ Int32 NumElems; /* Number of elements of DataType */ Int32 rfuA; /* reserved for future use (value = 0) */ Int32 rfuB; /* reserved for future use (value = 0) */ Int32 rfuC; /* reserved for future use (value = 0) */ Int32 rfuD; /* reserved for future use (value = -1) */ Int32 rfuE; /* reserved for future use (value = -1) */ }; #define AEDR_NULL (-1) #define AEDR_RECORD 0 #define AEDR_RECORDSIZE 1 #define AEDR_RECORDTYPE 2 #define AEDR_AEDRNEXT 3 #define AEDR_ATTRNUM 4 #define AEDR_DATATYPE 5 #define AEDR_NUM 6 #define AEDR_NUMELEMS 7 #define AEDR_VALUE 8 #define AEDR_RECORDSIZE_OFFSET 0 #define AEDR_RECORDTYPE_OFFSET 4 #define AEDR_AEDRNEXT_OFFSET 8 #define AEDR_ATTRNUM_OFFSET 12 #define AEDR_DATATYPE_OFFSET 16 #define AEDR_NUM_OFFSET 20 #define AEDR_NUMELEMS_OFFSET 24 #define AEDR_RFUa_OFFSET 28 #define AEDR_RFUb_OFFSET 32 #define AEDR_RFUc_OFFSET 36 #define AEDR_RFUd_OFFSET 40 #define AEDR_RFUe_OFFSET 44 #define AEDR_VALUE_OFFSET 48 /****************************************************************************** * CPR structure/fields/offsets - Compression Parameters Record. ******************************************************************************/ struct CPRstruct { Int32 RecordSize; /* Size of record (bytes) */ Int32 RecordType; /* Type of record (ie. CPR) */ Int32 cType; /* Type of compression. */ Int32 rfuA; /* Reserved for future use. Set to zero. */ Int32 pCount; /* Parameter count. */ Int32 cParms[CDF_MAX_PARMS]; /* Parameters. */ }; #define CPR_NULL (-1) #define CPR_RECORD 0 #define CPR_RECORDSIZE 1 #define CPR_RECORDTYPE 2 #define CPR_CTYPE 3 #define CPR_RFUa 4 #define CPR_PCOUNT 5 #define CPR_CPARM1 6 #define CPR_CPARM2 7 #define CPR_CPARM3 8 #define CPR_CPARM4 9 #define CPR_CPARM5 10 #define CPR_RECORDSIZE_OFFSET 0 #define CPR_RECORDTYPE_OFFSET 4 #define CPR_CTYPE_OFFSET 8 #define CPR_RFUa_OFFSET 12 #define CPR_PCOUNT_OFFSET 16 #define CPR_CPARM1_OFFSET 20 #define CPR_CPARM2_OFFSET 24 #define CPR_CPARM3_OFFSET 28 #define CPR_CPARM4_OFFSET 32 #define CPR_CPARM5_OFFSET 36 /****************************************************************************** * SPR structure/fields/offsets - Sparseness Parameters Record. ******************************************************************************/ struct SPRstruct { Int32 RecordSize; /* Size of record (bytes) */ Int32 RecordType; /* Type of record (ie. CPR) */ Int32 sArraysType; /* Type of array sparseness. */ Int32 rfuA; /* Reserved for future use. Set to zero. */ Int32 pCount; /* Parameter count. */ Int32 sArraysParms[CDF_MAX_PARMS]; /* Parameters. */ }; #define SPR_NULL (-1) #define SPR_RECORD 0 #define SPR_RECORDSIZE 1 #define SPR_RECORDTYPE 2 #define SPR_STYPE 3 #define SPR_RFUa 4 #define SPR_PCOUNT 5 #define SPR_SPARM1 6 #define SPR_SPARM2 7 #define SPR_SPARM3 8 #define SPR_SPARM4 9 #define SPR_SPARM5 10 #define SPR_RECORDSIZE_OFFSET 0 #define SPR_RECORDTYPE_OFFSET 4 #define SPR_STYPE_OFFSET 8 #define SPR_RFUa_OFFSET 12 #define SPR_PCOUNT_OFFSET 16 #define SPR_SPARM1_OFFSET 20 #define SPR_SPARM2_OFFSET 24 #define SPR_SPARM3_OFFSET 28 #define SPR_SPARM4_OFFSET 32 #define SPR_SPARM5_OFFSET 36 /****************************************************************************** * CVVR structure/fields/offsets - Compressed Variable Values Record. ******************************************************************************/ struct CVVRstruct { Int32 RecordSize; /* Size of record (bytes) */ Int32 RecordType; /* Type of record (ie. CVVR) */ Int32 rfuA; /* Reserved for future use. Set to zero (0). */ Int32 cSize; /* Size in bytes of compressed data. */ /* Bytes... */ /* Extra... */ }; #define CVVR_NULL (-1) #define CVVR_RECORDx 0 #define CVVR_RECORDSIZE 1 #define CVVR_RECORDTYPE 2 #define CVVR_RFUa 3 #define CVVR_CSIZE 4 #define CVVR_RECORDSIZE_OFFSET 0 #define CVVR_RECORDTYPE_OFFSET 4 #define CVVR_RFUa_OFFSET 8 #define CVVR_CSIZE_OFFSET 12 /****************************************************************************** * UIR structure/fields/offsets - Unused Internal Record. ******************************************************************************/ struct UIRstruct { Int32 RecordSize; /* Size of current record (bytes). */ Int32 RecordType; /* Type of record (ie. UIR). */ Int32 NextUIR; /* File offset of next UIR (bytes). */ Int32 PrevUIR; /* File offset of previous UIR (bytes). */ }; #define UIR_NULL (-1) #define UIR_RECORD 0 #define UIR_RECORDSIZE 1 #define UIR_RECORDTYPE 2 #define UIR_NEXTUIR 3 #define UIR_PREVUIR 4 #define UIR_RECORDSIZE_OFFSET 0 #define UIR_RECORDTYPE_OFFSET 4 #define UIR_NEXTUIR_OFFSET 8 #define UIR_PREVUIR_OFFSET 12 /****************************************************************************** * Structure for variable record/dimension states for read/write operations. ******************************************************************************/ struct rdSTRUCT { Int32 recNumber; /* Current record number. */ Int32 recCount; /* Current record count. */ Int32 recInterval; /* Current record interval. */ Int32 dimIndices[CDF_MAX_DIMS]; /* Current dimension indices. */ Int32 dimCounts[CDF_MAX_DIMS]; /* Current dimension counts. */ Int32 dimIntervals[CDF_MAX_DIMS]; /* Current dimension intervals. */ }; /****************************************************************************** * Structures for rVariable/zVariable related data. ******************************************************************************/ struct VarStageStruct { Int32 areaOffset; /* Offset in staging file of area for this variable. */ Int32 firstRec; /* Number of first record in staging area. */ Int32 lastRec; /* Number of last record in staging area. */ Int32 dotOffset; /* Associated VVR/CVVR offset in dotCDF file. NO_OFFSET if no VVR/CVVR yet. */ Logical modified; /* TRUE if record(s) in staging area have been modified. */ }; struct VarStruct { Int32 VDRoffset; /* Byte offset of rVDR/zVDR. */ Int32 varN; /* The variable's number. */ vFILE *fp; /* For a multi-file CDF, this is NULL when the variable file is closed. For a single-file CDF, this is always NULL. */ int varCacheSize; /* Number of cache buffers for the variable file (if a multi-file CDF). */ uLong accessed_at; /* Pseudo-clock time of last access. */ CDFstatus (*DecodeFunction) PROTOARGs((void *buffer, Int32 numElems)); /* Function which converts values read from the CDF to the desired decoding. */ CDFstatus (*EncodeFunction) PROTOARGs((void *buffer, Int32 numElems)); /* Function which converts values being written to the CDF to the desired encoding. */ /**************************************************************************** * The following values are calculated based on the current zMode. For * rVariables they may differ from the values in the VDR. For zVariables * they will be the same as the values in the VDR but are maintained here * for consistency. ****************************************************************************/ Int32 numDims; /* Number of dimensions, based on zMode. */ Int32 dimSizes[CDF_MAX_DIMS]; /* Dimension sizes, based on zMode. */ Int32 recVary; /* Record variance, based on zMode (doesn't differ but done for consistency). */ Int32 dimVarys[CDF_MAX_DIMS]; /* Dimension variances, based on zMode. */ /**************************************************************************** * The following values are maintained in memory for efficiency. ****************************************************************************/ Int32 NvalueElems; /* Number of elements per value. */ Int32 NelemBytes; /* Number of bytes per element. */ Int32 NvalueBytes; /* Number of bytes per value. */ Int32 NphyRecValues; /* Number of physical values per record. */ Int32 NvirtRecValues; /* Number of virtual values per record. */ Int32 NphyRecElems; /* Number of physical elements per record. */ Int32 NvirtRecElems; /* Number of virtual elements per record. */ Int32 NphyRecBytes; /* Number of physical bytes per record. */ Int32 NvirtRecBytes; /* Number of virtual bytes per record. */ Int32 nPhyDimValues[CDF_MAX_DIMS]; /* Number of physical values `below' each occurance of a dimension. */ Int32 maxRec; /* Maximum record number. */ /**************************************************************************** * The following values maintain the current positioning. ****************************************************************************/ Int32 seqValueOffset; /* Used for sequential access. The current value offset (not the byte offset). */ struct rdSTRUCT zRD; /* Current record/dimension states. These are always used for zVariables. For rVariables, these are only used while in zMode. When not in zMode, the current record/dimension states in the `CDF' structure are used (and are the same for all rVariables). */ /**************************************************************************** * The following are dependent on the type of variable. ****************************************************************************/ Logical zVar; /* TRUE if a zVariable, FALSE if an rVariable. Independent of zMode. */ int vType; /* Type of variable: STANDARD_, SPARSE_RECORDS, COMPRESSED_, SPARSE_COMPRESSED_RECORDS, SPARSE_ARRAYS, or SPARSE_RECORDS_AND_ARRAYS. */ Int32 blockingFactor; /* Standard (in single-file CDF): Number of records by which to extend a variable when necessary. Compressed: Number of records per block (except for the last block which may be smaller). Sparse compressed records: Maximum number of records per block. Sparse records: Number of records in staging area. Sparse records and arrays: Sparse arrays: In multi-file CDF: n/a. */ Int32 maxAllocated; /* Maximum record number allocated. */ Int32 maxWritten; /* Maximum record number written/padded. */ Int32 cType; /* Compression type. */ Int32 cParms[CDF_MAX_PARMS]; /* Compression parameters. */ struct VarStageStruct stage; /* Staging control. */ Logical prevIfMissing; /* TRUE: return previous records' value if a record is missing (sRecords.PREV). FALSE: return pad value if a record is missing (sRecords.PAD or sRecords.NO). */ int reservePct; /* Reserve percentage for compressed variables. 0 No reserve percentage (the default). 1..100 Allocate (as a minimum) n% of the uncompressed size. 101... Allocate an addition (n-100)% of space beyond the original compressed size. */ Int32 firstRecInVVR; /* First data record in the most recently accessed VVR. */ Int32 lastRecInVVR; /* Last data record in the most recently accessed VVR. */ Int32 offsetOfVVR; /* Offset of the most recently accessed VVR from the cdf. */ }; /****************************************************************************** * Structures for CDF related data. ******************************************************************************/ struct CDFstageStruct { vFILE *fp; /* Staging scratch file pointer. */ Int32 mark; /* New allocations (for a variable) are at this offset. */ int cacheSize; /* Number of cache buffers for the staging scratch file. */ }; struct CDFstruct { uInt32 magic; /* Magic number stored in CDF structure in memory. Used to check that a valid `CDFid' was specified. */ vFILE *fp; /* Working file pointer. Set to either `dotFp' (if not a compressed CDF) or `uDotFp' (if a compressed CDF).*/ vFILE *dotFp; /* File pointer to dotCDF file. */ vFILE *uDotFp; /* File pointer to uncompressed dotCDF file. */ vFILE *compressFp; /* Compression scratch file pointer. If NULL, the compression scratch file has not been created yet. */ Int32 CDRoffset; /* Byte offset of CDR. N/a if a Version 1 CDF. */ Int32 GDRoffset; /* Byte offset of GDR. N/a if a Version 1 CDF. */ char *CDFname; /* CDF name as specified by caller. */ char *scratchDir; /* Directory to be used for scratch files. */ Int32 decoding; /* Decoding (encoding) for attribute entry and variable values read from a CDF. */ Logical readOnly; /* TRUE: read-only access, FALSE: read-write access. */ int zMode; /* zMODEoff: no zMode, zMODEon1: keep NOVARY variances (rVariables --> zGroup), zMODEon2: remove dimensions with NOVARY variance. */ Logical negToPosFp0; /* TRUE: convert -0.0 to 0.0, FALSE: don't convert. */ int status; /* READ_ONLY, or READ_WRITE. */ int workingCacheSize; /* Number of cache buffers for the "working" dotCDF file. */ int compressCacheSize; /* Number of cache buffers for the compression scratch file. */ uLong pseudo_clock; /* Tick count used to determine which variable was least recently used. */ Logical singleFile; /* TRUE if a single-file CDF. */ Logical rowMajor; /* TRUE if a row major CDF. */ Int32 encoding; /* Encoding of CDF. */ Int32 rNumDims; /* Number of rVariable dimensions. */ Int32 rDimSizes[CDF_MAX_DIMS]; /* rVariable dimension sizes. */ Int32 rMaxRec; /* Maximum record number of all the rVariables. */ Int32 NrVars; /* Number of rVariables. */ Int32 NzVars; /* Number of zVariables. */ int MAXrVars; /* Current size of `rVars' array. */ int MAXzVars; /* Current size of `zVars' array. */ struct VarStruct **rVars; /* Pointer to array of pointers to rVariable data structures. */ struct VarStruct **zVars; /* Pointer to array of pointers to zVariable data structures. */ Int32 CURrVarNum; /* Current rVariable number (when not in zMode). */ Int32 CURzVarNum; /* Current zVariable number (used when zMode is on or off). */ Int32 CURattrOffset; /* Offset of current attribute's ADR. Set to RESERVED_ATTROFFSET if an attribute is not selected. */ Int32 CURgrEntryNum; /* Currently selected gEntry/rEntry number (a corresponding gEntry/ rEntry in the current attribute does not have to exist yet). When in zMode, this is used only for the gEntry number. Set to RESERVED_ENTRYNUM when a gEntry/rEntry is not selected. */ Int32 CURzEntryNum; /* Currently selected zEntry number (a corresponding zEntry in the current attribute does not have to exist yet). This is used when zMode is on or off. When zMode is on, could actually point to an AgrEDR. Set to RESERVED_ENTRYNUM when a zEntry is not selected. */ Int32 CURgrEntryOffset; /* Offset of current AgrEDR. Not set to RESERVED_ENTRYOFFSET when an attribute and gEntry/rEntry have been selected and the entry actually exists. */ Int32 CURzEntryOffset; /* Offset of current AzEDR. Not set to RESERVED_ENTRYOFFSET when an attribute and zEntry have been selected and the entry actually exists. If zMode is on, could point to an AgrEDR. */ struct rdSTRUCT rRD; /* Current record/dimension states for the rVariables (they are the same for all rVariables). */ struct CDFstageStruct stage; /* Staging control. */ Logical no_append; /* TRUE if pathnames should not have extensions or version numbers appended. */ Logical upper_case_ext; /* TRUE if uppercase file extensions.*/ Logical version_numbers; /* TRUE if a ";1" is appended to all pathnames. */ Logical fakeEPOCH; /* TRUE if a CDF prior to CDF V2.1.1 for which the data type CDF_EPOCH should be substituted for the actual data type in some cases involving the rVariable "EPOCH". */ Logical wastedSpace; /* TRUE if a CDF prior to CDF V2.5 in which there is 128 bytes of wasted space in each VDR and 1689 bytes of wasted space in the CDR. */ Logical badEOF; /* TRUE if a CDF prior to CDF V2.1 in which case the EOF of the GDR was not used (ie. contains garbage). */ Logical badTerminatingOffsets; /* TRUE if a CDF prior to CDF V2.1 in which the terminating offsets of the ADR and rVDR linked lists are bad.*/ Logical assumedScopes; /* TRUE if a CDF prior to CDF V2.5 in which there are assumed attribute scopes. */ vSTATS dotCDFvStats; /* Vstream statistics for the dotCDF file (compressed or uncompressed).*/ vSTATS uDotCDFvStats; /* Vstream statistics for the uncompressed dotCDF file (of a compressed CDF). */ }; /****************************************************************************** * Structure for `string' related data (used by FORTRAN interfaces). ******************************************************************************/ struct STRINGstruct { char *string; struct STRINGstruct *next; }; /****************************************************************************** * Structure for `varargs' related data. ******************************************************************************/ struct VAstruct { va_list ap; long fnc; long item; }; /****************************************************************************** * Structure for `current' data. ******************************************************************************/ struct CurStruct { struct CDFstruct *cdf; CDFstatus status; }; /****************************************************************************** * SelectCDF. ******************************************************************************/ #define SelectCDF(cur_,cdf_) \ if (cur_ == NULL) \ return NO_CDF_SELECTED; \ else \ if (cur_->magic == ABORTEDid_MAGIC_NUMBER) \ return NO_MORE_ACCESS; \ else \ cdf_ = cur_; /****************************************************************************** * SINGLEfileBITset. ******************************************************************************/ #define SINGLEfileBITset(flags) (BITSET(flags,CDR_FORMAT_BIT)) /****************************************************************************** * ROWmajorBITset. ******************************************************************************/ #define ROWmajorBITset(flags) (BITSET(flags,CDR_MAJORITY_BIT)) /****************************************************************************** * zModeON/zModeOFF. ******************************************************************************/ #define zModeON(CDF) (CDF->zMode == zMODEon1 || CDF->zMode == zMODEon2) #define zModeOFF(CDF) (CDF->zMode == zMODEoff) /****************************************************************************** * Checks for set bits in VDR flags. ******************************************************************************/ #define PADvalueBITset(flags) (BITSET(flags,VDR_PADVALUE_BIT)) #define RECvaryBITset(flags) (BITSET(flags,VDR_RECVARY_BIT)) #define SPARSEarraysBITset(flags) (BITSET(flags,VDR_SPARSEARRAYS_BIT)) #define VARcompressionBITset(flags) (BITSET(flags,VDR_COMPRESSION_BIT)) /****************************************************************************** * Function prototypes. ******************************************************************************/ STATICforIDL struct VarStruct *VarStructPtr PROTOARGs(( struct CDFstruct *CDF, Logical zOp, long varN )); STATICforIDL void DefaultPadValue PROTOARGs(( Int32 dataType, Int32 numElems, void *padValue )); STATICforIDL CDFstatus DefaultPadBuffer PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 nValues, void *buffer )); STATICforIDL CDFstatus PadBuffer PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 nValues, void *buffer )); STATICforIDL CDFstatus WasteIR PROTOARGs(( struct CDFstruct *CDF, Int32 offset, Int32 size )); STATICforIDL Int32 IndicesValueOffset PROTOARGs(( Int32 numDims, Int32 *indices, Int32 *dimVarys, Int32 *nPhyDimValues )); STATICforIDL void ValueOffsetIndices PROTOARGs(( Int32 offset, Logical rowMajor, Int32 numDims, Int32 *dimVarys, Int32 *nPhyDimValues, Int32 *indices )); STATICforIDL CDFstatus RecordByteOffset PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 phyRecN, Int32 *offset )); STATICforIDL CDFstatus ConfigureNEWzMode PROTOARGs((struct CDFstruct *CDF)); STATICforIDL void InitCURobjectsStates PROTOARGs((struct CDFstruct *CDF)); STATICforIDL Int32 HostEncoding PROTOARGs((void)); STATICforIDL Int32 HostDecoding PROTOARGs((void)); STATICforIDL int IntegerOrder PROTOARGs((Int32 ed)); STATICforIDL int FpType PROTOARGs((Int32 ed)); STATICforIDL Logical EquivDataTypes PROTOARGs(( Int32 dataType1, Int32 dataType2 )); STATICforIDL void FreeCDFid PROTOARGs(( struct CDFstruct *CDF, Logical aborting )); STATICforIDL CDFstatus CloseLRUvar PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus VarAccess PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus AllocateRecords VARPROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, struct AllocStruct alloc )); STATICforIDL CDFstatus PadUnRecords PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 firstRec, Int32 lastRec )); STATICforIDL CDFstatus CloseVarFiles PROTOARGs((struct CDFstruct *CDF)); STATICforIDL Logical WriteAccess PROTOARGs(( struct CDFstruct *CDF, Logical forDelete, CDFstatus *pStatus )); STATICforIDL CDFstatus WriteVarElems PROTOARGs(( struct VarStruct *Var, vFILE *fp, Int32 offset, Int32 numElems, void *buffer )); STATICforIDL CDFstatus WriteBuffer PROTOARGs(( struct CDFstruct *CDF, vFILE *fp, Int32 dataType, Int32 numElems, void *buffer )); STATICforIDL CDFstatus HyperRead PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, struct rdSTRUCT *rd, void *buffer )); STATICforIDL CDFstatus HyperReadDim PROTOARGs(( Int32 numDims, Int32 *dimSizes, Int32 *dimVarys, Int32 *indices, Int32 *counts, Int32 *intervals, Int32 *nHypDimValues, Int32 *nPhyDimValues, Logical *fullPhyDim, int firstDim, int dimIncr, Int32 recNum, Int32 offset, void *buffer, void *phyBuffer, struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus HyperWrite PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, struct rdSTRUCT *rd, void *buffer )); STATICforIDL CDFstatus HyperWriteDim PROTOARGs(( Int32 numDims, Int32 *dimSizes, Int32 *dimVarys, Int32 *indices, Int32 *counts, Int32 *intervals, Int32 *nHypDimValues, Int32 *nPhyDimValues, Logical *fullPhyDim, int firstDim, int dimIncr, Int32 recNum, Int32 offset, void *buffer, void *phyBuffer, struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus CDFcre PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFope PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFdel PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFclo PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFget PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFput1 PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFput2 PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFsel PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL CDFstatus CDFcon PROTOARGs(( struct VAstruct *Va, struct CurStruct *Cur )); STATICforIDL void CDFcopyRight PROTOARGs((char *copyRight)); STATICforIDL CDFstatus CDFstatusText PROTOARGs(( CDFstatus status, char *textPtr )); STATICforIDL CDFstatus Read_V1_header PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus Read_V2_header PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus Write_V2_header PROTOARGs((struct CDFstruct *CDF)); STATICforIDL char *NULterminate PROTOARGs(( char *string, size_t length, struct STRINGstruct **ssh )); STATICforIDL void FreeStrings PROTOARGs((struct STRINGstruct *ssh)); STATICforIDL Logical ValidVarName PROTOARGs((char *name)); STATICforIDL Logical ValidAttrName PROTOARGs((char *name)); STATICforIDL Logical ValidDataType PROTOARGs((Int32 dataType)); STATICforIDL Logical ValidAttrScope PROTOARGs((Int32 scope)); STATICforIDL Logical ValidEncoding PROTOARGs(( Int32 encoding, Int32 *actualEncoding )); STATICforIDL Logical ValidDecoding PROTOARGs((Int32 decoding)); STATICforIDL CDFstatus ValidateCompression PROTOARGs(( long cType, long *cParms )); STATICforIDL CDFstatus ConversionFunction PROTOARGs(( Int32 dataType, Int32 encoding, Int32 decoding, Logical negToPosFp0, CDFstatus (**function) PROTOARGs((void *buffer, Int32 numElems)) )); STATICforIDL CDFstatus FP1toFP34single PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP34single PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP34toFP1single PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP34toFP2single PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP2singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP34singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP1singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP34singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP34toFP1singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP34toFP2singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP3double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP4double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP3double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP4double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP1double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP2double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP4double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP1double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP2double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP3double PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP2doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP3doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1toFP4doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP1doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP3doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2toFP4doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP1doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP2doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3toFP4doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP1doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP2doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4toFP3doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP34singleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP1doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP2doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP4doubleNEGtoPOS PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus FP3doubleLIMIT PROTOARGs(( void *buffer, Int32 numElems )); STATICforIDL CDFstatus Reverse2 PROTOARGs((void *buffer, Int32 numElems)); STATICforIDL CDFstatus Reverse4 PROTOARGs((void *buffer, Int32 numElems)); STATICforIDL CDFstatus Reverse8 PROTOARGs((void *buffer, Int32 numElems)); #if defined(Fif_DESCR) STATICforIDL Logical isDESCR PROTOARGs((void *ptr, char **aptr, size_t *len)); STATICforIDL char *DESCRtoREF PROTOARGs((void *ptr)); STATICforIDL char *DESCRtoREFnul PROTOARGs(( void *ptr, size_t maxREFlen, struct STRINGstruct **ssh )); #endif #if defined(Fif_NOLEN) STATICforIDL char *FindEndNUL PROTOARGs(( char *ptr, size_t maxREFlen, struct STRINGstruct **ssh )); #endif STATICforIDL void SetBit32 PROTOARGs((Int32 *value, int bit)); STATICforIDL void ClearBit32 PROTOARGs((Int32 *value, int bit)); STATICforIDL void CtoFORTstring PROTOARGs(( char *Cstring, void *FORTstring, int length )); STATICforIDL void NulPad PROTOARGs((char *string, int length)); STATICforIDL CDFstatus UpdateMaxRec PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 phyRecNum )); STATICforIDL CDFstatus FindCDF PROTOARGs(( char *path, Logical *append, Logical *upper, Logical *version )); STATICforIDL void BuildFilePath PROTOARGs(( int fileType, char *pathBase, Logical noAppend, Logical upperCase, Logical versionNumber, Int32 varN, char pathX[DU_MAX_PATH_LEN+1] )); STATICforIDL CDFstatus LocateCurrentVar PROTOARGs(( struct CDFstruct *CDF, Logical zOp, Int32 *offset, Logical *zVar, struct VarStruct **Var )); STATICforIDL CDFstatus InitCurrentVar PROTOARGs(( struct CDFstruct *CDF, Logical zVar, struct VarStruct **Var )); STATICforIDL CDFstatus InitVar PROTOARGs(( struct CDFstruct *CDF, Int32 varN, Logical zVar, struct VarStruct **Var )); STATICforIDL CDFstatus InitVar2 PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus VarIdentity PROTOARGs(( struct CDFstruct *CDF, Int32 varN, Logical zOp, Int32 *varNt, Logical *zVar, struct VarStruct **Var )); STATICforIDL CDFstatus OpenVar PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus FindAttrByName PROTOARGs(( struct CDFstruct *CDF, char *searchName, Int32 *offset )); STATICforIDL CDFstatus FindAttrByNumber PROTOARGs(( struct CDFstruct *CDF, Int32 searchNum, Int32 *offset )); STATICforIDL CDFstatus FindEntryByNumber PROTOARGs(( struct CDFstruct *CDF, Int32 ADRoffset, Logical zEntry, Int32 entryN, Int32 *offset )); STATICforIDL CDFstatus FindVarByName PROTOARGs(( struct CDFstruct *CDF, char *searchName, Int32 *offset, Logical *zVar, struct VarStruct **Var )); STATICforIDL CDFstatus FindVarByNumber PROTOARGs(( struct CDFstruct *CDF, Int32 searchNum, Logical zVar, Int32 *offset )); STATICforIDL CDFstatus FindLastAttr PROTOARGs(( struct CDFstruct *CDF, Int32 *lastOffset )); STATICforIDL CDFstatus FindLastEntry PROTOARGs(( struct CDFstruct *CDF, Int32 ADRoffset, Logical zEntry, Int32 *lastOffset )); STATICforIDL CDFstatus FindPrevEntry PROTOARGs(( struct CDFstruct *CDF, Int32 ADRoffset, Int32 searchOffset, Logical zEntry, Int32 *prevOffset )); STATICforIDL CDFstatus CheckEntryOp PROTOARGs(( struct CDFstruct *CDF, int entryType )); STATICforIDL CDFstatus SetCURgrEntry PROTOARGs(( struct CDFstruct *CDF, Logical useCurrent, Int32 entryNum )); STATICforIDL CDFstatus SetCURzEntry PROTOARGs(( struct CDFstruct *CDF, Logical useCurrent, Int32 entryNum )); STATICforIDL CDFstatus CalcDimParms PROTOARGs(( struct CDFstruct *CDF, Int32 offset, Logical zVar, Int32 *numDimsP, Int32 dimSizesP[], Int32 dimVarysP[] )); STATICforIDL Int32 SeqValueByteOffset PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL void NULterminateMAX PROTOARGs((char *string, size_t maxLen)); STATICforIDL CDFstatus AllocateIR PROTOARGs(( struct CDFstruct *CDF, Int32 size, Int32 *offset )); STATICforIDL CDFstatus ResizeIR PROTOARGs(( struct CDFstruct *CDF, Int32 curOffset, Int32 newSize, Int32 *newOffset, Logical move, Logical *success )); STATICforIDL CDFstatus RemoveUIRs PROTOARGs(( struct CDFstruct *CDF, Int32 sOffset, Int32 eOffset )); STATICforIDL CDFstatus LastRecord PROTOARGs(( struct CDFstruct *CDF, Int32 offset, Logical zVar, Int32 *recNum )); STATICforIDL CDFstatus VerifyNoRecordsWritten PROTOARGs(( struct CDFstruct *CDF, Logical *no )); STATICforIDL CDFstatus VerifyNoPadsSpecified PROTOARGs(( struct CDFstruct *CDF, Logical *no )); STATICforIDL CDFstatus VerifyNoEntriesWritten PROTOARGs(( struct CDFstruct *CDF, Logical *no )); STATICforIDL Logical Read32s PROTOARGs((vFILE *fp, Int32 *buffer, int count)); STATICforIDL CDFstatus ReadIrSize PROTOARGs(( vFILE *fp, Int32 offset, Int32 *irSize )); STATICforIDL CDFstatus ReadCDR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadGDR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadADR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadAEDR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadVDR VARPROTOARGs(( struct CDFstruct *CDF, vFILE *fp, Int32 offset, Logical zVar, ... )); STATICforIDL CDFstatus ReadVVR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadCCR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadCPR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadSPR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadCVVR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ReadUIR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL Logical Write32 PROTOARGs((vFILE *fp, Int32 *value)); STATICforIDL Logical Write32s PROTOARGs((vFILE *fp, Int32 *buffer, int count)); STATICforIDL CDFstatus WriteIrSize PROTOARGs(( vFILE *fp, Int32 offset, Int32 *irSize )); STATICforIDL CDFstatus WriteIrType PROTOARGs(( vFILE *fp, Int32 offset, Int32 *irType )); STATICforIDL CDFstatus WriteCDR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteGDR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteADR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteAEDR VARPROTOARGs(( struct CDFstruct *CDF, vFILE *fp, Int32 offset, ... )); STATICforIDL CDFstatus WriteVDR VARPROTOARGs(( struct CDFstruct *CDF, vFILE *fp, Int32 offset, Logical zVar, ... )); STATICforIDL CDFstatus WriteVXR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteVVR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteCCR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteCPR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteSPR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteCVVR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus WriteUIR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); STATICforIDL CDFstatus ShortenCDR PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus ShortenVDRs PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus CorrectEPOCH PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus CorrectScopes PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus CorrectBlockingFactors PROTOARGs(( struct CDFstruct *CDF )); STATICforIDL CDFstatus CorrectV20offsets PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus CorrectV20eof PROTOARGs((struct CDFstruct *CDF)); STATICforIDL Logical DeleteFile PROTOARGs((char *path)); STATICforIDL void KillAbortedCDF PROTOARGs(( struct CDFstruct *CDF, struct CurStruct *Cur )); STATICforIDL void AbortAccess PROTOARGs(( struct CDFstruct *CDF, Logical updateCDF, Logical deleteCDF )); STATICforIDL CDFstatus DeleteCDFfiles PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus DeleteEntry PROTOARGs(( struct CDFstruct *CDF, Int32 aOffset, Int32 eOffset )); STATICforIDL void StripTrailingBlanks PROTOARGs((char *string)); STATICforIDL CDFstatus DecompressCDF PROTOARGs((vFILE *dotFp, vFILE *uDotFp)); STATICforIDL CDFstatus WriteCompressedCDF PROTOARGs(( struct CDFstruct *CDF, struct CPRstruct *CPR, Logical empty )); STATICforIDL CDFstatus CopyCDF PROTOARGs((vFILE *srcFp, vFILE *destFp)); STATICforIDL CDFstatus CompressRLE0 PROTOARGs(( vFILE *srcFp, Int32 srcOffset, Int32 srcSize, CDFstatus srcError, vFILE *destFp, Int32 destOffset, Int32 *destSize, CDFstatus destError )); STATICforIDL CDFstatus DecompressRLE0 PROTOARGs(( vFILE *srcFp, Int32 srcOffset, Int32 srcSize, CDFstatus srcError, vFILE *destFp, Int32 destOffset, CDFstatus destError )); STATICforIDL CDFstatus CompressHUFF0 PROTOARGs(( vFILE *input, Int32 iOffset, Int32 iSize, CDFstatus iError, vFILE *oFp, Int32 oOffset, Int32 *oSize, CDFstatus oError )); STATICforIDL CDFstatus DecompressHUFF0 PROTOARGs(( vFILE *iFp, Int32 iOffset, CDFstatus iError, vFILE *output, Int32 oOffset, CDFstatus oError )); STATICforIDL CDFstatus CompressAHUFF0 PROTOARGs(( vFILE *input, Int32 iOffset, Int32 iSize, CDFstatus iError, vFILE *oFp, Int32 oOffset, Int32 *oSize, CDFstatus oError )); STATICforIDL CDFstatus DecompressAHUFF0 PROTOARGs(( vFILE *iFp, Int32 iOffset, CDFstatus iError, vFILE *output, Int32 oOffset, CDFstatus oError )); STATICforIDL CDFstatus CompressGZIP PROTOARGs(( vFILE *srcFp, Int32 srcOffset, Int32 srcSize, CDFstatus srcError, vFILE *destFp, Int32 destOffset, Int32 *destSize, CDFstatus destError, Int32 level )); STATICforIDL CDFstatus DecompressGZIP PROTOARGs(( vFILE *srcFp, Int32 srcOffset, CDFstatus srcError, vFILE *destFp, Int32 destOffset, CDFstatus destError )); STATICforIDL CDFstatus WriteVarValues PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 recNum, Int32 offset, Int32 nValues, void *buffer )); STATICforIDL CDFstatus SearchForRecord PROTOARGs(( struct CDFstruct *CDF, Int32 VDRoffset, Logical zVar, Int32 recNum, Int32 *firstRec, Int32 *lastRec, Int32 *offset, Logical *found )); STATICforIDL CDFstatus IndexingStatistics PROTOARGs(( struct CDFstruct *CDF, Int32 VDRoffset, Logical zVar, Int32 *nVXRsP, Int32 *nEntriesP, Int32 *nAllocP, Int32 *nRecordsP, Int32 *nLevelsP )); STATICforIDL CDFstatus BuildPadBuffer PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 nRecords, int *how, void **buffer, Logical encode )); STATICforIDL CDFstatus WritePadValues PROTOARGs(( struct VarStruct *Var, vFILE *fp, Int32 offset, Int32 nRecords, int how, void *buffer )); STATICforIDL CDFstatus ReadVarElems PROTOARGs(( struct VarStruct *Var, vFILE *fp, Int32 offset, Int32 numElems, void *buffer )); STATICforIDL CDFstatus ReadVarValues PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 recNum, Int32 offset, Int32 nValues, void *buffer )); STATICforIDL CDFstatus PrevRecord PROTOARGs(( struct CDFstruct *CDF, Int32 VDRoffset, Logical zVar, Int32 baseRec, Int32 *prevRec, Logical *found )); STATICforIDL CDFstatus NextRecord PROTOARGs(( struct CDFstruct *CDF, Int32 VDRoffset, Logical zVar, Int32 baseRec, Int32 *nextRec, Logical *found )); STATICforIDL CDFstatus VariableType PROTOARGs(( struct CDFstruct *CDF, Int32 vdrOffset, Logical zVar, int *vType )); STATICforIDL CDFstatus InitVarStage PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 nBytes )); STATICforIDL CDFstatus CopyBytes PROTOARGs(( vFILE *iFp, Int32 iStart, CDFstatus iError, Int32 nBytes, vFILE *oFp, Int32 oStart, CDFstatus oError )); STATICforIDL CDFstatus ModIndexOffset PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 firstRec, Int32 lastRec, Int32 newOffset )); STATICforIDL CDFstatus InitScratch PROTOARGs(( char *scratchDir, vFILE **scratchFpH, int cacheSize )); STATICforIDL CDFstatus CalcBF PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus CalcCompressionPct PROTOARGs(( struct CDFstruct *CDF, Int32 vdrOffset, Logical zVar, long *cPct )); STATICforIDL CDFstatus CalcPhyRecBytes PROTOARGs(( struct CDFstruct *CDF, Int32 vdrOffset, Logical zVar, Int32 *nPhyRecBytes )); STATICforIDL void CalcNumDimValues PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL void CalcRecValues PROTOARGs((struct VarStruct *Var)); STATICforIDL CDFstatus UpdateConversions PROTOARGs((struct CDFstruct *CDF)); STATICforIDL CDFstatus UpdateNEWzMode PROTOARGs((struct CDFstruct *CDF)); STATICforIDL void InitNewVXR PROTOARGs(( struct VXRstruct *VXR, Int32 firstRec, Int32 lastRec, Int32 offset )); STATICforIDL CDFstatus UpdateVXRtailInVDR PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL CDFstatus Compress PROTOARGs(( vFILE *iFp, Int32 iOffset, Int32 iSize, CDFstatus iError, Int32 cType, Int32 cParms[], vFILE *oFp, Int32 oOffset, Int32 *oSize, CDFstatus oError )); STATICforIDL CDFstatus Decompress PROTOARGs(( vFILE *iFp, Int32 iOffset, Int32 iSize, CDFstatus iError, Int32 cType, Int32 cParms[], vFILE *oFp, Int32 oOffset, CDFstatus oError )); STATICforIDL CDFstatus DecompressToStage PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var, Int32 offset, Int32 uSize )); STATICforIDL CDFstatus FlushStage PROTOARGs(( struct CDFstruct *CDF, struct VarStruct *Var )); STATICforIDL char *ScratchDirectory PROTOARGs((struct CDFstruct *CDF)); STATICforIDL void AddTOvStats PROTOARGs((vSTATS *vStatsSum, vSTATS *vStats)); #if defined(__cplusplus) extern "C" { #endif VISIBLE_PREFIX Logical ValidCDFname PROTOARGs((char *name)); #if !defined(__CFM68K__) || defined(__USING_STATIC_LIBS__) || !defined(CFM68KDLL) VISIBLE_PREFIX CDFstatus UpdateDotCDF PROTOARGs((struct CDFstruct *CDF)); #endif VISIBLE_PREFIX vFILE *V_open PROTOARGs((char *file_spec, char *a_mode)); VISIBLE_PREFIX vFILE *V_scratch PROTOARGs((char *directory, char *extension)); VISIBLE_PREFIX int V_setcache PROTOARGs((vFILE *vfp, int nCacheBuffers)); VISIBLE_PREFIX int V_seek PROTOARGs((vFILE *vfp, long offset, int direction)); VISIBLE_PREFIX long V_tell PROTOARGs((vFILE *vfp)); VISIBLE_PREFIX int V_eof PROTOARGs((vFILE *vfp)); VISIBLE_PREFIX int V_error PROTOARGs((vFILE *vfp)); VISIBLE_PREFIX size_t V_read PROTOARGs(( void *buffer, size_t item_size, size_t n_items, vFILE *vfp )); VISIBLE_PREFIX size_t V_write PROTOARGs(( void *buffer, size_t item_size, size_t n_items, vFILE *vfp )); VISIBLE_PREFIX int V_getc PROTOARGs((vFILE *fp)); VISIBLE_PREFIX int V_putc PROTOARGs((int value, vFILE *fp)); #if !defined(__CFM68K__) || defined(__USING_STATIC_LIBS__) || !defined(CFM68KDLL) VISIBLE_PREFIX int V_flush PROTOARGs((vFILE *vfp)); #endif VISIBLE_PREFIX int V_clear PROTOARGs((vFILE *vfp)); VISIBLE_PREFIX int V_close PROTOARGs((vFILE *vfp, vSTATS *vStats)); VISIBLE_PREFIX int V_delete PROTOARGs((vFILE *vFp, vSTATS *vStats)); VISIBLE_PREFIX CDFstatus ReadVXR VARPROTOARGs((vFILE *fp, Int32 offset, ...)); VISIBLE_PREFIX CDFstatus ReadIrType PROTOARGs(( vFILE *fp, Int32 offset, Int32 *irType )); VISIBLE_PREFIX Logical Read32 PROTOARGs((vFILE *fp, Int32 *value)); VISIBLE_PREFIX CDFstatus ConvertBuffer PROTOARGs(( Int32 srcEncoding, Int32 dstEncoding, Logical negToPosFp0, Int32 dataType, Int32 numElems, void *srcbuffer, void *dstBuffer )); VISIBLE_PREFIX Logical PriorTo PROTOARGs(( char *spec, Int32 version, Int32 release, Int32 increment )); #if defined(__cplusplus) } #endif #if defined(DEBUG) STATICforIDL void DisplayVs PROTOARGs(( char *toWhere, char *label, vSTATS *vStats )); #endif #if defined(MICROSOFTC_700) && INCLUDEvMEMORY STATICforIDL MemHandle AllocateVMemory PROTOARGs((size_t nBytes)); STATICforIDL void *LoadVMemory PROTOARGs(( MemHandle handle, Logical writeFlag )); STATICforIDL int FreeVMemory PROTOARGs((MemHandle handle)); #endif /*****************************************************************************/ #endif cdf-to-fits/CDFmisc.c0000674000077000007660000014147210322750440014646 0ustar davidhcdf00000000000000/* #define CDFMISC */ #include "cdffits.h" #include "fitsio.h" #define MAX_LINES_WHEN_PAGING 22 #define MAX_PROGRAM_NAME_LEN 25 Logical pagingOn = TRUE; /* So online help will be paged. */ int soLineCount = 0; char pgmName[MAX_PROGRAM_NAME_LEN+1] = ""; static QOP *ParseSlashStyle PROTOARGs(( int argc, char *argv[], char *validQuals[], int optRequired[] )); static QOP *ParseHyphenStyle PROTOARGs(( int argc, char *argv[], char *validQuals[], int optRequired[] )); static void FreeArgvT PROTOARGs((int lastArgN, char *argvT[])); static QOP *BuildQOP PROTOARGs(( int Nparms, char *parms[], char *validQuals[], int *qualEntered, char *qualOpt[] )); void BreakdownCard(char *, long, char *, char *, char *, Logical *); /****************************************************************************** * WriteStringStdOut. ******************************************************************************/ void WriteStringStdOut (string, length) char *string; size_t length; { fprintf (stdout, "%*.*s", (int) length, (int) length, string); return; } /****************************************************************************** * strchrIgCase. ******************************************************************************/ int strncmpIgCase (string1, string2, count) char *string1; char *string2; size_t count; { int string1L = (int) strlen(string1); int string2L = (int) strlen(string2); int maxL, i; maxL = MAXIMUM(string1L,string2L); maxL = MINIMUM(maxL,(int)count); for (i = 0; i < maxL; i++) { if (MakeLower(string1[i]) != MakeLower(string2[i])) { return ((int) (string1[i] - string2[i])); } } return 0; } /****************************************************************************** * ReadCharStdIn. ******************************************************************************/ #if !defined(mac) void ReadCharStdIn (key) char *key; { *key = (char) fgetc (stdin); return; } #endif /****************************************************************************** * WriteOut. * Returns number of characters output. ******************************************************************************/ int WriteOut (fp, text) FILE *fp; char *text; { /**************************************************************************** * If the output is not going to `stdout', then assume it is going to a file * (and ignore paging if requested). ****************************************************************************/ if (fp != stdout) fprintf (fp, "%s", text); else { /************************************************************************** * The output is going to `stdout'. Assume that `stdout' has not been * redirected away from the user's terminal (to a file). If `stdout' has * been redirected to a file, then hopefully the user had enough sense not * to request paging. **************************************************************************/ #if defined(mac) || defined(win32) #if defined(mac) WriteOutMacSO (text); #else #if defined(SO) /* Jeff doesn't like this. This function should */ /* not be compiled if an FSI application. */ WriteOutWin32 (text); #endif #endif #else char *ptr = text, *ptrNL; size_t len; /************************************************************************** * If paging is on, first prompt for `more...' if the end of the standard * output screen has been reached. **************************************************************************/ for (;;) { /*********************************************************************** * If paging on, check if the maximum number of lines have been written. ***********************************************************************/ if (pagingOn) { if (soLineCount == MAX_LINES_WHEN_PAGING) { char key = NUL; static char prompt[] = "\nEnter RETURN for more..."; WriteStringStdOut (prompt, strlen(prompt)); ReadCharStdIn (&key); if (key != '\n') pagingOn = FALSE; WriteStringStdOut ("\n\n", 2); soLineCount = 0; } } /*********************************************************************** * Write the string up to the next newline character. If there aren't * any(more) newline characters, write the rest of the string. ***********************************************************************/ ptrNL = (char *) strchr (ptr, Nl); if (ptrNL == NULL) { len = strlen (ptr); WriteStringStdOut (ptr, len); break; } else { len = (int) (ptrNL - ptr + 1); WriteStringStdOut (ptr, len); if (pagingOn) soLineCount++; ptr = ptrNL + 1; if (*ptr == NUL) break; } } fflush (stdout); #endif } return strlen(text); } /****************************************************************************** * FatalError. ******************************************************************************/ void FatalError (message) char *message; { #if defined(mac) MacMessageDialog ("FATAL ERROR!", message); #else #if defined(win32) WinMessageDialog ("FATAL ERROR!", message); #else WriteOut (stdout, "FATAL ERROR! "); WriteOut (stdout, message); WriteOut (stdout, "\n"); #endif #endif ExitBAD; } /****************************************************************************** * DisplayError. ******************************************************************************/ void DisplayError (message) char *message; { #if defined(mac) MacMessageDialog ("Error!", message); #else #if defined(win32) WinMessageDialog ("Error!", message); #else WriteOut (stdout, "Error! "); WriteOut (stdout, message); WriteOut (stdout, "\n"); #endif #endif return; } /****************************************************************************** * Qop. ******************************************************************************/ QOP *Qop (argc, argv, validQuals, optRequired) int argc; char *argv[]; char *validQuals[]; int optRequired[]; { /**************************************************************************** * Check to see if a style definition has been specified. (A slash or hyphen * as the first command line argument.) ****************************************************************************/ if (argc > 1) { if (!strcmp(argv[1],"/")) return ParseSlashStyle (argc - 1, &argv[1], validQuals, optRequired); if (!strcmp(argv[1],"-")) return ParseHyphenStyle (argc - 1, &argv[1], validQuals,optRequired); } /**************************************************************************** * No style definition, parse according to default for operating system * being used. ****************************************************************************/ #if defined(vms) return ParseSlashStyle (argc, argv, validQuals, optRequired); #else return ParseHyphenStyle (argc, argv, validQuals, optRequired); #endif } /****************************************************************************** * ParseSlashStyle. * Assume qualifiers begin with a slash (/). ******************************************************************************/ static QOP *ParseSlashStyle (argc, argv, validQuals, optRequired) int argc; char *argv[]; char *validQuals[]; int optRequired[]; { QOP *qop; /* Pointer to QOP structure. */ int argN, /* Argument number. */ qualNv, /* Qualifier number (from list of valid qualifiers). */ qualNe, /* Qualifier number (from list of qualifiers entered). */ Nparms = 0, /* Number of parameters entered. */ Nquals = 0, /* Number of qualifiers entered. */ matchQualNv, /* Matching qualifier number (from list of valid qualifiers). */ qualEntered[QOP_MAX_QUALs]; /* TRUE if the corresponding qualifier was entered. */ char *parms[QOP_MAX_PARMs], /* Pointers to the parameters entered. */ *qualOpt[QOP_MAX_QUALs], /* Pointers to the options of the qualifiers entered (indexed to correspond to the list of valid qualifiers). */ *argvT[QOP_MAX_ARGVs], /* Pointers to temporary `argv' strings. */ *quals[QOP_MAX_QUALs], /* Pointers to the qualifiers entered (in the order they were entered). */ *opts[QOP_MAX_QUALs], /* Pointers to the options entered (in the order they were entered). */ *ptr; /* Pointer into character string. */ enum modes { UNKNOWN_, START_OF_PARM_, FIND_PARM_END_, START_OF_QUAL_, FIND_QUAL_END_, START_OF_OPT_, FIND_OPT_END_ } mode; /* The current mode when scanning the list of command line arguments. */ /**************************************************************************** * Determine parameters and qualifiers/options. ****************************************************************************/ for (argN = 1; argN < argc; argN++) { char nChars = strlen (argv[argN]); argvT[argN] = (char *) cdf_AllocateMemory (nChars + 1, FatalError); strcpyX (argvT[argN], argv[argN], nChars); mode = UNKNOWN_; for (ptr = argvT[argN]; *ptr != NUL;) { switch (mode) { case UNKNOWN_: if (*ptr == '/') { mode = START_OF_QUAL_; ptr++; } else mode = START_OF_PARM_; break; case START_OF_PARM_: Nparms++; if (Nparms <= QOP_MAX_PARMs) parms[Nparms-1] = ptr; else { DisplayError ("Too many parameters."); FreeArgvT (argN, argvT); return NULL; } mode = FIND_PARM_END_; ptr++; break; case FIND_PARM_END_: if (*ptr == '/') if (*(ptr+1) == '/') memmove (ptr, ptr+1, strlen(ptr+1) + 1); else { *ptr = NUL; mode = START_OF_QUAL_; } ptr++; break; case START_OF_QUAL_: if (*ptr == '/') mode = START_OF_PARM_; else { Nquals++; if (Nquals <= QOP_MAX_QUALs) quals[Nquals-1] = ptr; else { DisplayError ("Too many qualifiers."); FreeArgvT (argN, argvT); return NULL; } mode = FIND_QUAL_END_; ptr++; } break; case FIND_QUAL_END_: switch (*ptr) { case '/': *ptr = NUL; opts[Nquals-1] = NULL; mode = START_OF_QUAL_; break; case '=': *ptr = NUL; mode = START_OF_OPT_; break; } ptr++; break; case START_OF_OPT_: if (*ptr == '/') if (*(ptr+1) == '/') { opts[Nquals-1] = ptr + 1; ptr += 2; mode = FIND_OPT_END_; } else { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Missing option for qualifier `/%s'.", quals[Nquals-1]); DisplayError (tempS); FreeArgvT (argN, argvT); return NULL; } else { opts[Nquals-1] = ptr; mode = FIND_OPT_END_; ptr++; } break; case FIND_OPT_END_: if (*ptr == '/') if (*(ptr+1) == '/') memmove (ptr, ptr+1, strlen(ptr+1) + 1); else { *ptr = NUL; mode = START_OF_QUAL_; } ptr++; break; } } switch (mode) { case UNKNOWN_: /* Logic error. */ break; case START_OF_PARM_: /* Logic error. */ break; case START_OF_QUAL_: DisplayError ("Missing qualifier body (/)."); FreeArgvT (argN, argvT); return NULL; case FIND_QUAL_END_: /* Qualifier already NUL-terminated */ opts[Nquals-1] = NULL; break; case FIND_PARM_END_: /* Parameter already NUL-terminated */ break; case START_OF_OPT_: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS,"Missing option for qualifier `/%s'.",quals[Nquals-1]); DisplayError (tempS); FreeArgvT (argN, argvT); return NULL; } case FIND_OPT_END_: /* Option already NUL-terminated */ break; } } /**************************************************************************** * Set up to scan command line arguments (while checking number of valid * qualifiers). ****************************************************************************/ for (qualNv = 0; validQuals[qualNv] != NULL; qualNv++) { if (qualNv < QOP_MAX_QUALs) { qualEntered[qualNv] = FALSE; qualOpt[qualNv] = NULL; } else { WriteOut (stdout, "Too many valid qualifiers.\n"); FreeArgvT (argc - 1, argvT); return NULL; } } /**************************************************************************** * Determine which qualifiers/options were entered. ****************************************************************************/ for (qualNe = 0; qualNe < Nquals; qualNe++) { matchQualNv = FindUniqueMatch (quals[qualNe], validQuals); switch (matchQualNv) { case NOMATCH: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Unknown qualifier (/%s).", quals[qualNe]); DisplayError (tempS); FreeArgvT (argc - 1, argvT); return NULL; } case MATCHES: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Ambiguous qualifier (/%s).", quals[qualNe]); DisplayError (tempS); FreeArgvT (argc - 1, argvT); return NULL; } default: { if (optRequired[matchQualNv] && opts[qualNe] == NULL) { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Option missing for qualifier `/%s'.", validQuals[matchQualNv]); DisplayError (tempS); FreeArgvT (argc - 1, argvT); return NULL; } if (!optRequired[matchQualNv] && opts[qualNe] != NULL) { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Extraneous option for qualifier `/%s'.", validQuals[matchQualNv]); DisplayError (tempS); FreeArgvT (argc - 1, argvT); return NULL; } if (qualEntered[matchQualNv]) { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Redundant qualifier (/%s).", validQuals[matchQualNv]); DisplayError (tempS); FreeArgvT (argc - 1, argvT); return NULL; } qualEntered[matchQualNv] = TRUE; qualOpt[matchQualNv] = opts[qualNe]; break; } } } /**************************************************************************** * Build QOP structure. ****************************************************************************/ qop = BuildQOP (Nparms, parms, validQuals, qualEntered, qualOpt); /**************************************************************************** * Free memory used and return QOP structure. ****************************************************************************/ FreeArgvT (argc - 1, argvT); return qop; } /****************************************************************************** * ParseHyphenStyle. * Assume qualifiers begin with a hyphen (-). ******************************************************************************/ static QOP *ParseHyphenStyle (argc, argv, validQuals, optRequired) int argc; char *argv[]; char *validQuals[]; int optRequired[]; { QOP *qop; /* Pointer to a QOP structure. */ int argN, /* Command line argument number. */ qualNv, /* Qualifier number from `valids' list. */ Nparms = 0, /* Number of parameters entered. */ matchQualNv, /* Matching qualifier number (from list of valid qualifiers). */ qualEntered[QOP_MAX_QUALs]; /* TRUE if the corresponding qualifier was entered. */ char *parms[QOP_MAX_PARMs], /* Pointers to the parameters entered. */ *qualOpt[QOP_MAX_QUALs]; /* Pointers to the options of the qualifiers entered (indexed to correspond to the list of valid qualifiers). */ /**************************************************************************** * Set up to scan command line arguments (while checking number of valid * qualifiers). ****************************************************************************/ for (qualNv = 0; validQuals[qualNv] != NULL; qualNv++) { if (qualNv < QOP_MAX_QUALs) { qualEntered[qualNv] = FALSE; qualOpt[qualNv] = NULL; } else { DisplayError ("Too many valid qualifiers."); return NULL; } } /**************************************************************************** * Determine which qualifiers were entered (the rest being parameters). ****************************************************************************/ for (argN = 1; argN < argc; argN++) { if (argv[argN][0] == '-' && argv[argN][1] != '-') { matchQualNv = FindUniqueMatch (&argv[argN][1], validQuals); switch (matchQualNv) { case NOMATCH: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Unknown qualifier (-%s).", &argv[argN][1]); DisplayError (tempS); return NULL; } case MATCHES: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Ambiguous qualifier (-%s).", &argv[argN][1]); DisplayError (tempS); return NULL; } default: { if (qualEntered[matchQualNv]) { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Redundant qualifier (-%s).", validQuals[matchQualNv]); DisplayError (tempS); return NULL; } else qualEntered[matchQualNv] = TRUE; if (optRequired[matchQualNv]) { if (argN+1 < argc) { qualOpt[matchQualNv] = argv[argN+1]; argN++; } else { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Option missing for qualifier `-%s'.", validQuals[matchQualNv]); DisplayError (tempS); return NULL; } } } } } else { Nparms++; if (Nparms <= QOP_MAX_PARMs) parms[Nparms-1] = BOO(strncmp(argv[argN], "--", 2), argv[argN], argv[argN] + 1); else { DisplayError ("Too many parameters."); return NULL; } } } /**************************************************************************** * Build QOP structure. ****************************************************************************/ qop = BuildQOP (Nparms, parms, validQuals, qualEntered, qualOpt); /**************************************************************************** * Return QOP structure. ****************************************************************************/ return qop; } /****************************************************************************** * BuildQOP. ******************************************************************************/ static QOP *BuildQOP (Nparms, parms, validQuals, qualEntered, qualOpt) int Nparms; char *parms[]; char *validQuals[]; int *qualEntered; char *qualOpt[]; { QOP *qop; /* Pointer to a QOP structure. */ int parmN, /* Parameter number. */ qualNv, /* Qualifier number (in list of valid qualifiers. */ strCount = 0; /* Number of characters in the strings to be contained in the QOP structure. */ char *strOffset; /* Offset into the QOP structure of a string (parameter/option). */ for (parmN = 0; parmN < Nparms; parmN++) strCount += strlen(parms[parmN]) + 1; for (qualNv = 0; validQuals[qualNv] != NULL; qualNv++) if (qualEntered[qualNv]) if (qualOpt[qualNv] != NULL) strCount += strlen(qualOpt[qualNv]) + 1; qop = (QOP *) cdf_AllocateMemory (sizeof(QOP) + strCount, FatalError); strOffset = (char *) qop + sizeof(QOP); qop->Nparms = Nparms; for (parmN = 0; parmN < Nparms; parmN++) { qop->parms[parmN] = strOffset; strOffset += strlen(parms[parmN]) + 1; strcpyX (qop->parms[parmN], parms[parmN], 0); } for (qualNv = 0; validQuals[qualNv] != NULL; qualNv++) { qop->qualEntered[qualNv] = qualEntered[qualNv]; if (qualEntered[qualNv]) { if (qualOpt[qualNv] != NULL) { qop->qualOpt[qualNv] = strOffset; strOffset += strlen(qualOpt[qualNv]) + 1; strcpyX (qop->qualOpt[qualNv], qualOpt[qualNv], 0); } else qop->qualOpt[qualNv] = NULL; } } return qop; } /****************************************************************************** * FreeArgvT. ******************************************************************************/ static void FreeArgvT (lastArgN, argvT) int lastArgN; char *argvT[]; { int argN; for (argN = 1; argN <= lastArgN; argN++) cdf_FreeMemory (argvT[argN], FatalError); return; } /****************************************************************************** * FindUniqueMatch. * Returns: NOMATCH if a match was not found, * MATCHES if more than one match, * `index' if only one match. ******************************************************************************/ int FindUniqueMatch (target, strings) char *target; /* Searching for this string. */ char *strings[]; /* Terminated by a NULL pointer. */ { int match, beyond; size_t targetL = strlen(target); for (match = 0; strings[match] != NULL; match++) { if (!strncmpIgCase(target,strings[match],targetL)) { for (beyond = match + 1; strings[beyond] != NULL; beyond++) { if (!strncmpIgCase(target,strings[beyond],targetL)) return MATCHES; } return match; } } return NOMATCH; } /****************************************************************************** * TFqualifier. ******************************************************************************/ Logical TFqualifier (qop, variable, Tx, Fx, defaultTF, conflictText) QOP *qop; Logical *variable; int Tx; int Fx; Logical defaultTF; char *conflictText; { int count = 0; if (qop->qualEntered[Tx]) count++; if (qop->qualEntered[Fx]) count++; switch (count) { case 0: *variable = defaultTF; return TRUE; case 1: *variable = (qop->qualEntered[Tx] ? TRUE : FALSE); return TRUE; default: { char tempS[MAX_MESSAGE_TEXT_LEN+1]; sprintf (tempS, "Conflicting qualifiers (%s & no%s).", conflictText, conflictText); DisplayError (tempS); return FALSE; } } } /****************************************************************************** * DataTypeToken. * Returns address of character string for data type. ******************************************************************************/ char *DataTypeToken (dataType) long dataType; { switch (dataType) { case CDF_BYTE: return "CDF_BYTE"; case CDF_INT1: return "CDF_INT1"; case CDF_INT2: return "CDF_INT2"; case CDF_INT4: return "CDF_INT4"; case CDF_UINT1: return "CDF_UINT1"; case CDF_UINT2: return "CDF_UINT2"; case CDF_UINT4: return "CDF_UINT4"; case CDF_REAL4: return "CDF_REAL4"; case CDF_REAL8: return "CDF_REAL8"; case CDF_FLOAT: return "CDF_FLOAT"; case CDF_DOUBLE: return "CDF_DOUBLE"; case CDF_EPOCH: return "CDF_EPOCH"; case CDF_CHAR: return "CDF_CHAR"; case CDF_UCHAR: return "CDF_UCHAR"; default: return "?"; } } /****************************************************************************** * MajorityToken. * Returns address of character string for majority. ******************************************************************************/ char *MajorityToken (majority) long majority; { switch (majority) { case ROW_MAJOR: return "ROW_MAJOR"; case COLUMN_MAJOR: return "COLUMN_MAJOR"; default: return "?"; } } /****************************************************************************** * ConvertFormat. * Convert the format to Fortran-style if a C-style is passed. Otherwise, * return as is or a NULL. ******************************************************************************/ Logical ConvertFormat (char *format, long dataType, long numElemens, char *Fformat) { if (format == NULL) return FALSE; else if ((char *) strchr(format,'%') == NULL) { /* A Fortran format assumed. */ memcpy(Fformat, format, strlen(format)); return TRUE; } else { /* A C format is detected. Convert it to corresponding Fortran.*/ if (CtoFformat(format, Fformat, dataType, numElemens)) return TRUE; else return FALSE; } } /****************************************************************************** * CtoFformat. * Returns TRUE if valid Fortran format specification is returned. ******************************************************************************/ Logical CtoFformat (char *Cformat, char *Fformat, long dataType, long numElems) { int nFound, wpFound; int w, p, d; char m, cv, fv; int loc, len, iw, ip; w = p = d = iw = ip = 0; m = cv = fv = ' '; /**************************************************************************** * Change `Cformat' to point to first non-blank, non-digit, non-`(' * character. ****************************************************************************/ while (*Cformat != NUL && Spacing(*Cformat)) Cformat++; if (*Cformat == NUL) return FALSE; /**************************************************************************** * Encode Fortran format specification. * The C-style format: %<.prec> ****************************************************************************/ len = strlen(Cformat); loc = 1; /**************************************************************************** * Check flags. ****************************************************************************/ if (Cformat[loc] == '-' || Cformat[loc] == '+' || Cformat[loc] == '#') { loc++; len--; } if (Cformat[loc] == '0') { loc++; len--; } /**************************************************************************** * Check width and precision. ****************************************************************************/ if (Cformat[loc] == '.') wpFound = sscanf (&Cformat[loc], ".%d", &w); else wpFound = sscanf (&Cformat[loc], "%d.%d", &w, &p); switch (wpFound) { case 1: if (w < 10) {iw = 1; loc++;} else if (w < 100) {iw = 2; loc += 2;} else if (w < 1000) {iw = 3; loc += 3;} else if (w < 10000) {iw = 4; loc += 4;} break; case 2: if (w < 10) {iw = 1; loc++;} else if (w < 100) {iw = 2; loc += 2;} else if (w < 1000) {iw = 3; loc += 3;} else if (w < 10000) {iw = 4; loc += 4;} loc++; if (p < 10) {ip = 1; loc++;} else if (p < 100) {ip = 2; loc += 2;} else if (p < 1000) {ip = 3; loc += 3;} else if (p < 10000) {ip = 4; loc += 4;} break; default: break; } if (loc == (len - 2)) { /************************************************************************* * Check modifier. *************************************************************************/ nFound = sscanf (&Cformat[loc], "%c", &m); if (nFound > 0) loc++; } /**************************************************************************** * Check conversion. ****************************************************************************/ nFound = sscanf (&Cformat[loc], "%c", &cv); switch (cv) { case 'u': fv = 'I'; break; case 'd': fv = 'I'; break; case 'o': fv = 'O'; break; case 'i': fv = 'I'; break; case 'x': case 'X': fv = 'Z'; break; case 'e': case 'E': fv = 'D'; break; case 'f': fv = 'F'; break; case 'g': case 'G': fv = 'G'; break; case 'c': fv = 'A'; break; case 's': fv = 'A'; break; default: break; } if (fv == ' ') return FALSE; else { Fformat[0] = fv; if (wpFound > 0) { sprintf(Fformat+1, "%d", w); if (wpFound > 1) { Fformat[1+iw] = '.'; sprintf(Fformat+1+iw+1, "%d", p); Fformat[1+iw+ip+1] = (char) 0; } else Fformat[1+iw] = (char) 0; } else { if (numElems == 1) Fformat[1] = (char) 0; else { sprintf(Fformat+1, "%ld", numElems); if (numElems < 10) Fformat[2] = (char) 0; else if (numElems < 100) Fformat[3] = (char) 0; else if (numElems < 1000) Fformat[4] = (char) 0; else if (numElems < 10000) Fformat[5] = (char) 0; } } return TRUE; } } /****************************************************************************** * WhichDataType. ******************************************************************************/ long WhichDataType (token) char *token; { if (!strncmp(token,"BYTE",4)) return CDF_BYTE; if (!strncmp(token,"INT1",4)) return CDF_INT1; if (!strncmp(token,"UINT1",5)) return CDF_UINT1; if (!strncmp(token,"INT2",4)) return CDF_INT2; if (!strncmp(token,"UINT2",5)) return CDF_UINT2; if (!strncmp(token,"INT4",4)) return CDF_INT4; if (!strncmp(token,"UINT4",5)) return CDF_UINT4; if (!strncmp(token,"REAL4",5)) return CDF_REAL4; if (!strncmp(token,"FLOAT",5)) return CDF_FLOAT; if (!strncmp(token,"REAL8",5)) return CDF_REAL8; if (!strncmp(token,"DOUBLE",6)) return CDF_DOUBLE; if (!strncmp(token,"CHAR",4)) return CDF_CHAR; if (!strncmp(token,"UCHAR",5)) return CDF_UCHAR; if (!strncmp(token,"EPOCH",5)) return CDF_EPOCH; if (!strncmp(token,"CDF_BYTE",8)) return CDF_BYTE; if (!strncmp(token,"CDF_INT1",8)) return CDF_INT1; if (!strncmp(token,"CDF_UINT1",9)) return CDF_UINT1; if (!strncmp(token,"CDF_INT2",8)) return CDF_INT2; if (!strncmp(token,"CDF_UINT2",9)) return CDF_UINT2; if (!strncmp(token,"CDF_INT4",8)) return CDF_INT4; if (!strncmp(token,"CDF_UINT4",9)) return CDF_UINT4; if (!strncmp(token,"CDF_REAL4",9)) return CDF_REAL4; if (!strncmp(token,"CDF_FLOAT",9)) return CDF_FLOAT; if (!strncmp(token,"CDF_REAL8",9)) return CDF_REAL8; if (!strncmp(token,"CDF_DOUBLE",10)) return CDF_DOUBLE; if (!strncmp(token,"CDF_CHAR",8)) return CDF_CHAR; if (!strncmp(token,"CDF_UCHAR",9)) return CDF_UCHAR; if (!strncmp(token,"CDF_EPOCH",9)) return CDF_EPOCH; return -1; } /****************************************************************************** * BreakdownCard. ******************************************************************************/ void BreakdownCard (char *cardIn, long numElems, char *keyword, char *keywordValue, char *comment, Logical *strKeywordValue) { char *card; char value[80]; char *ptr1, *ptr2; int jj; int fstatus; int ii; char *ptr; card = (char *) malloc((size_t) numElems + 1); memcpy(card, cardIn, (size_t) numElems); card[(size_t) numElems] = '\0'; keyword[0] = (char) 0; keywordValue[0] = (char) 0; comment[0] = (char) 0; *strKeywordValue = FALSE; if (numElems == 0) return; if (numElems <= 8) { ii = sscanf(card, "%s", keyword); return; } if (card[8] == '=' && strncmp(card, "COMMENT", 7)) { if (numElems == 9) return; memcpy(keyword, card, 8); ptr1 = (char *) strchr(keyword, ' '); if (ptr1 != NULL) keyword[ptr1-keyword] = (char) 0; else keyword[8] = (char) 0; if (card[10] == '\'') { ptr1 = (char *) strrchr(card, '\''); ptr2 = (char *) strchr(card+30, '/'); if (ptr2 != NULL && ptr2 > ptr1) { if (!strncmp(keyword, "TFORM", 5)) { memcpy(keywordValue, card+11, ptr1-card-12); keywordValue[ptr1-card-12] = (char) 0; } else { char *ptr3; ptr3 = (char *) strchr(card+10, '('); if (ptr3 != NULL && ptr3 < ptr1) { char *ptr4 = (char *) strchr(ptr3, ')'); memcpy(keywordValue, ptr3+1, ptr4-ptr3-1); keywordValue[ptr4-ptr3-1] = (char) 0; } else { memcpy(keywordValue, card+11, ptr1-card-11); keywordValue[ptr1-card-11] = (char) 0; } } } else { if (ptr2 == NULL) { memcpy(keywordValue, card+11, ptr1-card-11); keywordValue[ptr1-card-11] = (char) 0; } else { memcpy(value, card, ptr1-card-1); ptr2 = (char *) strchr(value, '\''); memcpy(keywordValue, ptr2+1, ptr1-card-11); keywordValue[ptr1-card-11] = (char) 0; } } *strKeywordValue = TRUE; } else if (card[10] == '(') { ptr1 = (char *) strchr(card+10, '('); ptr2 = (char *) strchr(card+10, ')'); memcpy(keywordValue, ptr1+1, ptr2-ptr1-1); keywordValue[ptr2-ptr1-1] = (char) 0; } else if (sscanf(card+9, "%s", keywordValue) == 1) { ptr1 = (char *) strrchr(keywordValue, '/'); if (ptr1 != NULL) keywordValue[ptr1-keywordValue] = (char) 0; if (!strncmp(keywordValue, "/", 1)) keywordValue[0] = (char) 0; } ptr1 = (char *) strchr(card+31, '/'); if (ptr1 != NULL) { int len = ptr1+1-card; if (len < numElems) { memcpy(comment, ptr1+1, (size_t)(numElems - len)); comment[numElems - len] = (char) 0; } } } else { /* Got to be a CONTINUE, COMMENT or HISTORY. */ memcpy(keyword, card, 8); ptr1 = (char *) strchr(keyword, ' '); if (ptr1 != NULL) keyword[ptr1-keyword] = (char) 0; else keyword[8] = (char) 0; if (strncmp(keyword, "CONTINUE", 8)) { /* It is COMMENT or HISTORY. */ if (card[8] != '=') { memcpy(comment, card+8, (size_t)(numElems - 8)); comment[numElems - 8] = (char) 0; } else { if (numElems == 9) comment = (char *) strdup(""); else { memcpy(comment, card+9, (size_t)(numElems - 9)); comment[numElems - 9] = (char) 0; } } } else { /* A CONTINUE card. */ *strKeywordValue = TRUE; ptr1 = (char *) strchr(card, '\''); ptr2 = (char *) strrchr(card, '\''); memcpy(keywordValue, ptr1+1, ptr2-ptr1-1); keywordValue[ptr2-ptr1-1] = (char) 0; ptr1 = (char *) strchr(card, '/'); if (ptr1 != NULL) { memcpy(comment, ptr1+1, numElems-(ptr1-card)-1); comment[numElems-(ptr1-card)-1] = (char) 0; } else comment[0] = (char) 0; } } return; } /****************************************************************************** * CheckKeywordValue. ******************************************************************************/ void GetKeywordValue (char *keywordValue, void *value, int *dataType, char *floatFormat) { int ii, jj; long ll; float ff; double dd; char *ptr1, *ptr2; int len1, len2; floatFormat[0] = (char) 0; if (strlen(keywordValue) == 1) { if (keywordValue[0] == 'T') { *(int *)value = 1; *dataType = TLOGICAL; return; } else if (keywordValue[0] == 'F') { *(int *)value = 0; *dataType = TLOGICAL; return; } if (sscanf(keywordValue, "%d", &ii) == 1) { *(int *)value = ii; *dataType = TINT32BIT; return; } } ptr1 = (char *) strchr(keywordValue, '.'); if (ptr1 != NULL) { /************************************* * A floating number. *************************************/ len1 = strlen(keywordValue); ptr2 = (char *) strchr(keywordValue, 'E'); if (ptr2 == NULL) ptr2 = (char *) strchr(keywordValue, 'e'); if (ptr2 != NULL) /************************************* * A floating number with exponential. *************************************/ len2 = ptr2 - ptr1 - 1; /************************************* * A floating number w/t exponential. *************************************/ else len2 = len1 - (ptr1 - keywordValue) - 1; if (len2 <= 6) { if (ptr2 == NULL) { sprintf(floatFormat, "%%%d.%dF",len1, len2); sscanf(keywordValue, "%f", value); } else { sprintf(floatFormat, "%%%d.%dE",len1, len2); sscanf(keywordValue, "%e", value); } *dataType = TFLOAT; return; } else { if (ptr2 == NULL) { sprintf(floatFormat, "%%%d.%dlF",len1, len2); sscanf(keywordValue, "%lf", value); } else { sprintf(floatFormat, "%%%d.%dlE",len1, len2); sscanf(keywordValue, "%le", value); } *dataType = TDOUBLE; return; } } else { ptr1 = (char *) strchr(keywordValue, 'E'); if (ptr1 == NULL) ptr1 = (char *) strchr(keywordValue, 'e'); if (ptr1 != NULL) { /* eg., 1E05 */ /************************************* * A floating number. *************************************/ len1 = strlen(keywordValue); if (len1 > (ptr1 - keywordValue + 1)) { if (sscanf(ptr1+1, "%d", ii) == 1) { if (ii > -125 && ii < 125) { sscanf(keywordValue, "%e", value); *dataType = TFLOAT; return; } else { sscanf(keywordValue, "%le", value); *dataType = TDOUBLE; return; } } } else { sscanf(keywordValue, "%e", value); *dataType = TFLOAT; return; } } } len1 = strlen(keywordValue); if (len1 < 10) { if (sscanf(keywordValue, "%d", value) == 1) { *dataType = TINT32BIT; return; } } else { if (sscanf(keywordValue, "%ld", value) == 1) { *dataType = TLONG; return; } } } /****************************************************************************** * ComplexVariable. ******************************************************************************/ Logical ComplexVariable (CDFid id, long varNum, char **attrName, long *attrNums, long numAttrs) { int ii; long dataType, numElems; CDFstatus status; for (ii = 0; ii < numAttrs; ii++) { if (!strcmp(attrName[ii], "IsComplexNum_")) { status = GetVarAttributeEntryInfo(id, attrNums[ii], varNum, &dataType, &numElems); if (status == CDF_OK) return TRUE; else return FALSE; } } return FALSE; } /****************************************************************************** * ParseKeyword. This is for a non-native CDF, originally converted from FITS. * It parses the card and returns the keyword, keyword value and comment in * char string. It also checks for and sets the keyword value data type, its * size and returns its binary value, if a non-string type. ******************************************************************************/ void ParseKeyword(char *entry, long lengthEntry, char *keyword, char *keywordValue, char *comment, int *keyDataType, int *num, int *size, char *floatFormat, void *value) { Logical strKeywordValue; floatFormat[0] = (char) 0; /***************************************************************** * Breakdown the card for the CDF originally converted from FITS. *****************************************************************/ BreakdownCard(entry, lengthEntry, keyword, keywordValue, comment, &strKeywordValue); *size = 0; *num = 1; if (strlen(keywordValue) == 0 && strlen(comment) == 0) { *((char *)value) = '\0'; return; } if (strKeywordValue == FALSE && keywordValue != NULL && strlen(keywordValue) > 0) { if ((char *) strchr(keywordValue, ',') != NULL) { void *tmp = malloc(80); int offset = 0, numFields = 1, inArray = 0, itemSize = 0; int len = strlen(keywordValue); char *ptr1; int fieldLength; ptr1 = (char *) strchr(keywordValue, ','); fieldLength = ptr1 - keywordValue; while (ptr1 != NULL) { numFields++; ptr1 = (char *) strchr(ptr1+1, ','); } offset = 0; do { memcpy(tmp, keywordValue+offset, fieldLength); ((char *)tmp)[fieldLength] = (char) 0; GetKeywordValue(tmp, ((char *)value)+inArray*itemSize, keyDataType, floatFormat); offset += (fieldLength+2); if (*keyDataType == TFLOAT) itemSize = 4; else itemSize = 8; inArray++; } while (offset < len); *size = numFields * itemSize; *num = numFields; } else { GetKeywordValue(keywordValue, value, keyDataType, floatFormat); if (*keyDataType == TINT32BIT || *keyDataType == TLONG || *keyDataType == TLOGICAL || *keyDataType == TFLOAT) *size = 4; else if (*keyDataType == TDOUBLE) *size = 8; *num = 1; } } else if (strKeywordValue == TRUE && (strlen(keywordValue) > 0)) { *keyDataType = TSTRING; *size = strlen(keywordValue); *num = 1; strcpy(value, keywordValue); } } /****************************************************************************** * Print out error message from CFITSIO function call. ******************************************************************************/ void PrintFITSerror(int status, char *msg) { /*****************************************************/ /* Print out cfitsio error messages and exit program */ /*****************************************************/ if (status) { printf("\n*** at %s\n",msg); fits_report_error(stderr, status); /* print error report */ exit( status ); /* terminate the program, returning error status */ } return; } /****************************************************************************** * Convert CDF data type to its corresponding FITS data type. ******************************************************************************/ int ConvertCDFDataType(long dataType) { switch (dataType) { case CDF_BYTE: return TSHORT; case CDF_INT1: return TSHORT; case CDF_INT2: return TSHORT; case CDF_INT4: return TINT; case CDF_UINT1: return TBYTE; case CDF_UINT2: return TUSHORT; case CDF_UINT4: return TUINT; case CDF_REAL4: return TFLOAT; case CDF_REAL8: return TDOUBLE; case CDF_FLOAT: return TFLOAT; case CDF_DOUBLE: return TDOUBLE; case CDF_EPOCH: return TSTRING; case CDF_CHAR: return TSTRING; case CDF_UCHAR: return TSTRING; default: return -1; } return -1; } /****************************************************************************** * Get FITS data type from its header information, TFORMn. ******************************************************************************/ int GetFITSdataType(char *tform) { char *ptr; ptr = (char *) strchr(tform, 'A'); if (ptr != NULL) return TSTRING; ptr = (char *) strchr(tform, 'L'); if (ptr != NULL) return TLOGICAL; ptr = (char *) strchr(tform, 'X'); if (ptr != NULL) return TBIT; ptr = (char *) strchr(tform, 'B'); if (ptr != NULL) return TBYTE; ptr = (char *) strchr(tform, 'I'); if (ptr != NULL) return TSHORT; ptr = (char *) strchr(tform, 'J'); if (ptr != NULL) return TINT; ptr = (char *) strchr(tform, 'E'); if (ptr != NULL) return TFLOAT; ptr = (char *) strchr(tform, 'F'); if (ptr != NULL) return TFLOAT; ptr = (char *) strchr(tform, 'D'); if (ptr != NULL) return TDOUBLE; ptr = (char *) strchr(tform, 'C'); if (ptr != NULL) return TCOMPLEX; ptr = (char *) strchr(tform, 'M'); if (ptr != NULL) return TDBLCOMPLEX; return -999; } /****************************************************************************** * The first pass for the global attribute "FITS_Header_Keywords" in a * non-native CDF to collect information that is needed for header creation * later. ******************************************************************************/ void FirstPass(CDFid id, long attrNum, long numEntries, int *conformation, int *whichHeader, int *extension, int *bitpix, int *naxis, long *naxes, long *pcount, long *gcount, int *extend, char **ttype, char **tform, char **tunit, char *extName) { int jj; long dataType, numElems; CDFstatus status; char keyword[8], keywordValue[80], comment[80], floatFormat[40]; int keyNum, keySize, keyDataType; long kk; void *value; kk = 0; value = (void *) malloc(80); for (jj = 0; jj < numEntries; jj++) { /********************************************************************** * Acquire each global attribute entry's info. **********************************************************************/ status = GetGlobalAttributeEntryInfo(id, attrNum, kk, &dataType, &numElems); if (status == CDF_OK) { /* The entry exists. */ void *entry; int size = CDFelemSize(dataType) * numElems; entry = (void *) malloc ((size_t) size); /******************************************************************** * Acquire its entry's data. ********************************************************************/ GetGlobalAttributeEntryData(id, attrNum, kk, entry); /****************************************************************** * Acquire entry data from the "FITS_Header_Keywords" attribute. * This is a non-native CDF. ******************************************************************/ ParseKeyword(entry, numElems, keyword, keywordValue, comment, &keyDataType, &keyNum, &keySize, floatFormat, value); if (keySize > 0) { /* The keyword value is returned. */ if (!strncmp(keyword, "SIMPLE", 6)) { *whichHeader = PRIMARY; *extension = IMAGE; if (!strcmp(keywordValue, "T")) *conformation = TRUE; else *conformation = FALSE; } if (!strncmp(keyword, "XTENSION", 8)) { *whichHeader = XTENSION; if (!strcmp(keywordValue, "IMAGE ")) *extension = IMAGE; else if (!strcmp(keywordValue, "BINTABLE")) *extension = BINTABLE; else if (!strcmp(keywordValue, "TABLE ")) *extension = TABLE; } if (!strncmp(keyword, "BITPIX", 6)) { sscanf(keywordValue, "%d", bitpix); } else if (!strncmp(keyword, "NAXIS", 5)) { int tmpInt1, tmpInt2; tmpInt2 = sscanf(keyword, "NAXIS%d", &tmpInt1); if (tmpInt2 != 1) sscanf(keywordValue, "%d", naxis); else { sscanf(keywordValue, "%d", &tmpInt2); *(((long *)naxes)+tmpInt1-1) = tmpInt2; } } else if (!strncmp(keyword, "PCOUNT", 6)) { sscanf(keywordValue, "%d", pcount); } else if (!strncmp(keyword, "GCOUNT", 6)) { sscanf(keywordValue, "%d", gcount); } else if (!strncmp(keyword, "EXTEND", 6)) { if (!strcmp(keywordValue,"T")) *extend = 1; else *extend = 0; } else if (!strncmp(keyword, "TTYPE", 5)) { int tmpInt; sscanf(keyword, "TTYPE%d", &tmpInt); ttype[tmpInt-1] = (char *) strdup(keywordValue); } else if (!strncmp(keyword, "TFORM", 5)) { int tmpInt; sscanf(keyword, "TFORM%d", &tmpInt); tform[tmpInt-1] = (char *) strdup(keywordValue); } else if (!strncmp(keyword, "TUNIT", 5)) { int tmpInt; sscanf(keyword, "TUNIT%d", &tmpInt); tunit[tmpInt-1] = (char *) strdup(keywordValue); } else if (!strncmp(keyword, "EXTNAME", 7)) { strcpy(extName, keywordValue); } } free (entry); } kk++; } } cdf-to-fits/cdf-to-fits.c0000674000077000007660000023372210322750440015515 0ustar davidhcdf00000000000000/****************************************************************************** * * NSSDC/CDF Quick Start Test Program (INTERNAL interface/C). * * cdf-to-fits: convert native and non-native (FITS originated) CDF files to FITS. * * The data mapping of CDF files depends on their origin (FITS or native) * Native CDF files are always mapped to a FITS BINTABLE, with the caveat that * variant records force the output in multiple HDU for efficiency. Each * BINTABLE will have a different value for NAXIS2 (the number of rows). * The most common situation is one where is will result in two BINTABLEs, one * with NAXIS2 being 1 and the other with some non-1 number. * * Native CDF files have the following mappings: * * zVars are mapped to the columns in a BINTABLE * rVars are mapped to the columns in a BINTABLE (though is the old CDF format) * gAttr are mapped to keywords in the header of the BINTABLE (not pHDU) * vAttr are mapped to things describing the columns * * A non-native (FITS based) CDF can be recognized by the following * global attributes: * * FITS originating CDF files (i.e. converted with fits-to-cdf) are converted * to a multi-HDU FITS file with as much original structure as possible, i.e. * a one-to-one mapping with the original FITS HDU structure to the one this * program creates. * * * "Original_FITS_Filename" original filename * "Description" verbosities * "HDU_Type" IMAGE,ASCII_TBL,BINARY_TBL * "FITS_Header_Keywords" the cards from the fits header * "EXTNAME" the fits EXTNAME, if it has one * * * Code History: * pre 18-jun-2003: Initial version 1.0 - Mike Liu, Peter Teuben * 19-jun-2003: Version 2.0 merged code * * 21-May-2004: David Han, Fixed and added the following: * 1) Index for the 'comments' array was wrong (using totDM instead * of totDT) * 2) Global attribute with no entry used to create a blank keyword in * FITS. It now creates a keyword that is the same as the global * CDF attribute name. * 3) It now uses cdf_to_fits_mapping.h instead of fits_to_cdf_mapping.h. * 4) Added a logic to create placeholder keyword(s) from the * cdf_to_fits_mapping.dat file. * 5) If a CDF global attribute has multiple entries, only the first entry created * a keyword in the FITS file that is the same name as the CDF attribute name, * and the rest of the entries had blank keywords which is not correct. * All the entries now create FITS keywords that have the same CDF global * attribute name. For example, * * CDF global attribute name entry # entry value * ------------------------- ------- ----------- * MODS 1 Original version * 2 Modified by John, May 10, 2004 * * will be converted to * MODS = 'Original version' * MODS = 'Modified by John, May 10, 2004' * * Prior to this bug fix, it used to be * MODS = 'Original version' * = 'Modified by John, May 10, 2004' * * NOTE: if a keyword doesn't have a value (blank keyword), column 9 must not * contain "=". * * $Id: cdf-to-fits.c,v 1.16 2004/05/24 15:59:31 liu Exp $ * $Revision: 1.16 $ * ******************************************************************************/ static char *c2f_revision = "$Revision: 1.16 $"; static int cdf_fits = 20; /* Version encoded in the CDF-FITS keyword: */ /* 10 * major + minor */ #include #include #include #define CDFFITS #include "cdffits.h" #include "cdf_to_fits_mapping.h" #include "datatype_mapping.h" #if defined(vms) #include #define EXIT_SUCCESS_ SS$_NORMAL #define EXIT_FAILURE_ SS$_ABORT #else #define EXIT_SUCCESS_ 0 #define EXIT_FAILURE_ 1 #endif #define CDF_TYPES 14 #define MAX_FITSLEN 25 /* Max length of FITS datatype name */ #define MAX_CDFLEN 15 /* Max length of CDF datatype name */ #define MAX_TYPES 65 /* Number of predefined FITS datatypes */ #define MAX_REC_LENGTH 120 /* Max record length of MAPPING_FILE. */ #define MAX_FITS_KEYWORDS 200 /* Max # of FITS mapping keywords */ #define ELEN 24 /* EPOCH3 character length */ /****************************************************************************** * Macros/prototypes. ******************************************************************************/ void usage(void); void convert_ubytes(int n, char *data); int streq(char *a, char *b); void WriteKey(int, long, long, char *, void *, char *); void HandleOtherKeys(char *, char *, char *, int, void *, char *, int); void CreateHDUs(int, long, char **, char **, char **, long *, long *); void WriteID(void); void ModifyDupKey(char *, char *); void appendKey(char *, char *); void appendNumKey(char *, int); /*hid_t EpochFITSDataType PROTOARGs(()); */ void EquivCDFFITSDataTypes PROTOARGs((int)); /*int FindCDFMappingDataType PROTOARGs((hid_t)); */ char fits_dt[MAX_FITS_KEYWORDS][12]; char cdf_dt[MAX_FITS_KEYWORDS][CDF_ATTR_NAME_LEN]; char comments[MAX_FITS_KEYWORDS][70]; static fitsfile *fptr; static int fstatus; typedef struct gkey { char key[10]; int n; struct gkey *next; } gkey; static gkey *Gkeys = NULL; /****************************************************************************** program layout NG = number of global attributes (GATTR) NZ = number of Z variables (ZVARS) NV = number of variables (VATTR) native = (true or false) is it a native CDF file? block what is does ------ ------------ B-1: process command line options, display program title B-2: read (two) mapping files internally B-3: check fits file and open it for output big foreach CDF file loop starts: B-4: open CDF, get basic info, and allocate space for FITS tables B-5: NG > 0 write Gattr and prepare for non-native FITS B-6: native & NV > 0 B-7: native & NZ > 0 B-7a: special atttributes for fits columns B-7b: loop over all .. to gather info on the columns B-7c: create BINTABLE(s) layout, also writes ZVARn's B-7d: process dimensionality of columns (TDIM's) B-7e: get variable's other attribute entries. (TSCAL/BSCALE/...) B-8: NZ > 0: handle/write data scaling parameters B-9: native & NZ > 0 B-10: NZ > 0 write the data B-11: close CDF and free space end loop B-12: close FITS file, end program ******************************************************************************/ int main (int argC, char *argV[]) { CDFid id; CDFstatus status; int i, j, totDM = 0, totDT = 0; long startRec; Logical deleteOld = DEFAULTdelete; Logical noHeader = DEFAULTnoheader; Logical showMap = FALSE; char CDFpath[QOP_MAX_PARMs][DU_MAX_PATH_LEN+1], tFITSpath[DU_MAX_PATH_LEN+1]; char mapping[DU_MAX_PATH_LEN+1]; char oFile[DU_MAX_PATH_LEN+1]; int fitsDataType; int ii, jj, kk, ix; int parms = 0; int unitsNum; size_t bufferSize, strSize; long numAttrs, numGAttrs, numVAttrs, numZvars, dataType, numElems, maxEntry; long numEntries, scope, majority, maxRec, maxRecNum, numRecs, numDims; long phyValues, phySize, recNum, recAlloc, recVary; long dimSizes[CDF_MAX_DIMS], dimIndices[CDF_MAX_DIMS], dimIntervals[CDF_MAX_DIMS]; long dimVarys[CDF_MAX_DIMS], tDims[CDF_MAX_DIMS]; char DATATYPE_TOKEN[CDF_TYPES][12]; char tempS[MAX_REC_LENGTH]; long DATATYPE[CDF_TYPES]; double TZERO[CDF_TYPES], TSCALE[CDF_TYPES]; int BITPIX[CDF_TYPES]; char TFORM[CDF_TYPES][3]; char keyword[10], keywordValue[80], comment[80]; int keyDataType, keySize, keyNum; void *value = NULL; long ep_yr, ep_mo, ep_dy, ep_hr, ep_mn, ep_se; double ep_ms, ep_msX; char attrName[CDF_ATTR_NAME_LEN+1], newAttrName[CDF_ATTR_NAME_LEN+1]; char **varAttr = NULL; char colNumStr[5]; char tmpStr[201]; char floatFormat[20]; char varName[CDF_VAR_NAME_LEN]; char *ptr, rec[MAX_REC_LENGTH]; QOP *qop; Logical qopError = FALSE, foundMapping = FALSE, DEBUG = FALSE; static char *validQuals[] = { "help", "delete", "no-header", "show", "map", "debug", NULL }; static int optRequired[] = { FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, 0 }; FILE *inFile; Logical endExt = FALSE; Logical nativeCDF, firstEntry; /* fits things 'fitsfile *fptr' is now static global for local functions */ int hduType; int bitpix; int naxis, size, extend = -99; int addOne; long naxes[10], pcount = -99, gcount = -99; int extension; int conformation, whichHeader; /**************************************************************************** * B-1: Determine qualifiers/options/parameters from command line * and display the title of the program ****************************************************************************/ switch (argC) { case 1: usage(); return TRUE; default: qop = Qop (argC, argV, validQuals, optRequired); if (qop == NULL) return FALSE; /************************************************************************ * Check for `help' qualifier. ************************************************************************/ if (qop->qualEntered[HELPqual]) { usage(); cdf_FreeMemory (qop, FatalError); return TRUE; } /************************************************************************ * Check for 'delete' qualifier. ************************************************************************/ if (qop->qualEntered[DELETEqual]) { deleteOld = TRUE; } /************************************************************************ * Check for 'no-header' qualifier. ************************************************************************/ if (qop->qualEntered[NOHEADERqual]) { noHeader = TRUE; } /************************************************************************ * Check for 'mapping' file qualifier. TODO: fix this (see below) ************************************************************************/ if (qop->qualEntered[MAPqual]) { strcpyX (mapping, qop->qualOpt[MAPqual], DU_MAX_PATH_LEN); } else mapping[0] = 0; /************************************************************************ * Check for 'show' qualifier. ************************************************************************/ if (qop->qualEntered[SHOWqual]) { showMap = TRUE; } /************************************************************************ * Check for backdoor 'debug' qualifier. ************************************************************************/ if (qop->qualEntered[DEBUGqual]) { DEBUG = TRUE; } /************************************************************************ * Check for CDF path parameter(s). ************************************************************************/ if (qop->Nparms < 1) { if (!showMap) { DisplayError ("Missing parameter for FITS or CDF file(s)."); qopError = TRUE; } } else if (qop->Nparms == 1) { /* special case : only 1 cdf input file */ parms = 2; oFile[0] = 0; strcpyX (CDFpath[0], qop->parms[0], DU_MAX_PATH_LEN); } else { /* generic case: fits_out cdf_in_file(s) */ parms = qop->Nparms; strcpyX (oFile, qop->parms[0], DU_MAX_PATH_LEN); for (i = 1; i < qop->Nparms; i++) strcpyX (CDFpath[i-1], qop->parms[i], DU_MAX_PATH_LEN); } /************************************************************************ * Free QOP memory and check for an error. ************************************************************************/ cdf_FreeMemory (qop, FatalError); if (qopError) return FALSE; break; } /* argC */ if (!showMap) printf ("Converting CDF(s) to FITS...\nCVS Revision: %s\n",c2f_revision); /**************************************************************************** * B-2: Read mapping files. By default internally build, though can also be * be read from an external text file ****************************************************************************/ totDM = 0; if (mapping[0]) { inFile = fopen(mapping, "r"); if (inFile == NULL) { printf ("** Cannot open keywords mapping file: %s **\n", mapping); exit(1); } while (fgets(rec, MAX_REC_LENGTH, inFile) != NULL) { if (showMap) printf("%s",rec); if (rec[0] != '#' && rec[0] != ' ') { /* Not a comment */ rec[strlen(rec)-1] = '\0'; /* Remove the newline character. */ sscanf(rec, "%s %s", fits_dt[totDM], cdf_dt[totDM]); ptr = (char *) strstr(rec, "//"); if (ptr != NULL) { ptr += 3; strcpy (comments[totDM], ptr); } if (DEBUG) printf("fits:%s <===> cdf:%s\n", fits_dt[totDM],cdf_dt[totDM]); totDM++; } } fclose(inFile); } else { for (ii=0; fits_to_cdf_mapping[ii]; ii++) { strcpy(rec,fits_to_cdf_mapping[ii]); if (showMap) printf("%s\n",rec); if (rec[0] != '#' && rec[0] != ' ') { /* Not a comment */ if (totDM == MAX_FITS_KEYWORDS) { printf("Too many fits_to_cdf mappings. Can only handle %d\n", MAX_FITS_KEYWORDS); exit(1); } sscanf(rec, "%s %s", fits_dt[totDM], cdf_dt[totDM]); ptr = (char *) strstr(rec, "//"); if (ptr != NULL) { ptr += 3; strcpy (comments[totDM], ptr); } if (DEBUG) printf("fits_to_cdf_mapping fits= %s <===> cdf=%s\n", fits_dt[totDM], cdf_dt[totDM]); totDM++; } } /* for(ii) */ } if (showMap) exit(0); totDT = 0; for(ii=0; datatype_mapping[ii]; ii++) { strcpy(rec,datatype_mapping[ii]); if (rec[0] != '#' && rec[0] != ' ') { /* Not a comment. */ if (totDT == CDF_TYPES) { printf("Too many datatype mappings.. can only handle %d\n",CDF_TYPES); exit(1); } sscanf(rec, "%s %lf %lf %d %s", DATATYPE_TOKEN[totDT], &TZERO[totDT], &TSCALE[totDT], &BITPIX[totDT], TFORM[totDT]); DATATYPE[totDT] = WhichDataType(DATATYPE_TOKEN[totDT]); if (DEBUG) printf("datatype_mapping cdf: %-12s (%ld) <===> fits: %lF %lF %d %s\n", DATATYPE_TOKEN[ii], DATATYPE[ii], TZERO[ii], TSCALE[totDT], BITPIX[totDT], TFORM[totDT]); totDT++; } } /* for(ii) */ /************************************************************************** * B-3: Check the existence of the FITS file if "nodelete" is chosen. * then create the new FITS file, using the CFITSIO library **************************************************************************/ if (oFile[0] == 0) { /* FITS file name needs to be constructed */ char *cp = NULL; cp = strrchr(CDFpath[0], '/'); if (cp == NULL) cp = strrchr(CDFpath[0], '\\'); if (cp) { cp++; strcpy(tFITSpath, cp); } else { strcpy(tFITSpath, CDFpath[0]); } cp = strrchr(tFITSpath, '.'); if (cp) { cp++; strcpy(cp, "fits"); } else { strcat(tFITSpath, ".fits"); } } else { strcpyX (tmpStr, oFile, 0); MakeLowerString (tmpStr); if (strchr(tmpStr, '.') != NULL) strcpyX (tFITSpath, oFile, 0); else { strcpy (tFITSpath, oFile); strcat (tFITSpath, ".fits"); } } /* endExt = Trailer (tmpStr, ".fits"); if (!endExt) endExt = Trailer (tmpStr, ".fit"); if (!endExt) endExt = Trailer (tmpStr, ".fts"); */ /* if (!endExt) strcpyX (tFITSpath, oFile, 0); */ /* else strcpyX (tFITSpath, oFile, strlen(oFile) - 5); */ /* strcatX (tFITSpath, ".fits", DU_MAX_PATH_LEN); */ printf(" Output FITS=%s\n",tFITSpath); if ((inFile = fopen(tFITSpath, "r")) != NULL) { fclose (inFile); if (!deleteOld) { QuitFITS ("10.0 ", "** Cannot create FITS... as it already exists. **") ; } else /* Delete it. */ if (!DeleteFile (tFITSpath)) QuitFITS ("12.0H", "** Error deleting the FITS..."); } fptr = 0; fstatus = 0; fits_create_file(&fptr, tFITSpath, &fstatus); PrintFITSerror(fstatus, "1.0"); for (i = 0; i < 10; i++) naxes[i] = 0; /**************************************************************************** * A big loop processing each CDF ****************************************************************************/ for (i = 0; i < parms - 1; i++) { int group; char **ttype = NULL; /* fits column name */ char **tform = NULL; /* fits column type */ char **tunit = NULL; /* fits column unit */ char *extName = NULL; /* fits external name */ double *tzero = NULL; /* fits column tzero */ double *tscale = NULL; /* fits column tscale */ int *newNumDims = NULL; /* new numDims */ long **newDimSizes = NULL; /* new dimSizes */ long *tDataType = NULL; /* data type array */ long *tNumElems = NULL; /* numElements array */ long *attrNums = NULL; /* attribute num array */ long *recVarys = NULL; /* record variance array */ long *varMaxRec = NULL; /* var max record array */ char **varNames = NULL; /* variable names */ char **attrNames = NULL; /* attribute names */ long *hduGroup = NULL; /* HDU group */ int *varColumn = NULL; /* variable column in HDU*/ /************************************************************************** * B-4: Open CDF, aquire some basic info and allocate FITS table space **************************************************************************/ printf (" Process file no: %d CDF= %s\n", i+1, CDFpath[i]); id = OpenCDF(CDFpath[i]); GetCDFInfo(id, &majority, &numAttrs, &numGAttrs, &numVAttrs, &numZvars, &maxRecNum); if (DEBUG) { printf("<=== CDF: majority:%s Num of Max records: %ld \n", MajorityToken(majority), maxRecNum+1); printf(" Gattrs:%ld Vattrs:%ld Vars:%ld\n", numGAttrs, numVAttrs, numZvars); } #if 1 /* this hack is to get past testprog_hdu6.cdf */ if (numZvars == 0) { numZvars = 1; ttype = (char **) malloc(sizeof(char *)*numZvars); /* fits column name*/ tform = (char **) malloc(sizeof(char *)*numZvars); /* fits column type*/ tunit = (char **) malloc(sizeof(char *)*numZvars); /* fits column unit*/ tzero = (double *) malloc(sizeof(double)*numZvars); /* fits column tzero*/ tscale= (double *) malloc(sizeof(double)*numZvars); /* fits column tscale*/ newNumDims= (int *) malloc(sizeof(int)*numZvars); /* new numDims */ newDimSizes= (long **) malloc(sizeof(long *)*numZvars); /* new dimSizes*/ tDataType= (long *) malloc(sizeof(long)*numZvars); /* data type array*/ tNumElems= (long *) malloc(sizeof(long)*numZvars); /* numElements array*/ recVarys = (long *) malloc(sizeof(long)*numZvars); /* rec-variance array*/ varMaxRec = (long *) malloc(sizeof(long)*numZvars); /* rec-max array */ varNames = (char **) malloc(sizeof(char *)*numZvars); /* variable names */ hduGroup= (long *) malloc(sizeof(long)*numZvars); /* HDU group array*/ varColumn = (int *) malloc(sizeof(int)*numZvars); /* var column array*/ for (ii = 0; ii < numZvars; ii++) { tzero[ii] = 0.0; tscale[ii] = 1.0; tunit[ii] = (char *) strdup(""); } numZvars = 0; } #endif if (numZvars > 0) { ttype = (char **) malloc(sizeof(char *)*numZvars); /* fits column name*/ tform = (char **) malloc(sizeof(char *)*numZvars); /* fits column type*/ tunit = (char **) malloc(sizeof(char *)*numZvars); /* fits column unit*/ tzero = (double *) malloc(sizeof(double)*numZvars); /* fits column tzero*/ tscale= (double *) malloc(sizeof(double)*numZvars); /* fits column tscale*/ newNumDims= (int *) malloc(sizeof(int)*numZvars); /* new numDims */ newDimSizes= (long **) malloc(sizeof(long *)*numZvars); /* new dimSizes*/ tDataType= (long *) malloc(sizeof(long)*numZvars); /* data type array*/ tNumElems= (long *) malloc(sizeof(long)*numZvars); /* numElements array*/ recVarys = (long *) malloc(sizeof(long)*numZvars); /* rec-variance array*/ varMaxRec = (long *) malloc(sizeof(long)*numZvars); /* rec-max array */ varNames = (char **) malloc(sizeof(char *)*numZvars); /* variable names */ hduGroup= (long *) malloc(sizeof(long)*numZvars); /* HDU group array*/ varColumn = (int *) malloc(sizeof(int)*numZvars); /* var column array*/ for (ii = 0; ii < numZvars; ii++) { tzero[ii] = 0.0; tscale[ii] = 1.0; tunit[ii] = (char *) strdup(""); } group = GetVarsRecordNumbers(id, varNames, varMaxRec, hduGroup, varColumn); if (DEBUG) { printf(" Total group(s): %d\n", group); for (ii = 0; ii < numZvars; ii++) { printf(" varNames=%s varMax=%d HDU#=%d column=%d\n", varNames[ii], varMaxRec[ii], hduGroup[ii], varColumn[ii]); } } printf(" Columns: %d Rows: %d HDUgroups: %d; with rows [",numZvars, maxRecNum+1,group); for(jj=1; jj<=group; jj++) { for(ii=0; ii 0) */ /************************************************************************** * B-5: Process the global attributes. (keywords for the FITS header) * this is also the place where we decide if the CDF file is native * or FITS-non-native. **************************************************************************/ if (DEBUG) printf("<=== Total num of Global Attributes: %ld ===>\n", numGAttrs); if (numGAttrs == 0) { /* Must be a native CDF. Just create an FITS header*/ naxes[0] = 0; nativeCDF = TRUE; fits_write_imghdr(fptr, 8, 0, naxes, &fstatus); WriteID(); } else { /* Could be a native or non-native CDF. */ attrNums = (long *) malloc(sizeof(long) * numGAttrs); GetGlobalAttributeNumbers(id, numAttrs, attrNums); for (ii = 0; ii < numGAttrs; ii++) { /********************************************************************** * Acquire each global attribute's info. **********************************************************************/ GetGlobalAttributeInfo(id, attrNums[ii], attrName, &numEntries, &maxEntry); if (ii == 0) { if (streq(attrName, "Original_FITS_Filename")) nativeCDF = FALSE; /* A CDF converted from FITS-to-CDF program. */ else { nativeCDF = TRUE; /* A native CDF. */ naxes[0] = 0; if (i == 0) { /* very first CDF, first GATTR */ fits_write_imghdr(fptr, 8, 0, naxes, &fstatus); WriteID(); } } } if (!nativeCDF && streq(attrName, "FITS_Header_Keywords")) { char *extName1 = malloc(80); /****************************************************************** * Needs two passes for the non-native CDF. * The first pass is to collect the needed info to create the proper * header record. ******************************************************************/ FirstPass(id, attrNums[ii], numEntries, &conformation, &whichHeader, &extension, &bitpix, &naxis, naxes, &pcount, &gcount, &extend, ttype, tform, tunit, extName1); if (extension == IMAGE) { if (ii == 0) { if (gcount != -99) fits_write_grphdr(fptr, conformation, bitpix, naxis, naxes, pcount, gcount, extend, &fstatus); else fits_write_imghdr(fptr, bitpix, naxis, naxes, &fstatus); } else fits_create_img(fptr, bitpix, naxis, naxes, &fstatus); } else if (extension == BINTABLE) { fits_create_tbl(fptr, BINARY_TBL, 0, (int) numZvars, ttype, tform, tunit, extName1, &fstatus); } else if (extension == TABLE) { fits_create_tbl(fptr, ASCII_TBL, 0, (int) numZvars, ttype, tform, tunit, extName1, &fstatus); } else { printf("Extension %d not supported yet\n",extension); exit(1); } if (i==0) WriteID(); PrintFITSerror(fstatus, "1.5"); free (extName1); } /* !nativeCDF */ /********************************************************************** * For non-native CDF, only process the global attribute, with name * "FITS_Header_Keywords", and skip others. **********************************************************************/ if (!nativeCDF && !streq(attrName, "FITS_Header_Keywords")) continue; if (DEBUG) printf("Global attribute #%d: %s #_of_entries=%ld (%ld)\n", ii, attrName, numEntries, maxEntry); kk = 0; firstEntry = TRUE; /********************************************************************** * For non-native CDF, the second pass to add the remaining * fields to the header. **********************************************************************/ foundMapping = FALSE; strcpy(newAttrName, attrName); for (jj = 0; jj < totDM; jj++) { if (streq(attrName, cdf_dt[jj])) { /* Found the mapping. */ foundMapping = TRUE; strcpy(newAttrName, fits_dt[jj]); break; } } if (numEntries == 0) { /* No global attribute entry data */ if (foundMapping) strcpy(keyword, newAttrName); else /* strcpy(keyword, ""); */ strcpy(keyword, attrName); /* Bug fixed by David Han */ /* sprintf(comment, "GATTR[%d][%d]=%s (has no data)",ii+1,1,attrName); */ sprintf(comment, "%s (has no data)",attrName); fits_write_key_str(fptr, keyword, "", comment,&fstatus); } for (jj = 0; jj <= maxEntry; jj++) { /******************************************************************* * Acquire each global attribute entry's info. *******************************************************************/ status = GetGlobalAttributeEntryInfo(id, attrNums[ii], (long) jj, &dataType, &numElems); if (status == CDF_OK) { /* The entry exists. */ void *entry, *keywordValue; size = CDFelemSize(dataType) * numElems; entry = (void *) malloc ((size_t) size); if (dataType == CDF_CHAR || dataType == CDF_UCHAR) keywordValue = (void *) malloc ((size_t) size + 1); else keywordValue = (void *) malloc (25 * numElems); /***************************************************************** * Acquire a global attribute entry's data. *****************************************************************/ GetGlobalAttributeEntryData(id, attrNums[ii], (long) jj, entry); if (DEBUG) { printf(" entry: %ld ", jj); DumpAttributeEntry(dataType, numElems, entry); } if (streq(attrName, "FITS_Header_Keywords")) { /*************************************************************** * Acquire entry data from the "FITS_Header_Keywords" attribute. * This is a non-native CDF. ***************************************************************/ if (streq(entry, "END")) continue; if (value == NULL) value = (void *) malloc(80); *(char *)value = '\0'; ParseKeyword((char *)entry, numElems, keyword, keywordValue, comment, &keyDataType, &keyNum, &keySize, floatFormat, value); if (keySize > 0) { /* The keyword value is returned. */ if (DEBUG) DumpFITSCard(keyword, keywordValue, comment, keyNum, keyDataType, value, floatFormat); /*********************************************************** * Skip those keys that have already been processed in * FirstPass call. ***********************************************************/ if (SkipCard(keyword)) { kk++; continue; } if (CheckScaleZeroNull(keyword, keywordValue, comment, keyDataType, value, tscale, tzero)) continue; HandleOtherKeys(keyword, keywordValue, comment, keyDataType, value, floatFormat, keyNum); } else { /* No keyword value. A COMMENT, HISTORY or CONTINUE. */ if (DEBUG) { printf(" ** Keyword=%s ",keyword); if (strlen(comment) > 0) printf("COMMENT=%s\n",comment); else printf("\n"); } if (streq(keyword, "COMMENT") || streq(keyword, "comment")) { if (!streq(comment, "FITS (Flexible Image Transport System)") && !streq(comment, "and Astrophysics', volume 376, page 35")) fits_write_comment(fptr, comment, &fstatus); } else if (streq(keyword, "HISTORY") || streq(keyword, "history")) { fits_write_history(fptr, comment, &fstatus); } else if (streq(keyword, "CONTINUE") || streq(keyword, "continue")) { if (strlen(keywordValue) > 68) fits_write_key_longstr(fptr, keyword, keywordValue, comment, &fstatus); else fits_write_key_str(fptr, keyword, keywordValue, comment, &fstatus); } else /* A null value.*/ fits_write_key_null(fptr, keyword, comment, &fstatus); PrintFITSerror(fstatus, "2.0"); } } else { /* A global attribute entry from a native CDF. */ /* Convert the entry data into string. */ /*************************************************************** * Acquire entry data from a native CDF. ***************************************************************/ char *outString; if (dataType == CDF_CHAR || dataType == CDF_UCHAR) outString = (char *) malloc((size_t)numElems + 1); else outString = (char *) malloc(25 * numElems); /* Print the value of the entry data to 'outString' */ PrintData(entry, dataType, numElems, outString); strcpyX(keywordValue, outString, strlen(outString)); if (strlen(newAttrName) > 8) /* Show attribute name in comment */ /* sprintf(comment, "GATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ sprintf(comment, "%s",attrName); else if (foundMapping) { /* sprintf(comment, "GATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ sprintf(comment, "%s",attrName); } else comment[0] = (char) 0; /* sprintf(comment, "GATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ /* sprintf(comment, "%s",attrName); */ if (firstEntry) { /* Output the attribute name for the first */ char tmpKey[8]; int nr; strcpyX(tmpKey, newAttrName, 8); nr = FindGkey(tmpKey); if (nr == 0) strcpyX(keyword, newAttrName, 8); /* occurrence. */ else { appendNumKey(tmpKey, nr); strcpyX(keyword, tmpKey, 8); } firstEntry = FALSE; } else { /* Any following entries will have blanks as the */ /* strcpyX(keyword, " ", 8); */ comment[0] = (char) 0; } /* TODO: ?? comment and history are handled differently * from other attributes. */ if (streq(attrName, "COMMENT") || streq(attrName, "comment")) { fits_write_comment(fptr, (char *) outString, &fstatus); /* sprintf(comment, "GATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ /* sprintf(comment, "%s",attrName); */ /* fits_write_comment(fptr, comment, &fstatus); */ } else if (streq(attrName, "HISTORY") || streq(attrName, "history")) { fits_write_history(fptr, (char *) outString, &fstatus); /* sprintf(comment, "GATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ /* sprintf(comment, "%s",attrName); */ /* fits_write_comment(fptr, comment, &fstatus); */ } else { int ik = strlen(keywordValue); int ic = strlen(comment); /* int nr = FindGkey(keyword); if (nr > 0 && strlen(keyword) > 8) { if (nr < 10) sprintf(&keyword[7],"%d",nr); else if (nr < 100) sprintf(&keyword[6],"%d",nr); else if (nr < 1000) sprintf(&keyword[5],"%d",nr); } */ if (ik > 68) { int ir = ik - (ik / 68) * 68; if ((ir + ic ) <= 65 && (ic < 48)) { fits_write_key_longstr(fptr, keyword, keywordValue, comment, &fstatus); } else { fits_write_key_longstr(fptr, keyword, keywordValue, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } else { if ((ik + ic ) <= 65 && (ic < 48)) { fits_write_key_str(fptr, keyword, keywordValue, comment, &fstatus); } else { fits_write_key_str(fptr, keyword, keywordValue, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } } } /* native / non-native keyword */ kk++; free (entry); } /* status OK */ } /* for(jj) */ } /* for(ii) */ } /* (numGAttrs > 0) */ /************************************************************************** * Create placeholder attribute(s) - by David Han **************************************************************************/ for (jj = 0; jj < totDM; jj++) { if (strcmp(cdf_dt[jj], "*") == 0) /* placeholder indicator */ fits_write_key_str(fptr, fits_dt[jj], /* keyword */ comments[jj], /* keyword value */ "", /* comment */ &fstatus); } /************************************************************************** * B-6: Acquire variable attributes. **************************************************************************/ if (DEBUG) printf("<=== Total num of Variable Attributes=%ld ===>\n", numVAttrs); if (nativeCDF && numVAttrs > 0) { attrNums = (long *) malloc(sizeof(long) * numVAttrs); attrNames = (char **) malloc(sizeof(char *) * numVAttrs); for (ii = 0; ii < numVAttrs; ii++) attrNames[ii] = (char *) malloc((size_t) DU_MAX_PATH_LEN); /************************************************************************ * Acquire number of variable attributes, their attribute numbers and * variable names. ************************************************************************/ GetVarAttributes(id, numAttrs, attrNums, attrNames); if (DEBUG) for (ii = 0; ii < numVAttrs; ii++) printf(" Variable attribute #%d: name=%s\n", ii, attrNames[ii]); } /* if (nativeCDF && numVAttrs > 0) */ /************************************************************************** * B-7: process variables for native files **************************************************************************/ if (DEBUG) printf("<=== Total num of Variables=%ld (attribute entries) ===>\n", numZvars); if (nativeCDF && numZvars > 0) { /* * B-7a: Find special CDF attributes that have a meaning for FITS columns */ unitsNum = -1; for (ii = 0; ii < numVAttrs; ii++) { if (streq(attrNames[ii], "UNITS") || streq(attrNames[ii], "units")) { unitsNum = (int)attrNums[ii]; break; } } /* for(ii) */ /* * B-7b: Acquire each variable info and gather info for FITS columns */ for (ii = 0; ii < numZvars; ii++) { int jk; GetVarInfo(id, (long) ii, varName, &dataType, &numElems, &numDims, dimSizes, &recVary, &maxRec); if (DEBUG) printf("var(%d):%s (building the HDU(%d))\n", ii+1, varName, hduGroup[ii]+1); tDataType[ii] = dataType; tNumElems[ii] = numElems; recVarys[ii] = recVary; *(((int *)newNumDims)+ii) = (int) numDims; if (numDims > 0) newDimSizes[ii] = (long *) malloc(sizeof(long) * numDims); if (majority == ROW_MAJOR) { /* Switch row to column. */ for (jk = 0; jk < numDims; jk++) newDimSizes[ii][jk] = dimSizes[numDims-jk-1]; } else { for (jk = 0; jk < numDims; jk++) newDimSizes[ii][jk] = dimSizes[jk]; } /********************************************************************** * For a complex variable, identified by an attribute "IsComplexNum_", * the number of dimensions is deducted by one (1). **********************************************************************/ fitsDataType = -1; if (ComplexVariable(id, (long) ii, attrNames, attrNums, numVAttrs)) { *(((int *)newNumDims)+ii) = (int) numDims - 1; if (dataType == CDF_FLOAT || dataType == CDF_REAL4) fitsDataType = TCOMPLEX; else fitsDataType = TDBLCOMPLEX; } ttype[ii] = (char *) strdup(varName); for (jj = 0, size = 1; jj < *(((int *)newNumDims)+ii); jj++) size *= newDimSizes[ii][jj]; tform[ii] = (char *) malloc(32); for (jj = 0; jj < totDT; jj++) { if (dataType == DATATYPE[jj]) { tzero[ii] = TZERO[jj]; tscale[ii] = TSCALE[jj]; if (dataType == CDF_EPOCH) sprintf(tform[ii],"%d%s", size*ELEN, TFORM[jj]); else if (dataType == CDF_CHAR || dataType == CDF_UCHAR) sprintf(tform[ii],"%d%s%d", size*numElems, TFORM[jj], numElems); else if (dataType == CDF_FLOAT || dataType == CDF_REAL4 || dataType == CDF_DOUBLE || dataType == CDF_REAL8) { if (fitsDataType == -1) sprintf(tform[ii],"%d%s", size, TFORM[jj]); else { if (fitsDataType == TCOMPLEX) sprintf(tform[ii],"%dC", size); else sprintf(tform[ii],"%dM", size); } } else if (dataType == CDF_INT1 || dataType == CDF_BYTE) sprintf(tform[ii],"%dI", size); else sprintf(tform[ii],"%d%s", size, TFORM[jj]); break; } } /* for(jj) */ if (unitsNum > -1) { /******************************************************************** * Acquire variable attribute's, "UNITS", entry info, if it exists. ********************************************************************/ status = GetVarAttributeEntryInfo(id, (long) unitsNum, (long) ii, &dataType, &numElems); if (status == CDF_OK) { void *entry; size = CDFelemSize(dataType) * numElems; entry = malloc(size); GetVarAttributeEntryData(id, (long) unitsNum, (long) ii, entry); tunit[ii] = (char *) malloc(size+1); memcpy(tunit[ii], (char *) entry, size); *(((char *) tunit[ii])+size) = (char) 0; free (entry); } else { tunit[ii] = malloc(1); *((char *) tunit[ii]) = (char) 0; } } } /* for(ii) */ /************************************************************************ * B-7c: Create BINTABLE(s) layout for variables from a native CDF ************************************************************************/ CreateHDUs(group, numZvars, ttype, tform, tunit, hduGroup, varMaxRec); /************************************************************************ * B-7d: Write out the dimensionality of each column if it's greater than 0. ************************************************************************/ for (ii = 0; ii < numZvars; ii++) { if (*(((int *)newNumDims)+ii) > 0) { if (tDataType[ii] == CDF_CHAR || tDataType[ii] == CDF_UCHAR || tDataType[ii] == CDF_EPOCH) { int ya; int yb = *(((int *)newNumDims)+ii) + 1; long *yc = (long *) malloc(sizeof(long) * yb); for (ya = 0; ya < yb; ya++) { if (ya == 0) { if (tDataType[ii] != CDF_EPOCH) yc[0] = tNumElems[ii]; else yc[0] = ELEN; } else yc[ya] = newDimSizes[ii][ya-1]; } fits_movabs_hdu(fptr, (int) hduGroup[ii]+1, &hduType, &fstatus); fits_write_tdim(fptr, varColumn[ii], yb, yc, &fstatus); } else { fits_movabs_hdu(fptr, (int) hduGroup[ii]+1, &hduType, &fstatus); fits_write_tdim(fptr, varColumn[ii], *(((int *)newNumDims)+ii), newDimSizes[ii], &fstatus); } PrintFITSerror(fstatus, "4.0"); } } /* for(ii) */ /************************************************************************ * B-7e: Acquire each variable's other attribute entries. ************************************************************************/ for (ii = 0; ii < numZvars; ii++) { if (DEBUG) { GetVarInfo(id, (long) ii, varName, &dataType, &numElems, &numDims, dimSizes, &recVary, &maxRec); printf("var: %s (attribute entries)\n", varName); } for (jj = 0; jj < numVAttrs; jj++) { if (attrNums[jj] == unitsNum) continue; /* Skip processed UNITS. */ /******************************************************************** * Acquire each variable attribute entry info, if it exists. ********************************************************************/ status = GetVarAttributeEntryInfo(id, attrNums[jj], (long) ii, &dataType, &numElems); if (status == CDF_OK) { void *entry; size = CDFelemSize(dataType) * numElems; if (dataType == CDF_CHAR || dataType == CDF_UCHAR) size++; entry = (void *) malloc((size_t)size); foundMapping = FALSE; strcpy(newAttrName, attrNames[jj]); for (kk = 0; kk < totDM; kk++) { if (streq(attrNames[jj], cdf_dt[kk])) { /* Found the mapping.*/ foundMapping = TRUE; strcpy(newAttrName, fits_dt[kk]); break; } } GetVarAttributeEntryData(id, attrNums[jj], (long) ii, entry); if (DEBUG) { printf(" entry: (attribute:%s) ",attrNames[jj]); DumpAttributeEntry(dataType, numElems, entry); } if (tDataType[ii] == CDF_EPOCH && foundMapping && streq(newAttrName,"TDISP")) { free(entry); entry = strdup("A24"); /* ELEN */ } #if 0 /* (sort of) old style (see v1) */ /* sprintf(comment,"VATTR[%d][%d]=%s",ii+1,jj+1,newAttrName); */ sprintf(comment,"%s",newAttrName); #else /* new style, index them all (also does e.g. TDISP) */ sprintf(colNumStr, "%d", varColumn[ii]); if (ii < 9 ) colNumStr[1] = (char) 0; else if (ii < 98) colNumStr[2] = (char) 0; else if (ii < 998) colNumStr[3] = (char) 0; else if (ii < 9998) colNumStr[4] = (char) 0; strcatX(newAttrName, colNumStr, CDF_ATTR_NAME_LEN); if (streq(attrNames[jj], "DEPEND_") || streq(attrNames[jj], "LABL_PTR_")) { ModifyDupKey(attrNames[jj], newAttrName); strcatX(newAttrName, colNumStr, 8); } if (strlen(newAttrName) > 8) { /* sprintf(comment,"VATTR[%d][%d]=%s_%s",ii+1,jj+1,attrNames[jj],colNumStr); */ sprintf(comment, "%s(%s)", attrNames[jj], colNumStr); if (ii < 9 ) { newAttrName[7] = colNumStr[0]; } else if (ii < 98) { newAttrName[6] = colNumStr[0]; newAttrName[7] = colNumStr[1]; } else if (ii < 998) { newAttrName[5] = colNumStr[0]; newAttrName[6] = colNumStr[1]; newAttrName[7] = colNumStr[2]; } else if (ii < 9998) { newAttrName[4] = colNumStr[0]; newAttrName[5] = colNumStr[1]; newAttrName[6] = colNumStr[2]; newAttrName[7] = colNumStr[3]; } newAttrName[8] = (char) 0; } else if (foundMapping) /* sprintf(comment,"VATTR[%d][%d]=%s",ii+1,jj+1,attrName); */ sprintf(comment,"%s(%s)",attrNames[jj],colNumStr); else /* sprintf(comment,"VATTR[%d][%d]",ii+1,jj+1,attrNames[jj]); */ sprintf(comment,"%s(%s)",attrNames[jj],colNumStr); #endif WriteKey((int) hduGroup[ii], dataType, numElems, newAttrName, entry, comment); free (entry); } /* status OK */ } /* for(jj) */ } /* for(ii) */ } /* if (nativeCDF && numZvars > 0) */ /************************************************************************** * B-8: For native CDF, set the BSCALE/BZERO or TSCALE/TZERO for * unsigned 2 and 4 bytes intgers. * For non-native ... **************************************************************************/ if (numZvars > 0) { if (nativeCDF) { char forScale[9], forZero[9], tmpInd[5]; for (ii = 0; ii < numZvars; ii++) { if (tzero[ii] == 0.0 && tscale[ii] == 1.0) continue; strcpy(forScale, "TSCAL"); strcpy(forZero, "TZERO"); sprintf(tmpInd, "%d", varColumn[ii]); strcat(forScale, tmpInd); strcat(forZero, tmpInd); fits_movabs_hdu(fptr, (int) hduGroup[ii]+1, &hduType, &fstatus); fits_write_key(fptr, TDOUBLE, forScale, &tscale[ii], "TSCALE", &fstatus); fits_write_key(fptr, TDOUBLE, forZero, &tzero[ii], "TZERO", &fstatus); fits_set_tscale(fptr, varColumn[ii], tscale[ii], tzero[ii], &fstatus); PrintFITSerror(fstatus, "4.53"); } /* for(ii) */ } else { /* non-native CDF. */ for (ii = 0; ii < numZvars; ii++) { if (tzero[ii] == 0.0 && tscale[ii] == 1.0) continue; fits_set_tscale(fptr, ii+1, tscale[ii], tzero[ii], &fstatus); PrintFITSerror(fstatus, "4.55"); } /* for(ii) */ } /* native/non-native */ } /* if (numZvars > 0) */ /************************************************************************** * B-9: For native CDF, set the TNULLn for integer type data from the pad * value. * TODO: do we even have these? since we do multiHDU **************************************************************************/ if (nativeCDF && numZvars > 0) { long status; int dd; char forTNULL[9], tmpInd[5]; for (ii = 0; ii < numZvars; ii++) { if (tDataType[ii] == CDF_INT1 || tDataType[ii] == CDF_BYTE || tDataType[ii] == CDF_INT2 || tDataType[ii] == CDF_UINT2 || tDataType[ii] == CDF_INT4 || tDataType[ii] == CDF_UINT4 || tDataType[ii] == CDF_UINT1) { void *padValue = (void *) malloc(CDFelemSize(tDataType[ii])); status = GetVarPadValue(id, (long) ii, padValue); if (status == CDF_OK) { if (tDataType[ii] == CDF_INT1 || tDataType[ii] == CDF_BYTE) { dd = *(signed char *) padValue; if (dd < 0) dd = 0; } else if (tDataType[ii] == CDF_UINT1) dd = *(unsigned *) padValue; else if (tDataType[ii] == CDF_INT2) dd = *(short *) padValue; else if (tDataType[ii] == CDF_INT4) dd = *(int *) padValue; else if (tDataType[ii] == CDF_UINT2) dd = *(unsigned short *) padValue; else if (tDataType[ii] == CDF_UINT4) dd = *(unsigned int *) padValue; free (padValue); strcpy(forTNULL, "TNULL"); sprintf(tmpInd, "%d", varColumn[ii]); strcat(forTNULL, tmpInd); fits_movabs_hdu(fptr, (int) hduGroup[ii]+1, &hduType, &fstatus); fits_write_key(fptr, TINT, forTNULL, &dd, "Undefined value", &fstatus); PrintFITSerror(fstatus, "4.55"); } } } /* for(ii) */ } /* if (nativeCDF && numZvars > 0) */ /************************************************************************** * B-10: Acquire each variable's record data. (Fill to the FITS columns) **************************************************************************/ if (numZvars > 0) { int jk; long recAlloc; int typecode, fitsstatus; long repeat, width; int hduNum; if (DEBUG) printf("<=== Total num of Variables=%ld (variable records) ===>\n", numZvars); ix = 1; while (ix <= group) { if (nativeCDF) fits_movabs_hdu(fptr, (int) ix+1, &hduType, &fstatus); for (ii = 0; ii < numZvars; ii++) { if (nativeCDF) { if (hduGroup[ii] != ix ) continue; /******************************************************************** * Get variable's attribute entries. ********************************************************************/ foundMapping = FALSE; for (jj = 0; jj < numVAttrs; jj++) { for (kk = 0; kk < totDM; kk++) { if (streq(attrNames[jj], cdf_dt[kk])) { /* Found the mapping.*/ foundMapping = TRUE; /************************************************************** * Acquire variable attribute entry info, if it exists, for the * keyword field. **************************************************************/ status = GetVarAttributeEntryInfo(id, attrNums[jj], (long) ii, &dataType, &numElems); if (status == CDF_OK) { void *entry; size = CDFelemSize(dataType) * numElems; entry = malloc(size); /************************************************************ * Acquire a variable attribute's entry data. ************************************************************/ GetVarAttributeEntryData(id, attrNums[jj], (long) ii, entry); if (DEBUG) PrintData(entry, dataType, numElems, tempS); free (entry); break; } } } } } else /* non-native CDF. */ if (extension != IMAGE) typecode = GetFITSdataType(tform[ii]); /********************************************************************** * Acquire each variable's info. **********************************************************************/ GetVarInfo(id, (long) ii, varName, &dataType, &numElems, &numDims, dimSizes, &recVary, &maxRec); size = CDFelemSize(dataType) * numElems; phyValues = 1; if (numDims > 0) for (jk = 0; jk < numDims; jk++) phyValues *= dimSizes[jk]; phySize = phyValues * size; if (DEBUG) { printf("var=%s(%d) numDims=%ld",varName, ii, numDims); if (numDims > 0) { printf(":["); for (jk = 0; jk < numDims; jk++) { printf("%d",dimSizes[jk]); if (jk != (numDims-1)) printf(","); } printf("]"); } printf(" dataType=%s",DataTypeToken(dataType)); if (dataType == CDF_CHAR || dataType == CDF_UCHAR) printf("(%ld)",numElems); printf(" maxRecNum=%ld\n", maxRec); } if (maxRec < 0) continue; recNum = 0; startRec = 1; /********************************************************************* * Acquire record values. Try as many records as possible for a read. *********************************************************************/ while (recNum <= maxRec) { void *outData; recAlloc = maxRec - recNum + 1; while (TRUE) { /* Acquire a buffer as large as possible. */ size = recAlloc * phySize; outData = (void *) malloc(size); if (outData != NULL) break; else recAlloc = recAlloc / 2; /* Half the space request. */ } GetVarRecordData(id, (long) ii, recNum, recAlloc, numDims, dimSizes, outData); if (dataType == CDF_EPOCH) { /* Convert epoch in double to string. */ char **newTmp = malloc(sizeof(char *)); newTmp[0] = malloc(ELEN+1); for (jk = 0; jk < recAlloc; jk++) { for (jj = 0; jj < phyValues; jj++) { encodeEPOCH3(*(((double *)outData)+jk*phyValues+jj), newTmp[0]); fits_write_col(fptr, TSTRING, varColumn[ii], startRec, jj+1, 1, newTmp, &fstatus); } startRec++; } } else { /* For non-EPOCH data.... */ if (!nativeCDF && streq(varName, "Image")) { /* FITS image extension originally */ fits_write_img(fptr, ConvertCDFDataType(dataType), startRec, recAlloc * phyValues, outData, &fstatus); } else { /* other types of native/non-native CDF */ if (dataType == CDF_CHAR || dataType == CDF_UCHAR) { char **newTmp = malloc(phyValues*sizeof(char *)); for (jk = 0; jk < phyValues; jk++) newTmp[jk] = malloc(numElems); for (jj = 0; jj < recAlloc; jj++) { for (jk = 0; jk < phyValues; jk++) memcpy(newTmp[jk], ((char *)outData)+jj*numElems*phyValues+ jk*numElems, numElems); if (nativeCDF) fits_write_col(fptr, TSTRING, varColumn[ii], startRec, (long) 1, (long) phyValues, newTmp, &fstatus); else fits_write_col(fptr, TSTRING, ii+1, startRec, (long) 1, (long) phyValues, newTmp, &fstatus); startRec++; } } else if (dataType == CDF_INT1 || dataType == CDF_BYTE) { if (nativeCDF) { short *newOut; newOut = malloc(sizeof(short) * recAlloc * phyValues); if (newOut != NULL) { for (jk = 0; jk < recAlloc * phyValues; jk++) *(((short *)newOut)+jk) = (short) *(((signed char *) outData)+jk); fits_write_col(fptr, TSHORT, varColumn[ii], startRec, (long) 1, (long) recAlloc * phyValues, newOut, &fstatus); } else { int jl, jm; newOut = malloc(2); for (jk = 0; jk < recAlloc * phyValues; jk++) { *newOut = (short) *(((signed char *)outData)+jk); jl = startRec + jk / phyValues; jm = jk - jl * phyValues + 1; fits_write_col(fptr, TSHORT, varColumn[ii], (long) jl, (long) jm, (long) 1, newOut, &fstatus); } } } else { /* non-native CDF */ if (extension == IMAGE) fits_write_col(fptr, ConvertCDFDataType(dataType), ii+1, startRec, (long) 1, (long) recAlloc * phyValues, outData, &fstatus); else fits_write_col(fptr, typecode, ii+1, startRec, (long) 1, (long) recAlloc * phyValues, outData, &fstatus); } } else { /* other integer types or simple/complex float/double */ if (nativeCDF) { fits_write_col(fptr, ConvertCDFDataType(dataType), varColumn[ii], startRec, (long) 1, (long) recAlloc * phyValues, outData, &fstatus); } else { fits_write_col(fptr, ConvertCDFDataType(dataType), ii+1, startRec, (long) 1, (long) recAlloc * phyValues, outData, &fstatus); } } } PrintFITSerror(fstatus, "4.8"); startRec += recAlloc; } /* epoch/non-epoch */ if (DEBUG) printf(" Done a read/write %d record(s) (rec:%d to rec:%d)\n", recAlloc, recNum, (recNum+recAlloc-1)); recNum += recAlloc; /* a following read(s) are needed if records */ /* are still left. */ free (outData); } /* while (recNum <= maxRec) */ } /* for(ii) */ ix++; } /* (ix <= group) */ } /* if (numZvars > 0) */ /* * B-11: close the CDF file, and free any memory we allocated */ CloseCDF(id); if (numZvars > 0) { free (ttype); free (tform); free (tunit); free (tzero); free (tscale); free (newNumDims); free (newDimSizes); free (tDataType); free (tNumElems); free (recVarys); free (varMaxRec); free (varNames); free (hduGroup); free (varColumn); } if (numVAttrs > 0) { if (attrNums != NULL) free (attrNums); if (attrNames != NULL) free (attrNames); } FindGkey("END"); /* free memory */ } /* for (i) loop over all CDF's */ /* * B-12: close fits file, end program */ fits_close_file(fptr, &fstatus); PrintFITSerror(fstatus, "5.0"); return EXIT_SUCCESS_; } /* main() */ /****************************************************************************** * Check whether to skip the previously processed card. ******************************************************************************/ Logical SkipCard(char *keyWord) { if (streq(keyWord, "SIMPLE") || streq(keyWord, "XTENSION") || streq(keyWord, "BITPIX") || streq(keyWord, "NAXIS") || streq(keyWord, "PCOUNT") || streq(keyWord, "GCOUNT") || streq(keyWord, "EXTEND") || streq(keyWord, "TTYPE") || streq(keyWord, "TFORM") || streq(keyWord, "TUNIT") || streq(keyWord, "EXTNAME") || streq(keyWord, "TFIELDS")) return TRUE; else return FALSE; } /****************************************************************************** * Check whether this is a TSCALn/TZEROn/TNULLn card. ******************************************************************************/ Logical CheckScaleZeroNull(char *keyWord, char *keywordValue, char *comment, int keyDataType, void *value, double *tscale, double *tzero) { if (streq(keyWord, "TSCAL")) { int tmpInt; sscanf(keyWord, "TSCAL%d", &tmpInt); if (keyDataType == TINT32BIT) tscale[tmpInt-1] = (double) *(int *) value; else if (keyDataType == TFLOAT) tscale[tmpInt-1] = (double) *(float *) value; else if (keyDataType == TDOUBLE) tscale[tmpInt-1] = *(double *) value; fits_write_key(fptr, TDOUBLE, keyWord, &tscale[tmpInt-1], "TSCALE", &fstatus); return TRUE; } else if (streq(keyWord, "TZERO")) { int tmpInt; sscanf(keyWord, "TZERO%d", &tmpInt); if (keyDataType == TINT32BIT) tzero[tmpInt-1] = (double) *(int *) value; else if (keyDataType == TFLOAT) tzero[tmpInt-1] = (double) *(float *) value; else if (keyDataType == TDOUBLE) tzero[tmpInt-1] = *(double *) value; fits_write_key(fptr, TDOUBLE, keyWord, &tzero[tmpInt-1], "TZERO", &fstatus); return TRUE; } else if (streq(keyWord, "TNULL")) { if (keyDataType == TSTRING) fits_write_key(fptr, keyDataType, keyWord, keywordValue, comment, &fstatus); else fits_write_key(fptr, TINT, keyWord, value, comment, &fstatus); return TRUE; } return FALSE; } /****************************************************************************** * Handle other keywords that have not yet been processed. ******************************************************************************/ void HandleOtherKeys(char *keyWord, char *keywordValue, char *comment, int keyDataType, void *value, char *floatFormat, int keyNum) { if (keyDataType == TFLOAT || keyDataType == TDOUBLE) { /*********************************************************** * Check how the float/double value(s) should be keyed in * to the FITS file. ***********************************************************/ int len1, len2, num; char fl[3]; num = sscanf(floatFormat, "%%%d.%d%s", &len1, &len2, fl); if (keyNum == 1) { /* Single number key value */ if (fl[0] == 'F' || streq(fl, "lF")) { if (len2 <= 6) fits_write_key_fixflt(fptr, keyWord, *(float *)value, len2, comment, &fstatus); else fits_write_key_fixdbl(fptr, keyWord, *(double *)value, len2, comment, &fstatus); } else { /* fl == "E" || "lE" */ if (len2 <= 6) fits_write_key_flt(fptr, keyWord, *(float *)value, len2, comment, &fstatus); else fits_write_key_dbl(fptr, keyWord, *(double *)value, len2, comment, &fstatus); } } else { /* Multiple-number key values */ if (fl[0] == 'F' || streq(fl, "lF")) { if (len2 <= 6) fits_write_key_fixcmp(fptr, keyWord, value, len2, comment, &fstatus); else fits_write_key_fixdblcmp(fptr, keyWord, value, len2, comment, &fstatus); } else { if (len2 <= 6) fits_write_key_cmp(fptr, keyWord, value, len2, comment, &fstatus); else fits_write_key_dblcmp(fptr, keyWord, value, len2, comment, &fstatus); } } } else { if (strchr((char *)value, ',') != NULL) { char *tmpS = malloc(strlen(value)+3); tmpS[0] = '('; memcpy(tmpS+1, value, strlen(value)); tmpS[strlen(value)+1] = ')'; tmpS[strlen(value)+2] = '\0'; fits_write_key(fptr, keyDataType, keyWord, tmpS, comment, &fstatus); } else fits_write_key(fptr, keyDataType, keyWord, value, comment, &fstatus); } } /****************************************************************************** * Write the variable attribute entry to the HDU as a key. * TODO: there is a lot of code duplication in here from previous parsing, * see e.g. GATTR section ******************************************************************************/ void WriteKey(int hduNum, long dataType, long numElems, char *keyWord, void *entry, char *comment) { int hduType, fitsDataType; fits_movabs_hdu(fptr, (int) hduNum+1, &hduType, &fstatus); fitsDataType = ConvertCDFDataType(dataType); if (dataType == CDF_CHAR || dataType == CDF_UCHAR) { *(((char *)entry)+numElems) = '\0'; if (streq(keyWord, "COMMENT") || streq(keyWord, "comment") ) fits_write_comment(fptr, (char *) entry, &fstatus); else if (streq(keyWord, "HISTORY") || streq(keyWord, "history")) fits_write_history(fptr, (char *) entry, &fstatus); else { int ik = strlen((char *)entry); int ic = strlen(comment); if (ik > 68) { int ir = ik - (ik / 68) * 68; if ((ir + ic ) <= 65 && (ic < 48)) { fits_write_key_longstr(fptr, keyWord, (char *) entry, comment, &fstatus); } else { fits_write_key_longstr(fptr, keyWord, (char *) entry, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } else { if ((ik + ic ) <= 65 && (ic < 48)) { fits_write_key_str(fptr, keyWord, (char *) entry, comment, &fstatus); } else { fits_write_key_str(fptr, keyWord, (char *) entry, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } } } else if (dataType == CDF_EPOCH) { char tmp[ELEN+1]; encodeEPOCH3(*(double *)entry, tmp); fits_write_key(fptr, fitsDataType, keyWord, tmp, comment, &fstatus); } else { /* Number data type. */ if (numElems > 1) { int ik; int ic = strlen(comment); char *tmp = malloc(20 * numElems); PrintData(entry, dataType, numElems, tmp); ik = strlen(tmp); if (ik > 68) { int ir = ik - (ik / 68) * 68; if ((ir + ic ) <= 65 && (ic < 48)) { fits_write_key_longstr(fptr, keyWord, tmp, comment, &fstatus); } else { fits_write_key_longstr(fptr, keyWord, tmp, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } else { if ((ik + ic ) <= 65 && (ic < 48)) { fits_write_key_str(fptr, keyWord, tmp, comment, &fstatus); } else { fits_write_key_str(fptr, keyWord, tmp, "", &fstatus); fits_write_comment(fptr, comment, &fstatus); } } } else { fits_write_key(fptr, fitsDataType, keyWord, entry, comment, &fstatus); } } PrintFITSerror(fstatus, "6.0"); } /****************************************************************************** * Create FITS HDU(s), based on the number of groups, for variables from a * native CDF. ******************************************************************************/ void CreateHDUs(int groups, long numZvars, char **ttype, char **tform, char **tunit, long *hduGroup, long *varMaxRec) { int i, j, curGrp, numVars; long rows; char extName[80], keyword[9]; curGrp = 1; while (curGrp <= groups) { char **tmpType, **tmpForm, **tmpUnit; int *tmpzVar; j = 0; numVars = 0; for (i = 0; i < numZvars; i++) if (hduGroup[i] == curGrp) numVars++; tmpType = (char **) malloc(sizeof(char *) * numVars); tmpForm = (char **) malloc(sizeof(char *) * numVars); tmpUnit = (char **) malloc(sizeof(char *) * numVars); tmpzVar = (int *) malloc(sizeof(int) * numVars); sprintf(extName, "cdffits%d", curGrp); for (i = 0; i < numZvars; i++) { if (hduGroup[i] == curGrp) { tmpType[j] = (char *) strdup(ttype[i]); tmpForm[j] = (char *) strdup(tform[i]); tmpUnit[j] = (char *) strdup(tunit[i]); tmpzVar[j] = i+1; if (j == 0) rows = varMaxRec[i]; j++; } } fits_create_tbl(fptr, BINARY_TBL, rows, j, tmpType, tmpForm, tmpUnit, extName, &fstatus); PrintFITSerror(fstatus, "3.08"); #if 0 /* print out the ZVARn keyword -- probably not needed for most humans ? */ for (i=0; inext; while (f) { free(g); g = f; f = g->next; } Gkeys = NULL; return 0; } } if (*keyword == ' ') return 0; /* ignore blank keywords */ for (cp=keyword; *cp; cp++) if (islower(*cp)) *cp = toupper(*cp); if (Gkeys == NULL) { Gkeys = g = (gkey *) malloc(sizeof(gkey)); strcpy(g->key,keyword); g->n = 0; g->next = NULL; return 0; } for (g=Gkeys, n=0; ; g = g->next, n++) { if (streq(keyword,g->key)) { g->n++; return g->n; } if (g->next == NULL) break; } g->next = (gkey *) malloc(sizeof(gkey)); g = g->next; strcpy(g->key,keyword); g->n = 0; g->next = NULL; return 0; } /****************************************************************************** * This function compare two strings. ******************************************************************************/ int streq(char *a, char *b) { return !strncmp(a, b, strlen(b)); } /****************************************************************************** * This function converts a (signed) INT1 to a UINT1 array, such that * with TSCAL=1 TZERO=-128 the original INT1 values are recovered ******************************************************************************/ void convert_ubytes(int n, char *data) { while (n > 0) data[--n] ^= 0x80; } /****************************************************************************** * This function changes the keyword for an attribute so it will not duplicate. * It involves attributes starting with "DEPEND_" or "LABL_PTR_". * For "DEPEND_" case, it would change the keyword to the form of "DPxx_". * For "LABL_PTR_", it changes to "LPTxx_". ******************************************************************************/ void ModifyDupKey(char *attrName, char *keyword) { int ix; if (streq(attrName, "DEPEND_")) { sscanf(attrName, "DEPEND_%d", &ix); sprintf(keyword, "DP%02d_", ix); *(((char *) keyword)+5) = (char) 0; } else { sscanf(attrName, "LABL_PTR_%d", &ix); sprintf(keyword, "LPT%02d_", ix); *(((char *) keyword)+6) = (char) 0; } } /****************************************************************************** * This function appends an item to the keyword. It makes sure that the * appended keyword is less than 8 char long. Otherwise, the original keyword * is cut from the tail before the item is appended. ******************************************************************************/ void appendKey(char *srcKey, char *item) { int ik = strlen(srcKey); int ic = strlen(item); int ilen = ik + ic; if (ilen <= 8) { sprintf(&srcKey[ik], "%s", item); } else { if (ic < 10) sprintf(&srcKey[7],"%s",item); else if (ic < 100) sprintf(&srcKey[6],"%s",item); else if (ic < 1000) sprintf(&srcKey[5],"%s",item); } } /****************************************************************************** * This function appends an integer to the keyword. It makes sure that the * appended keyword is less than 8 char long. Otherwise, the original keyword * is cut from the tail before the integer is appended. ******************************************************************************/ void appendNumKey(char *srcKey, int item) { int ik = strlen(srcKey); int ic = 0; int ilen; if (item < 10) ic = 1; else if (item < 100) ic = 2; else if (item < 1000) ic = 3; ilen = ik + ic; if (ilen <= 8) { sprintf(&srcKey[ik], "%d", item); } else { if (ic == 1) sprintf(&srcKey[7],"%d",item); else if (ic == 2) sprintf(&srcKey[6],"%d",item); else if (ic == 3) sprintf(&srcKey[5],"%d",item); } } /****************************************************************************** * usage. ******************************************************************************/ void usage(void) { printf("\n"); printf("Usage: cdf-to-fits [-Options] or\n"); printf(" cdf-to-fits [-Options] \n"); printf("\n"); /* printf("%s\n",c2f_revision); */ /* printf("\n"); */ printf("Description:\n"); printf(" This program converts one or more native CDF files into a single FITS\n"); printf(" file with one (or possibly multiple) BINTABLE extensions\n"); printf(" All CDF files are assembled (in the order given on the command line)\n"); printf(" (FITS originating) non-native CDF files support a number of FITS extensions:\n"); printf(" IMAGE, TABLE and BINTABLE, though one has to be careful in what order the \n"); printf(" CDF files are given on the command line.\n"); printf("\n"); printf("Options:\n"); printf("-help Displays the help information.\n"); printf("-debug Show lots of debug info on contents of CDF file(s)\n"); printf("-delete Delete the FITS file if it already exists.\n"); printf("-map Use an alternate CDF<->FITS keyword mapping file.\n"); printf("-show Show the mapping file of FITS to/from CDF keywords.\n"); printf(" If the map option is provided ahead of the show option, the\n"); printf(" alternate mapping file is shown.\n"); printf("\n"); printf("Examples of usage:\n"); printf("1) cdf-to-fits a.cdf \n"); printf(" will convert a single 'a.cdf' into 'a.fits'. \n"); printf("2) cdf-to-fits my.fits a.cdf \n"); printf(" will convert a single 'a.cdf' into 'my.fits'. \n"); printf("3) cdf-to-fits a.fits a*.cdf \n"); printf(" will convert many 'a*.cdf' files into single (multiHDU) 'a.fits'. \n"); printf("4) cdf-to-fits -show > my.map\n"); printf(" vi my.map <-- add or delete mappings.\n"); printf(" cdf-to-fits -map my.map a.cdf\n"); printf(" will convert 'a.cdf' into 'a.fits' using the mapping\n"); printf(" information in the my.map file.\n\n"); } cdf-to-fits/cdf_to_fits_mapping.dat0000664000077000007660000000514710321536311017715 0ustar davidhcdf00000000000000#FITS CDF Comment #---- --- ------- EXTNAME EXTNAME // HDU extension name DATE File_Creation_Date // File creation date (but check the format) DATE-OBS Observation_Date // Observation date DATE_OBS Observation_Date_Time // Observation date & time (SOHO/FITS convention) TIME-OBS Observation_Time // Observation time OBSERVER PI_name // person/entity that acquired the data ORIGIN PI_Institution // Institution/org who created the FITS file AUTHOR Author // Person who compiled the metadata TELESCOP Telescope // Telescope INSTRUME Instrument // Instrument OBJECT Object_Observed // Name of the object observed REFERENC Reference // Reference where the data are published DATAMAX Maximum // Max value in the array (physical) DATAMIN Minimum // Min value in the array (physical) EQUINOX Equinox // Equinox in years for the celestial coordination CTYPE1 ctype1 // Name of the coordinate represented by axis 1 CTYPE2 ctype2 // Name of the coordinate represented by axis 2 CTYPE3 ctype3 // Name of the coordinate represented by axis 3 CRPIX1 crpx1 // Location of a reference point along axis 1 CRPIX2 crpx2 // Location of a reference point along axis 2 CRPIX3 crpx3 // Location of a reference point along axis 3 CRVAL1 crval1 // Value specified by CTYPE1 at CRPIX1 CRVAL2 crval2 // Value specified by CTYPE2 at CRPIX2 CRVAL3 crval3 // Value specified by CTYPE3 at CRPIX3 CDELT1 cdelt1 // Partial derivative specified by CTYPE1 at CRPIX1 CDELT2 cdelt2 // Partial derivative specified by CTYPE2 at CRPIX2 CDELT3 cdelt3 // Partial derivative specified by CTYPE3 at CRPIX3 CROTA1 crota1 // Rotation from CTYPE1 to a diff coordinate system CROTA2 crota2 // Rotation from CTYPE2 to a diff coordinate system CROTA3 crota3 // Rotation from CTYPE3 to a diff coordinate system TDISP FORMAT // Display format for tables DMAX VALIDMAX // Max value in the array (physical) DMIN VALIDMIN // Min value in the array (physical) SMAX SCALEMAX // Max value for the scale SMIN SCALEMIN // Min value for the scale DPLS DELTA_PLUS_VAR // Uncertainty in (or range of) the variable's value DMIS DELTA_MINUS_VAR // Uncertainty in (or range of) the variable's value #PHOLDER1 * // Placeholder 1 value #PHOLDER2 * // Placeholder 2 value cdf-to-fits/configure0000775000077000007660000037046610053160762015152 0ustar davidhcdf00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. 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 ## --------------------- ## ## 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 # Support unset when possible. if (FOO=FOO; unset FOO) >/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 -n "`(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 as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="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="cdf-to-fits.c" 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 CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP CFITSIO_INC CFITSIO_LIB CDF_INC CDF_LIB SOCKET_LIB NSL_LIB LIBOBJS 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 Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _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] --enable-debug compile for debugging Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-cfitsio-prefix=PFX CFITSIO installation prefix (default: $cfdefault) --with-cdf-prefix=PFX Prefix where CDF codebase was installed (CDF_BASE) 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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` 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 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 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.57. 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.* *.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 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 #line $LINENO "configure" /* 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" >&5 echo $ECHO_N "checking for C compiler default output... $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 #line $LINENO "configure" /* 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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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; } 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>&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.$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>&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 \ ''\ '#include ' \ '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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include $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>&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.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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>&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.$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.$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 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 #line $LINENO "configure" /* 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 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 #line $LINENO "configure" /* 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 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 #line $LINENO "configure" /* 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 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 #line $LINENO "configure" /* 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 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 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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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 #line $LINENO "configure" /* 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 #line $LINENO "configure" /* 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.* *.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 for ac_func in strchr memcpy 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* 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 /* 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>&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.$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 # Use native cc if present echo "$as_me:$LINENO: checking for vendor's cc to be used instead of gcc" >&5 echo $ECHO_N "checking for vendor's cc to be used instead of gcc... $ECHO_C" >&6 # 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 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="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 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); } 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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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; } 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>&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.$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>&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 \ ''\ '#include ' \ '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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include $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>&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.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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>&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.$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.$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 #AC_PROG_INSTALL #AC_PROG_MAKE_SET #AC_PROG_RANLIB test "$program_prefix" != NONE && program_transform_name="s,^,$program_prefix,;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$,$program_suffix,;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" ok=$enableval else ok=no fi; if test "$ok" = "yes"; then CFLAGS="-g" LDFLAGS="-g" fi #AC_ARG_ENABLE(shared, [ --enable-shared use shared libs], ok=$enableval, ok=yes) #if test "$ok" = "yes"; then # SHARED="yes" #else # SHARED="no" #fi #echo "Using shared libraries? : $SHARED" echo "$as_me:$LINENO: checking whether we have CFITSIO" >&5 echo $ECHO_N "checking whether we have CFITSIO... $ECHO_C" >&6 if test -d "$CFITSIO_DIR"; then cfdefault="$CFITSIO_DIR" else cfdefault="/usr/local/" fi # Check whether --with-cfitsio-prefix or --without-cfitsio-prefix was given. if test "${with_cfitsio_prefix+set}" = set; then withval="$with_cfitsio_prefix" cfitsio_config_prefix="$withval" else cfitsio_config_prefix="use_default" fi; if test "$cfitsio_config_prefix" = "use_default"; then if test -n "$CFITSIO"; then cfitsio_config_prefix="$CFITSIO" else cfitsio_config_prefix="$cfdefault" fi fi if test x$cfitsio_config_prefix != x; then cdir="$cfitsio_config_prefix" for dir in $cdir/include $cdir/cfitsio $cdir/include/cfitsio $cdir do if test -f ${dir}/fitsio.h ; then CFITSIO_INC="${dir}" break; fi done if test -n "$CFITSIO_INC"; then for dir in $cdir/lib $cdir do if test -f ${dir}/libcfitsio.a ; then CFITSIO_LIB="${dir}" break; fi done fi if test -z "$CFITSIO_LIB"; then echo "$as_me:$LINENO: result: $cdir (invalid)" >&5 echo "${ECHO_T}$cdir (invalid)" >&6 if test -z "$CFITSIO_INC"; then who="header"; else who="library"; fi { { echo "$as_me:$LINENO: error: CFITSIO ${who} not found, please specify valid --with-cfitsio-prefix=DIR" >&5 echo "$as_me: error: CFITSIO ${who} not found, please specify valid --with-cfitsio-prefix=DIR" >&2;} { (exit 1); exit 1; }; } else echo "$as_me:$LINENO: result: ${cdir}" >&5 echo "${ECHO_T}${cdir}" >&6 # if test "$SHARED" = "yes"; then # CFITSIO_LIB="$CFITSIO_LIB" # else # CFITSIO_LIB="$CFITSIO_LIB" # fi fi fi echo "$as_me:$LINENO: checking whether we have CDF" >&5 echo $ECHO_N "checking whether we have CDF... $ECHO_C" >&6 if test -d "$CDF_BASE"; then cdf_default="$CDF_BASE" else cdf_default="/usr/local/cdf" fi # Check whether --with-cdf-prefix or --without-cdf-prefix was given. if test "${with_cdf_prefix+set}" = set; then withval="$with_cdf_prefix" cdf_config_prefix="$withval" else cdf_config_prefix="$cdf_default" fi; if test x$cdf_config_prefix != x; then cdir="$cdf_config_prefix" found="no" for dir in $cdir do if test -f ${dir}/include/cdf.h ; then CDF_INC="${dir}/include" echo "$as_me:$LINENO: result: inc1: $CDF_INC" >&5 echo "${ECHO_T}inc1: $CDF_INC" >&6 found="yes" break; elif test -f ${dir}/cdf/include/cdf.h ; then CDF_INC="${dir}/cdf/include" echo "$as_me:$LINENO: result: inc2: $CDF_INC" >&5 echo "${ECHO_T}inc2: $CDF_INC" >&6 found="yes" break; fi done for dir in $cdir do if test -f ${dir}/lib/libcdf.a ; then CDF_LIB="${dir}/lib" echo "$as_me:$LINENO: result: lib1: $CDF_LIB" >&5 echo "${ECHO_T}lib1: $CDF_LIB" >&6 found="yes" break; fi done if test "$found" = "no"; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 { { echo "$as_me:$LINENO: error: could not find CDF. please specify valid --with-cdf-prefix=DIR" >&5 echo "$as_me: error: could not find CDF. please specify valid --with-cdf-prefix=DIR" >&2;} { (exit 1); exit 1; }; } # else # if test "$SHARED" = "yes"; then # CDF_LIB="$CDF_LIB " # else # CDF_LIB="$CDF_LIB " # fi fi fi echo "$as_me:$LINENO: checking whether we have a separate socket" >&5 echo $ECHO_N "checking whether we have a separate socket... $ECHO_C" >&6 cdir="/usr" SOCKET_LIB="" found="no" if test -f ${cdir}/lib/libsocket.a ; then SOCKET_LIB="-lsocket" found="yes" elif test -f ${cdir}/lib/libsocket.a ; then SOCKET_LIB="-lsocket" found="yes" fi if test "$found" = "yes"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T} yes" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T} no" >&6 fi echo "$as_me:$LINENO: checking whether we have a separate nsl" >&5 echo $ECHO_N "checking whether we have a separate nsl... $ECHO_C" >&6 cdir="/usr" NSL_LIB="" found="no" if test -f ${cdir}/lib/libnsl.a ; then NSL_LIB="-lnsl" found="yes" elif test -f ${cdir}/local/lib/libnsl.a ; then NSL_LIB="-lnsl" found="yes" fi if test "$found" = "yes"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T} yes" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T} no" >&6 fi 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 # Support unset when possible. if (FOO=FOO; unset FOO) >/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 -n "`(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 as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="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.57. 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.57, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 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,@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,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@CFITSIO_INC@,$CFITSIO_INC,;t t s,@CFITSIO_LIB@,$CFITSIO_LIB,;t t s,@CDF_INC@,$CDF_INC,;t t s,@CDF_LIB@,$CDF_LIB,;t t s,@SOCKET_LIB@,$SOCKET_LIB,;t t s,@NSL_LIB@,$NSL_LIB,;t t s,@LIBOBJS@,$LIBOBJS,;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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` 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 cdf-to-fits/configure.in0000674000077000007660000001344210053160762015541 0ustar davidhcdf00000000000000dnl Process this file with autoconf to produce a new configure script if it has changed. dnl --------------------------------------------------------------------------------- AC_MSG_CHECKING([cdf2fits config]) AC_INIT(cdf-to-fits.c) dnl -- checks for programs dnl -- checks for libraries dnl -- checks for header files dnl -- checks for typedefs dnl -- checks for structures dnl -- checks for compiler characteristics dnl -- checks for library functions dnl -- checks for system services AC_HEADER_STDC AC_CHECK_FUNCS(strchr memcpy) dnl AC_PROG_CPP # Use native cc if present AC_MSG_CHECKING([for vendor's cc to be used instead of gcc]) AC_CHECK_PROG(CC, cc, cc) AC_PROG_CC #AC_PROG_INSTALL #AC_PROG_MAKE_SET #AC_PROG_RANLIB AC_ARG_PROGRAM AC_ARG_ENABLE(debug, [ --enable-debug compile for debugging], ok=$enableval, ok=no) if test "$ok" = "yes"; then CFLAGS="-g" LDFLAGS="-g" fi #AC_ARG_ENABLE(shared, [ --enable-shared use shared libs], ok=$enableval, ok=yes) #if test "$ok" = "yes"; then # SHARED="yes" #else # SHARED="no" #fi #echo "Using shared libraries? : $SHARED" dnl # -------------------------------------------------------------------------------- dnl Could also check FTOOLS_INCLUDE and/or FTOOLS_DIR for cfitsio.... dnl Note again, there are two ideas on where to store CFITSIO: dnl library in PREFIX/lib dnl header in PREFIX/include or PREFIX/include/cfitsio dnl This section also allows --with-cfitsio-prefix to point to the dnl source code tree, since that is where the *.a and *.h files live AC_MSG_CHECKING(whether we have CFITSIO) if test -d "$CFITSIO_DIR"; then cfdefault="$CFITSIO_DIR" else cfdefault="/usr/local/" fi AC_ARG_WITH(cfitsio-prefix, [ --with-cfitsio-prefix=PFX CFITSIO installation prefix (default: $cfdefault)], cfitsio_config_prefix="$withval", cfitsio_config_prefix="use_default") if test "$cfitsio_config_prefix" = "use_default"; then # if test -n "$CFITSIO"; then # cfitsio_config_prefix="$CFITSIO" # else cfitsio_config_prefix="$cfdefault" # fi fi if test x$cfitsio_config_prefix != x; then cdir="$cfitsio_config_prefix" for dir in $cdir/include $cdir/cfitsio $cdir/include/cfitsio $cdir do if test -f ${dir}/fitsio.h ; then CFITSIO_INC="${dir}" break; fi done if test -n "$CFITSIO_INC"; then for dir in $cdir/lib $cdir do if test -f ${dir}/libcfitsio.a ; then CFITSIO_LIB="${dir}" break; fi done fi if test -z "$CFITSIO_LIB"; then AC_MSG_RESULT($cdir (invalid)) if test -z "$CFITSIO_INC"; then who="header"; else who="library"; fi AC_MSG_ERROR([CFITSIO ${who} not found, please specify valid --with-cfitsio-prefix=DIR]) else AC_MSG_RESULT(${cdir}) # if test "$SHARED" = "yes"; then # CFITSIO_LIB="$CFITSIO_LIB" # else # CFITSIO_LIB="$CFITSIO_LIB" # fi fi fi AC_SUBST(CFITSIO_INC) AC_SUBST(CFITSIO_LIB) dnl # -------------------------------------------------------------------------------- AC_MSG_CHECKING(whether we have CDF) if test -d "$CDF_BASE"; then cdf_default="$CDF_BASE" else cdf_default="/usr/local/cdf" fi AC_ARG_WITH(cdf-prefix, [ --with-cdf-prefix=PFX Prefix where CDF codebase was installed (CDF_BASE)], cdf_config_prefix="$withval", cdf_config_prefix="$cdf_default") if test x$cdf_config_prefix != x; then cdir="$cdf_config_prefix" found="no" for dir in $cdir do if test -f ${dir}/include/cdf.h ; then CDF_INC="${dir}/include" AC_MSG_RESULT([inc1: $CDF_INC]) found="yes" break; elif test -f ${dir}/cdf/include/cdf.h ; then CDF_INC="${dir}/cdf/include" AC_MSG_RESULT([inc2: $CDF_INC]) found="yes" break; fi done for dir in $cdir do if test -f ${dir}/lib/libcdf.a ; then CDF_LIB="${dir}/lib" AC_MSG_RESULT([lib1: $CDF_LIB]) found="yes" break; fi done if test "$found" = "no"; then AC_MSG_RESULT(no) AC_MSG_ERROR([could not find CDF. please specify valid --with-cdf-prefix=DIR]) # else # if test "$SHARED" = "yes"; then # CDF_LIB="$CDF_LIB " # else # CDF_LIB="$CDF_LIB " # fi fi fi AC_SUBST(CDF_INC) AC_SUBST(CDF_LIB) dnl # -------------------------------------------------------------------------------- AC_MSG_CHECKING(whether we have a separate socket) cdir="/usr" SOCKET_LIB="" found="no" if test -f ${cdir}/lib/libsocket.a ; then SOCKET_LIB="-lsocket" found="yes" elif test -f ${cdir}/lib/libsocket.a ; then SOCKET_LIB="-lsocket" found="yes" fi if test "$found" = "yes"; then AC_MSG_RESULT([ yes]) else AC_MSG_RESULT([ no]) fi AC_SUBST(SOCKET_LIB) dnl # -------------------------------------------------------------------------------- AC_MSG_CHECKING(whether we have a separate nsl) cdir="/usr" NSL_LIB="" found="no" if test -f ${cdir}/lib/libnsl.a ; then NSL_LIB="-lnsl" found="yes" elif test -f ${cdir}/local/lib/libnsl.a ; then NSL_LIB="-lnsl" found="yes" fi if test "$found" = "yes"; then AC_MSG_RESULT([ yes]) else AC_MSG_RESULT([ no]) fi AC_SUBST(NSL_LIB) dnl # -------------------------------------------------------------------------------- AC_OUTPUT(Makefile) cdf-to-fits/datatype_mapping.dat0000664000077000007660000000143310321536311017237 0ustar davidhcdf00000000000000# CDF Data Type BZERO BSCALE BITPIX TFORM CDF_BYTE -128.0 1.0 8 B CDF_INT1 -128.0 1.0 8 B CDF_UINT1 0.0 1.0 8 B CDF_INT2 0.0 1.0 16 I CDF_UINT2 32768.0 1.0 16 I CDF_INT4 0.0 1.0 32 J CDF_UINT4 2147483648.0 1.0 32 J CDF_REAL4 0.0 1.0 -32 E CDF_FLOAT 0.0 1.0 -32 E CDF_REAL8 0.0 1.0 -64 D CDF_DOUBLE 0.0 1.0 -64 D CDF_CHAR 0.0 1.0 8 A CDF_UCHAR 0.0 1.0 8 A CDF_EPOCH 0.0 1.0 8 A24 cdf-to-fits/Dumpfunc.c0000674000077000007660000004175410322750440015161 0ustar davidhcdf00000000000000#include #include "cdf.h" #include "cdffits.h" /* #include "cdfdist.h" */ #include "fitsio.h" #define ROWMAJOR(rowMajor,val1,val2) ((rowMajor == ROW_MAJOR)? val1 : val2) void PrintData(void *, long, long, char *); /**************************************************************************** * Dump data from input buffer, based on its record number, row/column * majority, dimensionality and data type. The dimensional size is limited * to 5-D, for now. ****************************************************************************/ void DumpData(long recNum, long majority, long numDims, long *dimSizes, long dataType, long numElems, void *buffer) { int j0, j1, j2, j3, j4, j5, phyValues; long numBytes; size_t offset; numBytes = CDFelemSize(dataType); if (numDims == 0) { for (j0 = 0; j0 < recNum; j0++ ) { printf ("{"); PrintData((char *)buffer+(j0 * numBytes * numElems), dataType, numElems, NULL); printf ("}\n"); } } else if (numDims == 1) { phyValues = dimSizes[0]; for (j0 = 0; j0 < recNum; j0++ ) { printf ("{["); for (j1 = 0; j1 < dimSizes[0]; j1++ ) { offset = (phyValues * j0 + j1) * numBytes * numElems; PrintData((char *)buffer+offset, dataType, numElems, NULL); if (j1 != (dimSizes[0] - 1)) printf(","); } printf ("]}\n"); } } else if (numDims == 2) { phyValues = dimSizes[0] * dimSizes[1]; for (j0 = 0; j0 < recNum; j0++ ) { printf ("{"); for (j1 = 0; j1 < ROWMAJOR(majority,dimSizes[0],dimSizes[1]); j1++ ) { if (j1 == 0) printf("["); else printf(" ["); for (j2 = 0; j2 < ROWMAJOR(majority,dimSizes[1],dimSizes[0]); j2++ ) { offset = (phyValues * j0 + j1 * ROWMAJOR(majority,dimSizes[1],dimSizes[0]) + j2) * numBytes * numElems; PrintData((char *)buffer+offset, dataType, numElems, NULL); if (j2 != (ROWMAJOR(majority,dimSizes[1],dimSizes[0]) - 1)) printf(","); } printf("]"); if (j1 != (ROWMAJOR(majority,dimSizes[0],dimSizes[1]) - 1)) printf("\n"); } printf ("}\n"); } } else if (numDims == 3) { phyValues = dimSizes[0] * dimSizes[1] * dimSizes[2]; for (j0 = 0; j0 < recNum; j0++ ) { printf ("{"); for (j1 = 0; j1 < ROWMAJOR(majority,dimSizes[0],dimSizes[2]); j1++ ) { if (j1 == 0) printf("["); else printf(" ["); for (j2 = 0; j2 < dimSizes[1]; j2++ ) { if (j2 == 0) printf("["); else printf(" ["); for (j3 = 0; j3 < ROWMAJOR(majority,dimSizes[2],dimSizes[0]); j3++ ) { offset = (phyValues * j0 + j1 * ROWMAJOR(majority,dimSizes[1],dimSizes[1]) * ROWMAJOR(majority,dimSizes[2],dimSizes[0]) + j2 * ROWMAJOR(majority,dimSizes[2],dimSizes[0]) + j3) * numBytes * numElems; PrintData((char *)buffer+offset, dataType, numElems, NULL); if (j3 != (ROWMAJOR(majority,dimSizes[2],dimSizes[0]) - 1)) printf(","); } printf("]"); if (j2 != (ROWMAJOR(majority,dimSizes[1],dimSizes[1]) - 1)) printf("\n"); } printf("]"); if (j1 != (ROWMAJOR(majority,dimSizes[0],dimSizes[2]) - 1)) printf("\n"); } printf ("}\n"); } } else if (numDims == 4) { phyValues = dimSizes[0] * dimSizes[1] * dimSizes[2] * dimSizes[3]; for (j0 = 0; j0 < recNum; j0++ ) { printf ("{"); for (j1 = 0; j1 < ROWMAJOR(majority,dimSizes[0],dimSizes[3]); j1++ ) { if (j1 == 0) printf("["); else printf(" ["); for (j2 = 0; j2 < ROWMAJOR(majority,dimSizes[1],dimSizes[2]); j2++ ) { if (j2 == 0) printf("["); else printf(" ["); for (j3 = 0; j3 < ROWMAJOR(majority,dimSizes[2],dimSizes[1]); j3++ ) { if (j3 == 0) printf("["); else printf(" ["); for (j4 = 0; j4 < ROWMAJOR(majority,dimSizes[3],dimSizes[0]); j4++ ) { offset = (phyValues * j0 + j1 * ROWMAJOR(majority,dimSizes[1],dimSizes[2]) * ROWMAJOR(majority,dimSizes[2],dimSizes[1]) * ROWMAJOR(majority,dimSizes[3],dimSizes[0]) + j2 * ROWMAJOR(majority,dimSizes[2],dimSizes[1]) * ROWMAJOR(majority,dimSizes[3],dimSizes[0]) + j3 * ROWMAJOR(majority,dimSizes[3],dimSizes[0]) + j4) * numBytes * numElems; PrintData((char *)buffer+offset, dataType, numElems, NULL); if (j4 != (ROWMAJOR(majority,dimSizes[3],dimSizes[0]) - 1)) printf(","); } printf("]"); if (j3 != (ROWMAJOR(majority,dimSizes[2],dimSizes[1]) - 1)) printf("\n"); } printf("]"); if (j2 != (ROWMAJOR(majority,dimSizes[1],dimSizes[2]) - 1)) printf("\n"); } printf("]"); if (j1 != (ROWMAJOR(majority,dimSizes[0],dimSizes[3]) - 1)) printf("\n"); } printf ("}\n"); } } else if (numDims == 5) { phyValues = dimSizes[0] * dimSizes[1] * dimSizes[2] * dimSizes[3] * dimSizes[4]; for (j0 = 0; j0 < recNum; j0++ ) { printf ("{"); for (j1 = 0; j1 < ROWMAJOR(majority,dimSizes[0],dimSizes[4]); j1++ ) { if (j1 == 0) printf("["); else printf(" ["); for (j2 = 0; j2 < ROWMAJOR(majority,dimSizes[1],dimSizes[3]); j2++ ) { if (j2 == 0) printf("["); else printf(" ["); for (j3 = 0; j3 < ROWMAJOR(majority,dimSizes[2],dimSizes[2]); j3++ ) { if (j3 == 0) printf("["); else printf(" ["); for (j4 = 0; j4 < ROWMAJOR(majority,dimSizes[3],dimSizes[1]); j4++ ) { if (j4 == 0) printf("["); else printf(" ["); for (j5 = 0; j5 < ROWMAJOR(majority,dimSizes[4],dimSizes[0]); j5++ ) { offset = (phyValues * j0 + j1 * ROWMAJOR(majority,dimSizes[1],dimSizes[3]) * ROWMAJOR(majority,dimSizes[2],dimSizes[2]) * ROWMAJOR(majority,dimSizes[3],dimSizes[1]) * ROWMAJOR(majority,dimSizes[4],dimSizes[0]) + j2 * ROWMAJOR(majority,dimSizes[2],dimSizes[2]) * ROWMAJOR(majority,dimSizes[3],dimSizes[1]) * ROWMAJOR(majority,dimSizes[4],dimSizes[0]) + j3 * ROWMAJOR(majority,dimSizes[3],dimSizes[1]) * ROWMAJOR(majority,dimSizes[4],dimSizes[0]) + j4 * ROWMAJOR(majority,dimSizes[4],dimSizes[0]) + j5) * numBytes * numElems; PrintData((char *)buffer+offset, dataType, numElems, NULL); if (j5 != (ROWMAJOR(majority,dimSizes[4],dimSizes[0]) - 1)) printf(","); } printf("]"); if (j4 != (ROWMAJOR(majority,dimSizes[3],dimSizes[1]) - 1)) printf("\n"); } printf("]"); if (j3 != (ROWMAJOR(majority,dimSizes[2],dimSizes[2]) - 1)) printf("\n"); } printf("]"); if (j2 != (ROWMAJOR(majority,dimSizes[1],dimSizes[3]) - 1)) printf("\n"); } printf("]"); if (j1 != (ROWMAJOR(majority,dimSizes[0],dimSizes[4]) - 1)) printf("\n"); } printf ("}\n"); } } } /**************************************************************************** * Print one data value, based on its data type. ****************************************************************************/ void PrintData(void *binary, long dataType, long numElems, char *outString) { int ii; size_t len; char *tmp, *ePtr, tText[80+1]; switch (dataType) { case CDF_BYTE: case CDF_INT1: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%d", (int) *((sChar *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, "%d", (int) *((sChar *) binary+ii)); else sprintf (EofS(outString), "%d", (int) *((sChar *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_INT2: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%d", (int) *((Int16 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, "%d", (int) *((Int16 *) binary+ii)); else sprintf (EofS(outString), "%d", (int) *((Int16 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_INT4: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf (Int32FORMAT, *((Int32 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, Int32FORMAT, *((Int32 *) binary+ii)); else sprintf (EofS(outString), Int32FORMAT, *((Int32 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_UINT1: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%u", (uInt) *((uChar *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, "%u", (uInt) *((uChar *) binary+ii)); else sprintf (EofS(outString), "%u", (uInt) *((uChar *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_UINT2: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%u", (uInt) *((uInt16 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, "%u", (uInt) *((uInt16 *) binary+ii)); else sprintf (EofS(outString), "%u", (uInt) *((uInt16 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_UINT4: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf (Int32uFORMAT, *((uInt32 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, Int32uFORMAT, *((uInt32 *) binary+ii)); else sprintf (EofS(outString), Int32uFORMAT, *((uInt32 *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(EofS(outString), ","); } } break; case CDF_REAL4: case CDF_FLOAT: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%g", *((float *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf (outString, "%g", *((float *) binary+ii)); else sprintf (EofS(outString), "%g", *((float *) binary+ii)); if ((ePtr = (char *) strchr(outString,'e')) == NULL) { /* eg., 0 */ if ((char *) strchr(outString,'.') == NULL) strcatX (outString,".0", 0); } else { if ((char *) strchr(outString,'.') == NULL) { /* eg., 1e+07 */ len = (size_t) (ePtr - outString); strcpyX (tText, outString, MINIMUM(len,80)); strcatX (tText, ".0", 0); strcatX (tText, ePtr, 0); strcpyX (outString, tText, 0); } } if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_REAL8: case CDF_DOUBLE: for (ii = 0; ii < numElems; ii++) { if (outString == NULL) { printf ("%g", *((double *) binary+ii)); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf(outString, "%g",*((double *) binary+ii)); else sprintf(EofS(outString), "%g",*((double *) binary+ii)); if ((ePtr = (char *) strchr(outString,'e')) == NULL) { /* eg., 0 */ if ((char *) strchr(outString,'.') == NULL) strcatX (outString,".0", 0); } else { if ((char *) strchr(outString,'.') == NULL) { /* eg., 1e+07 */ len = (size_t) (ePtr - outString); strcpyX (tText, outString, MINIMUM(len,80)); strcatX (tText, ".0", 0); strcatX (tText, ePtr, 0); strcpyX (outString, tText, 0); } } if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; case CDF_CHAR: tmp = (char *) malloc(numElems + 1); memcpy(tmp, (char *) binary, numElems); tmp[numElems] = (char) 0; if (outString == NULL) printf ("%s", tmp); else sprintf (outString, "%s", tmp); break; case CDF_UCHAR: tmp = (char *) malloc(numElems + 1); memcpy(tmp, (uChar *) binary, numElems); tmp[numElems] = (char) 0; if (outString == NULL) printf ("%s", tmp); else sprintf (outString, "%s", tmp); /* printf ("%s", (uChar *) binary); */ break; case CDF_EPOCH: tmp = (char *) malloc(EPOCH3_STRING_LEN + 1); for (ii = 0; ii < numElems; ii++) { encodeEPOCH3(*((double *)binary+ii), tmp); if (outString == NULL) { printf("%s",tmp); if (numElems > 1 && ii != (numElems - 1)) printf(","); } else { if (ii == 0) sprintf(outString, "%s",tmp); else sprintf(EofS(outString), "%s",tmp); if (numElems > 1 && ii != (numElems - 1)) sprintf(EofS(outString), ","); } } break; } } /****************************************************************************** * DumpAttributeEntry. ******************************************************************************/ void DumpAttributeEntry(long dataType, long numElems, void *entry) { char *tmp; if (dataType == CDF_CHAR || dataType == CDF_UCHAR) tmp = malloc((size_t)numElems+1); else tmp = malloc((size_t) 25*numElems); printf("dataType=%s numElems=%ld ", DataTypeToken(dataType), numElems); if (dataType == CDF_CHAR || dataType == CDF_UCHAR) { memcpy(tmp, (char *) entry, (size_t)numElems); tmp[numElems] = (char ) 0; printf("data=%s\n", tmp); } else { PrintData(entry, dataType, numElems, tmp); printf("data= %s\n",tmp); } } /****************************************************************************** * DumpFITSCard. ******************************************************************************/ void DumpFITSCard(char *keyword, char *keywordValue, char *comment, int keyNum, int keyDataType, void *value, char *floatFormat) { int xx; printf(" ** Keyword=%s ",keyword); if (strlen(keywordValue) > 0) printf("KeywordValue=%s ",keywordValue); if (strlen(comment) > 0) printf("COMMENT=%s\n",comment); else printf("\n"); for (xx = 0; xx < keyNum; xx++) { if (keyDataType == TINT32BIT) printf(" ** KeywordValue (FITS) datatype=%d value=%d\n", keyDataType, *(int *) value+xx); else if (keyDataType == TLONG) printf(" ** KeywordValue (FITS) datatype=%d value=%ld\n", keyDataType, *(long *) value+xx); else if (keyDataType == TLOGICAL) printf(" ** KeywordValue (FITS) datatype=%d value=%d\n", keyDataType, *(int *) value+xx); else if (keyDataType == TFLOAT) { printf(" ** KeywordValue (FITS) datatype=%d value=", keyDataType); printf(floatFormat, *(((float *) value)+xx)); printf("\n"); } else if (keyDataType == TSTRING) { printf(" ** KeywordValue (FITS) datatype=%d value=", keyDataType); printf("%s\n", value); } else if (keyDataType == TDOUBLE) { printf(" ** KeywordValue (FITS) datatype=%d value=", keyDataType); printf(floatFormat, *(((double *) value)+xx)); printf("\n"); } } } cdf-to-fits/FITSmisc.c0000674000077000007660000000534010322750440015010 0ustar davidhcdf00000000000000/* * some handy FITS (cfitsio) utilities to make life easier * */ #include #include "fitsio.h" static int dryrun = 0; /* * fits_dryrun: */ void fits_dryrun(int d) { dryrun = d; } /* * fits_error: * print out cfitsio error messages and exit the program * this is basically the routine "printerror" from CFITSIO's * cookbook/speed test routines */ void fits_error( int status) { char status_str[FLEN_STATUS], errmsg[FLEN_ERRMSG]; if (status==0) return; /* 0=ok, no need to do more checking */ if (dryrun) { /* actually, dryrun doesn't really work yet, for now, we will abort() */ abort(); /* this should cause a coredump, which is nice for debuggers */ } fits_get_errstatus(status, status_str); /* get the error description */ fprintf(stderr,"fits_error: status = %d: %s\n", status, status_str); if ( fits_read_errmsg(errmsg) ) { /* get first message; null if stack is empty */ fprintf(stderr,"Error message stack:\n"); fprintf(stderr," %s\n", errmsg); while ( fits_read_errmsg(errmsg) ) /* get remaining messages */ fprintf(stderr," %s\n", errmsg); } exit(status); /* terminate the program, NEMO style, return error status to parent */ } /* * LITTLE_ENDIAN: return 1 if the machine is little endian, i.e. where the * bytes need to be swapped if meant for output to FITS */ int little_endian() { short int n = 1; char *ep = (char *)&n; return (*ep != 0); /* Returns 1 on a little endian machine */ } /* * BSWAP: swap bytes on some work level (normally 2,4,or 8) * * dat (in/out) pointer to the data * len (in) item length in bytes, this amount will be swapped * cnt (in) total number of data-items of length 'len' to be * swapped */ void bswap(void *vdat, int len, int cnt) { char tmp, *dat = (char *) vdat; int k; if (len==1) return; else if (len==2) while (cnt--) { tmp = dat[0]; dat[0] = dat[1]; dat[1] = tmp; dat += 2; } else if (len==4) while (cnt--) { tmp = dat[0]; dat[0] = dat[3]; dat[3] = tmp; tmp = dat[1]; dat[1] = dat[2]; dat[2] = tmp; dat += 4; } else if (len==8) while (cnt--) { tmp = dat[0]; dat[0] = dat[7]; dat[7] = tmp; tmp = dat[1]; dat[1] = dat[6]; dat[6] = tmp; tmp = dat[2]; dat[2] = dat[5]; dat[5] = tmp; tmp = dat[3]; dat[3] = dat[4]; dat[4] = tmp; dat += 8; } else { /* the general SLOOOOOOOOOWE case */ for(k=0; k --with-cfitsio-prefix= The '--with-cdf-prefix' and '--with-cfitsio-prefix' options can be replaced with the environment variables CDF_BASE and CFITSIO_DIR to represent the location of the CDF and FITS library, respectively. For example, if the CDF library is installed in /home/myaccount/cdf and the FITS library is installed in /home/myaccount/cfitsio, you can execute the 'configure' script by using one of the methods describe below. a) ./configure --with-cdf-prefix=/home/myaccount/cdf --with-cfitsio-prefix=/home/myaccount/cfitsio OR b) setenv CDF_BASE /home/myaccount/cdf setenv CFITSIO_DIR /home/myaccount/cfitsio ./configure 4) Build the cdf-to-fits program. make all 5) Install the cdf-to-fits program. The cdf-to-fits program can be installed under the user-specified directory or the 'bin' directory located under the current working directory. a) The following command installs the cdf-to-fits program at the user-specified directory: make INSTALL_DIR= install b) The following command creates a directory called 'bin' under the current working directory and installs the cdf-to-fits program into that 'bin' directory. make install 6) Go to the place where the cdf-to-fits program is installed and run the cdf-to-fits program without any arguments. By default it will give the inline help. cdf-to-fits CDF-to-FITS keyword mapping customization (optional) ==================================================== The default CDF-to-FITS mapping built into the cdf-to-fits program can be viewed by typing the following command: cdf-to-fits -show If the default mapping is inadequate or incorrect and needs to be changed/augmented for some reason, one can create its own mapping file and use that mapping information. The following command will create an mapping file called 'my_mapping.dat'. cdf-to-fits -show > my_mapping.dat Once the mapping file is created, it can be edited, using an ASCII text editor (e.g. vi, emacs, etc.), to change the existing mappings and/or to add/delete mapping information. The following command (-map option) tells the cdf-to-fits program to use the new mapping information just created (instead of the default mapping information): cdf-to-fits -map my_mapping.dat cdf-to-fits/INSTALL.developer0000674000077000007660000001210110053160762016234 0ustar davidhcdf00000000000000Executive summary: autoconf (only needed if the file 'configure' is absent) configure (you may need options here to direct it to find cdf and cfitsio libraries) make all (this should not need any command line options) INSTALLATION directions: ======================== Preconditions: - a C compiler, GNU make, autoconf (most linux distributions will come with these) (autoconf is only needed for developers, not for client installation) - cfitsio library: See also http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html The easiest is to install it inside the cdf2fits source tree, and type (the version number, 2460 here, may differ) cd wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio2460.tar.gz tar zxf cfitsio2460.tar.gz cd cfitsio ./configure make (takes about 70" on a P4/1600) setenv CFITSIO_DIR `pwd`/cfitsio However, if somebody has installed it for you in e.g. "/usr/local", that should work too. An enviroment variable $CFITSIO_DIR can also be used to keep track of the source code directory where cfitsio was compiled from. Both the library and include files live there. Notes: --includedir=DIR appears not to work (tested w/ version 2440) --prefix=PREFIX then dumps all the .h files in /usr/local/include (their bug: PREFIX must already exist, and the default is /usr/local) - cdf library: See also http://nssdc.gsfc.nasa.gov/cdf/cdf_home.html You actually need access to the source code, not the installed base, and for this you need to have the environment variable $CDF_BASE set to the root directory of cdf, e.g. Example of installation: cd wget ftp://nssdcftp.gsfc.nasa.gov/standards/cdf/dist/cdf27/unix/cdf27-dist-all.tar.gz tar zxf cdf27-dist-all.tar.gz cd cdf27-dist make OS=linux ENV=gnu all (takes about 23" on a P4/1600) make test setenv CDF_BASE `pwd`/cdf27-dist Notes: the following OS/ENV combinations have been tried: OS ENV ------ ----- linux gnu ok sunos gnu ok, but failed to compile CDF header sunos SysV failed Installation steps: 1) autoconf (only needed if the file 'configure' is absent) This will convert the configure.in file into a configure script. You need the GNU automake package installed for this. Normally an export release is made with the configure script, but the development (CVS based) code is not. If you run this and see some error messages like warning: AC_TRY_RUN called.... AC_PROG_CPP was called before AC_PROG_CC .. you have an oldish version of autoconf (--version), but my experience is that despite these warnings, configure will work. 2) ./configure [options] Normally configure will try and find cdf and cfitsio in a number of places. We also allow $CDF_BASE for 'cdf' and $CFITSIO_DIR for 'cfitsio' to set defaults for those two libraries. Examples of options: --enable-debug [optimized] --with-cdf-prefix=/home/cdf/cdf27-dist [/usr/local/cdf] --with-cfitsio-prefix=/home/cfitsio [/usr/local] Note that it is important (because of shared library useage) that the install path be given in an absolute sense, not relative to cdf2fits. 3) make all This will build all executables, currently cdf-to-fits and the companion fits-to-cdf program. 4) make check test pjt Runs a few checks to see if the system processes data. ===================== here are some helpful cut&paste lines for CVS users 1) setup for anonymous CVS (if you've done this earlier, no need to do it again) cvs -d :pserver:anonymous@cvs.astro.umd.edu:/home/cvsroot login 2) get the source code cvs -d :pserver:anonymous@cvs.astro.umd.edu:/home/cvsroot co cdf2fits cd cdf2fits 3) make sure CDF_BASE and CFITSIO_DIR are set to where CDF and CFITSIO compiled source code are present, e.g. for you setenv CDF_BASE /home/davidh/cdf27-dist setenv CFITSIO_DIR /home/davidh/fits/lib-and-tools/cfitsio 4) if the file configure does not exist, run autoconf to generate it. autoconf This step only applies to developers, and normally you don't need this if you are receiving a full version of cdf2fits 5) configure the code to locate and check libraries and features ./configure if it fails, you will need to read the INSTALL file and see what options are to be given, e.g. you could need ./configure --with-cdf-prefix=/home/cdf --with-cfitsio-prefix=/opt of course it probably means either the CDF_BASE or CFITSIO_DIR from step 3) was wrong to begin with... 6) compile the code (it actually compiles a few other things too) make all 7) see what the program says if no arguments are given (should give some usage/help screen) ./cdf-to-fits 8) convert the example CDF files to FITS files: make test ======= other notes: - the U and V types in CFITSIO are much better to handle UINT2 and UINT4 with. - the new version of CFITSIO is able to handle INT1's properly (i.e. wihtout resorting to INT2 and wasting space). For that a new 'S' was invented, and also makes my convert_ubytes() superfluous. cdf-to-fits/Makefile.in0000674000077000007660000000610610054372256015300 0ustar davidhcdf00000000000000# # Makefile for cdf-to-fits # INSTALL_DIR = `pwd` CC = @CC@ CFLAGS = @CFLAGS@ INCS = -I@CDF_INC@ -I@CFITSIO_INC@ CDFLIB = @CDF_LIB@/libcdf.a FITSLIB = @CFITSIO_LIB@/libcfitsio.a # on solaris, add: -lsocket -lnsl SYSLIBS = -lcdf -lcfitsio -lm -lc @SOCKET_LIB@ @NSL_LIB@ SYSLIBS-static = -lm -lc @SOCKET_LIB@ @NSL_LIB@ LIBS = -L@CDF_LIB@ -L@CFITSIO_LIB@ $(SYSLIBS) LIBS-static = $(CDFLIB) $(FITSLIB) $(SYSLIBS-static) # BINS = cdf-to-fits fits-to-cdf BINS = cdf-to-fits cdf-to-fits-static SRC = CDFfunc.c CDFmisc.c Dumpfunc.c FITSmisc.c OBJ = $(SRC:.c=.o) # INC = fits_to_cdf_mapping.h datatype_mapping.h INC = cdf_to_fits_mapping.h datatype_mapping.h DAT = datatype_mapping.dat fits_to_cdf_mapping.dat # this is a list of all the files that end-users do not see # their poor minds can handle the truth.... all: $(INC) $(OBJ) $(BINS) show: @echo INCS=$(INCS) @echo LIBS=$(LIBS) @echo BINS=$(BINS) @echo OBJ=$(OBJ) .c.o: $(CC) $(CFLAGS) -c $(INCS) $*.c .c: $(CC) $(CFLAGS) $(INCS) $*.c -o $* $(OBJ) $(LIBS) obj: $(OBJ) cdf-to-fits: cdf-to-fits.c $(OBJ) $(INC) $(CDFLIB) $(FITSLIB) $(CC) $(CFLAGS) $(INCS) -o cdf-to-fits cdf-to-fits.c $(OBJ) $(LIBS) cdf-to-fits-static: cdf-to-fits.c $(OBJ) $(INC) $(CDFLIB) $(FITSLIB) $(CC) $(CFLAGS) $(INCS) -o cdf-to-fits-static cdf-to-fits.c $(OBJ) $(LIBS-static) clean: rm -f $(BINS) *.o check: @echo No checking enabled yet dryrun: -cdf-to-fits > /dev/null Makefile: Makefile.in configure @if [ -f config.status ]; then \ @echo "Re-running config.status to regenerate Makefile"; \ ./config.status; \ else \ @echo "Beware: you probably need to re-run 'configure'"; \ fi # automated generation of the mapping include files # M1 = fits_to_cdf_mapping M1 = cdf_to_fits_mapping M2 = datatype_mapping $(M1).h: $(M1).dat @echo '/* this file was generated from $(M1).dat - do not edit */' > $(M1).h @echo 'static char *fits_to_cdf_mapping[] = {' >> $(M1).h @awk '{printf(" \"%s\",\n",$$0)}' $(M1).dat >> $(M1).h @echo ' NULL};' >> $(M1).h $(M2).h: $(M2).dat @echo '/* this file was generated from $(M2).dat - do not edit */' > $(M2).h @echo 'static char *datatype_mapping[] = {' >> $(M2).h @awk '{printf(" \"%s\",\n",$$0)}' $(M2).dat >> $(M2).h @echo ' NULL};' >> $(M2).h install: cdf-to-fits ifeq (${INSTALL_DIR}, `pwd`) @if [ ! -d ${INSTALL_DIR}/bin ]; then \ mkdir ${INSTALL_DIR}/bin; \ fi @if [ -f cdf-to-fits ]; then \ cp cdf-to-fits ${INSTALL_DIR}/bin; \ fi else @if [ ! -d ${INSTALL_DIR} ]; then \ mkdir ${INSTALL_DIR}; \ fi @if [ -f cdf-to-fits ]; then \ cp cdf-to-fits ${INSTALL_DIR}; \ fi endif DIST_DIR = cdf2fits-`cat VERSION` export: rm -rf $(DIST_DIR) mkdir $(DIST_DIR) cp *.c $(DIST_DIR) cp cdffits.h $(DIST_DIR) cp *.dat $(DIST_DIR) cp *.in $(DIST_DIR) cp VERSION $(DIST_DIR) cp INSTALL $(DIST_DIR) cp configure $(DIST_DIR) (cd $(DIST_DIR);\ autoconf;\ rm -rf autom4te.cache) tar cf $(DIST_DIR).tar $(DIST_DIR) cdf-to-fits/README0000674000077000007660000000410210053160762014101 0ustar davidhcdf00000000000000 For developers only: some notes and caveats on the cdf-to-fits converter - the B (INT1) type is converted to I (INT2) to deal with the sign bit. this is strictly not needed. See old code in testcdf2fits and the supporting routine in convert_uint() how to preserve the bit width in clever way of combining bit masking and FITS scaling TZERO/TSCAL - to roughly preserve the size of a CDF file with variant records, it is necessary to write out multiple HDU's, each with a different number (NAXIS2) of rows, corresponding to the entries (maxRec+1) in the CDF variable. - each extension is marked 'cdffitsN', where N is the N-th HDU (1 for the pHDU) - the cdf-to-fits dataformat version we use is stored in an integer keyword CDF-FITS, currently 20 (meaning 2.0) - the cdf-to-fits software version is encoded in a CVS string CDF2FITS, e.g. '$Id: cdf-to-fits.c v1.5 ....' - it's possible to screw up teh conversion logic for non-native CDF's by giving them in the wrong order, or not giving them all. We could enforce a template name and parse them all... A few words about performance: SNOE_l3_mag.cdf 38MB 1.260u 1.000s 0:08.90 25.3% GUVI_im_disk_v008r01_#D5297.L1B.cdf 48MB 1.990u 0.810s 0:20.72 13.5% TIDI_PB_2003077000200_200307707.cdf 182MB 53.240u 67.240s 11:59.76 16.7% The last file caused the load on the machine to reach over 4 Here are some conventions you should know about this current CDF-FITS convention. - all native CDF files are translated to a FITS BINTABLE. Because the zVars are not all filled to the same length, we opted for a multi-HDU output, where each BINTABLE contains the same number of rows (NAXIS2). - CDF-FITS file format version (20 currently) - CDF2FITS software version ID (the CVS id) - DATE when the file was written - ZVARnnn the original zVar number (>=1) from the CDF file (in each relevant HDU) - VATTRnnn a very loose list of all the info for the variable attributes (in each relevant HDU) - GATTRnnn a very loose list of all the info for the global var's (only in the pHDU) cdf-to-fits/VERSION0000674000077000007660000000000410053160762014266 0ustar davidhcdf000000000000001.0