/*  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_dm_c.h"  
#include "ihipdmc.h" 

main (int argc,char **argv)
{
   array_hip_dm_c 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++)
	{
	   ccdm rec; 
	   
   	   checkIfCommandLineFlag(argv,argc,&i,&cols,&decode,&quite,&multiRecs);
	   

	   read_ccdm(argv[i],&rec);
	   if (! (rec.sign[0]=='+' || rec.sign[0]=='-')) 
	   {
	      fprintf(stderr,"CCDM identifier expected nnnnn[+-]nnnn\n");
	      exit(2);
	   }
	if ((dataFile = search_hip_dm_c (&rec,&anentry)) != 0)
	{
	    if (multiRecs > 1)
		{
		   printf("WARNING: +n option not supported for this program\n");
		}
		if (cols)
	    	   {
	    	      if (decode==ASRAW) decode=PRINTSUBRECS;
	    	      print_array_hip_dm_c_cols (&anentry, decode); 
	    	   }
	    	   else
	       	      print_array_hip_dm_c (&anentry, decode+ARRAYVERBOSE); 
	}

	   else
	      printf("%5d%s%4d not found\n",rec.left.value,rec.sign,rec.right.value);
	}
   }
 
} /* End Main for idx_hip_dm_c_test */

