summaryrefslogtreecommitdiff
path: root/src/bcop.in
blob: 1b1b224b5b791ab3cfe4c7ac4aa4aafba3ca8ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# 
#  Compiz option code generator
# 
#  Copyright : (C) 2007 by Dennis Kasprzyk
#  E-mail    : onestone@beryl-project.org
# 
# 
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#

xsltdir=@prefix@/share/bcop

function usage
{
    echo "Usage: $0 [options] <options file>"
    echo "Options:"
    echo "  -h, --help           display this help message"
    echo "  -v, --version        print version information"
    echo "      --source=<file>  source file name"
    echo "      --header=<file>  header file name"
    exit 1
}

srcfile=
hdrfile=

set -- `getopt -quo "hv" -l "help,version,source:,header:" -- "$@"`
[ $# -lt 2 ] && usage

while [ $# -gt 0 ]
do
    case "$1" in
        -h)         usage;;
        --help)     usage;;
        -v)         echo "@PACKAGE_STRING@"; exit 0;;
        --version)  echo "@PACKAGE_STRING@"; exit 0;;
        --source)   srcfile="$2"; shift;;
        --header)   hdrfile="$2"; shift;;
        --)         shift; break;;
        -*)         usage;;
        *)          break;;         # terminate while loop
    esac
    shift
done

xmlfile="$1"

if [ -e $xmlfile ]; then
    if [ -n "$hdrfile" ]; then
        xsltproc --stringparam "header" "true" $xsltdir/bcop.xslt $xmlfile > "$hdrfile"
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
	    rm -f $hdrfile
	    exit $RETVAL
	fi
    fi
    if [ -n "$srcfile" ]; then
        xsltproc --stringparam "source" "true" $xsltdir/bcop.xslt $xmlfile > "$srcfile"
	RETVAL=$?
	if [ $RETVAL -ne 0 ]; then
	    rm -f $srcfile
	    exit $RETVAL
	fi
    fi
fi