#!/bin/sh
#++++++++++++++++
# Copyright:    (C) 2008-2017 UDS/CNRS
# License:       GNU General Public License
#.IDENTIFICATION findenis
#.LANGUAGE       Bourne shell
#.AUTHOR         Francois Ochsenbein [CDS]
#.ENVIRONMENT    cdsclient package
#.KEYWORDS
#.VERSION  1.0   02-Mar-2001
#.VERSION  1.1   04-Jun-2003: 2nd Version
#.VERSION  1.2   23-Sep-2005: 3rd versions -- all versions in same physical file
#.VERSION  1.2   31-Jul-2007: Accept Jnames
#.VERSION  1.3   01-Sep-2008: for proxy usage
#.VERSION  1.4   30-Aug-2009: Bourne shell
#.PURPOSE        Find Stars in DENIS catakig
#.COMMENTS       Interface to the "aclient" remote query
#----------------

D_BIN=`dirname $0`
pgm=`basename $0`
rpc=`basename $0 | sed 's/find//'`
# No argument is assumed to call for help
test $# -eq 0 && exec $0 -help

# GSC: the version may be specificied as an argument
#   or at the end of the program
vers=`basename $0 | sed 's/findenis-*//'`

if [ -z "$vers" ]; then
    case "$1" in 
     [123]) vers="$1"; shift; 	;;
      [Pp]) vers="1";  shift; 	;;	# Preliminary version = 1
        "")  echo "Usage: $pgm version [query options]..."
            exit 1		;;
         *) vers="3";           ;;	# Default DENIS version
    esac
fi
test $# -eq 0 && exec $pgm $vers -help

rpc="denis${vers}"
pgm="find$rpc"
#echo "#...rpc=$rpc, pgm=$pgm, args=$* ($#)"


case "$1" in
     h*)  # Assume help
      exec $0 -help
      ;;
    -h*)  # Differs from standard help
    cat <<===Help
--------------------------------------------------------------------
Available DENIS versions:
     1 (1999Sep)   2 (2003Apr)   3 (2005Sep)
--------------------------------------------------------------------
Usage: $pgm J2000-center in decimal degrees [-r radius_in_arcmin]
   or  $pgm -i DENIS-identifier
   or  $pgm -f [file_with_data] [other_options]
   or  $pgm - [other_options]        (data in stdin)
--------------------------------------------------------------------
===Help
    exec $D_BIN/find_gen $pgm $rpc -rhelp
    ;;

  # Use the generic find_gen service
  *)
    exec $D_BIN/find_gen $pgm $rpc "$@"
    ;;
esac
