summaryrefslogtreecommitdiff
path: root/dbus/make-dbus-glib-error-enum.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dbus/make-dbus-glib-error-enum.sh')
-rwxr-xr-xdbus/make-dbus-glib-error-enum.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/dbus/make-dbus-glib-error-enum.sh b/dbus/make-dbus-glib-error-enum.sh
new file mode 100755
index 00000000..5b0df6c9
--- /dev/null
+++ b/dbus/make-dbus-glib-error-enum.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+SRC=$1
+DEST=$2
+
+function 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"