+sub show_slide {
+ my $slide = shift;
+
+ if ($slide->{ext} eq "html") {
+ # MozEmbed is incredibly crashy, so we run ourself as a
+ # subprocess, so when it segfaults we don't care.
+ my $cwd = getcwd;
+ my $url = "file://" . $cwd . "/" . $slide->{name};
+ my @cmd = ($0, "--mozembed", $url);
+ system (@cmd);
+ die "failed to execute subcommand: $!\n" if $? == -1;
+ if ($? & 127) {
+ # Subcommand probably segfaulted, just continue to next slide.
+ return "NEXT";
+ } else {
+ my $r = $? >> 8;
+ if ($r == 0) {
+ return "NEXT";
+ } elsif ($r == 1) {
+ return "PREV";
+ } elsif ($r == 2) {
+ return "QUIT";
+ }
+ }
+ }
+ elsif ($slide->{ext} eq "sh") {
+ system ("PATH=.:\$PATH " . $slide->{name});
+ return "NEXT";
+ }
+}