1
  $   H403239_•I|¥‰ÓMjqØ‚¦ ë<óo¬ÂÁ  ï    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
  S   ˆl–Ãa¾”*i?u8 …p/Üiå1hß“þBVqÀ
Yy·
ÛËMìÕÿ?Å{‹„„-i[D<†ªoZƒ›Ù«Æ‚C_‡I|¥‰ÓMÆÅ  Ó    ‹      u�M
‚pÅ÷žb¢UÛÇ¯jBiøÑ&ZTÚ÷-$4)*‚À›¼¹MS´¢Å,fÞÌ{¿A…+/pÃ‘Pá„oQJš¦zÞØàLÄ³Ìv(¨91ûŽë®F±o�)öªýZÓ”Ÿ‹•X®HYþ™«¶eè„œ—bŠš3ÞrJ¼F.Q
œNyC(QãA(¤Ëp©ÆEè¨Óú	nNì$Šƒ¡ên2¼ù~éf/žË/và»^_…A/±ãî÷þø Þö    L   	ˆl–Ðz¾”*_)ò‚ÆAp!S�ÿ�þBÐY·H&ã„ÐˆçÉƒl"oÈa–ßi~” T¾R( 	ÅõÀ‚ã!S�ÿÇ     	#!/usr/bin/env perl
#
# KETCindy starter script
#
# (C) 2017-2018 Norbert Preining
# Licensed under the same license terms as ketpic itself, that is GPLv3+
#

use strict;
$^W = 1;

use Digest::MD5;
use File::Copy;

my $BinaryName = "Cinderella2";
my $TemplateFile = "template1basic.cdy";
my $devnull = "/dev/null";
my $prog = "ketcindy";
my $systype;
if (win32()) {
  $systype = "Windows";
  $devnull = "nul";
} else {
  $systype = `uname`;
  chomp($systype);
}
my $HOME = ($systype eq "Windows") ? $ENV{'USERPROFILE'} : $ENV{'HOME'};
my $workdir ="$HOME/ketcindy";

my $cinderella;
if ($#ARGV >= 0) {
  if ($ARGV[0] eq '-c') {
    $cinderella = ($ARGV[1] ? $ARGV[1] : "");
  }
} else {
  $cinderella = which($BinaryName);
}

if (! "$cinderella") {
  if ($systype eq 'Darwin') {
    if (-r '/Applications/Cinderella2.app/Contents/MacOS/Cinderella2') {
      $cinderella = '/Applications/Cinderella2.app/Contents/MacOS/Cinderella2';
    }
  } elsif ($systype eq 'Windows') {
    if (-f 'c:/Program Files (x86)/Cinderella/Cinderella2.exe') {
      $cinderella = 'c:/Program Files (x86)/Cinderella/Cinderella2.exe';
    }
  }
}

if (! "$cinderella") {
  die "$prog: Cannot find $BinaryName!";
}

if ( ! -x "$cinderella" ) {
  die "$prog: Program $cinderella is not executable!";
}

# find real path
my $realcind = win32() ? $cinderella : `realpath "$cinderella"`;
chomp($realcind);
my ($cinddir, $bn) = dirname_and_basename($realcind);

my $plugindir = ($systype eq 'Darwin') ? "$cinddir/../PlugIns" : "$cinddir/Plugins";

my $plugin = "$plugindir/KetCindyPlugin.jar";
my $dirheadplugin = "$plugindir/ketcindy.ini";

# find Jar
chomp(my $KetCdyJar = `kpsewhich -format=texmfscripts KetCindyPlugin.jar`);
# search for template.cdy
chomp(my $TempCdy = `kpsewhich -format=texmfscripts $TemplateFile`);
chomp(my $DirHead=`kpsewhich -format=texmfscripts ketcindy.ini`);

if (-z "$TempCdy" || -z "$KetCdyJar") {
  die "$prog: Cannot find $TemplateFile via kpsewhich, is ketpic installed?";
}


if ( ! -r "$plugin" || ! -r "$dirheadplugin" ) {
  print "$prog: Cinderella is *NOT* set up for KETCindy!\n";
  print "$prog: You need to copy\n";
  print "$prog:    $KetCdyJar\n";
  print "$prog:    $DirHead\n";
  print "$prog: into\n";
  print "$prog:    $plugindir\n";
  print "\n";
  exit(1);
}

my $myjarmd = md5digest($KetCdyJar);
my $sysjarmd = md5digest($plugin);

if ( $myjarmd ne $sysjarmd ) {
  print "$prog: The installed version of the plugin in\n";
  print "$prog:   $plugin\n";
  print "$prog: differs from the version shipped in\n";
  print "$prog:   $KetCdyJar\n";
  print "$prog: You might need to update the former one with the later one!\n";
}

# print "DEBUG workdir =$workdir=\n";
# print "DEBUG TemplateFile =$TemplateFile=\n";
mkdir($workdir);
copy($TempCdy, $workdir) or die "$prog: Copy failed: $!";

# print "Exec $cinderella $workdir/$TemplateFile\n";
if (win32()) {
  # no idea why a normal call with exec did not find the template file
  my $out = `"$cinderella" "$workdir/$TemplateFile"`;
} else {
  exec($cinderella, "$workdir/$TemplateFile");
}


sub md5digest {
  my $file = shift;
  open(FILE, $file) || die "$prog: open($file) failed: $!";
  binmode(FILE);
  my $out = Digest::MD5->new->addfile(*FILE)->hexdigest;
  close(FILE);
  return $out;
}

# taken from TeXLive::TLUtils.pm
sub win32 {
  if ($^O =~ /^MSWin/i) {
    return 1;
  } else {
    return 0;
  }
}
sub which {