#ifndef  NBSREAD_H_SEEN  
#define  NBSREAD_H_SEEN
  
#ifdef __cplusplus

#ifdef  FLAG_MAIN_NBSREAD
#undef   EXTERN
#define  EXTERN 
#else
#undef   EXTERN
#define  EXTERN  extern
#endif

#else

#undef   EXTERN
#define  EXTERN 

#endif

#define NCOULMX ((int_4) (2))
#define NBFILMX ((int_4) (60))
#define NBSREAD_LSTR 512
#define NKILLMSMX 100

#include <stdio.h>
#include "randr48.h"
#include "fsvcache.h"

/* valeurs de control */
EXTERN DR48RandGen * RandGen;

EXTERN double GRAND2_KILL;

EXTERN FILE *dataccd;

EXTERN int_4 typsuivi;
EXTERN int_4 sztmi[NCOULMX], szmes[NCOULMX], szMXBYTE;

EXTERN int killms[NKILLMSMX],nkillms;
EXTERN int_4 nbccd,numccd,ccdnum;

EXTERN int_4 nbfil[NCOULMX],nbms[NCOULMX][NBFILMX],nms1fil[NCOULMX][NBFILMX],nbmsMX;
EXTERN SUIVIFIP *lunfil[NCOULMX][NBFILMX];
EXTERN char lunnam[NCOULMX][NBFILMX][NBSREAD_LSTR];

EXTERN int_4 nmes[NCOULMX],nmesure[NCOULMX];

EXTERN int_4 ietlim[NCOULMX],iet[NCOULMX],net[NCOULMX],netoiles,ietgen;

EXTERN int_4 OpenType;
EXTERN int_4 debug,idebug[4],nstdeb,ffprt;

EXTERN int NStId, NSelStId, FgSelSt, *StId1, *StId2;

EXTERN double Tfirst[NCOULMX], Tlast[NCOULMX], TFIRST, TLAST;

struct starcal_u {
  float Mag_B,Mag_R,Mag_V,Mag_I; /* magnitudes absolues Bj,Vj,Rc,Ic */
  float Rstar;                   /* rayon de l'etoile */
  int   Rtype;                   /* type d'etoile 0=indeter 1=SP 2=GR*/
};
typedef struct starcal_u STARCALU;

struct starcut_u {
  int Mag_B_cut;  float Mag_B_min,Mag_B_max;
  int Mag_V_cut;  float Mag_V_min,Mag_V_max;
  int Mag_R_cut;  float Mag_R_min,Mag_R_max;
  int Mag_I_cut;  float Mag_I_min,Mag_I_max;
  int Mag_BV_cut; float Mag_BV_min,Mag_BV_max;
  int Mag_BR_cut; float Mag_BR_min,Mag_BR_max;
  int Mag_VR_cut; float Mag_VR_min,Mag_VR_max;
  int Mag_RI_cut; float Mag_RI_min,Mag_RI_max;
  int Rstar_cut;  float Rstar_min,Rstar_max;
  int Rtype_cut;  int Rtype_min,Rtype_max;
};
typedef struct starcut_u STARCUTU;

EXTERN STARCALU            starcal;
EXTERN STARCUTU            starcut;
EXTERN GLOBINFO            globu;
EXTERN STARINFO            staru[NCOULMX];
EXTERN TIMEINFOU           *timeu[NCOULMX];
EXTERN MESUREU             *mesu[NCOULMX];
EXTERN int_4               *indexu[NCOULMX];
EXTERN unsigned short      *meslun[NCOULMX];
EXTERN double              *date[NCOULMX];
EXTERN float               *ampli[NCOULMX];
EXTERN void (*Calibration_Absolue)(float,float,STARCALU *, void*);
EXTERN void*  Calibration_Absolue_UParms;

#ifdef __cplusplus
extern "C" {
#endif
void UINIT(void);
void UDATCLEAN(int coul);
void UINITCCD(void);
void UEVT(void);
void UENDCCD(void);
void UEND(void);
int read_timeinfo(int ic,int imes,TIMEINFO *tim);
#ifdef __cplusplus
}
#endif

#endif
