This file is indexed.

/usr/share/perl5/AMC/Image.pm is in auto-multiple-choice-common 1.2.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# Copyright (C) 2008-2012 Alexis Bienvenue <paamc@passoire.fr>
#
# This file is part of Auto-Multiple-Choice
#
# Auto-Multiple-Choice is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# Auto-Multiple-Choice is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Auto-Multiple-Choice.  If not, see
# <http://www.gnu.org/licenses/>.

package AMC::Image;

use AMC::Basic;
use IPC::Open2;

sub new {
    my ($fichier,%o)=(@_);
    my $self={'fichier'=>$fichier,
	      'ipc_in'=>'',
	      'ipc_out'=>'',
	      'ipc'=>'',
	      'args'=>['%f'],
	      'mode'=>'auto',
	      'traitement'=>'',
	  };

    for my $k (keys %o) {
	$self->{$k}=$o{$k} if(defined($self->{$k}));
    }

    if(! $self->{'traitement'}) {
      if($self->{'mode'} eq 'auto') {
	if(-f amc_specdir('libexec').'/AMC-detect') {
	  $self->{'mode'}='opencv';
	} else {
	  $self->{'mode'}='manual';
	}
      }
      if($self->{'mode'} eq 'opencv') {
	$self->{'traitement'}=amc_specdir('libexec').'/AMC-detect';
      } elsif($self->{'mode'} eq 'manual') {
	$self->{'traitement'}=amc_specdir('libexec').'/AMC-traitement-image';
      }
    }

    if(! -f $self->{'traitement'}) {
      die "AMC::Image: No program to execute";
    }

    bless $self;

    return($self);
}

sub set {
    my ($self,%oo)=(@_);
    for my $k (keys %oo) {
	$self->{$k}=$oo{$k} if(defined($self->{$k}));
    }
}

sub mode {
    my ($self)=(@_);
    return($self->{'mode'});
}

sub commande {
    my ($self,@cmd)=(@_);
    my @r=();

    if(!$self->{'ipc'}) {
	debug "Exec traitement-image..."; 
	my @a=map { ( $_ eq '%f' ? $self->{'fichier'} : $_ ) }
	(@{$self->{'args'}});
	debug join(' ',$self->{'traitement'},@a);
	$self->{'times'}=[times()];
	$self->{'ipc'}=open2($self->{'ipc_out'},$self->{'ipc_in'},
			     $self->{'traitement'},@a);
	debug "PID=".$self->{'ipc'}." : ".$self->{'ipc_in'}." --> ".$self->{'ipc_out'};
    }

    debug "CMD : ".join(' ',@cmd);

    print { $self->{'ipc_in'} } join(' ',@cmd)."\n";

    my $o;
  GETREPONSE: while($o=readline($self->{'ipc_out'})) {
      chomp($o);
      debug "|> $o";
      last GETREPONSE if($o =~ /_{2}END_{2}/);
      push @r,$o;
  }

    return(@r);
}

sub ferme_commande {
    my ($self)=(@_);
    if($self->{'ipc'}) {
	debug "Image sending QUIT";
	print { $self->{'ipc_in'} } "quit\n";
	waitpid $self->{'ipc'},0;
	$self->{'ipc'}='';
	$self->{'ipc_in'}='';
	$self->{'ipc_out'}='';
	my @tb=times();
	debug sprintf("Image finished: parent times [%7.02f,%7.02f]",
		      $tb[0]+$tb[1]-$self->{'times'}->[0]-$self->{'times'}->[1],$tb[2]+$tb[3]-$self->{'times'}->[2]-$self->{'times'}->[3]);
    }
}

sub DESTROY {
    my ($self)=(@_);
    $self->ferme_commande();
}

1;