# include "imregister.h"
# include "spreg.h"

void ModifySubset (int *match, int Nmatch) {

  int i, j, Nold;
  char *tmppath;
  char *ext, *root, *path;
  int Nspectrum;
  Spectrum *spectrum;

  spectrum = get_spectra (&Nspectrum);

  /* create some necessary variables */
  if (output.modify_path) { 
    Nold = strlen (output.oldpath);
    ALLOCATE (tmppath, char, 128);
  }

  /* modify the selected entries */
  for (j = 0; j < Nmatch; j++) {

    i = match[j];

    if (output.modify_path) {
      if (!strncmp (spectrum[i].pathname, output.oldpath, Nold)) {
	strcpy (tmppath, &spectrum[i].pathname[Nold]);
	snprintf (spectrum[i].pathname, 128, "%s%s", output.newpath, tmppath);
      }
    }

    if (output.modify_mode) {
      spectrum[i].mode = output.mode;
    }

    if (output.modify_state) {
      spectrum[i].state = output.state;
    }
  }

  update_db (match, Nmatch);
  fprintf (stderr, "SUCCESS\n");
  exit (0);

}
