#ifndef lint
static char *RCSid = "$Header: /usr/brule/guest/empire/empire/emprcs/lib/gen/queue.c,v 2.1 1995/07/27 22:11:50 empire Exp $";
#endif

/*
 * queue.c
 *
 * insque, remque, initque
 *
 */

#include "queue.h"
void
insque(elem, queue)
	struct	qelem *elem;
	struct	qelem *queue;
{
	struct	qelem *next;

	next = queue->q_forw;
	queue->q_forw = elem;
	elem->q_forw = next;
	elem->q_back = queue;
	next->q_back = elem;
}

void
remque(elem)
	struct qelem *elem;
{
	if (elem == (struct qelem *)0)
		return;
	if (elem->q_forw != (struct qelem *)0)
		elem->q_forw->q_back = elem->q_back;
	if (elem->q_back != (struct qelem *)0)
		elem->q_back->q_forw = elem->q_forw;
}

void
initque(elem)
	struct	qelem *elem;
{
	elem->q_forw = elem;
	elem->q_back = elem;
}

