140412Sbostic /*
262087Sbostic  * Copyright (c) 1988, 1989, 1990, 1993
362087Sbostic  *	The Regents of the University of California.  All rights reserved.
440412Sbostic  *
540412Sbostic  * This code is derived from software contributed to Berkeley by
640412Sbostic  * Adam de Boor.
740412Sbostic  *
842741Sbostic  * %sccs.include.redist.c%
940412Sbostic  */
1040412Sbostic 
1140412Sbostic #ifndef lint
12*69094Schristos static char sccsid[] = "@(#)lstIsAtEnd.c	8.2 (Berkeley) 04/28/95";
1340412Sbostic #endif /* not lint */
1440412Sbostic 
1540411Sbostic /*-
1640411Sbostic  * LstIsAtEnd.c --
1740411Sbostic  *	Tell if the current node is at the end of the list.
1840411Sbostic  *	The sequential functions access the list in a slightly different way.
1940411Sbostic  *	CurPtr points to their idea of the current node in the list and they
2040411Sbostic  *	access the list based on it. Because the list is circular, Lst_Next
2140411Sbostic  *	and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
2240411Sbostic  *	used to determine when to stop.
2340411Sbostic  */
2440411Sbostic 
2540411Sbostic #include	"lstInt.h"
2640411Sbostic 
2740411Sbostic /*-
2840411Sbostic  *-----------------------------------------------------------------------
2940411Sbostic  * Lst_IsAtEnd --
3040411Sbostic  *	Return true if have reached the end of the given list.
3140411Sbostic  *
3240411Sbostic  * Results:
3340411Sbostic  *	TRUE if at the end of the list (this includes the list not being
3440411Sbostic  *	open or being invalid) or FALSE if not. We return TRUE if the list
3540411Sbostic  *	is invalid or unopend so as to cause the caller to exit its loop
3640411Sbostic  *	asap, the assumption being that the loop is of the form
3740411Sbostic  *	    while (!Lst_IsAtEnd (l)) {
3840411Sbostic  *	    	  ...
3940411Sbostic  *	    }
4040411Sbostic  *
4140411Sbostic  * Side Effects:
4240411Sbostic  *	None.
4340411Sbostic  *
4440411Sbostic  *-----------------------------------------------------------------------
4540411Sbostic  */
4640411Sbostic Boolean
Lst_IsAtEnd(l)4740411Sbostic Lst_IsAtEnd (l)
4840411Sbostic     Lst	    l;
4940411Sbostic {
5040411Sbostic     register List list = (List) l;
5140411Sbostic 
5240411Sbostic     return (!LstValid (l) || !list->isOpen ||
5340411Sbostic 	    (list->atEnd == Head) || (list->atEnd == Tail));
5440411Sbostic }
5540411Sbostic 
56