#!/bin/sh

##########@@@SOFT@@@WARE@@@COPY@@@RIGHT@@@##################################
# DIALOGIC CONFIDENTIAL
#
# Copyright (C) 1990-2008 Dialogic Corporation. All Rights Reserved.
# The source code contained or described herein and all documents related
# to the source code ("Material") are owned by Dialogic Corporation or its
# suppliers or licensors. Title to the Material remains with Dialogic Corporation
# or its suppliers and licensors. The Material contains trade secrets and
# proprietary and confidential information of Dialogic or its suppliers and
# licensors. The Material is protected by worldwide copyright and trade secret
# laws and treaty provisions. No part of the Material may be used, copied,
# reproduced, modified, published, uploaded, posted, transmitted, distributed,
# or disclosed in any way without Dialogic's prior express written permission.
#
# No license under any patent, copyright, trade secret or other intellectual
# property right is granted to or conferred upon you by disclosure or delivery
# of the Materials, either expressly, by implication, inducement, estoppel or
# otherwise. Any license under such intellectual property rights must be
# express and approved by Dialogic in writing.
#
###################################@@@SOFT@@@WARE@@@COPY@@@RIGHT@@@##########
############################################################################
#
#   Filename:        dinstall
#   %date_modified:  Mon Mar 17 15:30:58 2008 %
#   Description:     Installation script for Boston device Driver
#   
#############################################################################

#Can be used with little modifications on other Unix or Unix-like platforms.
#The only things requiring change should be:
#the bottom and some parts of get_driv_parms
#the bottom of disp_driv_parms
#the bottom of driver_remove
#the bottom of driver_install
#the parts of check_cmd_line pertaining to platform specific parameters
#maybe xecho

#Read the dinstlib file, which defines platform specific functions to
#actually do the installation
. ./dinstlib

#Functions


#Echo kludge, platform dependent
xecho()
{
    #Echo on some systems is broken, requires -e

    #echo "$*"
    echo -e "$*"
}

