windows-misc-20050722
[openafs.git] / src / WINNT / afsd / queue95.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* queue.h
11  *
12  * Class declaration for generic queue for use with Windows 95/DJGPP client
13  * disk cache
14  *
15  ***************************************************************************/
16
17 #ifndef _QUEUE_H
18 #define _QUEUE_H
19
20 /* offset of member m in struct T */
21 #define OFFSETOF(T, m) ((USHORT) &(((T *) NULL)->m))
22
23 /* get pointer to parent struct T containing member m at address p */
24 #define MEM_TO_OBJ(T, m, p) ((char *)(p) - OFFSETOF(T, m))
25
26 typedef struct _QLink {
27   struct _QLink *next;
28   struct _QLink *prev;
29   int ord;
30 } QLink;
31
32 typedef struct _Queue {
33   QLink *head;
34   QLink *tail;
35   int size;
36   QLink *currpos;
37 } Queue;
38
39 /* add item to tail of queue */
40 void QAddT(Queue *queue, QLink* node, int ord);
41
42 /* add item to head of queue */
43 void QAddH(Queue *queue, QLink *node, int ord);
44
45 /* add item based on order value */
46 void QAddOrd(Queue *queue, QLink *node, int ord);
47
48 /* remove and return head of queue */
49 QLink* QServe(Queue *queue);
50
51 /* move item to tail of queue */
52 void QMoveToTail(Queue *queue, QLink *x, int ord);
53
54 /* remove item from queue */
55 void QRemove(Queue *queue, QLink* x);
56
57 /* return current position */
58 QLink *QCurrent(Queue *queue);
59
60 /* print out list of queued items */
61 void QIterate(Queue *queue);
62
63 #endif