# include <ohana.h>
# include <gfitsio.h>
# define NBYTES 2880

/******************** fits create header ***********************************/
int gfits_create_header (Header *header) {

  int i;
  char axis[10];
  
  header[0].size = NBYTES;

  ALLOCATE (header[0].buffer, char, NBYTES);

  for (i = 0; i < NBYTES; i++) 
    header[0].buffer[i] = ' ';
  strncpy (header[0].buffer, "END", 3);

  gfits_modify (header, "SIMPLE", "%t", 1, header[0].simple);
  gfits_modify (header, "BITPIX", "%d", 1, header[0].bitpix);
  gfits_modify (header, "NAXIS",  "%d", 1, header[0].Naxes);
				       
  for (i = 0; i < header[0].Naxes; i++) {
    snprintf (axis, 10, "NAXIS%d", i + 1);
    gfits_modify (header,  axis, "%d", 1, header[0].Naxis[i]);
  }

  /* PCOUNT & GCOUNT are not implemented, but they are required to be here */
  gfits_modify (header, "PCOUNT", "%d", 1, 0);
  gfits_modify (header, "GCOUNT", "%d", 1, 1);
  gfits_modify (header, "BSCALE", "%lf", 1, header[0].bscale);
  gfits_modify (header, "BZERO",  "%lf", 1, header[0].bzero);
  gfits_modify (header, "EXTEND", "%t",  1, header[0].extend);
  return (TRUE);

}	


