xref: /csrg-svn/usr.bin/pascal/libpc/NAM.c (revision 1666)
1*1666Smckusick /* Copyright (c) 1979 Regents of the University of California */
2*1666Smckusick 
3*1666Smckusick static char sccsid[] = "@(#)NAM.c 1.1 10/30/80";
4*1666Smckusick 
5*1666Smckusick #include "h00vars.h"
6*1666Smckusick #include "h01errs.h"
7*1666Smckusick 
8*1666Smckusick char *
9*1666Smckusick NAM(value, name)
10*1666Smckusick 
11*1666Smckusick 	register int	value;	/* internal enumerated type value */
12*1666Smckusick 	char		*name;	/* ptr to enumerated type name descriptor */
13*1666Smckusick {
14*1666Smckusick 	register short	*sptr;
15*1666Smckusick 
16*1666Smckusick 	sptr = (short *)name;
17*1666Smckusick 	if (value < 0 || value >= *sptr) {
18*1666Smckusick 		ERROR(ENAMRNG, value);
19*1666Smckusick 		return;
20*1666Smckusick 	}
21*1666Smckusick 	sptr++;
22*1666Smckusick 	return	name + 2 + sptr[value];
23*1666Smckusick }
24