#!/usr/bin/env perl # kjbible-search.cgi - Wrapper for "kjbible" search tool # License: BSD-style (for this file only) # Revision: 110905 #--------------------------------------------------------------------- # standard module setup #--------------------------------------------------------------------- require 5.8.1; use strict; use Carp; use warnings; #--------------------------------------------------------------------- # basic constants #--------------------------------------------------------------------- use constant ZERO => 0; # Zero use constant ONE => 1; # One use constant TWO => 2; # Two use constant FALSE => 0; # Boolean FALSE use constant TRUE => 1; # Boolean TRUE #--------------------------------------------------------------------- # mount "kjbible" filesystem (if necessary) #--------------------------------------------------------------------- my $LOOPFILE = '/xzm/kjbibledata.xzm'; my $MNTDIR = '/mnt/kjbibledata'; my $PROGNAME = 'King James Bible'; my $TITLE = 'Not provided by this version'; if (-f $LOOPFILE) { my $cmd = << 'END'; mkdir -p $MNTDIR n=`ls $MNTDIR | wc -l` if [ $n = 0 ]; then sudo /bin/mount -o loop $LOOPFILE $MNTDIR fi END $cmd =~ s@\$LOOPFILE@$LOOPFILE@g; $cmd =~ s@\$MNTDIR@$MNTDIR@g; system $cmd; } else { my $MSG = << "END"; Due to disk-space constraints, this version of the distro omits the $PROGNAME. You can get the package by booting a lar- ger version. END my $cmd = << 'END'; /laclin/lacutil/single-instance --wait --usewin \ "^$TITLE" \ /laclin/bin/zenity --error --no-wrap --title="$TITLE" --text="$MSG" END $cmd =~ s@\$TITLE@$TITLE@g; $cmd =~ s@\$MSG@$MSG@g; system $cmd; exit ONE; } #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { my @htm = (); my $PATH = $ENV {PATH}; $PATH = "/usr/bin:/bin:$PATH"; $PATH = "/laclin/bin:/laclin/sbin:$PATH"; my $result = `__META_PREFIX__/bin/mnogomain.cgi 2>&1`; if (opendir (DIR, '/usr/local/pages/etext/Misc/kjbible/kjv/link')) { while (defined (my $dirent = readdir (DIR))) { next unless $dirent =~ s@\.htm\z@@; push (@htm, $dirent); } closedir DIR; } if (scalar (@htm)) { my $pattern = join '|', @htm; $result =~ s@kjv/($pattern)\.htm\b@kjv/link/$1.htm@g; } print $result; undef; } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ZERO; # Normal exit