#!/bin/csh -f
echo "@(#)fixswap	30.1 3/13/91 AppEng/SCCS Interphase"
#
# Interphase Corporation Northern CA. Standards for Coding based on
# DOD-STD-2167A ( Draft )
#
# ABSTRACT : fixswap  is used by the '4410_install' script to update the
#            OS4 swapgeneric.c file.
#

# KEYWORDS fixswap fixswap.in vjbn.awk conf.c
#

# CONTENTS 
#
#                  Ident        Date            Author
# -------------------------------------------------------------------------
# Designed By :    X00.00	24-Feb-89	Robert Hogue (rogue)
# Coded By  : rogue
# Tested By : rogue (OS3.5 and OS4.0 on SUN3/160 only)

# Revision History :
#
# Rev#  Date     Author   Change
#--------------------------------------------------------------------------
# 30.1  03-13-91 rbrant   New development/distribution format.
#

# Examples of Usage : fixswap tempfile destinationfile
#

# Parameter Description : tempfile is a copy of the destination file
#                         destination file is 'swapgeneric.c'

# Special Design Considerations : none
#

# External Units Accessed :  ( Called, Imported, WITHed, referenced )
#
#     Unit Name                        Purpose
#-------------------------------------------------------------------------
# $AWKFILES and $FIXFILES defined in the IPinstall environment
# fix/fixswap.in	'ed' input file used by fixswap to modify swapgeneric.c
# awkfiles/vjbn.awk	used to replace the VJBN label in the modifications with
#			the actual 'vj' block major number.
# awkfiles/vjcn.awk	used to replace the VJCN label in the modifications with
#			the actual 'vj' character major number.
# interphase/conf.c	scanned by ipbn.awk and ipcn.awk to find the 'ip'
#			block and character major numbers.

# Exceptions and the Conditions which will raise them :
#

# Input / Output : ( Files, Keyboards, Consoles, printers, modems, etc. )
#
#     Device name    Access type      Purpose      Summary
#------------------------------------------------------------------------
#

# Machine Dependencies : ( registers, storage, ports, machine code, etc. )
#
# Access type      Purpose                        Justification
#-----------------------------------------------------------------------
#

#
#  Start
#
if !($#argv == 2 ) then
	echo "usage: fixswap tempfile destinationfile"
	exit
endif

#
# test to see if there is already an entry for 'vjcdriver' in swapgeneric.c
# 
set tst = `awk -f $AWKFILES/swap.awk $2`

#
# modify the file if the above test fails.. 0=no ip entry present,  1=is present
#
if($tst == 0) then
	#
	# edit the file to add Interphase support
	#
	ed $1 < $FIXFILES/fixswap.in >& /dev/null

	#
	# replace the dummy label (VJBN) with the actual vj block major number
	#
	echo -n 's/VJBN/' >> med.in
	echo `awk -f $AWKFILES/vjbn.awk conf.c`/g >> med.in

	#
	# replace the dummy label (VJCN) with the actual vj character major
	# number
	#
	echo -n 's/VJCN/' >> med.in
	echo `awk -f $AWKFILES/vjcn.awk conf.c`/g >> med.in

	#
	# Now actually make the edits using the 'awk' output file (med.in)
	#
	sed -f med.in $1 > $2

	#
	# Flush the 'awk' output file
	#
	/bin/rm -f med.in
else
    echo ""
    echo "Interphase support already present in 'swapgeneric.c'.. no mods made"
endif
exit	#fixswap
