# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.
#ident	"$Header: gen-defs 1.2 89/10/10 $@(#)nlp:lib/oam/gen-defs	1.1"
##########
#
# Generate ../../include/oam_def.h
##########

echo "/*This file is automatically generated from msg.source.*/"

csplit -k -s msg.source /E_.*__MSGS/ {99} 2>/dev/null

sed -n -e '/^[ 	]*#/p' xx00
rm xx00

echo 'extern char		**_oam_msg_base_;'
for x in xx??
do
	BASE=`line <${x}`
	base=`echo ${BASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
	echo 'extern char		*'${base}'[];'
done

for x in xx??
do

    (
	BASE=`line`
	base=`echo ${BASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`

	echo "${BASE}"

	sed -e '/^[ 	]*$/d' \
	| sed -n \
      -e 's/^[ 	]*\(E_.*\)$/\1:(_oam_msg_base_='${base}',(long)(:-'${BASE}'))/p' \
      -e '/^[ 	]*#/p'
    ) <${x}

done \
| nl -bp"^E_" -v0 -i2 -s: \
| sed \
      -e 's/^[ 	]*\([0-9]*\):\(E_.*\):\(.*\):\(.*\)$/#define \2 \3\1\4/' \
      -e 's/^[ 	]*\([0-9]*\):\(E_.*\)$/#define \2 (\1+2)/' \
| sed -e 's/^[ 	]*//'
