/*
 * fitsTcl.h --
 *
 *          This header file describes the externally visible
 *          calls in the Tcl wrapping for Fitsio.
 *
 */

#ifndef FITSTCL
#define FITSTCL

#define FITSTCL_VERSION "2.5.1"
#define MAX_REGISTERED_COMMANDS 2
#define FITSTCL_MAJOR_VERSION  2
#define FITSTCL_MINOR_VERSION  5
#define FITSTCL_SERIAL         1

#define HAVE_WINNT_IGNORE_VOID
#include <tcl.h>
#undef HAVE_WINNT_IGNORE_VOID

/* Check, if Tcl version supports Tcl_Size,
   which was introduced in Tcl 8.7 and 9.
*/
#ifndef TCL_SIZE_MAX
    #include <limits.h>
    #define TCL_SIZE_MAX INT_MAX

    #ifndef Tcl_Size
        typedef int Tcl_Size;
    #endif

    #define TCL_SIZE_MODIFIER ""
    #define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
    #define Tcl_NewSizeIntObj     Tcl_NewIntObj
#endif

/*  Sun4s do not support %p, so switch to %lx  */

#ifdef HEX_PTRFORMAT
#define PTRFORMAT "%lx"
#else
#define PTRFORMAT "%p"
#endif

extern DLLEXPORT void FitsTclDeleteTokens(Tcl_Interp *interp);
extern DLLEXPORT void FitsTclFreeTokensHashTable(void);
extern DLLEXPORT Tcl_Command * FitsTclInterpToTokens( Tcl_Interp *interp);
extern DLLEXPORT int  Fits_Init (Tcl_Interp *interp);
extern DLLEXPORT int  Fits_SafeInit (Tcl_Interp *interp);
extern DLLEXPORT int  FitsTcl_SafeUnload(Tcl_Interp *interp, int flags);
extern DLLEXPORT int  FitsTcl_Unload(Tcl_Interp *interp, int flags);

extern DLLEXPORT int  Fits_MainCommand (ClientData clientData,  
			      Tcl_Interp *interp, int argc,
			      Tcl_Obj *const argv[]);

extern DLLEXPORT int  fitsDispatch (ClientData clientData,  
			  Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);

extern DLLEXPORT int  fitsLst2Ptr (ClientData clientData,  
			 Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
extern DLLEXPORT int  fitsPtr2Lst (ClientData clientData,  
			 Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
extern DLLEXPORT int  fitsExpr (ClientData clientData,  
		      Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);
extern DLLEXPORT int  fitsRange(ClientData clientData,
                      Tcl_Interp *interp, int argc, Tcl_Obj *const argv[]);



extern DLLEXPORT int  getMaxCmd (ClientData clientData,  
		       Tcl_Interp *interp, int argc, char *const argv[]);

extern DLLEXPORT int  getMinCmd (ClientData clientData,  
		       Tcl_Interp *interp, int argc, char *const argv[]);

extern DLLEXPORT int  isFitsCmd (ClientData clientData, 
		       Tcl_Interp *interp,
		       int argc,
		       char *const argv[]);

extern DLLEXPORT int  updateFirst (ClientData clientData, 
			 Tcl_Interp *interp,
			 int argc,
			 char *const argv[]);

extern DLLEXPORT int  dataBlockToVar (ClientData clientData, 
			    Tcl_Interp *interp,
			    int argc,
			    char *const argv[]);

extern DLLEXPORT int  setArray (ClientData clientData, 
		      Tcl_Interp *interp,
		      int argc,
		      char *const argv[]);

extern DLLEXPORT int  searchArray (ClientData clientData, 
			 Tcl_Interp *interp,
			 int argc,
			 char *const argv[]);

extern DLLEXPORT int  Table_calAbsXPos (ClientData clientData,
			      Tcl_Interp *interp,
			      int argc,
			      char *const argv[]);

extern DLLEXPORT int  Table_updateCell ( ClientData clientData,
			       Tcl_Interp *interp,
			       int argc,
                               Tcl_Obj *const argv[] );

#endif
