#!/usr/bin/ksh
#############################################################
# Copyright 05/22/02 Sun Microsystems, Inc. All Rights Reserved         
#############################################################
# This small ksh program turns out an diagnostic code
# in a more easily understood message.
# It uses the file $X25LIBFILES/diags_dec to do this mapping
#

USAGE="Usage:\tx25diags diag\n\
\tdiag: the diagnostic code (hexa) to be decoded\n"

if [ $# = 0 ]
then
echo $USAGE
else

. /etc/snet_info

let number=16#$1
let diag=$number%256
let diag_root=$diag/16*16
let cause=$number/256

#echo ""
#echo cause is $cause "(decimal)"
#awk '{ if ($NF == cause) { print substr($0, 0, 74) } }' cause=$cause causes_dec

# NP CTE fix for bug 4626559, clarify meaningful scope of diags.
echo ""
echo "Incoming codes from non Sun devices should be checked with manufacturer's docs"
echo ""
echo diag is $diag "(decimal), " $1 "(hexa) :"
echo ""

awk '{ if ($NF == diag_root) { print substr($0, 0, 74) } \
       if ($NF == diag) { print substr($0, 0, 74) } }' \
       diag=$diag  diag_root=$diag_root $X25LIBFILES/diags_dec

echo ""

fi
