#!/bin/sh

export WINEPATH="/usr/lib/i386-linux-gnu/wine"
export WINE_SRV_RT=${WINE_SRV_RT:-15}
export WINE_RT=${WINE_RT:-10}
export STAGING_RT_PRIORITY_SERVER=${STAGING_RT_PRIORITY_SERVER:-15}
export STAGING_RT_PRIORITY_BASE=${STAGING_RT_PRIORITY_BASE:-0}
export STAGING_SHARED_MEMORY=${STAGING_SHARED_MEMORY:-1}
export L_ENABLE_PIPE_SYNC_FOR_APP="fsthost32"
export L_RT_POLICY="${L_RT_POLICY:-FF}"
export L_RT_PRIO=${L_RT_PRIO:-10}
appname="fsthost32.so"
# determine the application directory
appdir=''
case "$0" in
  */*)
    # $0 contains a path, use it
    appdir=`dirname "$0"`
    ;;
  *)
    # no directory in $0, search in PATH
    saved_ifs=$IFS
    IFS=:
    for d in $PATH
    do
      IFS=$saved_ifs
      if [ -x "$d/$appname" ]; then appdir="$d"; break; fi
    done
    ;;
esac

# figure out the full app path
if [ -r "$appdir/$appname" ]; then
    apppath="$appdir/$appname"
    WINEDLLPATH="$appdir:$WINEDLLPATH"
    export WINEDLLPATH
else
    apppath="$appname"
fi

# determine the WINELOADER
if [ ! -x "$WINELOADER" ]; then WINELOADER="wine"; fi

# and try to start the app
exec "$WINELOADER" "$apppath" "$@"
