Commit | Line | Data |
---|---|---|
c65fedcf KB |
1 | /*- |
2 | * LstOpen.c -- | |
3 | * Open a list for sequential access. The sequential functions access the | |
4 | * list in a slightly different way. CurPtr points to their idea of the | |
5 | * current node in the list and they access the list based on it. | |
6 | * If the list is circular, Lst_Next and Lst_Prev will go around | |
7 | * the list forever. Lst_IsAtEnd must be used to determine when to stop. | |
8 | * | |
9 | * Copyright (c) 1988 by University of California Regents | |
10 | * | |
11 | * Permission to use, copy, modify, and distribute this | |
12 | * software and its documentation for any purpose and without | |
13 | * fee is hereby granted, provided that the above copyright | |
14 | * notice appears in all copies. Neither the University of California nor | |
15 | * Adam de Boor makes any representations about the suitability of this | |
16 | * software for any purpose. It is provided "as is" without | |
17 | * express or implied warranty. | |
18 | */ | |
19 | #ifndef lint | |
20 | static char *rcsid = | |
21 | "$Id: lstOpen.c,v 1.6 88/11/17 20:53:43 adam Exp $ SPRITE (Berkeley)"; | |
22 | #endif lint | |
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 | */ | |
42 | ReturnStatus | |
43 | Lst_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 |