:
#
# Copyright (c) 1995, 1997, 1998, 1999 Oracle Corporation
# $Header: genautab.sh.pp 01-jun-99.14:59:59 smckinle Exp $
#
#!/bin/sh 
#
# genautab generates nautab.o, much in the same way that gennttab works.
# usage: genautab [ nau_adapter ]+
# or     genautab NONE -> to generate an empty table
#
# generates .s file for SunOS 5 and AIXRIOS
# .c file for all others
#

# List of current valid authentication adapter names:
PREFIXES='SECURID | KERBEROS5 | OPENVISION | CYBERSAFE | IDENTIX | DCE1| NDS
DCEGSSAPI | IBMNETSP | RADIUS'

USAGE="usage: $0 [ $PREFIXES ] | NONE " 

# Default is to use non of the available drivers
for name in `echo $PREFIXES | sed 's/|/ /g'`
do
	eval NAU_USE_$name=false
done

if [ "$1" = "" ]
then
  ARG1="NONE"
else
  ARG1=$1
fi

if [ "${ARG1}" != "NONE" ]
then
  for arg in $*			# check for adapters to include
  do
	name=`echo $arg | tr [a-z] [A-Z]`	#uppercase arg

        eval arg_valid=FALSE                    #check for valid argument

        for adapter in `echo $PREFIXES | sed 's/|/ /g'`
        do
          if [ "$name" = "$adapter" ]
          then
		eval NAU_USE_$name=TRUE
                eval arg_valid=TRUE
 		break
          fi
	done
        if [ "$arg_valid" = "FALSE" ]
        then
          echo $USAGE 1>&2
          exit 1
        fi
  done
fi

# Count number of entries
count=0

#
# Generate assambly for SunOS5
#

# Print the comment header for the output file
echo '!'
echo '!'
echo '! This file is GENERATED by genautab on Solaris 2.x / SunOS 5.'
echo '!'
echo '!'

echo '#if __sparcv9'
echo '#define DALIGNMENT 8'
echo '#define ALWORD .align DALIGNMENT; .xword'
echo '#else'
echo '#define DALIGNMENT 4'
echo '#define ALWORD .align DALIGNMENT; .word'
echo '#endif'
echo

echo '! define cpp macros'
echo
echo '#define DATA .section ".data",#alloc,#write'
echo '#define STRING .section ".rodata1",#alloc'
echo '#define CONSTANT .section ".rodata",#alloc'
echo '#define TYPE(label, size) .type label, #object; .size label, size'

echo
echo '! More macros'

# str1 = name of the service
# len  = length of service name
# ptr  = boot function for authentication adapter
# prt2 = pointer to additional arguments for boot function
# len  = number of arguments
echo '#define NAUTABCON_RECORD(str1, len, ptr, ptr2, len2, ptr3, ptr4) \
ALWORD str1 ;\
ALWORD len ;\
ALWORD ptr ;\
ALWORD ptr2 ;\
ALWORD len2 ;\
ALWORD ptr3 ;\
ALWORD ptr4
'

echo '
! Declare the string table
! Adapter name, modele name, entry function name

	STRING
.SEC:     .asciz  "SECURID"
          .align	DALIGNMENT
.SECM:    .asciz  "nsid"
          .align	DALIGNMENT
.SECE:    .asciz  "nauseid"
          .align	DALIGNMENT
.KRB5:    .asciz  "KERBEROS5"
          .align	DALIGNMENT
.KRB5M:   .asciz  "nk5"
          .align	DALIGNMENT
.KRB5E:   .asciz  "nauk5akerberos"
          .align	DALIGNMENT
.CYB:     .asciz  "CYBERSAFE"
          .align	DALIGNMENT
.CYBM:    .asciz  "ngss"
          .align	DALIGNMENT
.CYBE:    .asciz  "naugssapi"
          .align	DALIGNMENT
.OVN:     .asciz  "OPENVISION"
          .align	DALIGNMENT
.OVNM:    .asciz  "ngss"
          .align	DALIGNMENT
