/* 
** Minimum includes required to run cridcalc.c routines.
** 12-08-1999, I. Barg
*/

# if !defined(BOOL_)
# define BOOL_
enum Bool_ { False = 0, True = 1 };
typedef enum Bool_ Bool;
# endif


/*
** Map the IDL basic underlying structures (from basic_structs) to HSTIO
** C language structures for use with CALL_EXTERNAL.  
** NOTE:  It is important that the IDL structure definition and the 
** C structure definition match exactly.
*/

#define hdrlins   600
#define sizhdrlin  80
#define xdim  	  256
#define ydim 	  256
#define max_nreads 26		/* same as MAX_MAREADS (calnic_structs) */

/* Basic underlying structure(s) */
typedef struct { 
        short x_beg; 		/* beginning x-coordinate of section */
        short y_beg; 		/* beginning y-coordinate of section */
        short sx; 		/* size of x dimension of section */
        short sy;		/* size of y dimension of section */
} section_st;
typedef section_st DataSection;

typedef struct {
        short tot_nx;
        short tot_ny;
        short nx;
        short ny;
        short data[xdim][ydim];
} short2d_st;
typedef short2d_st ShortTwoDArray;

typedef struct { 
        short tot_nx;
        short tot_ny;
        short nx;
        short ny;
        float data[xdim][ydim];		/* should be float *data */
} float2d_st;
typedef float2d_st FloatTwoDArray;


typedef struct {
        IDL_STRING filename;	/* file name */
        IDL_STRING extname; 	/* FITS EXTNAME value */
        short extver; 		/* FITS EXTVER value */
        short hflag; 		/* flag indicating header need updating */
        short naxis1; 		/* FITS NAXIS1 value */
        short naxis2; 		/* FITS NAXIS2 value */
        short type; 		/* FITS data type */
        short options; 		/* I/O options */
} IOdesc_st;
typedef IOdesc_st IODesc;

typedef struct {
        IODesc iodesc;
        DataSection section;
        IDL_STRING hdr[hdrlins];
	FloatTwoDArray data;	        /* float2d_st */
} floathd_st;
typedef floathd_st FloatHdrData;

typedef struct {
	IODesc iodesc;
	DataSection section;
	IDL_STRING hdr[hdrlins];
	ShortTwoDArray data;		/* short2d_st */
} shorthd_st;
typedef shorthd_st ShortHdrData;


typedef FloatHdrData SciHdrData;
typedef FloatHdrData ErrHdrData;
typedef ShortHdrData DQHdrData;
typedef ShortHdrData SmplHdrData;
typedef FloatHdrData IntgHdrData;

typedef struct {
        IDL_STRING filename;
        short group_num;
        IDL_STRING globalhdr[hdrlins];
        SciHdrData sci;
        ErrHdrData err;
        DQHdrData dq;        
        SmplHdrData smpl;
        IntgHdrData intg;
} nicdat;
typedef nicdat SingleNicmosGroup;	/* NicmosGroup */

typedef struct {
        short ngroups;
        SingleNicmosGroup group[max_nreads];
} mngdat;
typedef mngdat MultiNicmosGroup;

/***End of IDL basic structs ***/

/* modified HSTIO index macros 
**
** The following macros simulate those in "/iraf/stsdas/lib/hstio.h". 
** Normal array indexing is used instead of pointer addressing because 
** of the use of fixed size arrays within IDL structures.  IDL CALL_EXTERNAL 
** requires that the "C" code match the IDL structure definition exactly.  
** Therefore, a macro that looked like:
**
** # define Pix(a,i,j)      (a).data[(j)*(a).tot_nx + (i)]
** # define DQPix(a,i,j)    (a).data[(j)*(a).tot_nx + (i)]
** # define DQSetPix(a,i,j,value) (a).data[(j)*(a).tot_nx + (i)] = (value)
**
** now use std subscript indexing as shown below.  This was done in order
** retain the use of the macros in the unmodified STSDAS "C" code.
** 
** [I. Barg, 01-06-2000] 
*/

# define Pix(a,i,j)      (a).data[i][j]
# define DQPix(a,i,j)    (a).data[i][j]
# define DQSetPix(a,i,j,value) (a).data[i][j] = (value)
