#ifndef lint
static char *RCSid = "$Header: nat.c,v 1.4 89/09/26 19:53:10 mr-frog Exp $";
#endif

/*
 * nat.c
 *
 * XXX Perhaps make this process another tm_client?
 * misc nation file access ...gross.
 *
 * Dave Pare, 1986
 */

#include "misc.h"
#include "nat.h"
#include "file.h"
#include <fcntl.h>

int
natbyname(name)
	char	*name;
{
	struct	natstr *np;
	int	i;

	ef_close(EF_NATION);
	ef_open(EF_NATION, O_RDONLY, EFF_MEM);
	for (i=0; np = getnatp(i); i++) {
		if (strcmp(np->nat_cnam, name) == 0)
			return i;
	}
	return -1;
}

int
natpass(cn, pass)
	int	cn;
	char	*pass;
{
	struct	natstr *np;

	ef_close(EF_NATION);
	ef_open(EF_NATION, O_RDONLY, EFF_MEM);
	np = getnatp((natid)cn);
	if (np->nat_stat == VIS)
		return 1;
	if (strcmp(np->nat_pnam, pass) == 0)
		return 1;
	return 0;
}
