#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/lib/libcspoc/nls_print.sh 1.6 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1996,2011 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)88	1.6 src/43haes/lib/libcspoc/nls_print.sh, hacmp.cspoc, 61haes_r714 11/28/11 15:23:48
#
#   COMPONENT_NAME: CSPOC
#
#   FUNCTIONS: none
#
#   ORIGINS: 27
#
###############################################################################
#
#  Name:  nls_print
#
#  This routine prints messages from a message catalog
#
#  Arguments:    Meessage set number, Message Number [, Default Text]
#  Usage:        nls_print message_set, message_id, [default text], variables
#  Returns:      0 - success
#                2 - bad number (0) of arguments
#  Environment:  VERBOSE_LOGGING,PATH,NLSPATH,_MSG_CAT
#  Note:	 _MSG_CAT should be set to the message catalog name
#
###############################################################################

function nls_print
{
  PROGNAME=$(basename ${0})
  if [[ $VERBOSE_LOGGING == "high" ]]
  then
      set -x
      version='$Source: 61haes_r711 43haes/lib/libcspoc/nls_print.sh 3$'
  fi

  typeset CMD=$0
  CMD=${CMD##*/}

  USAGE="USAGE: $CMD { -1 | -2 } <message_set> <message_id> [default_message]"

  CSPOC_MSG_CAT=cspoc.cat

  set -u 

  case $1 in
   -1) # PRINT TO STDOUT
      exec 2>&1
      ;;
   -2) # PRINT TO STDERR
      exec >&2
      ;;
   *) # ERROR
     dspmsg ${CSPOC_MSG_CAT} -s 24 30 "ERROR: Must specify a stdout or stderr flag.\n"
     dspmsg ${CSPOC_MSG_CAT} -s 24 35 "$USAGE\n" $CMD >&2
     return 2
      ;;
  esac

  if (( $# < 2 ))
  then
     dspmsg ${CSPOC_MSG_CAT} -s 24 35 "$USAGE\n" $CMD >&2
     return 2
  else
     MSG_SET=$1
     MSG_ID=$2

     shift
     dspmsg $_MSG_CAT -s $MSG_SET $MSG_ID "$@"
  fi
  return 0
}

if [[ -n $@ ]]
then
    nls_print "$@"
fi
