summaryrefslogtreecommitdiff
path: root/rtl/netwlibc/libc.pp
blob: 05096b9acf3e338079d5c67ea58a79f6e194c27a (plain)
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
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2004 Armin Diehl, member of the Free Pascal
    development team

    Interface to Netware libc

    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.

 **********************************************************************}



{$ifndef INCLUDED_FROM_SYSTEM}
{$mode objfpc}
unit libc;
interface


{ Netware libc interface
  Translated from c ndk Armin Diehl 2004/09/02 }
{$endif}

const
  libc_nlm='libc';
  system_nlm='!netware';

{ Pointers to basic pascal types, inserted by h2pas conversion program.}
Type
{ $ifndef INCLUDED_FROM_SYSTEM - (always available in 2.0.x and above - TH)
  PLongint  = ^Longint;
  PSmallInt = ^SmallInt;
  PByte     = ^Byte;
  PWord     = ^Word;
  PDWord    = ^DWord;
  PDouble   = ^Double;
$endif}
//  PPPChar   = ^PPChar;
  void      = pointer;
  cint      = longint;
  TNLMHandle = Pointer;

const
  NullNlmHandle = nil;

{$PACKRECORDS C}

// string.h
// limits.h

{ some limits wanted by POSIX...  }
{ exact-width signed types...  }
type

   Pint8_t = ^int8_t;
   int8_t = char;

   Pint16 = ^Tint16;
   Tint16 = smallint;

   Pint64_t = ^Tint64;
   Tint64 = int64;
{ exact-width unsigned types...  }

   Puint64 = ^Tuint64;
   Tuint64 = qword;
{ lower and upper bound of exact width integer types...  }
{ macros for minimum-width integer constants...  }
{ minimum-width signed integer types...  }

   Pint_least8_t = ^int_least8_t;
   int_least8_t = char;

   Pint_least16_t = ^int_least16_t;
   int_least16_t = smallint;

   Pint_least32_t = ^int_least32_t;
   int_least32_t = longint;

   Pint_least64_t = ^int_least64_t;
   int_least64_t = int64;
{ minimum-width unsigned integer types...  }

   Puint_least8_t = ^uint_least8_t;
   uint_least8_t = byte;

   Puint_least16_t = ^uint_least16_t;
   uint_least16_t = word;

   Puint_least32_t = ^uint_least32_t;
   uint_least32_t = dword;

   Puint_least64_t = ^uint_least64_t;
   uint_least64_t = qword;
{ lower and upper bound of exact width integer types...  }
{ fastest minimum-width signed integer types...  }

   Pint_fast8_t = ^int_fast8_t;
   int_fast8_t = char;

   Pint_fast16_t = ^int_fast16_t;
   int_fast16_t = smallint;

   Pint_fast32_t = ^int_fast32_t;
   int_fast32_t = longint;

   Pint_fast64_t = ^int_fast64_t;
   int_fast64_t = int64;
{ fastest minimum-width unsigned integer types...  }

   Puint_fast8_t = ^uint_fast8_t;
   uint_fast8_t = byte;

   Puint_fast16_t = ^uint_fast16_t;
   uint_fast16_t = word;

   Puint_fast32_t = ^uint_fast32_t;
   uint_fast32_t = dword;

   Puint_fast64_t = ^uint_fast64_t;
   uint_fast64_t = qword;
{ lower and upper bound of fastest minimum-width integer types...  }
{ integer types capable of holding object pointer...  }

   Pintptr_t = ^intptr_t;
   intptr_t = longint;

   Puintptr_t = ^uintptr_t;
   uintptr_t = dword;
{ limit of integer type capable of holding object pointer...  }
{ maximum-width integer types...  }

   Pintmax_t = ^intmax_t;
   intmax_t = int64;

   Puintmax_t = ^uintmax_t;
   uintmax_t = Tuint64;
{ macros for maximum-width integer constants...  }
{ limits for other integer types...  }

   Psize_t = ^size_t;
   size_t = dword;
{ type yielded by sizeof()  }

   Pssize_t = ^ssize_t;
   ssize_t = longint;
{ signed byte counts for file I/O  }

   Psize64_t = ^size64_t;
   size64_t = Tuint64;
{ used for 64-bit (long) file I/O  }

   Pmode_t = ^mode_t;
   mode_t = dword;
{ file attributes, permissions  }

   Poff_t = ^off_t;
   off_t = longint;
{ file offset value  }

   Poff64_t = ^off64_t;
   off64_t = int64;
{ 64-bit (long) file offset value  }

   Pino_t = ^ino_t;
   ino_t = Tuint64;

   Ppid_t = ^pid_t;
   pid_t = longint;
{ capable of holding a pointer or -1  }

   Puid_t = ^uid_t;
   uid_t = Tuint64;

   Pgid_t = ^gid_t;
   gid_t = Tuint64;

   Pblksize_t = ^blksize_t;
   blksize_t = Tuint64;

   Pblkcnt_t = ^blkcnt_t;
   blkcnt_t = Tuint64;

   Pdev_t = ^dev_t;
   dev_t = Tuint64;

   Pnlink_t = ^nlink_t;
   nlink_t = dword;

   Pptrdiff_t = ^ptrdiff_t;
   ptrdiff_t = longint;

   Pwchar_t = ^wchar_t;
   wchar_t = WideChar;
   PPwchar_t = ^Pwchar_t;


{ prototypes for functions standard and nonstandard...  }

function memchr(_para1:pointer; _para2:longint; _para3:size_t):pointer;cdecl;external libc_nlm name 'memchr';
function memcmp(_para1, _para2:pointer; _para3:size_t):longint;cdecl;external libc_nlm name 'memcmp';
function memcpy(__restrict, __restrict1:pointer; _para3:size_t):pointer;cdecl;external libc_nlm name 'memcpy';
function memmove(_para1, _para2:pointer; _para3:size_t):pointer;cdecl;external libc_nlm name 'memmove';
function memset(_para1:pointer; _para2:longint; _para3:size_t):pointer;cdecl;external libc_nlm name 'memset';
function strcasecmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'strcasecmp';
function strcat(dst,src:Pchar):Pchar;cdecl;external libc_nlm name 'strcat';
function strchr(_para1:Pchar; _para2:longint):Pchar;cdecl;external libc_nlm name 'strchr';
function strcmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'strcmp';
function strcoll(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'strcoll';
function strcpy(__restrict, __restrict1:Pchar):Pchar;cdecl;external libc_nlm name 'strcpy';
function strcspn(_para1, _para2:Pchar):size_t;cdecl;external libc_nlm name 'strcspn';
function strerror(_para1:longint):Pchar;cdecl;external libc_nlm name 'strerror';
function strlcat(__restrict, __restrict1:Pchar; _para3:size_t):size_t;cdecl;external libc_nlm name 'strlcat';
function strlcpy(__restrict, __restrict1:Pchar; _para3:size_t):size_t;cdecl;external libc_nlm name 'strlcpy';
function {$ifdef INCLUDED_FROM_SYSTEM}libc_strlen{$else}strlen{$endif}(_para1:Pchar):size_t;cdecl;external libc_nlm name 'strlen';
function strncasecmp(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'strncasecmp';
function strncat(__restrict, __restrict1:Pchar; _para3:size_t):Pchar;cdecl;external libc_nlm name 'strncat';
function strncmp(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'strncmp';
function strncoll(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'strncoll';
function strncpy(__restrict, __restrict1:Pchar; _para3:size_t):Pchar;cdecl;external libc_nlm name 'strncpy';
function strnicmp(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'strnicmp';
function strnset(_para1, _para2:longint; _para3:size_t):Pchar;cdecl;external libc_nlm name 'strnset';
function strpbrk(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'strpbrk';
function strrchr(_para1, _para2:longint):Pchar;cdecl;external libc_nlm name 'strrchr';
function strrev(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'strrev';
function strset(_para1:Pchar; _para2:longint):Pchar;cdecl;external libc_nlm name 'strset';
function strspn(_para1, _para2:Pchar):size_t;cdecl;external libc_nlm name 'strspn';
function strstr(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'strstr';
function strtok(__restrict, __restrict1:Pchar):Pchar;cdecl;external libc_nlm name 'strtok';
function strxfrm(__restrict, __restrict1:Pchar; _para3:size_t):size_t;cdecl;external libc_nlm name 'strxfrm';
{ POSIX and other functions...  }

function strtok_r(__restrict, __restrict1, __restrict2:PPchar):Pchar;cdecl;external libc_nlm name 'strtok_r';
function memicmp(_para1, _para2:pointer; _para3:size_t):longint;cdecl;external libc_nlm name 'memicmp';
function stpcpy(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'stpcpy';
function stricmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'stricmp';
function strdup(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'strdup';
function strecpy(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'strecpy';
function strerror_r(_para1:longint; _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'strerror_r';

{$ifndef DisableArrayOfConst}
function strlist(_para1, _para2:Pchar; args:array of const):Pchar;cdecl;external libc_nlm name 'strlist';
{$endif}
function strlist(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'strlist';
function strlwr(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'strlwr';
function strrindex(_para1:Pchar; _para2:size_t; _para3:longint):Pchar;cdecl;external libc_nlm name 'strrindex';
function strwhich(_para1:Pchar; _para2:longint; _para3:Pchar):Pchar;cdecl;external libc_nlm name 'strwhich';
function strupr(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'strupr';
procedure swab(_para1, _para2:pointer; _para3:size_t);cdecl;external libc_nlm name 'swab';
procedure swaw(_para1, _para2:pointer; _para3:size_t);cdecl;external libc_nlm name 'swaw';
procedure ungettok(__restrict, __restrict1:Pchar);cdecl;external libc_nlm name 'ungettok';
procedure ungettok_r(__restrict, __restrict1:Pchar; __restrict2:PPchar);cdecl;external libc_nlm name 'ungettok_r';
{ multibyte (double) interfaces for locale code page work...  }
function Lstrbcpy(__restrict, __restrict1:Pchar; _para3:size_t):Pchar;cdecl;external libc_nlm name 'Lstrbcpy';
function Lstrchr(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrchr';
function Lstrcmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'Lstrcmp';
function Lstrcoll(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'Lstrcoll';
function Lstrcspn(_para1, _para2:Pchar):size_t;cdecl;external libc_nlm name 'Lstrcspn';
function Lstricmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'Lstricmp';
function Lstrlen(_para1:Pchar):size_t;cdecl;external libc_nlm name 'Lstrlen';
function Lstrlwr(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrlwr';
function Lstrncat(__restrict:Pchar; __restrict1:Pchar; _para3:size_t):Pchar;cdecl;external libc_nlm name 'Lstrncat';
function Lstrncmp(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'Lstrncmp';
function Lstrncoll(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'Lstrncoll';
function Lstrncpy(__restrict, __restrict1:Pchar; _para3:size_t):Pchar;cdecl;external libc_nlm name 'Lstrncpy';
function Lstrnicmp(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'Lstrnicmp';
function Lstrpbrk(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrpbrk';
function Lstrrchr(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrrchr';
function Lstrrev(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrrev';
function Lstrspn(_para1, _para2:Pchar):size_t;cdecl;external libc_nlm name 'Lstrspn';
function Lstrstr(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrstr';
function Lstrtok_r(__restrict:Pchar; __restrict1:Pchar; __restrict2:PPchar):Pchar;cdecl;external libc_nlm name 'Lstrtok_r';
function Lstrupr(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'Lstrupr';
function Lstrxfrm(__restrict:Pchar; __restrict1:Pchar; _para3:size_t):size_t;cdecl;external libc_nlm name 'Lstrxfrm';
{ length-preceeded string manipulation...  }
function ASCIIZToLenStr(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'ASCIIZToLenStr';
function ASCIIZToMaxLenStr(_para1, _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'ASCIIZToMaxLenStr';
function LenStrCat(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'LenStrCat';
function LenStrCmp(_para1, _para2:Pchar):longint;cdecl;external libc_nlm name 'LenStrCmp';
function LenStrCpy(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'LenStrCpy';
function LenToASCIIZStr(_para1,_para2:Pchar):longint;cdecl;external libc_nlm name 'LenToASCIIZStr';
function strindex(_para1, _para2:Pchar):Pchar;cdecl;external libc_nlm name 'strindex';


// stdarg.h

  const
     //EOF = -(1);
     BUFSIZ = 8096;           { default buffer size--change with setbuf()  }
     FOPEN_MAX = 1024;        { at least this many FILEs available         }
     FILENAME_MAX = 1024;     { maximum characters in any path name        }
                              { values for argument 'flags' to setvbuf()...}
     _IONBF = $0010;          { unbuffered (e.g.: stdout and stderr)       }
     _IOLBF = $0020;          { line buffered (e.g.: stdin)                }
     _IOFBF = $0040;          { fully buffered (most files)                }
                              { values for fseek()'s whence argument       }
     SEEK_SET = 0;            { add 'offset' to beginning of file          }
     SEEK_CUR = 1;            { add 'offset' to current position in file   }
     SEEK_END = 2;            { add 'offset' to end of file                }
                              { definitions for tmpnam() and tmpfil()      }
     TMP_MAX = 1000000;       { "T-000000.TMP" to "T-999999.TMP"           }
     L_tmpnam = 36;
     P_tmpdir = 'sys:/tmp';
  { FILE type definition (result is opaque)    }


type

   Pva_list = ^va_list;
   va_list = char;

   P_iobuf = ^_iobuf;
   _iobuf = record
        reserved : longint;
     end;
   TFILE = _iobuf;
   PFILE = ^TFILE;
   PPFILE = ^PFILE;

   Pfpos_t = ^fpos_t;
   fpos_t = longint;

   Pfpos64_t = ^fpos64_t;
   fpos64_t = off64_t;

procedure clearerr(_para1:PFILE);cdecl;external libc_nlm name 'clearerr';
function fclose(_para1:PFILE):longint;cdecl;external libc_nlm name 'fclose';
function feof(_para1:PFILE):longint;cdecl;external libc_nlm name 'feof';
function ferror(_para1:PFILE):longint;cdecl;external libc_nlm name 'ferror';
function fflush(_para1:PFILE):longint;cdecl;external libc_nlm name 'fflush';
function fgetc(_para1:PFILE):longint;cdecl;external libc_nlm name 'fgetc';
function fgetpos(_para1:PFILE; _para2:Pfpos_t):longint;cdecl;external libc_nlm name 'fgetpos';
function fgets(_para1:Pchar; _para2:longint; _para3:PFILE):Pchar;cdecl;external libc_nlm name 'fgets';


function fopen(__restrict:Pchar; __restrict1:Pchar):PFILE;cdecl;external libc_nlm name 'fopen';
{$ifndef DisableArrayOfConst}
function fprintf(__restrict:PFILE; __restrict1:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'fprintf';
{$endif}
function fprintf(__restrict:PFILE; __restrict1:Pchar):longint;cdecl;external libc_nlm name 'fprintf';
function fputc(_para1:longint; _para2:PFILE):longint;cdecl;external libc_nlm name 'fputc';

function fputs(__restrict:Pchar; __restrict1:PFILE):longint;cdecl;external libc_nlm name 'fputs';
function fread(__restrict:pointer; _para2:size_t; _para3:size_t; __restrict1:PFILE):size_t;cdecl;external libc_nlm name 'fread';


function freopen(__restrict:Pchar; __restrict1:Pchar; __restrict2:PFILE):PFILE;cdecl;external libc_nlm name 'freopen';
{$ifndef DisableArrayOfConst}
function fscanf(__restrict:PFILE; __restrict1:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'fscanf';
{$endif}
function fscanf(__restrict:PFILE; __restrict1:Pchar):longint;cdecl;external libc_nlm name 'fscanf';
function fseek(fp:PFILE; offset:longint; whence:longint):longint;cdecl;external libc_nlm name 'fseek';

function fsetpos(_para1:PFILE; _para2:Pfpos_t):longint;cdecl;external libc_nlm name 'fsetpos';
function ftell(_para1:PFILE):longint;cdecl;external libc_nlm name 'ftell';

function fwrite(__restrict:pointer; _para2:size_t; _para3:size_t; __restrict1:PFILE):size_t;cdecl;external libc_nlm name 'fwrite';
function getc(_para1:PFILE):longint;cdecl;external libc_nlm name 'getc';
function getchar:longint;cdecl;external libc_nlm name 'getchar';
function gets(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'gets';
procedure {$ifdef INCLUDED_FROM_SYSTEM}libc_perror{$else}perror{$endif}(_para1:Pchar);cdecl;external libc_nlm name 'perror';

{$ifndef DisableArrayOfConst}
function printf(__restrict:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'printf';
{$endif}
function printf(__restrict:Pchar):longint;cdecl;external libc_nlm name 'printf';
function putc(_para1:longint; _para2:PFILE):longint;cdecl;external libc_nlm name 'putc';
function putchar(_para1:longint):longint;cdecl;external libc_nlm name 'putchar';
function puts(_para1:Pchar):longint;cdecl;external libc_nlm name 'puts';
function remove(_para1:Pchar):longint;cdecl;external libc_nlm name 'remove';
function rename(_para1:Pchar; _para2:Pchar):longint;cdecl;external libc_nlm name 'rename';
procedure rewind(_para1:PFILE);cdecl;external libc_nlm name 'rewind';

{$ifndef DisableArrayOfConst}
function scanf(__restrict:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'scanf';
{$endif}
function scanf(__restrict:Pchar):longint;cdecl;external libc_nlm name 'scanf';
procedure setbuf(__restrict:PFILE; __restrict1:Pchar);cdecl;external libc_nlm name 'setbuf';
function setvbuf(__restrict:PFILE; __restrict1:Pchar; _para3:longint; _para4:size_t):longint;cdecl;external libc_nlm name 'setvbuf';
{$ifndef DisableArrayOfConst}
function sprintf(__restrict:Pchar; __restrict1:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'sprintf';
{$endif}
function sprintf(__restrict:Pchar; __restrict1:Pchar):longint;cdecl;external libc_nlm name 'sprintf';
{$ifndef DisableArrayOfConst}
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'snprintf';
{$endif}
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1:longint):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1:longint; p2:pchar):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1:pchar):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1,p2:pchar):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1,p2,p3:pchar):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1,p2:longint):longint;cdecl;external libc_nlm name 'snprintf';
function snprintf(__restrict:Pchar; n:size_t; Format:Pchar; p1,p2,p3:longint):longint;cdecl;external libc_nlm name 'snprintf';

{$ifndef DisableArrayOfConst}
function sscanf(__restrict:Pchar; __restrict1:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'sscanf';
{$endif}
function sscanf(__restrict:Pchar; __restrict1:Pchar):longint;cdecl;external libc_nlm name 'sscanf';
function tmpfile:PFILE;cdecl;external libc_nlm name 'tmpfile';
function tmpnam(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'tmpnam';
function ungetc(_para1:longint; _para2:PFILE):longint;cdecl;external libc_nlm name 'ungetc';

function vfprintf(__restrict:PFILE; __restrict1:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vfprintf';
function vfscanf(__restrict:PFILE; __restrict1:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vfscanf';
function vprintf(__restrict:Pchar; _para2:va_list):longint;cdecl;external libc_nlm name 'vprintf';
function vscanf(__restrict:Pchar; _para2:va_list):longint;cdecl;external libc_nlm name 'vscanf';
function vsnprintf(__restrict:Pchar; n:size_t; __restrict1:Pchar; _para4:va_list):longint;cdecl;external libc_nlm name 'vsnprintf';
function vsprintf(__restrict:Pchar; __restrict1:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vsprintf';

function vsscanf(__restrict:Pchar; __restrict1:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vsscanf';
{ functions underlying macro support...  }
function ___stdin:PPFILE;cdecl;external libc_nlm name '___stdin';
function ___stdout:PPFILE;cdecl;external libc_nlm name '___stdout';
function ___stderr:PPFILE;cdecl;external libc_nlm name '___stderr';
function ___cin:PPFILE;cdecl;external libc_nlm name '___cin';
function ___cout:PPFILE;cdecl;external libc_nlm name '___cout';
{ POSIX-defined and other additions...  }

function fdopen(_para1:longint; __restrict:Pchar):PFILE;cdecl;external libc_nlm name 'fdopen';
function fileno(_para1:PFILE):longint;cdecl;external libc_nlm name 'fileno';
procedure flockfile(_para1:PFILE);cdecl;external libc_nlm name 'flockfile';
function ftrylockfile(_para1:PFILE):longint;cdecl;external libc_nlm name 'ftrylockfile';
procedure funlockfile(_para1:PFILE);cdecl;external libc_nlm name 'funlockfile';
function getc_unlocked(_para1:PFILE):longint;cdecl;external libc_nlm name 'getc_unlocked';
function getchar_unlocked:longint;cdecl;external libc_nlm name 'getchar_unlocked';
function getw(_para1:PFILE):longint;cdecl;external libc_nlm name 'getw';
function pclose(stream:PFILE):longint;cdecl;external libc_nlm name 'pclose';
function popen(command:Pchar; mode:Pchar):PFILE;cdecl;external libc_nlm name 'popen';
function putc_unlocked(c:longint; _para2:PFILE):longint;cdecl;external libc_nlm name 'putc_unlocked';
function putchar_unlocked(c:longint):longint;cdecl;external libc_nlm name 'putchar_unlocked';
function tempnam(dirpath:Pchar; prefix:Pchar):Pchar;cdecl;external libc_nlm name 'tempnam';
{ nonstandard (transitional) addtions for 64-bit file I/O...  }
function fgetpos64(_para1:PFILE; _para2:Pfpos64_t):longint;cdecl;external libc_nlm name 'fgetpos64';
function fseek64(fp:PFILE; offset:fpos64_t; whence:longint):longint;cdecl;external libc_nlm name 'fseek64';
function fsetpos64(_para1:PFILE; _para2:Pfpos64_t):longint;cdecl;external libc_nlm name 'fsetpos64';
function ftell64(_para1:PFILE):off64_t;cdecl;external libc_nlm name 'ftell64';
{ hard-wired console I/O support (cannot be redirected)...  }
function cgetc:longint;cdecl;external libc_nlm name 'cgetc';
function cgets(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'cgets';

{$ifndef DisableArrayOfConst}
function cprintf(_para1:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'cprintf';
{$endif}
function cprintf(_para1:Pchar):longint;cdecl;external libc_nlm name 'cprintf';
function cputc(_para1:longint):longint;cdecl;external libc_nlm name 'cputc';
function cputs(_para1:Pchar):longint;cdecl;external libc_nlm name 'cputs';
{$ifndef DisableArrayOfConst}
function cscanf(__restrict:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'cscanf';
{$endif}
function cscanf(__restrict:Pchar):longint;cdecl;external libc_nlm name 'cscanf';
function vcprintf(__restrict:Pchar; _para2:va_list):longint;cdecl;external libc_nlm name 'vcprintf';
function vcscanf(__restrict:Pchar; _para2:va_list):longint;cdecl;external libc_nlm name 'vcscanf';
function vasprintf(__restrict:PPchar; __restrict1:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vasprintf';
{ defined as macros in both C and C++...  }
{ UNIX 98/POSIX.1-2002 defined additions  }


// stdlib.h
{ pshpack1.h }
{ turn on 1-byte packing...  }

  const
     EXIT_FAILURE = -(1);
     EXIT_SUCCESS = 0;
     RAND_MAX = 32767;


type
   Pdiv_t = ^div_t;
   div_t = record
        quot : longint;
        rem : longint;
     end;

   Pldiv_t = ^ldiv_t;
   ldiv_t = record
        quot : longint;
        rem : longint;
     end;

   Plldiv_t = ^lldiv_t;
   lldiv_t = record
        quot : Tint64;
        rem : Tint64;
     end;

(** unsupported pragma#pragma pack()*)

type TCDeclProcedure = procedure; cdecl;

procedure abort;cdecl;external libc_nlm name 'abort';
// function {$ifdef INCLUDED_FROM_SYSTEM}libc_abs{$else}abs{$endif}(_para1:longint):longint;cdecl;external libc_nlm name 'abs';
function atexit(_para1:TCDeclProcedure ):longint;cdecl;external libc_nlm name 'atexit';
function atof(_para1:Pchar):double;cdecl;external libc_nlm name 'atof';
function atoi(_para1:Pchar):longint;cdecl;external libc_nlm name 'atoi';
function atol(_para1:Pchar):longint;cdecl;external libc_nlm name 'atol';
function atoll(_para1:Pchar):Tint64;cdecl;external libc_nlm name 'atoll';

//!! function bsearch(_para1:pointer; _para2:pointer; _para3:size_t; _para4:size_t; _para5:function (_para1:pointer; _para2:pointer):longint):pointer;cdecl;external libc_nlm name 'bsearch';
function calloc(_para1:size_t; _para2:size_t):pointer;cdecl;external libc_nlm name 'calloc';
function __CW_div(_para1:longint; _para2:longint):div_t;cdecl;external libc_nlm name '__CW_div';
procedure libc_exit(status:longint);cdecl;external libc_nlm name 'exit';
procedure free(_para1:pointer);cdecl;external libc_nlm name 'free';
function getenv(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'getenv';
function labs(_para1:longint):longint;cdecl;external libc_nlm name 'labs';
function __CW_ldiv(_para1:longint; _para2:longint):ldiv_t;cdecl;external libc_nlm name '__CW_ldiv';
function llabs(_para1:Tint64):Tint64;cdecl;external libc_nlm name 'llabs';
function __CW_lldiv(_para1:Tint64; _para2:Tint64):lldiv_t;cdecl;external libc_nlm name '__CW_lldiv';
function malloc(_para1:size_t):pointer;cdecl;external libc_nlm name 'malloc';
function mblen(_para1:Pchar; _para2:size_t):longint;cdecl;external libc_nlm name 'mblen';
function mbstowcs(_para1:Pwchar_t; _para2:Pchar; _para3:size_t):size_t;cdecl;external libc_nlm name 'mbstowcs';
function mbtowc(_para1:Pwchar_t; _para2:Pchar; _para3:size_t):longint;cdecl;external libc_nlm name 'mbtowc';

type TQSortFunc = function (_para1:pointer; _para2:pointer):longint; cdecl;
procedure qsort(_para1:pointer; _para2:size_t; _para3:size_t; _para4:TQSortFunc);cdecl;external libc_nlm name 'qsort';
function rand:longint;cdecl;external libc_nlm name 'rand';
function realloc(_para1:pointer; _para2:size_t):pointer;cdecl;external libc_nlm name 'realloc';
procedure srand(_para1:dword);cdecl;external libc_nlm name 'srand';
function strtod(__restrict:Pchar; __restrict1:PPchar):double;cdecl;external libc_nlm name 'strtod';
function strtol(__restrict:Pchar; __restrict1:PPchar; _para3:longint):longint;cdecl;external libc_nlm name 'strtol';
function strtoll(__restrict:Pchar; __restrict1:PPchar; _para3:longint):Tint64;cdecl;external libc_nlm name 'strtoll';
function strtoul(__restrict:Pchar; __restrict1:PPchar; _para3:longint):dword;cdecl;external libc_nlm name 'strtoul';
function strtoull(__restrict:Pchar; __restrict1:PPchar; _para3:longint):Tuint64;cdecl;external libc_nlm name 'strtoull';
function system(_para1:Pchar):longint;cdecl;external libc_nlm name 'system';
function wcstombs(__restrict:Pchar; __restrict1:Pwchar_t; _para3:size_t):size_t;cdecl;external libc_nlm name 'wcstombs';
function wctomb(_para1:Pchar; _para2:wchar_t):longint;cdecl;external libc_nlm name 'wctomb';
function alloca(_para1:size_t):pointer;cdecl;external libc_nlm name 'alloca';
function clearenv:longint;cdecl;external libc_nlm name 'clearenv';
function getcmd(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'getcmd';
function flushenv(_para1:Pchar; _para2:longint):longint;cdecl;external libc_nlm name 'flushenv';
function getbsize(_para1:Plongint; _para2:Plongint):Pchar;cdecl;external libc_nlm name 'getbsize';
function htol(_para1:Pchar):dword;cdecl;external libc_nlm name 'htol';
function itoa(_para1:longint; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'itoa';
function itoab(_para1:dword; _para2:Pchar):Pchar;cdecl;external libc_nlm name 'itoab';
function ltoa(_para1:longint; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'ltoa';
function lltoa(_para1:Tint64; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'lltoa';
function _lrotr(_para1:dword; _para2:dword):dword;cdecl;external libc_nlm name '_lrotr';
function _lrotl(_para1:dword; _para2:dword):dword;cdecl;external libc_nlm name '_lrotl';
function mkdtemp(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'mkdtemp';
function mkstemp(_para1:Pchar):longint;cdecl;external libc_nlm name 'mkstemp';
function mktemp(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'mktemp';
function msize(_para1:pointer):size_t;cdecl;external libc_nlm name 'msize';
function multibyte:longint;cdecl;external libc_nlm name 'multibyte';
function mvalidrange(_para1:pointer; _para2:size_t):longint;cdecl;external libc_nlm name 'mvalidrange';
function nextmb(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'nextmb';
function prevmb(_para1:Pchar):Pchar;cdecl;external libc_nlm name 'prevmb';
function putenv(_para1:Pchar):longint;cdecl;external libc_nlm name 'putenv';
function rand_r(_para1:Pdword):longint;cdecl;external libc_nlm name 'rand_r';
function _rotr(_para1:dword; _para2:dword):dword;cdecl;external libc_nlm name '_rotr';
function _rotl(_para1:dword; _para2:dword):dword;cdecl;external libc_nlm name '_rotl';
function rotl8(_para1:byte; _para2:longint):byte;cdecl;external libc_nlm name 'rotl8';
function rotl16(_para1:word; _para2:longint):word;cdecl;external libc_nlm name 'rotl16';
function rotl32(_para1:dword; _para2:longint):dword;cdecl;external libc_nlm name 'rotl32';
function rotl64(_para1:Tuint64; _para2:longint):Tuint64;cdecl;external libc_nlm name 'rotl64';
function rotr8(_para1:byte; _para2:longint):byte;cdecl;external libc_nlm name 'rotr8';
function rotr16(_para1:word; _para2:longint):word;cdecl;external libc_nlm name 'rotr16';
function rotr32(_para1:dword; _para2:longint):dword;cdecl;external libc_nlm name 'rotr32';
function rotr64(_para1:Tuint64; _para2:longint):Tuint64;cdecl;external libc_nlm name 'rotr64';
function setenv(_para1:Pchar; _para2:Pchar; _para3:longint):longint;cdecl;external libc_nlm name 'setenv';
procedure setkey(_para1:Pchar);cdecl;external libc_nlm name 'setkey';
function stackavail:size_t;cdecl;external libc_nlm name 'stackavail';
function stackbase:pointer;cdecl;external libc_nlm name 'stackbase';
function stackwatermark:size_t;cdecl;external libc_nlm name 'stackwatermark';
function strtoi(_para1:Pchar; _para2:longint):longint;cdecl;external libc_nlm name 'strtoi';
function truncmb(_para1:Pchar; _para2:size_t):Pchar;cdecl;external libc_nlm name 'truncmb';
function ultoa(_para1:dword; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'ultoa';
function ulltoa(_para1:Tuint64; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'ulltoa';
function unsetenv(name:Pchar):longint;cdecl;external libc_nlm name 'unsetenv';
function utoa(_para1:dword; _para2:Pchar; _para3:longint):Pchar;cdecl;external libc_nlm name 'utoa';
function valuemb(_para1:Pchar):longint;cdecl;external libc_nlm name 'valuemb';
{ atomic functions...  }
procedure atomic_add(addr:Pdword; value:dword);cdecl;external libc_nlm name 'atomic_add';
function atomic_bts(addr:Pdword; offset:dword):dword;cdecl;external libc_nlm name 'atomic_bts';
function atomic_btr(addr:Pdword; offset:dword):dword;cdecl;external libc_nlm name 'atomic_btr';
procedure atomic_dec(addr:Pdword);cdecl;external libc_nlm name 'atomic_dec';
procedure atomic_inc(addr:Pdword);cdecl;external libc_nlm name 'atomic_inc';
procedure atomic_sub(addr:Pdword; value:dword);cdecl;external libc_nlm name 'atomic_sub';
function atomic_xchg(addr:Pdword; value:dword):dword;cdecl;external libc_nlm name 'atomic_xchg';
procedure atomic_or(addr:Pdword; value:dword);cdecl;external libc_nlm name 'atomic_or';
procedure atomic_xor(addr:Pdword; value:dword);cdecl;external libc_nlm name 'atomic_xor';
procedure atomic_and(addr:Pdword; value:dword);cdecl;external libc_nlm name 'atomic_and';
function atomic_xchgadd(addr:Pdword; value:dword):dword;cdecl;external libc_nlm name 'atomic_xchgadd';
function atomic_cmpxchg(addr:Pdword; cmpvalue:dword; newvalue:dword):dword;cdecl;external libc_nlm name 'atomic_cmpxchg';
procedure atomic64_inc(addr:Puint64);cdecl;external libc_nlm name 'atomic64_inc';
procedure atomic64_dec(addr:Puint64);cdecl;external libc_nlm name 'atomic64_dec';
procedure atomic64_add(addr:Puint64; value:tuint64);cdecl;external libc_nlm name 'atomic64_add';
procedure atomic64_sub(addr:Puint64; value:tuint64);cdecl;external libc_nlm name 'atomic64_sub';
function atomic64_xchg(addr:Puint64; value:tuint64):Tuint64;cdecl;external libc_nlm name 'atomic64_xchg';
function atomic64_xchgadd(addr:Puint64; value:Tuint64):Tuint64;cdecl;external libc_nlm name 'atomic64_xchgadd';
function atomic64_cmpxchg(addr:Puint64; cmpvalue:Tuint64; newvalue:Tuint64):Tuint64;cdecl;external libc_nlm name 'atomic64_cmpxchg';
{ compiler-specific implementations of alloca()...  }
function max(a:longint; b:longint):longint;cdecl;external libc_nlm name 'max';
function min(a:longint; b:longint):longint;cdecl;external libc_nlm name 'min';


// stropts.h
// sys/ioctl.h
// unistd.h
// sys/types.h

type
   Puchar_t = ^uchar_t;
   uchar_t = byte;

   Pushort_t = ^ushort_t;
   ushort_t = word;

   Puint_t = ^uint_t;
   uint_t = dword;

   Pulong_t = ^ulong_t;
   ulong_t = dword;

   Pu_char = ^u_char;
   u_char = byte;

   Pu_short = ^u_short;
   u_short = word;

   Pu_int = ^u_int;
   u_int = dword;

   Pu_long = ^u_long;
   u_long = dword;

   Pcaddr_t = ^caddr_t;
   caddr_t = char;

   Puseconds_t = ^useconds_t;
   useconds_t = Tuint64;

   Psuseconds_t = ^suseconds_t;
   suseconds_t = Tint64;

   Pu_int8_t = ^u_int8_t;
   u_int8_t = byte;

   Pu_int16_t = ^u_int16_t;
   u_int16_t = word;

   Pu_int32_t = ^u_int32_t;
   u_int32_t = dword;

   Pu_int64_t = ^u_int64_t;
   u_int64_t = Tuint64;

function getpid:pid_t;cdecl;external libc_nlm name 'getpid';
function getppid:pid_t;cdecl;external libc_nlm name 'getppid';
function getuid:uid_t;cdecl;external libc_nlm name 'getuid';
function geteuid:uid_t;cdecl;external libc_nlm name 'geteuid';
function getgid:gid_t;cdecl;external libc_nlm name 'getgid';
function getegid:gid_t;cdecl;external libc_nlm name 'getegid';
function setuid(uid:uid_t):longint;cdecl;external libc_nlm name 'setuid';
function setgid(gid:gid_t):longint;cdecl;external libc_nlm name 'setgid';
function getpgrp:pid_t;cdecl;external libc_nlm name 'getpgrp';
function setsid:pid_t;cdecl;external libc_nlm name 'setsid';
function setpgid(pid:pid_t; pgid:pid_t):longint;cdecl;external libc_nlm name 'setpgid';

function FpGetpid:pid_t;cdecl;external libc_nlm name 'getpid';
function FpGetppid:pid_t;cdecl;external libc_nlm name 'getppid';
function FpGetuid:uid_t;cdecl;external libc_nlm name 'getuid';
function FpGeteuid:uid_t;cdecl;external libc_nlm name 'geteuid';
function FpGetgid:gid_t;cdecl;external libc_nlm name 'getgid';
function FpGetegid:gid_t;cdecl;external libc_nlm name 'getegid';
function FpSetuid(uid:uid_t):longint;cdecl;external libc_nlm name 'setuid';
function FpSetgid(gid:gid_t):longint;cdecl;external libc_nlm name 'setgid';
function FpSetpgrp:pid_t;cdecl;external libc_nlm name 'getpgrp';
function FpSetsid:pid_t;cdecl;external libc_nlm name 'setsid';
function FpSetpgid(pid:pid_t; pgid:pid_t):longint;cdecl;external libc_nlm name 'setpgid';


// sys/unistd.h

type
  TFilDes = Array [0..1] of cInt;
  pFilDes = ^TFilDes;

  const
     R_OK = 1;
  { test for write permission                  }
     W_OK = 2;
  { test for execute permission                }
     X_OK = 4;
  { test for existence of file                 }
     F_OK = 8;
  { values for 'whence' in lseek()...                                  }
  { set file pointer to 'offset'               }
    // SEEK_SET = 0;
  { set file pointer to current plus 'offset'  }
     // SEEK_CUR = 1;
  { set file pointer to EOF plus 'offset'      }
     // SEEK_END = 2;
  { old Berkeley names...                                              }
     L_SET = SEEK_SET;
     L_INCR = SEEK_CUR;
     L_XTND = SEEK_END;
  { test using effective ids                   }
     EFF_ONLY_OK = 8;
  { descriptor underlying 'stdin'              }
     STDIN_FILENO = 0;
  { ibid for 'stdout'                          }
     STDOUT_FILENO = 1;
  { ibid for 'stderr'                          }
     STDERR_FILENO = 2;
     _POSIX_THREAD_SAFE_FUNCTIONS = 1;
     _POSIX_THREAD_ATTR_STACKADDR = 1;
     _POSIX_THREAD_ATTR_STACKSIZE = 1;
     _POSIX_MAPPED_FILES = 1;
     _POSIX_MEMLOCK = 1;
     _POSIX_MEMLOCK_RANGE = 1;
     _POSIX_MEMORY_PROTECTION = 1;
     _POSIX_SYNCHRONIZED_IO = 1;
     _POSIX_FSYNC = 1;
     _POSIX_ASYNC_IO = -(1);
     _POSIX_CHOWN_RESTRICTED = -(1);
     _POSIX_NO_TRUNC = -(1);
     _POSIX_PRIO_IO = -(1);
     _POSIX_SYNC_IO = 1;
     _POSIX_VDISABLE = 0;


function access(path:Pchar; mode:longint):longint;cdecl;external libc_nlm name 'access';
function FpAccess(path:Pchar; mode:longint):longint;cdecl;external libc_nlm name 'access';
function alarm(seconds:dword):dword;cdecl;external libc_nlm name 'alarm';
function FpChdir(path:Pchar):longint;cdecl;external libc_nlm name 'chdir';
function {$ifdef INCLUDED_FROM_SYSTEM}libc_chsize{$else}chsize{$endif}(fildes:longint; size:size_t):longint;cdecl;external libc_nlm name 'chsize';
function FpChsize(fildes:longint; size:size_t):longint;cdecl;external libc_nlm name 'chsize';
function FpClose(fildes:longint):longint;cdecl;external libc_nlm name 'close';
function crypt(key:Pchar; salt:Pchar):Pchar;cdecl;external libc_nlm name 'crypt';
function dup(fildes:longint):longint;cdecl;external libc_nlm name 'dup';
function Fpdup(fildes:longint):longint;cdecl;external libc_nlm name 'dup';
function dup2(fildes1:longint; fildes2:longint):longint;cdecl;external libc_nlm name 'dup2';
function Fpdup2(fildes1:longint; fildes2:longint):longint;cdecl;external libc_nlm name 'dup2';
type TArr064char = array [0..63] of char;
procedure encrypt(block:TArr064char; edflag:longint);cdecl;external libc_nlm name 'encrypt';
procedure _exit(status:longint);cdecl;external libc_nlm name '_exit';
procedure FpExit(status:longint);cdecl;external libc_nlm name '_exit';
function fchdir(fildes:longint):longint;cdecl;external libc_nlm name 'fchdir';
function fdatasync(fildes:longint):longint;cdecl;external libc_nlm name 'fdatasync';
function fork:pid_t;cdecl;external libc_nlm name 'fork';
function fsync(fildes:longint):longint;cdecl;external libc_nlm name 'fsync';
function fpathconf(fildes:longint; name:longint):longint;cdecl;external libc_nlm name 'fpathconf';
function ftruncate(fildes:longint; len:off_t):longint;cdecl;external libc_nlm name 'ftruncate';
function getcwd(path:Pchar; len:size_t):Pchar;cdecl;external libc_nlm name 'getcwd';
function gethostid:longint;cdecl;external libc_nlm name 'gethostid';
(* Const before declarator ignored *)

function getopt(argc:longint; argv:array of Pchar; optstr:Pchar):longint;cdecl;external libc_nlm name 'getopt';
{$ifndef DisableArrayOfConst}
function Fpioctl(_para1:longint; _para2:longint; args:array of const):longint;cdecl;external libc_nlm name 'ioctl';
{$endif}
function Fpioctl(_para1:longint; _para2:longint):longint;cdecl;external libc_nlm name 'ioctl';
function Fpisatty(fildes:longint):longint;cdecl;external libc_nlm name 'isatty';
//function lseek(fildes:longint; offset:off_t; whence:longint):off_t;cdecl;external libc_nlm name 'lseek';
function fplseek(fildes:longint; offset:off_t; whence:longint):off_t;cdecl;external libc_nlm name 'lseek';

function pathconf(path:Pchar; name:longint):longint;cdecl;external libc_nlm name 'pathconf';
//!!function pipe(fildes:array[0..1] of longint):longint;cdecl;external libc_nlm name 'pipe';
function FpPipe(var fildes:TFilDes):cInt;cdecl;external libc_nlm name 'pipe';
function pread(fildes:longint; buf:pointer; nbytes:size_t; off:off_t):ssize_t;cdecl;external libc_nlm name 'pread';
function pwrite(fildes:longint; buf:pointer; nbytes:size_t; off:off_t):ssize_t;cdecl;external libc_nlm name 'pwrite';
function FpRead(fildes:longint; buf:pointer; nbytes:size_t):ssize_t;cdecl;external libc_nlm name 'read';
function FpRead(fildes:longint; var buf; nbytes:size_t):ssize_t;cdecl;external libc_nlm name 'read';
function Fprmdir(path:Pchar):longint;cdecl;external libc_nlm name 'rmdir';
procedure sync;cdecl;external libc_nlm name 'sync';
function sysconf(name:longint):longint;cdecl;external libc_nlm name 'sysconf';
function unlink(path:Pchar):longint;cdecl;external libc_nlm name 'unlink';
function FpUnlink(path:Pchar):longint;cdecl;external libc_nlm name 'unlink';
function FpWrite(fildes:longint; buf:pointer; nbytes:size_t):ssize_t;cdecl;external libc_nlm name 'write';
function FpWrite(fildes:longint; var buf; nbytes:size_t):ssize_t;cdecl;external libc_nlm name 'write';
{ appeared in BSD...  }
function brk(endds:pointer):longint;cdecl;external libc_nlm name 'brk';
function getdtablehi:longint;cdecl;external libc_nlm name 'getdtablehi';
function getdtablesize:longint;cdecl;external libc_nlm name 'getdtablesize';
function getpagesize:longint;cdecl;external libc_nlm name 'getpagesize';

function readlink(path:Pchar; buf:Pchar; bufsize:size_t):longint;cdecl;external libc_nlm name 'readlink';
function FpReadlink(path:Pchar; buf:Pchar; bufsize:size_t):longint;cdecl;external libc_nlm name 'readlink';
function sbrk(incr:intptr_t):pointer;cdecl;external libc_nlm name 'sbrk';
{ nonstandard additions (see also fsio.h)...  }
function cancel(t_id:longint):longint;cdecl;external libc_nlm name 'cancel';
function confstr(name:longint; buf:Pchar; len:size_t):size_t;cdecl;external libc_nlm name 'confstr';
function delay(milliseconds:dword):longint;cdecl;external libc_nlm name 'delay';
function _delay(milliseconds:dword):longint;cdecl;external libc_nlm name 'delay';
function sethostid(hostid:longint):longint;cdecl;external libc_nlm name 'sethostid';
function setmode(fildes:longint; oflag:longint):longint;cdecl;external libc_nlm name 'setmode';
function sleep(seconds:dword):dword;cdecl;external libc_nlm name 'sleep';
function FpSleep(seconds:dword):dword;cdecl;external libc_nlm name 'sleep';
function usleep(useconds:useconds_t):longint;cdecl;external libc_nlm name 'usleep';
{ nonstandard (transitional) addtions for 64-bit file I/O...  }
function chsize64(fildes:longint; size:size64_t):longint;cdecl;external libc_nlm name 'chsize64';
function Fpchsize64(fildes:longint; size:size64_t):longint;cdecl;external libc_nlm name 'chsize64';
function ftruncate64(fildes:longint; len:off64_t):longint;cdecl;external libc_nlm name 'ftruncate64';
function Fpftruncate64(fildes:longint; len:off64_t):longint;cdecl;external libc_nlm name 'ftruncate64';
function lseek64(fildes:longint; offset:off64_t; whence:longint):off64_t;cdecl;external libc_nlm name 'lseek64';
function Fplseek64(fildes:longint; offset:off64_t; whence:longint):off64_t;cdecl;external libc_nlm name 'lseek64';
function pread64(fildes:longint; buf:pointer; nbytes:size_t; off:off64_t):ssize_t;cdecl;external libc_nlm name 'pread64';
function pwrite64(fildes:longint; buf:pointer; nbytes:size_t; off:off64_t):ssize_t;cdecl;external libc_nlm name 'pwrite64';
function tell64(fildes:longint):off64_t;cdecl;external libc_nlm name 'tell64';
function Fptell64(fildes:longint):off64_t;cdecl;external libc_nlm name 'tell64';
function ____environ:PPPchar;cdecl;external libc_nlm name '____environ';
function ___optarg:PPchar;cdecl;external libc_nlm name '___optarg';
function ___optind:Plongint;cdecl;external libc_nlm name '___optind';
function ___opterr:Plongint;cdecl;external libc_nlm name '___opterr';
function ___optopt:Plongint;cdecl;external libc_nlm name '___optopt';
function ___optreset:Plongint;cdecl;external libc_nlm name '___optreset';
function want_posix_semantics(timestamp:longint):longint;cdecl;external libc_nlm name 'want_posix_semantics';
{
** Prototype for libraries writing their own start-up and shut-down code. This
** is not an interface, but only a prototype for code furnished by the UNIX-
** style NLM library. The presence of these is noted by the prelude object.
 }
function _init:longint;cdecl;external libc_nlm name '_init';
function _fini:longint;cdecl;external libc_nlm name '_fini';
{ globals for getopt() implementation...  }
{ the prototype for ioctl() is in unistd.h...  }


// sys/byteorder.h
function htonl(_para1:dword):dword;cdecl;external libc_nlm name 'htonl';
function htons(_para1:word):word;cdecl;external libc_nlm name 'htons';
function ntohl(_para1:dword):dword;cdecl;external libc_nlm name 'ntohl';
function ntohs(_para1:word):word;cdecl;external libc_nlm name 'ntohs';


// sys/cdefs.h
// sys/dir.h
// dirent.h
// sys/mode.h

{ POSIX file types...  }
{ POSIX file modes: owner (user) permission...  }
{ POSIX file modes: group permission...  }
{ POSIX file modes: other permission...  }
{ POSIX setuid(), setgid(), and sticky...  }
{ for use with stat(), readdir(), chmod(), mkdir(), etc.  }
{ NetWare-specific additions to the upper half of mode_t...  }
{ values for field 'd_type'...  }

{ pshpack1.h }
{ turn on 1-byte packing...  }

  const
     S_IFMT = $F000;
  { first-in/first-out (FIFO/pipe)            }
     S_IFIFO = $1000;
  { character-special file (tty/console)      }
     S_IFCHR = $2000;
  { directory                                 }
     S_IFDIR = $4000;
  { blocking device (unused)                  }
     S_IFBLK = $6000;
  { regular                                   }
     S_IFREG = $8000;
  { symbolic link (unused)                    }
     S_IFLNK = $A000;
  { Berkeley socket                           }
     S_IFSOCK = $C000;
     S_IRWXU = $01C0;
     S_IRUSR = $0100;
     S_IWUSR = $0080;
     S_IXUSR = $0040;
     S_IREAD = S_IRUSR;
     S_IWRITE = S_IWUSR;
     S_IEXEC = S_IXUSR;
  { POSIX file modes: group permission...  }
     S_IRWXG = $0038;
     S_IRGRP = $0020;
     S_IWGRP = $0010;
     S_IXGRP = $0008;
  { POSIX file modes: other permission...  }
     S_IRWXO = $0007;
     S_IROTH = $0004;
     S_IWOTH = $0002;
     S_IXOTH = $0001;
  { POSIX setuid(), setgid(), and sticky...  }
     S_ISUID = $0800;
     S_ISGID = $0400;
     S_ISVTX = $0200;
  { for use with stat(), readdir(), chmod(), mkdir(), etc.  }
  { NetWare-specific additions to the upper half of mode_t...  }
     M_A_RDONLY          = $00010000;    // read-only entry
     M_A_HIDDEN          = $00020000;    // hidden entry
     M_A_SYSTEM          = $00040000;    // system entry
     M_A_SUBDIR          = $00080000;    // is Subdir
     M_A_ARCH            = $00100000;    // file has been archived
     M_A_SHARE           = $00200000;    // file is shared
     M_A_TRANS           = $00400000;    // file transactions are tracked
     M_A_IMMPURG         = $00800000;    // purge deleted file immediately
     M_A_NORENAM         = $01000000;    // inhibit renaming
     M_A_NODELET         = $02000000;    // inhibit deletion
     M_A_NOCOPY          = $04000000;    // inhibit copying
     M_A_IMMCOMPRESS     = $08000000;    // compress immediately
     M_A_FILE_COMPRESSED = $10000000;    // file is compressed
     M_A_DONT_COMPRESS   = $20000000;    // inhibit compression
     M_A_CANT_COMPRESS   = $40000000;    // file cannot be compressed
     M_A_BITS_SIGNIFICANT= $80000000;    // these M_A_- bits are important

     DT_UNKNOWN = 0;
     DT_TTY = 1;           { console (won't occur) }
     DT_REG = S_IFREG;     { normal file }
     DT_DIR = S_IFDIR;     { subdirectory }
     DT_FIFO = S_IFIFO;    { first-in/first-out (FIFO/pipe) }
     DT_SOCK = S_IFSOCK;   { socket (won't occur) }
     DT_CHR = S_IFCHR;     { character-special file (unused)}
     DT_BLK = S_IFBLK;     { blocking device (unused) }
     DT_LNK = S_IFLNK;     { symbolic or hard link (won't occur) }

type
   Pdirent = ^Tdirent;
   Tdirent = record
        d_userspec : dword;
        d_flags    : dword;
        d_type     : mode_t;
        d_mode     : mode_t;
        d_ino      : ino_t;
        d_size     : off64_t;
        d_spare    : array[0..54] of dword;
        d_pad1     : byte;
        d_pad2     : byte;
        d_pad3     : byte;
        d_namelen  : byte;
        d_name     : array[0..(255 + 1)-1] of char;
     end;
    PPdirent = ^Pdirent;
   //DIR = dirent;
   //PDIR = ^DIR;
   //TDir = Dir;
{ sizeof(struct dirent) == 0x200 (512.)  }

(** unsupported pragma#pragma pack()*)


function closedir(dirp:Pdirent):longint;cdecl;external libc_nlm name 'closedir';
function opendir(pathName:Pchar):Pdirent;cdecl;external libc_nlm name 'opendir';
function readdir(dirp:Pdirent):Pdirent;cdecl;external libc_nlm name 'readdir';
function readdir_r(dirp:Pdirent; entry:Pdirent; result:PPdirent):longint;cdecl;external libc_nlm name 'readdir_r';
procedure rewinddir(dirp:Pdirent);cdecl;external libc_nlm name 'rewinddir';

function Fpclosedir(dirp:Pdirent):longint;cdecl;external libc_nlm name 'closedir';
function Fpopendir(pathName:Pchar):Pdirent;cdecl;external libc_nlm name 'opendir';
function Fpreaddir(dirp:Pdirent):Pdirent;cdecl;external libc_nlm name 'readdir';
function Fpreaddir_r(dirp:Pdirent; entry:Pdirent; result:PPdirent):longint;cdecl;external libc_nlm name 'readdir_r';
procedure Fprewinddir(dirp:Pdirent);cdecl;external libc_nlm name 'rewinddir';

// sys/file.h
// fcntl.h

{ 'cmd' values for fcntl()...                                               }
const
 F_GETFL      = 1;        // get file status flags
 F_SETFL      = 2;        // set file status flags
 F_DUPFD      = 3;        // duplicate file descriptor
 F_GETFD      = 4;        // get file descriptor flags
 F_SETFD      = 5;        // set file descriptor flags
 F_SETLK      = 6;        // set record locking info
 F_SETLK64    = 16;       // set record locking info (64-bit)
 F_GETLK      = 7;        // get record locking info
 F_GETLK64    = 17;       // get record locking info (64-bit)
 F_SETLKW     = 8;        // get record locking info; wait if blocked
 F_SETLKW64   = 18;       // get record locking info (64-bit)
 F_CLOEXEC    = 9;        // close on execute

// values for 'l_type' field of 'struct flock'...
 F_RDLCK      = 1;        // shared or read lock
 F_WRLCK      = 2;        // exclusive or write lock
 F_UNLCK      = 3;        // unlock

// values for 'oflag' in open()...
 O_RDONLY     =$00000000; // open for read only
 O_WRONLY     =$00000001; // open for write only
 O_RDWR       =$00000002; // open for read and write
 O_ACCMODE    =$00000003; // access flags mask
 O_reserved1  =$00000004; // reserved
 O_reserved2  =$00000008; // reserved
 O_APPEND     =$00000010; // writes done at end of file
 O_CREAT      =$00000020; // create new file
 O_TRUNC      =$00000040; // truncate existing file
 O_EXCL       =$00000080; // exclusive open
 O_NOCTTY     =$00000100; // no controlling terminal--unsupported
 O_BINARY     =$00000200; // binary file--all files
 O_NDELAY     =$00000400; // nonblocking flag
 O_reserved3  =$00000800; // reserved
 O_SYNC       =$00001000; // synchronized I/O file integrity
 O_DSYNC      =$00002000; // synchronized I/O data integrity
 O_RSYNC      =$00004000; // synchronized read I/O
 O_NONBLOCK   = O_NDELAY; // alias
 FD_CLOEXEC   =$00008000; // parent closes after call to process()
 O_UPDATE     =$00010000; // keep legacy files updated
 O_FIFO       =$00100000; // opening one end of a FIFO [non-standard]

// value for third argument when 'cmd' is F_SETFL in fcntl()...
 FNDELAY      = O_NDELAY;   // fcntl() non-blocking I/O

// 'shflag' values for sopen()...
 SH_DENYRW    = $00000010; // deny read/write mode
 SH_DENYWR    = $00000020; // deny write mode
 SH_DENYRD    = $00000030; // deny read mode
 SH_DENYNO    = $00000040; // deny none mode

type
   Pflock = ^flock;
   flock = record
        l_pid : pid_t;                { process ID of owner, get with F_GETLK       }
        l_tid : pid_t;                { thread ID of owner, get with F_GETLK        }
        l_type : smallint;            { F_RDLCK or F_WRLCK                          }
        l_whence : smallint;          { flag for starting offset                    }
        ________spare : longint;      { unused                                      }
        ________reserved1 : longint;  { padding to resemble 64-bit structure        }
        l_start : off_t;              { relative offset in bytes                    }
        ________reserved2 : longint;  { padding to resemble 64-bit structure        }
        l_len : off_t;                { size; if 0, then until EOF                  }
     end;

   Pflock64 = ^flock64;
   flock64 = record                   { with F_GETLK64, F_SETLK64, FSETLKW64        }
        l_pid : pid_t;                { process ID of owner, get with F_GETLK       }
        l_tid : pid_t;                { thread ID of owner, get with F_GETLK        }
        l_type : smallint;            { F_RDLCK or F_WRLCK                          }
        l_whence : smallint;          { flag for starting offset                    }
        ________spare : longint;      { unused                                      }
        l_start : off64_t;            { relative offset in bytes                    }
        l_len : off64_t;              { size; if 0, then until EOF                  }
     end;

function creat(path:Pchar; mode:mode_t):longint;cdecl;external libc_nlm name 'creat';
{$ifndef DisableArrayOfConst}
function fcntl(fildes:longint; cmd:longint; args:array of const):longint;cdecl;external libc_nlm name 'fcntl';
{$endif}
function fcntl(fildes:longint; cmd:longint):longint;cdecl;external libc_nlm name 'fcntl';
{$ifndef DisableArrayOfConst}
function open(path:Pchar; oflag:longint; args:array of const):longint;cdecl;external libc_nlm name 'open';
{$endif}
function open(path:Pchar; oflag:longint):longint;cdecl;external libc_nlm name 'open';
function open(path:Pchar; oflag,mode:longint):longint;cdecl;external libc_nlm name 'open';
function FpOpen(path:Pchar; oflag:longint):longint;cdecl;external libc_nlm name 'open';
function FpOpen(path:Pchar; oflag,mode:longint):longint;cdecl;external libc_nlm name 'open';

function pipe_open(path:Pchar; oflag:longint):longint;cdecl;external libc_nlm name 'pipe_open';
function pipe_open(path:Pchar; oflag,mode:longint):longint;cdecl;external libc_nlm name 'pipe_open';
{$ifndef DisableArrayOfConst}
function sopen(path:Pchar; oflag:longint; shflag:longint; args:array of const):longint;cdecl;external libc_nlm name 'sopen';
{$endif}
function sopen(path:Pchar; oflag:longint; shflag:longint):longint;cdecl;external libc_nlm name 'sopen';


// sys/filio.h
{ defines for ioctl()...  }
// sys/ipc.h

{ mode bits...  }
{ keys...  }
{ control commands for semctl() and shmctl()...  }
type
   Pkey_t = ^key_t;
   key_t = longint;
   Pipc_perm = ^ipc_perm;
   ipc_perm = record
        uid  : uid_t;    // owner
        gid  : gid_t;    // owner
        cuid : uid_t;    // creator
        cgid : gid_t;    // creator
        mode : mode_t;   // read write permission
     end;



function ftok(path:Pchar; id:longint):key_t;cdecl;external libc_nlm name 'ftok';


// sys/mman.h

{ return value of mmap() in case of error...  }
{ 'flags' values for mlockall()...  }
{ 'protection' values for mmap()...  }
{ 'flags' values for mmap()...  }
{ 'flags' values for msync()...  }
{ 'advice' to madvice()...  }
{ effectual dummies that will never do anything...  }

function mlock(addr:pointer; len:size_t):longint;cdecl;external libc_nlm name 'mlock';
function mlockall(flags:longint):longint;cdecl;external libc_nlm name 'mlockall';
function munlock(addr:pointer; len:size_t):longint;cdecl;external libc_nlm name 'munlock';
function munlockall:longint;cdecl;external libc_nlm name 'munlockall';
function mprotect(addr:pointer; len:size_t; prot:longint):longint;cdecl;external libc_nlm name 'mprotect';
function madvise(addr:pointer; len:size_t; advice:longint):longint;cdecl;external libc_nlm name 'madvise';



// sys/param.h
// sys/stat.h
// time.h
type

   Pclock_t = ^clock_t;
   clock_t = dword;
   TClock  = clock_t;

   Ptime_t = ^time_t;
   time_t = longint;
   Ttime_t  = time_t;

{ turn on 1-byte packing...  }

type
   Ptm = ^Ttm;
   Ttm = record                // ANSI/ISO 'broken-down' time
        tm_sec   : longint;    // seconds after the minute [0..59]
        tm_min   : longint;    // minutes after the hour [0..59]
        tm_hour  : longint;    // hours since midnight [0..23]
        tm_mday  : longint;    // days of the month [1..31]
        tm_mon   : longint;    // months since January [0..11]
        tm_year  : longint;    // years since 1900 [0..ì]
        tm_wday  : longint;    // days since Sunday [0..6]
        tm_yday  : longint;    // days since first of January [0..365]
        tm_isdst: longint;    // on summer time (-1 unknown, 0 no, !0 yes)
     end;

   Ptimespec = ^Ttimespec;
   Ttimespec = record        // time expressed in seconds and nanoseconds
        tv_sec  : time_t;    // seconds
        tv_nsec : longint;   // nanoseconds
     end;
   timespec_t = Ttimespec;
   Ptimespec_t = ^timespec_t;
   timestrc_t = Ttimespec;
   Ptimestrc_t = ^timestrc_t;

   Pitimerspec = ^Titimerspec;
   Titimerspec = record
        it_interval : Ttimespec;  // timer period
        it_value    : Ttimespec;  // expiration
     end;
   itimerspec_t = Titimerspec;
   Pitimerspec_t = ^itimerspec_t;
{ DOS 'broken-down' time                     }
{ two-second increments only                 }
{ 0-59                                       }
{ 0-23                                       }
{ 1-31                                       }
{ 1-12                                       }
{ years since 1980 (limit: 0-119)            }
   Pdos_tm = ^Tdos_tm;
   Tdos_tm = record
        flag0 : longint;
     end;


const
   bm_dos_tm_bisecond = $1F;
   bp_dos_tm_bisecond = 0;
   bm_dos_tm_minute = $7E0;
   bp_dos_tm_minute = 5;
   bm_dos_tm_hour = $F800;
   bp_dos_tm_hour = 11;
   bm_dos_tm_day = $1F0000;
   bp_dos_tm_day = 16;
   bm_dos_tm_month = $1E00000;
   bp_dos_tm_month = 21;
   bm_dos_tm_year = $FE000000;
   bp_dos_tm_year = 25;

{$ifndef INCLUDED_FROM_SYSTEM}
function bisecond(var a : Tdos_tm) : word;
procedure set_bisecond(var a : Tdos_tm; __bisecond : word);
function minute(var a : Tdos_tm) : word;
procedure set_minute(var a : Tdos_tm; __minute : word);
function hour(var a : Tdos_tm) : word;
procedure set_hour(var a : Tdos_tm; __hour : word);
function day(var a : Tdos_tm) : word;
procedure set_day(var a : Tdos_tm; __day : word);
function month(var a : Tdos_tm) : word;
procedure set_month(var a : Tdos_tm; __month : word);
function year(var a : Tdos_tm) : word;
procedure set_year(var a : Tdos_tm; __year : word);
{$endif}


type
   Pdos_d = ^Tdos_d;
   Tdos_d = packed record   // DOS date separated from time
        time : word;        // time fields
        date : word;        // date fields
     end;

{ utility for passing DOS time               }
{ scalar for passing as argument             }
{ separated-out DOS time and date            }
{ broken-down DOS time and date              }
   Pdos_tm_u = ^Tdos_tm_u;
   Tdos_tm_u = record
       case longint of
          0 : ( long_dt : dword );
          1 : ( struct_dt : Tdos_d );
          2 : ( struct_tm : Tdos_tm );
       end;

(** unsupported pragma#pragma pack()*)


function asctime(localtime:Ptm):Pchar;cdecl;external libc_nlm name 'asctime';
function asctime(var localtime:Ttm):Pchar;cdecl;external libc_nlm name 'asctime';
function clock:clock_t;cdecl;external libc_nlm name 'clock';
function ctime(calendar:Ptime_t):Pchar;cdecl;external libc_nlm name 'ctime';
function ctime(var calendar:Ttime_t):Pchar;cdecl;external libc_nlm name 'ctime';
function difftime(t1, t2:Ttime_t):double;cdecl;external libc_nlm name 'difftime';
function gmtime(calendar:Ptime_t):Ptm;cdecl;external libc_nlm name 'gmtime';
function gmtime(var calendar:Ttime_t):Ptm;cdecl;external libc_nlm name 'gmtime';
function localtime(calendar:Ptime_t):Ptm;cdecl;external libc_nlm name 'localtime';
function localtime(var calendar:Ttime_t):Ptm;cdecl;external libc_nlm name 'localtime';
function mktime(localtime:Ptm):time_t;cdecl;external libc_nlm name 'mktime';
function mktime(var localtime:Ttm):time_t;cdecl;external libc_nlm name 'mktime';

//size_t strftime ( char * __restrict s, size_t, const char * __restrict format,
//size_t strftime ( char * __restrict s, size_t, const char * __restrict format,
//                      const tm * __restrict localtime );

function time(calendar:Ptime_t):time_t;cdecl;external libc_nlm name 'time';
function time(var calendar:Ttime_t):time_t;cdecl;external libc_nlm name 'time';
function ___clocks_per_sec:longint;cdecl;external libc_nlm name '___clocks_per_sec';
{ POSIX data and helper functions...  }
function ___daylight:Plongint;cdecl;external libc_nlm name '___daylight';
function ___daylightOnOff:Plongint;cdecl;external libc_nlm name '___daylightOnOff';
function ___daylightOffset:Ptime_t;cdecl;external libc_nlm name '___daylightOffset';
function ___timezone:Ptime_t;cdecl;external libc_nlm name '___timezone';
function ___tzname:PPchar;cdecl;external libc_nlm name '___tzname';
function __isleap(year:longint):longint;cdecl;external libc_nlm name '__isleap';
procedure tzset;cdecl;external libc_nlm name 'tzset';
{ POSIX-defined reentrant additions...  }

function asctime_r(localtime:Ptm; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'asctime_r';
function asctime_r(var localtime:Ttm; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'asctime_r';
function ctime_r(calendar:Ptime_t; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'ctime_r';
function ctime_r(var calendar:Ttime_t; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'ctime_r';
function gmtime_r(calendar:Ptime_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'gmtime_r';
function gmtime_r(var calendar:Ttime_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'gmtime_r';
function localtime_r(calendar:Ptime_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'localtime_r';
function localtime_r(var calendar:Ttime_t; var localtime:Ttm):Ptm;cdecl;external libc_nlm name 'localtime_r';
{ Single UNIX Specification additions...  }
function nanosleep(rqtp, rmtp:Ptimespec):longint;cdecl;external libc_nlm name 'nanosleep';
function nanosleep(var rqtp, rmtp:Ttimespec):longint;cdecl;external libc_nlm name 'nanosleep';
{ Novell-defined additions...  }
function ltime(calendar:Ptime_t):time_t;cdecl;external libc_nlm name 'ltime';
function ltime(var calendar:Ttime_t):time_t;cdecl;external libc_nlm name 'ltime';
function mkgmtime(gmtime:Ptm):time_t;cdecl;external libc_nlm name 'mkgmtime';
function mkgmtime(var gmtime:Ttm):time_t;cdecl;external libc_nlm name 'mkgmtime';
function dos2calendar(dostime:Tdos_d):time_t;cdecl;external libc_nlm name 'dos2calendar';
function calendar2dos(calendar:time_t):Tdos_d;cdecl;external libc_nlm name 'calendar2dos';


// sys/time.h
// sys/timeval.h
// sys/times.h

type
   Ptms = ^Ttms;
   Ttms = record                        { describes CPU time used by process, children  }
        tms_utime  : clock_t;           { user CPU time }
        tms_stime  : clock_t;           { system CPU time (identical to 'tms_utime')    }
        tms_cutime : clock_t;           { unimplemented }
        tms_cstime : clock_t;           { unimplemented }
     end;

   Ptimezone = ^Ttimezone;
   TTimezone = record                   { returned by gettimeofday() }
        tz_secondswest : time_t;        { seconds west of UTC }
        tz_minuteswest : longint;       { minutes west of UTC (GMT) }
        tz_dsttime     : longint;       { nonzero if DST is ever in effect }
     end;
   Timezone = TTimezone;

{
** Normally this functions fills struct tms with several time values. Most of
** the time it is very important to have only the return value, that is the
** realtime that has been elapsed.
 }

function times(__buffer:Ptms):clock_t;cdecl;external libc_nlm name 'times';
function times(var __buffer:Ttms):clock_t;cdecl;external libc_nlm name 'times';
{ turn on 1-byte packing...  }

{ this structure is returned by gettimeofday() and used in select()...  }
type
   Ptimeval = ^Ttimeval;
   Ttimeval = record
        tv_sec  : longint;
        tv_usec : longint;
     end;
   Timeval = TTimeval;

(** unsupported pragma#pragma pack()*)
{ operations on struct timeval; note timercmp() does not work for >= or <=  }

function gettimeofday(tp:Ptimeval; tpz:Ptimezone):longint;cdecl;external libc_nlm name 'gettimeofday';
function Fpgettimeofday(tp:Ptimeval; tpz:Ptimezone):longint;cdecl;external libc_nlm name 'gettimeofday';
function settimeofday(tp:Ptimeval; tpz:Ptimezone):longint;cdecl;external libc_nlm name 'settimeofday';
function gettimeofday(var tp:Ttimeval; var tpz:Ttimezone):longint;cdecl;external libc_nlm name 'gettimeofday';
function settimeofday(var tp:Ttimeval; var tpz:Ttimezone):longint;cdecl;external libc_nlm name 'settimeofday';
function Fpgettimeofday(var tp:Ttimeval; var tpz:Ttimezone):longint;cdecl;external libc_nlm name 'gettimeofday';
function Fpsettimeofday(var tp:Ttimeval; var tpz:Ttimezone):longint;cdecl;external libc_nlm name 'settimeofday';

{ turn on 1-byte packing...  }
type
   Pstat = ^Tstat;
   Tstat = record
        st_userspec: dword;                         // untouched by stat()
        st_flags   : dword;                         // flags for this entry
        st_mode    : mode_t;                        // emulated file mode
        st_spare1  : dword;
        st_gen     : Tuint64;                       // generation number of inode
        st_ino     : ino_t;                         // directory entry number
        st_dev     : dev_t;                         // volume number
        st_rdev    : dev_t;                         // device type (always 0)
        st_size    : off64_t;                       // total file size
        st_spare2  : Tuint64;
        st_blocks  : blkcnt_t;                      // count of blocks allocated to file
        st_blksize : blksize_t;                     // block size for allocation--files only
        st_nlink   : nlink_t;                       // count of hard links (always 1)
        st_spare3  : array[0..2] of dword;
        st_uid     : uid_t;                         // owner (object) identity
        st_gid     : gid_t;                         // group-id (always 0)
        st_bid     : uid_t;                         // identity of last archiver
        st_mid     : uid_t;                         // identity of last updator
        st_atim    : timespec_t;                    // last access date--files only
        st_mtim    : timespec_t;                    // last modify date and time
        st_ctim    : timespec_t;                    // last file attributes modification
        st_btim    : timespec_t;                    // last archived date and time
                                                    // NOT returned by stat() or fstat()...
        st_rights  : dword;                         // NetWare rights
        st_spare4  : array[0..2] of dword;
        st_name    : array[0..(255 + 1)-1] of char; // object name as if from readdir()
        st_spare5  : array[0..19] of dword;
     end;

{ sizeof(struct stat) == 0x200 (512.)      }

(** unsupported pragma#pragma pack()*)


function Fpchmod(path:Pchar; mode:mode_t):longint;cdecl;external libc_nlm name 'chmod';
function Fpfchmod(fildes:longint; mode:mode_t):longint;cdecl;external libc_nlm name 'fchmod';
function Fpfstat(fildes:longint; buf:Pstat):longint;cdecl;external libc_nlm name 'fstat';
function Fpfstat(fildes:longint; var buf:Tstat):longint;cdecl;external libc_nlm name 'fstat';
function Fplstat(path:Pchar; buf:Pstat):longint;cdecl;external libc_nlm name 'lstat';
function Fplstat(path:Pchar; var buf:Tstat):longint;cdecl;external libc_nlm name 'lstat';
function Fpmkdir(pathname:Pchar; mode:mode_t):longint;cdecl;external libc_nlm name 'mkdir';
function Fpmkfifo(pathname:Pchar; mode:mode_t):longint;cdecl;external libc_nlm name 'mkfifo';
function Fpmknod(path:Pchar; mode:mode_t; dev:dev_t):longint;cdecl;external libc_nlm name 'mknod';
function Fprealname(pathname:Pchar; name:Pchar):longint;cdecl;external libc_nlm name 'realname';
function Fpstat(path:Pchar; buf:Pstat):longint;cdecl;external libc_nlm name 'stat';
function Fpstat(path:Pchar; var buf:Tstat):longint;cdecl;external libc_nlm name 'stat';
function Fpumask(cmask:mode_t):mode_t;cdecl;external libc_nlm name 'umask';
{
** The following value is not really correct, but it is a value that has been
** used for a long time seems to be usable. Normally, NOFILE should not be used
** anyway.
 }
{ bit map related macros...   }
{ macros for counting and rounding...  }
{ supplementary macros for min/max...   }
{ unit of sys/stat.h `st_blocks'...   }


// sys/select.h

{
** Including file may make this bigger or smaller as long as the FD_- macros
** are faithfully used.
 }
type

   Pfd_set = ^Tfd_set;
   Tfd_set = record
        fd_count : longint;
        fd_array : array[0..63] of longint;
     end;
{ heterogeneous select calls (socket+pipe) unsupported on NetWare...  }


function Fppipe_select(nfds:longint; readfds, writefds, exceptfds:Pfd_set; timeout:Ptimeval):longint;cdecl;external libc_nlm name 'pipe_select';
function Fppipe_select(nfds:longint; var readfds, writefds, exceptfds:Tfd_set; var timeout:Ttimeval):longint;cdecl;external libc_nlm name 'pipe_select';

//function select(nfds:longint; readfds:Pfd_set; writefds:Pfd_set; exceptfds:Pfd_set; timeout:Ptimeval):longint;cdecl;external libc_nlm name 'select';
//function select(nfds:longint; var readfds, writefds, exceptfds:Tfd_set; var timeout:Ttimeval):longint;cdecl;external libc_nlm name 'select';
function FpSelect(nfds:longint; readfds:Pfd_set; writefds:Pfd_set; exceptfds:Pfd_set; timeout:Ptimeval):longint;cdecl;external libc_nlm name 'select';
function FpSelect(nfds:longint; var readfds, writefds, exceptfds:Tfd_set; var timeout:Ttimeval):longint;cdecl;external libc_nlm name 'select';
function ___fd_isset(fd:longint; _set:Pfd_set):longint;cdecl;external libc_nlm name '___fd_isset';
function ___fd_isset(fd:longint; var _set:Tfd_set):longint;cdecl;external libc_nlm name '___fd_isset';


// sys/sem.h

{ semctl() command definitions...  }
{ semaphore text map address        }
{ pid of last operation             }
{ count awaiting (semval > cval)    }
{ count awaiting (semval == 0)      }
type
   Psem = ^Tsem;
   Tsem = record
        semval  : ushort_t;
        semadj  : ushort_t;
        sempid  : pid_t;
        semncnt : ushort_t;
        semzcnt : ushort_t;
        semptr  : pointer;       // semaphore on which this is based
     end;
   TSemaphore = Tsem;
   PSemaphore = Psem;

   Psemid_ds = ^Tsemid_ds;
   Tsemid_ds = record
        sem_perm    : ipc_perm;
        sem_base    : Psem;       // pointer to first semaphore in set
        sem_nsems   : word;       // number of semaphores in set
        sem_otime   : time_t;     // last semop time
        sem_ctime   : time_t;     // last change time
        sem_ptr     : pointer;    // actual underlying semaphore
        sem_realkey : longint;    // 'real' semaphore key
     end;

   Psembuf = ^Tsembuf;
   Tsembuf = record
        sem_num : word;           // Number
        sem_op  : smallint;       // operation
        sem_flg : smallint;       // flags
     end;

   Psemun = ^Tsemun;
   Tsemun = record
       case longint of
          0 : ( val : longint );
          1 : ( buf : Psemid_ds );
          2 : ( _array : Pword );
       end;

{$ifndef DisableArrayOfConst}
function semctl(semid:longint; semnum:longint; cmd:longint; args:array of const):longint;cdecl;external libc_nlm name 'semctl';
{$endif}
function semctl(semid:longint; semnum:longint; cmd:longint):longint;cdecl;external libc_nlm name 'semctl';
function semget(key:key_t; nsems:longint; semflag:longint):longint;cdecl;external libc_nlm name 'semget';
function semop(semid:longint; sops:Psembuf; nsops:size_t):longint;cdecl;external libc_nlm name 'semop';
function semop(semid:longint; var sops:Tsembuf; nsops:size_t):longint;cdecl;external libc_nlm name 'semop';


// sys/sendfile.h

function sendfile(out_fd,in_fd:longint; offset:Poff_t; count:size_t):ssize_t;cdecl;external libc_nlm name 'sendfile';
function sendfile64(out_fd,in_fd:longint; offset:Poff64_t; count:size_t):ssize_t;cdecl;external libc_nlm name 'sendfile64';


// sys/shm.h

type

   Pshmatt_t = ^shmatt_t;
   shmatt_t = dword;
{ turn on 1-byte packing...  }

{ size of segment in bytes               }
{ process ID of last shared operation    }
{ process ID of creator                  }
{ number of current attaches             }
{ time of last shmat()                   }
{ time of last shmdt()                   }
{ time of last change by shmctl()        }
{ operation permission structure         }
type
   Pshmid_ds = ^shmid_ds;
   shmid_ds = record
        shm_segsz : size_t;
        shm_lpid : pid_t;
        shm_cpid : pid_t;
        shm_nattch : shmatt_t;
        shm_atime : time_t;
        shm_dtime : time_t;
        shm_ctime : time_t;
        shm_spare1 : longint;
        shm_perm : ipc_perm;
        shm_spare2 : array[0..2] of longint;
     end;

(** unsupported pragma#pragma pack()*)


function shmat(shmid:longint; shmaddr:pointer; shmflag:longint):pointer;cdecl;external libc_nlm name 'shmat';
function shmctl(shmid:longint; cmd:longint; buf:Pshmid_ds):longint;cdecl;external libc_nlm name 'shmctl';

function shmdt(shmaddr:pointer):longint;cdecl;external libc_nlm name 'shmdt';
function shmget(key:key_t; size:size_t; shmflag:longint):longint;cdecl;external libc_nlm name 'shmget';

// signal.h

    const
       SIGABRT = 1;
       SIGFPE = 2;
       SIGILL = 3;
       SIGINT = 4;
       SIGSEGV = 5;
       SIGTERM = 6;
       SIGPOLL = 7;
    { currently unimplemented POSIX-mandated signals  }
       SIGKILL  = 11;
       SIGSPARE = 12;
       SIGALRM  = 13;
       SIGCHILD = 14;
       SIGCHLD  = SIGCHILD;
       SIGCONT  = 15;
       SIGHUP   = 16;
       SIGPIPE  = 17;
       SIGQUIT  = 18;
       SIGSTOP  = 19;
       SIGTSTP  = 20;
       SIGTTIN  = 21;
       SIGTTOU  = 22;
       SIGUSR1  = 23;
       SIGUSR2  = 24;
       SIGUSR3  = 25;
       SIGUSR4  = 26;
       SIGUSR5  = 27;
       SIGUSR6  = 28;
       SIGUSR7  = 29;
    { Novell-defined signals  }
       SIG_FINI         = 30;
       SIG_LOCALECHANGE = 31;
       NSIG             = 32;
       SIG_BLOCK        = $00000000;
       SIG_UNBLOCK      = $00000001;
       SIG_SETMASK      = $FFFFFFFF;
//       SIGEMPTYSET      = $0000000000000000;
       SIGFULLSET       = $FFFFFFFFFFFFFFFF;


type
   Psig_atomic_t = ^sig_atomic_t;
   sig_atomic_t = longint;

   Psigset_t = ^sigset_t;
   sigset_t = Tuint64;
{ flags for sa_flags in struct sigaction  }
   Psigaction = ^sigaction;
   sigaction = record
        sa_handler : procedure (_para1:longint);cdecl;
        sa_mask    : sigset_t;
        sa_flags   : longint;
     end;

type TCDeclProc1LIntPara = procedure (_para1:longint); cdecl;
function Fpraise(_para1:longint):longint;cdecl;external libc_nlm name 'raise';
function Fpsignal(sig:longint; func:TCDeclProc1LIntPara):TCDeclProc1LIntPara;cdecl;external libc_nlm name 'signal';
function Fpsigwait(_set:Psigset_t; sig:Plongint):longint;cdecl;external libc_nlm name 'sigwait';
{ signal vector functions...  }

//!! function sigaction(sig:longint; act:Psigaction; oact:Psigaction):longint;cdecl;external libc_nlm name 'sigaction';

function Fpsigaddset(_para1:Psigset_t; _para2:longint):longint;cdecl;external libc_nlm name 'sigaddset';
function Fpsigdelset(_para1:Psigset_t; _para2:longint):longint;cdecl;external libc_nlm name 'sigdelset';
function Fpsigismember(_para1:Psigset_t; _para2:longint):longint;cdecl;external libc_nlm name 'sigismember';
function Fpsigfillset(_para1:Psigset_t):longint;cdecl;external libc_nlm name 'sigfillset';
function Fpsigemptyset(_para1:Psigset_t):longint;cdecl;external libc_nlm name 'sigemptyset';
function Fpsigpending(_set:Psigset_t):longint;cdecl;external libc_nlm name 'sigpending';
function Fpsigsuspend(mask:Psigset_t):longint;cdecl;external libc_nlm name 'sigsuspend';
function Fpsigprocmask(how:longint; act:Psigset_t; oldact:Psigset_t):longint;cdecl;external libc_nlm name 'sigprocmask';
function Fpkill(pid:pid_t; sig:longint):longint;cdecl;external libc_nlm name 'kill';


// sys/socket.h
// sys/uio.h
{ turn on 1-byte packing...  }

type
   Piovec = ^iovec;
   iovec = record
        iov_base : caddr_t;
        iov_len : longint;
     end;
   iovec_t = iovec;
   Piovec_t = ^iovec_t;

(** unsupported pragma#pragma pack()*)


function Fpreadv(fildes:longint; iov:Piovec; iovcnt:longint):ssize_t;cdecl;external libc_nlm name 'readv';
function Fpwritev(fildes:longint; iov:Piovec; iovcnt:longint):ssize_t;cdecl;external libc_nlm name 'writev';
{ socket types...  }
{ option flags per-socket...  }
{ additional options, not kept in so_options...  }
{ additional option to be used with level IPPROTO_TCP...  }
{ level number for get/setsockopt() to apply to socket itself...  }
{ address families  }
{ protocol families, same as address families for now...  }
{ values for shutdown() 'how'...  }

{
** Note:
**
** The Novell NDK headers for NKS/LibC contain structures that are explicitly
** hand-packed for best use on the platform in question (usually IA32). To
** avoid the impredictability encountered when compiling with different
** compilers, these headers rely on 1-byte packing.
 }
{ this header sets packing to 1 for different compilers  }
{ save off the previous packing directive in a compiler specific way...  }
{ turn on 1-byte packing...  }

{ structure used for manipulating linger option...  }
{ option on/off                          }
{ linger time                            }
type
   Plinger = ^linger;
   linger = record
        l_onoff : longint;
        l_linger : longint;
     end;

{ structure used to define addresses for bind(), connect(), etc...  }

   Psa_family_t = ^sa_family_t;
   sa_family_t = word;
{ address family                         }
{ up to 14 bytes of direct address       }
   Psockaddr = ^sockaddr;
   sockaddr = record
        sa_family : sa_family_t;
        sa_data : array[0..13] of char;
     end;

{ used by kernel to pass protocol info.  }
{    in raw sockets                      }
{ address family                         }
{ protocol                               }
   Psockproto = ^sockproto;
   sockproto = packed record
        sp_family : word;
        sp_protocol : word;
     end;


   Psocklen_t = ^socklen_t;
   socklen_t = dword;
{
** SUS' and BSD 4.4 message passing. struct msghdr has an additional field
** (msg_flags) and slightly different fieldnames over what we used to
** promote. msg_accrights(len) is done differently.
 }
{ optional address                       }
{ size of address                        }
{ scatter/gather array                   }
{ count of elements in msg_iov           }
{ access rights sent/received            }
   Pmsghdr = ^msghdr;
   msghdr = record
        msg_name : caddr_t;
        msg_namelen : socklen_t;
        msg_iov : Piovec;
        msg_iovlen : longint;
        msg_accrights : caddr_t;
        msg_accrightslen : socklen_t;
        msg_flags : longint;
     end;

{
** POSIX 1003.1g: Ancillary data object information consisting of a sequence
** of pairs of (cmsghdr, cmsg_data[1]).
 }
{ data byte count including header       }
{ originating protocol                   }
{ protocol-specific type                 }
   Pcmsghdr = ^cmsghdr;
   cmsghdr = record
        cmsg_len : socklen_t;
        cmsg_level : longint;
        cmsg_type : longint;
     end;


(** unsupported pragma#pragma pack()*)

function Fpaccept(s:longint; addr:Psockaddr; len:Psize_t):longint;cdecl;external libc_nlm name 'accept';
function Fpbind(s:longint; addr:Psockaddr; _para3:size_t):longint;cdecl;external libc_nlm name 'bind';
function Fpconnect(s:longint; addr:Psockaddr; len:size_t):longint;cdecl;external libc_nlm name 'connect';
function Fpgetpeername(s:longint; addr:Psockaddr; len:Psize_t):longint;cdecl;external libc_nlm name 'getpeername';
function Fpgetsockname(s:longint; addr:Psockaddr; len:Psize_t):longint;cdecl;external libc_nlm name 'getsockname';
function Fpgetsockopt(s:longint; level:longint; optname:longint; optval:pointer; optlen:Psize_t):longint;cdecl;external libc_nlm name 'getsockopt';
function Fplisten(s:longint; backlog:longint):longint;cdecl;external libc_nlm name 'listen';
function Fprecv(s:longint; buf:pointer; len:size_t; flags:longint):ssize_t;cdecl;external libc_nlm name 'recv';
function Fprecvfrom(s:longint; buf:pointer; len:size_t; flags:longint; from:Psockaddr;
           fromlen:Psize_t):ssize_t;cdecl;external libc_nlm name 'recvfrom';
function Fprecvmsg(s:longint; msg:Pmsghdr; flags:longint):ssize_t;cdecl;external libc_nlm name 'recvmsg';
function Fpsend(s:longint; msg:pointer; len:size_t; flags:longint):ssize_t;cdecl;external libc_nlm name 'send';
function Fpsendmsg(s:longint; _para2:Pmsghdr; flags:longint):ssize_t;cdecl;external libc_nlm name 'sendmsg';
function Fpsendto(s:longint; msg:pointer; len:size_t; flags:longint; _to:Psockaddr;
           tolen:size_t):ssize_t;cdecl;external libc_nlm name 'sendto';
function Fpsetsockopt(s:longint; level:longint; optname:longint; optval:pointer; optlen:size_t):longint;cdecl;external libc_nlm name 'setsockopt';
function Fpshutdown(s:longint; how:longint):longint;cdecl;external libc_nlm name 'shutdown';
function Fpsocket(domain:longint; _type:longint; protocol:longint):longint;cdecl;external libc_nlm name 'socket';


// sys/sockio.h
// sys/stat.h
{ turn on 1-byte packing...  }

{ file system type               }
{ fragment size                  }
{ block size                     }
{ total number of blocks         }
{ count of free blocks           }
{ total number of file nodes     }
{ count of free file nodes       }
{ server name                    }
{ volume name                    }
{ pack name                      }
type
   Pstatfs = ^Tstatfs;
   Tstatfs = record
        f_fstyp  : longint;
        f_frsize : size_t;
        f_bsize  : blksize_t;
        f_blocks : blkcnt_t;
        f_bfree,
        f_files,
        f_ffree  : Tuint64;
        f_fspare : array[0..1] of Tuint64;
        f_fserver: array[0..(48 + 4)-1] of char;
        f_fname  : array[0..(16 + 4)-1] of char;
        f_fpack  : array[0..19] of char;
     end;

(** unsupported pragma#pragma pack()*)


function Fpstatfs(path:Pchar; buf:Pstatfs):longint;cdecl;external libc_nlm name 'statfs';
function Fpstatfs(path:Pchar; var buf:Tstatfs):longint;cdecl;external libc_nlm name 'statfs';
function Fpfstatfs(fildes:longint; buf:Pstatfs):longint;cdecl;external libc_nlm name 'fstatfs';
function Fpfstatfs(fildes:longint; var buf:Tstatfs):longint;cdecl;external libc_nlm name 'fstatfs';

// sys/ttydefaults.h

{ system wide defaults for terminal state, mostly for porting help  }
{ defaults on "first" open...  }
{ control character defaults...  }
{ compatibility:  }
// sys/un.h

{ used in place of struct sockaddr_t to define addresses for UNIX domain...  }
type
   Psockaddr_un = ^sockaddr_un;
   sockaddr_un = record
        sun_family : sa_family_t;
        sun_path : array[0..510] of char;
     end;

// ======= sys/utsname.h ===============================================

{ turn on 1-byte packing...  }

// (request) bits for uname2()...
const
   UNAME_NLMMODULE      = $00000001;  // nlmmodule (if it can be gotten)
   UNAME_POSIXFIELDS    = $00000002;  // POSIX fields (see sys/utsname.h)
   UNAME_LIBVERSION     = $00000004;  // libminor/major/revision/threshold
   UNAME_FSVERSION      = $00000008;  // major/minor/revision/service pack
   UNAME_NETWAREVERSION = $00000010;  // netware_major/minor/revision
   UNAME_SERVERNAME     = $00000020;  // servername
   UNAME_CLUSTERNAME    = $00000040;  // clustername
   UNAME_LANGINFO       = $00000080;  // languagename/alt/id/altid/codepage
   UNAME_NLMMESSAGES    = $00000100;  // nlmmessagecount/table
   UNAME_NLMVERSION     = $00000200;  // nlmmajor/minor/revision
   UNAME_NLMINFO        = $00000400;  // nlmtimer/loadflags
   UNAME_NLMNAME        = $00000800;  // nlmname
   UNAME_NLMLOADPATH    = $00001000;  // nlmloadpath
   UNAME_NLMCOPYRIGHT   = $00002000;  // nlmcopyright
   UNAME_NLMDESCRIPTION = $00004000;  // nlmdescription
   UNAME_NLMCOMMANDLINE = $00008000;  // nlmcommandline
   UNAME_NDSTREENAME    = $00010000;  // treename
   UNAME_NLMCODEANDDATA = $00020000;  // code and datastart/-length

type
   Putsname = ^Tutsname;
   Tutsname = record
        userspec         : longint;     // untouched by uname()
                                        // Novell fields
                                        // Standard C Library implementation:
        libmajor         : longint;     //   major version number
        libminor         : longint;     //   minor version number
        librevision      : longint;     //   revision number
                                        // NetWare OS implementation
        major            : longint;     //   major version number
        minor            : longint;     //   minor version number
        revision         : longint;     //   revision number
                                        // NetWare C Library implementation
        libthreshold     : longint;     //   functionality and semantics timestamp
                                        // NetWare product distribution
        servicepack      : longint;
        netware_major    : longint;
        netware_minor    : longint;
        netware_revision : longint;
        servername       : array[0..63] of char;
        clustername      : array[0..63] of char;
        languagename     : array[0..31] of char;  // Server current language name
        altlanguagename  : array[0..31] of char;  // NLM's current language name
        languageid       : longint;
        altlanguageid    : longint;
        codepage         : longint;
        reserved1        : longint;
        reserved2        : array[0..3] of longint;
        nlmmodule        : pointer;              // NetWare-loadable module (NLM) handle
        nlmmajor         : longint;
        nlmminor         : longint;
        nlmrevision      : longint;
        nlmtimer         : time_t;               // module's date and time stamp in UTC
        nlmcommandline   : Pchar;
        nlmmessagecount  : dword;
        nlmmessagetable  : ^Pchar;
        nlmname          : array[0..35] of char;
        nlmloadpath      : array[0..255] of char;
        nlmcopyright     : array[0..255] of char;
        nlmdescription   : array[0..127] of char;
        nlmloadflags     : longint;
        reserved3        : longint;
        release          : array[0..15] of char;
        version          : array[0..15] of char;
        sysname          : array[0..15] of char;
        machine          : array[0..15] of char;
        nodename         : array[0..15] of char;
        treename         : array[0..95] of char; // name of NDS tree
        codeoffset       : pointer;
        codelength       : dword;
        dataoffset       : pointer;
        datalength       : dword;
        reserved4        : array[0..27] of longint;
     end;

(** unsupported pragma#pragma pack()*)

function Fpuname(name:Putsname):longint;cdecl;external libc_nlm name 'uname';
function Fpuname(var name:Tutsname):longint;cdecl;external libc_nlm name 'uname';
function Fpuname2(handle:pointer; info:Putsname; bits:dword):longint;cdecl;external libc_nlm name 'uname2';
function Fpuname2(handle:pointer; var info:Tutsname; bits:dword):longint;cdecl;external libc_nlm name 'uname2';


// sys/wait.h

function Fpwait(stat_loc:Plongint):pid_t;cdecl;external libc_nlm name 'wait';
function Fpwait(var stat_loc:longint):pid_t;cdecl;external libc_nlm name 'wait';
function Fpwaitpid(pid:pid_t; stat_loc:Plongint; options:longint):pid_t;cdecl;external libc_nlm name 'waitpid';
function Fpwaitpid(pid:pid_t; var stat_loc:longint; options:longint):pid_t;cdecl;external libc_nlm name 'waitpid';

// arpa/inet.h
// netinet/in.h

{ protocols...  }
{ port/socket numbers: network standard functions  }
{ port/socket numbers: host specific functions...  }
{ UNIX TCP sockets...   }
{ UNIX UDP sockets...  }
{
** Ports numbered less than IPPORT_RESERVED are reserved for privileged
** processes like 'root.'
 }
{ link numbers...  }
{
** Definitions of bits in Internet address integers. On subnets, the
** decomposition of addresses to host and net parts is done according
** to subnet mask, not the masks here.
 }
{ options for use with [gs]etsockopt at IP level...  }
{ macro to stuff the loopback address into an Internet address...  }
{ address testing macros...  }
{ type definitions...  }
type
   Pin_addr = ^in_addr;
   in_addr = record
        S_un : record
            case longint of
               0 : ( S_un_b : record
                    s_b1 : byte;
                    s_b2 : byte;
                    s_b3 : byte;
                    s_b4 : byte;
                 end );
               1 : ( S_un_w : record
                    s_w1 : word;
                    s_w2 : word;
                 end );
               2 : ( S_addr : dword );
            end;
     end;

   //!! in_addr = in_addr_t;
{ socket address, internet style    }
   Psockaddr_in = ^sockaddr_in;
   sockaddr_in = record
        sin_family : smallint;
        sin_port : u_short;
        sin_addr : in_addr;
        sin_zero : array[0..7] of char;
     end;

   //!! sockaddr_in = sockaddr_in_t;
   Pin6_addr = ^in6_addr;
   in6_addr = record
        in6a_u : record
            case longint of
               0 : ( bytes : array[0..15] of u_char );
               1 : ( shorts : array[0..7] of u_short );
               2 : ( words : array[0..3] of u_long );
            end;
     end;

   Psockaddr_in6 = ^sockaddr_in6;
   sockaddr_in6 = record
        sin6_family : smallint;
        sin6_port : u_short;
        sin6_flowinfo : u_long;
        sin6_addr : in6_addr;
        sin6_scope_id : u_long;
     end;

{ for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP...  }
{ IP multicast address of group    }
{ local IP address of interface    }
   Pip_mreq = ^ip_mreq;
   ip_mreq = record
        imr_multiaddr : in_addr;
        imr_interface : in_addr;
     end;

{ data...  }

//  var
//     in6addr_any : in6_addr;cvar;external;
//     in6addr_loopback : in6_addr;cvar;external;


function inet_addr(_string:Pchar):dword;cdecl;external libc_nlm name 'inet_addr';
function inet_aton(cp:Pchar; addr:Pin_addr):longint;cdecl;external libc_nlm name 'inet_aton';
function inet_makeaddr(net_num:in_addr; loc_addr:in_addr):in_addr;cdecl;external libc_nlm name 'inet_makeaddr';
function inet_network(_string:Pchar):in_addr;cdecl;external libc_nlm name 'inet_network';
function inet_ntoa(addr:in_addr):Pchar;cdecl;external libc_nlm name 'inet_ntoa';
function inet_ntop(af:longint; src:pointer; dst:Pchar; size:size_t):Pchar;cdecl;external libc_nlm name 'inet_ntop';
function inet_pton(af:longint; cp:Pchar; ap:pointer):longint;cdecl;external libc_nlm name 'inet_pton';


// netinet/in.h

{ User-settable options (used with setsockopt). }


// nks/defs.h

  const
     NX_MAX_KEYS = 64;
     NX_MAX_OBJECT_NAME_LEN = 31;
     NX_INTR1 = 0;
     NX_INTR2 = 1;
     NX_INTR3 = 2;
     NX_INTR4 = 3;
     NX_INTR5 = 4;
     NX_INTR6 = 5;
     NX_INTR7 = 6;
     NX_INTR8 = 7;
     NX_INTR9 = 8;
     NX_INTR10 = 9;
     NX_INTR11 = 10;
     NX_INTR12 = 11;
     NX_INTR13 = 12;
     NX_INTR14 = 13;
     NX_INTR15 = 14;
     NX_INTR16 = 15;
     NX_INTR17 = 16;
     NX_INTR18 = 17;
     NX_INTR19 = 18;
     NX_INTR20 = 19;
     NX_INTR21 = 20;
     NX_INTR22 = 21;
     NX_INTR23 = 22;
     NX_INTR24 = 23;
     NX_INTR25 = 24;
     NX_INTR26 = 25;
     NX_INTR27 = 26;
     NX_INTR28 = 27;
     NX_INTR29 = 28;
     NX_INTR30 = 29;
     NX_INTR31 = 30;
     NX_INTR32 = 31;
     NX_INTR33 = 32;
     NX_INTR34 = 33;
     NX_INTR35 = 34;
     NX_INTR36 = 35;
     NX_INTR37 = 36;
     NX_INTR38 = 37;
     NX_INTR39 = 38;
     NX_INTR40 = 39;
     NX_INTR41 = 40;
     NX_INTR42 = 41;
     NX_INTR43 = 42;
     NX_INTR44 = 43;
     NX_INTR45 = 44;
     NX_INTR46 = 45;
     NX_INTR47 = 46;
     NX_INTR48 = 47;
     NX_INTR49 = 48;
     NX_INTR50 = 49;
     NX_INTR51 = 50;
     NX_INTR52 = 51;
     NX_INTR53 = 52;
     NX_INTR54 = 53;
     NX_INTR55 = 54;
     NX_INTR56 = 55;
     NX_INTR57 = 56;
     NX_INTR58 = 57;
     NX_INTR59 = 58;
     NX_INTR60 = 59;
     NX_INTR61 = 60;
     NX_INTR62 = 61;
     NX_INTR63 = 62;
     NX_INTR64 = 63;


type

   PNXBool_t = ^NXBool_t;
   NXBool_t = longint;

   PNXVmId_t = ^NXVmId_t;
   NXVmId_t = longint;
{ values for NXInterruptId_t...  }


// nks/dirio.h
// nks/fsio.h
// unilib.h

  const
     UNI_ERR_MEM_ALLOC = -(494);
  { nonexistant rule table handle      }
     UNI_ERR_BAD_HANDLE = -(496);
  { table corruption detected          }
     UNI_ERR_TABLE_CORRUPT = -(498);
  { insufficient room in string        }
     UNI_ERR_TOO_FEW_BYTES = -(500);
  { unable to open data file           }
     UNI_ERR_FILE_OPEN = -(501);
  {                                    }
     UNI_ERR_FILE_EXIST = -(502);
  { unable to read data file           }
     UNI_ERR_FILE_READ = -(504);
  { functional stub only               }
     UNI_ERR_UNIMPLEMENTED = -(505);
  { premature end-of-string            }
     UNI_ERR_PREMATURE_END = -(506);
  { discovered during translation      }
     UNI_ERR_UNMAPPABLE_CHAR = -(532);
  { invalid UTF-8 character sequence   }
     UNI_ERR_INVALID_UTF8_SEQ = $FFFF;
  { the local, default rule table for argument 'table' below...  }
  { respective to local codepage       }
     UNI_LOCAL_DEFAULT = -(1);
  { 'noMapFlag' values; when no mapping found...  }
  { return UNI_ERR_UNMAPPABLE_CHAR     }
     UNI_MAP_NO_CHAR = 0;
  { use value in 'noMapChar' unless 0  }
     UNI_MAP_CHAR = 1;
  { use 'noMapFunc' if non-nil         }
     UNI_MAP_BY_FUNC = 1;
  { use character itself               }
     UNI_MAP_SELF = 2;
  { no-map character if 'noMapChar' 0  }
     UNI_NOMAP_DEFAULT = '?';
  { character classification (UniClass_t)...  }
  { no classification                      }
     UNI_UNDEF = $00000000;
  { control character                      }
     UNI_CNTRL = $00000001;
  { non-printing space                     }
     UNI_SPACE = $00000002;
  { printing (visible) character           }
     UNI_PRINT = $00000004;
  { dingbats, special symbols, et al.      }
     UNI_SPECIAL = $00000008;
  { general punctuation                    }
     UNI_PUNCT = $00000010;
  { decimal digit                          }
     UNI_DIGIT = $00000020;
  { hexadecimal digit                      }
     UNI_XDIGIT = $00000040;
  { reserved for future use                }
     UNI_RESERVED1 = $00000080;
  { lower-case if applicable               }
     UNI_LOWER = $00000100;
  { upper-case if applicable               }
     UNI_UPPER = $00000200;
  { reserved for future use                }
     UNI_RESERVED2 = $00000400;
  { non-number, non-punctuation including: }
     UNI_ALPHA = $00000800;
  { Latin-based                            }
     UNI_LATIN = $00001000;
  { Greek                                  }
     UNI_GREEK = $00002000;
  { Cyrillic                               }
     UNI_CYRILLIC = $00004000;
  { Hebrew                                 }
     UNI_HEBREW = $00008000;
  { Arabic                                 }
     UNI_ARABIC = $00010000;
  { Chinese/Japanese/Korean characters     }
     UNI_CJK = $00020000;
  { Devanagari, Bengali, Tamil, et al.     }
     UNI_INDIAN = $00040000;
  { southeast Asia: Thai, Lao              }
     UNI_SEASIA = $00080000;
  { cent. Asia: Armenian Tibetain, Georg.  }
     UNI_CENASIA = $00100000;
  { none of the above                      }
     UNI_OTHER = $80000000;


type
   Punicode_t = ^unicode_t;
   unicode_t = wchar_t;
   PPunicode_t = ^Punicode_t;

   PUniRuleTable_t = ^UniRuleTable_t;
   UniRuleTable_t = longint;
{ more a cookie than anything else      }

   PUniClass_t = ^UniClass_t;
   UniClass_t = dword;
{ Unicode character classification       }
{ for uni2mono(), unicase(), et al.      }
{ default monocasing as implemented      }
{ character is not 'alphabetic'          }
{ character has no case                  }
{ emphatically upper case                }
{ emphatically lower case                }

   PUniCase_t = ^UniCase_t;
   UniCase_t =  Longint;
   Const
     UNI_CASE_DEFAULT = $FFFFFFFD;
     UNI_CASE_NONE = $FFFFFFFE;
     UNI_CASE_AMBIGUOUS = $FFFFFFFF;
     UNI_CASE_UPPER = $00000000;
     UNI_CASE_LOWER = $00000001;
     UNI_CASE_TITLE = $00000002;

{ unmappable character handling function types...  }

type

   Loc2UniNoMapFunc_t = function (dest:PPunicode_t; remaining:size_t; src:PPchar; userParm:pointer):longint;cdecl;


   Loc2Utf8NoMapFunc_t = function (dest:PPchar; remaining:size_t; src:PPchar; userParm:pointer):longint;cdecl;


   Utf82LocNoMapFunc_t = function (dest:PPchar; remaining:size_t; src:PPchar; userParm:pointer):longint;cdecl;


   Utf82UniNoMapFunc_t = function (dest:PPchar; remaining:size_t; src:PPunicode_t; userParm:pointer):longint;cdecl;


   Uni2LocNoMapFunc_t = function (dest:PPchar; remaining:size_t; src:PPunicode_t; userParm:pointer):longint;cdecl;


   Uni2Utf8NoMapFunc_t = function (dest:PPchar; remaining:size_t; src:PPunicode_t; userParm:pointer):longint;cdecl;
{ rule table management...  }

function UniGetTable(codePage:longint; table:PUniRuleTable_t):longint;cdecl;external libc_nlm name 'UniGetTable';

function UniGetMacintoshTable(name:Pchar; table:PUniRuleTable_t):longint;cdecl;external libc_nlm name 'UniGetMacintoshTable';
function UniSetDefault(table:UniRuleTable_t):longint;cdecl;external libc_nlm name 'UniSetDefault';
function UniDisposeTable(table:UniRuleTable_t):longint;cdecl;external libc_nlm name 'UniDisposeTable';
function UniGetHostCodePage:longint;cdecl;external libc_nlm name 'UniGetHostCodePage';
{ translation between local and other codepages, Unicode and UTF-8...  }

function loc2uni(table:UniRuleTable_t; dest:Punicode_t; src:Pchar; noMapCh:unicode_t; noMapFlag:longint):longint;cdecl;external libc_nlm name 'loc2uni';

function loc2unipath(table:UniRuleTable_t; dest:Punicode_t; src:Pchar; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'loc2unipath';

function locn2uni(table:UniRuleTable_t; dest:Punicode_t; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapCh:unicode_t; noMapFlag:longint):longint;cdecl;external libc_nlm name 'locn2uni';
function locnp2uni(table:UniRuleTable_t; target:PPunicode_t; destLen:Psize_t; source:PPchar; srcLen:size_t;
           noMapCh:unicode_t; noMapFlag:longint):longint;cdecl;external libc_nlm name 'locnp2uni';

function locnx2uni(table:UniRuleTable_t; dest:Punicode_t; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapFunc:Loc2UniNoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint):longint;cdecl;external libc_nlm name 'locnx2uni';

function locnx2unipath(table:UniRuleTable_t; dest:Punicode_t; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapFunc:Loc2UniNoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'locnx2unipath';

function locn2unispecial(handle:UniRuleTable_t; dest:Punicode_t; destLen:Psize_t; src:Pchar; srcLen:size_t):longint;cdecl;external libc_nlm name 'locn2unispecial';

function loc2utf8(handle:UniRuleTable_t; dest:Pchar; src:Pchar; noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'loc2utf8';

function loc2utf8path(table:UniRuleTable_t; dest:Pchar; src:Pchar; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'loc2utf8path';

function locn2utf8(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'locn2utf8';

function locnx2utf8(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapFunc:Loc2Utf8NoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint):longint;cdecl;external libc_nlm name 'locnx2utf8';

function uni2loc(table:UniRuleTable_t; dest:Pchar; src:Punicode_t; noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'uni2loc';

function uni2locpath(table:UniRuleTable_t; dest:Pchar; src:Punicode_t; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'uni2locpath';

function unin2loc(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Punicode_t; srcLen:size_t;
           noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'unin2loc';
function uninp2loc(table:UniRuleTable_t; target:PPchar; destLen:Psize_t; source:PPunicode_t; srcLen:size_t;
           noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'uninp2loc';

function uninx2loc(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Punicode_t; srcLen:size_t;
           noMapFunc:Uni2LocNoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint):longint;cdecl;external libc_nlm name 'uninx2loc';

function uninx2locpath(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Punicode_t; srcLen:size_t;
           noMapFunc:Uni2LocNoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'uninx2locpath';

function unin2locspecial(handle:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Punicode_t; srcLen:size_t):longint;cdecl;external libc_nlm name 'unin2locspecial';

function uni2utf8(dest:Pchar; src:Punicode_t):longint;cdecl;external libc_nlm name 'uni2utf8';

function uni2utf8path(dest:Pchar; src:Punicode_t; dryRunSize:Psize_t):longint;cdecl;external libc_nlm name 'uni2utf8path';

function unin2utf8(dest:Pchar; destLen:Psize_t; src:Punicode_t; srcLen:size_t):longint;cdecl;external libc_nlm name 'unin2utf8';

function utf82loc(handle:UniRuleTable_t; dest:Pchar; src:Pchar; noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'utf82loc';

function utf8n2loc(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapCh:char; noMapFlag:longint):longint;cdecl;external libc_nlm name 'utf8n2loc';

function utf8nx2loc(table:UniRuleTable_t; dest:Pchar; destLen:Psize_t; src:Pchar; srcLen:size_t;
           noMapFunc:Utf82LocNoMapFunc_t; noMapFuncParm:pointer; noMapFlag:longint):longint;cdecl;external libc_nlm name 'utf8nx2loc';

function utf82uni(dest:Punicode_t; src:Pchar):longint;cdecl;external libc_nlm name 'utf82uni';

function utf8n2uni(dest:Punicode_t; destLen:Psize_t; src:Pchar; srcLen:size_t):longint;cdecl;external libc_nlm name 'utf8n2uni';
{ quick, 7-bit ASCII-capable translations--not preferred set...  }

function asc2uni(dest:Punicode_t; src:Pchar):Punicode_t;cdecl;external libc_nlm name 'asc2uni';

function ascn2uni(dest:Punicode_t; src:Pchar; nbytes:size_t):Punicode_t;cdecl;external libc_nlm name 'ascn2uni';

function uni2asc(dest:Pchar; src:Punicode_t):Pchar;cdecl;external libc_nlm name 'uni2asc';

function unin2asc(dest:Pchar; src:Punicode_t; nchars:size_t):Pchar;cdecl;external libc_nlm name 'unin2asc';
{ default 'noMapFunc' for X-translation to ensure round-trip conversion...  }

function LocToUniTagFunc(dest:PPunicode_t; remaining:size_t; src:PPchar; userParm:pointer):longint;cdecl;external libc_nlm name 'LocToUniTagFunc';

function UniToLocTagFunc(dest:PPchar; remaining:size_t; src:PPunicode_t; userParm:pointer):longint;cdecl;external libc_nlm name 'UniToLocTagFunc';
{ string size calculation...  }

function LocToUniSize(table:UniRuleTable_t; str:Pchar; unmappedCharSize:size_t; noMapFlag:longint; uniBufSize:Psize_t):longint;cdecl;external libc_nlm name 'LocToUniSize';

function LocToUtf8Size(table:UniRuleTable_t; str:Pchar; unmappedCharSize:size_t; noMapFlag:longint; utf8BufSize:Psize_t):longint;cdecl;external libc_nlm name 'LocToUtf8Size';

function UniToLocSize(table:UniRuleTable_t; str:Punicode_t; unmappedCharSize:size_t; noMapFlag:longint; locBufSize:Psize_t):longint;cdecl;external libc_nlm name 'UniToLocSize';

function UniToUtf8Size(str:Punicode_t; utf8BufSize:Psize_t):longint;cdecl;external libc_nlm name 'UniToUtf8Size';

function Utf8ToLocSize(table:UniRuleTable_t; str:Pchar; unmappedCharSize:size_t; noMapFlag:longint; locBufSize:Psize_t):longint;cdecl;external libc_nlm name 'Utf8ToLocSize';

function Utf8ToUniSize(str:Pchar; uniBufSize:Psize_t):longint;cdecl;external libc_nlm name 'Utf8ToUniSize';
{-----------------------------------------------------------------------------
** Little utility functions. These are not to be preferred over the interfaces
** from wchar.h.
 }
{ utility to measure width of a character in a codepage...  }

function dbcs_width(codepage:longint; str:Pchar):longint;cdecl;external libc_nlm name 'dbcs_width';
{ classification...  }
function unitype(ch:unicode_t):UniClass_t;cdecl;external libc_nlm name 'unitype';
{ collation...  }


function unicoll(s1:Punicode_t; s2:Punicode_t):longint;cdecl;external libc_nlm name 'unicoll';


function unincoll(s1:Punicode_t; s2:Punicode_t; n:size_t):longint;cdecl;external libc_nlm name 'unincoll';
{ casing...  }
function unicase(ch:unicode_t):UniCase_t;cdecl;external libc_nlm name 'unicase';

function uni2mono(dest:Punicode_t; src:Punicode_t; casing:UniCase_t):Punicode_t;cdecl;external libc_nlm name 'uni2mono';

function unin2mono(dest:Punicode_t; src:Punicode_t; casing:UniCase_t; destLen:size_t):Punicode_t;cdecl;external libc_nlm name 'unin2mono';
function chr2upr(ch:unicode_t):unicode_t;cdecl;external libc_nlm name 'chr2upr';
function chr2lwr(ch:unicode_t):unicode_t;cdecl;external libc_nlm name 'chr2lwr';
function chr2title(ch:unicode_t):unicode_t;cdecl;external libc_nlm name 'chr2title';
function unilwr(_string:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unilwr';
function uniupr(_string:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'uniupr';

function uni2lwr(dest:Punicode_t; src:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'uni2lwr';

function unin2lwr(dest:Punicode_t; src:Punicode_t; destLen:size_t):Punicode_t;cdecl;external libc_nlm name 'unin2lwr';

function uni2upr(dest:Punicode_t; src:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'uni2upr';

function unin2upr(dest:Punicode_t; src:Punicode_t; destLen:size_t):Punicode_t;cdecl;external libc_nlm name 'unin2upr';

function uni2title(dest:Punicode_t; src:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'uni2title';

function unin2title(dest:Punicode_t; src:Punicode_t; destLen:size_t):Punicode_t;cdecl;external libc_nlm name 'unin2title';
{ length...  }

function unilen(_string:Punicode_t):size_t;cdecl;external libc_nlm name 'unilen';

function uninlen(_string:Punicode_t; max:size_t):size_t;cdecl;external libc_nlm name 'uninlen';

function unisize(_string:Punicode_t):size_t;cdecl;external libc_nlm name 'unisize';
{ copying...  }

function unicpy(tgt:Punicode_t; src:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unicpy';

function unincpy(tgt:Punicode_t; src:Punicode_t; n:size_t):Punicode_t;cdecl;external libc_nlm name 'unincpy';
function uniset(base:Punicode_t; ch:unicode_t):Punicode_t;cdecl;external libc_nlm name 'uniset';
function uninset(base:Punicode_t; ch:unicode_t; n:size_t):Punicode_t;cdecl;external libc_nlm name 'uninset';
{ concatenation...  }

function unicat(tgt:Punicode_t; src:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unicat';

function unincat(tgt:Punicode_t; src:Punicode_t; n:size_t):Punicode_t;cdecl;external libc_nlm name 'unincat';

{$ifndef DisableArrayOfConst}
function unilist(tgt:Punicode_t; s1:Punicode_t; args:array of const):Punicode_t;cdecl;external libc_nlm name 'unilist';
{$endif}
function unilist(tgt:Punicode_t; s1:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unilist';
{ comparison...  }


function unicmp(s1:Punicode_t; s2:Punicode_t):longint;cdecl;external libc_nlm name 'unicmp';


function uniicmp(s1:Punicode_t; s2:Punicode_t):longint;cdecl;external libc_nlm name 'uniicmp';


function unincmp(s1:Punicode_t; s2:Punicode_t; n:size_t):longint;cdecl;external libc_nlm name 'unincmp';


function uninicmp(s1:Punicode_t; s2:Punicode_t; n:size_t):longint;cdecl;external libc_nlm name 'uninicmp';
{ character matching, indexing and miscellaneous...  }

function unichr(_string:Punicode_t; ch:unicode_t):Punicode_t;cdecl;external libc_nlm name 'unichr';
function unirchr(_string:Punicode_t; ch:unicode_t):Punicode_t;cdecl;external libc_nlm name 'unirchr';
function uniindex(_string:Punicode_t; search:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'uniindex';
function unistr(as1:Punicode_t; as2:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unistr';
function unirev(base:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unirev';
function unispn(_string:Punicode_t; charset:Punicode_t):size_t;cdecl;external libc_nlm name 'unispn';
function unicspn(_string:Punicode_t; charset:Punicode_t):size_t;cdecl;external libc_nlm name 'unicspn';
function unipbrk(s1:Punicode_t; s2:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unipbrk';
function unitok(_string:Punicode_t; sepset:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unitok';
function unitok_r(_string:Punicode_t; sepset:Punicode_t; lasts:PPunicode_t):Punicode_t;cdecl;external libc_nlm name 'unitok_r';
function unidup(s1:Punicode_t):Punicode_t;cdecl;external libc_nlm name 'unidup';
// nks/time.h

{ values for 'epoch' for NXGetTime()...  }
{ values for 'units' for NXGetTime()...  }
{ turn on 1-byte packing...  }

type

   PNXTime_t = ^NXTime_t;
   NXTime_t = Tuint64;

   PNXTimerVal_t = ^NXTimerVal_t;
   NXTimerVal_t = record
        tvPeriod : dword;
        tvCurrent : dword;
     end;

   PNXTimeOut_t = ^NXTimeOut_t;
   NXTimeOut_t = record
        reserved1 : array[0..3] of dword;
        toRoutine : procedure (_para1:pointer);cdecl;
        toArg : pointer;
        toTimerVal : NXTimerVal_t;
        reserved2 : array[0..15] of dword;
     end;

(** unsupported pragma#pragma pack()*)
{ Time and time-out...  }

function NXTimeOutCancel(tout:PNXTimeOut_t; wait:NXBool_t; status:PNXBool_t):longint;cdecl;external libc_nlm name 'NXTimeOutCancel';
function NXTimeOutSchedule(tout:PNXTimeOut_t):longint;cdecl;external libc_nlm name 'NXTimeOutSchedule';
function NXGetTime(epoch:longint; units:longint; time:PNXTime_t):longint;cdecl;external libc_nlm name 'NXGetTime';


// nks/thread.h
// nks/plat.h
type

   PNXCpuId_t = ^NXCpuId_t;
   NXCpuId_t = longint;
{ Platform-specific services...  }

function NXGetCacheLineSize:size_t;cdecl;external libc_nlm name 'NXGetCacheLineSize';
function NXGetCpuCount:dword;cdecl;external libc_nlm name 'NXGetCpuCount';
function NXGetCpuId:NXCpuId_t;cdecl;external libc_nlm name 'NXGetCpuId';
function NXGetPageSize:size_t;cdecl;external libc_nlm name 'NXGetPageSize';
function NXSeedRandom(width:size_t; seed:pointer):longint;cdecl;external libc_nlm name 'NXSeedRandom';
function NXGetSystemTick:dword;cdecl;external libc_nlm name 'NXGetSystemTick';
{ values for thread priority...  }
{ values for thread context flags...  }
{ values for thread flags...  }
{ value returned that specifies that the thread is unbound  }
{ value passed to NXThreadBind to bind it to the current CPU  }
{ return from NXThreadGetId indicating no-context or other error  }

{ turn on 1-byte packing...  }

type

   PNXContext_t = ^NXContext_t;
   NXContext_t = void;

   PNXWorkId_t = ^NXWorkId_t;
   NXWorkId_t = longint;

   PNXKey_t = ^NXKey_t;
   NXKey_t = longint;

   PNXThreadId_t = ^NXThreadId_t;
   NXThreadId_t = longint;

   PNXInterruptId_t = ^NXInterruptId_t;
   NXInterruptId_t = longint;

   PNXInterruptSet_t = ^NXInterruptSet_t;
   NXInterruptSet_t = Tuint64;

   PNXContextState_t = ^NXContextState_t;
   NXContextState_t =  Longint;
   Const
     NX_CTXSTATE_INIT = $FFFFFFFF;
     NX_CTXSTATE_BOUND = $00000001;
     NX_CTXSTATE_UNBOUND = $00000000;

type

   PNXContextInfo_t = ^NXContextInfo_t;
   NXContextInfo_t = record
        ciState : NXContextState_t;
        ciFunc : procedure (_para1:pointer);cdecl;
        ciArg : pointer;
        ciPriority : longint;
        ciStackSize : size_t;
        ciFlags : dword;
     end;

   PlwWork = ^lwWork;
   lwWork = record
        reserved : array[0..6] of pointer;
        lwWorkFunc : procedure (_para1:PlwWork; _para2:pointer);cdecl;
        lwAppRef : pointer;
     end;
   NXLwWork_t = lwWork;
   PNXLwWork_t = ^NXLwWork_t;

(** unsupported pragma#pragma pack()*)
{ Context management...  }

type TCDeclProc1PtrArg = procedure (_para1:pointer); cdecl;

function NXContextAlloc(start_routine:TCDeclProc1PtrArg; arg:pointer; priority:longint; stackSize:size_t; flags:dword;
           error:Plongint):NXContext_t;cdecl;external libc_nlm name 'NXContextAlloc';
function NXContextFree(ctx:NXContext_t):longint;cdecl;external libc_nlm name 'NXContextFree';
function NXContextGet:NXContext_t;cdecl;external libc_nlm name 'NXContextGet';
function NXContextGetInfo(ctx:NXContext_t; info:PNXContextInfo_t):longint;cdecl;external libc_nlm name 'NXContextGetInfo';
function NXContextGetName(ctx:NXContext_t; name:Pchar; len:size_t):longint;cdecl;external libc_nlm name 'NXContextGetName';
function NXContextReinit(ctx:NXContext_t; start_routine:TCDeclProc1PtrArg; arg:pointer; priority:longint; flags:dword):longint;cdecl;external libc_nlm name 'NXContextReinit';

function NXContextSetName(ctx:NXContext_t; name:Pchar):longint;cdecl;external libc_nlm name 'NXContextSetName';
{ Key-value pairs (per-context data)...  }
type TCdeclProc = procedure; cdecl;
function NXKeyCreate(_destructor: TCDeclProc; value:pointer; key:PNXKey_t):longint;cdecl;external libc_nlm name 'NXKeyCreate';
function NXKeyDelete(key:NXKey_t):longint;cdecl;external libc_nlm name 'NXKeyDelete';
function NXKeyGetValue(key:NXKey_t; value:Ppointer):longint;cdecl;external libc_nlm name 'NXKeyGetValue';
function NXKeySetValue(key:NXKey_t; value:pointer):longint;cdecl;external libc_nlm name 'NXKeySetValue';
{ Thread management...  }
function NXThreadBind(cpu_id:NXCpuId_t):longint;cdecl;external libc_nlm name 'NXThreadBind';
function NXThreadContinue(tid:NXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadContinue';
function NXThreadCreate(ctx:NXContext_t; flags:dword; idp:PNXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadCreate';
function NXThreadCreateSx(start_routine:TCDeclProc1PtrArg; arg:pointer; thread_flags:dword; ctx:PNXContext_t; thr:PNXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadCreateSx';
procedure NXThreadDelay(delay:dword);cdecl;external libc_nlm name 'NXThreadDelay';
function NXThreadDestroy(tid:NXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadDestroy';
function NXThreadDetach(tid:NXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadDetach';
procedure NXThreadExit(status:pointer);cdecl;external libc_nlm name 'NXThreadExit';
function NXThreadGetBinding:NXCpuId_t;cdecl;external libc_nlm name 'NXThreadGetBinding';
function NXThreadGetContext(tid:NXThreadId_t; ctx:PNXContext_t):longint;cdecl;external libc_nlm name 'NXThreadGetContext';
function NXThreadGetId:NXThreadId_t;cdecl;external libc_nlm name 'NXThreadGetId';
function NXThreadGetPriority(tid:NXThreadId_t; priority:Plongint):longint;cdecl;external libc_nlm name 'NXThreadGetPriority';
function NXThreadInterrupt(tid:NXThreadId_t; interId:NXInterruptId_t):longint;cdecl;external libc_nlm name 'NXThreadInterrupt';
function NXThreadIsInterrupted(_set:PNXInterruptSet_t):NXBool_t;cdecl;external libc_nlm name 'NXThreadIsInterrupted';
function NXThreadJoin(wait_for:NXThreadId_t; departed_thread:PNXThreadId_t; status:Ppointer):longint;cdecl;external libc_nlm name 'NXThreadJoin';
function NXThreadSetPriority(tid:NXThreadId_t; priority:longint):longint;cdecl;external libc_nlm name 'NXThreadSetPriority';
function NXThreadSuspend(tid:NXThreadId_t):longint;cdecl;external libc_nlm name 'NXThreadSuspend';
function NXThreadSwapContext(newctx:NXContext_t; prevctx:PNXContext_t):longint;cdecl;external libc_nlm name 'NXThreadSwapContext';
function NXThreadUnbind:longint;cdecl;external libc_nlm name 'NXThreadUnbind';
procedure NXThreadYield;cdecl;external libc_nlm name 'NXThreadYield';
function nxThreadCreate(start_routine:TCDeclProc1PtrArg; flags:dword; arg:pointer; ctxp:PNXContext_t; idp:PNXThreadId_t):longint;cdecl;external libc_nlm name 'nxThreadCreate';
{ Work-to-dos...  }
function NXDelayedWorkSchedule(ctx:NXContext_t; timerval:PNXTimerVal_t; bind:NXBool_t; wid:PNXWorkId_t):longint;cdecl;external libc_nlm name 'NXDelayedWorkSchedule';
function NXLwWorkCancel(work:PNXLwWork_t):longint;cdecl;external libc_nlm name 'NXLwWorkCancel';
function NXLwWorkSchedule(reserved:pointer; work:PNXLwWork_t; bind:NXBool_t):longint;cdecl;external libc_nlm name 'NXLwWorkSchedule';
function NXWorkCancel(wid:NXWorkId_t; wait:NXBool_t; status:PNXBool_t):longint;cdecl;external libc_nlm name 'NXWorkCancel';
function NXWorkSchedule(context:NXContext_t; bind:NXBool_t; wid:PNXWorkId_t):longint;cdecl;external libc_nlm name 'NXWorkSchedule';
{ Miscellaneous...  }
function NXProcessInterruptSet(_set:PNXInterruptSet_t; id:NXInterruptId_t; processed_id:PNXInterruptId_t):NXBool_t;cdecl;external libc_nlm name 'NXProcessInterruptSet';
{ values and masks for file modes...  }
{ values and masks for file operations...  }
{ for NXDeviceOpen() and NXConsoleOpen()...  }
{ aliases for above...  }
{ open flags...  }
{ sharing flags...  }
{ delegation type...  }
{ flush flags...  }
{ values and masks for access flags...  }
{ values for setting file length...  }
{ values for file byte-range locking flags...  }


{ turn on 1-byte packing...  }

  const
     NX_MAX_NAME_LEN = 255;
  { (big! --this isn't used yet)  }
{$define NX_MAX_FILESIZE}
  { values and masks for file modes...  }
     NX_O_RDONLY = $00000000;
     NX_O_WRONLY = $00000001;
     NX_O_RDWR = $00000002;
     NX_O_ACCMODE = $00000003;
  { values and masks for file operations...  }
     NX_O_APPEND = $00000010;
     NX_O_CREAT = $00000020;
     NX_O_TRUNC = $00000040;
     NX_O_EXCL = $00000080;
     NX_O_TRANS = $00000100;
     NX_O_NONBLOCK = $00000400;
     NX_O_OPMODE = $000005E0;
  { for NXDeviceOpen() and NXConsoleOpen()...  }
     NX_O_SCROLLABLE = $00000800;
  { aliases for above...  }
     NX_O_CREATE = NX_O_CREAT;
     NX_O_TRUNCATE = NX_O_TRUNC;
     NX_O_EXCLUSIVE = NX_O_EXCL;
  { open flags...  }
     NX_OFLAG_DIRECTIO = $00010000;
     NX_OFLAG_CRONLY = $00020000;
     NX_OFLAG_BACKUP = $00040000;
     NX_OFLAG_RESTORE = $00080000;
     NX_OFLAG_EXTEND = $00100000;
     NX_OFLAG_SYNCWR = $00200000;
     NX_OFLAG_ATOMIC_RW = $00400000;
     NX_OFLAG_NOTRAVERSE_LINK = $00800000;
     NX_OFLAG_MASK = $00FF0000;
  { sharing flags...  }
     NX_SHARE_DENYNO = $00000000;
     NX_SHARE_DENYRD = $00100000;
     NX_SHARE_DENYWR = $00200000;
     NX_SHARE_DENYALL = $00400000;
     NX_SHARE_MASK = $00700000;
  { delegation type...  }
     NX_DELEG_NONE = $00000000;
  { flush flags...  }
     NX_FLUSH_DATA = $00000001;
     NX_FLUSH_METADATA = $00000002;
     NX_FLUSH_ASYNC = $00000004;
  { values and masks for access flags...  }
     NX_R_OK = $00000001;
     NX_W_OK = $00000002;
     NX_X_OK = $00000004;
     NX_F_OK = $00000008;
  { values for setting file length...  }
     NX_FOP_RETURN_EXTEND = $00000001;
     NX_FOP_RETURN_TRUNC_FREE = $00000002;
     NX_FOP_RETURN_SPARSE = $00000004;
  { values for file byte-range locking flags...  }
     NX_RANGE_LOCK_SHARED = $00000001;
     NX_RANGE_LOCK_EXCL = $00000002;
     NX_RANGE_LOCK_CHECK = $00000004;
     NX_RANGE_LOCK_TRYLOCK = $00000008;
     NX_RANGE_LOCK_COURTESY = $00000010;
     NX_RANGE_LOCK_CANCEL = $00000020;
     NX_RANGE_LOCK_POSIX = $00000040;



type
   //Pfsio = ^fsio;
   //fsio = record
       {undefined structure}
    // end;


   PNXMode_t = ^NXMode_t;
   NXMode_t = dword;

   PNXOFlags_t = ^NXOFlags_t;
   NXOFlags_t = dword;

   PNXShareMode_t = ^NXShareMode_t;
   NXShareMode_t = dword;

   PNXOffset_t = ^NXOffset_t;
   NXOffset_t = Tuint64;
{ (file offsets and lengths)  }

   PNXSOffset_t = ^NXSOffset_t;
   NXSOffset_t = Tint64;

   PNXLockToken_t = ^NXLockToken_t;
   NXLockToken_t = Tuint64;

   PNXHandle_t = ^NXHandle_t;
   NXHandle_t = longint;

   PNXPathCtx_t = ^NXPathCtx_t;
   NXPathCtx_t = longint;

   PNXDelegType_t = ^NXDelegType_t;
   NXDelegType_t = longint;

   PNXAsyncId_t = ^NXAsyncId_t;
   NXAsyncId_t = void;
{ I/O objects supported...  }

   PNXObjType_t = ^NXObjType_t;
   NXObjType_t =  Longint;
   Const
     NX_OBJ_UNKNOWN = $FFFFFFFF;
     NX_OBJ_DEFAULT = $FFFFFFFE;
     NX_OBJ_FILE = $FFFFFFFD;
     NX_OBJ_DIR = $FFFFFFFC;
     NX_OBJ_FIFO = $FFFFFFFB;
     NX_OBJ_DEVICE = $FFFFFFFA;
     NX_OBJ_CONSOLE = $FFFFFFF9;
     NX_OBJ_SYMLINK = $FFFFFFF8;

type

   PNXGuid_t = ^NXGuid_t;
   NXGuid_t = record
       case longint of
          0 : ( guid_field : array[0..1] of Tuint64 );
       end;

   PNXFid_t = ^NXFid_t;
   NXFid_t = record
        fidFsId : NXGuid_t;
        fidFileId : array[0..1] of Tuint64;
     end;

   PNXUpCallReason_t = ^NXUpCallReason_t;
   NXUpCallReason_t =  Longint;
   Const
     NX_UPCALL_UNKNOWN = $FFFFFFFF;
     NX_UPCALL_DELEGRECALL = $00000000;
     NX_UPCALL_BACKUPIMMINENT = $00000001;

 Const
     NX_LOCK_RANGE_UNKNOWN = 2147483647;
     NX_LOCK_RANGE_FORWARD = 1;
     NX_LOCK_RANGE_BACKWARD = 2;

type

   NXFsUpCall_t = procedure (fileHandle:NXHandle_t; reason:NXUpCallReason_t; parm:pointer);cdecl;
{ generic filesystem name if used            }
{ Macintosh data stream (data or resource)   }

   PNXDataStream_t = ^NXDataStream_t;
   NXDataStream_t = record
       case longint of
          0 : ( name : pointer );
          1 : ( macintoshId : dword );
       end;
{ based on which 'fosPathname' is understood }

{ relative to 'fosPathCtx'                   }
{ NX_O_RDONLY, NX_O_RDWR, etc.               }
{ NX_OFLAG_SYNCWR, NX_OFLAG_DIRECTIO, etc.   }
{ NX_SHARE_DENYRD, NX_DENY_ALL, etc.         }
{ contiguous file block allocation hint      }
{ contiguous file block allocation hint      }
{ delegation type: NX_DELEG_NONE             }
{ data stream (if not part of fosPathname)   }
{ called to warn of delegation revocation    }
{ description of successful conclusion       }
{ actual grant of delegation                 }
{ returns FID of opened file                 }
{ time of last access                        }
{ time of last modification                  }
{ time of file creation                     }
{ time of last back-up                       }
{ length of file at open                     }
{ create/open operation results              }

   PNXFileOpenSpec_t = ^NXFileOpenSpec_t;
   NXFileOpenSpec_t = record
        fosPathCtx : NXPathCtx_t;
        fosPathname : pointer;
        fosMode : NXMode_t;
        fosOFlags : NXOFlags_t;
        fosShareMode : NXShareMode_t;
        fosExtentSize : size_t;
        reserved1 : dword;
        fosDelegType : NXDelegType_t;
        fosDataStream : NXDataStream_t;
        fosUpCallFunc : NXFsUpCall_t;
        fosResult : record
             actionTaken : NXMode_t;
             delegType : NXDelegType_t;
             fid : NXFid_t;
             accessTime : NXTime_t;
             modifyTime : NXTime_t;
             creationTime : NXTime_t;
             archiveTime : NXTime_t;
             length : NXOffset_t;
          end;
        reserved2 : dword;
        reserved3 : dword;
     end;
   Pfsio = ^fsio;
   NXIoComp_t = function (ioInfo:Pfsio):longint;cdecl;
{ length of I/O buffer                       }
{ pointer to data for I/O operation          }
{ application-maintained reference           }

   PNXIoVec_t = ^NXIoVec_t;
   NXIoVec_t = record
        ivLength : size_t;
        reserved : dword;
        ivBuffer : pointer;
        ivOpRef : pointer;
     end;
{ I/O objects supported...  }
{ For Internal Use Only                }

   PNXLockRange_t = ^NXLockRange_t;
   NXLockRange_t =  Longint;


{ application-maintained reference           }
{ file, FIFO, console, device, etc. handle   }
{ I/O flags and hints                        }
{ hint as to remaining number of bytes      }
{ from NXFileRangeLockEx()                   }
{ completion function if asynchronous        }
{ only for non-file system operations        }
{ offset at which to begin I/O               }
{ number of records in vector                }
{ IN/OUT: I/O operation record vector        }
{ OUT: asynchronous transaction ID           }
{ OUT: for asynchronous use                  }
{ OUT: total bytes written or read           }

   fsio = record
        ioAppRef : pointer;
        ioHandle : NXHandle_t;
        ioFlags : dword;
        reserved : dword;
        ioRemainingHint : NXOffset_t;
        ioLockToken : NXLockToken_t;
        ioCompletion : NXIoComp_t;
        ioTimeOut : dword;
        ioOffset : NXOffset_t;
        ioVecCount : longint;
        ioVector : PNXIoVec_t;
        ioAsyncID : NXAsyncId_t;
        ioStatus : longint;
        ioProcessed : NXOffset_t;
     end;
   NXIo_t = fsio;
   PNXIo_t = ^NXIo_t;
{ in file (0-based)                         }
{ magnitude of range                        }
{ NX_LOCK_RANGE_FORWARD, ...                }
{ usually 0; reserved to server apps        }
{ in use only with NX_RANGE_LOCK_NETWARE    }

   PNXFileLockDesc_t = ^NXFileLockDesc_t;
   NXFileLockDesc_t = record
        ldOffset : NXOffset_t;
        ldLength : NXOffset_t;
        ldDirection : NXLockRange_t;
        ldToken : NXLockToken_t;
        ldHandle : NXHandle_t;
        reserved : dword;
     end;

   NXLockUpCall_t = procedure (fileHandle:NXHandle_t; appRef:pointer; lockDesc:PNXFileLockDesc_t);cdecl;
{ application-maintained reference          }
{ handle on which file was opened           }
{ mandatory (TRUE) or merely advisory?     }
{ NX_RANGE_LOCK_EXCL, etc.                  }
{ maximum time to wait for lock             }
{ call-back by file system to release lock  }
{ info. on existing conflicting lock  }
{ info. for VM holding conflicting lock }
{ count of locks described in array         }
{ array of lock descriptions                }

   PNXFileRangeLockSpec_t = ^NXFileRangeLockSpec_t;
   NXFileRangeLockSpec_t = record
        rlsAppRef : pointer;
        rlsHandle : NXHandle_t;
        rlsMandatory : NXBool_t;
        rlsFlags : dword;
        rlsTimeOut : dword;
        rlsUpCall : NXLockUpCall_t;
        rlsConflictLockVm : NXVmId_t;
        rlsConflictLock : NXFileLockDesc_t;
        rlsVecCount : longint;
        rlsDescVec : PNXFileLockDesc_t;
     end;

(** unsupported pragma#pragma pack()*)
{ File I/O...  }

function NXClose(handle:NXHandle_t):longint;cdecl;external libc_nlm name 'NXClose';
function NXFileAllocExtentWithHandle(fileHandle:NXHandle_t; offset:NXOffset_t; length:NXOffset_t; flags:dword):longint;cdecl;external libc_nlm name 'NXFileAllocExtentWithHandle';
function NXFileCancelIo(async_id:NXAsyncId_t; wait:NXBool_t; status:PNXBool_t):longint;cdecl;external libc_nlm name 'NXFileCancelIo';
function NXFileFlushBuffers(fileHandle:NXHandle_t; flags:dword; offset:NXOffset_t; length:NXOffset_t):longint;cdecl;external libc_nlm name 'NXFileFlushBuffers';

function NXFileGetLength(pathCtx:NXPathCtx_t; pathname:pointer; length:PNXOffset_t):longint;cdecl;external libc_nlm name 'NXFileGetLength';
function NXFileGetLengthWithHandle(fileHandle:NXHandle_t; length:PNXOffset_t):longint;cdecl;external libc_nlm name 'NXFileGetLengthWithHandle';

function NXFileOpen(pathCtx:NXPathCtx_t; pathname:pointer; mode:NXMode_t; fileHandle:PNXHandle_t):longint;cdecl;external libc_nlm name 'NXFileOpen';
function NXFileOpenEx(openSpec:PNXFileOpenSpec_t; fileHandle:PNXHandle_t):longint;cdecl;external libc_nlm name 'NXFileOpenEx';
function NXFileRangeLock(fileHandle:NXHandle_t; flags:dword; offset:NXOffset_t; length:NXSOffset_t):longint;cdecl;external libc_nlm name 'NXFileRangeLock';
function NXFileRangeLockEx(lockSpec:NXFileRangeLockSpec_t):longint;cdecl;external libc_nlm name 'NXFileRangeLockEx';
function NXFileRangeUnlock(fileHandle:NXHandle_t; flags:dword; offset:NXOffset_t; length:NXSOffset_t):longint;cdecl;external libc_nlm name 'NXFileRangeUnlock';
function NXFileRangeUnlockEx(lockSpec:NXFileRangeLockSpec_t):longint;cdecl;external libc_nlm name 'NXFileRangeUnlockEx';
function NXFileRemoveWithHandle(handle:NXHandle_t):longint;cdecl;external libc_nlm name 'NXFileRemoveWithHandle';

function NXFileRenameWithHandle(fileHandle:NXHandle_t; targetPathCtx:NXPathCtx_t; newname:pointer; overwrite:NXBool_t):longint;cdecl;external libc_nlm name 'NXFileRenameWithHandle';
function NXFileSetLength(pathCtx:NXPathCtx_t; pathname:pointer; length:NXOffset_t; flags:dword):longint;cdecl;external libc_nlm name 'NXFileSetLength';
function NXFileSetLengthWithHandle(fileHandle:NXHandle_t; length:NXOffset_t; flags:dword):longint;cdecl;external libc_nlm name 'NXFileSetLengthWithHandle';
function NXRead(handle:NXHandle_t; offset:NXOffset_t; length:size_t; address:pointer; flags:dword;
           bytesRead:Psize_t):longint;cdecl;external libc_nlm name 'NXRead';
function NXReadEx(ioInfo:PNXIo_t; ioAsyncId:PNXAsyncId_t):longint;cdecl;external libc_nlm name 'NXReadEx';

function NXRemove(pathCtx:NXPathCtx_t; pathname:pointer):longint;cdecl;external libc_nlm name 'NXRemove';


function NXRename(sourcePathCtx:NXPathCtx_t; oldname:pointer; targetPathCtx:NXPathCtx_t; newname:pointer; overwrite:NXBool_t):longint;cdecl;external libc_nlm name 'NXRename';

function NXWrite(handle:NXHandle_t; offset:NXOffset_t; length:size_t; address:pointer; flags:dword;
           bytesWritten:Psize_t):longint;cdecl;external libc_nlm name 'NXWrite';
function NXWriteEx(ioInfo:PNXIo_t; ioAsyncId:PNXAsyncId_t):longint;cdecl;external libc_nlm name 'NXWriteEx';
{ Additional I/O (including FIFOs, devices, etc.)...  }

function NXDeviceOpen(pathCtx:NXPathCtx_t; name:pointer; mode:NXMode_t; shareMode:NXShareMode_t; flags:dword;
           ioBlockSize:Psize_t; deviceHandle:PNXHandle_t):longint;cdecl;external libc_nlm name 'NXDeviceOpen';

function NXFifoOpen(pathCtx:NXPathCtx_t; pathname:pointer; mode:NXMode_t; fifoSize:size_t; fifoHandle:PNXHandle_t):longint;cdecl;external libc_nlm name 'NXFifoOpen';
function NXIoSetBlockingState(handle:NXHandle_t; blocking:NXBool_t):longint;cdecl;external libc_nlm name 'NXIoSetBlockingState';
function NXIoGetOpenMode(handle:NXHandle_t; mode:PNXMode_t):longint;cdecl;external libc_nlm name 'NXIoGetOpenMode';


function NXLinkCreate(srcPathCtx:NXPathCtx_t; source:pointer; tgtPathCtx:PNXPathCtx_t; target:pointer; _type:longint):longint;cdecl;external libc_nlm name 'NXLinkCreate';


function NXLinkCreateSymbolic(srcPathCtx:NXPathCtx_t; linkname:pointer; target:pointer):longint;cdecl;external libc_nlm name 'NXLinkCreateSymbolic';
{ macro for useful alias...  }
{ basic change bits for NXSetAttr()...  }
{ flag values for NXDirAttr_t and NXDeEnum_t, etc...  }
{ deEffectiveRights bits  }

{ turn on 1-byte packing...  }

  { basic change bits for NXSetAttr()...  }

  const
     NX_DIRENT_EFFECTIVERIGHTS = $0000000000000001;
     NX_DIRENT_FLAGS = $0000000000000002;
     NX_DIRENT_OWNERID = $0000000000000004;
     NX_DIRENT_CREATETIME = $0000000000000008;
     NX_DIRENT_CHANGETIME = $0000000000000010;
     NX_DIRENT_ACCESSTIME = $0000000000000020;
     NX_DIRENT_MODIFYTIME = $0000000000000040;
     NX_DIRENT_ATTRIBUTES = $0000000000000080;
     NX_DIRENT_RESERVED1 = $0000000000000100;
     NX_DIRENT_RESERVED2 = $0000000000000200;
     NX_DIRENT_RESERVED3 = $0000000000000400;
     NX_DIRENT_RESERVED4 = $0000000000000800;
  { flag values for NXDirAttr_t and NXDeEnum_t, etc...  }
     NX_DEFLAGS_COMPRESSED = $00000001;
     NX_DEFLAGS_ENCRYPTED = $00000002;
     NX_DEFLAGS_TEMPORARY = $00000004;
     NX_DEFLAGS_MIGRATED = $00000008;
     NX_DEFLAGS_DELETED = $00000010;
     NX_DEFLAGS_SPARSE = $00000020;
  { deEffectiveRights bits  }
     NX_READ_EXISTING_FILE = $00000001;
     NX_WRITE_EXISTING_FILE = $00000002;
     NX_CREATE_NEW_ENTRY = $00000008;
     NX_DELETE_EXISTING_ENTRY = $00000010;
     NX_CHANGE_ACCESS_CONTROL = $00000020;
     NX_SEE_FILES = $00000040;
     NX_MODIFY_ENTRY = $00000080;
     NX_SUPERVISOR_PRIVILEGES = $00000100;
     NX_ACCESS_RIGHTS_MASK = $000001FB;



type

   PNXChangeBits_t = ^NXChangeBits_t;
   NXChangeBits_t = Tuint64;
   TNXChangeBits = NXChangeBits_t;
   PNXChangeBits = PNXChangeBits_t;
{ pathname format (PNF) enumeration         }
{ use PNF in effect at open                 }
{ generic NKS pathname format               }
{ DOS                                       }
{ Macintosh/AFP 3.0                         }
{ UNIX/NFS                                  }
{ Windows NT, OS/2                          }
{ Novell Storage Services (NSS)             }

   PNXPathFormat_t = ^NXPathFormat_t;
   NXPathFormat_t =  Longint;
   Const
     NX_PNF_DEFAULT = 2147483647;
     NX_PNF_NKS = 0;
     NX_PNF_DOS = 1;
     NX_PNF_MAC = 2;
     NX_PNF_UNIX = 4;
     NX_PNF_WIN = 5;
     NX_PNF_NSS = 7;

{ basic attribute information              }
{ filename                                 }
{ extended file system information         }
type

   PNXDeLevel_t = ^NXDeLevel_t;
   NXDeLevel_t =  Longint;
   Const
     NX_DELEVEL_BASIC = $7FFFFFFF;
     NX_DELEVEL_NAME_ONLY = $80000000;
     NX_DELEVEL_EXTENDED = $80000001;

{ marking place in directory enumeration    }
{ all private to implementation             }
type

   PNXDirMark_t = ^NXDirMark_t;
   NXDirMark_t = record
        mark : array[0..43] of byte;
        pathCtx : pointer;
        entryInfo : pointer;
     end;
{ structure size is 52 bytes on NetWare     }
{ information common to all PNF structures  }
{ total length of entry including any       }
{ type of entry (file, FIFO, etc.)          }
{ file system yielding information          }
{ level specified in NXDirEnumStart()       }

   PNXDeHeader_t = ^NXDeHeader_t;
   NXDeHeader_t = record
        length     : size_t;
        objectType : NXObjType_t;
        pathFormat : NXPathFormat_t;
        infoLevel  : NXDeLevel_t;
     end;
   PNXDeHeader = PNXDeHeader_t;
   TNDDeHeader = NXDeHeader_t;
{ common information                        }
{                                           }
{ length of file                            }
{ compressed, sparse, encrypted, etc.       }
{ timestamp of last attribute change        }
{ timestamp of last write+attribute change  }
{ timestamp of last write                   }
{ preferred I/O blocksize                   }

   PNXDirAttr_t = ^NXDirAttr_t;
   NXDirAttr_t = record
        deHeader : NXDeHeader_t;
        deFid : NXFid_t;
        deEffectiveRights : dword;
        deFileSize : NXOffset_t;
        deFlags : Tuint64;
        deAttrChangeTime : NXTime_t;
        deAccessTime : NXTime_t;
        deModifyTime : NXTime_t;
        deIoBlockSize : size_t;
     end;
{ plus name                                 }

   PNXDirAttrWithName_t = ^NXDirAttrWithName_t;
   NXDirAttrWithName_t = record
        deHeader : NXDeHeader_t;
        deName : pointer;
     end;
{ information fields                        }
{ NXDirEnum- navigational mark              }

   PNXDirEnum_t = ^NXDirEnum_t;
   NXDirEnum_t = record
        deDirAttr : NXDirAttr_t;
        deDirMark : NXDirMark_t;
        deName : pointer;
     end;
{ generic NKS (NX_PNF_NKS) attributes       }

   PNXDirAttrNks_t = ^NXDirAttrNks_t;
   NXDirAttrNks_t = record
        xdeHeader : NXDeHeader_t;
        xdeFid : NXFid_t;
        xdeEffectiveRights : dword;
        xdeFileSize : NXOffset_t;
        xdeFlags : Tuint64;
        xdeChangeTime : NXTime_t;
        xdeAccessTime : NXTime_t;
        xdeModifyTime : NXTime_t;
        xdeCreateTime : NXTime_t;
        xdeOwnerId : NXGuid_t;
     end;
{ generic NKS (NX_PNF_NKS) information...   }
{ ...including name                         }

   PNXDirEnumNks_t = ^NXDirEnumNks_t;
   NXDirEnumNks_t = record
        deNksDirAttr : NXDirAttrNks_t;
        deDirMark : NXDirMark_t;
        deName : pointer;
     end;

(** unsupported pragma#pragma pack()*)
{ Path context...  }

function NXFreePathContext(pathCtx:NXPathCtx_t):longint;cdecl;external libc_nlm name 'NXFreePathContext';

function NXCreatePathContext(pathCtx:NXPathCtx_t; pathname:pchar; format:NXPathFormat_t; securityBadge:pointer; newPathCtx:PNXPathCtx_t):longint;cdecl;external libc_nlm name 'NXCreatePathContext';
function NXCreatePathContext(pathCtx:NXPathCtx_t; pathname:pchar; format:NXPathFormat_t; securityBadge:pointer; var newPathCtx:NXPathCtx_t):longint;cdecl;external libc_nlm name 'NXCreatePathContext';
function NXCreatePathContextWithFid(fid:NXFid_t; format:NXPathFormat_t; securityBadge:pointer; newPathCtx:PNXPathCtx_t):longint;cdecl;external libc_nlm name 'NXCreatePathContextWithFid';
{ Directory I/O...  }

function NXDirCreate(pathCtx:NXPathCtx_t; pathname:pointer; reserved:pointer; newPathCtx:PNXPathCtx_t):longint;cdecl;external libc_nlm name 'NXDirCreate';

function NXDirRemove(pathCtx:NXPathCtx_t; pathname:pointer):longint;cdecl;external libc_nlm name 'NXDirRemove';
{ Directory entry attributes...  }

function NXGetAttr(pathCtx:NXPathCtx_t; pathname:pointer; level:NXDeLevel_t; buffer:pointer; length:size_t;
           flags:dword):longint;cdecl;external libc_nlm name 'NXGetAttr';
function NXGetAttrWithHandle(handle:NXHandle_t; format:NXPathFormat_t; level:NXDeLevel_t; buffer:pointer; length:size_t;
           flags:dword):longint;cdecl;external libc_nlm name 'NXGetAttrWithHandle';


function NXSetAttr(pathCtx:NXPathCtx_t; pathname:pointer; level:NXDeLevel_t; buffer:pointer; changeBits:NXChangeBits_t):longint;cdecl;external libc_nlm name 'NXSetAttr';

function NXSetAttrWithHandle(handle:NXHandle_t; format:NXPathFormat_t; level:NXDeLevel_t; buffer:pointer; changeBits:NXChangeBits_t):longint;cdecl;external libc_nlm name 'NXSetAttrWithHandle';
{ Subdirectory enumeration...  }
function NXDirMarkInit(handle:NXHandle_t; dirMark:PNXDirMark_t):longint;cdecl;external libc_nlm name 'NXDirMarkInit';
function NXDirMarkInit(handle:NXHandle_t; var dirMark:NXDirMark_t):longint;cdecl;external libc_nlm name 'NXDirMarkInit';
function NXDirEnumEnd(handle:NXHandle_t):longint;cdecl;external libc_nlm name 'NXDirEnumEnd';
function NXDirEnumGetEntries(handle:NXHandle_t; start:PNXDirMark_t; buffer:pointer; length:size_t; entriesReturned:Psize_t;
           next:PNXDirMark_t; sequenceGuarantee:PNXBool_t):longint;cdecl;external libc_nlm name 'NXDirEnumGetEntries';

function NXDirEnumStart(pathCtx:NXPathCtx_t; pathname:pchar; level:NXDeLevel_t; handle:PNXHandle_t):longint;cdecl;external libc_nlm name 'NXDirEnumStart';
function NXDirEnumStart(pathCtx:NXPathCtx_t; pathname:pchar; level:NXDeLevel_t; var handle:NXHandle_t):longint;cdecl;external libc_nlm name 'NXDirEnumStart';


// nks/doswin.h
// wchar.h
{ turn on 1-byte packing...  }

type

   Pwint_t = ^wint_t;
   wint_t = longint;

   Pwuchar_t = ^wuchar_t;
   wuchar_t = word;

   Pmbstate_t = ^mbstate_t;
   mbstate_t = longint;

(** unsupported pragma#pragma pack()*)


function mbsrtowcs(__restrict:Pwchar_t; __restrict1:PPchar; _para3:size_t; __restrict2:Pmbstate_t):size_t;cdecl;external libc_nlm name 'mbsrtowcs';

{$ifndef DisableArrayOfConst}
function fwprintf(__restrict:P_iobuf; __restrict1:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'fwprintf';
{$endif}
function fwprintf(__restrict:P_iobuf; __restrict1:Pwchar_t):longint;cdecl;external libc_nlm name 'fwprintf';

{$ifndef DisableArrayOfConst}
function fwscanf(__restrict:P_iobuf; __restrict1:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'fwscanf';
{$endif}
function fwscanf(__restrict:P_iobuf; __restrict1:Pwchar_t):longint;cdecl;external libc_nlm name 'fwscanf';

{$ifndef DisableArrayOfConst}
function swprintf(__restrict:Pwchar_t; _para2:size_t; __restrict1:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'swprintf';
{$endif}
function swprintf(__restrict:Pwchar_t; _para2:size_t; __restrict1:Pwchar_t):longint;cdecl;external libc_nlm name 'swprintf';

{$ifndef DisableArrayOfConst}
function swscanf(__restrict:Pwchar_t; __restrict1:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'swscanf';
{$endif}
function swscanf(__restrict:Pwchar_t; __restrict1:Pwchar_t):longint;cdecl;external libc_nlm name 'swscanf';

function vfwprintf(__restrict:P_iobuf; __restrict1:Pwchar_t; _para3:va_list):longint;cdecl;external libc_nlm name 'vfwprintf';

function vfwscanf(_para1:P_iobuf; _para2:Pwchar_t; _para3:va_list):longint;cdecl;external libc_nlm name 'vfwscanf';

function vwscanf(_para1:Pwchar_t; _para2:va_list):longint;cdecl;external libc_nlm name 'vwscanf';
function vswscanf(_para1:Pwchar_t; _para2:Pwchar_t; _para3:va_list):longint;cdecl;external libc_nlm name 'vswscanf';
function wcrtomb(__restrict:Pchar; _para2:wchar_t; __restrict1:Pmbstate_t):size_t;cdecl;external libc_nlm name 'wcrtomb';
function wcscat(__restrict:Pwchar_t; __restrict1:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcscat';
function wcschr(_para1:Pwchar_t; _para2:wchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcschr';
function wcscmp(_para1:Pwchar_t; _para2:Pwchar_t):longint;cdecl;external libc_nlm name 'wcscmp';
function wcscoll(_para1:Pwchar_t; _para2:Pwchar_t):longint;cdecl;external libc_nlm name 'wcscoll';
function wcscpy(__restrict:Pwchar_t; __restrict1:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcscpy';
function wcscspn(_para1:Pwchar_t; _para2:Pwchar_t):size_t;cdecl;external libc_nlm name 'wcscspn';
function wcsftime(__restrict:Pwchar_t; _para2:size_t; __restrict1:Pwchar_t; __restrict2:Ptm):size_t;cdecl;external libc_nlm name 'wcsftime';
function wcslen(_para1:Pwchar_t):size_t;cdecl;external libc_nlm name 'wcslen';
function wcsncat(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wcsncat';
function wcsncmp(_para1:Pwchar_t; _para2:Pwchar_t; _para3:size_t):longint;cdecl;external libc_nlm name 'wcsncmp';
function wcsncpy(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wcsncpy';
function wcspbrk(_para1:Pwchar_t; _para2:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcspbrk';
function wcsrchr(_para1:Pwchar_t; _para2:wchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcsrchr';
function wcsrtombs(__restrict:Pchar; __restrict1:PPwchar_t; _para3:size_t; __restrict2:Pmbstate_t):size_t;cdecl;external libc_nlm name 'wcsrtombs';
function wcsspn(_para1:Pwchar_t; _para2:Pwchar_t):size_t;cdecl;external libc_nlm name 'wcsspn';
function wcsstr(_para1:Pwchar_t; _para2:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcsstr';
function wcstod(__restrict:Pwchar_t; __restrict1:PPwchar_t):double;cdecl;external libc_nlm name 'wcstod';
function wcstof(__restrict:Pwchar_t; __restrict1:PPwchar_t):double;cdecl;external libc_nlm name 'wcstof';
function wcstok(__restrict:Pwchar_t; __restrict1:Pwchar_t; __restrict2:PPwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcstok';
function wcstok_r(__restrict:Pwchar_t; __restrict1:Pwchar_t; __restrict2:PPwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcstok_r';
function wcstol(__restrict:Pwchar_t; __restrict1:PPwchar_t; xx:longint):longint;cdecl;external libc_nlm name 'wcstol';

// long double wcstold(const wchar_t * __restrict1, wchar_t ** __restrict);
// long double wcstold(const wchar_t * __restrict1, wchar_t ** __restrict);

function wcstoll(__restrict:Pwchar_t; __restrict1:PPwchar_t; xx:longint):Tint64;cdecl;external libc_nlm name 'wcstoll';
function wcstoul(__restrict:Pwchar_t; __restrict1:PPwchar_t; _para3:longint):dword;cdecl;external libc_nlm name 'wcstoul';
function wcstoull(__restrict:Pwchar_t; __restrict1:PPwchar_t; _para3:longint):Tuint64;cdecl;external libc_nlm name 'wcstoull';
function wcsxfrm(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):size_t;cdecl;external libc_nlm name 'wcsxfrm';
function wctob(_para1:wint_t):longint;cdecl;external libc_nlm name 'wctob';
function wmemchr(ws:Pwchar_t; wc:wchar_t; n:size_t):Pwchar_t;cdecl;external libc_nlm name 'wmemchr';
function wmemcmp(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):longint;cdecl;external libc_nlm name 'wmemcmp';
function wmemcpy(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wmemcpy';
function wmemmove(_para1:Pwchar_t; _para2:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wmemmove';
function wmemset(ws:Pwchar_t; wc:wchar_t; n:size_t):Pwchar_t;cdecl;external libc_nlm name 'wmemset';
function putwc(_para1:wchar_t; _para2:P_iobuf):wint_t;cdecl;external libc_nlm name 'putwc';
function putwchar(_para1:wchar_t):wint_t;cdecl;external libc_nlm name 'putwchar';
function fwide(_para1:P_iobuf; _para2:longint):longint;cdecl;external libc_nlm name 'fwide';
function fputwc(_para1:wchar_t; _para2:P_iobuf):wint_t;cdecl;external libc_nlm name 'fputwc';
function fputws(__restrict:Pwchar_t; __restrict1:P_iobuf):longint;cdecl;external libc_nlm name 'fputws';
function fgetwc(_para1:P_iobuf):wint_t;cdecl;external libc_nlm name 'fgetwc';
function fgetws(__restrict:Pwchar_t; _para2:longint; __restrict1:P_iobuf):Pwchar_t;cdecl;external libc_nlm name 'fgetws';
function getwc(_para1:P_iobuf):wint_t;cdecl;external libc_nlm name 'getwc';
function getwchar:wint_t;cdecl;external libc_nlm name 'getwchar';
function ungetwc(_para1:wint_t; __restrict:P_iobuf):wint_t;cdecl;external libc_nlm name 'ungetwc';

{$ifndef DisableArrayOfConst}
function wprintf(__restrict:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'wprintf';
{$endif}
function wprintf(__restrict:Pwchar_t):longint;cdecl;external libc_nlm name 'wprintf';

{$ifndef DisableArrayOfConst}
function wscanf(__restrict:Pwchar_t; args:array of const):longint;cdecl;external libc_nlm name 'wscanf';
{$endif}
function wscanf(__restrict:Pwchar_t):longint;cdecl;external libc_nlm name 'wscanf';
function vwprintf(__restrict:Pwchar_t; _para2:va_list):longint;cdecl;external libc_nlm name 'vwprintf';
function vswprintf(__restrict:Pwchar_t; _para2:size_t; __restrict1:Pwchar_t; _para4:va_list):longint;cdecl;external libc_nlm name 'vswprintf';
function wcscasecmp(_para1:Pwchar_t; _para2:Pwchar_t):longint;cdecl;external libc_nlm name 'wcscasecmp';
function wcserror(_para1:longint):Pwchar_t;cdecl;external libc_nlm name 'wcserror';
function wcsicmp(_para1:Pwchar_t; _para2:Pwchar_t):longint;cdecl;external libc_nlm name 'wcsicmp';
function wcsindex(_para1:Pwchar_t; _para2:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcsindex';

{$ifndef DisableArrayOfConst}
function wcslist(_para1:Pwchar_t; _para2:Pwchar_t; args:array of const):Pwchar_t;cdecl;external libc_nlm name 'wcslist';
{$endif}
function wcslist(_para1:Pwchar_t; _para2:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcslist';
function wcslwr(_para1:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcslwr';
function wcsmemcmp(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):longint;cdecl;external libc_nlm name 'wcsmemcmp';
function wcsmemcpy(__restrict:Pwchar_t; __restrict1:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wcsmemcpy';
function wcsmemmove(_para1:Pwchar_t; _para2:Pwchar_t; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wcsmemmove';
function wcsncasecmp(_para1:Pwchar_t; _para2:Pwchar_t; _para3:size_t):longint;cdecl;external libc_nlm name 'wcsncasecmp';
function wcsnicmp(_para1:Pwchar_t; _para2:Pwchar_t; _para3:size_t):longint;cdecl;external libc_nlm name 'wcsnicmp';
function wcsnset(_para1:Pwchar_t; _para2:longint; _para3:size_t):Pwchar_t;cdecl;external libc_nlm name 'wcsnset';
function wcsrev(_para1:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcsrev';
function wcsrindex(_para1:Pwchar_t; _para2:size_t; _para3:longint):Pwchar_t;cdecl;external libc_nlm name 'wcsrindex';
function wcsset(_para1:Pwchar_t; _para2:longint):Pwchar_t;cdecl;external libc_nlm name 'wcsset';
function wcsupr(_para1:Pwchar_t):Pwchar_t;cdecl;external libc_nlm name 'wcsupr';
procedure wungettok(__restrict:Pwchar_t; __restrict1:Pwchar_t; __restrict2:PPwchar_t);cdecl;external libc_nlm name 'wungettok';
procedure wungettok_r(__restrict:Pwchar_t; __restrict1:Pwchar_t; __restrict2:PPwchar_t);cdecl;external libc_nlm name 'wungettok_r';
function btowc(_para1:longint):wint_t;cdecl;external libc_nlm name 'btowc';
function mbrlen(__restrict:Pchar; _para2:size_t; __restrict1:Pmbstate_t):longint;cdecl;external libc_nlm name 'mbrlen';
function mbrtowc(__restrict:Pwchar_t; __restrict1:Pchar; _para3:size_t; __restrict2:Pmbstate_t):longint;cdecl;external libc_nlm name 'mbrtowc';
function mbsinit(_para1:Pmbstate_t):longint;cdecl;external libc_nlm name 'mbsinit';
function wcwidth(_para1:wchar_t):longint;cdecl;external libc_nlm name 'wcwidth';
function wcswidth(_para1:Pwchar_t; _para2:size_t):longint;cdecl;external libc_nlm name 'wcswidth';
{ macros that overcome implementation's function call overhead...  }
{ attributes for NXDirAttrDos_t 'attrib' field...  }


// fsio.h
// netware.h
  const
     LD_MODULE_REENTRANT_BIT       = $00000001;
     LD_MODULE_MULTIPLE_LOAD       = $00000002;       { multiple load            }
     LD_SYNCHRONIZE_START          = $00000004;       { uses SynchronizeStart()  }
     LD_PSEUDOPREEMPTION_BIT       = $00000008;       { accept preemption        }
     LD_KERNEL_LOAD                = $00000010;       { ring 0-only              }
     LD_DONT_SHARE_CODE            = $00000020;
  { once dependencies gone   }
     LD_AUTO_UNLOAD                = $00000040;
     LD_HIDDEN_MODULE              = $00000080;
     LD_DIGITALLY_SIGNED_FILE      = $00000100;
     LD_PROTECTED_LOAD             = $00000200;       { protected address space  }
     LD_SHARED_LIBRARY             = $00000400;
     LD_RESTARTABLE                = $00000800;
     LD_MODULE_HAS_MPK_STUBS       = $00001000;
     LD_NOT_MULTIPROCESSOR_SAFE    = $00002000;
     LD_PREEMPTABLE                = $00004000;
     LD_HAS_SYSTEM_CALLS           = $00008000;
     LD_VIRTUAL_MEMORY             = $00010000;
     LD_ALL_EXPORTS_SAFE           = $00020000;
     LD_RESERVED_1                 = $00040000;
     LD_RESERVED_2                 = $00080000;
     LD_RESERVED_3                 = $00100000;
     LD_RESERVED_4                 = $00200000;
     LD_WANT_POSIX_SEMANTICS       = $00400000;       { assume POSIX semantics   }
     LD_UTF8_STRINGS               = $00800000;       { UTF-8 strings            }
     LD_TSR                        = $01000000;       { terminate-stay-resident  }
     LD_PROMPT_USER_AND_PASSWORD   = $02000000;       { with LD_WANT_POSIX...    }
     LD_HOTSWAP_DRIVER             = $04000000;
     LD_STARTUP_DEVICE_NLM_BIT     = $08000000;
     LD_BOUND_NLM_BIT              = $10000000;
     LD_DONT_UNLOAD_BIT            = $20000000;       { never unload             }
     LD_MODULE_BEING_DEBUGGED      = $40000000;       { (debugging)              }
     LD_MEMORY_ON_4K_BOUNDRIES_BIT = $80000000;       { (debugging)              }
  { Note LD_UNICODE_STRINGS mostly obsolete--used only by NKS applications:   }
     LD_UNICODE_STRINGS            = $02000000;       { Unicode strings          }


type
   Prtag_t = ^rtag_t;
   rtag_t = pointer;
   Trtag = rtag_t;
   Prtag = Prtag_t;

   {this is from the lan driver sdk () cmsm.h

    but be warned, like the ScanScreen function available in
    clib, there is no MP save way to access netware screens, a
    comment from Russell Bateman (libc developer @ novell) dated
    way to do screen discovery on NetWare. }

   PScreenStruct = ^TScreenStruct;
   TScreenStruct = packed record
     previousScreen       : PScreenStruct;
     nextScreen           : PScreenStruct;
     popUpOriginalScreen  : PScreenStruct;
     CLIBScreenStructure  : pdword;
     currentPalette       : byte;
     _Filler1             : byte;
     popUpCount           : byte;
     _Filler2             : byte;
     screenList           : byte;
     _Filler3             : byte;
     activeCount          : byte;
     _Filler4             : byte;
     resourceTag          : Prtag_t;
     screenName           : pchar;
     screenMemory         : pointer;
     flags                : dword;
     state                : dword;
     outputCursorPosition : word;
     inputCursorPosition  : word;
   end;

   Pscr_t = ^scr_t;
   scr_t = PScreenStruct;
   TScr = scr_t;
   PScr = Pscr_t;

// event.h
// screen.h

  const
     MAX_SCREEN_STRING_LEN = 255;
  { screen mode flags...  }
     SCR_NO_MODE           = $00000000;
     SCR_AUTOCLOSE_ON_EXIT = $00000001;   // default
     SCR_COLOR_ATTRS       = $00000002;
  { key types...  }
     NORMAL_KEY        = $00;
     FUNCTION_KEY      = $01;
     ENTER_KEY         = $02;
     ESCAPE_KEY        = $03;
     BACKSPACE_KEY     = $04;
     DELETE_KEY        = $05;
     INSERT_KEY        = $06;
     CURSOR_UP_KEY     = $07;
     CURSOR_DOWN_KEY   = $08;
     CURSOR_RIGHT_KEY  = $09;
     CURSOR_LEFT_KEY   = $0A;
     CURSOR_HOME_KEY   = $0B;
     CURSOR_END_KEY    = $0C;
     CURSOR_PUP_KEY    = $0D;
     CURSOR_PDOWN_KEY  = $0E;
  { some name equivalents...  }
     ENTER             = $0D;
     ESCAPE            = $1B;
     BACKSPACE         = $08;
  { modifier code constituents...  }
     SHIFT_KEY_HELD    = $01;
     CTRL_KEY_HELD     = $04;
     ALT_KEY_HELD      = $08;
     CAPS_LOCK_IS_ON   = $40;
     NUM_LOCK_IS_ON    = $20;
     SCROLL_LOCK_IS_ON = $10;
     _PASSWORD_LEN     = 128;  // suggested 'maxlen' argument for getpassword()...
  { string-embeddable color representations...  }
     COLOR_STR_BLACK   = '\x1B[0;30m';
     COLOR_STR_MAROON  = '\x1B[0;31m';
     COLOR_STR_GREEN   = '\x1B[0;32m';
     COLOR_STR_OLIVE   = '\x1B[0;33m';
     COLOR_STR_NAVY    = '\x1B[0;34m';
     COLOR_STR_PURPLE  = '\x1B[0;35m';
     COLOR_STR_TEAL    = '\x1B[0;36m';
     COLOR_STR_SILVER  = '\x1B[0;37m';
     COLOR_STR_GREY    = '\x1B[1;30m';
     COLOR_STR_RED     = '\x1B[1;31m';
     COLOR_STR_LIME    = '\x1B[1;32m';
     COLOR_STR_YELLOW  = '\x1B[1;33m';
     COLOR_STR_BLUE    = '\x1B[1;34m';
     COLOR_STR_MAGENTA = '\x1B[1;35m';
     COLOR_STR_CYAN    = '\x1B[1;36m';
     COLOR_STR_WHITE   = '\x1B[1;37m';

     COLOR_STR_NORMAL  = COLOR_STR_SILVER;  // dim/unhighlighted white
     COLOR_STR_GRAY    = COLOR_STR_GREY;
  { attributes for OutputToScreenWithAttributes(); cf. HTML color names  }

     COLOR_ATTR_NONE   = 0;            // black, no color at all
     COLOR_ATTR_NAVY   = 1;            // dim blue
     COLOR_ATTR_BLUE   = $01 or 8;
     COLOR_ATTR_GREEN  = 2;
     COLOR_ATTR_LIME   = 2 or 8;       // bright green
     COLOR_ATTR_TEAL   = 3;            // dim cyan
     COLOR_ATTR_CYAN   = 3 or 8;
     COLOR_ATTR_MAROON = 4;            // dim red
     COLOR_ATTR_RED    = 4 or 8;
     COLOR_ATTR_PURPLE = 5;
     COLOR_ATTR_MAGENTA= 5 or 8;       // bright purple
     COLOR_ATTR_OLIVE  = 6;            // brown, dim yellow
     COLOR_ATTR_YELLOW = 6 or 8;
     COLOR_ATTR_SILVER = 7;            // normal white, dim/unhighlighted
     COLOR_ATTR_GREY   = 8;            // dimmed white
     COLOR_ATTR_WHITE  = 15;           // bright, highlighted white

  const
//     OutputToScreenWithVaList = OutputToScreenWithPointer;
  { return and default values for Prompt functions...  }
     SCR_PROMPT_ANSWER_NO   = 0;
     SCR_PROMPT_ANSWER_YES  = 1;
     SCR_PROMPT_ANSWER_SKIP = 2;
     SCR_PROMPT_ANSWER_ALL  = 3;

  { cursor types...  }
     CURSOR_NORMAL = $0C0B;
     CURSOR_THICK  = $0C09;
     CURSOR_BLOCK  = $0C00;
     CURSOR_TOP    = $0400;
  { screen types...  }
     SCREEN_TYPE_TTY         = $00000000;
     SCREEN_TYPE_MONOCHROME  = $00000001;
     SCREEN_TYPE_DUAL_MODE   = $00000002;
     SCREEN_TYPE_CGA         = $00000003;
     SCREEN_TYPE_EGA         = $00000004;
     SCREEN_TYPE_VGA         = $00000005;
  { screen modes...  }
     SCREEN_MODE_TTY         = $00000000;
     SCREEN_MODE_80X25       = $00000001;
     SCREEN_MODE_80X43       = $00000002;
     SCREEN_MODE_80X50       = $00000003;
     SCREEN_MODE_D           = $0000000D;
     SCREEN_MODE_E           = $0000000E;
     SCREEN_MODE_F           = $0000000F;
     SCREEN_MODE_10          = $00000010;
     SCREEN_MODE_11          = $00000011;
     SCREEN_MODE_12          = $00000012;
     SCREEN_MODE_13          = $00000013;
  { voracious for memory!  }
     SCREEN_MODE_SCROLLABLE  = $80000000;
  { screen state...  }
     SCREEN_NON_SWITCHABLE   = $00000001;
     SCREEN_DUMMY            = $00000100;
     SCREEN_HIDDEN           = $00000200;

procedure clearscreen;cdecl;external libc_nlm name 'clearscreen';

{$ifndef DisableArrayOfConst}
function consoleprintf(txt:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'consoleprintf';
function consoleprintf(txt:Pchar):longint;cdecl;external libc_nlm name 'consoleprintf';
{$endif}
function __consoleprintfl1(txt:Pchar;p1:longint):longint;cdecl;external libc_nlm name 'consoleprintf';
function __consoleprintfl2(txt:Pchar;p1,p2:longint):longint;cdecl;external libc_nlm name 'consoleprintf';
function __consoleprintfl3(txt:Pchar;p1,p2,p3:longint):longint;cdecl;external libc_nlm name 'consoleprintf';
function getscreenmode(mode:Pdword):longint;cdecl;external libc_nlm name 'getscreenmode';
function getscreenmode(var mode:dword):longint;cdecl;external libc_nlm name 'getscreenmode';
function getcharacter:longint;cdecl;external libc_nlm name 'getcharacter';
function getkey(keytype,modifer,scancode:Plongint):longint;cdecl;external libc_nlm name 'getkey';
function getkey(var keytype, modifer, scancode:longint):longint;cdecl;external libc_nlm name 'getkey';
function getalternateconsole:scr_t;cdecl;external libc_nlm name 'getalternateconsole';
function getnetwareconsole:scr_t;cdecl;external libc_nlm name 'getnetwareconsole';
function getnetwarelogger:scr_t;cdecl;external libc_nlm name 'getnetwarelogger';

function getpassword(prompt,password:Pchar; maxlen:size_t):Pchar;cdecl;external libc_nlm name 'getpassword';
function getscreenhandle:scr_t;cdecl;external libc_nlm name 'getscreenhandle';
function getstring(_string:Pchar; max:size_t; display:longint):Pchar;cdecl;external libc_nlm name 'getstring';
function gotorowcol(row, col:longint):longint;cdecl;external libc_nlm name 'gotorowcol';
function kbhit:longint;cdecl;external libc_nlm name 'kbhit';
function pressanykey:longint;cdecl;external libc_nlm name 'pressanykey';
function pressanykeytocontinue:longint;cdecl;external libc_nlm name 'pressanykey';
function pressescape:longint;cdecl;external libc_nlm name 'pressescape';
function pressenter:longint;cdecl;external libc_nlm name 'pressenter';
function putcharacter(ch:longint):longint;cdecl;external libc_nlm name 'putcharacter';

function putstring(_string:Pchar):longint;cdecl;external libc_nlm name 'putstring';

{$ifndef DisableArrayOfConst}
function screenprintf(_para1:scr_t; _para2:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'screenprintf';
{$endif}
function screenprintf(_para1:scr_t; _para2:Pchar):longint;cdecl;external libc_nlm name 'screenprintf';
function screenprintf(_para1:scr_t; _para2:Pchar; l1:longint):longint;cdecl;external libc_nlm name 'screenprintf';
function screenprintf(_para1:scr_t; _para2:Pchar; l1,l2:longint):longint;cdecl;external libc_nlm name 'screenprintf';
function screenprintf(_para1:scr_t; _para2:Pchar; l1,l2,l3:longint):longint;cdecl;external libc_nlm name 'screenprintf';

function setscreenmode(mode:dword):longint;cdecl;external libc_nlm name 'setscreenmode';

function renamescreen(name:Pchar):longint;cdecl;external libc_nlm name 'renamescreen';
procedure ringbell;cdecl;external libc_nlm name 'ringbell';
function ungetcharacter(ch:longint):longint;cdecl;external libc_nlm name 'ungetcharacter';
function ungetkey(keytype:longint; modifer:longint; scancode:longint):longint;cdecl;external libc_nlm name 'ungetkey';

function vconsoleprintf(_para1:Pchar; _para2:va_list):longint;cdecl;external libc_nlm name 'vconsoleprintf';

function vscreenprintf(_para1:scr_t; _para2:Pchar; _para3:va_list):longint;cdecl;external libc_nlm name 'vscreenprintf';
function wherecol:longint;cdecl;external libc_nlm name 'wherecol';
function whererow:longint;cdecl;external libc_nlm name 'whererow';
function whererowcol(row,col:Plongint):longint;cdecl;external libc_nlm name 'whererowcol';
function whererowcol(var row,col:longint):longint;cdecl;external libc_nlm name 'whererowcol';
{ obsolete...  }
function getconsolehandle:scr_t;cdecl;external libc_nlm name 'getconsolehandle';
{ direct NetWare OS interfaces...  }
type

   Pscroll_t = ^scroll_t;
   scroll_t =  Longint;
   Const
     SCROLL_DOWN = 0;
     SCROLL_UP   = 1;
     SCROLL_NONE = 2147483647;


procedure ActivatePopUpScreen(scrID:scr_t);cdecl;external libc_nlm name 'ActivatePopUpScreen';
procedure ActivateScreen(scrID:scr_t);cdecl;external libc_nlm name 'ActivateScreen';
procedure ChangeToSystemConsoleScreen;cdecl;external libc_nlm name 'ChangeToSystemConsoleScreen';
function CheckIfScreenActive(scrID:scr_t; waitFlag:dword):longint;cdecl;external libc_nlm name 'CheckIfScreenActive';
function CheckKeyStatus(scrID:scr_t):longint;cdecl;external libc_nlm name 'CheckKeyStatus';
procedure ClearScreen(scrID:scr_t);cdecl;external libc_nlm name 'ClearScreen';
procedure CloseScreen(scrID:scr_t);cdecl;external libc_nlm name 'CloseScreen';
procedure ConsoleHungMenu;cdecl;external libc_nlm name 'ConsoleHungMenu';
procedure DisableInputCursor(scrID:scr_t);cdecl;external libc_nlm name 'DisableInputCursor';
function DisplayScreenLine(scrID:scr_t; line:dword; col:dword; length:dword; textAndAttr:Pbyte):longint;cdecl;external libc_nlm name 'DisplayScreenLine';
function DisplayScreenText(scrID:scr_t; line:dword; col:dword; length:dword; text:Pchar):longint;cdecl;external libc_nlm name 'DisplayScreenText';
function DisplayScreenTextWithAttribute(scrID:scr_t; line:dword; col:dword; length:dword; lineAttr:byte;
           text:Pchar):longint;cdecl;external libc_nlm name 'DisplayScreenTextWithAttribute';
procedure EnableInputCursor(scrID:scr_t);cdecl;external libc_nlm name 'EnableInputCursor';
procedure EndPopUpScreen(scr:scr_t);cdecl;external libc_nlm name 'EndPopUpScreen';
function FillScreenArea(scrID:scr_t; line:dword; col:dword; height:dword; width:dword;
           character:char; attr:byte):longint;cdecl;external libc_nlm name 'FillScreenArea';
function FillScreenAreaAttribute(scrID:scr_t; line:dword; col:dword; height:dword; width:dword;
           attr:byte):longint;cdecl;external libc_nlm name 'FillScreenAreaAttribute';
function GetActiveScreen:scr_t;cdecl;external system_nlm name 'GetActiveScreen';
function GetActualScreenSize(scrID:scr_t; height:Pdword; width:Pdword; bufferSize:Psize_t):longint;cdecl;external system_nlm name 'GetActualScreenSize';
function GetConsoleSecuredFlag:longint;cdecl;external libc_nlm name 'GetConsoleSecuredFlag';
procedure GetCursorStyle(scrID:scr_t; cursorStyle:Pword);cdecl;external system_nlm name 'GetCursorStyle';
procedure GetCursorStyle(scrID:scr_t; var cursorStyle:word);cdecl;external system_nlm name 'GetCursorStyle';
procedure GetInputCursorPosition(scrID:scr_t; row:Pword; col:Pword);cdecl;external system_nlm name 'GetInputCursorPosition';
procedure GetKey(scrID:scr_t; _type,value,status,scancode:Pbyte;linesToProtect:size_t);cdecl;external system_nlm name 'GetKey';
procedure GetKey(scrID:scr_t; var _type,value,status,scancode:byte;linesToProtect:size_t);cdecl;external system_nlm name 'GetKey';
procedure GetOutputCursorPosition(scrID:scr_t; row,col:Pword);cdecl;external system_nlm name 'GetOutputCursorPosition';
procedure GetOutputCursorPosition(scrID:scr_t; var row,col:word);cdecl;external system_nlm name 'GetOutputCursorPosition';
function GetRawKeyWithScreen(scrID:scr_t; _type,value,status,scancode:Pbyte):longint;cdecl;external libc_nlm name 'GetRawKeyWithScreen';
function GetRawKeyWithScreen(scrID:scr_t; var _type,value,status,scancode:byte):longint;cdecl;external libc_nlm name 'GetRawKeyWithScreen';
function GetScreenAddress:pointer;cdecl;external system_nlm name 'GetScreenAddress';  // not in protected mode
function GetScreenName(scrID:scr_t; nameBuffer:Pchar):longint;cdecl;external system_nlm name 'GetScreenName';
function GetScreenPhysicalAddress:pointer;cdecl;external libc_nlm name 'GetScreenPhysicalAddress';
procedure GetScreenSize(height,width:Pword);cdecl;external system_nlm name 'GetScreenSize';
procedure GetScreenSize(var height,width:word);cdecl;external system_nlm name 'GetScreenSize';

{$ifndef DisableArrayOfConst}
function InputFromScreen(scrID:scr_t; allowedCharacterSet:Pchar; bufferLength:size_t; editWidth:size_t; buffer:Pchar;
           linesToProtect:longint; hasDefaultString:longint; defaultString:Pchar; promptText:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'InputFromScreen';
{$endif}
function InputFromScreen(scrID:scr_t; allowedCharacterSet:Pchar; bufferLength:size_t; editWidth:size_t; buffer:Pchar;
           linesToProtect:longint; hasDefaultString:longint; defaultString:Pchar; promptText:Pchar):longint;cdecl;external libc_nlm name 'InputFromScreen';
function IsScreenModeSupported(screenMode:dword):longint;cdecl;external system_nlm name 'IsScreenModeSupported';

function OpenCustomScreen(name:Pchar; rTag:rtag_t; newScrID:Pscr_t; mode:longint):longint;cdecl;external libc_nlm name 'OpenCustomScreen';

function OpenPopUpScreen(name:Pchar; rTag:rtag_t; newScrID:Pscr_t):longint;cdecl;external libc_nlm name 'OpenPopUpScreen';

function OpenScreen(name:Pchar; rTag:rtag_t; newScrID:Pscr_t):longint;cdecl;external system_nlm name 'OpenScreen';

{$ifndef DisableArrayOfConst}
function OutputToScreen(scrID:scr_t; format:Pchar; args:array of const):longint;cdecl;external system_nlm name 'OutputToScreen';
{$endif}
function OutputToScreen(scrID:scr_t; format:Pchar):longint;cdecl;external system_nlm name 'OutputToScreen';

{$ifndef DisableArrayOfConst}
function OutputToScreenWithAttribute(scrID:scr_t; attr:byte; format:Pchar; args:array of const):longint;cdecl;external system_nlm name 'OutputToScreenWithAttribute';
{$endif}
function OutputToScreenWithAttribute(scrID:scr_t; attr:byte; format:Pchar):longint;cdecl;external system_nlm name 'OutputToScreenWithAttribute';


function OutputToScreenWithPointer(scrID:scr_t; format:Pchar; arguments:va_list):longint;cdecl;external system_nlm name 'OutputToScreenWithPointer';
procedure Pause(scrID:scr_t);cdecl;external system_nlm name 'Pause';
function PauseWithEscape(scrID:scr_t):longint;cdecl;external system_nlm name 'PauseWithEscape';
procedure PositionInputCursor(scrID:scr_t; row:word; col:word);cdecl;external system_nlm name 'PositionInputCursor';
function PositionOutputCursor(scrID:scr_t; row:word; col:word):longint;cdecl;external system_nlm name 'PositionOutputCursor';

function PromptForString(scr:scr_t; length:size_t; editWidth:size_t; _string:Pchar; hasDefaultValue:longint;
           defaultValue:Pchar; linesToProtect:longint; promptText:pointer):Pchar;cdecl;external libc_nlm name 'PromptForString';

function PromptForPassword(scr:scr_t; prompt:Pchar; blotOutChar:longint; password:Pchar; maxlen:size_t):Pchar;cdecl;external libc_nlm name 'PromptForPassword';

{$ifndef DisableArrayOfConst}
function PromptForUnsignedNumber(scrID:scr_t; result:Pdword; minValue:dword; maxValue:dword; radix:longint;
           linesToProtect:longint; hasDefaultValue:byte; defaultValue:dword; promptText:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'PromptForUnsignedNumber';
{$endif}
function PromptForUnsignedNumber(scrID:scr_t; result:Pdword; minValue:dword; maxValue:dword; radix:longint;
           linesToProtect:longint; hasDefaultValue:byte; defaultValue:dword; promptText:Pchar):longint;cdecl;external libc_nlm name 'PromptForUnsignedNumber';

{$ifndef DisableArrayOfConst}
function PromptForYesOrNo(scrID:scr_t; linesToProtect,defaultValue:longint; promptText:pointer; args:array of const):longint;cdecl;external libc_nlm name 'PromptForYesOrNo';
{$endif}
function PromptForYesOrNo(scrID:scr_t; linesToProtect,defaultValue:longint; promptText:pointer):longint;cdecl;external libc_nlm name 'PromptForYesOrNo';

{$ifndef DisableArrayOfConst}
function PromptForYesNoAllOrSkip(scrID:scr_t; linesToProtect:longint; defaultValue:dword; promptText:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'PromptForYesNoAllOrSkip';
{$endif}
function PromptForYesNoAllOrSkip(scrID:scr_t; linesToProtect:longint; defaultValue:dword; promptText:Pchar):longint;cdecl;external libc_nlm name 'PromptForYesNoAllOrSkip';
function ReadScreenCharacter(scrID:scr_t; line,col:dword; character:Pchar):longint;cdecl;external system_nlm name 'ReadScreenCharacter';

function RenameScreen(scrID:scr_t; name:Pchar):longint;cdecl;external system_nlm name 'RenameScreen';
function RestoreFullScreen(scrID:scr_t; buffer:pointer):longint;cdecl;external system_nlm name 'RestoreFullScreen';
function RestoreScreenArea(scrID:scr_t; line,col,height,width:dword; buffer:pointer):longint;cdecl;external system_nlm name 'RestoreScreenArea';
procedure ReturnScreenType(_type,colorFlag:Pdword);cdecl;external system_nlm name 'ReturnScreenType';
procedure ReturnScreenType(var _type,colorFlag:dword);cdecl;external system_nlm name 'ReturnScreenType';
procedure RingTheBell;cdecl;external system_nlm name 'RingTheBell';
function SaveFullScreen(scrID:scr_t; buffer:pointer):longint;cdecl;external system_nlm name 'SaveFullScreen';
function SaveScreenArea(scrID:scr_t; line,col,height,width:dword; buffer:pointer):longint;cdecl;external system_nlm name 'SaveScreenArea';
procedure SetConsoleSecuredFlag(value:byte);cdecl;external system_nlm name 'SetConsoleSecuredFlag';
procedure SetCursorStyle(scrID:scr_t; newStyle:word);cdecl;external system_nlm name 'SetCursorStyle';
procedure SetInputToOutputCursorPosition(scrID:scr_t);cdecl;external system_nlm name 'SetInputToOutputCursorPosition';
function ScrollScreenArea(scrID:scr_t; line,col,height,width,count:dword; newLineAttribute:byte; direction:scroll_t):longint;cdecl;external system_nlm name 'ScrollScreenArea';

procedure ShowTitleBarText(screenMemoryAddress:pointer; titleBarText:Pchar; textLength:size_t);cdecl;external system_nlm name 'ShowTitleBarText';
function UngetKey(scrID:scr_t; _type,value,status,scancode:byte):longint;cdecl;external system_nlm name 'UngetKey';
function ValidateScreenHandle(scrID:scr_t):longint;cdecl;external system_nlm name 'ValidateScreenHandle';
procedure WaitForKey(scrID:scr_t);cdecl;external system_nlm name 'WaitForKey';
function WriteScreenCharacter(scrID:scr_t; line,col:dword; character:char):longint;cdecl;external system_nlm name 'WriteScreenCharacter';
function WriteScreenCharacterAttribute(scrID:scr_t; line,col:dword; character:char; attr:byte):longint;cdecl;external system_nlm name 'WriteScreenCharacterAttribute';

{ turn on 1-byte packing...  }



{ file server event notification interfaces...  }
const
     EVENT_VOL_SYS_MOUNT = 0;
     EVENT_VOL_SYS_DISMOUNT = 1;
     EVENT_ANY_VOL_MOUNT = 2;
     EVENT_ANY_VOL_DISMOUNT = 3;
     EVENT_DOWN_SERVER = 4;        { (see EVENT_PRE_DOWN_SERVER)  }
     EVENT_EXIT_TO_DOS = 7;
     EVENT_MODULE_UNLOAD = 8;
     EVENT_MODULE_UNLOAD_POST_EXIT = 115;
     EVENT_CLEAR_CONNECTION = 9;
     EVENT_LOGIN_USER = 10;
     EVENT_CREATE_BINDERY_OBJ = 11;
     EVENT_DELETE_BINDERY_OBJ = 12;
     EVENT_CHANGE_SECURITY = 13;
     EVENT_CHANGE_SECURITY_ADD_EQUIVALENCE = 1;
     EVENT_ACTIVATE_SCREEN = 14;
     EVENT_UPDATE_SCREEN = 15;
     EVENT_UPDATE_CURSOR = 16;
     EVENT_KEY_WAS_PRESSED = 17;
     EVENT_DEACTIVATE_SCREEN = 18;
     EVENT_TRUSTEE_CHANGE = 19;
     EVENT_NO_RELINQUISH_CONTROL = 23;
     EVENT_THREAD_SWITCH = 25;
     EVENT_MODULE_LOAD = 27;
     EVENT_CREATE_PROCESS = 28;
     EVENT_DESTROY_PROCESS = 29;
     EVENT_NEW_PUBLIC = 32;
     EVENT_PROTOCOL_BIND = 33;
     EVENT_PROTOCOL_UNBIND = 34;
     EVENT_ALLOCATE_CONNECTION = 37;
     EVENT_LOGOUT_CONNECTION = 38;
     EVENT_MLID_REGISTER = 39;
     EVENT_MLID_DEREGISTER = 40;
     EVENT_DATA_MIGRATION = 41;
     EVENT_DATA_DEMIGRATION = 42;
     EVENT_CREATE_OBJECT = 46;
     EVENT_DELETE_OBJECT = 47;
     EVENT_RENAME_OBJECT = 48;
     EVENT_VALUE_CHANGE = 49;
     EVENT_MOVE_OBJECT = 52;
     EVENT_VALUE_ADD = 53;
     EVENT_VALUE_DEL = 54;
     EVENT_CHANGE_TIME = 51;
     EVENT_DM_KEY_MODIFIED = 55;
     EVENT_MODULE_UNLOADED = 56;
     EVENT_REMOVE_PUBLIC = 57;
     EVENT_UNICODE = 59;
     EVENT_SFT3_SERVER_STATE = 60;
     EVENT_SFT3_IMAGE_STATE = 61;
     EVENT_SFT3_PRESYNC_STATE = 62;
     EVENT_ALTERNATE_MOUNT_VOLUME = 63;
     EVENT_CONSOLE_CONFIG_COMMAND = 64;
     EVENT_CONSOLE_VERSION_COMMAND = 65;
     EVENT_PRE_LOAD_NLM = 66;
     EVENT_LOW_MEMORY = 67;
     EVENT_PRE_DOWN_SERVER = 129;     // called before NDS disappears
     EVENT_GET_KEY_INFORMATION = 148;
     EGKStructVersion =  $00000001;
     EVENT_PRIORITY_APPLICATION = 20;
     EVENT_PRIORITY_DEVICE = 40;      // lowest

  {** A consumer registering for an event sets this flag in the event type to
   ** denote that the consumer is multiprocessor safe. This allows us to
   ** distinguish multiprocessor safe consumers from unsafe ones. }
     EVENT_CONSUMER_MT_SAFE     = $40000000;
  { ** Values for fields of EventNetWareAlertStruct_t. }
     QueueThisAlertMask         = $00000001;
     AlertIDValidMask           = $00000002;
     AlertLocusValidMask        = $00000004;
     AlertEventNotifyOnlyMask   = $00000008;
     AlertNoEventNotifyMask     = $00000010;
     AlertMessageNumberValid    = $00010000;
     NoDisplayAlertUID          = $00200000;
     AlertNoRingBell            = $00400000;
     AlertIDNotUniqueBit        = $00800000;
     OldStyleSystemAlertMask    = $01000000;
     OldStyleINWSystemAlertMask = $02000000;
  { can be pointer or number  }
     OverloadMessageNumFieldBit = $04000000;
     NoDisplayLocusBit          = $10000000;
     NoDisplayAlertIDBit        = $20000000;
     OverrideNotificationBits   = $40000000;
     TargetStationIsAPointer    = $80000000;
     Alert300Mask = (AlertIDValidMask or AlertLocusValidMask) or OldStyleSystemAlertMask;
     Alert311Mask = AlertIDValidMask or OldStyleINWSystemAlertMask;
     //Alert320Mask = ((AlertIDValidMask or AlertMessageNumberValid) or AlertLocusValidMask) or NoDisp
     //QAlertMask = ((AlertIDValidMask or AlertLocusValidMask) or NoDisplayAlertIDBit) or QueueThisAle
     //QAlert320Mask = Alert320Mask or QueueThisAlertMask;
 { allotted ModuleNumbers for 'alertID' in EventNetWareAlertStruct_t...  }
     ALERT_BINDERY    = $01020000;   // Bindary
     ALERT_OS         = $01030000;   // OS Event Subject
     ALERT_LLC        = $01040000;   // LLC
     ALERT_SDLC       = $01050000;   // SDLC Stack
     ALERT_REMOTE     = $01060000;   // RConsole
     ALERT_MLID       = $01070000;   // MLID Lan Drivers
     ALERT_QLLC       = $01080000;   // QLLC
     ALERT_UPS        = $01090000;   // UPS Monitor
     ALERT_DS         = $010a0000;   // Directory Service
     ALERT_RSPX       = $010c0000;   // RSPX
     ALERT_R232       = $010d0000;   // Serial
     ALERT_TIME_SYNC  = $010e0000;   // TimeSync
     ALERT_CLIB       = $010f0000;   // Clib
     ALERT_PRINT      = $01100000;   // Print
     ALERT_NRS        = $01200000;   // Novell Replication Services
     ALERT_DNS        = $01300000;   // IP/Domain Name Services
     ALERT_DHCP       = $01400000;   // DHCP Services
     ALERT_MM         = $01500000;   // Media Manager
{
  ** OS-defined AlertNumber values for 'alertID' in EventNetWareAlertStruct_t
  ** structure.
   }
  { starting with NetWare 4...  }
     nmAllocFailed = 1;
     nmErrWrtExtDir = 2;
     nmSysErrWrtDSnoFN = 3;
     nmStaErrWrtDSnoFN = 4;
     nmSysErrWrtDSwithFN = 5;
     nmStaErrWrtDSwithFN = 6;
     nmSysErrRdDSnoFN = 7;
     nmStaErrRdDSnoFN = 8;
     nmSysErrRdDSwithFN = 9;
     nmStaErrRdDSwithFN = 10;
     nmSysWrtPreRDnoFN = 11;
     nmStaWrtPreRDnoFN = 12;
     nmSysWrtPreRDwithFN = 13;
     nmStaWrtPreRDwithFN = 14;
     nmCacheMemLimitExceded = 15;
     nmCacheMemOutOfMem = 16;
     nmCacheBufsGetLo = 17;
     nmDskSpcNoDelFiles = 18;
     nmDskSpcNoLimbo = 19;
     nmVolSpcAlmostGone = 20;
     nmFATWrtErr = 21;
     nmDirWrtErr = 22;
     nmDirCopyRdErr = 23;
     nmDirDblRdErr = 24;
     nmAllocDirWrtErr = 25;
     nmDirExpansionErr = 26;
     nmDirTooLarge = 27;
     nmErrExpandingDir = 28;
     nmErrExpandingMem = 29;
     nmErrDirGetTooLarge = 30;
     nmDskBottleneck = 31;
     nmWDClearedConn = 32;
     nmCpyrtViolation = 33;
     nmReadFault = 35;
     nmPktTooSmall = 36;
     nmCreatingVolLog = 37;
     nmWrtVolLog = 38;
     nmVolDmtDevDeact = 39;
     nmLoginDisabled = 40;
     nmLoginEnabled = 41;
     nmClrSta = 42;
     nmClrStaByUsr = 43;
     nmFSDownByUser = 44;
     nmRIPAlreadyOpn = 45;
     nmRouterConfigErr = 46;
     nmLANLoopbackErr = 47;
     nmRouterConfigErrNoInfo = 48;
     nmIPXUnreachable = 49;
     nmIPXUnbind = 50;
     nmSAPAlreadyOpn = 51;
     nmRouterConfigErrNameInfo = 52;
     nmSpuriousInt = 53;
     nmChecksumInvalidAlert = 54;
     nmPrimaryPicLostInt = 55;
     nmSecondaryPicLostInt = 56;
     nmCompErrHoleCountMismatch = 57;
     nmInvalidScreen = 58;
     nmRelinquishControl = 59;
     nmFSUserDeleted = 60;
     nmAccDelByUser = 61;
     nmInvalidRTag = 62;
     nmDeactUnknown = 63;
     nmDeactDriveUnld = 64;
     nmDeactDevFailure = 65;
     nmDeactUsrRequest = 66;
     nmDeactMediaDismount = 67;
     nmDeactMediaEject = 68;
     nmDeactServerDown = 69;
     nmDeactServerFailure = 70;
     nmResourceRelErr = 71;
     nmMirrorsNotSync = 72;
     nmMirrorsSyncUp = 73;
     nmPartMirrorSync = 74;
     nmPartMirrorNotSync = 75;
     nmReMirroringPart = 76;
     nmReMirroringPartAborted = 77;
     nmLogPartMirrorInconsist = 78;
     nmSysFileLockThresh = 79;
     nmStaFileLockThresh = 80;
     nmSysRecLockThresh = 81;
     nmStaRecLockThresh = 82;
     nmOpnNETACCTFailed = 83;
     nmNCPSearchLimitSys = 84;
     nmNCPSearchLimitSta = 85;
     nmInsMediaAck = 86;
     nmInsMediaAborted = 87;
     nmRemMediaAck = 88;
     nmRemMediaAbort = 89;
     nmInsMediaInto = 90;
     nmRemMediaFrom = 91;
     nmReDirectedBlockPart = 92;
     nmReDirectedBlockPartErr = 93;
     nmOutOfHotFixBlocks = 94;
     nmLowWarningHotFixBlocks = 95;
     nmReDirectInconsistNoFix = 96;
     nmReDirectInconsistFixed = 97;
     nmInvalidRTagHOptions = 98;
     nmCheckAndAddHWNoGetRTag = 99;
     nmRemHWBadPtr = 100;
     nmErrUnldNLM = 101;
     nmIvldRTagCrProc = 102;
     nmCrProcStkTooSmall = 103;
     nmCrProcNoPCB = 104;
     nmDelToLimboFileErr = 105;
     nmDelToLimboNoSpace = 106;
     nmMLIDResetLanBd = 107;
     nmRouterReset = 108;
     nmVolWrongDOSType = 109;
     nmNoOwnerNSfound = 110;
     nmRTDMDefSMchanged = 111;
     nmErrOpnTTSLOG = 112;
     nmErrWrtTTSLOG = 113;
     nmTTSdownVolDismount = 114;
     nmTTSdisableByStaUsr = 115;
     nmTTSdisByOp = 116;
     nmTTSdisErrRdBackFile = 117;
     nmTTSdisErrWrBackFile = 118;
     nmTTSdisTooManyDefVol = 119;
     nmTTSdisWrtVolDefInfo = 120;
     nmTTSdisErrRdBkFlRecGen = 121;
     nmTTSdisGrowMemTables = 122;
     nmTTSdisErrAllDiskSp = 123;
     nmTTSdisDirErrOnBkFile = 124;
     nmTTSEnableByStaUsr = 125;
     nmTTStransAbortedForSta = 126;
     nmTTStooManyTransDelaying = 127;
     nmTTSNoMemForExpTransNodes = 128;
     nmAuditEvent = 129;
     nmAuditDisNoAuditCfg = 130;
     nmInvldConnTypeToAllocConn = 131;
     nmInvldRTagToAllocConn = 132;
     nmOutOfServerConns = 133;
     nmConnTermAfter5Min = 134;
     nmUsrAccDisableBySta = 135;
     nmUnEncryptPwdNotAllowed = 136;
     nmSuperAccLockedByConsole = 137;
     nmSystemTimeChangedByCon = 138;
     nmSystemTimeChangedBySta = 139;
     nmVolStillActWithError = 140;
     nmRouterFalsehood = 141;
     nmServerAddressChanged = 142;
     nmExtFileNoOwnerCharge = 143;
     nmRouterConfigErrNode = 144;
     nmRouterConfigErrMyAddr = 145;
     nmNoMigratorLd = 146;
     nmNoSMLd = 147;
     nmNotEnoughRamForCompression = 148;
     nmDiskErrorCompressing = 149;
     nmUnknownErrorCompressing = 150;
     nmInsufficientSpaceForDeCompression = 151;
     nmDecompressUnknownCompressionVersion = 152;
     nmUnknownDecompressError = 153;
     nmInsufficientRAMToDecompress = 154;
     nmCompressedFileIsCorrupt = 155;
     nmStaAttemptedToUseBadPckt = 156;
     nmStaUsedABadPckt = 157;
     nmStaAttemptedToUseBadSFL = 158;
     nmStaUsedABadSFL = 159;
     nmCorruptCompFileWithName = 160;
     nmCorruptCompFileWithNameAndStation = 161;
     nmLowPriThreadsNotRun = 162;
     nmWorkToDoNotRun = 163;
     nmCompressErrorTempFileError = 164;
     nmCompressErrorLengthTotalsMismatch = 165;
     nmCompressErrorOffsetTotalsMismatch = 166;
     nmCompressErrorDataCodeCountMismatch = 167;
     nmCompressErrorLengthCountMismatch = 168;
     nmCompressErrorLargeLengthCountMismatch = 169;
     nmCompressErrorReadZeroBytesOrg = 170;
     nmCompressErrorTreeTooBig = 171;
     nmCompressErrorMatchSizeFail = 172;
     nmSignatureInvalidAlert = 173;
     nmLicenseIsInvalid = 174;
     nmDeactHotFixError = 175;
     nmUnknownDecompressErrorFN = 176;
     nmInsufficientRAMToDecompressFN = 177;
     nmDecompressUnderFreePercentage = 178;
     nmNegPktTriedLargeBuffer = 179;
     nmLoginDisabledByConsole = 180;
     nmLoginEnabledByConsole = 181;
     nmGrwStkNotAvail = 182;
     nmLicenseFileIsMissing = 183;
     nmFailedToDeletedMigratedFile = 184;
     nmNoMemForAuditing = 185;
     nmAuditFileWriteError = 186;
     nmAuditFileFull = 187;
     nmAuditFileThresholdOverflow = 188;
     nmCompressErrorReadZeroBytesInt = 189;
     nmEASpaceLimit = 190;
     nmThreadAreaNotEmpty = 191;
     nmErrMovingLogToMSEngine = 192;
     nmFaultInConsoleCmdHandler = 193;
     nmServerToServerComLinkActivated = 194;
     nmServerToServerComLinkFailure = 195;
     nmServerToServerComLinkDeact = 196;
     nmOtherServerAttemptedToSync = 197;
     nmServerToServerComLinkBrokeOK = 198;
     nmServerSyncStartingIAmSecondary = 199;
     nmBadSvrInitMsgFromOtherSvr = 200;
     nmSvrToSvrCommLinkInitFailed = 201;
     nmFailedDuringSyncWithReason = 202;
     nmCommDrvLdDuringActivateWait = 203;
     nmErrWritingStatusDump = 204;
     nmComDrvFailureOnPrimary = 205;
     nmComDrvFailureOnSecondary = 206;
     nmErrFinishingGenStatusDump = 207;
     nmSFTIIWhatToDoWithReasonString = 208;
     nmSFTIIErrorUnexpected = 209;
     nmSyncErrFromCustomServerNLM = 210;
     nmSvrLinkHasPluggedPacket = 211;
     nmSvrToBeRevived = 212;
     nmServersAreSyncPri = 213;
     nmSvrCantRouteIPXSec = 214;
     nmSrvIPXRouteInfoSec = 215;
     nmErrGivingRAMtoMS = 216;
     nmMoreRAMgivenToMS = 217;
     nmServersAreSyncSec = 218;
     nmSvrCantRouteIPXPri = 219;
     nmSrvIPXRouteInfoPri = 220;
     nmPriSvrFailedButSecDown = 221;
     nmPriSvrFailedNewPri = 222;
     nmNumMemSegsExceedLimit = 223;
     nmNumScreenExceedsLimit = 224;
     nmIOVersionMismatch = 225;
     nmOtherSvrProtectLvlNoMatch = 226;
     nmOtherSvrScrAddrMismatch = 227;
     nmIOEngNotAtSameAddr = 228;
     nmBothSvrHaveMSEng = 229;
     nmNoMSEngOnServers = 230;
     nmSecSvrMissingRAM = 231;
     nmBothSrvHaveSameIPXAddr = 232;
     nmIOEngIPXAddrMatchMSEng = 233;
     nmIOEngsMismatchRxSizes = 234;
     nmIOEngsHaveSameName = 235;
     nmNoMemForIOEngName = 236;
     nmSrvToSvrLinkBeginSync = 237;
     nmMSEngActivated = 238;
     nmMSEngActNowSyncOther = 239;
     nmIOtoMSComMisMatchUnload = 240;
     nmSFTIIIOutOfMsgCodes = 241;
     nmErrXferDumpToSystem = 242;
     nmFailureChkPrimary = 243;
     nmNoMemForOtherIOEngScr = 244;
     nmErrStarting2ndProc = 245;
     nmSrvFailureMsg = 246;
     nmSecIOEngSupModNotLd = 247;
     nmMSLBdNumHasConn = 248;
     nmSecSvrLANIsBetter = 249;
     nmIPXrtnStatusPckts = 250;
     nmIPXnotRtnStatChkPckts = 251;
     nmIPXnotRtnStatLANJam = 252;
     nmFailReasonByOtherSrv = 253;
     nmIPXMayBeTooSlowForSecSrv = 254;
     nmIPXToOtherSrvTooManyHops = 255;
     nmIPXappearsDown = 256;
     nmIPXFoundRouteToOtherSrv = 257;
     nmIPXLostRoute = 258;
     nmSecSrvGoingToDie = 259;
     nmPriSrcDyingTimerStart = 260;
     nmPriSrvDying = 261;
     nmIPXInternetIsJammed = 262;
     nmIPXNewRouteToSecSvr = 263;
     nmSrvsSyncing = 264;
     nmFSHookRegistered = 265;
     nmFSHookDeRegistered = 266;
     nmIOEngCantBorrowMemory = 267;
     nmDecompressNoCompressionOnVolume = 268;
     nmMkProcessUsingTooSmallStk = 269;
     nmQueueEventReportNoMemory = 270;
     nmServerPartMirrorNotSync = 271;
     nmStaWithoutRightsConsoleRPC = 272;
     nmAuditOverflowFileThreshold = 273;
     nmAuditOverflowFileFull = 274;
     nmSwitchStacksGrwStk = 275;
     nmConsoleCommandProcRestarted = 276;
     nmGrowableStackGrew = 278;
     nmOtherSvrIOLogSpaceNoMatch = 279;
     nmDFSLogicalStackRead = 280;
     nmDFSLogicalStackWrite = 281;
     nmSecureEraseFailure = 282;
     nmDropBadPktBurstConn = 283;
     nmOutOfIPXSockets = 284;
     nmVolumeObjectIDChanged = 285;
     nmAbendRecovery = 286;
     nmOpLockTimeout = 287;
     nmAbendRecovered = 288;
     nmUnknownSetCmd = 289;    { starting with NetWare 5...  }
     nmAddressSpaceProtectionFault = 290;
     nmAddressSpaceFailedToRestart = 291;
     nmAddressSpaceRestarted = 292;
     nmCorruptMemoryNodeDetected = 293;
     nmAddressSpaceCleanupFailure = 294;
     nmInvalidParameter = 295;
     nmInvalidObjectHandle = 296;
     nmNullPointer = 297;
     nmVolDmtMedDmt = 298;
     nmVolDmtmedChgd = 299;
     nmAccDelByUsrActConn = 300;
     nmResourcesRelErr = 301;
     nmDemoVersion = 302;
     nmDemoVersionTooLong = 303;
     nmLicenseReSellerFileIsMissing = 304;
     nmLicenseUpgradeIsMissing = 305;
     nmLicenseVersionInvalid = 306;
     nmLicenseProductInvalid = 307;
     nmLicenseNoMoreFiles = 308;
     nmLicensePIDInvalid = 309;
     nmLicenseContentInalid = 310;
     nmLicenseBadUpgrade = 311;
     nmLicensePrevMaxConnMisMatch = 312;
     nmLicenseContentResellerBad = 313;
     nmLicenseSNMisMatch = 314;
     nmLicenseUIDMisMatch = 315;
     nmLicenseOpenError = 316;
     nmLicenseCompanionErr = 317;
     nmLicenseSNUpgradeMisMatch = 318;
     nmLicenseUnableToRemMSL = 319;
     nmLicenseUnableToRemULF = 320;
     nmLicenseUnableToRemRLF = 321;
     nmLicenseUnableToGetFileSize = 322;
     nmLicenseUnkLicenseType = 323;
     nmLicenseReadErr = 324;
     nmLicenseFileSizeMisMatch = 325;
     nmLicenseDupServerLic = 326;
     nmLicenseNeedUpgrade = 327;
     nmLicenseMirrorNeedUpgrade = 328;
     nmLicenseDupLicDiscovered = 329;
     nmLicenseDupLicDiscoveredDel = 330;
     nmLicenseCpyRightViolated = 331;
     nmLicenseExpired = 332;
     nmVolDmtDevMedChgd = 333;
     nmVolDmtDevMedDmt = 334;
     nmInsMediaAckDS = 335;
     nmInsMediaAckMag = 336;
     nmInsMediaAbortedDS = 337;
     nmInsMediaAbortedMag = 338;
     nmRemMediaAckDS = 339;
     nmRemMediaAckMag = 340;
     nmRemMediaAbortDS = 341;
     nmRemMediaAbortMag = 342;
     nmInsMediaIntoDS = 343;
     nmInsMediaIntoMag = 344;
     nmRemMediaFromDS = 345;
     nmRemMediaFromMag = 346;
     nmServAddr = 347;
     nmSwapInError = 348;
     nmSwapOutError = 349;
     nmAveragePageInThresholdExceeded = 350;
     nmIllegalRequest = 351;
     nmTTSThrottleDelayError = 352;
     nmTTSLackOfResourcesError = 353;
     nmTTSLackOfResourcesNoReason = 354;
     nmDelayedWTDNotRunning = 355;
     nmInvalidCharacterInName = 356;
  { starting with NetWare 6...  }
     nmMPKBadThreadState = 357;
     nmPoolSeriousError = 358;
     nmPoolSeriousReadError = 359;
     nmVolSeriousError = 360;
     nmVolSeriousReadError = 361;
     nmVolDeactSeriousIOError = 362;
     nmVolDeactSeriousNonIOError = 363;
     nmPoolDeactSeriousIOError = 364;
     nmPoolDeactSeriousNonIOError = 365;
     nmTaskZeroCheck = 366;
  { values for 'alertLocus' in EventNetWareAlertStruct_t...  }
     LOCUS_UNKNOWN = 0;
     LOCUS_MEMORY = 1;
     LOCUS_FILESYSTEM = 2;
     LOCUS_DISKS = 3;
     LOCUS_LANBOARDS = 4;
     LOCUS_COMSTACKS = 5;
     LOCUS_TTS = 7;
     LOCUS_BINDERY = 8;
     LOCUS_STATION = 9;
     LOCUS_ROUTER = 10;
     LOCUS_LOCKS = 11;
     LOCUS_KERNEL = 12;
     LOCUS_UPS = 13;
     LOCUS_SERVICE_PROTOCOL = 14;
     LOCUS_SFT_III = 15;
     LOCUS_RESOURCE_TRACKING = 16;
     LOCUS_NLM = 17;
     LOCUS_OS_INFORMATION = 18;
     LOCUS_CACHE = 19;
  { values for 'alertClass' in EventNetWareAlertStruct_t...  }
     CLASS_UNKNOWN = 0;
     CLASS_OUT_OF_RESOURCE = 1;
     CLASS_TEMP_SITUATION = 2;
     CLASS_AUTHORIZATION_FAILURE = 3;
     CLASS_INTERNAL_ERROR = 4;
     CLASS_HARDWARE_FAILURE = 5;
     CLASS_SYSTEM_FAILURE = 6;
     CLASS_REQUEST_ERROR = 7;
     CLASS_NOT_FOUND = 8;
     CLASS_BAD_FORMAT = 9;
     CLASS_LOCKED = 10;
     CLASS_MEDIA_FAILURE = 11;
     CLASS_ITEM_EXISTS = 12;
     CLASS_STATION_FAILURE = 13;
     CLASS_LIMIT_EXCEEDED = 14;
     CLASS_CONFIGURATION_ERROR = 15;
     CLASS_LIMIT_ALMOST_EXCEEDED = 16;
     CLASS_SECURITY_AUDIT_INFO = 17;
     CLASS_DISK_INFORMATION = 18;
     CLASS_GENERAL_INFORMATION = 19;
     CLASS_FILE_COMPRESSION = 20;
     CLASS_PROTECTION_VIOLATION = 21;
     CLASS_VIRTUAL_MEMORY = 22;
  { values for 'alertSeverity' in EventNetWareAlertStruct_t...  }
  { counters reached thresholds          }
     SEVERITY_INFORMATIONAL = 0;
  { config errors, etc. no damage        }
     SEVERITY_WARNING = 1;
  { hot fix disk, etc. worked around     }
     SEVERITY_RECOVERABLE = 2;
  { disk mirror failure, etc. fix-up attempted  }
     SEVERITY_CRITICAL = 3;
  { resource fatally affected--shut down }
     SEVERITY_FATAL = 4;
  { cannot complete--result unknown      }
     SEVERITY_OPERATION_ABORTED = 5;
  { cannot complete--will not affect OS  }
     SEVERITY_NONOS_UNRECOVERABLE = 6;
  { values for 'targetNotificationBits' in EventNetWareAlertStruct_t...  }
     NOTIFY_CONNECTION_BIT = $00000001;
     NOTIFY_EVERYONE_BIT = $00000002;
     NOTIFY_ERROR_LOG_BIT = $00000004;
     NOTIFY_CONSOLE_BIT = $00000008;
  { use if alert to be queued  }
     NOTIFY_QUEUE_MESSAGE = $10000000;
     NOTIFY_DONT_NOTIFY_NMAGENT = $80000000;

type
  TnwAlertDataFreeProc = procedure (nwAlertDataPtr:pointer);cdecl;
  PNetWareAlertStructure  = ^TNetWareAlertStructure;
  TNetWareAlertStructure = record
    pNetworkManagementAttribute  : pointer;
    nwAlertFlags,
    nwTargetStation,
    nwTargetNotificationBits,
    nwAlertID,
    nwAlertLocus,
    nwAlertClass,
    nwAlertSeverity              : longint;
    nwAlertDataPtr               : pointer;
    nwAlertDataFree              : TnwAlertDataFreeProc;
    nwControlString              : pchar;
    nwControlStringMessageNumber : longint;
  end;

{$ifndef INCLUDED_FROM_SYSTEM}
procedure NetWareAlert(nlmHandle      : TNLMHandle;
                       nwAlert        : PNetWareAlertStructure;
                       parameterCount : longint;
                       args           : array of const); cdecl; external system_nlm name 'NetWareAlert';
{$endif}

procedure NetWareAlert(nlmHandle      : TNLMHandle;
                       nwAlert        : PNetWareAlertStructure;
                       parameterCount : longint); cdecl; external system_nlm name 'NetWareAlert';

type

   PEventSecurityChange_t = ^EventSecurityChange_t;
   EventSecurityChange_t = record
        objectID : dword;
        equivalentID : dword;
        changeFlags : dword;
     end;

   PEventTrusteeChange_t = ^EventTrusteeChange_t;
   EventTrusteeChange_t = record
        objectID : dword;
        entryID : dword;
        volumeNumber : longint;
        changeFlags : dword;
        newRights : dword;
     end;

   PEventModifyDirEntry_t = ^EventModifyDirEntry_t;
   EventModifyDirEntry_t = record
        primaryDirectoryEntry : dword;
        nameSpace : longint;
        modifyBits : dword;
        modifyVector : pointer;
        volumeNumber : longint;
        directoryEntry : dword;
     end;

   PEventProtocolBind_t = ^EventProtocolBind_t;
   EventProtocolBind_t = record
        boardNumber : longint;
        protocolNumber : longint;
     end;

   PEventDateMigrationInfo_t = ^EventDateMigrationInfo_t;
   EventDateMigrationInfo_t = record
        FileSystemTypeID : dword;
        Volume : longint;
        DOSDirEntry : dword;
        OwnerDirEntry : dword;
        OwnerNameSpace : longint;
        OwnerFileName : array[0..(1 + 255)-1] of char;
     end;

   PEventQueueNote_t = ^EventQueueNote_t;
   EventQueueNote_t = record
        QAction : longint;
        QID : dword;
        QName : array[0..(49 + 1)-1] of char;
     end;

   PEventNetWareAlert_t = ^EventNetWareAlert_t;
   EventNetWareAlert_t = record
        alertFlags : dword;
        alertId : dword;
        alertLocus : dword;
        alertClass : dword;
        alertSeverity : dword;
        targetStationCount : longint;
        targetStationList : array[0..31] of dword;
        targetNotificationBits : dword;
        alertParmCount : longint;
        alertDataPtr : pointer;
        NetWorkManagementAttributePointer : pointer;
        alertUnused : array[0..1] of dword;
        alertControlStringMessageNumber : longint;
        alertControlString : array[0..255] of char;
        alertParameters : array[0..(256 + 256)-1] of char;
        alertModuleName : array[0..35] of char;
        alertModuleMajorVersion : longint;
        alertModuleMinorVersion : longint;
        alertModuleRevision : longint;
     end;

   PEventBinderyObject_t = ^EventBinderyObject_t;
   EventBinderyObject_t = record
        EventObjectSignature : dword;
        ObjectID : dword;
        ObjectType : dword;
     end;

function DSAllocateEventTag(signature:dword):pointer;cdecl;external libc_nlm name 'DSAllocateEventTag';

type

   PEventDSObject_t = ^EventDSObject_t;
   EventDSObject_t = record
        EventObjectSignature : dword;
        EventType : dword;
        entry : pointer;
     end;

   PEventCloseFileInfo_t = ^EventCloseFileInfo_t;
   EventCloseFileInfo_t = record
        fileHandle : dword;
        station : longint;
        task : longint;
        fileHandleFlags : dword;
        completionCode : longint;
     end;

   PEventCheckKeyInfo_t = ^EventCheckKeyInfo_t;
   EventCheckKeyInfo_t = record
        structVersion : dword;
        keyData : dword;
        scrID : scr_t;
     end;
{
** A consumer registering for an event sets this flag in the event type to
** denote that the consumer is multiprocessor safe. This allows us to
** distinguish multiprocessor safe consumers from unsafe ones.
 }
{
** Values for fields of EventNetWareAlertStruct_t.
 }
{
** Values for 'alertID' in EventNetWareAlertStruct_t comprised of two parts,
** the ModuleNumber (upper 16 bits) and AlertNumber (lower 16 bits).
** AlertNumber is under the control of the module specified by ModuleNumber.
**
** ModuleNumber specifies which module is generating the alert and AlertNumber
** can then be used for a specific alert generated by that module.
**
** Any ModuleNumber in the range 0x8000xxxx to 0xFFFFxxxx. Range 0x0001xxxx
** through 0x7fffxxxx is reserved for Novell. Value 0x0000xxxx is considered
** invalid and is used for all legacy alerts.
 }
{ allotted ModuleNumbers for 'alertID' in EventNetWareAlertStruct_t...  }
{
** OS-defined AlertNumber values for 'alertID' in EventNetWareAlertStruct_t
** structure. }

   Pevent_handle_t = ^event_handle_t;
   event_handle_t = longint;

   Report_t = procedure (parm:pointer; userParm:pointer);cdecl;

   Warn_t = function (printf:pointer; parm:pointer; userParm:pointer):longint;cdecl;

function RegisterForEventNotification(rtag:rtag_t; _type:longint; priority:longint; warn:Warn_t; report:Report_t;
           userParm:pointer):event_handle_t;cdecl;external system_nlm name 'RegisterForEventNotification';
function UnRegisterEventNotification(handle:event_handle_t):longint;cdecl;external system_nlm name 'UnRegisterEventNotification';
function CanEventBlock(_type:longint):longint;cdecl;external system_nlm name 'CanEventBlock';
function CheckForRegisteredEvent(_type:longint):longint;cdecl;external system_nlm name 'CheckForRegisteredEvent';
function EventCheck(_type:longint; printf:pointer; parm:pointer):longint;cdecl;external system_nlm name 'EventCheck';
function EventReport(_type:longint; parm:pointer):longint;cdecl;external system_nlm name 'EventReport';


{ server interfaces...  }
{ ShutdownServer() 'flags'...  }

    const
       NW_POST65_MAX_CMDLINE_LEN = 2048 + 1;
       SHUTDOWN_RESET            = $00000001;   { ShutdownServer() 'flags'...  }
       SHUTDOWN_POWEROFF         = $00000002;   { unimplemented }


procedure RestartServer(commandLine:Pchar);cdecl;external system_nlm name 'RestartServer';
function ShutdownServer(scrID:scr_t; forceDown:byte; alternateMessage:Pchar; flags:dword):longint;cdecl;external system_nlm name 'ShutdownServer';
function ShutdownServer(scrID:scr_t; forceDown:boolean; alternateMessage:Pchar; flags:dword):longint;cdecl;external system_nlm name 'ShutdownServer';
function StopServer(scrID:scr_t; forceDown:byte; reserved1:dword; reserved2:pointer; alternateMessage:Pchar;
           reserved3:dword):longint;cdecl;external system_nlm name 'StopServer';
function StopServer(scrID:scr_t; forceDown:boolean; reserved1:dword; reserved2:pointer; alternateMessage:Pchar;
           reserved3:dword):longint;cdecl;external system_nlm name 'StopServer';

{ resource tag interfaces...  }
const
  AllocSignature               = $54524C41;
  BreakpointSignature          = $54504B42;
  ConsoleCommandSignature      = $4D4F4343;
  CommandLineServicesSignature = $5043574E;
  DebugCommandSignature        = $53504344;
  DebuggerSignature            = $47554244;
  EventSignature               = $544E5645;
  ScreenSignature              = $4E524353;
  SettableParameterSignature   = $4D505453;
  RTAG_DESC_LEN                = 63;


type
   Cleanup_t = procedure (rTag:rtag_t; forceFlag:longint);cdecl;

   Prtag_info = ^rtag_info;
   rtag_info = record
        tag         : rtag_t;
        signature   : dword;
        NLMHandle   : TNLMHandle;
        use_count   : longint;
        description : array[0..(63 + 1)-1] of char;
     end;
   rtag_info_t  = rtag_info;
   Prtag_info_t = ^rtag_info_t;


function AllocateResourceTag(NLMHandle:TNLMHandle; description:Pchar; signature:dword):rtag_t;cdecl;external system_nlm name 'AllocateResourceTag';
function GetModuleResourceTagInfo(rTag:rtag_t; NLMHandle:TNLMHandle; info:Prtag_info_t):longint;cdecl;external system_nlm name 'GetModuleResourceTagInfo';
function ReturnResourceTag(rTag:rtag_t; displayErrorsFlag:longint):longint;cdecl;external system_nlm name 'ReturnResourceTag';
function RegisterTrackedResource(NLMHandle:TNLMHandle; signature:dword; cleanup:Cleanup_t; description:Pchar):longint;cdecl;external system_nlm name 'RegisterTrackedResource';
function UnRegisterTrackedResource(NLMHandle:TNLMHandle; signature:dword):longint;cdecl;external system_nlm name 'UnRegisterTrackedResource';
function AddPollingProcedureRTag(proc:TCDeclProcedure ; rTag:rtag_t):longint;cdecl;external system_nlm name 'AddPollingProcedureRTag';
procedure RemovePollingProcedure(proc:TCDeclProcedure);cdecl;external system_nlm name 'RemovePollingProcedure';

{ NetWare-loader interfaces...  }
const
  MAX_SYMBOL_NAME_LEN = 80;

function ExportPublicObject(NLMHandle:TNLMHandle; name:Pchar; _object:pointer):longint;cdecl;external system_nlm name 'ExportPublicObject';
function ImportPublicObject(NLMHandle:TNLMHandle; name:Pchar):pointer;cdecl;external system_nlm name 'ImportPublicObject';

    const
       LO_NORMAL = $00000000;
       LO_PROTECT = $00000002;
       LO_LOAD_LOW = $00000020;
       LO_RETURN_HANDLE = $00000040;
       LO_LOAD_SILENT = $00000080;
       LO_RESTART = $00000200;
       LO_DONT_DISPLAY_ERROR = $00002000;
       LO_MEMORY_DEBUG = $00010000;          { debug only; no production use  }
       LO_RELAXED_MEMORY_DEBUG = $00020000;  { debug only; no production use  }
       ERR_LOADER_COULD_NOT_FIND_FILE = 1;   { error returns from LoadModule()  }
       ERR_LOADER_ERROR_READING_FILE = 2;
       ERR_LOADER_NOT_NLM_FILE_FORMAT = 3;
       ERR_LOADER_WRONG_NLM_FILE_VERSION = 4;
       ERR_LOADER_REENTRANT_INITIALIZE_FAILURE = 5;
       ERR_LOADER_CAN_NOT_LOAD_MULTIPLE_COPIES = 6;
       ERR_LOADER_ALREADY_IN_PROGRESS = 7;
       ERR_LOADER_NOT_ENOUGH_MEMORY = 8;
       ERR_LOADER_INITIALIZE_FAILURE = 9;
       ERR_LOADER_INCONSISTENT_FILE_FORMAT = 10;
       ERR_LOADER_CAN_NOT_LOAD_AT_STARTUP = 11;
       ERR_LOADER_AUTO_LOAD_MODULES_NOT_LOADED = 12;
       ERR_LOADER_UNRESOLVED_EXTERNAL = 13;
       ERR_LOADER_PUBLIC_ALREADY_DEFINED = 14;
       ERR_LOADER_XDC_DATA_ERROR = 15;
       ERR_LOADER_NOT_KERNEL = 16;
       ERR_LOADER_NIOS_ONLY_NLM = 17;
       ERR_LOADER_ADDRESS_SPACE_CREATION = 18;
       ERR_LOADER_INITIALIZE_FAULT = 19;
type
  TLoadModulePath = record
    case longint of
      0 : (NLMHandle : TNLMHandle);
      1 : (path      : array [0..1024] of char);
    end;


function GetNLMNames(NLMHandle:TNLMHandle; name:Pchar; description:Pchar):longint;cdecl;external system_nlm name 'GetNLMNames';
procedure KillMe(NLMHandle:TNLMHandle);cdecl;external system_nlm name 'KillMe';
function ReturnMessageInformation(NLMHandle:TNLMHandle; table:PPPchar; stringCount:Psize_t; languageID:Plongint; helpFile:pointer):longint;cdecl;external system_nlm name 'ReturnMessageInformation';
function SetAutoUnloadFlag(NLMHandle:TNLMHandle):longint;cdecl;external system_nlm name 'SetAutoUnloadFlag';

function UnImportPublicObject(NLMHandle:TNLMHandle; name:Pchar):longint;cdecl;external system_nlm name 'UnImportPublicObject';
function AddSearchPathAtEnd(scrID:scr_t; path:Pchar):longint;cdecl;external system_nlm name 'AddSearchPathAtEnd';
function DeleteSearchPath(scrID:scr_t; searchPathNumber:longint):longint;cdecl;external system_nlm name 'DeleteSearchPath';
function GetSearchPathElement(index:longint; isDOSFlag:Pdword; path:Pchar):longint;cdecl;external system_nlm name 'GetSearchPathElement';
function GetSearchPathElement(index:longint; var isDOSFlag:dword; path:Pchar):longint;cdecl;external system_nlm name 'GetSearchPathElement';
function GetSearchPathElement(index:longint; var isDOSFlag:longint; path:Pchar):longint;cdecl;external system_nlm name 'GetSearchPathElement';
function InsertSearchPath(scrID:scr_t; searchPathNumber:longint; path:Pchar):longint;cdecl;external system_nlm name 'InsertSearchPath';
function LoadModule(scrID:scr_t; path:Pchar; options:dword):longint;cdecl;external system_nlm name 'LoadModule';
function LoadModule(scrID:scr_t; var path:TLoadModulePath; options:dword):longint;cdecl;external system_nlm name 'LoadModule';
function UnloadModule(scrID:scr_t; commandline:Pchar):longint;cdecl;external system_nlm name 'UnloadModule';
{ memory management interfaces }
function _Alloc(size:size_t; rTag:rtag_t):pointer;cdecl;external system_nlm name 'Alloc';
function Alloc(size:size_t; rTag:rtag_t):pointer;cdecl;external system_nlm name 'Alloc';
function _AllocSleepOK(size:size_t; rTag:rtag_t; slept:Plongint):pointer;cdecl;external system_nlm name 'AllocSleepOK';
function AllocSleepOK(size:size_t; rTag:rtag_t; slept:Plongint):pointer;cdecl;external system_nlm name 'AllocSleepOK';
function _AllocSleepOK(size:size_t; rTag:rtag_t; var slept:longint):pointer;cdecl;external system_nlm name 'AllocSleepOK';
function AllocSleepOK(size:size_t; rTag:rtag_t; var slept:longint):pointer;cdecl;external system_nlm name 'AllocSleepOK';
procedure NWGarbageCollect(NLMHandle:TNLMHandle);cdecl;external system_nlm name 'NWGarbageCollect';
function NWGetAvailableMemory:size_t;cdecl;external system_nlm name 'NWGetAvailableMemory';
function NWGetPageSize:size_t;cdecl;external system_nlm name 'NWGetPageSize';
function NWMemorySizeAddressable(addr:pointer; size:size_t):longint;cdecl;external system_nlm name 'NWMemorySizeAddressable';
function _ReallocSleepOK(addr:pointer; size:size_t; rTag:rtag_t; slept:Plongint):pointer;cdecl;external system_nlm name 'ReallocSleepOK';
function _ReallocSleepOK(addr:pointer; size:size_t; rTag:rtag_t; var slept:longint):pointer;cdecl;external system_nlm name 'ReallocSleepOK';
function ReallocSleepOK(addr:pointer; size:size_t; rTag:rtag_t; slept:Plongint):pointer;cdecl;external system_nlm name 'ReallocSleepOK';
function ReallocSleepOK(addr:pointer; size:size_t; rTag:rtag_t; var slept:longint):pointer;cdecl;external system_nlm name 'ReallocSleepOK';
procedure _Free(addr:pointer);cdecl;external system_nlm name 'Free';

 const
       CMD_CONFIG_INFO     = $00000001;
       CMD_CONVERT_UPPER   = $00000002;   { convert command line to upper case?  }
       CMD_SERVER_RUNNING  = $00000004;   { server need to be running?  }
       CMD_LEGAL_SERVER    = $00000008;   { command legal on regular server?  }
       CMD_HIDDEN_CMD      = $00200000;   { don't display this command  }
       CMD_SUB_CMDS_AVAIL  = $00100000;   { command has sub commands  }
       CMD_NO_CMD_CHAIN    = $00010000;   { disallow chaining of command keyword  }
       CMD_PASS_ON_ERROR   = $00020000;   { ignore error  }
       CMD_ANY_PROCESS     = $80000000;   { can run on any process with keyboard  }
    { keyword flags for RegisterCommand()...  }
       CMD_MSG_NUMBER      = $80000000;   { pointer to keyword is number  }
       CMD_LENGTH_PREC     = $40000000;   { keyword is length-preceeded  }
    { insertion flags for RegisterCommand()...  }
       CMD_INSERT_AT_HEAD  = $00000001;   { insert at head  }
       CMD_INSERT_AT_TAIL  = $00000002;   { insert at tail  }
       CMD_PERM_POSITION   = $80000000;   { leave in place (head or tail)  }
    { valid error returns from command handler...  }
       CMD_CMD_EXECUTED    = $00000000;   { processed, go to next handler  }
       CMD_HALT_CMD_CHAIN  = $70000000;   { processed, but don't go on to next  }
       CMD_BAD_CMD_SYNTAX  = $70000010;   { not processed, syntax error  }
       CMD_NOT_RUNNING     = $70000011;   { won't execute until server up  }
       CMD_LINE_FAULT      = $70000012;   { command line fault--no error display  }
       CMD_BAD_MOD_HANDLE  = $70000021;   { NLM handle is invalid  }
       CMD_BAD_RTAG        = $70000022;   { invalid resource tag  }
       CMD_BAD_KEY         = $70000023;   { keyword is invalid  }
       CMD_RTAG_AND_MOD    = $70000024;   { resource tag doesn't match NLM  }
       CMD_NO_HANDLER      = $70000025;   { handler is missing  }
       CMD_KEY_TOO_LONG    = $70000026;   { keyword is too long  }
       CMD_INVAL_PERM      = $70000027;   { invalid syntax to make permanent  }
       CMD_NO_MEMORY       = $70000028;   { unable to allocate memory  }
       CMD_NOT_REGISTERED  = $70000029;   { unregistered command  }
       CMD_HAS_CHAIN       = $7000002A;   { command has a chain  }
       CMD_CANT_MAKE_HEAD  = $7000002B;   { cannot make command permanent head  }
       CMD_CANT_MAKE_TAIL  = $7000002C;   { cannot make command permanent tail  }
       CMD_PASS_TO_NEXT    = $7000002D;   { not processed, go to next handler  }
       CMD_PRIV_ON_ALT     = $7000002E;   { no privilege on alternate handler  }
       CMD_STOP_CMDS       = $7000002F;   { system no longer parsing commands  }
    { simplified versions of returns from command handler...  }
       CMD_PROCESSED_OK    = CMD_HALT_CMD_CHAIN;
       CMD_CHAIN_NEXT_CMD  = CMD_CMD_EXECUTED;
       CMD_SYNTAX_ERROR    = CMD_BAD_CMD_SYNTAX;
       CMD_NOT_MY_COMMAND  = CMD_PASS_TO_NEXT;
    { command handler function codes...  }
       CMD_HELP_ON_CMD     = $00000000;
       CMD_GET_SUB_CMDS    = $00000001;
       CMD_PROCESS_CMD     = $00000002;
       //CMD_MAX_HELP_CMDS = ProcessCommand;
    { error codes...  }
       ERR_INVALID_MODULE     = $00000001;
       ERR_INVALID_RTAG       = $00000002;
       ERR_INVALID_KEYWORD    = $00000003;
       ERR_MODULE_RTAG_MIX    = $00000004;
       ERR_MISSING_HANDLER    = $00000005;
       ERR_KEYWORD_TOO_LONG   = $00000006;
       ERR_INVALID_REQUEST    = $00000007;
       ERR_OUT_OF_MEMORY      = $00000008;
       ERR_FAILED_TO_REGISTER = $00000009;
       ERR_ALREADY_REGISTERED = $0000000A;
       ERR_CANT_GRANT_TOP     = $0000000B;
       ERR_CANT_GRANT_END     = $0000000C;

function SizeOfAllocBlock(addr:pointer):size_t;cdecl;external system_nlm name 'SizeOfAllocBlock';

type
   CommandHandler_t = function (funcCode:longint; scrID:pointer; command:Pchar; upperCaseCommand:Pchar; callerReference:pointer):longint;cdecl;


function DeRegisterCommand(NLMHandle:TNLMHandle; rTag:rtag_t; keywordFlags:dword; keyword:Pchar):longint;cdecl;external system_nlm name 'DeRegisterCommand';

function RegisterCommand(NLMHandle:TNLMHandle; rTag:rtag_t; keywordFlags:dword; keyword:Pchar; handlerFlags:dword;
           insertionFlags:dword; handler:CommandHandler_t; callerReference:pointer):longint;cdecl;external system_nlm name 'RegisterCommand';
{ legacy command parsing; uses ConsoleCommandSignature...  }

type
   TCommandParserFunc = function (scrID:scr_t; commandline:Pchar):longint;cdecl;

{ allocate with ConsoleCommandSignature  }

   PCommandParserStructure = ^TCommandParserStructure;
   TCommandParserStructure = record
        link   : pointer;
        case longint of
          0 : (parser : TCommandParserFunc; rTag : rtag_t);
          1 : (parseRoutine : TCommandParserFunc; rTag2 : rtag_t);
     end;
   TCommandParser = TCommandParserStructure;
   PCommandParser = PCommandParserStructure;

const
  HANDLEDCOMMAND  = 0;
  NOTMYCOMMAND    = 1;

function ParseCommand(commandLine:Pchar):longint;cdecl;external system_nlm name 'ParseCommand';
function RegisterConsoleCommand(cmdParser:PCommandParser):longint;cdecl;external system_nlm name 'RegisterConsoleCommand';
function RegisterConsoleCommand(var cmdParser:TCommandParser):longint;cdecl;external system_nlm name 'RegisterConsoleCommand';
function UnRegisterConsoleCommand(cmdParser:PCommandParser):longint;cdecl;external libc_nlm name 'UnRegisterConsoleCommand';
function UnRegisterConsoleCommand(var cmdParser:TCommandParser):longint;cdecl;external libc_nlm name 'UnRegisterConsoleCommand';

    const
       SP_TYPE_NUMBER = 0;
    { 'value' points to DWORD (0 or !0) }
       SP_TYPE_BOOLEAN = 1;
       SP_TYPE_TICKS = 2;
       SP_TYPE_BLOCK_SHIFT = 3;
    { [+|-]hh:mm:ss converted to seconds  }
       SP_TYPE_TIME_OFFSET = 4;
    { 'value' points to char buffer  }
       SP_TYPE_STRING = 5;
       SP_TYPE_TRIGGER = 6;
    { settable parameter flags...  }
       SP_STARTUP_ONLY = $01;
       SP_HIDE = $02;
       SP_ADVANCED = $04;
       SP_STARTUP_OR_LATER = $08;
    { can't be done on secured console  }
       SP_NOT_SECURED_CONSOLE = $10;
    { lock console RPC from changing value  }
       SP_RPC_LOCKOUT = $20;
    { settable parameter categories...  }
       SP_COMMUNICATIONS = 0;
       SP_MEMORY = 1;
       SP_FILE_CACHE = 2;
       SP_DIR_CACHE = 3;
       SP_FILE_SYSTEM = 4;
       SP_LOCKS = 5;
       SP_TRANS_TRACKING = 6;
       SP_DISK = 7;
       SP_TIME = 8;
       SP_NCP = 9;
    { recommended most common  }
       SP_MISCELLANEOUS = 10;
       SP_ERRORS = 11;
       SP_DIRECTORY_SERVICES = 12;
       SP_MULTIPROCESSOR = 13;
    { type depends on 'type' field  }
    { for parameter name  }
    { for parameter description  }


type

   Psettableparms_t = ^Tsettableparms;
   Tsettableparms = record
        link        : pointer;
        value       : pointer;
        rTag        : rtag_t;
        name        : Pchar;
        _type       : byte;
        flags       : byte;
        category    : byte;
        reserved    : byte;
        lower_limit : dword;
        upper_limit : dword;
        callback    : procedure (oldValue:dword);cdecl;
        description : Pchar;
        msg_namenum : word;
        msg_descnum : word;
     end;
    Psettableparms = Psettableparms_t;

function RegisterSetableParameter(setparms:Psettableparms_t):longint;cdecl;external system_nlm name 'RegisterSetableParameter';
function RegisterSetableParameter(var setparms:Tsettableparms):longint;cdecl;external system_nlm name 'RegisterSetableParameter';
function DeRegisterSetableParameter(setparms:Psettableparms_t):longint;cdecl;external system_nlm name 'DeRegisterSetableParameter';
function DeRegisterSetableParameter(var setparms:Tsettableparms):longint;cdecl;external system_nlm name 'DeRegisterSetableParameter';

function GetSetableParameterValue(slot:longint; name:Pchar; value:pointer):longint;cdecl;external system_nlm name 'GetSetableParameterValue';
function GetSetableParameterValue(slot:longint; name:Pchar; var value):longint;cdecl;external system_nlm name 'GetSetableParameterValue';

function ScanSetableParameters(scanCategory:longint; scanSequence:Pdword; name:Pchar; _type:Plongint; flags:Pdword;
           category:Plongint; description:pointer; value:pointer; lowerLimit:Plongint; upperLimit:Plongint):longint;cdecl;external system_nlm name 'ScanSetableParameters';
function ScanSetableParameters(scanCategory:longint; var scanSequence:dword; name:Pchar; var _type:longint; var flags:dword;
           var category:longint; var description, value; var lowerLimit,upperLimit:longint):longint;cdecl;external system_nlm name 'ScanSetableParameters';

function SetSetableParameterValue(slot:longint; name:Pchar; newValue:pointer):longint;cdecl;external system_nlm name 'SetSetableParameterValue';
function SetSetableParameterValue(slot:longint; name:Pchar; var newValue):longint;cdecl;external system_nlm name 'SetSetableParameterValue';
{ NLM start-up synchronization...  }
procedure SynchronizeStart;cdecl;external system_nlm name 'SynchronizeStart';
{ message table loading...  }
function LoadLanguageMessageTable(table:PPPchar; count:Plongint; languageID:Plongint):longint;cdecl;external system_nlm name 'LoadLanguageMessageTable';
{ timer interfaces...  }
function GetHighResolutionTimer:dword;cdecl;external system_nlm name 'GetHighResolutionTimer';
function GetSuperHighResolutionTimer:dword;cdecl;external system_nlm name 'GetSuperHighResolutionTimer';

{ spin locks for use in the kernel (not from a protected address space)...  }
type
   Pspinlock_t = ^spinlock_t;
   spinlock_t  = pointer;
   TSpinlock = spinlock_T;
   PSpinlock = Pspinlock_t;

function KernelSpinLockInit(lock:Pspinlock_t):longint;cdecl;external system_nlm name 'KernelSpinLockInit';
procedure KernelSpinLock(lock:Pspinlock_t);cdecl;external system_nlm name 'KernelSpinLock';
function KernelSpinTryLock(lock:Pspinlock_t):longint;cdecl;external system_nlm name 'KernelSpinTryLock';
procedure KernelSpinUnlock(lock:Pspinlock_t);cdecl;external system_nlm name 'KernelSpinUnlock';
function KernelSpinLockDisable(lock:Pspinlock_t):dword;cdecl;external system_nlm name 'KernelSpinLockDisable';
function KernelSpinTryLockDisable(lock:Pspinlock_t; flags:Pdword):longint;cdecl;external system_nlm name 'KernelSpinTryLockDisable';
procedure KernelSpinUnlockRestore(lock:Pspinlock_t; flags:dword);cdecl;external system_nlm name 'KernelSpinUnlockRestore';

function KernelSpinLockInit(var lock:spinlock_t):longint;cdecl;external system_nlm name 'KernelSpinLockInit';
procedure KernelSpinLock(var lock:spinlock_t);cdecl;external system_nlm name 'KernelSpinLock';
function KernelSpinTryLock(var lock:spinlock_t):longint;cdecl;external system_nlm name 'KernelSpinTryLock';
procedure KernelSpinUnlock(var lock:spinlock_t);cdecl;external system_nlm name 'KernelSpinUnlock';
function KernelSpinLockDisable(var lock:spinlock_t):dword;cdecl;external system_nlm name 'KernelSpinLockDisable';
function KernelSpinTryLockDisable(var lock:spinlock_t; flags:Pdword):longint;cdecl;external system_nlm name 'KernelSpinTryLockDisable';
procedure KernelSpinUnlockRestore(var lock:spinlock_t; flags:dword);cdecl;external system_nlm name 'KernelSpinUnlockRestore';


{ nonpreferred locale interfaces...  }
type
   Pcountryinfo_t = ^Tcountryinfo;
   Tcountryinfo = record
        infoID : byte;
        size : word;
        countryID : word;
        codePage : word;
        dateFormat : word;
        currencySymbol : array[0..4] of char;
        thousandSeparator : array[0..1] of char;
        decimalSeparator : array[0..1] of char;
        dateSeparator : array[0..1] of char;
        timeSeparator : array[0..1] of char;
        currencyFormatFlags : char;
        digitsInCurrency : char;
        timeFormat : char;
        UpperCase : procedure ;cdecl;
        dataListSeparator : array[0..1] of char;
        spare : array[0..9] of char;
     end;
   Pcountryinfo = Pcountryinfo_t;

function OSGetCodePage:longint;cdecl;external libc_nlm name 'OSGetCodePage';
procedure OSGetCountryInfo(_para1:Pcountryinfo_t);cdecl;external system_nlm name 'OSGetCountryInfo';
procedure OSGetCountryInfo(var _para1:Tcountryinfo);cdecl;external system_nlm name 'OSGetCountryInfo';

    const
       EXCEPTION_HANDLED     = 0;
       EXCEPTION_NOT_HANDLED = 1;     // chain to next handler
       { registered debugger parser returns:  }
       NEXT_DEBUG_PARSER     = -(2);  // call next debug parser
       NEXT_ALT_DEBUG_PARSER = -(1);  // call next registered debug parser
       COMMAND_HANDLED       = 0;     // call no other parser
       INTERNAL_DEBUGGER     = 1;     // pass to NetWare System Debugger


type
   Pexceptionframe = ^exceptionframe;
   exceptionframe = record
        xfReserved : array[0..6] of dword;
        xfCR3 : Pdword;
        xfEIP : dword;
        xfSystemFlags : dword;
        xfEAX : dword;
        xfECX : dword;
        xfEDX : dword;
        xfEBX : dword;
        xfESP : dword;
        xfEBP : dword;
        xfESI : dword;
        xfEDI : dword;
        xfES : array[0..1] of word;
        xfCS : array[0..1] of word;
        xfSS : array[0..1] of word;
        xfDS : array[0..1] of word;
        xfFS : array[0..1] of word;
        xfGS : array[0..1] of word;
        xfLDT : array[0..1] of word;
        xfSpecial : array[0..1] of word;
        xfNumber : dword;
        xfDescription : Pchar;
        xfFlags : dword;
        xfErrorCode : dword;
        xfPageFaultCR2 : dword;
        xfFPUState : dword;
        xfHistogram : dword;
        xfProcessorID : dword;
     end;
   xframe_t = exceptionframe;
   Pxframe_t = ^xframe_t;

   SoftBPHandler_t = function (number:longint; address:pointer; frame:Pxframe_t):longint;cdecl;
   DebugParser_t = function (scr:scr_t; command:Pchar; frame:Pxframe_t):longint;cdecl;


procedure Abend(message:Pchar);cdecl;external system_nlm name 'Abend';
function AddressOfSoftBreakpoint(number:longint):pointer;cdecl;external system_nlm name 'AddressOfSoftBreakpoint';
function AddSoftBreakpoint(addr:pointer; handler:SoftBPHandler_t):longint;cdecl;external system_nlm name 'AddSoftBreakpoint';
function CSetABreakpoint(number:longint; addr:pointer; _type:byte; length:byte):longint;cdecl;external system_nlm name 'CSetABreakpoint';
procedure EnterDebugger;cdecl;external system_nlm name 'EnterDebugger';
function GetDebuggerActiveCount:longint;cdecl;external system_nlm name 'GetDebuggerActiveCount';
function RegisterDebugCommandParser(parseRoutine:DebugParser_t; rTag:rtag_t):longint;cdecl;external system_nlm name 'RegisterDebugCommandParser';
function RemoveSoftBreakpoint(number:longint):longint;cdecl;external system_nlm name 'RemoveSoftBreakpoint';
function ReserveABreakpointRTag(_para1:rtag_t):longint;cdecl;external system_nlm name 'ReserveABreakpointRTag';
function UnRegisterDebugCommandParser(parseRoutine:DebugParser_t):longint;cdecl;external system_nlm name 'UnRegisterDebugCommandParser';
function UnReserveABreakpoint(_para1:longint):longint;cdecl;external system_nlm name 'UnReserveABreakpoint';


//?? dont know what this is: (exported by system)
//var preferredModule : pointer;cvar;external;

{ Prototypes for libraries and drivers writing their own start-up and shut-
  down code. (DllMain() is also part of this list and defined in windows.h.)
  These are not interfaces, but only prototypes for code furnished by the
  NLM application, library, driver, etc. }

function _NonAppCheckUnload:longint;cdecl;external libc_nlm name '_NonAppCheckUnload';

type TReadRoutine = function (conn:longint; fileHandle:pointer; offset,nbytes,bytesRead:Psize_t; buffer:pointer):longint; cdecl;
function _NonAppStart(NLMHandle:TNLMHandle; errorScreen:pointer; commandLine:Pchar; loadDirPath:Pchar; uninitializedDataLength:size_t;
           NLMFileHandle:pointer; readRoutineP:TReadRoutine; customDataOffset:size_t; customDataSize:size_t; messageCount:longint;
           messages:PPchar):longint;cdecl;external libc_nlm name '_NonAppStart';
procedure _NonAppStop;cdecl;external libc_nlm name '_NonAppStop';

  const
     CTX_ACTUAL_CWD = $01;
  { for set_pathname_format(), namespace appellations...  }
     SHORT_NAMES     = 0;    { 8.3 format  }
     MACINTOSH_NAMES = 1;
     NFS_NAMES       = 2;
     FTAM_NAMES      = 3;
     LONG_NAMES      = 4;    { default long-name format  }
     NT_NAMES        = 5;
  { definitions useful to fshooks.h (attribute-match) and others...  }

     ATTR_NORMAL             = $00000000;  { no read/write restrictions  }
     ATTR_READ_ONLY          = $00000001;  { read-only file }
     ATTR_HIDDEN             = $00000002;  { hidden file }
     ATTR_SYSTEM             = $00000004;  { system file }
     ATTR_EXECUTE            = $00000008;  { execute only file }
     ATTR_VOLUME_ID          = $00000008;  { file system label           }
     ATTR_DIRECTORY          = $00000010;  { subdirectory                }
     ATTR_ARCHIVE            = $00000020;  { archive file                }
     ATTR_SHARE              = $00000080;  { Sharable file               }
     ATTR_NO_SUBALLOC        = $00000800;  { don't sub allocate file     }
     ATTR_TRANS              = $00001000;  { trans'l file, TTS-usable    }
     ATTR_READAUD            = $00004000;  { read audit                  }
     ATTR_WRITAUD            = $00008000;  { write audit                 }
     ATTR_IMMPURG            = $00010000;  { immediate purge             }
     ATTR_NORENAM            = $00020000;  { rename inhibit              }
     ATTR_NODELET            = $00040000;  { delete inhibit              }
     ATTR_NOCOPY             = $00080000;  { copy inhibit                }

     ATTR_FILE_MIGRATED      = $00400000;  { file has been migrated      }
     ATTR_DONT_MIGRATE       = $00800000;  { don't migrate this file     }
     ATTR_IMMEDIATE_COMPRESS = $02000000;  { compress file immediately   }
     ATTR_FILE_COMPRESSED    = $04000000;  { file is compressed          }
     ATTR_DONT_COMPRESS      = $08000000;  { don't compress this file    }
     ATTR_CANT_COMPRESS      = $20000000;  { can't compress this file    }
     ATTR_ATTR_ARCHIVE       = $40000000;  { entry has been modified     }
  { Faster, better when getstat() or fgetstat() used with request bit map...  }
     ST_NONE        = $00000000;
     ST_FLAGS_BIT   = $00000001;
     ST_MODE_BIT    = $00000002;
     ST_GEN_BIT     = $00000004;
     ST_INO_BIT     = $00000008;
     ST_DEV_BIT     = $00000010;
     ST_RDEV_BIT    = $00000020;
     ST_SIZE_BIT    = $00000040;
     ST_BLOCKS_BIT  = $00000080;
     ST_BLKSIZE_BIT = $00000100;
     ST_NLINK_BIT   = $00000200;
     ST_UID_BIT     = $00000400;
     ST_GID_BIT     = $00000800;
     ST_BID_BIT     = $00001000;
     ST_MID_BIT     = $00002000;
     ST_ATIME_BIT   = $00004000;
     ST_MTIME_BIT   = $00008000;
     ST_CTIME_BIT   = $00010000;
     ST_BTIME_BIT   = $00020000;
     ST_STAT_BITS   = $0003FFFF;        { bits for normal stat call }
  { the following are not returned by a normal stat call }
     ST_RIGHTS_BIT  = $00040000;
     ST_NAME_BIT    = $00080000;
     ST_NS_BIT      = $00100000;        { return name in specified namespace }
  { path analysis/parsing 'type' and 'flags' arguments for [de]construct() }
     PATH_UNDEF     = $00000000;

     PATH_DOS       = PATH_UNDEF;       { indicates potential DOS path }
     PATH_UNC       = $00000001;        { double slash found at beginning }
     PATH_UNIX      = $00000002;        { forward slashes only }
     PATH_NETWARE   = $00000004;        { slash and colon followed by slashes }
     PATH_MACINTOSH = $00000008;        { only colons }
     PATH_ROOTED    = $00000010;        { starts with delimiter }
     PATH_VOLROOTED = $00000020;        { volume plus colon appears }
     PATH_EXTENSION = $00000040;        { contains period }
     PATH_HIERARCHY = $00000080;        { at least one subdirectory element }
     PATH_SHORTNAME = $00000100;        { 8.3 names only }
     PATH_LONGNAME  = $00000200;        { at least one element greater than 8.3 }
     PATH_ENDED     = $00000400;        { ends in delimiter }
     PATH_DOSDRIVE  = $00001000;        { single-letter drive, colon and path }
     PATH_MIXEDCASE = $00002000;        { at least one element in mixed case }
     PATH_DOTS      = $00004000;        { path contains dots }
     PATH_SLASH     = $00008000;        { path contains a slash }
     PATH_BACKSLASH = $00010000;        { path contains a backslash }
     PATH_COLON     = $00020000;        { path contains a colon }
     PATH_ILLEGAL   = $80000000;        { illegal character or combination }
     //PATH_MIXED = PATH_SHORT or PATH_LONG;
{     d_cdatetime = d_cdatetim.tv_sec;
     d_adatetime = d_adatetim.tv_sec;
     d_bdatetime = d_bdatetim.tv_sec;
     d_ddatetime = d_ddatetim.tv_sec;}
       FSKEY_NONE = -(1);
       FSKEY_TRAD = 0;
       FSKEY_NSS  = 1;
    { values returned by _fildes_type(): see sys/mode.h  }
    { values returned by _fs_type()...  }
    { 'fildes' is not a file                        }
       FS_NOT_FS  = $00000000;
       FS_LFS     = $00000100;  { file in local, traditional file system }
       FS_REMOTE  = $00000200;  { file in remote file system }
       FS_DOS     = $00000400;  { file in local, DOS file system }
       FS_NSS     = $00000800;  { file in Novell Storage Services }




{ for getcwdpath(), get NKS context for current working directory...  }
{ for set_pathname_format(), namespace appellations...  }
{ definitions useful to fshooks.h (attribute-match) and others...  }
{ Faster, better when getstat() or fgetstat() used with request bit map...  }
{ the following are not returned by a normal stat call                       }
{ path analysis/parsing 'type' and 'flags' arguments for [de]construct()     }
{ d_ddatetim & d_deletedID valid only in scanerasedfiles                     }
{ c.f. these fields in struct dirent...  }
{ untouched by scanerasedfiles()         }

type
   Pnwdirent = ^Tnwdirent;
   Tnwdirent = record
        d_userspec : dword;
        d_flags : dword;                         // flags for this entry
        d_type : mode_t;                         // type of entry
        d_mode : mode_t;                         // emulated file mode
        d_ino : ino_t;                           // directory entry number of d_name
        d_size : off64_t;                        // size of file
        d_spare : array[0..38] of dword;
        d_cdatetim : timespec_t;                 // creation date and time
        d_adatetim : timespec_t;                 // last access date--files only
        d_bdatetim : timespec_t;                 // last archive date and time
        d_ddatetim : timespec_t;                 // deleted date/time
        d_uid : uid_t;                           // owner id (object id)
        d_archivedID : uid_t;                    // object ID that last archived file
        d_updatedID : uid_t;                     // object ID that last updated file
        d_deletedID : uid_t;                     // deleted ID
        d_pad1 : byte;
        d_pad2 : byte;
        d_pad3 : byte;
        d_namelen : byte;                        // lenght of following name:
        d_name : array[0..(255 + 1)-1] of char;  // only portable field in this structure
     end;
   TNWDIR = Tnwdirent;
   PNWDIR = ^TNWDIR;
{ sizeof(struct nwdirent)==0x200 (512.)  }
{ extensions of unistd.h path parsing functions...  }


function deconstruct(path:Pchar; server:Pchar; volume:Pchar; directory:Pchar; name:Pchar;
           extension:Pchar; elements:Plongint; flags:Plongint):longint;cdecl;external libc_nlm name 'deconstruct';
function construct(path:Pchar; server:Pchar; volume:Pchar; directory:Pchar; name:Pchar;
           extension:Pchar; flags:longint):longint;cdecl;external libc_nlm name 'construct';
{ extensions of client.h identity functions...  }
function get_identity(pathctx:NXPathCtx_t; identity:Plongint):longint;cdecl;external libc_nlm name 'get_identity';
{ extensions of unistd.h current working directory I/O functions...  }
function getcwdpath(buf:Pchar; pathCtx:PNXPathCtx_t; flags:dword):Pchar;cdecl;external libc_nlm name 'getcwdpath';

function chdir2(path:Pchar):longint;cdecl;external libc_nlm name 'chdir2';
function setcwd(pathCtx:NXPathCtx_t):longint;cdecl;external libc_nlm name 'setcwd';
function setcwd2(pathCtx:NXPathCtx_t):longint;cdecl;external libc_nlm name 'setcwd2';
{ extensions of unistd.h file I/O functions...  }
function Fpeof(fildes:longint):longint;cdecl;external libc_nlm name 'eof';
function tell(fildes:longint):off_t;cdecl;external libc_nlm name 'tell';
function Fptell(fildes:longint):off_t;cdecl;external libc_nlm name 'tell';
{ extensions of sys/stat.h functions...  }
function fgetstat(fildes:longint; buf:Pstat; requestmap:dword):longint;cdecl;external libc_nlm name 'fgetstat';

function getstat(ctx:NXPathCtx_t; path:Pchar; buf:Pstat; requestmap:dword):longint;cdecl;external libc_nlm name 'getstat';
function fgetstat_with_namespace(fildes:longint; buf:Pstat; requestmap:dword; _namespace:longint):longint;cdecl;external libc_nlm name 'fgetstat_with_namespace';

function getstat_with_namespace(ctx:NXPathCtx_t; path:Pchar; buf:Pstat; requestmap:dword; _namespace:longint):longint;cdecl;external libc_nlm name 'getstat_with_namespace';
{ pathname format (namespace) state...  }
function set_pathname_format(newformat:longint; oldformat:Plongint):longint;cdecl;external libc_nlm name 'set_pathname_format';
{ for use with Novell Clustering...  }

function isclusteredvirtualserver(servername:Pchar):longint;cdecl;external libc_nlm name 'isclusteredvirtualserver';
{ equivalent to CLib's FileServerFileCopy()...  }
function fscopy(fildes1:longint; fildes2:longint; offset1:off64_t; offset2:off64_t; length:size_t;
           nbytes:Psize_t):longint;cdecl;external libc_nlm name 'fscopy';
{ equivalent to similarly named calls in CLib...  }

function purgeerasedfile(path:Pchar; sequence:longint):longint;cdecl;external libc_nlm name 'purgeerasedfile';


function salvageerasedfile(pathName:Pchar; sequence:longint; newFileName:Pchar):longint;cdecl;external libc_nlm name 'salvageerasedfile';

function scanerasedfiles(path:Pchar; nextEntryNumber:Plongint; deletedFileInfo:PNWDIR):longint;cdecl;external libc_nlm name 'scanerasedfiles';
function _fs_type(fildes:longint):longint;cdecl;external libc_nlm name '_fs_type';
function _fildes_type(fildes:longint):longint;cdecl;external libc_nlm name '_fildes_type';
function _fildes_from_nsskey(key:Tuint64; oflag:longint):longint;cdecl;external libc_nlm name '_fildes_from_nsskey';
function _key_from_fildes(fildes:longint; _type:Plongint; err:Plongint):Tuint64;cdecl;external libc_nlm name '_key_from_fildes';
{ fast type of a file descriptor--st_mode in fstat()...  }
{ equates to move between NKS file handles and POSIX descriptors...  }
{ derivation of POSIX descriptor from NSS open file key...  }
{ back-derivation of file system key...  }
{ types returned in back-derivation...  }
{ values returned by _fildes_type(): see sys/mode.h  }
{ values returned by _fs_type()...  }
{ attributes for NXDirAttrWin_t 'dwFileAttributes' field...  }


{ turn on 1-byte packing...  }

  const
     FILE_ATTRIBUTE_READONLY            = $00000001;
     FILE_ATTRIBUTE_HIDDEN              = $00000002;
     FILE_ATTRIBUTE_SYSTEM              = $00000004;
     FILE_ATTRIBUTE_DIRECTORY           = $00000010;
     FILE_ATTRIBUTE_ARCHIVE             = $00000020;
     FILE_ATTRIBUTE_ENCRYPTED           = $00000040;
     FILE_ATTRIBUTE_NORMAL              = $00000080;
     FILE_ATTRIBUTE_TEMPORARY           = $00000100;
     FILE_ATTRIBUTE_SPARSE_FILE         = $00000200;
     FILE_ATTRIBUTE_REPARSE_POINT       = $00000400;
     FILE_ATTRIBUTE_COMPRESSED          = $00000800;
     FILE_ATTRIBUTE_OFFLINE             = $00001000;
     FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = $00002000;


type
   PNXDirAttrDos_t = ^NXDirAttrDos_t;
   NXDirAttrDos_t = record                    { DOS/FAT32 (NX_PNF_DOS) attributes    }
        xdeHeader : NXDeHeader_t;
        xdeFid : NXFid_t;
        xdeEffectiveRights : dword;
                                              { FAT32 File System Spec., p. 22       }
        xdeAttr : dword;
        xdeCrtDate : word;
        xdeCrtTime : word;
        xdeCrtTimeTenth : word;
        xdeLastAccDate : word;
        xdeWrtDate : word;
        xdeWrtTime : word;
        xdeFileSize : dword;
        Reserved1 : dword;
        Reserved2 : dword;
     end;
{ DOS/FAT32 (NX_PNF_DOS) information.. }
{ ...including name                    }
{ maximum length is 255 characters     }

   PNXDirEnumDos_t = ^NXDirEnumDos_t;
   NXDirEnumDos_t = record
        deDosDirAttr : NXDirAttrDos_t;
        deDirMark : NXDirMark_t;
        deShortName : array[0..15] of char;
        deName : pointer;
     end;
{ Win32 (NX_PNF_WIN) attributes        }
{ see WIN32_FIND_DATA...               }
{ FILE_ATTRIBUTE_NORMAL, etc.          }
{ date and time of creation or -1      }
{ date and time of last access         }
{ date and time of last modification   }
{ date and time of last attr change    }
{ see BY_HANDLE_FILE_INFORMATION...    }
{ always 1 for FAT                     }
{ unique identifier                    }
{ CIFS Specification 0.9, 4.2.16.8...  }
{ file system block size               }
{ (currently) Ramesh-invented fields... }
{ not in Win32 docs, but exists        }
{ Boolean flag fields for CIFS         }
{ total size of extended attributes    }
{ size of compressed file           }
{ format of of compression           }

   PNXDirAttrWin_t = ^NXDirAttrWin_t;
   NXDirAttrWin_t = record
        xdeHeader : NXDeHeader_t;
        xdeFid : NXFid_t;
        xdeEffectiveRights : dword;
        xdeFileAttributes : dword;
        xdeCreateTime : Tuint64;
        xdeLastAccessTime : Tuint64;
        xdeLastWriteTime : Tuint64;
        xdeLastChangeTime : Tuint64;
        xdeFileSize : Tuint64;
        Reserved0 : dword;
        Reserved1 : dword;
        Reserved2 : dword;
        Reserved3 : dword;
        xdeNumberOfLinks : dword;
        xdeVolumeSerialNumber : dword;
        Reserved4 : dword;
        Reserved5 : dword;
        xdeFileIndex : Tuint64;
        Reserved6 : Tuint64;
        xdeAllocationSize : dword;
        xdeAccessFlags : dword;
        xdeMiscFlags : dword;
        Reserved7 : dword;
        xdeEaSize : Tuint64;
        xdeCompressedFileSize : Tuint64;
        xdeCompressionFormat : word;
        Reserved8 : word;
        Reserved9 : dword;
        Reserved10 : Tuint64;
     end;
{ Win32 (NX_PNF_WIN) information...    }
{ ...including name                    }
{ see WIN32_FIND_DATA...               }
{ maximum length is 255 characters     }

   PNXDirEnumWin_t = ^NXDirEnumWin_t;
   NXDirEnumWin_t = record
        deWinDirAttr : NXDirAttrWin_t;
        deDirMark : NXDirMark_t;
        deAlternativeFileName : array[0..15] of char;
        deName : pointer;
     end;

// nks/errno.h

  const
     NX_EOF = -(1);
     NX_ENOENT = 1;        { no such file or directory                      }
     NX_E2BIG = 2;         { argument list too big                          }
     NX_ENOEXEC = 3;       { exec format error                              }
     NX_EBADF = 4;         { bad file number (descriptor or handle)         }
     NX_ENOMEM = 5;        { not enough memory                              }
     NX_EACCES = 6;        { permission denied                              }
     NX_EEXIST = 7;        { file exists                                    }
     NX_EXDEV = 8;         { cross-device link                              }
     NX_EINVAL = 9;        { invalid argument                               }
     NX_ENFILE = 10;       { file table overflow                            }
     NX_EMFILE = 11;       { too many open files                            }
     NX_ENOSPC = 12;       { no space left on device                        }
     NX_ERANGE = 14;       { result too large                               }
     NX_EDEADLK = 15;      { resource deadlock would occur                  }
     NX_EINUSE = 16;       { resource(s) in use                             }
     NX_ESERVER = 17;      { server error (memory out, I/O error, etc.)     }
     NX_ENOSERVR = 18;     { no server (queue server, file server, etc.)    }
     NX_EWRNGKND = 19;     { wrong kind--an operation is being...           }
                           {  ...attempted on the wrong kind of object      }
     NX_ETRNREST = 20;     { transaction restarted                          }
     NX_ERESOURCE = 21;    { resources unavailable (maybe permanently)      }
     NX_EBADHNDL = 22;     { bad non-file handle (screen, semaphore, etc.)  }
     NX_EAGAIN = 24;       { resource temporarily unavailable               }
     NX_EIO = 28;          { physical I/O error                             }
     NX_EPIPE = 32;        { broken pipe                                    }
     NX_EALREADY = 37;     { operation already in progress                  }
     NX_ETIMEDOUT = 60;    { connection timed out                           }
     NX_EBUSY = 62;        { resource busy                                  }
     NX_EINTR = 63;        { interrupted function call                      }
     NX_EISDIR = 64;       { is a directory (not a file)                    }
     NX_ENAMETOOLONG = 65; { filename too long                              }
     NX_ENOSYS = 66;       { function not implemented                       }
     NX_ENOTDIR = 67;      { not a directory                                }
     NX_ENOTEMPTY = 68;    { directory is not empty                         }
     NX_EPERM = 69;        { operation not permitted                        }
     NX_ECHILD = 70;       { no child process                               }
     NX_EFBIG = 71;        { file too large                                 }
     NX_EMLINK = 72;       { too many links                                 }
     NX_ENOLCK = 74;       { no locks available                             }
     NX_ESRCH = 77;        { no such object                                 }
     NX_ENOTSUP = 79;      { this optional functionality not supported      }
     NX_EBADTYPE = 80;     { bad type for operation                         }
     NX_EOVERFLOW = 81;    { operation would overflow                       }
     NX_EHOSTDOWN = 82;    { host is down                                   }
     NX_EHOSTUNREACH = 83; { no route to host                               }
     NX_EPROCLIM = 84;     { too many processes                             }
     NX_EUNKNOWN = 99;     { unknown error occurring                        }
     NX_ENLMDATA = 100;    { anomaly in NLM data structure                  }
     NX_EILSEQ = 101;      { illegal character sequence in multibyte        }
     NX_EINCONSIS = 102;   { internal library inconsistency                 }
     NX_EDOSTEXTEOL = 103; { DOS-text file inconsistency--no newline...     }
                           { ...after carriage return                       }
     NX_ENONEXTANT = 104;  { object doesn't exist                           }
     NX_ENOCONTEXT = 105;  { the caller is not an NKS thread                }
     NX_ENAMESPACE = 106;  { invalid namespace or namespace operation       }
     NX_EBADCONN = 107;    { invalid connection                             }
     NX_EEXHAUSTED = 108;  { end of search                                  }
     NX_EFILESYS = 111;    { generic file system error                      }
     NX_ESUFFICIENT = 112; { insufficient space for any operation result    }
     NX_EPARTONLY = 113;   { partial result only  for lack of space         }
     NX_EBADIDENT = 114;   { invalid user or other identity                 }
     { aliases...  }
     NX_ENOSUPPORT = NX_ENOTSUP;
     //NX_ENORESOURCE = NX_BADIDENT;


procedure NXGetNKSVersion(major:Plongint; minor:Plongint; revision:Plongint; platformName:pointer; maxNameLength:size_t);cdecl;external libc_nlm name 'NXGetNKSVersion';
procedure NXGetNKSVersion(var major, minor, revision:longint; platformName:pchar; maxNameLength:size_t);cdecl;external libc_nlm name 'NXGetNKSVersion';
function NXStrError(errornumber:longint):Pchar;cdecl;external libc_nlm name 'NXStrError';


// nks/mac.h
{ turn on 1-byte packing...  }

  { values for 'fdFlags' (Inside Macintosh IV-105)...  }

const
  fOnDesk    = 1;
  fHasBundle = 8192;
  fInvisible = 16384;
  { values for 'fdLocation' (Inside Macintosh IV-105)...  }
  fDisk      = 0;
  fDesktop   = -(2);
  fTrash     = -(3);
  { 'ioFlAttrib' values...  }
  flLocked   = $01;
  flResOpen  = $04;
  flDatOpen  = $08;
  flIsDir    = $10;
  flBothOpen = $80;

type
   POSType = ^OSType;
   OSType = char;
{ (Inside Macintosh II-373)  }
{ (Inside Macintosh I-139)  }

   PPoint = ^Point;
   Point = record
        v : word;
        h : word;
     end;
{ (Inside Macintosh I-141)  }

   PRect = ^Rect;
   Rect = record
       case longint of
          0 : ( corner : record
               topLeft : Point;
               botRight : Point;
            end );
          1 : ( point : record
               top : word;
               left : word;
               bottom : word;
               right : word;
            end );
       end;
{ (Inside Macintosh IV-104)  }
{ window  }

   PFInfo = ^FInfo;
   FInfo = record
        fdType : OSType;
        fdCreator : OSType;
        fdFlags : word;
        fdLocation : Point;
        fdFldr : word;
     end;
{ (Inside Macintosh IV-105)  }
{ Finder (Desktop) comment ID  }
{ home directory ID  }

   PFXInfo = ^FXInfo;
   FXInfo = record
        fdIconID : word;
        fdUnused : array[0..3] of word;
        fdComment : word;
        fdPutAway : dword;
     end;
{ (Inside Macintosh IV-105)  }
{ folder's rectangle  }

   PDInfo = ^DInfo;
   DInfo = record
        frRect : Rect;
        frFlags : word;
        frLocation : Point;
        frView : word;
     end;
{ scroll position                            }
{ directory ID chain of open folders         }
{ directory ID                               }

   PDXInfo = ^DXInfo;
   DXInfo = record
        frScroll : Point;
        frOpenChain : dword;
        frUnused : word;
        frComment : word;
        frPutAway : dword;
     end;
{ information used by the Finder             }
{ directory ID or file number                }
{ first allocation block of data fork        }
{ logical end-of-file of data fork           }
{ physical end-of-file of data fork          }
{ first allocation block of resource fork    }
{ logical end-of-file of resource fork       }
{ physical end-of-file of resource fork      }
{ date and time of creation                  }
{ date and time of last modification         }
{ date and time of last back-up              }
{ additional information used by the Finder  }
{ file's parent directory ID                 }
{ file's clump size                          }

   PhFileInfo = ^hFileInfo;
   hFileInfo = record
        ioFlFndrInfo : FInfo;
        ioDirID : dword;
        ioFlStBlk : word;
        ioFlLgLen : dword;
        ioFlPyLen : dword;
        ioFlRStBlk : word;
        ioFlRLgLen : dword;
        ioFlRPyLen : dword;
        ioFlCrDat : dword;
        ioFlMdDat : dword;
        ioFlBkDat : dword;
        ioFlXFndrInfo : FXInfo;
        ioFlParID : dword;
        ioFlClpSiz : dword;
     end;
{ information used by the Finder             }
{ number of files in directory               }
{ date and time of creation                  }
{ date and time of last modification         }
{ date and time of last backup               }
{ additional information used by the Finder  }
{ directory's parent directory ID            }

   PdirInfo = ^dirInfo;
   dirInfo = record
        ioDrUsrWds : DInfo;
        ioDrDirID : dword;
        ioDrNmFls : word;
        filler3 : array[0..8] of word;
        ioDrCrDat : dword;
        ioDrMdDat : dword;
        ioDrBkDat : dword;
        ioDrFndrInfo : DXInfo;
        ioDrParID : dword;
     end;

   PCInfoPBRec = ^CInfoPBRec;
   CInfoPBRec = record
       case longint of
          0 : ( _file : hFileInfo );
          1 : ( dir : dirInfo );
       end;
{ Macintosh (NX_PNF_MAC) attributes          }
{ (Inside Macintosh IV-125)  }
{ path reference number  }

   PNXDirAttrMac_t = ^NXDirAttrMac_t;
   NXDirAttrMac_t = record
        xdeHeader : NXDeHeader_t;
        xdeFid : NXFid_t;
        xdeEffectRights : dword;
        xdeIoFRefNum : word;
        xdeIofVersNum : int8_t;
        filler1 : int8_t;
        xdeIoFDirIndex : word;
        xdeIoFlAttrib : int8_t;
        filler2 : int8_t;
        filler3 : dword;
        xdeInfo : CInfoPBRec;
     end;
{ Macintosh (NX_PNF_MAC) information...      }
{ ...including                               }
{ maximum length is 255 characters     }

   PNXDirEnumMac_t = ^NXDirEnumMac_t;
   NXDirEnumMac_t = record
        deMacDirAttr : NXDirAttrMac_t;
        deDirMark : NXDirMark_t;
        deName : pointer;
     end;

(** unsupported pragma#pragma pack()*)

// nks/memory.h

  { deprecated values for memory control flags...  }

  const
     NX_PAGE_UNLOCK       = $00000000;
     NX_PAGE_LOCK         = $00000001;
     NX_PAGE_RESERVE      = $00000020;
     NX_PAGE_COMMIT       = $00000040;
     NX_PAGE_PHYSICAL     = $00000080;
     NX_PAGE_RESERVE_ONLY = $00000100;
  { final values for memory control flags...  }
     NX_MEM_UNLOCK        = $00000000;
     NX_MEM_LOCK          = $00000001;
     NX_MEM_DECOMMIT      = $00000020;
     NX_MEM_COMMIT        = $00000040;
     NX_MEM_RESERVE       = $00000100;

function NXMemAlloc(size:size_t; alignment:size_t):pointer;cdecl;external libc_nlm name 'NXMemAlloc';
function NXMemCtl(start:pointer; size:size_t; flags:dword):longint;cdecl;external libc_nlm name 'NXMemCtl';
procedure NXMemFree(memory:pointer);cdecl;external libc_nlm name 'NXMemFree';
function NXMemRealloc(old:pointer; newSize:size_t; alignment:size_t):pointer;cdecl;external libc_nlm name 'NXMemRealloc';
function NXPageAlloc(pageCount:size_t; flags:dword):pointer;cdecl;external libc_nlm name 'NXPageAlloc';
procedure NXPageFree(memory:pointer);cdecl;external libc_nlm name 'NXPageFree';


{ nks/netware.h =============================================================}
{ turn on 1-byte packing...  }

type

   PnxTrustees_t = ^nxTrustees_t;
   nxTrustees_t = record
        trObjectID,
        trRights   : dword;
     end;

(** unsupported pragma#pragma pack()*)
{----------------------------------------------------------------------------
 The following are unofficial NKS interfaces and can only be used on NetWare.
 ----------------------------------------------------------------------------}

procedure nxCancelCheck;cdecl;external libc_nlm name 'nxCancelCheck';
procedure nxCancelDisable;cdecl;external libc_nlm name 'nxCancelDisable';
procedure nxCancelEnable;cdecl;external libc_nlm name 'nxCancelEnable';
function nxContextFlushName(context:PNXContext_t):longint;cdecl;external libc_nlm name 'nxContextFlushName';

function nxExportInterface(funcAddr:pointer; funcName:Pchar):longint;cdecl;external libc_nlm name 'nxExportInterface';

function nxExportInterfaceWrapped(funcAddr:pointer; stackWords:longint; funcName:Pchar; reference:Ppointer):longint;cdecl;external libc_nlm name 'nxExportInterfaceWrapped';
function nxGetEnviron:PPchar;cdecl;external libc_nlm name 'nxGetEnviron';
function nxIsLoadedProtected:NXBool_t;cdecl;external libc_nlm name 'nxIsLoadedProtected';
function nxIsProtectedAddress(_para1:pointer):NXBool_t;cdecl;external libc_nlm name 'nxIsProtectedAddress';
function nxMemGetSize(block:pointer):size_t;cdecl;external libc_nlm name 'nxMemGetSize';
procedure nxUnexportInterfaceWrapped(reference:pointer);cdecl;external libc_nlm name 'nxUnexportInterfaceWrapped';
{ NetWare trustees...  }

function nxAddTrustee(pathCtx:NXPathCtx_t; pathname:Pchar; objectID:dword; rights:dword):longint;cdecl;external libc_nlm name 'nxAddTrustee';
function nxDeleteTrustee(pathCtx:NXPathCtx_t; pathname:Pchar; objectID:dword):longint;cdecl;external libc_nlm name 'nxDeleteTrustee';
function nxScanTrustees(pathCtx:NXPathCtx_t; pathname:Pchar; sequence:dword; count:Pdword; trusteeVector:PnxTrustees_t;
           nextSequence:Pdword):longint;cdecl;external libc_nlm name 'nxScanTrustees';
{ wrap/unwrap sobriquets...  }
// nks/synch.h

{ turn on 1-byte packing...  }

type
   PNXHierarchy_t = ^NXHierarchy_t;
   NXHierarchy_t = longint;

   PNXMutex_t = ^NXMutex_t;
   NXMutex_t = record
        reserved1 : Tuint64;
        reserved2 : array[0..9] of pointer;
     end;

   PNXRwLock_t = ^NXRwLock_t;
   NXRwLock_t = record
        reserved1 : Tuint64;
        reserved2 : array[0..9] of pointer;
     end;

   PNXSema_t = ^NXSema_t;
   NXSema_t = record
        reserved1 : Tuint64;
        reserved2 : array[0..4] of pointer;
     end;

   PNXCond_t = ^NXCond_t;
   NXCond_t = record
        reserved1 : Tuint64;
        reserved2 : array[0..4] of pointer;
     end;

   PNXLockInfo_t = ^NXLockInfo_t;
   NXLockInfo_t = record
        liName : array[0..(31 + 1)-1] of char;
        liFlags : dword;
        liPad : array[0..1] of dword;
     end;

(** unsupported pragma#pragma pack()*)
{ Mutexes...  }


function NXMutexAlloc(flags:dword; hierarchy:NXHierarchy_t; info:PNXLockInfo_t):PNXMutex_t;cdecl;external libc_nlm name 'NXMutexAlloc';
procedure NXMutexDeinit(mutex:PNXMutex_t);cdecl;external libc_nlm name 'NXMutexDeinit';
function NXMutexDepth(mutex:PNXMutex_t):longint;cdecl;external libc_nlm name 'NXMutexDepth';
procedure NXMutexFree(mutex:PNXMutex_t);cdecl;external libc_nlm name 'NXMutexFree';
function NXMutexInit(mutex:PNXMutex_t; flags:dword; hierarchy:NXHierarchy_t; info:PNXLockInfo_t):longint;cdecl;external libc_nlm name 'NXMutexInit';
function NXMutexIsOwned(mutex:PNXMutex_t):NXBool_t;cdecl;external libc_nlm name 'NXMutexIsOwned';
function NXMutexTestFlag(mutex:PNXMutex_t; flag:dword):NXBool_t;cdecl;external libc_nlm name 'NXMutexTestFlag';
function NXLock(mutex:PNXMutex_t):longint;cdecl;external libc_nlm name 'NXLock';
function NXTryLock(mutex:PNXMutex_t):NXBool_t;cdecl;external libc_nlm name 'NXTryLock';
function NXUnlock(mutex:PNXMutex_t):longint;cdecl;external libc_nlm name 'NXUnlock';

{ Reader-writer locks...  }
function NXRwLockAlloc(hierarchy:NXHierarchy_t; info:PNXLockInfo_t):PNXRwLock_t;cdecl;external libc_nlm name 'NXRwLockAlloc';
procedure NXRwLockDeinit(lock:PNXRwLock_t);cdecl;external libc_nlm name 'NXRwLockDeinit';
procedure NXRwLockFree(lock:PNXRwLock_t);cdecl;external libc_nlm name 'NXRwLockFree';
function NXRwLockInit(lock:PNXRwLock_t; hierarchy:NXHierarchy_t; info:PNXLockInfo_t):longint;cdecl;external libc_nlm name 'NXRwLockInit';
function NXRwLockIsOwned(lock:PNXRwLock_t; mode:dword):NXBool_t;cdecl;external libc_nlm name 'NXRwLockIsOwned';
procedure NXRdLock(lock:PNXRwLock_t);cdecl;external libc_nlm name 'NXRdLock';
procedure NXWrLock(lock:PNXRwLock_t);cdecl;external libc_nlm name 'NXWrLock';
function NXTryRdLock(lock:PNXRwLock_t):NXBool_t;cdecl;external libc_nlm name 'NXTryRdLock';
function NXTryWrLock(lock:PNXRwLock_t):NXBool_t;cdecl;external libc_nlm name 'NXTryWrLock';
procedure NXRwUnlock(lock:PNXRwLock_t);cdecl;external libc_nlm name 'NXRwUnlock';
function NXRwLockUpgrade(lock:PNXRwLock_t):longint;cdecl;external libc_nlm name 'NXRwLockUpgrade';
function NXRwLockDowngrade(lock:PNXRwLock_t):longint;cdecl;external libc_nlm name 'NXRwLockDowngrade';
{ Semaphores...  }
function NXSemaAlloc(count:dword; arg:pointer):PNXSema_t;cdecl;external libc_nlm name 'NXSemaAlloc';
procedure NXSemaDeinit(sema:PNXSema_t);cdecl;external libc_nlm name 'NXSemaDeinit';
procedure NXSemaFree(sema:PNXSema_t);cdecl;external libc_nlm name 'NXSemaFree';
function NXSemaInit(sema:PNXSema_t; count:dword; arg:pointer):longint;cdecl;external libc_nlm name 'NXSemaInit';
procedure NXSemaPost(sema:PNXSema_t);cdecl;external libc_nlm name 'NXSemaPost';
function NXSemaTryWait(sema:PNXSema_t):NXBool_t;cdecl;external libc_nlm name 'NXSemaTryWait';
procedure NXSemaWait(sema:PNXSema_t);cdecl;external libc_nlm name 'NXSemaWait';
{ Condition variables...  }
function NXCondAlloc(arg:pointer):PNXCond_t;cdecl;external libc_nlm name 'NXCondAlloc';
procedure NXCondBroadcast(cond:PNXCond_t);cdecl;external libc_nlm name 'NXCondBroadcast';
procedure NXCondDeinit(cond:PNXCond_t);cdecl;external libc_nlm name 'NXCondDeinit';
procedure NXCondFree(cond:PNXCond_t);cdecl;external libc_nlm name 'NXCondFree';
function NXCondInit(cond:PNXCond_t; arg:pointer):longint;cdecl;external libc_nlm name 'NXCondInit';
procedure NXCondSignal(cond:PNXCond_t);cdecl;external libc_nlm name 'NXCondSignal';
function NXCondWait(cond:PNXCond_t; mutex:PNXMutex_t):longint;cdecl;external libc_nlm name 'NXCondWait';
function NXCondTimedWait(cond:PNXCond_t; mutex:PNXMutex_t; interval:dword):longint;cdecl;external libc_nlm name 'NXCondTimedWait';




//  assert.h

procedure _assert(_para1,_para2, _para3:Pchar; ActionCode:longint);cdecl;external libc_nlm name '_assert';
procedure FpAssert(_para1,_para2, _para3:Pchar; ActionCode:longint);cdecl;external libc_nlm name '_assert';

type
   Taction_code =  Longint;
Const                         // modifications to behavior of assert()
  __IGNORE = -(1);            // assert() prints but returns -1
  __NOERR = 0;                // (value returned for no assertion)
  __ABORT = 1;                // assert() aborts (normal, default action)
  __DEBUGGER = 2;             // assert() prints and drops into the debugger

function assert_action(_para1:Taction_code):longint;cdecl;external libc_nlm name 'assert_action';
function _assert_expr(_para1:longint; _para2,_para3,_para4:Pchar; _para5:longint):longint;cdecl;external libc_nlm name '_assert_expr';

// nks/unix.h

{ turn on 1-byte packing...  }

{ UNIX (NX_PNF_UNIX) attributes           }
{ file mode                               }
{ number of links                         }
{ last access time (files only)           }
{ last modify time                        }
{ last archive time                       }
{ last attribute change time (or 0)       }
{ generation; bumped when file modified   }
{ entry serial number                     }
{ file system (device) containing entry   }
{ ID of raw device containing this entry  }
{ user ID of the owner of this entry      }
{ group ID of the group of this entry     }
{ length of file in bytes                 }
{ number of 512-byte blocks allocated     }
{ preferred I/O block size                }
type

   PNXDirAttrUnix_t = ^NXDirAttrUnix_t;
   NXDirAttrUnix_t = record
        xdeHeader : NXDeHeader_t;
        xdeFid : NXFid_t;
        xdeEffectiveRights : dword;
        xde_mode : dword;
        xde_nlink : dword;
        spare1 : dword;
        xde_atime : time_t;
        xde_mtime : time_t;
        xde_btime : time_t;
        xde_ctime : time_t;
        xde_change : Tuint64;
        xde_ino : Tuint64;
        xde_dev : array[0..1] of Tuint64;
        xde_rdev : array[0..1] of Tuint64;
        xde_uid : Tuint64;
        xde_gid : Tuint64;
        xde_size : Tuint64;
        xde_blocks : Tuint64;
        xde_blksize : dword;
        spare2 : dword;
        spare3 : Tuint64;
        spare4 : Tuint64;
        spare5 : Tuint64;
        spare6 : Tuint64;
        spare7 : Tuint64;
        spare8 : Tuint64;
     end;
{ UNIX (NX_PNF_UNIX) information...       }
{ ...including name                       }
{ maximum length is 255 characters        }

   PNXDirEnumUnix_t = ^NXDirEnumUnix_t;
   NXDirEnumUnix_t = record
        deUnixDirAttr : NXDirAttrUnix_t;
        deDirMark : NXDirMark_t;
        deName : pointer;
     end;

(** unsupported pragma#pragma pack()*)
//  nks/vm.h

{ value for 'wait_for' in NXVmJoin()...  }
{ values for 'flags' in NXVmSpawn()...  }
{ returned in newVm if NXVmSpawn() is passed NX_VM_DETACHED or if it fails  }

{ turn on 1-byte packing...  }

type
   PNXStrType_t = ^NXStrType_t;
   NXStrType_t  =  Longint;
Const
   NX_STR_ASCII   = $FFFFFFFF;
   NX_STR_UTF8    = $00000000;
   NX_STR_UNICODE = $00000001;

{ NX_OBJ_FILE, NX_OBJ_CONSOLE, NX_OBJ_FIFO, etc. }
{ set to 0                                       }
{ ancestor of 'ssPath'                           }
{ relative to 'ssPathCtx'                        }
type
   PNXNameSpec_t = ^NXNameSpec_t;
   NXNameSpec_t = record
        ssType : NXObjType_t;
        ssReserved : longint;
        ssPathCtx : NXPathCtx_t;
        ssPath : pointer;
     end;
   NXStreamSpec_t = NXNameSpec_t;
   PNXStreamSpec_t = ^NXStreamSpec_t;
{ unused; set to 0                               }
{ count of arguments in 'esArgv'                 }
{ command-line arguments to spawned VM           }
{ starting environment of spawned VM             }
{ wiring of standard input for spawned VM        }
{ wiring of standard output for spawned VM       }
{ wiring of standard error for spawned VM        }

   PNXExecEnvSpec_t = ^NXExecEnvSpec_t;
   NXExecEnvSpec_t = record
        esFlags : longint;
        esArgc : longint;
        esArgv : ^pointer;
        esEnv : ^pointer;
        esStdin : NXStreamSpec_t;
        esStdout : NXStreamSpec_t;
        esStderr : NXStreamSpec_t;
     end;
{ maxmimum number of threads in worker pool      }
{ implementation-reserved                        }

   PNXVmWorkerThreadConfig_t = ^NXVmWorkerThreadConfig_t;
   NXVmWorkerThreadConfig_t = record
        wtcThreads : size_t;
        reserved : array[0..4] of longint;
     end;

(** unsupported pragma#pragma pack()*)
{ Virtual machine management...  }

function  NXVmDestroy(id:NXVmId_t):longint;cdecl;external libc_nlm name 'NXVmDestroy';
procedure NXVmExit(status:longint);cdecl;external libc_nlm name 'NXVmExit';
function  NXVmGetId:NXVmId_t;cdecl;external libc_nlm name 'NXVmGetId';
function  NXVmGetWorkerThreadConfig(reserved:pointer; config:PNXVmWorkerThreadConfig_t):longint;cdecl;external libc_nlm name 'NXVmGetWorkerThreadConfig';
function  NXVmGetStringType(_type:PNXStrType_t):longint;cdecl;external libc_nlm name 'NXVmGetStringType';
function  NXVmJoin(wait_for:NXVmId_t; departed_vm:PNXVmId_t; status:Plongint):longint;cdecl;external libc_nlm name 'NXVmJoin';
function  NXVmRegisterExitHandler(cleanup:TCDeclProc1PtrArg; arg:pointer):longint;cdecl;external libc_nlm name 'NXVmRegisterExitHandler';
function  NXVmSetWorkerThreadConfig(reserved:pointer; config:PNXVmWorkerThreadConfig_t):longint;cdecl;external libc_nlm name 'NXVmSetWorkerThreadConfig';
function  NXVmSpawn(name:PNXNameSpec_t; envSpec:PNXExecEnvSpec_t; flags:dword; newVm:PNXVmId_t):longint;cdecl;external libc_nlm name 'NXVmSpawn';
function  NXVmUnregisterExitHandler(func:TCDeclProc1PtrArg; arg:pointer):longint;cdecl;external libc_nlm name 'NXVmUnregisterExitHandler';


// alloca.h
{ Non-standard functions from stdlib.h }
//** void   *alloca( size_t );


// client.h

// stdbool.h

{ origin flags...  }
{ address type flags (used in combination with ORIGIN_ADDRESS)...  }
{ transport type flags...  }
{ NMAS sequence passed...  }
{ string format flags...  }
{ suggested maximum lengths (in characters)...  }

{ turn on 1-byte packing...  }

  const
     ORIGIN_NAME    = $0010;
     ORIGIN_ADDRESS = $0020;    { interpret 'server' as 'netaddr_t'      }
  { address type flags (used in combination with ORIGIN_ADDRESS)...  }
  { address is IPX                         }
     ADDR_IPX = $0100;
     ADDR_IP = $0200;           { address is Internet Protocol           }
     ADDR_IPV6 = $0400;         { address is Internet Protocol version 6 }
  { transport type flags...  }
  { transport type unspecified             }
     XPORT_WILD = $0000;
  { prefer Novell IPX                      }
     XPORT_IPX = $0001;
  { prefer TCP                             }
     XPORT_TCP = $0002;
  { NMAS sequence passed...  }
  { alternative NMAS-based authentication  }
     NMAS_SEQUENCE = $8000;
  { string format flags...  }
     USERNAME_ASCII = $00000;
     USERNAME_UTF8 = $10000;
     USERNAME_UNICODE = $20000;
  { suggested maximum lengths (in characters)...  }
  { ASCII, Unicode or UTF-8                }
     MAX_USERNAME_LEN = 255;
  { (always in ASCII characters)           }
     MAX_PASSWORD_LEN = 255;
     MAX_TREENAME_LEN = 48;
     MAX_SERVERNAME_LEN = 48;


type

   Pnetaddr_t = ^netaddr_t;
   netaddr_t = record
        _type : longint;
        length : size_t;
        address : array[0..47] of byte;
     end;

   Pfrag_t = ^frag_t;
   frag_t = record
        data : pointer;
        length : size_t;
     end;

(** unsupported pragma#pragma pack()*)
{ managing user identity...  }


{$ifndef DisableArrayOfConst}
function build_username(max:size_t; flags:dword; username:Pchar; user:Pchar; args:array of const):longint;cdecl;external libc_nlm name 'build_username';
{$endif}
function build_username(max:size_t; flags:dword; username:Pchar; user:Pchar):longint;cdecl;external libc_nlm name 'build_username';


function create_identity(treename:Pchar; username:pointer; password:Pchar; nmas_sequence:pointer; flags:dword;
           identity:Plongint):longint;cdecl;external libc_nlm name 'create_identity';
function create_server_identity(identity:Plongint):longint;cdecl;external libc_nlm name 'create_server_identity';
function is_valid_identity(identity:longint; error:Plongint):longint;cdecl;external libc_nlm name 'is_valid_identity';
procedure delete_identity(identity:longint);cdecl;external libc_nlm name 'delete_identity';
{ managing NCP sessions with a remote server...  }

function open_ncp_session(identity:longint; flags:dword; servername:Pchar; session:Plongint):longint;cdecl;external libc_nlm name 'open_ncp_session';
function close_ncp_session(session:longint):longint;cdecl;external libc_nlm name 'close_ncp_session';
function send_ncp(session:longint; requestCode:longint; sendFragCount:longint; sendFrags:array of frag_t; replyFragCount:longint;
           replyFrags:array of frag_t; replyFragsUsed:Plongint; ncp_error:Plongint):longint;cdecl;external libc_nlm name 'send_ncp';

// complex.h

{ not presently supported  }


// ctype.h
//  var __ctype : array of byte;cvar;external;
{ standard prototypes...  }

function isalnum(_para1:longint):longint;cdecl;external libc_nlm name 'isalnum';
function isalpha(_para1:longint):longint;cdecl;external libc_nlm name 'isalpha';
function isblank(_para1:longint):longint;cdecl;external libc_nlm name 'isblank';
function iscntrl(_para1:longint):longint;cdecl;external libc_nlm name 'iscntrl';
function isdigit(_para1:longint):longint;cdecl;external libc_nlm name 'isdigit';
function isgraph(_para1:longint):longint;cdecl;external libc_nlm name 'isgraph';
function islower(_para1:longint):longint;cdecl;external libc_nlm name 'islower';
function isprint(_para1:longint):longint;cdecl;external libc_nlm name 'isprint';
function ispunct(_para1:longint):longint;cdecl;external libc_nlm name 'ispunct';
function isspace(_para1:longint):longint;cdecl;external libc_nlm name 'isspace';
function isupper(_para1:longint):longint;cdecl;external libc_nlm name 'isupper';
function isxdigit(_para1:longint):longint;cdecl;external libc_nlm name 'isxdigit';
function tolower(_para1:longint):longint;cdecl;external libc_nlm name 'tolower';
function toupper(_para1:longint):longint;cdecl;external libc_nlm name 'toupper';
function isascii(_para1:longint):longint;cdecl;external libc_nlm name 'isascii';
function toascii(_para1:longint):longint;cdecl;external libc_nlm name 'toascii';
function ismultibyte(_para1:Pchar):longint;cdecl;external libc_nlm name 'ismultibyte';
function Lisalnum(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisalnum';
function Lisalpha(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisalpha';
function Lisblank(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisblank';
function Liscntrl(_para1:Pchar):longint;cdecl;external libc_nlm name 'Liscntrl';
function Lisdigit(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisdigit';
function Lisgraph(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisgraph';
function Lislower(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lislower';
function Lisprint(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisprint';
function Lispunct(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lispunct';
function Lisspace(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisspace';
function Lisupper(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisupper';
function Lisxdigit(_para1:Pchar):longint;cdecl;external libc_nlm name 'Lisxdigit';


// dfs.h

{===========================================================
  Traditional direct file system
  These were interfaced by CLib in its NDK header, nwdfs.h
============================================================}

  const
     DFS_FAILURE = -(1);
     DFS_SUCCESS = 0;
     DFS_ERR_INSUFFICIENT_SPACE = 1;
     DFS_ERR_VOLUME_SEGMENT_DEACTIVATED = 4;
     DFS_ERR_TRUNCATION_FAILURE = 16;
     DFS_ERR_HOLE_IN_FILE = 17;
     DFS_ERR_PARAMETER = 18;
     DFS_ERR_OVERLAP = 19;
     DFS_ERR_SEGMENT = 20;
     DFS_ERR_BOUNDARY = 21;
     DFS_ERR_INSUFFICIENT_LIMBO_FILE_SPACE = 22;
     DFS_ERR_NOT_IN_DIRECT_FILE_MODE = 23;
     DFS_ERR_OPERATION_BEYOND_EOF = 24;
     DFS_ERR_OUT_OF_FILDES = 129;
     DFS_ERR_HARD_IO = 131;
     DFS_ERR_EBADF = 136;
     DFS_ERR_CANT_READ = 147;
     DFS_ERR_CANT_WRITE = 148;
     DFS_ERR_FILE_DETACHED = 149;
     DFS_ERR_ENOMEM = 150;
     DFS_ERR_INVALID_VOLUME = 152;
     DFS_ERR_IO_LOCK = 162;
  { setSizeFlags  }

     DFS_SETSIZE_NON_SPARSE_FILE = $00000001;    { to extend the file  }
     DFS_SETSIZE_NO_ZERO_FILL    = $00000002;    { do not zero fill  }
     DFS_SETSIZE_UNDO_ON_ERROR   = $00000004;    { truncate to original eof  }
     DFS_SETSIZE_PHYSICAL_ONLY   = $00000008;    { change physical EOF only  }
     DFS_SETSIZE_LOGICAL_ONLY    = $00000010;    { change only the logical EOF  }


{ type definitions...  }
type

   Pdfs_filemap_t = ^dfs_filemap_t;
   dfs_filemap_t = record
        FileBlock : longint;
        VolumeBlock : longint;
        NumberOfBlocks : longint;
     end;

   Pdfs_volinfo_t = ^dfs_volinfo_t;
   dfs_volinfo_t = record
        VolumeAllocationUnitSizeInBytes : size_t;
        VolumeSizeInAllocationUnits : size_t;
        VolumeSectorSize : size_t;
        AllocationUnitsUsed : longint;
        AllocationUnitsFreelyAvailable : longint;
        AllocationUnitsInDeletedFilesNotAvailable : longint;
        AllocationUnitsInAvailableDeletedFiles : longint;
        NumberOfPhysicalSegmentsInVolume : longint;
        PhysicalSegmentSizeInAllocationUnits : array[0..63] of size_t;
     end;

   Pdfs_cbparms_t = ^dfs_cbparms_t;
   dfs_cbparms_t = record
        sema : pointer;
        ccode : longint;
     end;
{  dlfcn.h
==============================================================================
=  Interfaces from the Single UNIX Specification of the Open Group for the
=  management of imported symbols and shared (dynamic) libraries. The imple-
=  mentation on NetWare is narrower as noted by the number of features that
=  are ignored or unsupported.
==============================================================================}
  const
     RTLD_LAZY = $01;
     RTLD_NOW = $02;               { ignored }
     RTLD_GLOBAL = $04;            { ignored }
     RTLD_LOCAL = $08;             { ignored }
     RTLD_MULTIPLE = $10;          { NetWare: force-load multiple times  }
     MAX_DLL_NAME_LEN = 8;         { special purpose value for 'handle' in dlsym()...  }
     MAX_SYMNAME_LEN = 255;        { maximim length of 'name' in dlsym()...  }


function dlopen(path:Pchar; mode:longint):pointer;cdecl;external libc_nlm name 'dlopen';
function dlsym(handle:pointer; name:Pchar):pointer;cdecl;external libc_nlm name 'dlsym';
function dlclose(handle:pointer):longint;cdecl;external libc_nlm name 'dlclose';
function dlerror:Pchar;cdecl;external libc_nlm name 'dlerror';


// endian.h
{ defines `__BYTE_ORDER' for the hosting environment...  }
{ some environments use a different "endianness" for floating point values  }

  const
     __LITTLE_ENDIAN = 1234;
     __BIG_ENDIAN = 4321;
     __PDP_ENDIAN = 3412;
  { defines `__BYTE_ORDER' for the hosting environment...  }
     __BYTE_ORDER = __LITTLE_ENDIAN;
     __FLOAT_WORD_ORDER = __BYTE_ORDER;
     LITTLE_ENDIAN = __LITTLE_ENDIAN;
     BIG_ENDIAN = __BIG_ENDIAN;
     PDP_ENDIAN = __PDP_ENDIAN;
     BYTE_ORDER = __BYTE_ORDER;



// err.h

{$ifndef DisableArrayOfConst}
procedure err(_para1:longint; _para2:Pchar; args:array of const);cdecl;external libc_nlm name 'err';
{$endif}
procedure err(_para1:longint; _para2:Pchar);cdecl;external libc_nlm name 'err';
procedure verr(_para1:longint; _para2:Pchar; _para3:va_list);cdecl;external libc_nlm name 'verr';

{$ifndef DisableArrayOfConst}
procedure errx(_para1:longint; _para2:Pchar; args:array of const);cdecl;external libc_nlm name 'errx';
{$endif}
procedure errx(_para1:longint; _para2:Pchar);cdecl;external libc_nlm name 'errx';
procedure verrx(_para1:longint; _para2:Pchar; _para3:va_list);cdecl;external libc_nlm name 'verrx';

{$ifndef DisableArrayOfConst}
procedure warn(_para1:Pchar; args:array of const);cdecl;external libc_nlm name 'warn';
{$endif}
procedure warn(_para1:Pchar);cdecl;external libc_nlm name 'warn';
procedure vwarn(_para1:Pchar; _para2:va_list);cdecl;external libc_nlm name 'vwarn';

{$ifndef DisableArrayOfConst}
procedure warnx(_para1:Pchar; args:array of const);cdecl;external libc_nlm name 'warnx';
{$endif}
procedure warnx(_para1:Pchar);cdecl;external libc_nlm name 'warnx';
procedure vwarnx(_para1:Pchar; _para2:va_list);cdecl;external libc_nlm name 'vwarnx';



// errno.h

  const
     ENOENT = 1;
     E2BIG = 2;           { arg list too big                               }
     ENOEXEC = 3;         { exec format error                              }
     EBADF = 4;           { bad file number                                }
     ENOMEM = 5;          { not enough memory                              }
     EACCES = 6;          { permission denied                              }
     EEXIST = 7;          { file exists                                    }
     EXDEV = 8;           { cross-device link                              }
     EINVAL = 9;          { invalid argument                               }
     ENFILE = 10;         { file table overflow                            }
     EMFILE = 11;         { too many open files                            }
     ENOSPC = 12;         { no space left on device                        }
     EDOM = 13;           { argument too large                             }
     ERANGE = 14;         { result too large                               }
     EDEADLK = 15;        { resource deadlock would occur                  }
  { -------------------------- Miscellaneous NLM Library constants ----------  }
     EINUSE = 16;         { resource(s) in use                             }
     ESERVER = 17;        { server error (memory out, I/O error, etc.)     }
     ENOSERVR = 18;       { no server (queue server, file server, etc.)    }
     EWRNGKND = 19;       { wrong kind--an operation is being...           }
                          {  ...attempted on the wrong kind of object      }
     ETRNREST = 20;       { transaction restarted                          }
     ERESOURCE = 21;      { resources unavailable (maybe permanently)      }
     EBADHNDL = 22;       { bad non-file handle (screen, semaphore, etc.)  }
     ENO_SCRNS = 23;      { screen I/O attempted when no screens           }
  { -------------------------- Additional POSIX / traditional UNIX constants   }
     EAGAIN = 24;         { resource temporarily unavailable               }
     ENXIO = 25;          { no such device or address                      }
     EBADMSG = 26;        { not a data message                             }
     EFAULT = 27;         { bad address                                    }
     EIO = 28;            { physical I/O error                             }
     ENODATA = 29;        { no data                                        }
     ENOSTRMS = 30;       { streams not available                          }
  { Berkeley sockets constants ------------------  }
     EPROTO = 31;         { fatal protocol error                           }
     EPIPE = 32;          { broken pipe                                    }
     ESPIPE = 33;         { illegal seek                                   }
  { Non-blocking and interrupt I/O constants ----  }
     ETIME = 34;          { ioctl acknowledge timeout                      }
     EWOULDBLOCK = 35;    { operation would block                          }
     EINPROGRESS = 36;    { operation now in progress                      }
     EALREADY = 37;       { operation already in progress                  }
  { IPC network argument constants --------------  }
     ENOTSOCK = 38;       { socket operation on non-socket                 }
     EDESTADDRREQ = 39;   { destination address required                   }
     EMSGSIZE = 40;       { message too long                               }
     EPROTOTYPE = 41;     { protocol wrong type for socket                 }
     ENOPROTOOPT = 42;    { protocol not available                         }
     EPROTONOSUPPORT = 43;{ protocol not supported                         }
     ESOCKTNOSUPPORT = 44;{ socket type not supported                      }
     EOPNOTSUPP = 45;     { operation not supported on socket              }
     EPFNOSUPPORT = 46;   { protocol family not supported                  }
     EAFNOSUPPORT = 47;   { address family unsupported by protocol family  }
     EADDRINUSE = 48;     { address already in use                         }
     EADDRNOTAVAIL = 49;  { can't assign requested address                 }
  { Operational constants -----------------------  }
     ENETDOWN = 50;       { network is down                                }
     ENETUNREACH = 51;    { network is unreachable                         }
     ENETRESET = 52;      { network dropped connection on reset            }
     ECONNABORTED = 53;   { software caused connection abort               }
     ECONNRESET = 54;     { connection reset by peer                       }
     ENOBUFS = 55;        { no buffer space available                      }
     EISCONN = 56;        { socket is already connected                    }
     ENOTCONN = 57;       { socket is not connected                        }
     ESHUTDOWN = 58;      { can't send after socket shutdown               }
     ETOOMANYREFS = 59;   { too many references: can't splice              }
     ETIMEDOUT = 60;      { connection timed out                           }
     ECONNREFUSED = 61;   { connection refused                             }
  { -------------------------- Additional POSIX-mandated constants ----------  }
     EBUSY = 62;          { resource busy                                  }
     EINTR = 63;          { interrupted function call                      }
     EISDIR = 64;         { is a directory                                 }
     ENAMETOOLONG = 65;   { filename too long                              }
     ENOSYS = 66;         { function not implemented                       }
     ENOTDIR = 67;        { not a directory                                }
     ENOTEMPTY = 68;      { directory not empty                            }
     EPERM = 69;          { operation not permitted                        }
     ECHILD = 70;         { no child process                               }
     EFBIG = 71;          { file too large                                 }
     EMLINK = 72;         { too many links                                 }
     ENODEV = 73;         { no such device                                 }
     ENOLCK = 74;         { no locks available                             }
     ENOTTY = 75;         { inappropriate I/O control operation            }
     EFTYPE = ENOTTY;     { inappropriate operation for file type       }
     EROFS = 76;          { read-only file system                          }
     ESRCH = 77;          { no such process                                }
     ECANCELED = 78;      { operation was cancelled                        }
     ENOTSUP = 79;        { this optional functionality not supported      }
     ECANCELLED = ECANCELED;
     EBADTYPE = 80;       { bad type for operation                         }
     EOVERFLOW = 81;      { operation would overflow                       }
     EHOSTDOWN = 82;      { host is down                                   }
     EHOSTUNREACH = 83;   { no route to host                               }
     EPROCLIM = 84;       { too many processes                             }
  { -------------------------- Additional POSIX / traditional UNIX constants   }
     ENOMSG = 90;         { message does not exist                         }
  { -------------------------- LibC-implementation-specific constants -------  }
     ENLMDATA = 100;      { anomaly in NLM data structure                  }
     EILSEQ = 101;        { illegal character sequence in multibyte        }
     EINCONSIS = 102;     { internal library inconsistency                 }
     EDOSTEXTEOL = 103;   { DOS-text file inconsistency--no newline...     }
                          { ...after carriage return                       }
     ENONEXTANT = 104;    { object doesn't exist                           }
     ENOCONTEXT = 105;    { no thread library context present              }
     ENAMESPACE = 106;    { invalid namespace or operation                 }
     EBADCONN = 107;      { invalid connection                             }
     ENAMEINVAL = 108;    { invalid NDS name                               }
     EPASSINVAL = 109;    { invalid password                               }
     ENCPINVAL = 110;     { invalid or erroneous NCP                       }
     EFILESYS = 111;      { generic file system error, see 'filesyserrno'  }
     ESUFFICIENT = 112;   { insufficient space for any operation result    }
     EPARTONLY = 113;     { partial result only  for lack of space         }
     EBADIDENT = 114;     { invalid user or other identity                 }
     ENDS = 115;          { generic eDirectory error, see 'h_errno'        }
     ENCP = 116;          { generic NCP error, see 'h_errno'               }
     ELOOKUP = 117;       { generic look-up error, see 'h_errno'           }
     ELASTERR = ELOOKUP;


function ___errno:Plongint;cdecl;external libc_nlm name '___errno';
function __errno_location:Plongint;cdecl;external libc_nlm name '___errno';
function ___lastClientErrno:Plongint;cdecl;external libc_nlm name '___lastClientErrno';
function ___lastFileSysErrno:Plongint;cdecl;external libc_nlm name '___lastFileSysErrno';


// esm.h

  const
     ERR_ESM_AVAL = 1;
     ERR_SIZE_ZERO = 2;           { ESMAlloc size requested is zero          }
     ERR_TABLE_FULL = 3;          { allocation table is full                 }
     ERR_NOT_CONTIGUOUS = 4;      { ESMAlloc request cannot be continguous   }
     ERR_INVAL_ADDRESS = 5;       { already free or out of range             }
     ERR_INVAL_SRC_ADDR = 6;      { bad source address (ESMCopy)             }
     ERR_INVAL_DEST_ADDR = 7;     { bad destination address(ESMCopy/ESMFill) }
     ERR_SRC_DEST_OVERLAP = 8;    { buffer overlap (ESMCopy)                 }
  { (will be obsolete when the overlapping buffer copy implemented...)         }
     ERR_MAP_4M_PAGE = 9;         { mapping particular 4M page failed        }
     ERR_BUFFER_SIZE = 10;        { buffer passed too small (ESMQuery)       }
     ERR_LOGICAL_SPACE = 11;      { adequate logical/window not available    }
     ERR_ACQUIRING_LOCK = 12;     { failed to acquire lock (please retry)    }

type
   Paddr64_t = ^addr64_t;
   addr64_t = Tuint64;

   PESMQueryInfo_t = ^ESMQueryInfo_t;
   ESMQueryInfo_t = record
        TotalExtendedMemory : size64_t;
        RemainingExtendedMemory : size64_t;
        TotalMemoryBelow4G : size_t;
     end;

function ESMAlloc(size:size64_t; options:dword; esmAddress:Paddr64_t):longint;cdecl;external libc_nlm name 'ESMAlloc';
function ESMAllocWindow(size:size_t; logicalAddress:Ppointer; callerID:pointer):longint;cdecl;external libc_nlm name 'ESMAllocWindow';
function ESMCopy(source:addr64_t; destination:addr64_t; length:size64_t):longint;cdecl;external libc_nlm name 'ESMCopy';
function ESMFill(pattern:dword; destination:addr64_t; length:size64_t):longint;cdecl;external libc_nlm name 'ESMFill';
function ESMFree(esmAddress:addr64_t):longint;cdecl;external libc_nlm name 'ESMFree';
function ESMFreeWindow(logicalAddress:pointer; callerID:pointer):longint;cdecl;external libc_nlm name 'ESMFreeWindow';
function ESMMapMemory(windowAddress:pointer; memoryAddress:addr64_t; size:size_t):longint;cdecl;external libc_nlm name 'ESMMapMemory';
function ESMQuery(bufferSize:size_t; buffer:PESMQueryInfo_t):longint;cdecl;external libc_nlm name 'ESMQuery';



// float.h
{ turn on 1-byte packing...  }

{
typedef union __fp_u

   unsigned char __uc[16];
   float         __f;
   double        __d;
   long double   __ld;
 __fp_u;
 }
{
typedef struct __fp_s

   int    __MANT_DIG;
   int    __DIG;
   int    __MIN_EXP;
   int    __MIN_10_EXP;
   int    __MAX_EXP;
   int    __MAX_10_EXP;
   __fp_u __EPSILON[2];
   __fp_u __MIN[2];
   __fp_u __MAX[2];
 __fp_s;
 }

(** unsupported pragma#pragma pack()*)
{ extern const __fp_s __fp_characteristics[3]; }


// fenv.h

{ these interfaces not presently supported!  }
{ floating-point exception bits for 'excepts' argument  }

{ turn on 1-byte packing...  }

  { these interfaces not presently supported!  }

 const
   _MAX_FPFLAGS  = 8;
  { floating-point exception bits for 'excepts' argument  }
   FE_DIVBYZERO  = $00000001;
   FE_INEXACT    = $00000002;
   FE_INVALID    = $00000004;
   FE_OVERFLOW   = $00000008;
   FE_UNDERFLOW  = $00000010;
   FE_ALL_EXCEPT = $00000020;
   FE_DOWNWARD   = $00000040;
   FE_TONEAREST  = $00000080;
   FE_TOWARDZERO = $00000100;
   FE_UPWARD     = $00000200;
   FE_DFL_ENV    = $00000400;


type
   Pfexcept_t = ^fexcept_t;
   fexcept_t = dword;

   Pfenv_t = ^fenv_t;
   fenv_t = record
        excepts : longint;
        flagp : fexcept_t;
     end;


(** unsupported pragma#pragma pack()*)
{ not presently supported...  }

procedure feclearexcept(excepts:longint);cdecl;external libc_nlm name 'feclearexcept';
procedure fegetexceptflag(flagp:Pfexcept_t; excepts:longint);cdecl;external libc_nlm name 'fegetexceptflag';
procedure feraiseexceptflag(flagp:Pfexcept_t; excepts:longint);cdecl;external libc_nlm name 'feraiseexceptflag';
procedure fesetexceptflag(flagp:Pfexcept_t; excepts:longint);cdecl;external libc_nlm name 'fesetexceptflag';
function fetestexcept(excepts:longint):longint;cdecl;external libc_nlm name 'fetestexcept';
function fegetround(round:longint):longint;cdecl;external libc_nlm name 'fegetround';
function fesetround:longint;cdecl;external libc_nlm name 'fesetround';
function fegetenv(envp:Pfenv_t):longint;cdecl;external libc_nlm name 'fegetenv';
function feholdexcept(envp:Pfenv_t):longint;cdecl;external libc_nlm name 'feholdexcept';
procedure fesetenv(envp:Pfenv_t);cdecl;external libc_nlm name 'fesetenv';
procedure feupdateenv(envp:Pfenv_t);cdecl;external libc_nlm name 'feupdateenv';



// fnmatch.h

  const
     FNM_NOMATCH = -(1);     { string fails to match pattern  }
  { values for field 'flags'...  }
     FNM_NOSYS       = $01;  { reserved (unused)                              }
     FNM_PATHNAME    = $02;  { slash in string must match in pattern          }
     FNM_PERIOD      = $04;  { leading period in string must match in pattern }
     FNM_NOESCAPE    = $08;  { disable backslash escaping                     }
     FNM_CASEFOLD    = $10;  { ignore case                                    }
     FNM_LEADING_DIR = $20;  { Ignore `/...' after a match                    }
     FNM_FILE_NAME   = FNM_PATHNAME;



function fnmatch(pattern, _string:Pchar; flags:longint):longint;cdecl;external libc_nlm name 'fnmatch';



// fshooks.h

  const
     FSHOOK_MAY_NOT_SLEEP_BIT    = $00000001;
     FSHOOK_SORT_LOW_TO_HIGH_BIT = $00000002;
     FSHOOK_CONSUMABLE_BIT       = $00000004;
     FSHOOK_NO_SA_BIT            = $00000008;
     FSHOOK_NO_AUDITOR_BIT       = $00000010;
     FSHOOK_NO_CHECK_BIT         = $00000020;
     FSHOOK_NESL_DATA_BIT        = $00000040;
     FSHOOK_NESL_SHIM_BIT        = $00000080;
     FSHOOK_DATA_FILTERED_BIT    = $80000000;

     FSHOOK_TYPE_DELETE_WARN               = 0;
     FSHOOK_TYPE_DELETE_REPORT             = 1;
     FSHOOK_TYPE_CREATE_WARN               = 2;
     FSHOOK_TYPE_CREATE_REPORT             = 3;
     FSHOOK_TYPE_OPEN_WARN                 = 4;
     FSHOOK_TYPE_OPEN_REPORT               = 5;
     FSHOOK_TYPE_CLOSE_WARN                = 6;
     FSHOOK_TYPE_CLOSE_REPORT              = 7;
     FSHOOK_TYPE_RENAME_WARN               = 8;
     FSHOOK_TYPE_RENAME_REPORT             = 9;
     FSHOOK_TYPE_MODIFYINFO_WARN           = 10;
     FSHOOK_TYPE_MODIFYINFO_REPORT         = 11;
     FSHOOK_TYPE_SETDATASIZE_WARN          = 12;
     FSHOOK_TYPE_SETDATASIZE_REPORT        = 13;
     FSHOOK_TYPE_ADDTRUSTEE_WARN           = 14;
     FSHOOK_TYPE_ADDTRUSTEE_REPORT         = 15;
     FSHOOK_TYPE_REMOVETRUSTEE_WARN        = 16;
     FSHOOK_TYPE_REMOVETRUSTEE_REPORT      = 17;
     FSHOOK_TYPE_SETINHERITEDRIGHTS_WARN   = 18;
     FSHOOK_TYPE_SETINHERITEDRIGHTS_REPORT = 19;
     FSHOOK_TYPE_CHANGEVOLSTATE_WARN       = 20;
     FSHOOK_TYPE_CHANGEVOLSTATE_REPORT     = 21;
     FSHOOK_TYPE_CHANGEPOOLSTATE_WARN      = 22;
     FSHOOK_TYPE_CHANGEPOOLSTATE_REPORT    = 23;


{==========================================================
  NSS file system hooks
  These are based on the Novell Event Bus, supported by NSS
==========================================================}
type
   Pfse_info = ^fse_info;
   fse_info = record
        version   : longint;                  // event block version
        reserved1 : longint;                  // do not modify
        reserved2 : pointer;                  // do not modify
        rtag      : rtag_t;                   // registerer's resource tag
        link      : Pfse_info;                // used by registerer to link blocks
        regID     : pointer;                  // registerer of the event
        regSpace  : pointer;                  // scratch space for registerer's use
        consID    : pointer;                  // consumer of event if relevant
        length    : size_t;                   // in bytes of event data
        data      : pointer;                  // pointer to data
        reserved3 : array[0..3] of pointer;   // do not modify
        _type     : longint;                  // one of NSS_FSTYPE_-...
        userParm  : pointer;                  // specified at time of registration
        parm0     : pointer;                  // value depends on event type
        parm1     : pointer;                  // ibid
        flags     : dword;                    // as noted above
     end;
   fsevent_info_t = fse_info;
   Pfsevent_info_t = ^fsevent_info_t;
   Pfsevent_info = Pfsevent_info_t;
   Tfsevent_info = fsevent_info_t;

   Pzkey_t = ^zkey_t;
   zkey_t = Tuint64;

   Pzid_t = ^zid_t;
   zid_t = Tuint64;

   Pvolid_t = ^volid_t;
   volid_t = record
        timeLow : dword;
        timeMid : word;
        timeHighAndVersion : word;
        clockSeqHighAndReserved : byte;
        clockSeqLow : byte;
        node : array[0..5] of byte;
     end;
   userid_t = volid_t;
   Puserid_t = ^userid_t;
   TVolId = volid_t;
   PVolId = pvolid_t;
   TUserId = userid_t;
   PUserId = puserid_t;

   Ptimeinfo_t = ^timeinfo_t;
   timeinfo_t = record
        accessedTime,                    // last time file was accessed
        createdTime,                     // time file was created
        modifiedTime,                    // last time data was changed
        metaDataModifiedTime : time_t;   // last time metadata was changed
     end;
   Ttimeinfo = timeinfo_t;
   Ptimeinfo = Ptimeinfo_t;

{ commonlity in call-back structures...  }
{ NSS (NetWare 6) filesystem hooks events and call-back data structures...  }

   Pdel_warn_t = ^del_warn_t;
   del_warn_t = record
        enterExitID,
        slotID,
        taskID : dword;
        zid    : zid_t;
        volID  : volid_t;
     end;
   Tdel_warn = del_warn_t;
   Pdel_warn = Pdel_warn_t;


   Pdel_report_t = ^del_report_t;
   del_report_t = record
        enterExitID    : dword;
        enterRetStatus,
        opRetCode      : longint;
     end;
   Tdel_report = del_report_t;
   Pdel_report = Pdel_report_t;

   Pcreate_warn_t = ^create_warn_t;
   create_warn_t = record
        enterExitID,
        slotID,
        taskID          : dword;
        zid             : zid_t;
        volID           : volid_t;
        name            : Punicode_t;
        fileType,
        fileAttributes,
        createFlags     : dword;
        createParms     : pointer;
        requestedRights,
        createAndOpen   : dword;
     end;
   Tcreate_warn = create_warn_t;
   Pcreate_warn = Pcreate_warn_t;

   Pcreate_report_t = ^create_report_t;
   create_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        retOpenCreateAction : dword;
        retKey : zkey_t;
        retZid : zid_t;
        retVolID : volid_t;
        times : timeinfo_t;
     end;
   Tcreate_report = create_report_t;
   Pcreate_report = Pcreate_report_t;

   Popen_warn_t = ^open_warn_t;
   open_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        requestedRights : dword;
        openParms : pointer;
     end;
   Topen_warn = open_warn_t;
   Popen_warn = Popen_warn_t;

   Popen_report_t = ^open_report_t;
   open_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        retKey : zkey_t;
        retZid : zid_t;
        retVolID : volid_t;
        times : timeinfo_t;
     end;
   Topen_report = open_report_t;
   Popen_report = Popen_report_t;

   Pclose_warn_t = ^close_warn_t;
   close_warn_t = record
        enterExitID : dword;
        slotID : dword;
        key : zkey_t;
        fhState : dword;
        times : timeinfo_t;
     end;
   Tclose_warn = close_warn_t;
   Pclose_warn = Pclose_warn_t;

   Pclose_report_t = ^close_report_t;
   close_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        fileDeleted : dword;
     end;
   Tclose_report = close_report_t;
   Pclose_report = Pclose_report_t;

   Pren_warn_t = ^ren_warn_t;
   ren_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        destZid : zid_t;
        destName : Punicode_t;
        renameFlags : dword;
     end;
   Tren_warn = ren_warn_t;
   Pren_warn = Pren_warn_t;

   Pren_report_t = ^ren_report_t;
   ren_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
     end;
   Tren_report = ren_report_t;
   Pren_report = Pren_report_t;


   Pzinfo_t = ^zinfo_t;
   zinfo_t = record
        version : dword;
        totalBytes : size_t;
        nextByte : size_t;
        padding : dword;
        retMask : Tuint64;
        std : record
             zid : zid_t;
             dataStreamZid : zid_t;
             parentZid : zid_t;
             logicalEOF : off64_t;
             volumeID : volid_t;
             fileType : dword;
             fileAttributes : dword;
             fileAttributesModMask : dword;
             padding : dword;
          end;
        storageUsed : record
             physicalEOF : size64_t;
             dataBytes : size64_t;
             metaDataBytes : size64_t;
          end;
        primaryNameSpaceID : longint;
        nameStart : off_t;
        names : record
             numEntries : size_t;
             fileNameArray : off_t;
          end;
        time : record
             created : Tuint64;
             archived : Tuint64;
             modified : Tuint64;
             accessed : Tuint64;
             metaDataModified : Tuint64;
          end;
        id : record
             owner : userid_t;
             archiver : userid_t;
             modifier : userid_t;
             metaDataModifier : userid_t;
          end;
        blockSize : record
             size : size_t;
             sizeShift : off_t;
          end;
        count : record
             open : longint;
             hardLink : longint;
          end;
        dataStream : record
             count : longint;
             totalNameSize : size_t;
             totalDataSize : size64_t;
          end;
        extAttr : record
             count : size_t;
             totalNameSize : size_t;
             totalDataSize : size64_t;
          end;
        deleted : record
             time : Tuint64;
             id : userid_t;
          end;
        macNS : record
             finderInfo : record
                 case longint of
                    0 : ( generic : array[0..31] of byte );
                    1 : ( macintosh : record
                         FInfo : record
                              fdType : longint;
                              fdCreator : longint;
                              fdFlags : Tint16;
                              fdLocation : record
                                   v : Tint16;
                                   h : Tint16;
                                end;
                              fdFldr : Tint16;
                           end;
                         extended : record
                             case longint of
                                0 : ( FXInfo : record
                                     fdIconID : Tint16;
                                     fdUnused : Tint16;
                                     fdScript : int8_t;
                                     fdFlags : int8_t;
                                     fdComment : Tint16;
                                     fdPutAway : longint;
                                  end );
                                1 : ( DXInfo : record
                                     frScroll : record
                                          v : Tint16;
                                          h : Tint16;
                                       end;
                                     frOpenChain : longint;
                                     fdScript : int8_t;
                                     fdFlags : int8_t;
                                     fdComment : Tint16;
                                     fdPutAway : longint;
                                  end );
                             end;
                      end );
                 end;
             proDOSInfo : array[0..5] of byte;
             filler : array[0..1] of byte;
             dirRightsMask : dword;
          end;
        unixNS : record
             fMode : dword;
             rDev : dword;
             myFlags : dword;
             nfsUID : dword;
             nfsGID : dword;
             nwUID : dword;
             nwGID : dword;
             nwEveryone : dword;
             nwUIDRights : dword;
             nwGIDRights : dword;
             nwEveryoneRights : dword;
             acsFlags : byte;
             firstCreated : byte;
             variableSize : size_t;
             offsetToData : off_t;
          end;
        volumeID : volid_t;
        ndsObjectID : userid_t;
        volumeState : dword;
        nameSpaceMask : dword;
        features : record
             enabled : Tuint64;
             enableModMask : Tuint64;
             supported : Tuint64;
          end;
        maximumFileSize : size64_t;
        totalSpaceQuota : size64_t;
        numUsedBytes : size64_t;
        numObjects : size64_t;
        numFiles : size64_t;
        authModelID : dword;
        dataShreddingCount : size_t;
        salvage : record
             purgeableBytes : size64_t;
             nonPurgeableBytes : size64_t;
             numDeletedFiles : size64_t;
             oldestDeletedTime : Tuint64;
             minKeepSeconds : size_t;
             maxKeepSeconds : size_t;
             lowWaterMark : size_t;
             highWaterMark : size_t;
          end;
        comp : record
             numCompressedFiles : size64_t;
             numCompDelFiles : size64_t;
             numUncompressibleFiles : size64_t;
             numPreCompressedBytes : size64_t;
             numCompressedBytes : size64_t;
          end;
        pool : record
             poolID : volid_t;
             ndsObjectID : userid_t;
             poolState : dword;
             nameSpaceMask : dword;
             features : record
                  enabled : Tuint64;
                  enableModMask : Tuint64;
                  supported : Tuint64;
               end;
             totalSpace : size64_t;
             numUsedBytes : size64_t;
             purgeableBytes : size64_t;
             nonPurgeableBytes : size64_t;
          end;
        extAttrUserFlags : dword;
        variableData : array[0..0] of byte;
     end;
   Tzinfo = zinfo_t;
   Pzinfo = Pzinfo_t;

   Pmod_warn_t = ^mod_warn_t;
   mod_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        modifyInfoMask : dword;
        modifyTypeInfoMask : dword;
        modifyInfo : Pzinfo_t;
        modifyTypeInfo : pointer;
     end;
   Tmod_warn = mod_warn_t;
   Pmod_warn = Pmod_warn_t;

   Pmod_report_t = ^mod_report_t;
   mod_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
     end;
   Tmod_report = mod_report_t;
   Pmod_report = Pmod_report_t;

   Psetsize_warn_t = ^setsize_warn_t;
   setsize_warn_t = record
        enterExitID : dword;
        slotID : dword;
        key : zkey_t;
        curEOF : Tuint64;
        newEOF : Tuint64;
        setSizeFlags : dword;
     end;
   Tsetsize_warn = setsize_warn_t;
   Psetsize_warn = Psetsize_warn_t;

   Psetsize_report_t = ^setsize_report_t;
   setsize_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        newEOF : Tuint64;
     end;
   Tsetsize_report = setsize_report_t;
   Psetsize_report = Psetsize_report_t;

   Paddtrustee_warn_t = ^addtrustee_warn_t;
   addtrustee_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        trusteeID : userid_t;
        rights : dword;
        attributes : dword;
     end;
   Taddtrustee_warn = addtrustee_warn_t;
   Paddtrustee_warn = Paddtrustee_warn_t;

   Paddtrustee_report_t = ^addtrustee_report_t;
   addtrustee_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
     end;

   Taddtrustee_report = addtrustee_report_t;
   Paddtrustee_report = Paddtrustee_report_t;

   Premtrustee_warn_t = ^remtrustee_warn_t;
   remtrustee_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        trusteeID : userid_t;
        purgedFileFlag : dword;
     end;
   Tremtrustee_warn = remtrustee_warn_t;
   Premtrustee_warn = Premtrustee_warn_t;

   Premtrustee_report_t = ^remtrustee_report_t;
   remtrustee_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
     end;
   Tremtrustee_report = remtrustee_report_t;
   Premtrustee_report = Premtrustee_report_t;

   Psetrights_warn_t = ^setrights_warn_t;
   setrights_warn_t = record
        enterExitID : dword;
        slotID : dword;
        taskID : dword;
        zid : zid_t;
        volID : volid_t;
        inheritedRights : dword;
        authorizeFlag : longint;
     end;
   Tsetrights_warn = setrights_warn_t;
   Psetrights_warn = Psetrights_warn_t;

   Psetrights_report_t = ^setrights_report_t;
   setrights_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
     end;
   Tsetrights_report = setrights_report_t;
   Psetrights_report = Psetrights_report_t;

   Pxvolstate_warn_t = ^xvolstate_warn_t;
   xvolstate_warn_t = record
        enterExitID : dword;
        oldState : word;
        newState : word;
        mode : dword;
        volID : volid_t;
        poolID : volid_t;
     end;
   Txvolstate_warn = xvolstate_warn_t;
   Pxvolstate_warn = Pxvolstate_warn_t;

   Pxvolstate_report_t = ^xvolstate_report_t;
   xvolstate_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        oldState : word;
        newState : word;
        mode : dword;
        volID : volid_t;
        poolID : volid_t;
     end;
   Txvolstate_report = xvolstate_report_t;
   Pxvolstate_report = Pxvolstate_report_t;

   Pxpoolstate_warn_t = ^xpoolstate_warn_t;
   xpoolstate_warn_t = record
        enterExitID : dword;
        oldState : word;
        newState : word;
        mode : dword;
        poolID : volid_t;
     end;
   Txpoolstate_warn = xpoolstate_warn_t;
   Pxpoolstate_warn = Pxpoolstate_warn_t;


   Pxpoolstate_report_t = ^xpoolstate_report_t;
   xpoolstate_report_t = record
        enterExitID : dword;
        enterRetStatus : longint;
        opRetCode : longint;
        oldState : word;
        newState : word;
        mode : dword;
        poolID : volid_t;
     end;
   Txpoolstate_report = xpoolstate_report_t;
   Pxpoolstate_report = Pxpoolstate_report_t;

{============================================================
 Traditional file system hooks
 These were interfaced by CLib in its NDK header, nwfshook.h.
============================================================}

   PEraseFileCallBackStruct = ^TEraseFileCallBackStruct;
   TEraseFileCallBackStruct = record
     case longint of
      0: (slot : longint);
      1: (connection : longint;
          task : longint;
          volume : longint;
          dirBase : longint;
          pathString : Pchar;
          pathComponentCount : longint;
          nameSpace : longint;
          attributeMatchBits : dword);
     end;
{ (see fsio.h)  }

   POpenFileCallBackStruct = ^TOpenFileCallBackStruct;
   TOpenFileCallBackStruct = record
        case longint of
          0: (slot : longint);
          1: (connection : longint;
              task : longint;
              volume : longint;
              dirBase : longint;
              pathString : Pchar;
              pathComponentCount : longint;
              nameSpace : longint;
              attributeMatchBits : dword;
              requestedAccessRights : dword;
              dataStreamNumber : longint;
              fileHandle : Plongint);
     end;

   PCreateFileCallBackStruct = ^TCreateFileCallBackStruct;
   TCreateFileCallBackStruct = record
      case integer of
        0: (connection : longint);
        1: (slot : longint;
            task : longint;
            volume : longint;
            dirBase : longint;
            pathString : Pchar;
            pathComponentCount : longint;
            nameSpace : longint;
            createAttributeBits : dword;
            createFlagBits : dword;
            dataStreamNumber : longint;
            fileHandle : Plongint);
     end;

   PCreateAndOpenCallBackStruct = ^TCreateAndOpenCallBackStruct;
   TCreateAndOpenCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint;
           createAttributeBits : dword;
           requestedAccessRights : dword;
           createFlagBits : dword;
           dataStreamNumber : longint;
           fileHandle : Plongint);
     end;

   PRenameMoveEntryCallBackStruct = ^TRenameMoveEntryCallBackStruct;
   TRenameMoveEntryCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint;
           attributeMatchBits : dword;
           subDirsOnlyFlag : longint;
           newDirBase : longint;
           newPathString : Pchar;
           originalNewCount : longint;
           compatibilityFlag : dword;
           allowRenamesToMyselfFlag : longint);
     end;

   PCloseFileCallBackStruct = ^TCloseFileCallBackStruct;
   TCloseFileCallBackStruct = record
     case integer of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           fileHandle : longint);
     end;

   PCreateDirCallBackStruct = ^TCreateDirCallBackStruct;
   TCreateDirCallBackStruct = record
     case integer of
       0: (connection : longint);
       1: (slot : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint;
           directoryAccessMask : dword);
     end;

   PDeleteDirCallBackStruct = ^TDeleteDirCallBackStruct;
   TDeleteDirCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint);
     end;

   Tmodifyvector = record
             MModifyName : Pchar;
             MFileAttributes : dword;
             MFileAttributesMask : dword;
             MCreateDate : word;
             MCreateTime : word;
             MOwnerID : dword;
             MLastArchivedDate : word;
             MLastArchivedTime : word;
             MLastArchivedID : dword;
             MLastUpdatedDate : word;
             MLastUpdatedTime : word;
             MLastUpdatedID : dword;
             MLastAccessedDate : word;
             MInheritanceGrantMask : word;
             MInheritanceRevokeMask : word;
             MMaximumSpace : size_t;
             MLastUpdatedInSeconds : time_t;
          end;
   Pmodifyvector = ^Tmodifyvector;

   PModifyDirEntryCallBackStruct = ^TModifyDirEntryCallBackStruct;
   TModifyDirEntryCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint;
           attributeMatchBits : dword;
           targetNameSpace : longint;
           modifyVector : Pmodifyvector;
           modifyBits : dword;
           allowWildCardsFlag : longint);
     end;

   PSalvageDeletedCallBackStruct = ^TSalvageDeletedCallBackStruct;
   TSalvageDeletedCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           volume : longint;
           dirBase : longint;
           toBeSalvagedDirBase : longint;
           nameSpace : longint;
           newName : Pchar);
     end;

   PPurgeDeletedCallBackStruct = ^TPurgeDeletedCallBackStruct;
   TPurgeDeletedCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           volume : longint;
           dirBase : longint;
           toBePurgedDirBase : longint;
           nameSpace : longint);
     end;

   PRenameNSEntryCallBackStruct = ^TRenameNSEntryCallBackStruct;
   TRenameNSEntryCallBackStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           dirBase : longint;
           pathString : Pchar;
           pathComponentCount : longint;
           nameSpace : longint;
           matchBits : dword;
           newName : Pchar);
     end;

   PGenericSalvageDeletedCBStruct = ^TGenericSalvageDeletedCBStruct;
   TGenericSalvageDeletedCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           nameSpace : longint;
           sequence : longint;
           volume : longint;
           dirBase : longint;
           newName : Pchar);
     end;

   PGenericPurgeDeletedCBStruct = ^TGenericPurgeDeletedCBStruct;
   TGenericPurgeDeletedCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           nameSpace : longint;
           sequence : longint;
           volume : longint;
           dirBase : longint);
     end;

   PGenericOpenCreateCBStruct = ^TGenericOpenCreateCBStruct;
   TGenericOpenCreateCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           pathComponentCount : longint;
           dirBase : longint;
           pathString : Pchar;
           nameSpace : longint;
           dataStreamNumber : longint;
           openCreateFlags : dword;
           searchAttributes : dword;
           createAttributes : dword;
           requestedAccessRights : dword;
           returnInfoMask : dword;
           fileHandle : Plongint;
           openCreateAction : Pchar);
     end;

   PGenericRenameCBStruct = ^TGenericRenameCBStruct;
   TGenericRenameCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           nameSpace : longint;
           renameFlag : longint;
           searchAttributes : dword;
           srcVolume : longint;
           srcPathComponentCount : longint;
           srcDirBase : longint;
           srcPathString : Pchar;
           dstVolume : longint;
           dstPathComponentCount : longint;
           dstDirBase : longint;
           dstPathString : Pchar);
     end;

   PGenericEraseFileCBStruct = ^TGenericEraseFileCBStruct;
   TGenericEraseFileCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           pathComponentCount : longint;
           dirBase : longint;
           pathString : Pchar;
           nameSpace : longint;
           searchAttributes : dword);
     end;

   PGenericModifyDOSInfoCBStruct = ^TGenericModifyDOSInfoCBStruct;
   TGenericModifyDOSInfoCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           volume : longint;
           pathComponentCount : longint;
           dirBase : longint;
           pathString : Pchar;
           nameSpace : longint;
           searchAttributes : dword;
           modifyMask : dword;
           modifyInfo : pointer);
     end;

   PGenericModifyNSInfoCBStruct = ^TGenericModifyNSInfoCBStruct;
   TGenericModifyNSInfoCBStruct = record
     case longint of
       0: (connection : longint);
       1: (slot : longint;
           task : longint;
           dataLength : size_t;
           srcNameSpace : longint;
           dstNameSpace : longint;
           volume : longint;
           dirBase : longint;
           modifyMask : dword;
           modifyInfo : pointer);
     end;
{============================================================================
** NSS file system hook prototypes...
 }

//type TCdeclPfsEventFunc = function (info:Pfsevent_info_t):longint; cdecl;
type TCdeclPfsEventFunc = function (var info:Tfsevent_info):longint; cdecl;

function fs_register(_type:longint; cbFunc:TCdeclPfsEventFunc; userParm:pointer):longint;cdecl;external libc_nlm name 'fs_register';
function fs_unregister(_type:longint; cbFunc:TCdeclPfsEventFunc):longint;cdecl;external libc_nlm name 'fs_unregister';

function fs_mapkeytopath(key:zkey_t; path:Punicode_t; maxpathlen:Psize_t; want_volume:longint):longint;cdecl;external libc_nlm name 'fs_mapkeytopath';
function fs_mapkeytopath(key:zkey_t; path:Punicode_t; maxpathlen:Psize_t; want_volume:longbool):longint;cdecl;external libc_nlm name 'fs_mapkeytopath';
function fs_mapkeytopath(key:zkey_t; path:Punicode_t; var maxpathlen:longint; want_volume:longint):longint;cdecl;external libc_nlm name 'fs_mapkeytopath';
function fs_mapkeytopath(key:zkey_t; path:Punicode_t; var maxpathlen:longint; want_volume:longbool):longint;cdecl;external libc_nlm name 'fs_mapkeytopath';

function fs_mapzidtopath(zid:zid_t; volId:Pvolid_t; path:Punicode_t; maxpathlen:Psize_t; want_volume:longint):longint;cdecl;external libc_nlm name 'fs_mapzidtopath';
function fs_mapzidtopath(zid:zid_t; volId:Pvolid_t; path:Punicode_t; maxpathlen:Psize_t; want_volume:longbool):longint;cdecl;external libc_nlm name 'fs_mapzidtopath';
function fs_mapzidtopath(zid:zid_t; var volId:volid_t; path:Punicode_t; var maxpathlen:longint; want_volume:longint):longint;cdecl;external libc_nlm name 'fs_mapzidtopath';
function fs_mapzidtopath(zid:zid_t; var volId:volid_t; path:Punicode_t; var maxpathlen:longint; want_volume:longbool):longint;cdecl;external libc_nlm name 'fs_mapzidtopath';

function fs_read(key:zkey_t; buf:pointer; off:off64_t; len:size_t; bytes:Pssize_t):longint;cdecl;external libc_nlm name 'fs_read';
function fs_read(key:zkey_t; var buf; off:off64_t; len:size_t; var bytes:ssize_t):longint;cdecl;external libc_nlm name 'fs_read';

function fs_write(key:zkey_t; buf:pointer; off:off64_t; len:size_t; bytes:Pssize_t):longint;cdecl;external libc_nlm name 'fs_write';
function fs_write(key:zkey_t; var buf; off:off64_t; len:size_t; var bytes:ssize_t):longint;cdecl;external libc_nlm name 'fs_write';


{============================================================================
 Generic information (NEB and traditional) based on connection slot. This
 has little to do with file system hooks, but in LibC, there is no way to
 get a hold of a connection slot except through file system hook interfaces.}
function fs_getslotinfo(slot:longint;
                        name:Pchar;
                        objectType:PWord;
                        objectId:Pdword;
                        loginTime:Pointer):longint;cdecl;external libc_nlm name 'fs_getslotinfo';
function fs_getslotinfo(slot:longint;
                        name:Pchar;
                        var objectType:word;
                        var objectId:dword;
                        var loginTime):longint;cdecl;external libc_nlm name 'fs_getslotinfo';

// Clib compatible function name:
function GetConnectionInformation (connectionNumber:longint;
                                   objectName      :Pchar;
                                   objectType      :PWORD;
                                   objectID        :Plongint;
                                   loginTime       :pointer):longint;cdecl;external libc_nlm name 'fs_getslotinfo';
function GetConnectionInformation (connectionNumber:longint;
                                   objectName      :Pchar;
                               var objectType      :word;
                               var objectID        :longint;
                               var loginTime):longint;cdecl;external libc_nlm name 'fs_getslotinfo';



{==========================================
 Traditional file system hook prototypes... }

type TCDeclFunc1PtrArgLongint = function (info:pointer):longint; cdecl;

function fst_register(_type:longint; cbFunc:pointer):longint;cdecl;external libc_nlm name 'fst_register';
function fst_unregister(_type:longint; cbFunc:pointer):longint;cdecl;external libc_nlm name 'fst_unregister';
function fst_getvoldir(slot:longint; fileHandle:longint; namespace:longint; volNum:Plongint; dirBase:Plongint):longint;cdecl;external libc_nlm name 'fst_getvoldir';
function fst_getvoldir(slot, fileHandle, namespace:longint; var volNum, dirBase:longint):longint;cdecl;external libc_nlm name 'fst_getvoldir';
function fst_getorignamespace(volNum, dirBase:longint; namespace:Plongint):longint;cdecl;external libc_nlm name 'fst_getorignamespace';
function fst_getorignamespace(volNum, dirBase:longint; var namespace:longint):longint;cdecl;external libc_nlm name 'fst_getorignamespace';
function fst_mapvoldirtopath(volNum,dirBase,namespace:longint; path:Pchar; maxPathLen:longint):longint;cdecl;external libc_nlm name 'fst_mapvoldirtopath';
function fst_mapvoltoname(volNum:longint; name:Pchar):longint;cdecl;external libc_nlm name 'fst_mapvoltoname';
function fst_read(slot,fileHandle:longint; buffer:pointer; offset:off64_t; length:size_t;
           bytes:Plongint):longint;cdecl;external libc_nlm name 'fst_read';
function fst_read(slot,fileHandle:longint; buffer:pointer; offset:off64_t; length:size_t;
           var bytes:longint):longint;cdecl;external libc_nlm name 'fst_read';
function fst_write(slot, fileHandle:longint; buffer:pointer; offset:off64_t; length:size_t;
           bytes:Plongint):longint;cdecl;external libc_nlm name 'fst_write';
function fst_write(slot, fileHandle:longint; buffer:pointer; offset:off64_t; length:size_t;
           var bytes:longint):longint;cdecl;external libc_nlm name 'fst_write';
function fst_size(slot, fileHandle:longint; length:Poff64_t):longint;cdecl;external libc_nlm name 'fst_size';
function fst_flush(slot, fileHandle:longint):longint;cdecl;external libc_nlm name 'fst_flush';


type
   Pfst_info_t = ^fst_info_t;
   fst_info_t = record
        volNum,
        DosBase,
        dirBase,
        namespace,
        datastream : longint;
        flags : dword;
     end;
    Tfst_info = fst_info_t;
    Pfst_info = Pfst_info_t;

function fst_getinfo(slot,fileHandle:longint; info:Pfst_info_t):longint;cdecl;external libc_nlm name 'fst_getinfo';
function fst_getinfo(slot,fileHandle:longint; var info:fst_info_t):longint;cdecl;external libc_nlm name 'fst_getinfo';


// getopt.h

{ values for 'has_arg'...  }
const
  no_argument = 0;
  required_argument = 1;
  optional_argument = 2;

{ definition for getopt_long() and getopt_long_only()...  }

type
   Poption = ^option;
   option = record
        name    : Pchar;
        has_arg : longint;
        flag    : Plongint;
        val     : longint;
     end;

function getopt_long(argc:longint; argv:array of Pchar; optstring:Pchar; longopts:Poption; longindex:Plongint):longint;cdecl;external libc_nlm name 'getopt_long';
function getopt_long_only(argc:longint; argv:array of Pchar; optstring:Pchar; longopts:Poption; longindex:Plongint):longint;cdecl;external libc_nlm name 'getopt_long_only';

// err.h

  const
     GLOB_APPEND = $0001;
     GLOB_DOOFFS = $0002;        { use gl_offs                                }
     GLOB_ERR = $0004;           { return on error                            }
     GLOB_MARK = $0008;          { append / to matching directories           }
     GLOB_NOCHECK = $0010;       { return pattern itself if nothing matches   }
     GLOB_NOSORT = $0020;        { don't sort                                 }
     GLOB_ALTDIRFUNC = $0040;    { use alternately specified directory funcs  }
     GLOB_BRACE = $0080;         { expand braces ala csh                      }
     GLOB_MAGCHAR = $0100;       { pattern had globbing characters            }
     GLOB_NOMAGIC = $0200;       { GLOB_NOCHECK without magic chars (csh)     }
     GLOB_QUOTE = $0400;         { quote special chars with \                 }
     GLOB_TILDE = $0800;         { expand tilde names from the passwd file    }
     GLOB_NOESCAPE = $1000;      { disable backslash escaping                 }
     GLOB_LIMIT = $2000;         { limit pattern match output to ARG_MAX      }
  { error values returned by glob(3)  }
     GLOB_NOSPACE = -(1);        { malloc call failed                         }
     GLOB_ABORTED = -(2);        { unignored error                            }
     GLOB_NOMATCH = -(3);        { no match and GLOB_NOCHECK not set          }
  { function not supported }
     GLOB_NOSYS = -(4);
     GLOB_ABEND = GLOB_ABORTED;

type
   Pglob_t = ^glob_t;
   glob_t = record
        gl_pathc : longint;
        gl_matchc : longint;
        gl_offs : longint;
        gl_flags : longint;
        gl_pathv : ^Pchar;
        gl_errfunc : function (_para1:Pchar; _para2:longint):longint;cdecl;
        gl_closedir : procedure (_para1:pointer);
        gl_readdir : function (_para1:pointer):Pdirent;
        gl_opendir : function (_para1:Pchar):pointer;
        gl_lstat : function (_para1:Pchar; _para2:Pstat):longint;
        gl_stat : function (_para1:Pchar; _para2:Pstat):longint;
     end;

// grp.h

type
   Pgroup = ^group;
   group = record
        gr_name : Pchar;
        gr_passwd : Pchar;
        gr_gid : gid_t;
        gr_spare : gid_t;
        gr_mem : ^Pchar;
     end;

function getgrgid(gid:gid_t):Pgroup;cdecl;external libc_nlm name 'getgrgid';
function getgrnam(name:Pchar):Pgroup;cdecl;external libc_nlm name 'getgrnam';

// guid.h
// iconv.h

type
   Piconv_t = ^iconv_t;
   iconv_t = longint;

function iconv_open(tocode:Pchar; fromcode:Pchar):iconv_t;cdecl;external libc_nlm name 'iconv_open';
function iconv(cd:iconv_t; inbuf:PPchar; inbytesleft:Psize_t; outbuf:PPchar; outbytesleft:Psize_t):size_t;cdecl;external libc_nlm name 'iconv';
function iconv_close(cd:iconv_t):longint;cdecl;external libc_nlm name 'iconv_close';


// inttypes.h

{ printf-style macros for signed and unsigned integers...  }
{ scanf-style macros for signed and unsigned integers...  }


// iso646.h

// nl_types.h

  const
     NL_SETD = 1;
  { 'oflag' value for catopen()...  }
  { base on value of environment variable "LANG"  }
     NL_CAT_DEFAULT = 0;
  { base on LC_MESSAGES in effect  }
     NL_CAT_LOCALE = 1;
{$define _NL_ITEM}

type
   Pnl_item = ^nl_item;
   nl_item = longint;
   Pnl_catd = ^nl_catd;
   nl_catd = longint;

function catclose(catd:nl_catd):longint;cdecl;external libc_nlm name 'catclose';
function catgets(catd:nl_catd; set_id:longint; msg_id:longint; _string:Pchar):Pchar;cdecl;external libc_nlm name 'catgets';
function catopen(name:Pchar; oflag:longint):nl_catd;cdecl;external libc_nlm name 'catopen';

// langinfo.h

  const
     DAY_1 = 1;    // Sunday
     DAY_2 = 2;    // Monday
     DAY_3 = 3;    // Tuesday
     DAY_4 = 4;    // Wednesday
     DAY_5 = 5;    // Thursday
     DAY_6 = 6;    // Friday
     DAY_7 = 7;    // Saturday
     ABDAY_1 = 8;  // Sun
     ABDAY_2 = 9;  // Mon
     ABDAY_3 = 10; // Tue
     ABDAY_4 = 11; // Wed
     ABDAY_5 = 12; // Thu
     ABDAY_6 = 13; // Fri
     ABDAY_7 = 14; // Sat
     MON_1 = 15;   // January
     MON_2 = 16;   // February
     MON_3 = 17;   // March
     MON_4 = 18;   // April
     MON_5 = 19;   // May
     MON_6 = 20;   // June
     MON_7 = 21;   // July
     MON_8 = 22;   // August
     MON_9 = 23;   // September
     MON_10 = 24;  // October
     MON_11 = 25;  // November
     MON_12 = 26;  // December
     ABMON_1 = 27; // Jan
     ABMON_2 = 28; // Feb
     ABMON_3 = 29;     // Mar
     ABMON_4 = 30;     // Apr
     ABMON_5 = 31;     // May
     ABMON_6 = 32;     // Jun
     ABMON_7 = 33;     // Jul
     ABMON_8 = 34;     // Aug
     ABMON_9 = 35;     // Sep
     ABMON_10 = 36;    // Oct
     ABMON_11 = 37;    // Nov
     ABMON_12 = 38;    // Dec
     RADIXCHAR = 39;   // radix character (not supported)
     THOUSEP = 40;     // separator for thousand
     CRNCYSTR = 43;    // currency symbol
     D_T_FMT = 44;     // string for formatting date and time
     D_FMT = 45;       // date format
     T_FMT = 46;       // time format
     AM_STR = 47;      // am string
     PM_STR = 48;      // pm string
     CODESET = 49;     // code set name
     T_FMT_AMPM = 50;  // a.m. or p.m. time format string (not supported)
     ERA = 51;         //era description segments (not supported)
     ERA_D_FMT = 52;   // era date format string (not supported)
     ERA_D_T_FMT = 53; // era date and time format string (not supported)
     ERA_T_FMT = 54;   // era time format string (not supported)
     ALT_DIGITS = 55;  // alternative symbols for digits  (not supported)
     _MAXSTRMSG = 57;  // maximum number of strings in langinfo


function nl_langinfo(item:nl_item):Pchar;cdecl;external libc_nlm name 'nl_langinfo';


// libgen.h

function basename(path:Pchar):Pchar;cdecl;external libc_nlm name 'basename';
function dirname(path:Pchar):Pchar;cdecl;external libc_nlm name 'dirname';


// library.h

{ return flags for get_app_type()...  }
  const
     LIBRARY_UNKNOWN = $01;
     LIBRARY_LIBC    = $02;  { thread has specific NKS/LibC context    }
     LIBRARY_CLIB    = $04;  { thread has CLib context                 }
     LIBRARY_JAVA    = $08;  { thread belongs to Java Virtual Machine  }

type
   Paddrsp_t = ^addrsp_t;
   addrsp_t = void;
{ O_RDONLY, etc. from fcntl.h...  }

   Predirect_t = ^redirect_t;
   redirect_t = record
        pathname : Pchar;
        oflag : longint;
     end;
{ traditional NetWare solution for libraries...  }

function get_app_data(lib_id:longint):pointer;cdecl;external libc_nlm name 'get_app_data';
function get_app_type:longint;cdecl;external libc_nlm name 'get_app_type';
function register_library(cleanupFunc:TCDeclFunc1PtrArgLongint):longint;cdecl;external libc_nlm name 'register_library';
function register_destructor(libid:longint; cleanupFunc:TCDeclFunc1PtrArgLongint):longint;cdecl;external libc_nlm name 'register_destructor';
function set_app_data(lib_id:longint; data_area:pointer):longint;cdecl;external libc_nlm name 'set_app_data';
function unregister_library(lib_id:longint):longint;cdecl;external libc_nlm name 'unregister_library';
{ more prototypes for library creators, debugging and other uses...  }
function cleardontunloadflag(handle:pointer):longint;cdecl;external libc_nlm name 'cleardontunloadflag';
function findnlmhandle(name:Pchar; space:addrsp_t):TNLMHandle;cdecl;external libc_nlm name 'findnlmhandle';
function getaddressspace:addrsp_t;cdecl;external libc_nlm name 'getaddressspace';
function getaddressspacename(space:addrsp_t; name:Pchar):Pchar;cdecl;external libc_nlm name 'getaddressspacename';
function getallocresourcetag:rtag_t;cdecl;external libc_nlm name 'getallocresourcetag';
function getnativethread:pointer;cdecl;external libc_nlm name 'getnativethread';
{ (current process)  }
function getnlmhandle:TNLMHandle;cdecl;external libc_nlm name 'getnlmhandle';
function getnlmhandlefromthread(thread:pointer):TNLMHandle;cdecl;external libc_nlm name 'getnlmhandlefromthread';
function getnlmname(handle:TNLMHandle; name:Pchar):Pchar;cdecl;external libc_nlm name 'getnlmname';
function getnlmloadpath(loadpath:Pchar):Pchar;cdecl;external libc_nlm name 'getnlmloadpath';
function getthreadname(threadid:pointer; name:Pchar; maxlen:size_t):longint;cdecl;external libc_nlm name 'getthreadname';
function _getthreadid:pointer;cdecl;external libc_nlm name 'getthreadid';
function library_calloc(handle:pointer; size:size_t; count:size_t):pointer;cdecl;external libc_nlm name 'library_calloc';
procedure library_free(addr:pointer);cdecl;external libc_nlm name 'library_free';
function library_malloc(handle:pointer; size:size_t):pointer;cdecl;external libc_nlm name 'library_malloc';
function library_msize(addr:pointer):size_t;cdecl;external libc_nlm name 'library_msize';
function library_realloc(handle:pointer; old:pointer; size:size_t):pointer;cdecl;external libc_nlm name 'library_realloc';
function nlmisloadedprotected:longint;cdecl;external libc_nlm name 'nlmisloadedprotected';
function setdontunloadflag(handle:pointer):longint;cdecl;external libc_nlm name 'setdontunloadflag';
function setthreadname(threadid:pointer; name:Pchar):longint;cdecl;external libc_nlm name 'setthreadname';
//!! function uname2(handle:pointer; info:Putsname; bits:dword):longint;cdecl;external libc_nlm name 'uname2';
function validateaddressrange(addr:pointer; bytes:size_t):longint;cdecl;external libc_nlm name 'validateaddressrange';
function verifynlmhandle(handle:pointer):pointer;cdecl;external libc_nlm name 'verifynlmhandle';
function construct_argc_argv(command_line:Pchar; argv0:Pchar; argc:Plongint; argv:array of Pchar):longint;cdecl;external libc_nlm name 'construct_argc_argv';
type TRedirectSpecs = array [0..2] of redirect_t;
function detect_redirection(r:TRedirectSpecs; argc:Plongint; argv:array of Pchar):longint;cdecl;external libc_nlm name 'detect_redirection';
{ name-logical additions to library_malloc...  }


// locale.h

{ locale categories...  }
{ turn on 1-byte packing...  }

  { for use with LC_ALL                          }

const
   MAX_LOCNAME_LEN = 31 + 1;
  { locale categories...  }
   LC_CTYPE    = 0;  { character classification (unsupported) }
   LC_COLLATE  = 1;  { the locale's collation table (unsupported) }
   LC_NUMERIC  = 2;  { the numeric part of struct lconv }
   LC_MONETARY = 3;  { the monetary part of struct lconv }
   LC_TIME     = 4;  { the time and date part of struct lconv }
   LC_MESSAGES = 5;  { new starting in NetWare v4.11 (unsupported) }
   LC_ALL      = 6;



{ for the current locale...                    }
{ internal representations...                  }
{ ibid                                         }
{ as returned from setlocale(LC_ALL, NULL)     }
{ -------------------------- [Numeric Conventions] ---------------------  }
{ decimal point                                }
{ separator for digits left of decimal         }
{ digit grouping size                          }
{ -------------------------- [Monetary Conventions] --------------------  }
{ currency symbol                              }
{ decimal point                                }
{ separator for digits left of decimal         }
{ digit grouping sizes                         }
{ string indicating positive quantities        }
{ string indicating negative quantities        }
{ count of digits right of decimal             }
{ for positive monetary quantities:            }
{   currency symbol precedes quantity          }
{   currency symbol separated by blank         }
{   position of positive symbol                }
{ for negative monetary quantities:            }
{   currency symbol precedes quantity          }
{   currency symbol separated by blank         }
{   position of negative symbol                }
{ (reserved for future use)                    }
{ -------------------------- [International Monetary Conventions] ------  }
{ international currency symbol and separator  }
{ (international) digits right of decimal      }
{ -------------------------- [Time and Date Conventions] ---------------  }
{ always enforce 24-hour display (Boolean)     }
{ hour and seconds separator                   }
{ hour separator when no seconds displayed     }
{ month/day/year separator                     }
{ hours:minutes:seconds format (hh:mm:ss)      }
{ month/day/year format (mm/dd/yyyy)           }
{ weekday, month, day and year format          }
{ delimited string indicating am and pm        }
{ delimited string indicating AM and PM        }
{ delimited string of day names                }
{ delimited string of abbreviated day names    }
{ delimited string of month names              }
{ delimited string of abbreviated month names  }
type
   Plconv = ^lconv;
   lconv = record
        country : longint;//cdecl;
        language : longint;
        name : array[0..7] of char;
        decimal_point : array[0..3] of char;
        thousands_sep : array[0..3] of char;
        grouping : array[0..3] of char;
        currency_symbol : array[0..3] of char;
        mon_decimal_point : array[0..3] of char;
        mon_thousands_sep : array[0..3] of char;
        mon_grouping : array[0..7] of char;
        positive_sign : array[0..3] of char;
        negative_sign : array[0..3] of char;
        frac_digits : char;
        p_cs_precedes : char;
        p_sep_by_space : char;
        p_sign_posn : char;
        n_cs_precedes : char;
        n_sep_by_space : char;
        n_sign_posn : char;
        reserved : char;
        int_curr_symbol : array[0..14] of char;
        int_frac_digits : char;
        always_24 : longint;
        hour_sep : array[0..3] of char;
        hour_sans_sec_sep : array[0..3] of char;
        date_sep : array[0..3] of char;
        time_fmt : array[0..15] of char;
        date_fmt : array[0..15] of char;
        full_date_fmt : array[0..31] of char;
        ampm : array[0..31] of char;
        _AMPM : array[0..31] of char;
        days : array[0..159] of char;
        day_abbrevs : array[0..159] of char;
        months : array[0..159] of char;
        month_abbrevs : array[0..159] of char;
     end;

{ sizeof(struct lconv) == 0x360 (864.)         }


(** unsupported pragma#pragma pack()*)
{ prototypes for functions standard and nonstandard...  }

function localeconv:Plconv;cdecl;external libc_nlm name 'localeconv';
function setlocale(_para1:longint; _para2:Pchar):Pchar;cdecl;external libc_nlm name 'setlocale';
//!! function derivelocale(_para1:Pchar; _para2:Pchar; _para3:array[0..(31 + 1)-1] of char):Pchar;cdecl;external libc_nlm name 'derivelocale';
function setlocale_r(_para1:longint; _para2:Pchar; _para3:Plconv; _para4:Pchar):Pchar;cdecl;external libc_nlm name 'setlocale_r';


// malloc.h
{
** According to ISO/IEC (ANSI) 9899:1990 and 1999, memory allocation and
** management functions are properly the domain of stdlib.h:
** void   *calloc ( size_t, size_t );
** void    free   ( void * );
** void   *malloc ( size_t );
** void   *realloc( void *, size_t );
**
** Non-standard functions from stdlib.h (don't define __STDC__ or these
** disappear):
** void   *alloca        ( size_t );
** size_t  msize         ( void * );
** int     mvalidate     ( void * );
** size_t  stackavail    ( void );
** void   *stackbase     ( void );
** size_t  stackwatermark( void );
 }


// math.h

{ constants for type exception using matherr()       }
{ turn on 1-byte packing...  }

  const
     DOMAIN = 1;
     SING = 2;      { argument singularity }
     OVERFLOW = 3;  { overflow range error }
     UNDERFLOW = 4; { underflow range error  }
     TLOSS = 5;     { total loss of significance }
     PLOSS = 6;     { partial loss of significance  }


{ for C++, __fp_exception; for C, exception  }
type
   Pexception = ^Texception;
   Texception = record
        _type : longint;
        name : Pchar;
        arg1 : double;
        arg2 : double;
        retval : double;
     end;

{ for C++, __COMPLEX; for C, complex  }
   Pcomplex = ^complex;
   complex = record
        real : double;
        imag : double;
     end;

(** unsupported pragma#pragma pack()*)
//var
//  ___nan_float : double;cvar;external;
//  ___huge_float : double;cvar;external;
//  ___huge_double : double;cvar;external;
//  ___huge_long_double : double;cvar;external;

function acos(_para1:double):double;cdecl;external libc_nlm name 'acos';
function asin(_para1:double):double;cdecl;external libc_nlm name 'asin';
function atan(_para1:double):double;cdecl;external libc_nlm name 'atan';
function atan2(_para1:double; _para2:double):double;cdecl;external libc_nlm name 'atan2';
function cbrt(_para1:double):double;cdecl;external libc_nlm name 'cbrt';
function ceil(_para1:double):double;cdecl;external libc_nlm name 'ceil';
function cos(_para1:double):double;cdecl;external libc_nlm name 'cos';
function cosh(_para1:double):double;cdecl;external libc_nlm name 'cosh';
function exp(_para1:double):double;cdecl;external libc_nlm name 'exp';
function fabs(_para1:double):double;cdecl;external libc_nlm name 'fabs';
function floor(_para1:double):double;cdecl;external libc_nlm name 'floor';
function fmod(_para1:double; _para2:double):double;cdecl;external libc_nlm name 'fmod';
function frexp(_para1:double; _para2:Plongint):double;cdecl;external libc_nlm name 'frexp';
function hypot(_para1:double; _para2:double):double;cdecl;external libc_nlm name 'hypot';
function ldexp(_para1:double; _para2:longint):double;cdecl;external libc_nlm name 'ldexp';
function log(_para1:double):double;cdecl;external libc_nlm name 'log';
function log10(_para1:double):double;cdecl;external libc_nlm name 'log10';
function modf(_para1:double; _para2:Pdouble):double;cdecl;external libc_nlm name 'modf';
function pow(_para1:double; _para2:double):double;cdecl;external libc_nlm name 'pow';
function remainder(_para1:double; _para2:double):double;cdecl;external libc_nlm name 'remainder';
function rint(_para1:double):double;cdecl;external libc_nlm name 'rint';
function sin(_para1:double):double;cdecl;external libc_nlm name 'sin';
function sinh(_para1:double):double;cdecl;external libc_nlm name 'sinh';
function sqrt(_para1:double):double;cdecl;external libc_nlm name 'sqrt';
function tan(_para1:double):double;cdecl;external libc_nlm name 'tan';
function tanh(_para1:double):double;cdecl;external libc_nlm name 'tanh';
function cabs(_para1:complex):double;cdecl;external libc_nlm name 'cabs';
function finite(_para1:double):longint;cdecl;external libc_nlm name 'finite';
function j0(_para1:double):double;cdecl;external libc_nlm name 'j0';
function j1(_para1:double):double;cdecl;external libc_nlm name 'j1';
function jn(_para1:longint; _para2:double):double;cdecl;external libc_nlm name 'jn';
function y0(_para1:double):double;cdecl;external libc_nlm name 'y0';
function y1(_para1:double):double;cdecl;external libc_nlm name 'y1';
function yn(_para1:longint; _para2:double):double;cdecl;external libc_nlm name 'yn';
function matherr(_para1:Pexception):longint;cdecl;external libc_nlm name 'matherr';
type TmathErrHandlerFunc = function (_para1:Pexception):longint; cdecl;
function matherr_handler(_para1:TmathErrHandlerFunc):longint;cdecl;external libc_nlm name 'matherr_handler';
function ___fpclassify_f(_para1:double):longint;cdecl;external libc_nlm name '___fpclassify_f';
function ___fpclassify_d(_para1:double):longint;cdecl;external libc_nlm name '___fpclassify_d';
function ___fpclassify_ld(double:longint):longint;cdecl;external libc_nlm name '___fpclassify_ld';
function ___isfinite_f(_para1:double):longint;cdecl;external libc_nlm name '___isfinite_f';
function ___isfinite_d(_para1:double):longint;cdecl;external libc_nlm name '___isfinite_d';
function ___isfinite_ld(double:longint):longint;cdecl;external libc_nlm name '___isfinite_ld';
function ___signbit_f(_para1:double):longint;cdecl;external libc_nlm name '___signbit_f';
function ___signbit_d(_para1:double):longint;cdecl;external libc_nlm name '___signbit_d';
function ___signbit_ld(double:longint):longint;cdecl;external libc_nlm name '___signbit_ld';


// monitor.h
{ turn on 1-byte packing...  }

type
   Pconn_info = ^Tconn_info;
   Tconn_info = record
        codepage : longint;
        spares   : array[0..507] of byte;
     end;

{ additional processor information that may be available...  }
{ (may not equal 'ThreadsOnProcessor' when totalled:)  }
   Pcpu_info = ^Tcpu_info;
   Tcpu_info = record
        which : longint;
        CurrentProcessor : longint;
        ProcessorUtilization : dword;
        ThreadsOnProcessor : dword;
        reserved1 : dword;
        Family : dword;
        Model : dword;
        Stepping : dword;
        Revision : dword;
        FeatureFlags : dword;
        SerialNumber : Tuint64;
        Speed : dword;
        L1CacheSize : dword;
        L2CacheSize : dword;
        L3CacheSize : dword;
        ReadyThreads : dword;
        RunningThreads : dword;
        SuspendedThreads : dword;
        reserved2 : dword;
        ThreadCPUTime : Tuint64;
        reserved3 : Tuint64;
        reserved4 : array[0..7] of dword;
     end;

   Pfilesystem_info = ^Tfilesystem_info;
   Tfilesystem_info = record
        OpenFileCount : longint;
        CurrentDiskRequests : longint;
        reserved : array[0..61] of dword;
     end;

   Prestag_info = ^Trestag_info;
   Trestag_info = record                      { per-NLM resource-allocation information  }
        tag_count : longint;                  { count of discrete resource tags  }
        res_count : size_t;                   { total number of resources across tags  }
        reserved1 : longint;                  { used only by 'ALRT' tags  }
        signature : dword;                    { type of resource (see netware.h)  }
        description : array[0..79] of char;   { resource tag description string  }
     end;

   Pmem_restag_info = ^Tmem_restag_info;
   Tmem_restag_info = record                  { per-NLM memory information  }
        tag_count   : longint;                { discrete memory allocation resource tags  }
        total_bytes : size_t;                 { total number of bytes allocated across tags  }
        allocations : longint;                { total actual calls to allocator  }
        reserved2   : dword;                  { always signature ('ALRT')  }
        description : array[0..79] of char;   { resource tag description string  }
     end;

   Pmemory_info = ^Tmemory_info;
   Tmemory_info = record
        AllocatedMemoryPool    : size64_t;
        CacheBufferSize        : size64_t;
        CacheBufferMemory      : size64_t;
        CacheMoveableMemory    : size64_t;
        CacheNonmoveableMemory : size64_t;
        CodeMemory             : size64_t;
        DataMemory             : size64_t;
        TotalWorkMemory        : size64_t;
        OtherCachePagesMemory  : size64_t;
        reserved1              : size64_t;
        TotalKnownSystemMemoryUnder4Gb : size64_t;
        TotalKnownSystemMemory : size64_t;
        reserved               : array[0..11] of dword;
     end;

   Pvmemory_info = ^Tvmemory_info;
   Tvmemory_info = record
        PageInCount : Tuint64;
        PageOutCount : Tuint64;
        SwapResvCount : Tuint64;
        SwapPageCount : Tuint64;
        SwapFreeCount : Tuint64;
        PageFaultCount : Tuint64;
        freeCachePages : Tuint64;
        freeCleanPages : Tuint64;
        freeDirtyPages : Tuint64;
        VMPhysicalPageCount : Tuint64;
        reserved : array[0..19] of dword;
     end;

   Pnet_info = ^Tnet_info;
   Tnet_info = record
        MaximumConnections : longint;
        spare0 : array[0..11] of dword;
        IPXAddr : array[0..5] of byte;
        spare1 : array[0..1] of byte;
        MaximumBoards : dword;
        spare3 : array[0..11] of dword;
        IPAddrsBound : array[0..11] of dword;
        spare4 : array[0..23] of dword;
     end;

   Pos_info = ^Tos_info;
   Tos_info = record
        AbendedProcessCount    : longint;
        CurrentServerProcesses : longint;
        reserved               : array[0..61] of dword;
     end;

{ includes namespace list  }
   Pvolume_info = ^Tvolume_info;
   Tvolume_info = record
        which : longint;
        flags : dword;
        name : array[0..(31 + 1)-1] of char;
        SectorSize : dword;
        SectorsPerCluster : dword;
        VolumeSizeInClusters : dword;
        FreedClusters : dword;
        SubAllocFreeableClusters : dword;
        FreeableLimboSectors : dword;
        NonFreeableLimboSectors : dword;
        NonFreeableAvailableSubAllocSectors : dword;
        NotUsableSubAllocSectors : dword;
        SubAllocClusters : dword;
        DataStreamsCount : dword;
        LimboDataStreamsCount : dword;
        OldestDeletedFileAgeInTicks : dword;
        CompressedDataStreamsCount : dword;
        CompressedLimboDataStreamsCount : dword;
        UnCompressableDataStreamsCount : dword;
        PreCompressedSectors : dword;
        CompressedSectors : dword;
        MigratedFiles : dword;
        MigratedSectors : dword;
        ClustersUsedByFAT : dword;
        ClustersUsedByDirectories : dword;
        ClustersUsedByExtendedDirectories : dword;
        TotalDirectoryEntries : dword;
        UnUsedDirectoryEntries : dword;
        TotalExtendedDirectoryExtants : dword;
        UnUsedExtendedDirectoryExtants : dword;
        ExtendedAttributesDefined : dword;
        ExtendedAttributeExtantsUsed : dword;
        DirectoryServicesObjectID : dword;
        VolumeLastModifiedDateAndTime : dword;
        mounted : longint;
        BlockCount : Tuint64;
        BlocksFree : Tuint64;
        BlockSize : dword;
        reserved : array[0..57] of dword;
     end;

(** unsupported pragma#pragma pack()*)
{ prototypes...  }

function netware_conn_info(info:Pconn_info; sequence:Plongint):longint;cdecl;external libc_nlm name 'netware_conn_info';
function netware_conn_info_from_slot(info:Pconn_info; slot:longint):longint;cdecl;external libc_nlm name 'netware_conn_info_from_slot';
function netware_cpu_info(info:Pcpu_info; sequence:Plongint):longint;cdecl;external libc_nlm name 'netware_cpu_info';
function netware_fs_info(info:Pfilesystem_info):longint;cdecl;external libc_nlm name 'netware_fs_info';
function netware_net_info(info:Pnet_info):longint;cdecl;external libc_nlm name 'netware_net_info';
//!! function netware_net_macaddr(board:longint; macAddr:array[0..5] of byte):longint;cdecl;external libc_nlm name 'netware_net_macaddr';
function netware_mem_info(info:Pmemory_info):longint;cdecl;external libc_nlm name 'netware_mem_info';
function netware_mem_info_for_nlm(info:Pmem_restag_info; handle:pointer):longint;cdecl;external libc_nlm name 'netware_mem_info_for_nlm';
function netware_os_info(info:Pos_info):longint;cdecl;external libc_nlm name 'netware_os_info';
function netware_vmem_info(info:Pvmemory_info):longint;cdecl;external libc_nlm name 'netware_vmem_info';
function netware_vol_info(info:Pvolume_info; sequence:Plongint):longint;cdecl;external libc_nlm name 'netware_vol_info';
function netware_vol_info_from_number(info:Pvolume_info; volNum:longint):longint;cdecl;external libc_nlm name 'netware_vol_info_from_number';
function netware_vol_info_from_name(info:Pvolume_info; name:Pchar):longint;cdecl;external libc_nlm name 'netware_vol_info_from_name';
function netware_restag_info_for_nlm(info:Prestag_info; handle:pointer; signature:dword; which:longint):longint;cdecl;external libc_nlm name 'netware_restag_info_for_nlm';

function netware_conn_info(var info:Tconn_info; var sequence:longint):longint;cdecl;external libc_nlm name 'netware_conn_info';
function netware_conn_info_from_slot(var info:Tconn_info; slot:longint):longint;cdecl;external libc_nlm name 'netware_conn_info_from_slot';
function netware_cpu_info(var info:Tcpu_info; var sequence:longint):longint;cdecl;external libc_nlm name 'netware_cpu_info';
function netware_fs_info(var info:Tfilesystem_info):longint;cdecl;external libc_nlm name 'netware_fs_info';
function netware_net_info(var info:Tnet_info):longint;cdecl;external libc_nlm name 'netware_net_info';
//!! function netware_net_macaddr(board:longint; macAddr:array[0..5] of byte):longint;cdecl;external libc_nlm name 'netware_net_macaddr';
function netware_mem_info(var info:Tmemory_info):longint;cdecl;external libc_nlm name 'netware_mem_info';
function netware_mem_info_for_nlm(var info:Tmem_restag_info; handle:pointer):longint;cdecl;external libc_nlm name 'netware_mem_info_for_nlm';
function netware_os_info(var info:Tos_info):longint;cdecl;external libc_nlm name 'netware_os_info';
function netware_vmem_info(var info:Tvmemory_info):longint;cdecl;external libc_nlm name 'netware_vmem_info';
function netware_vol_info(var info:Tvolume_info; var sequence:longint):longint;cdecl;external libc_nlm name 'netware_vol_info';
function netware_vol_info_from_number(var info:Tvolume_info; volNum:longint):longint;cdecl;external libc_nlm name 'netware_vol_info_from_number';
function netware_vol_info_from_name(var info:Tvolume_info; name:Pchar):longint;cdecl;external libc_nlm name 'netware_vol_info_from_name';
function netware_restag_info_for_nlm(var info:Trestag_info; handle:pointer; signature:dword; which:longint):longint;cdecl;external libc_nlm name 'netware_restag_info_for_nlm';


// ncpx.h

const
     MAX_NCPX_NAMELEN = 33;
     NCPX_BEGIN_SCAN = $FFFFFFFF;
     NCPX_REPLY_IS_FRAGGED = $FFFFFFFF;
     NCPX_BEING_RESTARTED = $01101001;
     NCPX_BEING_KILLED = $02202002;
     NCPX_BEING_LOGGED_OUT = $03303003;
     NCPX_BEING_FREED = $04404004;

type

   Pncpx_id_t = ^ncpx_id_t;
   ncpx_id_t = dword;

   Pncpx_client_t = ^ncpx_client_t;
   ncpx_client_t = Tuint64;

   Pncpx_frag_element_t = ^ncpx_frag_element_t;
   ncpx_frag_element_t = record
        addr : pointer;
        size : size_t;
     end;

   Pncpx_msgfrag_t = ^ncpx_msgfrag_t;
   ncpx_msgfrag_t = record
        totalMessageSize : size_t;
        fragCount : longint;
        fragList : array[0..3] of ncpx_frag_element_t;
     end;

   Pncpx_vers_t = ^ncpx_vers_t;
   ncpx_vers_t = record
        major : longint;
        minor : longint;
        revision : longint;
     end;
{ the handler that implements the extended NCP service... }

   ncpx_handler_t = function (client:Pncpx_client_t; request:pointer; requestLen:size_t; reply:pointer; replyLen:Psize_t):longint;cdecl;
{ the call-back made when the session goes away for whatever reason... }

   sess_handler_t = procedure (session:longint; _type:longint);cdecl;
{ the handler that replies to extended NCP requests (if any)... }

   reply_mgr_t = procedure (client:Pncpx_client_t; repBuffer:pointer);cdecl;
{ server registering an extended NCP service...  }
function NcpxRegister(name:Pchar; ncpHandler:ncpx_handler_t; sessionHandler:sess_handler_t; replyManager:reply_mgr_t; version:ncpx_vers_t;
           queryData:Ppointer):longint;cdecl;external libc_nlm name 'NcpxRegister';
function NcpxRegisterWithId(id:ncpx_id_t; name:Pchar; ncpHandler:ncpx_handler_t; sessionHandler:sess_handler_t; replyManager:reply_mgr_t;
           version:ncpx_vers_t; queryData:Ppointer):longint;cdecl;external libc_nlm name 'NcpxRegisterWithId';
function NcpxDeregister(queryData:pointer):longint;cdecl;external libc_nlm name 'NcpxDeregister';
{ client getting information about extended NCP services...  }
function NcpxGetInfoByName(name:Pchar; id:Pncpx_id_t; version:ncpx_vers_t; queryData:pointer):longint;cdecl;external libc_nlm name 'NcpxGetInfoByName';
function NcpxGetInfoById(id:ncpx_id_t; name:Pchar; version:ncpx_vers_t; queryData:pointer):longint;cdecl;external libc_nlm name 'NcpxGetInfoById';
function NcpxScan(id:Pncpx_id_t; name:Pchar; version:ncpx_vers_t; queryData:pointer):longint;cdecl;external libc_nlm name 'NcpxScan';
{ for the client sending extended NCP packets to a service...  }

function NcpxSend(id:ncpx_id_t; request:pointer; requestLen:size_t; reply:pointer; replyLen:Psize_t):longint;cdecl;external libc_nlm name 'NcpxSend';
function NcpxSendFragged(id:ncpx_id_t; reqFrag:Pncpx_msgfrag_t; repFrag:Pncpx_msgfrag_t):longint;cdecl;external libc_nlm name 'NcpxSendFragged';

// ndkvers.h
{==============================================================================
=  This is a timestamp offered by the NDK. Calling libcthreshold() with the
=  defined value as first argument (the second argument returns that of the
=  currently loaded libc.nlm), will ensure at least the functionality and
=  semantics offered by the NDK this file accompanied or this function returns
=  an error (ENOTSUP). Whether or not this function fails, it always returns
=  the loaded library's threshold.
==============================================================================}

  const
     CURRENT_NDK_THRESHOLD = 406230000;
  { timestamps for known releases of LibC on NetWare...  }
     NETWARE_65_FCS = 306250000;        { 25 June 2003  }
     NETWARE_65_SP1 = 310090000;        { 9 October 2003  }
     NETWARE_CSP10  = 310070000;        { 7 October 2003  }
     NETWARE_51_SP7 = NETWARE_CSP10;
     NETWARE_60_SP4 = NETWARE_CSP10;
     NETWARE_CSP11  = 405260000;        { 26 May 2004  }
     NETWARE_60_SP5 = NETWARE_CSP11;
     NETWARE_65_SP2 = NETWARE_CSP11;
     NETWARE_CSP12  = 410310000;       { 31 October 2004 (just a guess)  }
     NETWARE_51_SP8 = NETWARE_CSP12;
     NETWARE_65_SP3 = NETWARE_CSP12;


function libcthreshold(desiredthreshold:longint; libthreshold:Plongint):longint;cdecl;external libc_nlm name 'libcthreshold';
function libcthreshold(desiredthreshold:longint; var libthreshold:longint):longint;cdecl;external libc_nlm name 'libcthreshold';

// netdb.h

  const
     NETDB_INTERNAL = -(1);
     NETDB_SUCCESS = 0;      { no problem  }
     HOST_NOT_FOUND = 1;     { authoritative answer host not found  }
     TRY_AGAIN = 2;          { non authoritative host not found or SERVERFAIL  }
     NO_RECOVERY = 3;        { non recoverable: FORMERR, REFUSED, NOTIMP  }
     NO_DATA = 4;            { valid name, no data record of requested type  }
     NO_ADDRESS = NO_DATA;   { no address, look for MX record  }


{ Addresses are supplied in host order and returned in network order. }
type
   Phostent = ^hostent;
   hostent = record
        h_name      : Pchar;     { official name of host }
        h_aliases   : PPchar;    { alias list }
        h_addrtype  : smallint;  { host address type }
        h_length    : smallint;  { length of address }
        h_addr_list : PPchar;    { list of addresses }
     end;

{ It is assumed here that a network number fits in 32 bits. }
   Pnetent = ^netent;
   netent = record
        n_name     : Pchar;      { official name of net }
        n_aliases  : PPchar;     { alias list }
        n_addrtype : smallint;   { net address type }
        n_net      : u_long;     { network number }
     end;

   Pservent = ^servent;
   servent = record
        s_name    : Pchar;       { official service name }
        s_aliases : PPchar;      { alias list }
        s_port    : smallint;    { port number }
        s_proto   : Pchar;       { protocol to use }
     end;

   Pprotoent = ^protoent;
   protoent = record
        p_name    : Pchar;       { official protocol name }
        p_aliases : PPchar;      { alias list }
        p_proto   : smallint;    { protocol number }
     end;


function gethostbyaddr(_para1:Pchar; _para2:longint; _para3:longint):Phostent;cdecl;external libc_nlm name 'gethostbyaddr';
function gethostbyname(_para1:Pchar):Phostent;cdecl;external libc_nlm name 'gethostbyname';
function gethostname(_para1:Pchar; _para2:longint):longint;cdecl;external libc_nlm name 'gethostname';
function getprotobyname(_para1:Pchar):Pprotoent;cdecl;external libc_nlm name 'getprotobyname';
function getprotobynumber(_para1:longint):Pprotoent;cdecl;external libc_nlm name 'getprotobynumber';
function getservbyname(_para1:Pchar; _para2:Pchar):Pservent;cdecl;external libc_nlm name 'getservbyname';
function getservbyport(_para1:longint; _para2:Pchar):Pservent;cdecl;external libc_nlm name 'getservbyport';
function ___h_errno:Plongint;cdecl;external libc_nlm name '___h_errno';


// nks/nksapi.h
// nlmformat.h

{ 0x002E --------------------------- }
{ 0x0032 --------------------------- }
{ 0x0036 --------------------------- }
{ 0x003A --------------------------- }
{ 0x003E --------------------------- }
{ 0x0042 --------------------------- }
{ 0x0046 --------------------------- }
{ 0x004A --------------------------- }
{ 0x004E --------------------------- }
{ 0x0052 --------------------------- }
{ 0x0056 --------------------------- }
{ 0x005A --------------------------- }
{ 0x005E --------------------------- }
{ 0x0062 --------------------------- }
{ 0x0066 --------------------------- }
{ 0x006A --------------------------- }
{ 0x006E --------------------------- }
{ 0x0072 --------------------------- }
{ 0x0076 --------------------------- }
{ 0x007A --------------------------- }
{ 0x007E --------------------------- }
{ 0x0082 --------------------------- }
{ -------------------------------------------------------------------------
   ** NB: Here begins the variable part of this structure's format; what is
   ** shown here are the maximums. Consequently, sizeof(NLM_HEADER) is almost
   ** always meaningless--the 400 bytes of 'otherData' actually referring to
   ** the original size of the scratch buffer in NLMLINK set up to hold the
   ** data before writing it to the binary file.
   ** -------------------------------------------------------------------------
    }

const
 MAX_DESCRIPTION_LENGTH   = 127;
 OLD_THREAD_NAME_LENGTH   = 5;    // (exactly " LONG")
 MAX_SCREEN_NAME_LENGTH   = 71;
 MAX_THREAD_NAME_LENGTH   = 71;


{ 0x0083 --------------------------- }
{ 0x0103 --------------------------- }
{ 0x0107 --------------------------- }
{ 0x010B --------------------------- }
{ 0x0110 --------------------------- }
{ 0x0111 --------------------------- }
{ 0x0158 --------------------------- }
{ 0x015C --------------------------- }
{ 0x01A3 --------------------------- }
type

   PNLM_HEADER = ^NLM_HEADER;
   NLM_HEADER = record                                       { offset in structure -------------- }
        signature                  : array[0..23] of char;   { "NetWare Loadable Modulex\1A" }
        version                    : dword;               { 0x0018 --------------------------- }
        moduleName                 : array[0..13] of char;   { 0x001C --------------------------- }
        codeImageOffset            : dword;               { 0x002A --------------------------- }
        codeImageSize              : dword;
        dataImageOffset            : dword;
        dataImageSize              : dword;
        uninitializedDataSize      : dword;
        customDataOffset           : dword;
        customDataSize             : dword;
        moduleDependencyOffset     : dword;
        numberOfModuleDependencies : dword;
        relocationFixupOffset      : dword;
        numberOfRelocationFixups   : dword;
        externalReferencesOffset   : dword;
        numberOfExternalReferences : dword;
        publicsOffset              : dword;
        numberOfPublics            : dword;
        debugInfoOffset            : dword;
        numberOfDebugRecords       : dword;
        codeStartOffset            : dword;
        exitProcedureOffset        : dword;
        checkUnloadProcedureOffset : dword;
        moduleType                 : dword;
        flags                      : dword;
        descriptionLength          : byte;
        descriptionText            : array[0..126] of char;
        stackSize                  : dword;
        reserved                   : dword;
        reserved2                  : array[0..4] of byte;
        screenNameLength           : byte;
        screenName                 : array[0..70] of char;
        threadNameLength           : byte;
        threadName                 : array[0..70] of char;
        otherData                  : array[0..399] of byte;
     end;
{ (note: length not actually 0x0333) }
{ starts 'otherData' of NLM_HEADER }
{ offset in structure -------------- }
{ 0x0000 (exactly "VeRsIoN#") }
{ 0x0008 --------------------------- }
{ 0x000C --------------------------- }
{ 0x0010 --------------------------- }
{ 0x0014 --------------------------- }
{ 0x0018 --------------------------- }
{ 0x001A --------------------------- }

   PVERSION_MASK = ^VERSION_MASK;
   VERSION_MASK = record
        VeRsIoN : array[0..7] of char;
        majorVersion : dword;
        minorVersion : dword;
        revision : dword;
        year : dword;
        month : dword;
        day : dword;
     end;                                           { 0x0020 (structure length) }


   PCOPYRIGHT_MASK = ^COPYRIGHT_MASK;               { immediately follows VERSION_MASK }
   COPYRIGHT_MASK = record                          { offset in structure -------------- }
        _CoPyRiGhT      : array[0..9] of char;      { 0x0000 (exactly "CoPyRiGhT=") }
        copyrightLength : byte;                  { 0x000A --------------------------- }
        copyright       : array[0..251] of char;    { 0x000B --------------------------- }
     end;
{ 0x0107 (structure length) }
{ immediately follows COPYRIGHT_MASK }
{ offset in structure -------------- }
{ 0x0000 (exactly "MeSsAgEs") }
{ 0x0008 --------------------------- }
{ 0x000C --------------------------- }
{ 0x0010 --------------------------- }
{ 0x0014 --------------------------- }
{ 0x0018 --------------------------- }
{ 0x001C --------------------------- }
{ 0x0020 --------------------------- }
{ 0x0024 --------------------------- }
{ 0x0028 (ignore to end of structure }
{ 0x0030     ...all these are either }
{ 0x0034     no longer used or never }
{ 0x0038     really have been) }
{ 0x003C --------------------------- }
{ 0x0040 --------------------------- }
{ 0x0044 --------------------------- }
{ 0x0048 --------------------------- }
{ 0x004C --------------------------- }
{ 0x0050 --------------------------- }
{ 0x0054 --------------------------- }
{ 0x0058 --------------------------- }
{ 0x0064 --------------------------- }
{ 0x0068 --------------------------- }
{ 0x006C --------------------------- }
{ 0x0070 --------------------------- }
{ 0x0074 --------------------------- }
{ 0x0078 --------------------------- }
{ 0x007C (* see CODEWARRIOR_LASTMOD) }

   PEXTENDED_HEADER = ^EXTENDED_HEADER;
   EXTENDED_HEADER = record
        MeSsAgEs : array[0..7] of char;
        languageID : dword;
        messageFileOffset : dword;
        messageFileLength : dword;
        messageCount : dword;
        helpFileOffset : dword;
        helpFileLength : dword;
        RPCDataOffset : dword;
        RPCDataLength : dword;
        sharedCodeOffset : dword;
        sharedCodeLength : dword;
        sharedDataOffset : dword;
        sharedDataLength : dword;
        sharedRelocationFixupOffset : dword;
        sharedRelocationFixupLength : dword;
        sharedExternalReferenceOffset : dword;
        sharedExternalReferenceCount : dword;
        sharedPublicsOffset : dword;
        sharedPublicsCount : dword;
        sharedDebugRecordOffset : dword;
        sharedDebugRecordCount : dword;
        sharedInitializationOffset : function :dword;cdecl;
        sharedExitProcedureOffset : procedure ;
        productID : dword;
        reserved0 : dword;
        reserved1 : dword;
        reserved2 : dword;
        reserved3 : dword;
        reserved4 : dword;
        reserved5 : dword;
     end;
{ 0x0080 (structure length) }
{
** The following syntagm appears only in NLMs linked with Metrowerks
** Code Warrior. In the hexadecimal dump, it appears starting at 'reserved5'
** in EXTENDED_HEADER above and appears thus (purely for example):
**
** 1C0: 4C 61 53 74  4D 6F 44 69  20 54 68 75  20 4F 63 74   "LaStMoDi Thu Oct"
** 1D0: 20 20 39 20  31 35 3A 30  33 3A 33 30  20 32 30 30   "  9 19:22:31 200"
** 1E0: 33 0A 00                                             "3..             "
**
** The start point shown (1C0) is variable, but LASTMOD_MASK will appear at
** very nearly this offset.
 }
{ at 'reserved5' in EXTENDED_HEADER }
{ offset in structure }
{ 0x0000 (exactly "LaStMoDi") }
{ 0x0009 --------------------------- }
{ 0x000A --------------------------- }
{ 0x000D --------------------------- }
{ 0x000E --------------------------- }
{ 0x0011 --------------------------- }
{ 0x0012 (blank-padded) ------------ }
{ 0x0014 --------------------------- }
{ 0x0015 --------------------------- }
{ 0x0017 --------------------------- }
{ 0x0018 --------------------------- }
{ 0x001A --------------------------- }
{ 0x001B --------------------------- }
{ 0x001D --------------------------- }
{ 0x001E --------------------------- }
{ 0x0022 --------------------------- }
{ 0x0023 --------------------------- }

   PLASTMOD_MASK = ^LASTMOD_MASK;
   LASTMOD_MASK = record
        LaStMoDi : array[0..7] of char;
        space : char;
        weekday : array[0..2] of char;
        space2 : char;
        month : array[0..2] of char;
        space3 : char;
        day : array[0..1] of char;
        space4 : char;
        hours24 : array[0..1] of char;
        colon1 : char;
        minutes : array[0..1] of char;
        colon2 : char;
        seconds : array[0..1] of char;
        space5 : char;
        year : array[0..3] of char;
        newline : char;
        null : char;
     end;


   PCUSTOM_HEADER_MASK = ^CUSTOM_HEADER_MASK;    { 0x0024 (structure length) }
   CUSTOM_HEADER_MASK = record                   { offset in structure -------------- }
        CuStHeAd : array[0..7] of byte;          { 0x0000 "CuStHeAd" }
     end;                                        { (note: length is custom) }

// nwieeefp.h

type fp_except = longint;
const
  FP_X_INV  = $01;  { invalid operation exception }
  FP_X_DNML = $02;  { denormal operation exception }
  FP_X_DZ   = $04;  { divide by zero exception }
  FP_X_OFL  = $08;  { overflow exception }
  FP_X_UFL  = $10;  { underflow exception }
  FP_X_IMP  = $20;  { inexact (precision) exception  }

type
   Pfp_rnd = ^fp_rnd;
   fp_rnd =  Longint;
Const
   FP_RN = 0;   { round to nearest representable number, tie -> even }
   FP_RM = 1;   { round toward minus infinity }
   FP_RP = 2;   { round toward plus infinity }
   FP_RZ = 3;   { round toward zero (truncate) }

(** unsupported pragma#pragma pack()*)

function fpgetmask:longint;cdecl;external libc_nlm name 'fpgetmask';
function fpgetround:fp_rnd;cdecl;external libc_nlm name 'fpgetround';
function fpgetsticky:longint;cdecl;external libc_nlm name 'fpgetsticky';
function fpsetmask(newmask:longint):longint;cdecl;external libc_nlm name 'fpsetmask';
function fpsetround(newround:fp_rnd):fp_rnd;cdecl;external libc_nlm name 'fpsetround';
function fpsetsticky(newsticky:longint):longint;cdecl;external libc_nlm name 'fpsetsticky';


(** unsupported pragma#pragma pack()*)


// paths.h

const
  _PATH_DEFPATH = '/system';
  _PATH_STDPATH = '/system';
  _PATH_DEVNULL = '/dev/null';
  _PATH_MAILDIR = '/mail';
  _PATH_DEV     = '/system/';
  _PATH_TMP     = '/tmp/';


// proc.h

const
  PROC_DETACHED = $00000001;
  PROC_CURRENT_SPACE = $00000004;    { use current address space    }
  PROC_MEMORY_DEBUG = $00000008;     { same as load -m              }
  PROC_LOAD_SILENT = $00000010;      { no console messages          }
  PROC_INHERIT_CWD = $00000020;      { child start in same CWD      }
  PROC_INHERIT_ID = $00000040;       { child inherits identity      }
  FD_UNUSED  = -1;                   { ignore: do not wire the console }

type
   Pwiring_t = ^wiring_t;    { standard console wiring for process()... }
   wiring_t = record
        infd  : longint;     { new process' standard input, etc. }
        outfd : longint;
        errfd : longint;
     end;
   TWiring = wiring_t;
   PWiring = Pwiring_t;

{$ifndef DisableArrayOfConst}
//function procle(path:Pchar; flags:dword; env:array of Pchar; wiring:Pwiring_t; fds:Pfd_set;
//           appdata:pointer; appdata_size:size_t; reserved:pointer; arg0:Pchar; args:array of const):pid_t;cdecl;external libc_nlm name 'procle';
{$endif}
{function procle(path:Pchar; flags:dword; env:array of Pchar; wiring:Pwiring_t; fds:Pfd_set;
           appdata:pointer; appdata_size:size_t; reserved:pointer; arg0:Pchar):pid_t;cdecl;external libc_nlm name 'procle';
function procve(path:Pchar; flags:dword; env:array of Pchar; wiring:Pwiring_t; fds:Pfd_set;
           appdata:pointer; appdata_size:size_t; reserved:pointer; argv:array of Pchar):pid_t;cdecl;external libc_nlm name 'procve';}
function procve(path:Pchar; flags:dword; env:pointer; wiring:Pwiring_t; fds:Pfd_set;
           appdata:pointer; appdata_size:size_t; reserved:pointer; argv:ppchar):pid_t;cdecl;external libc_nlm name 'procve';
function procle(path:Pchar; flags:dword; env:pointer; wiring:Pwiring_t; fds:Pfd_set;
           appdata:pointer; appdata_size:size_t; reserved:pointer; arg0:Pchar; args:ppchar):pid_t;cdecl;external libc_nlm name 'procle';

// pthread.h
// sched.h
{ turn on 1-byte packing...  }

const
  SCHED_UNKNOWN = 0;
  SCHED_FIFO = 1;         { first-in, first-out      (default NetWare MPK)  }
  SCHED_RR = 2;           { round-robin                    (unimplemented)  }
  SCHED_SPORADIC = 3;     { Single UNIX Specification      (unimplemented)  }
  SCHED_OTHER = 4;        { "other" policy                 (unimplemented)  }

type
   Psched_param = ^sched_param;
   sched_param = record
        sched_priority        : longint;    { for SPORADIC (unimplemented):   }
        sched_ss_low_priority : longint;    { low scheduling priority         }
        sched_ss_repl_period  : Ttimespec;  { replenishment period for        }
        sched_ss_init_budget  : Ttimespec;  { initial budget                  }
        sched_ss_max_repl     : longint;    { maximum pending replenishments  }
        sched_policy          : longint;
     end;

(** unsupported pragma#pragma pack()*)

  const
     PTHREAD_KEYS_MAX = 64;
  { no actual maximum   }
     PTHREAD_THREADS_MAX = 32767;
     PTHREAD_STACK_MIN = 16384;
  { pthread_setdetachstate, etc...  }
     PTHREAD_CREATE_DETACHED = $00000010;
     PTHREAD_CREATE_JOINABLE = 0;
  { values for field 'attr_scope'...  }
     PTHREAD_SCOPE_PROCESS = 0;
  { as yet unsupported  }
     PTHREAD_SCOPE_SYSTEM = 1;
  { values for field 'mattr_flags', 'cattr_flags' and 'rwattr_flags'...  }
     PTHREAD_PROCESS_PRIVATE = 0;
  { as yet unsupported  }
     PTHREAD_PROCESS_SHARED = 1;
  { pthread_setcancelstate, etc...  }
     PTHREAD_CANCELED = -(1);
     PTHREAD_CANCEL_ASYNCHRONOUS = 1;
     PTHREAD_CANCEL_DEFERRED = 2;
     PTHREAD_CANCEL_DISABLE = 0;
     PTHREAD_CANCEL_ENABLE = 1;
  { values for field 'attr_flags'...  }
     PTHREAD_EXPLICIT_SCHED = $0002;
  { as yet unsupported  }
     PTHREAD_INHERIT_SCHED = $0004;
  { values for field 'mattr_protocol'...  }
  { as yet unsupported  }
     PTHREAD_PRIO_PROTECT = -(1);
  { as yet unsupported  }
     PTHREAD_PRIO_INHERIT = 1;
  { as yet unsupported  }
     PTHREAD_PRIO_NONE = 0;
     PTHREAD_ONCE_INIT = 0;
  { values for field 'mattr_kind'...  }
     PTHREAD_MUTEX_NORMAL = $0000;
     PTHREAD_MUTEX_RECURSIVE = $0010;
  { as yet unsupported  }
     PTHREAD_MUTEX_ERRORCHECK = $0020;
  { as yet unsupported  }
     PTHREAD_MUTEX_DEFAULT = $0040;

type
   Ppthread_once_t = ^pthread_once_t;
   pthread_once_t = longint;

   Ppthread_key_t = ^pthread_key_t;
   pthread_key_t = longint;

   Ppthread_t = ^pthread_t;
   pthread_t = pointer; // longint;

{ turn on 1-byte packing...  }

   Ppthread_cond_t = ^pthread_cond_t;
   pthread_cond_t = record
        cond : pointer;
        spares : array[0..5] of longint;
     end;

   Ppthread_mutex_t = PRtlCriticalSection;
   pthread_mutex_t = TRtlCriticalSection;
   TpthreadMutex = TRtlCriticalSection;

   Ppthread_rwlock_t = ^pthread_rwlock_t;
   pthread_rwlock_t = record
        rwlock : pointer;
        reserved : array[0..2] of dword;
     end;

   Ppthread_attr_t = ^pthread_attr_t;
   pthread_attr_t = record
        attr_flags : dword;
        attr_scope : longint;
        attr_priority : longint;
        attr_detachstate : longint;
        attr_stackaddr : pointer;
        attr_stacksize : size_t;
        attr_policy : longint;
        attr_name : array[0..19] of char;
     end;

   Ppthread_condattr_t = ^pthread_condattr_t;
   pthread_condattr_t = record
        cattr_flags : dword;
        cattr_arg : pointer;
        cattr_spare1 : longint;
        cattr_spare2 : longint;
     end;

   Ppthread_mutexattr_t = ^pthread_mutexattr_t;
   pthread_mutexattr_t = record
        mattr_flags : dword;
        mattr_kind : longint;
        mattr_priority : longint;
        mattr_prioceiling : longint;
        mattr_protocol : longint;
        mattr_spares2 : array[0..5] of longint;
        mattr_name : array[0..31] of char;
     end;
   Ppthread_mutex_attr_t = Ppthread_mutexattr_t;
   pthread_mutex_attr_t = pthread_mutexattr_t;
   TMutexAttribute = pthread_mutex_attr_t;

   Ppthread_rwlockattr_t = ^pthread_rwlockattr_t;
   pthread_rwlockattr_t = record
        rwattr_flags : dword;
        rwattr_spare1 : longint;
        rwattr_priority : longint;
        rwattr_prioceiling : longint;
        rwattr_protocol : longint;
        rwattr_spares2 : array[0..5] of longint;
        rwattr_name : array[0..31] of char;
     end;

(** unsupported pragma#pragma pack()*)
{ pthread functions...  }


type TPTThreadStartFunction = function (_para1:pointer):pointer; cdecl;

function pthread_create(thread:Ppthread_t; attr:Ppthread_attr_t; start_routine:TPTThreadStartFunction; arg:pointer):longint;cdecl;external libc_nlm name 'pthread_create';
function pthread_cancel(thread:pthread_t):longint;cdecl;external libc_nlm name 'pthread_cancel';
function pthread_join(thread:pthread_t; status:Ppointer):longint;cdecl;external libc_nlm name 'pthread_join';
procedure pthread_exit(status:pointer);cdecl;external libc_nlm name 'pthread_exit';
function pthread_equal(t1:pthread_t; t2:pthread_t):longint;cdecl;external libc_nlm name 'pthread_equal';
procedure pthread_yield;cdecl;external libc_nlm name 'pthread_yield';
function pthread_kill(thread:pthread_t; sig:longint):longint;cdecl;external libc_nlm name 'pthread_kill';
function pthread_detach(thread:pthread_t):longint;cdecl;external libc_nlm name 'pthread_detach';

function pthread_once(once_control:Ppthread_once_t; init_routine:TCDeclProcedure ):longint;cdecl;external libc_nlm name 'pthread_once';
function pthread_self:pthread_t;cdecl;external libc_nlm name 'pthread_self';
function pthread_key_create(_para1:Ppthread_key_t; _destructor:TCDeclProc1PtrArg):longint;cdecl;external libc_nlm name 'pthread_key_create';
function pthread_key_delete(key:pthread_key_t):longint;cdecl;external libc_nlm name 'pthread_key_delete';
function pthread_getspecific(key:pthread_key_t):pointer;cdecl;external libc_nlm name 'pthread_getspecific';

function pthread_setspecific(key:pthread_key_t; value:pointer):longint;cdecl;external libc_nlm name 'pthread_setspecific';
function pthread_getschedparam(thread:pthread_t; policy:Plongint; param:Psched_param):longint;cdecl;external libc_nlm name 'pthread_getschedparam';

function pthread_setschedparam(thread:pthread_t; policy:longint; param:Psched_param):longint;cdecl;external libc_nlm name 'pthread_setschedparam';
function pthread_setcancelstate(state:longint; oldstate:Plongint):longint;cdecl;external libc_nlm name 'pthread_setcancelstate';
function pthread_setcanceltype(_type:longint; oldtype:Plongint):longint;cdecl;external libc_nlm name 'pthread_setcanceltype';
procedure pthread_testcancel;cdecl;external libc_nlm name 'pthread_testcancel';

function pthread_sigmask(how:longint; _set:Psigset_t; oset:Psigset_t):longint;cdecl;external libc_nlm name 'pthread_sigmask';
procedure pthread_cleanup_push(routine:TCDeclProc1PtrArg; arg:pointer);cdecl;external libc_nlm name 'pthread_cleanup_push';
procedure pthread_cleanup_pop(execute:longint);cdecl;external libc_nlm name 'pthread_cleanup_pop';
{ pthread attribute functions...  }
function pthread_attr_init(attr:Ppthread_attr_t):longint;cdecl;external libc_nlm name 'pthread_attr_init';
function pthread_attr_destroy(attr:Ppthread_attr_t):longint;cdecl;external libc_nlm name 'pthread_attr_destroy';

function pthread_attr_getdetachstate(attr:Ppthread_attr_t; detachstate:Plongint):longint;cdecl;external libc_nlm name 'pthread_attr_getdetachstate';
function pthread_attr_setdetachstate(attr:Ppthread_attr_t; detachstate:longint):longint;cdecl;external libc_nlm name 'pthread_attr_setdetachstate';

function pthread_attr_getinheritsched(attr:Ppthread_attr_t; inheritsched:Plongint):longint;cdecl;external libc_nlm name 'pthread_attr_getinheritsched';
function pthread_attr_setinheritsched(attr:Ppthread_attr_t; inheritsched:longint):longint;cdecl;external libc_nlm name 'pthread_attr_setinheritsched';
function pthread_attr_getschedparam(attr:Ppthread_attr_t; param:Psched_param):longint;cdecl;external libc_nlm name 'pthread_attr_getschedparam';
function pthread_attr_setschedparam(attr:Ppthread_attr_t; param:Psched_param):longint;cdecl;external libc_nlm name 'pthread_attr_setschedparam';
function pthread_attr_getschedpolicy(attr:Ppthread_attr_t; policy:Plongint):longint;cdecl;external libc_nlm name 'pthread_attr_getschedpolicy';
function pthread_attr_setschedpolicy(attr:Ppthread_attr_t; policy:longint):longint;cdecl;external libc_nlm name 'pthread_attr_setschedpolicy';
function pthread_attr_getscope(attr:Ppthread_attr_t; contentionscope:Plongint):longint;cdecl;external libc_nlm name 'pthread_attr_getscope';
function pthread_attr_setscope(attr:Ppthread_attr_t; contentionscope:longint):longint;cdecl;external libc_nlm name 'pthread_attr_setscope';
function pthread_attr_getstackaddr(attr:Ppthread_attr_t; stackaddr:Ppointer):longint;cdecl;external libc_nlm name 'pthread_attr_getstackaddr';
function pthread_attr_setstackaddr(attr:Ppthread_attr_t; stackaddr:pointer):longint;cdecl;external libc_nlm name 'pthread_attr_setstackaddr';
function pthread_attr_getstacksize(attr:Ppthread_attr_t; stacksize:Psize_t):longint;cdecl;external libc_nlm name 'pthread_attr_getstacksize';
function pthread_attr_setstacksize(attr:Ppthread_attr_t; stacksize:size_t):longint;cdecl;external libc_nlm name 'pthread_attr_setstacksize';
function pthread_attr_getname_np(attr:Ppthread_attr_t; name:Pchar; len:size_t; mbz:Ppointer):longint;cdecl;external libc_nlm name 'pthread_attr_getname_np';
function pthread_attr_setname_np(attr:Ppthread_attr_t; name:Pchar; mbz:pointer):longint;cdecl;external libc_nlm name 'pthread_attr_setname_np';
{ condition variable functions...  }

function pthread_cond_init(cond:Ppthread_cond_t; attr:Ppthread_condattr_t):longint;cdecl;external libc_nlm name 'pthread_cond_init';
function pthread_cond_destroy(cond:Ppthread_cond_t):longint;cdecl;external libc_nlm name 'pthread_cond_destroy';
function pthread_cond_signal(cond:Ppthread_cond_t):longint;cdecl;external libc_nlm name 'pthread_cond_signal';
function pthread_cond_broadcast(cond:Ppthread_cond_t):longint;cdecl;external libc_nlm name 'pthread_cond_broadcast';
function pthread_cond_wait(cond:Ppthread_cond_t; mutex:Ppthread_mutex_t):longint;cdecl;external libc_nlm name 'pthread_cond_wait';

function pthread_cond_timedwait(cond:Ppthread_cond_t; mutex:Ppthread_mutex_t; abstime:Ptimespec):longint;cdecl;external libc_nlm name 'pthread_cond_timedwait';
{ condition variable attribute functions...  }
function pthread_condattr_init(attr:Ppthread_condattr_t):longint;cdecl;external libc_nlm name 'pthread_condattr_init';
function pthread_condattr_destroy(attr:Ppthread_condattr_t):longint;cdecl;external libc_nlm name 'pthread_condattr_destroy';
function pthread_condattr_getpshared(attr:Ppthread_condattr_t; pshared:Plongint):longint;cdecl;external libc_nlm name 'pthread_condattr_getpshared';
function pthread_condattr_setpshared(attr:Ppthread_condattr_t; pshared:longint):longint;cdecl;external libc_nlm name 'pthread_condattr_setpshared';
{ mutex functions...  }

function pthread_mutex_init(mutex:Ppthread_mutex_t; attr:Ppthread_mutexattr_t):longint;cdecl;external libc_nlm name 'pthread_mutex_init';
function pthread_mutex_destroy(mutex:Ppthread_mutex_t):longint;cdecl;external libc_nlm name 'pthread_mutex_destroy';
function pthread_mutex_lock(mutex:Ppthread_mutex_t):longint;cdecl;external libc_nlm name 'pthread_mutex_lock';
function pthread_mutex_trylock(mutex:Ppthread_mutex_t):longint;cdecl;external libc_nlm name 'pthread_mutex_trylock';
function pthread_mutex_unlock(mutex:Ppthread_mutex_t):longint;cdecl;external libc_nlm name 'pthread_mutex_unlock';
{ mutex attribute functions...  }
function pthread_mutexattr_init(attr:Ppthread_mutexattr_t):longint;cdecl;external libc_nlm name 'pthread_mutexattr_init';
function pthread_mutexattr_destroy(attr:Ppthread_mutexattr_t):longint;cdecl;external libc_nlm name 'pthread_mutexattr_destroy';
function pthread_mutexattr_getprioceiling(attr:Ppthread_mutexattr_t; prioceiling:Plongint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_getprioceiling';
function pthread_mutexattr_setprioceiling(attr:Ppthread_mutexattr_t; prioceiling:longint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_setprioceiling';
function pthread_mutexattr_getprotocol(attr:Ppthread_mutexattr_t; protocol:Plongint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_getprotocol';
function pthread_mutexattr_setprotocol(attr:Ppthread_mutexattr_t; protocol:longint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_setprotocol';
function pthread_mutexattr_getpshared(attr:Ppthread_mutexattr_t; pshared:Plongint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_getpshared';
function pthread_mutexattr_setpshared(attr:Ppthread_mutexattr_t; pshared:longint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_setpshared';
function pthread_mutexattr_gettype(attr:Ppthread_mutexattr_t; kind:Plongint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_gettype';
function pthread_mutexattr_settype(attr:Ppthread_mutexattr_t; kind:longint):longint;cdecl;external libc_nlm name 'pthread_mutexattr_settype';
{ reader-writer lock functions...  }
function pthread_rwlock_init(rwlp:Ppthread_rwlock_t; attr:Ppthread_rwlockattr_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_init';
function pthread_rwlock_destroy(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_destroy';
function pthread_rwlock_rdlock(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_rdlock';
function pthread_rwlock_wrlock(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_wrlock';
function pthread_rwlock_tryrdlock(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_tryrdlock';
function pthread_rwlock_trywrlock(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_trywrlock';
function pthread_rwlock_unlock(rwlp:Ppthread_rwlock_t):longint;cdecl;external libc_nlm name 'pthread_rwlock_unlock';
function pthread_rwlock_timedrdlock(rwlock:Ppthread_rwlock_t; abs_timeout:Ptimespec):longint;cdecl;external libc_nlm name 'pthread_rwlock_timedrdlock';
function pthread_rwlock_timedwrlock(rwlock:Ppthread_rwlock_t; abs_timeout:Ptimespec):longint;cdecl;external libc_nlm name 'pthread_rwlock_timedwrlock';
{ reader-writer lock attribute functions...  }
function pthread_rwlockattr_init(attr:Ppthread_rwlockattr_t):longint;cdecl;external libc_nlm name 'pthread_rwlockattr_init';
function pthread_rwlockattr_destroy(attr:Ppthread_rwlockattr_t):longint;cdecl;external libc_nlm name 'pthread_rwlockattr_destroy';
function pthread_rwlockattr_getpshared(attr:Ppthread_rwlockattr_t; pshared:Plongint):longint;cdecl;external libc_nlm name 'pthread_rwlockattr_getpshared';
function pthread_rwlockattr_setpshared(attr:Ppthread_rwlockattr_t; pshared:longint):longint;cdecl;external libc_nlm name 'pthread_rwlockattr_setpshared';
{ registering functions to execute at call to fork()...  }
function pthread_atfork(prepare, parent, child:TCDeclProcedure):longint;cdecl;external libc_nlm name 'pthread_atfork';


type
   Ppasswd = ^passwd;
   passwd = record
        pw_uid     : uid_t;     // user id
        pw_spare1  : uid_t;
        pw_gid     : gid_t;     // group id
        pw_spare2  : gid_t;
        pw_name    : Pchar;     // username
        pw_dir     : Pchar;     // home directory
        pw_shell   : Pchar;     // default shell
        pw_LDAPName: Pchar;     // real name
        pw_passwd  : Pchar;     // password (always nil)
        pw_gecos   : Pchar;     // general information
        pw_comment : Pchar;     // commend
        pw_change  : time_t;    // password change time
        pw_expire  : time_t;    // account expiration
        spare1 : array[0..2] of pointer;
        spare2 : array[0..3] of pointer;
     end;


//!! function geteuid:uid_t;cdecl;external libc_nlm name 'geteuid';
//!! function getuid:uid_t;cdecl;external libc_nlm name 'getuid';
function posixlogin(host:Pchar; port:longint; name:Pchar; pwd:Pchar; ctx:Pchar):longint;cdecl;external libc_nlm name 'posixlogin';
function posixlogout:longint;cdecl;external libc_nlm name 'posixlogout';

{$ifdef EnableLibcRegex}


// regex.h
type
   Pregoff_t = ^regoff_t;
   regoff_t = off_t;

   Preg_syntax_t = ^reg_syntax_t;
   reg_syntax_t = dword;

   Ps_reg_t = ^s_reg_t;
   s_reg_t = longint;

   Pactive_reg_t = ^active_reg_t;
   active_reg_t = dword;
{ number of parenthesized subexpressions  }

{ end pointer for REG_PEND                }
{ not visible                             }

   Pregex_t = ^regex_t;
   regex_t = record
        re_magic : longint;
        re_nsub : size_t;
        re_endp : Pchar;
        re_g : Pre_guts;
     end;

  const
     REG_BASIC = 0000;
     REG_EXTENDED = 0001;
     REG_ICASE = 0002;
     REG_NOSUB = 0004;
     REG_NEWLINE = 0010;
     REG_NOSPEC = 0020;
     REG_PEND = 0040;
     REG_DUMP = 0200;
  { regerror() flags  }
     REG_NOMATCH = 1;
     REG_BADPAT = 2;
     REG_ECOLLATE = 3;
     REG_ECTYPE = 4;
     REG_EESCAPE = 5;
     REG_ESUBREG = 6;
     REG_EBRACK = 7;
     REG_EPAREN = 8;
     REG_EBRACE = 9;
     REG_BADBR = 10;
     REG_ERANGE = 11;
     REG_ESPACE = 12;
     REG_BADRPT = 13;
     REG_EMPTY = 14;
     REG_ASSERT = 15;
     REG_INVARG = 16;
  { convert name to number (!)  }
     REG_ATOI = 255;
  { convert number to name (!)  }
     REG_ITOA = 0400;
  { regexec() flags  }
     REG_NOTBOL = 00001;
     REG_NOTEOL = 00002;
     REG_STARTEND = 00004;
  { tracing of execution        }
     REG_TRACE = 00400;
  { force large representation  }
     REG_LARGE = 01000;
  { force use of backref code   }
     REG_BACKR = 02000;


   Pregmatch_t = ^regmatch_t;
   regmatch_t = record
        rm_so : regoff_t;
        rm_eo : regoff_t;
     end;
{ regcomp() flags...  }
{ regerror() flags  }
{ regexec() flags  }

{$endif EnableLibcRegex}


// ringx.h

const PAGE_SIZE = 4096;


type RxCleanup_t = procedure (addr:pointer);cdecl;
{ preliminary (registration and clean-up)...  }

function RxIdentifyCode(startFuncAddr:pointer; endFuncAddrPlusOne:pointer; marshallingCodeReference:Plongint):longint;cdecl;external system_nlm name 'RxIdentifyCode';
function RxUnidentifyCode(marshallingCodeReference:longint):longint;cdecl;external system_nlm name 'RxUnidentifyCode';
function RxRegisterSysCall(marshalledFuncAddr:pointer; unmarshalledName:Pchar; argCount:longint):longint;cdecl;external system_nlm name 'RxRegisterSysCall';
function RxUnregisterSysCall(unmarshalledName:Pchar):longint;cdecl;external system_nlm name 'RxUnregisterSysCall';
{ mundane calls...  }
function RxLockMemory(addr:pointer; length:size_t):longint;cdecl;external system_nlm name 'RxLockMemory';
function RxUnlockMemory(addr:pointer; length:size_t):longint;cdecl;external system_nlm name 'RxUnlockMemory';
{ to handle address space fault and threads caught in kernel...  }
function RxRegisterKernelResource(_para1:pointer; _para2:RxCleanup_t):longint;cdecl;external system_nlm name 'RxRegisterKernelResource';
function RxRegisterThreadResource(_para1:pointer; _para2:RxCleanup_t):longint;cdecl;external system_nlm name 'RxRegisterThreadResource';
function RxUnregisterKernelResource(_para1:pointer):longint;cdecl;external system_nlm name 'RxUnregisterKernelResource';
function RxUnregisterThreadResource(_para1:pointer):longint;cdecl;external system_nlm name 'RxUnregisterThreadResource';
{ data; referenced to avoid compiler optimization of code including this  }
//??  var
//??     RxTmp : longint;cvar;public;
{ main working macros (buffers and structures, char and wide strings...  }


// semaphore.h

const
  SEM_VALUE_MAX = $7FFFFFFF;
// #define SEM_FAILED      ((sem_t *) 0)

type
   Psem_t = ^sem_t;
   sem_t = record
        sema : pointer;
        spares : array[0..5] of longint;
     end;

function sem_init(sem:Psem_t; pshared:longint; value:dword):longint;cdecl;external libc_nlm name 'sem_init';
function sem_destroy(sem:Psem_t):longint;cdecl;external libc_nlm name 'sem_destroy';
function sem_getvalue(sem:Psem_t; sval:Plongint):longint;cdecl;external libc_nlm name 'sem_getvalue';
function sem_post(sem:Psem_t):longint;cdecl;external libc_nlm name 'sem_post';
function sem_wait(sem:Psem_t):longint;cdecl;external libc_nlm name 'sem_wait';
function sem_trywait(sem:Psem_t):longint;cdecl;external libc_nlm name 'sem_trywait';
function sem_timedwait(sem:Psem_t; abstime:Ptimespec):longint;cdecl;external libc_nlm name 'sem_timedwait';


// setjmp.h

type
   _Pjmp_buf = ^_jmp_buf;
   _jmp_buf = double;

procedure __longjmp(_para1:_jmp_buf; _para2:longint);cdecl;external libc_nlm name '__longjmp';
function __setjmp(_para1:_jmp_buf):longint;cdecl;external libc_nlm name '__setjmp';

// synch.h

const
  USYNC_THREAD    = 0;
  USYNC_PROCESS   = 1;  { shared between processes (unsupported)}
  USYNC_DESTROYED = 2;  { deallocated object }

type
   //!! timespec = timestruc_t;
   Pbarrier = ^barrier;
   barrier = record
        reserved : array[0..7] of longint;
     end;
   barrier_t = barrier;
   Pbarrier_t = ^barrier_t;

   Pcond_t = ^cond_t;
   cond_t = pthread_cond_t;

   Pmutex_t = ^mutex_t;
   mutex_t = pthread_mutex_t;

   Prwlock_t = ^rwlock_t;
   rwlock_t = pthread_rwlock_t;

   Psema_t = ^sema_t;
   sema_t = sem_t;

function barrier_init(bp:Pbarrier_t; threads:longint):longint;cdecl;external libc_nlm name 'barrier_init';
procedure barrier_destroy(bp:Pbarrier_t);cdecl;external libc_nlm name 'barrier_destroy';
function barrier_wait(bp:Pbarrier_t):longint;cdecl;external libc_nlm name 'barrier_wait';
function barrier_inc(bp:Pbarrier_t):longint;cdecl;external libc_nlm name 'barrier_inc';
function barrier_dec(bp:Pbarrier_t):longint;cdecl;external libc_nlm name 'barrier_dec';
function cond_init(cvp:Pcond_t; _type:longint; arg:longint):longint;cdecl;external libc_nlm name 'cond_init';
function cond_destroy(cvp:Pcond_t):longint;cdecl;external libc_nlm name 'cond_destroy';
function cond_broadcast(cvp:Pcond_t):longint;cdecl;external libc_nlm name 'cond_broadcast';
function cond_signal(cvp:Pcond_t):longint;cdecl;external libc_nlm name 'cond_signal';
function cond_wait(cvp:Pcond_t; mp:Pmutex_t):longint;cdecl;external libc_nlm name 'cond_wait';
//!! function cond_timedwait(cvp:Pcond_t; mp:Pmutex_t; abstime:Ptimestruc_t):longint;cdecl;external libc_nlm name 'cond_timedwait';
function mutex_init(mp:Pmutex_t; _type:longint; arg:pointer):longint;cdecl;external libc_nlm name 'mutex_init';
function mutex_destroy(mp:Pmutex_t):longint;cdecl;external libc_nlm name 'mutex_destroy';
function mutex_lock(mp:Pmutex_t):longint;cdecl;external libc_nlm name 'mutex_lock';
function mutex_trylock(mp:Pmutex_t):longint;cdecl;external libc_nlm name 'mutex_trylock';
function mutex_unlock(mp:Pmutex_t):longint;cdecl;external libc_nlm name 'mutex_unlock';
function rwlock_init(rwlp:Prwlock_t; _type:longint; arg:pointer):longint;cdecl;external libc_nlm name 'rwlock_init';
function rwlock_destroy(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rwlock_destroy';
function rw_rdlock(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rw_rdlock';
function rw_wrlock(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rw_wrlock';
function rw_tryrdlock(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rw_tryrdlock';
function rw_trywrlock(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rw_trywrlock';
function rw_unlock(rwlp:Prwlock_t):longint;cdecl;external libc_nlm name 'rw_unlock';
function sema_init(sp:Psema_t; count:dword; _type:longint; arg:pointer):longint;cdecl;external libc_nlm name 'sema_init';
function sema_destroy(sp:Psema_t):longint;cdecl;external libc_nlm name 'sema_destroy';
function sema_post(sp:Psema_t):longint;cdecl;external libc_nlm name 'sema_post';
function sema_trywait(sp:Psema_t):longint;cdecl;external libc_nlm name 'sema_trywait';
function sema_wait(sp:Psema_t):longint;cdecl;external libc_nlm name 'sema_wait';

// syslog.h

{ log options for openlog()...  }
{ message facilities for openlog()...  }
{ for constructing 'maskpri' for setlogmask()...  }
{ values for priority argument of syslog()...  }
{ with no filename argument, syslogd.nlm uses this configuration file:  }
// termio.h
// termios.h
{
** Note: This is a very primitive and narrow adaptation of POSIX termios.h.
** Most of what is in this file is for completeness and to avoid locking
** termios.h interfaces off from advancing progressively as needed.}


  const
     NCCS = 32;
  { ^C  }
     INTR = $03;
  { ^D  }
     QUIT = $04;
  { ^Z  }
     SUSP = $1A;
  { currently unsupported                          }
     ECHO = $01;
  { currently unsupported                          }
     ECHOE = $02;
  { currently unsupported                          }
     ECHOK = $04;
  { currently unsupported                          }
     ECHONL = $08;
  { currently unsupported                          }
     ICANON = $10;
  { currently unsupported                          }
     IEXTEN = $20;
  { check against INTR, QUIT and SUSP (default)    }
     ISIG = $40;
  { currently unsupported                          }
     NOFLSH = $80;
  { c_iflag bits...  }
     IGNBRK = 0000001;
     BRKINT = 0000002;
     IGNPAR = 0000004;
     PARMRK = 0000010;
     INPCK = 0000020;
     ISTRIP = 0000040;
     INLCR = 0000100;
     IGNCR = 0000200;
     ICRNL = 0000400;
     IUCLC = 0001000;
     IXON = 0002000;
     IXANY = 0004000;
     IXOFF = 0010000;
     IMAXBEL = 0020000;
     CSIZE = 0000060;
     CS5 = 0000000;
     CS6 = 0000020;
     CS7 = 0000040;
     CS8 = 0000060;
     CSTOPB = 0000100;
     CREAD = 0000200;
     PARENB = 0000400;
     PARODD = 0001000;
     HUPCL = 0002000;
     CLOCAL = 0004000;
  { 'c_cc' control characters...  }
  { ^C                                             }
     VINTR = 1;
  { ^\   (unsupported)                             }
     VQUIT = 2;
  { del  (unsupported)                             }
     VERASE = 3;
  { ^D                                             }
     VEOF = 4;
  { @    (unsupported)                             }
     VKILL = 5;
  { currently unsupported                          }
     VTIME = 6;
  { currently unsupported                          }
     VMIN = 7;
  { ^q   (unsupported)                             }
     VSTART = 8;
  { ^s   (unsupported)                             }
     VSTOP = 9;
  { ^z                                             }
     VSUSP = 10;
  { '\0' (unsupported)                             }
     VEOL = 11;
  { 'optional_actions' causes action to be effectuated when:  }
  { immediately                                    }
     TCSANOW = 1;
  { output done                     (unsupported)  }
     TCSADRAIN = 2;
  { output done and input discarded (unsupported)  }
     TCSAFLUSH = 3;


{ c_iflag bits...  }
{ 'c_cc' control characters...  }
{ 'optional_actions' causes action to be effectuated when:  }
type
   Ptcflag_t = ^tcflag_t;
   tcflag_t = dword;

   Pcc_t = ^cc_t;
   cc_t = byte;

   Pspeed_t = ^speed_t;
   speed_t =  Longint;
   Const
     B0 = 0;
     B50 = 50;
     B75 = 75;
     B110 = 110;
     B134 = 134;
     B150 = 150;
     B200 = 200;
     B300 = 300;
     B600 = 600;
     B1200 = 1200;
     B1800 = 1800;
     B2400 = 2400;
     B4800 = 4800;
     B9600 = 9600;
     B19200 = 19200;
     B38400 = 38400;

{ ioctl() control packet...  }
{ input modes     --currently unused          }
{ output modes    --currently unused          }
{ control modes   --currently unused          }
{ local modes     --ISIG currently supported  }
{ input speed     --currently unused          }
{ output speed    --currently unused          }
{ line discipline --currently unused          }
{ control chars   --currently used            }
type
   Ptermios = ^termios;
   termios = record
        c_iflag : tcflag_t;
        c_oflag : tcflag_t;
        c_cflag : tcflag_t;
        c_lflag : tcflag_t;
        c_ispeed : speed_t;
        c_ospeed : speed_t;
        c_line : cc_t;
        c_spare1 : dword;
        c_cc : array[0..31] of cc_t;
        c_spare2 : dword;
        c_spare3 : dword;
        c_spare4 : dword;
        c_spare5 : dword;
     end;

{ POSIX-defined functions...  }

function tcgetattr(fildes:longint; tp:Ptermios):longint;cdecl;external libc_nlm name 'tcgetattr';
function tcsetattr(fildes:longint; optional_actions:longint; tp:Ptermios):longint;cdecl;external libc_nlm name 'tcsetattr';

// tgmath.h

{ syslog.h
  ==============================================================================}
  { log options for openlog()...  }
  { log the process ID with each message  }

  const
     LOG_PID = $00000001;
     LOG_CONS = $00000002;                   { log to the system console on error    }
     LOG_NDELAY = $00000004;                 { connect to syslog daemon immediately  }
     LOG_ODELAY = $00000008;                 { delay open until syslog() is called   }
     LOG_NOWAIT = $00000010;                 { do not wait for child processes       }
  { message facilities for openlog()...  }
     LOG_KERN = $00000001;                   { generated by system  }
     LOG_USER = $00000002;                   { generated by a process                }
     LOG_MAIL = $00000004;                   { generated by mail system              }
     LOG_NEWS = $00000008;                   { generated by news system              }
     LOG_UUCP = $00000010;                   { generated by UUCP system              }
     LOG_DAEMON = $00000020;                 { generated by daemon                   }
     LOG_AUTH = $00000040;                   { generated by auth. daemon             }
     LOG_CRON = $00000080;                   { generated by clock daemon             }
     LOG_LPR = $00000100;                    { generated by printer system           }
     LOG_LOCAL0 = $00000200;                 { local use                             }
     LOG_LOCAL1 = $00000400;
     LOG_LOCAL2 = $00000800;
     LOG_LOCAL3 = $00001000;
     LOG_LOCAL4 = $00002000;
     LOG_LOCAL5 = $00004000;
     LOG_LOCAL6 = $00008000;
     LOG_LOCAL7 = $00010000;
     LOG_UNUSED1 = $00020000;
     LOG_UNUSED2 = $00040000;
     LOG_UNUSED3 = $00080000;
     LOG_UNUSED4 = $00100000;
     LOG_UNUSED5 = $00200000;
     LOG_UNUSED6 = $00400000;                { unused                                }
     LOG_UNUSED7 = $00800000;                { unused                                }
  { for constructing 'maskpri' for setlogmask()...  }
  { was #define dname(params) para_def_expr }
  { argument types are unknown }
  { return type might be wrong }
//  function LOG_MASK(p : longint) : longint;
     LOG_EMERG = $01000000;
     LOG_ALERT = $02000000;                  { condition to correct immediately       }
     LOG_CRIT = $04000000;                   { critical condition                     }
     LOG_ERR = $08000000;                    { error message                          }
     LOG_WARNING = $10000000;                { warning message                        }
     LOG_NOTICE = $20000000;                 { condition requiring special handling   }
     LOG_INFO = $40000000;                   { general information message            }
     LOG_DEBUG = $80000000;                  { message useful for debugging programs  }
     P_cfgfile = 'sys:/etc/syslog.conf';     { with no filename argument, syslogd.nlm uses this configuration file:  }

  procedure closelog;cdecl;external libc_nlm name 'closelog';
  procedure openlog(ident:Pchar; logopt:longint; facility:longint);cdecl;external libc_nlm;
  function setlogmask(maskpri:longint):longint;cdecl;external libc_nlm name 'setlogmask';
{$ifndef DisableArrayOfConst}
  procedure syslog(priority:longint; message:Pchar; args:array of const);cdecl;external libc_nlm name 'syslog';
{$endif}
  procedure syslog(priority:longint; message:Pchar);cdecl;external libc_nlm name 'syslog';



// thread.h

  const
     THR_BOUND = $00000080;
     THR_DETACHED = PTHREAD_CREATE_DETACHED;
     THR_NEW_LWP = $FFFFFFFE;
     THR_SUSPENDED = $00000020;
     THR_DAEMON = $00000040;


{ type definitions...  }
type

//!!   Pthread_t = ^thread_t;
   thread_t = pthread_t;

//!!   Pthread_key_t = ^thread_key_t;
   thread_key_t = pthread_key_t;
{ prototypes...  }

type TThrStartRoutine = function (_para1:pointer):pointer; cdecl;
function thr_create(stack_based:pointer; stack_size:size_t;
           start_routine:TThrStartRoutine; arg:pointer; flags:longint;
           new_thr:Pthread_t):longint;cdecl;external libc_nlm name 'thr_create';
function thr_self:thread_t;cdecl;external libc_nlm name 'thr_self';
function thr_suspend(thr:thread_t):longint;cdecl;external libc_nlm name 'thr_suspend';
function thr_continue(thr:thread_t):longint;cdecl;external libc_nlm name 'thr_continue';
function thr_join(wait_for:thread_t; dead:Pthread_t; status:Ppointer):longint;cdecl;external libc_nlm name 'thr_join';
procedure thr_yield;cdecl;external libc_nlm name 'thr_yield';
procedure thr_exit(status:pointer);cdecl;external libc_nlm name 'thr_exit';
function thr_minstack:size_t;cdecl;external libc_nlm name 'thr_minstack';
function thr_kill(thr:thread_t; sig:longint):longint;cdecl;external libc_nlm name 'thr_kill';

function thr_sigsetmask(how:longint; _set:Psigset_t; oset:Psigset_t):longint;cdecl;external libc_nlm name 'thr_sigsetmask';
function thr_getconcurrency:longint;cdecl;external libc_nlm name 'thr_getconcurrency';
function thr_setconcurrency(new_level:longint):longint;cdecl;external libc_nlm name 'thr_setconcurrency';
function thr_getprio(thr:thread_t; pri:Plongint):longint;cdecl;external libc_nlm name 'thr_getprio';
function thr_setprio(thr:thread_t; pri:longint):longint;cdecl;external libc_nlm name 'thr_setprio';
function thr_keycreate(key:Pthread_key_t; _destructor:TCDeclProc1PtrArg):longint;cdecl;external libc_nlm name 'thr_keycreate';
function thr_getspecific(key:thread_key_t; value:Ppointer):longint;cdecl;external libc_nlm name 'thr_getspecific';
function thr_setspecific(key:thread_key_t; value:pointer):longint;cdecl;external libc_nlm name 'thr_setspecific';

// utf8.h

type
   Putf8_t = ^utf8_t;
   utf8_t = byte;
   PPutf8_t = ^Putf8_t;
// var __utf8width : array of byte;cvar;external;
{ prototypes...  }


function utf8width(ch:Putf8_t):size_t;cdecl;external libc_nlm name 'utf8width';
function utf8cat(tgt:Putf8_t; src:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8cat';
function utf8chr(_string:Putf8_t; ch:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8chr';
function utf8cmp(s1:Putf8_t; s2:Putf8_t):longint;cdecl;external libc_nlm name 'utf8cmp';
function utf8cpy(tgt:Putf8_t; src:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8cpy';
function utf8cspn(_string:Putf8_t; charset:Putf8_t):size_t;cdecl;external libc_nlm name 'utf8cspn';
function utf8dup(s:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8dup';
function utf8index(_string:Putf8_t; search:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8index';
function utf8len(_string:Putf8_t):size_t;cdecl;external libc_nlm name 'utf8len';
{$ifndef DisableArrayOfConst}
function utf8list(tgt:Putf8_t; s1:Putf8_t; args:array of const):Putf8_t;cdecl;external libc_nlm name 'utf8list';
{$endif}
function utf8list(tgt:Putf8_t; s1:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8list';
function utf8lwr(_string:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8lwr';
function utf8ncat(tgt:Putf8_t; src:Putf8_t; n:size_t):Putf8_t;cdecl;external libc_nlm name 'utf8ncat';
function utf8ncmp(s1:Putf8_t; s2:Putf8_t; n:size_t):longint;cdecl;external libc_nlm name 'utf8ncmp';
function utf8ncpy(tgt:Putf8_t; src:Putf8_t; n:size_t):Putf8_t;cdecl;external libc_nlm name 'utf8ncpy';
function utf8next(_string:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8next';
function utf8nlen(_string:Putf8_t; nbytes:size_t):size_t;cdecl;external libc_nlm name 'utf8nlen';
function utf8nset(base:Putf8_t; ch:Putf8_t; n:size_t):Putf8_t;cdecl;external libc_nlm name 'utf8nset';
function utf8pbrk(s1:Putf8_t; s2:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8pbrk';
function utf8prev(_string:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8prev';
function utf8rchr(_string:Putf8_t; ch:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8rchr';
function utf8rev(_string:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8rev';
function utf8size(_string:Putf8_t):size_t;cdecl;external libc_nlm name 'utf8size';
function utf8spn(_string:Putf8_t; charset:Putf8_t):size_t;cdecl;external libc_nlm name 'utf8spn';
function utf8str(as1:Putf8_t; as2:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8str';
function utf8tolower(_string:Putf8_t; dest:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8tolower';
function utf8tok_r(_string:Putf8_t; sepset:Putf8_t; lasts:PPutf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8tok_r';
function utf8toupper(_string:Putf8_t; dest:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8toupper';
function utf8upr(_string:Putf8_t):Putf8_t;cdecl;external libc_nlm name 'utf8upr';
function isutf8ascii(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8ascii';
function isutf8digit(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8digit';
function isutf8xdigit(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8xdigit';
function isutf8space(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8space';
function isutf8alnum(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8alnum';
function isutf8alpha(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8alpha';
function isutf8lower(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8lower';
function isutf8upper(_string:Putf8_t):longint;cdecl;external libc_nlm name 'isutf8upper';


// utime.h
{ turn on 1-byte packing...  }

{ access time  }
{ modification time  }
type
   Putimbuf = ^Tutimbuf;
   Tutimbuf = record
        actime  : time_t;
        modtime : time_t;
     end;
   utimbuf = Tutimbuf;

(** unsupported pragma#pragma pack()*)



function utime(path:Pchar; times:Putimbuf):longint;cdecl;external libc_nlm name 'utime';
function utime(path:Pchar; var times:Tutimbuf):longint;cdecl;external libc_nlm name 'utime';


// utsname.h
// wctype.h
type
   Pwctype_t = ^wctype_t;
   wctype_t =  Longint;
Const
   WCTYPE_UNDEF = 0;
   WCTYPE_ALNUM = 1;
   WCTYPE_ALPHA = 2;
   WCTYPE_BLANK = 3;
   WCTYPE_CNTRL = 4;
   WCTYPE_DIGIT = 5;
   WCTYPE_GRAPH = 6;
   WCTYPE_LOWER = 7;
   WCTYPE_PRINT = 8;
   WCTYPE_PUNCT = 9;
   WCTYPE_SPACE = 10;
   WCTYPE_UPPER = 11;
   WCTYPE_XDIGIT = 12;

type
   Pwctrans_t = ^wctrans_t;
   wctrans_t = wchar_t;

function iswalnum(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswalnum';
function iswalpha(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswalpha';
function iswblank(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswblank';
function iswcntrl(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswcntrl';
function iswdigit(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswdigit';
function iswgraph(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswgraph';
function iswlower(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswlower';
function iswprint(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswprint';
function iswpunct(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswpunct';
function iswspace(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswspace';
function iswupper(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswupper';
function iswxdigit(_para1:longint):longint;cdecl;external libc_nlm name 'iswxdigit';
function towlower(_para1:wint_t):wint_t;cdecl;external libc_nlm name 'towlower';
function towupper(_para1:wint_t):wint_t;cdecl;external libc_nlm name 'towupper';
function iswctype(_para1:wint_t; _para2:wctype_t):longint;cdecl;external libc_nlm name 'iswctype';

function wctype(_para1:Pchar):wctype_t;cdecl;external libc_nlm name 'wctype';
function towctrans(_para1:wint_t; _para2:wctrans_t):wint_t;cdecl;external libc_nlm name 'towctrans';

function wctrans(_para1:Pchar):wctrans_t;cdecl;external libc_nlm name 'wctrans';
function iswascii(_para1:wint_t):longint;cdecl;external libc_nlm name 'iswascii';


// windows.h


  const
     DLL_ACTUAL_DLLMAIN = 0;
     DLL_NLM_STARTUP = 1;        { start-up, 'lpvReserved' is NLM handle  }
     DLL_NLM_SHUTDOWN = 2;       { unload, 'lpvReserved' is NLM handle    }
     { standard DllMain() messages...  }
     DLL_PROCESS_ATTACH = 3;     { DLL "loaded" into application space    }
     DLL_THREAD_ATTACH = 4;      { application creating new thread        }
     DLL_THREAD_DETACH = 5;      { application thread exiting cleanly     }
     DLL_PROCESS_DETACH = 6;     { DLL "unloaded" from application space  }
     TLS_MINIMUM_AVAILABLE = 64; { minumum number of keys available       }


type

   PLPVOID = ^LPVOID;
   LPVOID = void;

   PBOOL = ^BOOL;
   BOOL = longint;

   PHMODULE = ^HMODULE;
   //HMODULE = void;

   PLPCTSTR = ^LPCTSTR;
   LPCTSTR = char;

   _PHINSTANCE = ^_HINSTANCE;
   _HINSTANCE = void;
{ Win32 DLL solutions for dynamic NLM libraries on NetWare...  }

function GetLastError:dword;cdecl;external libc_nlm name 'GetLastError';
procedure SetLastError(dwErrCode:dword);cdecl;external libc_nlm name 'SetLastError';
function FreeLibrary(hModule:HMODULE):BOOL;cdecl;external libc_nlm name 'FreeLibrary';
function LoadLibrary(lpFileName:LPCTSTR):HMODULE;cdecl;external libc_nlm name 'LoadLibrary';
{
** Prototype for libraries writing their own start-up and shut-down code.
** This is not an interface, but only a prototype for code furnished by the
** NLM library.
 }
function DllMain(hinstDLL:_HINSTANCE; fdwReason:dword; lpvReserve:LPVOID):BOOL;cdecl;external libc_nlm name 'DllMain';


// xmalloc.h

function xcalloc(_para1,_para2:size_t):pointer;cdecl;external libc_nlm name 'xcalloc';
procedure xfree(_para1:pointer);cdecl;external libc_nlm name 'xfree';
function xmalloc(_para1:size_t):pointer;cdecl;external libc_nlm name 'xmalloc';
function xrealloc(_para1:pointer; _para2:size_t):pointer;cdecl;external libc_nlm name 'xrealloc';


{$ifndef INCLUDED_FROM_SYSTEM}

implementation

function bisecond(var a : Tdos_tm) : word;
begin
   bisecond:=(a.flag0 and bm_dos_tm_bisecond) shr bp_dos_tm_bisecond;
end;

procedure set_bisecond(var a : Tdos_tm; __bisecond : word);
begin
   a.flag0:=a.flag0 or ((__bisecond shl bp_dos_tm_bisecond) and bm_dos_tm_bisecond);
end;

function minute(var a : Tdos_tm) : word;
begin
   minute:=(a.flag0 and bm_dos_tm_minute) shr bp_dos_tm_minute;
end;

procedure set_minute(var a : Tdos_tm; __minute : word);
begin
   a.flag0:=a.flag0 or ((__minute shl bp_dos_tm_minute) and bm_dos_tm_minute);
end;

function hour(var a : Tdos_tm) : word;
begin
   hour:=(a.flag0 and bm_dos_tm_hour) shr bp_dos_tm_hour;
end;

procedure set_hour(var a : Tdos_tm; __hour : word);
begin
   a.flag0:=a.flag0 or ((__hour shl bp_dos_tm_hour) and bm_dos_tm_hour);
end;

function day(var a : Tdos_tm) : word;
begin
   day:=(a.flag0 and bm_dos_tm_day) shr bp_dos_tm_day;
end;

procedure set_day(var a : Tdos_tm; __day : word);
begin
   a.flag0:=a.flag0 or ((__day shl bp_dos_tm_day) and bm_dos_tm_day);
end;

function month(var a : Tdos_tm) : word;
begin
   month:=(a.flag0 and bm_dos_tm_month) shr bp_dos_tm_month;
end;

procedure set_month(var a : Tdos_tm; __month : word);
begin
   a.flag0:=a.flag0 or ((__month shl bp_dos_tm_month) and bm_dos_tm_month);
end;

function year(var a : Tdos_tm) : word;
begin
   year:=(a.flag0 and bm_dos_tm_year) shr bp_dos_tm_year;
end;

procedure set_year(var a : Tdos_tm; __year : word);
begin
   a.flag0:=a.flag0 or ((__year shl bp_dos_tm_year) and bm_dos_tm_year);
end;

end.

{$endif}