#include        <fc.h>          /* fcs header                   */
#include	<pccom.ih>
extern	io_wvb;			/* value for write virtual block */
#define IO_WVB (int)&io_wvb

#DEFINE EOF     -10             /* end of file status           */

#define RECSIZ  132             /* size of the largest record   */

int     fdbin1[ SFDBW ] = {0};  /* fdb for file .stb file       */

char    outbuf[RECSIZ] = {0};    /* input file buffer            */
int     riob[2] = {0};          /* record i/o status block      */
int	_molun = 0;		/* Lun for accessing the stb file */

struct {
	int     type;
	struct  {
		long    nam;
		int     filler;
		int     adr;
		} symbol[20];
	} stbbuf = {0};

char   *fil = "RSX11M.STB";          /* parsed file name             */
char   *dev  = "LB:";          /* parsed device name           */
char   *uic  = "[1,54]";          /* parsed uic                   */

char	fmtstr[80] = {0};
int *fdsstb( ss)
char *ss;
{
char *edmsg();
union{
	int shrt[2];
	long lng;
	}s;

int	status = 0;
int	adr= 0 ;	/* address of the symbol found		*/
register int     i, j;	/* asorted loop and index counters	*/

	if((status = fcopen ( fdbin1, dev, uic, fil, _molun, FCSEQIO+FCROACC, NOFOB )) != ISSUC){
		*edmsg( fmtstr,"%NFile open error %P", &status)='\0';
		emt( QIOW, IO_WVB, 5,5,0,0 ,fmtstr,lenstr(fmtstr),0,0,0,0);
		return(0);
	}

	i = lenstr( ss);
	s.lng  = 0l;

	j = (i>3) ? 3 : i;
	s.shrt[0] = rad50(ss,j);
	if((i = i-3) >0 )
		s.shrt[1] = rad50( ss+3,i);

	while ((  status = getrb ( fdbin1, &stbbuf, 132, NORECNUM,&riob)) == ISSUC  ){
		i = (riob[1]- 2)/ 8;    /* loop count   */

		if ( stbbuf.type != 1 )
			continue;

		for ( j=0; j<i; j++ ){
			if ( s.lng == stbbuf.symbol[j].nam){
				fcclos( fdbin1);
				return( stbbuf.symbol[j].adr );
			}
		}
	}
	*edmsg(fmtstr,"%NRecord access error = %P", &status) = '\0';
	emt( QIOW, IO_WVB, 5,5,0,0,fmtstr, lenstr( fmtstr),0,0,0,0);
	fcclos ( fdbin1 );
	return( adr );
}
