xref: /csrg-svn/usr.bin/make/lst.lib/lstInt.h (revision 40420)
1*40420Sbostic /*
2*40420Sbostic  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
3*40420Sbostic  * All rights reserved.
440419Sbostic  *
5*40420Sbostic  * This code is derived from software contributed to Berkeley by
6*40420Sbostic  * Adam de Boor.
740419Sbostic  *
8*40420Sbostic  * Redistribution and use in source and binary forms are permitted
9*40420Sbostic  * provided that the above copyright notice and this paragraph are
10*40420Sbostic  * duplicated in all such forms and that any documentation,
11*40420Sbostic  * advertising materials, and other materials related to such
12*40420Sbostic  * distribution and use acknowledge that the software was developed
13*40420Sbostic  * by the University of California, Berkeley.  The name of the
14*40420Sbostic  * University may not be used to endorse or promote products derived
15*40420Sbostic  * from this software without specific prior written permission.
16*40420Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17*40420Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18*40420Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1940419Sbostic  *
20*40420Sbostic  *	@(#)lstInt.h	5.2 (Berkeley) 03/12/90
2140419Sbostic  */
22*40420Sbostic 
23*40420Sbostic /*-
24*40420Sbostic  * lstInt.h --
25*40420Sbostic  *	Internals for the list library
26*40420Sbostic  */
2740419Sbostic #ifndef _LSTINT_H_
2840419Sbostic #define _LSTINT_H_
2940419Sbostic 
3040419Sbostic #include	  "lst.h"
3140419Sbostic 
3240419Sbostic typedef struct ListNode {
3340419Sbostic 	struct ListNode	*prevPtr;   /* previous element in list */
3440419Sbostic 	struct ListNode	*nextPtr;   /* next in list */
3540419Sbostic 	short	    	useCount:8, /* Count of functions using the node.
3640419Sbostic 				     * node may not be deleted until count
3740419Sbostic 				     * goes to 0 */
3840419Sbostic  	    	    	flags:8;    /* Node status flags */
3940419Sbostic 	ClientData	datum;	    /* datum associated with this element */
4040419Sbostic } *ListNode;
4140419Sbostic /*
4240419Sbostic  * Flags required for synchronization
4340419Sbostic  */
4440419Sbostic #define LN_DELETED  	0x0001      /* List node should be removed when done */
4540419Sbostic 
4640419Sbostic #define NilListNode	((ListNode)-1)
4740419Sbostic 
4840419Sbostic typedef enum {
4940419Sbostic     Head, Middle, Tail, Unknown
5040419Sbostic } Where;
5140419Sbostic 
5240419Sbostic typedef struct	{
5340419Sbostic 	ListNode  	firstPtr; /* first node in list */
5440419Sbostic 	ListNode  	lastPtr;  /* last node in list */
5540419Sbostic 	Boolean	  	isCirc;	  /* true if the list should be considered
5640419Sbostic 				   * circular */
5740419Sbostic /*
5840419Sbostic  * fields for sequential access
5940419Sbostic  */
6040419Sbostic 	Where	  	atEnd;	  /* Where in the list the last access was */
6140419Sbostic 	Boolean	  	isOpen;	  /* true if list has been Lst_Open'ed */
6240419Sbostic 	ListNode  	curPtr;	  /* current node, if open. NilListNode if
6340419Sbostic 				   * *just* opened */
6440419Sbostic 	ListNode  	prevPtr;  /* Previous node, if open. Used by
6540419Sbostic 				   * Lst_Remove */
6640419Sbostic } *List;
6740419Sbostic 
6840419Sbostic #define NilList	  	((List)-1)
6940419Sbostic 
7040419Sbostic /*
7140419Sbostic  * PAlloc (var, ptype) --
7240419Sbostic  *	Allocate a pointer-typedef structure 'ptype' into the variable 'var'
7340419Sbostic  */
7440419Sbostic #define	PAlloc(var,ptype)	var = (ptype) Malloc (sizeof (*var))
7540419Sbostic 
7640419Sbostic /*
7740419Sbostic  * LstValid (l) --
7840419Sbostic  *	Return TRUE if the list l is valid
7940419Sbostic  */
8040419Sbostic #define LstValid(l)	(((Lst)l == NILLST) ? FALSE : TRUE)
8140419Sbostic 
8240419Sbostic /*
8340419Sbostic  * LstNodeValid (ln, l) --
8440419Sbostic  *	Return TRUE if the LstNode ln is valid with respect to l
8540419Sbostic  */
8640419Sbostic #define LstNodeValid(ln, l)	((((LstNode)ln) == NILLNODE) ? FALSE : TRUE)
8740419Sbostic 
8840419Sbostic /*
8940419Sbostic  * LstIsEmpty (l) --
9040419Sbostic  *	TRUE if the list l is empty.
9140419Sbostic  */
9240419Sbostic #define LstIsEmpty(l)	(((List)l)->firstPtr == NilListNode)
9340419Sbostic 
9440419Sbostic #endif _LSTINT_H_
95