#include <stdio.h>
#include <string.h>

#include "../include/mag_hskp.h"
#include "df.h"

void main(argc, argv)
int argc;
char *argv[];
{
  int32 hdf_fp;
  struct MagHskpSet testdata;
  int ii,retval;

  if (argc!=2)
    {
      printf("Usage: rd_hdf hdf_file\n");
      exit(1);
    }

  /* open hdf input file */

  if ((hdf_fp=Hopen(argv[1], DFACC_READ, 0))==FAIL)
    {
      fprintf(stderr, "Hopen: could not open hdf file\n");
      exit(-1);
    }
  Vstart(hdf_fp);

  init_rd_mag_hskp(hdf_fp, 0, "ACE HDF test");

  ii=0;
  while((retval= read_mag_hskp(&testdata,-1))!=-1) {
	  printf("sc clock = %8d\n", testdata.sctime);
	  printf("  %3x %3x %3x %3x %3x %3x %3x %3x %3x %3x %3x %3x %3x %3x\n",
	    testdata.st1a, testdata.st2a, testdata.st3,    testdata.st4, 
	    testdata.st5,  testdata.st6,  testdata.pctemp, testdata.cmon, 
	    testdata.hk1,  testdata.hk2,  testdata.hk3,    testdata.hk4,
	    testdata.hk5,  testdata.sync);
  }

  /* all done, close HDF file */

  close_rd_mag_hskp();
  fprintf(stderr,"VS detached \n");
  Vend(hdf_fp);
  fprintf(stderr,"VS ended \n");
  if (Hclose(hdf_fp)==FAIL)
    {
      fprintf(stderr, "Hclose: could not close hdf file\n");
      exit(-1);
    }
  fprintf(stderr,"file closed \n");
  

  exit(0);
}
    
