#!/bin/sh
#++++++++++++++++
# Copyright:    (C) 2008-2017 UDS/CNRS
# License:       GNU General Public License
#.IDENTIFICATION findcat
#.LANGUAGE       C-shell
#.AUTHOR         Francois Ochsenbein [CDS]
#.ENVIRONMENT    
#.KEYWORDS       
#.VERSION  1.0   18-Feb-1993
#.VERSION  1.1   01-Sep-2008: for proxy usage
#.VERSION  1.2   29-Aug-2009: Bourne shell
#.PURPOSE        Find Catalogues
#.COMMENTS       
#----------------

D_BIN=`dirname $0`
PATH="$D_BIN:$PATH"
server=cdsarc.u-strasbg.fr	# The only server for catalogs

if test $# -eq 0 ; then
    echo "Usage: `basename $0` keyword..."
    exit 1
fi

which aclient | awk 'NF!=1{exit 1}'; use_http=$?
test `expr "$CDSCLIENT" : http` -gt 0 && use_http=1
test -z "$http_proxy" || use_http=1

if [ $use_http -eq 0 ]; then			# Use aclient/aserver
    exec aclient $server 1660 qcat % "$@"	# % means: code special chars
fi

# Use http
exec aclient_cgi $server qcat "$@"
