1*40411Sbostic /*- 2*40411Sbostic * LstOpen.c -- 3*40411Sbostic * Open a list for sequential access. The sequential functions access the 4*40411Sbostic * list in a slightly different way. CurPtr points to their idea of the 5*40411Sbostic * current node in the list and they access the list based on it. 6*40411Sbostic * If the list is circular, Lst_Next and Lst_Prev will go around 7*40411Sbostic * the list forever. Lst_IsAtEnd must be used to determine when to stop. 8*40411Sbostic * 9*40411Sbostic * Copyright (c) 1988 by University of California Regents 10*40411Sbostic * 11*40411Sbostic * Permission to use, copy, modify, and distribute this 12*40411Sbostic * software and its documentation for any purpose and without 13*40411Sbostic * fee is hereby granted, provided that the above copyright 14*40411Sbostic * notice appears in all copies. Neither the University of California nor 15*40411Sbostic * Adam de Boor makes any representations about the suitability of this 16*40411Sbostic * software for any purpose. It is provided "as is" without 17*40411Sbostic * express or implied warranty. 18*40411Sbostic */ 19*40411Sbostic #ifndef lint 20*40411Sbostic static char *rcsid = 21*40411Sbostic "$Id: lstOpen.c,v 1.6 88/11/17 20:53:43 adam Exp $ SPRITE (Berkeley)"; 22*40411Sbostic #endif lint 23*40411Sbostic 24*40411Sbostic #include "lstInt.h" 25*40411Sbostic 26*40411Sbostic /*- 27*40411Sbostic *----------------------------------------------------------------------- 28*40411Sbostic * Lst_Open -- 29*40411Sbostic * Open a list for sequential access. A list can still be searched, 30*40411Sbostic * etc., without confusing these functions. 31*40411Sbostic * 32*40411Sbostic * Results: 33*40411Sbostic * SUCCESS or FAILURE. 34*40411Sbostic * 35*40411Sbostic * Side Effects: 36*40411Sbostic * isOpen is set TRUE and curPtr is set to NilListNode so the 37*40411Sbostic * other sequential functions no it was just opened and can choose 38*40411Sbostic * the first element accessed based on this. 39*40411Sbostic * 40*40411Sbostic *----------------------------------------------------------------------- 41*40411Sbostic */ 42*40411Sbostic ReturnStatus 43*40411Sbostic Lst_Open (l) 44*40411Sbostic register Lst l; 45*40411Sbostic { 46*40411Sbostic if (LstValid (l) == FALSE) { 47*40411Sbostic return (FAILURE); 48*40411Sbostic } 49*40411Sbostic ((List) l)->isOpen = TRUE; 50*40411Sbostic ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown; 51*40411Sbostic ((List) l)->curPtr = NilListNode; 52*40411Sbostic 53*40411Sbostic return (SUCCESS); 54*40411Sbostic } 55*40411Sbostic 56