upgraded to the latest NetBSD version
[unix-history] / usr / src / usr.bin / make / lst.lib / lstOpen.c
CommitLineData
bb2109e7 1/*
4f703748
KB
2 * Copyright (c) 1988, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
bb2109e7
KB
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Adam de Boor.
7 *
f15db449 8 * %sccs.include.redist.c%
bb2109e7
KB
9 */
10
11#ifndef lint
bfdbffbb 12static char sccsid[] = "@(#)lstOpen.c 8.2 (Berkeley) %G%";
bb2109e7
KB
13#endif /* not lint */
14
c65fedcf
KB
15/*-
16 * LstOpen.c --
17 * Open a list for sequential access. The sequential functions access the
18 * list in a slightly different way. CurPtr points to their idea of the
19 * current node in the list and they access the list based on it.
20 * If the list is circular, Lst_Next and Lst_Prev will go around
21 * the list forever. Lst_IsAtEnd must be used to determine when to stop.
c65fedcf 22 */
c65fedcf
KB
23
24#include "lstInt.h"
25
26/*-
27 *-----------------------------------------------------------------------
28 * Lst_Open --
29 * Open a list for sequential access. A list can still be searched,
30 * etc., without confusing these functions.
31 *
32 * Results:
33 * SUCCESS or FAILURE.
34 *
35 * Side Effects:
36 * isOpen is set TRUE and curPtr is set to NilListNode so the
37 * other sequential functions no it was just opened and can choose
38 * the first element accessed based on this.
39 *
40 *-----------------------------------------------------------------------
41 */
42ReturnStatus
43Lst_Open (l)
44 register Lst l;
45{
46 if (LstValid (l) == FALSE) {
47 return (FAILURE);
48 }
49 ((List) l)->isOpen = TRUE;
50 ((List) l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
51 ((List) l)->curPtr = NilListNode;
52
53 return (SUCCESS);
54}
55