# Function to prompt for driver parameters
get_driv_parms()
{
    #Define default values
    _mill_driver_defaults

#    num_isa_addrs=-1
#    while [ "$num_isa_addrs" -lt 0 -o "$num_isa_addrs" -gt $MAXNMILL ]
#    do
#        xecho "Number of ISA hardware modules to configure (default: $DEFAULTNMILL): \c"
#        getnum num_isa_addrs
#        if [ $? != 0 ]
#        then
#            continue
#        fi
#        if [ "$num_isa_addrs" = "" ]
#        then
#            num_isa_addrs=$DEFAULTNMILL
#        fi
#    done
#    
#    if [ "$num_isa_addrs" -gt 0 ]
#    then
#        tmp=280
#        #Maintain both a human readable list and a list for the C file
#        #The latter is platform specific
#        isa_addrs=
#        isa_addrs_hex=
#        i=0
#        while [ $i -lt $num_isa_addrs ]
#        do
#            xecho "Enter ISA board address [$tmp]: \c"
#            getnum inp_string
#            if [ $? != 0 ]
#            then
#                continue
#            fi
#            if [ "$inp_string" != "" ]
#            then
#                tmp=$inp_string
#                #convert lowercase hex to uppercase, or bc will fail
#                tmp=`xecho $tmp | /bin/sed y/abcdef/ABCDEF/`
#            fi
#            if [ $i -gt 0 ]
#            then
#                isa_addrs="$isa_addrs $tmp"
#                isa_addrs_hex="$isa_addrs_hex,0x$tmp"
#            else
#                isa_addrs=$tmp
#                isa_addrs_hex=0x$tmp
#            fi
#                
#            i=`expr $i + 1`
#            tmp=`/usr/bin/bc <<!
#                obase=16
#                ibase=16
#                $tmp + 8
#!
#                `
#        done
#
#        intrline=100
#        while [ "$intrline" -gt 15 ]
#        do
#            xecho "What interrupt line will the ISA boards use (default $DEFAULTINTRLINE): \c"
#            getnum intrline
#            if [ $? != 0 ]
#            then
#                continue
#            fi
#            if [ "$intrline" = "" ]
#            then
#                intrline=$DEFAULTINTRLINE
#            fi
#        done
    
#       dmachan=100
#       while [ "$dmachan" -gt 7 -o "$dmachan" -eq 4 ]
#       do
#           xecho "What DMA channel will the ISA boards use,"
#           xecho "-1 if no DMA channel (default $DEFAULTDMACHAN): \c"
#           getnum dmachan
#           if [ $? != 0 ]
#           then
#               continue
#           fi
#           if [ "$dmachan" = "" ]
#           then
#               dmachan=$DEFAULTDMACHAN
#           fi
#       done
#
#    else
     num_isa_addrs=0
        isa_addrs_hex=0
        intrline=-1
#    fi
    dmachan=-1

    max_pci_hw_modules=0
    while [ "$max_pci_hw_modules" -le 0 ]
    do
        xecho "Maximum number of PCI/cPCI hardware modules (default $DEFAULTMAXPCIHWMOD): \c"
        getnum max_pci_hw_modules
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$max_pci_hw_modules" = "" ]
        then
            max_pci_hw_modules=$DEFAULTMAXPCIHWMOD
        fi
    done
    
    phybufsize=0
    while [ "$phybufsize" -lt $MINPHYBUFSIZE -o "$phybufsize" -gt $MAXPHYBUFSIZE ]
    do
        xecho "Physical buffer size (default $DEFAULTPHYBUFSIZE): \c"
        getnum phybufsize
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$phybufsize" = "" ]
        then
            phybufsize=$DEFAULTPHYBUFSIZE
        fi
    done
    
    appbufsize=0
    while [ "$appbufsize" -lt $MINAPPBUFSIZE -o "$appbufsize" -gt $MAXAPPBUFSIZE ]
    do
        xecho "Application buffer size (default $DEFAULTAPPBUFSIZE): \c"
        getnum appbufsize
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$appbufsize" = "" ]
        then
            appbufsize=$DEFAULTAPPBUFSIZE
        fi
    done
    
    dec_machine_id=0
    while [ "$dec_machine_id" -lt $MINMACHINEID -o "$dec_machine_id" -gt $MAXMACHINEID ]
    do
        xecho "Machine ID, in hex (default $DEFAULTMACHINEID): \c"
        getnum machine_id
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$machine_id" = "" ]
        then
            machine_id=$DEFAULTMACHINEID
        fi
        #Convert to decimal for comparison
        #convert lowercase hex to uppercase, or bc will fail
        h2=`xecho $machine_id | /bin/sed y/abcdef/ABCDEF/`
        dec_machine_id=`/usr/bin/bc <<!
                       obase=10
                       ibase=16
                       $h2
!
                        `
    done
    
    do_reset=-1
    while [ "$do_reset" -lt 0 -o "$do_reset" -gt 1 ]
    do
        xecho "Do initial reset (default 1): \c"
        getnum do_reset
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$do_reset" = "" ]
        then
            do_reset=1
        fi
    done
    
    history_enable=-1
    while [ "$history_enable" -lt 0 -o "$history_enable" -gt 1 ]
    do
        xecho "History enable (default 0): \c"
        getnum history_enable
        if [ $? != 0 ]
        then
            continue
        fi
        if [ "$history_enable" = "" ]
        then
            history_enable=0
        fi
    done
    
    if [ "$history_enable" = 0 ]
    then
        dhsize=$DHSIZEDEF
    else
        dhsize=-1
        while [ "$dhsize" -lt 0 ]
        do
            xecho "History size (default $DHSIZEDEF): \c"
            getnum inp_string
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$inp_string" = "" ]
            then
                dhsize=$DHSIZEDEF
            else
                dhsize=$inp_string
                if [ $dhsize -lt $DHSIZEMIN ]
                then
                    dhsize=$DHSIZEMIN
                fi
            fi
        done
    fi

    if [ "$history_enable" = 0 ]
    then
        num_hists_phy=$NUM_HISTS_PHY_DEF
    else
        num_hists_phy=-1
        while [ "$num_hists_phy" -lt 0 ]
        do
            xecho "Number of physical channel histories (default $NUM_HISTS_PHY_DEF): \c"
            getnum num_hists_phy
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$num_hists_phy" = "" ]
            then
                num_hists_phy=$NUM_HISTS_PHY_DEF
            fi
        done
    fi
    
    if [ "$history_enable" = 0 ]
    then
        num_hists_apl=$NUM_HISTS_APL_DEF
    else
        num_hists_apl=-1
        while [ "$num_hists_apl" -lt 0 ]
        do
            xecho "Number of application channel histories (default $NUM_HISTS_APL_DEF): \c"
            getnum num_hists_apl
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$num_hists_apl" = "" ]
            then
                num_hists_apl=$NUM_HISTS_APL_DEF
            fi
        done
    fi
    
    if [ "$history_enable" = 0 -o $num_hists_phy -le 0 ]
    then
        hist_phy_admin_only=$HIST_PHY_ADMIN_ONLY_DEF
    else
        hist_phy_admin_only=-1
        while [ "$hist_phy_admin_only" -lt 0 -o "$hist_phy_admin_only" -gt 1 ]
        do
            xecho "Restrict physical channel histories to admin channel 1 (default $HIST_PHY_ADMIN_ONLY_DEF): \c"
            getnum hist_phy_admin_only
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$hist_phy_admin_only" = "" ]
            then
                hist_phy_admin_only=$HIST_PHY_ADMIN_ONLY_DEF
            fi
        done
    fi

    xecho "Configure advanced parameters (n)? \c"
    read conf_adv
    if [ "$conf_adv" != y ]
    then
        #Driver will use defaults
        num_I2O_frames_per_module=0
        fc_interval=0
        mem_drv_alloc_min=0
        mem_drv_alloc_quanta=0
        num_reserved_modules=0
        init_mod_vals=0
        mill_test1=0
        mill_test2=0
        mill_test3=0
    else
        num_I2O_frames_per_module=-1
        while [ $num_I2O_frames_per_module -lt 0 ]
        do
            xecho "Number of I2O frames per module (default $DFLT_I2O_FRAMES_PER_MODULE): \c"
            getnum num_I2O_frames_per_module
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$num_I2O_frames_per_module" = "" ]
            then
                num_I2O_frames_per_module=$DFLT_I2O_FRAMES_PER_MODULE
            fi
            case $num_I2O_frames_per_module in
                4 | 8 | 16 | 32 | 64 | 128)
                    ;;
                *)
                    num_I2O_frames_per_module=-1
                    ;;
            esac
        done

        fc_interval=-1
        while [ "$fc_interval" -lt 0 ]
        do
            xecho "Driver flow control interval (default $DFLT_FC_INTERVAL): \c"
            getnum fc_interval
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$fc_interval" = "" ]
            then
                fc_interval=$DFLT_FC_INTERVAL
            fi
            if [ "$fc_interval" -lt $MIN_FC_INTERVAL ]
            then
                fc_interval=-1
            fi
        done

        mem_drv_alloc_min=-1
        while [ "$mem_drv_alloc_min" -lt 0 ]
        do
            xecho "Internal memory allocation minimum (default $MEM_DRV_ALLOC_MIN): \c"
            getnum mem_drv_alloc_min
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$mem_drv_alloc_min" = "" ]
            then
                mem_drv_alloc_min=$MEM_DRV_ALLOC_MIN
            fi
        done

        mem_drv_alloc_quanta=-1
        while [ "$mem_drv_alloc_quanta" -lt 0 ]
        do
            xecho "Internal memory allocation quanta (default $MEM_DRV_ALLOC_QUANTA): \c"
            getnum mem_drv_alloc_quanta
            if [ $? != 0 ]
            then
                continue
            fi
            if [ "$mem_drv_alloc_quanta" = "" ]
            then
                mem_drv_alloc_quanta=$MEM_DRV_ALLOC_QUANTA
            fi
        done

        xecho "To reserve module numbers, enter mod_id/serial number and"
        xecho "module number, in hex. Mod_num will default as indicated:"
        default_mod_num=$DEFAULT_MOD_NUM
        num_reserved_modules=0
        init_mod_vals=0
        while [ $num_reserved_modules -lt $MAX_RESERVED_MODULE_NUMS ]
        do
            xecho "mod_id mod_num["$default_mod_num"]: \c"
            read inp_string
            if [ "x$inp_string" = "x" ]
            then
                break
            fi
            #A set of C initializations is generated, platform-specific
