#include	"quotas.h"
#include	"hsubs.h"

extern	struct	qent	q;
uint	lent = -1;
getqent(fd, pq, name)
short fd;
register struct qent *pq;
register char *name;
{
	register uint	qval;
	char err;

	err = 0;
	qval = hkey(name);
	lseek(fd, (long)(qval) * QSZ, 0);

lp:
	if(read(fd, pq, QSZ) != QSZ){
		if(err++){
			write(2, "Read error in quofile\n", 22);
			return(0);
		}
		lseek(fd, 0L, 0);
		qval = 0;
		goto lp;
	}
	if(pq->q_ln[0] == 0){
		lent = qval;
		return(0);
	}
	if(strncmp(pq->q_ln, name, 8)){
		qval++;
		if(qval >= NHENT){
			qval = 0;
			lseek(fd, 0L, 0);
		}
		goto lp;
	}
	return(qval);
}

ckquo()
{
	if(q.q_fused <= q.q_fquo &&
		q.q_dused <= q.q_dquo &&
		(q.q_mquo == 0 || q.q_mused <= q.q_mquo))
			q.q_flg &= ~037;
}
