1 /* 2 This file is part of "fitsverify" and was imported from: 3 http://heasarc.gsfc.nasa.gov/docs/software/ftools/fitsverify/ 4 */ 5 #ifndef _FVERIFY_H 6 #define _FVERIFY_H 7 8 #include <stdio.h> 9 #include <ctype.h> 10 #include <string.h> 11 #include <stdlib.h> 12 #include <math.h> 13 #include <limits.h> 14 #include "fitsio.h" 15 #define MAXERRORS 200 16 #define MAXWRNS 200 17 18 static char errmes[256]; 19 static char comm[256]; 20 extern int prhead; 21 extern int testdata; 22 extern int testfill; 23 extern int testcsum; 24 extern int totalhdu; /* total number of hdu */ 25 extern int err_report; 26 extern int heasarc_conv; 27 extern int prstat; 28 /******************************** 29 * * 30 * Keywords * 31 * * 32 ********************************/ 33 34 typedef enum { STR_KEY, /* string key */ 35 LOG_KEY, /* Logical key */ 36 INT_KEY, /* Integer key */ 37 FLT_KEY, /* Float key */ 38 CMI_KEY, /* Complex integer key */ 39 CMF_KEY, /* Complex float key */ 40 COM_KEY, /* history, comment, " ", and end */ 41 UNKNOWN /* Unknown types */ 42 } kwdtyp; 43 /* error number masks of the keyword test */ 44 #define BAD_STR 0X0001 45 #define NO_TRAIL_QUOTE 0X0002 46 #define BAD_NUM 0X0004 47 #define LOWCASE_EXPO 0X0008 48 #define NO_TRAIL_PAREN 0X0010 49 #define NO_COMMA 0X0020 50 #define TOO_MANY_COMMA 0X0040 51 #define BAD_REAL 0X0080 52 #define BAD_IMG 0X0100 53 #define BAD_LOGICAL 0x0200 54 #define NO_START_SLASH 0X0400 55 #define BAD_COMMENT 0x0800 56 #define UNKNOWN_TYPE 0x1000 57 58 /* keyword structure */ 59 typedef struct { 60 char kname[FLEN_KEYWORD]; /* fits keyword name */ 61 kwdtyp ktype; /* fits keyword type */ 62 char kvalue[FLEN_VALUE]; /* fits keyword name */ 63 int kindex; /* position at the header */ 64 int goodkey; /* good keyword flag (=1 good)*/ 65 }FitsKey; 66 int fits_parse_card(FILE *out, int pos, char *card, char *kname, kwdtyp *ktype, 67 char *kvalue, char *kcomm); 68 void get_str(char **p, char *kvalue, unsigned long *stat); 69 void get_log(char **p, char *kvalue, unsigned long *stat); 70 void get_num(char **p, char *kvalue, kwdtyp *ktype, unsigned long *stat); 71 void get_cmp(char **p, char *kvalue, kwdtyp *ktype, unsigned long *stat); 72 int check_str(FitsKey* pkey, FILE *out); 73 int check_int(FitsKey* pkey, FILE *out); 74 int check_flt(FitsKey* pkey, FILE *out); 75 int check_cmi(FitsKey* pkey, FILE *out); 76 int check_cmf(FitsKey* pkey, FILE *out); 77 int check_log(FitsKey* pkey, FILE *out); 78 int check_fixed_int(char *card, FILE *out); 79 int check_fixed_log(char *card, FILE *out); 80 int check_fixed_str(char *card, FILE *out); 81 82 void get_unknown(char **p, char *kvalue, kwdtyp *ktype, unsigned long *stat); 83 void get_comm(char **p, char *kcomm, unsigned long *stat); 84 void pr_kval_err(FILE *out, int pos, char *keyname, char *keyval, 85 unsigned long stat); 86 87 /******************************** 88 * * 89 * Headers * 90 * * 91 ********************************/ 92 typedef struct { 93 int hdutype; /* hdutype */ 94 int hdunum; /* hdunum */ 95 int isgroup; /* random group flag */ 96 int istilecompressed; /* tile compressed image */ 97 int gcount; /* gcount */ 98 int pcount; /* pcount */ 99 int bitpix; /* pix number */ 100 int naxis; /* number of the axis,used for image array*/ 101 LONGLONG *naxes; /* dimension of each axis,used for image array*/ 102 int ncols; /* number of the columns, used for image only*/ 103 char extname[FLEN_VALUE]; /* EXTENSION NAME */ 104 int extver; /* extension version */ 105 char **datamax; /* strings for the maximum of the data in a column */ 106 char **datamin; /* strings for the minimum of the data in a column */ 107 char **tnull; /* number of NULL values */ 108 int nkeys; /* number of keys */ 109 int tkeys; /* total of the keys tested*/ 110 int heap; /* heap */ 111 FitsKey **kwds; /* keywords list starting from the 112 last NAXISn keyword. The array 113 is sorted in the ascending alphabetical 114 order of keyword names. The last keyword END 115 and commentary keywords are excluded. 116 The total number of element, tkey, is 117 nkeys - 4 - naxis - ncomm. */ 118 int use_longstr; /* flag indicates that the long string 119 convention is used */ 120 }FitsHdu; 121 122 typedef struct { 123 char * name; 124 int index; 125 }ColName; 126 127 void verify_fits(char *infile, FILE *out); 128 void leave_early (FILE* out); 129 void close_err(FILE* out); 130 void init_hdu(fitsfile *infits, FILE *out, int hdunum, int hdutype, 131 FitsHdu *hduptr); 132 void test_hdu(fitsfile *infits, FILE *out, FitsHdu *hduptr); 133 void test_ext(fitsfile *infits, FILE *out, FitsHdu *hduptr); 134 void test_tbl(fitsfile *infits, FILE *out, FitsHdu *hduptr); 135 void test_array(fitsfile *infits, FILE *out, FitsHdu *hduptr); 136 void test_prm(fitsfile *infits, FILE *out, FitsHdu *hduptr); 137 void test_img_ext(fitsfile *infits, FILE *out, FitsHdu *hduptr); 138 void test_asc_ext(fitsfile *infits, FILE *out, FitsHdu *hduptr); 139 void test_bin_ext(fitsfile *infits, FILE *out, FitsHdu *hduptr); 140 void test_header(fitsfile *infits, FILE *out, FitsHdu *hduptr); 141 void key_match(char **strs, int nstr, char **pattern, int exact, 142 int *ikey, int *mkey); 143 void test_colnam(FILE *out, FitsHdu *hduptr); 144 void parse_vtform(fitsfile *infits, FILE *out, FitsHdu *hduptr, 145 int colnum, int *datacode, long *maxlen); 146 void print_title(FILE* out, int hdunum, int hdutype); 147 void print_header(FILE* out); 148 void print_summary(fitsfile *infits, FILE *out, FitsHdu *hduptr); 149 void close_hdu(FitsHdu *hduptr); 150 151 152 /******************************** 153 * * 154 * Data * 155 * * 156 ********************************/ 157 158 void test_data(fitsfile *infits, FILE *out, FitsHdu *hduptr); 159 void test_agap(fitsfile *infits, FILE *out, FitsHdu *hduptr); 160 void test_checksum(fitsfile *infits, FILE *out); 161 int iterdata(long totaln, long offset, long firstn, long nrows, 162 int narrays, iteratorCol *iter_col, void *usrdata); 163 /******************************** 164 * * 165 * Files * 166 * * 167 ********************************/ 168 typedef struct { 169 int hdutype; /* hdutype */ 170 int hdunum; /* hdunum */ 171 char extname[FLEN_VALUE]; /* extension name, used for extension*/ 172 int extver; /* extension version, used for extension */ 173 int errnum; /* number of errors in this hdu */ 174 int wrnno; /* number of warnning in this hdu */ 175 }HduName; 176 int get_total_warn(); 177 int get_total_err(); 178 void init_hduname(); 179 void set_hduname(int hdunum,int hdutype, char* extname,int extver); 180 void set_hduerr(int hdunum); 181 void set_hdubasic(int hdunum,int hdutype); 182 int test_hduname(int hdunum1, int hdunum2); 183 void total_errors (int *totalerr, int * totalwrn); 184 void hdus_summary(FILE *out); 185 void destroy_hduname(); 186 void test_end(fitsfile *infits, FILE *out); 187 void init_report(FILE *out, char *rootnam); 188 void close_report(FILE *out); 189 void update_parfile(int numerr, int numwrn); 190 191 192 /******************************** 193 * * 194 * Miscellaneous * 195 * * 196 ********************************/ 197 void print_fmt(FILE *out, char *temp, int nprompt); 198 int wrtout (FILE *out,char *comm); 199 int wrterr (FILE *out,char *comm, int severity); 200 int wrtwrn (FILE *out,char *comm, int heasarc); 201 int wrtferr(FILE *out, char* mess, int *status, int severity); 202 int wrtserr(FILE *out, char* mess, int *status, int severity); 203 void wrtsep (FILE *out,char fill, char *title, int nchar); 204 void num_err_wrn(int *num_err, int *num_wrn); 205 void reset_err_wrn(); 206 int compkey (const void *key1, const void *key2); 207 int compcol (const void *col1, const void *col2); 208 int compcol (const void *col1, const void *col2); 209 int compstrp (const void *str1, const void *str2); 210 int compstre (const void *str1, const void *str2); 211 212 #endif 213