1 /* list.h
2 
3    Written by D.R.Maszle
4    28 October 1991
5 
6    Copyright (c) 1991-2017 Free Software Foundation, Inc.
7 
8    This file is part of GNU MCSim.
9 
10    GNU MCSim is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    as published by the Free Software Foundation; either version 3
13    of the License, or (at your option) any later version.
14 
15    GNU MCSim is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with GNU MCSim; if not, see <http://www.gnu.org/licenses/>
22 */
23 
24 #ifndef LIST_H_DEFINED
25 
26 /* ----------------------------------------------------------------------------
27    Inclusions  */
28 
29 #include "hungtype.h"
30 
31 
32 /* ----------------------------------------------------------------------------
33    Typedefs  */
34 
35 typedef struct tagLISTELEM {   /* List element record */
36   PVOID pData;                 /* User data, to be recast */
37   struct tagLISTELEM *pleNext; /* Next in the list */
38 } LISTELEM, *PLISTELEM; /* tagLISTELEM */
39 
40 
41 typedef struct tagLIST { /* List header record */
42   PLISTELEM pleHead;     /* First elem in list */
43   PLISTELEM pleTail;     /* Last elem in list */
44   int    iSize;          /* Number of elems in list */
45 } LIST, *PLIST; /* tagLIST */
46 
47 /* Callback function for ForAllList, ForAllList3 */
48 typedef int (*PFI_FORLISTCALLBACK) (PVOID pData, PVOID pUserInfo);
49 typedef void (*PFI_FORLISTCALLBACK3) (PVOID pData, PVOID pUserInfo1,
50                                      PVOID pUserInfo2, PVOID pUserInfo3);
51 
52 /* Callback for FreeList() */
53 typedef void (*PFV_FREELISTCALLBACK) (PVOID pData);
54 
55 /* ----------------------------------------------------------------------------
56    Macros  */
57 
58 #define ListLength(plist) ((plist) ? (plist)->iSize : 0)
59 
60 
61 /* ----------------------------------------------------------------------------
62    Prototypes  */
63 
64 
65 int  ForAllList (PLIST plist, PFI_FORLISTCALLBACK pfiForAllData, PVOID pInfo);
66 void ForAllList3 (PLIST plist, PFI_FORLISTCALLBACK3 pfiCallback,
67                   PVOID pUserInfo1, PVOID pUserInfo2, PVOID pUserInfo3);
68 
69 void FreeList(PLIST *pplist, PFV_FREELISTCALLBACK pfvFreeData, BOOL bAndData);
70 
71 PLIST InitList (void);
72 
73 void QueueListItem (PLIST plist, PVOID pData);
74 
75 #define LIST_H_DEFINED
76 #endif
77 
78 /* end */
79 
80