/*
 *	Copyright (c) 1995, 1996, Sun Microsystems, Inc.
 *
 * This software is provided by Sun ``AS IS'' and any express or implied
 * warranties, including, but not limited to, the implied warranties of
 * merchantability and fitness for a particular purpose are disclaimed.
 * In no event shall Sun Microsystems be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages.
 *
 * This software is not a product, and is provided for evaluation purposes
 * only.
 *
 * This software may not be resold without the express permission of
 * Sun Microsystems.
 *
 * Feedback on this tool may be sent to packet-shell-owner@sunroof.eng.sun.com.
 *
 * Packet Shell.
 */

#pragma ident	"@(#)name2int.c	1.5	98/11/12 SMI"

#include <string.h>
#include "name2int.h"

int
name2int(char *name, int *value, struct nameint *n2ip, int tsize)
{
	while (tsize-- > 0) {
		if (strcmp(name, n2ip->name) == 0) {
			*value = n2ip->value;
			return (1);
		}
		n2ip++;
	}
	return (0);
}

char *
int2name(int value, struct nameint *n2ip, int tsize)
{
	while (tsize-- > 0) {
		if (value == n2ip->value) {
			return (n2ip->name);
		}
		n2ip++;
	}
	return (0);
}
