summaryrefslogtreecommitdiffstats
path: root/dbus/make-dbus-glib-error-enum.sh
blob: c2f538db6a7010e5b89bb1fc7735973d3038058b (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
#!/bin/sh

SRC=$1
DEST=$2

die()
{
    echo $1 1>&2
    /bin/rm $DEST.tmp
    exit 1
}

cat $SRC | grep '#define DBUS_ERROR' | sed -e 's/#define //g' | \
  sed -e 's/".*//g' | sed -e 's/_ERROR/_GERROR/g' | sed -e 's/ *$/,/g' > $DEST.tmp

if ! test -s $DEST.tmp ; then
    die "$DEST.tmp is empty, something went wrong, see any preceding error message"
fi

echo "#ifndef DBUS_INSIDE_DBUS_GLIB_H" >> $DEST.tmp
echo '#error "' "$DEST" 'may only be included by dbus-glib.h"' >> $DEST.tmp
echo "#endif" >> $DEST.tmp

mv $DEST.tmp $DEST || die "could not move $DEST.tmp to $DEST"