#!/usr/bin/perl -w

#---libsetup---

# having . in @INC can cause tainting issues for use

no lib '.';

use FindBin;
BEGIN {
  ($dir)=($FindBin::Bin=~/^([\w\d\-\/\.]+)$/)
    or die "invalid current directory $FindBin::Bin";
}
use lib $dir;

#---endlibsetup---

use PhotoPub::Global qw(&init &finit $error);
use PhotoPub::CLBase qw();
use PhotoPub::Config;

use PhotoPub::Handlers qw(&listhandlephoto);
use PhotoPub::Utils qw(&parserange);

&init();

my $path=shift @ARGV;
my %photos=();

foreach my $photo (@{&listhandlephoto('photolist',$path)}) {
  $photos{$photo}=1;
}

foreach my $range (@{&listhandlephoto('photogroups',$path)}) {
  &parserange($range->{'range'},$path,
	      sub {
		my ($thispath,$num)=@_;
		delete $photos{$num} if $thispath eq $path;
		return 1;
	      });
}

foreach my $photo (sort { $a <=> $b } keys %photos) {
  print "$photo\n";
}

&finit();
