factored out filter script common code

This commit is contained in:
dockes
2007-02-06 15:08:23 +00:00
parent c3ad4341dc
commit 2f75b9acb0
14 changed files with 674 additions and 214 deletions
+62 -23
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# @(#$Id: rcldvi,v 1.3 2007-01-30 11:36:02 dockes Exp $ (C) 2006 J.F.Dockes
# @(#$Id: rcldvi,v 1.4 2007-02-06 15:08:22 dockes Exp $ (C) 2006 J.F.Dockes
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,20 +22,32 @@
# or using catdvi. dvitops has given better results during tests, and is
# chosen first if available, but the dvitops/rclps combination is much
# slower than catdvi
# set variables
LANG=C ; export LANG
LC_ALL=C ; export LC_ALL
progname="rcldvi"
filetype=dvi
# Show help message
if test $# -ne 1 -o "$1" = "--help"
then
printf 'Convert a dvi file to unformatted HTML text for recoll indexation.\n'
printf 'Usage: %s [infile]\n' "$progname"
exit 1
fi
# Find rclps. Note: this only works because we are always executed with a
# full path
infile="$1"
rclps=`dirname $0`/rclps
#RECFILTCOMMONCODE
##############################################################################
# !! Leave the previous line unmodified!! Code imported from the
# recfiltcommon file
# Utility code common to all shell filters. This could be sourced at run
# time, but it's slightly more efficient to include the code in the
# filters at build time (with a sed script).
# Describe error in a way that can be interpreted by our caller
senderror()
{
echo RECFILTERROR $*
# Also alert on stderr just in case
echo ":2:$progname::: $*" 1>&2
exit 1
}
iscmd()
{
@@ -50,24 +62,51 @@ iscmd()
esac
}
checkcmds()
{
for cmd in $*;do
if iscmd $cmd
then
a=1
else
senderror HELPERNOTFOUND $cmd
fi
done
}
# show help message
if test $# -ne 1 -o "$1" = "--help"
then
echo "Convert a $filetype file to HTML text for Recoll indexing."
echo "Usage: $progname [infile]"
exit 1
fi
infile="$1"
# check the input file existence (may be '-' for stdin)
if test "X$infile" != X- -a ! -f "$infile"
then
senderror INPUTNOSUCHFILE "$infile"
fi
##############################################################################
# !! Leave the following line unmodified !
#ENDRECFILTCOMMONCODE
# Find rclps. Note: this only works because we are always executed with a
# full path
rclps=`dirname $0`/rclps
decoder=""
if iscmd dvips -a iscmd pstotext ; then
decoder=dvips
else
elsif iscmd catdvi
decoder=catdvi
fi
if test X$decoder = X ; then
echo "$progname: did not find either catdvi or dvips." 1>&2
exit 1
fi
# check the input file existence
if test ! -f "$infile"
then
printf '%s: %s: no such file\n' "$progname" "$infile"
exit 1
senderror NOTFOUND dvips catdvi
fi
if test X$decoder = Xdvips ; then