# Frontend to convert a docbook file into something else
# Send any comments to Eric Bischoff <eric@caldera.de>
# This program is under GPL license. See LICENSE file for details.

case "$1" in
# Give the location of the centralized catalog
# First try the one with a version matching the version that is indicated in the document
  centralized-catalog)
	SGML_VERSION=`grep -i "<!DOCTYPE" $SGML_FILE | head -n 1 | sed 's/\(V[0-9]\.[0-9]\).*$/\1/; s/^.* V\([0-9]\.[0-9]\)/\1/'`
	if [ -f ${SGML_CATALOGS_DIR}/${SGML_XML}-docbook-${SGML_VERSION}.cat ]
	then echo "${SGML_CATALOGS_DIR}/${SGML_XML}-docbook-${SGML_VERSION}.cat"
	else echo "${SGML_CATALOGS_DIR}/${SGML_XML}-docbook.cat"
	fi
	;;
# Find a stylesheet on the model "html/docbook.dsl" or "print/docbook.dsl"
  style-sheet)
	case $SGML_STYLESHEET in
	  default)
	    echo "${SGML_BASE_DIR}/docbook/utils-0.6/docbook-utils.dsl#${SGML_TYPE}"
	    ;;
	  none)
	    find $SGML_BASE_DIR -name docbook.dsl | grep "$SGML_TYPE/docbook.dsl" | awk '{print $1}'
	    ;;
	esac
        ;;
  *)    exit 1
	;;
esac

exit 0