#           tmp_mod_val=`/bin/awk '{if (NF==1) printf "{0x%s,0x'$default_mod_num'}\n",$1; else printf "{0x%s,0x%s}\n",$1,$2};' <<!

            tmp_x1=`/bin/awk '{printf "%s\n",$1};' <<!
            $inp_string
!`
            #convert lowercase hex to uppercase, or bc will fail
            tmp_x1=`xecho $tmp_x1 | /bin/sed y/abcdef/ABCDEF/`
            tmp_x1=`/usr/bin/bc <<!
                    obase=10
                    ibase=16
                    $tmp_x1
!
                    `
            if [ "$tmp_x1" -le 0 ]
            then
                xecho Bad mod_id value.
                continue
            fi
            tmp_x2=`/bin/awk '{if (NF==1) printf ""; else printf "%s\n",$2};' <<!
            $inp_string
!`
            if [ "$tmp_x2" = "" ]
            then
                tmp_x2=$default_mod_num
            fi
            #convert lowercase hex to uppercase, or bc will fail
            tmp_x2=`xecho $tmp_x2 | /bin/sed y/abcdef/ABCDEF/`
            tmp_x2=`/usr/bin/bc <<!
                    obase=10
                    ibase=16
                    $tmp_x2
!
                    `
            mod_limit=254
            if [ "$tmp_x2" -le 1 -o "$tmp_x2" -ge "$mod_limit" ]
            then
                xecho Bad mod_num value.
                continue
            fi

            tmp_mod_val=`/bin/awk '{if (NF==1) printf "0x%s,0x'$default_mod_num'\n",$1; else printf "0x%s,0x%s\n",$1,$2};' <<!
            $inp_string
!`
            if [ $num_reserved_modules -eq 0 ]
            then
                init_mod_vals=$tmp_mod_val
            else
                init_mod_vals=$init_mod_vals,$tmp_mod_val
            fi
            default_mod_num=`/bin/awk '{if (NF==1) print "'$default_mod_num'"; else print $2}' <<!
            $inp_string
!`
            #convert lowercase hex to uppercase, or bc will fail
            default_mod_num=`xecho $default_mod_num | /bin/sed y/abcdef/ABCDEF/`
            #Increment, in hex
            default_mod_num=`/usr/bin/bc <<!
                            obase=16
                            ibase=16
                            $default_mod_num + 1
!
                            `
            num_reserved_modules=`expr $num_reserved_modules + 1`
        done

        xecho "Configure test parameters (n)? \c"
        read conf_test
        if [ "$conf_test" = y ]
        then
            while [ 1 ]
            do
                xecho "Test1 (0): \c"
                getnum mill_test1
                if [ $? = 0 ]
                then
                    break
                fi
            done
            while [ 1 ]
            do
                xecho "Test2 (0): \c"
                getnum mill_test2
                if [ $? = 0 ]
                then
                    break
                fi
            done
            while [ 1 ]
            do
                xecho "Test3 (0): \c"
                getnum mill_test3
                if [ $? = 0 ]
                then
                    break
                fi
            done
        else
            mill_test1=0
            mill_test2=0
            mill_test3=0
        fi
    fi

    #The part of this function below this point is prompting for
    #platform-specific parameters
}

