1#!/bin/sh 2 3wv_script_name="$0" 4 5prefix=@prefix@ 6exec_prefix= 7datadir= 8t_dir=. 9 10wv_opts= 11i_file= 12o_file= 13print_help=no 14 15while test $# -gt 0; do 16 case "$1" in 17 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 18 *) optarg= ;; 19 esac 20 21 case $1 in 22 --prefix=*) 23 prefix=$optarg 24 ;; 25 --exec-prefix=*) 26 exec_prefix=$optarg 27 ;; 28 --datadir=*) 29 datadir=$optarg 30 ;; 31 --targetdir=*) 32 t_dir=$optarg 33 ;; 34 --charset=* | --password=*) 35 wv_opts="$wv_opts $1" 36 ;; 37 -v | --version) 38 echo @VERSION@ 39 exit 0 40 ;; 41 -\? | -h | --help) 42 cat << EOF 43Usage: $wv_script_name [OPTIONS] <input-file> <output-file> 44Options: 45 --prefix=<DIR> Set prefix (default is @prefix@) 46 --exec-prefix=<DIR> Set exec_prefix (default is @exec_prefix@) 47 --datadir=<DIR> Set datadir (default is @datadir@) 48 --targetdir=<DIR> Target directory (target is <DIR>/<output-file>) 49 --charset=<charset> Specify an iconv charset encoding 50 --password=<password> Specify password for encrypted 51 -v, --version Print version info and exit 52 53Authors: 54 Dom Lachowicz (dominicl@seas.upenn.edu) 55 Caolan McNamara (original author) 56Visit http://www.wvware.com/ 57EOF 58 exit 0 59 ;; 60 -?*) 61 echo "Option '$1' not recognized." 62 exit 1 63 ;; 64 *) 65 if test "x$i_file" = "x"; then 66 i_file=$1 67 elif test "x$o_file" = "x"; then 68 o_file=$1 69 else 70 echo "Option '$1' not recognized." 71 exit 1 72 fi 73 ;; 74 esac 75 shift 76done 77 78if test "x$i_file" = "x-"; then 79 echo "error: cannot specify '-' as input" 80 exit 1 81fi 82if test -r "$i_file"; then 83 okay=yes 84else 85 echo "error: '$i_file' unreadable" 86 exit 1 87fi 88 89if test "x$o_file" = "x"; then 90 echo "Usage: $1 [OPTIONS] <input-file> <output-file>" 91 exit 1 92fi 93name=`basename "$o_file"` 94if test "x$o_file" != "x$name"; then 95 echo "* * * Better to use '--targetdir' for writing in another directory * * *" 96 exit 1 97fi 98sp_chk=`echo $name | sed "s/ /_/g"` 99if test "x$name" != "x$sp_chk"; then 100 echo "sorry, LaTeX file names cannot contain spaces." 101 exit 1 102fi 103name=`echo $name | sed 's/\.[^\.]*$//'` 104 105if test "x$exec_prefix" = "x"; then 106 exec_prefix=@exec_prefix@ 107fi 108wv_exec="$exec_prefix/bin/wvWare" 109if test -x "$wv_exec"; then 110 okay=yes 111else 112 wv_version=`wvWare -v 2>&1 | cut -f 2 -d " "` 113 if test "x$wv_version" = "x@VERSION@"; then 114 wv_exec="wvWare" 115 else 116 echo "error: no executable at '$wv_exec' or in path" 117 exit 1 118 fi 119fi 120 121if test "x$datadir" = "x"; then 122 datadir=@datadir@ 123fi 124xmlcfg="$datadir/wv/wvCleanLaTeX.xml" 125if test -r "$xmlcfg"; then 126 okay=yes 127else 128 echo "error: '$xmlcfg' unreadable" 129 exit 1 130fi 131 132if test -d "$t_dir"; then 133 if test -w "$t_dir"; then 134 okay=yes 135 else 136 echo "error: '$t_dir' is not writable" 137 exit 1 138 fi 139else 140 echo "error: '$t_dir' is not a directory" 141 exit 1 142fi 143 144if test "x$o_file" = "x-"; then 145 "$wv_exec" $wv_opts -x "$xmlcfg" -d "$t_dir" -b "$name" "$i_file" 146else 147 "$wv_exec" $wv_opts -x "$xmlcfg" -d "$t_dir" -b "$name" "$i_file" > "$t_dir"/"$o_file" 148fi 149