#!/bin/bash

#This script runs QCTerm in Wine. A host and port separated by a colon may
#optionally be specified as the first argument.

SCRIPTNAME="`realpath $0`"
SCRIPTDIR="`dirname $SCRIPTNAME`"
WINEPREFIX="`realpath $SCRIPTDIR/../utils/qcterm/wine`"
export WINEPREFIX
if [ "$1" ]
then
	if [ -f "$1" ]
	then
		config="$1"
	else
		tmpfile="`mktemp /tmp/tmpXXXXXXXX.qct`"
		trap "rm -f $tmpfile" INT HUP TERM EXIT
		echo -e "addr $1\r" > "$tmpfile"
		config="$tmpfile"
	fi
	config="`winepath -w "$config"`"
fi
wine 'C:\Program Files (x86)\AICS Research\qcterm\qcterm.exe' $config
