1 /* Part of publib.
2 
3    Copyright (c) 1994-2006 Lars Wirzenius.  All rights reserved.
4 
5    Redistribution and use in source and binary forms, with or without
6    modification, are permitted provided that the following conditions
7    are met:
8 
9    1. Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11 
12    2. Redistributions in binary form must reproduce the above
13       copyright notice, this list of conditions and the following
14       disclaimer in the documentation and/or other materials provided
15       with the distribution.
16 
17    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20    ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 /*
30  * File:	queue.h
31  * Purpose:	Declarations for Publib's queue abstract data type.
32  * Description:	A queue is a list-like data structure where all additions
33  *		are done at one end (the behind of the queue) all deletions at
34  *		the other end (the front of the queue).  It is very similar
35  *		to a queue in a large food store, except that no-one tries
36  *		to get in the queue anywhere except at the behind.
37  * Note:	This Publib module reserves all names beginning with
38  *		``queue'' or ``Queue''.
39  * Author:	Lars Wirzenius
40  * Version:	"@(#)publib:$Id: queue.h,v 1.1.1.1 1996/01/18 15:44:03 liw Exp $"
41  */
42 
43 
44 #ifndef __publib_queue_h_included
45 #define __publib_queue_h_included
46 
47 #include <stddef.h>
48 typedef struct queue Queue;
49 
50 Queue *queue_create(void);
51 void queue_destroy(Queue *);
52 void *queue_front(Queue *);
53 void *queue_remove(Queue *);
54 int queue_is_empty(Queue *);
55 int queue_add(Queue *, const void *, size_t);
56 
57 #ifdef __publib__
58 	struct queue_node {
59 		void *queue_data;
60 		struct queue_node *queue_previous;
61 	};
62 
63 	struct queue {
64 		struct queue_node *queue_front, *queue_behind;
65 	};
66 #endif
67 
68 #endif
69