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[] = "@(#)lstOpen.c 8.2 (Berkeley) 04/28/95"; 1340412Sbostic #endif /* not lint */ 1440412Sbostic 1540411Sbostic /*- 1640411Sbostic * LstOpen.c -- 1740411Sbostic * Open a list for sequential access. The sequential functions access the 1840411Sbostic * list in a slightly different way. CurPtr points to their idea of the 1940411Sbostic * current node in the list and they access the list based on it. 2040411Sbostic * If the list is circular, Lst_Next and Lst_Prev will go around 2140411Sbostic * the list forever. Lst_IsAtEnd must be used to determine when to stop. 2240411Sbostic */ 2340411Sbostic 2440411Sbostic #include "lstInt.h" 2540411Sbostic 2640411Sbostic /*- 2740411Sbostic *----------------------------------------------------------------------- 2840411Sbostic * Lst_Open -- 2940411Sbostic * Open a list for sequential access. A list can still be searched, 3040411Sbostic * etc., without confusing these functions. 3140411Sbostic * 3240411Sbostic * Results: 3340411Sbostic * SUCCESS or FAILURE. 3440411Sbostic * 3540411Sbostic * Side Effects: 3640411Sbostic * isOpen is set TRUE and curPtr is set to NilListNode so the 3740411Sbostic * other sequential functions no it was just opened and can choose 3840411Sbostic * the first element accessed based on this. 3940411Sbostic * 4040411Sbostic *----------------------------------------------------------------------- 4140411Sbostic */ 4240411Sbostic ReturnStatus Lst_Open(l)4340411SbosticLst_Open (l) 4440411Sbostic register Lst l; 4540411Sbostic { 4640411Sbostic if (LstValid (l) == FALSE) { 4740411Sbostic return (FAILURE); 4840411Sbostic } 4940411Sbostic ((List) l)->isOpen = TRUE; 5040411Sbostic ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown; 5140411Sbostic ((List) l)->curPtr = NilListNode; 5240411Sbostic 5340411Sbostic return (SUCCESS); 5440411Sbostic } 5540411Sbostic 56