/*
   queue_library.h --- queue library internals.

   Copyright (c) 1995 SHW Wabnitz
   Written by Bernhard Fastenrath (fasten@shw.com)

   This file may be distributed under the terms
   of the GNU General Public License.
*/

#include <exec/types.h>
#include <exec/lists.h>
#include <exec/nodes.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <dos/filehandler.h>

#include <proto/exec.h>
#include <proto/dos.h>

#include <stdlib.h>
#include <string.h>

#include "queue.h"

typedef struct List List;
typedef struct Node Node;
typedef struct MinNode MinNode;
typedef struct MsgPort MsgPort;
typedef struct Message Message;
typedef struct SignalSemaphore Semaphore;
typedef struct Task Task;

typedef struct {
  Node		qn_Node;
  List		qn_List;
  ULONG		qn_Refs;
  ULONG		qn_Read;
  List		qn_Handles;
  Semaphore	qn_Semaphore;
} QueueNode;

/* bitmasks for qm_Status */
#define QMS_ACTIVE   0x01
#define QMS_INACTIVE 0x02
#define QMS_REMOVED ( QMS_INACTIVE | 0x04 )
#define QMS_MARKER  ( QMS_INACTIVE | 0x08 )

typedef struct {
  MinNode       qh_MinNode;
  USHORT        qh_Mode;
  USHORT        qh_Pad;
  QueueNode    *qh_QNode;
  ULONG		qh_SigMask;
  Task         *qh_SigTask;
  union {
    struct {
      QMessage *qhl_Message;
      MinNode   qhl_MinNode; /* same as qm_MinNode */
      USHORT    qhl_Status;  /* same as qm_Status  */
      USHORT    qhl_Pad;
    } qhl;
    struct {
      List	qhs_ReplyList;
      ULONG	qhs_MsgCount;
    } qhs;
  } qh_un;
} QueueHandle;
