/*  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 "hip_ep.h"  
#include "ihipep.h" 

main (int argc,char **argv)
{
   hip_ep anentry ;
   int headPrinted=0;

   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; 
	   
   	   checkIfCommandLineFlag(argv,argc,&i,&cols,&decode,&quite,&multiRecs);
	   if (cols==1 && headPrinted==0 && quite==0)
	   {
	      print_hip_ep_header ();
	      headPrinted=1;
	   }

	strAsINT( argv[i], &rec);
	if ((dataFile = search_hip_ep (&rec,&anentry)) != 0)
	{
	    for (recNo=0; recNo<=multiRecs; recNo++)
		{
		   if (cols)
	    	   {
	    	      
	    	      print_hip_ep_cols (&anentry, decode); 
	    	   }
	    	   else
	       	      print_hip_ep (&anentry, decode); 
	    	   if (read_hip_ep(dataFile,&anentry)!=0)
			break;
		}
	}

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

