#****************************************************************************
#  ##   ##         #####   #####  ##     **      NoSQL RDBMS - addtypes     *
#  ###  ##        ####### ####### ##     **      $Revision: 2.1 $			*
#  #### ##        ###     ##   ## ##     ************************************
#  #######  ####  #####   ##   ## ##     **      Carlo Strozzi (c) 1998     *
#  ####### ######   ##### ## # ## ##     ************************************
#  ## #### ##  ##     ### ##  ### ##     **           Written by            *
#  ##  ### ###### ####### ######  ###### **          Carlo Strozzi          *
#  ##   ##  ####   #####   #### # ###### **     e-mail: carlos@linux.it     *
#****************************************************************************
#   NoSQL RDBMS, Copyright (C) 1998 Carlo Strozzi.                          *
#   This program comes with ABSOLUTELY NO WARRANTY; for details             *
#   refer to the GNU General Public License.                                *
#****************************************************************************
#
# Shell front-end to NSQLIB/awk/addtypes. See the latter file for more
# explanations.
#
# Usage:  addtypes  [-w|--width n]  [-x|--debug c] < table
#
# where 'n' is a positive integer with the max. field length                    
# (truncation). The default is no truncation. Applying truncation               
# will affect the datatype detection.
#
# The 'debug' flag prints verbose info on column number 'c' to STDERR.
# If 'c' is not specified then no debug will occur.
#
##########################################################################

while [ $# -ge 1 ]
do
  case $1 in
    -w|--width)    shift; trunc=$1 ;;
    -x|--debug)    shift; debug=$1 ;;
    *)     		   break ;;
  esac
  shift
done

# Make sure this is a number.
trunc=$(expr "${trunc}" : '\([0-9]*$\)')

table_tmp=$(${NSQTEMPF})
trap "rm -f ${table_tmp}" 0 1 2 15

${NSQAWK:-awk} -f ${NSQLIB}/awk/addtypes -v debug=${debug:-0} \
	-v trunc=${trunc:-0} -v table_tmp=${table_tmp}

test -s ${table_tmp} && cat ${table_tmp}

