/*  Hipparcos ASCII CD-ROM load and search routines Release 1.1 June 1997
    William O'Mullane 
    Astrophysics Division, ESTEC, Noordwijk, The Netherlands. 
    See the readme.pdf file for more information */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "utils.h" 
 
#include "ihipva.h" 
#include "hip_va_1.h"
#include "hip_va_2.h"

main (int argc,char **argv)
{
   FILE* hip_va1fp;
   FILE* hip_va2fp;
   if (argc == 1) 
   { 
        fprintf (stderr,"You must pass a key value on the command line \n");
   }
   else /* some numbers on the command line */
   { 
	int i,decode=ASRAW,cols=0,quite=0;
	long multiRecs=0,recNo;
	FILE* dataFile;
	for (i=1; i<argc ; i++)
	{
	   INT rec; 
	   idx_hip_va *idxEntry;
   	   checkIfCommandLineFlag(argv,argc,&i,&cols,&decode,&quite,&multiRecs);
	   

	strAsINT( argv[i], &rec);
		if ( (idxEntry = find_idx_hip_va(&rec)) != NULL)
		{
		   if (idxEntry->ANNEX.value == 1)
		   {
			hip_va_1 arec;	
			hip_va1fp= jump_hip_va_1(idxEntry->RECNO.value);
			read_hip_va_1(hip_va1fp,&arec);
			if (cols)
			   print_hip_va_1_cols(&arec,decode);
		    	else
			   print_hip_va_1(&arec,decode);
	   	   }

		   if (idxEntry->ANNEX.value == 2)
		   {
			hip_va_2 arec;	
			hip_va2fp= jump_hip_va_2(idxEntry->RECNO.value);
			read_hip_va_2(hip_va2fp,&arec);
			if (cols)
			   print_hip_va_2_cols(&arec,decode);
		    	else
			   print_hip_va_2(&arec,decode);
	   	   }

		}

	   else
	      printf("%d not found\n",rec.value);
	}
   }
 
} /* End Main for idx_hip_va_test */

