#!/bin/bash
# 
 # Copyright (C) 2001-2007 Michael Fuchs
#

function usage() {

    [ "$0" != "" ] && echo "$0"
 
    cat <<EOF
Syntax: dbdfop -i fofile -t pdf|rtf -o outfile
EOF
    exit -1
}

prog=`type -p -- $0`

if [ $? -ne 0 ] ; then
    echo "Can't find installation directory!"
    exit 1
fi

prog=`readlink -f $prog`
bindir=`dirname "$prog"`

dbdhome=`cd "$bindir/.." && pwd`

in=""
out=""
type=""

while getopts "i:t:o:" args; do
    case $args in
        i) in=$OPTARG;;
        t) type=$OPTARG;;
        o) out=$OPTARG;;
        *) usage;;
    esac
done

if [ "x${in}" = "x" ] ; then
    usage
fi

if [ "x${type}" = "x" ] ; then
    usage
fi

if [ "x${out}" = "x" ] ; then
    usage
fi

$dbdhome/fop/fop -fo $in -${type} $out

exit $?
