1 /* $OpenBSD: lstInt.h,v 1.4 1996/11/30 21:09:18 millert Exp $ */ 2 /* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */ 3 4 /* 5 * Copyright (c) 1988, 1989, 1990, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Adam de Boor. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * 39 * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93 40 */ 41 42 /*- 43 * lstInt.h -- 44 * Internals for the list library 45 */ 46 #ifndef _LSTINT_H_ 47 #define _LSTINT_H_ 48 49 #include "make.h" 50 #include "lst.h" 51 52 typedef struct ListNode { 53 struct ListNode *prevPtr; /* previous element in list */ 54 struct ListNode *nextPtr; /* next in list */ 55 short useCount:8, /* Count of functions using the node. 56 * node may not be deleted until count 57 * goes to 0 */ 58 flags:8; /* Node status flags */ 59 ClientData datum; /* datum associated with this element */ 60 } *ListNode; 61 /* 62 * Flags required for synchronization 63 */ 64 #define LN_DELETED 0x0001 /* List node should be removed when done */ 65 66 #define NilListNode ((ListNode)-1) 67 68 typedef enum { 69 Head, Middle, Tail, Unknown 70 } Where; 71 72 typedef struct { 73 ListNode firstPtr; /* first node in list */ 74 ListNode lastPtr; /* last node in list */ 75 Boolean isCirc; /* true if the list should be considered 76 * circular */ 77 /* 78 * fields for sequential access 79 */ 80 Where atEnd; /* Where in the list the last access was */ 81 Boolean isOpen; /* true if list has been Lst_Open'ed */ 82 ListNode curPtr; /* current node, if open. NilListNode if 83 * *just* opened */ 84 ListNode prevPtr; /* Previous node, if open. Used by 85 * Lst_Remove */ 86 } *List; 87 88 #define NilList ((List)-1) 89 90 /* 91 * PAlloc (var, ptype) -- 92 * Allocate a pointer-typedef structure 'ptype' into the variable 'var' 93 */ 94 #define PAlloc(var,ptype) var = (ptype) emalloc (sizeof (*var)) 95 96 /* 97 * LstValid (l) -- 98 * Return TRUE if the list l is valid 99 */ 100 #define LstValid(l) (((Lst)l == NILLST) ? FALSE : TRUE) 101 102 /* 103 * LstNodeValid (ln, l) -- 104 * Return TRUE if the LstNode ln is valid with respect to l 105 */ 106 #define LstNodeValid(ln, l) ((((LstNode)ln) == NILLNODE) ? FALSE : TRUE) 107 108 /* 109 * LstIsEmpty (l) -- 110 * TRUE if the list l is empty. 111 */ 112 #define LstIsEmpty(l) (((List)l)->firstPtr == NilListNode) 113 114 #endif _LSTINT_H_ 115