1 /*
2  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Adam de Boor.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  */
20 
21 #ifndef lint
22 static char sccsid[] = "@(#)lstIsAtEnd.c	5.2 (Berkeley) 03/11/90";
23 #endif /* not lint */
24 
25 /*-
26  * LstIsAtEnd.c --
27  *	Tell if the current node is at the end of the list.
28  *	The sequential functions access the list in a slightly different way.
29  *	CurPtr points to their idea of the current node in the list and they
30  *	access the list based on it. Because the list is circular, Lst_Next
31  *	and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
32  *	used to determine when to stop.
33  */
34 
35 #include	"lstInt.h"
36 
37 /*-
38  *-----------------------------------------------------------------------
39  * Lst_IsAtEnd --
40  *	Return true if have reached the end of the given list.
41  *
42  * Results:
43  *	TRUE if at the end of the list (this includes the list not being
44  *	open or being invalid) or FALSE if not. We return TRUE if the list
45  *	is invalid or unopend so as to cause the caller to exit its loop
46  *	asap, the assumption being that the loop is of the form
47  *	    while (!Lst_IsAtEnd (l)) {
48  *	    	  ...
49  *	    }
50  *
51  * Side Effects:
52  *	None.
53  *
54  *-----------------------------------------------------------------------
55  */
56 Boolean
57 Lst_IsAtEnd (l)
58     Lst	    l;
59 {
60     register List list = (List) l;
61 
62     return (!LstValid (l) || !list->isOpen ||
63 	    (list->atEnd == Head) || (list->atEnd == Tail));
64 }
65 
66