1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
|
/*
*
* Copyright (c) International Business Machines Corp., 2000
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Module: dlist.h
*
* Functions: dlist_t CreateList
* int InsertItem
* int InsertObject
* int DeleteItem
* int DeleteAllItems
* int GetItem
* int GetNextItem
* int GetPreviousItem
* int GetObject
* int BlindGetObject
* int GetNextObject
* int GetPreviousObject
* int ExtractItem
* int ExtractObject
* int BlindExtractObject
* int ReplaceItem
* int ReplaceObject
* int GetTag
* int GetHandle
* int GetListSize
* BOOLEAN ListEmpty
* BOOLEAN AtEndOfList
* BOOLEAN AtStartOfList
* int DestroyList
* int NextItem
* int PreviousItem
* int GoToStartOfList
* int GoToEndOfList
* int GoToSpecifiedItem
* int SortList
* int ForEachItem
* int PruneList
* int AppendList
* int TransferItem
* int CopyList
* BOOLEAN CheckListIntegrity
*
* Description: This module implements a simple, generic, doubly linked list.
* Data objects of any type can be placed into a linked list
* created by this module. Furthermore, data objects of different
* types may be placed into the same linked list.
*
* Notes: This linked list implementation makes use of the concept of the
* current item. In any non-empty list, one item in the list will
* be designated as the current item. When any of the following
* functions are called, they will operate upon the current item
* only: GetItem, ReplaceItem, DeleteItem, GetTag, NextItem,
* PreviousItem, GetObject, ExtractItem, and ExtractObject. The
* user of this module may set the current item through the use of
* the GoToStartOfList, GoToEndOfList, NextItem, PreviousItem,
* and GoToSpecifiedItem functions.
*
* Since a linked list created by this module may contain items
* of different types, the user will need a way to identify items
* of different types which may be in the same list. To allow users
* to do this, the concept of an item tag is used. When an item is
* added to the list, the user must enter an item tag. The item
* tag is merely some identifier that the user wishes to associate
* with the item being placed into the list. When used as intended,
* each type of data item will have a unique tag associated with it.
* This way, all data items of the same type will have the same tag
* while data items of different types will have different tags.
* Thus, by using the GetTag function, the user can get the item
* tag for the current item without having to get the item from the
* list. This allows the user to differentiate between items of
* different types which reside in the same list.
*
* This module is single threaded. If used in a multi-threaded
* environment, the user must implement appropriate access controls.
*
* When an item is inserted or appended to a list, this module
* allocates memory on the heap to hold the item and then copies
* the item to the memory that it allocated. This allows local
* variables to be safely inserted or appended to a list. However,
* it should be noted that under certain circumstances a copy of the
* entire data item will NOT be made. Specifically, if the data item
* is a structure or array containing pointers, then the data pointed
* to by the pointers will NOT be copied even though the structure or
* array is! This results from the fact that, when an item is being
* inserted or appended to a list, the user provides just an address
* and size. This module assumes that the item to inserted or append
* lies in a contiguous block of memory at the address provided by the
* user. This module has no way of knowing the structure of the data
* at the specified address, and therefore can not know about any
* embedded pointers which may lie within that block of memory.
*
* This module now employs the concept of a handle. A handle is a
* reference to a specific item in a list which allows that item to
* be made the current item in the list quickly. Example: If you
* use the GetHandle function to get a handle for the current item
* (lets call the item B1), then, regardless of where you are in the
* list (or any reodering of the items in the list), you can make item
* B1 the current item by passing its handle to the GoToSpecifiedItem
* function. Alternatively, you could operate directly on B1 using
* the other handle based functions, such as GetItem_By_Handle, for
* example. GetItem_By_Handle gets the item associated with the
* specified handle without changing which item in the list is the
* current item in the list.
*
* The functions of this module refer to user data as either items or
* objects. The difference between the two is simple, yet subtle. It
* deals with who is responsible for the memory used to hold the data.
* In the case of an item, this module is responsible for the memory
* used to hold the user data. In the case of an object, the user
* is responsible for the memory used to hold the data.
*
* What this means is that, for functions adding ITEMS to a list,
* this module will be responsible for allocating memory to hold
* the user data and then copying the user data into the memory
* that was allocated. For functions which return items, this
* module will COPY the user data from the LIST into a buffer
* specified by the user. For functions which add objects to a
* list, the user provides a pointer to a block of memory holding
* user data. This block of memory was allocated by the user, and
* becomes the "property" of this module once it has been added to
* a LIST. For functions which return objects, a pointer to the
* memory where the data is stored is returned. As long as an item/object
* is in a LIST, this module will be responsible for the memory that
* is used to store the data associated with that item. This means that
* users of this module should not call free on an object returned by this
* module as long as that object is still within a list.
*
*
*/
#ifndef DLISTHANDLER
#define DLISTHANDLER 1
#include <linux/types.h> /* will pull in platform specific data type info from linux/include/asm */
#include <errno.h>
#ifndef BOOLEAN_DEFINED
#define BOOLEAN_DEFINED 1
typedef u_int8_t BOOLEAN;
#endif
typedef void * ADDRESS;
typedef ulong TAG;
struct LinkNodeRecord
{
ADDRESS DataLocation; /* Where the data associated with this LinkNode is */
uint DataSize; /* The size of the data associated with this LinkNode. */
TAG DataTag; /* The item tag the user gave to the data. */
struct MasterListRecord * ControlNodeLocation; /* The control node of the list containing this item. */
struct LinkNodeRecord * NextLinkNode; /* The LinkNode of the next item in the list. */
struct LinkNodeRecord * PreviousLinkNode; /* The LinkNode of the item preceding this one in the list. */
};
typedef struct LinkNodeRecord LinkNode;
struct MasterListRecord
{
uint ItemCount; /* The number of items in the list. */
LinkNode * StartOfList; /* The address of the LinkNode of the first item in the list. */
LinkNode * EndOfList; /* The address of the LinkNode of the last item in the list. */
LinkNode * CurrentItem; /* The address of the LinkNode of the current item in the list. */
#ifdef USE_POOLMAN
POOL NodePool; /* The pool of LinkNodes for this dlist_t. */
#endif
uint Verify; /* A field to contain the VerifyValue which marks this as a list created by this module. */
};
typedef struct MasterListRecord ControlNode;
typedef ControlNode * dlist_t;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef enum _Insertion_Modes {
InsertAtStart,
InsertBefore,
InsertAfter,
AppendToList,
} Insertion_Modes;
/* Update the IS_DLIST_ERROR() macro below if you add, remove, or change */
/* error codes. */
#define DLIST_SUCCESS 0
#define DLIST_OUT_OF_MEMORY ENOMEM
#define DLIST_CORRUPTED 201
#define DLIST_BAD 202
#define DLIST_NOT_INITIALIZED 203
#define DLIST_EMPTY 204
#define DLIST_ITEM_SIZE_WRONG 205
#define DLIST_BAD_ITEM_POINTER 206
#define DLIST_ITEM_SIZE_ZERO 207
#define DLIST_ITEM_TAG_WRONG 208
#define DLIST_END_OF_LIST 209
#define DLIST_ALREADY_AT_START 210
#define DLIST_BAD_HANDLE 211
#define DLIST_INVALID_INSERTION_MODE 212
#define DLIST_OBJECT_NOT_FOUND 213
#define DLIST_OBJECT_ALREADY_IN_LIST 214
/* Macro to determine if an error code is a dlist error code. */
#define IS_DLIST_ERROR(rc) ((abs(rc) >= DLIST_CORRUPTED) && (abs(rc) <= DLIST_OBJECT_ALREADY_IN_LIST))
/* The following code is special. It is for use with the PruneList and ForEachItem functions. Basically, these functions
can be thought of as "searching" a list. They present each item in the list to a user supplied function which can then
operate on the items. If the user supplied function returns a non-zero error code, ForEachItem and PruneList abort and
return an error to the caller. This may be undesirable. If the user supplied function used with PruneList and ForEachItem
returns the code below, PruneList/ForEachItem will abort and return DLIST_SUCCESS. This allows PruneList and ForEachItem
to be used to search a list and terminate the search when the desired item is found without having to traverse the
remaining items in the list. */
#define DLIST_SEARCH_COMPLETE 0xFF
#ifdef USE_POOLMAN
/*********************************************************************/
/* */
/* Function Name: CreateList */
/* */
/* Descriptive Name: This function allocates and initializes the */
/* data structures associated with a list and */
/* then returns a pointer to these structures. */
/* */
/* Input: uint InitialPoolSize - Each List gets a pool of */
/* link nodes. When items are */
/* added to the List, a link node*/
/* is removed from the pool. */
/* When an item is removed from */
/* the List, the link node used */
/* for that item is returned to */
/* the pool. InitialPoolSize is */
/* the number of link nodes to */
/* place in the pool when the */
/* pool is created. */
/* uint MaximumPoolSize - When the pool runs out of */
/* link nodes, new nodes are */
/* allocated by the pool. When */
/* these links start being */
/* returned to the pool, the pool*/
/* will grow. This parameter */
/* puts a limit on how big the */
/* pool may grow to. Once the */
/* pool reaches this size, any */
/* link nodes being returned to */
/* the pool will be deallocated. */
/* uint PoolIncrement - When the pool runs out of link*/
/* nodes and more are required, */
/* the pool will allocate one or */
/* more link nodes. This tells the*/
/* pool how many link nodes to */
/* allocate at one time. */
/* */
/* Output: If Success : The function return value will be non-NULL */
/* */
/* If Failure : The function return value will be NULL. */
/* */
/* Error Handling: The function will only fail if it can not */
/* allocate enough memory to create the new list */
/* and its associated pool of link nodes. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
dlist_t CreateList(uint InitialPoolSize,
uint MaximumPoolSize,
uint PoolIncrement);
#else
/*********************************************************************/
/* */
/* Function Name: CreateList */
/* */
/* Descriptive Name: This function allocates and initializes the */
/* data structures associated with a list and */
/* then returns a pointer to these structures. */
/* */
/* Input: None. */
/* */
/* Output: If Success : The function return value will be non-NULL */
/* */
/* If Failure : The function return value will be NULL. */
/* */
/* Error Handling: The function will only fail if it can not */
/* allocate enough memory to create the new list. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
dlist_t CreateList( void );
#endif
/*********************************************************************/
/* */
/* Function Name: InsertItem */
/* */
/* Descriptive Name: This function inserts an item into a dlist_t.*/
/* The item can be placed either before or */
/* after the current item in the dlist_t. */
/* */
/* Input: dlist_t ListToAddTo : The list to which the */
/* data item is to be */
/* added. */
/* uint ItemSize : The size of the data item, in */
/* bytes. */
/* ADDRESS ItemLocation : The address of the data */
/* to append to the list */
/* TAG ItemTag : The item tag to associate with */
/* item being appended to the list */
/* ADDRESS TargetHandle : The item in ListToAddTo which */
/* is used to determine where */
/* the item being transferred will */
/* be placed. If this is NULL, */
/* then the current item in */
/* ListToAddTo will be used. */
/* Insertion_Modes InsertMode : This indicates where, */
/* relative to the item in */
/* ListToAddTo specified by */
/* Target_Handle, the item being */
/* inserted can be placed. */
/* BOOLEAN MakeCurrent : If TRUE, the item being inserted */
/* into ListToAddTo becomes the */
/* current item in ListToAddTo. */
/* ADDRESS * Handle : The address of a variable to hold */
/* the handle for the item that was */
/* inserted into the list. */
/* */
/* Output: If all went well, the return value will be */
/* DLIST_SUCCESS and *Handle will contain the ADDRESS of */
/* the new item. If errors were encountered, the . */
/* return value will be the error code and *Handle will */
/* be NULL. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToAddTo does not point to a valid */
/* list */
/* ItemSize is 0 */
/* ItemLocation is NULL */
/* The memory required to hold a copy of the */
/* item can not be allocated. */
/* The memory required to create a LINK NODE */
/* can not be allocated. */
/* TargetHandle is invalid or is for an item */
/* in another list. */
/* If this routine fails, an error code is returned*/
/* and any memory allocated by this function is */
/* freed. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The item to add is copied to the heap to */
/* avoid possible conflicts with the usage of */
/* local variables in functions which process */
/* dlist_ts. However, a pointer to a local variable */
/* should not be appended to the dlist_t. */
/* */
/* It is assumed that TargetHandle is valid, or is at least*/
/* the address of an accessible block of storage. If */
/* TargetHandle is invalid, or is not the address of an */
/* accessible block of storage, then a trap or exception */
/* may occur. */
/* */
/* It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/*********************************************************************/
int InsertItem (dlist_t ListToAddTo,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS TargetHandle,
Insertion_Modes Insert_Mode,
BOOLEAN MakeCurrent,
ADDRESS * Handle);
/*********************************************************************/
/* */
/* Function Name: InsertObject */
/* */
/* Descriptive Name: This function inserts an object into a */
/* dlist_t. The object can be inserted before */
/* or after the current item in the list. */
/* */
/* Input: dlist_t ListToAddTo : The list to which the */
/* data object is to be */
/* inserted. */
/* uint ItemSize : The size of the data item, in */
/* bytes. */
/* ADDRESS ItemLocation : The address of the data */
/* to append to the list */
/* TAG ItemTag : The item tag to associate with */
/* the item being appended to the */
/* list */
/* ADDRESS TargetHandle : The item in ListToAddTo which */
/* is used to determine where */
/* the item being transferred will */
/* be placed. If this is NULL, */
/* then the current item in */
/* ListToAddTo will be used. */
/* Insertion_Modes Insert_Mode : This indicates where, */
/* relative to the item in */
/* ListToAddTo specified by */
/* Target_Handle, the item being */
/* inserted can be placed. */
/* BOOLEAN MakeCurrent : If TRUE, the item being inserted */
/* into ListToAddTo becomes the */
/* current item in ListToAddTo. */
/* ADDRESS * Handle : The address of a variable to hold */
/* the handle for the item that was */
/* inserted into the list. */
/* */
/* Output: If all went well, the return value will be */
/* DLIST_SUCCESS and *Handle will contain the ADDRESS of */
/* the new item. If errors were encountered, the . */
/* return value will be the error code and *Handle will */
/* be NULL. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToAddTo does not point to a valid */
/* list */
/* ItemSize is 0 */
/* ItemLocation is NULL */
/* The memory required for a LINK NODE can not */
/* be allocated. */
/* TargetHandle is invalid or is for an item */
/* in another list. */
/* If this routine fails, an error code is returned*/
/* and any memory allocated by this function is */
/* freed. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The item to insert is NOT copied to the heap. Instead, */
/* the location of the item is stored in the list. This */
/* is the major difference between InsertObject and */
/* InsertItem. InsertItem allocates memory on the heap, */
/* copies the item to the memory it allocated, and stores */
/* the address of the memory it allocated in the list. */
/* InsertObject stores the address provided by the user. */
/* */
/* It is assumed that TargetHandle is valid, or is at least*/
/* the address of an accessible block of storage. If */
/* TargetHandle is invalid, or is not the address of an */
/* accessible block of storage, then a trap or exception */
/* may occur. */
/* */
/* It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/*********************************************************************/
int InsertObject (dlist_t ListToAddTo,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS TargetHandle,
Insertion_Modes Insert_Mode,
BOOLEAN MakeCurrent,
ADDRESS * Handle);
/*********************************************************************/
/* */
/* Function Name: ExclusiveInsertObject */
/* */
/* Descriptive Name: This function inserts an object into a */
/* dlist_t. The object can be inserted before */
/* or after the current item in the list. If */
/* object is already in the list, it is not */
/* added again. */
/* */
/* Input: dlist_t ListToAddTo : The list to which the */
/* data object is to be */
/* inserted. */
/* uint ItemSize : The size of the data item, in */
/* bytes. */
/* ADDRESS ItemLocation : The address of the data */
/* to append to the list */
/* TAG ItemTag : The item tag to associate with */
/* the item being appended to the */
/* list */
/* ADDRESS TargetHandle : The item in ListToAddTo which */
/* is used to determine where */
/* the item being transferred will */
/* be placed. If this is NULL, */
/* then the current item in */
/* ListToAddTo will be used. */
/* Insertion_Modes Insert_Mode : This indicates where, */
/* relative to the item in */
/* ListToAddTo specified by */
/* Target_Handle, the item being */
/* inserted can be placed. */
/* BOOLEAN MakeCurrent : If TRUE, the item being inserted */
/* into ListToAddTo becomes the */
/* current item in ListToAddTo. */
/* ADDRESS * Handle : The address of a variable to hold */
/* the handle for the item that was */
/* inserted into the list. */
/* */
/* Output: If all went well, the return value will be */
/* DLIST_SUCCESS and *Handle will contain the ADDRESS of */
/* the new item. If errors were encountered, the . */
/* return value will be the error code and *Handle will */
/* be NULL. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToAddTo does not point to a valid */
/* list */
/* ItemSize is 0 */
/* ItemLocation is NULL */
/* The memory required for a LINK NODE can not */
/* be allocated. */
/* TargetHandle is invalid or is for an item */
/* in another list. */
/* If this routine fails, an error code is returned*/
/* and any memory allocated by this function is */
/* freed. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The item to insert is NOT copied to the heap. Instead, */
/* the location of the item is stored in the list. This */
/* is the major difference between InsertObject and */
/* InsertItem. InsertItem allocates memory on the heap, */
/* copies the item to the memory it allocated, and stores */
/* the address of the memory it allocated in the list. */
/* InsertObject stores the address provided by the user. */
/* */
/* It is assumed that TargetHandle is valid, or is at least*/
/* the address of an accessible block of storage. If */
/* TargetHandle is invalid, or is not the address of an */
/* accessible block of storage, then a trap or exception */
/* may occur. */
/* */
/* It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/*********************************************************************/
int ExclusiveInsertObject (dlist_t ListToAddTo,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS TargetHandle,
Insertion_Modes Insert_Mode,
BOOLEAN MakeCurrent,
ADDRESS * Handle);
/*********************************************************************/
/* */
/* Function Name: DeleteItem */
/* */
/* Descriptive Name: This function removes the specified item from*/
/* the list and optionally frees the memory */
/* associated with it. */
/* */
/* Input: dlist_t ListToDeleteFrom : The list whose current */
/* item is to be deleted. */
/* BOOLEAN FreeMemory : If TRUE, then the memory */
/* associated with the current */
/* item will be freed. If FALSE */
/* then the current item will be */
/* removed from the list but its */
/* memory will not be freed. */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToDeleteFrom, or NULL. If */
/* NULL is used, then the current item */
/* in ListToDeleteFrom will be deleted. */
/* */
/* Output: Return DLIST_SUCCESS if successful, else an error code.*/
/* */
/* Error Handling: This function will fail if ListToDeleteFrom is */
/* not a valid list, or if ListToDeleteFrom is */
/* empty, or if Handle is invalid. */
/* If this routine fails, an error code is */
/* returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: Items in a list can be accessed in two ways: A copy of */
/* the item can be obtained using GetItem and its related */
/* calls, or a pointer to the item can be obtained using */
/* GetObject and its related calls. If you have a copy of */
/* the data and wish to remove the item from the list, set */
/* FreeMemory to TRUE. This will remove the item from the */
/* list and deallocate the memory used to hold it. If you */
/* have a pointer to the item in the list (from one of the */
/* GetObject style functions) and wish to remove the item */
/* from the list, set FreeMemory to FALSE. This removes */
/* the item from the list without freeing its memory, so */
/* that the pointer obtained with the GetObject style */
/* functions is still useable. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list, unless the handle specified belongs */
/* to the current item in the list, in which case this */
/* function behaves the same as DeleteItem. */
/* */
/*********************************************************************/
int DeleteItem (dlist_t ListToDeleteFrom,
BOOLEAN FreeMemory,
ADDRESS Handle);
/*********************************************************************/
/* */
/* Function Name: DeleteAllItems */
/* */
/* Descriptive Name: This function deletes all of the items in the*/
/* specified list and optionally frees the */
/* memory associated with each item deleted. */
/* */
/* Input: dlist_t ListToDeleteFrom : The list whose items */
/* are to be deleted. */
/* BOOLEAN FreeMemory : If TRUE, then the memory */
/* associated with each item in the*/
/* list will be freed. If FALSE */
/* then the each item will be */
/* removed from the list but its */
/* memory will not be freed. */
/* */
/* Output: Return DLIST_SUCCESS if successful, else an error code.*/
/* */
/* Error Handling: This function will fail if ListToDeleteFrom is */
/* not a valid list, or if ListToDeleteFrom is */
/* empty. */
/* If this routine fails, an error code is */
/* returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: Items in a list can be accessed in two ways: A copy of */
/* the item can be obtained using GetItem and its related */
/* calls, or a pointer to the item can be obtained using */
/* GetObject and its related calls. If you have a copy of */
/* the data and wish to remove the item from the list, set */
/* FreeMemory to TRUE. This will remove the item from the */
/* list and deallocate the memory used to hold it. If you */
/* have a pointer to the item in the list (from one of the */
/* GetObject style functions) and wish to remove the item */
/* from the list, set FreeMemory to FALSE. This removes */
/* the item from the list without freeing its memory, so */
/* that the pointer obtained with the GetObject style */
/* functions is still useable. */
/* */
/*********************************************************************/
int DeleteAllItems (dlist_t ListToDeleteFrom,
BOOLEAN FreeMemory);
/*********************************************************************/
/* */
/* Function Name: DeleteObject */
/* */
/* Descriptive Name: This function removes the specified object */
/* from the list. */
/* */
/* Input: dlist_t ListToDeleteFrom : The list whose current */
/* item is to be deleted. */
/* ADDRESS Object : The address of the object to be removed*/
/* from the list. */
/* */
/* Output: Return DLIST_SUCCESS if successful, else an error code.*/
/* */
/* Error Handling: This function will fail if ListToDeleteFrom is */
/* not a valid list, or if ListToDeleteFrom is */
/* empty, or if Handle is invalid. */
/* If this routine fails, an error code is */
/* returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: This function does not alter which item is the current */
/* item in the list, unless the handle specified belongs */
/* to the current item in the list, in which case this */
/* function behaves the same as DeleteItem. */
/* */
/*********************************************************************/
int DeleteObject (dlist_t ListToDeleteFrom,
ADDRESS Object);
/*********************************************************************/
/* */
/* Function Name: GetItem */
/* */
/* Descriptive Name: This function copies the specified item in */
/* the list to a buffer provided by the caller. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* ADDRESS ItemLocation : This is the location of the */
/* buffer into which the current*/
/* item is to be copied. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the list*/
/* will be used. */
/* BOOLEAN MakeCurrent : If TRUE, the item to get will */
/* become the current item in the */
/* list. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* The buffer at ItemLocation will contain a copy of */
/* the current item from ListToGetItemFrom. */
/* If Failure : */
/* Return an error code. */
/* */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemLocation is NULL */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle corresponding to the current item in the */
/* list. */
/* */
/* This function does not alter which item is the current */
/* item in the list. */
/* */
/*********************************************************************/
int GetItem( dlist_t ListToGetItemFrom,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS Handle,
BOOLEAN MakeCurrent);
/*********************************************************************/
/* */
/* Function Name: GetNextItem */
/* */
/* Descriptive Name: This function advances the current item */
/* pointer and then copies the current item in */
/* the list to a buffer provided by the caller. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* ADDRESS ItemLocation : This is the location of the */
/* buffer into which the current*/
/* item is to be copied. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* The buffer at ItemLocation will contain a copy of */
/* the current item from ListToGetItemFrom. */
/* If Failure : */
/* Return an error code. */
/* The current item pointer will NOT be advanced. */
/* The current item in the list will be the same */
/* as before the call to this function. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemLocation is NULL */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* The current item in the list before this */
/* function is called is the last item */
/* item in the list. */
/* If any of these conditions occur, an error */
/* code will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/*********************************************************************/
int GetNextItem(dlist_t ListToGetItemFrom,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag);
/*********************************************************************/
/* */
/* Function Name: GetPreviousItem */
/* */
/* Descriptive Name: This function makes the previous item in the */
/* list the current item in the list and then */
/* copies that item to a buffer provided by the */
/* user. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* ADDRESS ItemLocation : This is the location of the */
/* buffer into which the current */
/* item is to be copied. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* The buffer at ItemLocation will contain a copy of */
/* the current item from ListToGetItemFrom. */
/* If Failure : */
/* Return an error code. */
/* The current item pointer will NOT be advanced. */
/* The current item in the list will be the same */
/* as before the call to this function. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemLocation is NULL */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* The current item in the list before this */
/* function is called is the last item */
/* item in the list. */
/* If any of these conditions occur, an error */
/* code will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* this assumption is violated, an exception or trap may */
/* occur. */
/* */
/*********************************************************************/
int GetPreviousItem(dlist_t ListToGetItemFrom,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag);
/*********************************************************************/
/* */
/* Function Name: GetObject */
/* */
/* Descriptive Name: This function returns the address of the data*/
/* associated with the specified item in the */
/* list. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to have its address */
/* returned to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the list*/
/* BOOLEAN MakeCurrent : If TRUE, the item to get will */
/* become the current item in the */
/* list. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the current item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user should not free the memory associated with */
/* the address returned by this function as the object is */
/* still in the list. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle designating the current item in the list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list. */
/* */
/*********************************************************************/
int GetObject(dlist_t ListToGetItemFrom,
uint ItemSize,
TAG ItemTag,
ADDRESS Handle,
BOOLEAN MakeCurrent,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: BlindGetObject */
/* */
/* Descriptive Name: This function returns the address of the data*/
/* associated with the specified item in the */
/* list. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current */
/* item is to have its address */
/* returned to the caller. */
/* uint * ItemSize : The size of the current item */
/* TAG * ItemTag : The tag of the current item */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the list*/
/* BOOLEAN MakeCurrent : If TRUE, the item to get will */
/* become the current item in the */
/* list. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the current item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user should not free the memory associated with */
/* the address returned by this function as the object is */
/* still in the list. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle designating the current item in the list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list. */
/* */
/*********************************************************************/
int BlindGetObject(dlist_t ListToGetItemFrom,
uint * ItemSize,
TAG * ItemTag,
ADDRESS Handle,
BOOLEAN MakeCurrent,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: GetNextObject */
/* */
/* Descriptive Name: This function advances the current item */
/* pointer and then returns the address of the */
/* data associated with the current item in the */
/* list. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the next item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* The current item pointer will NOT be advanced. */
/* The current item in the list will be the same */
/* as before the call to this function. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* The current item in the list before this */
/* function is called is the last item */
/* item in the list. */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user should not free the memory associated with */
/* the address returned by this function as the object is */
/* still in the list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/*********************************************************************/
int GetNextObject(dlist_t ListToGetItemFrom,
uint ItemSize,
TAG ItemTag,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: GetPreviousObject */
/* */
/* Descriptive Name: This function makes the previous item in the */
/* list the current item and then returns the */
/* address of the data associated with the */
/* current item in the list. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the previous item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* The current item pointer will NOT be advanced. */
/* The current item in the list will be the same */
/* as before the call to this function. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* The current item in the list before this */
/* function is called is the last item */
/* item in the list. */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user should not free the memory associated with */
/* the address returned by this function as the object is */
/* still in the list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/*********************************************************************/
int GetPreviousObject(dlist_t ListToGetItemFrom,
uint ItemSize,
TAG ItemTag,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: ExtractItem */
/* */
/* Descriptive Name: This function copies the specified item in */
/* the list to a buffer provided by the caller */
/* and removes the item from the list. */
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* ADDRESS ItemLocation : This is the location of the */
/* buffer into which the current*/
/* item is to be copied. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the list*/
/* will be used. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* The buffer at ItemLocation will contain a copy of */
/* the current item from ListToGetItemFrom. */
/* The item will have been removed from the list and */
/* its memory deallocated. */
/* If Failure : */
/* Return an error code. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemLocation is NULL */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, *Error will */
/* contain a non-zero error code. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* these assumptions are violated, an exception or trap */
/* may occur. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle which refers to the current item in the */
/* list. */
/* */
/* This function does not alter which item is the current */
/* item in the list, unless the handle specified belongs */
/* to the current item in the list, in which case the */
/* item following the current item becomes the current */
/* item in the list. If there is no item following the */
/* current item in the list, then the item preceding the */
/* current item will become the current item in the list. */
/* */
/*********************************************************************/
int ExtractItem(dlist_t ListToGetItemFrom,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS Handle);
/*********************************************************************/
/* */
/* Function Name: ExtractObject */
/* */
/* Descriptive Name: This function returns the address of the data*/
/* associated with the specified item in the */
/* list and then removes that item from the list*/
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current item */
/* is to be copied and returned*/
/* to the caller. */
/* uint ItemSize : What the caller thinks the size of*/
/* the current item is. */
/* TAG ItemTag : What the caller thinks the item tag */
/* of the current item is. */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the */
/* list will be used. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the current item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user is responsible for the memory associated with */
/* the address returned by this function since this */
/* function removes that object from the list. This means */
/* that, when the user is through with the object, they */
/* should free it. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle which refers to the current item in the */
/* list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list, unless the handle specified belongs */
/* to the current item in the list, in which case the */
/* item following the current item becomes the current */
/* item in the list. If there is no item following the */
/* current item in the list, then the item preceding the */
/* current item will become the current item in the list. */
/* */
/*********************************************************************/
int ExtractObject(dlist_t ListToGetItemFrom,
uint ItemSize,
TAG ItemTag,
ADDRESS Handle,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: BlindExtractObject */
/* */
/* Descriptive Name: This function returns the address of the data*/
/* associated with the specified item in the */
/* list and then removes that item from the list*/
/* */
/* Input: dlist_t ListToGetItemFrom : The list whose current */
/* item is to be copied and */
/* returned to the caller. */
/* uint * ItemSize : The size of the current item */
/* TAG * ItemTag : The tag of the current item */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides*/
/* in ListToGetItemFrom, or NULL. If */
/* NULL, then the current item in the */
/* list will be used. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of data associated */
/* with the current item. */
/* */
/* Output: If Successful : */
/* Return DLIST_SUCCESS. */
/* *Object will be the address of the data */
/* associated with the current item in the list. */
/* If Failure : */
/* Return an error code. */
/* *Object will be NULL. */
/* */
/* Error Handling: This function will fail under any of the */
/* following conditions: */
/* ListToGetItemFrom is not a valid list */
/* ItemSize does not match the size of the */
/* current item in the list */
/* ItemTag does not match the item tag */
/* of the current item in the list */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occur, an error code */
/* will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user is responsible for the memory associated with */
/* the address returned by this function since this */
/* function removes that object from the list. This means */
/* that, when the user is through with the object, they */
/* should free it. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is considered a valid */
/* handle which refers to the current item in the */
/* list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list, unless the handle specified belongs */
/* to the current item in the list, in which case the */
/* item following the current item becomes the current */
/* item in the list. If there is no item following the */
/* current item in the list, then the item preceding the */
/* current item will become the current item in the list. */
/* */
/*********************************************************************/
int BlindExtractObject(dlist_t ListToGetItemFrom,
uint * ItemSize,
TAG * ItemTag,
ADDRESS Handle,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: ReplaceItem */
/* */
/* Descriptive Name: This function replaces the specified item in */
/* the list with the one provided as its */
/* argument. */
/* */
/* Input: dlist_t ListToReplaceItemIn : The list whose current item*/
/* is to be replaced */
/* uint ItemSize : The size, in bytes, of the */
/* replacement item */
/* ADDRESS ItemLocation : The address of the replacement */
/* item */
/* TAG ItemTag : The item tag that the user wishes to */
/* associate with the replacement item */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides */
/* in ListToGetItemFrom, or NULL. If NULL */
/* then the current item in the list will */
/* used. */
/* BOOLEAN MakeCurrent : If TRUE, the item to get will */
/* become the current item in the */
/* list. */
/* */
/* Output: If Successful then return DLIST_SUCCESS. */
/* If Unsuccessful, then return an error code. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToReplaceItemIn is empty */
/* ItemSize is 0 */
/* ItemLocation is NULL */
/* The memory required can not be allocated. */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occurs, an error */
/* code will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* these assumptions are violated, an exception or trap */
/* may occur. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is a valid handle which */
/* refers to the current item in the list. */
/* */
/* This function does not alter which item is the current */
/* item in the list. */
/* */
/*********************************************************************/
int ReplaceItem(dlist_t ListToReplaceItemIn,
uint ItemSize,
ADDRESS ItemLocation,
TAG ItemTag,
ADDRESS Handle,
BOOLEAN MakeCurrent);
/*********************************************************************/
/* */
/* Function Name: ReplaceObject */
/* */
/* Descriptive Name: This function replaces the specified object */
/* in the list with the one provided as its */
/* argument. */
/* */
/* Input: dlist_t ListToReplaceItemIn : The list whose current */
/* object is to be replaced */
/* uint ItemSize : The size, in bytes, of the */
/* replacement object */
/* ADDRESS ItemLocation : The address of the replacement */
/* item */
/* TAG ItemTag : The item tag that the user wishes to */
/* associate with the replacement item */
/* ADDRESS Handle : The handle of the item to get. This */
/* handle must be of an item which resides */
/* in ListToGetItemFrom, or NULL. If NULL */
/* then the current item in the list will */
/* be used. */
/* BOOLEAN MakeCurrent : If TRUE, the item to get will */
/* become the current item in the */
/* list. */
/* ADDRESS * Object : The address of a variable to hold */
/* the ADDRESS of the object that */
/* was replaced. */
/* */
/* Output: If Successful then return DLIST_SUCCESS and the */
/* *Object will contain the address of the object that */
/* was replaced. */
/* If Unsuccessful, then return an error code and */
/* *Object will be NULL. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToReplaceItemIn is empty */
/* ItemSize is 0 */
/* ItemLocation is NULL */
/* The memory required can not be allocated. */
/* Handle is invalid, or is for an item */
/* which is not in ListToGetItemFrom */
/* If any of these conditions occurs, an error */
/* code will be returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The user is responsible for the memory associated with */
/* the object returned by this function as that object is */
/* removed from the list. This means that, when the user */
/* is through with the object returned by this function, */
/* they should free it. */
/* */
/* It is assumed that if ItemLocation is not NULL, then */
/* it is a valid address that can be dereferenced. If */
/* these assumptions are violated, an exception or trap */
/* may occur. */
/* */
/* It is assumed that Handle is valid, or is at least the */
/* address of an accessible block of storage. If Handle */
/* is invalid, or is not the address of an accessible block*/
/* of storage, then a trap or exception may occur. */
/* NOTE: For this function, NULL is a valid handle for the */
/* current item in the list. */
/* */
/* It is assumed that Object is a valid address. If not, */
/* an exception or trap may occur. */
/* */
/* This function does not alter which item is the current */
/* item in the list. */
/* */
/*********************************************************************/
int ReplaceObject(dlist_t ListToReplaceItemIn,
uint * ItemSize, /* On input - size of new object. On return = size of old object. */
ADDRESS ItemLocation,
TAG * ItemTag, /* On input - TAG of new object. On return = TAG of old object. */
ADDRESS Handle,
BOOLEAN MakeCurrent,
ADDRESS * Object);
/*********************************************************************/
/* */
/* Function Name: GetTag */
/* */
/* Descriptive Name: This function returns the item tag associated*/
/* with the current item in the list. */
/* */
/* Input: dlist_t ListToGetTagFrom : The list from which the item */
/* tag of the current item is to*/
/* be returned */
/* ADDRESS Handle : The handle of the item whose TAG and */
/* size we are to get. This handle must */
/* be of an item which resides in */
/* in ListToGetTagFrom, or NULL. If NULL */
/* then the current item in the list will */
/* be used. */
/* uint * ItemSize : The size, in bytes, of the */
/* current item in the list. */
/* TAG * Tag : The address of a variable to hold */
/* the returned tag. */
/* */
/* Output: If successful, the function returns DLIST_SUCCESS. */
/* *ItemSize contains the size of the item. *Tag */
/* contains the tag. */
/* If unsuccessful, an error code is returned. */
/* */
/* Error Handling: This function will fail if ListToGetTagFrom is */
/* not a valid list or is an empty list. In either*/
/* of these cases, an error code is returned. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
int GetTag(dlist_t ListToGetTagFrom,
ADDRESS Handle,
uint * ItemSize,
TAG * Tag);
/*********************************************************************/
/* */
/* Function Name: GetHandle */
/* */
/* Descriptive Name: This function returns a handle for the */
/* current item in the list. This handle is */
/* then associated with that item regardless of */
/* its position in the list. This handle can be*/
/* used to make its associated item the current */
/* item in the list. */
/* */
/* Input: dlist_t ListToGetHandleFrom : The list from which a */
/* handle is needed. */
/* ADDRESS * Handle : The address of a variable to hold */
/* the handle */
/* */
/* Output: If successful, the function returns DLIST_SUCCESS and */
/* *Handle is set to the handle for the current item */
/* in ListToGetHandleFrom. */
/* If unsuccessful, an error code is returned and *Handle */
/* is set to 0. */
/* */
/* Error Handling: This function will fail if ListToGetHandleFrom */
/* is not a valid list or is an empty list. In */
/* either of these cases, an error code is */
/* returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: The handle returned is a pointer to the LinkNode of the */
/* current item in the list. This allows the item to move */
/* around in the list without losing its associated handle.*/
/* However, if the item is deleted from the list, then the */
/* handle is invalid and its use could result in a trap. */
/* */
/*********************************************************************/
int GetHandle (dlist_t ListToGetHandleFrom,
ADDRESS * Handle);
/*********************************************************************/
/* */
/* Function Name: GetListSize */
/* */
/* Descriptive Name: This function returns the number of items in */
/* a list. */
/* */
/* Input: dlist_t ListToGetSizeOf : The list whose size we wish to*/
/* know */
/* uint * Size : The address of a variable to hold */
/* the size of the list. */
/* */
/* Output: If successful, the function returns DLIST_SUCCESS and */
/* *Size contains the a count of the number of items */
/* in the list. */
/* If unsuccessful, an error code is returned and *Size */
/* is set to 0. */
/* */
/* Error Handling: This function will fail if ListToGetSizeOf is */
/* not a valid list. If this happens, then an */
/* error code is returned. . */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that Size contains a valid address. If */
/* this assumption is violated, an exception or trap */
/* may occur. */
/* */
/*********************************************************************/
int GetListSize(dlist_t ListToGetSizeOf,
uint * Size);
/*********************************************************************/
/* */
/* Function Name: ListEmpty */
/* */
/* Descriptive Name: This function returns TRUE if the */
/* specified list is empty, otherwise it returns*/
/* FALSE. */
/* */
/* Input: dlist_t ListToCheck : The list to check to see if it*/
/* is empty */
/* */
/* Output: If successful, the function returns TRUE if the */
/* number of items in the list is 0, otherwise it */
/* returns FALSE. */
/* If unsuccessful, the function returns TRUE. */
/* */
/* Error Handling: This function will return TRUE if ListToCheck */
/* is not a valid list. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
BOOLEAN ListEmpty(dlist_t ListToCheck);
/*********************************************************************/
/* */
/* Function Name: AtEndOfList */
/* */
/* Descriptive Name: This function returns TRUE if the */
/* current item in the list is the last item */
/* in the list. Returns FALSE otherwise. */
/* */
/* Input: dlist_t ListToCheck : The list to check. */
/* */
/* Output: If successful, the function returns TRUE if the */
/* current item in the list is the last item in the */
/* list. If it is not the last item in the list, */
/* FALSE is returned. */
/* If unsuccessful, the function returns FALSE. */
/* */
/* Error Handling: This function will return FALSE ListToCheck is */
/* not a valid list. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
BOOLEAN AtEndOfList(dlist_t ListToCheck);
/*********************************************************************/
/* */
/* Function Name: AtStartOfList */
/* */
/* Descriptive Name: This function returns TRUE if the */
/* current item in the list is the first item */
/* in the list. Returns FALSE otherwise. */
/* */
/* Input: dlist_t ListToCheck : The list to check. */
/* */
/* Output: If successful, the function returns TRUE if the */
/* current item in the list is the first item in the */
/* list. If it is not the first item in the list, */
/* FALSE is returned. */
/* If unsuccessful, the function returns FALSE */
/* */
/* Error Handling: This function will return FALSE if ListToCheck */
/* is not a valid list. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
BOOLEAN AtStartOfList(dlist_t ListToCheck);
/*********************************************************************/
/* */
/* Function Name: DestroyList */
/* */
/* Descriptive Name: This function releases the memory associated */
/* with the internal data structures of a */
/* dlist_t. Once a dlist_t has been destroyed */
/* by this function, it must be reinitialized */
/* before it can be used again. */
/* */
/* Input: dlist_t ListToDestroy : The list to be eliminated */
/* from memory. */
/* BOOLEAN FreeItemMemory : If TRUE, all items in the list */
/* will be freed. If FALSE, all */
/* items in the list are not */
/* freed, only the list structures*/
/* associated with them are. */
/* */
/* Output: If successful, return DLIST_SUCCESS */
/* If unsuccessful, return an error code. */
/* */
/* Error Handling: This function will fail if ListToDestroy is not */
/* a valid list. If this happens, then an error */
/* code is returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: If FreeItemMemory is TRUE, then this function will try */
/* to delete any items which may be in the list. However, */
/* since this function has no way of knowing the internal */
/* structure of an item, items which contain embedded */
/* pointers will not be entirely freed. This can lead to */
/* memory leaks. The programmer should ensure that any */
/* list passed to this function when the FreeItemMemory */
/* parameter is TRUE is empty or does not contain any */
/* items with embedded pointers. */
/* */
/*********************************************************************/
int DestroyList(dlist_t * ListToDestroy,
BOOLEAN FreeItemMemory);
/*********************************************************************/
/* */
/* Function Name: NextItem */
/* */
/* Descriptive Name: This function makes the next item in the list*/
/* the current item in the list (i.e. it */
/* advances the current item pointer). */
/* */
/* Input: dlist_t ListToAdvance : The list whose current item */
/* pointer is to be advanced */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return error code. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToAdvance is not a valid list */
/* ListToAdvance is empty */
/* The current item is the last item in the */
/* list */
/* If any of these conditions occurs, then an */
/* error code is returned. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
int NextItem(dlist_t ListToAdvance);
/*********************************************************************/
/* */
/* Function Name: PreviousItem */
/* */
/* Descriptive Name: This function makes the previous item in the */
/* list the current item in the list. */
/* */
/* Input: dlist_t ListToChange : The list whose current item */
/* pointer is to be changed */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code. */
/* */
/* Error Handling: This function will fail under the following */
/* conditions: */
/* ListToChange is not a valid list */
/* ListToChange is empty */
/* The current item is the first item in the */
/* list */
/* If any of these conditions occurs, then return */
/* an error code. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
int PreviousItem(dlist_t ListToChange);
/*********************************************************************/
/* */
/* Function Name: GoToStartOfList */
/* */
/* Descriptive Name: This function makes the first item in the */
/* list the current item in the list. */
/* */
/* Input: dlist_t ListToReset : The list whose current item */
/* is to be set to the first */
/* item in the list */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code */
/* */
/* Error Handling: This function will fail if ListToAdvance is not */
/* a valid list. If this occurs, then an error */
/* code is returned. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
int GoToStartOfList(dlist_t ListToReset);
/*********************************************************************/
/* */
/* Function Name: GoToEndOfList */
/* */
/* Descriptive Name: This function makes the last item in the */
/* list the current item in the list. */
/* */
/* Input: dlist_t ListToSet : The list whose current item */
/* is to be set to the last item */
/* in the list */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code */
/* */
/* Error Handling: This function will fail if ListToAdvance is not */
/* a valid list. If this occurs, then an error */
/* code is returned. */
/* */
/* Side Effects: None. */
/* */
/*********************************************************************/
int GoToEndOfList(dlist_t ListToSet);
/*********************************************************************/
/* */
/* Function Name: GoToSpecifiedItem */
/* */
/* Descriptive Name: This function makes the item associated with */
/* Handle the current item in the list. */
/* */
/* Input: dlist_t ListToReposition: The list whose current item */
/* is to be set to the item */
/* associated with Handle. */
/* ADDRESS Handle : A handle obtained by using the */
/* GetHandle function. This handle */
/* identifies a unique item in the list. */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code */
/* */
/* Error Handling: This function will fail if ListToAdvance is not */
/* a valid list. If this occurs, then an error */
/* code is returned. */
/* */
/* Side Effects: None. */
/* */
/* Notes: It is assumed that Handle is a valid handle and that */
/* the item associated with Handle is still in the list. */
/* If these conditions are not met, an exception or trap */
/* may occur. */
/* */
/*********************************************************************/
int GoToSpecifiedItem(dlist_t ListToReposition,
ADDRESS Handle);
/*********************************************************************/
/* */
/* Function Name: SortList */
/* */
/* Descriptive Name: This function sorts the contents of a list. */
/* The sorting algorithm used is a stable sort */
/* whose performance is not dependent upon the */
/* initial order of the items in the list. */
/* */
/* Input: dlist_t ListToSort : The dlist_t that is to be sorted. */
/* */
/* int (*Compare) ( ... ) */
/* */
/* This is a pointer to a function that can compare any */
/* two items in the list. It should return -1 if */
/* Object1 is less than Object2, 0 if Object1 is equal */
/* to Object2, and 1 if Object1 is greater than Object2.*/
/* This function will be called during the sort whenever*/
/* the sorting algorithm needs to compare two objects. */
/* */
/* The Compare function takes the following parameters: */
/* */
/* ADDRESS Object1 : The address of the data for the */
/* first object to be compared. */
/* TAG Object1Tag : The user assigned TAG value for the */
/* first object to be compared. */
/* ADDRESS Object2 : The address of the data for the */
/* second object to be compared. */
/* TAG Object2Tag : The user assigned TAG value for the */
/* second object to be compared. */
/* uint * Error : The address of a variable to hold the */
/* error return value. */
/* */
/* If this function ever sets *Error to a non-zero value*/
/* the sort will terminate and the error code will be */
/* returned to the caller of the SortList function. */
/* */
/* */
/* Output: If successful, this function will return DLIST_SUCCESS */
/* and ListToSort will have been sorted. */
/* If unsuccessful, an error code will be returned. */
/* The order of the items in ListToSort is undefined */
/* and may have changed. */
/* */
/* Error Handling: This function will terminate if *Compare sets */
/* *Error to a non-zero value, or if ListToSort */
/* is invalid. If this function does terminate in */
/* the middle of a sort, the order of the items in */
/* ListToSort may be different than it was before */
/* the function was called. */
/* */
/* Side Effects: None. */
/* */
/* Notes: This function works by breaking the list into sublists */
/* and merging the sublists back into one list. The size */
/* of the sublists starts at 1, and with each pass, the */
/* of the sublists is doubled. The sort ends when the size*/
/* of a sublist is greater than the size of the original */
/* list. */
/* */
/*********************************************************************/
int SortList(dlist_t ListToSort,
int (*Compare) (ADDRESS Object1,
TAG Object1Tag,
ADDRESS Object2,
TAG Object2Tag,
uint * Error));
/*********************************************************************/
/* */
/* Function Name: ForEachItem */
/* */
/* Descriptive Name: This function passes a pointer to each item */
/* in a list to a user provided function for */
/* processing by the user provided function. */
/* */
/* Input: dlist_t ListToProcess : The dlist_t whose items are to */
/* be processed by the user */
/* provided function. */
/* */
/* int (*ProcessItem) (...) */
/* */
/* This is a pointer to the user provided function. */
/* This user provided function takes the following */
/* parameters: */
/* */
/* ADDRESS Object : A pointer to an item in */
/* ListToProcess. */
/* TAG Object1Tag : The user assigned TAG value for */
/* the item pointed to by Object. */
/* ADDRESS Parameter : The address of a block of */
/* memory containing any */
/* parameters that the user */
/* wishes to have passed to this*/
/* function. */
/* */
/* ADDRESS Parameters : This field is passed through to */
/* *ProcessItem. This function does */
/* not even look at the contents of */
/* this field. This field is here to */
/* provide the user a way to pass */
/* additional data to *ProcessItem */
/* that *ProcessItem may need to */
/* function correctly. */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code. */
/* */
/* Error Handling: This function aborts immediately when an error */
/* is detected, and any remaining items in the list*/
/* will not be processed. */
/* */
/* Side Effects: None. */
/* */
/* Notes: This function allows the user to access all of the items */
/* in a list and perform an operation on them. The */
/* operation performed must not free any items in the list, */
/* or perform any list operations on the list being */
/* processed. */
/* */
/* As an example of when this would be useful, consider a */
/* a list of graphic objects (rectangles, triangles, circles*/
/* etc.) which comprise a drawing. To draw the picture */
/* that these graphic objects represent, one could build a */
/* loop which gets and draws each item. Another way to */
/* do this would be to build a drawing function which can */
/* draw any of the graphic objects, and then use that */
/* function as the ProcessItem function in a call to */
/* ForEachItem. */
/* */
/* If the ProcessItem function returns an error code */
/* other than DLIST_SUCCESS, then ForEachItem will terminate*/
/* and return an error to whoever called it. The single */
/* exception to this is if ProcessItem returns */
/* DLIST_SEARCH_COMPLETE, in which case ForEachItem */
/* terminates and returns DLIST_SUCCESS. This is */
/* useful for using ForEachItem to search a list and then */
/* terminating the search once the desired item is found. */
/* */
/* A word about the Parameters parameter. This parameter */
/* is passed through to *ProcessItem and is never looked at */
/* by this function. This means that the user can put any */
/* value they desire into Parameters as long as it is the */
/* same size (in bytes) as Parameters. The intended use of */
/* Parameters is to allow the user to pass information to */
/* *ProcessItem that *ProcessItem may need. Either way, */
/* how Parameters is used is literally up to the user. */
/* */
/*********************************************************************/
int ForEachItem(dlist_t ListToProcess,
int (*ProcessItem) (ADDRESS Object,
TAG ObjectTag,
uint ObjectSize,
ADDRESS ObjectHandle,
ADDRESS Parameters),
ADDRESS Parameters,
BOOLEAN Forward);
/*********************************************************************/
/* */
/* Function Name: PruneList */
/* */
/* Descriptive Name: This function allows the caller to examine */
/* each item in a list and optionally delete */
/* it from the list. */
/* */
/* Input: dlist_t ListToProcess : The dlist_t to be pruned. */
/* */
/* BOOLEAN (*KillItem) (...) */
/* */
/* This is a pointer to a user provided function. */
/* This user provided function takes the following */
/* parameters: */
/* */
/* ADDRESS Object : A pointer to an item in */
/* ListToProcess. */
/* TAG Object1Tag : The user assigned TAG value for */
/* the item pointed to by Object. */
/* ADDRESS Parameter : The address of a block of */
/* memory containing any */
/* parameters that the user */
/* wishes to have passed to this*/
/* function. */
/* BOOLEAN * FreeMemory : The address of a BOOLEAN */
/* variable which this */
/* function will set to */
/* either TRUE or FALSE. */
/* If the function return */
/* value is TRUE, then the */
/* value in *FreeMemory will */
/* be examined. If it is */
/* TRUE, then PruneList will */
/* free the memory associated*/
/* with the item being */
/* deleted. If *FreeMemory */
/* is FALSE, then the item */
/* being removed from the */
/* dlist_t will not be freed,*/
/* and it is up to the user */
/* to ensure that this memory*/
/* is handled properly. */
/* uint * Error : The address of a variable to*/
/* hold the error return value.*/
/* */
/* ADDRESS Parameters : This field is passed through to */
/* *KillItem. This function does */
/* not even look at the contents of */
/* this field. This field is here to */
/* provide the user a way to pass */
/* additional data to *ProcessItem */
/* that *ProcessItem may need to */
/* function correctly. */
/* */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* If unsuccessful, return an error code. */
/* */
/* Error Handling: This function aborts immediately when an error */
/* is detected, and any remaining items in the list*/
/* will not be processed. */
/* */
/* Side Effects: None. */
/* */
/* Notes: This function allows the user to access all of the items */
/* in a list, perform an operation on them, and then */
/* optionally delete ("remove") them from the dlist_t. The */
/* operation performed must not free any items in the list, */
/* or perform any list operations on the list being */
/* processed. */
/* */
/* If the KillItem function sets *Error to something other */
/* than DLIST_SUCCESS, then PruneList will terminate and */
/* return an error to whoever called it. The single */
/* exception to this is if KillItem sets *Error to */
/* DLIST_SEARCH_COMPLETE, in which case KillItem */
/* terminates and sets *Error to DLIST_SUCCESS. This is */
/* useful for using KillItem to search a list and then */
/* terminating the search once the desired item is found. */
/* */
/* A word about the Parameters parameter. This parameter */
/* is passed through to *ProcessItem and is never looked at */
/* by this function. This means that the user can put any */
/* value they desire into Parameters as long as it is the */
/* same size (in bytes) as Parameters. The intended use of */
/* Parameters is to allow the user to pass information to */
/* *ProcessItem that *ProcessItem may need. Either way, */
/* how Parameters is used is literally up to the user. */
/* */
/*********************************************************************/
int PruneList(dlist_t ListToProcess,
BOOLEAN (*KillItem) (ADDRESS Object,
TAG ObjectTag,
uint ObjectSize,
ADDRESS ObjectHandle,
ADDRESS Parameters,
BOOLEAN * FreeMemory,
uint * Error),
ADDRESS Parameters);
/*********************************************************************/
/* */
/* Function Name: AppendList */
/* */
/* Descriptive Name: Removes the items in SourceList and appends */
/* them to TargetList. */
/* */
/* Input: dlist_t TargetList : The dlist_t which is to have the */
/* items from SourceList appended to */
/* it. */
/* dlist_t SourceList : The dlist_t whose items are to be */
/* removed and appended to TargetList.*/
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* SourceList will be empty, and TargetList will contain*/
/* all of its original items and all of the items that */
/* were in SourceList. */
/* If unsuccessful, return an error code. SourceList and */
/* TargetList will be unmodified. */
/* */
/* Error Handling: This function will abort immediately upon */
/* detection of an error. All errors that can be */
/* detected are detected before the contents of */
/* SourceList are appended to TargetList, so if an*/
/* error is detected and the function aborts, */
/* SourceList and TargetList are unaltered. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
int AppendList(dlist_t TargetList,
dlist_t SourceList);
/*********************************************************************/
/* */
/* Function Name: TransferItem */
/* */
/* Descriptive Name: Removes an item in SourceList and places in */
/* TargetList. */
/* */
/* Input: dlist_t SourceList : The dlist_t containing the item */
/* which is to be transferred. */
/* ADDRESS SourceHandle : The handle of the item in */
/* SourceList which is to be */
/* transferred to another dlist_t. */
/* If this is NULL, then the */
/* current item in SourceList will */
/* be used. */
/* dlist_t TargetList : The dlist_t which is to receive the*/
/* item being transferred. */
/* ADDRESS TargetHandle : The item in TargetList which */
/* is used to determine where */
/* the item being transferred will */
/* be placed. If this is NULL, */
/* then the current item in */
/* TargetList will be used. */
/* Insertion_Modes TransferMode : This indicates where, */
/* relative to the item in */
/* TargetList specified by */
/* Target_Handle, the item being */
/* transferred can be placed. */
/* BOOLEAN MakeCurrent : If TRUE, the item transferred to */
/* TargetList becomes the current */
/* item in TargetList. */
/* */
/* Output: If successful, return DLIST_SUCCESS, SourceList will be */
/* empty, and TargetList will contain all of its */
/* original items and all of the items that were in */
/* SourceList. */
/* If unsuccessful, an error code will be returned and */
/* SourceList and TargetList will be unmodified. */
/* */
/* Error Handling: This function will abort immediately upon */
/* detection of an error. All errors that can be */
/* detected are detected before the contents of */
/* SourceList are appended to TargetList, so if an*/
/* error is detected and the function aborts, */
/* SourceList and TargetList are unaltered. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
int TransferItem(dlist_t SourceList,
ADDRESS SourceHandle,
dlist_t TargetList,
ADDRESS TargetHandle,
Insertion_Modes TransferMode,
BOOLEAN MakeCurrent);
/*********************************************************************/
/* */
/* Function Name: CopyList */
/* */
/* Descriptive Name: Copies the items in SourceList to the */
/* TargetList. */
/* */
/* Input: dlist_t TargetList : The dlist_t which is to have the */
/* items from SourceList copied to it.*/
/* dlist_t SourceList : The dlist_t whose items are to be */
/* copied to TargetList. */
/* */
/* Output: If successful, return DLIST_SUCCESS. */
/* SourceList will be unchanged and TargetList will */
/* contain all of its original items and all of the */
/* items that were in SourceList. */
/* If unsuccessful, return an error code. SourceList and */
/* TargetList will be unmodified. */
/* */
/* Error Handling: This function will abort immediately upon */
/* detection of an error. All errors that can be */
/* detected are detected before the contents of */
/* SourceList are appended to TargetList, so if an*/
/* error is detected and the function aborts, */
/* SourceList and TargetList are unaltered. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
int CopyList(dlist_t TargetList,
dlist_t SourceList,
Insertion_Modes Insert_Mode);
/*********************************************************************/
/* */
/* Function Name: CheckListIntegrity */
/* */
/* Descriptive Name: Checks the integrity of a dlist_t. All link */
/* nodes in the list are checked, as are all */
/* fields in the list control block. */
/* */
/* Input: dlist_t ListToCheck - The list whose integrity is to be */
/* checked. */
/* */
/* Output: The function return value will be TRUE if all of the */
/* elements in the dlist_t are correct. If this function */
/* returns FALSE, then the dlist_t being checked has been */
/* corrupted! */
/* */
/* Error Handling: If this function encounters an error in a */
/* dlist_t, it will return FALSE. */
/* */
/* Side Effects: None. */
/* */
/* Notes: None. */
/* */
/*********************************************************************/
BOOLEAN CheckListIntegrity(dlist_t ListToCheck);
#endif
|