# include "astro.h"

main (argc, argv)
int argc;
char **argv;
{

  int N, N1, N2;
  double dx, dy, Rx, Ry;
  double X_O, X_X, X_Y, dX, Y_O, Y_X, Y_Y, dY;
  char *c, *ref, filename[200], head[200], obj[200];
  Stars *stars1, *stars2;

  rargs (&argc, argv);

  ref = argv[1];
  N1 = 5000;
  stars1 = get_stars (ref, &N1);

  fprintf (stderr, "enter filenames, followed by EOF\n");
  while (fscanf (stdin, "%s", filename) != EOF) {
    /**** See comment 1 below ****/
    strcpy (head, filename);
    if ((c = strrchr(head, '.')) != NULL)
      strcpy(strrchr(head, '.'), ".head");
    else 
      strcat(head, ".head");
    strcpy (obj, filename);
    if ((c = strrchr(obj, '.')) != NULL)
      strcpy(strrchr(obj, '.'), ".obj_out");
    else 
      strcat(obj, ".obj_out");

    N2 = N2NUMBER;
    stars2 = get_stars (obj, &N2);
    if (N2 >= 3) {
      Rx = 1.0;
      Ry = 1.0;
      
      delta (stars1, stars2, N1, N2, &dx, &dy, &Rx, &Ry);
      N = line_fit (stars1, stars2, N1, N2, dx, dy, Rx, Ry, 
		&X_O, &X_X, &X_Y, &dX, &Y_O, &Y_X, &Y_Y, &dY);
      ralter_header (head, ref, X_O, X_X, X_Y, dX, Y_O, Y_X, Y_Y, dY, N);
    }
    else {
      fprintf (stderr, "too few stars in %s, skipped\n", filename);
    }
    free (stars2);
  }
  free (stars1);
}






    /* comment 1:
       assign the assumed names: 
       filename.head, filename.obj_out 
       if filename is of the form xxxx.xxx, cut off
       extention before attaching .head, .obj_out
       this entire problem can be removed by making the 
       Dophot output file contain the header info from
       the image, but until this is the Dophot output
       format... */
