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