# Function to display driver parameters
disp_driv_parms()
{
    xecho "Configuring Boston driver:"
#    if [ $num_isa_addrs -gt 0 ]
#    then
#        xecho "\tISA Board addresses: $isa_addrs"
#        xecho "\tISA Interrupt line $intrline"
##       xecho "\tISA DMA channel $dmachan"
#    fi
    xecho "    Max PCI hw modules $max_pci_hw_modules"
    xecho "    Phys buf size $phybufsize"
    xecho "    App buf size $appbufsize"
    xecho "    Machine ID $machine_id"
    if [ "$history_enable" != 0 ]
    then
        xecho "\tHistory size $dhsize"
        xecho "\tNum phys hist bufs $num_hists_phy"
        xecho "\tNum apl hist bufs $num_hists_apl"
        if [ $num_hists_phy -gt 0 ]
        then
            xecho "\tRestrict phys hists $hist_phy_admin_only"
        fi
    else
        xecho "\tHistory disabled"
    fi
    #Module reservation stuff would go here, if we wanted to display it.

    #The part of this function below this point is displaying for
    #platform-specific parameters
}

# Usage message
usage()
{
    xecho "Usage: dinstall [-r] [-d working_directory] [-c config_options]"
    xecho "config_options for installation:"
    xecho "  reserved reserved max_pci_modules phybufsize appbufsize reserved"
    xecho "  machine_id do_reset hist_enable dhsize num_hists_phy num_hists_apl"
    xecho "  hist_phy_admin_only num_I2O_frames fc_interval"
    xecho "  mem_drv_alloc_min mem_drv_alloc_quanta reserved test1 test2 test3"
    xecho "  (module_id mod_num) ... reserved"
    xecho "config_options for removal:"
    xecho "  <none>"

    exit 1
}

