Index: trunk/psLib/src/fits/psFits.h
===================================================================
--- trunk/psLib/src/fits/psFits.h	(revision 14877)
+++ trunk/psLib/src/fits/psFits.h	(revision 15179)
@@ -4,6 +4,6 @@
  * @author Robert DeSonia, MHPCC
  *
- * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-09-18 02:56:36 $
+ * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-10-03 21:27:21 $
  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  */
@@ -21,4 +21,6 @@
 #include "psMetadata.h"
 #include "psImage.h"
+
+#include "psErrorCodes.h"
 
 /** FITS HDU type.
@@ -49,15 +51,15 @@
  *
  */
-typedef struct
-{
-    fitsfile* fd;			///< the CFITSIO fits files handle.
-    bool writable;			///< Is the file writable?
-    char *extword;			///< user-specified word to name extensions (NULL implies EXTNAME)
-}
-psFits;
-
-/** FITS options object. */
-typedef struct
-{
+typedef struct {
+    fitsfile* fd;                       ///< the CFITSIO fits files handle.
+    bool writable;                      ///< Is the file writable?
+    char *extword;                      ///< user-specified word to name extensions (NULL implies EXTNAME)
+    struct {
+        bool compression;               ///< Honour compression convention, handling compressed images
+    } conventions;                      ///< Conventions to honour
+} psFits;
+
+/** FITS compression settings. */
+typedef struct {
     psFitsCompressionType type;         ///< type of compression
     psVector *tilesize;                 ///< vector defining compression tile size
@@ -65,6 +67,5 @@
     int scale;                          ///< hcompress scale
     int smooth;                         ///< hcompress smothing
-}
-psFitsOptions;
+} psFitsCompression;
 
 /** Opens a FITS file and allocates the associated psFits object.
@@ -84,9 +85,35 @@
 );
 
-/** Creates a new FITS options struct 
+
+/// Generate an error including the cfitsio error string
+#ifdef DOXYGEN
+psErrorCode psFitsError(
+    int status,                         ///< cfitsio status value
+    bool new,                           ///< new error?
+    const char *errorMsg,               ///< printf-style format of header line
+    ...                                 ///< any parameters required in format
+    );
+#else // ifdef DOXYGEN
+psErrorCode p_psFitsError(
+    const char* filename,               ///< file name
+    unsigned int lineno,                ///< line number in file
+    const char* func,                   ///< function name
+    int status,                         ///< cfitsio status value
+    bool new,                           ///< new error?
+    const char *errorMsg,               ///< printf-style format of header line
+    ...                                 ///< any parameters required in format
+    ) PS_ATTR_FORMAT(printf, 6, 7);
+#ifndef SWIG
+#define psFitsError(status,new,...) \
+      p_psFitsError(__FILE__,__LINE__,__func__,status,new,__VA_ARGS__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
+
+/** Creates a new FITS options struct
  *
  *  @return psFitsOptions or NULL on failure
  */
-psFitsOptions* psFitsOptionsAlloc(
+psFitsCompression* psFitsCompressionAlloc(
     psFitsCompressionType type,         ///< type of compression
     psVector *tilesize,                 ///< vector defining compression tile size
@@ -96,4 +123,9 @@
 );
 
+/// Return the FITS compression type specified by a string
+psFitsCompressionType psFitsCompressionTypeFromString(
+    const char *string                  ///< String with compression type
+    );
+
 /** Closes a FITS file.
  *
@@ -111,5 +143,5 @@
  */
 bool psFitsSetCompression(
-    psFits* fits,                       ///< psFits object to close
+    psFits* fits,                       ///< psFits object for which to set compression
     psFitsCompressionType type,         ///< type of compression
     psVector *tilesize,                 ///< vector defining compression tile size
@@ -119,11 +151,21 @@
 );
 
+/// Get the compression options for a file handle
+psFitsCompression *psFitsCompressionGet(
+    psFits* fits                        ///< psFits object for which to get compression
+);
+
+/// Get the compression type for a file handle
+psFitsCompressionType psFitsCompressionGetType(
+    psFits* fits                        ///< psFits object for which to get compression type
+    );
+
 /** Sets FITS write options
  *
  *  @return bool      TRUE if successfully configured, otherwise FALSE
  */
-bool psFitsSetOptions(
-    psFits* fits,                       ///< psFits object to close
-    psFitsOptions *opt                  ///< options object
+bool psFitsCompressionApply(
+    psFits* fits,                       ///< psFits object for which to set compression
+    psFitsCompression *compress         ///< options object
 );
 
@@ -146,6 +188,6 @@
 // a user-defined word in place of EXTNAME
 bool p_psFitsMoveExtName_UserKey(const psFits *fits,
-				 const char *extname,
-				 const char *extword);
+                                 const char *extname,
+                                 const char *extword);
 
 /** Moves the FITS HDU to the specified extension name.
@@ -261,4 +303,10 @@
                           );
 
+#define PS_ASSERT_FITS_NON_NULL(NAME, RVAL) \
+if (!(NAME) || !(NAME)->fd) { \
+    psError(PS_ERR_UNEXPECTED_NULL, true, "Error: FITS file pointer %s is NULL", #NAME); \
+    return RVAL; \
+}
+
 /// @}
 #endif // #ifndef PS_FITS_H
