# include <ohana.h>
# include <dvo.h>
# include <errno.h>
# include <time.h>
# include <ctype.h>
# include <stdlib.h>

/* config variables from very old versions - remove?
char ImageTemplate[256];
char DBServer[256];
*/

char ImstatFifo[256];
char PtolemyFifo[256];

char ImageDB[256];
char DetrendDB[256];
char PhotDB[256];
char TransDB[256];
char ImPhotDB[256];
char TempDB[256];
char LogFile[256];
char CONNECT[64];

int  NDetrendAltDB;
char **DetrendAltDB;

char PhotCodeFile[256];
char TempLogFile[256];
char FilterList[256];
char CameraConfig[256];
char RecipeFile[256];

char DateKeyword[64];
char DateMode[64];
char UTKeyword[64];
char MJDKeyword[64];
char JDKeyword[64];
char ExptimeKeyword[16];
char ImagetypeKeyword[16];
char CCDnumKeyword[16];
char FilterKeyword[16];
char AirmassKeyword[16];
char FocusKeyword[16];
char RotationKeyword[16];
char DettempKeyword[16];
char Teldata1Keyword[16];
char Teldata2Keyword[16];
char Teldata3Keyword[16];
char RADecDegKeyword[16];
char DECDecDegKeyword[16];
char RASexigKeyword[16];
char DECSexigKeyword[16];
char CameraKeyword[16];
char Camera[64];
char SeeingREFCCD[64];
double ARCSEC_PIXEL;

/* global vars used by camera info */
char **ccds, **ccdn;
int  Nccd;

/* global vars used by filter abstraction */
# define FILTER_ANY  -1 
# define FILTER_NONE 0
int NFILTER;
char **filtername;
char **filterhash;
int   *filternum;

int get_trange_arguments (int *argc, char **argv, unsigned long **Tstart, unsigned long **Tstop, int *ntimes);
int get_filter_arguments (int *argc, char **argv, int **Filt, int *Nfilt);

int parse_time (Header *header);
void sort (float *value, int N);
void dsort (double *value, int N);
void sortstr (char **S, int *X, int N);
void sortpair (int *X, int *Y, int N);

void ConfigCamera ();
int MatchCCDNameHeader (Header *header);
int MatchCCDName (char *ID);
void ConfigFilter ();
int MatchFilterList (char *line);
void ConfigInit (int *argc, char **argv);
void WarnConfig (char *config, char *key, char * mode, int N, void *var);
int WriteFIFO (char *filename, char *line);
double get_fwhm (char *filename);

void get_version (int argc, char **argv, char *version);
int set_db (char *filename);

void warn_scan (Header *header, char *field, char *format, int N, void *var);
int gfits_scan_nchar (Header *header, int size, char *field, int N,...);
void warn_scan_nchar (Header *header, int size, char *field, int N, void *var);

void clean_spaces (char *line);

/* where is this defined ?? */
char *basename (char *);