# Function to check count of parameters
param_usage_check()
{
    if [ $1 -le 0 ]
    then
        xecho Incorrect number of configuration parameters.
        usage
    fi
}

#Takes optional argument, the word partial, which is passed 
#to _mill_driver_remove
driver_removal()
{
    _mill_driver_remove $1

    if [ $? != 0 ]
    then
        xecho $err_msg
        xecho "Sorry, but the Brooktrout removal script must abort."
        exit 1
    fi

    if [ "$1" = partial ]
    then
        return 0
    fi

    xecho
    xecho "The Brooktrout Boston device driver has been removed from your system."

    #Platform specific post-removal code below
    return 0
}

driver_install()
{
#    version=`/bin/grep MILL_DRIVER_VERSION ../../inc/millver.h | head -1 | /bin/awk '{print $3}' | /bin/sed s/\"//g`
#    ver_maj=`/bin/grep SDK_MAJOR_VERSION ../../../bfv.api/inc/sdk_version.h | head -1 | /bin/awk '{print $3}'`
#    ver_mid=`/bin/grep SDK_MIDDLE_VERSION ../../../bfv.api/inc/sdk_version.h | head -1 | /bin/awk '{print $3}'`
#    ver_min=`/bin/grep SDK_MINOR_VERSION ../../../bfv.api/inc/sdk_version.h | head -1 | /bin/awk '{print $3}'`
    
    ver_maj=6
    ver_mid=0
    ver_min=0

    version=$ver_maj.$ver_mid.$ver_min

    xecho "Installing Brooktrout Boston Device Driver Version" $version

    #Is there a driver installed yet?
    _mill_driver_install_check
    ret=$?

    if [ $ret != 0 ]
    then
        if [ $ret = 2 ]
        then
            xecho $err_msg
            xecho "Sorry, but the Brooktrout installation script must abort."
            exit 1
        fi

        if [ "${command_line_config}" = 1 ]
        then
            xecho Previously installed driver being removed.
            answer=y
        else
            xecho "Brooktrout Boston driver has been installed (or partially installed)"

            xecho "Do you want to overwrite the existing driver files?"
            answer=
            defaultanswer=y
            while [ "$answer" != "n" -a "$answer" != "y" ]
            do
                xecho "Overwrite? (y or n, default $defaultanswer): \c"
                read answer
                if [ "$answer" = "" ]
                then
                    answer=$defaultanswer
                fi
            done
        fi

        if [ "$answer" = "y" ]
        then
            xecho Removing previously installed driver...
            driver_removal partial
        else
            return 0
        fi
    fi

    if [ "${command_line_config}" != 1 ]
    then
    #Prompt for parameters
        get_driv_parms
    fi
    disp_driv_parms

    check_kernel_dir

    _mill_driver_install

    if [ $? != 0 ]
    then
        xecho $err_msg

        #platform specific case

        xecho "Sorry, but the Brooktrout installation script must abort."
        exit 1
    fi

    xecho The Brooktrout Boston Driver has been installed on your system.

    #Platform specific post-install code below

    return 0
}

