/*
 * This code is part of Screws project.
 * Copylefted by pancake@phreaker.net at 2003
 */

#include "Queue.h"

#ifndef NULL
#define NULL 0x0
#endif

void
q_ini_queue (q)
    queue_t* q;
{
    q->last=q->first=NULL;
}

void
q_enqueue (q, n)
    queue_t* q;
    node_t* n;
{
    if (q->first == NULL)
	q->first = n;
    n->next = NULL;
    if (q->last != NULL)
	q->last->next = n;
    q->last = n;
}

int
q_last (q, n)
    queue_t* q;
    node_t* n;
{
    return ((q->last != NULL) && (q->last == n));
}

node_t*
q_first (q)
    queue_t* q;
{
    return q->first;
}

node_t*
q_next (q, n)
    queue_t* q;
    node_t* n;
{
    return n->next;
}

