1cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project#!/bin/bash 2cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# see the README file for usage etc. 3cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# 4cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# ------------------------------------------------------------------ 5cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# This file is part of bzip2/libbzip2, a program and library for 6cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# lossless, block-sorting data compression. 7cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# 8172b266ed7845eac2edc7e7f8a72371356a9a277Nick Kralevich# bzip2/libbzip2 version 1.0.6 of 6 September 2010 9172b266ed7845eac2edc7e7f8a72371356a9a277Nick Kralevich# Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org> 10cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# 11cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# Please read the WARNING, DISCLAIMER and PATENTS sections in the 12cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# README file. 13cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# 14cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# This program is released under the terms of the license contained 15cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# in the file LICENSE. 16cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# ---------------------------------------------------------------- 17cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 18cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 19cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectusage() { 20cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo ''; 21cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo 'Usage: xmlproc.sh -[option] <filename.xml>'; 22cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo 'Specify a target from:'; 23cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo '-v verify xml file conforms to dtd'; 24cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo '-html output in html format (single file)'; 25cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo '-ps output in postscript format'; 26cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo '-pdf output in pdf format'; 27cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project exit; 28cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project} 29cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 30cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectif test $# -ne 2; then 31cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project usage 32cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectfi 33cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# assign the variable for the output type 34cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectaction=$1; shift 35cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# assign the output filename 36cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectxmlfile=$1; shift 37cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# and check user input it correct 38cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectif !(test -f $xmlfile); then 39cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo "No such file: $xmlfile"; 40cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project exit; 41cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectfi 42cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# some other stuff we will use 43cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source ProjectOUT=output 44cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectxsl_fo=bz-fo.xsl 45cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectxsl_html=bz-html.xsl 46cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 47cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectbasename=$xmlfile 48cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectbasename=${basename//'.xml'/''} 49cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 50cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectfofile="${basename}.fo" 51cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projecthtmlfile="${basename}.html" 52cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectpdffile="${basename}.pdf" 53cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectpsfile="${basename}.ps" 54cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectxmlfmtfile="${basename}.fmt" 55cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 56cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# first process the xmlfile with CDATA tags 57cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project./format.pl $xmlfile $xmlfmtfile 58cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# so the shell knows where the catalogs live 59cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectexport XML_CATALOG_FILES=/etc/xml/catalog 60cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 61cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# post-processing tidy up 62cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectcleanup() { 63cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo "Cleaning up: $@" 64cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project while [ $# != 0 ] 65cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project do 66cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project arg=$1; shift; 67cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo " deleting $arg"; 68cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project rm $arg 69cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project done 70cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project} 71cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 72cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectcase $action in 73cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project -v) 74cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project flags='--noout --xinclude --noblanks --postvalid' 75cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd' 76cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project xmllint $flags $dtd $xmlfmtfile 2> $OUT 77cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project egrep 'error' $OUT 78cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project rm $OUT 79cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project ;; 80cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 81cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project -html) 82cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo "Creating $htmlfile ..." 83cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project xsltproc --nonet --xinclude -o $htmlfile $xsl_html $xmlfmtfile 84cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project cleanup $xmlfmtfile 85cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project ;; 86cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 87cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project -pdf) 88cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo "Creating $pdffile ..." 89cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile 90cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 91cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 92cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 93cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project cleanup $OUT $xmlfmtfile *.aux *.fo *.log *.out 94cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project ;; 95cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 96cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project -ps) 97cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project echo "Creating $psfile ..." 98cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile 99cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 100cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 101cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdfxmltex $fofile >$OUT </dev/null 102cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project pdftops $pdffile $psfile 103cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project cleanup $OUT $xmlfmtfile $pdffile *.aux *.fo *.log *.out 104cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# passivetex is broken, so we can't go this route yet. 105cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# xmltex $fofile >$OUT </dev/null 106cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# xmltex $fofile >$OUT </dev/null 107cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# xmltex $fofile >$OUT </dev/null 108cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project# dvips -R -q -o bzip-manual.ps *.dvi 109cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project ;; 110cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project 111cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project *) 112cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project usage 113cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Project ;; 114cfb3b2780016b4e9ab4849e22d9c3acbaf535248The Android Open Source Projectesac 115