
   /*
    * a little program to convert data in some simple ASCII multi-column
    * format from one equinox to another, without touching the other info.
    *
    * we expect input in ASCII text, with lines of the form
    *
    *      name   type    RA   Dec  mag period comments...
    *
    * and want to convert (RA, Dec), but leave other items alone
    *
    *    MWR 3/4/1997
    */
   
#include <stdio.h>
#include <math.h>

#define LINELEN 200


char *progname = "landolt";

main(int argc, char *argv[])
{
   int num_read;
   char line[LINELEN+1];
   char name[LINELEN+1];
   char type[LINELEN+1];
   char comments[LINELEN+1];
   double equinox;
   double ra, dec, newra, newdec;
   double u, b, v, r, i;
   double rah, ram, decd, decm;
   double mag, period;

   equinox = 1950.0;
   while (fgets(line, LINELEN, stdin) != NULL) {

      if (line[0] == '#') {
	 printf("%s", line);
	 continue;
      }
      
      sprintf(comments, " ");

      num_read = sscanf(line, "%s %s %lf %lf %lf %lf %s",
	    name, type, &ra, &dec, &mag, &period, comments);
      if (num_read != 7) {
	 if (num_read != 6) {
	    fprintf(stderr, "landolt: bad input line:\n%s\n", line);
	    exit(1);
	 }
	 else {
	    comments[0] = '\0';
	 }
      }

      to_j2000(equinox, ra, dec, &newra, &newdec);

      rah = floor(newra/15.0);
      ram = ((newra/15.0) - rah)*60.0;
      if (newdec < 0) {
        decd = floor(newdec) + 1;
        decm = -(newdec - decd)*60.0;
      } else {
        decd = floor(newdec);
        decm = (newdec - decd)*60.0;
      }

      printf("%-10s %-11s %9.5f %10.5f %6.3f %8.2f %s\n", 
		name, type, newra, newdec, mag, period, comments);
   }
}
