# include "fits.h"
int FT_UNSIGN_MODE;

/*********************** fits read header ***********************************/
int fits_read_Xheader (char *filename, Header *header, int N) {
  
  /* read header for extension number N */

  FILE *f;
  int j, Nmatrix, Nskip;
  Header theader;
  
  f = fopen (filename, "r");
  if (f == NULL) {
    header[0].buffer = NULL;
    return (FALSE);
  }

  Nskip = 0;
  for (j = -1; j < N; j++) {
    /* load data for this header */
    if (!fits_load_header (f, &theader)) {
      fclose (f);
      return (FALSE);
    }

    Nmatrix = fits_matrix_size (&theader);

    /* skip to next header */
    fseek (f, Nmatrix, SEEK_CUR);
    Nskip += (Nmatrix + theader.size);
    fits_free_header (&theader);
  }
  
  if (!fits_load_header (f, header)) {
    fclose (f);
    return (FALSE);
  }
  fclose (f);
  Nskip += header[0].size;
  return (Nskip);
}	

