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
+41 -15
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# @(#$Id: rcldoc,v 1.6 2007-01-30 11:36:02 dockes Exp $ (C) 2004 J.F.Dockes
# @(#$Id: rcldoc,v 1.7 2007-02-06 15:08:22 dockes Exp $ (C) 2004 J.F.Dockes
# Parts taken from Estraier:
#================================================================
# Estraier: a personal full-text search system
@@ -20,20 +20,32 @@
LANG=C ; export LANG
LC_ALL=C ; export LC_ALL
progname="rcldoc"
filetype=ms-word
decoder="antiword -t -i 1 -m UTF-8"
# Not ready to use this for now (it outputs html, so the code below has to
# be simplified.)
#decoder="wvWare -1 -c UTF-8"
# show help message
if test $# -ne 1 -o "$1" = "--help"
then
printf 'Convert a word file to unformatted HTML text.\n'
printf 'Usage: %s [infile]\n' "$progname"
exit 1
fi
infile="$1"
#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()
{
@@ -47,6 +59,7 @@ iscmd()
return 1 ;;
esac
}
checkcmds()
{
for cmd in $*;do
@@ -54,20 +67,33 @@ checkcmds()
then
a=1
else
echo $cmd not found 1>&2
exit 1
senderror HELPERNOTFOUND $cmd
fi
done
}
checkcmds awk antiword iconv
# check the input file existence
if test ! -f "$infile"
# show help message
if test $# -ne 1 -o "$1" = "--help"
then
printf '%s: %s: no such file\n' "$progname" "$infile"
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
checkcmds awk antiword iconv
# output the result
# The strange 'BEGIN' setup is to prevent 'file' from thinking this file
# is an awk program