# include "dvo.h"

/* returns a list of region files names from file */
RegionFile *region_list (char *filename, int *Nregions) {
  
  int NREGIONS, nregion;
  RegionFile *regions;
  FILE *f;

  f = fopen (filename, "r");
  if (f == NULL) {
    fprintf (stderr, "ERROR: can't find region list file %s\n", filename);
    *Nregions = 0;
    return ((RegionFile *) NULL);
  }
  
  NREGIONS = 50;
  ALLOCATE (regions, RegionFile, NREGIONS);
  nregion = 0;

  while (fscanf (f, "%s", regions[nregion].name) != EOF) {
    nregion ++;
    if (nregion == NREGIONS) {
      NREGIONS += 50;
      REALLOCATE (regions, RegionFile, NREGIONS);
    }
  }

  *Nregions = nregion;

  return (regions);

}

