1 /***********************************************************************/
2 /* Open Visualization Data Explorer                                    */
3 /* (C) Copyright IBM Corp. 1989,1999                                   */
4 /* ALL RIGHTS RESERVED                                                 */
5 /* This code licensed under the                                        */
6 /*    "IBM PUBLIC LICENSE - Open Visualization Data Explorer"          */
7 /***********************************************************************/
8 
9 #include <dxconfig.h>
10 
11 
12 #include <dx/dx.h>
13 #include "config.h"
14 #include "distp.h"
15 
16 /*
17  * Initialize the structures for the dpsend queue.
18  */
_dxf_ExSendQInit(DPSendQ * sendq)19 Error _dxf_ExSendQInit (DPSendQ *sendq)
20 {
21     sendq->head = NULL;
22     sendq->tail = NULL;
23 
24     return (OK);
25 }
26 
27 /*
28  * Insert an entry into the dpsend queue.
29  */
_dxf_ExSendQEnqueue(DPSendQ * sendq,DPSendPkg * pkg)30 void _dxf_ExSendQEnqueue (DPSendQ *sendq, DPSendPkg *pkg)
31 {
32     dps_elem	*elem;
33 
34     if (pkg == NULL)
35 	return;
36 
37     if ((elem = (dps_elem *) DXAllocate (sizeof (dps_elem))) == NULL)
38 	_dxf_ExDie ("_dxf_ExSendQEnqueue:  can't Allocate");
39 
40     elem->pkg   = pkg;
41     elem->next  = NULL;
42 
43     if (sendq->head)
44         (sendq->tail)->next = elem;		/* add to end */
45     else
46         sendq->head = elem;			/* new list */
47 
48     sendq->tail = elem;
49 
50 }
51 
52 /*
53  * Remove an entry from the dpsend queue.
54  */
_dxf_ExSendQDequeue(DPSendQ * sendq)55 DPSendPkg *_dxf_ExSendQDequeue (DPSendQ *sendq)
56 {
57     dps_elem	*elem;
58     DPSendPkg	*pkg;
59 
60     if (sendq->head == NULL)
61 	return (NULL);
62 
63     elem = sendq->head;
64     sendq->head = elem->next;
65 
66     if (sendq->tail == elem)			/* last one */
67 	sendq->tail = NULL;
68 
69     pkg = elem->pkg;
70     DXFree ((Pointer)elem);
71 
72     return (pkg);
73 }
74 
_dxf_ExSendQEmpty(DPSendQ * sendq)75 int _dxf_ExSendQEmpty(DPSendQ *sendq)
76 {
77     if(sendq->head)
78         return(FALSE);
79     else return(TRUE);
80 }
81