.OVNE:    .asciz  "naugssapi"
          .align	DALIGNMENT
.IDTX:    .asciz  "IDENTIX"
          .align	DALIGNMENT
.IDTXM:   .asciz  "nidx"
          .align	DALIGNMENT
.IDTXE:   .asciz  "nauidtx"
          .align	DALIGNMENT
.DCE1:    .asciz  "DCE1.0"
          .align	DALIGNMENT
.DCE1M:   .asciz  "ndce"
          .align	DALIGNMENT
.DCE1E:   .asciz  "naudini"
          .align	DALIGNMENT
.NDS:     .asciz  "NDS"
          .align	DALIGNMENT
.NDSM:    .asciz  "nnds"
          .align	DALIGNMENT
.NDSE:    .asciz  "naunds"
          .align	DALIGNMENT
.IBMNET:  .asciz  "IBMNETSP"
	  .align	DALIGNMENT
.IBMNETM: .asciz  "ngss"
	  .align	DALIGNMENT
.IBMNETE: .asciz  "naugssapi"
	  .align	DALIGNMENT
.DCEG:    .asciz  "DCEGSSAPI"
          .align	DALIGNMENT
.DCEGM:   .asciz  "ngss"
	  .align	DALIGNMENT
.DCEGE:   .asciz  "naugssapi"
          .align	DALIGNMENT
.RADIUS:  .asciz  "RADIUS"
          .align	DALIGNMENT
.RADIUSM: .asciz  "nrad"
          .align	DALIGNMENT
.RADIUSE: .asciz  "nauradius"
          .align	DALIGNMENT

! Now the protocol table

	DATA
	.global	nautab
nautab:
'

if [ "$NAU_USE_SECURID" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.SEC, 7 , nauseid, 0, 0, .SECM, .SECE)'
fi
if [ "$NAU_USE_KERBEROS5" = "TRUE" ]
then
     count=`expr $count + 1`
     echo 'NAUTABCON_RECORD(.KRB5, 9 , nauk5akerberos, 0, 0, .KRB5M, .KRB5E)'
fi
if [ "$NAU_USE_CYBERSAFE" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.CYB, 9 , naugssapi, 0, 0, .CYBM, .CYBE)'
fi
if [ "$NAU_USE_OPENVISION" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.OVN, 10 , naugssapi, 0, 0, .OVNM, .OVNE)'
fi
if [ "$NAU_USE_IDENTIX" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.IDTX, 7 , nauidtx, 0, 0, .IDTXM, .IDTXE)'
fi
if [ "$NAU_USE_DCE1" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.DCE1, 6 , naudini, 0, 0, .DCE1M, .DCE1E)'
fi
if [ "$NAU_USE_NDS" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.NDS, 6 , naunds, 0, 0, .NDSM, .NDSE)'
fi
if [ "$NAU_USE_IBMNETSP" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.IBMNET, 8, naugssapi,0,0, .IBMNETM, .IBMNETE)'
fi
if [ "$NAU_USE_DCEGSSAPI" = "TRUE" ]
then
	count=`expr $count + 1`
	echo 'NAUTABCON_RECORD(.DCEG, 9 , naugssapi, 0, 0, .DCEGM, .DCEGE)'
fi

if [ "$NAU_USE_RADIUS" = "TRUE" ]
then
        count=`expr $count + 1`
        echo 'NAUTABCON_RECORD(.RADIUS, 6, nauradius, 0, 0, .RADIUSM, .RADIUSE)'
fi

echo '
! Final record, similar to C : { 0,0,0,0,0,0,0 }
NAUTABCON_RECORD(0, 0, 0, 0, 0, 0, 0)

.size nautab, (.-nautab);
.type nautab, #object

! const eword nautabnum = (sizeof(nautab)/sizeof(nautab[0])) - 1;

	CONSTANT
	.global	nautabnum
nautabnum:
	.align	DALIGNMENT
'
# Double quotes need for count to print

echo "	.word	$count"

echo ' .size nautabnum, (.-nautabnum);
.type nautabnum, #object'

echo '
! Epilog

'