check_cmd_line()
{
    if [ "$1" = "-r" ]
    then
        shift
#       if [ "$1" = -c ]
#       then
#           #The part of this section below this point is saved for
#           #platform-specific removal parameters
#       fi

        xecho Removing driver...
        driver_removal
        exit 0
    fi

    if [ "$1" = "-d" ]
    then
        shift
        param_usage_check $#
        cd $1
        shift
    fi

    if [ "$1" = "-c" ]
    then
        command_line_config=1
        shift
        param_usage_check $#
#        num_isa_addrs="$1"
        num_isa_addrs=0
        isa_addrs=
        isa_addrs_hex=0
#        i=0
#        while [ $i -lt $num_isa_addrs ]
#        do
#            shift
#            param_usage_check $#
#            tmp="$1"
#            if [ $i -gt 0 ]
#            then
#                isa_addrs="$isa_addrs $tmp"
#                isa_addrs_hex="$isa_addrs_hex,0x$tmp"
#            else
#                isa_addrs=$tmp
#                isa_addrs_hex=0x$tmp
#            fi
#            i=`expr $i + 1`
#        done
        shift
        param_usage_check $#
#        intrline="$1"
        intrline=-1
        dmachan=-1
        shift
        param_usage_check $#
        max_pci_hw_modules="$1"
        shift
        param_usage_check $#
        phybufsize="$1"
        shift
        param_usage_check $#
        appbufsize="$1"
        shift
        param_usage_check $#
#        numapps="$1"
        shift
        param_usage_check $#
        machine_id="$1"
        shift
        param_usage_check $#
        do_reset="$1"
        shift
        param_usage_check $#
        history_enable="$1"
        shift
        param_usage_check $#
        dhsize="$1"
        shift
        param_usage_check $#
        num_hists_phy="$1"
        shift
        param_usage_check $#
        num_hists_apl="$1"
        shift
        param_usage_check $#
        hist_phy_admin_only="$1"
        shift
        param_usage_check $#
        num_I2O_frames_per_module="$1"
        shift
        param_usage_check $#
        fc_interval="$1"
        shift
        param_usage_check $#
        mem_drv_alloc_min="$1"
        shift
        param_usage_check $#
        mem_drv_alloc_quanta="$1"
        shift
        param_usage_check $#
        shift
        param_usage_check $#
        mill_test1="$1"
        shift
        param_usage_check $#
        mill_test2="$1"
        shift
        param_usage_check $#
        mill_test3="$1"
        num_reserved_modules=0
        init_mod_vals=0
        MAX_RESERVED_MODULE_NUMS=32
        while [ $num_reserved_modules -lt $MAX_RESERVED_MODULE_NUMS ]
        do
            shift
            param_usage_check $#
            m1="$1"
            if [ $m1 -eq 0 ]
            then
                break
            fi
            shift
            param_usage_check $#
            m2="$1"
#           tmp_mod_val={0x$m1,0x$m2}
            tmp_mod_val=0x$m1,0x$m2

            if [ $num_reserved_modules -eq 0 ]
            then
                init_mod_vals=$tmp_mod_val
            else
                init_mod_vals=$init_mod_vals,$tmp_mod_val
            fi
            num_reserved_modules=`expr $num_reserved_modules + 1`
        done

        #The part of this section below this point is saved for
        #platform-specific installation parameters
        shift
        param_usage_check $#
#        selected_kernel_dir="$1"

        if [ $# -ne 1 ]
        then
            xecho Incorrect number of configuration parameters.
            usage
        fi
    fi
    driver_install
    exit 0
}

# Platform specific function for determining kernel dir
# Now just verifies that we support the booted kernel
check_kernel_dir()
{
    #Find current kernel version, check for dir in kvers
#    kernel_dir=`/bin/uname -r | /bin/awk --field-separator=s '{print $1}'`
    kernel_dir=`/bin/uname -r`
    if [ ! -d ../kernel/kvers/$kernel_dir ]
    then
        xecho Support for current kernel version $kernel_dir not found.
        xecho "Sorry, but the Brooktrout installation script must abort."
        exit 2
    fi

    driv_kvers_dir=../kernel/kvers
}

getnum()
{
    read tmpxyz
    xecho "$tmpxyz" | /bin/grep -q '^[0-9]*$'
    if [ $? = 0 ]
    then
        eval $1=$tmpxyz
        return 0
    fi
    return 1
}


# Execution starts here

check_cmd_line $*
exit 0
