# include "addstar.h"
# define NARGS 3  /* minimum is: addstar (filename) */

void help () {

  fprintf (stderr, "USAGE: addrefs (filename) (photcode)\n");
  fprintf (stderr, "  optional flags:\n");
  fprintf (stderr, "  -v (verbose mode)\n");
  fprintf (stderr, "\n"); 
  exit (2);

}

int args (int argc, char **argv) {
  
  int i;

  if (get_argument (argc, argv, "-help") ||
      get_argument (argc, argv, "-h")) {
    help ();
  }

  ConfigInit (&argc, argv);

  VERBOSE = FALSE;
  if ((i = get_argument (argc, argv, "-v"))) {
    VERBOSE = TRUE;
    remove_argument (i, &argc, argv);
  }
  REPLACE = FALSE;
  if ((i = get_argument (argc, argv, "-replace"))) {
    REPLACE = TRUE;
    remove_argument (i, &argc, argv);
  }
  ONLY_MATCH = FALSE;
  if ((i = get_argument (argc, argv, "-only-match"))) {
    ONLY_MATCH = TRUE;
    remove_argument (i, &argc, argv);
  }
  TIMEREF = 0; 
  if ((i = get_argument (argc, argv, "-time"))) {
    remove_argument (i, &argc, argv);
    if (!str_to_time (argv[i], &TIMEREF)) { 
      fprintf (stderr, "syntax error in time\n");
      exit (1);
    }
    remove_argument (i, &argc, argv);
  }

  if (argc != NARGS) help ();

  /* get photcode, check for type == PHOT_REF? */
  if ((thiscode = GetPhotcodebyName (argv[2])) == NULL) {
    fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[2]);
    exit (1);
  }
  return (TRUE);
}
