#!/bin/bash

################################################################################
# Copyright (C) 2015-2026 NICE s.r.l.
# All Rights Reserved
#
# This software is the confidential and proprietary information
# of NICE s.r.l. ("Confidential Information").
# You shall not disclose such Confidential Information
# and shall use it only in accordance with the terms of
# the license agreement you entered into with NICE.
################################################################################

prefix=/usr
exec_prefix=/usr
bindir=/usr/bin
libdir=/usr/lib/x86_64-linux-gnu
libexecdir=/usr/lib/x86_64-linux-gnu
datadir=/usr/share
dcv_bin="${libexecdir}/dcv/dcv"

export LD_LIBRARY_PATH="${libdir}/dcv:${LD_LIBRARY_PATH}"
export XDG_DATA_DIRS="${datadir}:${XDG_DATA_DIRS}:/usr/share:/usr/local/share"
export GIO_EXTRA_MODULES="${libdir}/dcv/gio/modules"

case "$1" in
    --gdb)
        shift
        export G_DEBUG=fatal-criticals
        gdb -ex run --args "${dcv_bin}" "$@"
        _exit=$?
        ;;
    --valgrind)
        shift
        export G_DEBUG=resident-modules
        valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --log-file=vgdump-cli "${dcv_bin}" "$@"
        _exit=$?
        ;;
    *)
        "${dcv_bin}" "$@"
        _exit=$?
        ;;
esac

exit ${_exit}

# --------------------------------------------------------------------------- #
# ex: set ts=4 sw=4 et syntax=sh :
# --------------------------------------------------------------------------- #
