#!/bin/bash

############################################################
### This is the launching script for the Hornix verifier ###
###     This tool is licensed under the MIT License.     ###
###                                                      ###
###   This tools is based on other tools with various    ###
###      licenses, please refer to the LICENSE file.     ###
############################################################


VERSION="0.2.0"

DIR="$(cd "$(dirname "$0")" && pwd)"

#echo $DIR

if [ "$#" -ne 1 ]; then
    echo "Usage: hornix [--version | inputfile.c]"
    exit 1
fi

fullname="$1"

if [ "$fullname" == "--version" ]; then
    echo "Hornix $VERSION"
    exit 0
fi

# Extracting the file extension
extension="${fullname##*.}"

# Checking if the extension is "c"
#if [ "$extension" = "cpp" ]; then
#  filename=$(basename $fullname .cpp)

if [ "$extension" = "c" ]; then
  filename=$(basename $fullname .c)
#elif [ "$extension" = "i" ]; then
#  filename=$(basename $fullname .i)
else
  echo "$fullname is neither a C++ nor a C file."
  exit
fi

PATH="${DIR}/bin":${PATH}
$DIR/bin/wrapper.py $fullname
