1*40419Sbostic /*- 2*40419Sbostic * lstInt.h -- 3*40419Sbostic * Internals for the list library 4*40419Sbostic * 5*40419Sbostic * Copyright (c) 1988 by University of California Regents 6*40419Sbostic * 7*40419Sbostic * Permission to use, copy, modify, and distribute this 8*40419Sbostic * software and its documentation for any purpose and without 9*40419Sbostic * fee is hereby granted, provided that the above copyright 10*40419Sbostic * notice appears in all copies. Neither the University of California nor 11*40419Sbostic * Adam de Boor makes any representations about the suitability of this 12*40419Sbostic * software for any purpose. It is provided "as is" without 13*40419Sbostic * express or implied warranty. 14*40419Sbostic * 15*40419Sbostic * $Id: lstInt.h,v 1.11 89/06/13 15:01:46 adam Exp $ SPRITE (Berkeley) 16*40419Sbostic */ 17*40419Sbostic #ifndef _LSTINT_H_ 18*40419Sbostic #define _LSTINT_H_ 19*40419Sbostic 20*40419Sbostic #include "lst.h" 21*40419Sbostic 22*40419Sbostic typedef struct ListNode { 23*40419Sbostic struct ListNode *prevPtr; /* previous element in list */ 24*40419Sbostic struct ListNode *nextPtr; /* next in list */ 25*40419Sbostic short useCount:8, /* Count of functions using the node. 26*40419Sbostic * node may not be deleted until count 27*40419Sbostic * goes to 0 */ 28*40419Sbostic flags:8; /* Node status flags */ 29*40419Sbostic ClientData datum; /* datum associated with this element */ 30*40419Sbostic } *ListNode; 31*40419Sbostic /* 32*40419Sbostic * Flags required for synchronization 33*40419Sbostic */ 34*40419Sbostic #define LN_DELETED 0x0001 /* List node should be removed when done */ 35*40419Sbostic 36*40419Sbostic #define NilListNode ((ListNode)-1) 37*40419Sbostic 38*40419Sbostic typedef enum { 39*40419Sbostic Head, Middle, Tail, Unknown 40*40419Sbostic } Where; 41*40419Sbostic 42*40419Sbostic typedef struct { 43*40419Sbostic ListNode firstPtr; /* first node in list */ 44*40419Sbostic ListNode lastPtr; /* last node in list */ 45*40419Sbostic Boolean isCirc; /* true if the list should be considered 46*40419Sbostic * circular */ 47*40419Sbostic /* 48*40419Sbostic * fields for sequential access 49*40419Sbostic */ 50*40419Sbostic Where atEnd; /* Where in the list the last access was */ 51*40419Sbostic Boolean isOpen; /* true if list has been Lst_Open'ed */ 52*40419Sbostic ListNode curPtr; /* current node, if open. NilListNode if 53*40419Sbostic * *just* opened */ 54*40419Sbostic ListNode prevPtr; /* Previous node, if open. Used by 55*40419Sbostic * Lst_Remove */ 56*40419Sbostic } *List; 57*40419Sbostic 58*40419Sbostic #define NilList ((List)-1) 59*40419Sbostic 60*40419Sbostic /* 61*40419Sbostic * PAlloc (var, ptype) -- 62*40419Sbostic * Allocate a pointer-typedef structure 'ptype' into the variable 'var' 63*40419Sbostic */ 64*40419Sbostic #define PAlloc(var,ptype) var = (ptype) Malloc (sizeof (*var)) 65*40419Sbostic 66*40419Sbostic /* 67*40419Sbostic * LstValid (l) -- 68*40419Sbostic * Return TRUE if the list l is valid 69*40419Sbostic */ 70*40419Sbostic #define LstValid(l) (((Lst)l == NILLST) ? FALSE : TRUE) 71*40419Sbostic 72*40419Sbostic /* 73*40419Sbostic * LstNodeValid (ln, l) -- 74*40419Sbostic * Return TRUE if the LstNode ln is valid with respect to l 75*40419Sbostic */ 76*40419Sbostic #define LstNodeValid(ln, l) ((((LstNode)ln) == NILLNODE) ? FALSE : TRUE) 77*40419Sbostic 78*40419Sbostic /* 79*40419Sbostic * LstIsEmpty (l) -- 80*40419Sbostic * TRUE if the list l is empty. 81*40419Sbostic */ 82*40419Sbostic #define LstIsEmpty(l) (((List)l)->firstPtr == NilListNode) 83*40419Sbostic 84*40419Sbostic #endif _LSTINT_H_ 85