|
root / base / usr / src / head
head Plain Text 48797 lines 1.4 MB
    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
 9225
 9226
 9227
 9228
 9229
 9230
 9231
 9232
 9233
 9234
 9235
 9236
 9237
 9238
 9239
 9240
 9241
 9242
 9243
 9244
 9245
 9246
 9247
 9248
 9249
 9250
 9251
 9252
 9253
 9254
 9255
 9256
 9257
 9258
 9259
 9260
 9261
 9262
 9263
 9264
 9265
 9266
 9267
 9268
 9269
 9270
 9271
 9272
 9273
 9274
 9275
 9276
 9277
 9278
 9279
 9280
 9281
 9282
 9283
 9284
 9285
 9286
 9287
 9288
 9289
 9290
 9291
 9292
 9293
 9294
 9295
 9296
 9297
 9298
 9299
 9300
 9301
 9302
 9303
 9304
 9305
 9306
 9307
 9308
 9309
 9310
 9311
 9312
 9313
 9314
 9315
 9316
 9317
 9318
 9319
 9320
 9321
 9322
 9323
 9324
 9325
 9326
 9327
 9328
 9329
 9330
 9331
 9332
 9333
 9334
 9335
 9336
 9337
 9338
 9339
 9340
 9341
 9342
 9343
 9344
 9345
 9346
 9347
 9348
 9349
 9350
 9351
 9352
 9353
 9354
 9355
 9356
 9357
 9358
 9359
 9360
 9361
 9362
 9363
 9364
 9365
 9366
 9367
 9368
 9369
 9370
 9371
 9372
 9373
 9374
 9375
 9376
 9377
 9378
 9379
 9380
 9381
 9382
 9383
 9384
 9385
 9386
 9387
 9388
 9389
 9390
 9391
 9392
 9393
 9394
 9395
 9396
 9397
 9398
 9399
 9400
 9401
 9402
 9403
 9404
 9405
 9406
 9407
 9408
 9409
 9410
 9411
 9412
 9413
 9414
 9415
 9416
 9417
 9418
 9419
 9420
 9421
 9422
 9423
 9424
 9425
 9426
 9427
 9428
 9429
 9430
 9431
 9432
 9433
 9434
 9435
 9436
 9437
 9438
 9439
 9440
 9441
 9442
 9443
 9444
 9445
 9446
 9447
 9448
 9449
 9450
 9451
 9452
 9453
 9454
 9455
 9456
 9457
 9458
 9459
 9460
 9461
 9462
 9463
 9464
 9465
 9466
 9467
 9468
 9469
 9470
 9471
 9472
 9473
 9474
 9475
 9476
 9477
 9478
 9479
 9480
 9481
 9482
 9483
 9484
 9485
 9486
 9487
 9488
 9489
 9490
 9491
 9492
 9493
 9494
 9495
 9496
 9497
 9498
 9499
 9500
 9501
 9502
 9503
 9504
 9505
 9506
 9507
 9508
 9509
 9510
 9511
 9512
 9513
 9514
 9515
 9516
 9517
 9518
 9519
 9520
 9521
 9522
 9523
 9524
 9525
 9526
 9527
 9528
 9529
 9530
 9531
 9532
 9533
 9534
 9535
 9536
 9537
 9538
 9539
 9540
 9541
 9542
 9543
 9544
 9545
 9546
 9547
 9548
 9549
 9550
 9551
 9552
 9553
 9554
 9555
 9556
 9557
 9558
 9559
 9560
 9561
 9562
 9563
 9564
 9565
 9566
 9567
 9568
 9569
 9570
 9571
 9572
 9573
 9574
 9575
 9576
 9577
 9578
 9579
 9580
 9581
 9582
 9583
 9584
 9585
 9586
 9587
 9588
 9589
 9590
 9591
 9592
 9593
 9594
 9595
 9596
 9597
 9598
 9599
 9600
 9601
 9602
 9603
 9604
 9605
 9606
 9607
 9608
 9609
 9610
 9611
 9612
 9613
 9614
 9615
 9616
 9617
 9618
 9619
 9620
 9621
 9622
 9623
 9624
 9625
 9626
 9627
 9628
 9629
 9630
 9631
 9632
 9633
 9634
 9635
 9636
 9637
 9638
 9639
 9640
 9641
 9642
 9643
 9644
 9645
 9646
 9647
 9648
 9649
 9650
 9651
 9652
 9653
 9654
 9655
 9656
 9657
 9658
 9659
 9660
 9661
 9662
 9663
 9664
 9665
 9666
 9667
 9668
 9669
 9670
 9671
 9672
 9673
 9674
 9675
 9676
 9677
 9678
 9679
 9680
 9681
 9682
 9683
 9684
 9685
 9686
 9687
 9688
 9689
 9690
 9691
 9692
 9693
 9694
 9695
 9696
 9697
 9698
 9699
 9700
 9701
 9702
 9703
 9704
 9705
 9706
 9707
 9708
 9709
 9710
 9711
 9712
 9713
 9714
 9715
 9716
 9717
 9718
 9719
 9720
 9721
 9722
 9723
 9724
 9725
 9726
 9727
 9728
 9729
 9730
 9731
 9732
 9733
 9734
 9735
 9736
 9737
 9738
 9739
 9740
 9741
 9742
 9743
 9744
 9745
 9746
 9747
 9748
 9749
 9750
 9751
 9752
 9753
 9754
 9755
 9756
 9757
 9758
 9759
 9760
 9761
 9762
 9763
 9764
 9765
 9766
 9767
 9768
 9769
 9770
 9771
 9772
 9773
 9774
 9775
 9776
 9777
 9778
 9779
 9780
 9781
 9782
 9783
 9784
 9785
 9786
 9787
 9788
 9789
 9790
 9791
 9792
 9793
 9794
 9795
 9796
 9797
 9798
 9799
 9800
 9801
 9802
 9803
 9804
 9805
 9806
 9807
 9808
 9809
 9810
 9811
 9812
 9813
 9814
 9815
 9816
 9817
 9818
 9819
 9820
 9821
 9822
 9823
 9824
 9825
 9826
 9827
 9828
 9829
 9830
 9831
 9832
 9833
 9834
 9835
 9836
 9837
 9838
 9839
 9840
 9841
 9842
 9843
 9844
 9845
 9846
 9847
 9848
 9849
 9850
 9851
 9852
 9853
 9854
 9855
 9856
 9857
 9858
 9859
 9860
 9861
 9862
 9863
 9864
 9865
 9866
 9867
 9868
 9869
 9870
 9871
 9872
 9873
 9874
 9875
 9876
 9877
 9878
 9879
 9880
 9881
 9882
 9883
 9884
 9885
 9886
 9887
 9888
 9889
 9890
 9891
 9892
 9893
 9894
 9895
 9896
 9897
 9898
 9899
 9900
 9901
 9902
 9903
 9904
 9905
 9906
 9907
 9908
 9909
 9910
 9911
 9912
 9913
 9914
 9915
 9916
 9917
 9918
 9919
 9920
 9921
 9922
 9923
 9924
 9925
 9926
 9927
 9928
 9929
 9930
 9931
 9932
 9933
 9934
 9935
 9936
 9937
 9938
 9939
 9940
 9941
 9942
 9943
 9944
 9945
 9946
 9947
 9948
 9949
 9950
 9951
 9952
 9953
 9954
 9955
 9956
 9957
 9958
 9959
 9960
 9961
 9962
 9963
 9964
 9965
 9966
 9967
 9968
 9969
 9970
 9971
 9972
 9973
 9974
 9975
 9976
 9977
 9978
 9979
 9980
 9981
 9982
 9983
 9984
 9985
 9986
 9987
 9988
 9989
 9990
 9991
 9992
 9993
 9994
 9995
 9996
 9997
 9998
 9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
37211
37212
37213
37214
37215
37216
37217
37218
37219
37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
37231
37232
37233
37234
37235
37236
37237
37238
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
37254
37255
37256
37257
37258
37259
37260
37261
37262
37263
37264
37265
37266
37267
37268
37269
37270
37271
37272
37273
37274
37275
37276
37277
37278
37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
37294
37295
37296
37297
37298
37299
37300
37301
37302
37303
37304
37305
37306
37307
37308
37309
37310
37311
37312
37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
37325
37326
37327
37328
37329
37330
37331
37332
37333
37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
37346
37347
37348
37349
37350
37351
37352
37353
37354
37355
37356
37357
37358
37359
37360
37361
37362
37363
37364
37365
37366
37367
37368
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
37389
37390
37391
37392
37393
37394
37395
37396
37397
37398
37399
37400
37401
37402
37403
37404
37405
37406
37407
37408
37409
37410
37411
37412
37413
37414
37415
37416
37417
37418
37419
37420
37421
37422
37423
37424
37425
37426
37427
37428
37429
37430
37431
37432
37433
37434
37435
37436
37437
37438
37439
37440
37441
37442
37443
37444
37445
37446
37447
37448
37449
37450
37451
37452
37453
37454
37455
37456
37457
37458
37459
37460
37461
37462
37463
37464
37465
37466
37467
37468
37469
37470
37471
37472
37473
37474
37475
37476
37477
37478
37479
37480
37481
37482
37483
37484
37485
37486
37487
37488
37489
37490
37491
37492
37493
37494
37495
37496
37497
37498
37499
37500
37501
37502
37503
37504
37505
37506
37507
37508
37509
37510
37511
37512
37513
37514
37515
37516
37517
37518
37519
37520
37521
37522
37523
37524
37525
37526
37527
37528
37529
37530
37531
37532
37533
37534
37535
37536
37537
37538
37539
37540
37541
37542
37543
37544
37545
37546
37547
37548
37549
37550
37551
37552
37553
37554
37555
37556
37557
37558
37559
37560
37561
37562
37563
37564
37565
37566
37567
37568
37569
37570
37571
37572
37573
37574
37575
37576
37577
37578
37579
37580
37581
37582
37583
37584
37585
37586
37587
37588
37589
37590
37591
37592
37593
37594
37595
37596
37597
37598
37599
37600
37601
37602
37603
37604
37605
37606
37607
37608
37609
37610
37611
37612
37613
37614
37615
37616
37617
37618
37619
37620
37621
37622
37623
37624
37625
37626
37627
37628
37629
37630
37631
37632
37633
37634
37635
37636
37637
37638
37639
37640
37641
37642
37643
37644
37645
37646
37647
37648
37649
37650
37651
37652
37653
37654
37655
37656
37657
37658
37659
37660
37661
37662
37663
37664
37665
37666
37667
37668
37669
37670
37671
37672
37673
37674
37675
37676
37677
37678
37679
37680
37681
37682
37683
37684
37685
37686
37687
37688
37689
37690
37691
37692
37693
37694
37695
37696
37697
37698
37699
37700
37701
37702
37703
37704
37705
37706
37707
37708
37709
37710
37711
37712
37713
37714
37715
37716
37717
37718
37719
37720
37721
37722
37723
37724
37725
37726
37727
37728
37729
37730
37731
37732
37733
37734
37735
37736
37737
37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
37750
37751
37752
37753
37754
37755
37756
37757
37758
37759
37760
37761
37762
37763
37764
37765
37766
37767
37768
37769
37770
37771
37772
37773
37774
37775
37776
37777
37778
37779
37780
37781
37782
37783
37784
37785
37786
37787
37788
37789
37790
37791
37792
37793
37794
37795
37796
37797
37798
37799
37800
37801
37802
37803
37804
37805
37806
37807
37808
37809
37810
37811
37812
37813
37814
37815
37816
37817
37818
37819
37820
37821
37822
37823
37824
37825
37826
37827
37828
37829
37830
37831
37832
37833
37834
37835
37836
37837
37838
37839
37840
37841
37842
37843
37844
37845
37846
37847
37848
37849
37850
37851
37852
37853
37854
37855
37856
37857
37858
37859
37860
37861
37862
37863
37864
37865
37866
37867
37868
37869
37870
37871
37872
37873
37874
37875
37876
37877
37878
37879
37880
37881
37882
37883
37884
37885
37886
37887
37888
37889
37890
37891
37892
37893
37894
37895
37896
37897
37898
37899
37900
37901
37902
37903
37904
37905
37906
37907
37908
37909
37910
37911
37912
37913
37914
37915
37916
37917
37918
37919
37920
37921
37922
37923
37924
37925
37926
37927
37928
37929
37930
37931
37932
37933
37934
37935
37936
37937
37938
37939
37940
37941
37942
37943
37944
37945
37946
37947
37948
37949
37950
37951
37952
37953
37954
37955
37956
37957
37958
37959
37960
37961
37962
37963
37964
37965
37966
37967
37968
37969
37970
37971
37972
37973
37974
37975
37976
37977
37978
37979
37980
37981
37982
37983
37984
37985
37986
37987
37988
37989
37990
37991
37992
37993
37994
37995
37996
37997
37998
37999
38000
38001
38002
38003
38004
38005
38006
38007
38008
38009
38010
38011
38012
38013
38014
38015
38016
38017
38018
38019
38020
38021
38022
38023
38024
38025
38026
38027
38028
38029
38030
38031
38032
38033
38034
38035
38036
38037
38038
38039
38040
38041
38042
38043
38044
38045
38046
38047
38048
38049
38050
38051
38052
38053
38054
38055
38056
38057
38058
38059
38060
38061
38062
38063
38064
38065
38066
38067
38068
38069
38070
38071
38072
38073
38074
38075
38076
38077
38078
38079
38080
38081
38082
38083
38084
38085
38086
38087
38088
38089
38090
38091
38092
38093
38094
38095
38096
38097
38098
38099
38100
38101
38102
38103
38104
38105
38106
38107
38108
38109
38110
38111
38112
38113
38114
38115
38116
38117
38118
38119
38120
38121
38122
38123
38124
38125
38126
38127
38128
38129
38130
38131
38132
38133
38134
38135
38136
38137
38138
38139
38140
38141
38142
38143
38144
38145
38146
38147
38148
38149
38150
38151
38152
38153
38154
38155
38156
38157
38158
38159
38160
38161
38162
38163
38164
38165
38166
38167
38168
38169
38170
38171
38172
38173
38174
38175
38176
38177
38178
38179
38180
38181
38182
38183
38184
38185
38186
38187
38188
38189
38190
38191
38192
38193
38194
38195
38196
38197
38198
38199
38200
38201
38202
38203
38204
38205
38206
38207
38208
38209
38210
38211
38212
38213
38214
38215
38216
38217
38218
38219
38220
38221
38222
38223
38224
38225
38226
38227
38228
38229
38230
38231
38232
38233
38234
38235
38236
38237
38238
38239
38240
38241
38242
38243
38244
38245
38246
38247
38248
38249
38250
38251
38252
38253
38254
38255
38256
38257
38258
38259
38260
38261
38262
38263
38264
38265
38266
38267
38268
38269
38270
38271
38272
38273
38274
38275
38276
38277
38278
38279
38280
38281
38282
38283
38284
38285
38286
38287
38288
38289
38290
38291
38292
38293
38294
38295
38296
38297
38298
38299
38300
38301
38302
38303
38304
38305
38306
38307
38308
38309
38310
38311
38312
38313
38314
38315
38316
38317
38318
38319
38320
38321
38322
38323
38324
38325
38326
38327
38328
38329
38330
38331
38332
38333
38334
38335
38336
38337
38338
38339
38340
38341
38342
38343
38344
38345
38346
38347
38348
38349
38350
38351
38352
38353
38354
38355
38356
38357
38358
38359
38360
38361
38362
38363
38364
38365
38366
38367
38368
38369
38370
38371
38372
38373
38374
38375
38376
38377
38378
38379
38380
38381
38382
38383
38384
38385
38386
38387
38388
38389
38390
38391
38392
38393
38394
38395
38396
38397
38398
38399
38400
38401
38402
38403
38404
38405
38406
38407
38408
38409
38410
38411
38412
38413
38414
38415
38416
38417
38418
38419
38420
38421
38422
38423
38424
38425
38426
38427
38428
38429
38430
38431
38432
38433
38434
38435
38436
38437
38438
38439
38440
38441
38442
38443
38444
38445
38446
38447
38448
38449
38450
38451
38452
38453
38454
38455
38456
38457
38458
38459
38460
38461
38462
38463
38464
38465
38466
38467
38468
38469
38470
38471
38472
38473
38474
38475
38476
38477
38478
38479
38480
38481
38482
38483
38484
38485
38486
38487
38488
38489
38490
38491
38492
38493
38494
38495
38496
38497
38498
38499
38500
38501
38502
38503
38504
38505
38506
38507
38508
38509
38510
38511
38512
38513
38514
38515
38516
38517
38518
38519
38520
38521
38522
38523
38524
38525
38526
38527
38528
38529
38530
38531
38532
38533
38534
38535
38536
38537
38538
38539
38540
38541
38542
38543
38544
38545
38546
38547
38548
38549
38550
38551
38552
38553
38554
38555
38556
38557
38558
38559
38560
38561
38562
38563
38564
38565
38566
38567
38568
38569
38570
38571
38572
38573
38574
38575
38576
38577
38578
38579
38580
38581
38582
38583
38584
38585
38586
38587
38588
38589
38590
38591
38592
38593
38594
38595
38596
38597
38598
38599
38600
38601
38602
38603
38604
38605
38606
38607
38608
38609
38610
38611
38612
38613
38614
38615
38616
38617
38618
38619
38620
38621
38622
38623
38624
38625
38626
38627
38628
38629
38630
38631
38632
38633
38634
38635
38636
38637
38638
38639
38640
38641
38642
38643
38644
38645
38646
38647
38648
38649
38650
38651
38652
38653
38654
38655
38656
38657
38658
38659
38660
38661
38662
38663
38664
38665
38666
38667
38668
38669
38670
38671
38672
38673
38674
38675
38676
38677
38678
38679
38680
38681
38682
38683
38684
38685
38686
38687
38688
38689
38690
38691
38692
38693
38694
38695
38696
38697
38698
38699
38700
38701
38702
38703
38704
38705
38706
38707
38708
38709
38710
38711
38712
38713
38714
38715
38716
38717
38718
38719
38720
38721
38722
38723
38724
38725
38726
38727
38728
38729
38730
38731
38732
38733
38734
38735
38736
38737
38738
38739
38740
38741
38742
38743
38744
38745
38746
38747
38748
38749
38750
38751
38752
38753
38754
38755
38756
38757
38758
38759
38760
38761
38762
38763
38764
38765
38766
38767
38768
38769
38770
38771
38772
38773
38774
38775
38776
38777
38778
38779
38780
38781
38782
38783
38784
38785
38786
38787
38788
38789
38790
38791
38792
38793
38794
38795
38796
38797
38798
38799
38800
38801
38802
38803
38804
38805
38806
38807
38808
38809
38810
38811
38812
38813
38814
38815
38816
38817
38818
38819
38820
38821
38822
38823
38824
38825
38826
38827
38828
38829
38830
38831
38832
38833
38834
38835
38836
38837
38838
38839
38840
38841
38842
38843
38844
38845
38846
38847
38848
38849
38850
38851
38852
38853
38854
38855
38856
38857
38858
38859
38860
38861
38862
38863
38864
38865
38866
38867
38868
38869
38870
38871
38872
38873
38874
38875
38876
38877
38878
38879
38880
38881
38882
38883
38884
38885
38886
38887
38888
38889
38890
38891
38892
38893
38894
38895
38896
38897
38898
38899
38900
38901
38902
38903
38904
38905
38906
38907
38908
38909
38910
38911
38912
38913
38914
38915
38916
38917
38918
38919
38920
38921
38922
38923
38924
38925
38926
38927
38928
38929
38930
38931
38932
38933
38934
38935
38936
38937
38938
38939
38940
38941
38942
38943
38944
38945
38946
38947
38948
38949
38950
38951
38952
38953
38954
38955
38956
38957
38958
38959
38960
38961
38962
38963
38964
38965
38966
38967
38968
38969
38970
38971
38972
38973
38974
38975
38976
38977
38978
38979
38980
38981
38982
38983
38984
38985
38986
38987
38988
38989
38990
38991
38992
38993
38994
38995
38996
38997
38998
38999
39000
39001
39002
39003
39004
39005
39006
39007
39008
39009
39010
39011
39012
39013
39014
39015
39016
39017
39018
39019
39020
39021
39022
39023
39024
39025
39026
39027
39028
39029
39030
39031
39032
39033
39034
39035
39036
39037
39038
39039
39040
39041
39042
39043
39044
39045
39046
39047
39048
39049
39050
39051
39052
39053
39054
39055
39056
39057
39058
39059
39060
39061
39062
39063
39064
39065
39066
39067
39068
39069
39070
39071
39072
39073
39074
39075
39076
39077
39078
39079
39080
39081
39082
39083
39084
39085
39086
39087
39088
39089
39090
39091
39092
39093
39094
39095
39096
39097
39098
39099
39100
39101
39102
39103
39104
39105
39106
39107
39108
39109
39110
39111
39112
39113
39114
39115
39116
39117
39118
39119
39120
39121
39122
39123
39124
39125
39126
39127
39128
39129
39130
39131
39132
39133
39134
39135
39136
39137
39138
39139
39140
39141
39142
39143
39144
39145
39146
39147
39148
39149
39150
39151
39152
39153
39154
39155
39156
39157
39158
39159
39160
39161
39162
39163
39164
39165
39166
39167
39168
39169
39170
39171
39172
39173
39174
39175
39176
39177
39178
39179
39180
39181
39182
39183
39184
39185
39186
39187
39188
39189
39190
39191
39192
39193
39194
39195
39196
39197
39198
39199
39200
39201
39202
39203
39204
39205
39206
39207
39208
39209
39210
39211
39212
39213
39214
39215
39216
39217
39218
39219
39220
39221
39222
39223
39224
39225
39226
39227
39228
39229
39230
39231
39232
39233
39234
39235
39236
39237
39238
39239
39240
39241
39242
39243
39244
39245
39246
39247
39248
39249
39250
39251
39252
39253
39254
39255
39256
39257
39258
39259
39260
39261
39262
39263
39264
39265
39266
39267
39268
39269
39270
39271
39272
39273
39274
39275
39276
39277
39278
39279
39280
39281
39282
39283
39284
39285
39286
39287
39288
39289
39290
39291
39292
39293
39294
39295
39296
39297
39298
39299
39300
39301
39302
39303
39304
39305
39306
39307
39308
39309
39310
39311
39312
39313
39314
39315
39316
39317
39318
39319
39320
39321
39322
39323
39324
39325
39326
39327
39328
39329
39330
39331
39332
39333
39334
39335
39336
39337
39338
39339
39340
39341
39342
39343
39344
39345
39346
39347
39348
39349
39350
39351
39352
39353
39354
39355
39356
39357
39358
39359
39360
39361
39362
39363
39364
39365
39366
39367
39368
39369
39370
39371
39372
39373
39374
39375
39376
39377
39378
39379
39380
39381
39382
39383
39384
39385
39386
39387
39388
39389
39390
39391
39392
39393
39394
39395
39396
39397
39398
39399
39400
39401
39402
39403
39404
39405
39406
39407
39408
39409
39410
39411
39412
39413
39414
39415
39416
39417
39418
39419
39420
39421
39422
39423
39424
39425
39426
39427
39428
39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
39509
39510
39511
39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
39561
39562
39563
39564
39565
39566
39567
39568
39569
39570
39571
39572
39573
39574
39575
39576
39577
39578
39579
39580
39581
39582
39583
39584
39585
39586
39587
39588
39589
39590
39591
39592
39593
39594
39595
39596
39597
39598
39599
39600
39601
39602
39603
39604
39605
39606
39607
39608
39609
39610
39611
39612
39613
39614
39615
39616
39617
39618
39619
39620
39621
39622
39623
39624
39625
39626
39627
39628
39629
39630
39631
39632
39633
39634
39635
39636
39637
39638
39639
39640
39641
39642
39643
39644
39645
39646
39647
39648
39649
39650
39651
39652
39653
39654
39655
39656
39657
39658
39659
39660
39661
39662
39663
39664
39665
39666
39667
39668
39669
39670
39671
39672
39673
39674
39675
39676
39677
39678
39679
39680
39681
39682
39683
39684
39685
39686
39687
39688
39689
39690
39691
39692
39693
39694
39695
39696
39697
39698
39699
39700
39701
39702
39703
39704
39705
39706
39707
39708
39709
39710
39711
39712
39713
39714
39715
39716
39717
39718
39719
39720
39721
39722
39723
39724
39725
39726
39727
39728
39729
39730
39731
39732
39733
39734
39735
39736
39737
39738
39739
39740
39741
39742
39743
39744
39745
39746
39747
39748
39749
39750
39751
39752
39753
39754
39755
39756
39757
39758
39759
39760
39761
39762
39763
39764
39765
39766
39767
39768
39769
39770
39771
39772
39773
39774
39775
39776
39777
39778
39779
39780
39781
39782
39783
39784
39785
39786
39787
39788
39789
39790
39791
39792
39793
39794
39795
39796
39797
39798
39799
39800
39801
39802
39803
39804
39805
39806
39807
39808
39809
39810
39811
39812
39813
39814
39815
39816
39817
39818
39819
39820
39821
39822
39823
39824
39825
39826
39827
39828
39829
39830
39831
39832
39833
39834
39835
39836
39837
39838
39839
39840
39841
39842
39843
39844
39845
39846
39847
39848
39849
39850
39851
39852
39853
39854
39855
39856
39857
39858
39859
39860
39861
39862
39863
39864
39865
39866
39867
39868
39869
39870
39871
39872
39873
39874
39875
39876
39877
39878
39879
39880
39881
39882
39883
39884
39885
39886
39887
39888
39889
39890
39891
39892
39893
39894
39895
39896
39897
39898
39899
39900
39901
39902
39903
39904
39905
39906
39907
39908
39909
39910
39911
39912
39913
39914
39915
39916
39917
39918
39919
39920
39921
39922
39923
39924
39925
39926
39927
39928
39929
39930
39931
39932
39933
39934
39935
39936
39937
39938
39939
39940
39941
39942
39943
39944
39945
39946
39947
39948
39949
39950
39951
39952
39953
39954
39955
39956
39957
39958
39959
39960
39961
39962
39963
39964
39965
39966
39967
39968
39969
39970
39971
39972
39973
39974
39975
39976
39977
39978
39979
39980
39981
39982
39983
39984
39985
39986
39987
39988
39989
39990
39991
39992
39993
39994
39995
39996
39997
39998
39999
40000
40001
40002
40003
40004
40005
40006
40007
40008
40009
40010
40011
40012
40013
40014
40015
40016
40017
40018
40019
40020
40021
40022
40023
40024
40025
40026
40027
40028
40029
40030
40031
40032
40033
40034
40035
40036
40037
40038
40039
40040
40041
40042
40043
40044
40045
40046
40047
40048
40049
40050
40051
40052
40053
40054
40055
40056
40057
40058
40059
40060
40061
40062
40063
40064
40065
40066
40067
40068
40069
40070
40071
40072
40073
40074
40075
40076
40077
40078
40079
40080
40081
40082
40083
40084
40085
40086
40087
40088
40089
40090
40091
40092
40093
40094
40095
40096
40097
40098
40099
40100
40101
40102
40103
40104
40105
40106
40107
40108
40109
40110
40111
40112
40113
40114
40115
40116
40117
40118
40119
40120
40121
40122
40123
40124
40125
40126
40127
40128
40129
40130
40131
40132
40133
40134
40135
40136
40137
40138
40139
40140
40141
40142
40143
40144
40145
40146
40147
40148
40149
40150
40151
40152
40153
40154
40155
40156
40157
40158
40159
40160
40161
40162
40163
40164
40165
40166
40167
40168
40169
40170
40171
40172
40173
40174
40175
40176
40177
40178
40179
40180
40181
40182
40183
40184
40185
40186
40187
40188
40189
40190
40191
40192
40193
40194
40195
40196
40197
40198
40199
40200
40201
40202
40203
40204
40205
40206
40207
40208
40209
40210
40211
40212
40213
40214
40215
40216
40217
40218
40219
40220
40221
40222
40223
40224
40225
40226
40227
40228
40229
40230
40231
40232
40233
40234
40235
40236
40237
40238
40239
40240
40241
40242
40243
40244
40245
40246
40247
40248
40249
40250
40251
40252
40253
40254
40255
40256
40257
40258
40259
40260
40261
40262
40263
40264
40265
40266
40267
40268
40269
40270
40271
40272
40273
40274
40275
40276
40277
40278
40279
40280
40281
40282
40283
40284
40285
40286
40287
40288
40289
40290
40291
40292
40293
40294
40295
40296
40297
40298
40299
40300
40301
40302
40303
40304
40305
40306
40307
40308
40309
40310
40311
40312
40313
40314
40315
40316
40317
40318
40319
40320
40321
40322
40323
40324
40325
40326
40327
40328
40329
40330
40331
40332
40333
40334
40335
40336
40337
40338
40339
40340
40341
40342
40343
40344
40345
40346
40347
40348
40349
40350
40351
40352
40353
40354
40355
40356
40357
40358
40359
40360
40361
40362
40363
40364
40365
40366
40367
40368
40369
40370
40371
40372
40373
40374
40375
40376
40377
40378
40379
40380
40381
40382
40383
40384
40385
40386
40387
40388
40389
40390
40391
40392
40393
40394
40395
40396
40397
40398
40399
40400
40401
40402
40403
40404
40405
40406
40407
40408
40409
40410
40411
40412
40413
40414
40415
40416
40417
40418
40419
40420
40421
40422
40423
40424
40425
40426
40427
40428
40429
40430
40431
40432
40433
40434
40435
40436
40437
40438
40439
40440
40441
40442
40443
40444
40445
40446
40447
40448
40449
40450
40451
40452
40453
40454
40455
40456
40457
40458
40459
40460
40461
40462
40463
40464
40465
40466
40467
40468
40469
40470
40471
40472
40473
40474
40475
40476
40477
40478
40479
40480
40481
40482
40483
40484
40485
40486
40487
40488
40489
40490
40491
40492
40493
40494
40495
40496
40497
40498
40499
40500
40501
40502
40503
40504
40505
40506
40507
40508
40509
40510
40511
40512
40513
40514
40515
40516
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
40532
40533
40534
40535
40536
40537
40538
40539
40540
40541
40542
40543
40544
40545
40546
40547
40548
40549
40550
40551
40552
40553
40554
40555
40556
40557
40558
40559
40560
40561
40562
40563
40564
40565
40566
40567
40568
40569
40570
40571
40572
40573
40574
40575
40576
40577
40578
40579
40580
40581
40582
40583
40584
40585
40586
40587
40588
40589
40590
40591
40592
40593
40594
40595
40596
40597
40598
40599
40600
40601
40602
40603
40604
40605
40606
40607
40608
40609
40610
40611
40612
40613
40614
40615
40616
40617
40618
40619
40620
40621
40622
40623
40624
40625
40626
40627
40628
40629
40630
40631
40632
40633
40634
40635
40636
40637
40638
40639
40640
40641
40642
40643
40644
40645
40646
40647
40648
40649
40650
40651
40652
40653
40654
40655
40656
40657
40658
40659
40660
40661
40662
40663
40664
40665
40666
40667
40668
40669
40670
40671
40672
40673
40674
40675
40676
40677
40678
40679
40680
40681
40682
40683
40684
40685
40686
40687
40688
40689
40690
40691
40692
40693
40694
40695
40696
40697
40698
40699
40700
40701
40702
40703
40704
40705
40706
40707
40708
40709
40710
40711
40712
40713
40714
40715
40716
40717
40718
40719
40720
40721
40722
40723
40724
40725
40726
40727
40728
40729
40730
40731
40732
40733
40734
40735
40736
40737
40738
40739
40740
40741
40742
40743
40744
40745
40746
40747
40748
40749
40750
40751
40752
40753
40754
40755
40756
40757
40758
40759
40760
40761
40762
40763
40764
40765
40766
40767
40768
40769
40770
40771
40772
40773
40774
40775
40776
40777
40778
40779
40780
40781
40782
40783
40784
40785
40786
40787
40788
40789
40790
40791
40792
40793
40794
40795
40796
40797
40798
40799
40800
40801
40802
40803
40804
40805
40806
40807
40808
40809
40810
40811
40812
40813
40814
40815
40816
40817
40818
40819
40820
40821
40822
40823
40824
40825
40826
40827
40828
40829
40830
40831
40832
40833
40834
40835
40836
40837
40838
40839
40840
40841
40842
40843
40844
40845
40846
40847
40848
40849
40850
40851
40852
40853
40854
40855
40856
40857
40858
40859
40860
40861
40862
40863
40864
40865
40866
40867
40868
40869
40870
40871
40872
40873
40874
40875
40876
40877
40878
40879
40880
40881
40882
40883
40884
40885
40886
40887
40888
40889
40890
40891
40892
40893
40894
40895
40896
40897
40898
40899
40900
40901
40902
40903
40904
40905
40906
40907
40908
40909
40910
40911
40912
40913
40914
40915
40916
40917
40918
40919
40920
40921
40922
40923
40924
40925
40926
40927
40928
40929
40930
40931
40932
40933
40934
40935
40936
40937
40938
40939
40940
40941
40942
40943
40944
40945
40946
40947
40948
40949
40950
40951
40952
40953
40954
40955
40956
40957
40958
40959
40960
40961
40962
40963
40964
40965
40966
40967
40968
40969
40970
40971
40972
40973
40974
40975
40976
40977
40978
40979
40980
40981
40982
40983
40984
40985
40986
40987
40988
40989
40990
40991
40992
40993
40994
40995
40996
40997
40998
40999
41000
41001
41002
41003
41004
41005
41006
41007
41008
41009
41010
41011
41012
41013
41014
41015
41016
41017
41018
41019
41020
41021
41022
41023
41024
41025
41026
41027
41028
41029
41030
41031
41032
41033
41034
41035
41036
41037
41038
41039
41040
41041
41042
41043
41044
41045
41046
41047
41048
41049
41050
41051
41052
41053
41054
41055
41056
41057
41058
41059
41060
41061
41062
41063
41064
41065
41066
41067
41068
41069
41070
41071
41072
41073
41074
41075
41076
41077
41078
41079
41080
41081
41082
41083
41084
41085
41086
41087
41088
41089
41090
41091
41092
41093
41094
41095
41096
41097
41098
41099
41100
41101
41102
41103
41104
41105
41106
41107
41108
41109
41110
41111
41112
41113
41114
41115
41116
41117
41118
41119
41120
41121
41122
41123
41124
41125
41126
41127
41128
41129
41130
41131
41132
41133
41134
41135
41136
41137
41138
41139
41140
41141
41142
41143
41144
41145
41146
41147
41148
41149
41150
41151
41152
41153
41154
41155
41156
41157
41158
41159
41160
41161
41162
41163
41164
41165
41166
41167
41168
41169
41170
41171
41172
41173
41174
41175
41176
41177
41178
41179
41180
41181
41182
41183
41184
41185
41186
41187
41188
41189
41190
41191
41192
41193
41194
41195
41196
41197
41198
41199
41200
41201
41202
41203
41204
41205
41206
41207
41208
41209
41210
41211
41212
41213
41214
41215
41216
41217
41218
41219
41220
41221
41222
41223
41224
41225
41226
41227
41228
41229
41230
41231
41232
41233
41234
41235
41236
41237
41238
41239
41240
41241
41242
41243
41244
41245
41246
41247
41248
41249
41250
41251
41252
41253
41254
41255
41256
41257
41258
41259
41260
41261
41262
41263
41264
41265
41266
41267
41268
41269
41270
41271
41272
41273
41274
41275
41276
41277
41278
41279
41280
41281
41282
41283
41284
41285
41286
41287
41288
41289
41290
41291
41292
41293
41294
41295
41296
41297
41298
41299
41300
41301
41302
41303
41304
41305
41306
41307
41308
41309
41310
41311
41312
41313
41314
41315
41316
41317
41318
41319
41320
41321
41322
41323
41324
41325
41326
41327
41328
41329
41330
41331
41332
41333
41334
41335
41336
41337
41338
41339
41340
41341
41342
41343
41344
41345
41346
41347
41348
41349
41350
41351
41352
41353
41354
41355
41356
41357
41358
41359
41360
41361
41362
41363
41364
41365
41366
41367
41368
41369
41370
41371
41372
41373
41374
41375
41376
41377
41378
41379
41380
41381
41382
41383
41384
41385
41386
41387
41388
41389
41390
41391
41392
41393
41394
41395
41396
41397
41398
41399
41400
41401
41402
41403
41404
41405
41406
41407
41408
41409
41410
41411
41412
41413
41414
41415
41416
41417
41418
41419
41420
41421
41422
41423
41424
41425
41426
41427
41428
41429
41430
41431
41432
41433
41434
41435
41436
41437
41438
41439
41440
41441
41442
41443
41444
41445
41446
41447
41448
41449
41450
41451
41452
41453
41454
41455
41456
41457
41458
41459
41460
41461
41462
41463
41464
41465
41466
41467
41468
41469
41470
41471
41472
41473
41474
41475
41476
41477
41478
41479
41480
41481
41482
41483
41484
41485
41486
41487
41488
41489
41490
41491
41492
41493
41494
41495
41496
41497
41498
41499
41500
41501
41502
41503
41504
41505
41506
41507
41508
41509
41510
41511
41512
41513
41514
41515
41516
41517
41518
41519
41520
41521
41522
41523
41524
41525
41526
41527
41528
41529
41530
41531
41532
41533
41534
41535
41536
41537
41538
41539
41540
41541
41542
41543
41544
41545
41546
41547
41548
41549
41550
41551
41552
41553
41554
41555
41556
41557
41558
41559
41560
41561
41562
41563
41564
41565
41566
41567
41568
41569
41570
41571
41572
41573
41574
41575
41576
41577
41578
41579
41580
41581
41582
41583
41584
41585
41586
41587
41588
41589
41590
41591
41592
41593
41594
41595
41596
41597
41598
41599
41600
41601
41602
41603
41604
41605
41606
41607
41608
41609
41610
41611
41612
41613
41614
41615
41616
41617
41618
41619
41620
41621
41622
41623
41624
41625
41626
41627
41628
41629
41630
41631
41632
41633
41634
41635
41636
41637
41638
41639
41640
41641
41642
41643
41644
41645
41646
41647
41648
41649
41650
41651
41652
41653
41654
41655
41656
41657
41658
41659
41660
41661
41662
41663
41664
41665
41666
41667
41668
41669
41670
41671
41672
41673
41674
41675
41676
41677
41678
41679
41680
41681
41682
41683
41684
41685
41686
41687
41688
41689
41690
41691
41692
41693
41694
41695
41696
41697
41698
41699
41700
41701
41702
41703
41704
41705
41706
41707
41708
41709
41710
41711
41712
41713
41714
41715
41716
41717
41718
41719
41720
41721
41722
41723
41724
41725
41726
41727
41728
41729
41730
41731
41732
41733
41734
41735
41736
41737
41738
41739
41740
41741
41742
41743
41744
41745
41746
41747
41748
41749
41750
41751
41752
41753
41754
41755
41756
41757
41758
41759
41760
41761
41762
41763
41764
41765
41766
41767
41768
41769
41770
41771
41772
41773
41774
41775
41776
41777
41778
41779
41780
41781
41782
41783
41784
41785
41786
41787
41788
41789
41790
41791
41792
41793
41794
41795
41796
41797
41798
41799
41800
41801
41802
41803
41804
41805
41806
41807
41808
41809
41810
41811
41812
41813
41814
41815
41816
41817
41818
41819
41820
41821
41822
41823
41824
41825
41826
41827
41828
41829
41830
41831
41832
41833
41834
41835
41836
41837
41838
41839
41840
41841
41842
41843
41844
41845
41846
41847
41848
41849
41850
41851
41852
41853
41854
41855
41856
41857
41858
41859
41860
41861
41862
41863
41864
41865
41866
41867
41868
41869
41870
41871
41872
41873
41874
41875
41876
41877
41878
41879
41880
41881
41882
41883
41884
41885
41886
41887
41888
41889
41890
41891
41892
41893
41894
41895
41896
41897
41898
41899
41900
41901
41902
41903
41904
41905
41906
41907
41908
41909
41910
41911
41912
41913
41914
41915
41916
41917
41918
41919
41920
41921
41922
41923
41924
41925
41926
41927
41928
41929
41930
41931
41932
41933
41934
41935
41936
41937
41938
41939
41940
41941
41942
41943
41944
41945
41946
41947
41948
41949
41950
41951
41952
41953
41954
41955
41956
41957
41958
41959
41960
41961
41962
41963
41964
41965
41966
41967
41968
41969
41970
41971
41972
41973
41974
41975
41976
41977
41978
41979
41980
41981
41982
41983
41984
41985
41986
41987
41988
41989
41990
41991
41992
41993
41994
41995
41996
41997
41998
41999
42000
42001
42002
42003
42004
42005
42006
42007
42008
42009
42010
42011
42012
42013
42014
42015
42016
42017
42018
42019
42020
42021
42022
42023
42024
42025
42026
42027
42028
42029
42030
42031
42032
42033
42034
42035
42036
42037
42038
42039
42040
42041
42042
42043
42044
42045
42046
42047
42048
42049
42050
42051
42052
42053
42054
42055
42056
42057
42058
42059
42060
42061
42062
42063
42064
42065
42066
42067
42068
42069
42070
42071
42072
42073
42074
42075
42076
42077
42078
42079
42080
42081
42082
42083
42084
42085
42086
42087
42088
42089
42090
42091
42092
42093
42094
42095
42096
42097
42098
42099
42100
42101
42102
42103
42104
42105
42106
42107
42108
42109
42110
42111
42112
42113
42114
42115
42116
42117
42118
42119
42120
42121
42122
42123
42124
42125
42126
42127
42128
42129
42130
42131
42132
42133
42134
42135
42136
42137
42138
42139
42140
42141
42142
42143
42144
42145
42146
42147
42148
42149
42150
42151
42152
42153
42154
42155
42156
42157
42158
42159
42160
42161
42162
42163
42164
42165
42166
42167
42168
42169
42170
42171
42172
42173
42174
42175
42176
42177
42178
42179
42180
42181
42182
42183
42184
42185
42186
42187
42188
42189
42190
42191
42192
42193
42194
42195
42196
42197
42198
42199
42200
42201
42202
42203
42204
42205
42206
42207
42208
42209
42210
42211
42212
42213
42214
42215
42216
42217
42218
42219
42220
42221
42222
42223
42224
42225
42226
42227
42228
42229
42230
42231
42232
42233
42234
42235
42236
42237
42238
42239
42240
42241
42242
42243
42244
42245
42246
42247
42248
42249
42250
42251
42252
42253
42254
42255
42256
42257
42258
42259
42260
42261
42262
42263
42264
42265
42266
42267
42268
42269
42270
42271
42272
42273
42274
42275
42276
42277
42278
42279
42280
42281
42282
42283
42284
42285
42286
42287
42288
42289
42290
42291
42292
42293
42294
42295
42296
42297
42298
42299
42300
42301
42302
42303
42304
42305
42306
42307
42308
42309
42310
42311
42312
42313
42314
42315
42316
42317
42318
42319
42320
42321
42322
42323
42324
42325
42326
42327
42328
42329
42330
42331
42332
42333
42334
42335
42336
42337
42338
42339
42340
42341
42342
42343
42344
42345
42346
42347
42348
42349
42350
42351
42352
42353
42354
42355
42356
42357
42358
42359
42360
42361
42362
42363
42364
42365
42366
42367
42368
42369
42370
42371
42372
42373
42374
42375
42376
42377
42378
42379
42380
42381
42382
42383
42384
42385
42386
42387
42388
42389
42390
42391
42392
42393
42394
42395
42396
42397
42398
42399
42400
42401
42402
42403
42404
42405
42406
42407
42408
42409
42410
42411
42412
42413
42414
42415
42416
42417
42418
42419
42420
42421
42422
42423
42424
42425
42426
42427
42428
42429
42430
42431
42432
42433
42434
42435
42436
42437
42438
42439
42440
42441
42442
42443
42444
42445
42446
42447
42448
42449
42450
42451
42452
42453
42454
42455
42456
42457
42458
42459
42460
42461
42462
42463
42464
42465
42466
42467
42468
42469
42470
42471
42472
42473
42474
42475
42476
42477
42478
42479
42480
42481
42482
42483
42484
42485
42486
42487
42488
42489
42490
42491
42492
42493
42494
42495
42496
42497
42498
42499
42500
42501
42502
42503
42504
42505
42506
42507
42508
42509
42510
42511
42512
42513
42514
42515
42516
42517
42518
42519
42520
42521
42522
42523
42524
42525
42526
42527
42528
42529
42530
42531
42532
42533
42534
42535
42536
42537
42538
42539
42540
42541
42542
42543
42544
42545
42546
42547
42548
42549
42550
42551
42552
42553
42554
42555
42556
42557
42558
42559
42560
42561
42562
42563
42564
42565
42566
42567
42568
42569
42570
42571
42572
42573
42574
42575
42576
42577
42578
42579
42580
42581
42582
42583
42584
42585
42586
42587
42588
42589
42590
42591
42592
42593
42594
42595
42596
42597
42598
42599
42600
42601
42602
42603
42604
42605
42606
42607
42608
42609
42610
42611
42612
42613
42614
42615
42616
42617
42618
42619
42620
42621
42622
42623
42624
42625
42626
42627
42628
42629
42630
42631
42632
42633
42634
42635
42636
42637
42638
42639
42640
42641
42642
42643
42644
42645
42646
42647
42648
42649
42650
42651
42652
42653
42654
42655
42656
42657
42658
42659
42660
42661
42662
42663
42664
42665
42666
42667
42668
42669
42670
42671
42672
42673
42674
42675
42676
42677
42678
42679
42680
42681
42682
42683
42684
42685
42686
42687
42688
42689
42690
42691
42692
42693
42694
42695
42696
42697
42698
42699
42700
42701
42702
42703
42704
42705
42706
42707
42708
42709
42710
42711
42712
42713
42714
42715
42716
42717
42718
42719
42720
42721
42722
42723
42724
42725
42726
42727
42728
42729
42730
42731
42732
42733
42734
42735
42736
42737
42738
42739
42740
42741
42742
42743
42744
42745
42746
42747
42748
42749
42750
42751
42752
42753
42754
42755
42756
42757
42758
42759
42760
42761
42762
42763
42764
42765
42766
42767
42768
42769
42770
42771
42772
42773
42774
42775
42776
42777
42778
42779
42780
42781
42782
42783
42784
42785
42786
42787
42788
42789
42790
42791
42792
42793
42794
42795
42796
42797
42798
42799
42800
42801
42802
42803
42804
42805
42806
42807
42808
42809
42810
42811
42812
42813
42814
42815
42816
42817
42818
42819
42820
42821
42822
42823
42824
42825
42826
42827
42828
42829
42830
42831
42832
42833
42834
42835
42836
42837
42838
42839
42840
42841
42842
42843
42844
42845
42846
42847
42848
42849
42850
42851
42852
42853
42854
42855
42856
42857
42858
42859
42860
42861
42862
42863
42864
42865
42866
42867
42868
42869
42870
42871
42872
42873
42874
42875
42876
42877
42878
42879
42880
42881
42882
42883
42884
42885
42886
42887
42888
42889
42890
42891
42892
42893
42894
42895
42896
42897
42898
42899
42900
42901
42902
42903
42904
42905
42906
42907
42908
42909
42910
42911
42912
42913
42914
42915
42916
42917
42918
42919
42920
42921
42922
42923
42924
42925
42926
42927
42928
42929
42930
42931
42932
42933
42934
42935
42936
42937
42938
42939
42940
42941
42942
42943
42944
42945
42946
42947
42948
42949
42950
42951
42952
42953
42954
42955
42956
42957
42958
42959
42960
42961
42962
42963
42964
42965
42966
42967
42968
42969
42970
42971
42972
42973
42974
42975
42976
42977
42978
42979
42980
42981
42982
42983
42984
42985
42986
42987
42988
42989
42990
42991
42992
42993
42994
42995
42996
42997
42998
42999
43000
43001
43002
43003
43004
43005
43006
43007
43008
43009
43010
43011
43012
43013
43014
43015
43016
43017
43018
43019
43020
43021
43022
43023
43024
43025
43026
43027
43028
43029
43030
43031
43032
43033
43034
43035
43036
43037
43038
43039
43040
43041
43042
43043
43044
43045
43046
43047
43048
43049
43050
43051
43052
43053
43054
43055
43056
43057
43058
43059
43060
43061
43062
43063
43064
43065
43066
43067
43068
43069
43070
43071
43072
43073
43074
43075
43076
43077
43078
43079
43080
43081
43082
43083
43084
43085
43086
43087
43088
43089
43090
43091
43092
43093
43094
43095
43096
43097
43098
43099
43100
43101
43102
43103
43104
43105
43106
43107
43108
43109
43110
43111
43112
43113
43114
43115
43116
43117
43118
43119
43120
43121
43122
43123
43124
43125
43126
43127
43128
43129
43130
43131
43132
43133
43134
43135
43136
43137
43138
43139
43140
43141
43142
43143
43144
43145
43146
43147
43148
43149
43150
43151
43152
43153
43154
43155
43156
43157
43158
43159
43160
43161
43162
43163
43164
43165
43166
43167
43168
43169
43170
43171
43172
43173
43174
43175
43176
43177
43178
43179
43180
43181
43182
43183
43184
43185
43186
43187
43188
43189
43190
43191
43192
43193
43194
43195
43196
43197
43198
43199
43200
43201
43202
43203
43204
43205
43206
43207
43208
43209
43210
43211
43212
43213
43214
43215
43216
43217
43218
43219
43220
43221
43222
43223
43224
43225
43226
43227
43228
43229
43230
43231
43232
43233
43234
43235
43236
43237
43238
43239
43240
43241
43242
43243
43244
43245
43246
43247
43248
43249
43250
43251
43252
43253
43254
43255
43256
43257
43258
43259
43260
43261
43262
43263
43264
43265
43266
43267
43268
43269
43270
43271
43272
43273
43274
43275
43276
43277
43278
43279
43280
43281
43282
43283
43284
43285
43286
43287
43288
43289
43290
43291
43292
43293
43294
43295
43296
43297
43298
43299
43300
43301
43302
43303
43304
43305
43306
43307
43308
43309
43310
43311
43312
43313
43314
43315
43316
43317
43318
43319
43320
43321
43322
43323
43324
43325
43326
43327
43328
43329
43330
43331
43332
43333
43334
43335
43336
43337
43338
43339
43340
43341
43342
43343
43344
43345
43346
43347
43348
43349
43350
43351
43352
43353
43354
43355
43356
43357
43358
43359
43360
43361
43362
43363
43364
43365
43366
43367
43368
43369
43370
43371
43372
43373
43374
43375
43376
43377
43378
43379
43380
43381
43382
43383
43384
43385
43386
43387
43388
43389
43390
43391
43392
43393
43394
43395
43396
43397
43398
43399
43400
43401
43402
43403
43404
43405
43406
43407
43408
43409
43410
43411
43412
43413
43414
43415
43416
43417
43418
43419
43420
43421
43422
43423
43424
43425
43426
43427
43428
43429
43430
43431
43432
43433
43434
43435
43436
43437
43438
43439
43440
43441
43442
43443
43444
43445
43446
43447
43448
43449
43450
43451
43452
43453
43454
43455
43456
43457
43458
43459
43460
43461
43462
43463
43464
43465
43466
43467
43468
43469
43470
43471
43472
43473
43474
43475
43476
43477
43478
43479
43480
43481
43482
43483
43484
43485
43486
43487
43488
43489
43490
43491
43492
43493
43494
43495
43496
43497
43498
43499
43500
43501
43502
43503
43504
43505
43506
43507
43508
43509
43510
43511
43512
43513
43514
43515
43516
43517
43518
43519
43520
43521
43522
43523
43524
43525
43526
43527
43528
43529
43530
43531
43532
43533
43534
43535
43536
43537
43538
43539
43540
43541
43542
43543
43544
43545
43546
43547
43548
43549
43550
43551
43552
43553
43554
43555
43556
43557
43558
43559
43560
43561
43562
43563
43564
43565
43566
43567
43568
43569
43570
43571
43572
43573
43574
43575
43576
43577
43578
43579
43580
43581
43582
43583
43584
43585
43586
43587
43588
43589
43590
43591
43592
43593
43594
43595
43596
43597
43598
43599
43600
43601
43602
43603
43604
43605
43606
43607
43608
43609
43610
43611
43612
43613
43614
43615
43616
43617
43618
43619
43620
43621
43622
43623
43624
43625
43626
43627
43628
43629
43630
43631
43632
43633
43634
43635
43636
43637
43638
43639
43640
43641
43642
43643
43644
43645
43646
43647
43648
43649
43650
43651
43652
43653
43654
43655
43656
43657
43658
43659
43660
43661
43662
43663
43664
43665
43666
43667
43668
43669
43670
43671
43672
43673
43674
43675
43676
43677
43678
43679
43680
43681
43682
43683
43684
43685
43686
43687
43688
43689
43690
43691
43692
43693
43694
43695
43696
43697
43698
43699
43700
43701
43702
43703
43704
43705
43706
43707
43708
43709
43710
43711
43712
43713
43714
43715
43716
43717
43718
43719
43720
43721
43722
43723
43724
43725
43726
43727
43728
43729
43730
43731
43732
43733
43734
43735
43736
43737
43738
43739
43740
43741
43742
43743
43744
43745
43746
43747
43748
43749
43750
43751
43752
43753
43754
43755
43756
43757
43758
43759
43760
43761
43762
43763
43764
43765
43766
43767
43768
43769
43770
43771
43772
43773
43774
43775
43776
43777
43778
43779
43780
43781
43782
43783
43784
43785
43786
43787
43788
43789
43790
43791
43792
43793
43794
43795
43796
43797
43798
43799
43800
43801
43802
43803
43804
43805
43806
43807
43808
43809
43810
43811
43812
43813
43814
43815
43816
43817
43818
43819
43820
43821
43822
43823
43824
43825
43826
43827
43828
43829
43830
43831
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842
43843
43844
43845
43846
43847
43848
43849
43850
43851
43852
43853
43854
43855
43856
43857
43858
43859
43860
43861
43862
43863
43864
43865
43866
43867
43868
43869
43870
43871
43872
43873
43874
43875
43876
43877
43878
43879
43880
43881
43882
43883
43884
43885
43886
43887
43888
43889
43890
43891
43892
43893
43894
43895
43896
43897
43898
43899
43900
43901
43902
43903
43904
43905
43906
43907
43908
43909
43910
43911
43912
43913
43914
43915
43916
43917
43918
43919
43920
43921
43922
43923
43924
43925
43926
43927
43928
43929
43930
43931
43932
43933
43934
43935
43936
43937
43938
43939
43940
43941
43942
43943
43944
43945
43946
43947
43948
43949
43950
43951
43952
43953
43954
43955
43956
43957
43958
43959
43960
43961
43962
43963
43964
43965
43966
43967
43968
43969
43970
43971
43972
43973
43974
43975
43976
43977
43978
43979
43980
43981
43982
43983
43984
43985
43986
43987
43988
43989
43990
43991
43992
43993
43994
43995
43996
43997
43998
43999
44000
44001
44002
44003
44004
44005
44006
44007
44008
44009
44010
44011
44012
44013
44014
44015
44016
44017
44018
44019
44020
44021
44022
44023
44024
44025
44026
44027
44028
44029
44030
44031
44032
44033
44034
44035
44036
44037
44038
44039
44040
44041
44042
44043
44044
44045
44046
44047
44048
44049
44050
44051
44052
44053
44054
44055
44056
44057
44058
44059
44060
44061
44062
44063
44064
44065
44066
44067
44068
44069
44070
44071
44072
44073
44074
44075
44076
44077
44078
44079
44080
44081
44082
44083
44084
44085
44086
44087
44088
44089
44090
44091
44092
44093
44094
44095
44096
44097
44098
44099
44100
44101
44102
44103
44104
44105
44106
44107
44108
44109
44110
44111
44112
44113
44114
44115
44116
44117
44118
44119
44120
44121
44122
44123
44124
44125
44126
44127
44128
44129
44130
44131
44132
44133
44134
44135
44136
44137
44138
44139
44140
44141
44142
44143
44144
44145
44146
44147
44148
44149
44150
44151
44152
44153
44154
44155
44156
44157
44158
44159
44160
44161
44162
44163
44164
44165
44166
44167
44168
44169
44170
44171
44172
44173
44174
44175
44176
44177
44178
44179
44180
44181
44182
44183
44184
44185
44186
44187
44188
44189
44190
44191
44192
44193
44194
44195
44196
44197
44198
44199
44200
44201
44202
44203
44204
44205
44206
44207
44208
44209
44210
44211
44212
44213
44214
44215
44216
44217
44218
44219
44220
44221
44222
44223
44224
44225
44226
44227
44228
44229
44230
44231
44232
44233
44234
44235
44236
44237
44238
44239
44240
44241
44242
44243
44244
44245
44246
44247
44248
44249
44250
44251
44252
44253
44254
44255
44256
44257
44258
44259
44260
44261
44262
44263
44264
44265
44266
44267
44268
44269
44270
44271
44272
44273
44274
44275
44276
44277
44278
44279
44280
44281
44282
44283
44284
44285
44286
44287
44288
44289
44290
44291
44292
44293
44294
44295
44296
44297
44298
44299
44300
44301
44302
44303
44304
44305
44306
44307
44308
44309
44310
44311
44312
44313
44314
44315
44316
44317
44318
44319
44320
44321
44322
44323
44324
44325
44326
44327
44328
44329
44330
44331
44332
44333
44334
44335
44336
44337
44338
44339
44340
44341
44342
44343
44344
44345
44346
44347
44348
44349
44350
44351
44352
44353
44354
44355
44356
44357
44358
44359
44360
44361
44362
44363
44364
44365
44366
44367
44368
44369
44370
44371
44372
44373
44374
44375
44376
44377
44378
44379
44380
44381
44382
44383
44384
44385
44386
44387
44388
44389
44390
44391
44392
44393
44394
44395
44396
44397
44398
44399
44400
44401
44402
44403
44404
44405
44406
44407
44408
44409
44410
44411
44412
44413
44414
44415
44416
44417
44418
44419
44420
44421
44422
44423
44424
44425
44426
44427
44428
44429
44430
44431
44432
44433
44434
44435
44436
44437
44438
44439
44440
44441
44442
44443
44444
44445
44446
44447
44448
44449
44450
44451
44452
44453
44454
44455
44456
44457
44458
44459
44460
44461
44462
44463
44464
44465
44466
44467
44468
44469
44470
44471
44472
44473
44474
44475
44476
44477
44478
44479
44480
44481
44482
44483
44484
44485
44486
44487
44488
44489
44490
44491
44492
44493
44494
44495
44496
44497
44498
44499
44500
44501
44502
44503
44504
44505
44506
44507
44508
44509
44510
44511
44512
44513
44514
44515
44516
44517
44518
44519
44520
44521
44522
44523
44524
44525
44526
44527
44528
44529
44530
44531
44532
44533
44534
44535
44536
44537
44538
44539
44540
44541
44542
44543
44544
44545
44546
44547
44548
44549
44550
44551
44552
44553
44554
44555
44556
44557
44558
44559
44560
44561
44562
44563
44564
44565
44566
44567
44568
44569
44570
44571
44572
44573
44574
44575
44576
44577
44578
44579
44580
44581
44582
44583
44584
44585
44586
44587
44588
44589
44590
44591
44592
44593
44594
44595
44596
44597
44598
44599
44600
44601
44602
44603
44604
44605
44606
44607
44608
44609
44610
44611
44612
44613
44614
44615
44616
44617
44618
44619
44620
44621
44622
44623
44624
44625
44626
44627
44628
44629
44630
44631
44632
44633
44634
44635
44636
44637
44638
44639
44640
44641
44642
44643
44644
44645
44646
44647
44648
44649
44650
44651
44652
44653
44654
44655
44656
44657
44658
44659
44660
44661
44662
44663
44664
44665
44666
44667
44668
44669
44670
44671
44672
44673
44674
44675
44676
44677
44678
44679
44680
44681
44682
44683
44684
44685
44686
44687
44688
44689
44690
44691
44692
44693
44694
44695
44696
44697
44698
44699
44700
44701
44702
44703
44704
44705
44706
44707
44708
44709
44710
44711
44712
44713
44714
44715
44716
44717
44718
44719
44720
44721
44722
44723
44724
44725
44726
44727
44728
44729
44730
44731
44732
44733
44734
44735
44736
44737
44738
44739
44740
44741
44742
44743
44744
44745
44746
44747
44748
44749
44750
44751
44752
44753
44754
44755
44756
44757
44758
44759
44760
44761
44762
44763
44764
44765
44766
44767
44768
44769
44770
44771
44772
44773
44774
44775
44776
44777
44778
44779
44780
44781
44782
44783
44784
44785
44786
44787
44788
44789
44790
44791
44792
44793
44794
44795
44796
44797
44798
44799
44800
44801
44802
44803
44804
44805
44806
44807
44808
44809
44810
44811
44812
44813
44814
44815
44816
44817
44818
44819
44820
44821
44822
44823
44824
44825
44826
44827
44828
44829
44830
44831
44832
44833
44834
44835
44836
44837
44838
44839
44840
44841
44842
44843
44844
44845
44846
44847
44848
44849
44850
44851
44852
44853
44854
44855
44856
44857
44858
44859
44860
44861
44862
44863
44864
44865
44866
44867
44868
44869
44870
44871
44872
44873
44874
44875
44876
44877
44878
44879
44880
44881
44882
44883
44884
44885
44886
44887
44888
44889
44890
44891
44892
44893
44894
44895
44896
44897
44898
44899
44900
44901
44902
44903
44904
44905
44906
44907
44908
44909
44910
44911
44912
44913
44914
44915
44916
44917
44918
44919
44920
44921
44922
44923
44924
44925
44926
44927
44928
44929
44930
44931
44932
44933
44934
44935
44936
44937
44938
44939
44940
44941
44942
44943
44944
44945
44946
44947
44948
44949
44950
44951
44952
44953
44954
44955
44956
44957
44958
44959
44960
44961
44962
44963
44964
44965
44966
44967
44968
44969
44970
44971
44972
44973
44974
44975
44976
44977
44978
44979
44980
44981
44982
44983
44984
44985
44986
44987
44988
44989
44990
44991
44992
44993
44994
44995
44996
44997
44998
44999
45000
45001
45002
45003
45004
45005
45006
45007
45008
45009
45010
45011
45012
45013
45014
45015
45016
45017
45018
45019
45020
45021
45022
45023
45024
45025
45026
45027
45028
45029
45030
45031
45032
45033
45034
45035
45036
45037
45038
45039
45040
45041
45042
45043
45044
45045
45046
45047
45048
45049
45050
45051
45052
45053
45054
45055
45056
45057
45058
45059
45060
45061
45062
45063
45064
45065
45066
45067
45068
45069
45070
45071
45072
45073
45074
45075
45076
45077
45078
45079
45080
45081
45082
45083
45084
45085
45086
45087
45088
45089
45090
45091
45092
45093
45094
45095
45096
45097
45098
45099
45100
45101
45102
45103
45104
45105
45106
45107
45108
45109
45110
45111
45112
45113
45114
45115
45116
45117
45118
45119
45120
45121
45122
45123
45124
45125
45126
45127
45128
45129
45130
45131
45132
45133
45134
45135
45136
45137
45138
45139
45140
45141
45142
45143
45144
45145
45146
45147
45148
45149
45150
45151
45152
45153
45154
45155
45156
45157
45158
45159
45160
45161
45162
45163
45164
45165
45166
45167
45168
45169
45170
45171
45172
45173
45174
45175
45176
45177
45178
45179
45180
45181
45182
45183
45184
45185
45186
45187
45188
45189
45190
45191
45192
45193
45194
45195
45196
45197
45198
45199
45200
45201
45202
45203
45204
45205
45206
45207
45208
45209
45210
45211
45212
45213
45214
45215
45216
45217
45218
45219
45220
45221
45222
45223
45224
45225
45226
45227
45228
45229
45230
45231
45232
45233
45234
45235
45236
45237
45238
45239
45240
45241
45242
45243
45244
45245
45246
45247
45248
45249
45250
45251
45252
45253
45254
45255
45256
45257
45258
45259
45260
45261
45262
45263
45264
45265
45266
45267
45268
45269
45270
45271
45272
45273
45274
45275
45276
45277
45278
45279
45280
45281
45282
45283
45284
45285
45286
45287
45288
45289
45290
45291
45292
45293
45294
45295
45296
45297
45298
45299
45300
45301
45302
45303
45304
45305
45306
45307
45308
45309
45310
45311
45312
45313
45314
45315
45316
45317
45318
45319
45320
45321
45322
45323
45324
45325
45326
45327
45328
45329
45330
45331
45332
45333
45334
45335
45336
45337
45338
45339
45340
45341
45342
45343
45344
45345
45346
45347
45348
45349
45350
45351
45352
45353
45354
45355
45356
45357
45358
45359
45360
45361
45362
45363
45364
45365
45366
45367
45368
45369
45370
45371
45372
45373
45374
45375
45376
45377
45378
45379
45380
45381
45382
45383
45384
45385
45386
45387
45388
45389
45390
45391
45392
45393
45394
45395
45396
45397
45398
45399
45400
45401
45402
45403
45404
45405
45406
45407
45408
45409
45410
45411
45412
45413
45414
45415
45416
45417
45418
45419
45420
45421
45422
45423
45424
45425
45426
45427
45428
45429
45430
45431
45432
45433
45434
45435
45436
45437
45438
45439
45440
45441
45442
45443
45444
45445
45446
45447
45448
45449
45450
45451
45452
45453
45454
45455
45456
45457
45458
45459
45460
45461
45462
45463
45464
45465
45466
45467
45468
45469
45470
45471
45472
45473
45474
45475
45476
45477
45478
45479
45480
45481
45482
45483
45484
45485
45486
45487
45488
45489
45490
45491
45492
45493
45494
45495
45496
45497
45498
45499
45500
45501
45502
45503
45504
45505
45506
45507
45508
45509
45510
45511
45512
45513
45514
45515
45516
45517
45518
45519
45520
45521
45522
45523
45524
45525
45526
45527
45528
45529
45530
45531
45532
45533
45534
45535
45536
45537
45538
45539
45540
45541
45542
45543
45544
45545
45546
45547
45548
45549
45550
45551
45552
45553
45554
45555
45556
45557
45558
45559
45560
45561
45562
45563
45564
45565
45566
45567
45568
45569
45570
45571
45572
45573
45574
45575
45576
45577
45578
45579
45580
45581
45582
45583
45584
45585
45586
45587
45588
45589
45590
45591
45592
45593
45594
45595
45596
45597
45598
45599
45600
45601
45602
45603
45604
45605
45606
45607
45608
45609
45610
45611
45612
45613
45614
45615
45616
45617
45618
45619
45620
45621
45622
45623
45624
45625
45626
45627
45628
45629
45630
45631
45632
45633
45634
45635
45636
45637
45638
45639
45640
45641
45642
45643
45644
45645
45646
45647
45648
45649
45650
45651
45652
45653
45654
45655
45656
45657
45658
45659
45660
45661
45662
45663
45664
45665
45666
45667
45668
45669
45670
45671
45672
45673
45674
45675
45676
45677
45678
45679
45680
45681
45682
45683
45684
45685
45686
45687
45688
45689
45690
45691
45692
45693
45694
45695
45696
45697
45698
45699
45700
45701
45702
45703
45704
45705
45706
45707
45708
45709
45710
45711
45712
45713
45714
45715
45716
45717
45718
45719
45720
45721
45722
45723
45724
45725
45726
45727
45728
45729
45730
45731
45732
45733
45734
45735
45736
45737
45738
45739
45740
45741
45742
45743
45744
45745
45746
45747
45748
45749
45750
45751
45752
45753
45754
45755
45756
45757
45758
45759
45760
45761
45762
45763
45764
45765
45766
45767
45768
45769
45770
45771
45772
45773
45774
45775
45776
45777
45778
45779
45780
45781
45782
45783
45784
45785
45786
45787
45788
45789
45790
45791
45792
45793
45794
45795
45796
45797
45798
45799
45800
45801
45802
45803
45804
45805
45806
45807
45808
45809
45810
45811
45812
45813
45814
45815
45816
45817
45818
45819
45820
45821
45822
45823
45824
45825
45826
45827
45828
45829
45830
45831
45832
45833
45834
45835
45836
45837
45838
45839
45840
45841
45842
45843
45844
45845
45846
45847
45848
45849
45850
45851
45852
45853
45854
45855
45856
45857
45858
45859
45860
45861
45862
45863
45864
45865
45866
45867
45868
45869
45870
45871
45872
45873
45874
45875
45876
45877
45878
45879
45880
45881
45882
45883
45884
45885
45886
45887
45888
45889
45890
45891
45892
45893
45894
45895
45896
45897
45898
45899
45900
45901
45902
45903
45904
45905
45906
45907
45908
45909
45910
45911
45912
45913
45914
45915
45916
45917
45918
45919
45920
45921
45922
45923
45924
45925
45926
45927
45928
45929
45930
45931
45932
45933
45934
45935
45936
45937
45938
45939
45940
45941
45942
45943
45944
45945
45946
45947
45948
45949
45950
45951
45952
45953
45954
45955
45956
45957
45958
45959
45960
45961
45962
45963
45964
45965
45966
45967
45968
45969
45970
45971
45972
45973
45974
45975
45976
45977
45978
45979
45980
45981
45982
45983
45984
45985
45986
45987
45988
45989
45990
45991
45992
45993
45994
45995
45996
45997
45998
45999
46000
46001
46002
46003
46004
46005
46006
46007
46008
46009
46010
46011
46012
46013
46014
46015
46016
46017
46018
46019
46020
46021
46022
46023
46024
46025
46026
46027
46028
46029
46030
46031
46032
46033
46034
46035
46036
46037
46038
46039
46040
46041
46042
46043
46044
46045
46046
46047
46048
46049
46050
46051
46052
46053
46054
46055
46056
46057
46058
46059
46060
46061
46062
46063
46064
46065
46066
46067
46068
46069
46070
46071
46072
46073
46074
46075
46076
46077
46078
46079
46080
46081
46082
46083
46084
46085
46086
46087
46088
46089
46090
46091
46092
46093
46094
46095
46096
46097
46098
46099
46100
46101
46102
46103
46104
46105
46106
46107
46108
46109
46110
46111
46112
46113
46114
46115
46116
46117
46118
46119
46120
46121
46122
46123
46124
46125
46126
46127
46128
46129
46130
46131
46132
46133
46134
46135
46136
46137
46138
46139
46140
46141
46142
46143
46144
46145
46146
46147
46148
46149
46150
46151
46152
46153
46154
46155
46156
46157
46158
46159
46160
46161
46162
46163
46164
46165
46166
46167
46168
46169
46170
46171
46172
46173
46174
46175
46176
46177
46178
46179
46180
46181
46182
46183
46184
46185
46186
46187
46188
46189
46190
46191
46192
46193
46194
46195
46196
46197
46198
46199
46200
46201
46202
46203
46204
46205
46206
46207
46208
46209
46210
46211
46212
46213
46214
46215
46216
46217
46218
46219
46220
46221
46222
46223
46224
46225
46226
46227
46228
46229
46230
46231
46232
46233
46234
46235
46236
46237
46238
46239
46240
46241
46242
46243
46244
46245
46246
46247
46248
46249
46250
46251
46252
46253
46254
46255
46256
46257
46258
46259
46260
46261
46262
46263
46264
46265
46266
46267
46268
46269
46270
46271
46272
46273
46274
46275
46276
46277
46278
46279
46280
46281
46282
46283
46284
46285
46286
46287
46288
46289
46290
46291
46292
46293
46294
46295
46296
46297
46298
46299
46300
46301
46302
46303
46304
46305
46306
46307
46308
46309
46310
46311
46312
46313
46314
46315
46316
46317
46318
46319
46320
46321
46322
46323
46324
46325
46326
46327
46328
46329
46330
46331
46332
46333
46334
46335
46336
46337
46338
46339
46340
46341
46342
46343
46344
46345
46346
46347
46348
46349
46350
46351
46352
46353
46354
46355
46356
46357
46358
46359
46360
46361
46362
46363
46364
46365
46366
46367
46368
46369
46370
46371
46372
46373
46374
46375
46376
46377
46378
46379
46380
46381
46382
46383
46384
46385
46386
46387
46388
46389
46390
46391
46392
46393
46394
46395
46396
46397
46398
46399
46400
46401
46402
46403
46404
46405
46406
46407
46408
46409
46410
46411
46412
46413
46414
46415
46416
46417
46418
46419
46420
46421
46422
46423
46424
46425
46426
46427
46428
46429
46430
46431
46432
46433
46434
46435
46436
46437
46438
46439
46440
46441
46442
46443
46444
46445
46446
46447
46448
46449
46450
46451
46452
46453
46454
46455
46456
46457
46458
46459
46460
46461
46462
46463
46464
46465
46466
46467
46468
46469
46470
46471
46472
46473
46474
46475
46476
46477
46478
46479
46480
46481
46482
46483
46484
46485
46486
46487
46488
46489
46490
46491
46492
46493
46494
46495
46496
46497
46498
46499
46500
46501
46502
46503
46504
46505
46506
46507
46508
46509
46510
46511
46512
46513
46514
46515
46516
46517
46518
46519
46520
46521
46522
46523
46524
46525
46526
46527
46528
46529
46530
46531
46532
46533
46534
46535
46536
46537
46538
46539
46540
46541
46542
46543
46544
46545
46546
46547
46548
46549
46550
46551
46552
46553
46554
46555
46556
46557
46558
46559
46560
46561
46562
46563
46564
46565
46566
46567
46568
46569
46570
46571
46572
46573
46574
46575
46576
46577
46578
46579
46580
46581
46582
46583
46584
46585
46586
46587
46588
46589
46590
46591
46592
46593
46594
46595
46596
46597
46598
46599
46600
46601
46602
46603
46604
46605
46606
46607
46608
46609
46610
46611
46612
46613
46614
46615
46616
46617
46618
46619
46620
46621
46622
46623
46624
46625
46626
46627
46628
46629
46630
46631
46632
46633
46634
46635
46636
46637
46638
46639
46640
46641
46642
46643
46644
46645
46646
46647
46648
46649
46650
46651
46652
46653
46654
46655
46656
46657
46658
46659
46660
46661
46662
46663
46664
46665
46666
46667
46668
46669
46670
46671
46672
46673
46674
46675
46676
46677
46678
46679
46680
46681
46682
46683
46684
46685
46686
46687
46688
46689
46690
46691
46692
46693
46694
46695
46696
46697
46698
46699
46700
46701
46702
46703
46704
46705
46706
46707
46708
46709
46710
46711
46712
46713
46714
46715
46716
46717
46718
46719
46720
46721
46722
46723
46724
46725
46726
46727
46728
46729
46730
46731
46732
46733
46734
46735
46736
46737
46738
46739
46740
46741
46742
46743
46744
46745
46746
46747
46748
46749
46750
46751
46752
46753
46754
46755
46756
46757
46758
46759
46760
46761
46762
46763
46764
46765
46766
46767
46768
46769
46770
46771
46772
46773
46774
46775
46776
46777
46778
46779
46780
46781
46782
46783
46784
46785
46786
46787
46788
46789
46790
46791
46792
46793
46794
46795
46796
46797
46798
46799
46800
46801
46802
46803
46804
46805
46806
46807
46808
46809
46810
46811
46812
46813
46814
46815
46816
46817
46818
46819
46820
46821
46822
46823
46824
46825
46826
46827
46828
46829
46830
46831
46832
46833
46834
46835
46836
46837
46838
46839
46840
46841
46842
46843
46844
46845
46846
46847
46848
46849
46850
46851
46852
46853
46854
46855
46856
46857
46858
46859
46860
46861
46862
46863
46864
46865
46866
46867
46868
46869
46870
46871
46872
46873
46874
46875
46876
46877
46878
46879
46880
46881
46882
46883
46884
46885
46886
46887
46888
46889
46890
46891
46892
46893
46894
46895
46896
46897
46898
46899
46900
46901
46902
46903
46904
46905
46906
46907
46908
46909
46910
46911
46912
46913
46914
46915
46916
46917
46918
46919
46920
46921
46922
46923
46924
46925
46926
46927
46928
46929
46930
46931
46932
46933
46934
46935
46936
46937
46938
46939
46940
46941
46942
46943
46944
46945
46946
46947
46948
46949
46950
46951
46952
46953
46954
46955
46956
46957
46958
46959
46960
46961
46962
46963
46964
46965
46966
46967
46968
46969
46970
46971
46972
46973
46974
46975
46976
46977
46978
46979
46980
46981
46982
46983
46984
46985
46986
46987
46988
46989
46990
46991
46992
46993
46994
46995
46996
46997
46998
46999
47000
47001
47002
47003
47004
47005
47006
47007
47008
47009
47010
47011
47012
47013
47014
47015
47016
47017
47018
47019
47020
47021
47022
47023
47024
47025
47026
47027
47028
47029
47030
47031
47032
47033
47034
47035
47036
47037
47038
47039
47040
47041
47042
47043
47044
47045
47046
47047
47048
47049
47050
47051
47052
47053
47054
47055
47056
47057
47058
47059
47060
47061
47062
47063
47064
47065
47066
47067
47068
47069
47070
47071
47072
47073
47074
47075
47076
47077
47078
47079
47080
47081
47082
47083
47084
47085
47086
47087
47088
47089
47090
47091
47092
47093
47094
47095
47096
47097
47098
47099
47100
47101
47102
47103
47104
47105
47106
47107
47108
47109
47110
47111
47112
47113
47114
47115
47116
47117
47118
47119
47120
47121
47122
47123
47124
47125
47126
47127
47128
47129
47130
47131
47132
47133
47134
47135
47136
47137
47138
47139
47140
47141
47142
47143
47144
47145
47146
47147
47148
47149
47150
47151
47152
47153
47154
47155
47156
47157
47158
47159
47160
47161
47162
47163
47164
47165
47166
47167
47168
47169
47170
47171
47172
47173
47174
47175
47176
47177
47178
47179
47180
47181
47182
47183
47184
47185
47186
47187
47188
47189
47190
47191
47192
47193
47194
47195
47196
47197
47198
47199
47200
47201
47202
47203
47204
47205
47206
47207
47208
47209
47210
47211
47212
47213
47214
47215
47216
47217
47218
47219
47220
47221
47222
47223
47224
47225
47226
47227
47228
47229
47230
47231
47232
47233
47234
47235
47236
47237
47238
47239
47240
47241
47242
47243
47244
47245
47246
47247
47248
47249
47250
47251
47252
47253
47254
47255
47256
47257
47258
47259
47260
47261
47262
47263
47264
47265
47266
47267
47268
47269
47270
47271
47272
47273
47274
47275
47276
47277
47278
47279
47280
47281
47282
47283
47284
47285
47286
47287
47288
47289
47290
47291
47292
47293
47294
47295
47296
47297
47298
47299
47300
47301
47302
47303
47304
47305
47306
47307
47308
47309
47310
47311
47312
47313
47314
47315
47316
47317
47318
47319
47320
47321
47322
47323
47324
47325
47326
47327
47328
47329
47330
47331
47332
47333
47334
47335
47336
47337
47338
47339
47340
47341
47342
47343
47344
47345
47346
47347
47348
47349
47350
47351
47352
47353
47354
47355
47356
47357
47358
47359
47360
47361
47362
47363
47364
47365
47366
47367
47368
47369
47370
47371
47372
47373
47374
47375
47376
47377
47378
47379
47380
47381
47382
47383
47384
47385
47386
47387
47388
47389
47390
47391
47392
47393
47394
47395
47396
47397
47398
47399
47400
47401
47402
47403
47404
47405
47406
47407
47408
47409
47410
47411
47412
47413
47414
47415
47416
47417
47418
47419
47420
47421
47422
47423
47424
47425
47426
47427
47428
47429
47430
47431
47432
47433
47434
47435
47436
47437
47438
47439
47440
47441
47442
47443
47444
47445
47446
47447
47448
47449
47450
47451
47452
47453
47454
47455
47456
47457
47458
47459
47460
47461
47462
47463
47464
47465
47466
47467
47468
47469
47470
47471
47472
47473
47474
47475
47476
47477
47478
47479
47480
47481
47482
47483
47484
47485
47486
47487
47488
47489
47490
47491
47492
47493
47494
47495
47496
47497
47498
47499
47500
47501
47502
47503
47504
47505
47506
47507
47508
47509
47510
47511
47512
47513
47514
47515
47516
47517
47518
47519
47520
47521
47522
47523
47524
47525
47526
47527
47528
47529
47530
47531
47532
47533
47534
47535
47536
47537
47538
47539
47540
47541
47542
47543
47544
47545
47546
47547
47548
47549
47550
47551
47552
47553
47554
47555
47556
47557
47558
47559
47560
47561
47562
47563
47564
47565
47566
47567
47568
47569
47570
47571
47572
47573
47574
47575
47576
47577
47578
47579
47580
47581
47582
47583
47584
47585
47586
47587
47588
47589
47590
47591
47592
47593
47594
47595
47596
47597
47598
47599
47600
47601
47602
47603
47604
47605
47606
47607
47608
47609
47610
47611
47612
47613
47614
47615
47616
47617
47618
47619
47620
47621
47622
47623
47624
47625
47626
47627
47628
47629
47630
47631
47632
47633
47634
47635
47636
47637
47638
47639
47640
47641
47642
47643
47644
47645
47646
47647
47648
47649
47650
47651
47652
47653
47654
47655
47656
47657
47658
47659
47660
47661
47662
47663
47664
47665
47666
47667
47668
47669
47670
47671
47672
47673
47674
47675
47676
47677
47678
47679
47680
47681
47682
47683
47684
47685
47686
47687
47688
47689
47690
47691
47692
47693
47694
47695
47696
47697
47698
47699
47700
47701
47702
47703
47704
47705
47706
47707
47708
47709
47710
47711
47712
47713
47714
47715
47716
47717
47718
47719
47720
47721
47722
47723
47724
47725
47726
47727
47728
47729
47730
47731
47732
47733
47734
47735
47736
47737
47738
47739
47740
47741
47742
47743
47744
47745
47746
47747
47748
47749
47750
47751
47752
47753
47754
47755
47756
47757
47758
47759
47760
47761
47762
47763
47764
47765
47766
47767
47768
47769
47770
47771
47772
47773
47774
47775
47776
47777
47778
47779
47780
47781
47782
47783
47784
47785
47786
47787
47788
47789
47790
47791
47792
47793
47794
47795
47796
47797
47798
47799
47800
47801
47802
47803
47804
47805
47806
47807
47808
47809
47810
47811
47812
47813
47814
47815
47816
47817
47818
47819
47820
47821
47822
47823
47824
47825
47826
47827
47828
47829
47830
47831
47832
47833
47834
47835
47836
47837
47838
47839
47840
47841
47842
47843
47844
47845
47846
47847
47848
47849
47850
47851
47852
47853
47854
47855
47856
47857
47858
47859
47860
47861
47862
47863
47864
47865
47866
47867
47868
47869
47870
47871
47872
47873
47874
47875
47876
47877
47878
47879
47880
47881
47882
47883
47884
47885
47886
47887
47888
47889
47890
47891
47892
47893
47894
47895
47896
47897
47898
47899
47900
47901
47902
47903
47904
47905
47906
47907
47908
47909
47910
47911
47912
47913
47914
47915
47916
47917
47918
47919
47920
47921
47922
47923
47924
47925
47926
47927
47928
47929
47930
47931
47932
47933
47934
47935
47936
47937
47938
47939
47940
47941
47942
47943
47944
47945
47946
47947
47948
47949
47950
47951
47952
47953
47954
47955
47956
47957
47958
47959
47960
47961
47962
47963
47964
47965
47966
47967
47968
47969
47970
47971
47972
47973
47974
47975
47976
47977
47978
47979
47980
47981
47982
47983
47984
47985
47986
47987
47988
47989
47990
47991
47992
47993
47994
47995
47996
47997
47998
47999
48000
48001
48002
48003
48004
48005
48006
48007
48008
48009
48010
48011
48012
48013
48014
48015
48016
48017
48018
48019
48020
48021
48022
48023
48024
48025
48026
48027
48028
48029
48030
48031
48032
48033
48034
48035
48036
48037
48038
48039
48040
48041
48042
48043
48044
48045
48046
48047
48048
48049
48050
48051
48052
48053
48054
48055
48056
48057
48058
48059
48060
48061
48062
48063
48064
48065
48066
48067
48068
48069
48070
48071
48072
48073
48074
48075
48076
48077
48078
48079
48080
48081
48082
48083
48084
48085
48086
48087
48088
48089
48090
48091
48092
48093
48094
48095
48096
48097
48098
48099
48100
48101
48102
48103
48104
48105
48106
48107
48108
48109
48110
48111
48112
48113
48114
48115
48116
48117
48118
48119
48120
48121
48122
48123
48124
48125
48126
48127
48128
48129
48130
48131
48132
48133
48134
48135
48136
48137
48138
48139
48140
48141
48142
48143
48144
48145
48146
48147
48148
48149
48150
48151
48152
48153
48154
48155
48156
48157
48158
48159
48160
48161
48162
48163
48164
48165
48166
48167
48168
48169
48170
48171
48172
48173
48174
48175
48176
48177
48178
48179
48180
48181
48182
48183
48184
48185
48186
48187
48188
48189
48190
48191
48192
48193
48194
48195
48196
48197
48198
48199
48200
48201
48202
48203
48204
48205
48206
48207
48208
48209
48210
48211
48212
48213
48214
48215
48216
48217
48218
48219
48220
48221
48222
48223
48224
48225
48226
48227
48228
48229
48230
48231
48232
48233
48234
48235
48236
48237
48238
48239
48240
48241
48242
48243
48244
48245
48246
48247
48248
48249
48250
48251
48252
48253
48254
48255
48256
48257
48258
48259
48260
48261
48262
48263
48264
48265
48266
48267
48268
48269
48270
48271
48272
48273
48274
48275
48276
48277
48278
48279
48280
48281
48282
48283
48284
48285
48286
48287
48288
48289
48290
48291
48292
48293
48294
48295
48296
48297
48298
48299
48300
48301
48302
48303
48304
48305
48306
48307
48308
48309
48310
48311
48312
48313
48314
48315
48316
48317
48318
48319
48320
48321
48322
48323
48324
48325
48326
48327
48328
48329
48330
48331
48332
48333
48334
48335
48336
48337
48338
48339
48340
48341
48342
48343
48344
48345
48346
48347
48348
48349
48350
48351
48352
48353
48354
48355
48356
48357
48358
48359
48360
48361
48362
48363
48364
48365
48366
48367
48368
48369
48370
48371
48372
48373
48374
48375
48376
48377
48378
48379
48380
48381
48382
48383
48384
48385
48386
48387
48388
48389
48390
48391
48392
48393
48394
48395
48396
48397
48398
48399
48400
48401
48402
48403
48404
48405
48406
48407
48408
48409
48410
48411
48412
48413
48414
48415
48416
48417
48418
48419
48420
48421
48422
48423
48424
48425
48426
48427
48428
48429
48430
48431
48432
48433
48434
48435
48436
48437
48438
48439
48440
48441
48442
48443
48444
48445
48446
48447
48448
48449
48450
48451
48452
48453
48454
48455
48456
48457
48458
48459
48460
48461
48462
48463
48464
48465
48466
48467
48468
48469
48470
48471
48472
48473
48474
48475
48476
48477
48478
48479
48480
48481
48482
48483
48484
48485
48486
48487
48488
48489
48490
48491
48492
48493
48494
48495
48496
48497
48498
48499
48500
48501
48502
48503
48504
48505
48506
48507
48508
48509
48510
48511
48512
48513
48514
48515
48516
48517
48518
48519
48520
48521
48522
48523
48524
48525
48526
48527
48528
48529
48530
48531
48532
48533
48534
48535
48536
48537
48538
48539
48540
48541
48542
48543
48544
48545
48546
48547
48548
48549
48550
48551
48552
48553
48554
48555
48556
48557
48558
48559
48560
48561
48562
48563
48564
48565
48566
48567
48568
48569
48570
48571
48572
48573
48574
48575
48576
48577
48578
48579
48580
48581
48582
48583
48584
48585
48586
48587
48588
48589
48590
48591
48592
48593
48594
48595
48596
48597
48598
48599
48600
48601
48602
48603
48604
48605
48606
48607
48608
48609
48610
48611
48612
48613
48614
48615
48616
48617
48618
48619
48620
48621
48622
48623
48624
48625
48626
48627
48628
48629
48630
48631
48632
48633
48634
48635
48636
48637
48638
48639
48640
48641
48642
48643
48644
48645
48646
48647
48648
48649
48650
48651
48652
48653
48654
48655
48656
48657
48658
48659
48660
48661
48662
48663
48664
48665
48666
48667
48668
48669
48670
48671
48672
48673
48674
48675
48676
48677
48678
48679
48680
48681
48682
48683
48684
48685
48686
48687
48688
48689
48690
48691
48692
48693
48694
48695
48696
48697
48698
48699
48700
48701
48702
48703
48704
48705
48706
48707
48708
48709
48710
48711
48712
48713
48714
48715
48716
48717
48718
48719
48720
48721
48722
48723
48724
48725
48726
48727
48728
48729
48730
48731
48732
48733
48734
48735
48736
48737
48738
48739
48740
48741
48742
48743
48744
48745
48746
48747
48748
48749
48750
48751
48752
48753
48754
48755
48756
48757
48758
48759
48760
48761
48762
48763
48764
48765
48766
48767
48768
48769
48770
48771
48772
48773
48774
48775
48776
48777
48778
48779
48780
48781
48782
48783
48784
48785
48786
48787
48788
48789
48790
48791
48792
48793
48794
48795
48796
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2025 Oxide Computer Company
#

# rpcgen-generated headers now committed as permanent source (2026-04-09)
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
# Copyright 2013 Garrett D'Amore <garrett@damore.org>
# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
# Copyright 2017 Nexenta Systems, Inc.
#

# include global definitions
include ../Makefile.master

sparc_HDRS=
i386_HDRS=	stack_unwind.h

KRB5HDRS=		\
	mit_copyright.h	\
	mit-sipb-copyright.h

ATTRDB_HDRS=		\
	auth_attr.h	\
	auth_list.h	\
	exec_attr.h	\
	prof_attr.h	\
	secdb.h		\
	user_attr.h

HDRS=   $($(MACH)_HDRS)	\
	$(ATTRDB_HDRS)	\
	aio.h		\
	alloca.h	\
	apptrace.h	\
	apptrace_impl.h	\
	ar.h		\
	archives.h	\
	assert.h	\
	atomic.h	\
	attr.h		\
	complex.h	\
	config_admin.h	\
	cpio.h		\
	crypt.h		\
	ctype.h		\
	deflt.h		\
	devid.h		\
	devmgmt.h	\
	devpoll.h	\
	dial.h		\
	dirent.h	\
	dlfcn.h		\
	door.h		\
	elf.h		\
	endian.h	\
	err.h		\
	errno.h		\
	euc.h		\
	exacct.h	\
	exacct_impl.h	\
	execinfo.h	\
	fatal.h		\
	fcntl.h		\
	fenv.h		\
	float.h		\
	floatingpoint.h	\
	fmtmsg.h	\
	fnmatch.h	\
	fts.h		\
	ftw.h		\
	gelf.h		\
	getopt.h	\
	getwidth.h	\
	glob.h		\
	grp.h		\
	iconv.h		\
	ieeefp.h	\
	ifaddrs.h	\
	inttypes.h	\
	iso646.h	\
	klpd.h		\
	langinfo.h	\
	lastlog.h	\
	lber.h		\
	ldap.h		\
	libelf.h	\
	libgen.h	\
	libintl.h	\
	libw.h		\
	libzonecfg.h	\
	limits.h	\
	link.h		\
	listen.h	\
	locale.h	\
	macros.h	\
	malloc.h	\
	math.h		\
	memory.h	\
	mon.h		\
	monetary.h	\
	mp.h		\
	mqueue.h	\
	nan.h		\
	ndbm.h		\
	ndpd.h		\
	netconfig.h	\
	netdb.h		\
	netdir.h	\
	nl_types.h	\
	nlist.h		\
	note.h		\
	nsswitch.h	\
	nss_common.h	\
	nss_dbdefs.h	\
	nss_netdir.h	\
	paths.h		\
	pfmt.h		\
	pkgdev.h	\
	pkginfo.h	\
	pkglocs.h	\
	pkgstrct.h	\
	pkgtrans.h	\
	poll.h		\
	port.h		\
	priv.h		\
	priv_utils.h	\
	proc_service.h	\
	procfs.h	\
	project.h	\
	pthread.h	\
	pw.h		\
	pwd.h		\
	rctl.h		\
	re_comp.h	\
	regex.h		\
	regexp.h	\
	resolv.h	\
	rtld_db.h	\
	sac.h		\
	sched.h		\
	schedctl.h	\
	search.h	\
	semaphore.h	\
	setjmp.h	\
	sgtty.h		\
	shadow.h	\
	siginfo.h	\
	signal.h	\
	spawn.h		\
	stdalign.h	\
	stdarg.h	\
	stdbit.h	\
	stdbool.h	\
	stddef.h	\
	stdint.h	\
	stdio.h		\
	stdio_ext.h	\
	stdio_tag.h	\
	stdio_impl.h	\
	stdlib.h	\
	stdnoreturn.h	\
	string.h	\
	strings.h	\
	stropts.h	\
	synch.h		\
	sysexits.h	\
	syslog.h	\
	tar.h		\
	termio.h	\
	termios.h	\
	tgmath.h	\
	thread.h	\
	thread_db.h	\
	threads.h	\
	time.h		\
	tiuser.h	\
	tzfile.h	\
	uchar.h		\
	ucontext.h	\
	ucred.h		\
	ulimit.h	\
	unistd.h	\
	upanic.h	\
	userdefs.h	\
	ustat.h		\
	utime.h		\
	utmp.h		\
	utmpx.h		\
	valtools.h	\
	values.h	\
	varargs.h	\
	wait.h		\
	wchar.h		\
	wchar_impl.h	\
	wctype.h	\
	widec.h		\
	wordexp.h	\
	xlocale.h	\
	xti.h		\
	xti_inet.h	\
	zone.h

ISOHDRS = \
	assert_iso.h	\
	ctype_iso.h	\
	limits_iso.h	\
	locale_iso.h	\
	math_c99.h	\
	math_iso.h	\
	setjmp_iso.h	\
	signal_iso.h	\
	stdarg_c99.h	\
	stdarg_iso.h	\
	stddef_iso.h	\
	stdio_c99.h	\
	stdio_iso.h	\
	stdlib_c99.h	\
	stdlib_c11.h	\
	stdlib_iso.h	\
	string_iso.h	\
	time_iso.h	\
	wchar_c99.h	\
	wchar_iso.h	\
	wctype_iso.h

ARPAHDRS =		\
	inet.h		\
	nameser.h	\
	telnet.h	\
	tftp.h		\
	nameser_compat.h

AUDIOHDRS =		\
	au.h

UUIDHDRS =		\
	uuid.h

# rpcsvc headers which are just headers (not derived from a .x file)
RPCSVC_SRC_HDRS =	\
	bootparam.h	\
	daemon_utils.h	\
	dbm.h		\
	nis_db.h	\
	nislib.h	\
	svc_dg_priv.h	\
	yp_prot.h	\
	ypclnt.h	\
	yppasswd.h	\
	nis.h		\
	ypupd.h		\
	rpc_sztypes.h

# rpcsvc headers which are generated from .x files
RPCSVC_GEN_HDRS = \
	bootparam_prot.h \
	mount.h		\
	nfs_prot.h	\
	nfs4_prot.h	\
	rquota.h	\
	rstat.h		\
	rusers.h	\
	rwall.h		\
	spray.h		\
	nfs_acl.h

SYMHDRERRNO = $(ROOT)/usr/include/iso/errno_iso.h
SYMHDRFLOAT = $(ROOT)/usr/include/iso/float_iso.h
SYMHDRISO646 = $(ROOT)/usr/include/iso/iso646_iso.h

# Hammerhead: pre-generated (rpcgen + GNU cpp truncation bug)
# RPCGENFLAGS = -C -h
# rpcsvc/rwall.h :	RPCGENFLAGS += -M

# rpcsvc rpcgen source (.x files)
#
# yp.x is an attempt at codifying what was hand coded in RPCL.
# Unfortunately it doesn't quite work. (The handcoded stuff isn't
# expressable in RPCL) this is due to the fact that YP was written
# before rpcgen existed.  Hence, yp_prot.h cannot be derived from yp.x
#
# There is no `.h' for nis_object.x because it is included by nis.x and
# the resulting .h is nis.h.

RPCSVCPROTS = \
$(RPCSVC_GEN_HDRS:%.h=%.x)        nis_object.x       yp.x

RPCSVCHDRS= $(RPCSVC_SRC_HDRS) $(RPCSVC_GEN_HDRS)

# Hammerhead: Explicit paths for generated headers to ensure they're built
# before installation (GNU Make implicit rule chaining doesn't always work)
RPCSVC_GEN_HDR_PATHS = $(RPCSVC_GEN_HDRS:%=rpcsvc/%)

# Hammerhead: removed rwhod.h (in.rwhod gone), timed.h (timed gone).
# routed.h kept for snoop_rip.c; ripngd.h kept for snoop_rip6.c + in.ripngd.
PROTOHDRS=   dumprestore.h routed.h ripngd.h

ROOTHDRS= $(HDRS:%=$(ROOT)/usr/include/%)  \
	$(KRB5HDRS:%=$(ROOT)/usr/include/kerberosv5/%)  \
	$(ISOHDRS:%=$(ROOT)/usr/include/iso/%)  \
	$(ARPAHDRS:%=$(ROOT)/usr/include/arpa/%)  \
	$(AUDIOHDRS:%=$(ROOT)/usr/include/audio/%)  \
	$(UUIDHDRS:%=$(ROOT)/usr/include/uuid/%)  \
	$(RPCSVCHDRS:%=$(ROOT)/usr/include/rpcsvc/%)  \
	$(RPCSVCPROTS:%=$(ROOT)/usr/include/rpcsvc/%)  \
	$(PROTOHDRS:%=$(ROOT)/usr/include/protocols/%)

DIRS= iso arpa audio rpcsvc protocols security uuid kerberosv5
ROOTDIRS= $(DIRS:%=$(ROOT)/usr/include/%)

# check files really don't exist
#
# should do something with the rpcsvc headers

iso/%.check:		iso/%.h
	$(DOT_H_CHECK)

arpa/%.check:		arpa/%.h
	$(DOT_H_CHECK)

audio/%.check:		audio/%.h
	$(DOT_H_CHECK)

rpcsvc/%.check:		rpcsvc/%.h
	$(DOT_H_CHECK)

rpcsvc/%.check:		rpcsvc/%.x
	$(DOT_X_CHECK)

protocols/%.check:	protocols/%.h
	$(DOT_H_CHECK)

kerberosv5/%.check:             kerberosv5/%.h
	$(DOT_H_CHECK)

uuid/%.check:		uuid/%.h
	$(DOT_H_CHECK)

# Note that the derived headers (rpcgen) are not checked at this time.  These
# need work at the source level and rpcgen itself has a bug which causes a
# cstyle violation.  Furthermore, there seems to be good reasons for the
# generated headers to not pass all of the hdrchk rules.
#
# Add the following to the CHECKHDRS list to activate the .x checks:
#	$(RPCSVCPROTS:%.x=rpcsvc/%.check) \
#
CHECKHDRS= $(HDRS:%.h=%.check)  \
	$(KRB5HDRS:%.h=kerberosv5/%.check)  \
	$(ISOHDRS:%.h=iso/%.check)  \
	$(ARPAHDRS:%.h=arpa/%.check)  \
	$(AUDIOHDRS:%.h=audio/%.check)  \
	$(UUIDHDRS:%.h=uuid/%.check)  \
	$(RPCSVC_SRC_HDRS:%.h=rpcsvc/%.check) \
	$(PROTOHDRS:%.h=protocols/%.check)

# headers which won't quite meet the standards...
#
# assert.h is required by ansi-c to *not* be idempotent (section 4.1.2).
# Hence the trailing guard is not the last thing in the file nor can it
# be without playing silly games.

assert.check	: HDRCHK_TAIL = 2>&1 | grep -v "header guard" | true

# install rules

$(ROOT)/usr/include/security/%: security/%
	$(INS.file)

$(ROOT)/usr/include/protocols/%: protocols/%
	$(INS.file)

$(ROOT)/usr/include/rpcsvc/%: rpcsvc/%
	$(INS.file)

$(ROOT)/usr/include/kerberosv5/%: kerberosv5/%
	$(INS.file)

$(ROOT)/usr/include/arpa/%: arpa/%
	$(INS.file)

$(ROOT)/usr/include/audio/%: audio/%
	$(INS.file)

$(ROOT)/usr/include/iso/%: iso/%
	$(INS.file)

$(ROOT)/usr/include/uuid/%: uuid/%
	$(INS.file)

$(ROOT)/usr/include/%: %
	$(INS.file)

.KEEP_STATE:

.PARALLEL:	$(ROOTHDRS) $(CHECKHDRS)

# Hammerhead: Explicitly build generated rpcsvc headers before installing
# This ensures they exist before the implicit install rules need them
rpcsvc_gen_hdrs: $(RPCSVC_GEN_HDR_PATHS)

install_h:	$(ROOTDIRS) .WAIT rpcsvc_gen_hdrs .WAIT $(ROOTHDRS) $(SYMHDRERRNO) \
		$(SYMHDRFLOAT) $(SYMHDRISO646)

check:	$(CHECKHDRS)

clean clobber:
	@# Hammerhead: rpcsvc headers are pre-generated source, do not delete

$(ROOTDIRS):
	$(INS.dir)

$(SYMHDRERRNO):
	-$(RM) $@; $(SYMLINK) ../errno.h $@

$(SYMHDRFLOAT):
	-$(RM) $@; $(SYMLINK) ../float.h $@

$(SYMHDRISO646):
	-$(RM) $@; $(SYMLINK) ../iso646.h $@

# Hammerhead: pre-generated (rpcgen + GNU cpp truncation bug)
# rpcsvc/%.h:	rpcsvc/%.x
#	$(RPCGEN) $(RPCGENFLAGS) $< | $(SED) -e 's/^#ifdef 1$$/#if 1/' -e 's/defined(1)/1/g' > $@
#
# rpcsvc/nis.h:	rpcsvc/nis.x
#	@echo "Using pre-generated rpcsvc/nis.h"
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _AIO_H
#define	_AIO_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/siginfo.h>
#include <sys/aiocb.h>
#include <time.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if	(_POSIX_C_SOURCE - 0 > 0) && (_POSIX_C_SOURCE - 0 <= 2)
#error	"POSIX Asynchronous I/O is not supported in POSIX.1-1990"
#endif

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	aio_read	aio_read64
#pragma	redefine_extname	aio_write	aio_write64
#pragma	redefine_extname	lio_listio	lio_listio64
#pragma	redefine_extname	aio_error	aio_error64
#pragma	redefine_extname	aio_return	aio_return64
#pragma	redefine_extname	aio_cancel	aio_cancel64
#pragma	redefine_extname	aio_suspend	aio_suspend64
#pragma	redefine_extname	aio_fsync	aio_fsync64
#pragma	redefine_extname	aio_waitn	aio_waitn64
#else
#define	aiocb		aiocb64
#define	aiocb_t		aiocb64_t
#define	aio_read	aio_read64
#define	aio_write	aio_write64
#define	lio_listio	lio_listio64
#define	aio_error	aio_error64
#define	aio_return	aio_return64
#define	aio_cancel	aio_cancel64
#define	aio_suspend	aio_suspend64
#define	aio_fsync	aio_fsync64
#define	aio_waitn	aio_waitn64
#endif
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */

#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
/*
 * In the LP64 compilation environment, map the 64-bit-explicit versions
 * back to the generic versions: all i/o operations are already "large file"
 */
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	aio_read64	aio_read
#pragma	redefine_extname	aio_write64	aio_write
#pragma	redefine_extname	lio_listio64	lio_listio
#pragma	redefine_extname	aio_error64	aio_error
#pragma	redefine_extname	aio_return64	aio_return
#pragma	redefine_extname	aio_cancel64	aio_cancel
#pragma	redefine_extname	aio_suspend64	aio_suspend
#pragma	redefine_extname	aio_fsync64	aio_fsync
#pragma	redefine_extname	aio_waitn64	aio_waitn
#else
#define	aiocb64		aiocb
#define	aiocb64_t	aiocb_t
#define	aio_read64	aio_read
#define	aio_write64	aio_write
#define	lio_listio64	lio_listio
#define	aio_error64	aio_error
#define	aio_return64	aio_return
#define	aio_cancel64	aio_cancel
#define	aio_suspend64	aio_suspend
#define	aio_fsync64	aio_fsync
#define	aio_waitn64	aio_waitn
#endif
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

/*
 * function prototypes
 */
extern int	aio_read(aiocb_t *);
extern int	aio_write(aiocb_t *);
extern int	lio_listio(int,
		    aiocb_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
		    int, struct sigevent *_RESTRICT_KYWD);
extern int	aio_error(const aiocb_t *);
extern ssize_t	aio_return(aiocb_t *);
extern int	aio_cancel(int, aiocb_t *);
extern int	aio_suspend(const aiocb_t *const[], int,
		    const struct timespec *);
extern int	aio_fsync(int, aiocb_t *);
extern int	aio_waitn(aiocb_t *[], uint_t, uint_t *,
		    const struct timespec *);


#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	!defined(__PRAGMA_REDEFINE_EXTNAME))
extern int	aio_read64(aiocb64_t *);
extern int	aio_write64(aiocb64_t *);
extern int	lio_listio64(int,
			aiocb64_t *_RESTRICT_KYWD const *_RESTRICT_KYWD,
			int, struct sigevent *_RESTRICT_KYWD);
extern int	aio_error64(const aiocb64_t *);
extern ssize_t	aio_return64(aiocb64_t *);
extern int	aio_cancel64(int, aiocb64_t *);
extern int	aio_suspend64(const aiocb64_t *const[], int,
			const struct timespec *);
extern int	aio_fsync64(int, aiocb64_t *);
extern int	aio_waitn64(aiocb64_t *[], uint_t, uint_t *,
		    const struct timespec *);
#endif	/* _LARGEFILE64_SOURCE */

#ifdef	__cplusplus
}
#endif

#endif	/* _AIO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_ALLOCA_H
#define	_ALLOCA_H

#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Many compilation systems depend upon the use of special functions
 * built into the the compilation system to handle variable argument
 * lists and stack allocations.  The method to obtain this in SunOS
 * is to define the feature test macro "__BUILTIN_VA_ARG_INCR" which
 * enables the following special built-in functions:
 *	__builtin_alloca
 *	__builtin_va_alist
 *	__builtin_va_arg_incr
 * It is intended that the compilation system define this feature test
 * macro, not the user of the system.
 *
 * The tests on the processor type are to provide a transitional period
 * for existing compilation systems, and may be removed in a future
 * release.
 */

#if defined(__BUILTIN_VA_ARG_INCR) || \
	defined(__sparc) || defined(__i386) || defined(__amd64)
#define	alloca(x)	__builtin_alloca(x)

extern void *__builtin_alloca(size_t);

#else

extern void *alloca(size_t);

#endif	/* defined(__BUILTIN_VA_ARG_INCR) || defined(__sparc) ... */

#ifdef __cplusplus
}
#endif

#endif	/* _ALLOCA_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998-2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_APPTRACE_H
#define	_APPTRACE_H

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <dlfcn.h>
#include <link.h>
#include <signal.h>
#include <synch.h>
#include <wchar.h>
#include <thread.h>
#include <apptrace_impl.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Extract the verbosity flag.
 */
#define	ABI_VFLAG(lib, symbol) \
	__abi_ ## lib ## _ ## symbol ## _sym.a_vflag

/*
 * Extract the function pointer to the real ABI function.
 */
#define	ABI_REAL(lib, symbol) \
	__abi_ ## lib ## _ ## symbol ## _sym.a_real

/*
 * Macro to create the part of a function call prior
 * to the arg list.
 *   cast is a full cast expression for a _pointer_ to
 *   the ABI function being called.
 *
 * e.g.  ABI_CALL_REAL(libc, getpid, (pid_t (*)(void)))  ();
 */
#define	ABI_CALL_REAL(lib, sym, cast) \
	(cast __abi_ ## lib ## _ ## sym ## _sym.a_real)

#define	ABISTREAM	__abi_outfile
#define	ABIPUTS(x)	(void) fputs((x), ABISTREAM)

/*
 * The following declarations and macros are needed for
 * anybody needing the vprintf family of calls where they
 * MUST come from the BASE link map instead of the auditing
 * link map.
 */
#define	ABI_VSNPRINTF	__abi_real_vsnprintf
#define	ABI_VSWPRINTF	__abi_real_vswprintf
#define	ABI_VWPRINTF	__abi_real_vwprintf
#define	ABI_VFPRINTF	__abi_real_vfprintf
#define	ABI_VFWPRINTF	__abi_real_vfwprintf
#define	ABI_VPRINTF	__abi_real_vprintf
#define	ABI_VSPRINTF	__abi_real_vsprintf
#define	ABI_ERRNO	(*(__abi_real_errno()))

/* From libstabspf */
typedef enum {
	STAB_SUCCESS	= 0,	/* All is well. */
	STAB_FAIL	= -1,	/* Parsing error. */
	STAB_NA		= -2,	/* Information is Not Applicable. */
	STAB_NOMEM	= -3	/* Out of Memory! */
} stabsret_t;

extern int (*ABI_VFPRINTF)(FILE *, const char *, va_list);
extern int (*ABI_VFWPRINTF)(FILE *, const wchar_t *, va_list);
extern int (*ABI_VPRINTF)(const char *, va_list);
extern int (*ABI_VSNPRINTF)(char *, size_t, const char *, va_list);
extern int (*ABI_VSPRINTF)(char *, const char *, va_list);
extern int (*ABI_VSWPRINTF)(wchar_t *, size_t, const wchar_t *, va_list);
extern int (*ABI_VWPRINTF)(const wchar_t *, va_list);
extern int *(*__abi_real_errno)(void);

extern void *abi_malloc(size_t);
extern void *abi_calloc(size_t, size_t);
extern void *abi_realloc(void *, size_t);
extern int  abi_putc(int, FILE *);
extern int  abi_fputs(const char *, FILE *);
extern void abi_free(void *);

/* From libstabspf */
extern stabsret_t spf_load_stabs(const char *);
extern int spf_prtype(FILE *, char const *, int, void const *);

extern int abi_strpsz;	/* size constraint for string printing */

#ifdef	__cplusplus
}
#endif

#endif	/* _APPTRACE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_APPTRACE_IMPL_H
#define	_APPTRACE_IMPL_H

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct abisym {
	void	*a_real;
	int	a_vflag;
	int	a_tflag;
} abisym_t;

/*
 * From the apptrace auditing object
 */
extern FILE *__abi_outfile;
extern struct liblist *__abi_pflib_list;

extern sigset_t abisigset;

extern void abilock(sigset_t *);
extern void abiunlock(sigset_t *);

extern int	is_empty_string(char const *);

extern int (*abi_thr_main)(void);
extern thread_t (*abi_thr_self)(void);
extern int (*abi_sigsetmask)(int, const sigset_t *, sigset_t *);
extern int (*abi_sigaction)(int, const struct sigaction *, struct sigaction *);
extern int (*abi_mutex_lock)(mutex_t *);
extern int (*abi_mutex_unlock)(mutex_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _APPTRACE_IMPL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _AR_H
#define	_AR_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *		COMMON ARCHIVE FORMAT
 *
 *	ARCHIVE File Organization:
 *	_________________________________________________
 *	|__________ARCHIVE_MAGIC_STRING_________________|
 *	|__________ARCHIVE_FILE_MEMBER_1________________|
 *	|						|
 *	|	Archive File Header "ar_hdr"		|
 *	|...............................................|
 *	|	Member Contents				|
 *	|		1. External symbol directory	|
 *	|		2. Text file			|
 *	|_______________________________________________|
 *	|________ARCHIVE_FILE_MEMBER_2__________________|
 *	|		"ar_hdr"			|
 *	|...............................................|
 *	|	Member Contents (.o or text file)	|
 *	|_______________________________________________|
 *	|	.		.		.	|
 *	|	.		.		.	|
 *	|	.		.		.	|
 *	|_______________________________________________|
 *	|________ARCHIVE_FILE_MEMBER_n__________________|
 *	|		"ar_hdr"			|
 *	|...............................................|
 *	|		Member Contents			|
 *	|_______________________________________________|
 *
 */

#define	ARMAG	"!<arch>\n"
#define	SARMAG	8
#define	ARFMAG	"`\n"

struct ar_hdr		/* archive file member header - printable ascii */
{
	char	ar_name[16];	/* file member name - `/' terminated */
	char	ar_date[12];	/* file member date - decimal */
	char	ar_uid[6];	/* file member user id - decimal */
	char	ar_gid[6];	/* file member group id - decimal */
	char	ar_mode[8];	/* file member mode - octal */
	char	ar_size[10];	/* file member size - decimal */
	char	ar_fmag[2];	/* ARFMAG - string to end header */
};

#ifdef	__cplusplus
}
#endif

#endif	/* _AR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1988,1997-1998,2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_ARCHIVES_H
#define	_ARCHIVES_H

#include <tar.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Magic numbers */

#define	CMN_ASC	0x070701	/* Cpio Magic Number for ASCii header */
#define	CMN_BIN	070707		/* Cpio Magic Number for Binary header */
#define	CMN_BBS	0143561		/* Cpio Magic Number for Byte-Swap header */
#define	CMN_CRC	0x070702	/* Cpio Magic Number for CRC header */
#define	CMS_ASC	"070701"	/* Cpio Magic String for ASCii header */
#define	CMS_CHR	"070707"	/* Cpio Magic String for CHR (-c) header */
#define	CMS_CRC	"070702"	/* Cpio Magic String for CRC header */
#define	CMS_LEN	6		/* Cpio Magic String LENgth */

/* Various header and field lengths */

#define	CHRSZ	76		/* -c hdr size minus filename field */
#define	ASCSZ	110		/* ASC and CRC hdr size minus filename field */
#define	TARSZ	512		/* TAR hdr size */

#define	HNAMLEN	256	/* maximum filename length for binary and -c headers */
#define	EXPNLEN	1024	/* maximum filename length for ASC and CRC headers */
#define	HTIMLEN	2	/* length of modification time field */
#define	HSIZLEN	2	/* length of file size field */

/* cpio binary header definition */

struct hdr_cpio {
	short	h_magic,		/* magic number field */
		h_dev;			/* file system of file */
	ushort_t h_ino,			/* inode of file */
		h_mode,			/* modes of file */
		h_uid,			/* uid of file */
		h_gid;			/* gid of file */
	short	h_nlink,		/* number of links to file */
		h_rdev,			/* maj/min numbers for special files */
		h_mtime[HTIMLEN],	/* modification time of file */
		h_namesize,		/* length of filename */
		h_filesize[HSIZLEN];	/* size of file */
	char	h_name[HNAMLEN];	/* filename */
};

/* cpio ODC header format */

struct c_hdr {
	char	c_magic[CMS_LEN],
		c_dev[6],
		c_ino[6],
		c_mode[6],
		c_uid[6],
		c_gid[6],
		c_nlink[6],
		c_rdev[6],
		c_mtime[11],
		c_namesz[6],
		c_filesz[11],
		c_name[HNAMLEN];
};

/* -c and CRC header format */

struct Exp_cpio_hdr {
	char	E_magic[CMS_LEN],
		E_ino[8],
		E_mode[8],
		E_uid[8],
		E_gid[8],
		E_nlink[8],
		E_mtime[8],
		E_filesize[8],
		E_maj[8],
		E_min[8],
		E_rmaj[8],
		E_rmin[8],
		E_namesize[8],
		E_chksum[8],
		E_name[EXPNLEN];
};

/* Tar header structure and format */

#define	TBLOCK	512	/* length of tar header and data blocks */
#define	TNAMLEN	100	/* maximum length for tar file names */
#define	TMODLEN	8	/* length of mode field */
#define	TUIDLEN	8	/* length of uid field */
#define	TGIDLEN	8	/* length of gid field */
#define	TSIZLEN	12	/* length of size field */
#define	TTIMLEN	12	/* length of modification time field */
#define	TCRCLEN	8	/* length of header checksum field */

/* tar header definition */

union tblock {
	char dummy[TBLOCK];
	struct tar_hdr {
		char	t_name[TNAMLEN],	/* name of file */
			t_mode[TMODLEN],	/* mode of file */
			t_uid[TUIDLEN],		/* uid of file */
			t_gid[TGIDLEN],		/* gid of file */
			t_size[TSIZLEN],	/* size of file in bytes */
			t_mtime[TTIMLEN],	/* modification time of file */
			t_cksum[TCRCLEN],	/* checksum of header */
			t_typeflag,
			t_linkname[TNAMLEN],	/* file this file linked with */
			t_magic[TMAGLEN],
			t_version[TVERSLEN],
			t_uname[32],
			t_gname[32],
			t_devmajor[8],
			t_devminor[8],
			t_prefix[155];
	} tbuf;
};

/* volcopy tape label format and structure */

#define	VMAGLEN 8
#define	VVOLLEN 6
#define	VFILLEN 464

struct volcopy_label {
	char	v_magic[VMAGLEN],
		v_volume[VVOLLEN],
		v_reels,
		v_reel;
	int	v_time,
		v_length,
		v_dens,
		v_reelblks,	/* u370 added field */
		v_blksize,	/* u370 added field */
		v_nblocks;	/* u370 added field */
	char	v_fill[VFILLEN];
	int	v_offset;	/* used with -e and -reel options */
	int	v_type;		/* does tape have nblocks field? */
};

/*
 * Define archive formats for extended attributes.
 *
 * Extended attributes are stored in two pieces.
 * 1. An attribute header which has information about
 *    what file the attribute is for and what the attribute
 *    is named.
 * 2. The attribute record itself.  Stored as a normal file type
 *    of entry.
 * Both the header and attribute record have special modes/typeflags
 * associated with them.
 *
 * The names of the header in the archive look like:
 * /dev/null/attr.hdr
 *
 * The name of the attribute looks like:
 * /dev/null/attr.
 *
 * This is done so that an archiver that doesn't understand these formats
 * can just dispose of the attribute records unless the user chooses to
 * rename them via cpio -r or pax -i
 *
 * The format is composed of a fixed size header followed
 * by a variable sized xattr_buf. If the attribute is a hard link
 * to another attribute, then another xattr_buf section is included
 * for the link.
 *
 * The xattr_buf is used to define the necessary "pathing" steps
 * to get to the extended attribute.  This is necessary to support
 * a fully recursive attribute model where an attribute may itself
 * have an attribute.
 *
 * The basic layout looks like this.
 *
 *     --------------------------------
 *     |                              |
 *     |         xattr_hdr            |
 *     |                              |
 *     --------------------------------
 *     --------------------------------
 *     |                              |
 *     |        xattr_buf             |
 *     |                              |
 *     --------------------------------
 *     --------------------------------
 *     |                              |
 *     |      (optional link info)    |
 *     |                              |
 *     --------------------------------
 *     --------------------------------
 *     |                              |
 *     |      attribute itself        |
 *     |      stored as normal tar    |
 *     |      or cpio data with       |
 *     |      special mode or         |
 *     |      typeflag                |
 *     |                              |
 *     --------------------------------
 *
 */
#define	XATTR_ARCH_VERS	"1.0"

/*
 * extended attribute fixed header
 *
 * h_version		format version.
 * h_size               size of header + variable sized data sections.
 * h_component_len      Length of entire pathing section.
 * h_link_component_len Length of link component section.  Again same definition
 *                      as h_component_len.
 */
struct xattr_hdr {
	char	h_version[7];
	char	h_size[10];
	char	h_component_len[10];	   /* total length of path component */
	char	h_link_component_len[10];
};

/*
 * The name is encoded like this:
 * filepathNULattrpathNUL[attrpathNULL]...
 */
struct xattr_buf {
	char	h_namesz[7];   /* length of h_names */
	char	h_typeflag;    /* actual typeflag of file being archived */
	char	h_names[1];	/* filepathNULattrpathNUL... */
};

/*
 * Special values for tar archives
 */

/*
 * typeflag for tar archives.
 */

/*
 * Attribute hdr and attribute files have the following typeflag
 */
#define	_XATTR_HDRTYPE		'E'

/*
 * For cpio archives the header and attribute have
 * _XATTR_CPIO_MODE ORED into the mode field in both
 * character and binary versions of the archive format
 */
#define	_XATTR_CPIO_MODE	0xB000

#ifdef	__cplusplus
}
#endif

#endif	/* _ARCHIVES_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _ARPA_INET_H
#define	_ARPA_INET_H

#include <sys/feature_tests.h>

#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
#include <sys/socket.h>
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

#include <netinet/in.h>
#if defined(_XPG4_2) && !defined(__EXTENSIONS__)
#include <sys/byteorder.h>
#endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * External definitions for
 * functions in inet(3C)
 */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int inet_net_pton(int, const char *, void *, size_t);
extern int inet_matchaddr(const void *, const char *);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
extern int inet_pton(int, const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD);
extern const char *inet_ntop(int, const void *_RESTRICT_KYWD,
			char *_RESTRICT_KYWD, socklen_t);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

extern in_addr_t inet_addr(const char *);
/*
 * With the introduction of CIDR the
 * following 4 routines are now considered to be Obsolete
 */
extern in_addr_t inet_lnaof(struct in_addr);
extern struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
extern in_addr_t inet_netof(struct in_addr);
extern in_addr_t inet_network(const char *);


extern char *inet_neta(ulong_t, char *, size_t);
extern char *inet_net_ntop(int, const void *, int, char *, size_t);

extern char *inet_cidr_ntop(int, const void *, int, char *, size_t);
extern int inet_cidr_pton(int, const char *, void *, int *);
extern char *inet_ntoa(struct in_addr);
extern int inet_aton(const char *, struct in_addr *);

extern uint_t inet_nsap_addr(const char *, uchar_t *, int);
extern char *inet_nsap_ntoa(int, const uchar_t *, char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _ARPA_INET_H */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
 */

/*
 * Copyright (c) 1983, 1989, 1993
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Portions Copyright (C) 2004, 2005, 2008, 2009
 * Internet Systems Consortium, Inc. ("ISC")
 * Portions Copyright (C) 1996-2003  Internet Software Consortium.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

/*
 *	$Id: nameser.h,v 8.50 2003/05/27 23:36:52 marka Exp $
 */

#ifndef _ARPA_NAMESER_H
#define	_ARPA_NAMESER_H

#include <sys/isa_defs.h>


#ifdef	__cplusplus
extern "C" {
#endif

#define	BIND_4_COMPAT

/*
 * Revision information.  This is the release date in YYYYMMDD format.
 * It can change every day so the right thing to do with it is use it
 * in preprocessor commands such as "#if (__NAMESER > 19931104)".  Do not
 * compare for equality; rather, use it to determine whether your libresolv
 * contains a new enough lib/nameser/ to support the feature you need.
 */

#define	__NAMESER	20090302	/* New interface version stamp. */

/*
 * Define constants based on RFC 883, RFC 1034, RFC 1035
 */
#define	NS_PACKETSZ	512	/* default UDP packet size */
#define	NS_MAXDNAME	1025	/* maximum domain name */
#define	NS_MAXMSG	65535	/* maximum message size */
#define	NS_MAXCDNAME	255	/* maximum compressed domain name */
#define	NS_MAXLABEL	63	/* maximum length of domain label */
#define	NS_MAXLABELS	128	/* theoretical max #/labels per domain name */
#define	NS_MAXNNAME	256	/* maximum uncompressed (binary) domain name */
#define	NS_MAXPADDR	(sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"))
#define	NS_HFIXEDSZ	12	/* #/bytes of fixed data in header */
#define	NS_QFIXEDSZ	4	/* #/bytes of fixed data in query */
#define	NS_RRFIXEDSZ	10	/* #/bytes of fixed data in r record */
#define	NS_INT32SZ	4	/* #/bytes of data in a u_int32_t */
#define	NS_INT16SZ	2	/* #/bytes of data in a u_int16_t */
#define	NS_INT8SZ	1	/* #/bytes of data in a u_int8_t */
#define	NS_INADDRSZ	4	/* IPv4 T_A */
#define	NS_IN6ADDRSZ	16	/* IPv6 T_AAAA */
#define	NS_CMPRSFLGS	0xc0	/* Flag bits indicating name compression. */
#define	NS_DEFAULTPORT	53	/* For both TCP and UDP. */

/*
 * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
 * in synch with it.
 */
typedef enum __ns_sect {
	ns_s_qd = 0,		/* Query: Question. */
	ns_s_zn = 0,		/* Update: Zone. */
	ns_s_an = 1,		/* Query: Answer. */
	ns_s_pr = 1,		/* Update: Prerequisites. */
	ns_s_ns = 2,		/* Query: Name servers. */
	ns_s_ud = 2,		/* Update: Update. */
	ns_s_ar = 3,		/* Query|Update: Additional records. */
	ns_s_max = 4
} ns_sect;

/*
 * Network name (compressed or not) type.  Equivalent to a pointer when used
 * in a function prototype.  Can be const'd.
 */
typedef uchar_t ns_nname[NS_MAXNNAME];
typedef const uchar_t *ns_nname_ct;
typedef uchar_t *ns_nname_t;

struct ns_namemap { ns_nname_ct base; int len; };
typedef struct ns_namemap *ns_namemap_t;
typedef const struct ns_namemap *ns_namemap_ct;

/*
 * This is a message handle.  It is caller allocated and has no dynamic data.
 * This structure is intended to be opaque to all but ns_parse.c, thus the
 * leading _'s on the member names.  Use the accessor functions, not the _'s.
 */
typedef struct __ns_msg {
	const uchar_t	*_msg, *_eom;
	uint16_t	_id, _flags, _counts[ns_s_max];
	const uchar_t	*_sections[ns_s_max];
	ns_sect		_sect;
	int		_rrnum;
	const uchar_t	*_msg_ptr;
} ns_msg;

/*
 * This is a newmsg handle, used when constructing new messages with
 * ns_newmsg_init, et al.
 */
struct ns_newmsg {
	ns_msg		msg;
	const uchar_t	*dnptrs[25];
	const uchar_t	**lastdnptr;
};
typedef struct ns_newmsg ns_newmsg;

/* Private data structure - do not use from outside library. */
struct _ns_flagdata {  int mask, shift;  };
extern struct _ns_flagdata _ns_flagdata[];

/* Accessor macros - this is part of the public interface. */
#define	ns_msg_id(handle) ((handle)._id + 0)
#define	ns_msg_base(handle) ((handle)._msg + 0)
#define	ns_msg_end(handle) ((handle)._eom + 0)
#define	ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define	ns_msg_count(handle, section) ((handle)._counts[section] + 0)

/*
 * This is a parsed record.  It is caller allocated and has no dynamic data.
 */
typedef	struct __ns_rr {
	char		name[NS_MAXDNAME];
	uint16_t	type;
	uint16_t	rr_class;
	uint32_t	ttl;
	uint16_t	rdlength;
	const uchar_t	*rdata;
} ns_rr;

/*
 * Same thing, but using uncompressed network binary names, and real C types.
 */
typedef	struct __ns_rr2 {
	ns_nname	nname;
	size_t		nnamel;
	int		type;
	int		rr_class;
	uint_t		ttl;
	int		rdlength;
	const uchar_t	*rdata;
} ns_rr2;

/* Accessor macros - this is part of the public interface. */
#define	ns_rr_name(rr)	(((rr).name[0] != '\0') ? (rr).name : ".")
#define	ns_rr_nname(rr)	((const ns_nname_t)(rr).nname)
#define	ns_rr_nnamel(rr) ((rr).nnamel + 0)
#define	ns_rr_type(rr)	((ns_type)((rr).type + 0))
#define	ns_rr_class(rr)	((ns_class)((rr).rr_class + 0))
#define	ns_rr_ttl(rr)	((rr).ttl + 0)
#define	ns_rr_rdlen(rr)	((rr).rdlength + 0)
#define	ns_rr_rdata(rr)	((rr).rdata + 0)

/*
 * These don't have to be in the same order as in the packet flags word,
 * and they can even overlap in some cases, but they will need to be kept
 * in synch with ns_parse.c:ns_flagdata[].
 */
typedef enum __ns_flag {
	ns_f_qr,		/* Question/Response. */
	ns_f_opcode,		/* Operation code. */
	ns_f_aa,		/* Authoritative Answer. */
	ns_f_tc,		/* Truncation occurred. */
	ns_f_rd,		/* Recursion Desired. */
	ns_f_ra,		/* Recursion Available. */
	ns_f_z,			/* MBZ. */
	ns_f_ad,		/* Authentic Data (DNSSEC). */
	ns_f_cd,		/* Checking Disabled (DNSSEC). */
	ns_f_rcode,		/* Response code. */
	ns_f_max
} ns_flag;

/*
 * Currently defined opcodes.
 */
typedef enum __ns_opcode {
	ns_o_query = 0,		/* Standard query. */
	ns_o_iquery = 1,	/* Inverse query (deprecated/unsupported). */
	ns_o_status = 2,	/* Name server status query (unsupported). */
				/* Opcode 3 is undefined/reserved. */
	ns_o_notify = 4,	/* Zone change notification. */
	ns_o_update = 5,	/* Zone update message. */
	ns_o_max = 6
} ns_opcode;

/*
 * Currently defined response codes.
 */
typedef	enum __ns_rcode {
	ns_r_noerror = 0,	/* No error occurred. */
	ns_r_formerr = 1,	/* Format error. */
	ns_r_servfail = 2,	/* Server failure. */
	ns_r_nxdomain = 3,	/* Name error. */
	ns_r_notimpl = 4,	/* Unimplemented. */
	ns_r_refused = 5,	/* Operation refused. */
	/* these are for BIND_UPDATE */
	ns_r_yxdomain = 6,	/* Name exists */
	ns_r_yxrrset = 7,	/* RRset exists */
	ns_r_nxrrset = 8,	/* RRset does not exist */
	ns_r_notauth = 9,	/* Not authoritative for zone */
	ns_r_notzone = 10,	/* Zone of record different from zone section */
	ns_r_max = 11,
	/* The following are EDNS extended rcodes */
	ns_r_badvers = 16,
	/* The following are TSIG errors */
	ns_r_badsig = 16,
	ns_r_badkey = 17,
	ns_r_badtime = 18
} ns_rcode;

/* BIND_UPDATE */
typedef enum __ns_update_operation {
	ns_uop_delete = 0,
	ns_uop_add = 1,
	ns_uop_max = 2
} ns_update_operation;

/*
 * This RR-like structure is particular to UPDATE.
 */
struct ns_updrec {
	struct ns_updrec *r_prev;	/* prev record */
	struct ns_updrec *r_next;	/* next record */
	uint8_t		r_section;	/* ZONE/PREREQUISITE/UPDATE */
	char		*r_dname;	/* owner of the RR */
	uint16_t	r_class;	/* class number */
	uint16_t	r_type;		/* type number */
	uint32_t	r_ttl;		/* time to live */
	uchar_t		*r_data;	/* rdata fields as text string */
	uint16_t	r_size;		/* size of r_data field */
	int		r_opcode;	/* type of operation */
	/* following fields for private use by the resolver/server routines */
	struct ns_updrec *r_grpnext;	/* next record when grouped */
	struct databuf *r_dp;		/* databuf to process */
	struct databuf *r_deldp;	/* databuf's deleted/overwritten */
	uint16_t	r_zone;		/* zone number on server */
};
typedef struct ns_updrec ns_updrec;

/*
 * This structure is used for TSIG authenticated messages
 */
struct ns_tsig_key {
		char name[NS_MAXDNAME], alg[NS_MAXDNAME];
		unsigned char *data;
		int len;
};
typedef struct ns_tsig_key ns_tsig_key;

/*
 * This structure is used for TSIG authenticated TCP messages
 */
struct ns_tcp_tsig_state {
	int counter;
	struct dst_key *key;
	void *ctx;
	unsigned char sig[NS_PACKETSZ];
	int siglen;
};
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;

#define	NS_TSIG_FUDGE 300
#define	NS_TSIG_TCP_COUNT 100
#define	NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"

#define	NS_TSIG_ERROR_NO_TSIG -10
#define	NS_TSIG_ERROR_NO_SPACE -11
#define	NS_TSIG_ERROR_FORMERR -12

/*
 * Currently defined type values for resources and queries.
 */
typedef enum __ns_type {
	ns_t_invalid = 0,	/* Cookie. */
	ns_t_a = 1,		/* Host address. */
	ns_t_ns = 2,		/* Authoritative server. */
	ns_t_md = 3,		/* Mail destination. */
	ns_t_mf = 4,		/* Mail forwarder. */
	ns_t_cname = 5,		/* Canonical name. */
	ns_t_soa = 6,		/* Start of authority zone. */
	ns_t_mb = 7,		/* Mailbox domain name. */
	ns_t_mg = 8,		/* Mail group member. */
	ns_t_mr = 9,		/* Mail rename name. */
	ns_t_null = 10,		/* Null resource record. */
	ns_t_wks = 11,		/* Well known service. */
	ns_t_ptr = 12,		/* Domain name pointer. */
	ns_t_hinfo = 13,	/* Host information. */
	ns_t_minfo = 14,	/* Mailbox information. */
	ns_t_mx = 15,		/* Mail routing information. */
	ns_t_txt = 16,		/* Text strings. */
	ns_t_rp = 17,		/* Responsible person. */
	ns_t_afsdb = 18,	/* AFS cell database. */
	ns_t_x25 = 19,		/* X_25 calling address. */
	ns_t_isdn = 20,		/* ISDN calling address. */
	ns_t_rt = 21,		/* Router. */
	ns_t_nsap = 22,		/* NSAP address. */
	ns_t_nsap_ptr = 23,	/* Reverse NSAP lookup (deprecated). */
	ns_t_sig = 24,		/* Security signature. */
	ns_t_key = 25,		/* Security key. */
	ns_t_px = 26,		/* X.400 mail mapping. */
	ns_t_gpos = 27,		/* Geographical position (withdrawn). */
	ns_t_aaaa = 28,		/* IPv6 Address. */
	ns_t_loc = 29,		/* Location Information. */
	ns_t_nxt = 30,		/* Next domain (security). */
	ns_t_eid = 31,		/* Endpoint identifier. */
	ns_t_nimloc = 32,	/* Nimrod Locator. */
	ns_t_srv = 33,		/* Server Selection. */
	ns_t_atma = 34,		/* ATM Address */
	ns_t_naptr = 35,	/* Naming Authority PoinTeR */
	ns_t_kx = 36,		/* Key Exchange */
	ns_t_cert = 37,		/* Certification record */
	ns_t_a6 = 38,		/* IPv6 address (deprecated) */
	ns_t_dname = 39,	/* Non-terminal DNAME (for IPv6) */
	ns_t_sink = 40,		/* Kitchen sink (experimentatl) */
	ns_t_opt = 41,		/* EDNS0 option (meta-RR) */
	ns_t_apl = 42,		/* Address prefix list (RFC 3123) */
	ns_t_ds = 43,		/* Delegation Signer */
	ns_t_sshfp = 44,	/* SSH Fingerprint */
	ns_t_ipseckey = 45,	/* IPSEC Key */
	ns_t_rrsig = 46,	/* RRset Signature */
	ns_t_nsec = 47,		/* Negative security */
	ns_t_dnskey = 48,	/* DNS Key */
	ns_t_dhcid = 49,	/* Dynamic host configuratin identifier */
	ns_t_nsec3 = 50,	/* Negative security type 3 */
	ns_t_nsec3param = 51,	/* Negative security type 3 parameters */
	ns_t_tlsa = 52,		/* TLSA (RFC 6698) */
	ns_t_smimea = 53,	/* S/MIME cert association (RFC 8162) */
	ns_t_hip = 55,		/* Host Identity Protocol */
	ns_t_cds = 59,		/* Child DS (RFC 7344) */
	ns_t_cdnskey = 60,	/* DNSKEY(s) the Child wants reflected in DS */
	ns_t_openpgpkey = 61,	/* OpenPGP Key (RFC 7929) */
	ns_t_csync = 62,	/* Child-To-Parent Synchronization (RFC 7477) */
	ns_t_spf = 99,		/* Sender Policy Framework */
	ns_t_tkey = 249,	/* Transaction key */
	ns_t_tsig = 250,	/* Transaction signature. */
	ns_t_ixfr = 251,	/* Incremental zone transfer. */
	ns_t_axfr = 252,	/* Transfer zone of authority. */
	ns_t_mailb = 253,	/* Transfer mailbox records. */
	ns_t_maila = 254,	/* Transfer mail agent records. */
	ns_t_any = 255,		/* Wildcard match. */
	ns_t_zxfr = 256,	/* BIND-specific, nonstandard. */
	ns_t_caa = 257,		/* Certification Authority Restriction */
	ns_t_dlv = 32769,	/* DNSSEC look-aside validatation. */
	ns_t_max = 65536
} ns_type;

/* Exclusively a QTYPE? (not also an RTYPE) */
#define	ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
		(t) == ns_t_mailb || (t) == ns_t_maila)
/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
#define	ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
#define	ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
#define	ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
#define	ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
		(t) == ns_t_zxfr)

/*
 * Values for class field
 */
typedef enum __ns_class {
	ns_c_invalid = 0,	/* Cookie. */
	ns_c_in = 1,		/* Internet. */
	ns_c_2 = 2,		/* unallocated/unsupported. */
	ns_c_chaos = 3,		/* MIT Chaos-net. */
	ns_c_hs = 4,		/* MIT Hesiod. */
	/* Query class values which do not appear in resource records */
	ns_c_none = 254,	/* for prereq. sections in update requests */
	ns_c_any = 255,		/* Wildcard match. */
	ns_c_max = 65536
} ns_class;

/* DNSSEC constants. */

typedef enum __ns_key_types {
	ns_kt_rsa = 1,		/* key type RSA/MD5 */
	ns_kt_dh  = 2,		/* Diffie Hellman */
	ns_kt_dsa = 3,		/* Digital Signature Standard (MANDATORY) */
	ns_kt_private = 254	/* Private key type starts with OID */
} ns_key_types;

typedef enum __ns_cert_types {
	cert_t_pkix = 1,	/* PKIX (X.509v3) */
	cert_t_spki = 2,	/* SPKI */
	cert_t_pgp  = 3,	/* PGP */
	cert_t_url  = 253,	/* URL private type */
	cert_t_oid  = 254	/* OID private type */
} ns_cert_types;

/* Flags field of the KEY RR rdata. */
#define	NS_KEY_TYPEMASK		0xC000	/* Mask for "type" bits */
#define	NS_KEY_TYPE_AUTH_CONF	0x0000	/* Key usable for both */
#define	NS_KEY_TYPE_CONF_ONLY	0x8000	/* Key usable for confidentiality */
#define	NS_KEY_TYPE_AUTH_ONLY	0x4000	/* Key usable for authentication */
#define	NS_KEY_TYPE_NO_KEY	0xC000	/* No key usable for either; no key */
/* The type bits can also be interpreted independently, as single bits: */
#define	NS_KEY_NO_AUTH		0x8000	/* Key unusable for authentication */
#define	NS_KEY_NO_CONF		0x4000	/* Key unusable for confidentiality */
#define	NS_KEY_RESERVED2	0x2000	/* Security is *mandatory* if bit=0 */
#define	NS_KEY_EXTENDED_FLAGS	0x1000	/* reserved - must be zero */
#define	NS_KEY_RESERVED4	0x0800  /* reserved - must be zero */
#define	NS_KEY_RESERVED5	0x0400  /* reserved - must be zero */
#define	NS_KEY_NAME_TYPE	0x0300	/* these bits determine the type */
#define	NS_KEY_NAME_USER	0x0000	/* key is assoc. with user */
#define	NS_KEY_NAME_ENTITY	0x0200	/* key is assoc. with entity eg host */
#define	NS_KEY_NAME_ZONE	0x0100	/* key is zone key */
#define	NS_KEY_NAME_RESERVED	0x0300	/* reserved meaning */
#define	NS_KEY_RESERVED8	0x0080  /* reserved - must be zero */
#define	NS_KEY_RESERVED9	0x0040  /* reserved - must be zero */
#define	NS_KEY_RESERVED10	0x0020  /* reserved - must be zero */
#define	NS_KEY_RESERVED11	0x0010  /* reserved - must be zero */
#define	NS_KEY_SIGNATORYMASK	0x000F	/* key can sign RR's of same name */
#define	NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | \
    NS_KEY_RESERVED4 | \
    NS_KEY_RESERVED5 | \
    NS_KEY_RESERVED8 | \
    NS_KEY_RESERVED9 | \
    NS_KEY_RESERVED10 | \
    NS_KEY_RESERVED11)
#define	NS_KEY_RESERVED_BITMASK2	0xFFFF /* no bits defined here */

/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
#define	NS_ALG_MD5RSA		1	/* MD5 with RSA */
#define	NS_ALG_DH		2	/* Diffie Hellman KEY */
#define	NS_ALG_DSA		3	/* DSA KEY */
#define	NS_ALG_DSS		NS_ALG_DSA
#define	NS_ALG_EXPIRE_ONLY	253	/* No alg, no security */
#define	NS_ALG_PRIVATE_OID	254	/* Key begins with OID giving alg */

/* Protocol values  */
/* value 0 is reserved */
#define	NS_KEY_PROT_TLS		1
#define	NS_KEY_PROT_EMAIL	2
#define	NS_KEY_PROT_DNSSEC	3
#define	NS_KEY_PROT_IPSEC	4
#define	NS_KEY_PROT_ANY		255

/* Signatures */
#define	NS_MD5RSA_MIN_BITS	 512	/* Size of a mod or exp in bits */
#define	NS_MD5RSA_MAX_BITS	4096
	/* Total of binary mod and exp */
#define	NS_MD5RSA_MAX_BYTES	((NS_MD5RSA_MAX_BITS+7/8)*2+3)
	/* Max length of text sig block */
#define	NS_MD5RSA_MAX_BASE64	(((NS_MD5RSA_MAX_BYTES+2)/3)*4)
#define	NS_MD5RSA_MIN_SIZE	((NS_MD5RSA_MIN_BITS+7)/8)
#define	NS_MD5RSA_MAX_SIZE	((NS_MD5RSA_MAX_BITS+7)/8)

#define	NS_DSA_SIG_SIZE		41
#define	NS_DSA_MIN_SIZE		213
#define	NS_DSA_MAX_BYTES	405

/* Offsets into SIG record rdata to find various values */
#define	NS_SIG_TYPE	0	/* Type flags */
#define	NS_SIG_ALG	2	/* Algorithm */
#define	NS_SIG_LABELS	3	/* How many labels in name */
#define	NS_SIG_OTTL	4	/* Original TTL */
#define	NS_SIG_EXPIR	8	/* Expiration time */
#define	NS_SIG_SIGNED	12	/* Signature time */
#define	NS_SIG_FOOT	16	/* Key footprint */
#define	NS_SIG_SIGNER	18	/* Domain name of who signed it */

/* How RR types are represented as bit-flags in NXT records */
#define	NS_NXT_BITS 8
#define	NS_NXT_BIT_SET(n, p) \
	(p[(n)/NS_NXT_BITS] |=  (0x80>>((n)%NS_NXT_BITS)))
#define	NS_NXT_BIT_CLEAR(n, p) \
	(p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
#define	NS_NXT_BIT_ISSET(n, p) \
	(p[(n)/NS_NXT_BITS] &   (0x80>>((n)%NS_NXT_BITS)))
#define	NS_NXT_MAX	127

/*
 * EDNS0 extended flags, host order.
 */
#define	NS_OPT_DNSSEC_OK	0x8000U
#define	NS_OPT_NSID		3

/*
 * Inline versions of get/put short/long.  Pointer is advanced.
 */
#define	NS_GET16(s, cp) do { \
	register const uchar_t *t_cp = (const uchar_t *)(cp); \
	(s) = ((uint16_t)t_cp[0] << 8) \
	    | ((uint16_t)t_cp[1]) \
	; \
	(cp) += NS_INT16SZ; \
} while (0)

#define	NS_GET32(l, cp) do { \
	register const uchar_t *t_cp = (const uchar_t *)(cp); \
	(l) = ((uint32_t)t_cp[0] << 24) \
	    | ((uint32_t)t_cp[1] << 16) \
	    | ((uint32_t)t_cp[2] << 8) \
	    | ((uint32_t)t_cp[3]) \
	; \
	(cp) += NS_INT32SZ; \
} while (0)

#define	NS_PUT16(s, cp) do { \
	register uint16_t t_s = (uint16_t)(s); \
	register uchar_t *t_cp = (uchar_t *)(cp); \
	*t_cp++ = t_s >> 8; \
	*t_cp   = t_s; \
	(cp) += NS_INT16SZ; \
} while (0)

#define	NS_PUT32(l, cp) do { \
	register uint32_t t_l = (uint32_t)(l); \
	register uchar_t *t_cp = (uchar_t *)(cp); \
	*t_cp++ = t_l >> 24; \
	*t_cp++ = t_l >> 16; \
	*t_cp++ = t_l >> 8; \
	*t_cp   = t_l; \
	(cp) += NS_INT32SZ; \
} while (0)

/*
 * ANSI C identifier hiding.
 */
#define	ns_msg_getflag		__ns_msg_getflag
#define	ns_get16		__ns_get16
#define	ns_get32		__ns_get32
#define	ns_put16		__ns_put16
#define	ns_put32		__ns_put32
#define	ns_initparse		__ns_initparse
#define	ns_skiprr		__ns_skiprr
#define	ns_parserr		__ns_parserr
#define	ns_parserr2		__ns_parserr2
#define	ns_sprintrr		__ns_sprintrr
#define	ns_sprintrrf		__ns_sprintrrf
#define	ns_format_ttl		__ns_format_ttl
#define	ns_parse_ttl		__ns_parse_ttl
#define	ns_datetosecs		__ns_datetosecs
#define	ns_name_ntol		__ns_name_ntol
#define	ns_name_ntop		__ns_name_ntop
#define	ns_name_pton		__ns_name_pton
#define	ns_name_pton2		__ns_name_pton2
#define	ns_name_unpack		__ns_name_unpack
#define	ns_name_pack		__ns_name_pack
#define	ns_name_compress	__ns_name_compress
#define	ns_name_uncompress	__ns_name_uncompress
#define	ns_name_skip		__ns_name_skip
#define	ns_name_rollback	__ns_name_rollback
#define	ns_name_length		__ns_name_length
#define	ns_name_eq		__ns_name_eq
#define	ns_name_owned		__ns_name_owned
#define	ns_name_map		__ns_name_map
#define	ns_name_labels		__ns_name_labels
#define	ns_sign			__ns_sign
#define	ns_sign2		__ns_sign2
#define	ns_sign_tcp		__ns_sign_tcp
#define	ns_sign_tcp2		__ns_sign_tcp2
#define	ns_sign_tcp_init	__ns_sign_tcp_init
#define	ns_find_tsig		__ns_find_tsig
#define	ns_verify		__ns_verify
#define	ns_verify_tcp		__ns_verify_tcp
#define	ns_verify_tcp_init	__ns_verify_tcp_init
#define	ns_samedomain		__ns_samedomain
#define	ns_subdomain		__ns_subdomain
#define	ns_makecanon		__ns_makecanon
#define	ns_samename		__ns_samename
#define	ns_newmsg_init		__ns_newmsg_init
#define	ns_newmsg_copy		__ns_newmsg_copy
#define	ns_newmsg_id		__ns_newmsg_id
#define	ns_newmsg_flag		__ns_newmsg_flag
#define	ns_newmsg_q		__ns_newmsg_q
#define	ns_newmsg_rr		__ns_newmsg_rr
#define	ns_newmsg_done		__ns_newmsg_done
#define	ns_rdata_unpack		__ns_rdata_unpack
#define	ns_rdata_equal		__ns_rdata_equal
#define	ns_rdata_refers		__ns_rdata_refers

int		ns_msg_getflag(ns_msg, int);
uint_t		ns_get16(const uchar_t *);
ulong_t		ns_get32(const uchar_t *);
void		ns_put16(uint_t, uchar_t *);
void		ns_put32(ulong_t, uchar_t *);
int		ns_initparse(const uchar_t *, int, ns_msg *);
int		ns_skiprr(const uchar_t *, const uchar_t *, ns_sect, int);
int		ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
int		ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
int		ns_sprintrr(const ns_msg *, const ns_rr *,
    const char *, const char *, char *, size_t);
int		ns_sprintrrf(const uchar_t *, size_t, const char *,
    ns_class, ns_type, ulong_t, const uchar_t *,
    size_t, const char *, const char *,
    char *, size_t);
int		ns_format_ttl(ulong_t, char *, size_t);
int		ns_parse_ttl(const char *, ulong_t *);
uint32_t	ns_datetosecs(const char *cp, int *errp);
int		ns_name_ntol(const uchar_t *, uchar_t *, size_t);
int		ns_name_ntop(const uchar_t *, char *, size_t);
int		ns_name_pton(const char *, uchar_t *, size_t);
int		ns_name_pton2(const char *, uchar_t *, size_t, size_t *);
int		ns_name_unpack(const uchar_t *, const uchar_t *,
				    const uchar_t *, uchar_t *, size_t);
int		ns_name_pack(const uchar_t *, uchar_t *, int,
    const uchar_t **, const uchar_t **);
int		ns_name_uncompress(const uchar_t *, const uchar_t *,
					const uchar_t *, char *, size_t);
int		ns_name_compress(const char *, uchar_t *, size_t,
			const uchar_t **, const uchar_t **);
int		ns_name_skip(const uchar_t **, const uchar_t *);
void	ns_name_rollback(const uchar_t *, const uchar_t **,
			const uchar_t **);
ssize_t		ns_name_length(ns_nname_ct, size_t);
int		ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
int		ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
int		ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
int		ns_name_labels(ns_nname_ct, size_t);
int		ns_sign(uchar_t *, int *, int, int, void *,
			const uchar_t *, int, uchar_t *, int *, time_t);
int		ns_sign2(uchar_t *, int *, int, int, void *,
			const uchar_t *, int, uchar_t *, int *, time_t,
			uchar_t **, uchar_t **);
int		ns_sign_tcp(uchar_t *, int *, int, int,
			ns_tcp_tsig_state *, int);
int		ns_sign_tcp2(uchar_t *, int *, int, int,
			ns_tcp_tsig_state *, int,
			uchar_t **, uchar_t **);
int		ns_sign_tcp_init(void *, const uchar_t *, int,
					ns_tcp_tsig_state *);
uchar_t		*ns_find_tsig(uchar_t *, uchar_t *);
int		ns_verify(uchar_t *, int *, void *,
			const uchar_t *, int, uchar_t *, int *,
			time_t *, int);
int		ns_verify_tcp(uchar_t *, int *, ns_tcp_tsig_state *, int);
int		ns_verify_tcp_init(void *, const uchar_t *, int,
					ns_tcp_tsig_state *);
int		ns_samedomain(const char *, const char *);
int		ns_subdomain(const char *, const char *);
int		ns_makecanon(const char *, char *, size_t);
int		ns_samename(const char *, const char *);
int		ns_newmsg_init(uchar_t *buffer, size_t bufsiz, ns_newmsg *);
int		ns_newmsg_copy(ns_newmsg *, ns_msg *);
void		ns_newmsg_id(ns_newmsg *handle, uint16_t id);
void		ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, uint_t value);
int		ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
			    ns_type qtype, ns_class qclass);
int		ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
			    ns_nname_ct name, ns_type type,
			    ns_class rr_class, uint32_t ttl,
			    uint16_t rdlen, const uchar_t *rdata);
size_t		ns_newmsg_done(ns_newmsg *handle);
ssize_t		ns_rdata_unpack(const uchar_t *, const uchar_t *, ns_type,
				const uchar_t *, size_t, uchar_t *, size_t);
int		ns_rdata_equal(ns_type, const uchar_t *, size_t,
				const uchar_t *, size_t);
int		ns_rdata_refers(ns_type,
				const uchar_t *, size_t,
				const uchar_t *);

#ifdef BIND_4_COMPAT
#include <arpa/nameser_compat.h>
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* !_ARPA_NAMESER_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright(c)	1983,	1989
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 *      from nameser.h	8.1 (Berkeley) 6/2/93
 *	$Id: nameser_compat.h,v 8.15 2002/07/17 07:01:02 marka Exp $
 */

#ifndef _ARPA_NAMESER_COMPAT_H
#define	_ARPA_NAMESER_COMPAT_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	__BIND		19950621	/* (DEAD) interface version stamp. */

#ifndef BYTE_ORDER
#if (BSD >= 199103)
#include <machine/endian.h>
#else
#ifdef linux
#include <endian.h>
#else
#define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax, pc) */
#define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
#define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */

#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
	defined(__i386) || defined(__amd64) || \
	defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
	defined(__alpha__) || defined(__alpha) || \
	(defined(__Lynx__) && defined(__x86__))
#define	BYTE_ORDER	LITTLE_ENDIAN
#endif

#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
    defined(__sparc) || \
    defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
    defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
    defined(apollo) || defined(__convex__) || defined(_CRAY) || \
    defined(__hppa) || defined(__hp9000) || \
    defined(__hp9000s300) || defined(__hp9000s700) || \
    defined(__hp3000s900) || defined(MPE) || \
    defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \
	(defined(__Lynx__) && \
	(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
#define	BYTE_ORDER	BIG_ENDIAN
#endif
#endif /* linux */
#endif /* BSD */
#endif /* BYTE_ORDER */

#if !defined(BYTE_ORDER) || \
	((BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) && \
	(BYTE_ORDER != PDP_ENDIAN))
/*
 * you must determine what the correct bit order is for
 * your compiler - the next line is an intentional error
 * which will force your compiles to bomb until you fix
 * the above macros.
 */
#error "Undefined or invalid BYTE_ORDER";
#endif

/*
 * Structure for query header.  The order of the fields is machine- and
 * compiler-dependent, depending on the byte/bit order and the layout
 * of bit fields.  We use bit fields only in int variables, as this
 * is all ANSI requires.  This requires a somewhat confusing rearrangement.
 */

typedef struct {
	unsigned	id :16;		/* query identification number */
#if BYTE_ORDER == BIG_ENDIAN
			/* fields in third byte */
	unsigned	qr: 1;		/* response flag */
	unsigned	opcode: 4;	/* purpose of message */
	unsigned	aa: 1;		/* authoritive answer */
	unsigned	tc: 1;		/* truncated message */
	unsigned	rd: 1;		/* recursion desired */
			/* fields in fourth byte */
	unsigned	ra: 1;		/* recursion available */
	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
	unsigned	ad: 1;		/* authentic data from named */
	unsigned	cd: 1;		/* checking disabled by resolver */
	unsigned	rcode :4;	/* response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
			/* fields in third byte */
	unsigned	rd :1;		/* recursion desired */
	unsigned	tc :1;		/* truncated message */
	unsigned	aa :1;		/* authoritive answer */
	unsigned	opcode :4;	/* purpose of message */
	unsigned	qr :1;		/* response flag */
			/* fields in fourth byte */
	unsigned	rcode :4;	/* response code */
	unsigned	cd: 1;		/* checking disabled by resolver */
	unsigned	ad: 1;		/* authentic data from named */
	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
	unsigned	ra :1;		/* recursion available */
#endif
			/* remaining bytes */
	unsigned	qdcount :16;	/* number of question entries */
	unsigned	ancount :16;	/* number of answer entries */
	unsigned	nscount :16;	/* number of authority entries */
	unsigned	arcount :16;	/* number of resource entries */
} HEADER;

#define	PACKETSZ	NS_PACKETSZ
#define	MAXDNAME	NS_MAXDNAME
#define	MAXCDNAME	NS_MAXCDNAME
#define	MAXLABEL	NS_MAXLABEL
#define	HFIXEDSZ	NS_HFIXEDSZ
#define	QFIXEDSZ	NS_QFIXEDSZ
#define	RRFIXEDSZ	NS_RRFIXEDSZ
#define	INT32SZ		NS_INT32SZ
#define	INT16SZ		NS_INT16SZ
#define	INT8SZ		NS_INT8SZ
#define	INADDRSZ	NS_INADDRSZ
#define	IN6ADDRSZ	NS_IN6ADDRSZ
#define	INDIR_MASK	NS_CMPRSFLGS
#define	NAMESERVER_PORT	NS_DEFAULTPORT

#define	S_ZONE		ns_s_zn
#define	S_PREREQ	ns_s_pr
#define	S_UPDATE	ns_s_ud
#define	S_ADDT		ns_s_ar

#define	QUERY		ns_o_query
#define	IQUERY		ns_o_iquery
#define	STATUS		ns_o_status
#define	NS_NOTIFY_OP	ns_o_notify
#define	NS_UPDATE_OP	ns_o_update

#define	NOERROR		ns_r_noerror
#define	FORMERR		ns_r_formerr
#define	SERVFAIL	ns_r_servfail
#define	NXDOMAIN	ns_r_nxdomain
#define	NOTIMP		ns_r_notimpl
#define	REFUSED		ns_r_refused
#define	YXDOMAIN	ns_r_yxdomain
#define	YXRRSET		ns_r_yxrrset
#define	NXRRSET		ns_r_nxrrset
#define	NOTAUTH		ns_r_notauth
#define	NOTZONE		ns_r_notzone
/* #define	BADSIG		ns_r_badsig */
/* #define	BADKEY		ns_r_badkey */
/* #define	BADTIME		ns_r_badtime */

#define	DELETE		ns_uop_delete
#ifndef	ADD
#define	ADD		ns_uop_add
#endif

#define	T_A		ns_t_a
#define	T_NS		ns_t_ns
#define	T_MD		ns_t_md
#define	T_MF		ns_t_mf
#define	T_CNAME		ns_t_cname
#define	T_SOA		ns_t_soa
#define	T_MB		ns_t_mb
#define	T_MG		ns_t_mg
#define	T_MR		ns_t_mr
#define	T_NULL		ns_t_null
#define	T_WKS		ns_t_wks
#define	T_PTR		ns_t_ptr
#define	T_HINFO		ns_t_hinfo
#define	T_MINFO		ns_t_minfo
#define	T_MX		ns_t_mx
#define	T_TXT		ns_t_txt
#define	T_RP		ns_t_rp
#define	T_AFSDB		ns_t_afsdb
#define	T_X25		ns_t_x25
#define	T_ISDN		ns_t_isdn
#define	T_RT		ns_t_rt
#define	T_NSAP		ns_t_nsap
#define	T_NSAP_PTR	ns_t_nsap_ptr
#define	T_SIG		ns_t_sig
#define	T_KEY		ns_t_key
#define	T_PX		ns_t_px
#define	T_GPOS		ns_t_gpos
#define	T_AAAA		ns_t_aaaa
#define	T_LOC		ns_t_loc
#define	T_NXT		ns_t_nxt
#define	T_EID		ns_t_eid
#define	T_NIMLOC	ns_t_nimloc
#define	T_SRV		ns_t_srv
#define	T_ATMA		ns_t_atma
#define	T_NAPTR		ns_t_naptr
#define	T_A6		ns_t_a6
#define	T_TSIG		ns_t_tsig
#define	T_IXFR		ns_t_ixfr
#define	T_AXFR		ns_t_axfr
#define	T_MAILB		ns_t_mailb
#define	T_MAILA		ns_t_maila
#define	T_ANY		ns_t_any

#define	C_IN		ns_c_in
#define	C_CHAOS		ns_c_chaos
#define	C_HS		ns_c_hs
/* BIND_UPDATE */
#define	C_NONE		ns_c_none
#define	C_ANY		ns_c_any

#define	GETSHORT		NS_GET16
#define	GETLONG			NS_GET32
#define	PUTSHORT		NS_PUT16
#define	PUTLONG			NS_PUT32

#ifdef	__cplusplus
}
#endif

#endif	/* _ARPA_NAMESER_COMPAT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright (c) 2016 by Delphix. All rights reserved.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef	_ARPA_TELNET_H
#define	_ARPA_TELNET_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Definitions for the TELNET protocol.
 */
#define	IAC	255		/* interpret as command: */
#define	DONT	254		/* you are not to use option */
#define	DO	253		/* please, you use option */
#define	WONT	252		/* I won't use option */
#define	WILL	251		/* I will use option */
#define	SB	250		/* interpret as subnegotiation */
#define	GA	249		/* you may reverse the line */
#define	EL	248		/* erase the current line */
#define	EC	247		/* erase the current character */
#define	AYT	246		/* are you there */
#define	AO	245		/* abort output--but let prog finish */
#define	IP	244		/* interrupt process--permanently */
#define	BREAK	243		/* break */
#define	DM	242		/* data mark--for connect. cleaning */
#define	NOP	241		/* nop */
#define	SE	240		/* end sub negotiation */
#define	EOR	239		/* end of record (transparent mode) */
#define	ABORT	238		/* Abort process */
#define	SUSP	237		/* Suspend process */
#define	xEOF	236		/* End of file: EOF is already used... */

#define	SYNCH	242		/* for telfunc calls */

#ifdef TELCMDS
char *telcmds[] = {
	"EOF", "SUSP", "ABORT", "EOR",
	"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
	"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0
};
#endif

#define	TELCMD_FIRST	xEOF
#define	TELCMD_LAST	IAC
#define	TELCMD_OK(x)	((unsigned int)(x) <= TELCMD_LAST && \
			    (unsigned int)(x) >= TELCMD_FIRST)
#define	TELCMD(x)	telcmds[(x)-TELCMD_FIRST]

/* telnet options */
#define	TELOPT_BINARY	0	/* 8-bit data path */
#define	TELOPT_ECHO	1	/* echo */
#define	TELOPT_RCP	2	/* prepare to reconnect */
#define	TELOPT_SGA	3	/* suppress go ahead */
#define	TELOPT_NAMS	4	/* approximate message size */
#define	TELOPT_STATUS	5	/* give status */
#define	TELOPT_TM	6	/* timing mark */
#define	TELOPT_RCTE	7	/* remote controlled transmission and echo */
#define	TELOPT_NAOL	8	/* negotiate about output line width */
#define	TELOPT_NAOP	9	/* negotiate about output page size */
#define	TELOPT_NAOCRD	10	/* negotiate about CR disposition */
#define	TELOPT_NAOHTS	11	/* negotiate about horizontal tabstops */
#define	TELOPT_NAOHTD	12	/* negotiate about horizontal tab disposition */
#define	TELOPT_NAOFFD	13	/* negotiate about formfeed disposition */
#define	TELOPT_NAOVTS	14	/* negotiate about vertical tab stops */
#define	TELOPT_NAOVTD	15	/* negotiate about vertical tab disposition */
#define	TELOPT_NAOLFD	16	/* negotiate about output LF disposition */
#define	TELOPT_XASCII	17	/* extended ascic character set */
#define	TELOPT_LOGOUT	18	/* force logout */
#define	TELOPT_BM	19	/* byte macro */
#define	TELOPT_DET	20	/* data entry terminal */
#define	TELOPT_SUPDUP	21	/* supdup protocol */
#define	TELOPT_SUPDUPOUTPUT 22	/* supdup output */
#define	TELOPT_SNDLOC	23	/* send location */
#define	TELOPT_TTYPE	24	/* terminal type */
#define	TELOPT_EOR	25	/* end or record */
#define	TELOPT_TUID	26	/* TACACS user identification */
#define	TELOPT_OUTMRK	27	/* output marking */
#define	TELOPT_TTYLOC	28	/* terminal location number */
#define	TELOPT_3270REGIME 29	/* 3270 regime */
#define	TELOPT_X3PAD	30	/* X.3 PAD */
#define	TELOPT_NAWS	31	/* window size */
#define	TELOPT_TSPEED	32	/* terminal speed */
#define	TELOPT_LFLOW	33	/* remote flow control */
#define	TELOPT_LINEMODE	34	/* Linemode option */
#define	TELOPT_XDISPLOC	35	/* X Display Location */
#define	TELOPT_OLD_ENVIRON 36	/* Old - Environment variables */
#define	TELOPT_AUTHENTICATION 37 /* Authenticate */
#define	TELOPT_ENCRYPT	38	/* Encryption option */
#define	TELOPT_NEW_ENVIRON 39	/* New - Environment variables */
#define	TELOPT_EXOPL	255	/* extended-options-list */

#ifdef TELOPTS
#define	NTELOPTS	(1+TELOPT_NEW_ENVIRON)
char *telopts[NTELOPTS+1] = {
	"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
	"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
	"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
	"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
	"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
	"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
	"TACACS UID", "OUTPUT MARKING", "TTYLOC",
	"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
	"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
	"ENCRYPT", "NEW-ENVIRON",
	0,
};
#endif /* TELOPTS */
#define	TELOPT_FIRST	TELOPT_BINARY
#define	TELOPT_LAST	TELOPT_NEW_ENVIRON
#define	TELOPT_OK(x)	((unsigned int)(x) <= TELOPT_LAST)
#define	TELOPT(x)	telopts[(x)-TELOPT_FIRST]

/* sub-option qualifiers */
#define	TELQUAL_IS	0	/* option is... */
#define	TELQUAL_SEND	1	/* send option */
#define	TELQUAL_INFO	2	/* ENVIRON: informational version of IS */
#define	TELQUAL_REPLY	2	/* AUTHENTICATION: client version of IS */
#define	TELQUAL_NAME	3	/* AUTHENTICATION: client version of IS */

#define	LFLOW_OFF		0	/* Disable remote flow control */
#define	LFLOW_ON		1	/* Enable remote flow control */
#define	LFLOW_RESTART_ANY	2	/* Restart output on any char */
#define	LFLOW_RESTART_XON	3	/* Restart output only on XON */

/*
 * LINEMODE suboptions
 */

#define	LM_MODE		1
#define	LM_FORWARDMASK	2
#define	LM_SLC		3

#define	MODE_EDIT	0x01
#define	MODE_TRAPSIG	0x02
#define	MODE_ACK	0x04
#define	MODE_SOFT_TAB	0x08
#define	MODE_LIT_ECHO	0x10

#define	MODE_MASK	0x1f

/* Not part of protocol, but needed to simplify things... */
#define	MODE_FLOW		0x0100
#define	MODE_ECHO		0x0200
#define	MODE_INBIN		0x0400
#define	MODE_OUTBIN		0x0800
#define	MODE_FORCE		0x1000

#define	SLC_SYNCH	1
#define	SLC_BRK		2
#define	SLC_IP		3
#define	SLC_AO		4
#define	SLC_AYT		5
#define	SLC_EOR		6
#define	SLC_ABORT	7
#define	SLC_EOF		8
#define	SLC_SUSP	9
#define	SLC_EC		10
#define	SLC_EL		11
#define	SLC_EW		12
#define	SLC_RP		13
#define	SLC_LNEXT	14
#define	SLC_XON		15
#define	SLC_XOFF	16
#define	SLC_FORW1	17
#define	SLC_FORW2	18

#define	NSLC		18

/*
 * For backwards compatability, we define SLC_NAMES to be the
 * list of names if SLC_NAMES is not defined.
 */
#define	SLC_NAMELIST	"0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
			"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
			"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
#ifdef	SLC_NAMES
char *slc_names[] = {
	SLC_NAMELIST
};
#else
extern char *slc_names[];
#define	SLC_NAMES SLC_NAMELIST
#endif

#define	SLC_NAME_OK(x)	((unsigned int)(x) <= NSLC)
#define	SLC_NAME(x)	slc_names[x]

#define	SLC_NOSUPPORT	0
#define	SLC_CANTCHANGE	1
#define	SLC_VARIABLE	2
#define	SLC_DEFAULT	3
#define	SLC_LEVELBITS	0x03

#define	SLC_FUNC	0
#define	SLC_FLAGS	1
#define	SLC_VALUE	2

#define	SLC_ACK		0x80
#define	SLC_FLUSHIN	0x40
#define	SLC_FLUSHOUT	0x20

#define	OLD_ENV_VAR	1
#define	OLD_ENV_VALUE	0
#define	NEW_ENV_VAR	0
#define	NEW_ENV_VALUE	1
#define	ENV_ESC		2
#define	ENV_USERVAR	3

/*
 * AUTHENTICATION suboptions
 */
#define	AUTH_REJECT	0	/* Rejected */
#define	AUTH_UNKNOWN	1	/* We don't know who it is, but it's okay */
#define	AUTH_OTHER	2	/* We know it, but not its name */
#define	AUTH_USER	3	/* We know its name */
#define	AUTH_VALID	4	/* We know it, and it needs no password */

/*
 * Who is authenticating who ...
 */
#define	AUTH_WHO_CLIENT		0	/* Client authenticating server */
#define	AUTH_WHO_SERVER		1	/* Server authenticating client */
#define	AUTH_WHO_MASK		1

#ifdef	AUTHWHO_STR
char *authwho_str[] = {
	"CLIENT", "SERVER" };
#define	AUTHWHO_NAME(x)	authwho_str[x]
#endif /* AUTHWHO_STR */

/*
 * amount of authentication done
 */
#define	AUTH_HOW_ONE_WAY	0
#define	AUTH_HOW_MUTUAL		2
#define	AUTH_HOW_MASK		2

/*
 * should we be encrypting? (not yet formally standardized)
 */
#define	AUTH_ENCRYPT_OFF	0
#define	AUTH_ENCRYPT_ON		4
#define	AUTH_ENCRYPT_MASK	4

#define	AUTHTYPE_NULL		0
#define	AUTHTYPE_KERBEROS_V4	1	/* not supported */
#define	AUTHTYPE_KERBEROS_V5	2
#define	AUTHTYPE_CNT		3

#define	OPTS_FORWARD_CREDS		0x00000002
#define	OPTS_FORWARDABLE_CREDS		0x00000001

#ifdef AUTHTYPE_NAMES
char *authtype_names[] = {
	"NULL", "KERBEROS_V4", "KERBEROS_V5", 0,
};
#else
extern char *authtype_names[];
#endif /* AUTHTYPE_NAMES */

#define	AUTHTYPE_NAME(x)	authtype_names[x]
#define	AUTHTYPE_NAME_OK(x)	((unsigned int)(x) < AUTHTYPE_CNT)

#ifdef AUTHHOW_NAMES
char *authhow_names[] = {
	"ONE-WAY", "[undefined]", "MUTUAL" };
#endif /* AUTHHOW_NAMES */

#define	AUTHHOW_NAME(x)		authhow_names[x]

#define	KRB_AUTH		0	/* Authentication data follows */
#define	KRB_REJECT		1	/* Rejected (reason might follow) */
#define	KRB_ACCEPT		2	/* Accepted */
#define	KRB_RESPONSE		3	/* Response for mutual auth. */
#define	KRB_FORWARD		4	/* Forwarded credentials follow */
#define	KRB_FORWARD_ACCEPT	5	/* Forwarded credentials accepted */
#define	KRB_FORWARD_REJECT	6	/* Forwarded credentials rejected */

#ifdef AUTHRSP_NAMES
char *authrsp_names[] = {
	"AUTH", "REJECT", "ACCEPT", "RESPONSE", "FORWARD",
	"FORWARD_ACCEPT", "FORWARD_REJECT" };
#define	AUTHRSP_NAME(x)		authrsp_names[x]
#endif /* AUTHRSP_NAMES */

#define	AUTH_MODE_REQUIRE	0
#define	AUTH_MODE_PROMPT	1
#define	AUTH_MODE_WARN		2
#define	AUTH_MODE_REJECT	3


/*
 * Encryption suboptions. See RFC 2946.
 */
#define	ENCRYPT_IS		0	/* I pick encryption type ... */
#define	ENCRYPT_SUPPORT		1	/* I support encryption types ... */
#define	ENCRYPT_REPLY		2	/* Initial setup response */
#define	ENCRYPT_START		3	/* Starting encrypting output */
#define	ENCRYPT_END		4	/* End encrypting output */
#define	ENCRYPT_REQSTART	5	/* Request to start encrypting output */
#define	ENCRYPT_REQEND		6	/* Request to stop encrypting output */
#define	ENCRYPT_ENC_KEYID	7	/* Negotiate encryption key */
#define	ENCRYPT_DEC_KEYID	8	/* Negotiate decryption key */
#define	ENCRYPT_CNT		9	/* marks the maximum ENCRYPT value */

#define	TELOPT_ENCTYPE_NULL		0
#define	TELOPT_ENCTYPE_DES_CFB64	1 /* 64-bit Cipher Feedback Mode */
#define	TELOPT_ENCTYPE_CNT		2

#define	CFB64_IV	1
#define	CFB64_IV_OK	2
#define	CFB64_IV_BAD	3

#define	FB64_IV		CFB64_IV
#define	FB64_IV_OK	CFB64_IV_OK
#define	FB64_IV_BAD	CFB64_IV_BAD

#ifdef ENCRYPT_NAMES
char *encrypt_names[] = {
	"IS", "SUPPORT", "REPLY", "START", "END",
	"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
	0,
};

char *enctype_names[] = {
	"ANY", "DES_CFB64", 0,
};
#else
extern char *encrypt_names[];
extern char *enctype_names[];
#endif /* ENCRYPT_NAMES */

#define	ENCRYPT_NAME(x)		encrypt_names[x]
#define	ENCTYPE_NAME(x)		enctype_names[x]

#define	ENCRYPT_NAME_OK(x)	((unsigned int)(x) < ENCRYPT_CNT)
#define	ENCTYPE_NAME_OK(x)	((unsigned int)(x) < TELOPT_ENCTYPE_CNT)

#define	SK_DES	1 /* Matched Kerberos v5 ENCTYPE_DES */

#ifndef	DES_BLOCKSIZE
#define	DES_BLOCKSIZE  8
#endif	/* DES_BLOCKSIZE */

#define	TELNET_MAXNUMKEYS	64
#define	TELNET_MAXKEYIDLEN	16

#define	CFB 0

#define	ENCR_STATE_FAILED	-1
#define	ENCR_STATE_OK		0x00
#define	ENCR_STATE_NO_SEND_IV	0x01
#define	ENCR_STATE_NO_RECV_IV	0x02
#define	ENCR_STATE_NO_KEYID	0x04
#define	ENCR_STATE_NOT_READY	0x08
#define	ENCR_STATE_IN_PROGRESS \
	(ENCR_STATE_NO_SEND_IV|ENCR_STATE_NO_RECV_IV|ENCR_STATE_NO_KEYID)
#define	TELNET_DIR_ENCRYPT	0
#define	TELNET_DIR_DECRYPT	1

typedef unsigned char Block[DES_BLOCKSIZE];
typedef unsigned char *BlockT;
typedef struct { Block _; } Schedule[16];

typedef struct {
	short		type;
	int		length;
	unsigned char	*data;
} Session_Key;

typedef struct {
	unsigned char	need_start;
	unsigned char	autoflag;	/* automatically start operation */
	unsigned char	setup;
	unsigned char	type;
	unsigned int	state;
	unsigned char	keyid[TELNET_MAXNUMKEYS];
	int		keyidlen;
	Block		ivec;
	Block		krbdes_key;
} cipher_info_t;

typedef struct {
	cipher_info_t encrypt;
	cipher_info_t decrypt;
} telnet_enc_data_t;

/* A valid key has no "0" bytes */
#define	VALIDKEY(key)	(key[0] | key[1] | key[2] | key[3] | \
		key[4] | key[5] | key[6] | key[7])


#ifdef	__cplusplus
}
#endif

#endif	/* _ARPA_TELNET_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _ARPA_TFTP_H
#define	_ARPA_TFTP_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Trivial File Transfer Protocol (RFC 1350, RFC 2347)
 */
#define	SEGSIZE		512		/* data segment size */

/*
 * Packet types.
 */
#define	RRQ	01			/* read request */
#define	WRQ	02			/* write request */
#define	DATA	03			/* data packet */
#define	ACK	04			/* acknowledgement */
#define	ERROR	05			/* error code */
#define	OACK	06			/* option acknowledgement */

struct	tftphdr {
	short		th_opcode;	/* packet type */
	ushort_t	th_block;	/* block # */
	char		th_data[1];	/* data or error string */
};

#define	th_code		th_block	/* error code overlay on tu_block */
#define	th_stuff	th_block	/* ditto */

#define	th_msg		th_data

/*
 * Error codes.
 */
#define	EUNDEF		0		/* not defined */
#define	ENOTFOUND	1		/* file not found */
#define	EACCESS		2		/* access violation */
#define	ENOSPACE	3		/* disk full or allocation exceeded */
#define	EBADOP		4		/* illegal TFTP operation */
#define	EBADID		5		/* unknown transfer ID */
#define	EEXISTS		6		/* file already exists */
#define	ENOUSER		7		/* no such user */
#define	EOPTNEG		8		/* option negotiation error */

#ifdef	__cplusplus
}
#endif

#endif	/* _ARPA_TFTP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2016 Joyent, Inc.
 * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
 * Copyright 2023 Oxide Computer Company
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Note that the ANSI C Standard requires all headers to be idempotent except
 * <assert.h> which is explicitly required not to be idempotent (section 4.1.2).
 * We split up the idempotent sections into <iso/assert_iso.h> and leave the
 * rest of this that should be impacted by NDEBUG here. There is no header
 * guard.  This is intentional. For more information on the split, see
 * <iso/assert_iso.h>.
 */

#include <iso/assert_iso.h>

#undef	assert

#ifdef	NDEBUG

#define	assert(EX) ((void)0)

#else

#if (__cplusplus - 0 >= 201103L) || (__STDC_VERSION__ - 0 >= 199901L)
#define	assert(EX) (void)((EX) || \
	(__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
#else
#define	assert(EX) (void)((EX) || (__assert(#EX, __FILE__, __LINE__), 0))
#endif /* __cplusplus - 0 >= 201103L || __STDC_VERSION__ - 0 >= 199901L */

#endif	/* NDEBUG */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_ATOMIC_H
#define	_ATOMIC_H

#include <sys/atomic.h>

#endif	/* _ATOMIC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_ATTR_H
#define	_ATTR_H

#include <sys/types.h>
#include <sys/nvpair.h>
#include <sys/attr.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern int getattrat(int, xattr_view_t, const char *, nvlist_t **);
extern int fgetattr(int, xattr_view_t, nvlist_t **);
extern int setattrat(int, xattr_view_t, const char *, nvlist_t *);
extern int fsetattr(int, xattr_view_t, nvlist_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _ATTR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _AUDIO_AU_H
#define	_AUDIO_AU_H

#include <sys/isa_defs.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Define an on-disk audio file header for the AU file format.
 *
 * Note that there is an optional 'info' field that immediately follows this
 * structure in the file. It is an optional length field that is sometimes
 * used to store additional information. At the minimum, it is at
 * least 4 bytes.
 *
 * The offset field is problematic in the general case because the
 * field is really "data location", which does not ensure that all
 * the bytes between the header and the data are really 'info'.
 * Further, there are no absolute guarantees that the info is ASCII text.
 *
 * When audio files are passed through pipes, the au_data_size field may
 * not be known in advance.  In such cases, au_data_size should be
 * set to AUDIO_AU_UNKNOWN_SIZE.
 */

struct au_filehdr {
	uint32_t	au_magic;	/* magic number */
	uint32_t	au_offset;	/* size of this header */
	uint32_t	au_data_size;	/* length of data */
	uint32_t	au_encoding;	/* data encoding format */
	uint32_t	au_sample_rate;	/* samples per second */
	uint32_t	au_channels;	/* number of interleaved channels */
};
typedef struct au_filehdr au_filehdr_t;

	/*
	 *	This is the appearance of a typical AU audio file as described
	 *	by this structure.
	 *
	 *	------------------------------------------------------------
	 *	|			|		|		   |
	 *	|   AU Audio Header	|    Info	|   Audio Data	   |
	 *	|			| (optional)	|		   |
	 *	|			|		|		   |
	 *	|	24 bytes	| 4 bytes (min)	|    n bytes	   |
	 *	|			|		|		   |
	 *	------------------------------------------------------------
	 */

/* Define the magic number */
#define	AUDIO_AU_FILE_MAGIC	((uint32_t)0x2e736e64)	/* ".snd" */

/* Unknown header size */
#define	AUDIO_AU_UNKNOWN_SIZE	((unsigned)(~0))	/* (unsigned) -1 */

/* Define the AU encoding fields */
#define	AUDIO_AU_ENCODING_ULAW		(1)	/* 8-bit u-law */
#define	AUDIO_AU_ENCODING_LINEAR_8	(2)	/* 8-bit linear PCM */
#define	AUDIO_AU_ENCODING_LINEAR_16	(3)	/* 16-bit linear PCM */
#define	AUDIO_AU_ENCODING_LINEAR_24	(4)	/* 24-bit linear PCM */
#define	AUDIO_AU_ENCODING_LINEAR_32	(5)	/* 32-bit linear PCM */
#define	AUDIO_AU_ENCODING_FLOAT		(6)	/* 32-bit IEEE floating point */
#define	AUDIO_AU_ENCODING_DOUBLE	(7)	/* 64-bit IEEE double */
						/*   precision float */
#define	AUDIO_AU_ENCODING_FRAGMENTED	(8)	/* Fragmented sample data */
#define	AUDIO_AU_ENCODING_DSP		(10)	/* DSP program */
#define	AUDIO_AU_ENCODING_FIXED_8	(11)	/* 8-bit fixed point */
#define	AUDIO_AU_ENCODING_FIXED_16	(12)	/* 16-bit fixed point */
#define	AUDIO_AU_ENCODING_FIXED_24	(13)	/* 24-bit fixed point */
#define	AUDIO_AU_ENCODING_FIXED_32	(14)	/* 32-bit fixed point */
#define	AUDIO_AU_ENCODING_EMPHASIS	(18)	/* 16-bit linear with */
						/*   emphasis */
#define	AUDIO_AU_ENCODING_COMPRESSED	(19)	/* 16-bit linear compressed */
#define	AUDIO_AU_ENCODING_EMP_COMP	(20)	/* 16-bit linear with */
						/*   emphasis and compression */
#define	AUDIO_AU_ENCODING_MUSIC_KIT	(21)	/* Music kit DSP commands */
#define	AUDIO_AU_ENCODING_ADPCM_G721	(23)	/* 4-bit CCITT G.721 ADPCM */
#define	AUDIO_AU_ENCODING_ADPCM_G722	(24)	/* CCITT G.722 ADPCM */
#define	AUDIO_AU_ENCODING_ADPCM_G723_3	(25)	/* CCITT G.723.3 ADPCM */
#define	AUDIO_AU_ENCODING_ADPCM_G723_5	(26)	/* CCITT G.723.5 ADPCM */
#define	AUDIO_AU_ENCODING_ALAW		(27)	/* 8-bit A-law G.711 */


/* Byte swapping routines */
#if defined(_BIG_ENDIAN)
#define	AUDIO_AU_FILE2HOST(from, to)	*((long *)(to)) = *((long *)(from))
#else
#define	AUDIO_AU_FILE2HOST(from, to)					\
			    ((char *)(to))[0] = ((char *)(from))[3];	\
			    ((char *)(to))[1] = ((char *)(from))[2];	\
			    ((char *)(to))[2] = ((char *)(from))[1];	\
			    ((char *)(to))[3] = ((char *)(from))[0];
#endif /* byte swapping */

#if defined(__sparc) || defined(__i386) || defined(__amd64)
#define	AUDIO_AU_HOST2FILE(from, to)	AUDIO_AU_FILE2HOST((from), (to))
#else
#error unknown machine type;
#endif /* encode */

#ifdef	__cplusplus
}
#endif

#endif /* _AUDIO_AU_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1999 by Sun Microsystems, Inc. All rights reserved.
 */

#ifndef	_AUTH_ATTR_H
#define	_AUTH_ATTR_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <secdb.h>

/*
 * Some macros used internally by the nsswitch code
 */
#define	AUTH_MMAPLEN			1024
#define	AUTH_POLICY			"/etc/security/policy.conf"
#define	DEF_AUTH			"AUTHS_GRANTED="
#define	AUTHATTR_FILENAME		"/etc/security/auth_attr"
#define	AUTHATTR_DB_NAME		"auth_attr.org_dir"
#define	AUTHATTR_DB_NCOL		6	/* total columns */
#define	AUTHATTR_DB_NKEYCOL		1	/* total searchable columns */
#define	AUTHATTR_DB_TBLT		"auth_attr_tbl"
#define	AUTHATTR_NAME_DEFAULT_KW	"nobody"

#define	AUTHATTR_COL0_KW		"name"
#define	AUTHATTR_COL1_KW		"res1"
#define	AUTHATTR_COL2_KW		"res2"
#define	AUTHATTR_COL3_KW		"short_desc"
#define	AUTHATTR_COL4_KW		"long_desc"
#define	AUTHATTR_COL5_KW		"attr"

/*
 * indices of searchable columns
 */
#define	AUTHATTR_KEYCOL0		0	/* name */


/*
 * Key words used in the auth_attr database
 */
#define	AUTHATTR_HELP_KW		"help"

/*
 * Nsswitch internal representation of authorization attributes.
 */
typedef struct authstr_s {
	char   *name;		/* authorization name */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	char   *short_desc;	/* short description */
	char   *long_desc;	/* long description */
	char   *attr;		/* string of key-value pair attributes */
} authstr_t;

/*
 * API representation of authorization attributes.
 */
typedef struct authattr_s {
	char   *name;		/* authorization name */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	char   *short_desc;	/* short description */
	char   *long_desc;	/* long description */
	kva_t  *attr;		/* array of key-value pair attributes */
} authattr_t;

extern authattr_t *getauthnam(const char *);
extern authattr_t *getauthattr(void);
extern void setauthattr(void);
extern void endauthattr(void);
extern void free_authattr(authattr_t *);
extern int chkauthattr(const char *, const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _AUTH_ATTR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 * This is an internal header file. Not to be shipped.
 */

#ifndef	_AUTH_LIST_H
#define	_AUTH_LIST_H

#ifdef	__cplusplus
extern "C" {
#endif


/*
 * Names of authorizations currently in use in the system
 */

#define	AUTOCONF_READ_AUTH	"solaris.network.autoconf.read"
#define	AUTOCONF_SELECT_AUTH	"solaris.network.autoconf.select"
#define	AUTOCONF_WLAN_AUTH	"solaris.network.autoconf.wlan"
#define	AUTOCONF_WRITE_AUTH	"solaris.network.autoconf.write"
#define	CDRW_AUTH		"solaris.device.cdrw"
#define	CRONADMIN_AUTH		"solaris.jobs.admin"
#define	CRONUSER_AUTH		"solaris.jobs.user"
#define	DEFAULT_DEV_ALLOC_AUTH	"solaris.device.allocate"
#define	DEVICE_REVOKE_AUTH	"solaris.device.revoke"
#define	LINK_SEC_AUTH		"solaris.network.link.security"
#define	MAILQ_AUTH		"solaris.mail.mailq"
#define	NET_ILB_CONFIG_AUTH	"solaris.network.ilb.config"
#define	NET_ILB_ENABLE_AUTH	"solaris.network.ilb.enable"
#define	SET_DATE_AUTH		"solaris.system.date"
#define	WIFI_CONFIG_AUTH	"solaris.network.wifi.config"
#define	WIFI_WEP_AUTH		"solaris.network.wifi.wep"
#define	HP_MODIFY_AUTH		"solaris.hotplug.modify"

/*
 * The following authorizations can be qualified by appending <zonename>
 */
#define	ZONE_CLONEFROM_AUTH	"solaris.zone.clonefrom"
#define	ZONE_LOGIN_AUTH		"solaris.zone.login"
#define	ZONE_MANAGE_AUTH	"solaris.zone.manage"

#define	ZONE_AUTH_PREFIX	"solaris.zone."

/*
 * Authorizations used by Trusted Extensions.
 */
#define	DEVICE_CONFIG_AUTH	"solaris.device.config"
#define	FILE_CHOWN_AUTH		"solaris.file.chown"
#define	FILE_DOWNGRADE_SL_AUTH	"solaris.label.file.downgrade"
#define	FILE_OWNER_AUTH		"solaris.file.owner"
#define	FILE_UPGRADE_SL_AUTH	"solaris.label.file.upgrade"
#define	MAINTENANCE_AUTH	"solaris.system.maintenance"
#define	PRINT_ADMIN_AUTH	"solaris.print.admin"
#define	PRINT_CANCEL_AUTH	"solaris.print.cancel"
#define	PRINT_LIST_AUTH		"solaris.print.list"
#define	PRINT_MAC_AUTH		"solaris.label.print"
#define	PRINT_NOBANNER_AUTH	"solaris.print.nobanner"
#define	PRINT_POSTSCRIPT_AUTH	"solaris.print.ps"
#define	PRINT_UNLABELED_AUTH	"solaris.print.unlabeled"
#define	SHUTDOWN_AUTH		"solaris.system.shutdown"
#define	SYS_ACCRED_SET_AUTH	"solaris.label.range"
#define	SYSEVENT_READ_AUTH	"solaris.system.sysevent.read"
#define	SYSEVENT_WRITE_AUTH	"solaris.system.sysevent.write"

#ifdef	__cplusplus
}
#endif

#endif	/* _AUTH_LIST_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _COMPLEX_H
#define	_COMPLEX_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Compilation environments for Solaris must provide the _Imaginary datatype
 * and the compiler intrinsics _Complex_I and _Imaginary_I
 */
#if defined(__SUNPRO_C)
#define	_Complex_I	_Complex_I
#define	_Imaginary_I	_Imaginary_I
#else
#define	_Complex_I	1.0fi
#define	_Imaginary_I	1.0fi
#endif
#define	complex		_Complex
#define	imaginary	_Imaginary
#undef	I
#define	I		_Imaginary_I

extern float cabsf(float complex);
extern float cargf(float complex);
extern float cimagf(float complex);
extern float crealf(float complex);
extern float complex cacosf(float complex);
extern float complex cacoshf(float complex);
extern float complex casinf(float complex);
extern float complex casinhf(float complex);
extern float complex catanf(float complex);
extern float complex catanhf(float complex);
extern float complex ccosf(float complex);
extern float complex ccoshf(float complex);
extern float complex cexpf(float complex);
extern float complex clogf(float complex);
extern float complex conjf(float complex);
extern float complex cpowf(float complex, float complex);
extern float complex cprojf(float complex);
extern float complex csinf(float complex);
extern float complex csinhf(float complex);
extern float complex csqrtf(float complex);
extern float complex ctanf(float complex);
extern float complex ctanhf(float complex);

extern double cabs(double complex);
extern double carg(double complex);
extern double cimag(double complex);
extern double creal(double complex);
extern double complex cacos(double complex);
extern double complex cacosh(double complex);
extern double complex casin(double complex);
extern double complex casinh(double complex);
extern double complex catan(double complex);
extern double complex catanh(double complex);
extern double complex ccos(double complex);
extern double complex ccosh(double complex);
extern double complex cexp(double complex);
#if defined(__PRAGMA_REDEFINE_EXTNAME)
#pragma redefine_extname clog __clog
#else
#undef	clog
#define	clog	__clog
#endif
extern double complex clog(double complex);
extern double complex conj(double complex);
extern double complex cpow(double complex, double complex);
extern double complex cproj(double complex);
extern double complex csin(double complex);
extern double complex csinh(double complex);
extern double complex csqrt(double complex);
extern double complex ctan(double complex);
extern double complex ctanh(double complex);

extern long double cabsl(long double complex);
extern long double cargl(long double complex);
extern long double cimagl(long double complex);
extern long double creall(long double complex);
extern long double complex cacoshl(long double complex);
extern long double complex cacosl(long double complex);
extern long double complex casinhl(long double complex);
extern long double complex casinl(long double complex);
extern long double complex catanhl(long double complex);
extern long double complex catanl(long double complex);
extern long double complex ccoshl(long double complex);
extern long double complex ccosl(long double complex);
extern long double complex cexpl(long double complex);
extern long double complex clogl(long double complex);
extern long double complex conjl(long double complex);
extern long double complex cpowl(long double complex, long double complex);
extern long double complex cprojl(long double complex);
extern long double complex csinhl(long double complex);
extern long double complex csinl(long double complex);
extern long double complex csqrtl(long double complex);
extern long double complex ctanhl(long double complex);
extern long double complex ctanl(long double complex);

#ifdef	__cplusplus
}
#endif
#endif	/* _COMPLEX_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1998-2002 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SYS_CONFIG_ADMIN_H
#define	_SYS_CONFIG_ADMIN_H

/*
 * config_admin.h
 *
 * this file supports usage of the interfaces defined in
 * config_admin.3x. which are contained in /usr/lib/libcfgadm.so.1
 */

#include <sys/param.h>

#ifdef __cplusplus
extern "C" {
#endif


/*
 * Defined constants
 */
#define	CFGA_AP_LOG_ID_LEN	20
#define	CFGA_AP_PHYS_ID_LEN	MAXPATHLEN
#define	CFGA_INFO_LEN		4096
#define	CFGA_TYPE_LEN		12

#define	CFGA_CLASS_LEN		12
#define	CFGA_LOG_EXT_LEN	30

#define	CFGA_DYN_SEP		"::"
#define	CFGA_PHYS_EXT_LEN	(CFGA_AP_PHYS_ID_LEN + CFGA_LOG_EXT_LEN)


/*
 * Configuration change state commands
 */
typedef enum {
	CFGA_CMD_NONE = 0,
	CFGA_CMD_LOAD,
	CFGA_CMD_UNLOAD,
	CFGA_CMD_CONNECT,
	CFGA_CMD_DISCONNECT,
	CFGA_CMD_CONFIGURE,
	CFGA_CMD_UNCONFIGURE
} cfga_cmd_t;

/*
 * Configuration states
 */
typedef enum {
	CFGA_STAT_NONE = 0,
	CFGA_STAT_EMPTY,
	CFGA_STAT_DISCONNECTED,
	CFGA_STAT_CONNECTED,
	CFGA_STAT_UNCONFIGURED,
	CFGA_STAT_CONFIGURED
} cfga_stat_t;

/*
 * Configuration conditions
 */
typedef enum {
	CFGA_COND_UNKNOWN = 0,
	CFGA_COND_OK,
	CFGA_COND_FAILING,
	CFGA_COND_FAILED,
	CFGA_COND_UNUSABLE
} cfga_cond_t;

/*
 * Flags
 */
#define	CFGA_FLAG_FORCE		1
#define	CFGA_FLAG_VERBOSE	2
#define	CFGA_FLAG_LIST_ALL	4

typedef char cfga_ap_log_id_t[CFGA_AP_LOG_ID_LEN];
typedef char cfga_ap_phys_id_t[CFGA_AP_PHYS_ID_LEN];
typedef char cfga_info_t[CFGA_INFO_LEN];
typedef char cfga_type_t[CFGA_TYPE_LEN];
typedef int cfga_flags_t;
typedef int cfga_busy_t;


typedef char cfga_log_ext_t[CFGA_LOG_EXT_LEN];
typedef char cfga_phys_ext_t[CFGA_PHYS_EXT_LEN];
typedef char cfga_class_t[CFGA_CLASS_LEN];

typedef struct cfga_list_data {
	cfga_log_ext_t	ap_log_id;	/* Attachment point logical id */
	cfga_phys_ext_t	ap_phys_id;	/* Attachment point physical id */
	cfga_class_t	ap_class;	/* Attachment point class */
	cfga_stat_t	ap_r_state;	/* Receptacle state */
	cfga_stat_t	ap_o_state;	/* Occupant state */
	cfga_cond_t	ap_cond;	/* Attachment point condition */
	cfga_busy_t	ap_busy;	/* Busy indicators */
	time_t		ap_status_time;	/* Attachment point last change */
	cfga_info_t	ap_info;	/* Miscellaneous information */
	cfga_type_t	ap_type;	/* Occupant type */
} cfga_list_data_t;

/*
 * The following structure is retained for backward compatibility
 */
typedef struct cfga_stat_data {
	cfga_ap_log_id_t ap_log_id;	/* Attachment point logical id */
	cfga_ap_phys_id_t ap_phys_id;	/* Attachment point physical id */
	cfga_stat_t	ap_r_state;	/* Receptacle state */
	cfga_stat_t	ap_o_state;	/* Occupant state */
	cfga_cond_t	ap_cond;	/* Attachment point condition */
	cfga_busy_t	ap_busy;	/* Busy indicators */
	time_t		ap_status_time;	/* Attachment point last change */
	cfga_info_t	ap_info;	/* Miscellaneous information */
	cfga_type_t	ap_type;	/* Occupant type */
} cfga_stat_data_t;


struct cfga_confirm {
	int (*confirm)(void *appdata_ptr, const char *message);
	void *appdata_ptr;
};

struct cfga_msg {
	int (*message_routine)(void *appdata_ptr, const char *message);
	void *appdata_ptr;
};

/*
 * Library function error codes returned by all functions below
 * except config_strerror which is used to decode the error
 * codes.
 */
typedef enum {
	CFGA_OK = 0,
	CFGA_NACK,
	CFGA_NOTSUPP,
	CFGA_OPNOTSUPP,
	CFGA_PRIV,
	CFGA_BUSY,
	CFGA_SYSTEM_BUSY,
	CFGA_DATA_ERROR,
	CFGA_LIB_ERROR,
	CFGA_NO_LIB,
	CFGA_INSUFFICENT_CONDITION,
	CFGA_INVAL,
	CFGA_ERROR,
	CFGA_APID_NOEXIST,
	CFGA_ATTR_INVAL
} cfga_err_t;


/*
 * config_admin.3x library interfaces
 */

cfga_err_t config_change_state(cfga_cmd_t state_change_cmd, int num_ap_ids,
    char *const *ap_ids, const char *options, struct cfga_confirm *confp,
    struct cfga_msg *msgp, char **errstring, cfga_flags_t flags);

cfga_err_t config_private_func(const char *function, int num_ap_ids,
    char *const *ap_ids, const char *options, struct cfga_confirm *confp,
    struct cfga_msg *msgp, char **errstring, cfga_flags_t flags);

cfga_err_t config_test(int num_ap_ids, char *const *ap_ids,
    const char *options, struct cfga_msg *msgp, char **errstring,
    cfga_flags_t flags);

cfga_err_t config_list_ext(int num_ap_ids, char *const *ap_ids,
    struct cfga_list_data **ap_id_list, int *nlist, const char *options,
    const char *listopts, char **errstring, cfga_flags_t flags);

cfga_err_t config_help(int num_ap_ids, char *const *ap_ids,
    struct cfga_msg *msgp, const char *options, cfga_flags_t flags);

const char *config_strerror(cfga_err_t cfgerrnum);

int config_ap_id_cmp(const cfga_ap_log_id_t ap_id1,
    const cfga_ap_log_id_t ap_id2);

void config_unload_libs();

/*
 * The following two routines are retained only for backward compatibility
 */
cfga_err_t config_stat(int num_ap_ids, char *const *ap_ids,
    struct cfga_stat_data *buf, const char *options, char **errstring);

cfga_err_t config_list(struct cfga_stat_data **ap_di_list, int *nlist,
    const char *options, char **errstring);


#ifdef CFGA_PLUGIN_LIB
/*
 * Plugin library routine hooks - only to be used by the generic
 * library and plugin libraries (who must define CFGA_PLUGIN_LIB
 * prior to the inclusion of this header).
 */

cfga_err_t cfga_change_state(cfga_cmd_t, const char *, const char *,
    struct cfga_confirm *, struct cfga_msg *, char **, cfga_flags_t);
cfga_err_t cfga_private_func(const char *, const char *, const char *,
    struct cfga_confirm *, struct cfga_msg *, char **, cfga_flags_t);
cfga_err_t cfga_test(const char *, const char *, struct cfga_msg *,
    char **, cfga_flags_t);
cfga_err_t cfga_list_ext(const char *, struct cfga_list_data **, int *,
    const char *, const char *, char **, cfga_flags_t);
cfga_err_t cfga_help(struct cfga_msg *, const char *, cfga_flags_t);
int cfga_ap_id_cmp(const cfga_ap_log_id_t,
    const cfga_ap_log_id_t);


/*
 * Plugin version information.
 */
#define	CFGA_HSL_V1	1
#define	CFGA_HSL_V2	2
#define	CFGA_HSL_VERS	CFGA_HSL_V2

/*
 * The following two routines are retained only for backward compatibility.
 */
cfga_err_t cfga_stat(const char *, struct cfga_stat_data *,
    const char *, char **);
cfga_err_t cfga_list(const char *, struct cfga_stat_data **, int *,
    const char *, char **);


#endif /* CFGA_PLUGIN_LIB */

#ifdef __cplusplus
}
#endif

#endif /* _SYS_CONFIG_ADMIN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _CPIO_H
#define	_CPIO_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The following are values used by c_mode field of the cpio archive.
 */

#define	C_IRUSR		0000400
#define	C_IWUSR		0000200
#define	C_IXUSR		0000100
#define	C_IRGRP		0000040
#define	C_IWGRP		0000020
#define	C_IXGRP		0000010
#define	C_IROTH		0000004
#define	C_IWOTH		0000002
#define	C_IXOTH		0000001
#define	C_ISUID		0004000
#define	C_ISGID		0002000
#define	C_ISVTX		0001000
#define	C_ISDIR		0040000
#define	C_ISFIFO	0010000
#define	C_ISREG		0100000
#define	C_ISBLK		0060000
#define	C_ISCHR		0020000
#define	C_ISCTG		0110000
#define	C_ISLNK		0120000
#define	C_ISSOCK	0140000

#define	MAGIC		"070707"

#ifdef	__cplusplus
}
#endif

#endif	/* _CPIO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_CRYPT_H
#define	_CRYPT_H

#include <pwd.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Password and file encryption functions */

#define	CRYPT_MAXCIPHERTEXTLEN	512

extern char *crypt(const char *, const char *);
extern char *crypt_gensalt(const char *, const struct passwd *);
extern char *crypt_genhash_impl(char *, size_t, const char *,
    const char *, const char **);
extern char *crypt_gensalt_impl(char *, size_t, const char *,
    const struct passwd *, const char **);
extern int crypt_close(int *);
extern char *des_crypt(const char *, const char *);
extern void des_encrypt(char *, int);
extern void des_setkey(const char *);
extern void encrypt(char *, int);
extern int run_crypt(long, char *, unsigned, int *);
extern int run_setkey(int *, const char *);
extern void setkey(const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _CRYPT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _CTYPE_H
#define	_CTYPE_H

#include <iso/ctype_iso.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/ctype_iso.h>.
 */
#if __cplusplus >= 199711L
using std::isalnum;
using std::isalpha;
using std::iscntrl;
using std::isdigit;
using std::isgraph;
using std::islower;
using std::isprint;
using std::ispunct;
using std::isspace;
using std::isupper;
using std::isxdigit;
using std::tolower;
using std::toupper;
#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \
	!defined(_STRICT_SYMBOLS)
using std::isblank;
#endif
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || \
	((!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XOPEN_SOURCE))

extern int isascii(int);
extern int toascii(int);
extern int _tolower(int);
extern int _toupper(int);

#endif /* defined(__EXTENSIONS__) || ((!defined(_STRICT_STDC) ... */

#if !defined(__lint)

#if defined(__EXTENSIONS__) || \
	((!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XOPEN_SOURCE)) || defined(__XPG4_CHAR_CLASS__)
#define	isascii(c)	(!(((int)(c)) & ~0177))
#define	toascii(c)	(((int)(c)) & 0177)
#define	_toupper(c)	(toupper(c))
#define	_tolower(c)	(tolower(c))

#endif /* defined(__EXTENSIONS__) || ((!defined(_STRICT_STDC) ... */

#endif	/* !defined(__lint) */

#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)

#ifndef _LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern int isalnum_l(int, locale_t);
extern int isalpha_l(int, locale_t);
extern int isblank_l(int, locale_t);
extern int iscntrl_l(int, locale_t);
extern int isdigit_l(int, locale_t);
extern int isgraph_l(int, locale_t);
extern int islower_l(int, locale_t);
extern int isprint_l(int, locale_t);
extern int ispunct_l(int, locale_t);
extern int isspace_l(int, locale_t);
extern int isupper_l(int, locale_t);
extern int isxdigit_l(int, locale_t);
extern int tolower_l(int, locale_t);
extern int toupper_l(int, locale_t);

#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */

#ifdef	__cplusplus
}
#endif

#endif	/* _CTYPE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*	Copyright (c) 1987, 1988 Microsoft Corporation	*/
/*	  All Rights Reserved	*/

#ifndef	_DEFLT_H
#define	_DEFLT_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	DEFLT	"/etc/default"

/*
 * Following for defcntl(3).
 * If you add new args, make sure that the default is:
 *	OFF	new-improved-feature-off, i.e. current state of affairs
 *	ON	new-improved-feature-on
 * or that you change the code for deflt(3) to have the old value as the
 * default.  (for compatibility).
 */

/* ... cmds */
#define	DC_GETFLAGS	0	/* get current flags */
#define	DC_SETFLAGS	1	/* set flags */

/* ... args */
#define	DC_CASE		0001	/* ON: respect case; OFF: ignore case */
#define	DC_NOREWIND	0002	/* ON: don't rewind in defread */
				/* OFF: do rewind in defread */
#define	DC_STRIP_QUOTES	0004	/* ON: strip quotes; OFF: leave quotes */

#define	DC_STD		((0) | (DC_CASE))

extern int defcntl(int, int);
extern int defopen(char *);
extern char *defread(char *);

extern int	defcntl_r(int, int, void *);
extern void	*defopen_r(const char *);
extern char	*defread_r(const char *, void *);
extern void	defclose_r(void *);

#define	TURNON(flags, mask)	((flags) |= (mask))
#define	TURNOFF(flags, mask)	((flags) &= ~(mask))
#define	ISON(flags, mask)	(((flags) & (mask)) == (mask))
#define	ISOFF(flags, mask)	(((flags) & (mask)) != (mask))

#ifdef	__cplusplus
}
#endif

#endif	/* _DEFLT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2017 Nexenta Systems, Inc.
 */

#ifndef	_DEVID_H
#define	_DEVID_H

#ifndef	_KERNEL
#include <sys/types.h>
#endif	/* _KERNEL */

#include <sys/sunddi.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct devid_nmlist {
	char	*devname;
	dev_t	dev;
} devid_nmlist_t;

extern int	devid_get(int fd, ddi_devid_t *retdevid);
extern void	devid_free(ddi_devid_t devid);
extern int	devid_get_minor_name(int fd, char **retminor_name);
extern size_t	devid_sizeof(ddi_devid_t devid);
extern int	devid_compare(ddi_devid_t devid1, ddi_devid_t devid2);
extern int	devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid,
		    char *minor_name, devid_nmlist_t **retlist);
extern void	devid_free_nmlist(devid_nmlist_t *list);
extern int	devid_valid(ddi_devid_t devid);
extern char	*devid_str_encode(ddi_devid_t devid, char *minor_name);
extern int	devid_str_decode(char *devidstr,
		    ddi_devid_t *retdevid, char **retminor_name);
extern void	devid_str_free(char *devidstr);
extern char	*devid_str_from_path(const char *path);

#ifdef	__cplusplus
}
#endif

#endif	/* _DEVID_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_DEVMGMT_H
#define	_DEVMGMT_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * devmgmt.h
 *
 * Contents:
 *    -	Device Management definitions,
 *    -	getvol() definitions
 */

/*
 * Device management definitions
 *	- Default pathnames (relative to installation point)
 *	- Environment variable namess
 *	- Standard field names in the device table
 *	- Flags
 *	- Miscellaneous definitions
 */


/*
 * Default pathnames (relative to the package installation
 * point) to the files used by Device Management:
 *
 *	DTAB_PATH	Device table
 *	DGRP_PATH	Device group table
 *	DVLK_PATH	Device reservation table
 */

#define	DTAB_PATH			"/etc/device.tab"
#define	DGRP_PATH			"/etc/dgroup.tab"
#define	DVLK_PATH			"/etc/devlkfile"


/*
 * Names of environment variables
 *
 *	OAM_DEVTAB	Name of variable that defines the pathname to
 *			the device-table file
 *	OAM_DGROUP	Name of variable that defines the pathname to
 *			the device-group table file
 *	OAM_DEVLKTAB	Name of variable that defines the pathname to
 *			the device-reservation table file
 */

#define	OAM_DEVTAB			"OAM_DEVTAB"
#define	OAM_DGROUP			"OAM_DGROUP"
#define	OAM_DEVLKTAB			"OAM_DEVLKTAB"


/*
 * Standard field names in the device table
 */

#define	DTAB_ALIAS			"alias"
#define	DTAB_CDEVICE			"cdevice"
#define	DTAB_BDEVICE			"bdevice"
#define	DTAB_PATHNAME			"pathname"


/*
 * Flags:
 *	For getdev() and getdgrp():
 *		DTAB_ANDCRITERIA	Devices must meet all criteria
 *					instead of any of the criteria
 *		DTAB_EXCLUDEFLAG	The list of devices or device groups
 *					is the list that is to be excluded,
 *					not those to select from.
 *		DTAB_LISTALL		List all device groups, even those that
 *					have no valid members (getdgrp() only).
 */

#define	DTAB_ANDCRITERIA		0x01
#define	DTAB_EXCLUDEFLAG		0x02
#define	DTAB_LISTALL			0x04


/*
 * Miscellaneous Definitions
 *
 *	DTAB_MXALIASLN	Maximum alias length
 */

#define	DTAB_MXALIASLN			14

/*
 * Device Management Structure definitions
 *	reservdev	Reserved device description
 */

/*
 * struct reservdev
 *
 *	Structure describes a reserved device.
 *
 *  Elements:
 *	char   *devname		Alias of the reserved device
 *	pid_t	key		Key used to reserve the device
 */

struct reservdev {
	char   *devname;
	pid_t	key;
};

/*
 * Device Management Functions:
 *
 *	devattr()	Returns a device's attribute
 *	devreserv()	Reserves a device
 *	devfree()	Frees a reserved device
 *	reservdev()	Return list of reserved devices
 *	getdev()	Get devices that match criteria
 *	getdgrp()	Get device-groups containing devices
 *			that match criteria
 *	listdev()	List attributes defined for a device
 *	listdgrp()	List members of a device-group
 */

	char			*devattr(char *, char *);
	int			devfree(int, char *);
	char			**devreserv(int, char ***);
	char			**getdev(char **, char **, int);
	char			**getdgrp(char **, char **, int);
	char			**listdev(char *);
	char			**listdgrp(char *);
	struct reservdev	**reservdev(void);

/*
 * getvol() definitions
 */

#define	DM_BATCH	0x0001
#define	DM_ELABEL	0x0002
#define	DM_FORMAT	0x0004
#define	DM_FORMFS	0x0008
#define	DM_WLABEL	0x0010
#define	DM_OLABEL	0x0020

	int			getvol(char *, char *, int, char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _DEVMGMT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_DEVPOLL_H
#define	_DEVPOLL_H

#include <sys/devpoll.h>

#endif	/* _DEVPOLL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _DIAL_H
#define	_DIAL_H

#ifndef IUCLC
#include <sys/termio.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/* uucico routines need these */
#define	DIAL

/* The following are no longer used by dial() and may be out of date.	*/
/* They are included here only to maintain source compatibility.	*/
#define	STANDALONE
#define	DEVDIR	"/dev/"				/* device path		*/
#define	LOCK	"/usr/spool/uucp/LCK.."		/* lock file semaphore	*/
#define	DVC_LEN	80	/* max NO of chars in TTY-device path name	*/
/* End of unused definitions						*/

		/* error mnemonics */

#define	TRUE	1
#define	FALSE	0
#define	INTRPT	(-1)	/* interrupt occured */
#define	D_HUNG	(-2)	/* dialer hung (no return from write) */
#define	NO_ANS	(-3)	/* no answer (caller script failed) */
#define	ILL_BD	(-4)	/* illegal baud-rate */
#define	A_PROB	(-5)	/* acu problem (open() failure) */
#define	L_PROB	(-6)	/* line problem (open() failure) */
#define	NO_Ldv	(-7)	/* can't open Devices file */
#define	DV_NT_A	(-8)	/* requested device not available */
#define	DV_NT_K	(-9)	/* requested device not known */
#define	NO_BD_A	(-10)	/* no device available at requested baud */
#define	NO_BD_K	(-11)	/* no device known at requested baud */
#define	DV_NT_E (-12)	/* requested speed does not match */
#define	BAD_SYS (-13)	/* system not in Systems file */

typedef struct {
	struct termio *attr;	/* ptr to termio attribute struct */
	int	baud;		/* unused */
	int	speed;		/* 212A modem: low=300, high=1200 */
	char	*line;		/* device name for out-going line */
	char	*telno;		/* ptr to tel-no/system name string */
	int	modem;		/* unused */
	char	*device;	/* unused */
	int	dev_len;	/* unused */
} CALL;

extern int dial(CALL);
extern void undial(int);

#ifdef	__cplusplus
}
#endif

#endif	/* _DIAL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _DIRENT_H
#define	_DIRENT_H

#include <sys/feature_tests.h>

#include <sys/types.h>
#include <sys/dirent.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)

#define	MAXNAMLEN	512		/* maximum filename length */
#define	DIRBUF		8192		/* buffer size for fs-indep. dirs */

#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */

#if !defined(__XOPEN_OR_POSIX)

typedef struct {
	int	dd_fd;		/* file descriptor */
	int	dd_loc;		/* offset in block */
	int	dd_size;	/* amount of valid data */
	char	*dd_buf;	/* directory block */
} DIR;				/* stream data from opendir() */


#else

typedef struct {
	int	d_fd;		/* file descriptor */
	int	d_loc;		/* offset in block */
	int	d_size;		/* amount of valid data */
	char	*d_buf;		/* directory block */
} DIR;				/* stream data from opendir() */

#endif /* !defined(__XOPEN_OR_POSIX) */

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	readdir	readdir64
#pragma	redefine_extname	scandir	scandir64
#pragma	redefine_extname	alphasort alphasort64
#else
#define	readdir			readdir64
#define	scandir			scandir64
#define	alphasort		alphasort64
#endif
#endif	/* _FILE_OFFSET_BITS == 64 */

/* In the LP64 compilation environment, all APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	readdir64	readdir
#pragma	redefine_extname	scandir64	scandir
#pragma	redefine_extname	alphasort64	alphasort
#else
#define	readdir64		readdir
#define	scandir64		scandir
#define	alphsort64		alphasort
#endif
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

extern DIR		*opendir(const char *);
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
extern DIR		*fdopendir(int);
extern int		dirfd(DIR *);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
extern int		scandir(const char *, struct dirent *(*[]),
				int (*)(const struct dirent *),
				int (*)(const struct dirent **,
					const struct dirent **));
extern int		alphasort(const struct dirent **,
					const struct dirent **);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
extern struct dirent	*readdir(DIR *);
#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
	defined(_XOPEN_SOURCE)
extern long		telldir(DIR *);
extern void		seekdir(DIR *, long);
#endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
extern void		rewinddir(DIR *);
extern int		closedir(DIR *);

/* transitional large file interface */
#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern struct dirent64	*readdir64(DIR *);
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
extern int	scandir64(const char *, struct dirent64 *(*[]),
			int (*)(const struct dirent64 *),
			int (*)(const struct dirent64 **,
				const struct dirent64 **));
extern int	alphasort64(const struct dirent64 **, const struct dirent64 **);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
#endif

#if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
	defined(_XOPEN_SOURCE)
#define	rewinddir(dirp)	seekdir(dirp, 0L)
#endif

/*
 * readdir_r() prototype is defined here.
 *
 * There are several variations, depending on whether compatibility with old
 * POSIX draft specifications or the final specification is desired and on
 * whether the large file compilation environment is active.  To combat a
 * combinatorial explosion, enabling large files implies using the final
 * specification (since the definition of the large file environment
 * considerably postdates that of the final readdir_r specification).
 *
 * In the LP64 compilation environment, all APIs are already large file,
 * and since there are no 64-bit applications that can have seen the
 * draft implementation, again, we use the final POSIX specification.
 */

#if	defined(__EXTENSIONS__) || defined(_REENTRANT) || \
	!defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
	defined(_POSIX_PTHREAD_SEMANTICS)

#if	!defined(_LP64) && _FILE_OFFSET_BITS == 32

#if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname readdir_r	__posix_readdir_r
extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD,
		struct dirent **_RESTRICT_KYWD);
#else	/* __PRAGMA_REDEFINE_EXTNAME */

extern int __posix_readdir_r(DIR *_RESTRICT_KYWD,
    struct dirent *_RESTRICT_KYWD, struct dirent **_RESTRICT_KYWD);

#ifdef	__lint
#define	readdir_r	__posix_readdir_r
#else	/* !__lint */

static int
readdir_r(DIR *_RESTRICT_KYWD __dp, struct dirent *_RESTRICT_KYWD __ent,
    struct dirent **_RESTRICT_KYWD __res)
{
	return (__posix_readdir_r(__dp, __ent, __res));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

extern struct dirent *readdir_r(DIR *__dp, struct dirent *__ent);

#endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#else	/* !_LP64 && _FILE_OFFSET_BITS == 32 */

#if defined(_LP64)
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname readdir64_r	readdir_r
#else
#define	readdir64_r		readdir_r
#endif
#else	/* _LP64 */
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname readdir_r	readdir64_r
#else
#define	readdir_r		readdir64_r
#endif
#endif	/* _LP64 */
extern int readdir_r(DIR *_RESTRICT_KYWD, struct dirent *_RESTRICT_KYWD,
	struct dirent **_RESTRICT_KYWD);

#endif	/* !_LP64 && _FILE_OFFSET_BITS == 32 */

#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
/* transitional large file interface */
extern int readdir64_r(DIR *_RESTRICT_KYWD, struct dirent64 *_RESTRICT_KYWD,
	struct dirent64 **_RESTRICT_KYWD);
#endif

#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */

#ifdef	__cplusplus
}
#endif

#endif	/* _DIRENT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 *	Copyright (c) 1989 AT&T
 *	  All Rights Reserved
 *
 */

#ifndef _DLFCN_H
#define	_DLFCN_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
#include <sys/auxv.h>
#include <sys/mman.h>
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Information structures for various dlinfo() requests.
 */
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
typedef struct	dl_info {
	const char	*dli_fname;	/* file containing address range */
	void		*dli_fbase;	/* base address of file image */
	const char	*dli_sname;	/* symbol name */
	void		*dli_saddr;	/* symbol address */
} Dl_info;
typedef	Dl_info		Dl_info_t;

typedef struct	dl_serpath {
	char		*dls_name;	/* library search path name */
	uint_t		dls_flags;	/* path information */
} Dl_serpath;
typedef	Dl_serpath	Dl_serpath_t;

typedef struct	dl_serinfo {
	size_t		dls_size;	/* total buffer size */
	uint_t		dls_cnt;	/* number of path entries */
	Dl_serpath	dls_serpath[1];	/* there may be more than one */
} Dl_serinfo;
typedef	Dl_serinfo	Dl_serinfo_t;

typedef struct	dl_argsinfo {
	long		dla_argc;	/* process argument count */
	char		**dla_argv;	/* process arguments */
	char		**dla_envp;	/* process environment variables */
	auxv_t		*dla_auxv;	/* process auxv vectors */
} Dl_argsinfo;
typedef	Dl_argsinfo	Dl_argsinfo_t;

typedef struct {
	mmapobj_result_t *dlm_maps;	/* mapping information */
	uint_t		dlm_acnt;	/* number of dlm_maps mappings */
	uint_t		dlm_rcnt;	/* number of returned mappings */
} Dl_mapinfo_t;

typedef struct {
	uint_t		dlui_version;	/* version # */
	uint_t		dlui_flags;	/* flags */
	char		*dlui_objname;	/* path to object */
	void		*dlui_unwindstart; /* star of unwind hdr */
	void		*dlui_unwindend; /* end of unwind hdr */
	void		*dlui_segstart;	/* start of segment described */
					/*  by unwind block */
	void		*dlui_segend;	/* end of segment described */
					/*  by unwind block */
} Dl_amd64_unwindinfo;
typedef	Dl_amd64_unwindinfo	Dl_amd64_unwindinfo_t;

typedef	struct {
	const char	*dld_refname;	/* reference name */
	const char	*dld_depname;	/* new dependency name */
} Dl_definfo_t;

#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */


typedef ulong_t		Lmid_t;

/*
 * Declarations used for dynamic linking support routines.
 */
extern void	*dlopen(const char *, int);
extern void	*dlsym(void *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern int	dlclose(void *);
extern char	*dlerror(void);
#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
extern void	*dlmopen(Lmid_t, const char *, int);
extern int	dladdr(void *, Dl_info *);
extern int	dladdr1(void *, Dl_info *, void **, int);
extern int	dldump(const char *, const char *, int);
extern int	dlinfo(void *, int, void *);
extern Dl_amd64_unwindinfo  *dlamd64getunwind(void *, Dl_amd64_unwindinfo *);
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */

/*
 * Valid values for handle argument to dlsym(3C).
 */
#define	RTLD_NEXT		(void *)-1	/* look in `next' dependency */
#define	RTLD_DEFAULT		(void *)-2	/* look up symbol from scope */
						/*	of current object */
#define	RTLD_SELF		(void *)-3	/* look in `ourself' */
#define	RTLD_PROBE		(void *)-4	/* look up symbol from scope */
						/*	of current object, */
						/*	using currently */
						/*	loaded objects only. */
/*
 * Valid values for mode argument to dlopen.
 */
#define	RTLD_LAZY		0x00001		/* deferred function binding */
#define	RTLD_NOW		0x00002		/* immediate function binding */
#define	RTLD_NOLOAD		0x00004		/* don't load object */

#define	RTLD_GLOBAL		0x00100		/* export symbols to others */
#define	RTLD_LOCAL		0x00000		/* symbols are only available */
						/*	to group members */
#define	RTLD_PARENT		0x00200		/* add parent (caller) to */
						/*	a group dependencies */
#define	RTLD_GROUP		0x00400		/* resolve symbols within */
						/*	members of the group */
#define	RTLD_WORLD		0x00800		/* resolve symbols within */
						/*	global objects */
#define	RTLD_NODELETE		0x01000		/* do not remove members */
#define	RTLD_FIRST		0x02000		/* only first object is */
						/*	available for dlsym */
#define	RTLD_CONFGEN		0x10000		/* crle(1) config generation */
						/*	internal use only */

/*
 * Valid values for flag argument to dldump.
 */
#define	RTLD_REL_RELATIVE	0x00001		/* apply relative relocs */
#define	RTLD_REL_EXEC		0x00002		/* apply symbolic relocs that */
						/*	bind to main */
#define	RTLD_REL_DEPENDS	0x00004		/* apply symbolic relocs that */
						/*	bind to dependencies */
#define	RTLD_REL_PRELOAD	0x00008		/* apply symbolic relocs that */
						/*	bind to preload objs */
#define	RTLD_REL_SELF		0x00010		/* apply symbolic relocs that */
						/*	bind to ourself */
#define	RTLD_REL_WEAK		0x00020		/* apply symbolic weak relocs */
						/*	even if unresolved */
#define	RTLD_REL_ALL		0x00fff		/* apply all relocs */

#define	RTLD_MEMORY		0x01000		/* use memory sections */
#define	RTLD_STRIP		0x02000		/* retain allocable sections */
						/*	only */
#define	RTLD_NOHEAP		0x04000		/* do no save any heap */
#define	RTLD_CONFSET		0x10000		/* crle(1) config generation */
						/*	internal use only */

/*
 * Valid values for dladdr1() flags.
 */
#define	RTLD_DL_SYMENT		1		/* return symbol table entry */
#define	RTLD_DL_LINKMAP		2		/* return public link-map */
#define	RTLD_DL_MASK		0xffff


/*
 * Arguments for dlinfo()
 */
#define	RTLD_DI_LMID		1		/* obtain link-map id */
#define	RTLD_DI_LINKMAP		2		/* obtain link-map */
#define	RTLD_DI_CONFIGADDR	3		/* obtain config addr */
#define	RTLD_DI_SERINFO		4		/* obtain search path info or */
#define	RTLD_DI_SERINFOSIZE	5		/*    associated info size */
#define	RTLD_DI_ORIGIN		6		/* obtain objects origin */
#define	RTLD_DI_PROFILENAME	7		/* obtain profile object name */
						/*    internal use only */
#define	RTLD_DI_PROFILEOUT	8		/* obtain profile output name */
						/*    internal use only */
#define	RTLD_DI_GETSIGNAL	9		/* get termination signal */
#define	RTLD_DI_SETSIGNAL	10		/* set termination signal */
#define	RTLD_DI_ARGSINFO	11		/* get process arguments */
						/*    environment and auxv */
#define	RTLD_DI_MMAPS		12		/* obtain objects mappings or */
#define	RTLD_DI_MMAPCNT		13		/*    mapping count */
#define	RTLD_DI_DEFERRED	14		/* assign new dependency to a */
						/*    deferred dependency */
#define	RTLD_DI_DEFERRED_SYM	15		/* assign new dependency to a */
						/*    deferred dependency */
						/*    using a symbol name */
#define	RTLD_DI_MAX		15

#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
/*
 * Version information for Dl_amd64_unwindinfo.dlui_version
 */
#define	DLUI_VERS_1		1
#define	DLUI_VERS_CURRENT	DLUI_VERS_1

/*
 * Valid flags for Dl_amd64_unwindinfo.dlfi_flags
 */
#define	DLUI_FLG_NOUNWIND	0x0001		/* object has no Unwind info */
#define	DLUI_FLG_NOOBJ		0x0002		/* no object was found */
						/*  matching the pc provided */
#endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _DLFCN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_DOOR_H
#define	_DOOR_H

#include <sys/types.h>
#include <sys/door.h>
#include <ucred.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASM

/*
 * Doors API
 */

typedef void door_server_procedure_t(void *, char *, size_t, door_desc_t *,
    uint_t);

int	door_create(door_server_procedure_t *, void *, uint_t);
int	door_revoke(int);
int	door_info(int, door_info_t *);
int	door_call(int, door_arg_t *);
int	door_return(char *, size_t, door_desc_t *, uint_t);
int	door_cred(door_cred_t *);
int	door_ucred(ucred_t **);
int	door_bind(int);
int	door_unbind(void);
int	door_getparam(int, int, size_t *);
int	door_setparam(int, int, size_t);

typedef void door_server_func_t(door_info_t *);
door_server_func_t *door_server_create(door_server_func_t *);

typedef int door_xcreate_server_func_t(door_info_t *,
    void *(*)(void *), void *, void *);
typedef void door_xcreate_thrsetup_func_t(void *);

int	door_xcreate(door_server_procedure_t *, void *, uint_t,
	    door_xcreate_server_func_t *, door_xcreate_thrsetup_func_t *,
	    void *, int);

#endif /* _ASM */

#ifdef __cplusplus
}
#endif

#endif	/* _DOOR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _ELF_H
#define	_ELF_H

#include <sys/elf.h>

#endif	/* _ELF_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2016 Joyent, Inc.
 */

#ifndef _ENDIAN_H
#define	_ENDIAN_H

/*
 * Endian conversion routines, see endian(3C)
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/isa_defs.h>
#include <inttypes.h>

#define	__LITTLE_ENDIAN	1234
#define	__BIG_ENDIAN	4321
#define	__PDP_ENDIAN	3412

#if	defined(_LITTLE_ENDIAN)
#define	__BYTE_ORDER	LITTLE_ENDIAN
#elif	defined(_BIG_ENDIAN)
#define	__BYTE_ORDER	BIG_ENDIAN
#else
#error	"Unknown byte order"
#endif	/* _LITTLE_ENDIAN */

#define	LITTLE_ENDIAN	__LITTLE_ENDIAN
#define	BIG_ENDIAN	__BIG_ENDIAN
#define	BYTE_ORDER	__BYTE_ORDER

extern uint16_t htobe16(uint16_t);
extern uint32_t htobe32(uint32_t);
extern uint64_t htobe64(uint64_t);

extern uint16_t htole16(uint16_t);
extern uint32_t htole32(uint32_t);
extern uint64_t htole64(uint64_t);

/* Supply both the old and new BSD names */
extern uint16_t betoh16(uint16_t);
extern uint16_t letoh16(uint16_t);
extern uint16_t be16toh(uint16_t);
extern uint16_t le16toh(uint16_t);

extern uint32_t betoh32(uint32_t);
extern uint32_t letoh32(uint32_t);
extern uint32_t be32toh(uint32_t);
extern uint32_t le32toh(uint32_t);

extern uint64_t betoh64(uint64_t);
extern uint64_t letoh64(uint64_t);
extern uint64_t be64toh(uint64_t);
extern uint64_t le64toh(uint64_t);

#ifdef __cplusplus
}
#endif

#endif /* _ENDIAN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
 */

#ifndef	_ERR_H
#define	_ERR_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdarg.h>
#include <sys/ccompile.h>

/* Program exit and warning calls */
void err(int, const char *, ...) __PRINTFLIKE(2) __NORETURN;
void verr(int, const char *, va_list) __VPRINTFLIKE(2) __NORETURN;
void errc(int, int, const char *, ...) __PRINTFLIKE(3) __NORETURN;
void verrc(int, int, const char *, va_list) __VPRINTFLIKE(3) __NORETURN;
void errx(int, const char *, ...) __PRINTFLIKE(2) __NORETURN;
void verrx(int, const char *, va_list) __VPRINTFLIKE(2) __NORETURN;
void warn(const char *, ...) __PRINTFLIKE(1);
void vwarn(const char *, va_list) __VPRINTFLIKE(1);
void warnc(int, const char *, ...) __PRINTFLIKE(2);
void vwarnc(int, const char *, va_list) __VPRINTFLIKE(2);
void warnx(const char *, ...) __PRINTFLIKE(1);
void vwarnx(const char *, va_list) __VPRINTFLIKE(1);

#ifdef __cplusplus
}
#endif

#endif	/* _ERR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */


#ifndef _ERRNO_H
#define	_ERRNO_H

/*
 * Error codes
 */

#include <sys/errno.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(_LP64)
/*
 * The symbols _sys_errlist and _sys_nerr are not visible in the
 * LP64 libc.  Use strerror(3C) instead.
 */
#endif /* _LP64 */

#if defined(_REENTRANT) || defined(_TS_ERRNO) || _POSIX_C_SOURCE - 0 >= 199506L
extern int *___errno();
#define	errno (*(___errno()))
#else
extern int errno;
/* ANSI C++ requires that errno be a macro */
#if __cplusplus >= 199711L
#define	errno errno
#endif
#endif	/* defined(_REENTRANT) || defined(_TS_ERRNO) */

#if __EXT1_VISIBLE
/* ISO/IEC 9899:2011 K.3.2.2 */
#ifndef	_ERRNO_T_DEFINED
#define	_ERRNO_T_DEFINED
typedef int errno_t;
#endif
#endif	/* __EXT1_VISIBLE */

#ifdef	__cplusplus
}
#endif

#endif	/* _ERRNO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _EUC_H
#define	_EUC_H

#include <sys/euc.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern int csetcol(int n);	/* Returns # of columns for codeset n. */
extern int csetlen(int n);	/* Returns # of bytes excluding SSx. */
extern int euclen(const unsigned char *s);
extern int euccol(const unsigned char *s);
extern int eucscol(const unsigned char *str);

/* Returns code set number for the first byte of an EUC char. */
#define	csetno(c) \
	(((c)&0x80)?(((c)&0xff) == SS2)?2:((((c)&0xff) == SS3)?3:1):0)

/*
 * Copied from _wchar.h of SVR4
 */
#define	multibyte	(__ctype[520] > 1)
#define	eucw1		__ctype[514]
#define	eucw2		__ctype[515]
#define	eucw3		__ctype[516]
#define	scrw1		__ctype[517]
#define	scrw2		__ctype[518]
#define	scrw3		__ctype[519]

#ifdef	__cplusplus
}
#endif

#endif	/* _EUC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_EXACCT_H
#define	_EXACCT_H

/*
 * exacct item, group, and object definitions as well as structure manipulation
 * and conversion routines are given in sys/exacct.h.
 */
#include <sys/exacct.h>
#include <sys/exacct_catalog.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * ea_open positioning options:  passed in via the aflags argument, these flags
 * determine whether the newly opened file is positioned for reading prior to
 * its first record, or after its last.
 */
#define	EO_HEAD		0x0	/* open file positioned at first object */
#define	EO_TAIL		0x1	/* open file positioned at last object */
#define	EO_POSN_MSK	0x1

/*
 * ea_open validation options:  passed in via the aflags argument, these flags
 * specify whether the open operation should validate the header on the input
 * file.  The EO_NO_VALID_HDR is useful in the case that no header is present on
 * the file, but the version and file type checks are omitted, meaning that
 * incompatibilities might not be caught immediately.
 */
#define	EO_VALID_HDR	0x0	/* validate header on opening file */
#define	EO_NO_VALID_HDR	0x2	/* omit header validation */
#define	EO_VALIDATE_MSK	0x2

typedef struct _ea_file {
	void		*ef_opaque_ptr[8];
	offset_t	ef_opaque_off[3];
	int		ef_opaque_int[6];
} ea_file_t;

extern int ea_error(void);
extern int ea_open(ea_file_t *, const char *, const char *, int, int, mode_t);
extern int ea_fdopen(ea_file_t *, int, const char *, int, int);
extern void ea_clear(ea_file_t *);
extern int ea_close(ea_file_t *);
extern int ea_match_object_catalog(ea_object_t *, ea_catalog_t);
extern ea_object_type_t ea_next_object(ea_file_t *, ea_object_t *);
extern ea_object_type_t ea_previous_object(ea_file_t *, ea_object_t *);
extern ea_object_type_t ea_get_object(ea_file_t *, ea_object_t *);
extern ea_object_type_t ea_unpack_object(ea_object_t **, int, void *, size_t);
extern int ea_write_object(ea_file_t *, ea_object_t *);
extern const char *ea_get_creator(ea_file_t *);
extern const char *ea_get_hostname(ea_file_t *);
extern ea_object_t *ea_copy_object(const ea_object_t *);
extern ea_object_t *ea_copy_object_tree(const ea_object_t *);
extern ea_object_t *ea_get_object_tree(ea_file_t *, uint32_t);

#ifdef	__cplusplus
}
#endif

#endif	/* _EXACCT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_EXACCT_IMPL_H
#define	_EXACCT_IMPL_H

#include <sys/exacct.h>
#include <stdio.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct _ea_file_depth {
	int	efd_nobjs;		/* number of objects in group */
	int	efd_obj;		/* index of curr object within group */
} ea_file_depth_t;

typedef struct _ea_file_impl {
	char	*ef_filename;		/* file name */
	char	*ef_creator;		/* file creator */
	char	*ef_hostname;		/* file hostname */
	FILE	*ef_fp;			/* file stream pointer */
	ea_file_depth_t *ef_depth;	/* pointer to depth stack */
	char	*ef_buf;		/* pointer for buffer consumption */
	ssize_t	ef_bufsize;		/* remaining bytes in buffer */
	void	*ef_lpad[1];
	offset_t ef_advance;		/* bytes to advance on next op */
	offset_t ef_opad[2];
	mode_t	ef_oflags;		/* flags to open(2) */
	int	ef_fd;			/* file descriptor */
	int	ef_version;		/* exacct file version */
	int	ef_ndeep;		/* current depth in allocated stack */
	int	ef_mxdeep;		/* maximum depth of allocated stack */
	int	ef_ipad[1];
} ea_file_impl_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _EXACCT_IMPL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_EXEC_ATTR_H
#define	_EXEC_ATTR_H

#ifdef	__cplusplus
extern "C" {
#endif


#include <sys/types.h>
#include <secdb.h>


#define	EXECATTR_FILENAME		"/etc/security/exec_attr"
#define	EXECATTR_DB_NAME		"exec_attr.org_dir"
#define	EXECATTR_DB_NCOL		7	/* total columns */
#define	EXECATTR_DB_NKEYCOL		3	/* total searchable columns */
#define	EXECATTR_DB_TBLT		"exec_attr_tbl"
#define	EXECATTR_NAME_DEFAULT_KW	"nobody"

#define	EXECATTR_COL0_KW		"name"
#define	EXECATTR_COL1_KW		"policy"
#define	EXECATTR_COL2_KW		"type"
#define	EXECATTR_COL3_KW		"res1"
#define	EXECATTR_COL4_KW		"res2"
#define	EXECATTR_COL5_KW		"id"
#define	EXECATTR_COL6_KW		"attr"

/*
 * indices of searchable columns
 */
#define	EXECATTR_KEYCOL0		0	/* name */
#define	EXECATTR_KEYCOL1		1	/* policy */
#define	EXECATTR_KEYCOL2		5	/* id */


/*
 * Some macros used internally by the nsswitch code
 */

/*
 * These macros are bitmasks. GET_ONE and GET_ALL are bitfield 0
 * and thus mutually exclusive. __SEARCH_ALL_POLLS is bitfield
 * 1 and can be logically ORed with GET_ALL if one wants to get
 * all matching profiles from all policies, not just the ones from
 * the currently active policy
 *
 * Testing for these values should be done using the IS_* macros
 * defined below.
 */
#define	GET_ONE			0
#define	GET_ALL			1
#define	__SEARCH_ALL_POLS	2

/* get only one exec_attr from list */
#define	IS_GET_ONE(f) (((f) & GET_ALL) == 0)
/* get all matching exec_attrs in list */
#define	IS_GET_ALL(f) (((f) & GET_ALL) == 1)
/* search all existing policies */
#define	IS_SEARCH_ALL(f) (((f) & __SEARCH_ALL_POLS) == __SEARCH_ALL_POLS)

/*
 * Key words used in the exec_attr database
 */
#define	EXECATTR_EUID_KW	"euid"
#define	EXECATTR_EGID_KW	"egid"
#define	EXECATTR_UID_KW		"uid"
#define	EXECATTR_GID_KW		"gid"
#define	EXECATTR_LPRIV_KW	"limitprivs"
#define	EXECATTR_IPRIV_KW	"privs"

/*
 * Nsswitch representation of execution attributes.
 */
typedef struct execstr_s {
	char   *name;		/* profile name */
	char   *policy;		/* suser/rbac/tsol */
	char   *type;		/* cmd/act */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	char   *id;		/* unique ID */
	char   *attr;		/* string of key-value pair attributes */
	struct execstr_s *next;	/* pointer to next entry */
} execstr_t;

typedef struct execattr_s {
	char   *name;		/* profile name */
	char   *policy;		/* suser/rbac/tsol */
	char   *type;		/* cmd/act */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	char   *id;		/* unique ID */
	kva_t  *attr;		/* array of key-value pair attributes */
	struct execattr_s *next;	/* pointer to next entry */
} execattr_t;

typedef struct __private_execattr {
	const char *name;
	const char *type;
	const char *id;
	const char *policy;
	int search_flag;
	execstr_t *head_exec;
	execstr_t *prev_exec;
} _priv_execattr;		/* Un-supported. For Sun internal use only */


extern execattr_t *getexecattr(void);
extern execattr_t *getexecuser(const char *, const char *, const char *, int);
extern execattr_t *getexecprof(const char *, const char *, const char *, int);
extern execattr_t *match_execattr(execattr_t *, const char *, const char *, \
	const char *);
extern void free_execattr(execattr_t *);
extern void setexecattr(void);
extern void endexecattr(void);

#ifdef __cplusplus
}
#endif

#endif	/* _EXEC_ATTR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_EXECINFO_H
#define	_EXECINFO_H

/*
 * These functions provide glibc-compatible backtrace functionality.
 * Improved functionality is available using Solaris-specific APIs;
 * see man page for walkcontext(), printstack() and addtosymstr().
 */
#ifdef	__cplusplus
extern "C" {
#endif

extern int backtrace(void **, int);
extern char **backtrace_symbols(void *const *, int);
extern void backtrace_symbols_fd(void *const *, int, int);

#ifdef	__cplusplus
}
#endif

#endif /* _EXECINFO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_FATAL_H
#define	_FATAL_H

#ifdef	__cplusplus
extern "C" {
#endif

extern	int	Fflags;
extern	char	*Ffile;
extern	int	Fvalue;
extern	int	(*Ffunc)();
extern	int	Fjmp[10];

#define	FTLMSG		0100000
#define	FTLCLN		0040000
#define	FTLFUNC		0020000
#define	FTLACT		0000077
#define	FTLJMP		0000002
#define	FTLEXIT		0000001
#define	FTLRET		0000000

#define	FSAVE(val)	SAVE(Fflags, old_Fflags); Fflags = val;
#define	FRSTR()	RSTR(Fflags, old_Fflags);

#ifdef	__cplusplus
}
#endif

#endif	/* _FATAL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_FCNTL_H
#define	_FCNTL_H

#include <sys/feature_tests.h>
#if defined(__EXTENSIONS__) || defined(_XPG4)
#include <sys/stat.h>
#endif
#include <sys/types.h>
#include <sys/fcntl.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || defined(_XPG4)

/* Symbolic constants for the "lseek" routine. */

#ifndef	SEEK_SET
#define	SEEK_SET	0	/* Set file pointer to "offset" */
#endif

#ifndef	SEEK_CUR
#define	SEEK_CUR	1	/* Set file pointer to current plus "offset" */
#endif

#ifndef	SEEK_END
#define	SEEK_END	2	/* Set file pointer to EOF plus "offset" */
#endif
#endif /* defined(__EXTENSIONS__) || defined(_XPG4) */

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#ifndef	SEEK_DATA
#define	SEEK_DATA	3	/* Set file pointer to next data past offset */
#endif

#ifndef	SEEK_HOLE
#define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
#endif
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */


/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	open	open64
#pragma redefine_extname	creat	creat64
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
#pragma redefine_extname	posix_fadvise posix_fadvise64
#pragma redefine_extname	posix_fallocate posix_fallocate64
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
#pragma redefine_extname	openat	openat64
#pragma	redefine_extname	attropen attropen64
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#else
#define	open			open64
#define	creat			creat64
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
#define	posix_fadvise		posix_fadvise64
#define	posix_fallocate		posix_fallocate64
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
#define	openat			openat64
#define	attropen		attropen64
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#endif
#endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */

#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	open64	open
#pragma	redefine_extname	creat64	creat
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
#pragma redefine_extname	posix_fadvise64 posix_fadvise
#pragma redefine_extname	posix_fallocate64 posix_fallocate
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
#pragma	redefine_extname	openat64	openat
#pragma	redefine_extname	attropen64	attropen
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#else
#define	open64				open
#define	creat64				creat
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
#define	posix_fadvise64			posix_fadvise
#define	posix_fallocate64		posix_fallocate
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
#define	openat64			openat
#define	attropen64			attropen
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#endif
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

extern int fcntl(int, int, ...);
extern int open(const char *, int, ...);
extern int creat(const char *, mode_t);
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
extern int posix_fadvise(int, off_t, off_t, int);
extern int posix_fallocate(int, off_t, off_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
extern int openat(int, const char *, int, ...);
extern int attropen(const char *, const char *, int, ...);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
extern int directio(int, int);
#endif

/* transitional large file interface versions */
#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern int open64(const char *, int, ...);
extern int creat64(const char *, mode_t);
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
extern int posix_fadvise64(int, off64_t, off64_t, int);
extern int posix_fallocate64(int, off64_t, off64_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || ... */
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	defined(_ATFILE_SOURCE)
extern int openat64(int, const char *, int, ...);
extern int attropen64(const char *, const char *, int, ...);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _FCNTL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _FENV_H
#define	_FENV_H

#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Rounding modes
 */
#if defined(__sparc)

#define	FE_TONEAREST	0
#define	FE_TOWARDZERO	1
#define	FE_UPWARD	2
#define	FE_DOWNWARD	3

#elif defined(__i386) || defined(__amd64)

#define	FE_TONEAREST	0
#define	FE_DOWNWARD	1
#define	FE_UPWARD	2
#define	FE_TOWARDZERO	3

#endif

extern int fegetround(void);
extern int fesetround(int);

#if (defined(__i386) || defined(__amd64)) && \
	(!defined(_STRICT_STDC) || defined(__EXTENSIONS__))

#define	FE_FLTPREC	0
#define	FE_DBLPREC	2
#define	FE_LDBLPREC	3

extern int fegetprec(void);
extern int fesetprec(int);

#endif

/*
 * Exception flags
 */
#if defined(__sparc)

#define	FE_INEXACT	0x01
#define	FE_DIVBYZERO	0x02
#define	FE_UNDERFLOW	0x04
#define	FE_OVERFLOW	0x08
#define	FE_INVALID	0x10
#define	FE_ALL_EXCEPT	0x1f

#elif defined(__i386) || defined(__amd64)

#define	FE_INVALID	0x01
#define	FE_DIVBYZERO	0x04
#define	FE_OVERFLOW	0x08
#define	FE_UNDERFLOW	0x10
#define	FE_INEXACT	0x20
#define	FE_ALL_EXCEPT	0x3d

#endif

typedef int fexcept_t;

extern int feclearexcept(int);
extern int feraiseexcept(int);
extern int fetestexcept(int);
extern int fegetexceptflag(fexcept_t *, int);
extern int fesetexceptflag(const fexcept_t *, int);

#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)

/*
 * Exception handling extensions
 */
#define	FEX_NOHANDLER	-1
#define	FEX_NONSTOP	0
#define	FEX_ABORT	1
#define	FEX_SIGNAL	2
#define	FEX_CUSTOM	3

#define	FEX_INEXACT	0x001
#define	FEX_DIVBYZERO	0x002
#define	FEX_UNDERFLOW	0x004
#define	FEX_OVERFLOW	0x008
#define	FEX_INV_ZDZ	0x010
#define	FEX_INV_IDI	0x020
#define	FEX_INV_ISI	0x040
#define	FEX_INV_ZMI	0x080
#define	FEX_INV_SQRT	0x100
#define	FEX_INV_SNAN	0x200
#define	FEX_INV_INT	0x400
#define	FEX_INV_CMP	0x800
#define	FEX_INVALID	0xff0
#define	FEX_COMMON	(FEX_INVALID | FEX_DIVBYZERO | FEX_OVERFLOW)
#define	FEX_ALL		(FEX_COMMON | FEX_UNDERFLOW | FEX_INEXACT)
#define	FEX_NONE	0

#define	FEX_NUM_EXC	12

/* structure to hold a numeric value in any format used by the FPU */
typedef struct {
	enum fex_nt {
		fex_nodata	= 0,
		fex_int		= 1,
		fex_llong	= 2,
		fex_float	= 3,
		fex_double	= 4,
		fex_ldouble	= 5
	} type;
	union {
		int		i;
#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
	defined(__C99FEATURES__)
		long long	l;
#else
		struct {
			int	l[2];
		} l;
#endif
		float		f;
		double		d;
		long double	q;
	} val;
} fex_numeric_t;

/* structure to supply information about an exception to a custom handler */
typedef struct {
	enum fex_op {
		fex_add		= 0,
		fex_sub		= 1,
		fex_mul		= 2,
		fex_div		= 3,
		fex_sqrt	= 4,
		fex_cnvt	= 5,
		fex_cmp		= 6,
		fex_other	= 7
	} op;			/* operation that caused the exception */
	int		flags;	/* flags to be set */
	fex_numeric_t	op1, op2, res;	/* operands and result */
} fex_info_t;

typedef struct fex_handler_data {
	int	__mode;
	void	(*__handler)();
} fex_handler_t[FEX_NUM_EXC];

extern int fex_get_handling(int);
extern int fex_set_handling(int, int, void (*)());

extern void fex_getexcepthandler(fex_handler_t *, int);
extern void fex_setexcepthandler(const fex_handler_t *, int);

#ifdef __STDC__
#include <stdio_tag.h>
#ifndef	_FILEDEFED
#define	_FILEDEFED
typedef	__FILE FILE;
#endif
#endif
extern FILE *fex_get_log(void);
extern int fex_set_log(FILE *);
extern int fex_get_log_depth(void);
extern int fex_set_log_depth(int);
extern void fex_log_entry(const char *);

#define	__fex_handler_t	fex_handler_t

#else

typedef struct {
	int	__mode;
	void	(*__handler)();
} __fex_handler_t[12];

#endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */

/*
 * Environment as a whole
 */
typedef struct {
	__fex_handler_t	__handlers;
	unsigned long	__fsr;
} fenv_t;

#ifdef __STDC__
extern const fenv_t __fenv_dfl_env;
#else
extern fenv_t __fenv_dfl_env;
#endif

#define	FE_DFL_ENV	(&__fenv_dfl_env)

extern int fegetenv(fenv_t *);
extern int fesetenv(const fenv_t *);
extern int feholdexcept(fenv_t *);
extern int feupdateenv(const fenv_t *);

#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
extern void fex_merge_flags(const fenv_t *);
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _FENV_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _FLOAT_H
#define	_FLOAT_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__sparc)

extern int __flt_rounds(void);
#define	FLT_ROUNDS	__flt_rounds()

#else /* defined(__sparc) */

extern int __fltrounds(void);

#if defined(__amd64)
#define	FLT_ROUNDS	__fltrounds()
#else	/* defined(__amd64) */
extern int __flt_rounds;
#define	FLT_ROUNDS	__flt_rounds
#endif	/* defined(__amd64) */
#endif /* defined(__sparc) */

/* Introduced in ISO/IEC 9899:1999 standard */
#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
#if defined(__FLT_EVAL_METHOD__)
#define	FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
#define	FLT_EVAL_METHOD	-1
#endif /* defined(__FLT_EVAL_METHOD__) */
#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */

#define	FLT_RADIX	2
#define	FLT_MANT_DIG	24
#define	FLT_EPSILON	1.1920928955078125000000E-07F
#define	FLT_DIG		6
#define	FLT_MIN_EXP	(-125)
#define	FLT_MIN		1.1754943508222875079688E-38F
#define	FLT_MIN_10_EXP	(-37)
#define	FLT_MAX_EXP	(+128)
#define	FLT_MAX		3.4028234663852885981170E+38F
#define	FLT_MAX_10_EXP	(+38)

#define	DBL_MANT_DIG	53
#define	DBL_EPSILON	2.2204460492503130808473E-16
#define	DBL_DIG		15
#define	DBL_MIN_EXP	(-1021)
#define	DBL_MIN		2.2250738585072013830903E-308
#define	DBL_MIN_10_EXP	(-307)
#define	DBL_MAX_EXP	(+1024)
#define	DBL_MAX		1.7976931348623157081452E+308
#define	DBL_MAX_10_EXP	(+308)

/* Introduced in ISO/IEC 9899:1999 standard */
#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
#if defined(__sparc)
#define	DECIMAL_DIG	36
#elif defined(__i386) || defined(__amd64)
#define	DECIMAL_DIG	21
#endif
#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */


#if defined(__i386) || defined(__amd64)

/* Follows IEEE standards for 80-bit floating point */
#define	LDBL_MANT_DIG	64
#define	LDBL_EPSILON	1.0842021724855044340075E-19L
#define	LDBL_DIG	18
#define	LDBL_MIN_EXP	(-16381)
#define	LDBL_MIN	3.3621031431120935062627E-4932L
#define	LDBL_MIN_10_EXP	(-4931)
#define	LDBL_MAX_EXP	(+16384)
#define	LDBL_MAX	1.1897314953572317650213E+4932L
#define	LDBL_MAX_10_EXP	(+4932)

#elif defined(__sparc)

/* Follows IEEE standards for 128-bit floating point */
#define	LDBL_MANT_DIG	113
#define	LDBL_EPSILON	1.925929944387235853055977942584927319E-34L
#define	LDBL_DIG	33
#define	LDBL_MIN_EXP	(-16381)
#define	LDBL_MIN	3.362103143112093506262677817321752603E-4932L
#define	LDBL_MIN_10_EXP	(-4931)
#define	LDBL_MAX_EXP	(+16384)
#define	LDBL_MAX	1.189731495357231765085759326628007016E+4932L
#define	LDBL_MAX_10_EXP	(+4932)

#else

#error "Unknown architecture!"

#endif


#ifdef	__cplusplus
}
#endif

#endif	/* _FLOAT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (C) 1989 AT&T	*/
/*	  All Rights Reserved */

/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _FLOATINGPOINT_H
#define	_FLOATINGPOINT_H

#ifdef __STDC__
#include <stdio_tag.h>
#endif
#include <sys/ieeefp.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * <floatingpoint.h> contains definitions for constants, types, variables,
 * and functions for:
 *	IEEE floating-point arithmetic base conversion;
 *	IEEE floating-point arithmetic modes;
 *	IEEE floating-point arithmetic exception handling.
 */
#if defined(__STDC__) && !defined(_FILEDEFED)
#define	_FILEDEFED
typedef	__FILE FILE;
#endif

typedef int sigfpe_code_type;	/* Type of SIGFPE code. */

typedef void (*sigfpe_handler_type)();	/* Pointer to exception handler */

#define	SIGFPE_DEFAULT (void (*)())0	/* default exception handling */
#define	SIGFPE_IGNORE  (void (*)())1	/* ignore this exception or code */
#define	SIGFPE_ABORT   (void (*)())2	/* force abort on exception */

extern sigfpe_handler_type sigfpe(sigfpe_code_type, sigfpe_handler_type);

/*
 * Types for IEEE floating point.
 */
typedef float single;

#ifndef _EXTENDED
#define	_EXTENDED
typedef unsigned extended[3];
#endif

typedef long double quadruple;	/* Quadruple-precision type. */

typedef unsigned fp_exception_field_type;
				/*
				 * A field containing fp_exceptions OR'ed
				 * together.
				 */
/*
 * Definitions for base conversion.
 */
#define	DECIMAL_STRING_LENGTH 512	/* Size of buffer in decimal_record. */

typedef char decimal_string[DECIMAL_STRING_LENGTH];
				/* Decimal significand. */

typedef struct {
	enum fp_class_type fpclass;
	int	sign;
	int	exponent;
	decimal_string ds;	/* Significand - each char contains an ascii */
				/* digit, except the string-terminating */
				/* ascii null. */
	int	more;		/* On conversion from decimal to binary, != 0 */
				/* indicates more non-zero digits following */
				/* ds. */
	int	ndigits;	/* On fixed_form conversion from binary to */
				/* decimal, contains number of digits */
				/* required for ds. */
} decimal_record;

enum decimal_form {
	fixed_form,		/* Fortran F format: ndigits specifies number */
				/* of digits after point; if negative, */
				/* specifies rounding to occur to left of */
				/* point. */
	floating_form		/* Fortran E format: ndigits specifies number */
				/* of significant digits. */
};

typedef struct {
	enum fp_direction_type rd;
				/* Rounding direction. */
	enum decimal_form df;	/* Format for conversion from binary to */
				/* decimal. */
	int ndigits;		/* Number of digits for conversion. */
} decimal_mode;

enum decimal_string_form {	/* Valid decimal number string formats. */
	invalid_form,		/* Not a valid decimal string format. */
	whitespace_form,	/* All white space - valid in Fortran! */
	fixed_int_form,		/* <digs>		*/
	fixed_intdot_form,	/* <digs>.		*/
	fixed_dotfrac_form,	/* .<digs>		*/
	fixed_intdotfrac_form,	/* <digs>.<frac>	*/
	floating_int_form,	/* <digs><exp>		*/
	floating_intdot_form,	/* <digs>.<exp>		*/
	floating_dotfrac_form,	/* .<digs><exp>		*/
	floating_intdotfrac_form, /* <digs>.<digs><exp>	*/
	inf_form,		/* inf			*/
	infinity_form,		/* infinity		*/
	nan_form,		/* nan			*/
	nanstring_form		/* nan(string)		*/
};

extern void single_to_decimal(single *, decimal_mode *, decimal_record *,
    fp_exception_field_type *);
extern void double_to_decimal(double *, decimal_mode *, decimal_record *,
    fp_exception_field_type *);
extern void extended_to_decimal(extended *, decimal_mode *,
    decimal_record *, fp_exception_field_type *);
extern void quadruple_to_decimal(quadruple *, decimal_mode *,
    decimal_record *, fp_exception_field_type *);

extern void decimal_to_single(single *, decimal_mode *, decimal_record *,
    fp_exception_field_type *);
extern void decimal_to_double(double *, decimal_mode *, decimal_record *,
    fp_exception_field_type *);
extern void decimal_to_extended(extended *, decimal_mode *,
    decimal_record *, fp_exception_field_type *);
extern void decimal_to_quadruple(quadruple *, decimal_mode *,
    decimal_record *, fp_exception_field_type *);

extern void string_to_decimal(char **, int, int, decimal_record *,
    enum decimal_string_form *, char **);
extern void func_to_decimal(char **, int, int, decimal_record *,
    enum decimal_string_form *, char **,
    int (*)(void), int *, int (*)(int));
extern void file_to_decimal(char **, int, int, decimal_record *,
    enum decimal_string_form *, char **,
    FILE *, int *);

extern char *seconvert(single *, int, int *, int *, char *);
extern char *sfconvert(single *, int, int *, int *, char *);
extern char *sgconvert(single *, int, int, char *);
extern char *econvert(double, int, int *, int *, char *);
extern char *fconvert(double, int, int *, int *, char *);
extern char *gconvert(double, int, int, char *);
extern char *qeconvert(quadruple *, int, int *, int *, char *);
extern char *qfconvert(quadruple *, int, int *, int *, char *);
extern char *qgconvert(quadruple *, int, int, char *);

extern char *ecvt(double, int, int *, int *);
extern char *fcvt(double, int, int *, int *);
extern char *gcvt(double, int, char *);

#if __cplusplus >= 199711L
namespace std {
#endif
/*
 * ANSI C Standard says the following entry points should be
 * prototyped in <stdlib.h>.  They are now, but weren't before.
 */
extern double atof(const char *);
extern double strtod(const char *, char **);
#if __cplusplus >= 199711L
}

using std::atof;
using std::strtod;
#endif /* end of namespace std */

#ifdef __cplusplus
}
#endif

#endif /* _FLOATINGPOINT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014-2015 PALO, Richard.
 *
 * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_FMTMSG_H
#define	_FMTMSG_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * fmtmsg.h
 *
 *	The <fmtmsg.h> header file contains the definitions needed
 *	to use the fmtmsg() function.  This function writes messages
 *	in a standard format to the standard error stream (stderr)
 *	and to the system console.
 */

/*
 * Constraint definitions:
 *	MM_MXLABELLN	Maximum size of a "label" in a message
 *	MM_MXTAGLN	Maximum size of a "tag" in a message
 *	MM_MXTXTLN	Maximum size of a text string
 *	MM_MXACTLN	Maximum size of an action string
 */

#define	MM_MXLABELLN	25
#define	MM_MXTAGLN	32
#define	MM_MXTXTLN	512
#define	MM_MXACTLN	512

/*
 * Environment variable names used by fmtmsg():
 *	MSGVERB		Tells fmtmsg() which components it is to write
 *			to the standard error stream
 */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	MSGVERB		"MSGVERB"
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

/*
 * Classification information
 *	- Definition of classifications
 *	- Definition of recoverability
 *	- Definition of source classifications
 */

/*
 * Definition of the "null" classification
 *	MM_NULL		Indicates that the classification has been omitted
 */

#define	MM_NULL		0L

/*
 * Definitions of type classifications:
 *	MM_HARD		Hardware
 *	MM_SOFT		Software
 *	MM_FIRM		Firmware
 */

#define	MM_HARD		0x00000001L
#define	MM_SOFT		0x00000002L
#define	MM_FIRM		0x00000004L

/*
 * Definitions of recoverability subclassification
 *	MM_RECOVER	Recoverable
 *	MM_NRECOV	Non-recoverable
 */

#define	MM_RECOVER	0x00000100L
#define	MM_NRECOV	0x00000200L

/*
 * Definitions of source subclassification
 *	MM_APPL		Application
 *	MM_UTIL		Utility
 *	MM_OPSYS	Kernel
 */

#define	MM_APPL		0x00000008L
#define	MM_UTIL		0x00000010L
#define	MM_OPSYS	0x00000020L

/*
 * Definitions for the action to take with the message:
 *	MM_PRINT	Write to the standard error stream
 *	MM_CONSOLE	Treat the message as a console message
 */

#define	MM_PRINT	0x00000040L
#define	MM_CONSOLE	0x00000080L

/*
 * Constants for severity values
 *
 *	SEV_LEVEL	Names the env variable that defines severities
 *
 *	MM_NOSEV	Message has no severity
 *	MM_HALT		Message describes a severe error condition
 *	MM_ERROR	Message describes an error condition
 *	MM_WARNING	Message tells of probable error condition
 *	MM_INFO		Message informs, not in error
 */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	SEV_LEVEL	"SEV_LEVEL"
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#define	MM_NOSEV	0
#define	MM_HALT		1
#define	MM_ERROR	2
#define	MM_WARNING	3
#define	MM_INFO		4

/*
 * Null values for message components
 *	MM_NULLLBL		Null value for the label-component
 *	MM_NULLSEV		Null value for the severity-component
 *	MM_NULLMC		Null value for the classification-component
 *	MM_NULLTXT		Null value for the text-component
 *	MM_NULLACT		Null value for the action-component
 *	MM_NULLTAG		Null value for the tag-component
 */

#define	MM_NULLLBL	((char *)0)
#define	MM_NULLSEV	MM_NOSEV
#define	MM_NULLMC	MM_NULL
#define	MM_NULLTXT	((char *)0)
#define	MM_NULLACT	((char *)0)
#define	MM_NULLTAG	((char *)0)

/*
 * Values returned by fmtmsg()
 *
 *	MM_NOTOK	None of the requested messages were generated
 *	MM_NOMSG	No message was written to stderr
 *	MM_NOCON	No console message was generated
 */

#define	MM_NOTOK	-1
#define	MM_OK		0x00
#define	MM_NOMSG	0x01
#define	MM_NOCON	0x04

/* Function definition */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
int	addseverity(int, const char *);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

int	fmtmsg(long, const char *, int, const char *, const char *,
	    const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _FMTMSG_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1994 by Sun Microsystems, Inc.
 * Copyright 1985, 1994 by Mortice Kern Systems Inc.  All rights reserved.
 */

#ifndef	_FNMATCH_H
#define	_FNMATCH_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	FNM_PATHNAME	0x01	/* Slash in str only matches slash in pattern */
#define	FNM_NOESCAPE	0x02	/* Disable '\'-quoting of metacharacters */
#define	FNM_PERIOD	0x04	/* Leading period in string must be exactly */
				/* matched by period in pattern	*/
#define	FNM_IGNORECASE	0x08	/* Ignore case when making comparisons */
#define	FNM_CASEFOLD	0x08	/* Ignore case when making comparisons */
				/* (for FreeBSD/Linux compatibility) */
#define	FNM_LEADING_DIR	0x10	/* Match if pattern matches initial segment */
				/* of str which is followed by a slash */

#define	FNM_NOMATCH	1	/* string doesnt match the specified pattern */
#define	FNM_ERROR	2	/* error occured */
#define	FNM_NOSYS	3	/* Function (XPG4) not supported */

extern int fnmatch(const char *, const char *, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _FNMATCH_H */
/*
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef	_FTS_H
#define	_FTS_H

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct {
	struct _ftsent *fts_cur;	/* current node */
	struct _ftsent *fts_child;	/* linked list of children */
	struct _ftsent **fts_array;	/* sort array */
	dev_t fts_dev;			/* starting device # */
	char *fts_path;			/* path for this descent */
	int fts_rfd;			/* fd for root */
	size_t fts_pathlen;		/* sizeof(path) */
	int fts_nitems;			/* elements in the sort array */
	int (*fts_compar)();		/* compare function */

#define	FTS_COMFOLLOW	0x0001		/* follow command line symlinks */
#define	FTS_LOGICAL	0x0002		/* logical walk */
#define	FTS_NOCHDIR	0x0004		/* don't change directories */
#define	FTS_NOSTAT	0x0008		/* don't get stat info */
#define	FTS_PHYSICAL	0x0010		/* physical walk */
#define	FTS_SEEDOT	0x0020		/* return dot and dot-dot */
#define	FTS_XDEV	0x0040		/* don't cross devices */
#define	FTS_OPTIONMASK	0x00ff		/* valid user option mask */

#define	FTS_NAMEONLY	0x1000		/* (private) child names only */
#define	FTS_STOP	0x2000		/* (private) unrecoverable error */
	int fts_options;		/* fts_open options, global flags */
} FTS;

typedef struct _ftsent {
	struct _ftsent *fts_cycle;	/* cycle node */
	struct _ftsent *fts_parent;	/* parent directory */
	struct _ftsent *fts_link;	/* next file in directory */
	long fts_number;		/* local numeric value */
	void *fts_pointer;		/* local address value */
	char *fts_accpath;		/* access path */
	char *fts_path;			/* root path */
	int fts_errno;			/* errno for this node */
	int fts_symfd;			/* fd for symlink */
	size_t fts_pathlen;		/* strlen(fts_path) */
	size_t fts_namelen;		/* strlen(fts_name) */

	ino_t fts_ino;			/* inode */
	dev_t fts_dev;			/* device */
	nlink_t fts_nlink;		/* link count */

#define	FTS_ROOTPARENTLEVEL	-1
#define	FTS_ROOTLEVEL		 0
#define	FTS_MAXLEVEL		 0x7fffffff
	int fts_level;		/* depth (-1 to N) */

#define	FTS_D		 1		/* preorder directory */
#define	FTS_DC		 2		/* directory that causes cycles */
#define	FTS_DEFAULT	 3		/* none of the above */
#define	FTS_DNR		 4		/* unreadable directory */
#define	FTS_DOT		 5		/* dot or dot-dot */
#define	FTS_DP		 6		/* postorder directory */
#define	FTS_ERR		 7		/* error; errno is set */
#define	FTS_F		 8		/* regular file */
#define	FTS_INIT	 9		/* initialized only */
#define	FTS_NS		10		/* stat(2) failed */
#define	FTS_NSOK	11		/* no stat(2) requested */
#define	FTS_SL		12		/* symbolic link */
#define	FTS_SLNONE	13		/* symbolic link without target */
	unsigned short fts_info;	/* user flags for FTSENT structure */

#define	FTS_DONTCHDIR	 0x01		/* don't chdir .. to the parent */
#define	FTS_SYMFOLLOW	 0x02		/* followed a symlink to get here */
	unsigned short fts_flags;	/* private flags for FTSENT structure */

#define	FTS_AGAIN	 1		/* read node again */
#define	FTS_FOLLOW	 2		/* follow symbolic link */
#define	FTS_NOINSTR	 3		/* no instructions */
#define	FTS_SKIP	 4		/* discard node */
	unsigned short fts_instr;	/* fts_set() instructions */

	unsigned short fts_spare;	/* unused */

	struct stat *fts_statp;		/* stat(2) information */
	char fts_name[1];		/* file name */
} FTSENT;

#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	fts_children	fts_children64
#pragma	redefine_extname	fts_close	fts_close64
#pragma	redefine_extname	fts_open	fts_open64
#pragma	redefine_extname	fts_read	fts_read64
#pragma	redefine_extname	fts_set		fts_set64
#else
#define	fts_children	fts_children64
#define	fts_close	fts_close64
#define	fts_open	fts_open64
#define	fts_read	fts_read64
#define	fts_set		fts_set64
#endif /* __PRAGMA_REDEFINE_EXTNAME */
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */

FTSENT	*fts_children(FTS *, int);
int	 fts_close(FTS *);
FTS	*fts_open(char * const *, int,
	    int (*)(const FTSENT **, const FTSENT **));
FTSENT	*fts_read(FTS *);
int	 fts_set(FTS *, FTSENT *, int);

#ifdef	__cplusplus
}
#endif

#endif /* !_FTS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_FTW_H
#define	_FTW_H

#include <sys/feature_tests.h>

#include <sys/types.h>
#include <sys/stat.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *	Codes for the third argument to the user-supplied function.
 */

#define	FTW_F	0	/* file */
#define	FTW_D	1	/* directory */
#define	FTW_DNR	2	/* directory without read permission */
#define	FTW_NS	3	/* unknown type, stat failed */
#define	FTW_SL	4	/* symbolic link */
#define	FTW_DP	6	/* directory */
#define	FTW_SLN	7	/* symbolic link that points to nonexistent file */
#define	FTW_DL	8	/* private interface for find utility */

/*
 *	Codes for the fourth argument to nftw.  You can specify the
 *	union of these flags.
 */

#define	FTW_PHYS	01  /* use lstat instead of stat */
#define	FTW_MOUNT	02  /* do not cross a mount point */
#define	FTW_CHDIR	04  /* chdir to each directory before reading */
#define	FTW_DEPTH	010 /* call descendents before calling the parent */
#define	FTW_ANYERR	020 /* return FTW_NS on any stat failure */
#define	FTW_HOPTION	040 /* private interface for find utility */
#define	FTW_NOLOOP	0100 /* private interface for find utility */

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2)
struct FTW
{
#if defined(_XPG4_2)
	int	__quit;
#else
	int	quit;
#endif
	int	base;
	int	level;
};
#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */

/*
 * legal values for quit
 */

#define	FTW_SKD		1
#define	FTW_FOLLOW	2
#define	FTW_PRUNE	4

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	_xftw	_xftw64
#pragma redefine_extname	_ftw	_ftw64
#if !defined(_XOPEN_SOURCE) || defined(_XPG5)
#pragma redefine_extname	nftw	nftw64
#endif
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	_xftw			_xftw64
#define	_ftw			_ftw64
#if !defined(_XOPEN_SOURCE) || defined(_XPG5)
#define	nftw			nftw64
#endif
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */

/* In the LP64 compilation environment, all APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	_xftw64		_xftw
#pragma	redefine_extname	_ftw64		_ftw
#if !defined(_XOPEN_SOURCE) || defined(_XPG5)
#pragma	redefine_extname	nftw64		nftw
#endif
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	_xftw64		_xftw
#define	_ftw64		_ftw
#if !defined(_XOPEN_SOURCE) || defined(_XPG5)
#define	nftw64		nftw
#endif
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

extern int ftw(const char *,
	int (*)(const char *, const struct stat *, int), int);
extern int _xftw(int, const char *,
	int (*)(const char *, const struct stat *, int), int);
#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2)
extern int nftw(const char *,
	int (*)(const char *, const struct stat *, int, struct FTW *),
	int, int);
#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */

/*
 * transitional large file interface versions
 */
#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern int ftw64(const char *,
	int (*)(const char *, const struct stat64 *, int), int);
extern int _xftw64(int, const char *,
	int (*)(const char *, const struct stat64 *, int), int);
#if !defined(_XOPEN_SOURCE)
extern int nftw64(const char *,
	int (*)(const char *, const struct stat64 *, int, struct FTW *),
	int, int);
#endif /* !defined(_XOPEN_SOURCE) */
#endif /* _LARGEFILE64_SOURCE .. */

#define	_XFTWVER	2	/* version of file tree walk */

#define	ftw(path, fn, depth)	_xftw(_XFTWVER, (path), (fn), (depth))

#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
#define	ftw64(path, fn, depth)	_xftw64(_XFTWVER, (path), (fn), (depth))
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _FTW_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_GELF_H
#define	_GELF_H

#include <sys/feature_tests.h>

#include <libelf.h>
#include <sys/link.h>

#ifdef	__cplusplus
extern "C" {
#endif


#if !defined(_INT64_TYPE)
#error "64-bit integer types are required by gelf."
#endif

/*
 * Class-independent ELF API for Elf utilities.  This is
 * for manipulating Elf32 and Elf64 specific information
 * in a format common to both classes.
 */

typedef Elf64_Addr	GElf_Addr;
typedef Elf64_Half	GElf_Half;
typedef Elf64_Off	GElf_Off;
typedef Elf64_Sword	GElf_Sword;
typedef Elf64_Sxword	GElf_Sxword;
typedef Elf64_Word	GElf_Word;
typedef Elf64_Xword	GElf_Xword;

typedef Elf64_Ehdr	GElf_Ehdr;
typedef	Elf64_Move	GElf_Move;
typedef Elf64_Phdr	GElf_Phdr;
typedef Elf64_Shdr	GElf_Shdr;
typedef Elf64_Sym	GElf_Sym;
typedef	Elf64_Syminfo	GElf_Syminfo;
typedef Elf64_Rela	GElf_Rela;
typedef Elf64_Rel	GElf_Rel;
typedef Elf64_Dyn	GElf_Dyn;
typedef Elf64_Cap	GElf_Cap;

/*
 * The processing of versioning information can stay the
 * same because both the Elf32 and Elf64 structures are
 * of equal sizes.
 */
typedef Elf64_Verdef	GElf_Verdef;
typedef Elf64_Verdaux	GElf_Verdaux;
typedef Elf64_Verneed	GElf_Verneed;
typedef Elf64_Vernaux	GElf_Vernaux;
typedef Elf64_Versym	GElf_Versym;

/*
 * move.m_info is encoded using the 64bit fields in Gelf.
 */
#define	GELF_M_SYM	ELF64_M_SYM
#define	GELF_M_SIZE	ELF64_M_SIZE

/*
 * sym.st_info field is same size for Elf32 and Elf64.
 */
#define	GELF_ST_BIND	ELF64_ST_BIND
#define	GELF_ST_TYPE	ELF64_ST_TYPE
#define	GELF_ST_INFO	ELF64_ST_INFO


/*
 * Elf64 r_info may have data field in type id's word,
 * so GELF_R_TYPE is defined as ELF64_R_TYPE_ID in order
 * to isolate the proper bits for the true type id.
 */
#define	GELF_R_TYPE		ELF64_R_TYPE_ID
#define	GELF_R_SYM		ELF64_R_SYM
#define	GELF_R_INFO		ELF64_R_INFO
#define	GELF_R_TYPE_DATA	ELF64_R_TYPE_DATA
#define	GELF_R_TYPE_ID		ELF64_R_TYPE_ID
#define	GELF_R_TYPE_INFO	ELF64_R_TYPE_INFO



int		gelf_getclass(Elf*);
size_t		gelf_fsize(Elf *, Elf_Type, size_t, uint_t);
GElf_Ehdr *	gelf_getehdr(Elf *, GElf_Ehdr *);
int		gelf_update_ehdr(Elf *, GElf_Ehdr *);
unsigned long	gelf_newehdr(Elf *, int);
GElf_Phdr *	gelf_getphdr(Elf *, int, GElf_Phdr *);
int		gelf_update_phdr(Elf *, int, GElf_Phdr *);
unsigned long	gelf_newphdr(Elf *, size_t);
GElf_Shdr *	gelf_getshdr(Elf_Scn *,  GElf_Shdr *);
int		gelf_update_shdr(Elf_Scn *, GElf_Shdr *);
Elf_Data *	gelf_xlatetof(Elf *, Elf_Data *, const Elf_Data *, uint_t);
Elf_Data *	gelf_xlatetom(Elf *, Elf_Data *, const Elf_Data *, uint_t);
GElf_Sym *	gelf_getsym(Elf_Data *, int, GElf_Sym *);
int		gelf_update_sym(Elf_Data *, int, GElf_Sym *);
GElf_Sym *	gelf_getsymshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
		    Elf32_Word *);
int		gelf_update_symshndx(Elf_Data *, Elf_Data *, int, GElf_Sym *,
		    Elf32_Word);
GElf_Syminfo *	gelf_getsyminfo(Elf_Data *, int, GElf_Syminfo *);
int		gelf_update_syminfo(Elf_Data *, int, GElf_Syminfo *);
GElf_Move *	gelf_getmove(Elf_Data *, int, GElf_Move *);
int		gelf_update_move(Elf_Data *, int, GElf_Move *);
GElf_Dyn *	gelf_getdyn(Elf_Data *, int, GElf_Dyn *);
int		gelf_update_dyn(Elf_Data *, int, GElf_Dyn *);
GElf_Rela *	gelf_getrela(Elf_Data *, int, GElf_Rela *);
int		gelf_update_rela(Elf_Data *, int, GElf_Rela *);
GElf_Rel *	gelf_getrel(Elf_Data *, int, GElf_Rel *);
int		gelf_update_rel(Elf_Data *, int, GElf_Rel *);
long		gelf_checksum(Elf *);
GElf_Cap *	gelf_getcap(Elf_Data *, int, GElf_Cap *);
int		gelf_update_cap(Elf_Data *, int, GElf_Cap *);


#ifdef	__cplusplus
}
#endif

#endif	/* _GELF_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 2020 Joyent Inc.
 */

/*
 * GNU-like getopt_long(), getopt_long_only().
 * Solaris-specific getopt_clip().
 */

#ifndef	_GETOPT_H
#define	_GETOPT_H

#ifdef	__cplusplus
extern "C" {
#endif


/*
 * Values for has_arg field.
 *
 * optional_argument is not supported by getopt_clip()
 */
#define	no_argument		0
#define	required_argument	1
#define	optional_argument	2

struct option {
	const char *name;	/* name of long option */
	int has_arg;		/* whether option takes an argument */
	int *flag;		/* if not NULL, set *flag to val when option */
				/* found */
	int val;		/* if flag is not NULL, value to set *flag */
				/* to. */
				/* if flag is NULL, return value */
};

/*
 * External variables used by these routines.
 */
extern char *optarg;
extern int  opterr;
extern int  optind;
extern int  optopt;

/*
 * The use of getopt_long_only in new development is strongly discouraged.
 */
extern int	getopt_long(int, char * const *, const char *,
		    const struct option *, int *);
extern int	getopt_long_only(int, char * const *, const char *,
		    const struct option *, int *);
extern int	getopt_clip(int, char * const *, const char *,
		    const struct option *, int *);

#ifdef __cplusplus
}
#endif

#endif	/* _GETOPT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_GETWIDTH_H
#define	_GETWIDTH_H

#include <euc.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern void getwidth(eucwidth_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _GETWIDTH_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 1985, 1992 by Mortice Kern Systems Inc.  All rights reserved.
 */

/*
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Guido van Rossum.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)glob.h	8.1 (Berkeley) 6/2/93
 */

/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright (c) 2013 Gary Mills
 */

#ifndef	_GLOB_H
#define	_GLOB_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef	struct	glob_t	{
	/*
	 * Members specified by POSIX
	 */
	size_t	gl_pathc;	/* Total count of paths matched by pattern */
	char	**gl_pathv;	/* List of matched pathnames */
	size_t	gl_offs;	/* # of slots reserved in gl_pathv */

	/*
	 * Internal-use members:
	 *
	 * NB: The next two members are carried in both the
	 * libc backward compatibility wrapper functions and
	 * the extended functions.
	 */
	char	**gl_pathp;	/* gl_pathv + gl_offs */
	int	gl_pathn;	/* # of elements allocated */

	/*
	 * Non-POSIX extensions
	 *
	 * NB: The following members are not carried in
	 * the libc backward compatibility wrapper functions.
	 */
	int	gl_matchc;	/* Count of paths matching pattern. */
	int	gl_flags;	/* Copy of flags parameter to glob. */
	struct	stat **gl_statv; /* Stat entries corresponding to gl_pathv */

	/*
	 * Alternate filesystem access methods for glob; replacement
	 * versions of closedir(3), readdir(3), opendir(3), stat(2)
	 * and lstat(2).
	 */
	void (*gl_closedir)(void *);
	struct dirent *(*gl_readdir)(void *);
	void *(*gl_opendir)(const char *);
	int (*gl_lstat)(const char *, struct stat *);
	int (*gl_stat)(const char *, struct stat *);
}	glob_t;

/*
 * POSIX "flags" argument to glob function.
 */
#define	GLOB_ERR	0x0001		/* Don't continue on directory error */
#define	GLOB_MARK	0x0002		/* Mark directories with trailing / */
#define	GLOB_NOSORT	0x0004		/* Don't sort pathnames */
#define	GLOB_NOCHECK	0x0008		/* Return unquoted arg if no match */
#define	GLOB_DOOFFS	0x0010		/* Ignore gl_offs unless set */
#define	GLOB_APPEND	0x0020		/* Append to previous glob_t */
#define	GLOB_NOESCAPE	0x0040		/* Backslashes do not quote M-chars */

/*
 * Non-POSIX "flags" argument to glob function, from OpenBSD.
 */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#define	GLOB_POSIX	0x007F	/* All POSIX flags */
#define	GLOB_BRACE	0x0080	/* Expand braces ala csh. */
#define	GLOB_MAGCHAR	0x0100	/* Pattern had globbing characters. */
#define	GLOB_NOMAGIC	0x0200	/* GLOB_NOCHECK without magic chars (csh). */
#define	GLOB_QUOTE	0x0400	/* Quote special chars with \. */
#define	GLOB_TILDE	0x0800	/* Expand tilde names from the passwd file. */
#define	GLOB_LIMIT	0x2000	/* Limit pattern match output to ARG_MAX */
#define	GLOB_KEEPSTAT	0x4000	/* Retain stat data for paths in gl_statv. */
#define	GLOB_ALTDIRFUNC	0x8000	/* Use alternately specified directory funcs. */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

/*
 * Error returns from "glob"
 */
#define	GLOB_NOSYS	(-4)		/* function not supported (XPG4) */
#define	GLOB_NOMATCH	(-3)		/* Pattern does not match */
#define	GLOB_NOSPACE	(-2)		/* Not enough memory */
#define	GLOB_ABORTED	(-1)		/* GLOB_ERR set or errfunc return!=0 */
#define	GLOB_ABEND	GLOB_ABORTED	/* backward compatibility */


#ifdef __PRAGMA_REDEFINE_EXTNAME
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#pragma	redefine_extname	glob	_glob_ext64
#pragma	redefine_extname	globfree	_globfree_ext64
#else
#pragma	redefine_extname	glob	_glob_ext
#pragma	redefine_extname	globfree	_globfree_ext
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
#else /* __PRAGMA_REDEFINE_EXTNAME */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#define	glob	_glob_ext64
#define	globfree	_globfree_ext64
#else
#define	glob	_glob_ext
#define	globfree	_globfree_ext
#endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

extern int glob(const char *_RESTRICT_KYWD, int, int(*)(const char *, int),
		glob_t *_RESTRICT_KYWD);
extern void globfree(glob_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _GLOB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Copyright 2020 Joyent, Inc.
 */

#ifndef _GRP_H
#define	_GRP_H

#include <sys/feature_tests.h>

#include <sys/types.h>

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
#include <stdio.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

struct	group {	/* see getgrent(3C) */
	char	*gr_name;
	char	*gr_passwd;
	gid_t	gr_gid;
	char	**gr_mem;
};

extern struct group *getgrgid(gid_t);		/* MT-unsafe */
extern struct group *getgrnam(const char *);	/* MT-unsafe */

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
extern struct group *getgrent_r(struct group *, char *, int);
extern struct group *fgetgrent_r(FILE *, struct group *, char *, int);


extern struct group *fgetgrent(FILE *);		/* MT-unsafe */
extern int initgroups(const char *, gid_t);
extern int getgrouplist(const char *, gid_t, gid_t *, int *);
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
extern void endgrent(void);
extern void setgrent(void);
extern struct group *getgrent(void);		/* MT-unsafe */
#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */

/*
 * getgrgid_r() & getgrnam_r() prototypes are defined here.
 */

/*
 * Previous releases of Solaris, starting at 2.3, provided definitions of
 * various functions as specified in POSIX.1c, Draft 6.  For some of these
 * functions, the final POSIX 1003.1c standard had a different number of
 * arguments and return values.
 *
 * The following segment of this header provides support for the standard
 * interfaces while supporting applications written under earlier
 * releases.  The application defines appropriate values of the feature
 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
 * whether it was written to expect the Draft 6 or standard versions of
 * these interfaces, before including this header.  This header then
 * provides a mapping from the source version of the interface to an
 * appropriate binary interface.  Such mappings permit an application
 * to be built from libraries and objects which have mixed expectations
 * of the definitions of these functions.
 *
 * For applications using the Draft 6 definitions, the binary symbol is the
 * same as the source symbol, and no explicit mapping is needed.  For the
 * standard interface, the function func() is mapped to the binary symbol
 * _posix_func().  The preferred mechanism for the remapping is a compiler
 * #pragma.  If the compiler does not provide such a #pragma, the header file
 * defines a static function func() which calls the _posix_func() version;
 * this has to be done instead of #define since POSIX specifies that an
 * application can #undef the symbol and still be bound to the correct
 * implementation.  Unfortunately, the statics confuse lint so we fallback to
 * #define in that case.
 *
 * NOTE: Support for the Draft 6 definitions is provided for compatibility
 * only.  New applications/libraries should use the standard definitions.
 */

#if	defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getgrgid_r __posix_getgrgid_r
#pragma redefine_extname getgrnam_r __posix_getgrnam_r
extern int getgrgid_r(gid_t, struct group *, char *,
    size_t, struct group **);
extern int getgrnam_r(const char *, struct group *, char *,
    size_t, struct group **);
#else  /* __PRAGMA_REDEFINE_EXTNAME */

extern int __posix_getgrgid_r(gid_t, struct group *, char *, size_t,
    struct group **);
extern int __posix_getgrnam_r(const char *, struct group *, char *, size_t,
    struct group **);

static int
getgrgid_r(gid_t __gid, struct group *__grp, char *__buf, size_t __len,
    struct group **__res)
{
	return (__posix_getgrgid_r(__gid, __grp, __buf, __len, __res));
}
static int
getgrnam_r(const char *__cb, struct group *__grp, char *__buf, size_t __len,
    struct group **__res)
{
	return (__posix_getgrnam_r(__cb, __grp, __buf, __len, __res));
}

#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

extern struct group *getgrgid_r(gid_t, struct group *, char *, int);
extern struct group *getgrnam_r(const char *, struct group *, char *, int);

#endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)... */

#ifdef	__cplusplus
}
#endif

#endif	/* _GRP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_ICONV_H
#define	_ICONV_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct _iconv_info *iconv_t;

extern iconv_t	iconv_open(const char *, const char *);
#ifdef _XPG6
extern size_t	iconv(iconv_t, char **_RESTRICT_KYWD,
		size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
		size_t *_RESTRICT_KYWD);
#else
extern size_t	iconv(iconv_t, const char **_RESTRICT_KYWD,
		size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
		size_t *_RESTRICT_KYWD);
#endif
extern int	iconv_close(iconv_t);

#ifdef	__cplusplus
}
#endif

#endif	/* _ICONV_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T */
/*	  All Rights Reserved */


#ifndef _IEEEFP_H
#define	_IEEEFP_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Floating point enviornment for machines that support
 * the IEEE 754 floating-point standard.  This file currently
 * supports the 80*87, and SPARC families.
 *
 * This header defines the following interfaces:
 *	1) Classes of floating point numbers
 *	2) Rounding Control
 *	3) Exception Control
 *	4) Exception Handling
 *	5) Utility Macros
 *	6) Full Exception Environment Control
 */

/*
 * CLASSES of floating point numbers *************************
 * IEEE floating point values fall into 1 of the following 10
 * classes
 */
typedef	enum	fpclass_t {
	FP_SNAN = 0,	/* signaling NaN */
	FP_QNAN = 1,	/* quiet NaN */
	FP_NINF = 2,	/* negative infinity */
	FP_PINF = 3,	/* positive infinity */
	FP_NDENORM = 4, /* negative denormalized non-zero */
	FP_PDENORM = 5, /* positive denormalized non-zero */
	FP_NZERO = 6,	/* -0.0 */
	FP_PZERO = 7,   /* +0.0 */
	FP_NNORM = 8,	/* negative normalized non-zero */
	FP_PNORM = 9	/* positive normalized non-zero */
} fpclass_t;

extern fpclass_t fpclass(double);	/* get class of double value */
extern int	finite(double);
extern int	unordered(double, double);

/*
 * ROUNDING CONTROL ******************************************
 *
 * At all times, floating-point math is done using one of four
 * mutually-exclusive rounding modes.
 */

#if defined(__i386) || defined(__amd64)

/*
 * NOTE: the values given are chosen to match those used by the
 * 80*87 rounding mode field in the control word.
 */
typedef	enum	fp_rnd {
	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) */
} fp_rnd;

#endif

#if defined(__sparc)

/*
 * NOTE: the values given are chosen to match those used by the
 * RD (Round Direction) field of the FSR (Floating Point State Register).
 */
typedef	enum	fp_rnd {
	FP_RN = 0,	/* round to nearest representable number, tie -> even */
	FP_RZ = 1,	/* round toward zero (truncate) */
	FP_RP = 2,	/* round toward plus infinity */
	FP_RM = 3	/* round toward minus infinity */
} fp_rnd;

#endif

extern fp_rnd	fpsetround(fp_rnd);	/* set rounding mode, return previous */
extern fp_rnd	fpgetround(void);	/* return current rounding mode */

/*
 * EXCEPTION CONTROL *****************************************
 *
 */

#define	fp_except	int

#define	FP_DISABLE	0	/* exception will be ignored */
#define	FP_ENABLE	1	/* exception will cause SIGFPE */
#define	FP_CLEAR	0	/* exception has not occurred */
#define	FP_SET		1	/* exception has occurred */

#if defined(__i386) || defined(__amd64)

/*
 * There are six floating point exceptions, which can be individually
 * ENABLED (== 1) or DISABLED (== 0).  When an exception occurs
 * (ENABLED or not), the fact is noted by changing an associated
 * "sticky bit" from CLEAR (==0) to SET (==1).
 *
 * NOTE: the bit positions in fp_except are chosen to match those of
 * the 80*87 control word mask bits.  Although the 87 chips actually
 * ENABLE exceptions with a mask value of 0 (not 1, as on the 3b), it
 * is felt that switching these values may create more problems than
 * it solves.
 */

/* an fp_except can have the following (not exclusive) values: */
#define	FP_X_INV	0x01	/* invalid operation exception */
#define	FP_X_DNML	0x02	/* denormalization exception */
#define	FP_X_DZ		0x04	/* divide-by-zero exception */
#define	FP_X_OFL	0x08	/* overflow exception */
#define	FP_X_UFL	0x10	/* underflow exception */
#define	FP_X_IMP	0x20	/* imprecise (loss of precision) */

#endif

#if defined(__sparc)

/*
 * There are five floating-point exceptions, which can be individually
 * ENABLED (== 1) or DISABLED (== 0).  When an exception occurs
 * (ENABLED or not), the fact is noted by changing an associated
 * "sticky bit" from CLEAR (==0) to SET (==1).
 *
 * NOTE: the bit positions in an fp_except are chosen to match that in
 * the Trap Enable Mask of the FSR (Floating Point State Register).
 */

/* an fp_except can have the following (not exclusive) values: */
#define	FP_X_INV	0x10	/* invalid operation exception */
#define	FP_X_OFL	0x08	/* overflow exception */
#define	FP_X_UFL	0x04	/* underflow exception */
#define	FP_X_DZ		0x02	/* divide-by-zero exception */
#define	FP_X_IMP	0x01	/* imprecise (loss of precision) */

#endif

extern fp_except fpgetmask(void);		/* current exception mask */
extern fp_except fpsetmask(fp_except);		/* set mask, return previous */
extern fp_except fpgetsticky(void);		/* return logged exceptions */
extern fp_except fpsetsticky(fp_except);	/* change logged exceptions */

/*
 * UTILITY MACROS ********************************************
 */

extern int isnanf(float);
extern int isnand(double);

#if defined(__i386) || defined(__amd64)

/*
 * EXCEPTION HANDLING ****************************************
 *
 * When a signal handler catches an FPE, it will have a freshly initialized
 * coprocessor.  This allows signal handling routines to make use of
 * floating point arithmetic, if need be.  The previous state of the 87
 * chip is available, however.  There are two ways to get at this information,
 * depending on how the signal handler was set up.
 *
 * If the handler was set via signal() or sigset(), the old, SVR3, method
 * should be used: the signal handler assumes that it has a single parameter,
 * which is of type struct _fpstackframe, defined below.  By investigating
 * this parameter, the cause of the FPE may be determined.  By modifying it,
 * the state of the coprocessor can be changed upon return to the main task.
 * THIS METHOD IS OBSOLETE, AND MAY NOT BE SUPPORTED IN FUTURE RELEASES.
 *
 * If the handler was set via sigaction(), the new, SVR4, method should be
 * used: the third argument to the handler will be a pointer to a ucontext
 * structure (see sys/ucontext.h).  The uc_mcontext.fpregs member of the
 * ucontext structure holds the saved floating-point registers.  This can be
 * examined and/or modified.  By modifying it, the state of the coprocessor
 * can be changed upon return to the main task.
 */

struct _fpreg {	/* structure of a temp real fp register */
	unsigned short significand[4];	/* 64 bit mantissa value */
	unsigned short exponent;	/* 15 bit exponent and sign bit */
};

#if defined(__i386)

/*
 * AMD64 users should use sigaction() as described above.
 */

struct _fpstackframe {		/* signal handler's argument */
	long signo;		/* signal number arg */
	long regs[19];		/* all registers */
	struct _fpstate *fpsp;	/* address of saved 387 state */
	char *wsp;		/* address of saved Weitek state */
};

#endif

#if defined(__i386) || defined(__amd64)

#if defined(__amd64)
#define	_fpstate _fpstate32
#endif

struct _fpstate {		/* saved state info from an exception */
	unsigned int	cw,	/* control word */
			sw,	/* status word after fnclex-not useful */
			tag,	/* tag word */
			ipoff,	/* %eip register */
			cssel,	/* code segment selector */
			dataoff, /* data operand address */
			datasel; /* data operand selector */
	struct _fpreg _st[8];	/* saved register stack */
	unsigned int status;	/* status word saved at exception */
	unsigned int mxcsr;
	unsigned int xstatus;	/* status word saved at exception */
	unsigned int __pad[2];
	unsigned int xmm[8][4];
};

#if defined(__amd64)
#undef	_fpstate
#endif

#endif	/* __i386 || __amd64 */

/*
 * The structure of the 80*87 status and control words, and the mxcsr
 * register are given by the following structures.
 */
struct _cw87 {
	unsigned
		mask:	6,	/* exception masks */
		res1:	2,	/* not used */
		prec:	2,	/* precision control field */
		rnd:	2,	/* rounding control field */
		inf:	1,	/* infinity control (not on 387) */
		res2:	3;	/* not used */
};

struct _sw87 {
	unsigned
		excp:	6,	/* exception sticky bits */
		res1:	1,	/* not used */
		errs:	1,	/* error summary-set if unmasked excp */
		c012:	3,	/* condition code bits 0..2 */
		stkt:	3,	/* stack top pointer */
		c3:	1,	/* condition code bit 3 */
		busy:	1;	/* coprocessor busy */
};

struct _mxcsr {
	unsigned
		excp:	6,	/* exception sticky bits */
		daz:	1,	/* denormals are zeroes */
		mask:	6,	/* exception masks */
		rnd:	2,	/* rounding control */
		fzero:	1;	/* flush to zero */
};

#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _IEEEFP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright 2022 Sebastian Wiedenroth
 */
#ifndef _IFADDRS_H
#define	_IFADDRS_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>

/*
 * The `getifaddrs' function generates a linked list of these structures.
 * Each element of the list describes one network interface.
 */
#if defined(_INT64_TYPE)
struct ifaddrs {
	struct ifaddrs	*ifa_next;	/* Pointer to the next structure. */
	char		*ifa_name;	/* Name of this network interface. */
	uint64_t	ifa_flags;	/* Flags as from SIOCGLIFFLAGS ioctl. */
	struct sockaddr	*ifa_addr;	/* Network address of this interface. */
	struct sockaddr	*ifa_netmask;	/* Netmask of this interface. */
	union {
		/*
		 * At most one of the following two is valid.  If the
		 * IFF_BROADCAST bit is set in `ifa_flags', then
		 * `ifa_broadaddr' is valid.  If the IFF_POINTOPOINT bit is
		 * set, then `ifa_dstaddr' is valid. It is never the case that
		 * both these bits are set at once.
		 */
		struct sockaddr	*ifu_broadaddr;
		struct sockaddr	*ifu_dstaddr;
	} ifa_ifu;
	void		*ifa_data; /* Address-specific data (may be unused). */
/*
 * This may have been defined in <net/if.h>.
 */
#ifndef ifa_broadaddr
#define	ifa_broadaddr	ifa_ifu.ifu_broadaddr	/* broadcast address */
#endif
#ifndef ifa_dstaddr
#define	ifa_dstaddr	ifa_ifu.ifu_dstaddr	/* other end of p-to-p link */
#endif
};
#endif

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getifaddrs __getifaddrs
#else
extern int __getifaddrs(struct ifaddrs **);
#define	getifaddrs __getifaddrs
#endif

/*
 * Create a linked list of `struct ifaddrs' structures, one for each
 * network interface on the host machine.  If successful, store the
 * list in *ifap and return 0.  On errors, return -1 and set `errno'.
 *
 * The storage returned in *ifap is allocated dynamically and can
 * only be properly freed by passing it to `freeifaddrs'.
 */
extern int getifaddrs(struct ifaddrs **);

/* Reclaim the storage allocated by a previous `getifaddrs' call. */
extern void freeifaddrs(struct ifaddrs *);


#ifdef	__cplusplus
}
#endif

#endif	/* _IFADDRS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _INTTYPES_H
#define	_INTTYPES_H

/*
 * This file, <inttypes.h>, is specified by the ISO C standard,
 * standard, ISO/IEC 9899:1999 Programming language - C and is
 * also defined by SUSv3.
 *
 * ISO	  International Organization for Standardization.
 * SUSv3  Single Unix Specification, Version 3
 */

#include <sys/feature_tests.h>
#include <sys/inttypes.h>

#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \
	defined(__EXTENSIONS__)
#include <sys/stdint.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Inclusion of <stddef.h> breaks namespace, therefore define wchar_t */

/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef	int	wchar_t;
#else
typedef	long	wchar_t;
#endif
#endif	/* !_WCHAR_T */
#endif	/* !__cplusplus || (__cplusplus < 199711L && !__GNUG__) */

#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \
	defined(__EXTENSIONS__)
typedef struct {
	intmax_t quot;
	intmax_t rem;
} imaxdiv_t;
#endif /* (!defined(_XOPEN_SOURCE) || defined(_XPG6)) ... */

#if !defined(_LP64) && !defined(_LONGLONG_TYPE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname imaxabs	_imaxabs_c89
#pragma	redefine_extname imaxdiv	_imaxdiv_c89
#pragma	redefine_extname strtoimax	_strtoimax_c89
#pragma	redefine_extname strtoumax	_strtoumax_c89
#pragma	redefine_extname wcstoimax	_wcstoimax_c89
#pragma	redefine_extname wcstoumax	_wcstoumax_c89
#else
#define	imaxabs		_imaxabs_c89
#define	imaxdiv		_imaxdiv_c89
#define	strtoimax	_strtoimax_c89
#define	strtoumax	_strtoumax_c89
#define	wcstoimax	_wcstoimax_c89
#define	wcstoumax	_wcstoumax_c89
#endif
#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */

#if (!defined(_XOPEN_SOURCE) || defined(_XPG6)) || defined(_STDC_C99) || \
	defined(__EXTENSIONS__)

extern intmax_t  imaxabs(intmax_t);
extern imaxdiv_t imaxdiv(intmax_t, intmax_t);
extern intmax_t  strtoimax(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
	int);
extern uintmax_t strtoumax(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
	int);
extern intmax_t  wcstoimax(const wchar_t *_RESTRICT_KYWD,
	wchar_t **_RESTRICT_KYWD, int);
extern uintmax_t wcstoumax(const wchar_t *_RESTRICT_KYWD,
	wchar_t **_RESTRICT_KYWD, int);

#endif /* (!defined(_XOPEN_SOURCE) || defined(_XPG6)) ... */

#ifdef __cplusplus
}
#endif

#endif /* _INTTYPES_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2016 Joyent, Inc.
 * Copyright 2025 Oxide Computer Company
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _ISO_ASSERT_ISO_H
#define	_ISO_ASSERT_ISO_H

/*
 * This file contains all of the portions of the assert.h implementation that we
 * wish to be re-entrant safe. This is not in <assert.h> as a number of
 * third-party applications have tried to use their own wrappers that use a
 * header guard, which lead to us losing the definitions that we need to have.
 * While those applications are potentially using the implementation namespace
 * incorrectly, separating out the two logical uses is helpful nonetheless and
 * hopefully makes it clearer what is what.
 *
 * This header should not be included directly by applications!
 */

#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * This does not use _STDC_C99 as it must match the definition of assert in
 * <assert.h>. Many C++ compilers on illumos have defined either a
 * __STDC_VERSION__ or the internal definitions such as _STDC_C99 so mixing
 * these can result in either missing the macro or the function prototype.
 */
#if (__cplusplus - 0 >= 201103L) || (__STDC_VERSION__ - 0 >= 199901L)
extern _NORETURN_KYWD void __assert_c99(const char *, const char *, int,
    const char *) __NORETURN;
#else
extern _NORETURN_KYWD void __assert(const char *, const char *, int) __NORETURN;
#endif /* __cplusplus - 0 >= 201103L || (__STDC_VERSION__ - 0 >= 199901L) */

/*
 * In C11 the static_assert macro is always defined, unlike the assert macro.
 * Starting in C23, static_assert is a keyword, so this is no longer required.
 */
#if defined(_STDC_C11) && !defined(__cplusplus) && !defined(_STDC_C23)
#define	static_assert	_Static_assert
#endif /* _STDC_C11 && !defined(__cplusplus) && !_STDC_C23 */

#ifdef __cplusplus
}
#endif

#endif /* _ISO_ASSERT_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <ctype.h>.
 */

#ifndef _ISO_CTYPE_ISO_H
#define	_ISO_CTYPE_ISO_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	_U	0x00000001	/* Upper case */
#define	_L	0x00000002	/* Lower case */
#define	_N	0x00000004	/* Numeral (digit) */
#define	_S	0x00000008	/* Spacing character */
#define	_P	0x00000010	/* Punctuation */
#define	_C	0x00000020	/* Control character */
#define	_B	0x00000040	/* Blank */
#define	_X	0x00000080	/* heXadecimal digit */

#define	_ISUPPER	_U
#define	_ISLOWER	_L
#define	_ISDIGIT	_N
#define	_ISSPACE	_S
#define	_ISPUNCT	_P
#define	_ISCNTRL	_C
#define	_ISBLANK	_B
#define	_ISXDIGIT	_X
#define	_ISGRAPH	0x00002000
#define	_ISALPHA	0x00004000
#define	_ISPRINT	0x00008000
#define	_ISALNUM	(_ISALPHA | _ISDIGIT)

extern unsigned char	__ctype[];
extern unsigned int	*__ctype_mask;
extern int		*__trans_upper;
extern int		*__trans_lower;

#if __cplusplus >= 199711L
namespace std {
#endif

/*
 * These used to be macros, which while more efficient, precludes operation
 * with thread specific locales.  The old macros will still work, but new
 * code compiles to use functions.  This is specifically permitted by the
 * various standards.  Only _tolower and _toupper were required to be
 * delivered in macro form.
 */
extern int isalnum(int);
extern int isalpha(int);
extern int iscntrl(int);
extern int isdigit(int);
extern int isgraph(int);
extern int islower(int);
extern int isprint(int);
extern int ispunct(int);
extern int isspace(int);
extern int isupper(int);
extern int isxdigit(int);
#if defined(_XPG6) || defined(_STDC_C99) || !defined(_STRICT_SYMBOLS)
extern int isblank(int);
#endif

extern int tolower(int);
extern int toupper(int);

#if __cplusplus >= 199711L
} /* end of namespace std */
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_CTYPE_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <limits.h>.
 */

#ifndef _ISO_LIMITS_ISO_H
#define	_ISO_LIMITS_ISO_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Sizes of integral types
 */
#define	CHAR_BIT	8		/* max # of bits in a "char" */
#define	SCHAR_MIN	(-128)		/* min value of a "signed char" */
#define	SCHAR_MAX	127		/* max value of a "signed char" */
#define	UCHAR_MAX	255		/* max value of an "unsigned char" */

#define	MB_LEN_MAX	5

#if defined(_CHAR_IS_SIGNED)
#define	CHAR_MIN	SCHAR_MIN	/* min value of a "char" */
#define	CHAR_MAX	SCHAR_MAX	/* max value of a "char" */
#elif defined(_CHAR_IS_UNSIGNED)
#define	CHAR_MIN	0		/* min value of a "char" */
#define	CHAR_MAX	UCHAR_MAX	/* max value of a "char" */
#else
#error "chars are signed or unsigned"
#endif

#define	SHRT_MIN	(-32768)	/* min value of a "short int" */
#define	SHRT_MAX	32767		/* max value of a "short int" */
#define	USHRT_MAX	65535		/* max value of "unsigned short int" */
#define	INT_MIN		(-2147483647-1)	/* min value of an "int" */
#define	INT_MAX		2147483647	/* max value of an "int" */
#define	UINT_MAX	4294967295U	/* max value of an "unsigned int" */
#if defined(_LP64)
#define	LONG_MIN	(-9223372036854775807L-1L)
					/* min value of a "long int" */
#define	LONG_MAX	9223372036854775807L
					/* max value of a "long int" */
#define	ULONG_MAX	18446744073709551615UL
					/* max value of "unsigned long int" */
#else	/* _ILP32 */
#define	LONG_MIN	(-2147483647L-1L)
					/* min value of a "long int" */
#define	LONG_MAX	2147483647L	/* max value of a "long int" */
#define	ULONG_MAX	4294967295UL	/* max value of "unsigned long int" */
#endif
#if !defined(_STRICT_STDC) || defined(_STDC_C99) || defined(__EXTENSIONS__)
#define	LLONG_MIN	(-9223372036854775807LL-1LL)
					/* min value of a long long */
#define	LLONG_MAX	9223372036854775807LL
					/* max value of a long long */
#define	ULLONG_MAX	18446744073709551615ULL
					/* max value of "unsigned long long */
#endif /* !defined(_STRICT_STDC) || defined(_STDC_C99)... */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_LIMITS_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <locale.h>.
 */

#ifndef	_ISO_LOCALE_ISO_H
#define	_ISO_LOCALE_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>

#ifdef __cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

struct lconv {
	char *decimal_point;
	char *thousands_sep;
	char *grouping;
	char *int_curr_symbol;
	char *currency_symbol;
	char *mon_decimal_point;
	char *mon_thousands_sep;
	char *mon_grouping;
	char *positive_sign;
	char *negative_sign;
	char int_frac_digits;
	char frac_digits;
	char p_cs_precedes;
	char p_sep_by_space;
	char n_cs_precedes;
	char n_sep_by_space;
	char p_sign_posn;
	char n_sign_posn;

/*
 * New in IEEE Std 1003.1-2001 for alignment with the ISO/IEC 9899:1999
 * standard.  Namespace and binary compatibility dictate that visibility
 * of these new members be limited, but all instances of this structure created
 * by libc include space for the new fields.   The new fields are excluded in a
 * strictly-conforming pre-C99 environment if _LCONV_C99 is not also defined.
 */
#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C99) || defined(_LCONV_C99)
	char int_p_cs_precedes;
	char int_p_sep_by_space;
	char int_n_cs_precedes;
	char int_n_sep_by_space;
	char int_p_sign_posn;
	char int_n_sign_posn;
#endif
};

#define	LC_CTYPE	0
#define	LC_NUMERIC	1
#define	LC_TIME		2
#define	LC_COLLATE	3
#define	LC_MONETARY	4
#define	LC_MESSAGES	5
#define	LC_ALL		6

extern char	*setlocale(int, const char *);
extern struct lconv *localeconv(void);

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_LOCALE_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _ISO_MATH_C99_H
#define	_ISO_MATH_C99_H

#include <sys/isa_defs.h>
#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

#undef	FP_ZERO
#define	FP_ZERO		0
#undef	FP_SUBNORMAL
#define	FP_SUBNORMAL	1
#undef	FP_NORMAL
#define	FP_NORMAL	2
#undef	FP_INFINITE
#define	FP_INFINITE	3
#undef	FP_NAN
#define	FP_NAN		4

#if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__)
#if defined(__GNUC__)
#undef	HUGE_VAL
#define	HUGE_VAL	(__builtin_huge_val())
#undef	HUGE_VALF
#define	HUGE_VALF	(__builtin_huge_valf())
#undef	HUGE_VALL
#define	HUGE_VALL	(__builtin_huge_vall())
#undef	INFINITY
#define	INFINITY	(__builtin_inff())
#undef	NAN
#define	NAN		(__builtin_nanf(""))

/*
 * C99 7.12.3 classification macros
 */
#undef	isnan
#undef	isinf
#if __GNUC__ >= 4
#define	fpclassify(x)	__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, \
    FP_SUBNORMAL, FP_ZERO, x)
#define	isnan(x)	__builtin_isnan(x)
#define	isinf(x)	__builtin_isinf(x)
#define	isfinite(x)	(__builtin_isfinite(x) != 0)
#define	isnormal(x)	(__builtin_isnormal(x) != 0)
#define	signbit(x)	(__builtin_signbit(x) != 0)
#else  /* __GNUC__ >= 4 */
#define	isnan(x)	__extension__( \
			{ __typeof(x) __x_n = (x); \
			__builtin_isunordered(__x_n, __x_n); })
#define	isinf(x)	__extension__( \
			{ __typeof(x) __x_i = (x); \
			__x_i == (__typeof(__x_i)) INFINITY || \
			__x_i == (__typeof(__x_i)) (-INFINITY); })
#undef	isfinite
#define	isfinite(x)	__extension__( \
			{ __typeof(x) __x_f = (x); \
			!isnan(__x_f) && !isinf(__x_f); })
#undef	isnormal
#define	isnormal(x)	__extension__( \
			{ __typeof(x) __x_r = (x); isfinite(__x_r) && \
			(sizeof (__x_r) == sizeof (float) ? \
			__builtin_fabsf(__x_r) >= __FLT_MIN__ : \
			sizeof (__x_r) == sizeof (double) ? \
			__builtin_fabs(__x_r) >= __DBL_MIN__ : \
			__builtin_fabsl(__x_r) >= __LDBL_MIN__); })
#undef	fpclassify
#define	fpclassify(x)	__extension__( \
			{ __typeof(x) __x_c = (x); \
			isnan(__x_c) ? FP_NAN : \
			isinf(__x_c) ? FP_INFINITE : \
			isnormal(__x_c) ? FP_NORMAL : \
			__x_c == (__typeof(__x_c)) 0 ? FP_ZERO : \
			FP_SUBNORMAL; })
#undef	signbit
#if defined(_BIG_ENDIAN)
#define	signbit(x)	__extension__( \
			{ __typeof(x) __x_s = (x); \
			(int)(*(unsigned *)&__x_s >> 31); })
#elif defined(_LITTLE_ENDIAN)
#define	signbit(x)	__extension__( \
			{ __typeof(x) __x_s = (x); \
			(sizeof (__x_s) == sizeof (float) ? \
			(int)(*(unsigned *)&__x_s >> 31) : \
			sizeof (__x_s) == sizeof (double) ? \
			(int)(((unsigned *)&__x_s)[1] >> 31) : \
			(int)(((unsigned short *)&__x_s)[4] >> 15)); })
#endif	/* defined(_BIG_ENDIAN) */
#endif	/* __GNUC__ >= 4 */

/*
 * C99 7.12.14 comparison macros
 */
#undef	isgreater
#define	isgreater(x, y)		__builtin_isgreater(x, y)
#undef	isgreaterequal
#define	isgreaterequal(x, y)	__builtin_isgreaterequal(x, y)
#undef	isless
#define	isless(x, y)		__builtin_isless(x, y)
#undef	islessequal
#define	islessequal(x, y)	__builtin_islessequal(x, y)
#undef	islessgreater
#define	islessgreater(x, y)	__builtin_islessgreater(x, y)
#undef	isunordered
#define	isunordered(x, y)	__builtin_isunordered(x, y)
#else	/* defined(__GNUC__) */
#undef	HUGE_VAL
#define	HUGE_VAL	__builtin_huge_val
#undef	HUGE_VALF
#define	HUGE_VALF	__builtin_huge_valf
#undef	HUGE_VALL
#define	HUGE_VALL	__builtin_huge_vall
#undef	INFINITY
#define	INFINITY	__builtin_infinity
#undef	NAN
#define	NAN		__builtin_nan

/*
 * C99 7.12.3 classification macros
 */
#undef	fpclassify
#define	fpclassify(x)	__builtin_fpclassify(x)
#undef	isfinite
#define	isfinite(x)	__builtin_isfinite(x)
#undef	isinf
#define	isinf(x)	__builtin_isinf(x)
#undef	isnan
#define	isnan(x)	__builtin_isnan(x)
#undef	isnormal
#define	isnormal(x)	__builtin_isnormal(x)
#undef	signbit
#define	signbit(x)	__builtin_signbit(x)

/*
 * C99 7.12.14 comparison macros
 */
#undef	isgreater
#define	isgreater(x, y)		((x) __builtin_isgreater(y))
#undef	isgreaterequal
#define	isgreaterequal(x, y)	((x) __builtin_isgreaterequal(y))
#undef	isless
#define	isless(x, y)		((x) __builtin_isless(y))
#undef	islessequal
#define	islessequal(x, y)	((x) __builtin_islessequal(y))
#undef	islessgreater
#define	islessgreater(x, y)	((x) __builtin_islessgreater(y))
#undef	isunordered
#define	isunordered(x, y)	((x) __builtin_isunordered(y))
#endif	/* defined(__GNUC__) */
#endif	/* defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || ... */

#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(__C99FEATURES__)
#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ - 0 == 0
typedef float float_t;
typedef double double_t;
#elif __FLT_EVAL_METHOD__ - 0 == 1
typedef double float_t;
typedef double double_t;
#elif __FLT_EVAL_METHOD__ - 0 == 2
typedef long double float_t;
typedef long double double_t;
#elif defined(__sparc) || defined(__amd64)
typedef float float_t;
typedef double double_t;
#elif defined(__i386)
typedef long double float_t;
typedef long double double_t;
#endif

#undef	FP_ILOGB0
#define	FP_ILOGB0	(-2147483647)
#undef	FP_ILOGBNAN
#define	FP_ILOGBNAN	2147483647

#undef	MATH_ERRNO
#define	MATH_ERRNO	1
#undef	MATH_ERREXCEPT
#define	MATH_ERREXCEPT	2
#undef	math_errhandling
#define	math_errhandling	MATH_ERREXCEPT

extern double acosh(double);
extern double asinh(double);
extern double atanh(double);

extern double exp2(double);
extern double expm1(double);
extern int ilogb(double);
extern double log1p(double);
extern double log2(double);
extern double logb(double);
extern double scalbn(double, int);
extern double scalbln(double, long int);

extern double cbrt(double);
extern double hypot(double, double);

extern double erf(double);
extern double erfc(double);
extern double lgamma(double);
extern double tgamma(double);

extern double nearbyint(double);
extern double rint(double);
extern long int lrint(double);
extern double round(double);
extern long int lround(double);
extern double trunc(double);

extern double remainder(double, double);
extern double remquo(double, double, int *);

extern double copysign(double, double);
extern double nan(const char *);
extern double nextafter(double, double);
extern double nexttoward(double, long double);

extern double fdim(double, double);
extern double fmax(double, double);
extern double fmin(double, double);

extern double fma(double, double, double);

extern float acosf(float);
extern float asinf(float);
extern float atanf(float);
extern float atan2f(float, float);
extern float cosf(float);
extern float sinf(float);
extern float tanf(float);

extern float acoshf(float);
extern float asinhf(float);
extern float atanhf(float);
extern float coshf(float);
extern float sinhf(float);
extern float tanhf(float);

extern float expf(float);
extern float exp2f(float);
extern float expm1f(float);
extern float frexpf(float, int *);
extern int ilogbf(float);
extern float ldexpf(float, int);
extern float logf(float);
extern float log10f(float);
extern float log1pf(float);
extern float log2f(float);
extern float logbf(float);
extern float modff(float, float *);
extern float scalbnf(float, int);
extern float scalblnf(float, long int);

extern float cbrtf(float);
extern float fabsf(float);
extern float hypotf(float, float);
extern float powf(float, float);
extern float sqrtf(float);

extern float erff(float);
extern float erfcf(float);
extern float lgammaf(float);
extern float tgammaf(float);

extern float ceilf(float);
extern float floorf(float);
extern float nearbyintf(float);
extern float rintf(float);
extern long int lrintf(float);
extern float roundf(float);
extern long int lroundf(float);
extern float truncf(float);

extern float fmodf(float, float);
extern float remainderf(float, float);
extern float remquof(float, float, int *);

extern float copysignf(float, float);
extern float nanf(const char *);
extern float nextafterf(float, float);
extern float nexttowardf(float, long double);

extern float fdimf(float, float);
extern float fmaxf(float, float);
extern float fminf(float, float);

extern float fmaf(float, float, float);

extern long double acosl(long double);
extern long double asinl(long double);
extern long double atanl(long double);
extern long double atan2l(long double, long double);
extern long double cosl(long double);
extern long double sinl(long double);
extern long double tanl(long double);

extern long double acoshl(long double);
extern long double asinhl(long double);
extern long double atanhl(long double);
extern long double coshl(long double);
extern long double sinhl(long double);
extern long double tanhl(long double);

extern long double expl(long double);
extern long double exp2l(long double);
extern long double expm1l(long double);
extern long double frexpl(long double, int *);
extern int ilogbl(long double);
extern long double ldexpl(long double, int);
extern long double logl(long double);
extern long double log10l(long double);
extern long double log1pl(long double);
extern long double log2l(long double);
extern long double logbl(long double);
extern long double modfl(long double, long double *);
extern long double scalbnl(long double, int);
extern long double scalblnl(long double, long int);

extern long double cbrtl(long double);
extern long double fabsl(long double);
extern long double hypotl(long double, long double);
extern long double powl(long double, long double);
extern long double sqrtl(long double);

extern long double erfl(long double);
extern long double erfcl(long double);
extern long double lgammal(long double);
extern long double tgammal(long double);

extern long double ceill(long double);
extern long double floorl(long double);
extern long double nearbyintl(long double);
extern long double rintl(long double);
extern long int lrintl(long double);
extern long double roundl(long double);
extern long int lroundl(long double);
extern long double truncl(long double);

extern long double fmodl(long double, long double);
extern long double remainderl(long double, long double);
extern long double remquol(long double, long double, int *);

extern long double copysignl(long double, long double);
extern long double nanl(const char *);
extern long double nextafterl(long double, long double);
extern long double nexttowardl(long double, long double);

extern long double fdiml(long double, long double);
extern long double fmaxl(long double, long double);
extern long double fminl(long double, long double);

extern long double fmal(long double, long double, long double);

#if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
	defined(__C99FEATURES__)
extern long long int llrint(double);
extern long long int llround(double);

extern long long int llrintf(float);
extern long long int llroundf(float);

extern long long int llrintl(long double);
extern long long int llroundl(long double);
#endif

#endif	/* defined(__EXTENSIONS__) || defined(_STDC_C99) || ... */

#ifdef __cplusplus
}
#endif

#endif	/* _ISO_MATH_C99_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _ISO_MATH_ISO_H
#define	_ISO_MATH_ISO_H

#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && !defined(__C99FEATURES__)
typedef union _h_val {
	unsigned long _i[sizeof (double) / sizeof (unsigned long)];
	double _d;
} _h_val;

#ifdef __STDC__
extern const _h_val __huge_val;
#else
extern _h_val __huge_val;
#endif
#undef	HUGE_VAL
#define	HUGE_VAL __huge_val._d
#endif	/* !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && ... */

#if __cplusplus >= 199711L
namespace std {
#endif

extern double acos(double);
extern double asin(double);
extern double atan(double);
extern double atan2(double, double);
extern double cos(double);
extern double sin(double);
extern double tan(double);

extern double cosh(double);
extern double sinh(double);
extern double tanh(double);

extern double exp(double);
extern double frexp(double, int *);
extern double ldexp(double, int);
extern double log(double);
extern double log10(double);
extern double modf(double, double *);

extern double pow(double, double);
extern double sqrt(double);

extern double ceil(double);
extern double fabs(double);
extern double floor(double);
extern double fmod(double, double);

#if defined(__MATHERR_ERRNO_DONTCARE)
#pragma does_not_read_global_data(acos, asin, atan, atan2)
#pragma does_not_read_global_data(cos, sin, tan, cosh, sinh, tanh)
#pragma does_not_read_global_data(exp, log, log10, pow, sqrt)
#pragma does_not_read_global_data(frexp, ldexp, modf)
#pragma does_not_read_global_data(ceil, fabs, floor, fmod)
#pragma does_not_write_global_data(acos, asin, atan, atan2)
#pragma does_not_write_global_data(cos, sin, tan, cosh, sinh, tanh)
#pragma does_not_write_global_data(exp, log, log10, pow, sqrt)
#pragma does_not_write_global_data(ldexp)
#pragma does_not_write_global_data(ceil, fabs, floor, fmod)
#pragma no_side_effect(acos, asin, atan, atan2)
#pragma no_side_effect(cos, sin, tan, cosh, sinh, tanh)
#pragma no_side_effect(exp, log, log10, pow, sqrt)
#pragma no_side_effect(ldexp)
#pragma no_side_effect(ceil, fabs, floor, fmod)
#endif

#if __cplusplus >= 199711L
extern float __acosf(float);
extern float __asinf(float);
extern float __atanf(float);
extern float __atan2f(float, float);
extern float __ceilf(float);
extern float __cosf(float);
extern float __coshf(float);
extern float __expf(float);
extern float __fabsf(float);
extern float __floorf(float);
extern float __fmodf(float, float);
extern float __frexpf(float, int *);
extern float __ldexpf(float, int);
extern float __logf(float);
extern float __log10f(float);
extern float __modff(float, float *);
extern float __powf(float, float);
extern float __sinf(float);
extern float __sinhf(float);
extern float __sqrtf(float);
extern float __tanf(float);
extern float __tanhf(float);

extern long double __acosl(long double);
extern long double __asinl(long double);
extern long double __atanl(long double);
extern long double __atan2l(long double, long double);
extern long double __ceill(long double);
extern long double __cosl(long double);
extern long double __coshl(long double);
extern long double __expl(long double);
extern long double __fabsl(long double);
extern long double __floorl(long double);
extern long double __fmodl(long double, long double);
extern long double __frexpl(long double, int *);
extern long double __ldexpl(long double, int);
extern long double __logl(long double);
extern long double __log10l(long double);
extern long double __modfl(long double, long double *);
extern long double __powl(long double, long double);
extern long double __sinl(long double);
extern long double __sinhl(long double);
extern long double __sqrtl(long double);
extern long double __tanl(long double);
extern long double __tanhl(long double);

extern "C++" {
#undef	__X
#undef	__Y
	inline double abs(double __X) { return fabs(__X); }

	inline double pow(double __X, int __Y) {
		return (pow(__X, (double)(__Y)));
	}

	inline float abs(float __X) { return __fabsf(__X); }
	inline float acos(float __X) { return __acosf(__X); }
	inline float asin(float __X) { return __asinf(__X); }
	inline float atan(float __X) { return __atanf(__X); }
	inline float atan2(float __X, float __Y) { return __atan2f(__X, __Y); }
	inline float ceil(float __X) { return __ceilf(__X); }
	inline float cos(float __X) { return __cosf(__X); }
	inline float cosh(float __X) { return __coshf(__X); }
	inline float exp(float __X) { return __expf(__X); }
	inline float fabs(float __X) { return __fabsf(__X); }
	inline float floor(float __X) { return __floorf(__X); }
	inline float fmod(float __X, float __Y) { return __fmodf(__X, __Y); }
	inline float frexp(float __X, int *__Y) { return __frexpf(__X, __Y); }
	inline float ldexp(float __X, int __Y) { return __ldexpf(__X, __Y); }
	inline float log(float __X) { return __logf(__X); }
	inline float log10(float __X) { return __log10f(__X); }
	inline float modf(float __X, float *__Y) { return __modff(__X, __Y); }
	inline float pow(float __X, float __Y) { return __powf(__X, __Y); }

	inline float pow(float __X, int __Y) {
		return (pow((double)(__X), (double)(__Y)));
	}

	inline float sin(float __X) { return __sinf(__X); }
	inline float sinh(float __X) { return __sinhf(__X); }
	inline float sqrt(float __X) { return __sqrtf(__X); }
	inline float tan(float __X) { return __tanf(__X); }
	inline float tanh(float __X) { return __tanhf(__X); }

	inline long double abs(long double __X) { return __fabsl(__X); }
	inline long double acos(long double __X) { return __acosl(__X); }
	inline long double asin(long double __X) { return __asinl(__X); }
	inline long double atan(long double __X) { return __atanl(__X); }

	inline long double atan2(long double __X, long double __Y) {
		return (__atan2l(__X, __Y));
	}

	inline long double ceil(long double __X) { return __ceill(__X); }
	inline long double cos(long double __X) { return __cosl(__X); }
	inline long double cosh(long double __X) { return __coshl(__X); }
	inline long double exp(long double __X) { return __expl(__X); }
	inline long double fabs(long double __X) { return __fabsl(__X); }
	inline long double floor(long double __X) { return __floorl(__X); }

	inline long double fmod(long double __X, long double __Y) {
		return (__fmodl(__X, __Y));
	}

	inline long double frexp(long double __X, int *__Y) {
		return (__frexpl(__X, __Y));
	}

	inline long double ldexp(long double __X, int __Y) {
		return (__ldexpl(__X, __Y));
	}

	inline long double log(long double __X) { return __logl(__X); }
	inline long double log10(long double __X) { return __log10l(__X); }

	inline long double modf(long double __X, long double *__Y) {
		return (__modfl(__X, __Y));
	}

	inline long double pow(long double __X, long double __Y) {
		return (__powl(__X, __Y));
	}

	inline long double pow(long double __X, int __Y) {
		return (__powl(__X, (long double) (__Y)));
	}

	inline long double sin(long double __X) { return __sinl(__X); }
	inline long double sinh(long double __X) { return __sinhl(__X); }
	inline long double sqrt(long double __X) { return __sqrtl(__X); }
	inline long double tan(long double __X) { return __tanl(__X); }
	inline long double tanh(long double __X) { return __tanhl(__X); }
}	/* end of extern "C++" */
#endif	/* __cplusplus >= 199711L */

#if __cplusplus >= 199711L
}	/* end of namespace std */
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _ISO_MATH_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <setjmp.h>.
 */

#ifndef _ISO_SETJMP_ISO_H
#define	_ISO_SETJMP_ISO_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _JBLEN

/*
 * The sizes of the jump-buffer (_JBLEN) and the sigjump-buffer
 * (_SIGJBLEN) are defined by the appropriate, processor specific,
 * ABI.
 */
#if defined(__amd64)
#define	_JBLEN		8	/* ABI value */
#define	_SIGJBLEN	128	/* ABI value */
#elif defined(__i386)
#define	_JBLEN		10	/* ABI value */
#define	_SIGJBLEN	128	/* ABI value */
#elif defined(__sparcv9)
#define	_JBLEN		12	/* ABI value */
#define	_SIGJBLEN	19	/* ABI value */
#elif defined(__sparc)
#define	_JBLEN		12	/* ABI value */
#define	_SIGJBLEN	19	/* ABI value */
#else
#error "ISA not supported"
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

#if defined(__i386) || defined(__amd64) || \
	defined(__sparc) || defined(__sparcv9)
#if defined(_LP64)
typedef long	jmp_buf[_JBLEN];
#else
typedef int	jmp_buf[_JBLEN];
#endif
#else
#error "ISA not supported"
#endif

extern int setjmp(jmp_buf) __RETURNS_TWICE;
extern int _setjmp(jmp_buf) __RETURNS_TWICE;
extern void longjmp(jmp_buf, int) __NORETURN;
extern void _longjmp(jmp_buf, int) __NORETURN;

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#if __cplusplus >= 199711L
using std::setjmp;
#endif

#if defined(_STRICT_STDC) || __cplusplus >= 199711L
#define	setjmp(env)	setjmp(env)
#endif

#endif  /* _JBLEN */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_SETJMP_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1998-1999, by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <signal.h>.
 */

#ifndef _ISO_SIGNAL_ISO_H
#define	_ISO_SIGNAL_ISO_H

#include <sys/iso/signal_iso.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

typedef int	sig_atomic_t;

#ifdef __cplusplus
extern "C" SIG_PF signal(int, SIG_PF);
#else
extern void (*signal(int, void (*)(int)))(int);
#endif
extern int raise(int);

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_SIGNAL_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _ISO_STDARG_C99_H
#define	_ISO_STDARG_C99_H

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * This header defines the va_copy variable argument macro, which is
 * new in ISO C 1999, and thus not present in ISO C 1989 and ISO C++
 * 1998.  Because this macro is a long-standing Solaris extension, it
 * is also permitted in other contexts.
 *
 * The varargs definitions within this header are defined in terms of
 * implementation definitions.  These implementation definitions reside
 * in <sys/va_list.h>.  This organization enables protected use of
 * the implementation by other standard headers without introducing
 * names into the users' namespace.
 */

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * va_copy was initially a Solaris extension to provide a portable
 * way to perform a variable argument list ``bookmarking'' function.
 * It is now specified in the ISO/IEC 9899:1999 standard.
 */
#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG6)

#define	va_copy(to, from)	__va_copy(to, from)

#endif	/* defined(__EXTENSIONS__) || defined(_STDC_C99)... */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDARG_C99_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <stdarg.h>.
 */

#ifndef _ISO_STDARG_ISO_H
#define	_ISO_STDARG_ISO_H

/*
 * This header defines the ISO C 1989 and ISO C++ 1998 variable
 * argument definitions.
 *
 * The varargs definitions within this header are defined in terms of
 * implementation definitions.  These implementation definitions reside
 * in <sys/va_impl.h>.  This organization enables protected use of
 * the implementation by other standard headers without introducing
 * names into the users' namespace.
 */

#include <sys/va_impl.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
typedef __va_list va_list;
}
#elif !defined(_VA_LIST)
#define	_VA_LIST
typedef __va_list va_list;
#endif

#define	va_start(list, name)	__va_start(list, name)
#define	va_arg(list, type)	__va_arg(list, type)
#define	va_end(list)		__va_end(list)

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDARG_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 1999-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 2014 PALO, Richard.
 * Copyright 2016 Joyent, Inc.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <stddef.h.h>.
 */

#ifndef _ISO_STDDEF_ISO_H
#define	_ISO_STDDEF_ISO_H

#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
#define	_PTRDIFF_T
#if defined(_LP64)
typedef	long	ptrdiff_t;		/* pointer difference */
#else
typedef int	ptrdiff_t;		/* (historical version) */
#endif
#endif	/* !_PTRDIFF_T */

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned int	size_t;		/* (historical version) */
#endif
#endif	/* !_SIZE_T */

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#if !defined(_MAX_ALIGN_T)
#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
#define	_MAX_ALIGN_T
typedef	_MAX_ALIGNMENT_TYPE max_align_t;
#endif /* !_STRICT_SYMBOLS || _STDC_C11 */
#endif	/* _MAX_ALIGN_T */

#if __EXT1_VISIBLE
/* ISO/IEC 9899:2011 K.3.3.2 */
#ifndef	_RSIZE_T_DEFINED
#define	_RSIZE_T_DEFINED
typedef size_t rsize_t;
#endif
#endif	/* __EXT1_VISIBLE */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDDEF_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in
 * the C99 standard and in conflict with the C++ implementation of the
 * standard header.  The C++ standard may adopt the C99 standard at
 * which point it is expected that the symbols included here will
 * become part of the C++ std namespace.
 */

#ifndef _ISO_STDIO_C99_H
#define	_ISO_STDIO_C99_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The following have been added as a result of the ISO/IEC 9899:1999
 * standard. For a strictly conforming C application, visibility is
 * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h).
 * For non-strictly conforming C applications, there are no restrictions
 * on the C namespace.
 */

#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))

#if !defined(_LP64) && !defined(_LONGLONG_TYPE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname snprintf	_snprintf_c89
#pragma	redefine_extname vsnprintf	_vsnprintf_c89
#pragma	redefine_extname vfscanf	_vfscanf_c89
#pragma	redefine_extname vscanf		_vscanf_c89
#pragma	redefine_extname vsscanf	_vsscanf_c89
#else
#define	snprintf	_snprintf_c89
#define	vsnprintf	_vsnprintf_c89
#define	vfscanf		_vfscanf_c89
#define	vscanf		_vscanf_c89
#define	vsscanf		_vsscanf_c89
#endif
#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */

extern int vfscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, __va_list);
extern int vscanf(const char *_RESTRICT_KYWD, __va_list);
extern int vsscanf(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
		__va_list);
#endif /* defined(__EXTENSIONS__) ... */
#if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG5)
extern int snprintf(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD,
	...);
extern int vsnprintf(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD,
	__va_list);

#endif /* defined(__EXTENSIONS__) || defined(_STDC_C99) ... */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDIO_C99_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <stdio.h>.
 */

/*
 * User-visible pieces of the ANSI C standard I/O package.
 */

#ifndef _ISO_STDIO_ISO_H
#define	_ISO_STDIO_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>
#include <sys/va_list.h>
#include <stdio_tag.h>
#include <stdio_impl.h>

/*
 * If feature test macros are set that enable interfaces that use types
 * defined in <sys/types.h>, get those types by doing the include.
 *
 * Note that in asking for the interfaces associated with this feature test
 * macro one also asks for definitions of the POSIX types.
 */

#ifdef	__cplusplus
extern "C" {
#endif

#if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE))
/*
 * The following typedefs are adopted from ones in <sys/types.h> (with leading
 * underscores added to avoid polluting the ANSI C name space).  See the
 * commentary there for further explanation.
 */
#if defined(_LONGLONG_TYPE)
typedef	long long	__longlong_t;
#else
/* used to reserve space and generate alignment */
typedef union {
	double	_d;
	int	_l[2];
} __longlong_t;
#endif
#endif  /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_FILEDEFED) || __cplusplus >= 199711L
#define	_FILEDEFED
typedef	__FILE FILE;
#endif

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned int	size_t;		/* (historical version) */
#endif
#endif	/* !_SIZE_T */

#if defined(_LP64) || _FILE_OFFSET_BITS == 32
typedef long		fpos_t;
#else
typedef	__longlong_t	fpos_t;
#endif

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#define	BUFSIZ	1024

/*
 * The value of _NFILE is defined in the Processor Specific ABI.  The value
 * is chosen for historical reasons rather than for truly processor related
 * attribute.  Note that the SPARC Processor Specific ABI uses the common
 * UNIX historical value of 20 so it is allowed to fall through.
 */
#if defined(__i386)
#define	_NFILE	60	/* initial number of streams: Intel x86 ABI */
#else
#define	_NFILE	20	/* initial number of streams: SPARC ABI and default */
#endif

#define	_SBFSIZ	8	/* compatibility with shared libs */

#define	_IOFBF		0000	/* full buffered */
#define	_IOLBF		0100	/* line buffered */
#define	_IONBF		0004	/* not buffered */
#define	_IOEOF		0020	/* EOF reached on read */
#define	_IOERR		0040	/* I/O error from system */

#define	_IOREAD		0001	/* currently reading */
#define	_IOWRT		0002	/* currently writing */
#define	_IORW		0200	/* opened for reading and writing */
#define	_IOMYBUF	0010	/* stdio malloc()'d buffer */

#ifndef EOF
#define	EOF	(-1)
#endif

#define	FOPEN_MAX	_NFILE
#define	FILENAME_MAX    1024	/* max # of characters in a path name */

#define	SEEK_SET	0
#define	SEEK_CUR	1
#define	SEEK_END	2
#define	TMP_MAX		17576	/* 26 * 26 * 26 */

#define	L_tmpnam	25	/* (sizeof(P_tmpdir) + 15) */

extern __FILE	__iob[_NFILE];
#define	stdin	(&__iob[0])
#define	stdout	(&__iob[1])
#define	stderr	(&__iob[2])

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_LP64) && !defined(_LONGLONG_TYPE)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname fprintf	_fprintf_c89
#pragma redefine_extname printf		_printf_c89
#pragma redefine_extname sprintf	_sprintf_c89
#pragma redefine_extname vfprintf	_vfprintf_c89
#pragma redefine_extname vprintf	_vprintf_c89
#pragma redefine_extname vsprintf	_vsprintf_c89
#pragma redefine_extname fscanf		_fscanf_c89
#pragma redefine_extname scanf		_scanf_c89
#pragma redefine_extname sscanf		_sscanf_c89
#else
#define	fprintf		_fprintf_c89
#define	printf		_printf_c89
#define	sprintf		_sprintf_c89
#define	vfprintf	_vfprintf_c89
#define	vprintf		_vprintf_c89
#define	vsprintf	_vsprintf_c89
#define	fscanf		_fscanf_c89
#define	scanf		_scanf_c89
#define	sscanf		_sscanf_c89
#endif

#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */

extern int	remove(const char *);
extern int	rename(const char *, const char *);
extern FILE	*tmpfile(void);
extern char	*tmpnam(char *);
extern int	fclose(FILE *);
extern int	fflush(FILE *);
extern FILE	*fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern FILE	*freopen(const char *_RESTRICT_KYWD,
			const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
extern void	setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
extern int	setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int,
			size_t);
/* PRINTFLIKE2 */
extern int	fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
/* SCANFLIKE2 */
extern int	fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
/* PRINTFLIKE1 */
extern int	printf(const char *_RESTRICT_KYWD, ...);
/* SCANFLIKE1 */
extern int	scanf(const char *_RESTRICT_KYWD, ...);
/* PRINTFLIKE2 */
extern int	sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
/* SCANFLIKE2 */
extern int	sscanf(const char *_RESTRICT_KYWD,
			const char *_RESTRICT_KYWD, ...);
extern int	vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
			__va_list);
extern int	vprintf(const char *_RESTRICT_KYWD, __va_list);
extern int	vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
			__va_list);
extern int	fgetc(FILE *);
extern char	*fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD);
extern int	fputc(int, FILE *);
extern int	fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
	__cplusplus < 199711L
extern int	getc(FILE *);
extern int	putc(int, FILE *);
#endif
#if (__cplusplus >= 199711L && defined(_REENTRANT)) || \
	__cplusplus < 199711L
extern int	getchar(void);
extern int	putchar(int);
#endif

/*
 * ISO/IEC C11 removed gets from the standard library. Therefore if a strict C11
 * environment has been requested, we remove it.
 */
#if !defined(_STDC_C11) || defined(__EXTENSIONS__)
extern char	*gets(char *);
#endif
extern int	puts(const char *);
extern int	ungetc(int, FILE *);
extern size_t	fread(void *_RESTRICT_KYWD, size_t, size_t,
	FILE *_RESTRICT_KYWD);
extern size_t	fwrite(const void *_RESTRICT_KYWD, size_t, size_t,
	FILE *_RESTRICT_KYWD);
#if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32
extern int	fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD);
extern int	fsetpos(FILE *, const fpos_t *);
#endif
extern int	fseek(FILE *, long, int);
extern long	ftell(FILE *);
extern void	rewind(FILE *);
#if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
	__cplusplus < 199711L
extern void	clearerr(FILE *);
extern int	feof(FILE *);
extern int	ferror(FILE *);
#endif
extern void	perror(const char *);

#ifndef	_LP64
extern int	__filbuf(FILE *);
extern int	__flsbuf(int, FILE *);
#endif	/*	_LP64	*/

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#if !defined(__lint)

#if	!defined(_REENTRANT) && !defined(_LP64)

#if __cplusplus >= 199711L
namespace std {
inline int getc(FILE *_p) {
	return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); }
inline int putc(int _x, FILE *_p) {
	return (--_p->_cnt < 0 ? __flsbuf(_x, _p)
		: (int)(*_p->_ptr++ = (unsigned char) _x)); }
}
#else /* __cplusplus >= 199711L */
#define	getc(p)		(--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
#define	putc(x, p)	(--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
				: (int)(*(p)->_ptr++ = (unsigned char) (x)))
#endif /* __cplusplus >= 199711L */

#endif /* !defined(_REENTRANT) && !defined(_LP64) */

#ifndef	_REENTRANT

#if __cplusplus >= 199711L
namespace std {
inline int getchar() { return getc(stdin); }
inline int putchar(int _x) { return putc(_x, stdout); }
}
#else
#define	getchar()	getc(stdin)
#define	putchar(x)	putc((x), stdout)
#endif /* __cplusplus >= 199711L */

#ifndef	_LP64
#if __cplusplus >= 199711L
namespace std {
inline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); }
inline int feof(FILE *_p) { return _p->_flag & _IOEOF; }
inline int ferror(FILE *_p) { return _p->_flag & _IOERR; }
}
#else /* __cplusplus >= 199711L */
#define	clearerr(p)	((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
#define	feof(p)		((p)->_flag & _IOEOF)
#define	ferror(p)	((p)->_flag & _IOERR)
#endif /* __cplusplus >= 199711L */
#endif	/* _LP64 */

#endif	/* _REENTRANT */

#endif	/* !defined(__lint) */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDIO_ISO_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2016 Joyent, Inc.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other illumos headers.
 *
 * The contents of this header is limited to identifiers specified in
 * the C11 standard and in conflict with the C++ implementation of the
 * standard header.  The C++ standard may adopt the C11 standard at
 * which point it is expected that the symbols included here will
 * become part of the C++ std namespace.
 */

#ifndef _ISO_STDLIB_C11_H
#define	_ISO_STDLIB_C11_H

#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

/*
 * The following have been added as a result of the ISO/IEC 9899:2011
 * standard. For a strictly conforming C application, visibility is
 * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h).
 * For non-strictly conforming C applications, there are no restrictions
 * on the C namespace.
 */

/*
 * Work around fix-includes and other bad actors with using multiple headers.
 */
#if !defined(_NORETURN_KYWD)
#if __STDC_VERSION__ - 0 >= 201112L
#define	_NORETURN_KYWD	_Noreturn
#else
#define	_NORETURN_KYWD
#endif	/* __STDC_VERSION__ - 0 >= 201112L */
#endif	/* !defined(_NORETURN_KYWD) */

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
extern void *aligned_alloc(size_t, size_t);
#endif /* !_STRICT_SYMBOLS || _STDC_C11 */

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11) || __cplusplus >= 201103L
extern int at_quick_exit(void (*)(void));
extern _NORETURN_KYWD void quick_exit(int);
#endif /* !_STRICT_SYMBOLS || _STDC_C11 || __cplusplus >= 201103L */

#if __cplusplus >= 199711L
}
#endif

/*
 * ISO C11 Annex K functions are not allowed to be in the standard
 * namespace; however, it is implementation-defined as to whether or
 * not they are in the global namespace and we opt to make them
 * available to software.
 */
#if __EXT1_VISIBLE

#ifndef	_ERRNO_T_DEFINED
#define	_ERRNO_T_DEFINED
typedef int errno_t;
#endif

/* K.3.6 */
typedef void (*constraint_handler_t)(const char *_RESTRICT_KYWD,
    void *_RESTRICT_KYWD, errno_t);
/* K.3.6.1.1 */
extern constraint_handler_t set_constraint_handler_s(constraint_handler_t);
/* K.3.6.1.2 */
extern _NORETURN_KYWD void abort_handler_s(const char *_RESTRICT_KYWD,
    void *_RESTRICT_KYWD, errno_t);
/* K3.6.1.3 */
extern void ignore_handler_s(const char *_RESTRICT_KYWD, void *_RESTRICT_KYWD,
    errno_t);
#endif	/* __EXT1_VISIBLE */

#ifdef __cplusplus
}
#endif

#endif /* _ISO_STDLIB_C11_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in
 * the C99 standard and in conflict with the C++ implementation of the
 * standard header.  The C++ standard may adopt the C99 standard at
 * which point it is expected that the symbols included here will
 * become part of the C++ std namespace.
 */

#ifndef _ISO_STDLIB_C99_H
#define	_ISO_STDLIB_C99_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The following have been added as a result of the ISO/IEC 9899:1999
 * standard. For a strictly conforming C application, visibility is
 * contingent on the value of __STDC_VERSION__ (see sys/feature_tests.h).
 * For non-strictly conforming C applications, there are no restrictions
 * on the C namespace.
 */

#if defined(_LONGLONG_TYPE)
typedef struct {
	long long	quot;
	long long	rem;
} lldiv_t;
#endif  /* defined(_LONGLONG_TYPE) */

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_STDC_C99) || defined(__EXTENSIONS__)

#if !defined(_NORETURN_KYWD)
#if __STDC_VERSION__ - 0 >= 201112L
#define	_NORETURN_KYWD	_Noreturn
#else
#define	_NORETURN_KYWD
#endif	/* __STDC_VERSION__ - 0 >= 201112L */
#endif	/* !defined(_NORETURN_KYWD) */

extern _NORETURN_KYWD void _Exit(int);
extern float strtof(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
extern long double strtold(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);

#if defined(_LONGLONG_TYPE)
extern long long atoll(const char *);
extern long long llabs(long long);
extern lldiv_t lldiv(long long, long long);
extern long long strtoll(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
	int);
extern unsigned long long strtoull(const char *_RESTRICT_KYWD,
	char **_RESTRICT_KYWD, int);
#endif /* defined(_LONGLONG_TYPE) */

#endif  /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDLIB_C99_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <locale.h>.
 */

#ifndef _ISO_STDLIB_ISO_H
#define	_ISO_STDLIB_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

unsigned char __mb_cur_max(void);
#ifndef MB_CUR_MAX
#define	MB_CUR_MAX	(__mb_cur_max())
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

typedef	struct {
	int	quot;
	int	rem;
} div_t;

typedef struct {
	long	quot;
	long	rem;
} ldiv_t;

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned int    size_t;		/* (historical version) */
#endif
#endif	/* !_SIZE_T */

#define	EXIT_FAILURE	1
#define	EXIT_SUCCESS    0
#define	RAND_MAX	32767

/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef	int	wchar_t;
#else
typedef long	wchar_t;
#endif
#endif	/* !_WCHAR_T */
#endif	/* !defined(__cplusplus) ... */

#if !defined(_NORETURN_KYWD)
#if __STDC_VERSION__ - 0 >= 201112L
#define	_NORETURN_KYWD	_Noreturn
#else
#define	_NORETURN_KYWD
#endif	/* __STDC_VERSION__ - 0 >= 201112L */
#endif	/* !defined(_NORETURN_KYWD) */

extern _NORETURN_KYWD void abort(void) __NORETURN;
extern int abs(int);
extern int atexit(void (*)(void));
extern double atof(const char *);
extern int atoi(const char *);
extern long int atol(const char *);
extern void *bsearch(const void *, const void *, size_t, size_t,
	int (*)(const void *, const void *));
#if __cplusplus >= 199711L && defined(__SUNPRO_CC)
extern "C++" {
	void *bsearch(const void *, const void *, size_t, size_t,
		int (*)(const void *, const void *));
}
#endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
extern void *calloc(size_t, size_t);
extern div_t div(int, int);
extern _NORETURN_KYWD void exit(int)
	__NORETURN;
extern void free(void *);
extern char *getenv(const char *);
extern long int labs(long);
extern ldiv_t ldiv(long, long);
extern void *malloc(size_t);
extern int mblen(const char *, size_t);
extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
	size_t);
extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
#if __cplusplus >= 199711L && defined(__SUNPRO_CC)
extern "C++" {
	void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
}
#endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
extern int rand(void);
extern void *realloc(void *, size_t);
extern void srand(unsigned int);
extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
	char **_RESTRICT_KYWD, int);
extern int system(const char *);
extern int wctomb(char *, wchar_t);
extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
	size_t);

#if __cplusplus >= 199711L
extern "C++" {
	inline long   abs(long _l) { return labs(_l); }
	inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
}
#endif /* __cplusplus */

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STDLIB_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <string.h>.
 */

#ifndef _ISO_STRING_ISO_H
#define	_ISO_STRING_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned int	size_t;		/* (historical version) */
#endif
#endif	/* !_SIZE_T */

extern int memcmp(const void *, const void *, size_t);
extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t);
extern void *memmove(void *, const void *, size_t);
extern void *memset(void *, int, size_t);
extern char *strcat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern int strcmp(const char *, const char *);
extern char *strcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern int strcoll(const char *, const char *);
extern size_t strcspn(const char *, const char *);
extern char *strerror(int);
extern size_t strlen(const char *);
extern char *strncat(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
extern int strncmp(const char *, const char *, size_t);
extern char *strncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
extern size_t strspn(const char *, const char *);
extern char *strtok(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern size_t strxfrm(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);

/*
 * The C++ Standard (ISO/IEC 14882:1998) specifies that each of the
 * function signatures for the following functions be replaced by
 * two declarations, both of which have the same behavior.
 */
#if __cplusplus >= 199711L
extern const void *memchr(const void *, int, size_t);
#ifndef	_MEMCHR_INLINE
#define	_MEMCHR_INLINE
extern "C++" {
	inline void *memchr(void * __s, int __c, size_t __n) {
		return (void *)memchr((const void *)__s, __c, __n);
	}
}
#endif  /* _MEMCHR_INLINE */
extern const char *strchr(const char *, int);
#ifndef _STRCHR_INLINE
#define	_STRCHR_INLINE
extern "C++" {
	inline char *strchr(char *__s, int __c) {
		return (char *)strchr((const char *)__s, __c);
	}
}
#endif	/* _STRCHR_INLINE */
extern const char *strpbrk(const char *, const char *);
#ifndef _STRPBRK_INLINE
#define	_STRPBRK_INLINE
extern "C++" {
	inline char *strpbrk(char *__s1, const char *__s2) {
		return (char *)strpbrk((const char *)__s1, __s2);
	}
}
#endif	/* _STRPBRK_INLINE */
extern const char *strrchr(const char *, int);
#ifndef _STRRCHR_INLINE
#define	_STRRCHR_INLINE
extern "C++" {
	inline char *strrchr(char *__s, int __c) {
		return (char *)strrchr((const char *)__s, __c);
	}
}
#endif	/* _STRRCHR_INLINE */
extern const char *strstr(const char *, const char *);
#ifndef _STRSTR_INLINE
#define	_STRSTR_INLINE
extern "C++" {
	inline char *strstr(char *__s1, const char *__s2) {
		return (char *)strstr((const char *)__s1, __s2);
	}
}
#endif	/* _STRSTR_INLINE */
#else /* __cplusplus >= 199711L */
extern void *memchr(const void *, int, size_t);
extern char *strchr(const char *, int);
extern char *strpbrk(const char *, const char *);
extern char *strrchr(const char *, int);
extern char *strstr(const char *, const char *);
#endif /* __cplusplus >= 199711L */

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

/*
 * ISO C11 Annex K functions are not allowed to be in the standard
 * namespace; however, it is implementation-defined as to whether or
 * not they are in the global namespace and we opt to make them
 * available to software.
 */
#if __EXT1_VISIBLE

#ifndef	_RSIZE_T_DEFINED
#define	_RSIZE_T_DEFINED
#if __cplusplus >= 199711L
typedef std::size_t rsize_t;
#else
typedef size_t rsize_t;
#endif
#endif

#ifndef	_ERRNO_T_DEFINED
#define	_ERRNO_T_DEFINED
typedef int errno_t;
#endif

/* ISO/IEC 9899:2011 K.3.7.4.1.1 */
extern errno_t memset_s(void *, rsize_t, int, rsize_t);
#endif	/* __EXT1_VISIBLE */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_STRING_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <time.h.h>.
 */

#ifndef _ISO_TIME_ISO_H
#define	_ISO_TIME_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef	unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned	size_t;		/* (historical version) */
#endif
#endif	/* !_SIZE_T */

#if !defined(_CLOCK_T) || __cplusplus >= 199711L
#define	_CLOCK_T
typedef	long	clock_t;
#endif	/* !_CLOCK_T */

#if !defined(_TIME_T) || __cplusplus >= 199711L
#define	_TIME_T
typedef	long	time_t;
#endif	/* !_TIME_T */

#define	CLOCKS_PER_SEC		1000000L

struct	tm {	/* see ctime(3) */
	int	tm_sec;
	int	tm_min;
	int	tm_hour;
	int	tm_mday;
	int	tm_mon;
	int	tm_year;
	int	tm_wday;
	int	tm_yday;
	int	tm_isdst;
};


extern char *asctime(const struct tm *);
extern clock_t clock(void);
extern char *ctime(const time_t *);
extern double difftime(time_t, time_t);
extern struct tm *gmtime(const time_t *);
extern struct tm *localtime(const time_t *);
extern time_t mktime(struct tm *);
extern time_t time(time_t *);
extern size_t strftime(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD,
	const struct tm *_RESTRICT_KYWD);

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_TIME_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in
 * the C99 standard and in conflict with the C++ implementation of the
 * standard header.  The C++ standard may adopt the C99 standard at
 * which point it is expected that the symbols included here will
 * become part of the C++ std namespace.
 */

#ifndef	_ISO_WCHAR_C99_H
#define	_ISO_WCHAR_C99_H

#ifdef	__cplusplus
extern "C" {
#endif

/* Introduced in ISO/IEC 9899:1999 standard */

#if !defined(_LP64) && !defined(_LONGLONG_TYPE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname vfwscanf	_vfwscanf_c89
#pragma	redefine_extname vswscanf	_vswscanf_c89
#pragma	redefine_extname vwscanf	_vwscanf_c89
#else
#define	vfwscanf	_vfwscanf_c89
#define	vswscanf	_vswscanf_c89
#define	vwscanf		_vwscanf_c89
#endif
#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */

#if defined(_STDC_C99) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG6) || defined(__EXTENSIONS__)
extern int vfwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
		__va_list);
extern int vswscanf(const wchar_t *_RESTRICT_KYWD,
		const wchar_t *_RESTRICT_KYWD, __va_list);
extern int vwscanf(const wchar_t *_RESTRICT_KYWD, __va_list);
extern float wcstof(const wchar_t *_RESTRICT_KYWD,
		wchar_t **_RESTRICT_KYWD);
#if defined(_LONGLONG_TYPE)
extern long double wcstold(const wchar_t *_RESTRICT_KYWD,
		wchar_t **_RESTRICT_KYWD);
extern long long wcstoll(const wchar_t *_RESTRICT_KYWD,
		wchar_t **_RESTRICT_KYWD, int);
extern unsigned long long wcstoull(const wchar_t *_RESTRICT_KYWD,
		wchar_t **_RESTRICT_KYWD, int);
#endif /* defined(_LONGLONG_TYPE) */

#endif /* defined(_STDC_C99) || (!defined(_STRICT_STDC)... */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_WCHAR_C99_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <wchar.h>.
 */

#ifndef	_ISO_WCHAR_ISO_H
#define	_ISO_WCHAR_ISO_H

#include <sys/feature_tests.h>
#include <sys/null.h>
#include <stdio_tag.h>
#include <wchar_impl.h>
#include <iso/time_iso.h>

#if (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) || \
	(!defined(__cplusplus) && !defined(_STRICT_STDC)) || \
	defined(__EXTENSIONS__)
#include <stdio.h>
#endif  /*  (defined(__cplusplus) && (__cplusplus - 0 < 54321L)) ... */

#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
#include <ctype.h>
#include <stddef.h>
#endif /* !defined(_STRICT_STDC) || defined(__EXTENSIONS__) */

#include <sys/va_list.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef	int	wchar_t;
#else
typedef	long	wchar_t;
#endif
#endif	/* !_WCHAR_T */
#endif	/* !defined(__cplusplus) ... */

#if !defined(_WINT_T) || __cplusplus >= 199711L
#define	_WINT_T
#if defined(_LP64)
typedef	int	wint_t;
#else
typedef	long	wint_t;
#endif
#endif	/* !defined(_WINT_T) || __cplusplus >= 199711L */

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef	unsigned long	size_t;		/* size of something in bytes */
#else
typedef unsigned int	size_t;		/* (historical version) */
#endif
#endif  /* !defined(_SIZE_T) || __cplusplus >= 199711L */

#ifndef WEOF
#if __cplusplus >= 199711L
#define	WEOF	((std::wint_t)(-1))
#else
#define	WEOF	((wint_t)(-1))
#endif
#endif /* WEOF */

/* not XPG4 and not XPG4v2 */
#if !defined(_XPG4) || defined(_XPG5)
#ifndef	WCHAR_MAX
#define	WCHAR_MAX	2147483647
#endif
#ifndef	WCHAR_MIN
#define	WCHAR_MIN	(-2147483647-1)
#endif
#endif /* not XPG4 and not XPG4v2 */

#if !defined(_MBSTATE_T) || __cplusplus >= 199711L
#define	_MBSTATE_T
typedef __mbstate_t	mbstate_t;
#endif	/* _MBSTATE_T */

#if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
#define	_FILEDEFED
typedef __FILE FILE;
#endif

#if !defined(_LP64) && !defined(_LONGLONG_TYPE)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname fwprintf	_fwprintf_c89
#pragma	redefine_extname swprintf	_swprintf_c89
#pragma	redefine_extname vfwprintf	_vfwprintf_c89
#pragma	redefine_extname vswprintf	_vswprintf_c89
#pragma	redefine_extname vwprintf	_vwprintf_c89
#pragma	redefine_extname wprintf	_wprintf_c89
#pragma	redefine_extname fwscanf	_fwscanf_c89
#pragma	redefine_extname swscanf	_swscanf_c89
#pragma	redefine_extname wscanf		_wscanf_c89
#else
#define	fwprintf	_fwprintf_c89
#define	swprintf	_swprintf_c89
#define	vfwprintf	_vfwprintf_c89
#define	vswprintf	_vswprintf_c89
#define	vwprintf	_vwprintf_c89
#define	wprintf		_wprintf_c89
#define	fwscanf		_fwscanf_c89
#define	swscanf		_swscanf_c89
#define	wscanf		_wscanf_c89
#endif

#endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */

#if (!defined(_MSE_INT_H))
/* not XPG4 and not XPG4v2 */
#if !defined(_XPG4) || defined(_XPG5)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname fgetwc	__fgetwc_xpg5
#pragma redefine_extname getwc	__getwc_xpg5
#pragma redefine_extname getwchar	__getwchar_xpg5
#pragma redefine_extname fputwc	__fputwc_xpg5
#pragma redefine_extname putwc	__putwc_xpg5
#pragma redefine_extname putwchar	__putwchar_xpg5
#pragma redefine_extname fgetws	__fgetws_xpg5
#pragma redefine_extname fputws	__fputws_xpg5
#pragma redefine_extname ungetwc	__ungetwc_xpg5
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern wint_t __fgetwc_xpg5(__FILE *);
extern wint_t __getwc_xpg5(__FILE *);
extern wint_t __getwchar_xpg5(void);
extern wint_t __fputwc_xpg5(wint_t, __FILE *);
extern wint_t __putwc_xpg5(wint_t, __FILE *);
extern wint_t __putwchar_xpg5(wint_t);
extern wchar_t *__fgetws_xpg5(wchar_t *_RESTRICT_KYWD, int,
			__FILE *_RESTRICT_KYWD);
extern int __fputws_xpg5(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
extern wint_t __ungetwc_xpg5(wint_t, __FILE *);
#define	fgetwc	__fgetwc_xpg5
#define	getwc	__getwc_xpg5
#define	getwchar	__getwchar_xpg5
#define	fputwc	__fputwc_xpg5
#define	putwc	__putwc_xpg5
#define	putwchar	__putwchar_xpg5
#define	fgetws	__fgetws_xpg5
#define	fputws	__fputws_xpg5
#define	ungetwc	__ungetwc_xpg5
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif /* not XPG4 and not XPG4v2 */
#endif /* defined(_MSE_INT_H) */

extern wint_t fgetwc(__FILE *);
extern wchar_t *fgetws(wchar_t *_RESTRICT_KYWD, int, __FILE *_RESTRICT_KYWD);
extern wint_t fputwc(wint_t, __FILE *);
extern int fputws(const wchar_t *_RESTRICT_KYWD, __FILE *_RESTRICT_KYWD);
extern wint_t ungetwc(wint_t, __FILE *);
extern wint_t getwc(__FILE *);
extern wint_t getwchar(void);
extern wint_t putwc(wint_t, __FILE *);
extern wint_t putwchar(wint_t);
extern double wcstod(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
extern long wcstol(const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD,
	int);
extern unsigned long wcstoul(const wchar_t *_RESTRICT_KYWD,
	wchar_t **_RESTRICT_KYWD, int);
extern wchar_t *wcscat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD);
extern int wcscmp(const wchar_t *, const wchar_t *);
extern int wcscoll(const wchar_t *, const wchar_t *);
extern wchar_t *wcscpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD);
extern size_t wcscspn(const wchar_t *, const wchar_t *);
extern size_t wcslen(const wchar_t *);
extern wchar_t *wcsncat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
	size_t);
extern int wcsncmp(const wchar_t *, const wchar_t *, size_t);
extern wchar_t *wcsncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
	size_t);
extern size_t wcsspn(const wchar_t *, const wchar_t *);
extern size_t wcsxfrm(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
	size_t);
#if __cplusplus >= 199711L
extern const wchar_t *wcschr(const wchar_t *, wchar_t);
extern "C++" {
	inline wchar_t *wcschr(wchar_t *__ws, wchar_t __wc) {
		return (wchar_t *)wcschr((const wchar_t *)__ws, __wc);
	}
}
extern const wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
extern "C++" {
	inline wchar_t *wcspbrk(wchar_t *__ws1, const wchar_t *__ws2) {
		return (wchar_t *)wcspbrk((const wchar_t *)__ws1, __ws2);
	}
}
extern const wchar_t *wcsrchr(const wchar_t *, wchar_t);
extern "C++" {
	inline wchar_t *wcsrchr(wchar_t *__ws, wchar_t __wc) {
		return (wchar_t *)wcsrchr((const wchar_t *)__ws, __wc);
	}
}
#else /* __cplusplus >= 199711L */
extern wchar_t *wcschr(const wchar_t *, wchar_t);
extern wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
extern wchar_t *wcsrchr(const wchar_t *, wchar_t);
#endif /* __cplusplus >= 199711L */

#if (!defined(_MSE_INT_H))
#if defined(_XPG4) && !defined(_XPG5) /* XPG4 or XPG4v2 */
extern wchar_t *wcstok(wchar_t *, const wchar_t *);
extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm *);
#else	/* XPG4 or XPG4v2 */
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname wcstok	__wcstok_xpg5
#pragma redefine_extname wcsftime	__wcsftime_xpg5
extern wchar_t *wcstok(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
	wchar_t **_RESTRICT_KYWD);
extern size_t wcsftime(wchar_t *_RESTRICT_KYWD, size_t,
	const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern wchar_t *__wcstok_xpg5(wchar_t *_RESTRICT_KYWD,
	const wchar_t *_RESTRICT_KYWD, wchar_t **_RESTRICT_KYWD);
extern size_t __wcsftime_xpg5(wchar_t *_RESTRICT_KYWD, size_t,
	const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD);
#define	wcstok	__wcstok_xpg5
#define	wcsftime	__wcsftime_xpg5
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* XPG4 or XPG4v2 */
#endif	/* !defined(_MSE_INT_H) */

/* not XPG4 and not XPG4v2 */
#if !defined(_XPG4) || defined(_XPG5)
extern wint_t	btowc(int);
extern int	fwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
			...);
extern int	fwscanf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
			...);
extern int	fwide(__FILE *, int);
extern int	mbsinit(const mbstate_t *);
extern size_t	mbrlen(const char *_RESTRICT_KYWD, size_t,
			mbstate_t *_RESTRICT_KYWD);
extern size_t	mbrtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
			size_t, mbstate_t *_RESTRICT_KYWD);
extern size_t	mbsrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
			size_t, mbstate_t *_RESTRICT_KYWD);
extern int	swprintf(wchar_t *_RESTRICT_KYWD, size_t,
			const wchar_t *_RESTRICT_KYWD, ...);
extern int	swscanf(const wchar_t *_RESTRICT_KYWD,
			const wchar_t *_RESTRICT_KYWD, ...);
extern int	vfwprintf(__FILE *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
			__va_list);
extern int	vwprintf(const wchar_t *_RESTRICT_KYWD, __va_list);
extern int	vswprintf(wchar_t *_RESTRICT_KYWD, size_t,
			const wchar_t *_RESTRICT_KYWD, __va_list);
extern size_t	wcrtomb(char *_RESTRICT_KYWD, wchar_t,
			mbstate_t *_RESTRICT_KYWD);
extern size_t	wcsrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
			size_t, mbstate_t *_RESTRICT_KYWD);
#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
extern size_t	wcsnrtombs(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
			size_t, size_t, mbstate_t *_RESTRICT_KYWD);
#endif
extern int	wctob(wint_t);
extern int	wmemcmp(const wchar_t *, const wchar_t *, size_t);
extern wchar_t	*wmemcpy(wchar_t *_RESTRICT_KYWD,
			const wchar_t *_RESTRICT_KYWD, size_t);
extern wchar_t	*wmemmove(wchar_t *, const wchar_t *, size_t);
extern wchar_t	*wmemset(wchar_t *, wchar_t, size_t);
extern int	wprintf(const wchar_t *_RESTRICT_KYWD, ...);
extern int	wscanf(const wchar_t *_RESTRICT_KYWD, ...);
#if __cplusplus >= 199711L
extern const wchar_t *wcsstr(const wchar_t *, const wchar_t *);
extern "C++" {
	inline wchar_t *wcsstr(wchar_t *__ws1, const wchar_t *__ws2) {
		return (wchar_t *)wcsstr((const wchar_t *)__ws1, __ws2);
	}
}
extern const wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
extern "C++" {
	inline wchar_t *wmemchr(wchar_t *__ws, wchar_t __wc, size_t __n) {
		return (wchar_t *)wmemchr((const wchar_t *)__ws, __wc, __n);
	}
}
#else /* __cplusplus >= 199711L */
extern wchar_t	*wcsstr(const wchar_t *_RESTRICT_KYWD,
	const wchar_t *_RESTRICT_KYWD);
extern wchar_t	*wmemchr(const wchar_t *, wchar_t, size_t);
#endif /* __cplusplus >= 199711L */
#endif /* not XPG4 and not XPG4v2 */

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_WCHAR_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*	wctype.h	1.13 89/11/02 SMI; JLE	*/
/*	from AT&T JAE 2.1			*/
/*	definitions for international functions	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * An application should not include this header directly.  Instead it
 * should be included only through the inclusion of other Sun headers.
 *
 * The contents of this header is limited to identifiers specified in the
 * C Standard.  Any new identifiers specified in future amendments to the
 * C Standard must be placed in this header.  If these new identifiers
 * are required to also be in the C++ Standard "std" namespace, then for
 * anything other than macro definitions, corresponding "using" directives
 * must also be added to <wctype.h>.
 */

#ifndef	_ISO_WCTYPE_ISO_H
#define	_ISO_WCTYPE_ISO_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if __cplusplus >= 199711L
namespace std {
#endif

#if !defined(_WINT_T) || __cplusplus >= 199711L
#define	_WINT_T
#if defined(_LP64)
typedef	int	wint_t;
#else
typedef long	wint_t;
#endif
#endif  /* !defined(_WINT_T) || __cplusplus >= 199711L */

#if !defined(_WCTYPE_T) || __cplusplus >= 199711L
#define	_WCTYPE_T
typedef	int	wctype_t;
#endif

typedef unsigned int	wctrans_t;

/* not XPG4 and not XPG4v2 */
#if !defined(_XPG4) || defined(_XPG5)
#ifndef WEOF
#if __cplusplus >= 199711L
#define	WEOF	((std::wint_t)(-1))
#else
#define	WEOF	((wint_t)(-1))
#endif
#endif /* WEOF */
#endif /* not XPG4 and not XPG4v2 */

extern	int iswalnum(wint_t);
extern	int iswalpha(wint_t);
extern	int iswcntrl(wint_t);
extern	int iswdigit(wint_t);
extern	int iswgraph(wint_t);
extern	int iswlower(wint_t);
extern	int iswprint(wint_t);
extern	int iswpunct(wint_t);
extern	int iswspace(wint_t);
extern	int iswupper(wint_t);
extern	int iswxdigit(wint_t);

#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \
	!defined(_STRICT_SYMBOLS)
extern	int iswblank(wint_t);
#endif

/* tow* also become functions */
extern	wint_t towlower(wint_t);
extern	wint_t towupper(wint_t);
extern	wctrans_t wctrans(const char *);
extern	wint_t towctrans(wint_t, wctrans_t);
extern  int iswctype(wint_t, wctype_t);
extern  wctype_t wctype(const char *);

/* bit definition for character class */

#define	_E1	0x00000100	/* phonogram (international use) */
#define	_E2	0x00000200	/* ideogram (international use) */
#define	_E3	0x00000400	/* English (international use) */
#define	_E4	0x00000800	/* number (international use) */
#define	_E5	0x00001000	/* special (international use) */
#define	_E6	0x00002000	/* other characters (international use) */
#define	_E7	0x00004000	/* reserved (international use) */
#define	_E8	0x00008000	/* reserved (international use) */

#define	_E9	0x00010000
#define	_E10	0x00020000
#define	_E11	0x00040000
#define	_E12	0x00080000
#define	_E13	0x00100000
#define	_E14	0x00200000
#define	_E15	0x00400000
#define	_E16	0x00800000
#define	_E17	0x01000000
#define	_E18	0x02000000
#define	_E19	0x04000000
#define	_E20	0x08000000
#define	_E21	0x10000000
#define	_E22	0x20000000
#define	_E23	0x40000000
#define	_E24	0x80000000

#if __cplusplus >= 199711L
}
#endif /* end of namespace std */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO_WCTYPE_ISO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_ISO646_H
#define	_ISO646_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Introduced in ISO/IEC 9899:1990/Ammendment 1:1995 (C Standard).
 * In ISO/IEC 14882:1998 (C++ Standard), these tokens are keywords
 * rather than macro names.
 */

#if !defined(__cplusplus) || __cplusplus < 199711L
#define	and	&&
#define	and_eq	&=
#define	bitand	&
#define	bitor	|
#define	compl	~
#define	not	!
#define	not_eq	!=
#define	or	||
#define	or_eq	|=
#define	xor	^
#define	xor_eq	^=
#endif	/* !defined(__cplusplus) || __cplusplus < 199711 */

#ifdef	__cplusplus
}
#endif

#endif	/* _ISO646_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_MIT_SIPB_COPYRIGHT_H
#define	_MIT_SIPB_COPYRIGHT_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *
 * Copyright 1987 by the Student Information Processing Board
 *	of the Massachusetts Institute of Technology
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purpose and without fee is
 * hereby granted, provided that the above copyright notice
 * appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation,
 * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
 * used in advertising or publicity pertaining to distribution
 * of the software without specific, written prior permission.
 * M.I.T. and the M.I.T. S.I.P.B. make no representations about
 * the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 *
 */

#ifdef	__cplusplus
}
#endif

#endif	/* _MIT_SIPB_COPYRIGHT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_MIT_COPYRIGHT_H
#define	_MIT_COPYRIGHT_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Copyright (C) 1996 by the Massachusetts Institute of Technology
 */

/*
 * Copyright 1994 Cygnus Support
 * Mark W. Eichin
 */

/*
 * Copyright (c) 1990 Regents of the University of Michigan.
 * All Rights Reserved.
 */

/*
 * Copyright (c) 1991, 1993
 *	The Regents of the University of California. All rights reserved.
 */

/*
 * Copyright 1987, 1998 by the Student Informatiion Processing Board
 *	of the Massachusetts Institute of Technology
 */

/*
 * Copyright (c) 1993, 1994 C Consortium
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation file (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OF OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of the X Consortium shall not be
 * used in advertising or otherwise to promote the sale, use or other dealings
 * in this Software without prior written authorization from the X Consortium.
 */

/*
 * Copyright 1992 Network Computing Devices, Inc.
 */

/*
 * Copyright 1995 by Richard P. Basch. All Rights Reserved.
 * Copyright 1995 by Lehman Brotchers, Inc. All Rights Reserved.
 */

/*
 *	Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.
 *
 *	License to copy and use this software is granted provided that
 *	it is identified as the "RSA Data Security, Inc. MD5 Message
 *	Digest Algorithm" in all material mentioning or referencing this
 *	software or this function.
 *
 *	License is also granted to make and use derivative works
 *	provided that such works are identified as "derived from the RSA
 *	Data Security, Inc. MD4 Message Digest Algorithm" in all
 *	material mentioning or referencing the derived work.
 *
 *	RSA Data Security, Inc. make no representations concerning
 *	either the merchantability of this software or the suitability
 *	of this software for any particular purpose.  It is provided "as
 *	is" without express or implied warranty of any kind.
 *
 *	These notices must be retained in any copies of any part of this
 *	documentation and/or software.
 *
 */




#ifdef	__cplusplus
}
#endif


#endif	/* _MIT_COPYRIGHT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_KLPD_H
#define	_KLPD_H

#include <sys/klpd.h>
#include <priv.h>
#include <ucred.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern void *klpd_create(boolean_t (*)(void *, const priv_set_t *, void *),
    void *);
extern int klpd_register_id(const priv_set_t *, void *, idtype_t, id_t);
extern int klpd_register(const priv_set_t *, void *);
extern int klpd_unregister_id(void *, idtype_t, id_t);
extern int klpd_unregister(void *);
extern const char *klpd_getpath(void *);
extern int klpd_getport(void *, int *);
extern int klpd_getucred(ucred_t **, void *);

#ifdef	__cplusplus
}
#endif

#endif	/* _KLPD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_LANGINFO_H
#define	_LANGINFO_H

#include <sys/feature_tests.h>
#include <nl_types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The seven days of the week in their full beauty
 */

#define	DAY_1	  1	/* sunday */
#define	DAY_2	  2	/* monday */
#define	DAY_3	  3	/* tuesday */
#define	DAY_4	  4	/* wednesday */
#define	DAY_5	  5	/* thursday */
#define	DAY_6	  6	/* friday */
#define	DAY_7	  7	/* saturday */

/*
 * The abbreviated seven days of the week
 */

#define	ABDAY_1	  8  /* sun */
#define	ABDAY_2	  9  /* mon */
#define	ABDAY_3	  10 /* tue */
#define	ABDAY_4	  11 /* wed */
#define	ABDAY_5	  12 /* thu */
#define	ABDAY_6	  13 /* fri */
#define	ABDAY_7	  14 /* sat */

/*
 * The full names of the twelve months...
 */

#define	MON_1	  15 /* january */
#define	MON_2	  16 /* february */
#define	MON_3	  17 /* march */
#define	MON_4	  18 /* april */
#define	MON_5	  19 /* may */
#define	MON_6	  20 /* june */
#define	MON_7	  21 /* july */
#define	MON_8	  22 /* august */
#define	MON_9	  23 /* september */
#define	MON_10	  24 /* october */
#define	MON_11	  25 /* november */
#define	MON_12	  26 /* december */

/*
 * ... and their abbreviated form
 */

#define	ABMON_1	  27 /* jan */
#define	ABMON_2	  28 /* feb */
#define	ABMON_3	  29 /* mar */
#define	ABMON_4	  30 /* apr */
#define	ABMON_5	  31 /* may */
#define	ABMON_6	  32 /* jun */
#define	ABMON_7	  33 /* jul */
#define	ABMON_8	  34 /* aug */
#define	ABMON_9	  35 /* sep */
#define	ABMON_10  36 /* oct */
#define	ABMON_11  37 /* nov */
#define	ABMON_12  38 /* dec */

/*
 * plus some special strings you might need to know
 */

#define	RADIXCHAR 39	/* radix character */
#define	THOUSEP	  40	/* separator for thousand */
/* YESSTR and NOSTR marked as legacy in XPG5 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
#define	YESSTR	  41    /* affirmative response for yes/no queries */
#define	NOSTR	  42	/* negative response for yes/no queries */
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__ */
#define	CRNCYSTR  43	/* currency symbol */

/*
 * Default string used to format date and time
 *	e.g. Sunday, August 24 21:08:38 MET 1986
 */

#define	D_T_FMT	  44	/* string for formatting date and time */
#define	D_FMT	  45	/* date format */
#define	T_FMT	  46	/* time format */
#define	AM_STR	  47	/* am string */
#define	PM_STR	  48	/* pm string */

/*
 * Additions for XPG4 (XSH4) Compliance
 */

#define	CODESET		49	/* codeset name */
#define	T_FMT_AMPM	50	/* am or pm time format string */
#define	ERA		51	/* era description segments */
#define	ERA_D_FMT	52	/* era date format string */
#define	ERA_D_T_FMT	53	/* era date and time format string */
#define	ERA_T_FMT	54	/* era time format string */
#define	ALT_DIGITS	55	/* alternative symbols for digits */
#define	YESEXPR		56	/* affirmative response expression */
#define	NOEXPR		57	/* negative response expression */
#define	_DATE_FMT	58	/* strftime format for date(1) */

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
#define	MAXSTRMSG	58 /* Maximum number of strings in langinfo */
#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

/*
 * and the definitions of functions nl_langinfo(3C)
 */
char   *nl_langinfo(nl_item);	/* get a string from the database	*/

#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

char	*nl_langinfo_l(nl_item, locale_t);
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _LANGINFO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _LASTLOG_H
#define	_LASTLOG_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef _LP64
#include <sys/types32.h>
#endif

struct lastlog {
#ifdef _LP64
	time32_t ll_time;
#else
	time_t	ll_time;
#endif
	char	ll_line[8];
	char	ll_host[16];		/* same as in utmp */
};

#ifdef	__cplusplus
}
#endif

#endif	/* _LASTLOG_H */
/*
 * Copyright (c) 2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4
 *
 * The contents of this file are subject to the Netscape Public License
 * Version 1.0(the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * http:/ /www.mozilla.org/NPL/
 *
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 *
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright(C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.
 */

#ifndef	_LBER_H
#define	_LBER_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	_SOLARIS_SDK
#define	_SOLARIS_SDK
#endif

#include <stdlib.h>	/* to pick up size_t typedef */

#ifdef	_SOLARIS_SDK
#ifdef	sunos4
#define	SAFEMEMCPY(d, s, n)   bcopy(s, d, n)
#else /* sunos4 */
#define	SAFEMEMCPY(d, s, n)   memmove(d, s, n)
#endif /* sunos4 */
#endif /* _SOLARIS_SDK */
/*
 * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
 * as valid BER tags, and so it is safe to use them to report errors.  In
 * fact, any tag for which the following is true is invalid:
 *     (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 )
 */
#define	LBER_ERROR		0xffffffffU
#define	LBER_DEFAULT		0xffffffffU
#define	LBER_END_OF_SEQORSET	0xfffffffeU
/* BER classes and mask */
#define	LBER_CLASS_UNIVERSAL    0x00
#define	LBER_CLASS_APPLICATION  0x40
#define	LBER_CLASS_CONTEXT	0x80
#define	LBER_CLASS_PRIVATE	0xc0
#define	LBER_CLASS_MASK		0xc0

/* BER encoding type and mask */
#define	LBER_PRIMITIVE		0x00
#define	LBER_CONSTRUCTED	0x20
#define	LBER_ENCODING_MASK	0x20

#define	LBER_BIG_TAG_MASK	0x1f
#define	LBER_MORE_TAG_MASK	0x80

/* general BER types we know about */
#define	LBER_BOOLEAN		0x01
#define	LBER_INTEGER		0x02
#define	LBER_BITSTRING		0x03
#define	LBER_OCTETSTRING	0x04
#define	LBER_NULL		0x05
#define	LBER_ENUMERATED		0x0a
#define	LBER_SEQUENCE		0x30
#define	LBER_SET		0x31


typedef unsigned int	ber_len_t;   /* for BER len */
typedef unsigned int	ber_tag_t;   /* for BER tags */
typedef int		ber_int_t;   /* for BER ints, enums, and Booleans */
typedef unsigned int	ber_uint_t; /* unsigned equivalent of ber_int_t */
typedef int		ber_slen_t; /* signed equivalent of ber_len_t */

typedef struct berval {
	ber_len_t	bv_len;
	char		*bv_val;
} BerValue;

typedef struct berelement BerElement;

#ifdef	_SOLARIS_SDK
#define	NULLBER ((BerElement *)NULL)
#endif

typedef int (*BERTranslateProc)(char **bufp, ber_uint_t *buflenp,
	int free_input);
#ifndef	macintosh
#if defined(_WINDOWS) || defined(_WIN32) || defined(_CONSOLE)
#include <winsock.h> /* for SOCKET */
typedef SOCKET LBER_SOCKET;
#else
typedef int LBER_SOCKET;
#endif /* _WINDOWS */
#else /* macintosh */
typedef void *LBER_SOCKET;
#endif /* macintosh */

/* calling conventions used by library */
#ifndef	LDAP_CALL
#if defined(_WINDOWS) || defined(_WIN32)
#define	LDAP_C __cdecl
#ifndef	_WIN32
#define	__stdcall _far _pascal
#define	LDAP_CALLBACK _loadds
#else
#define	LDAP_CALLBACK
#endif /* _WIN32 */
#define	LDAP_PASCAL __stdcall
#define	LDAP_CALL LDAP_PASCAL
#else /* _WINDOWS */
#define	LDAP_C
#define	LDAP_CALLBACK
#define	LDAP_PASCAL
#define	LDAP_CALL
#endif /* _WINDOWS */
#endif /* LDAP_CALL */

/*
 * function prototypes for lber library
 */
#ifndef	LDAP_API
#if defined(_WINDOWS) || defined(_WIN32)
#define	LDAP_API(rt) rt
#else /* _WINDOWS */
#define	LDAP_API(rt) rt
#endif /* _WINDOWS */
#endif /* LDAP_API */

/*
 * decode routines
 */
ber_tag_t LDAP_CALL ber_get_tag(BerElement *ber);
ber_tag_t LDAP_CALL ber_skip_tag(BerElement *ber,
	ber_len_t *len);
ber_tag_t LDAP_CALL ber_peek_tag(BerElement *ber,
	ber_len_t *len);
ber_tag_t LDAP_CALL ber_get_int(BerElement *ber, ber_int_t *num);
ber_tag_t LDAP_CALL ber_get_stringb(BerElement *ber, char *buf,
	ber_len_t *len);
ber_tag_t LDAP_CALL ber_get_stringa(BerElement *ber,
	char **buf);
ber_tag_t LDAP_CALL ber_get_stringal(BerElement *ber,
	struct berval **bv);
ber_tag_t ber_get_bitstringa(BerElement *ber,
	char **buf, ber_len_t *len);
ber_tag_t LDAP_CALL ber_get_null(BerElement *ber);
ber_tag_t LDAP_CALL ber_get_boolean(BerElement *ber,
	int *boolval);
ber_tag_t LDAP_CALL ber_first_element(BerElement *ber,
	ber_len_t *len, char **last);
ber_tag_t LDAP_CALL ber_next_element(BerElement *ber,
	ber_len_t *len, char *last);
ber_tag_t LDAP_C ber_scanf(BerElement *ber, const char *fmt,
	...);
LDAP_API(void) LDAP_CALL ber_bvfree(struct berval *bv);
LDAP_API(void) LDAP_CALL ber_bvecfree(struct berval **bv);
struct berval *LDAP_CALL ber_bvdup(const struct berval *bv);
LDAP_API(void) LDAP_CALL ber_set_string_translators(BerElement *ber,
	BERTranslateProc encode_proc, BERTranslateProc decode_proc);
LDAP_API(BerElement *) LDAP_CALL ber_init(const struct berval *bv);

/*
 * encoding routines
 */
int LDAP_CALL ber_put_enum(BerElement *ber, ber_int_t num,
	ber_tag_t tag);
int LDAP_CALL ber_put_int(BerElement *ber, ber_int_t num,
	ber_tag_t tag);
int LDAP_CALL ber_put_ostring(BerElement *ber, char *str,
	ber_len_t len, ber_tag_t tag);
int LDAP_CALL ber_put_string(BerElement *ber, char *str,
	ber_tag_t tag);
int LDAP_CALL ber_put_bitstring(BerElement *ber, char *str,
	ber_len_t bitlen, ber_tag_t tag);
int LDAP_CALL ber_put_null(BerElement *ber, ber_tag_t tag);
int LDAP_CALL ber_put_boolean(BerElement *ber, int boolval,
	ber_tag_t tag);
int LDAP_CALL ber_start_seq(BerElement *ber, ber_tag_t tag);
int LDAP_CALL ber_start_set(BerElement *ber, ber_tag_t tag);
int LDAP_CALL ber_put_seq(BerElement *ber);
int LDAP_CALL ber_put_set(BerElement *ber);
int LDAP_C ber_printf(BerElement *ber, const char *fmt, ...);
int LDAP_CALL ber_flatten(BerElement *ber,
	struct berval **bvPtr);

/*
 * miscellaneous routines
 */
LDAP_API(void) LDAP_CALL ber_free(BerElement *ber, int freebuf);
LDAP_API(BerElement*) LDAP_CALL ber_alloc(void);
LDAP_API(BerElement*) LDAP_CALL der_alloc(void);
LDAP_API(BerElement*) LDAP_CALL ber_alloc_t(int options);
LDAP_API(BerElement*) LDAP_CALL ber_dup(BerElement *ber);
ber_int_t LDAP_CALL ber_read(BerElement *ber, char *buf,
	ber_len_t len);
ber_int_t LDAP_CALL ber_write(BerElement *ber, char *buf,
	ber_len_t len, int nosos);
LDAP_API(void) LDAP_CALL ber_reset(BerElement *ber, int was_writing);

#ifdef	__cplusplus
}
#endif

#endif /* _LBER_H */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 * Copyright 2001-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * The contents of this file are subject to the Netscape Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/NPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is Mozilla Communicator client code, released
 * March 31, 1998.
 *
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation. Portions created by Netscape are
 * Copyright (C) 1998-1999 Netscape Communications Corporation. All
 * Rights Reserved.
 *
 * Contributor(s):
 */

#ifndef	_LDAP_H
#define	_LDAP_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	_SOLARIS_SDK
#define	_SOLARIS_SDK
#endif

#ifndef	LDAP_TYPE_TIMEVAL_DEFINED
#include <sys/time.h>
#endif
#ifndef	LDAP_TYPE_SOCKET_DEFINED	/* API extension */
#include <sys/types.h>
#include <sys/socket.h>
#endif

#include <lber.h>

#define	LDAP_PORT		389
#define	LDAPS_PORT		636
#define	LDAP_PORT_MAX		65535		/* API extension */
#define	LDAP_VERSION1		1		/* API extension */
#define	LDAP_VERSION2		2
#define	LDAP_VERSION3		3
#define	LDAP_VERSION		LDAP_VERSION2	/* API extension */
#define	LDAP_VERSION_MIN	LDAP_VERSION3
#define	LDAP_VERSION_MAX	LDAP_VERSION3

#define	LDAP_VENDOR_VERSION	500	/* version # * 100 */
#define	LDAP_VENDOR_NAME	"Sun Microsystems Inc."
/*
 * The following will be an RFC number once the LDAP C API Internet Draft
 * is published as a Proposed Standard RFC.  For now we use 2000 + the
 * draft revision number (currently 5) since we are close to compliance
 * with revision 5 of the draft.
 */
#define	LDAP_API_VERSION	2005

/*
 * C LDAP features we support that are not (yet) part of the LDAP C API
 * Internet Draft.  Use the ldap_get_option() call with an option value of
 * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature.
 *
 * Note that this list is incomplete; it includes only the most widely
 * used extensions.  Also, the version is 1 for all of these for now.
 */
#define	LDAP_API_FEATURE_SERVER_SIDE_SORT	1
#define	LDAP_API_FEATURE_VIRTUAL_LIST_VIEW	1
#define	LDAP_API_FEATURE_PERSISTENT_SEARCH	1
#define	LDAP_API_FEATURE_PROXY_AUTHORIZATION	1
#define	LDAP_API_FEATURE_X_LDERRNO		1
#define	LDAP_API_FEATURE_X_MEMCACHE		1
#define	LDAP_API_FEATURE_X_IO_FUNCTIONS		1
#define	LDAP_API_FEATURE_X_EXTIO_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_DNS_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_THREAD_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_GETLANGVALUES	1
#define	LDAP_API_FEATURE_X_CLIENT_SIDE_SORT	1
#define	LDAP_API_FEATURE_X_URL_FUNCTIONS	1
#define	LDAP_API_FEATURE_X_FILTER_FUNCTIONS	1

#define	LDAP_ROOT_DSE		""		/* API extension */
#define	LDAP_NO_ATTRS		"1.1"
#define	LDAP_ALL_USER_ATTRS	"*"

/*
 * Standard options (used with ldap_set_option() and ldap_get_option):
 */
#define	LDAP_OPT_API_INFO		0x00	/*  0 */
#define	LDAP_OPT_DESC			0x01	/*  1 */
#define	LDAP_OPT_DEREF			0x02	/*  2 */
#define	LDAP_OPT_SIZELIMIT		0x03	/*  3 */
#define	LDAP_OPT_TIMELIMIT		0x04	/*  4 */
#define	LDAP_OPT_REFERRALS		0x08	/*  8 */
#define	LDAP_OPT_RESTART		0x09	/*  9 */
#define	LDAP_OPT_PROTOCOL_VERSION	0x11	/* 17 */
#define	LDAP_OPT_SERVER_CONTROLS	0x12	/* 18 */
#define	LDAP_OPT_CLIENT_CONTROLS	0x13	/* 19 */
#define	LDAP_OPT_API_FEATURE_INFO	0x15	/* 21 */
#define	LDAP_OPT_HOST_NAME		0x30	/* 48 */
#define	LDAP_OPT_ERROR_NUMBER		0x31	/* 49 */
#define	LDAP_OPT_ERROR_STRING		0x32	/* 50 */
#define	LDAP_OPT_MATCHED_DN		0x33	/* 51 */

/*
 * Well-behaved private and experimental extensions will use option values
 * between 0x4000 (16384) and 0x7FFF (32767) inclusive.
 */
#define	LDAP_OPT_PRIVATE_EXTENSION_BASE	0x4000	/* to 0x7FFF inclusive */
/*
 * Special timeout values for poll and connect:
 */
#define	LDAP_X_IO_TIMEOUT_NO_WAIT	0	/* return immediately */
#define	LDAP_X_IO_TIMEOUT_NO_TIMEOUT    (-1)    /* block indefinitely */
/*
 * Timeout value for nonblocking connect call
 */
#define	LDAP_X_OPT_CONNECT_TIMEOUT    (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01)
	/* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */

/* for on/off options */
#define	LDAP_OPT_ON	((void *)1)
#define	LDAP_OPT_OFF	((void *)0)

typedef struct ldap	LDAP;		/* opaque connection handle */
typedef struct ldapmsg  LDAPMessage;    /* opaque result/entry handle */

#define	NULLMSG ((LDAPMessage *)0)

/* structure representing an LDAP modification */
typedef struct ldapmod {
	int		mod_op;		/* kind of mod + form of values */
#define	LDAP_MOD_ADD		0x00
#define	LDAP_MOD_DELETE		0x01
#define	LDAP_MOD_REPLACE	0x02
#define	LDAP_MOD_BVALUES	0x80
	char			*mod_type;	/* attribute name to modify */
	union mod_vals_u {
		char		**modv_strvals;
		struct berval   **modv_bvals;
	} mod_vals;		/* values to add/delete/replace */
#define	mod_values	mod_vals.modv_strvals
#define	mod_bvalues	mod_vals.modv_bvals
} LDAPMod;


/*
 * structure for holding ldapv3 controls
 */
typedef struct ldapcontrol {
    char		*ldctl_oid;
    struct berval	ldctl_value;
    char		ldctl_iscritical;
} LDAPControl;


/*
 * LDAP API information.  Can be retrieved by using a sequence like:
 *
 *    LDAPAPIInfo ldai;
 *    ldai.ldapai_info_version = LDAP_API_INFO_VERSION;
 *    if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ...
 */
#define	LDAP_API_INFO_VERSION		1
typedef struct ldapapiinfo {
    int	 ldapai_info_version;	  /* version of this struct (1) */
    int	ldapai_api_version;	/* revision of API supported */
    int  ldapai_protocol_version; /* highest LDAP version supported */
    char **ldapai_extensions;	/* names of API extensions */
    char *ldapai_vendor_name;	/* name of supplier */
    int  ldapai_vendor_version;   /* supplier-specific version times 100 */
} LDAPAPIInfo;


/*
 * LDAP API extended features info.  Can be retrieved by using a sequence like:
 *
 *    LDAPAPIFeatureInfo ldfi;
 *    ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION;
 *    ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW";
 *    if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 ) ...
 */
#define	LDAP_FEATURE_INFO_VERSION	1
typedef struct ldap_apifeature_info {
    int   ldapaif_info_version;	/* version of this struct (1) */
    char  *ldapaif_name;	/* name of supported feature */
    int   ldapaif_version;	/* revision of supported feature */
} LDAPAPIFeatureInfo;


/* possible result types a server can return */
#define	LDAP_RES_BIND			0x61	/* 97 */
#define	LDAP_RES_SEARCH_ENTRY		0x64	/* 100 */
#define	LDAP_RES_SEARCH_RESULT		0x65	/* 101 */
#define	LDAP_RES_MODIFY			0x67	/* 103 */
#define	LDAP_RES_ADD			0x69	/* 105 */
#define	LDAP_RES_DELETE			0x6b	/* 107 */
#define	LDAP_RES_MODDN			0x6d	/* 109 */
#define	LDAP_RES_COMPARE		0x6f	/* 111 */
#define	LDAP_RES_SEARCH_REFERENCE	0x73	/* 115 */
#define	LDAP_RES_EXTENDED		0x78	/* 120 */

/* Special values for ldap_result() "msgid" parameter */
#define	LDAP_RES_ANY			(-1)
#define	LDAP_RES_UNSOLICITED		0

/* built-in SASL methods */
#define	LDAP_SASL_SIMPLE	0	/* special value used for simple bind */
#define	LDAP_SASL_EXTERNAL	"EXTERNAL"	/* TLS/SSL extension */

#ifdef	_SOLARIS_SDK
#define	LDAP_SASL_CRAM_MD5	"CRAM-MD5"
#define	LDAP_SASL_DIGEST_MD5	"DIGEST-MD5"
#define	LDAP_SASL_BIND_INPROGRESS	0x0e    /* for backward compatibility */
#endif

/* search scopes */
#define	LDAP_SCOPE_BASE		0x00
#define	LDAP_SCOPE_ONELEVEL	0x01
#define	LDAP_SCOPE_SUBTREE	0x02

/* alias dereferencing */
#define	LDAP_DEREF_NEVER	0
#define	LDAP_DEREF_SEARCHING	1
#define	LDAP_DEREF_FINDING	2
#define	LDAP_DEREF_ALWAYS	3

/* predefined size/time limits */
#define	LDAP_NO_LIMIT		0

/* allowed values for "all" ldap_result() parameter */
#define	LDAP_MSG_ONE		0
#define	LDAP_MSG_ALL		1
#define	LDAP_MSG_RECEIVED	2

/* possible error codes we can be returned */
#define	LDAP_SUCCESS			0x00	/* 0 */
#define	LDAP_OPERATIONS_ERROR		0x01	/* 1 */
#define	LDAP_PROTOCOL_ERROR		0x02	/* 2 */
#define	LDAP_TIMELIMIT_EXCEEDED		0x03	/* 3 */
#define	LDAP_SIZELIMIT_EXCEEDED		0x04	/* 4 */
#define	LDAP_COMPARE_FALSE		0x05	/* 5 */
#define	LDAP_COMPARE_TRUE		0x06	/* 6 */
#define	LDAP_STRONG_AUTH_NOT_SUPPORTED	0x07	/* 7 */
#define	LDAP_STRONG_AUTH_REQUIRED	0x08	/* 8 */
#define	LDAP_PARTIAL_RESULTS		0x09	/* 9 (UMich LDAPv2 extn) */
#define	LDAP_REFERRAL			0x0a	/* 10 - LDAPv3 */
#define	LDAP_ADMINLIMIT_EXCEEDED	0x0b	/* 11 - LDAPv3 */
#define	LDAP_UNAVAILABLE_CRITICAL_EXTENSION  0x0c /* 12 - LDAPv3 */
#define	LDAP_CONFIDENTIALITY_REQUIRED	0x0d	/* 13 */
#define	LDAP_SASL_BIND_IN_PROGRESS	0x0e	/* 14 - LDAPv3 */

#define	LDAP_NO_SUCH_ATTRIBUTE		0x10	/* 16 */
#define	LDAP_UNDEFINED_TYPE		0x11	/* 17 */
#define	LDAP_INAPPROPRIATE_MATCHING	0x12	/* 18 */
#define	LDAP_CONSTRAINT_VIOLATION	0x13	/* 19 */
#define	LDAP_TYPE_OR_VALUE_EXISTS	0x14	/* 20 */
#define	LDAP_INVALID_SYNTAX		0x15	/* 21 */

#define	LDAP_NO_SUCH_OBJECT		0x20	/* 32 */
#define	LDAP_ALIAS_PROBLEM		0x21	/* 33 */
#define	LDAP_INVALID_DN_SYNTAX		0x22	/* 34 */
#define	LDAP_IS_LEAF			0x23	/* 35 (not used in LDAPv3) */
#define	LDAP_ALIAS_DEREF_PROBLEM	0x24	/* 36 */

#define	NAME_ERROR(n)   ((n & 0xf0) == 0x20)

#define	LDAP_INAPPROPRIATE_AUTH		0x30	/* 48 */
#define	LDAP_INVALID_CREDENTIALS	0x31	/* 49 */
#define	LDAP_INSUFFICIENT_ACCESS	0x32	/* 50 */
#define	LDAP_BUSY			0x33	/* 51 */
#define	LDAP_UNAVAILABLE		0x34	/* 52 */
#define	LDAP_UNWILLING_TO_PERFORM	0x35	/* 53 */
#define	LDAP_LOOP_DETECT		0x36	/* 54 */

#define	LDAP_SORT_CONTROL_MISSING	0x3C	/* 60 (server side sort extn) */
#define	LDAP_INDEX_RANGE_ERROR		0x3D    /* 61 (VLV extn) */

#define	LDAP_NAMING_VIOLATION		0x40	/* 64 */
#define	LDAP_OBJECT_CLASS_VIOLATION	0x41	/* 65 */
#define	LDAP_NOT_ALLOWED_ON_NONLEAF	0x42	/* 66 */
#define	LDAP_NOT_ALLOWED_ON_RDN		0x43	/* 67 */
#define	LDAP_ALREADY_EXISTS		0x44	/* 68 */
#define	LDAP_NO_OBJECT_CLASS_MODS	0x45	/* 69 */
#define	LDAP_RESULTS_TOO_LARGE		0x46	/* 70 - CLDAP */
#define	LDAP_AFFECTS_MULTIPLE_DSAS	0x47	/* 71 */

#define	LDAP_OTHER			0x50	/* 80 */
#define	LDAP_SERVER_DOWN		0x51	/* 81 */
#define	LDAP_LOCAL_ERROR		0x52	/* 82 */
#define	LDAP_ENCODING_ERROR		0x53	/* 83 */
#define	LDAP_DECODING_ERROR		0x54	/* 84 */
#define	LDAP_TIMEOUT			0x55	/* 85 */
#define	LDAP_AUTH_UNKNOWN		0x56	/* 86 */
#define	LDAP_FILTER_ERROR		0x57	/* 87 */
#define	LDAP_USER_CANCELLED		0x58	/* 88 */
#define	LDAP_PARAM_ERROR		0x59	/* 89 */
#define	LDAP_NO_MEMORY			0x5a	/* 90 */
#define	LDAP_CONNECT_ERROR		0x5b	/* 91 */
#define	LDAP_NOT_SUPPORTED		0x5c	/* 92 - LDAPv3 */
#define	LDAP_CONTROL_NOT_FOUND		0x5d	/* 93 - LDAPv3 */
#define	LDAP_NO_RESULTS_RETURNED	0x5e	/* 94 - LDAPv3 */
#define	LDAP_MORE_RESULTS_TO_RETURN	0x5f	/* 95 - LDAPv3 */
#define	LDAP_CLIENT_LOOP		0x60	/* 96 - LDAPv3 */
#define	LDAP_REFERRAL_LIMIT_EXCEEDED	0x61	/* 97 - LDAPv3 */

/*
 * LDAPv3 unsolicited notification messages we know about
 */
#define	LDAP_NOTICE_OF_DISCONNECTION	"1.3.6.1.4.1.1466.20036"

/*
 * LDAPv3 server controls we know about
 */
#define	LDAP_CONTROL_MANAGEDSAIT	"2.16.840.1.113730.3.4.2"
#define	LDAP_CONTROL_SORTREQUEST	"1.2.840.113556.1.4.473"
#define	LDAP_CONTROL_SORTRESPONSE	"1.2.840.113556.1.4.474"
#define	LDAP_CONTROL_PERSISTENTSEARCH	"2.16.840.1.113730.3.4.3"
#define	LDAP_CONTROL_ENTRYCHANGE	"2.16.840.1.113730.3.4.7"
#define	LDAP_CONTROL_VLVREQUEST		"2.16.840.1.113730.3.4.9"
#define	LDAP_CONTROL_VLVRESPONSE	"2.16.840.1.113730.3.4.10"
#define	LDAP_CONTROL_PROXYAUTH		"2.16.840.1.113730.3.4.12"
	/* version 1 */
#define	LDAP_CONTROL_PROXIEDAUTH	"2.16.840.1.113730.3.4.18"
	/* version 2 */

#ifdef	_SOLARIS_SDK
/*
 * Simple Page control OID
 */
#define	LDAP_CONTROL_SIMPLE_PAGE	"1.2.840.113556.1.4.319"

/*
 * Begin LDAP Display Template Definitions
 */
#define	LDAP_TEMPLATE_VERSION   1

/*
 * general types of items (confined to most significant byte)
 */
#define	LDAP_SYN_TYPE_TEXT		0x01000000L
#define	LDAP_SYN_TYPE_IMAGE		0x02000000L
#define	LDAP_SYN_TYPE_BOOLEAN		0x04000000L
#define	LDAP_SYN_TYPE_BUTTON		0x08000000L
#define	LDAP_SYN_TYPE_ACTION		0x10000000L

/*
 * syntax options (confined to second most significant byte)
 */
#define	LDAP_SYN_OPT_DEFER		0x00010000L

/*
 * display template item syntax ids (defined by common agreement)
 * these are the valid values for the ti_syntaxid of the tmplitem
 * struct (defined below).  A general type is encoded in the
 * most-significant 8 bits, and some options are encoded in the next
 * 8 bits.  The lower 16 bits are reserved for the distinct types.
 */
#define	LDAP_SYN_CASEIGNORESTR  (1 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_MULTILINESTR   (2 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_DN		(3 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_BOOLEAN	(4 | LDAP_SYN_TYPE_BOOLEAN)
#define	LDAP_SYN_JPEGIMAGE	(5 | LDAP_SYN_TYPE_IMAGE)
#define	LDAP_SYN_JPEGBUTTON	(6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
#define	LDAP_SYN_FAXIMAGE	(7 | LDAP_SYN_TYPE_IMAGE)
#define	LDAP_SYN_FAXBUTTON	(8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
#define	LDAP_SYN_AUDIOBUTTON	(9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
#define	LDAP_SYN_TIME		(10 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_DATE		(11 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_LABELEDURL	(12 | LDAP_SYN_TYPE_TEXT)
#define	LDAP_SYN_SEARCHACTION	(13 | LDAP_SYN_TYPE_ACTION)
#define	LDAP_SYN_LINKACTION	(14 | LDAP_SYN_TYPE_ACTION)
#define	LDAP_SYN_ADDDNACTION	(15 | LDAP_SYN_TYPE_ACTION)
#define	LDAP_SYN_VERIFYDNACTION	(16 | LDAP_SYN_TYPE_ACTION)
#define	LDAP_SYN_RFC822ADDR	(17 | LDAP_SYN_TYPE_TEXT)

/*
 * handy macros
 */
#define	LDAP_GET_SYN_TYPE(syid)		((syid) & 0xFF000000UL)
#define	LDAP_GET_SYN_OPTIONS(syid)	((syid) & 0x00FF0000UL)


/*
 * display options for output routines (used by entry2text and friends)
 */
/*
 * use calculated label width (based on length of longest label in
 * template) instead of contant width
 */
#define	LDAP_DISP_OPT_AUTOLABELWIDTH    0x00000001L
#define	LDAP_DISP_OPT_HTMLBODYONLY	0x00000002L

/*
 * perform search actions (applies to ldap_entry2text_search only)
 */
#define	LDAP_DISP_OPT_DOSEARCHACTIONS   0x00000002L

/*
 * include additional info. relevant to "non leaf" entries only
 * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
 * and "Move Up" HREFs
 */
#define	LDAP_DISP_OPT_NONLEAF		0x00000004L

/*
 * display template item options (may not apply to all types)
 * if this bit is set in ti_options, it applies.
 */
#define	LDAP_DITEM_OPT_READONLY		0x00000001L
#define	LDAP_DITEM_OPT_SORTVALUES	0x00000002L
#define	LDAP_DITEM_OPT_SINGLEVALUED	0x00000004L
#define	LDAP_DITEM_OPT_HIDEIFEMPTY	0x00000008L
#define	LDAP_DITEM_OPT_VALUEREQUIRED	0x00000010L
#define	LDAP_DITEM_OPT_HIDEIFFALSE	0x00000020L	/* booleans only */

#endif	/* _SOLARIS_SDK */

/* Authentication request and response controls */
#define	LDAP_CONTROL_AUTH_REQUEST	"2.16.840.1.113730.3.4.16"
#define	LDAP_CONTROL_AUTH_RESPONSE	"2.16.840.1.113730.3.4.15"

/* Password information sent back to client */
#define	LDAP_CONTROL_PWEXPIRED		"2.16.840.1.113730.3.4.4"
#define	LDAP_CONTROL_PWEXPIRING		"2.16.840.1.113730.3.4.5"


/*
 * Client controls we know about
 */
#define	LDAP_CONTROL_REFERRALS		"1.2.840.113556.1.4.616"


/*
 * LDAP_API macro definition:
 */
#ifndef	LDAP_API
#define	LDAP_API(rt) rt
#endif	/* LDAP_API */

#ifdef	_SOLARIS_SDK
/* Simple Page Control functions for Solaris SDK */
int ldap_create_page_control(LDAP *ld, unsigned int pagesize,
	struct berval *cookie, char isCritical, LDAPControl **output);
int ldap_parse_page_control(LDAP *ld, LDAPControl **controls,
	unsigned int *totalcount, struct berval **cookie);

/* CRAM-MD5 functions */
int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn,
	struct berval *cred, LDAPControl **serverctrls,
	LDAPControl **clientctrls);
/* DIGEST-MD5 Function */
int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn,
	struct berval *cred, LDAPControl **serverctrls,
	LDAPControl **clientctrls);
int ldap_x_sasl_digest_md5_bind(LDAP *ld, char *dn,
	struct berval *cred, LDAPControl **serverctrls,
	LDAPControl **clientctrls, struct timeval *timeout,
	LDAPMessage **result);

#endif	/* _SOLARIS_SDK */

LDAP_API(LDAP *) LDAP_CALL ldap_open(const char *host, int port);
LDAP_API(LDAP *) LDAP_CALL ldap_init(const char *defhost, int defport);
int LDAP_CALL ldap_set_option(LDAP *ld, int option,
	const void *optdata);
int LDAP_CALL ldap_get_option(LDAP *ld, int option, void *optdata);
int LDAP_CALL ldap_unbind(LDAP *ld);
int LDAP_CALL ldap_unbind_s(LDAP *ld);

/*
 * perform ldap operations and obtain results
 */
int LDAP_CALL ldap_abandon(LDAP *ld, int msgid);
int LDAP_CALL ldap_add(LDAP *ld, const char *dn, LDAPMod **attrs);
int LDAP_CALL ldap_add_s(LDAP *ld, const char *dn, LDAPMod **attrs);
int LDAP_CALL ldap_simple_bind(LDAP *ld, const char *who,
	const char *passwd);
int LDAP_CALL ldap_simple_bind_s(LDAP *ld, const char *who,
	const char *passwd);
int LDAP_CALL ldap_modify(LDAP *ld, const char *dn, LDAPMod **mods);
int LDAP_CALL ldap_modify_s(LDAP *ld, const char *dn,
	LDAPMod **mods);
int LDAP_CALL ldap_modrdn(LDAP *ld, const char *dn,
	const char *newrdn);
int LDAP_CALL ldap_modrdn_s(LDAP *ld, const char *dn,
	const char *newrdn);

/* The following 2 functions are deprecated */
int LDAP_CALL ldap_modrdn2(LDAP *ld, const char *dn,
	const char *newrdn, int deleteoldrdn);
int LDAP_CALL ldap_modrdn2_s(LDAP *ld, const char *dn,
	const char *newrdn, int deleteoldrdn);

int LDAP_CALL ldap_compare(LDAP *ld, const char *dn,
	const char *attr, const char *value);
int LDAP_CALL ldap_compare_s(LDAP *ld, const char *dn,
	const char *attr, const char *value);
int LDAP_CALL ldap_delete(LDAP *ld, const char *dn);
int LDAP_CALL ldap_delete_s(LDAP *ld, const char *dn);
int LDAP_CALL ldap_search(LDAP *ld, const char *base, int scope,
	const char *filter, char **attrs, int attrsonly);
int LDAP_CALL ldap_search_s(LDAP *ld, const char *base, int scope,
	const char *filter, char **attrs, int attrsonly, LDAPMessage **res);
int LDAP_CALL ldap_search_st(LDAP *ld, const char *base, int scope,
	const char *filter, char **attrs, int attrsonly,
	struct timeval *timeout, LDAPMessage **res);
int LDAP_CALL ldap_result(LDAP *ld, int msgid, int all,
	struct timeval *timeout, LDAPMessage **result);
int LDAP_CALL ldap_msgfree(LDAPMessage *lm);
int LDAP_CALL ldap_msgid(LDAPMessage *lm);
int LDAP_CALL ldap_msgtype(LDAPMessage *lm);


/*
 * Routines to parse/deal with results and errors returned
 */
int LDAP_CALL ldap_result2error(LDAP *ld, LDAPMessage *r,
	int freeit);
char *LDAP_CALL ldap_err2string(int err);
LDAP_API(void) LDAP_CALL ldap_perror(LDAP *ld, const char *s);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry(LDAP *ld,
    LDAPMessage *chain);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry(LDAP *ld,
    LDAPMessage *entry);
int LDAP_CALL ldap_count_entries(LDAP *ld, LDAPMessage *chain);
char *LDAP_CALL ldap_get_dn(LDAP *ld, LDAPMessage *entry);
char *LDAP_CALL ldap_dn2ufn(const char *dn);
char **LDAP_CALL ldap_explode_dn(const char *dn,
	const int notypes);
char **LDAP_CALL ldap_explode_rdn(const char *rdn,
	const int notypes);
char *LDAP_CALL ldap_first_attribute(LDAP *ld, LDAPMessage *entry,
	BerElement **ber);
char *LDAP_CALL ldap_next_attribute(LDAP *ld, LDAPMessage *entry,
	BerElement *ber);

/* The following function is deprecated */
LDAP_API(void) LDAP_CALL ldap_ber_free(BerElement *ber, int freebuf);

char **LDAP_CALL ldap_get_values(LDAP *ld, LDAPMessage *entry,
	const char *target);
struct berval **LDAP_CALL ldap_get_values_len(LDAP *ld,
	LDAPMessage *entry, const char *target);
int LDAP_CALL ldap_count_values(char **vals);
int LDAP_CALL ldap_count_values_len(struct berval **vals);
LDAP_API(void) LDAP_CALL ldap_value_free(char **vals);
LDAP_API(void) LDAP_CALL ldap_value_free_len(struct berval **vals);
LDAP_API(void) LDAP_CALL ldap_memfree(void *p);


/*
 * LDAPv3 extended operation calls
 */
/*
 * Note: all of the new asynchronous calls return an LDAP error code,
 * not a message id.  A message id is returned via the int *msgidp
 * parameter (usually the last parameter) if appropriate.
 */
int LDAP_CALL ldap_abandon_ext(LDAP *ld, int msgid,
	LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_add_ext(LDAP *ld, const char *dn, LDAPMod **attrs,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_add_ext_s(LDAP *ld, const char *dn,
	LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_sasl_bind(LDAP *ld, const char *dn,
	const char *mechanism, const struct berval *cred,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_sasl_bind_s(LDAP *ld, const char *dn,
	const char *mechanism, const struct berval *cred,
	LDAPControl **serverctrls, LDAPControl **clientctrls,
	struct berval **servercredp);
int LDAP_CALL ldap_modify_ext(LDAP *ld, const char *dn,
	LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls,
	int *msgidp);
int LDAP_CALL ldap_modify_ext_s(LDAP *ld, const char *dn,
	LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_rename(LDAP *ld, const char *dn,
	const char *newrdn, const char *newparent, int deleteoldrdn,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_rename_s(LDAP *ld, const char *dn,
	const char *newrdn, const char *newparent, int deleteoldrdn,
	LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_compare_ext(LDAP *ld, const char *dn,
	const char *attr, const struct berval *bvalue,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_compare_ext_s(LDAP *ld, const char *dn,
	const char *attr, const struct berval *bvalue,
	LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_delete_ext(LDAP *ld, const char *dn,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_delete_ext_s(LDAP *ld, const char *dn,
	LDAPControl **serverctrls, LDAPControl **clientctrls);
int LDAP_CALL ldap_search_ext(LDAP *ld, const char *base,
	int scope, const char *filter, char **attrs, int attrsonly,
	LDAPControl **serverctrls, LDAPControl **clientctrls,
	struct timeval *timeoutp, int sizelimit, int *msgidp);
int LDAP_CALL ldap_search_ext_s(LDAP *ld, const char *base,
	int scope, const char *filter, char **attrs, int attrsonly,
	LDAPControl **serverctrls, LDAPControl **clientctrls,
	struct timeval *timeoutp, int sizelimit, LDAPMessage **res);
int LDAP_CALL ldap_extended_operation(LDAP *ld,
	const char *requestoid, const struct berval *requestdata,
	LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
int LDAP_CALL ldap_extended_operation_s(LDAP *ld,
	const char *requestoid, const struct berval *requestdata,
	LDAPControl **serverctrls, LDAPControl **clientctrls,
	char **retoidp, struct berval **retdatap);
int LDAP_CALL ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls,
	LDAPControl **clientctrls);


/*
 * LDAPv3 extended parsing / result handling calls
 */
int LDAP_CALL ldap_parse_sasl_bind_result(LDAP *ld,
	LDAPMessage *res, struct berval **servercredp, int freeit);
int LDAP_CALL ldap_parse_result(LDAP *ld, LDAPMessage *res,
	int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp,
	LDAPControl ***serverctrlsp, int freeit);
int LDAP_CALL ldap_parse_extended_result(LDAP *ld, LDAPMessage *res,
	char **retoidp, struct berval **retdatap, int freeit);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message(LDAP *ld,
    LDAPMessage *res);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message(LDAP *ld,
    LDAPMessage *msg);
int LDAP_CALL ldap_count_messages(LDAP *ld, LDAPMessage *res);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference(LDAP *ld,
    LDAPMessage *res);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference(LDAP *ld,
    LDAPMessage *ref);
int LDAP_CALL ldap_count_references(LDAP *ld, LDAPMessage *res);
int LDAP_CALL ldap_parse_reference(LDAP *ld, LDAPMessage *ref,
	char ***referralsp, LDAPControl ***serverctrlsp, int freeit);
int LDAP_CALL ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry,
	LDAPControl ***serverctrlsp);
LDAP_API(void) LDAP_CALL ldap_control_free(LDAPControl *ctrl);
LDAP_API(void) LDAP_CALL ldap_controls_free(LDAPControl **ctrls);

#ifdef  _SOLARIS_SDK
char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
#endif

LDAP_API(void) LDAP_CALL ldap_add_result_entry(
	LDAPMessage **list, LDAPMessage *e);
LDAP_API(LDAPMessage *) LDAP_CALL ldap_delete_result_entry(
	LDAPMessage **list, LDAPMessage *e);


/* End of core standard C LDAP API definitions */

/*
 * Server side sorting of search results (an LDAPv3 extension --
 * LDAP_API_FEATURE_SERVER_SIDE_SORT)
 */
typedef struct LDAPsortkey {	/* structure for a sort-key */
	char *sk_attrtype;
	char *sk_matchruleoid;
	int	sk_reverseorder;
} LDAPsortkey;

int LDAP_CALL ldap_create_sort_control(LDAP *ld,
	LDAPsortkey **sortKeyList, const char ctl_iscritical,
	LDAPControl **ctrlp);
int LDAP_CALL ldap_parse_sort_control(LDAP *ld,
	LDAPControl **ctrls, unsigned long *result, char **attribute);

LDAP_API(void) LDAP_CALL ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
int LDAP_CALL ldap_create_sort_keylist(LDAPsortkey ***sortKeyList,
	const char *string_rep);


/*
 * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW)
 */
/*
 * structure that describes a VirtualListViewRequest control.
 * note that ldvlist_index and ldvlist_size are only relevant to
 * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL.
 */
typedef struct ldapvirtuallist {
    unsigned long	ldvlist_before_count;	/* # entries before target */
    unsigned long   ldvlist_after_count;	/* # entries after target */
    char	    *ldvlist_attrvalue;		/* jump to this value */
    unsigned long   ldvlist_index;		/* list offset */
    unsigned long   ldvlist_size;		/* number of items in vlist */
    void	*ldvlist_extradata;		/* for use by application */
} LDAPVirtualList;

/*
 * VLV functions:
 */
int LDAP_CALL ldap_create_virtuallist_control(LDAP *ld,
	LDAPVirtualList *ldvlistp, LDAPControl **ctrlp);

int LDAP_CALL ldap_parse_virtuallist_control(LDAP *ld,
	LDAPControl **ctrls, unsigned long *target_posp,
	unsigned long *list_sizep, int *errcodep);


/*
 * Routines for creating persistent search controls and for handling
 * "entry changed notification" controls (an LDAPv3 extension --
 * LDAP_API_FEATURE_PERSISTENT_SEARCH)
 */
#define	LDAP_CHANGETYPE_ADD		1
#define	LDAP_CHANGETYPE_DELETE		2
#define	LDAP_CHANGETYPE_MODIFY		4
#define	LDAP_CHANGETYPE_MODDN		8
#define	LDAP_CHANGETYPE_ANY		(1|2|4|8)
int LDAP_CALL ldap_create_persistentsearch_control(LDAP *ld,
	int changetypes, int changesonly, int return_echg_ctls,
	char ctl_iscritical, LDAPControl **ctrlp);
int LDAP_CALL ldap_parse_entrychange_control(LDAP *ld,
	LDAPControl **ctrls, int *chgtypep, char **prevdnp,
	int *chgnumpresentp, ber_int_t *chgnump);


/*
 * Routines for creating Proxied Authorization controls (an LDAPv3
 * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION)
 * ldap_create_proxyauth_control() is for the old (version 1) control.
 * ldap_create_proxiedauth_control() is for the newer (version 2) control.
 * Version 1 is supported by iPlanet Directory Server 4.1 and later.
 * Version 2 is supported by iPlanet Directory Server 5.0 and later.
 */
int LDAP_CALL ldap_create_proxyauth_control(LDAP *ld,
	const char *dn, const char ctl_iscritical, LDAPControl **ctrlp);
int LDAP_CALL ldap_create_proxiedauth_control(LDAP *ld,
	const char *authzid, LDAPControl **ctrlp);


/*
 * Functions to get and set LDAP error information (API extension --
 * LDAP_API_FEATURE_X_LDERRNO )
 */
int LDAP_CALL ldap_get_lderrno(LDAP *ld, char **m, char **s);
int LDAP_CALL ldap_set_lderrno(LDAP *ld, int e, char *m, char *s);


/*
 * LDAP URL functions and definitions (an API extension --
 * LDAP_API_FEATURE_X_URL_FUNCTIONS)
 */
/*
 * types for ldap URL handling
 */
typedef struct ldap_url_desc {
    char		*lud_host;
    int			lud_port;
    char		*lud_dn;
    char		**lud_attrs;
    int			lud_scope;
    char		*lud_filter;
    unsigned long	lud_options;
#define	LDAP_URL_OPT_SECURE	0x01
    char	*lud_string;    /* for internal use only */
} LDAPURLDesc;

#define	NULLLDAPURLDESC ((LDAPURLDesc *)NULL)

/*
 * possible errors returned by ldap_url_parse()
 */
#define	LDAP_URL_ERR_NOTLDAP	1	/* URL doesn't begin with "ldap://" */
#define	LDAP_URL_ERR_NODN	2	/* URL has no DN (required) */
#define	LDAP_URL_ERR_BADSCOPE	3	/* URL scope string is invalid */
#define	LDAP_URL_ERR_MEM	4	/* can't allocate memory space */
#define	LDAP_URL_ERR_PARAM	5	/* bad parameter to an URL function */
#define	LDAP_URL_ERR_HOSTPORT	6	/* URL hostcode is invalid */

/*
 * URL functions:
 */
int LDAP_CALL ldap_is_ldap_url(const char *url);
int LDAP_CALL ldap_url_parse(const char *url, LDAPURLDesc **ludpp);
int LDAP_CALL ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp);
LDAP_API(void) LDAP_CALL ldap_free_urldesc(LDAPURLDesc *ludp);
int LDAP_CALL ldap_url_search(LDAP *ld, const char *url,
	int attrsonly);
int LDAP_CALL ldap_url_search_s(LDAP *ld, const char *url,
	int attrsonly, LDAPMessage **res);
int LDAP_CALL ldap_url_search_st(LDAP *ld, const char *url,
	int attrsonly, struct timeval *timeout, LDAPMessage **res);

#ifdef	_SOLARIS_SDK
/*
 * Additional URL functions plus Character set, Search Preference
 * and Display Template functions moved from internal header files
 */

/*
 * URL functions
 */
char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
	char *scope, char *filter);
char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);

/*
 * Character set functions
 */
#ifdef	STR_TRANSLATION
void ldap_set_string_translators(LDAP *ld,
	BERTranslateProc encode_proc, BERTranslateProc decode_proc);
int ldap_translate_from_t61(LDAP *ld, char **bufp,
	unsigned long *lenp, int free_input);
int ldap_translate_to_t61(LDAP *ld, char **bufp,
	unsigned long *lenp, int free_input);
void ldap_enable_translation(LDAP *ld, LDAPMessage *entry,
	int enable);
#ifdef	LDAP_CHARSET_8859
int ldap_t61_to_8859(char **bufp, unsigned long *buflenp,
	int free_input);
int ldap_8859_to_t61(char **bufp, unsigned long *buflenp,
	int free_input);
#endif	/* LDAP_CHARSET_8859 */
#endif	/* STR_TRANSLATION */

/*
 * Display Temple functions/structures
 */
/*
 * display template item structure
 */
struct ldap_tmplitem {
    unsigned long		ti_syntaxid;
    unsigned long		ti_options;
    char			*ti_attrname;
    char			*ti_label;
    char			**ti_args;
    struct ldap_tmplitem	*ti_next_in_row;
    struct ldap_tmplitem	*ti_next_in_col;
    void			*ti_appdata;
};

#define	NULLTMPLITEM	((struct ldap_tmplitem *)0)

#define	LDAP_SET_TMPLITEM_APPDATA(ti, datap)  \
	(ti)->ti_appdata = (void *)(datap)

#define	LDAP_GET_TMPLITEM_APPDATA(ti, type)   \
	(type)((ti)->ti_appdata)

#define	LDAP_IS_TMPLITEM_OPTION_SET(ti, option)       \
	(((ti)->ti_options & option) != 0)

/*
 * object class array structure
 */
struct ldap_oclist {
    char		**oc_objclasses;
    struct ldap_oclist	*oc_next;
};

#define	NULLOCLIST	((struct ldap_oclist *)0)


/*
 * add defaults list
 */
struct ldap_adddeflist {
    int			ad_source;
#define	LDAP_ADSRC_CONSTANTVALUE	1
#define	LDAP_ADSRC_ADDERSDN		2
    char		*ad_attrname;
    char		*ad_value;
    struct ldap_adddeflist	*ad_next;
};

#define	NULLADLIST	((struct ldap_adddeflist *)0)


/*
 * display template global options
 * if this bit is set in dt_options, it applies.
 */
/*
 * users should be allowed to try to add objects of these entries
 */
#define	LDAP_DTMPL_OPT_ADDABLE		0x00000001L

/*
 * users should be allowed to do "modify RDN" operation of these entries
 */
#define	LDAP_DTMPL_OPT_ALLOWMODRDN	0x00000002L

/*
 * this template is an alternate view, not a primary view
 */
#define	LDAP_DTMPL_OPT_ALTVIEW	0x00000004L


/*
 * display template structure
 */
struct ldap_disptmpl {
    char			*dt_name;
    char			*dt_pluralname;
    char			*dt_iconname;
    unsigned long		dt_options;
    char			*dt_authattrname;
    char			*dt_defrdnattrname;
    char			*dt_defaddlocation;
    struct ldap_oclist		*dt_oclist;
    struct ldap_adddeflist	*dt_adddeflist;
    struct ldap_tmplitem	*dt_items;
    void			*dt_appdata;
    struct ldap_disptmpl	*dt_next;
};

#define	NULLDISPTMPL	((struct ldap_disptmpl *)0)

#define	LDAP_SET_DISPTMPL_APPDATA(dt, datap)  \
	(dt)->dt_appdata = (void *)(datap)

#define	LDAP_GET_DISPTMPL_APPDATA(dt, type)   \
	(type)((dt)->dt_appdata)

#define	LDAP_IS_DISPTMPL_OPTION_SET(dt, option)       \
	(((dt)->dt_options & option) != 0)

#define	LDAP_TMPL_ERR_VERSION   1
#define	LDAP_TMPL_ERR_MEM	2
#define	LDAP_TMPL_ERR_SYNTAX    3
#define	LDAP_TMPL_ERR_FILE	4

/*
 * buffer size needed for entry2text and vals2text
 */
#define	LDAP_DTMPL_BUFSIZ	8192

typedef int (*writeptype)(void *writeparm, char *p, int len);

LDAP_API(int) LDAP_CALL ldap_init_templates(char *file,
    struct ldap_disptmpl **tmpllistp);

LDAP_API(int) LDAP_CALL ldap_init_templates_buf(char *buf, long buflen,
    struct ldap_disptmpl **tmpllistp);

LDAP_API(void) LDAP_CALL ldap_free_templates(struct ldap_disptmpl *tmpllist);

LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_first_disptmpl(
    struct ldap_disptmpl *tmpllist);

LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_next_disptmpl(
    struct ldap_disptmpl *tmpllist,
    struct ldap_disptmpl *tmpl);

LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_name2template(char *name,
    struct ldap_disptmpl *tmpllist);

LDAP_API(struct ldap_disptmpl *) LDAP_CALL ldap_oc2template(char **oclist,
    struct ldap_disptmpl *tmpllist);

LDAP_API(char **) LDAP_CALL ldap_tmplattrs(struct ldap_disptmpl *tmpl,
    char **includeattrs, int exclude,
    unsigned long syntaxmask);

LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_first_tmplrow(
    struct ldap_disptmpl *tmpl);

LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_next_tmplrow(
    struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);

LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_first_tmplcol(
    struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);

LDAP_API(struct ldap_tmplitem *) LDAP_CALL ldap_next_tmplcol(
    struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
    struct ldap_tmplitem *col);

LDAP_API(int) LDAP_CALL ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry,
    struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
    writeptype writeproc, void *writeparm, char *eol, int rdncount,
    unsigned long opts);

LDAP_API(int) LDAP_CALL ldap_vals2text(LDAP *ld, char *buf, char **vals,
    char *label, int labelwidth,
    unsigned long syntaxid, writeptype writeproc, void *writeparm,
    char *eol, int rdncount);

LDAP_API(int) LDAP_CALL ldap_entry2text_search(LDAP *ld, char *dn, char *base,
    LDAPMessage *entry,
    struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
    writeptype writeproc, void *writeparm, char *eol, int rdncount,
    unsigned long opts);

LDAP_API(int) LDAP_CALL ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry,
    struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
    writeptype writeproc, void *writeparm, char *eol, int rdncount,
    unsigned long opts, char *urlprefix, char *base);

LDAP_API(int) LDAP_CALL ldap_vals2html(LDAP *ld, char *buf, char **vals,
    char *label, int labelwidth,
    unsigned long syntaxid, writeptype writeproc, void *writeparm,
    char *eol, int rdncount, char *urlprefix);

LDAP_API(int) LDAP_CALL ldap_entry2html_search(LDAP *ld, char *dn, char *base,
    LDAPMessage *entry,
    struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
    writeptype writeproc, void *writeparm, char *eol, int rdncount,
    unsigned long opts, char *urlprefix);

/*
 * Search Preference Definitions
 */

struct ldap_searchattr {
	char				*sa_attrlabel;
	char				*sa_attr;
					/* max 32 matchtypes for now */
	unsigned long			sa_matchtypebitmap;
	char				*sa_selectattr;
	char				*sa_selecttext;
	struct ldap_searchattr		*sa_next;
};

struct ldap_searchmatch {
	char				*sm_matchprompt;
	char				*sm_filter;
	struct ldap_searchmatch		*sm_next;
};

struct ldap_searchobj {
	char				*so_objtypeprompt;
	unsigned long			so_options;
	char				*so_prompt;
	short				so_defaultscope;
	char				*so_filterprefix;
	char				*so_filtertag;
	char				*so_defaultselectattr;
	char				*so_defaultselecttext;
	struct ldap_searchattr		*so_salist;
	struct ldap_searchmatch		*so_smlist;
	struct ldap_searchobj		*so_next;
};

#define	NULLSEARCHOBJ			((struct ldap_searchobj *)0)

/*
 * global search object options
 */
#define	LDAP_SEARCHOBJ_OPT_INTERNAL	0x00000001

#define	LDAP_IS_SEARCHOBJ_OPTION_SET(so, option)      \
	(((so)->so_options & option) != 0)

#define	LDAP_SEARCHPREF_VERSION_ZERO    0
#define	LDAP_SEARCHPREF_VERSION		1

#define	LDAP_SEARCHPREF_ERR_VERSION	1
#define	LDAP_SEARCHPREF_ERR_MEM		2
#define	LDAP_SEARCHPREF_ERR_SYNTAX	3
#define	LDAP_SEARCHPREF_ERR_FILE	4

LDAP_API(int) LDAP_CALL ldap_init_searchprefs(char *file,
    struct ldap_searchobj **solistp);

LDAP_API(int) LDAP_CALL ldap_init_searchprefs_buf(char *buf, long buflen,
    struct ldap_searchobj **solistp);

LDAP_API(void) LDAP_CALL ldap_free_searchprefs(struct ldap_searchobj *solist);

LDAP_API(struct ldap_searchobj *) LDAP_CALL ldap_first_searchobj(
    struct ldap_searchobj *solist);

LDAP_API(struct ldap_searchobj *) LDAP_CALL ldap_next_searchobj(
    struct ldap_searchobj *sollist, struct ldap_searchobj *so);

/*
 * specific LDAP instantiations of BER types we know about
 */

/* general stuff */
#define	LDAP_TAG_MESSAGE	0x30   /* tag is 16 + constructed bit */
#define	LDAP_TAG_MSGID		0x02   /* INTEGER */
#define	LDAP_TAG_CONTROLS	0xa0   /* context specific + constructed + 0 */
#define	LDAP_TAG_REFERRAL	0xa3   /* context specific + constructed + 3 */
#define	LDAP_TAG_NEWSUPERIOR    0x80   /* context specific + primitive + 0 */
#define	LDAP_TAG_SASL_RES_CREDS 0x87   /* context specific + primitive + 7 */
#define	LDAP_TAG_VLV_BY_INDEX   0xa0   /* context specific + constructed + 0 */
#define	LDAP_TAG_VLV_BY_VALUE   0x81   /* context specific + primitive + 1 */
/* tag for sort control */
#define	LDAP_TAG_SK_MATCHRULE   0x80L   /* context specific + primitive + 0 */
#define	LDAP_TAG_SK_REVERSE	0x81L   /* context specific + primitive + 1 */
#define	LDAP_TAG_SR_ATTRTYPE    0x80L   /* context specific + primitive + 0 */

/* possible operations a client can invoke */
#define	LDAP_REQ_BIND	0x60   /* application + constructed + 0 */
#define	LDAP_REQ_UNBIND		0x42   /* application + primitive   + 2 */
#define	LDAP_REQ_SEARCH		0x63   /* application + constructed + 3 */
#define	LDAP_REQ_MODIFY		0x66   /* application + constructed + 6 */
#define	LDAP_REQ_ADD		0x68   /* application + constructed + 8 */
#define	LDAP_REQ_DELETE		0x4a   /* application + primitive   + 10 */
#define	LDAP_REQ_MODRDN		0x6c   /* application + constructed + 12 */
#define	LDAP_REQ_MODDN		0x6c   /* application + constructed + 12 */
#define	LDAP_REQ_RENAME		0x6c   /* application + constructed + 12 */
#define	LDAP_REQ_COMPARE	0x6e   /* application + constructed + 14 */
#define	LDAP_REQ_ABANDON	0x50   /* application + primitive   + 16 */
#define	LDAP_REQ_EXTENDED	0x77   /* application + constructed + 23 */

/* U-M LDAP release 3.0 compatibility stuff */
#define	LDAP_REQ_UNBIND_30	0x62
#define	LDAP_REQ_DELETE_30	0x6a
#define	LDAP_REQ_ABANDON_30	0x70

/* U-M LDAP 3.0 compatibility auth methods */
#define	LDAP_AUTH_SIMPLE_30	0xa0   /* context specific + constructed */
#define	LDAP_AUTH_KRBV41_30	0xa1   /* context specific + constructed */
#define	LDAP_AUTH_KRBV42_30	0xa2   /* context specific + constructed */

/* filter types */
#define	LDAP_FILTER_AND		0xa0   /* context specific + constructed + 0 */
#define	LDAP_FILTER_OR		0xa1   /* context specific + constructed + 1 */
#define	LDAP_FILTER_NOT		0xa2   /* context specific + constructed + 2 */
#define	LDAP_FILTER_EQUALITY	0xa3   /* context specific + constructed + 3 */
#define	LDAP_FILTER_SUBSTRINGS	0xa4   /* context specific + constructed + 4 */
#define	LDAP_FILTER_GE		0xa5   /* context specific + constructed + 5 */
#define	LDAP_FILTER_LE		0xa6   /* context specific + constructed + 6 */
#define	LDAP_FILTER_PRESENT	0x87   /* context specific + primitive   + 7 */
#define	LDAP_FILTER_APPROX	0xa8   /* context specific + constructed + 8 */
#define	LDAP_FILTER_EXTENDED	0xa9   /* context specific + constructed + 0 */

/* U-M LDAP 3.0 compatibility filter types */
#define	LDAP_FILTER_PRESENT_30	0xa7   /* context specific + constructed */

/* substring filter component types */
#define	LDAP_SUBSTRING_INITIAL	0x80   /* context specific + primitive + 0 */
#define	LDAP_SUBSTRING_ANY	0x81   /* context specific + primitive + 1 */
#define	LDAP_SUBSTRING_FINAL    0x82   /* context specific + primitive + 2 */

/* U-M LDAP 3.0 compatibility substring filter component types */
#define	LDAP_SUBSTRING_INITIAL_30	0xa0   /* context specific */
#define	LDAP_SUBSTRING_ANY_30		0xa1   /* context specific */
#define	LDAP_SUBSTRING_FINAL_30		0xa2   /* context specific */

#endif	/* _SOLARIS_SDK */

/*
 * Function to dispose of an array of LDAPMod structures (an API extension).
 * Warning: don't use this unless the mods array was allocated using the
 * same memory allocator as is being used by libldap.
 */
LDAP_API(void) LDAP_CALL ldap_mods_free(LDAPMod **mods, int freemods);

/*
 * Preferred language and get_lang_values (an API extension --
 * LDAP_API_FEATURE_X_GETLANGVALUES)
 *
 * The following two APIs are deprecated
 */

char **LDAP_CALL ldap_get_lang_values(LDAP *ld, LDAPMessage *entry,
	const char *target, char **type);
struct berval **LDAP_CALL ldap_get_lang_values_len(LDAP *ld,
	LDAPMessage *entry, const char *target, char **type);


/*
 * Rebind callback function (an API extension)
 */
#define	LDAP_OPT_REBIND_FN		0x06	/* 6 - API extension */
#define	LDAP_OPT_REBIND_ARG		0x07	/* 7 - API extension */
typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)(LDAP *ld,
	char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg);
LDAP_API(void) LDAP_CALL ldap_set_rebind_proc(LDAP *ld,
    LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg);

/*
 * Thread function callbacks (an API extension --
 * LDAP_API_FEATURE_X_THREAD_FUNCTIONS).
 */
#define	LDAP_OPT_THREAD_FN_PTRS		0x05	/* 5 - API extension */

/*
 * Thread callback functions:
 */
typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)(void);
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)(void *m);
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)(void *m);
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)(void *m);
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)(void);
typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)(int e);
typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)(
	char **matchedp, char **errmsgp, void *arg);
typedef void    (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)(int err,
	char *matched, char *errmsg, void *arg);

/*
 * Structure to hold thread function pointers:
 */
struct ldap_thread_fns {
	LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc;
	LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free;
	LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock;
	LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock;
	LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno;
	LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno;
	LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno;
	LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno;
	void    *ltf_lderrno_arg;
};

/*
 * Client side sorting of entries (an API extension --
 * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT)
 */
/*
 * Client side sorting callback functions:
 */
typedef const struct berval *(LDAP_C LDAP_CALLBACK
	LDAP_KEYGEN_CALLBACK)(void *arg, LDAP *ld, LDAPMessage *entry);
typedef int (LDAP_C LDAP_CALLBACK
	LDAP_KEYCMP_CALLBACK)(void *arg, const struct berval *,
	const struct berval *);
typedef void (LDAP_C LDAP_CALLBACK
	LDAP_KEYFREE_CALLBACK)(void *arg, const struct berval *);
typedef int (LDAP_C LDAP_CALLBACK
	LDAP_CMP_CALLBACK)(const char *val1, const char *val2);
typedef int (LDAP_C LDAP_CALLBACK
	LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p);

/*
 * Client side sorting functions:
 */
int LDAP_CALL ldap_multisort_entries(LDAP *ld, LDAPMessage **chain,
	char **attr, LDAP_CMP_CALLBACK *cmp);
int LDAP_CALL ldap_sort_entries(LDAP *ld, LDAPMessage **chain,
	char *attr, LDAP_CMP_CALLBACK *cmp);
int LDAP_CALL ldap_sort_values(LDAP *ld, char **vals,
	LDAP_VALCMP_CALLBACK *cmp);
int LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp(const char **a,
	const char **b);


/*
 * Filter functions and definitions (an API extension --
 * LDAP_API_FEATURE_X_FILTER_FUNCTIONS)
 */
/*
 * Structures, constants, and types for filter utility routines:
 */
typedef struct ldap_filt_info {
	char			*lfi_filter;
	char			*lfi_desc;
	int			lfi_scope;	/* LDAP_SCOPE_BASE, etc */
	int			lfi_isexact;    /* exact match filter? */
	struct ldap_filt_info   *lfi_next;
} LDAPFiltInfo;

#define	LDAP_FILT_MAXSIZ	1024

typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */
typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */

/*
 * Filter utility functions:
 */
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter(char *fname);
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf(char *buf,
    ssize_t buflen);
LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter(LDAPFiltDesc *lfdp,
    char *tagpat, char *value);
LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter(LDAPFiltDesc *lfdp);
int LDAP_CALL ldap_set_filter_additions(LDAPFiltDesc *lfdp,
	char *prefix, char *suffix);
int LDAP_CALL ldap_create_filter(char *buf, unsigned long buflen,
	char *pattern, char *prefix, char *suffix, char *attr,
	char *value, char **valwords);
LDAP_API(void) LDAP_CALL ldap_getfilter_free(LDAPFiltDesc *lfdp);


/*
 * Friendly mapping structure and routines (an API extension)
 */
typedef struct friendly {
	char    *f_unfriendly;
	char    *f_friendly;
} *FriendlyMap;
char *LDAP_CALL ldap_friendly_name(char *filename, char *name,
	FriendlyMap *map);
LDAP_API(void) LDAP_CALL ldap_free_friendlymap(FriendlyMap *map);


/*
 * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE)
 */
typedef struct ldapmemcache  LDAPMemCache;  /* opaque in-memory cache handle */

int LDAP_CALL ldap_memcache_init(unsigned long ttl,
	unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns,
	LDAPMemCache **cachep);
int LDAP_CALL ldap_memcache_set(LDAP *ld, LDAPMemCache *cache);
int LDAP_CALL ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep);
LDAP_API(void) LDAP_CALL ldap_memcache_flush(LDAPMemCache *cache, char *dn,
    int scope);
LDAP_API(void) LDAP_CALL ldap_memcache_destroy(LDAPMemCache *cache);
LDAP_API(void) LDAP_CALL ldap_memcache_update(LDAPMemCache *cache);

/*
 * Server reconnect (an API extension).
 */
#define	LDAP_OPT_RECONNECT		0x62    /* 98 - API extension */

/*
 * Asynchronous I/O (an API extension).
 */
/*
 * This option enables completely asynchronous IO.  It works by using ioctl()
 * on the fd, (or tlook())
 */
#define	LDAP_OPT_ASYNC_CONNECT		0x63    /* 99 - API extension */

/*
 * I/O function callbacks option (an API extension --
 * LDAP_API_FEATURE_X_IO_FUNCTIONS).
 * Use of the extended I/O functions instead is recommended; see above.
 */
#define	LDAP_OPT_IO_FN_PTRS		0x0B    /* 11 - API extension */

/*
 * Extended I/O function callbacks option (an API extension --
 * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS).
 */
#define	LDAP_X_OPT_EXTIO_FN_PTRS   (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00)
	/* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */



/*
 * generalized bind
 */
/*
 * Authentication methods:
 */
#define	LDAP_AUTH_NONE		0x00
#define	LDAP_AUTH_SIMPLE	0x80
#define	LDAP_AUTH_SASL		0xa3
int LDAP_CALL ldap_bind(LDAP *ld, const char *who,
	const char *passwd, int authmethod);
int LDAP_CALL ldap_bind_s(LDAP *ld, const char *who,
	const char *cred, int method);

/*
 * experimental DN format support
 */
char **LDAP_CALL ldap_explode_dns(const char *dn);
int LDAP_CALL ldap_is_dns_dn(const char *dn);

#ifdef	_SOLARIS_SDK
char *ldap_dns_to_dn(char *dns_name, int *nameparts);
#endif


/*
 * user friendly naming/searching routines
 */
typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)(void *cl);
int LDAP_CALL ldap_ufn_search_c(LDAP *ld, char *ufn,
	char **attrs, int attrsonly, LDAPMessage **res,
	LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm);
int LDAP_CALL ldap_ufn_search_ct(LDAP *ld, char *ufn,
	char **attrs, int attrsonly, LDAPMessage **res,
	LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm,
	char *tag1, char *tag2, char *tag3);
int LDAP_CALL ldap_ufn_search_s(LDAP *ld, char *ufn,
	char **attrs, int attrsonly, LDAPMessage **res);
LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter(LDAP *ld, char *fname);
LDAP_API(void) LDAP_CALL ldap_ufn_setprefix(LDAP *ld, char *prefix);
int LDAP_C ldap_ufn_timeout(void *tvparam);

/*
 * functions and definitions that have been replaced by new improved ones
 */
/*
 * Use ldap_get_option() with LDAP_OPT_API_INFO and an LDAPAPIInfo structure
 * instead of ldap_version(). The use of this API is deprecated.
 */
typedef struct _LDAPVersion {
	int sdk_version;	/* Version of the SDK, * 100 */
	int protocol_version;	/* Highest protocol version supported, * 100 */
	int SSL_version;	/* SSL version if this SDK supports it, * 100 */
	int security_level;	/* highest level available */
	int reserved[4];
} LDAPVersion;
#define	LDAP_SECURITY_NONE	0
int LDAP_CALL ldap_version(LDAPVersion *ver);

/* use ldap_create_filter() instead of ldap_build_filter() */
LDAP_API(void) LDAP_CALL ldap_build_filter(char *buf, size_t buflen,
    char *pattern, char *prefix, char *suffix, char *attr,
    char *value, char **valwords);
/* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */
LDAP_API(void) LDAP_CALL ldap_setfilteraffixes(LDAPFiltDesc *lfdp,
    char *prefix, char *suffix);

/* older result types a server can return -- use LDAP_RES_MODDN instead */
#define	LDAP_RES_MODRDN			LDAP_RES_MODDN
#define	LDAP_RES_RENAME			LDAP_RES_MODDN

/* older error messages */
#define	LDAP_AUTH_METHOD_NOT_SUPPORTED  LDAP_STRONG_AUTH_NOT_SUPPORTED

/* end of unsupported functions */

#ifdef	_SOLARIS_SDK

/* SSL Functions */

/*
 * these three defines resolve the SSL strength
 * setting auth weak, diables all cert checking
 * the CNCHECK tests for the man in the middle hack
 */
#define	LDAPSSL_AUTH_WEAK	0
#define	LDAPSSL_AUTH_CERT	1
#define	LDAPSSL_AUTH_CNCHECK    2

/*
 * Initialize LDAP library for SSL
 */
LDAP * LDAP_CALL ldapssl_init(const char *defhost, int defport,
	int defsecure);

/*
 * Install I/O routines to make SSL over LDAP possible.
 * Use this after ldap_init() or just use ldapssl_init() instead.
 */
int LDAP_CALL ldapssl_install_routines(LDAP *ld);


/*
 * The next three functions initialize the security code for SSL
 * The first one ldapssl_client_init() does initialization for SSL only
 * The next one supports ldapssl_clientauth_init() intializes security
 * for SSL for client authentication. The third function initializes
 * security for doing SSL with client authentication, and PKCS, that is,
 * the third function initializes the security module database(secmod.db).
 * The parameters are as follows:
 * const char *certdbpath - path to the cert file.  This can be a shortcut
 * to the directory name, if so cert7.db will be postfixed to the string.
 * void *certdbhandle - Normally this is NULL.  This memory will need
 * to be freed.
 * int needkeydb - boolean.  Must be ! = 0 if client Authentification
 * is required
 * char *keydbpath - path to the key database.  This can be a shortcut
 * to the directory name, if so key3.db will be postfixed to the string.
 * void *keydbhandle - Normally this is NULL, This memory will need
 * to be freed
 * int needsecmoddb - boolean.  Must be ! = 0 to assure that the correct
 * security module is loaded into memory
 * char *secmodpath - path to the secmod.  This can be a shortcut to the
 * directory name, if so secmod.db will be postfixed to the string.
 *
 * These three functions are mutually exclusive.  You can only call
 * one.  This means that, for a given process, you must call the
 * appropriate initialization function for the life of the process.
 */


/*
 * Initialize the secure parts (Security and SSL) of the runtime for use
 * by a client application.  This is only called once.
 */
int LDAP_CALL ldapssl_client_init(
    const char *certdbpath, void *certdbhandle);

/*
 * Initialize the secure parts (Security and SSL) of the runtime for use
 * by a client application that may want to do SSL client authentication.
 */
int LDAP_CALL ldapssl_clientauth_init(
    const char *certdbpath, void *certdbhandle,
    const int needkeydb, const char *keydbpath, void *keydbhandle);

/*
 * Initialize the secure parts (Security and SSL) of the runtime for use
 * by a client application that may want to do SSL client authentication.
 */
int LDAP_CALL ldapssl_advclientauth_init(
    const char *certdbpath, void *certdbhandle,
    const int needkeydb, const char *keydbpath, void *keydbhandle,
    const int needsecmoddb, const char *secmoddbpath,
    const int sslstrength);

/*
 * get a meaningful error string back from the security library
 * this function should be called, if ldap_err2string doesn't
 * identify the error code.
 */
const char *LDAP_CALL ldapssl_err2string(const int prerrno);

/*
 * Enable SSL client authentication on the given ld.
 */
int LDAP_CALL ldapssl_enable_clientauth(LDAP *ld, char *keynickname,
	char *keypasswd, char *certnickname);

typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK)
	(void *context, char **tokenname);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK)
	(void *context, const char *tokenname, char **tokenpin);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK)
	(void *context, char **certpath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK)
	(void *context, char **keypath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK)
	(void *context, char **modulepath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK)
	(void *context, char **certname);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK)
	(void *context, char **filename);

#define	PKCS_STRUCTURE_ID 1
struct ldapssl_pkcs_fns {
    int local_structure_id;
    void *local_data;
    LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath;
    LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname;
    LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath;
    LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath;
    LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin;
    LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname;
    LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename;

};


int LDAP_CALL ldapssl_pkcs_init(const struct ldapssl_pkcs_fns *pfns);

/* end of SSL functions */
#endif	/* _SOLARIS_SDK */

/* SASL options */
#define	LDAP_OPT_X_SASL_MECH		0x6100
#define	LDAP_OPT_X_SASL_REALM		0x6101
#define	LDAP_OPT_X_SASL_AUTHCID		0x6102
#define	LDAP_OPT_X_SASL_AUTHZID		0x6103
#define	LDAP_OPT_X_SASL_SSF		0x6104 /* read-only */
#define	LDAP_OPT_X_SASL_SSF_EXTERNAL	0x6105 /* write-only */
#define	LDAP_OPT_X_SASL_SECPROPS	0x6106 /* write-only */
#define	LDAP_OPT_X_SASL_SSF_MIN		0x6107
#define	LDAP_OPT_X_SASL_SSF_MAX		0x6108
#define	LDAP_OPT_X_SASL_MAXBUFSIZE	0x6109

/*
 * ldap_interactive_bind_s Interaction flags
 *  Interactive: prompt always - REQUIRED
 */
#define	LDAP_SASL_INTERACTIVE		1U

/*
 * V3 SASL Interaction Function Callback Prototype
 *      when using SASL, interact is pointer to sasl_interact_t
 *  should likely passed in a control (and provided controls)
 */
typedef int (LDAP_SASL_INTERACT_PROC)
	(LDAP *ld, unsigned flags, void* defaults, void *interact);

int LDAP_CALL ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn,
	const char *saslMechanism, LDAPControl **serverControls,
	LDAPControl **clientControls, unsigned flags,
	LDAP_SASL_INTERACT_PROC *proc, void *defaults);

#ifdef	__cplusplus
}
#endif

#endif	/* _LDAP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2014 PALO, Richard. All rights reserved.
 */

#ifndef _LIBELF_H
#define	_LIBELF_H

#include <sys/types.h>
#include <sys/elf.h>


#ifdef	__cplusplus
extern "C" {
#endif


#if defined(_ILP32) && (_FILE_OFFSET_BITS != 32)
#error "large files are not supported by libelf"
#endif

typedef void	Elf_Void;

/*
 * Commands
 */
typedef enum {
	ELF_C_NULL = 0,	/* must be first, 0 */
	ELF_C_READ,
	ELF_C_WRITE,
	ELF_C_CLR,
	ELF_C_SET,
	ELF_C_FDDONE,
	ELF_C_FDREAD,
	ELF_C_RDWR,
	ELF_C_WRIMAGE,
	ELF_C_IMAGE,
	ELF_C_NUM	/* must be last */
} Elf_Cmd;


/*
 * Flags
 */
#define	ELF_F_DIRTY	0x1
#define	ELF_F_LAYOUT	0x4


/*
 * File types
 */
typedef enum {
	ELF_K_NONE = 0,	/* must be first, 0 */
	ELF_K_AR,
	ELF_K_COFF,
	ELF_K_ELF,
	ELF_K_NUM	/* must be last */
} Elf_Kind;


/*
 * Translation types
 */
typedef enum {
	ELF_T_BYTE = 0,	/* must be first, 0 */
	ELF_T_ADDR,
	ELF_T_DYN,
	ELF_T_EHDR,
	ELF_T_HALF,
	ELF_T_OFF,
	ELF_T_PHDR,
	ELF_T_RELA,
	ELF_T_REL,
	ELF_T_SHDR,
	ELF_T_SWORD,
	ELF_T_SYM,
	ELF_T_WORD,
	ELF_T_VDEF,
	ELF_T_VNEED,
	ELF_T_SXWORD,
	ELF_T_XWORD,
	ELF_T_SYMINFO,
	ELF_T_NOTE,
	ELF_T_MOVE,
	ELF_T_MOVEP,
	ELF_T_CAP,
	ELF_T_NUM	/* must be last */
} Elf_Type;


typedef struct Elf	Elf;
typedef struct Elf_Scn	Elf_Scn;


/*
 * Archive member header
 */
typedef struct {
	char		*ar_name;
	time_t		ar_date;
	uid_t		ar_uid;
	gid_t		ar_gid;
	mode_t		ar_mode;
	off_t		ar_size;
	char		*ar_rawname;
} Elf_Arhdr;


/*
 * Archive symbol table
 */
typedef struct {
	char		*as_name;
	size_t		as_off;
	unsigned long	as_hash;
} Elf_Arsym;


/*
 * Data descriptor
 */
typedef struct {
	Elf_Void	*d_buf;
	Elf_Type	d_type;
	size_t		d_size;
	off_t		d_off;		/* offset into section */
	size_t		d_align;	/* alignment in section */
	unsigned	d_version;	/* elf version */
} Elf_Data;


/*
 * Function declarations
 */
Elf		*elf_begin(int, Elf_Cmd, Elf *);
int		elf_cntl(Elf *, Elf_Cmd);
int		elf_end(Elf *);
const char	*elf_errmsg(int);
int		elf_errno(void);
void		elf_fill(int);
unsigned	elf_flagdata(Elf_Data *, Elf_Cmd, unsigned);
unsigned	elf_flagehdr(Elf *, Elf_Cmd,  unsigned);
unsigned	elf_flagelf(Elf *, Elf_Cmd, unsigned);
unsigned	elf_flagphdr(Elf *, Elf_Cmd, unsigned);
unsigned	elf_flagscn(Elf_Scn *, Elf_Cmd, unsigned);
unsigned	elf_flagshdr(Elf_Scn *, Elf_Cmd, unsigned);
size_t		elf32_fsize(Elf_Type, size_t, unsigned);
Elf_Arhdr	*elf_getarhdr(Elf *);
Elf_Arsym	*elf_getarsym(Elf *, size_t *);
off_t		elf_getbase(Elf *);
Elf_Data	*elf_getdata(Elf_Scn *, Elf_Data *);
Elf32_Ehdr	*elf32_getehdr(Elf *);
char		*elf_getident(Elf *, size_t *);
Elf32_Phdr	*elf32_getphdr(Elf *);
Elf_Scn		*elf_getscn(Elf *elf, size_t);
Elf32_Shdr	*elf32_getshdr(Elf_Scn *);
int		elf_getphnum(Elf *, size_t *);
int		elf_getphdrnum(Elf *, size_t *);
int		elf_getshnum(Elf *, size_t *);
int		elf_getshdrnum(Elf *, size_t *);
int		elf_getshstrndx(Elf *, size_t *);
int		elf_getshdrstrndx(Elf *, size_t *);
unsigned long	elf_hash(const char *);
uint_t		elf_sys_encoding(void);
long		elf32_checksum(Elf *);
Elf_Kind	elf_kind(Elf *);
Elf		*elf_memory(char *, size_t);
size_t		elf_ndxscn(Elf_Scn *);
Elf_Data	*elf_newdata(Elf_Scn *);
Elf32_Ehdr	*elf32_newehdr(Elf *);
Elf32_Phdr	*elf32_newphdr(Elf *, size_t);
Elf_Scn		*elf_newscn(Elf *);
Elf_Scn		*elf_nextscn(Elf *, Elf_Scn *);
Elf_Cmd		elf_next(Elf *);
size_t		elf_rand(Elf *, size_t);
Elf_Data	*elf_rawdata(Elf_Scn *, Elf_Data *);
char		*elf_rawfile(Elf *, size_t *);
char		*elf_strptr(Elf *, size_t, size_t);
off_t		elf_update(Elf *, Elf_Cmd);
unsigned	elf_version(unsigned);
Elf_Data	*elf32_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
Elf_Data	*elf32_xlatetom(Elf_Data *, const Elf_Data *, unsigned);

#if defined(_LP64) || defined(_LONGLONG_TYPE)
size_t		elf64_fsize(Elf_Type, size_t, unsigned);
Elf64_Ehdr	*elf64_getehdr(Elf *);
Elf64_Phdr	*elf64_getphdr(Elf *);
Elf64_Shdr	*elf64_getshdr(Elf_Scn *);
long		elf64_checksum(Elf *);
Elf64_Ehdr	*elf64_newehdr(Elf *);
Elf64_Phdr	*elf64_newphdr(Elf *, size_t);
Elf_Data	*elf64_xlatetof(Elf_Data *, const Elf_Data *, unsigned);
Elf_Data	*elf64_xlatetom(Elf_Data *, const Elf_Data *, unsigned);
#endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBELF_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * declarations of functions found in libgen
 */

#ifndef _LIBGEN_H
#define	_LIBGEN_H

#include <sys/feature_tests.h>

#include <sys/types.h>
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#include <time.h>
#include <stdio.h>
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
extern "C" {
#endif

extern char *basename(char *);
extern char *dirname(char *);

#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern char *regcmp(const char *, ...);
extern char *regex(const char *, const char *, ...);
#endif

#ifdef _REENTRANT
extern char **____loc1(void);
#define	__loc1 (*(____loc1()))
#elif !defined(_XPG6) || defined(__EXTENSIONS__)
extern char *__loc1;	/* Marked LEGACY in XPG5 and removed in XPG6 */
#endif /* _REENTRANT */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)

extern char *bgets(char *, size_t, FILE *, char *);
extern size_t bufsplit(char *, size_t, char **);

#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	copylist	copylist64
#else
#define	copylist		copylist64
#endif
#endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */

#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	copylist64	copylist
#else
#define	copylist64		copylist
#endif
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

extern char *copylist(const char *, off_t *);
#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern char *copylist64(const char *, off64_t *);
#endif	/* _LARGEFILE64_SOURCE... */

extern int eaccess(const char *, int);
extern int gmatch(const char *, const char *);
extern int isencrypt(const char *, size_t);
extern int mkdirp(const char *, mode_t);
extern int p2open(const char *, FILE *[2]);
extern int p2close(FILE *[2]);
extern char *pathfind(const char *, const char *, const char *);

#ifdef _REENTRANT
#define	__i_size (*(___i_size()))
#else
extern int __i_size;
#endif

extern int rmdirp(char *, char *);
extern char *strcadd(char *, const char *);
extern char *strccpy(char *, const char *);
extern char *streadd(char *, const char *, const char *);
extern char *strecpy(char *, const char *, const char *);
extern int strfind(const char *, const char *);
extern char *strrspn(const char *, const char *);
extern char *strtrns(const char *, const char *, const char *, char *);

#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBGEN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */


#ifndef	_LIBINTL_H
#define	_LIBINTL_H

#include <sys/isa_defs.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef int	wchar_t;
#else
typedef long	wchar_t;
#endif
#endif	/* !_WCHAR_T */
#endif	/* !defined(__cplusplus) ... */

#define	TEXTDOMAINMAX	256

#define	__GNU_GETTEXT_SUPPORTED_REVISION(m)	\
	((((m) == 0) || ((m) == 1)) ? 1 : -1)

extern char *dcgettext(const char *, const char *, const int);
extern char *dgettext(const char *, const char *);
extern char *gettext(const char *);
extern char *textdomain(const char *);
extern char *bindtextdomain(const char *, const char *);

/*
 * LI18NUX 2000 Globalization Specification Version 1.0
 * with Amendment 2
 */
extern char *dcngettext(const char *, const char *,
	const char *, unsigned long int, int);
extern char *dngettext(const char *, const char *,
	const char *, unsigned long int);
extern char *ngettext(const char *, const char *, unsigned long int);
extern char *bind_textdomain_codeset(const char *, const char *);

/* Word handling functions --- requires dynamic linking */
/* Warning: these are experimental and subject to change. */
extern int wdinit(void);
extern int wdchkind(wchar_t);
extern int wdbindf(wchar_t, wchar_t, int);
extern wchar_t *wddelim(wchar_t, wchar_t, int);
extern wchar_t mcfiller(void);
extern int mcwrap(void);

#ifdef	__cplusplus
}
#endif

#endif /* _LIBINTL_H */
/*
 * Copyright 2026 Zygaena Project Contributors
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * BSD-compatible utility library.
 * Link with -lutil.
 */

#ifndef _LIBUTIL_H
#define	_LIBUTIL_H

#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>

struct termios;
struct winsize;

#ifdef __cplusplus
extern "C" {
#endif

/* PTY functions (also available via <pty.h>) */
int	openpty(int *, int *, char *, struct termios *, struct winsize *);
pid_t	forkpty(int *, char *, struct termios *, struct winsize *);
int	login_tty(int);

/* Atomic open + flock */
int	flopen(const char *, int, ...);
int	flopenat(int, const char *, int, ...);

/* PID file management */
struct pidfh;

struct pidfh *pidfile_open(const char *, mode_t, pid_t *);
int	pidfile_write(struct pidfh *);
int	pidfile_close(struct pidfh *);
int	pidfile_remove(struct pidfh *);
int	pidfile_fileno(const struct pidfh *);

/* Human-readable number formatting */
#define	HN_DECIMAL		0x01
#define	HN_NOSPACE		0x02
#define	HN_B			0x04
#define	HN_DIVISOR_1000		0x08
#define	HN_IEC_PREFIXES		0x10

#define	HN_GETSCALE		0x10
#define	HN_AUTOSCALE		0x20

int	humanize_number(char *, size_t, int64_t, const char *, int, int);
int	expand_number(const char *, uint64_t *);

/* Config file line parsing */
#define	FPARSELN_UNESCESC	0x01
#define	FPARSELN_UNESCCONT	0x02
#define	FPARSELN_UNESCCOMM	0x04
#define	FPARSELN_UNESCREST	0x08
#define	FPARSELN_UNESCALL	0x0f

char	*fparseln(FILE *, size_t *, size_t *, const char[3], int);

#ifdef __cplusplus
}
#endif

#endif /* _LIBUTIL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _LIBW_H
#define	_LIBW_H

#include <stdlib.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _EUCWIDTH_T
#define	_EUCWIDTH_T
typedef struct {
	short int _eucw1, _eucw2, _eucw3;	/*	EUC width	*/
	short int _scrw1, _scrw2, _scrw3;	/*	screen width	*/
	short int _pcw;		/*	WIDE_CHAR width	*/
	char _multibyte;	/*	1=multi-byte, 0=single-byte	*/
} eucwidth_t;
#endif

void getwidth(eucwidth_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _LIBW_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef _LIBZONECFG_H
#define	_LIBZONECFG_H

/*
 * Zone configuration header file.
 */

#ifdef __cplusplus
extern "C" {
#endif

/* sys/socket.h is required by net/if.h, which has a constant needed here */
#include <sys/param.h>
#include <sys/fstyp.h>
#include <sys/mount.h>
#include <priv.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <net/if.h>
#include <stdio.h>
#include <rctl.h>
#include <zone.h>
#include <libbrand.h>
#include <sys/uuid.h>
#include <libuutil.h>
#include <sys/mnttab.h>
#include <limits.h>
#include <utmpx.h>

#define	ZONE_ID_UNDEFINED	-1

#define	Z_OK			0
#define	Z_EMPTY_DOCUMENT	1	/* XML doc root element is null */
#define	Z_WRONG_DOC_TYPE	2	/* top-level XML doc element != zone */
#define	Z_BAD_PROPERTY		3	/* libxml-level property problem */
#define	Z_TEMP_FILE		4	/* problem creating temporary file */
#define	Z_SAVING_FILE		5	/* libxml error saving or validating */
#define	Z_NO_ENTRY		6	/* no such entry */
#define	Z_BOGUS_ZONE_NAME	7	/* illegal zone name */
#define	Z_REQD_RESOURCE_MISSING	8	/* required resource missing */
#define	Z_REQD_PROPERTY_MISSING	9	/* required property missing */
#define	Z_BAD_HANDLE		10	/* bad document handle */
#define	Z_NOMEM			11	/* out of memory (like ENOMEM) */
#define	Z_INVAL			12	/* invalid argument (like EINVAL) */
#define	Z_ACCES			13	/* permission denied (like EACCES) */
#define	Z_TOO_BIG		14	/* string won't fit in char array */
#define	Z_MISC_FS		15	/* miscellaneous file-system error */
#define	Z_NO_ZONE		16	/* no such zone */
#define	Z_NO_RESOURCE_TYPE	17	/* no/wrong resource type */
#define	Z_NO_RESOURCE_ID	18	/* no/wrong resource id */
#define	Z_NO_PROPERTY_TYPE	19	/* no/wrong property type */
#define	Z_NO_PROPERTY_ID	20	/* no/wrong property id */
#define	Z_BAD_ZONE_STATE	21	/* zone state invalid for given task */
#define	Z_INVALID_DOCUMENT	22	/* libxml can't validate against DTD */
#define	Z_NAME_IN_USE		23	/* zone name already in use (rename) */
#define	Z_NO_SUCH_ID		24	/* delete_index: no old ID */
#define	Z_UPDATING_INDEX	25	/* add/modify/delete_index problem */
#define	Z_LOCKING_FILE		26	/* problem locking index file */
#define	Z_UNLOCKING_FILE	27	/* problem unlocking index file */
#define	Z_SYSTEM		28	/* consult errno instead */
#define	Z_INSUFFICIENT_SPEC	29	/* resource insufficiently specified */
#define	Z_RESOLVED_PATH		34	/* resolved path mismatch */
#define	Z_IPV6_ADDR_PREFIX_LEN	35	/* IPv6 address prefix length needed */
#define	Z_BOGUS_ADDRESS		36	/* not IPv[4|6] address or host name */
#define	Z_PRIV_PROHIBITED	37	/* specified privilege is prohibited */
#define	Z_PRIV_REQUIRED		38	/* required privilege is missing */
#define	Z_PRIV_UNKNOWN		39	/* specified privilege is unknown */
#define	Z_BRAND_ERROR		40	/* brand-specific error */
#define	Z_INCOMPATIBLE		41	/* incompatible settings */
#define	Z_ALIAS_DISALLOW	42	/* rctl alias disallowed */
#define	Z_CLEAR_DISALLOW	43	/* clear property disallowed */
#define	Z_POOL			44	/* generic libpool error */
#define	Z_POOLS_NOT_ACTIVE	45	/* pool service not enabled */
#define	Z_POOL_ENABLE		46	/* pools enable failed */
#define	Z_NO_POOL		47	/* no such pool configured */
#define	Z_POOL_CREATE		48	/* pool create failed */
#define	Z_POOL_BIND		49	/* pool bind failed */
#define	Z_INVALID_PROPERTY	50	/* invalid property value */

/*
 * Warning: these are shared with the admin/install consolidation.
 * Do not insert states between any of the currently defined states,
 * and any new states must be evaluated for impact on range comparisons.
 */
#define	ZONE_STATE_CONFIGURED		0
#define	ZONE_STATE_INCOMPLETE		1
#define	ZONE_STATE_INSTALLED		2
#define	ZONE_STATE_READY		3
#define	ZONE_STATE_RUNNING		4
#define	ZONE_STATE_SHUTTING_DOWN	5
#define	ZONE_STATE_DOWN			6
#define	ZONE_STATE_MOUNTED		7

#define	ZONE_STATE_MAXSTRLEN	14

#define	LIBZONECFG_PATH		"libzonecfg.so.1"

#define	ZONE_CONFIG_ROOT	"/etc/zones"
#define	ZONE_INDEX_FILE		ZONE_CONFIG_ROOT "/index"

#define	MAXUSERNAME		(sizeof (((struct utmpx *)0)->ut_name))
#define	MAXAUTHS		4096
#define	ZONE_MGMT_PROF		"Zone Management"

/* Owner, group, and mode (defined by packaging) for the config directory */
#define	ZONE_CONFIG_UID		0		/* root */
#define	ZONE_CONFIG_GID		3		/* sys */
#define	ZONE_CONFIG_MODE	0755

/* Owner, group, and mode (defined by packaging) for the index file */
#define	ZONE_INDEX_UID		0		/* root */
#define	ZONE_INDEX_GID		3		/* sys */
#define	ZONE_INDEX_MODE		0644

/* The maximum length of the VERSION string in the pkginfo(5) file. */
#define	ZONE_PKG_VERSMAX	256

/*
 * Shortened alias names for the zones rctls.
 */
#define	ALIAS_MAXLWPS		"max-lwps"
#define	ALIAS_MAXSHMMEM		"max-shm-memory"
#define	ALIAS_MAXSHMIDS		"max-shm-ids"
#define	ALIAS_MAXMSGIDS		"max-msg-ids"
#define	ALIAS_MAXSEMIDS		"max-sem-ids"
#define	ALIAS_MAXLOCKEDMEM	"locked"
#define	ALIAS_MAXSWAP		"swap"
#define	ALIAS_SHARES		"cpu-shares"
#define	ALIAS_CPUCAP		"cpu-cap"
#define	ALIAS_MAXPROCS		"max-processes"

/* Default name for zone detached manifest */
#define	ZONE_DETACHED	"SUNWdetached.xml"

/*
 * Bit flag definitions for passing into libzonecfg functions.
 */
#define	ZONE_DRY_RUN		0x01

/*
 * The integer field expresses the current values on a get.
 * On a put, it represents the new values if >= 0 or "don't change" if < 0.
 */
struct zoneent {
	char	zone_name[ZONENAME_MAX];	/* name of the zone */
	int	zone_state;	/* configured | incomplete | installed */
	char	zone_path[MAXPATHLEN];		/* path to zone storage */
	uuid_t	zone_uuid;			/* unique ID for zone */
	char	zone_newname[ZONENAME_MAX];	/* for doing renames */
};

typedef struct zone_dochandle *zone_dochandle_t;	/* opaque handle */

typedef uint_t zone_state_t;

typedef struct zone_fsopt {
	struct zone_fsopt *zone_fsopt_next;
	char		   zone_fsopt_opt[MAX_MNTOPT_STR];
} zone_fsopt_t;

struct zone_fstab {
	char		zone_fs_special[MAXPATHLEN];	/* special file */
	char		zone_fs_dir[MAXPATHLEN];	/* mount point */
	char		zone_fs_type[FSTYPSZ];		/* e.g. ufs */
	zone_fsopt_t   *zone_fs_options;		/* mount options */
	char		zone_fs_raw[MAXPATHLEN];	/* device to fsck */
};

struct zone_nwiftab {
	char	zone_nwif_address[INET6_ADDRSTRLEN]; /* shared-ip only */
	char	zone_nwif_allowed_address[INET6_ADDRSTRLEN]; /* excl-ip only */
	char	zone_nwif_physical[LIFNAMSIZ];
	char	zone_nwif_defrouter[INET6_ADDRSTRLEN];
};

struct zone_devtab {
	char	zone_dev_match[MAXPATHLEN];
};

struct zone_rctlvaltab {
	char	zone_rctlval_priv[MAXNAMELEN];
	char	zone_rctlval_limit[MAXNAMELEN];
	char	zone_rctlval_action[MAXNAMELEN];
	struct zone_rctlvaltab *zone_rctlval_next;
};

struct zone_rctltab {
	char	zone_rctl_name[MAXNAMELEN];
	struct zone_rctlvaltab *zone_rctl_valptr;
};

struct zone_attrtab {
	char	zone_attr_name[MAXNAMELEN];
	char	zone_attr_type[MAXNAMELEN];
	char	zone_attr_value[2 * BUFSIZ];
};

struct zone_dstab {
	char	zone_dataset_name[MAXNAMELEN];
};

struct zone_psettab {
	char	zone_ncpu_min[MAXNAMELEN];
	char	zone_ncpu_max[MAXNAMELEN];
	char	zone_importance[MAXNAMELEN];
};

struct zone_mcaptab {
	char	zone_physmem_cap[MAXNAMELEN];
};

struct zone_pkgtab {
	char	zone_pkg_name[MAXNAMELEN];
	char	zone_pkg_version[ZONE_PKG_VERSMAX];
};

struct zone_devpermtab {
	char	zone_devperm_name[MAXPATHLEN];
	uid_t	zone_devperm_uid;
	gid_t	zone_devperm_gid;
	mode_t	zone_devperm_mode;
	char	*zone_devperm_acl;
};

struct zone_admintab {
	char	zone_admin_user[MAXUSERNAME];
	char	zone_admin_auths[MAXAUTHS];
};

#define	ZONECFG_SECFLAGS_MAX	1024
struct zone_secflagstab {
	char zone_secflags_lower[ZONECFG_SECFLAGS_MAX];
	char zone_secflags_upper[ZONECFG_SECFLAGS_MAX];
	char zone_secflags_default[ZONECFG_SECFLAGS_MAX];
};

typedef struct zone_userauths {
	char			user[MAXUSERNAME];
	char			zonename[ZONENAME_MAX];
	struct zone_userauths	*next;
} zone_userauths_t;

typedef struct {
	uu_avl_node_t	zpe_entry;
	char		*zpe_name;
	char		*zpe_vers;
} zone_pkg_entry_t;

typedef enum zone_iptype {
	ZS_SHARED,
	ZS_EXCLUSIVE
} zone_iptype_t;

/*
 * Basic configuration management routines.
 */
extern	zone_dochandle_t	zonecfg_init_handle(void);
extern	int	zonecfg_get_handle(const char *, zone_dochandle_t);
extern	int	zonecfg_get_snapshot_handle(const char *, zone_dochandle_t);
extern	int	zonecfg_get_template_handle(const char *, const char *,
    zone_dochandle_t);
extern	int	zonecfg_get_xml_handle(const char *, zone_dochandle_t);
extern	int	zonecfg_check_handle(zone_dochandle_t);
extern	void	zonecfg_fini_handle(zone_dochandle_t);
extern	int	zonecfg_destroy(const char *, boolean_t);
extern	int	zonecfg_destroy_snapshot(const char *);
extern	int	zonecfg_save(zone_dochandle_t);
extern	int	zonecfg_create_snapshot(const char *);
extern	char	*zonecfg_strerror(int);
extern	int	zonecfg_access(const char *, int);
extern	void	zonecfg_set_root(const char *);
extern	const char *zonecfg_get_root(void);
extern	boolean_t zonecfg_in_alt_root(void);
extern	int	zonecfg_num_resources(zone_dochandle_t, char *);
extern	int	zonecfg_del_all_resources(zone_dochandle_t, char *);
extern	boolean_t zonecfg_valid_ncpus(char *, char *);
extern	boolean_t zonecfg_valid_importance(char *);
extern	int	zonecfg_str_to_bytes(char *, uint64_t *);
extern	boolean_t zonecfg_valid_memlimit(char *, uint64_t *);
extern	boolean_t zonecfg_valid_alias_limit(char *, char *, uint64_t *);

/*
 * Zone name, path to zone directory, autoboot setting, pool, boot
 * arguments, and scheduling-class.
 */
extern	int	zonecfg_validate_zonename(const char *);
extern	int	zonecfg_get_name(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_name(zone_dochandle_t, char *);
extern	int	zonecfg_get_zonepath(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_zonepath(zone_dochandle_t, char *);
extern	int	zonecfg_get_autoboot(zone_dochandle_t, boolean_t *);
extern	int	zonecfg_set_autoboot(zone_dochandle_t, boolean_t);
extern	int	zonecfg_get_iptype(zone_dochandle_t, zone_iptype_t *);
extern	int	zonecfg_set_iptype(zone_dochandle_t, zone_iptype_t);
extern	int	zonecfg_get_pool(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_pool(zone_dochandle_t, char *);
extern	int	zonecfg_get_bootargs(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_bootargs(zone_dochandle_t, char *);
extern	int	zonecfg_get_sched_class(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_sched(zone_dochandle_t, char *);
extern	int	zonecfg_get_dflt_sched_class(zone_dochandle_t, char *, int);

/*
 * Set/retrieve the brand for the zone
 */
extern	int	zonecfg_get_brand(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_brand(zone_dochandle_t, char *);

/*
 * Filesystem configuration.
 */
extern	int	zonecfg_add_filesystem(zone_dochandle_t, struct zone_fstab *);
extern	int	zonecfg_delete_filesystem(zone_dochandle_t,
    struct zone_fstab *);
extern	int	zonecfg_modify_filesystem(zone_dochandle_t,
    struct zone_fstab *, struct zone_fstab *);
extern	int	zonecfg_lookup_filesystem(zone_dochandle_t,
    struct zone_fstab *);
extern	int	zonecfg_add_fs_option(struct zone_fstab *, char *);
extern	int	zonecfg_remove_fs_option(struct zone_fstab *, char *);
extern	void	zonecfg_free_fs_option_list(zone_fsopt_t *);
extern	int	zonecfg_find_mounts(char *, int(*)(const struct mnttab *,
    void *), void *);

/*
 * Network interface configuration.
 */
extern	int	zonecfg_add_nwif(zone_dochandle_t, struct zone_nwiftab *);
extern	int	zonecfg_delete_nwif(zone_dochandle_t, struct zone_nwiftab *);
extern	int	zonecfg_modify_nwif(zone_dochandle_t, struct zone_nwiftab *,
    struct zone_nwiftab *);
extern	int	zonecfg_lookup_nwif(zone_dochandle_t, struct zone_nwiftab *);

/*
 * Hostid emulation configuration.
 */
extern	int	zonecfg_get_hostid(zone_dochandle_t, char *, size_t);
extern	int	zonecfg_set_hostid(zone_dochandle_t, const char *);

/*
 * Allowed FS mounts configuration.
 */
extern int	zonecfg_get_fs_allowed(zone_dochandle_t, char *, size_t);
extern int	zonecfg_set_fs_allowed(zone_dochandle_t, const char *);

/*
 * Device configuration and rule matching.
 */
extern	int	zonecfg_add_dev(zone_dochandle_t, struct zone_devtab *);
extern	int	zonecfg_delete_dev(zone_dochandle_t, struct zone_devtab *);
extern	int	zonecfg_modify_dev(zone_dochandle_t, struct zone_devtab *,
    struct zone_devtab *);
extern	int	zonecfg_lookup_dev(zone_dochandle_t, struct zone_devtab *);

/*
 * Resource control configuration.
 */
extern	int	zonecfg_add_rctl(zone_dochandle_t, struct zone_rctltab *);
extern	int	zonecfg_delete_rctl(zone_dochandle_t, struct zone_rctltab *);
extern	int	zonecfg_modify_rctl(zone_dochandle_t, struct zone_rctltab *,
    struct zone_rctltab *);
extern	int	zonecfg_lookup_rctl(zone_dochandle_t, struct zone_rctltab *);
extern	int	zonecfg_add_rctl_value(struct zone_rctltab *,
    struct zone_rctlvaltab *);
extern	int	zonecfg_remove_rctl_value(struct zone_rctltab *,
    struct zone_rctlvaltab *);
extern	void	zonecfg_free_rctl_value_list(struct zone_rctlvaltab *);
extern	boolean_t zonecfg_aliased_rctl_ok(zone_dochandle_t, char *);
extern	int	zonecfg_set_aliased_rctl(zone_dochandle_t, char *, uint64_t);
extern	int	zonecfg_get_aliased_rctl(zone_dochandle_t, char *, uint64_t *);
extern	int	zonecfg_rm_aliased_rctl(zone_dochandle_t, char *);
extern	int	zonecfg_apply_rctls(char *, zone_dochandle_t);

/*
 * Generic attribute configuration and type/value extraction.
 */
extern	int	zonecfg_add_attr(zone_dochandle_t, struct zone_attrtab *);
extern	int	zonecfg_delete_attr(zone_dochandle_t, struct zone_attrtab *);
extern	int	zonecfg_modify_attr(zone_dochandle_t, struct zone_attrtab *,
    struct zone_attrtab *);
extern	int	zonecfg_lookup_attr(zone_dochandle_t, struct zone_attrtab *);
extern	int	zonecfg_get_attr_boolean(const struct zone_attrtab *,
    boolean_t *);
extern	int	zonecfg_get_attr_int(const struct zone_attrtab *, int64_t *);
extern	int	zonecfg_get_attr_string(const struct zone_attrtab *, char *,
    size_t);
extern	int	zonecfg_get_attr_uint(const struct zone_attrtab *, uint64_t *);

/*
 * ZFS configuration.
 */
extern	int	zonecfg_add_ds(zone_dochandle_t, struct zone_dstab *);
extern	int	zonecfg_delete_ds(zone_dochandle_t, struct zone_dstab *);
extern	int	zonecfg_modify_ds(zone_dochandle_t, struct zone_dstab *,
    struct zone_dstab *);
extern	int	zonecfg_lookup_ds(zone_dochandle_t, struct zone_dstab *);

/*
 * cpu-set configuration.
 */
extern	int	zonecfg_add_pset(zone_dochandle_t, struct zone_psettab *);
extern	int	zonecfg_delete_pset(zone_dochandle_t);
extern	int	zonecfg_modify_pset(zone_dochandle_t, struct zone_psettab *);
extern	int	zonecfg_lookup_pset(zone_dochandle_t, struct zone_psettab *);

/*
 * mem-cap configuration.
 */
extern	int	zonecfg_delete_mcap(zone_dochandle_t);
extern	int	zonecfg_modify_mcap(zone_dochandle_t, struct zone_mcaptab *);
extern	int	zonecfg_lookup_mcap(zone_dochandle_t, struct zone_mcaptab *);

/* security-flags configuration */
extern	int	zonecfg_add_secflags(zone_dochandle_t,
    struct zone_secflagstab *);
extern	int	zonecfg_delete_secflags(zone_dochandle_t,
    struct zone_secflagstab *);
extern	int	zonecfg_modify_secflags(zone_dochandle_t,
    struct zone_secflagstab *, struct zone_secflagstab *);
extern	int	zonecfg_lookup_secflags(zone_dochandle_t,
    struct zone_secflagstab *);

/*
 * Temporary pool support functions.
 */
extern	int	zonecfg_destroy_tmp_pool(char *, char *, int);
extern	int	zonecfg_bind_tmp_pool(zone_dochandle_t, zoneid_t, char *, int);
extern	int	zonecfg_bind_pool(zone_dochandle_t, zoneid_t, char *, int);
extern	boolean_t zonecfg_warn_poold(zone_dochandle_t);
extern	int	zonecfg_get_poolname(zone_dochandle_t, char *, char *, size_t);

/*
 * Miscellaneous utility functions.
 */
extern	int	zonecfg_enable_rcapd(char *, int);

/*
 * attach/detach support.
 */
extern	int	zonecfg_get_attach_handle(const char *, const char *,
    const char *, boolean_t, zone_dochandle_t);
extern	int	zonecfg_attach_manifest(int, zone_dochandle_t,
    zone_dochandle_t);
extern	int	zonecfg_detach_save(zone_dochandle_t, uint_t);
extern	boolean_t zonecfg_detached(const char *);
extern	void	zonecfg_rm_detached(zone_dochandle_t, boolean_t forced);
extern	int	zonecfg_dev_manifest(zone_dochandle_t);
extern	int	zonecfg_devperms_apply(zone_dochandle_t, const char *,
    uid_t, gid_t, mode_t, const char *);
extern	void	zonecfg_set_swinv(zone_dochandle_t);
extern	int	zonecfg_add_pkg(zone_dochandle_t, char *, char *);

/*
 * External zone verification support.
 */
extern	int	zonecfg_verify_save(zone_dochandle_t, char *);

/*
 * '*ent' iterator routines.
 */
extern	int	zonecfg_setfsent(zone_dochandle_t);
extern	int	zonecfg_getfsent(zone_dochandle_t, struct zone_fstab *);
extern	int	zonecfg_endfsent(zone_dochandle_t);
extern	int	zonecfg_setnwifent(zone_dochandle_t);
extern	int	zonecfg_getnwifent(zone_dochandle_t, struct zone_nwiftab *);
extern	int	zonecfg_endnwifent(zone_dochandle_t);
extern	int	zonecfg_setdevent(zone_dochandle_t);
extern	int	zonecfg_getdevent(zone_dochandle_t, struct zone_devtab *);
extern	int	zonecfg_enddevent(zone_dochandle_t);
extern	int	zonecfg_setattrent(zone_dochandle_t);
extern	int	zonecfg_getattrent(zone_dochandle_t, struct zone_attrtab *);
extern	int	zonecfg_endattrent(zone_dochandle_t);
extern	int	zonecfg_setrctlent(zone_dochandle_t);
extern	int	zonecfg_getrctlent(zone_dochandle_t, struct zone_rctltab *);
extern	int	zonecfg_endrctlent(zone_dochandle_t);
extern	int	zonecfg_setdsent(zone_dochandle_t);
extern	int	zonecfg_getdsent(zone_dochandle_t, struct zone_dstab *);
extern	int	zonecfg_enddsent(zone_dochandle_t);
extern	int	zonecfg_getpsetent(zone_dochandle_t, struct zone_psettab *);
extern	int	zonecfg_getmcapent(zone_dochandle_t, struct zone_mcaptab *);
extern	int	zonecfg_getpkgdata(zone_dochandle_t, uu_avl_pool_t *,
    uu_avl_t *);
extern	int	zonecfg_setdevperment(zone_dochandle_t);
extern	int	zonecfg_getdevperment(zone_dochandle_t,
    struct zone_devpermtab *);
extern	int	zonecfg_enddevperment(zone_dochandle_t);
extern	int	zonecfg_setadminent(zone_dochandle_t);
extern	int	zonecfg_getadminent(zone_dochandle_t, struct zone_admintab *);
extern	int	zonecfg_endadminent(zone_dochandle_t);
extern	int	zonecfg_getsecflagsent(zone_dochandle_t,
    struct zone_secflagstab *);

/*
 * Privilege-related functions.
 */
extern	int	zonecfg_default_privset(priv_set_t *, const char *);
extern	int	zonecfg_get_privset(zone_dochandle_t, priv_set_t *,
    char **);
extern	int	zonecfg_get_limitpriv(zone_dochandle_t, char **);
extern	int	zonecfg_set_limitpriv(zone_dochandle_t, char *);

/*
 * Higher-level routines.
 */
extern  int	zone_get_brand(char *, char *, size_t);
extern	int	zone_get_rootpath(char *, char *, size_t);
extern	int	zone_get_devroot(char *, char *, size_t);
extern	int	zone_get_zonepath(char *, char *, size_t);
extern	int	zone_get_state(char *, zone_state_t *);
extern	int	zone_set_state(char *, zone_state_t);
extern	char	*zone_state_str(zone_state_t);
extern	int	zonecfg_get_name_by_uuid(const uuid_t, char *, size_t);
extern	int	zonecfg_get_uuid(const char *, uuid_t);
extern	int	zonecfg_default_brand(char *, size_t);

/*
 * Iterator for configured zones.
 */
extern FILE		*setzoneent(void);
extern char		*getzoneent(FILE *);
extern struct zoneent	*getzoneent_private(FILE *);
extern void		endzoneent(FILE *);

/*
 * File-system-related convenience functions.
 */
extern boolean_t zonecfg_valid_fs_type(const char *);

/*
 * Network-related convenience functions.
 */
extern boolean_t zonecfg_same_net_address(char *, char *);
extern int zonecfg_valid_net_address(char *, struct lifreq *);
extern boolean_t zonecfg_ifname_exists(sa_family_t, char *);

/*
 * Rctl-related common functions.
 */
extern boolean_t zonecfg_is_rctl(const char *);
extern boolean_t zonecfg_valid_rctlname(const char *);
extern boolean_t zonecfg_valid_rctlblk(const rctlblk_t *);
extern boolean_t zonecfg_valid_rctl(const char *, const rctlblk_t *);
extern int zonecfg_construct_rctlblk(const struct zone_rctlvaltab *,
    rctlblk_t *);

/*
 * Live Upgrade support functions.  Shared between ON and install gate.
 */
extern FILE *zonecfg_open_scratch(const char *, boolean_t);
extern int zonecfg_lock_scratch(FILE *);
extern void zonecfg_close_scratch(FILE *);
extern int zonecfg_get_scratch(FILE *, char *, size_t, char *, size_t, char *,
    size_t);
extern int zonecfg_find_scratch(FILE *, const char *, const char *, char *,
    size_t);
extern int zonecfg_reverse_scratch(FILE *, const char *, char *, size_t,
    char *, size_t);
extern int zonecfg_add_scratch(FILE *, const char *, const char *,
    const char *);
extern int zonecfg_delete_scratch(FILE *, const char *);
extern boolean_t zonecfg_is_scratch(const char *);

/*
 * zoneadmd support functions.  Shared between zoneadm and brand hook code.
 */
extern void zonecfg_init_lock_file(const char *, char **);
extern void zonecfg_release_lock_file(const char *, int);
extern int zonecfg_grab_lock_file(const char *, int *);
extern boolean_t zonecfg_lock_file_held(int *);
extern int zonecfg_ping_zoneadmd(const char *);
extern int zonecfg_call_zoneadmd(const char *, zone_cmd_arg_t *, char *,
    boolean_t);
extern int zonecfg_insert_userauths(zone_dochandle_t, char *, char *);
extern int zonecfg_remove_userauths(zone_dochandle_t, char *, char *,
    boolean_t);
extern int zonecfg_add_admin(zone_dochandle_t, struct zone_admintab *,
    char *);
extern int zonecfg_delete_admin(zone_dochandle_t,
    struct zone_admintab *, char *);
extern int zonecfg_modify_admin(zone_dochandle_t, struct zone_admintab *,
    struct zone_admintab *, char *);
extern int zonecfg_delete_admins(zone_dochandle_t, char *);
extern int zonecfg_lookup_admin(zone_dochandle_t, struct zone_admintab *);
extern int zonecfg_authorize_users(zone_dochandle_t, char *);
extern int zonecfg_update_userauths(zone_dochandle_t, char *);
extern int zonecfg_deauthorize_user(zone_dochandle_t, char *, char *);
extern int zonecfg_deauthorize_users(zone_dochandle_t, char *);
extern boolean_t zonecfg_valid_auths(const char *, const char *);

#ifdef __cplusplus
}
#endif

#endif	/* _LIBZONECFG_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright (c) 2013 Gary Mills
 * Copyright 2017 RackTop Systems.
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2015 Joyent, Inc.  All rights reserved.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _LIMITS_H
#define	_LIMITS_H

#include <sys/feature_tests.h>
#include <sys/isa_defs.h>
#include <iso/limits_iso.h>
#include <sys/limits.h>

/*
 * Include fixed width type limits as proposed by the ISO/JTC1/SC22/WG14 C
 * committee's working draft for the revision of the current ISO C standard,
 * ISO/IEC 9899:1990 Programming language - C.  These are not currently
 * required by any standard but constitute a useful, general purpose set
 * of type definitions and limits which is namespace clean with respect to
 * all standards.
 */
#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(__XOPEN_OR_POSIX)
#include <sys/int_limits.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(__XOPEN_OR_POSIX)

#define	SSIZE_MAX	LONG_MAX	/* max value of an "ssize_t" */

/*
 * ARG_MAX is calculated as follows:
 * NCARGS - space for other stuff on initial stack
 * like aux vectors, saved registers, etc..
 */
#define	_ARG_MAX32	1048320	/* max length of args to exec 32-bit program */
#define	_ARG_MAX64	2096640	/* max length of args to exec 64-bit program */
#ifdef	_LP64
#define	ARG_MAX		_ARG_MAX64	/* max length of arguments to exec */
#else	/* _LP64 */
#define	ARG_MAX		_ARG_MAX32	/* max length of arguments to exec */
#endif	/* _LP64 */


/*
 * These two symbols have their historical values, the actual buffer is
 * larger.
 */
#ifndef MAX_CANON
#define	MAX_CANON	256	/* max bytes in line for canonical processing */
#endif

#ifndef MAX_INPUT
#define	MAX_INPUT	512	/* max size of a char input buffer */
#endif

#define	NGROUPS_MAX	16	/* max number of groups for a user */

#ifndef PATH_MAX
#define	PATH_MAX	1024	/* max # of characters in a path name */
#endif

#define	SYMLINK_MAX	1024	/* max # of characters a symlink can contain */

#define	PIPE_BUF	5120	/* max # bytes atomic in write to a pipe */

#ifndef TMP_MAX
#define	TMP_MAX		17576	/* 26 * 26 * 26 */
#endif

/*
 * POSIX conformant definitions - An implementation may define
 * other symbols which reflect the actual implementation. Alternate
 * definitions may not be as restrictive as the POSIX definitions.
 */
#define	_POSIX_AIO_LISTIO_MAX	    2
#define	_POSIX_AIO_MAX		    1
#define	_POSIX_ARG_MAX		 4096
#ifdef _XPG6
#define	_POSIX_CHILD_MAX	   25
#else
#define	_POSIX_CHILD_MAX	    6	/* POSIX.1-1990 default */
#endif
#define	_POSIX_CLOCKRES_MIN	20000000
#define	_POSIX_DELAYTIMER_MAX	   32
#define	_POSIX_LINK_MAX		    8
#define	_POSIX_MAX_CANON	  255
#define	_POSIX_MAX_INPUT	  255
#define	_POSIX_MQ_OPEN_MAX	    8
#define	_POSIX_MQ_PRIO_MAX	   32
#define	_POSIX_NAME_MAX		   14
#ifdef _XPG6
#define	_POSIX_NGROUPS_MAX	    8
#define	_POSIX_OPEN_MAX		   20
#define	_POSIX_PATH_MAX		  256
#else					/* POSIX.1-1990 defaults */
#define	_POSIX_NGROUPS_MAX	    0
#define	_POSIX_OPEN_MAX		   16
#define	_POSIX_PATH_MAX		  255
#endif
#define	_POSIX_PIPE_BUF		  512
#define	_POSIX_RTSIG_MAX	    8
#define	_POSIX_SEM_NSEMS_MAX	  256
#define	_POSIX_SEM_VALUE_MAX	32767
#define	_POSIX_SIGQUEUE_MAX	   32
#define	_POSIX_SSIZE_MAX	32767
#define	_POSIX_STREAM_MAX	    8
#define	_POSIX_TIMER_MAX	   32
#ifdef _XPG6
#define	_POSIX_TZNAME_MAX	    6
#else
#define	_POSIX_TZNAME_MAX	    3	/* POSIX.1-1990 default */
#endif
/* POSIX.1c conformant */
#define	_POSIX_LOGIN_NAME_MAX			9
#define	_POSIX_THREAD_DESTRUCTOR_ITERATIONS	4
#define	_POSIX_THREAD_KEYS_MAX			128
#define	_POSIX_THREAD_THREADS_MAX		64
#define	_POSIX_TTY_NAME_MAX			9
/* UNIX 03 conformant */
#define	_POSIX_HOST_NAME_MAX			255
#define	_POSIX_RE_DUP_MAX			255
#define	_POSIX_SYMLINK_MAX			255
#define	_POSIX_SYMLOOP_MAX			8

/*
 * POSIX.2 and XPG4-XSH4 conformant definitions
 */

#define	_POSIX2_BC_BASE_MAX		  99
#define	_POSIX2_BC_DIM_MAX		2048
#define	_POSIX2_BC_SCALE_MAX		  99
#define	_POSIX2_BC_STRING_MAX		1000
#define	_POSIX2_COLL_WEIGHTS_MAX	   2
#define	_POSIX2_EXPR_NEST_MAX		  32
#define	_POSIX2_LINE_MAX		2048
#define	_POSIX2_RE_DUP_MAX		 255
/* UNIX 03 conformant */
#define	_POSIX2_CHARCLASS_NAME_MAX	  14

#define	BC_BASE_MAX		_POSIX2_BC_BASE_MAX
#define	BC_DIM_MAX		_POSIX2_BC_DIM_MAX
#define	BC_SCALE_MAX		_POSIX2_BC_SCALE_MAX
#define	BC_STRING_MAX		_POSIX2_BC_STRING_MAX
#define	COLL_WEIGHTS_MAX	10
#define	EXPR_NEST_MAX		_POSIX2_EXPR_NEST_MAX
#define	LINE_MAX		_POSIX2_LINE_MAX
#if !defined(_XPG6)
#define	RE_DUP_MAX		_POSIX2_RE_DUP_MAX
#else
#define	RE_DUP_MAX		_POSIX_RE_DUP_MAX
#endif /* !defined(_XPG6) */

#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XOPEN_SOURCE)

/*
 * For dual definitions for PASS_MAX and sysconf.c
 */
#define	_PASS_MAX_XPG	8	/* old standards PASS_MAX */
#define	_PASS_MAX	256	/* modern Solaris PASS_MAX */

#if defined(_XPG3) && !defined(_XPG6)
#define	PASS_MAX	_PASS_MAX_XPG	/* max # of characters in a password */
#else	/* XPG6 or just Solaris */
#define	PASS_MAX	_PASS_MAX	/* max # of characters in a password */
#endif	/* defined(_XPG3) && !defined(_XPG6) */

#define	CHARCLASS_NAME_MAX	_POSIX2_CHARCLASS_NAME_MAX

#define	NL_ARGMAX	9	/* max value of "digit" in calls to the	*/
				/* NLS printf() and scanf() */
#define	NL_LANGMAX	14	/* max # of bytes in a LANG name */
#define	NL_MSGMAX	32767	/* max message number */
#define	NL_NMAX		1	/* max # bytes in N-to-1 mapping characters */
#define	NL_SETMAX	255	/* max set number */
#define	NL_TEXTMAX	2048	/* max set number */
#define	NZERO		20	/* default process priority */

#define	WORD_BIT	32	/* # of bits in a "word" or "int" */
#if defined(_LP64)
#define	LONG_BIT	64	/* # of bits in a "long" */
#else	/* _ILP32 */
#define	LONG_BIT	32	/* # of bits in a "long" */
#endif

/* Marked as LEGACY in SUSv2 and removed in UNIX 03 */
#ifndef _XPG6
#define	DBL_DIG		15	/* digits of precision of a "double" */
#define	DBL_MAX		1.7976931348623157081452E+308	/* max decimal value */
							/* of a double */
#define	FLT_DIG		6		/* digits of precision of a "float" */
#define	FLT_MAX		3.4028234663852885981170E+38F	/* max decimal value */
							/* of a "float" */
#endif

/* Marked as LEGACY in SUSv1 and removed in SUSv2 */
#ifndef _XPG5
#define	DBL_MIN		2.2250738585072013830903E-308	/* min decimal value */
							/* of a double */
#define	FLT_MIN		1.1754943508222875079688E-38F	/* min decimal value */
							/* of a float */
#endif

#endif	/* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */

#define	_XOPEN_IOV_MAX	16	/* max # iovec/process with readv()/writev() */
#define	_XOPEN_NAME_MAX	255	/* max # bytes in filename excluding null */
#define	_XOPEN_PATH_MAX	1024	/* max # bytes in a pathname */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))

#define	FCHR_MAX	1048576		/* max size of a file in bytes */
#define	PID_MAX		999999		/* max value for a process ID */

/*
 * POSIX 1003.1a, section 2.9.5, table 2-5 contains [NAME_MAX] and the
 * related text states:
 *
 * A definition of one of the values from Table 2-5 shall be omitted from the
 * <limits.h> on specific implementations where the corresponding value is
 * equal to or greater than the stated minimum, but where the value can vary
 * depending on the file to which it is applied. The actual value supported for
 * a specific pathname shall be provided by the pathconf() (5.7.1) function.
 *
 * This is clear that any machine supporting multiple file system types
 * and/or a network should not include this define, regardless of protection
 * by the _POSIX_SOURCE and _POSIX_C_SOURCE flags. We chose to ignore that
 * and provide it anyway for compatibility with other platforms that don't
 * follow the spec as precisely as they should. Its usage is discouraged.
 */
#define	NAME_MAX	255

#define	CHILD_MAX	25	/* max # of processes per user id */
#ifndef OPEN_MAX
#define	OPEN_MAX	256	/* max # of files a process can have open */
#endif

#define	PIPE_MAX	5120	/* max # bytes written to a pipe in a write */

#define	STD_BLK		1024	/* # bytes in a physical I/O block */
#define	UID_MAX		2147483647	/* max value for a user or group ID */
#define	USI_MAX		4294967295	/* max decimal value of an "unsigned" */
#define	SYSPID_MAX	1	/* max pid of system processes */

#ifndef SYS_NMLN		/* also defined in sys/utsname.h */
#define	SYS_NMLN	257	/* 4.0 size of utsname elements */
#endif

#ifndef CLK_TCK

#if !defined(_CLOCK_T) || __cplusplus >= 199711L
#define	_CLOCK_T
typedef long	clock_t;
#endif	/* !_CLOCK_T */

extern long _sysconf(int);	/* System Private interface to sysconf() */
#define	CLK_TCK	((clock_t)_sysconf(3))	/* 3 is _SC_CLK_TCK */

#endif /* CLK_TCK */

#ifdef	__USE_LEGACY_LOGNAME__
#define	LOGNAME_MAX	8	/* max # of characters in a login name */
#else	/* __USE_LEGACY_LOGNAME__ */
#define	LOGNAME_MAX	32	/* max # of characters in a login name */
				/* Increased for illumos */
#endif	/* __USE_LEGACY_LOGNAME__ */
#define	LOGIN_NAME_MAX	(LOGNAME_MAX + 1)	/* max buffer size */
#define	LOGNAME_MAX_TRAD	8		/* traditional length */
#define	LOGIN_NAME_MAX_TRAD	(LOGNAME_MAX_TRAD + 1)	/* and size */

#define	TTYNAME_MAX	128	/* max # of characters in a tty name */

#endif	/* if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */

#if	defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L)
#include <sys/unistd.h>

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef	unsigned long size_t;	/* size of something in bytes */
#else
typedef	unsigned int  size_t;	/* (historical version) */
#endif
#endif	/* _SIZE_T */

extern long _sysconf(int);	/* System Private interface to sysconf() */

#define	PTHREAD_STACK_MIN	((size_t)_sysconf(_SC_THREAD_STACK_MIN))
/* Added for UNIX98 conformance */
#define	PTHREAD_DESTRUCTOR_ITERATIONS	_POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define	PTHREAD_KEYS_MAX		_POSIX_THREAD_KEYS_MAX
#define	PTHREAD_THREADS_MAX		_POSIX_THREAD_THREADS_MAX
#endif	/* defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L) */

#ifdef	__cplusplus
}
#endif

#endif	/* _LIMITS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef _LINK_H
#define	_LINK_H

#include <sys/link.h>

#ifndef _ASM
#include <elf.h>
#include <sys/types.h>
#include <dlfcn.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _ASM
/*
 * ld support library calls.
 *
 * These cannot be used in a 32bit large file capable environment because
 * libelf is not large-file safe.  Only define these interfaces if we are not
 * 32bit, or not in the large file environment.
 */
#if !defined(_ILP32) || _FILE_OFFSET_BITS != 64
#include <libelf.h>
extern uint_t	ld_version(uint_t);
extern void	ld_input_done(uint_t *);

extern void	ld_start(const char *, const Elf32_Half, const char *);
extern void	ld_atexit(int);
extern void	ld_open(const char **, const char **, int *, int, Elf **,
			Elf *, size_t, const Elf_Kind);
extern void	ld_file(const char *, const Elf_Kind, int, Elf *);
extern void	ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
			Elf_Data *, Elf *, uint_t *);
extern void	ld_section(const char *, Elf32_Shdr *, Elf32_Word,
			Elf_Data *, Elf *);

#if defined(_LP64) || defined(_LONGLONG_TYPE)
extern void	ld_start64(const char *, const Elf64_Half, const char *);
extern void	ld_atexit64(int);
extern void	ld_open64(const char **, const char **, int *, int, Elf **,
			Elf *, size_t, const Elf_Kind);
extern void	ld_file64(const char *, const Elf_Kind, int, Elf *);
extern void	ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
			Elf_Data *, Elf *, uint_t *);
extern void	ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
			Elf_Data *, Elf *);

#endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
#endif /* !defined(_ILP32) || _FILE_OFFSET_BITS != 64 */

/*
 * ld_version() version values.
 */
#define	LD_SUP_VNONE	0
#define	LD_SUP_VERSION1	1
#define	LD_SUP_VERSION2	2
#define	LD_SUP_VERSION3	3
#define	LD_SUP_VCURRENT	LD_SUP_VERSION3

/*
 * Flags passed to ld support calls.
 */
#define	LD_SUP_DERIVED		0x1	/* derived filename */
#define	LD_SUP_INHERITED	0x2	/* file inherited from .so DT_NEEDED */
#define	LD_SUP_EXTRACTED	0x4	/* file extracted from archive */
#endif

/*
 * Runtime link-map identifiers.
 */
#define	LM_ID_BASE		0x00
#define	LM_ID_LDSO		0x01
#define	LM_ID_NUM		2

#define	LM_ID_BRAND		0xfd	/* brand emulation linkmap objs */
#define	LM_ID_NONE		0xfe	/* no link map specified */
#define	LM_ID_NEWLM		0xff	/* create a new link-map */

/*
 * Runtime Link-Edit Auditing.
 */
#define	LAV_NONE		0
#define	LAV_VERSION1		1
#define	LAV_VERSION2		2
#define	LAV_VERSION3		3
#define	LAV_VERSION4		4
#define	LAV_VERSION5		5
#define	LAV_CURRENT		LAV_VERSION5
#define	LAV_NUM			6

/*
 * Flags that can be or'd into the la_objopen() return code
 */
#define	LA_FLG_BINDTO		0x0001	/* audit symbinds TO this object */
#define	LA_FLG_BINDFROM		0x0002	/* audit symbinding FROM this object */

/*
 * Flags that can be or'd into the 'flags' argument of la_symbind()
 */
#define	LA_SYMB_NOPLTENTER	0x0001	/* disable pltenter for this symbol */
#define	LA_SYMB_NOPLTEXIT	0x0002	/* disable pltexit for this symbol */
#define	LA_SYMB_STRUCTCALL	0x0004	/* this function call passes a */
					/*	structure as it's return code */
#define	LA_SYMB_DLSYM		0x0008	/* this symbol bindings is due to */
					/*	a call to dlsym() */
#define	LA_SYMB_ALTVALUE	0x0010	/* alternate symbol binding returned */
					/*	by la_symbind() */

/*
 * Flags that describe the object passed to la_objsearch()
 */
#define	LA_SER_ORIG		0x001	/* original (needed) name */
#define	LA_SER_LIBPATH		0x002	/* LD_LIBRARY_PATH entry prepended */
#define	LA_SER_RUNPATH		0x004	/* runpath entry prepended */
#define	LA_SER_CONFIG		0x008	/* configuration entry prepended */
#define	LA_SER_DEFAULT		0x040	/* default path prepended */
#define	LA_SER_SECURE		0x080	/* default (secure) path prepended */

#define	LA_SER_MASK		0xfff	/* mask of known flags */

/*
 * Flags that describe the la_activity()
 */
#define	LA_ACT_CONSISTENT	0x00	/* add/deletion of objects complete */
#define	LA_ACT_ADD		0x01	/* objects being added */
#define	LA_ACT_DELETE		0x02	/* objects being deleted */
#define	LA_ACT_MAX		3


#ifndef	_KERNEL
#ifndef	_ASM

#if defined(_LP64)
typedef long	lagreg_t;
#else
typedef int	lagreg_t;
#endif

struct _la_sparc_regs {
	lagreg_t	lr_rego0;
	lagreg_t	lr_rego1;
	lagreg_t	lr_rego2;
	lagreg_t	lr_rego3;
	lagreg_t	lr_rego4;
	lagreg_t	lr_rego5;
	lagreg_t	lr_rego6;
	lagreg_t	lr_rego7;
};

#if defined(_LP64)
typedef struct _la_sparc_regs	La_sparcv9_regs;
typedef struct {
	lagreg_t	lr_rsp;
	lagreg_t	lr_rbp;
	lagreg_t	lr_rdi;	    /* arg1 */
	lagreg_t	lr_rsi;	    /* arg2 */
	lagreg_t	lr_rdx;	    /* arg3 */
	lagreg_t	lr_rcx;	    /* arg4 */
	lagreg_t	lr_r8;	    /* arg5 */
	lagreg_t	lr_r9;	    /* arg6 */
} La_amd64_regs;
#else
typedef struct _la_sparc_regs	La_sparcv8_regs;
typedef struct {
	lagreg_t	lr_esp;
	lagreg_t	lr_ebp;
} La_i86_regs;
#endif

#if	!defined(_SYS_INT_TYPES_H)
#if	defined(_LP64)
typedef unsigned long		uintptr_t;
#else
typedef	unsigned int		uintptr_t;
#endif
#endif


extern uint_t		la_version(uint_t);
extern void		la_activity(uintptr_t *, uint_t);
extern void		la_preinit(uintptr_t *);
extern char		*la_objsearch(const char *, uintptr_t *, uint_t);
extern uint_t		la_objopen(Link_map *, Lmid_t, uintptr_t *);
extern uint_t		la_objclose(uintptr_t *);
extern int		la_objfilter(uintptr_t *, const char *, uintptr_t *,
				uint_t);
#if	defined(_LP64)
extern uintptr_t	la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
				uintptr_t *, La_amd64_regs *,	uint_t *,
				const char *);
extern uintptr_t	la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
				uintptr_t *, uint_t *, const char *);
extern uintptr_t	la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
				uintptr_t *, La_sparcv9_regs *,	uint_t *,
				const char *);
extern uintptr_t	la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
				uintptr_t *, uintptr_t, const char *);
#else  /* !defined(_LP64) */
extern uintptr_t	la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
				uintptr_t *, uint_t *);
extern uintptr_t	la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
				uintptr_t *, La_sparcv8_regs *, uint_t *);
extern uintptr_t	la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
				uintptr_t *, La_i86_regs *, uint_t *);
extern uintptr_t	la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
				uintptr_t *, uintptr_t);
#endif /* _LP64 */

/*
 * The ElfW() macro is a GNU/Linux feature, provided as support for
 * the dl_phdr_info structure used by dl_phdr_iterate(), which also
 * originated under Linux. Given an ELF data type, without the ElfXX_
 * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for
 * the ELFCLASS of the code being compiled.
 *
 * Note that ElfW() is not suitable in situations in which the ELFCLASS
 * of the code being compiled does not match that of the objects that
 * code is intended to operate on (e.g. a 32-bit link-editor building
 * a 64-bit object). The macros defined in <sys/machelf.h> are
 * recommended in such cases.
 */
#ifdef _LP64
#define	ElfW(type)	Elf64_ ## type
#else
#define	ElfW(type)	Elf32_ ## type
#endif

/*
 * The callback function to dl_interate_phdr() receives a pointer
 * to a structure of this type.
 *
 * dlpi_addr is defined such that the address of any segment in
 * the program header array can be calculated as:
 *
 *	addr == info->dlpi_addr + info->dlpi_phdr[x].p_vaddr;
 *
 * It is therefore 0 for ET_EXEC objects, and the base address at
 * which the object is mapped otherwise.
 */
struct dl_phdr_info {
	ElfW(Addr)		dlpi_addr;	/* Base address of object */
	const char		*dlpi_name;	/* Null-terminated obj name */
	const ElfW(Phdr)	*dlpi_phdr;	/* Ptr to ELF program hdr arr */
	ElfW(Half)		dlpi_phnum;	/* # of items in dlpi_phdr[] */

	/*
	 * Note: Following members were introduced after the first version
	 * of this structure was available.  The dl_iterate_phdr() callback
	 * function is passed a 'size' argument giving the size of the info
	 * structure, and must compare that size to the offset of these fields
	 * before accessing them to ensure that they are present.
	 */

	/* Incremented when a new object is mapped into the process */
	u_longlong_t		dlpi_adds;
	/* Incremented when an object is unmapped from the process */
	u_longlong_t		dlpi_subs;
};

extern  int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
	    void *);

#endif	/* _ASM */
#endif /* _KERNEL */


#ifdef __cplusplus
}
#endif

#endif	/* _LINK_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_LISTEN_H
#define	_LISTEN_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * listen.h:	Include file for network listener related user programs
 *
 */

/*
 * The NLPS (Network Listener Process Service)
 * protocol message sent by client machines to
 * a listener process to request a service on the listener's
 * machine. The message is sent to "netnodename(r_nodename)"
 * where r_nodename is the nodename (see uname(2)) of the
 * remote host. Note that client's need not know (or care)
 * about the details of this message.  They use the "nls_connect(3)"
 * library routine which uses this message.
 *
 * msg format:
 *
 *		"id:low:high:service_code"
 *
 *		id = "NLPS"
 *		low:high = version number of listener (see prot msg)
 *		service_code is ASCII/decimal
 *
 * the following prot string can be run through sprintf with a service code
 * to generate the message:
 *
 *	len = sprintf(buf,nls_prot_msg,svc_code);
 *	t_snd(fd, buf, len, ...);
 *
 * See also:  listen(1), nlsrequest(3)
 *
 * and on the UNIX PC STARLAN NETWORK:
 * See also:  nlsname(3), nlsconnect(3), nlsestablish(3)
 */

/*
 * defines for compatability purposes
 */

#define	nls_prot_msg	nls_v0_d
#define	nls_v2_msg	nls_v2_s

static char *nls_v0_d = "NLPS:000:001:%d";
static char *nls_v0_s = "NLPS:000:001:%s";
static char *nls_v2_d = "NLPS:002:002:%d";
static char *nls_v2_s = "NLPS:002:002:%s";

#define	NLSSTART	0
#define	NLSFORMAT	2
#define	NLSUNKNOWN	3
#define	NLSDISABLED	4

#define	SVC_CODE_SZ	14

/*
 * Structure for handling multiple connection requests on the same stream.
 */

struct callsave {
	struct t_call *c_cp;
	struct callsave *c_np;
};

struct call_list {
	struct callsave *cl_head;
	struct callsave *cl_tail;
};


#define	EMPTYLIST(p)	(p->cl_head == (struct callsave *)NULL)

/*
 * Ridiculously high value for maximum number of connects per stream.
 * Transport Provider will determine actual maximum to be used.
 */

#define	MAXCON		100

/*
 * these are names of environment variables that the listener
 * adds to the servers environment before the exec(2).
 *
 * the variables should be accessed via library routines.
 *
 * see nlsgetcall(3NSL) and nlsprovider(3NSL).
 */

#define	NLSADDR		"NLSADDR"
#define	NLSOPT		"NLSOPT"
#define	NLSUDATA	"NLSUDATA"
#define	NLSPROVIDER	"NLSPROVIDER"

/*
 * the following variables can be accessed "normally"
 */

#define	HOME		"HOME"
#define	PATH		"PATH"

#ifdef	__cplusplus
}
#endif

#endif	/* _LISTEN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Portions of this file developed by Garrett D'Amore are licensed
 * under the terms of the Common Development and Distribution License (CDDL)
 * version 1.0 only.  The use of subsequent versions of the License are
 * is specifically prohibited unless those terms are not in conflict with
 * version 1.0 of the License.  You can find this license on-line at
 * http://www.illumos.org/license/CDDL
 */

#ifndef _LOCALE_H
#define	_LOCALE_H

#include <iso/locale_iso.h>

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(__EXTENSIONS__)
#include <libintl.h>
#endif

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/locale_iso.h>.
 */
#if __cplusplus >= 199711L
using std::lconv;
using std::setlocale;
using std::localeconv;
#endif

#ifdef __cplusplus
extern "C" {
#endif

#define	_LastCategory	LC_MESSAGES	/* This must be last category */

#define	_ValidCategory(c) \
	(((int)(c) >= LC_CTYPE) && ((int)(c) <= _LastCategory) || \
	((int)c == LC_ALL))


#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)

/*
 * These were added in POSIX 2008 as part of the newlocale() specification.
 */
#define	LC_CTYPE_MASK		(1 << LC_CTYPE)
#define	LC_NUMERIC_MASK		(1 << LC_NUMERIC)
#define	LC_TIME_MASK		(1 << LC_TIME)
#define	LC_COLLATE_MASK		(1 << LC_COLLATE)
#define	LC_MONETARY_MASK	(1 << LC_MONETARY)
#define	LC_MESSAGES_MASK	(1 << LC_MESSAGES)
#define	LC_ALL_MASK		(0x3f)

#ifndef _LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern locale_t	duplocale(locale_t);
extern void	freelocale(locale_t);
extern locale_t	newlocale(int, const char *, locale_t);
extern locale_t	uselocale(locale_t);

#define	LC_GLOBAL_LOCALE	(__global_locale())
extern locale_t			__global_locale(void);

#endif	/* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */

#if defined(_XPG8) || !defined(_STRICT_SYMBOLS)
extern const char *getlocalename_l(int, locale_t);
#endif	/* _XPG8 || !_STRICT_SYMBOLS */

#ifdef	__cplusplus
}
#endif

#endif	/* _LOCALE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_MACROS_H
#define	_MACROS_H

#include <sys/types.h>
#include <sys/stat.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *	numeric() is useful in while's, if's, etc., but don't use *p++
 *	max() and min() depend on the types of the operands
 *	abs() is absolute value
 */
#define	numeric(c)		((c) >= '0' && (c) <= '9')
#define	max(a, b)		((a) < (b) ? (b) : (a))
#define	min(a, b)		((a) > (b) ? (b) : (a))
#define	abs(x)			((x) >= 0 ? (x) : -(x))

#define	compare(str1, str2)	strcmp((str1), (str2))
#define	equal(str1, str2)	(strcmp((str1), (str2)) == 0)
#define	length(str)		strlen(str)
#define	size(str)		(strlen(str) + 1)

/*
 *	The global variable Statbuf is available for use as a stat(II)
 *	structure.  Note that "stat.h" is included here and should
 *	not be included elsewhere.
 *	Exists(file) returns 0 if the file does not exist;
 *	the flags word if it does (the flags word is always non-zero).
 */

extern struct stat Statbuf;
#define	exists(file)		(stat(file, &Statbuf) < 0 ? 0 : Statbuf.st_mode)

/*
 *	SAVE() and RSTR() use local data in nested blocks.
 *	Make sure that they nest cleanly.
 */
#define	SAVE(name, place)	{ int place = name;
#define	RSTR(name, place)	name = place; }

/*
 *	Use: DEBUG(sum,d) which becomes fprintf(stderr,"sum = %d\n",sum)
 */
#define	DEBUG(var, type)	fprintf(stderr, #var "= %" #type "\n", var)

/*
 *	Use of ERRABORT() will cause libS.a internal
 *	errors to cause aborts
 */
#define	ERRABORT()	_error() { abort(); }

/*
 *	Use of USXALLOC() is required to force all calls to alloc()
 *	(e.g., from libS.a) to call xalloc().
 */
#define	NONBLANK(p)	while (*(p) == ' ' || *(p) == '\t') (p)++

/*
 *	A global null string.
 */
extern char	Null[1];

/*
 *	A global error message string.
 */
extern char	Error[128];

#ifdef	__cplusplus
}
#endif

#endif	/* _MACROS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _MALLOC_H
#define	_MALLOC_H

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *	Constants defining mallopt operations
 */
#define	M_MXFAST	1	/* set size of blocks to be fast */
#define	M_NLBLKS	2	/* set number of block in a holding block */
#define	M_GRAIN		3	/* set number of sizes mapped to one, for */
				/* small blocks */
#define	M_KEEP		4	/* retain contents of block after a free */
				/* until another allocation */
/*
 *	structure filled by
 */
struct mallinfo  {
	unsigned long arena;	/* total space in arena */
	unsigned long ordblks;	/* number of ordinary blocks */
	unsigned long smblks;	/* number of small blocks */
	unsigned long hblks;	/* number of holding blocks */
	unsigned long hblkhd;	/* space in holding block headers */
	unsigned long usmblks;	/* space in small blocks in use */
	unsigned long fsmblks;	/* space in free small blocks */
	unsigned long uordblks;	/* space in ordinary blocks in use */
	unsigned long fordblks;	/* space in free ordinary blocks */
	unsigned long keepcost;	/* cost of enabling keep option */
};

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG3)
#if __cplusplus >= 199711L
namespace std {
#endif

void *malloc(size_t);
void free(void *);
void *realloc(void *, size_t);
void *calloc(size_t, size_t);

#if __cplusplus >= 199711L
} /* end of namespace std */

using std::malloc;
using std::free;
using std::realloc;
using std::calloc;
#endif /* __cplusplus >= 199711L */
#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || ... */

int mallopt(int, int);
struct mallinfo mallinfo(void);

#ifdef	__cplusplus
}
#endif

#endif	/* _MALLOC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */

#ifndef _MATH_H
#define	_MATH_H

#include <iso/math_iso.h>
#include <iso/math_c99.h>

#if __cplusplus >= 199711L
using std::abs;
using std::acos;
using std::asin;
using std::atan2;
using std::atan;
using std::ceil;
using std::cos;
using std::cosh;
using std::exp;
using std::fabs;
using std::floor;
using std::fmod;
using std::frexp;
using std::ldexp;
using std::log10;
using std::log;
using std::modf;
using std::pow;
using std::sin;
using std::sinh;
using std::sqrt;
using std::tan;
using std::tanh;
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__cplusplus)
#define	exception	__math_exception
#endif

#if defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || \
	!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)
/*
 * SVID & X/Open
 */
#define	M_E		2.7182818284590452354
#define	M_LOG2E		1.4426950408889634074
#define	M_LOG10E	0.43429448190325182765
#define	M_LN2		0.69314718055994530942
#define	M_LN10		2.30258509299404568402
#define	M_PI		3.14159265358979323846
#define	M_PI_2		1.57079632679489661923
#define	M_PI_4		0.78539816339744830962
#define	M_1_PI		0.31830988618379067154
#define	M_2_PI		0.63661977236758134308
#define	M_2_SQRTPI	1.12837916709551257390
#define	M_SQRT2		1.41421356237309504880
#define	M_SQRT1_2	0.70710678118654752440

extern int signgam;

#define	MAXFLOAT	((float)3.40282346638528860e+38)

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
/*
 * SVID
 */
enum version {libm_ieee = -1, c_issue_4, ansi_1, strict_ansi};

#ifdef __STDC__
extern const enum version _lib_version;
#else
extern enum version _lib_version;
#endif

struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};

#define	HUGE		MAXFLOAT

#define	_ABS(x)		((x) < 0 ? -(x) : (x))

#define	_REDUCE(TYPE, X, XN, C1, C2)	{ \
	double x1 = (double)(TYPE)X, x2 = X - x1; \
	X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }

#define	DOMAIN		1
#define	SING		2
#define	OVERFLOW	3
#define	UNDERFLOW	4
#define	TLOSS		5
#define	PLOSS		6

#define	_POLY1(x, c)	((c)[0] * (x) + (c)[1])
#define	_POLY2(x, c)	(_POLY1((x), (c)) * (x) + (c)[2])
#define	_POLY3(x, c)	(_POLY2((x), (c)) * (x) + (c)[3])
#define	_POLY4(x, c)	(_POLY3((x), (c)) * (x) + (c)[4])
#define	_POLY5(x, c)	(_POLY4((x), (c)) * (x) + (c)[5])
#define	_POLY6(x, c)	(_POLY5((x), (c)) * (x) + (c)[6])
#define	_POLY7(x, c)	(_POLY6((x), (c)) * (x) + (c)[7])
#define	_POLY8(x, c)	(_POLY7((x), (c)) * (x) + (c)[8])
#define	_POLY9(x, c)	(_POLY8((x), (c)) * (x) + (c)[9])
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

/*
 * SVID & X/Open
 */
/* BEGIN adopted by C99 */
extern double erf(double);
extern double erfc(double);
extern double hypot(double, double);
extern double lgamma(double);

#if !defined(_STDC_C99) && _XOPEN_SOURCE - 0 < 600 && !defined(__C99FEATURES__)
extern int isnan(double);
#endif
/* END adopted by C99 */

#if defined(__EXTENSIONS__) || _XOPEN_SOURCE - 0 < 600
extern double gamma(double);		/* deprecated; use lgamma */
#endif
extern double j0(double);
extern double j1(double);
extern double jn(int, double);
extern double y0(double);
extern double y1(double);
extern double yn(int, double);

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || \
	_XOPEN_SOURCE - 0 >= 500 || \
	defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1
/*
 * SVID & XPG 4.2/5 - removed from XPG7.
 */
#if !defined(_STRICT_SYMBOLS) || !defined(_XPG7)
extern double scalb(double, double);
#endif

/* BEGIN adopted by C99 */
extern double acosh(double);
extern double asinh(double);
extern double atanh(double);
extern double cbrt(double);
extern double logb(double);
extern double nextafter(double, double);
extern double remainder(double, double);

/*
 * XPG 4.2/5
 */
extern double expm1(double);
extern int ilogb(double);
extern double log1p(double);
extern double rint(double);

/* END adopted by C99 */
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || ... */

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
/*
 * SVID
 */
extern int matherr(struct exception *);

/*
 * IEEE Test Vector
 */
extern double significand(double);

extern int signgamf;				/* deprecated; use signgam */
extern int signgaml;				/* deprecated; use signgam */

extern int isnanf(float);
extern int isnanl(long double);
extern float gammaf(float);		/* deprecated; use lgammaf */
extern float gammaf_r(float, int *);	/* deprecated; use lgammaf_r */
extern float j0f(float);
extern float j1f(float);
extern float jnf(int, float);
extern float lgammaf_r(float, int *);
extern float scalbf(float, float);
extern float significandf(float);
extern float y0f(float);
extern float y1f(float);
extern float ynf(int, float);
extern long double gammal(long double);	/* deprecated; use lgammal */
extern long double gammal_r(long double, int *);	/* deprecated */
extern long double j0l(long double);
extern long double j1l(long double);
extern long double jnl(int, long double);
extern long double lgammal_r(long double, int *);
extern long double scalbl(long double, long double);
extern long double significandl(long double);
extern long double y0l(long double);
extern long double y1l(long double);
extern long double ynl(int, long double);

/*
 * for sin+cos->sincos transformation
 */
extern void sincos(double, double *, double *);
extern void sincosf(float, float *, float *);
extern void sincosl(long double, long double *, long double *);

/* BEGIN adopted by C99 */
/*
 * Functions callable from C, intended to support IEEE arithmetic.
 */
extern double copysign(double, double);
extern double scalbn(double, int);
/* END adopted by C99 */

/*
 * Reentrant version of gamma & lgamma; passes signgam back by reference
 * as the second argument; user must allocate space for signgam.
 */
extern double gamma_r(double, int *);	/* deprecated; use lgamma_r */
extern double lgamma_r(double, int *);

/* BEGIN adopted by C99 */
extern float modff(float, float *);
/* END adopted by C99 */

#if defined(__EXTENSIONS__) || !defined(__cplusplus)
#include <floatingpoint.h>
#endif
#endif	/* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */
#endif	/* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) || ... */

#if defined(__cplusplus) && defined(__GNUC__)
#undef	exception
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _MATH_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2026 Gordon Ross <gordon.w.ross@gmail.com>
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_MEMORY_H
#define	_MEMORY_H

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern void *memccpy(void *, const void *, int, size_t);

#if __cplusplus >= 199711L
namespace std {
#endif

extern int memcmp(const void *, const void *, size_t);
extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t);
extern void *memset(void *, int, size_t);

/* See similar in string_iso.h */
#if __cplusplus >= 199711L
extern const void *memchr(const void *, int, size_t);
#ifndef	_MEMCHR_INLINE
#define	_MEMCHR_INLINE
extern "C++" {
	inline void *memchr(void * __s, int __c, size_t __n) {
		return (void *)memchr((const void *)__s, __c, __n);
	}
}
#endif	/* _MEMCHR_INLINE */

#else	/* __cplusplus >= 199711L */

extern void *memchr(const void *, int, size_t);

#endif	/* __cplusplus >= 199711L */

#if __cplusplus >= 199711L
}	/* end of namespace std */
#endif	/* __cplusplus >= 199711L */

#ifdef	__cplusplus
}
#endif

#if __cplusplus >= 199711L
using std::memcmp;
using std::memcpy;
using std::memset;
using std::memchr;
#endif	/* __cplusplus >= 199711L */

#endif	/* _MEMORY_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2014 PALO, Richard.
 *
 * Copyright 1997-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _MON_H
#define	_MON_H

#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Inclusion of <sys/types.h> will break SVID namespace, hence only
 * the size_t type is defined in this header.
 */
#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef unsigned long size_t;	/* size of something in bytes */
#else
typedef unsigned int  size_t;	/* (historical version) */
#endif
#endif  /* _SIZE_T */

struct hdr {
	char	*lpc;
	char	*hpc;
	size_t	nfns;
};

struct cnt {
	char	*fnpc;
	long	mcnt;
};

typedef unsigned short WORD;

#define	MON_OUT	"mon.out"
#define	MPROGS0	(150 * sizeof (WORD))	/* 300 for pdp11, 600 for 32-bits */
#define	MSCALE0	4

extern void monitor(int (*)(void), int (*)(void), WORD *, size_t, size_t);

#ifdef	__cplusplus
}
#endif

#endif	/* _MON_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_MONETARY_H
#define	_MONETARY_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

extern ssize_t	strfmon(char *_RESTRICT_KYWD, size_t,
			const char *_RESTRICT_KYWD, ...);

#if defined(_XPG7) || (!defined(_STRICT_STRICT_SYMBOLS))

#ifndef _LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern ssize_t strfmon_l(char *_RESTRICT_KYWD, size_t, locale_t,
		const char *_RESTRICT_KYWD, ...);
#endif

#ifdef __cplusplus
}
#endif

#endif	/* _MONETARY_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _MP_H
#define	_MP_H

#ifdef	__cplusplus
extern "C" {
#endif

struct mint {
	int len;
	short *val;
};
typedef struct mint MINT;


extern void mp_gcd(MINT *, MINT *, MINT *);
extern void mp_madd(MINT *, MINT *, MINT *);
extern void mp_msub(MINT *, MINT *, MINT *);
extern void mp_mdiv(MINT *, MINT *, MINT *, MINT *);
extern void mp_sdiv(MINT *, short, MINT *, short *);
extern int mp_min(MINT *);
extern void mp_mout(MINT *);
extern int mp_msqrt(MINT *, MINT *, MINT *);
extern void mp_mult(MINT *, MINT *, MINT *);
extern void mp_pow(MINT *, MINT *, MINT *, MINT *);
extern void mp_rpow(MINT *, short, MINT *);
extern MINT *mp_itom(short);
extern int mp_mcmp(MINT *, MINT *);
extern MINT *mp_xtom(char *);
extern char *mp_mtox(MINT *);
extern void mp_mfree(MINT *);

#define	FREE(x)	_mp_xfree(&(x))		/* Compatibility */

#ifdef	__cplusplus
}
#endif

#endif /* _MP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _MQUEUE_H
#define	_MQUEUE_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/signal.h>
#include <sys/siginfo.h>
#include <time.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef void	*mqd_t;		/* opaque message queue descriptor */

struct mq_attr {
	long	mq_flags;	/* message queue flags */
	long	mq_maxmsg;	/* maximum number of messages */
	long	mq_msgsize;	/* maximum message size */
	long	mq_curmsgs;	/* number of messages currently queued */
	int	mq_pad[12];
};

/*
 * function prototypes
 */
#if	(_POSIX_C_SOURCE - 0 > 0) && (_POSIX_C_SOURCE - 0 <= 2)
#error	"POSIX Message Passing is not supported in POSIX.1-1990"
#endif
#include <sys/siginfo.h>
mqd_t	mq_open(const char *, int, ...);
int	mq_close(mqd_t);
int	mq_unlink(const char *);
int	mq_send(mqd_t, const char *, size_t, unsigned int);
int	mq_timedsend(mqd_t, const char *, size_t, unsigned int,
		const struct timespec *);
int	mq_reltimedsend_np(mqd_t, const char *, size_t, unsigned int,
		const struct timespec *);
ssize_t	mq_receive(mqd_t, char *, size_t, unsigned int *);
ssize_t	mq_timedreceive(mqd_t, char *_RESTRICT_KYWD, size_t,
		unsigned int *_RESTRICT_KYWD,
		const struct timespec *_RESTRICT_KYWD);
ssize_t	mq_reltimedreceive_np(mqd_t, char *_RESTRICT_KYWD, size_t,
		unsigned int *_RESTRICT_KYWD,
		const struct timespec *_RESTRICT_KYWD);
int	mq_notify(mqd_t, const struct sigevent *);
int	mq_getattr(mqd_t, struct mq_attr *);
int	mq_setattr(mqd_t, const struct mq_attr *_RESTRICT_KYWD,
		struct mq_attr *_RESTRICT_KYWD);

#ifdef	__cplusplus
}
#endif

#endif	/* _MQUEUE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1996, by Sun Microsystems, Inc.
 * All Rights Reserved
 */

#ifndef _NAN_H
#define	_NAN_H

/*
 * Handling of Not_a_Number's (only in IEEE floating-point standard)
 */

#include <sys/isa_defs.h>
#include <values.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(_IEEE_754)
/*
 * Structure order is endian dependent.  Only the common variants of
 * big and little endian are supported.
 */

#if defined(_BIG_ENDIAN)

typedef union
{
	struct
	{
		unsigned sign		: 1;
		unsigned exponent	:11;
		unsigned bits		:20;
		unsigned fraction_low	:32;
	} inf_parts;
	struct
	{
		unsigned sign		: 1;
		unsigned exponent	:11;
		unsigned qnan_bit	: 1;
		unsigned bits		:19;
		unsigned fraction_low	:32;
	} nan_parts;
	double d;

} dnan;

#else	/* Must be _LITTLE_ENDIAN */

typedef union
{
	struct {
		unsigned fraction_low	:32;
		unsigned bits		:20;
		unsigned exponent	:11;
		unsigned sign		: 1;
	} inf_parts;
	struct {
		unsigned fraction_low	:32;
		unsigned bits		:19;
		unsigned qnan_bit	: 1;
		unsigned exponent	:11;
		unsigned sign		: 1;
	} nan_parts;
	double d;
} dnan;

#endif	/* Endian based selection */

/*
 * IsNANorINF checks that exponent of double == 2047
 * i.e. that number is a NaN or an infinity
 */
#define	IsNANorINF(X)  (((dnan *)&(X))->nan_parts.exponent == 0x7ff)

/*
 * IsINF must be used after IsNANorINF has checked the exponent
 */
#define	IsINF(X)	(((dnan *)&(X))->inf_parts.bits == 0 && \
			    ((dnan *)&(X))->inf_parts.fraction_low == 0)

/*
 * IsPosNAN and IsNegNAN can be used to check the sign of infinities too
 */
#define	IsPosNAN(X)	(((dnan *)&(X))->nan_parts.sign == 0)

#define	IsNegNAN(X)	(((dnan *)&(X))->nan_parts.sign == 1)

/*
 * GETNaNPC gets the leftmost 32 bits of the fraction part
 */
#define	GETNaNPC(dval)	(((dnan *)&(dval))->inf_parts.bits << 12 | \
			    ((dnan *)&(dval))->nan_parts.fraction_low >> 20)

#define	KILLFPE()	(void) _kill(_getpid(), 8)
#define	NaN(X)		(((dnan *)&(X))->nan_parts.exponent == 0x7ff)
#define	KILLNaN(X)	if (NaN(X)) KILLFPE()

#else	/* defined(_IEEE_754) */
/* #error is strictly ansi-C, but works as well as anything for K&R systems. */
#error ISA not supported
#endif	/* defined(_IEEE_754) */

#ifdef	__cplusplus
}
#endif

#endif	/* _NAN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

/*
 * Hashed key data base library.
 */

#ifndef _NDBM_H
#define	_NDBM_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * flags to dbm_store()
 */
#define	DBM_INSERT	0
#define	DBM_REPLACE	1

#define	_PBLKSIZ 1024
#define	_DBLKSIZ 4096

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	PBLKSIZ _PBLKSIZ
#define	DBLKSIZ _DBLKSIZ
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

typedef struct {
	int	dbm_dirf;		/* open directory file */
	int	dbm_pagf;		/* open page file */
	int	dbm_flags;		/* flags, see below */
	long	dbm_maxbno;		/* last ``bit'' in dir file */
	long	dbm_bitno;		/* current bit number */
	long	dbm_hmask;		/* hash mask */
	long	dbm_blkptr;		/* current block for dbm_nextkey */
	int	dbm_keyptr;		/* current key for dbm_nextkey */
	long	dbm_blkno;		/* current page to read/write */
	long	dbm_pagbno;		/* current page in pagbuf */
	char	dbm_pagbuf[_PBLKSIZ];	/* page file block buffer */
	long	dbm_dirbno;		/* current block in dirbuf */
	char	dbm_dirbuf[_DBLKSIZ];	/* directory file block buffer */
} DBM;

#if defined(_XPG4_2)
typedef struct {
	void	*dptr;
	size_t	dsize;
} datum;
#else
typedef struct {
	char	*dptr;
	long	dsize;
} datum;
#endif

DBM	*dbm_open(const char *, int, mode_t);
void	dbm_close(DBM *);
datum	dbm_fetch(DBM *, datum);
datum	dbm_firstkey(DBM *);
datum	dbm_nextkey(DBM *);
int	dbm_delete(DBM *, datum);
int	dbm_store(DBM *, datum, datum, int);
int	dbm_clearerr(DBM *);
int	dbm_error(DBM *);

#define	_DBM_RDONLY	0x1	/* data base open read-only */
#define	_DBM_IOERR	0x2	/* data base I/O error */

#define	dbm_rdonly(__db)	((__db)->dbm_flags & _DBM_RDONLY)
#define	dbm_error(__db)		((__db)->dbm_flags & _DBM_IOERR)
/* use this one at your own risk! */
#define	dbm_clearerr(__db)	((__db)->dbm_flags &= ~_DBM_IOERR)
/* for fstat(2) */
#define	dbm_dirfno(__db)	((__db)->dbm_dirf)
#define	dbm_pagfno(__db)	((__db)->dbm_pagf)

#ifdef	__cplusplus
}
#endif

#endif	/* _NDBM_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_NDPD_H
#define	_NDPD_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	NDPD_SNMP_SOCKET	"/var/run/in.ndpd_mib"
#define	NDPD_SNMP_INFO_REQ	1
#define	NDPD_SNMP_INFO_RESPONSE	2
#define	NDPD_PHYINT_INFO	3
#define	NDPD_PREFIX_INFO	4
#define	NDPD_ROUTER_INFO	5

#define	NDPD_SNMP_INFO_VER	1
#define	NDPD_PHYINT_INFO_VER    1
#define	NDPD_PREFIX_INFO_VER    1
#define	NDPD_ROUTER_INFO_VER	1

/*
 * Data structures used to handle configuration variables set in ndpd.conf.
 * cf_notdefault is set for variables explicitly set in ndpd.conf.
 */
struct confvar {
	uint_t		cf_value;
	boolean_t	cf_notdefault;
};

extern struct confvar ifdefaults[];

/*
 * Interfaces configuration variable indicies
 */
#define	I_DupAddrDetectTransmits	0	/* From RFC 2462 */
#define	I_AdvSendAdvertisements		1
#define	I_MaxRtrAdvInterval		2	/* In seconds */
#define	I_MinRtrAdvInterval		3	/* In seconds */
#define	I_AdvManagedFlag		4
#define	I_AdvOtherConfigFlag		5
#define	I_AdvLinkMTU			6
#define	I_AdvReachableTime		7	/* In milliseconds */
#define	I_AdvRetransTimer		8	/* In milliseconds */
#define	I_AdvCurHopLimit		9
#define	I_AdvDefaultLifetime		10	/* In seconds */
#define	I_StatelessAddrConf		11
#define	I_TmpAddrsEnabled		12	/* From RFC 3041 */
#define	I_TmpValidLifetime		13	/* In seconds */
#define	I_TmpPreferredLifetime		14	/* In seconds */
#define	I_TmpRegenAdvance		15	/* In seconds */
#define	I_TmpMaxDesyncFactor		16	/* In seconds */
#define	I_StatefulAddrConf		17
#define	I_IFSIZE			18	/* # of variables */

typedef struct ndpd_info_s {
	uint_t	info_type;
	uint_t	info_version;
	uint_t	info_num_of_phyints;
} ndpd_info_t;

typedef struct ndpd_prefix_info_s {
	uint_t		prefix_info_type;
	uint_t		prefix_info_version;
	struct in6_addr prefix_prefix;		/* Used to indentify prefix */
	uint_t		prefix_len;		/* Num bits valid */
	uint_t		prefix_flags;		/* IFF_ flags */
	uint_t		prefix_phyint_index;
	uint_t		prefix_ValidLifetime;	 /* In ms w/ 2 hour rule */
	uint_t		prefix_PreferredLifetime; /* In millseconds */
	uint_t		prefix_OnLinkLifetime;	/* ms valid w/o 2 hour rule */
	boolean_t	prefix_OnLinkFlag;
	boolean_t	prefix_AutonomousFlag;
} ndpd_prefix_info_t;

typedef struct ndpd_router_info_s {
	uint_t		router_info_type;
	uint_t		router_info_version;
	struct in6_addr	router_address;		/* Used to identify router */
	uint_t		router_lifetime;	/* In milliseconds */
	uint_t		router_phyint_index;
} ndpd_router_info_t;


typedef struct ndpd_phyint_info_s {
	uint_t		phyint_info_type;
	uint_t		phyint_info_version;
	int		phyint_index;
	struct confvar	phyint_config[I_IFSIZE];
#define	phyint_DupAddrDetectTransmits	\
				phyint_config[I_DupAddrDetectTransmits].cf_value
#define	phyint_AdvSendAdvertisements	\
				phyint_config[I_AdvSendAdvertisements].cf_value
#define	phyint_MaxRtrAdvInterval	\
				phyint_config[I_MaxRtrAdvInterval].cf_value
#define	phyint_MinRtrAdvInterval	\
				phyint_config[I_MinRtrAdvInterval].cf_value
#define	phyint_AdvManagedFlag	phyint_config[I_AdvManagedFlag].cf_value
#define	phyint_AdvOtherConfigFlag	\
				phyint_config[I_AdvOtherConfigFlag].cf_value
#define	phyint_AdvLinkMTU	phyint_config[I_AdvLinkMTU].cf_value
#define	phyint_AdvReachableTime	phyint_config[I_AdvReachableTime].cf_value
#define	phyint_AdvRetransTimer	phyint_config[I_AdvRetransTimer].cf_value
#define	phyint_AdvCurHopLimit	phyint_config[I_AdvCurHopLimit].cf_value
#define	phyint_AdvDefaultLifetime	\
				phyint_config[I_AdvDefaultLifetime].cf_value
#define	phyint_StatelessAddrConf	\
				phyint_config[I_StatelessAddrConf].cf_value
#define	phyint_TmpAddrsEnabled	phyint_config[I_TmpAddrsEnabled].cf_value
#define	phyint_TmpValidLifetime	phyint_config[I_TmpValidLifetime].cf_value
#define	phyint_TmpPreferredLifetime	\
				phyint_config[I_TmpPreferredLifetime].cf_value
#define	phyint_TmpRegenAdvance	phyint_config[I_TmpRegenAdvance].cf_value
#define	phyint_TmpMaxDesyncFactor	\
				phyint_config[I_TmpMaxDesyncFactor].cf_value
#define	phyint_StatefulAddrConf	\
				phyint_config[I_StatefulAddrConf].cf_value
	uint_t		phyint_num_of_prefixes;
	uint_t		phyint_num_of_routers;
} ndpd_phyint_info_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _NDPD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_NETCONFIG_H
#define	_NETCONFIG_H

#include <sys/netconfig.h>

#endif	/* _NETCONFIG_H */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * BIND 4.9.3:
 *
 * Copyright (c) 1980, 1983, 1988, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * -
 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies, and that
 * the name of Digital Equipment Corporation not be used in advertising or
 * publicity pertaining to distribution of the document or software without
 * specific, written prior permission.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 * --Copyright--
 *
 * End BIND 4.9.3
 */

/*
 * Structures returned by network data base library.
 * All addresses are supplied in host order, and
 * returned in network order (suitable for use in system calls).
 */

#ifndef _NETDB_H
#define	_NETDB_H

#include <sys/types.h>
#include <netinet/in.h>
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
#include <sys/socket.h>
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	_PATH_HEQUIV	"/etc/hosts.equiv"
#define	_PATH_HOSTS	"/etc/hosts"
#define	_PATH_IPNODES	"/etc/inet/ipnodes"
#define	_PATH_IPSECALGS	"/etc/inet/ipsecalgs"
#define	_PATH_NETMASKS	"/etc/netmasks"
#define	_PATH_NETWORKS	"/etc/networks"
#define	_PATH_PROTOCOLS	"/etc/protocols"
#define	_PATH_SERVICES	"/etc/services"

struct	hostent {
	char	*h_name;	/* official name of host */
	char	**h_aliases;	/* alias list */
	int	h_addrtype;	/* host address type */
	int	h_length;	/* length of address */
	char	**h_addr_list;	/* list of addresses from name server */
#define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
};


/*
 * addrinfo introduced with IPv6 for Protocol-Independent Hostname
 * and Service Name Translation.
 */

#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
struct addrinfo {
	int ai_flags;		/* AI_PASSIVE, AI_CANONNAME, ... */
	int ai_family;		/* PF_xxx */
	int ai_socktype;	/* SOCK_xxx */
	int ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
#ifdef __sparcv9
	int _ai_pad;		/* for backwards compat with old size_t */
#endif /* __sparcv9 */
	socklen_t ai_addrlen;
	char *ai_canonname;	/* canonical name for hostname */
	struct sockaddr *ai_addr;	/* binary address */
	struct addrinfo *ai_next;	/* next structure in linked list */
};

/*
 * The flag 0x8000 is currently reserved for private use between libnsl and
 * libsocket. See lib/libsocket/inet/getaddrinfo.c for more information.
 */
/* addrinfo flags */
#define	AI_PASSIVE	0x0008	/* intended for bind() + listen() */
#define	AI_CANONNAME	0x0010	/* return canonical version of host */
#define	AI_NUMERICHOST	0x0020	/* use numeric node address string */
#define	AI_NUMERICSERV	0x0040	/* servname is assumed numeric */

/* getipnodebyname() flags */
#define	AI_V4MAPPED	0x0001	/* IPv4 mapped addresses if no IPv6 */
#define	AI_ALL		0x0002	/* IPv6 and IPv4 mapped addresses */
#define	AI_ADDRCONFIG	0x0004	/* AAAA or A records only if IPv6/IPv4 cnfg'd */


/*
 * These were defined in RFC 2553 but not SUSv3
 * or RFC 3493 which obsoleted 2553.
 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
#define	AI_DEFAULT	(AI_V4MAPPED | AI_ADDRCONFIG)

/* addrinfo errors */
#define	EAI_ADDRFAMILY	1	/* address family not supported */
#define	EAI_NODATA	7	/* no address */
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
#define	EAI_AGAIN	2	/* DNS temporary failure */
#define	EAI_BADFLAGS	3	/* invalid ai_flags */
#define	EAI_FAIL	4	/* DNS non-recoverable failure */
#define	EAI_FAMILY	5	/* ai_family not supported */
#define	EAI_MEMORY	6	/* memory allocation failure */
#define	EAI_NONAME	8	/* host/servname not known */
#define	EAI_SERVICE	9	/* servname not supported for ai_socktype */
#define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
#define	EAI_SYSTEM	11	/* system error in errno */
#define	EAI_OVERFLOW	12	/* argument buffer overflow */
#define	EAI_PROTOCOL	13
#define	EAI_MAX		14

/* getnameinfo flags */
#define	NI_NOFQDN	0x0001
#define	NI_NUMERICHOST	0x0002	/* return numeric form of address */
#define	NI_NAMEREQD	0x0004	/* request DNS name */
#define	NI_NUMERICSERV	0x0008
#define	NI_DGRAM	0x0010

#if !defined(_XPG6) || defined(__EXTENSIONS__)
/* Not listed in any standards document */
#define	NI_WITHSCOPEID  0x0020
#define	NI_NUMERICSCOPE 0x0040

/* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
#define	NI_MAXHOST	1025
#define	NI_MAXSERV	32
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

/*
 * Scope delimit character
 */
#define	SCOPE_DELIMITER	'%'


/*
 * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
 * and algorithms.
 */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
typedef struct ipsecalgent {
	char **a_names;		/* algorithm names */
	int a_proto_num;	/* protocol number */
	int a_alg_num;		/* algorithm number */
	char *a_mech_name;	/* encryption framework mechanism name */
	int *a_block_sizes;	/* supported block sizes */
	int *a_key_sizes;	/* supported key sizes */
	int a_key_increment;	/* key size increment */
	int *a_mech_params;	/* mechanism specific parameters */
	int a_alg_flags;	/* algorithm flags */
} ipsecalgent_t;

/* well-known IPsec protocol numbers */

#define	IPSEC_PROTO_AH		2
#define	IPSEC_PROTO_ESP		3
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

/*
 * Assumption here is that a network number
 * fits in 32 bits -- probably a poor one.
 */
struct	netent {
	char		*n_name;	/* official name of net */
	char		**n_aliases;	/* alias list */
	int		n_addrtype;	/* net address type */
	in_addr_t	n_net;		/* network # */
};

struct	protoent {
	char	*p_name;	/* official protocol name */
	char	**p_aliases;	/* alias list */
	int	p_proto;	/* protocol # */
};

struct	servent {
	char	*s_name;	/* official service name */
	char	**s_aliases;	/* alias list */
	int	s_port;		/* port # */
	char	*s_proto;	/* protocol to use */
};

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
struct hostent	*gethostbyname_r
	(const char *, struct hostent *, char *, int, int *h_errnop);
struct hostent	*gethostbyaddr_r
	(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
struct hostent	*getipnodebyname(const char *, int, int, int *);
struct hostent	*getipnodebyaddr(const void *, size_t, int, int *);
void		freehostent(struct hostent *);
struct hostent	*gethostent_r(struct hostent *, char *, int, int *h_errnop);

struct servent	*getservbyname_r
	(const char *name, const char *, struct servent *, char *, int);
struct servent	*getservbyport_r
	(int port, const char *, struct servent *, char *, int);
struct servent	*getservent_r(struct	servent *, char *, int);

struct netent	*getnetbyname_r
	(const char *, struct netent *, char *, int);
struct netent	*getnetbyaddr_r(long, int, struct netent *, char *, int);
struct netent	*getnetent_r(struct netent *, char *, int);

struct protoent	*getprotobyname_r
	(const char *, struct protoent *, char *, int);
struct protoent	*getprotobynumber_r
	(int, struct protoent *, char *, int);
struct protoent	*getprotoent_r(struct protoent *, char *, int);

int getnetgrent_r(char **, char **, char **, char *, int);
int innetgr(const char *, const char *, const char *, const char *);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

/* Old interfaces that return a pointer to a static area;  MT-unsafe */
struct hostent	*gethostbyname(const char *);
struct hostent	*gethostent(void);
struct netent	*getnetbyaddr(in_addr_t, int);
struct netent	*getnetbyname(const char *);
struct netent	*getnetent(void);
struct protoent	*getprotobyname(const char *);
struct protoent	*getprotobynumber(int);
struct protoent	*getprotoent(void);
struct servent	*getservbyname(const char *, const char *);
struct servent	*getservbyport(int, const char *);
struct servent	*getservent(void);

/* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
struct hostent	*gethostbyaddr(const void *, socklen_t, int);
#else
struct hostent	*gethostbyaddr(const void *, size_t, int);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
int endhostent(void);
int endnetent(void);
int endprotoent(void);
int endservent(void);
int sethostent(int);
int setnetent(int);
int setprotoent(int);
int setservent(int);
#else
void endhostent(void);
void endnetent(void);
void endprotoent(void);
void endservent(void);
void sethostent(int);
void setnetent(int);
void setprotoent(int);
void setservent(int);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)

#ifdef	_XPG6
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getaddrinfo __xnet_getaddrinfo
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	getaddrinfo __xnet_getaddrinfo
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* _XPG6 */

int		getaddrinfo(const char *_RESTRICT_KYWD,
			const char *_RESTRICT_KYWD,
			const struct addrinfo *_RESTRICT_KYWD,
			struct addrinfo **_RESTRICT_KYWD);
void		freeaddrinfo(struct addrinfo *);
const char	*gai_strerror(int);
int		getnameinfo(const struct sockaddr *_RESTRICT_KYWD,
			socklen_t, char *_RESTRICT_KYWD, socklen_t,
			char *_RESTRICT_KYWD, socklen_t, int);
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
int getnetgrent(char **, char **, char **);
int setnetgrent(const char *);
int endnetgrent(void);
int rcmd(char **, unsigned short,
	const char *, const char *, const char *, int *);
int rcmd_af(char **, unsigned short,
	const char *, const char *, const char *, int *, int);
int rresvport_af(int *, int);
int rresvport_addr(int *, struct sockaddr_storage *);
int rexec(char **, unsigned short,
	const char *, const char *, const char *, int *);
int rexec_af(char **, unsigned short,
	const char *, const char *, const char *, int *, int);
int rresvport(int *);
int ruserok(const char *, int, const char *, const char *);
/* BIND */
struct hostent	*gethostbyname2(const char *, int);
void		herror(const char *);
const char	*hstrerror(int);
/* End BIND */

/* IPsec algorithm prototype definitions */
struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
struct ipsecalgent *getipsecalgbynum(int, int, int *);
int getipsecprotobyname(const char *doi_name);
char *getipsecprotobynum(int doi_domain);
void freeipsecalgent(struct ipsecalgent *ptr);
/* END IPsec algorithm prototype definitions */

#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

/*
 * Error return codes from gethostbyname() and gethostbyaddr()
 * (when using the resolver)
 */

extern  int h_errno;

#ifdef	_REENTRANT
extern int	*__h_errno(void);

/* Only #define h_errno if there is no conflict with other use */
#ifdef	H_ERRNO_IS_FUNCTION
#define	h_errno	(*__h_errno())
#endif	/* NO_H_ERRNO_DEFINE */
#endif	/* _REENTRANT */

/*
 * Error return codes from gethostbyname() and gethostbyaddr()
 * (left in extern int h_errno).
 */
#define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define	NO_DATA		4 /* Valid name, no data record of requested type */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */

/* BIND */
#define	NETDB_INTERNAL	-1	/* see errno */
#define	NETDB_SUCCESS	0	/* no problem */
/* End BIND */

#define	MAXHOSTNAMELEN	256

#define	MAXALIASES	35
#define	MAXADDRS	35
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _NETDB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 2016 by Delphix. All rights reserved.
 */
/*	Copyright (c) 1992 Sun Microsystems, Inc.	*/
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * netdir.h
 *
 * This is the include file that defines various structures and
 * constants used by the netdir routines.
 */

#ifndef _NETDIR_H
#define	_NETDIR_H

/*
 * This files uses struct netconfig, and netconfig.h must be included
 * before this to avoid warnings.
 */

#include <netconfig.h>

#ifdef	__cplusplus
extern "C" {
#endif

struct nd_addrlist {
	int		n_cnt;		/* number of netbufs */
	struct netbuf	*n_addrs;	/* the netbufs */
};

struct nd_hostservlist {
	int			h_cnt;		/* number of nd_hostservs */
	struct nd_hostserv	*h_hostservs;	/* the entries */
};

struct nd_hostserv {
	char		*h_host;	/* the host name */
	char		*h_serv;	/* the service name */
};

struct nd_mergearg {
	char		*s_uaddr;	/* servers universal address */
	char		*c_uaddr;	/* clients universal address */
	char		*m_uaddr;	/* merged universal address */
};

/*
 * _nderror is a private variable to the netdir system.
 */
#ifdef _REENTRANT
extern int	*__nderror();
#define	_nderror	(*(__nderror()))
#else
extern int _nderror;
#endif  /* _REENTRANT */


int netdir_options(struct netconfig *, int option, int fd, char *par);
int netdir_getbyname(struct netconfig *, struct nd_hostserv *,
    struct nd_addrlist **);
int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **,
    struct netbuf *);
int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **,
    struct netbuf *);
int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr,
    char *ruaddr);
void netdir_free(void *, int);
struct netbuf *uaddr2taddr(struct netconfig *, char *);
char *taddr2uaddr(struct netconfig *, struct netbuf *);
void netdir_perror(char *);
char *netdir_sperror();
struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *);
struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *);
struct netbuf *_uaddr2taddr(struct netconfig *, char *);
char *_taddr2uaddr(struct netconfig *, struct netbuf *);
char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr);

/*
 * These are all objects that can be freed by netdir_free
 */
#define	ND_HOSTSERV	0
#define	ND_HOSTSERVLIST	1
#define	ND_ADDR		2
#define	ND_ADDRLIST	3

/*
 * These are the various errors that can be encountered while attempting
 * to translate names to addresses. Note that none of them (except maybe
 * no memory) are truely fatal unless the ntoa deamon is on its last attempt
 * to translate the name. First four errors are to failitate return values
 * from DNS, that are used by mail and others.
 *
 * Negative errors terminate the search resolution process, positive errors
 * are treated as warnings.
 */

#define	ND_TRY_AGAIN	-5	/* Non-Authoritive Host not found, or */
				/* SERVERFAIL */
#define	ND_NO_RECOVERY	-4	/* Non recoverable errors, FORMERR, REFUSED, */
				/* NOTIMP */
#define	ND_NO_DATA	-3	/* Valid name, no data record of requested */
				/* type */
#define	ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */
#define	ND_BADARG	-2	/* Bad arguments passed		*/
#define	ND_NOMEM	-1	/* No virtual memory left	*/
#define	ND_OK		0	/* Translation successful	*/
#define	ND_NOHOST	1	/* Hostname was not resolvable	*/
#define	ND_NOSERV	2	/* Service was unknown		*/
#define	ND_NOSYM	3	/* Couldn't resolve symbol	*/
#define	ND_OPEN		4	/* File couldn't be opened	*/
#define	ND_ACCESS	5	/* File is not accessable	*/
#define	ND_UKNWN	6	/* Unknown object to be freed	*/
#define	ND_NOCTRL	7	/* Unknown option passed to netdir_options */
#define	ND_FAILCTRL	8	/* Option failed in netdir_options */
#define	ND_SYSTEM	9	/* Other System error		*/

/*
 * The following netdir_options commands can be given to the fd. These is
 * a way of providing for any transport specific action which the caller
 * may want to initiate on its transport. It is up to the trasport provider
 * to support the netdir_options it wants to support.
 */

#define	ND_SET_BROADCAST	1	/* Do t_optmgmt to support broadcast */
#define	ND_SET_RESERVEDPORT	2	/* bind it to reserve address */
#define	ND_CHECK_RESERVEDPORT	3	/* check if address is reserved */
#define	ND_MERGEADDR		4	/* Merge universal address */

/*
 *	The following special case host names are used to give the underlying
 *	transport provides a clue as to the intent of the request.
 */

#define	HOST_SELF	"\\1"
#define	HOST_ANY	"\\2"
#define	HOST_BROADCAST	"\\3"
#define	HOST_SELF_BIND	HOST_SELF
#define	HOST_SELF_CONNECT	"\\4"

#ifdef	__cplusplus
}
#endif

#endif	/* _NETDIR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *  nl_types.h
 *
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1991,1997,2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	All Rights Reserved	*/

#ifndef	_NL_TYPES_H
#define	_NL_TYPES_H

#include <sys/isa_defs.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	NL_SETD			1    /* XPG3 Conformant Default set number. */
#define	NL_CAT_LOCALE		(-1) /* XPG4 requirement */

#define	_CAT_MAGIC		0xFF88FF89
#define	_CAT_HDR_SIZE		sizeof (struct _cat_hdr)
#define	_CAT_SET_HDR_SIZE	sizeof (struct _cat_set_hdr)
#define	_CAT_MSG_HDR_SIZE	sizeof (struct _cat_msg_hdr)

struct _cat_hdr
{
#if	!defined(_LP64)
	long __hdr_magic;		/* must contain CAT_MAGIC */
#else
	int	__hdr_magic;		/* must contain CAT_MAGIC */
#endif
	int __nsets;		/* the number of sets in the catalogue */
	int __mem;		/* the size of the catalogue; the size	   */
				/* does not include the size of the header */
#if	!defined(_LP64)
	long __msg_hdr_offset;	/* the byte offset of the first message */
				/* header */
	long __msg_text_offset;	/* the byte offset of the message text area */
#else
	int __msg_hdr_offset;	/* the byte offset of the first message */
				/* header */
	int __msg_text_offset;	/* the byte offset of the message text area */
#endif
};

struct _cat_set_hdr
{
	int __set_no;	/* the set number; must be greater than 0;   */
			/* should be less than or equal to NL_SETMAX */
	int __nmsgs;	/* the number of msgs in the set */
	int __first_msg_hdr;	/* the index of the first message header in */
				/* the set; the value is not a byte offset, */
				/* it is a 0-based index		    */
};

struct _cat_msg_hdr
{
	int __msg_no;	/* the message number; must be greater than 0; */
			/* should be less than or equal to NL_MSGMAX   */
	int __msg_len;	/* the length of the message; must be greater */
			/* than or equal to zero; should be less than */
			/* or equal to NL_TEXTMAX */
	int __msg_offset; /* the byte offset of the message in the message */
			/* area; the offset is relative to the start of  */
			/* the message area, not to the start of the	 */
			/* catalogue.					 */
};

struct _nl_catd_struct {
	void	*__content;	/* mmaped catalogue contents */
	int	__size;		/* Size of catalogue file */
	int	__trust;	/* File is from a trusted location */
};

typedef struct _nl_catd_struct *nl_catd;
typedef int nl_item;	/* XPG3 Conformant for nl_langinfo(). */

/* The following is just for the compatibility between OSF and Solaris */
/* Need to be removed later */
typedef	nl_item	__nl_item;

int	catclose(nl_catd);
char	*catgets(nl_catd, int, int, const char *);
nl_catd catopen(const char *, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _NL_TYPES_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _NLIST_H
#define	_NLIST_H

#ifdef	__cplusplus
extern "C" {
#endif

struct nlist {
	char		*n_name;	/* symbol name */
	long		n_value;	/* value of symbol */
	short		n_scnum;	/* section number */
	unsigned short	n_type;		/* type and derived type */
	char		n_sclass;	/* storage class */
	char		n_numaux;	/* number of aux. entries */
};

extern int nlist(const char *, struct nlist *);

#ifdef	__cplusplus
}
#endif

#endif	/* _NLIST_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1994 by Sun Microsystems, Inc.
 */

/*
 * note.h:	interface for annotating source with info for tools
 *
 * NOTE is the default interface, but if the identifier NOTE is in use for
 * some other purpose, you may prepare a similar header file using your own
 * identifier, mapping that identifier to _NOTE.  Also, exported header
 * files should *not* use NOTE, since the name may already be in use in
 * a program's namespace.  Rather, exported header files should include
 * sys/note.h directly and use _NOTE.  For consistency, all kernel source
 * should use _NOTE.
 */

#ifndef	_NOTE_H
#define	_NOTE_H

#include <sys/note.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	NOTE _NOTE

#ifdef	__cplusplus
}
#endif

#endif	/* _NOTE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 *
 * NOTE:  The interfaces documented in this file may change in a minor
 *	  release.  It is intended that in the future a stronger committment
 *	  will be made to these interface definitions which will guarantee
 *	  them across minor releases.
 */

#ifndef _NSS_COMMON_H
#define	_NSS_COMMON_H

#include <synch.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The name-service switch
 * -----------------------
 *
 * From nsswitch.conf(5):
 *
 *	    The operating system uses a number of "databases" of information
 *	    about hosts, users (passwd/shadow), groups and so forth.  Data for
 *	    these can come from a variety of "sources":  host-names and
 *	    -addresses, for example, may be found in /etc/hosts, NIS, NIS+ or
 *	    DNS.  One or more sources may be used for each database;  the
 *	    sources and their lookup order are specified in the
 *	    /etc/nsswitch.conf file.
 *
 * The implementation of this consists of:
 *
 *    -	a "frontend" for each database, which provides a programming
 *	interface for that database [for example, the "passwd" frontend
 *	consists of getpwnam_r(), getpwuid_r(), getpwent_r(), setpwent(),
 *	endpwent(), and the old MT-unsafe routines getpwnam() and getpwuid()]
 *	and is implemented by calls to...
 *
 *    -	the common core of the switch (called the "switch" or "policy" engine);
 *	that determines what sources to use and when to invoke them.  This
 *	component works in conjunction with the name service switch (nscd).
 *	Usually nscd is the policy engine for an application lookup.
 *
 *    - Old style backend interfaces follow this pointer to function interface:
 *
 *	A "backend" exists for useful <database, source> pairs.  Each backend
 *	consists of whatever private data it needs and a set of functions
 *	that the switch engine may invoke on behalf of the frontend
 *	[e.g. the "nis" backend for "passwd" provides routines to lookup
 *	by name and by uid, as well as set/get/end iterator routines].
 *	The set of functions, and their expected arguments and results,
 *	constitutes a (database-specific) interface between a frontend and
 *	all its backends.  The switch engine knows as little as possible
 *	about these interfaces.
 *
 *	(The term "backend" is used ambiguously;  it may also refer to a
 *	particular instantiation of a backend, or to the set of all backends
 *	for a particular source, e.g. "the nis backend").
 *
 * This header file defines the interface between the switch engine and the
 * frontends and backends.  Interfaces between specific frontends and
 * backends are defined elsewhere;  many are in <nss_dbdefs.h>.
 * Most of these definitions are in the form of pointer to function
 * indicies used to call specific backend APIs.
 *
 *
 * Switch-engine outline
 * ---------------------
 *
 * Frontends may call the following routines in the switch engine:
 *
 *	nss_search() does getXXXbyYYY,	e.g. getpwnam_r(), getpwuid_r()
 *	nss_getent() does getXXXent,	e.g. getpwent_r()
 *	nss_setent() does setXXXent,	e.g. setpwent()
 *	nss_endent() does endXXXent,	e.g. endpwent()
 *	nss_delete() releases resources, in the style of endpwent().
 *
 * A getpwnam_r() call might proceed thus (with many details omitted):
 *
 *	(1)  getpwnam_r	fills in (getpwnam-specific) argument/result struct,
 *			calls nss_search(),
 *	(2)  nss_search queries the name service cache for an existing
 *			result via a call to _nsc_search().  if the cache
 *			(nscd) has a definitive answer skip to step 7
 *	(3)  nss_search	looks up configuration info, gets "passwd: files nis",
 *	(4)  nss_search	decides to try first source ("files"),
 *	 (a) nss_search	locates code for <"passwd", "files"> backend,
 *	 (b) nss_search	creates instance of backend,
 *	 (c) nss_search	calls get-by-name routine in backend,
 *			through a function pointer interface,
 *	 (d) backend	searches /etc/passwd, doesn't find the name,
 *			returns "not found" status to nss_search,
 *	(5)  nss_search	examines status and config info, decides to try
 *			next source ("nis"),
 *	 (a) nss_search	locates code for <"passwd", "nis"> backend,
 *	 (b) nss_search	creates instance of backend,
 *	 (c) nss_search	calls get-by-name routine in backend,
 *			through a function pointer interface,
 *	 (d) backend	searches passwd.byname, finds the desired entry,
 *			fills in the result part of the getpwnam-specific
 *			struct, returns "success" status to nss_search,
 *	(6)  nss_search	examines status and config info, decides to return
 *			to caller,
 *	(7)  getpwnam_r	extracts result from getpwnam-specific struct,
 *			returns to caller.
 *
 *
 * Data structures
 * ---------------
 *
 * Both databases and sources are represented by case-sensitive strings
 * (the same strings that appear in the configuration file).
 *
 * The switch engine maintains a per-frontend data structure so that the
 * results of steps (2), (a) and (b) can be cached.  The frontend holds a
 * handle (nss_db_root_t) to this structure and passes it in to the
 * nss_*() routines.
 *
 * The nss_setent(), nss_getent() and nss_endent() routines introduce another
 * variety of state (the current position in the enumeration process).
 * Within a single source, this information is maintained by private data
 * in the backend instance -- but, in the presence of multiple sources, the
 * switch engine must keep track of the current backend instance [e.g either
 * <"passwd", "files"> or <"passwd", "nis"> instances].  The switch engine
 * has a separate per-enumeration data structure for this;  again, the
 * frontend holds a handle (nss_getent_t) and passes it in, along with the
 * nss_db_root_t handle, to nss_setent(), nss_getent() and nss_endent().
 *
 *
 * Multithreading
 * --------------
 *
 * The switch engine takes care of locking;  frontends should be written to
 * be reentrant, and a backend instance may assume that all calls to it are
 * serialized.
 *
 * If multiple threads simultaneously want to use a particular backend, the
 * switch engine creates multiple backend instances (up to some limit
 * specified by the frontend).  Backends must of course lock any state that
 * is shared between instances, and must serialize calls to any MT-unsafe
 * code.
 *
 * The switch engine has no notion of per-thread state.
 *
 * Frontends can use the nss_getent_t handle to define the scope of the
 * enumeration (set/get/endXXXent) state:  a static handle gives global state
 * (which is what Posix has specified for the getXXXent_r routines), handles
 * in Thread-Specific Data give per-thread state, and handles on the stack
 * give per-invocation state.
 */

/*
 * Backend instances
 * -----------------
 *
 * As far as the switch engine is concerned, an instance of a backend is a
 * struct whose first two members are:
 *    -	A pointer to a vector of function pointers, one for each
 *	database-specific function,
 *    -	The length of the vector (an int), used for bounds-checking.
 * There are four well-known function slots in the vector:
 *	[0] is a destructor for the backend instance,
 *	[1] is the endXXXent routine,
 *	[2] is the setXXXent routine,
 *	[3] is the getXXXent routine.
 * Any other slots are database-specific getXXXbyYYY routines;  the frontend
 * specifies a slot-number to nss_search().
 *
 * The functions take two arguments:
 *    -	a pointer to the backend instance (like a C++ "this" pointer)
 *    -	a single (void *) pointer to the database-specific argument/result
 *	structure (the contents are opaque to the switch engine).
 * The four well-known functions ignore the (void *) pointer.
 *
 * Backend routines return the following status codes to the switch engine:
 *
 * SUCCESS, UNAVAIL, NOTFOUND, TRYAGAIN (these are the same codes that may
 * be specified in the config information;  see nsswitch.conf(5))
 *
 * The remaining conditions/errors are internally generated and if
 * necessary are translated, as to one of the above external errors,
 * usually NOTFOUND or UNAVAIL.
 *
 * NSS_NISSERVDNS_TRYAGAIN (should only be used by the NIS backend for
 * NIS server in DNS forwarding mode to indicate DNS server non-response).
 *
 * The policy component may return NSS_TRYLOCAL which signifies that nscd
 * is not going to process the request, and it should be performed locally.
 *
 * NSS_ERROR is a catchall for internal error conditions, errno will be set
 * to a system <errno.h> error that can help track down the problem if
 * it is persistent.  This error is the result of some internal error
 * condition and should not be seen during or exposed to aan application.
 * The error may be from the application side switch component or from the
 * nscd side switch component.
 *
 * NSS_ALTRETRY and NSS_ALTRESET are internal codes used by the application
 * side policy component and nscd to direct the policy component to
 * communicate to a per-user nscd if/when per-user authentication is enabled.
 *
 * NSS_NSCD_PRIV is a catchall for internal nscd errors or status
 * conditions.  This return code is not visible to applications.  nscd
 * may use this as a status flag and maintain additional error or status
 * information elsewhere in other private nscd data.  This status value
 * is for nscd private/internal use only.
 */

typedef enum {
	NSS_SUCCESS = 0,
	NSS_NOTFOUND = 1,
	NSS_UNAVAIL = 2,
	NSS_TRYAGAIN = 3,
	NSS_NISSERVDNS_TRYAGAIN = 4,
	NSS_TRYLOCAL = 5,
	NSS_ERROR = 6,
	NSS_ALTRETRY = 7,
	NSS_ALTRESET = 8,
	NSS_NSCD_PRIV = 9
} nss_status_t;

struct nss_backend;

typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args);

struct nss_backend {
	nss_backend_op_t	*ops;
	int			n_ops;
};
typedef struct nss_backend	nss_backend_t;
typedef int			nss_dbop_t;

#define	NSS_DBOP_DESTRUCTOR	0
#define	NSS_DBOP_ENDENT		1
#define	NSS_DBOP_SETENT		2
#define	NSS_DBOP_GETENT		3
#define	NSS_DBOP_next_iter	(NSS_DBOP_GETENT + 1)
#define	NSS_DBOP_next_noiter	(NSS_DBOP_DESTRUCTOR + 1)
#define	NSS_DBOP_next_ipv6_iter	(NSS_DBOP_GETENT + 3)

#define	NSS_LOOKUP_DBOP(instp, n)					    \
		(((n) >= 0 && (n) < (instp)->n_ops) ? (instp)->ops[n] : 0)

#define	NSS_INVOKE_DBOP(instp, n, argp)					    (\
		((n) >= 0 && (n) < (instp)->n_ops && (instp)->ops[n] != 0) \
		? (*(instp)->ops[n])(instp, argp)			    \
		: NSS_UNAVAIL)

/*
 * Locating and instantiating backends
 * -----------------------------------
 *
 * To perform step (a), the switch consults a list of backend-finder routines,
 * passing a <database, source> pair.
 *
 * There is a standard backend-finder;  frontends may augment or replace this
 * in order to, say, indicate that some backends are "compiled in" with the
 * frontend.
 *
 * Backend-finders return a pointer to a constructor function for the backend.
 * (or NULL if they can't find the backend).  The switch engine caches these
 * function pointers;  when it needs to perform step (b), it calls the
 * constructor function, which returns a pointer to a new instance of the
 * backend, properly initialized (or returns NULL).
 */

typedef	nss_backend_t		*(*nss_backend_constr_t)(const char *db_name,
							const char *src_name,
/* Hook for (unimplemented) args in nsswitch.conf */	const char *cfg_args);

struct nss_backend_finder {
	nss_backend_constr_t	(*lookup)
		(void *lkp_priv, const char *, const char *, void **del_privp);
	void			(*delete)
		(void *del_priv, nss_backend_constr_t);
	struct nss_backend_finder *next;
	void			*lookup_priv;
};

typedef struct nss_backend_finder nss_backend_finder_t;

extern nss_backend_finder_t	*nss_default_finders;

/*
 * Frontend parameters
 * -------------------
 *
 * The frontend must tell the switch engine:
 *    -	the database name,
 *    -	the compiled-in default configuration entry.
 * It may also override default values for:
 *    -	the database name to use when looking up the configuration
 *	information (e.g. "shadow" uses the config entry for "passwd"),
 *    -	a limit on the number of instances of each backend that are
 *	simultaneously active,
 *    - a limit on the number of instances of each backend that are
 *	simultaneously dormant (waiting for new requests),
 *    -	a flag that tells the switch engine to use the default configuration
 *	entry and ignore any other config entry for this database,
 *    -	backend-finders (see above)
 *    - a cleanup routine that should be called when these parameters are
 *	about to be deleted.
 *
 * In order to do this, the frontend includes a pointer to an initialization
 * function (nss_db_initf_t) in every nss_*() call.  When necessary (normally
 * just on the first invocation), the switch engine allocates a parameter
 * structure (nss_db_params_t), fills in the default values, then calls
 * the initialization function, which should update the parameter structure
 * as necessary.
 *
 * (This might look more natural if we put nss_db_initf_t in nss_db_root_t,
 * or abolished nss_db_initf_t and put nss_db_params_t in nss_db_root_t.
 * It's done the way it is for shared-library efficiency, namely:
 *	- keep the unshared data (nss_db_root_t) to a minimum,
 *	- keep the symbol lookups and relocations to a minimum.
 * In particular this means that non-null pointers, e.g. strings and
 * function pointers, in global data are a bad thing).
 */

enum nss_dbp_flags {
	NSS_USE_DEFAULT_CONFIG	= 0x1
};

struct nss_db_params {
	const char		*name;		/* Mandatory: database name */
	const char		*config_name;	/* config-file database name */
	const char		*default_config; /* Mandatory: default config */
	unsigned		max_active_per_src;
	unsigned		max_dormant_per_src;
	enum nss_dbp_flags	flags;
	nss_backend_finder_t	*finders;
	void			*private;	/* Not used by switch */
	void			(*cleanup)(struct nss_db_params *);
};

typedef struct nss_db_params nss_db_params_t;

typedef void (*nss_db_initf_t)(nss_db_params_t *);

/*
 * DBD param offsets in NSS2 nscd header.
 * Offsets are relative to beginning of dbd section.
 * 32 bit offsets should be sufficient, forever.
 * 0 offset == NULL
 * flags == nss_dbp_flags
 */
typedef struct nss_dbd {
	uint32_t	o_name;
	uint32_t	o_config_name;
	uint32_t	o_default_config;
	uint32_t	flags;
} nss_dbd_t;

/*
 * These structures are defined inside the implementation of the switch
 * engine;  the interface just holds pointers to them.
 */
struct nss_db_state;
struct nss_getent_context;

/*
 * Finally, the two handles that frontends hold:
 */

struct nss_db_root {
	struct nss_db_state	*s;
	mutex_t			lock;
};
typedef struct nss_db_root nss_db_root_t;
#define	NSS_DB_ROOT_INIT		{ 0, DEFAULTMUTEX }
#define	DEFINE_NSS_DB_ROOT(name)	nss_db_root_t name = NSS_DB_ROOT_INIT


typedef struct {
	struct nss_getent_context *ctx;
	mutex_t			lock;
} nss_getent_t;

#define	NSS_GETENT_INIT			{ 0, DEFAULTMUTEX }
#define	DEFINE_NSS_GETENT(name)		nss_getent_t name = NSS_GETENT_INIT

/*
 * Policy Engine Configuration
 * ---------------------------
 *
 * When nscd is running it can reconfigure it's internal policy engine
 * as well as advise an application's front-end and policy engine on how
 * respond optimally to results being returned from nscd.  This is done
 * through the policy engine configuration interface.
 */

typedef enum {
	NSS_CONFIG_GET,
	NSS_CONFIG_PUT,
	NSS_CONFIG_ADD,
	NSS_CONFIG_DELETE,
	NSS_CONFIG_LIST
} nss_config_op_t;

struct nss_config {
	char		*name;
	nss_config_op_t	cop;
	mutex_t		*lock;
	void		*buffer;
	size_t		length;
};
typedef struct nss_config nss_config_t;


extern nss_status_t nss_config(nss_config_t **, int);

extern nss_status_t nss_search(nss_db_root_t *, nss_db_initf_t,
			int search_fnum, void *search_args);
extern nss_status_t nss_getent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *,
			void *getent_args);
extern void nss_setent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *);
extern void nss_endent(nss_db_root_t *, nss_db_initf_t, nss_getent_t *);
extern void nss_delete(nss_db_root_t *);

extern nss_status_t nss_pack(void *, size_t, nss_db_root_t *,
			nss_db_initf_t, int, void *);
extern nss_status_t nss_pack_ent(void *, size_t, nss_db_root_t *,
			nss_db_initf_t, nss_getent_t *);
extern nss_status_t nss_unpack(void *, size_t, nss_db_root_t *,
			nss_db_initf_t, int, void *);
extern nss_status_t nss_unpack_ent(void *, size_t, nss_db_root_t *,
			nss_db_initf_t, nss_getent_t *, void *);

extern nss_status_t _nsc_search(nss_db_root_t *, nss_db_initf_t,
			int search_fnum, void *search_args);
extern nss_status_t _nsc_getent_u(nss_db_root_t *, nss_db_initf_t,
			nss_getent_t *, void *getent_args);
extern nss_status_t _nsc_setent_u(nss_db_root_t *, nss_db_initf_t,
			nss_getent_t *);
extern nss_status_t _nsc_endent_u(nss_db_root_t *, nss_db_initf_t,
			nss_getent_t *);


#ifdef	__cplusplus
}
#endif

#endif /* _NSS_COMMON_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Database-specific definitions for the getXXXbyYYY routines
 * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
 * Database-independent definitions are in <nss_common.h>
 *
 * Ideally, this is the only switch header file one would add things
 * to in order to support a new database.
 *
 * NOTE:  The interfaces documented in this file may change in a minor
 *	  release.  It is intended that in the future a stronger committment
 *	  will be made to these interface definitions which will guarantee
 *	  them across minor releases.
 */

#ifndef _NSS_DBDEFS_H
#define	_NSS_DBDEFS_H

#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <netdb.h>		/* MAXALIASES, MAXADDRS */
#include <limits.h>		/* LOGNAME_MAX */
#include <nss_common.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	NSS_INCLUDE_UNSAFE
#define	NSS_INCLUDE_UNSAFE	1	/* Build old, MT-unsafe interfaces, */
#endif	/* NSS_INCLUDE_UNSAFE */	/*  e.g. getpwnam (c.f. getpwnam_r) */

/*
 * Names of the well-known databases.
 */

#define	NSS_DBNAM_ALIASES	"aliases"	/* E-mail aliases, that is */
#define	NSS_DBNAM_AUTOMOUNT	"automount"
#define	NSS_DBNAM_BOOTPARAMS	"bootparams"
#define	NSS_DBNAM_ETHERS	"ethers"
#define	NSS_DBNAM_GROUP		"group"
#define	NSS_DBNAM_HOSTS		"hosts"
#define	NSS_DBNAM_IPNODES	"ipnodes"
#define	NSS_DBNAM_NETGROUP	"netgroup"
#define	NSS_DBNAM_NETMASKS	"netmasks"
#define	NSS_DBNAM_NETWORKS	"networks"
#define	NSS_DBNAM_PASSWD	"passwd"
#define	NSS_DBNAM_PRINTERS	"printers"
#define	NSS_DBNAM_PROJECT	"project"
#define	NSS_DBNAM_PROTOCOLS	"protocols"
#define	NSS_DBNAM_PUBLICKEY	"publickey"
#define	NSS_DBNAM_RPC		"rpc"
#define	NSS_DBNAM_SERVICES	"services"
#define	NSS_DBNAM_AUDITUSER	"audit_user"
#define	NSS_DBNAM_AUTHATTR	"auth_attr"
#define	NSS_DBNAM_EXECATTR	"exec_attr"
#define	NSS_DBNAM_PROFATTR	"prof_attr"
#define	NSS_DBNAM_USERATTR	"user_attr"

#define	NSS_DBNAM_TSOL_TP	"tnrhtp"
#define	NSS_DBNAM_TSOL_RH	"tnrhdb"
#define	NSS_DBNAM_TSOL_ZC	"tnzonecfg"

/* getspnam() et al use the "passwd" config entry but the "shadow" backend */
#define	NSS_DBNAM_SHADOW	"shadow"

/* The "compat" backend gets config entries for these pseudo-databases */
#define	NSS_DBNAM_PASSWD_COMPAT	"passwd_compat"
#define	NSS_DBNAM_GROUP_COMPAT	"group_compat"

/*
 * Default switch configuration, compiled into the front-ends.
 *
 * Absent good reasons to the contrary, this should be compatible with the
 * default /etc/nsswitch.conf file.
 */
#define	NSS_FILES_ONLY		"files"
#define	NSS_FILES_NS		"files nis"
#define	NSS_NS_FALLBACK		"nis [NOTFOUND=return] files"
#define	NSS_NS_ONLY		"nis"
#define	NSS_TSOL_FALLBACK	"files ldap"

#define	NSS_DEFCONF_ALIASES	NSS_FILES_NS
#define	NSS_DEFCONF_AUTOMOUNT	NSS_FILES_NS
#define	NSS_DEFCONF_BOOTPARAMS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_ETHERS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_GROUP	NSS_FILES_NS
#define	NSS_DEFCONF_HOSTS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_IPNODES	NSS_NS_FALLBACK
#define	NSS_DEFCONF_NETGROUP	NSS_NS_ONLY
#define	NSS_DEFCONF_NETMASKS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_NETWORKS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_PASSWD	NSS_FILES_NS
#define	NSS_DEFCONF_PRINTERS	"user files nis"
#define	NSS_DEFCONF_PROJECT	NSS_FILES_NS
#define	NSS_DEFCONF_PROTOCOLS	NSS_NS_FALLBACK
#define	NSS_DEFCONF_PUBLICKEY	NSS_FILES_NS
#define	NSS_DEFCONF_RPC		NSS_NS_FALLBACK
#define	NSS_DEFCONF_SERVICES	NSS_FILES_NS	/* speeds up byname() */

#define	NSS_DEFCONF_GROUP_COMPAT	NSS_NS_ONLY
#define	NSS_DEFCONF_PASSWD_COMPAT	NSS_NS_ONLY

#define	NSS_DEFCONF_ATTRDB	NSS_FILES_NS

#define	NSS_DEFCONF_AUDITUSER	NSS_DEFCONF_PASSWD
#define	NSS_DEFCONF_USERATTR	NSS_DEFCONF_PASSWD
#define	NSS_DEFCONF_AUTHATTR	NSS_DEFCONF_ATTRDB
#define	NSS_DEFCONF_PROFATTR	NSS_DEFCONF_ATTRDB
#define	NSS_DEFCONF_EXECATTR	NSS_DEFCONF_PROFATTR

#define	NSS_DEFCONF_TSOL_TP	NSS_TSOL_FALLBACK
#define	NSS_DEFCONF_TSOL_RH	NSS_TSOL_FALLBACK
#define	NSS_DEFCONF_TSOL_ZC	NSS_TSOL_FALLBACK

/*
 * Line-lengths that the "files" and "compat" backends will try to support.
 * It may be reasonable (even advisable) to use smaller values than these.
 */

#define	NSS_BUFSIZ		1024

#define	NSS_LINELEN_GROUP	((NSS_BUFSIZ) * 8)
#define	NSS_LINELEN_HOSTS	((NSS_BUFSIZ) * 8)
#define	NSS_LINELEN_IPNODES	((NSS_BUFSIZ) * 8)
#define	NSS_LINELEN_NETGROUP	((NSS_BUFSIZ) * 32)
#define	NSS_LINELEN_NETMASKS	NSS_BUFSIZ
#define	NSS_LINELEN_NETWORKS	NSS_BUFSIZ
#define	NSS_LINELEN_PASSWD	NSS_BUFSIZ
#define	NSS_LINELEN_PRINTERS	NSS_BUFSIZ
#define	NSS_LINELEN_PROJECT	((NSS_BUFSIZ) * 4)
#define	NSS_LINELEN_PROTOCOLS	NSS_BUFSIZ
#define	NSS_LINELEN_PUBLICKEY	NSS_BUFSIZ
#define	NSS_LINELEN_RPC		NSS_BUFSIZ
#define	NSS_LINELEN_SERVICES	NSS_BUFSIZ
#define	NSS_LINELEN_SHADOW	NSS_BUFSIZ
#define	NSS_LINELEN_ETHERS	NSS_BUFSIZ
#define	NSS_LINELEN_BOOTPARAMS	NSS_BUFSIZ

#define	NSS_LINELEN_ATTRDB	NSS_BUFSIZ

#define	NSS_LINELEN_AUDITUSER	NSS_LINELEN_ATTRDB
#define	NSS_LINELEN_AUTHATTR	NSS_LINELEN_ATTRDB
#define	NSS_LINELEN_EXECATTR	NSS_LINELEN_ATTRDB
#define	NSS_LINELEN_PROFATTR	NSS_LINELEN_ATTRDB
#define	NSS_LINELEN_USERATTR	NSS_LINELEN_ATTRDB

#define	NSS_MMAPLEN_EXECATTR	NSS_LINELEN_EXECATTR * 8

#define	NSS_LINELEN_TSOL	NSS_BUFSIZ

#define	NSS_LINELEN_TSOL_TP	NSS_LINELEN_TSOL
#define	NSS_LINELEN_TSOL_RH	NSS_LINELEN_TSOL
#define	NSS_LINELEN_TSOL_ZC	NSS_LINELEN_TSOL

/*
 * Reasonable defaults for 'buflen' values passed to _r functions.  The BSD
 * and SunOS 4.x implementations of the getXXXbyYYY() functions used hard-
 * coded array sizes;  the values here are meant to handle anything that
 * those implementations handled.
 * === These might more reasonably go in <pwd.h>, <netdb.h> et al
 */

#define	NSS_BUFLEN_GROUP	NSS_LINELEN_GROUP
#define	NSS_BUFLEN_HOSTS	\
	(NSS_LINELEN_HOSTS + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
#define	NSS_BUFLEN_IPNODES	\
	(NSS_LINELEN_IPNODES + (MAXALIASES + MAXADDRS + 2) * sizeof (char *))
#define	NSS_BUFLEN_NETGROUP	(MAXHOSTNAMELEN * 2 + LOGNAME_MAX + 3)
#define	NSS_BUFLEN_NETWORKS	NSS_LINELEN_NETWORKS	/* === ?  + 35 * 4 */
#define	NSS_BUFLEN_PASSWD	NSS_LINELEN_PASSWD
#define	NSS_BUFLEN_PROJECT	(NSS_LINELEN_PROJECT + 800 * sizeof (char *))
#define	NSS_BUFLEN_PROTOCOLS	NSS_LINELEN_PROTOCOLS	/* === ?  + 35 * 4 */
#define	NSS_BUFLEN_PUBLICKEY	NSS_LINELEN_PUBLICKEY
#define	NSS_BUFLEN_RPC		NSS_LINELEN_RPC		/* === ?  + 35 * 4 */
#define	NSS_BUFLEN_SERVICES	NSS_LINELEN_SERVICES	/* === ?  + 35 * 4 */
#define	NSS_BUFLEN_SHADOW	NSS_LINELEN_SHADOW
#define	NSS_BUFLEN_ETHERS	NSS_LINELEN_ETHERS
#define	NSS_BUFLEN_BOOTPARAMS	NSS_LINELEN_BOOTPARAMS

#define	NSS_BUFLEN_ATTRDB	NSS_LINELEN_ATTRDB

#define	NSS_BUFLEN_AUDITUSER	NSS_BUFLEN_ATTRDB
#define	NSS_BUFLEN_AUTHATTR	NSS_BUFLEN_ATTRDB
#define	NSS_BUFLEN_EXECATTR	NSS_BUFLEN_ATTRDB
#define	NSS_BUFLEN_PROFATTR	NSS_BUFLEN_ATTRDB
#define	NSS_BUFLEN_USERATTR	((NSS_BUFLEN_ATTRDB) * 8)

#define	NSS_BUFLEN_TSOL		NSS_LINELEN_TSOL
#define	NSS_BUFLEN_TSOL_TP	NSS_BUFLEN_TSOL
#define	NSS_BUFLEN_TSOL_RH	NSS_BUFLEN_TSOL
#define	NSS_BUFLEN_TSOL_ZC	NSS_BUFLEN_TSOL

/*
 * Default cache door buffer size (2x largest buffer)
 */

#define	NSS_BUFLEN_DOOR		((NSS_BUFSIZ) * 16)

/*
 * Arguments and results, passed between the frontends and backends for
 * the well-known databases.  The getXbyY_r() and getXent_r() routines
 * use a common format that is further described below;  other routines
 * use their own formats.
 */

/*
 * The nss_str2ent_t routine is the data marshaller for the nsswitch.
 * it converts 'native files' format into 'entry' format as part of the
 * return processing for a getXbyY interface.
 *
 * The nss_groupstr_t routine does the real work for any backend
 * that can supply a netgroup entry as a string in /etc/group format
 */
typedef int		(*nss_str2ent_t)(const char *in, int inlen,
				void *ent, char *buf, int buflen);

struct nss_groupsbymem;		/* forward definition */
typedef nss_status_t	(*nss_groupstr_t)(const char *instr, int inlen,
				struct nss_groupsbymem *);

/*
 * The initgroups() function [see initgroups(3c)] needs to find all the
 *   groups to which a given user belongs.  To do this it calls
 *   _getgroupsbymember(), which is part of the frontend for the "group"
 *   database.
 * We want the same effect as if we used getgrent_r() to enumerate the
 *   entire groups database (possibly from multiple sources), but getgrent_r()
 *   is too inefficient.  Most backends can do better if they know they're
 *   meant to scan all groups;  hence there's a separate backend operation,
 *   NSS_DBOP_GROUP_BYMEMBER, which uses the nss_groupsbymem struct.
 * Note that the normal return-value from such a backend, even when it
 *   successfully finds matching group entries, is NSS_NOTFOUND, because
 *   this tells the switch engine to keep searching in any more sources.
 *   In fact, the backends only return NSS_SUCCESS if they find enough
 *   matching entries that the gid_array is completely filled, in which
 *   case the switch engine should stop searching.
 * If the force_slow_way field is set, the backend should eschew any cached
 *   information (e.g. the YP netid.byname map or the NIS+ cred.org_dir table)
 *   and should instead grind its way through the group map/table/whatever.
 */

struct nss_groupsbymem {			/* For _getgroupsbymember() */
/* in: */
	const char	*username;
	gid_t		*gid_array;
	int		maxgids;
	int		force_slow_way;
	nss_str2ent_t	str2ent;
	nss_groupstr_t	process_cstr;

/* in_out: */
	int		numgids;
};

/*
 * The netgroup routines are handled as follows:
 *
 *   Policy decision:
 *	If netgroup A refers to netgroup B, both must occur in the same
 *	source (other choices give very confusing semantics).  This
 *	assumption is deeply embedded in the frontend and backends.
 *
 *    -	setnetgrent(), despite its name, is really a getXXXbyYYY operation:
 *	it takes a name and finds a netgroup with that name (see the
 *	nss_setnetgrent_args struct below).  The "result" that it returns
 *	to the frontend is an nss_backend_t for a pseudo-backend that allows
 *	one to enumerate the members of that netgroup.
 *
 *    -	getnetgrent() calls the 'getXXXent' function in the pseudo-backend;
 *	it doesn't go through the switch engine at all.  It uses the
 *	nss_getnetgrent_args struct below.
 *
 *    -	innetgr() is implemented on top of __multi_innetgr(), which replaces
 *	each (char *) argument of innetgr() with a counted vector of (char *).
 *	The semantics are the same as an OR of the results of innetgr()
 *	operations on each possible 4-tuple picked from the arguments, but
 *	it's possible to implement some cases more efficiently.  This is
 *	important for mountd, which used to read YP netgroup.byhost directly
 *	in order to determine efficiently whether a given host belonged to any
 *	one of a long list of netgroups.  Wildcarded arguments are indicated
 *	by a count of zero.
 *
 *    -	__multi_innetgr() uses the nss_innetgr_args struct.  A backend whose
 *	source contains at least one of the groups listed in the 'groups'
 *	vector will return NSS_SUCCESS and will set the 'status' field to
 *	indicate whether any 4-tuple was satisfied.  A backend will only
 *	return NSS_NOTFOUND if the source contained none of the groups
 *	listed in the 'groups' vector.
 */

enum nss_netgr_argn {		/* We need (machine, user, domain) triples */
	NSS_NETGR_MACHINE = 0,
	NSS_NETGR_USER = 1,
	NSS_NETGR_DOMAIN = 2,
	NSS_NETGR_N = 3
};

enum nss_netgr_status {		/* Status from setnetgrent, multi_innetgr */
	NSS_NETGR_FOUND = 0,
	NSS_NETGR_NO = 1,
	NSS_NETGR_NOMEM = 2
};

struct nss_setnetgrent_args {
/* in: */
	const char		*netgroup;
/* out: */
	nss_backend_t		*iterator;	/* <==== Explain */
};

struct nss_getnetgrent_args {
/* in: */
	char			*buffer;
	int			buflen;
/* out: */
	enum nss_netgr_status	status;
	char			*retp[NSS_NETGR_N];
};

typedef unsigned	nss_innetgr_argc;    /* 0 means wildcard */
typedef char **		nss_innetgr_argv;    /* === Do we really need these? */

struct nss_innetgr_1arg {
	nss_innetgr_argc	argc;
	nss_innetgr_argv	argv;
};

struct nss_innetgr_args {
/* in: */
	struct nss_innetgr_1arg	arg[NSS_NETGR_N];
	struct nss_innetgr_1arg groups;
/* out: */
	enum nss_netgr_status	status;
};

/* For NSS_DBOP_NETGROUP_BYNAME */
struct nss_netgrent {
	char	*netgr_name;
	char	*netgr_members;
};

/*
 * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
 *   getXXXbyYYY_r() and getXXXent_r() routines.  The (void *) value points to
 *   a struct of the appropriate type, e.g. struct passwd or struct hostent.
 *
 * The functions that allocate and free these structures do no locking at
 * all, since the routines that use them are inherently MT-unsafe anyway.
 */

typedef struct {
	void		*result;	/* "result" parameter to getXbyY_r() */
	char		*buffer;	/* "buffer"     "             "      */
	int		buflen;		/* "buflen"     "             "      */
} nss_XbyY_buf_t;

extern nss_XbyY_buf_t	*_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
extern void		 _nss_XbyY_buf_free(nss_XbyY_buf_t *);

#define	NSS_XbyY_ALLOC(bufpp, str_size, buf_size)		(\
	(*bufpp) == 0						\
	? (*bufpp) = _nss_XbyY_buf_alloc(str_size, buf_size)	\
	: (*bufpp))

#define	NSS_XbyY_FREE(bufpp)	(_nss_XbyY_buf_free(*bufpp), (*bufpp) = 0)

/*
 * The nss_XbyY_args_t struct contains all the information passed between
 * frontends and backends for the getXbyY_r() and getXent() routines,
 * including an nss_XbyY_buf_t and the lookup key (unused for getXXXent_r).
 *
 * The (*str2ent)() member converts a single XXXent from ASCII text to the
 * appropriate struct, storing any pointer data (strings, in_addrs, arrays
 * of these) in the buffer.  The ASCII text is a counted string (*not* a
 * zero-terminated string) whose length is specified by the instr_len
 * parameter.  The text is found at the address specified by instr and
 * the string is treated as readonly. buffer and instr must be non-
 * intersecting memory areas.
 *
 * With the exception of passwd, shadow and group, the text form for these
 * databases allows trailing comments and arbitrary whitespace.  The
 * corresponding str2ent routine assumes that comments, leading whitespace
 * and trailing whitespace have been stripped (and thus assumes that entries
 * consisting only of these have been discarded).
 *
 * The text entries for "rpc" and for the databases described in <netdb.h>
 * follow a common format (a canonical name with a possibly empty list
 * of aliases, and some other value), albeit with minor variations.
 * The function _nss_netdb_aliases() does most of the generic work involved
 * in parsing and marshalling these into the buffer.
 */

typedef union nss_XbyY_key {	/* No tag; backend should know what to expect */
	uid_t		uid;
	gid_t		gid;
	projid_t	projid;
	const char	*name;
	int		number;
	struct {
		int	net;
		int		type;
	}	netaddr;
	struct {
		const char	*addr;
		int		len;
		int		type;
	}	hostaddr;
	struct {
		union {
			const char	*name;
			int		port;
		}		serv;
		const char	*proto;
	}	serv;
	void *ether;
	struct {
		const char	*name;
		const char	*keytype;
	} pkey;
	struct {
		const char	*name;
		int		af_family;
		int		flags;
	}	ipnode;
	void *attrp;	/* for the new attr databases */
} nss_XbyY_key_t;


typedef int		(*nss_key2str_t)(void *buffer, size_t buflen,
				nss_XbyY_key_t *key, size_t *len);


typedef struct nss_XbyY_args {

/* IN */
	nss_XbyY_buf_t	buf;
	int		stayopen;
			/*
			 * Support for setXXXent(stayopen)
			 * Used only in hosts, protocols,
			 * networks, rpc, and services.
			 */
	nss_str2ent_t	str2ent;
	union nss_XbyY_key key;

/* OUT */
	void		*returnval;
	int		erange;
	int		h_errno;	/* For gethost*_r() */
	nss_status_t	status;		/* from the backend last called */
/* NSS2 */
	nss_key2str_t	key2str;	/* IN */
	size_t		returnlen;	/* OUT */

/* NSCD/DOOR data */

/* ... buffer arena follows... */
} nss_XbyY_args_t;



/*
 * nss/nscd v2 interface, packed buffer format
 *
 * A key component of the v2 name service switch is the redirection
 * of all activity to nscd for actual processing.  In the original
 * switch most activity took place in each application, and the nscd
 * cache component was an add-on optional interface.
 *
 * The nscd v1 format was a completely private interface that
 * implemented specific bufferiing formats on a per getXbyY API basis.
 *
 * The nss/nscd v2 interface uses a common header and commonalizes
 * the buffering format as consistently as possible.  The general rule
 * of thumb is that backends are required to assemble their results in
 * "files based" format [IE the format used on a per result basis as
 * returned by the files backend] and then call the standard str2ent
 * interface.  This is the original intended design as used in the files
 * and nis backends.
 *
 * The benefit of this is that the application side library can assemble
 * a request and provide a header and a variable length result buffer via
 * a doors API, and then the nscd side switch can assemble a a getXbyY
 * request providing the result buffer and a str2ent function that copies
 * but does not unpack the result.
 *
 * This results is returned back via the door, and unpacked using the
 * native library side str2ent interface.
 *
 * Additionally, the common header allows extensibility to add new
 * getXbyYs, putXbyYs or other maintenance APIs to/from nscd without
 * changing the existing "old style" backend interfaces.
 *
 * Finally new style getXbyY, putXbyY and backend interfaces can be
 * by adding new operation requests to the header, while old style
 * backwards compatability.
 */

/*
 * nss/nscd v2 callnumber definitions
 */

/*
 * callnumbers are separated by categories, such as:
 * application to nscd requests, nscd to nscd requests,
 * smf to nscd requests, etc.
 */

#define	NSCDV2CATMASK	(0xFF000000)
#define	NSCDV2CALLMASK	(0x00FFFFFF)

/*
 * nss/nscd v2 categories
 */

#define	NSCD_CALLCAT_APP	('a'<<24)
#define	NSCD_CALLCAT_N2N	('n'<<24)

/* nscd v2 app-> nscd callnumbers */

#define	NSCD_SEARCH	(NSCD_CALLCAT_APP|0x01)
#define	NSCD_SETENT	(NSCD_CALLCAT_APP|0x02)
#define	NSCD_GETENT	(NSCD_CALLCAT_APP|0x03)
#define	NSCD_ENDENT	(NSCD_CALLCAT_APP|0x04)
#define	NSCD_PUT	(NSCD_CALLCAT_APP|0x05)
#define	NSCD_GETHINTS	(NSCD_CALLCAT_APP|0x06)

/* nscd v2 SETENT cookie markers */

#define	NSCD_NEW_COOKIE		0
#define	NSCD_LOCAL_COOKIE	1

/* nscd v2 header revision */
/* treated as 0xMMMMmmmm MMMM - Major Rev, mmmm - Minor Rev */

#define	NSCD_HEADER_REV		0x00020000

/*
 * ptr/uint data type used to calculate shared nscd buffer struct sizes
 * sizes/offsets are arbitrarily limited to 32 bits for 32/64 compatibility
 * datatype is 64 bits for possible pointer storage and future use
 */

typedef uint64_t	nssuint_t;

/*
 * nscd v2 buffer layout overview
 *
 * The key interface to nscd moving forward is the doors interface
 * between applications and nscd (NSCD_CALLCAT_APP), and nscd and
 * it's children (NSCD_CALLCAT_N2N).
 *
 * Regardless of the interface used, the buffer layout is consistent.
 * The General Layout is:
 *   [nss_pheader_t][IN key][OUT data results]{extend results}
 *
 *   The header (nss_pheader_t) remains constant.
 *   Keys and key layouts vary between call numbers/requests
 *	NSCD_CALLCAT_APP use key layouts mimics/defines in nss_dbdefs.h
 *	NSCD_CALLCAT_NSN use layouts defined by nscd headers
 *   Data and data results vary between results
 *	NSCD_CALLCAT_APP return "file standard format" output buffers
 *	NSCD_CALLCAT_NSN return data defined by nscd headers
 *   extended results are optional and vary
 *
 */

/*
 * nss_pheader_t -- buffer header structure that contains switch data
 * "packed" by the client into a buffer suitable for transport over
 * nscd's door, and that can be unpacked into a native form within
 * nscd's switch.  Capable of packing and unpacking data ans results.
 *
 * NSCD_HEADER_REV: 0x00020000		16 x uint64 = (128 byte header)
 */

typedef struct {
	uint32_t	nsc_callnumber;		/* packed buffer request */
	uint32_t	nss_dbop;		/* old nss dbop */
	uint32_t	p_ruid;			/* real uid */
	uint32_t	p_euid;			/* effective uid */
	uint32_t	p_version;		/* 0xMMMMmmmm Major/minor */
	uint32_t	p_status;		/* nss_status_t */
	uint32_t	p_errno;		/* errno */
	uint32_t	p_herrno;		/* h_errno */
	nssuint_t	libpriv;		/* reserved (for lib/client) */
	nssuint_t	pbufsiz;		/* buffer size */
	nssuint_t	dbd_off;		/* IN: db desc off */
	nssuint_t	dbd_len;		/* IN: db desc len */
	nssuint_t	key_off;		/* IN: key off */
	nssuint_t	key_len;		/* IN: key len */
	nssuint_t	data_off;		/* OUT: data off */
	nssuint_t	data_len;		/* OUT: data len */
	nssuint_t	ext_off;		/* OUT: extended results off */
	nssuint_t	ext_len;		/* OUT: extended results len */
	nssuint_t	nscdpriv;		/* reserved (for nscd) */
	nssuint_t	reserved1;		/* reserved (TBD) */
} nss_pheader_t;

/*
 * nss_pnetgr_t -- packed offset structure for holding keys used
 * by innetgr (__multi_innetgr) key
 * Key format is:
 *    nss_pnetgr_t
 *     (nssuint_t)[machine_argc] offsets to strings
 *     (nssuint_t)[user_argc] offsets to strings
 *     (nssuint_t)[domain_argc] offsets to strings
 *     (nssuint_t)[groups_argc] offsets to strings
 *     machine,user,domain,groups strings
 */

typedef struct {
	uint32_t	machine_argc;
	uint32_t	user_argc;
	uint32_t	domain_argc;
	uint32_t	groups_argc;
	nssuint_t	machine_offv;
	nssuint_t	user_offv;
	nssuint_t	domain_offv;
	nssuint_t	groups_offv;
} nss_pnetgr_t;


/* status returned by the str2ent parsing routines */
#define	NSS_STR_PARSE_SUCCESS 0
#define	NSS_STR_PARSE_PARSE 1
#define	NSS_STR_PARSE_ERANGE 2

#define	NSS_XbyY_INIT(str, res, bufp, len, func)	(\
	(str)->buf.result = (res),			\
	(str)->buf.buffer = (bufp),			\
	(str)->buf.buflen = (len),			\
	(str)->stayopen  = 0,				\
	(str)->str2ent  = (func),			\
	(str)->key2str  = NULL,				\
	(str)->returnval = 0,				\
	(str)->returnlen = 0,				\
	(str)->h_errno    = 0,				\
	(str)->erange    = 0)

#define	NSS_XbyY_INIT_EXT(str, res, bufp, len, func, kfunc)	(\
	(str)->buf.result = (res),			\
	(str)->buf.buffer = (bufp),			\
	(str)->buf.buflen = (len),			\
	(str)->stayopen  = 0,				\
	(str)->str2ent  = (func),			\
	(str)->key2str  = (kfunc),			\
	(str)->returnval = 0,				\
	(str)->returnlen = 0,				\
	(str)->h_errno    = 0,				\
	(str)->erange    = 0)

#define	NSS_XbyY_FINI(str)	_nss_XbyY_fini(str)

#define	NSS_PACKED_CRED_CHECK(buf, ruid, euid)		(\
	((nss_pheader_t *)(buf))->p_ruid == (ruid) && \
	((nss_pheader_t *)(buf))->p_euid == (euid))

extern void		*_nss_XbyY_fini(nss_XbyY_args_t *);
extern char		**_nss_netdb_aliases(const char *, int, char *, int);
extern nss_status_t	nss_default_key2str(void *, size_t, nss_XbyY_args_t *,
					const char *, int, size_t *);
extern nss_status_t	nss_packed_arg_init(void *, size_t, nss_db_root_t *,
					nss_db_initf_t *, int *,
					nss_XbyY_args_t *);
extern nss_status_t	nss_packed_context_init(void *, size_t, nss_db_root_t *,
					nss_db_initf_t *, nss_getent_t **,
					nss_XbyY_args_t *);
extern void		nss_packed_set_status(void *, size_t, nss_status_t,
					nss_XbyY_args_t *);
extern nss_status_t	nss_packed_getkey(void *, size_t, char **, int *,
					nss_XbyY_args_t *);

/*
 * nss_dbop_t values for searches with various keys;  values for
 * destructor/endent/setent/getent are defined in <nss_common.h>
 */

/*
 * These are part of the "Over the wire" IE app->nscd getXbyY
 * op for well known getXbyY's.  Cannot use NSS_DBOP_X_Y directly
 * because NSS_DBOP_next_iter is NOT an incrementing counter value
 * it's a starting offset into an array value.
 */

#define	NSS_DBOP_X(x)			((x)<<16)
#define	NSS_DBOP_XY(x, y)		((x)|(y))

#define	NSS_DBOP_ALIASES	NSS_DBOP_X(1)
#define	NSS_DBOP_AUTOMOUNT	NSS_DBOP_X(2)
#define	NSS_DBOP_BOOTPARAMS	NSS_DBOP_X(3)
#define	NSS_DBOP_ETHERS		NSS_DBOP_X(4)
#define	NSS_DBOP_GROUP		NSS_DBOP_X(5)
#define	NSS_DBOP_HOSTS		NSS_DBOP_X(6)
#define	NSS_DBOP_IPNODES	NSS_DBOP_X(7)
#define	NSS_DBOP_NETGROUP	NSS_DBOP_X(8)
#define	NSS_DBOP_NETMASKS	NSS_DBOP_X(9)
#define	NSS_DBOP_NETWORKS	NSS_DBOP_X(10)
#define	NSS_DBOP_PASSWD		NSS_DBOP_X(11)
#define	NSS_DBOP_PRINTERS	NSS_DBOP_X(12)
#define	NSS_DBOP_PROJECT	NSS_DBOP_X(13)
#define	NSS_DBOP_PROTOCOLS	NSS_DBOP_X(14)
#define	NSS_DBOP_PUBLICKEY	NSS_DBOP_X(15)
#define	NSS_DBOP_RPC		NSS_DBOP_X(16)
#define	NSS_DBOP_SERVICES	NSS_DBOP_X(17)
#define	NSS_DBOP_AUDITUSER	NSS_DBOP_X(18)
#define	NSS_DBOP_AUTHATTR	NSS_DBOP_X(19)
#define	NSS_DBOP_EXECATTR	NSS_DBOP_X(20)
#define	NSS_DBOP_PROFATTR	NSS_DBOP_X(21)
#define	NSS_DBOP_USERATTR	NSS_DBOP_X(22)

#define	NSS_DBOP_GROUP_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_GROUP_BYGID		(NSS_DBOP_GROUP_BYNAME + 1)
#define	NSS_DBOP_GROUP_BYMEMBER		(NSS_DBOP_GROUP_BYGID  + 1)

#define	NSS_DBOP_PASSWD_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_PASSWD_BYUID		(NSS_DBOP_PASSWD_BYNAME + 1)

/* The "compat" backend requires that PASSWD_BYNAME == SHADOW_BYNAME */
/*   (it also requires that both use key.name to pass the username). */
#define	NSS_DBOP_SHADOW_BYNAME		(NSS_DBOP_PASSWD_BYNAME)

#define	NSS_DBOP_PROJECT_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_PROJECT_BYID		(NSS_DBOP_PROJECT_BYNAME + 1)

#define	NSS_DBOP_HOSTS_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_HOSTS_BYADDR		(NSS_DBOP_HOSTS_BYNAME + 1)

#define	NSS_DBOP_IPNODES_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_IPNODES_BYADDR		(NSS_DBOP_IPNODES_BYNAME + 1)

/*
 * NSS_DBOP_NAME_2ADDR
 * NSS_DBOP_ADDR_2NAME
 *                                : are defines for ipv6 api's
 */

#define	NSS_DBOP_NAME_2ADDR		(NSS_DBOP_next_ipv6_iter)
#define	NSS_DBOP_ADDR_2NAME		(NSS_DBOP_NAME_2ADDR + 1)

#define	NSS_DBOP_RPC_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_RPC_BYNUMBER		(NSS_DBOP_RPC_BYNAME + 1)

#define	NSS_DBOP_NETWORKS_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_NETWORKS_BYADDR		(NSS_DBOP_NETWORKS_BYNAME + 1)

#define	NSS_DBOP_SERVICES_BYNAME	(NSS_DBOP_next_iter)
#define	NSS_DBOP_SERVICES_BYPORT	(NSS_DBOP_SERVICES_BYNAME + 1)

#define	NSS_DBOP_PROTOCOLS_BYNAME	(NSS_DBOP_next_iter)
#define	NSS_DBOP_PROTOCOLS_BYNUMBER	(NSS_DBOP_PROTOCOLS_BYNAME + 1)

#define	NSS_DBOP_ETHERS_HOSTTON	(NSS_DBOP_next_noiter)
#define	NSS_DBOP_ETHERS_NTOHOST	(NSS_DBOP_ETHERS_HOSTTON + 1)

#define	NSS_DBOP_BOOTPARAMS_BYNAME	(NSS_DBOP_next_noiter)
#define	NSS_DBOP_NETMASKS_BYNET	(NSS_DBOP_next_noiter)

#define	NSS_DBOP_PRINTERS_BYNAME	(NSS_DBOP_next_iter)

/*
 * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
 * Note: _BYNAME is implemented only in "files" (for now).
 */
#define	NSS_DBOP_NETGROUP_IN		(NSS_DBOP_next_iter)
#define	NSS_DBOP_NETGROUP_SET		(NSS_DBOP_NETGROUP_IN  + 1)
#define	NSS_DBOP_NETGROUP_BYNAME	(NSS_DBOP_NETGROUP_SET + 1)

/*
 * The backend for getpublickey and getsecretkey (getkeys)
 */
#define	NSS_DBOP_KEYS_BYNAME		(NSS_DBOP_next_iter)

/*
 * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
 *   any getXXXbyYYY operations, just the usual destr/end/set/get ops,
 *   so needs no definitions here.
 */

#define	NSS_DBOP_ATTRDB_BYNAME		(NSS_DBOP_next_iter)

#define	NSS_DBOP_AUDITUSER_BYNAME	NSS_DBOP_ATTRDB_BYNAME
#define	NSS_DBOP_AUTHATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
#define	NSS_DBOP_EXECATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
#define	NSS_DBOP_EXECATTR_BYID		(NSS_DBOP_EXECATTR_BYNAME + 1)
#define	NSS_DBOP_EXECATTR_BYNAMEID	(NSS_DBOP_EXECATTR_BYID + 1)
#define	NSS_DBOP_PROFATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME
#define	NSS_DBOP_USERATTR_BYNAME	NSS_DBOP_ATTRDB_BYNAME

#define	NSS_DBOP_TSOL_TP_BYNAME		(NSS_DBOP_next_iter)
#define	NSS_DBOP_TSOL_RH_BYADDR		(NSS_DBOP_next_iter)
#define	NSS_DBOP_TSOL_ZC_BYNAME		(NSS_DBOP_next_iter)

/*
 * Used all over in the switch code. The best home for it I can think of.
 * Power-of-two alignments only.
 */
#define	ROUND_DOWN(n, align)	(((uintptr_t)n) & ~((align) - 1l))
#define	ROUND_UP(n, align)	ROUND_DOWN(((uintptr_t)n) + (align) - 1l, \
				(align))

#ifdef	__cplusplus
}
#endif

#endif /* _NSS_DBDEFS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * nss_netdir.h
 *
 * Defines structures that are shared between the OSNET-private
 * _get_hostserv_inetnetdir_byYY() interfaces and the public
 * interfaces gethostbyYY()/getservbyYY() and netdir_getbyYY().
 * Ideally, this header file should never be visible to developers
 * outside of the OSNET build.
 */

#ifndef _NSS_NETDIR_H
#define	_NSS_NETDIR_H

#ifdef	__cplusplus
extern "C" {
#endif

typedef enum {
	NSS_HOST,
	NSS_SERV,
	NETDIR_BY,
	NETDIR_BY_NOSRV,		/* bypass service lookup */
	NETDIR_BY6,
	NETDIR_BY_NOSRV6,		/* bypass service lookup */
	NSS_HOST6
} nss_netdir_op_t;

struct nss_netdirbyname_in {
	nss_netdir_op_t	op_t;
	union {
		struct nd_hostserv *nd_hs;
		union {
			struct {
				const char	*name;
				char	*buf;
				int	buflen;
			} host;
			struct {
				const char	*name;
				char	*buf;
				int	buflen;
				int	af_family;	/* for ipnode */
				int	flags;		/* for ipnode */
			} host6;
			struct {
				const char	*name;
				const char	*proto;
				char	*buf;
				int	buflen;
			} serv;
		} nss;
	} arg;
};

union nss_netdirbyname_out {
	struct nd_addrlist **nd_alist;
	union {
		struct {
			struct hostent *hent;
			int	*herrno_p;
		} host;
		struct servent *serv;
	} nss;
};

struct nss_netdirbyaddr_in {
	nss_netdir_op_t	op_t;
	union {
		struct netbuf *nd_nbuf;
		union {
			struct {
				const char	*addr;
				int	len;
				int	type;
				char	*buf;
				int	buflen;
			} host;
			struct {
				int	port;
				const char	*proto;
				char	*buf;
				int	buflen;
			} serv;
		} nss;
	} arg;
};

union nss_netdirbyaddr_out {
	struct nd_hostservlist **nd_hslist;
	union {
		struct {
			struct hostent *hent;
			int	*herrno_p;
		} host;
		struct servent *serv;
	} nss;
};

int __classic_netdir_getbyname(struct netconfig *,
		struct nd_hostserv *, struct nd_addrlist **);
int __classic_netdir_getbyaddr(struct netconfig *,
		struct nd_hostservlist **, struct netbuf *);
int _get_hostserv_inetnetdir_byname(struct netconfig *,
		struct nss_netdirbyname_in *, union nss_netdirbyname_out *);
int _get_hostserv_inetnetdir_byaddr(struct netconfig *,
		struct nss_netdirbyaddr_in *, union nss_netdirbyaddr_out *);
int __inet_netdir_options(struct netconfig *,
		int option, int fd, char *par);
struct netbuf *__inet_uaddr2taddr(struct netconfig *, char *);
char *__inet_taddr2uaddr(struct netconfig *, struct netbuf *);

#ifdef	__cplusplus
}
#endif

#endif /* _NSS_NETDIR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * nsswitch.h
 *
 * Low-level interface to the name-service switch.  The interface defined
 * in <nss_common.h> should be used in preference to this.
 *
 * This is a Project Private interface.  It may change in future releases.
 */

#ifndef _NSSWITCH_H
#define	_NSSWITCH_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	__NSW_CONFIG_FILE
#define	__NSW_CONFIG_FILE	"/etc/nsswitch.conf"
#endif
#define	__NSW_DEFAULT_FILE	"/etc/default/nss"

#define	__NSW_HOSTS_DB		"hosts"
#define	__NSW_PASSWD_DB		"passwd"
#define	__NSW_GROUP_DB		"group"
#define	__NSW_NETGROUP_DB	"netgroup"
#define	__NSW_NETWORKS_DB	"networks"
#define	__NSW_PROTOCOLS_DB	"protocols"
#define	__NSW_RPC_DB		"rpc"
#define	__NSW_SERVICES_DB	"services"
#define	__NSW_ETHERS_DB		"ethers"
#define	__NSW_BOOTPARAMS_DB	"bootparams"
#define	__NSW_NETMASKS_DB	"netmasks"
#define	__NSW_BROADCASTADDRS_DB	"broadcastaddrs"
#define	__NSW_MAIL_ALIASES_DB	"aliases"
#define	__NSW_AUDITUSER_DB	"audit_user"
#define	__NSW_AUTHATTR_DB	"auth_attr"
#define	__NSW_EXECATTR_DB	"exec_attr"
#define	__NSW_PROFATTR_DB	"prof_attr"
#define	__NSW_USERATTR_DB	"user_attr"
#define	__NSW_PROJECT_DB	"project"

#define	__NSW_STD_ERRS	4	/* number of reserved errors that follow */

#define	__NSW_SUCCESS	0	/* found the required data */
#define	__NSW_NOTFOUND	1	/* the naming service returned lookup failure */
#define	__NSW_UNAVAIL	2	/* could not call the naming service */
#define	__NSW_TRYAGAIN	3	/* bind error to suggest a retry */

typedef unsigned char action_t;
#define	__NSW_CONTINUE	0	/* the action is to continue to next service */
#define	__NSW_RETURN	1	/* the action is to return to the user */

#define	__NSW_STR_RETURN	"return"
#define	__NSW_STR_CONTINUE	"continue"
#define	__NSW_STR_SUCCESS	"success"
#define	__NSW_STR_NOTFOUND	"notfound"
#define	__NSW_STR_UNAVAIL	"unavail"
#define	__NSW_STR_TRYAGAIN	"tryagain"

/* prefix for all switch shared objects */
#define	__NSW_LIB	"nsw"

enum __nsw_parse_err {
	__NSW_CONF_PARSE_SUCCESS = 0,	/* parser found the required policy */
	__NSW_CONF_PARSE_NOFILE = 1,	/* the policy files does not exist */
	__NSW_CONF_PARSE_NOPOLICY = 2,	/* the required policy is not set */
					/* in the file */
	__NSW_CONF_PARSE_SYSERR = 3	/* system error in the parser */
};


struct __nsw_long_err {
	int nsw_errno;
	action_t action;
	struct __nsw_long_err *next;
};

struct __nsw_lookup {
	char *service_name;
	action_t actions[__NSW_STD_ERRS];
	struct __nsw_long_err *long_errs;
	struct __nsw_lookup *next;
};

struct __nsw_switchconfig {
	int vers;
	char *dbase;
	int num_lookups;
	struct __nsw_lookup *lookups;
};

#define	__NSW_ACTION(lkp, err)	\
	((lkp)->next == NULL ? \
		__NSW_RETURN \
	: \
		((err) >= 0 && (err) < __NSW_STD_ERRS ? \
			(lkp)->actions[err] \
		: \
			__nsw_extended_action(lkp, err)))

struct __nsw_switchconfig *__nsw_getconfig
	(const char *, enum __nsw_parse_err *);
int __nsw_freeconfig(struct __nsw_switchconfig *);
action_t __nsw_extended_action(struct __nsw_lookup *, int);

#ifdef	__cplusplus
}
#endif

#endif /* _NSSWITCH_H */
/*	$NetBSD: paths.h,v 1.39 2010/12/29 15:53:57 pooka Exp $	*/

/*
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)paths.h	8.1 (Berkeley) 6/2/93
 */

#ifndef _PATHS_H
#define	_PATHS_H

#ifdef __cplusplus
extern "C" {
#endif

#define	_PATH_DEFPATH	"/usr/ccs/bin:/usr/bin:/bin"
#define	_PATH_STDPATH   _PATH_DEFPATH ":/usr/sbin:/sbin"

#define	_PATH_BPF	"/dev/bpf"
#define	_PATH_BSHELL	"/usr/bin/sh"
#define	_PATH_CONSOLE	"/dev/console"
#define	_PATH_CSHELL	"/usr/bin/csh"
#define	_PATH_DEVNULL	"/dev/null"
#define	_PATH_FTPUSERS	"/etc/ftpusers"
#define	_PATH_KMEM	"/dev/kmem"
#define	_PATH_LOCALE	"/usr/share/locale"
#define	_PATH_MAILDIR	"/var/mail"
#define	_PATH_MAN	"/usr/share/man"
#define	_PATH_MEM	"/dev/mem"
#define	_PATH_NOLOGIN	"/etc/nologin"
#define	_PATH_RANDOM	"/dev/random"
#define	_PATH_SENDMAIL	"/usr/sbin/sendmail"
#define	_PATH_SHELLS	"/etc/shells"
#define	_PATH_TTY	"/dev/tty"
#define	_PATH_URANDOM	"/dev/urandom"
#define	_PATH_VI	"/usr/bin/vi"

/*
 * Provide trailing slash, since mostly used for building pathnames.
 */
#define	_PATH_DEV	"/dev/"
#define	_PATH_DEV_PTS	"/dev/pts/"
#define	_PATH_TMP	"/tmp/"
#define	_PATH_VARDB	"/var/db/"
#define	_PATH_VARRUN	"/var/run/"
#define	_PATH_VARTMP	"/var/tmp/"


#ifdef __cplusplus
}
#endif
#endif /* !_PATHS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_PFMT_H
#define	_PFMT_H

#include <stdio.h>
#ifndef va_args
#include <stdarg.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#define	MM_STD		0
#define	MM_NOSTD	0x100
#define	MM_GET		0
#define	MM_NOGET	0x200

#define	MM_ACTION	0x400

#define	MM_NOCONSOLE	0
#define	MM_CONSOLE	0x800

/* Classification */
#define	MM_NULLMC	0
#define	MM_HARD		0x1000
#define	MM_SOFT		0x2000
#define	MM_FIRM		0x4000
#define	MM_APPL		0x8000
#define	MM_UTIL		0x10000
#define	MM_OPSYS	0x20000

/* Most commonly used combinations */
#define	MM_SVCMD	MM_UTIL|MM_SOFT

#define	MM_ERROR	0
#define	MM_HALT		1
#define	MM_WARNING	2
#define	MM_INFO		3

int pfmt(FILE *, long, const char *, ...);
int lfmt(FILE *, long, const char *, ...);
int vpfmt(FILE *, long, const char *, va_list);
int vlfmt(FILE *, long, const char *, va_list);
const char *setcat(const char *);
int setlabel(const char *);
int addsev(int, const char *);

#define	DB_NAME_LEN		15
#define	MAXLABEL		25

#ifdef	__cplusplus
}
#endif

#endif	/* _PFMT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _PKGDEV_H
#define	_PKGDEV_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>

struct pkgdev {
	int			rdonly;
	int			mntflg;
	longlong_t	capacity; /* number of 512-blocks on device */
	char		*name;
	char		*dirname;
	char		*pathname;
	char		*mount;
	char		*fstyp;
	char		*cdevice;
	char		*bdevice;
	char		*norewind;
};

#ifdef	__cplusplus
}
#endif

#endif	/* _PKGDEV_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_PKGINFO_H
#define	_PKGINFO_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	PI_INSTALLED	0
#define	PI_PARTIAL	1
#define	PI_PRESVR4	2
#define	PI_UNKNOWN	3
#define	PI_SPOOLED	4

struct pkginfo {
	char	*pkginst;
	char	*name;
	char	*arch;
	char	*version;
	char	*vendor;
	char	*basedir;
	char	*catg;
	char	status;
};

extern char	*pkgdir;

extern char	*pkgparam(char *, char *);
extern int	pkginfo(struct pkginfo *, char *, ...),
		pkgnmchk(char *, char *, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _PKGINFO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_PKGLOCS_H
#define	_PKGLOCS_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	PKGLOC	"/var/sadm/pkg"
#define	PKGADM	"/var/sadm/install"
#define	PKGBIN	"/usr/sadm/install/bin"
#define	PKGSCR	"/usr/sadm/install/scripts"

#ifdef	__cplusplus
}
#endif

#endif	/* _PKGLOCS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_PKGSTRCT_H
#define	_PKGSTRCT_H

#include <time.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	CLSSIZ	64
#define	PKGSIZ	64
#define	ATRSIZ	64

#define	BADFTYPE	'?'
#define	BADMODE		(mode_t)ULONG_MAX
#define	BADOWNER	"?"
#define	BADGROUP	"?"
#define	BADMAJOR	(major_t)ULONG_MAX
#define	BADMINOR	(minor_t)ULONG_MAX
#define	BADCLASS	"none"
#define	BADINPUT	1 /* not EOF */
#define	BADCONT		(-1L)

extern char	*errstr;

struct ainfo {
	char	*local;
	mode_t	mode;
	char	owner[ATRSIZ+1];
	char	group[ATRSIZ+1];
	major_t	major;
	minor_t	minor;
};

struct cinfo {
	long		cksum;
	fsblkcnt_t	size;
	time_t		modtime;
};

struct pinfo {
	char	status;
	char	pkg[PKGSIZ+1];
	char	editflag;
	char	aclass[ATRSIZ+1];
	struct pinfo
		*next;
};

struct cfent {
	short	volno;
	char	ftype;
	char	pkg_class[CLSSIZ+1];
	int	pkg_class_idx;
	char	*path;
	struct ainfo ainfo;
	struct cinfo cinfo;
	short	npkgs;
	struct pinfo
		*pinfo;
};

/* averify() & cverify() error codes */
#define	VE_EXIST	0x0001
#define	VE_FTYPE	0x0002
#define	VE_ATTR		0x0004
#define	VE_CONT		0x0008
#define	VE_FAIL		0x0010
#define	VE_TIME		0x0020

#ifdef	__cplusplus
}
#endif

#endif	/* _PKGSTRCT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_PKGTRANS_H
#define	_PKGTRANS_H

#ifdef	__cplusplus
extern "C" {
#endif

#define	PT_OVERWRITE	0x01
#define	PT_INFO_ONLY	0x02
#define	PT_RENAME	0x04
#define	PT_DEBUG	0x08
#define	PT_SILENT	0x10
#define	PT_ODTSTREAM	0x40

#ifdef	__cplusplus
}
#endif

#endif	/* _PKGTRANS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_POLL_H
#define	_POLL_H

/*
 * Poll system call interface definitions.
 */

#include <sys/feature_tests.h>
#include <sys/poll.h>
#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
#include <time.h>
#include <signal.h>
#endif	/* defined(__EXTENSIONS__) ... */

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)

extern int ppoll(struct pollfd *_RESTRICT_KYWD, nfds_t,
    const struct timespec *_RESTRICT_KYWD, const sigset_t *_RESTRICT_KYWD);

#endif	/* defined(__EXTENSIONS__) ... */

#ifdef __cplusplus
}
#endif

#endif	/* _POLL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_PORT_H
#define	_PORT_H

#include <sys/types.h>
#include <sys/port.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * ports API
 */

int	port_create(void);
int	port_associate(int, int, uintptr_t, int, void *);
int	port_dissociate(int, int, uintptr_t);
int	port_send(int, int, void *);
int	port_sendn(int [], int [], uint_t, int, void *);
int	port_get(int, port_event_t *, struct timespec *);
int	port_getn(int, port_event_t [], uint_t, uint_t *, struct timespec *);
int	port_alert(int, int, int, void *);

#ifdef	__cplusplus
}
#endif

#endif	/* _PORT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_PRIV_H_
#define	_PRIV_H_

#include <sys/priv.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	PRIV_STR_PORT		0x00			/* portable output */
#define	PRIV_STR_LIT		0x01			/* literal output */
#define	PRIV_STR_SHORT		0x02			/* shortest output */

#define	PRIV_ALLSETS		((priv_ptype_t)0)	/* for priv_set() */

/*
 * library functions prototype.
 */

extern int setppriv(priv_op_t, priv_ptype_t, const priv_set_t *);
extern int getppriv(priv_ptype_t, priv_set_t *);
extern int setpflags(uint_t, uint_t);
extern uint_t getpflags(uint_t);
extern const priv_impl_info_t *getprivimplinfo(void);

extern int priv_set(priv_op_t, priv_ptype_t, ...);
extern boolean_t priv_ineffect(const char *);
extern priv_set_t *priv_str_to_set(const char *, const char *, const char **);
extern char *priv_set_to_str(const priv_set_t *, char, int);

extern int priv_getbyname(const char *);
extern const char *priv_getbynum(int);
extern int priv_getsetbyname(const char *);
extern const char *priv_getsetbynum(int);
extern char *priv_gettext(const char *);

extern priv_set_t *priv_allocset(void);
extern void priv_freeset(priv_set_t *);

extern void priv_emptyset(priv_set_t *);
extern void priv_basicset(priv_set_t *);
extern void priv_fillset(priv_set_t *);
extern boolean_t priv_isemptyset(const priv_set_t *);
extern boolean_t priv_isfullset(const priv_set_t *);
extern boolean_t priv_isequalset(const priv_set_t *, const priv_set_t *);
extern boolean_t priv_issubset(const priv_set_t *, const priv_set_t *);
extern void priv_intersect(const priv_set_t *, priv_set_t *);
extern void priv_union(const priv_set_t *, priv_set_t *);
extern void priv_inverse(priv_set_t *);
extern int priv_addset(priv_set_t *, const char *);
extern void priv_copyset(const priv_set_t *, priv_set_t *);
extern int priv_delset(priv_set_t *, const char *);
extern boolean_t priv_ismember(const priv_set_t *, const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _PRIV_H_ */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * This is a private header file.  The interfaces in this header are
 * subject to change or removal without notice.
 * The Sun classification is "Project Private".
 */

#ifndef	_PRIV_UTILS_H
#define	_PRIV_UTILS_H

#include <priv.h>


#ifdef	__cplusplus
extern "C" {
#endif

#define	PU_RESETGROUPS		0x0001	/* Remove supplemental groups */
#define	PU_LIMITPRIVS		0x0002	/* L=P */
#define	PU_INHERITPRIVS		0x0004	/* I=P */
#define	PU_CLEARLIMITSET	0x0008	/* L=0 */

/*
 * Should be run at the start of a set-uid root program;
 * if the effective uid == 0 and the real uid != 0,
 * the specified privileges X are assigned as follows:
 *
 * P = I + X + B (B added insofar allowable from L)
 * E = I
 * (i.e., the requested privileges are dormant, not active)
 * Then resets all uids to the invoking uid; no-op if euid == uid == 0.
 *
 * flags: PU_LIMITPRIVS, PU_CLEARLIMITSET, PU_CLEARINHERITABLE
 *
 * Caches the required privileges for use by __priv_bracket().
 *
 */
extern int __init_suid_priv(int, ...);

/*
 * After calling __init_suid_priv we can __priv_bracket(PRIV_ON) and
 * __priv_bracket(PRIV_OFF) and __priv_relinquish to get rid of the
 * privileges forever.
 */
extern int __priv_bracket(priv_op_t);
extern void __priv_relinquish(void);

/*
 * Runs at the start of a daemon, assuming euid=uid=0.
 *
 * P = E = B + X
 *
 * Then resets uids.
 *
 * Flags: all
 *
 */
extern int __init_daemon_priv(int, uid_t, gid_t, ...);

/*
 * Runs after the daemon is initialized, and gives up the privileges
 * passed in as argument because they are no longer needed.
 * Reenables core dumps.
 */
extern void __fini_daemon_priv(const char *, ...);

#ifdef	__cplusplus
}
#endif

#endif	/* _PRIV_UTILS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _PROC_SERVICE_H
#define	_PROC_SERVICE_H

/*
 *  Description:
 *	Types, global variables, and function definitions for provider
 * of import functions for users of libc_db and librtld_db.
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <sys/procfs_isa.h>
#include <sys/lwp.h>
#include <sys/auxv.h>
#include <elf.h>
#if defined(__i386) || defined(__amd64)	/* for struct ssd */
#include <sys/segments.h>
#include <sys/sysi86.h>
#endif


typedef unsigned long	psaddr_t;

typedef enum {
	PS_OK,		/* generic "call succeeded" */
	PS_ERR,		/* generic error */
	PS_BADPID,	/* bad process handle */
	PS_BADLID,	/* bad lwp identifier */
	PS_BADADDR,	/* bad address */
	PS_NOSYM,	/* p_lookup() could not find given symbol */
	PS_NOFREGS,	/* FPU register set not available for given lwp */
	PS_NOXREGS	/* extended register set not available for given lwp */
} ps_err_e;

struct ps_prochandle;

/*
 * See <sys/procfs_isa.h> for possible values of data_model.
 */
extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model);

/*
 * Special values for 'object_name' to refer to certain well-known objects.
 */
#define	PS_OBJ_EXEC	((const char *)0x0)	/* the executable file */
#define	PS_OBJ_LDSO	((const char *)0x1)	/* the dynamic linker */

extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *,
	const char *object_name, const char *sym_name, psaddr_t *sym_addr);

#ifdef _LP64
typedef	Elf64_Sym	ps_sym_t;
#else
typedef	Elf32_Sym	ps_sym_t;
#endif
extern ps_err_e ps_pglobal_sym(struct ps_prochandle *,
	const char *object_name, const char *sym_name, ps_sym_t *sym);

/*
 * To read and write the process's address space.
 */
extern ps_err_e ps_pread(struct ps_prochandle *,
			psaddr_t, void *, size_t);
extern ps_err_e ps_pwrite(struct ps_prochandle *,
			psaddr_t, const void *, size_t);
/*
 * The following four functions can be implemented as simple aliases for
 * the corresponding primary two functions above (#pragma weak ...).
 * They are artifacts of history that must be maintained.
 */
extern ps_err_e ps_pdread(struct ps_prochandle *,
			psaddr_t, void *, size_t);
extern ps_err_e ps_pdwrite(struct ps_prochandle *,
			psaddr_t, const void *, size_t);
extern ps_err_e ps_ptread(struct ps_prochandle *,
			psaddr_t, void *, size_t);
extern ps_err_e ps_ptwrite(struct ps_prochandle *,
			psaddr_t, const void *, size_t);

extern ps_err_e ps_pstop(struct ps_prochandle *);
extern ps_err_e ps_pcontinue(struct ps_prochandle *);
extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t);
extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t);

extern ps_err_e ps_lgetregs(struct ps_prochandle *,
			lwpid_t, prgregset_t);
extern ps_err_e ps_lsetregs(struct ps_prochandle *,
			lwpid_t, const prgregset_t);
extern ps_err_e ps_lgetfpregs(struct ps_prochandle *,
			lwpid_t, prfpregset_t *);
extern ps_err_e ps_lsetfpregs(struct ps_prochandle *,
			lwpid_t, const prfpregset_t *);

extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *);
extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t);
extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t);

#if defined(__i386) || defined(__amd64)
extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *);
#endif

extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **);
extern ps_err_e ps_pbrandname(struct ps_prochandle *, char *, size_t);

extern ps_err_e ps_kill(struct ps_prochandle *, int sig);
extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *,
			lwpid_t, psaddr_t go_addr, psaddr_t stop_addr);

extern void	ps_plog(const char *fmt, ...);

#ifdef __cplusplus
}
#endif

#endif	/* _PROC_SERVICE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1996, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_PROCFS_H
#define	_PROCFS_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * This include file forces the new structured /proc definitions.
 * The structured /proc interface is the preferred API, and the
 * older ioctl()-based /proc interface will be removed in a future
 * version of Solaris.
 */
#ifdef	_STRUCTURED_PROC
#undef	_STRUCTURED_PROC
#endif
#define	_STRUCTURED_PROC	1

#include <sys/procfs.h>

/*
 * libproc API
 */

#ifdef	__cplusplus
}
#endif

#endif	/* _PROCFS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef	_PROF_ATTR_H
#define	_PROF_ATTR_H

#ifdef	__cplusplus
extern "C" {
#endif


#include <sys/types.h>
#include <secdb.h>


#define	PROFATTR_FILENAME		"/etc/security/prof_attr"
#define	PROFATTR_DB_NAME		"prof_attr.org_dir"
#define	PROFATTR_DB_NCOL		5	/* total columns */
#define	PROFATTR_DB_NKEYCOL		1	/* total searchable columns */
#define	PROFATTR_DB_TBLT		"prof_attr_tbl"
#define	PROFATTR_NAME_DEFAULT_KW	"nobody"

#define	PROFATTR_COL0_KW		"name"
#define	PROFATTR_COL1_KW		"res1"
#define	PROFATTR_COL2_KW		"res2"
#define	PROFATTR_COL3_KW		"desc"
#define	PROFATTR_COL4_KW		"attr"

#define	PROFILE_STOP			"Stop"

#define	DEF_PROF			"PROFS_GRANTED="
#define	DEF_CONSUSER			"CONSOLE_USER="

#define	MAXPROFS			4096

/*
 * indices of searchable columns
 */
#define	PROFATTR_KEYCOL0		0	/* name */


/*
 * Key words used in the prof_attr database
 */
#define	PROFATTR_AUTHS_KW		"auths"
#define	PROFATTR_PROFS_KW		"profiles"
#define	PROFATTR_PRIVS_KW		"privs"


/*
 * Nsswitch representation of profile attributes.
 */

typedef struct profstr_s {
	char   *name;	/* proforization name */
	char   *res1;	/* RESERVED */
	char   *res2;	/* RESERVED */
	char   *desc;	/* description */
	char   *attr;	/* string of key-value pair attributes */
} profstr_t;

typedef struct profattr_s {
	char   *name;	/* proforization name */
	char   *res1;	/* RESERVED */
	char   *res2;	/* RESERVED */
	char   *desc;	/* description */
	kva_t  *attr;	/* array of key-value pair attributes */
} profattr_t;

extern profattr_t *getprofnam(const char *);
extern profattr_t *getprofattr(void);
extern void getproflist(const char *, char **, int *);
extern void setprofattr(void);
extern void endprofattr(void);
extern void free_profattr(profattr_t *);
extern void free_proflist(char **, int);

#ifdef __cplusplus
}
#endif

#endif	/* _PROF_ATTR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _PROJECT_H
#define	_PROJECT_H

#include <stdio.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	PROJF_PATH	"/etc/project"	/* pathname of the "project" file */
#define	PROJNAME_MAX	64		/* maximum project name size */
#define	PROJECT_BUFSZ	4096		/* default buffer size */

#define	SETPROJ_ERR_TASK	(-1)	/* error creating new task */
#define	SETPROJ_ERR_POOL	(-2)	/* error binding to pool */

struct project {
	char	*pj_name;	/* name of the project */
	projid_t pj_projid;	/* numerical project id */
	char	*pj_comment;	/* project description */
	char	**pj_users;	/* vector of pointers to project user names */
	char	**pj_groups;	/* vector of pointers to project group names */
	char	*pj_attr;	/* project attributes string */
};

extern void setprojent(void);
extern void endprojent(void);
extern struct project *getprojent(struct project *, void *, size_t);
extern struct project *getprojbyname(const char *,
    struct project *, void *, size_t);
extern struct project *getprojbyid(projid_t, struct project *, void *, size_t);
extern struct project *getdefaultproj(const char *,
    struct project *, void *, size_t);
extern struct project *fgetprojent(FILE *, struct project *, void *, size_t);
extern int inproj(const char *, const char *, void *, size_t);
extern projid_t getprojidbyname(const char *);

extern projid_t getprojid(void);

extern projid_t setproject(const char *, const char *, int);
extern int project_walk(int (*)(projid_t, void *), void *);

#ifdef	__cplusplus
}
#endif

#endif /* _PROJECT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/* Copyright (c) 1983,1984,1985,1986,1987,1988,1989  AT&T. */
/*	All rights reserved. */

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _PROTOCOLS_DUMPRESTORE_H
#define	_PROTOCOLS_DUMPRESTORE_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * This header file defines two different versions of the
 * ufsdump/ufsrestore interface.  If the defined constant
 * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in
 * this header file will support backups of more than 2 terabytes
 * of data.
 *
 * In the old format (the format that only supports dumps
 * of less than 2 terabytes), TP_BSIZE is the size of file blocks
 * on the dump tapes.
 * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
 *
 * In the new format, tp_bsize is used to store the
 * tape block size, which is variable.  The tape block size
 * is like 'fragsize', in that 'c_tapea' in each tape record
 * contains the 'tape block record' number in a signed int.
 * We set TP_BSIZE_MAX to 65536, which will handle 128TB
 * of data.  The new format is indicated by a magic number
 * in the tape header of MTB_MAGIC.  The new format is only
 * used when the size of the backup exceeds 2 TB.  If the
 * backup can be stored in less thatn 2 TB, ufsdump still
 * uses the format indicated by the NFS_MAGIC magic number.
 * Therefore, backups of less than 2 TB are still readable
 * by earlier versions of ufsrestore.
 *
 * NTREC is the number of TP_BSIZE blocks that are written
 * in each tape record. HIGHDENSITYTREC is the number of
 * TP_BSIZE blocks that are written in each tape record on
 * 6250 BPI or higher density tapes.  CARTRIDGETREC is the
 * number of TP_BSIZE (or tp_bsize) blocks that are written
 * in each tape record on cartridge tapes.
 *
 * TP_NINDIR is the number of indirect pointers in a TS_INODE
 * or TS_ADDR record. Note that it must be a power of two.
 *
 */
#define	TP_BSIZE_MAX	65536
#define	TP_BSIZE_MIN	1024
#define	ESIZE_SHIFT_MAX	6	/* shift TP_BSIZE_MIN to TP_BSIZE_MAX */

#ifdef SUPPORTS_MTB_TAPE_FORMAT
#define	TP_BUFSIZE	TP_BSIZE_MAX
extern	int32_t		tp_bsize;
#else
#define	TP_BSIZE	1024
#define	TP_BUFSIZE	TP_BSIZE
#endif /* SUPPORTS_MTB_TAPE_FORMAT */

#define	NTREC		10
#define	HIGHDENSITYTREC	32
#define	CARTRIDGETREC	63
#define	TP_NINDIR	(TP_BSIZE_MIN/2)
#define	TP_NINOS	(TP_NINDIR / sizeof (long))
#define	LBLSIZE		16
#define	NAMELEN		64

#define	OFS_MAGIC	(int)60011
#define	NFS_MAGIC	(int)60012
#define	MTB_MAGIC	(int)60013
#define	CHECKSUM	(int)84446

union u_data {
	char	s_addrs[TP_NINDIR];	/* 1 => data; 0 => hole in inode */
	int32_t	s_inos[TP_NINOS];	/* starting inodes on tape */
};

union u_shadow {
	struct s_nonsh {
		int32_t	c_level;		/* level of this dump */
		char	c_filesys[NAMELEN];	/* dumpped file system name */
		char	c_dev[NAMELEN];		/* name of dumpped device */
		char	c_host[NAMELEN];	/* name of dumpped host */
	} c_nonsh;
	char    c_shadow[1];
};

/* if you change anything here, be sure to change normspcl in byteorder.c */

extern union u_spcl {
	char dummy[TP_BUFSIZE];
	struct	s_spcl {
		int32_t	c_type;		    /* record type (see below) */
		time32_t c_date;	    /* date of previous dump */
		time32_t c_ddate;	    /* date of this dump */
		int32_t	c_volume;	    /* dump volume number */
		daddr32_t c_tapea;	    /* logical block of this record */
		ino32_t	c_inumber;	    /* number of inode */
		int32_t	c_magic;	    /* magic number (see above) */
		int32_t	c_checksum;	    /* record checksum */
		struct	dinode	c_dinode;   /* ownership and mode of inode */
		int32_t	c_count;	    /* number of valid c_addr entries */
		union	u_data c_data;	    /* see union above */
		char	c_label[LBLSIZE];   /* dump label */
		union	u_shadow c_shadow;  /* see union above */
		int32_t	c_flags;	    /* additional information */
		int32_t	c_firstrec;	    /* first record on volume */
#ifdef SUPPORTS_MTB_TAPE_FORMAT
		int32_t	c_tpbsize;	    /* tape block size */
		int32_t	c_spare[31];	    /* reserved for future uses */
#else
		int32_t c_spare[32];
#endif /* SUPPORTS_MTB_TAPE_FORMAT */
	} s_spcl;
} u_spcl;
#define	spcl u_spcl.s_spcl
#define	c_addr c_data.s_addrs
#define	c_inos c_data.s_inos
#define	c_level c_shadow.c_nonsh.c_level
#define	c_filesys c_shadow.c_nonsh.c_filesys
#define	c_dev c_shadow.c_nonsh.c_dev
#define	c_host c_shadow.c_nonsh.c_host

/*
 * special record types
 */
#define	TS_TAPE		1	/* dump tape header */
#define	TS_INODE	2	/* beginning of file record */
#define	TS_ADDR		4	/* continuation of file record */
#define	TS_BITS		3	/* map of inodes on tape */
#define	TS_CLRI		6	/* map of inodes deleted since last dump */
#define	TS_END		5	/* end of volume marker */
#define	TS_EOM		7	/* floppy EOM - restore compat w/ old dump */

/*
 * flag values
 */
#define	DR_NEWHEADER	1	/* new format tape header */
#define	DR_INODEINFO	2	/* header contains starting inode info */
#define	DR_REDUMP	4	/* dump contains recopies of active files */
#define	DR_TRUEINC	8	/* dump is a "true incremental"	*/
#define	DR_HASMETA	16	/* metadata in this header */



#define	DUMPOUTFMT	"%-32s %c %s"		/* for printf */
						/* name, incno, ctime(date) */
#define	DUMPINFMT	"%258s %c %128[^\n]\n"	/* inverse for scanf */

#ifdef __cplusplus
}
#endif

#endif	/* !_PROTOCOLS_DUMPRESTORE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

/*
 * Routing Information Protocol for IPv6 (RIPng)
 * as specfied by RFC 2080.
 */

#ifndef _PROTOCOLS_RIPNGD_H
#define	_PROTOCOLS_RIPNGD_H

#ifdef	__cplusplus
extern "C" {
#endif

struct netinfo6 {
	struct in6_addr	rip6_prefix;		/* destination prefix */
	uint16_t	rip6_route_tag;		/* route tag */
	uint8_t		rip6_prefix_length;	/* destination prefix length */
	uint8_t		rip6_metric;		/* cost of route */
};

struct rip6 {
	uint8_t		rip6_cmd;		/* request/response */
	uint8_t		rip6_vers;		/* protocol version # */
	uint16_t	rip6_res1;		/* pad to 32-bit boundary */
	struct netinfo6	rip6_nets[1];		/* variable length... */
};

#define	RIPVERSION6		1

/*
 * Packet types.
 */
#define	RIPCMD6_REQUEST		1	/* want info - from suppliers */
#define	RIPCMD6_RESPONSE	2	/* responding to request */

#define	IPPORT_ROUTESERVER6	521

#ifdef	__cplusplus
}
#endif

#endif	/* _PROTOCOLS_RIPNGD_H */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright (c) 1983, 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgment:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Routing Information Protocol
 *
 * Derived from Xerox NS Routing Information Protocol
 * by changing 32-bit net numbers to sockaddr's and
 * padding stuff to 32-bit boundaries.
 */

#ifndef _PROTOCOLS_ROUTED_H
#define	_PROTOCOLS_ROUTED_H

#ifdef	__cplusplus
extern "C" {
#endif

/* The RIPv2 protocol is described in RFC 2453 */

#define	RIPv1		1
#define	RIPv2		2
#ifndef RIPVERSION
#define	RIPVERSION	RIPv1
#endif

#define	RIP_PORT	520

#if RIPVERSION == RIPv1
struct netinfo {
	struct	sockaddr rip_dst;	/* destination net/host */
	uint32_t   rip_metric;		/* cost of route */
};
#else
struct netinfo {
	uint16_t   n_family;
#define	RIP_AF_INET	htons(AF_INET)
#define	    RIP_AF_UNSPEC   0
#define	    RIP_AF_AUTH	    0xffff
	uint16_t   n_tag;		/* optional in RIPv2 */
	uint32_t   n_dst;		/* destination net or host */
#define	    RIP_DEFAULT	    0
	uint32_t   n_mask;		/* netmask in RIPv2 */
	uint32_t   n_nhop;		/* optional next hop in RIPv2 */
	uint32_t   n_metric;		/* cost of route */
};
#endif /* RIPv1 */

/* RIPv2 authentication */
struct netauth {
	uint16_t   a_family;		/* always RIP_AF_AUTH */
	uint16_t   a_type;
#define	RIP_AUTH_NONE		0
#define	RIP_AUTH_TRAILER	htons(1)	/* authentication data */
#define	RIP_AUTH_PW		htons(2)	/* password type */
#define	RIP_AUTH_MD5		htons(3)	/* Keyed MD5 */
	union {
#define	    RIP_AUTH_PW_LEN 16
	    uint8_t    au_pw[RIP_AUTH_PW_LEN];
	    struct a_md5 {
		int16_t	md5_pkt_len;	/* RIP-II packet length */
		int8_t	md5_keyid;	/* key ID and auth data len */
		int8_t	md5_auth_len;	/* 16 */
		uint32_t md5_seqno;	/* sequence number */
		uint32_t rsvd[2];	/* must be 0 */
#define	    RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
	    } a_md5;
	} au;
};

struct rip_emetric {
	uint16_t	rip_metric;
	uint16_t	rip_mask;
	uint32_t	rip_token[1];
};

struct rip_sec_entry {
	uint32_t	rip_dst;
	uint32_t	rip_count;
	struct rip_emetric rip_emetric[1];
};

struct rip {
	uint8_t    rip_cmd;		/* request/response */
	uint8_t    rip_vers;		/* protocol version # */
	uint16_t   rip_res1;		/* pad to 32-bit boundary */
	union {				/* variable length... */
	    struct netinfo ru_nets[1];	/* variable length... */
	    char    ru_tracefile[1];	/* ditto ... */
	    struct netauth ru_auth[1];
	    struct {
		uint32_t rip_generation;
		struct rip_sec_entry rip_sec_entry[1];
	    } ru_tsol;
	} ripun;
#define	rip_nets	ripun.ru_nets
#define	rip_tracefile	ripun.ru_tracefile
#define	rip_auths	ripun.ru_auth
#define	rip_tsol	ripun.ru_tsol
};

struct entryinfo {
	struct	sockaddr rtu_dst;
	struct	sockaddr rtu_router;
	short	rtu_flags;
	short	rtu_state;
	int	rtu_timer;
	int	rtu_metric;
	int	int_flags;
	char	int_name[16];
};

typedef struct rdisc_info_s {
	uint_t  info_type;
	uint_t  info_version;
	uint_t	info_num_of_routers;
} rdisc_info_t;

/*
 * Structure that is returned with the default router info.
 */
typedef struct defr_s {
	uint32_t	defr_info_type;
	uint32_t	defr_version;
	struct in_addr	defr_addr;
	uint32_t	defr_index;
	uint32_t	defr_life;
	uint32_t	defr_pref;
} defr_t;


/*
 * Packet types.
 */
#define	RIPCMD_REQUEST		1	/* want info - from suppliers */
#define	RIPCMD_RESPONSE		2	/* responding to request */
#define	RIPCMD_TRACEON		3	/* turn tracing on */
#define	RIPCMD_TRACEOFF		4	/* turn it off */

/*
 * Gated extended RIP to include a "poll" command instead of using
 * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT).  RFC 1058 says
 * command 5 is used by Sun Microsystems for its own purposes.
 */
#define	RIPCMD_POLL		5	/* like request, but anyone answers */
#define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */

#define	RIPCMD_SEC_RESPONSE	51	/* response includes E-metrics */
#define	RIPCMD_SEC_T_RESPONSE	52	/* tunneling */

#define	RIPCMD_MAX		7

#define	RDISC_SNMP_SOCKET	"/var/run/in.rdisc_mib"

#define	RDISC_SNMP_INFO_REQ		1
#define	RDISC_SNMP_INFO_RESPONSE	2
#define	RDISC_DEF_ROUTER_INFO		3

#define	RDISC_SNMP_INFO_VER	1
#define	RDISC_DEF_ROUTER_VER	1

#define	HOPCNT_INFINITY		16	/* per Xerox NS */
#define	MAXPACKETSIZE		512	/* max broadcast size */
#define	NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip))	\
	/ sizeof (struct netinfo) +1)

#define	INADDR_RIP_GROUP 0xe0000009U	/* 224.0.0.9 */

/*
 * Timer values used in managing the routing table.
 *
 * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
 * If changes occur between updates, dynamic updates containing only changes
 * may be sent.  When these are sent, a timer is set for a random value
 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
 * are sent until the timer expires.
 *
 * Every update of a routing entry forces an entry's timer to be reset.
 * After EXPIRE_TIME without updates, the entry is marked invalid,
 * but held onto until GARBAGE_TIME so that others may see it, to
 * "poison" the bad route.
 */
#define	TIMER_RATE		30	/* alarm clocks every 30 seconds */

#define	SUPPLY_INTERVAL		30	/* time to supply tables */
#define	MIN_WAITTIME		2	/* min sec until next flash updates */
#define	MAX_WAITTIME		5	/* max sec until flash update */

#define	STALE_TIME		90	/* switch to a new gateway */
#define	EXPIRE_TIME		180	/* time to mark entry invalid */
#define	GARBAGE_TIME		300	/* time to garbage collect */

#ifdef	__cplusplus
}
#endif

#endif	/* _PROTOCOLS_ROUTED_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2018 Joyent, Inc.
 * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _PTHREAD_H
#define	_PTHREAD_H

#include <sys/feature_tests.h>

#ifndef	_ASM
#include <sys/types.h>
#include <time.h>
#include <sched.h>
#endif	/* _ASM */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Thread related attribute values defined as in thread.h.
 * These are defined as bit pattern in thread.h.
 * Any change here should be reflected in thread.h.
 */
/* detach */
#define	PTHREAD_CREATE_DETACHED		0x40	/* = THR_DETACHED */
#define	PTHREAD_CREATE_JOINABLE		0
/* scope */
#define	PTHREAD_SCOPE_SYSTEM		0x01	/* = THR_BOUND */
#define	PTHREAD_SCOPE_PROCESS		0

/*
 * Other attributes which are not defined in thread.h
 */
/* inherit */
#define	PTHREAD_INHERIT_SCHED		1
#define	PTHREAD_EXPLICIT_SCHED		0

/*
 * Value of process-shared attribute
 * These are defined as values defined in sys/synch.h
 * Any change here should be reflected in sys/synch.h.
 */
#define	PTHREAD_PROCESS_SHARED		1	/* = USYNC_PROCESS */
#define	PTHREAD_PROCESS_PRIVATE		0	/* = USYNC_THREAD */

/*
 * mutex types
 *
 * _ERRORCHECK and _RERCURSIVE are kept in line with their corresponding values
 * in sys/synch.h; however, in general these types have their own semantics.
 */
#define	PTHREAD_MUTEX_NORMAL		0x0
#define	PTHREAD_MUTEX_ERRORCHECK	0x2
#define	PTHREAD_MUTEX_RECURSIVE		0x4
#define	PTHREAD_MUTEX_DEFAULT		0x8

/*
 * Mutex protocol values. Keep these in synch with sys/synch.h lock types.
 */
#define	PTHREAD_PRIO_NONE		0x0
#define	PTHREAD_PRIO_INHERIT		0x10
#define	PTHREAD_PRIO_PROTECT		0x20

/*
 * Mutex robust attribute values.
 * Keep these in synch with sys/synch.h lock types.
 */
#define	PTHREAD_MUTEX_STALLED		0x0
#define	PTHREAD_MUTEX_ROBUST		0x40
/*
 * Historical solaris-specific names,
 * from before pthread_mutexattr_getrobust() became standardized
 */
#define	PTHREAD_MUTEX_STALL_NP		PTHREAD_MUTEX_STALLED
#define	PTHREAD_MUTEX_ROBUST_NP		PTHREAD_MUTEX_ROBUST

/*
 * macros - default initializers defined as in synch.h
 * Any change here should be reflected in synch.h.
 *
 * NOTE:
 * Make sure that any change in the macros is consistent with the definition
 * of the corresponding types in sys/types.h (e.g. PTHREAD_MUTEX_INITIALIZER
 * should be consistent with the definition for pthread_mutex_t).
 */
#define	PTHREAD_MUTEX_INITIALIZER		/* = DEFAULTMUTEX */	\
	{{0, 0, 0, PTHREAD_PROCESS_PRIVATE, _MUTEX_MAGIC}, {{{0}}}, 0}

#define	PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP /* = ERRORCHECKMUTEX */ \
	{{0, 0, 0, PTHREAD_PROCESS_PRIVATE | PTHREAD_MUTEX_ERRORCHECK,  \
	_MUTEX_MAGIC}, {{{0}}}, 0}

#define	PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP  /* = RECURSIVEMUTEX */  \
	{{0, 0, 0, PTHREAD_PROCESS_PRIVATE | PTHREAD_MUTEX_RECURSIVE |  \
	PTHREAD_MUTEX_ERRORCHECK, _MUTEX_MAGIC}, {{{0}}}, 0}

#define	PTHREAD_COND_INITIALIZER		/* = DEFAULTCV */	\
	{{{0, 0, 0, 0}, PTHREAD_PROCESS_PRIVATE, _COND_MAGIC}, 0}

#define	PTHREAD_RWLOCK_INITIALIZER		/* = DEFAULTRWLOCK */	\
	{0, PTHREAD_PROCESS_PRIVATE, _RWL_MAGIC, PTHREAD_MUTEX_INITIALIZER, \
	PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER}

/* cancellation type and state */
#define	PTHREAD_CANCEL_ENABLE		0x00
#define	PTHREAD_CANCEL_DISABLE		0x01
#define	PTHREAD_CANCEL_DEFERRED		0x00
#define	PTHREAD_CANCEL_ASYNCHRONOUS	0x02
#define	PTHREAD_CANCELED		(void *)-19

/* pthread_once related values */
#define	PTHREAD_ONCE_NOTDONE	0
#define	PTHREAD_ONCE_DONE	1
#define	PTHREAD_ONCE_INIT	{ {0, 0, 0, PTHREAD_ONCE_NOTDONE} }

/*
 * The key to be created by pthread_key_create_once_np()
 * must be statically initialized with PTHREAD_ONCE_KEY_NP.
 * This must be the same as THR_ONCE_KEY in <thread.h>
 */
#define	PTHREAD_ONCE_KEY_NP	(pthread_key_t)(-1)

/* barriers */
#define	PTHREAD_BARRIER_SERIAL_THREAD	-2

/* For pthread_{get,set}name_np(). */
#define	PTHREAD_MAX_NAMELEN_NP (32)

#ifndef	_ASM

/*
 * cancellation cleanup structure
 */
typedef struct _cleanup {
	uintptr_t	pthread_cleanup_pad[4];
} _cleanup_t;

void	__pthread_cleanup_push(void (*)(void *), void *, caddr_t, _cleanup_t *);
void	__pthread_cleanup_pop(int, _cleanup_t *);
caddr_t	_getfp(void);

#if __cplusplus
extern "C" {
#endif

typedef void (*_Voidfp)(void*); /* pointer to extern "C" function */

#if __cplusplus
} /* extern "C" */
#endif

#define	pthread_cleanup_push(routine, args) { \
	_cleanup_t _cleanup_info; \
	__pthread_cleanup_push((_Voidfp)(routine), (void *)(args), \
				(caddr_t)_getfp(), &_cleanup_info);

#define	pthread_cleanup_pop(ex) \
	__pthread_cleanup_pop(ex, &_cleanup_info); \
}

/*
 * function prototypes - thread related calls
 */

/*
 * pthread_atfork() is also declared in <unistd.h> as per SUSv2. The
 * declarations are identical. A change to either one may also require
 * appropriate namespace updates in order to avoid redeclaration
 * warnings in the case where both prototypes are exposed via inclusion
 * of both <pthread.h> and <unistd.h>.
 */
extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void));
extern int pthread_attr_init(pthread_attr_t *);
extern int pthread_attr_destroy(pthread_attr_t *);
extern int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
extern int pthread_attr_getstack(const pthread_attr_t *_RESTRICT_KYWD,
		void **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD);
extern int pthread_attr_setstacksize(pthread_attr_t *, size_t);
extern int pthread_attr_getstacksize(const pthread_attr_t *_RESTRICT_KYWD,
		size_t *_RESTRICT_KYWD);
extern int pthread_attr_setstackaddr(pthread_attr_t *, void *);
extern int pthread_attr_getstackaddr(const pthread_attr_t *_RESTRICT_KYWD,
		void **_RESTRICT_KYWD);
extern int pthread_attr_setdetachstate(pthread_attr_t *, int);
extern int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
extern int pthread_attr_setscope(pthread_attr_t *, int);
extern int pthread_attr_getscope(const pthread_attr_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_attr_setinheritsched(pthread_attr_t *, int);
extern int pthread_attr_getinheritsched(const pthread_attr_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_attr_setschedpolicy(pthread_attr_t *, int);
extern int pthread_attr_getschedpolicy(const pthread_attr_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_attr_setschedparam(pthread_attr_t *_RESTRICT_KYWD,
		const struct sched_param *_RESTRICT_KYWD);
extern int pthread_attr_getschedparam(const pthread_attr_t *_RESTRICT_KYWD,
		struct sched_param *_RESTRICT_KYWD);
extern int pthread_attr_setname_np(pthread_attr_t *_RESTRICT_KYWD,
    const char *_RESTRICT_KYWD);
extern int pthread_attr_getname_np(pthread_attr_t *_RESTRICT_KYWD,
    char *_RESTRICT_KYWD, size_t);
extern int pthread_create(pthread_t *_RESTRICT_KYWD,
		const pthread_attr_t *_RESTRICT_KYWD, void * (*)(void *),
		void *_RESTRICT_KYWD);
extern int pthread_once(pthread_once_t *, void (*)(void));
extern int pthread_join(pthread_t, void **);
extern int pthread_detach(pthread_t);
extern void pthread_exit(void *) __NORETURN;
extern int pthread_cancel(pthread_t);
extern int pthread_setschedparam(pthread_t, int, const struct sched_param *);
extern int pthread_getschedparam(pthread_t, int *_RESTRICT_KYWD,
		struct sched_param *_RESTRICT_KYWD);
extern int pthread_setschedprio(pthread_t, int);
extern int pthread_setcancelstate(int, int *);
extern int pthread_setcanceltype(int, int *);
extern void pthread_testcancel(void);
extern int pthread_equal(pthread_t, pthread_t);
extern int pthread_key_create(pthread_key_t *, void (*)(void *));
extern int pthread_key_create_once_np(pthread_key_t *, void (*)(void *));
extern int pthread_key_delete(pthread_key_t);
extern int pthread_setspecific(pthread_key_t, const void *);
extern void *pthread_getspecific(pthread_key_t);
extern pthread_t pthread_self(void);
extern int pthread_setname_np(pthread_t, const char *);
extern int pthread_getname_np(pthread_t, char *, size_t);

/*
 * function prototypes - synchronization related calls
 */
extern int pthread_mutexattr_init(pthread_mutexattr_t *);
extern int pthread_mutexattr_destroy(pthread_mutexattr_t *);
extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_getpshared(
	const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_getprotocol(
	const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_getprioceiling(
	const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_getrobust(
	const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_mutex_init(pthread_mutex_t *_RESTRICT_KYWD,
	const pthread_mutexattr_t *_RESTRICT_KYWD);
extern int pthread_mutex_consistent(pthread_mutex_t *);
extern int pthread_mutex_destroy(pthread_mutex_t *);
extern int pthread_mutex_lock(pthread_mutex_t *);
extern int pthread_mutex_clocklock(pthread_mutex_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_mutex_timedlock(pthread_mutex_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_mutex_relclocklock_np(pthread_mutex_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_mutex_reltimedlock_np(pthread_mutex_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_mutex_unlock(pthread_mutex_t *);
extern int pthread_mutex_trylock(pthread_mutex_t *);
extern int pthread_mutex_setprioceiling(pthread_mutex_t *_RESTRICT_KYWD,
	int, int *_RESTRICT_KYWD);
extern int pthread_mutex_getprioceiling(const pthread_mutex_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_condattr_init(pthread_condattr_t *);
extern int pthread_condattr_destroy(pthread_condattr_t *);
extern int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
extern int pthread_condattr_getclock(const pthread_condattr_t *_RESTRICT_KYWD,
	clockid_t *_RESTRICT_KYWD);
extern int pthread_condattr_setpshared(pthread_condattr_t *, int);
extern int pthread_condattr_getpshared(const pthread_condattr_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_cond_init(pthread_cond_t *_RESTRICT_KYWD,
	const pthread_condattr_t *_RESTRICT_KYWD);
extern int pthread_cond_destroy(pthread_cond_t *);
extern int pthread_cond_broadcast(pthread_cond_t *);
extern int pthread_cond_signal(pthread_cond_t *);
extern int pthread_cond_wait(pthread_cond_t *_RESTRICT_KYWD,
	pthread_mutex_t *_RESTRICT_KYWD);
extern int pthread_cond_clockwait(pthread_cond_t *_RESTRICT_KYWD,
	pthread_mutex_t *_RESTRICT_KYWD, clockid_t,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_cond_timedwait(pthread_cond_t *_RESTRICT_KYWD,
	pthread_mutex_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
extern int pthread_cond_relclockwait_np(pthread_cond_t *_RESTRICT_KYWD,
	pthread_mutex_t *_RESTRICT_KYWD, clockid_t,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_cond_reltimedwait_np(pthread_cond_t *_RESTRICT_KYWD,
	pthread_mutex_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
extern int pthread_attr_getguardsize(const pthread_attr_t *_RESTRICT_KYWD,
	size_t *_RESTRICT_KYWD);
extern int pthread_attr_setguardsize(pthread_attr_t *, size_t);
extern int pthread_getconcurrency(void);
extern int pthread_setconcurrency(int);
extern int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *_RESTRICT_KYWD,
	int *_RESTRICT_KYWD);
extern int pthread_rwlock_init(pthread_rwlock_t *_RESTRICT_KYWD,
	const pthread_rwlockattr_t *_RESTRICT_KYWD);
extern int pthread_rwlock_destroy(pthread_rwlock_t *);
extern int pthread_rwlock_rdlock(pthread_rwlock_t *);
extern int pthread_rwlock_clockrdlock(pthread_rwlock_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_relclockrdlock_np(pthread_rwlock_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_reltimedrdlock_np(pthread_rwlock_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
extern int pthread_rwlock_wrlock(pthread_rwlock_t *);
extern int pthread_rwlock_clockwrlock(pthread_rwlock_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_relclockwrlock_np(pthread_rwlock_t *_RESTRICT_KYWD,
	clockid_t, const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_reltimedwrlock_np(pthread_rwlock_t *_RESTRICT_KYWD,
	const struct timespec *_RESTRICT_KYWD);
extern int pthread_rwlock_trywrlock(pthread_rwlock_t *);
extern int pthread_rwlock_unlock(pthread_rwlock_t *);
extern int pthread_rwlockattr_init(pthread_rwlockattr_t *);
extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
extern int pthread_rwlockattr_getpshared(
	const pthread_rwlockattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
extern int pthread_spin_init(pthread_spinlock_t *, int);
extern int pthread_spin_destroy(pthread_spinlock_t *);
extern int pthread_spin_lock(pthread_spinlock_t *);
extern int pthread_spin_trylock(pthread_spinlock_t *);
extern int pthread_spin_unlock(pthread_spinlock_t *);
extern int pthread_barrierattr_init(pthread_barrierattr_t *);
extern int pthread_barrierattr_destroy(pthread_barrierattr_t *);
extern int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
extern int pthread_barrierattr_getpshared(
	const pthread_barrierattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int pthread_barrier_init(pthread_barrier_t *_RESTRICT_KYWD,
	const pthread_barrierattr_t *_RESTRICT_KYWD, uint_t);
extern int pthread_barrier_destroy(pthread_barrier_t *);
extern int pthread_barrier_wait(pthread_barrier_t *);

/* Historical names -- present only for binary compatibility */
extern int pthread_mutex_consistent_np(pthread_mutex_t *);
extern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t *, int);
extern int pthread_mutexattr_getrobust_np(
	const pthread_mutexattr_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);

/*
 * These are non-standardized extensions that we provide. Their origins are
 * documented in their manual pages.
 */
#if !defined(_STRICT_SYMBOLS)
extern int pthread_attr_get_np(pthread_t, pthread_attr_t *);
extern void pthread_mutex_enter_np(pthread_mutex_t *);
extern void pthread_mutex_exit_np(pthread_mutex_t *);
#endif	/* !_STRICT_SYMBOLS */

#endif	/* _ASM */

#ifdef	__cplusplus
}
#endif

#endif	/* _PTHREAD_H */
/*
 * Copyright 2026 Zygaena Project Contributors
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * BSD-compatible PTY utility functions.
 * Link with -lutil.
 */

#ifndef _PTY_H
#define	_PTY_H

#include <sys/types.h>
#include <termios.h>

struct winsize;

#ifdef __cplusplus
extern "C" {
#endif

int	openpty(int *, int *, char *, struct termios *, struct winsize *);
pid_t	forkpty(int *, char *, struct termios *, struct winsize *);
int	login_tty(int);

#ifdef __cplusplus
}
#endif

#endif /* _PTY_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_PW_H
#define	_PW_H

#ifdef	__cplusplus
extern "C" {
#endif

extern char *logname(void);
extern char *regcmp(const char *, ...);
extern char *regex(const char *, const char *, ...);

#ifdef	__cplusplus
}
#endif

#endif	/* _PW_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _PWD_H
#define	_PWD_H

#include <sys/feature_tests.h>

#include <sys/types.h>

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#include <stdio.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

struct passwd {
	char	*pw_name;
	char	*pw_passwd;
	uid_t	pw_uid;
	gid_t	pw_gid;
	char	*pw_age;
	char	*pw_comment;
	char	*pw_gecos;
	char	*pw_dir;
	char	*pw_shell;
};

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
struct comment {
	char	*c_dept;
	char	*c_name;
	char	*c_acct;
	char	*c_bin;
};
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

extern struct passwd *getpwuid(uid_t);		/* MT-unsafe */
extern struct passwd *getpwnam(const char *);	/* MT-unsafe */

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern struct passwd *getpwent_r(struct passwd *, char *, int);
extern struct passwd *fgetpwent_r(FILE *, struct passwd *, char *, int);
extern struct passwd *fgetpwent(FILE *);	/* MT-unsafe */
extern int putpwent(const struct passwd *, FILE *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
	defined(__EXTENSIONS__)
extern void endpwent(void);
extern struct passwd *getpwent(void);		/* MT-unsafe */
extern void setpwent(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */

/*
 * getpwuid_r() & getpwnam_r() prototypes are defined here.
 */

/*
 * Previous releases of Solaris, starting at 2.3, provided definitions of
 * various functions as specified in POSIX.1c, Draft 6.  For some of these
 * functions, the final POSIX 1003.1c standard had a different number of
 * arguments and return values.
 *
 * The following segment of this header provides support for the standard
 * interfaces while supporting applications written under earlier
 * releases.  The application defines appropriate values of the feature
 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
 * whether it was written to expect the Draft 6 or standard versions of
 * these interfaces, before including this header.  This header then
 * provides a mapping from the source version of the interface to an
 * appropriate binary interface.  Such mappings permit an application
 * to be built from libraries and objects which have mixed expectations
 * of the definitions of these functions.
 *
 * For applications using the Draft 6 definitions, the binary symbol is the
 * same as the source symbol, and no explicit mapping is needed.  For the
 * standard interface, the function func() is mapped to the binary symbol
 * _posix_func().  The preferred mechanism for the remapping is a compiler
 * #pragma.  If the compiler does not provide such a #pragma, the header file
 * defines a static function func() which calls the _posix_func() version;
 * this has to be done instead of #define since POSIX specifies that an
 * application can #undef the symbol and still be bound to the correct
 * implementation.  Unfortunately, the statics confuse lint so we fallback to
 * #define in that case.
 *
 * NOTE: Support for the Draft 6 definitions is provided for compatibility
 * only.  New applications/libraries should use the standard definitions.
 */

#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
	defined(_POSIX_PTHREAD_SEMANTICS) || defined(__EXTENSIONS__)

#if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getpwuid_r __posix_getpwuid_r
#pragma redefine_extname getpwnam_r __posix_getpwnam_r
extern int getpwuid_r(uid_t, struct passwd *, char *,
    size_t, struct passwd **);
extern int getpwnam_r(const char *, struct passwd *, char *,
    size_t, struct passwd **);
#else  /* __PRAGMA_REDEFINE_EXTNAME */

extern int __posix_getpwuid_r(uid_t, struct passwd *, char *, size_t,
    struct passwd **);
extern int __posix_getpwnam_r(const char *, struct passwd *, char *,
    size_t, struct passwd **);

#ifdef __lint

#define	getpwuid_r __posix_getpwuid_r
#define	getpwnam_r __posix_getpwnam_r

#else	/* !__lint */

static int
getpwuid_r(uid_t __uid, struct passwd *__pwd, char *__buf, size_t __len,
    struct passwd **__res)
{
	return (__posix_getpwuid_r(__uid, __pwd, __buf, __len, __res));
}
static int
getpwnam_r(const char *__cb, struct passwd *__pwd, char *__buf, size_t __len,
    struct passwd **__res)
{
	return (__posix_getpwnam_r(__cb, __pwd, __buf, __len, __res));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

extern struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
extern struct passwd *getpwnam_r(const char *, struct passwd *, char *, int);

#endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L)... */

#ifdef	__cplusplus
}
#endif

#endif /* _PWD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_RCTL_H
#define	_RCTL_H

#include <sys/rctl.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

int rctl_walk(int (*)(const char *, void *), void *);

hrtime_t rctlblk_get_firing_time(rctlblk_t *);
uint_t rctlblk_get_global_action(rctlblk_t *);
uint_t rctlblk_get_global_flags(rctlblk_t *);
uint_t rctlblk_get_local_action(rctlblk_t *, int *);
uint_t rctlblk_get_local_flags(rctlblk_t *);
id_t rctlblk_get_recipient_pid(rctlblk_t *);
rctl_priv_t rctlblk_get_privilege(rctlblk_t *);
rctl_qty_t rctlblk_get_value(rctlblk_t *);
rctl_qty_t rctlblk_get_enforced_value(rctlblk_t *);

void rctlblk_set_local_action(rctlblk_t *, uint_t, int);
void rctlblk_set_local_flags(rctlblk_t *, uint_t);
void rctlblk_set_recipient_pid(rctlblk_t *, id_t);
void rctlblk_set_privilege(rctlblk_t *, rctl_priv_t);
void rctlblk_set_value(rctlblk_t *, rctl_qty_t);

size_t rctlblk_size(void);

#ifdef	__cplusplus
}
#endif

#endif	/* _RCTL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1995, 2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_RE_COMP_H
#define	_RE_COMP_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern char *re_comp(const char *);
extern int re_exec(const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _RE_COMP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 1989, 1994 by Mortice Kern Systems Inc.
 * All rights reserved.
 */

/*
 * Copyright 2017 Nexenta Systems, Inc.
 */

#ifndef	_REGEX_H
#define	_REGEX_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif


/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef int	wchar_t;
#else
typedef long    wchar_t;
#endif
#endif	/* !_WCHAR_T */
#endif	/* !defined(__cplusplus) ... */

typedef ssize_t regoff_t;

/* regcomp flags */
#define	REG_BASIC	0x00000
#define	REG_EXTENDED	0x00001		/* Use Extended Regular Expressions */
#define	REG_NOSUB	0x00002		/* Don't set subexpression */
#define	REG_ICASE	0x00004		/* Ignore case in match */
#define	REG_NEWLINE	0x00008		/* Treat \n as regular character */
#define	REG_DELIM	0x00010		/* legacy, no effect */
#define	REG_DEBUG	0x00020		/* legacy, no effect */
#define	REG_ANCHOR	0x00040		/* legacy, no effect */
#define	REG_WORDS	0x00080		/* legacy, no effect */
#define	REG_EGREP	0x01000		/* legacy, no effect */
#define	REG_DUMP	0x02000		/* internal */
#define	REG_PEND	0x04000		/* NULs are ordinary characters */
#define	REG_NOSPEC	0x08000		/* no special characters */

/* internal flags */
#define	REG_MUST	0x00100		/* legacy, no effect */

/* regexec flags */
#define	REG_NOTBOL	0x00200		/* string is not BOL */
#define	REG_NOTEOL	0x00400		/* string has no EOL */
#define	REG_NOOPT	0x00800		/* legacy, no effect */
#define	REG_STARTEND	0x10000		/* match whole pattern */
#define	REG_TRACE	0x20000		/* tracing of execution */
#define	REG_LARGE	0x40000		/* force large representation */
#define	REG_BACKR	0x80000		/* force use of backref code */

/* regcomp and regexec return codes */
#define	REG_OK		0		/* success (non-standard) */
#define	REG_NOMATCH	1		/* regexec failed to match */
#define	REG_ECOLLATE	2		/* invalid collation element ref. */
#define	REG_EESCAPE	3		/* trailing \ in pattern */
#define	REG_ENEWLINE	4		/* \n found before end of pattern */
#define	REG_ENSUB	5		/* more than 9 \( \) pairs (OBS) */
#define	REG_ESUBREG	6		/* number in \[0-9] invalid */
#define	REG_EBRACK	7		/* [ ] imbalance */
#define	REG_EPAREN	8		/* ( ) imbalance */
#define	REG_EBRACE	9		/* \{ \} imbalance */
#define	REG_ERANGE	10		/* invalid endpoint in range */
#define	REG_ESPACE	11		/* no memory for compiled pattern */
#define	REG_BADRPT	12		/* invalid repetition */
#define	REG_ECTYPE	13		/* invalid char-class type */
#define	REG_BADPAT	14		/* syntax error */
#define	REG_BADBR	15		/* \{ \} contents bad */
#define	REG_EFATAL	16		/* internal error, not POSIX.2 */
#define	REG_ECHAR	17		/* invalid multibyte character */
#define	REG_STACK	18		/* backtrack stack overflow */
#define	REG_ENOSYS	19		/* function not supported (XPG4) */
#define	REG__LAST	20		/* first unused code */
#define	REG_EBOL	21		/* ^ anchor and not BOL */
#define	REG_EEOL	22		/* $ anchor and not EOL */
#define	REG_ATOI	255		/* convert name to number (!) */
#define	REG_ITOA	256		/* convert number to name (!) */

#define	_REG_BACKREF_MAX 9		/* Max # of subexp. backreference */

typedef struct {		/* regcomp() data saved for regexec() */
	size_t  re_nsub;	/* # of subexpressions in RE pattern */

	/*
	 * Internal use only.  Note that any changes to this structure
	 * have to preserve sizing, as it is baked into applications.
	 */
	struct re_guts *re_g;
	int re_magic;
	const char *re_endp;

	/* here for compat */
	size_t	re_len;		/* # wchar_t chars in compiled pattern */
	struct _regex_ext_t *re_sc;	/* for binary compatibility */
} regex_t;

/* subexpression positions */
typedef struct {
	const char	*rm_sp, *rm_ep;	/* Start pointer, end pointer */
	regoff_t	rm_so, rm_eo;	/* Start offset, end offset */
	int		rm_ss, rm_es;	/* Used internally */
} regmatch_t;


/*
 * IEEE Std 1003.2 ("POSIX.2") regular expressions API.
 */

extern int regcomp(regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, int);
extern int regexec(const regex_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, regmatch_t *_RESTRICT_KYWD, int);
extern size_t regerror(int, const regex_t *_RESTRICT_KYWD, char *_RESTRICT_KYWD,
    size_t);
extern void regfree(regex_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _REGEX_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _REGEXP_H
#define	_REGEXP_H

#include <string.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	CBRA	2
#define	CCHR	4
#define	CDOT	8
#define	CCL	12
#define	CXCL	16
#define	CDOL	20
#define	CCEOF	22
#define	CKET	24
#define	CBACK	36
#define	NCCL	40

#define	STAR	01
#define	RNGE	03

#define	NBRA	9

#define	PLACE(c)	ep[c >> 3] |= bittab[c & 07]
#define	ISTHERE(c)	(ep[c >> 3] & bittab[c & 07])
#define	ecmp(s1, s2, n)	(strncmp(s1, s2, n) == 0)

static char	*braslist[NBRA];
static char	*braelist[NBRA];
int	sed, nbra;
char	*loc1, *loc2, *locs;
static int	nodelim;

int	circf;
static int	low;
static int	size;

static unsigned char	bittab[] = { 1, 2, 4, 8, 16, 32, 64, 128 };

int advance(const char *lp, const char *ep);
static void getrnge(const char *str);

char *
compile(char *instring, char *ep, const char *endbuf, int seof)
{
	INIT	/* Dependent declarations and initializations */
	register int c;
	register int eof = seof;
	char *lastep;
	int cclcnt;
	char bracket[NBRA], *bracketp;
	int closed;
	int neg;
	int lc;
	int i, cflg;
	int iflag; /* used for non-ascii characters in brackets */

#ifdef __lint
	/* make lint happy */
	c = nodelim;
#endif

	lastep = NULL;
	if ((c = GETC()) == eof || c == '\n') {
		if (c == '\n') {
			UNGETC(c);
			nodelim = 1;
		}
		if (*ep == 0 && !sed)
			ERROR(41);
		RETURN(ep);
	}
	bracketp = bracket;
	circf = closed = nbra = 0;
	if (c == '^')
		circf++;
	else
		UNGETC(c);
	for (;;) {
		if (ep >= endbuf)
			ERROR(50);
		c = GETC();
		if (c != '*' && ((c != '\\') || (PEEKC() != '{')))
			lastep = ep;
		if (c == eof) {
			*ep++ = CCEOF;
			if (bracketp != bracket)
				ERROR(42);
			RETURN(ep);
		}
		switch (c) {

		case '.':
			*ep++ = CDOT;
			continue;

		case '\n':
			if (!sed) {
				UNGETC(c);
				*ep++ = CCEOF;
				nodelim = 1;
				if (bracketp != bracket)
					ERROR(42);
				RETURN(ep);
			} else ERROR(36);
		case '*':
			if (lastep == NULL || *lastep == CBRA ||
			    *lastep == CKET)
				goto defchar;
			*lastep |= STAR;
			continue;

		case '$':
			if (PEEKC() != eof && PEEKC() != '\n')
				goto defchar;
			*ep++ = CDOL;
			continue;

		case '[':
			if (&ep[17] >= endbuf)
				ERROR(50);

			*ep++ = CCL;
			lc = 0;
			for (i = 0; i < 16; i++)
				ep[i] = 0;

			neg = 0;
			if ((c = GETC()) == '^') {
				neg = 1;
				c = GETC();
			}
			iflag = 1;
			do {
				c &= 0377;
				if (c == '\0' || c == '\n')
					ERROR(49);
				if ((c & 0200) && iflag) {
					iflag = 0;
					if (&ep[32] >= endbuf)
						ERROR(50);
					ep[-1] = CXCL;
					for (i = 16; i < 32; i++)
						ep[i] = 0;
				}
				if (c == '-' && lc != 0) {
					if ((c = GETC()) == ']') {
						PLACE('-');
						break;
					}
					if ((c & 0200) && iflag) {
						iflag = 0;
						if (&ep[32] >= endbuf)
							ERROR(50);
						ep[-1] = CXCL;
						for (i = 16; i < 32; i++)
							ep[i] = 0;
					}
					while (lc < c) {
						PLACE(lc);
						lc++;
					}
				}
				lc = c;
				PLACE(c);
			} while ((c = GETC()) != ']');

			if (iflag)
				iflag = 16;
			else
				iflag = 32;

			if (neg) {
				if (iflag == 32) {
					for (cclcnt = 0; cclcnt < iflag;
					    cclcnt++)
						ep[cclcnt] ^= 0377;
					ep[0] &= 0376;
				} else {
					ep[-1] = NCCL;
					/* make nulls match so test fails */
					ep[0] |= 01;
				}
			}

			ep += iflag;

			continue;

		case '\\':
			switch (c = GETC()) {

			case '(':
				if (nbra >= NBRA)
					ERROR(43);
				*bracketp++ = (char)nbra;
				*ep++ = CBRA;
				*ep++ = (char)nbra++;
				continue;

			case ')':
				if (bracketp <= bracket)
					ERROR(42);
				*ep++ = CKET;
				*ep++ = *--bracketp;
				closed++;
				continue;

			case '{':
				if (lastep == NULL)
					goto defchar;
				*lastep |= RNGE;
				cflg = 0;
			nlim:
				c = GETC();
				i = 0;
				do {
					if ('0' <= c && c <= '9')
						i = 10 * i + c - '0';
					else
						ERROR(16);
				} while (((c = GETC()) != '\\') && (c != ','));
				if (i >= 255)
					ERROR(11);
				*ep++ = (char)i;
				if (c == ',') {
					if (cflg++)
						ERROR(44);
					if ((c = GETC()) == '\\')
						*ep++ = (char)255;
					else {
						UNGETC(c);
						goto nlim;
						/* get 2'nd number */
					}
				}
				if (GETC() != '}')
					ERROR(45);
				if (!cflg)	/* one number */
					*ep++ = (char)i;
				else if ((ep[-1] & 0377) < (ep[-2] & 0377))
					ERROR(46);
				continue;

			case '\n':
				ERROR(36);

			case 'n':
				c = '\n';
				goto defchar;

			default:
				if (c >= '1' && c <= '9') {
					if ((c -= '1') >= closed)
						ERROR(25);
					*ep++ = CBACK;
					*ep++ = (char)c;
					continue;
				}
				/* FALLTHROUGH */
			}
			/* FALLTHROUGH */
	/* Drop through to default to use \ to turn off special chars */

		defchar:
		default:
			lastep = ep;
			*ep++ = CCHR;
			*ep++ = (char)c;
		}
	}
	/*NOTREACHED*/
}

int
step(const char *p1, const char *p2)
{
	char c;


	if (circf) {
		loc1 = (char *)p1;
		return (advance(p1, p2));
	}
	/* fast check for first character */
	if (*p2 == CCHR) {
		c = p2[1];
		do {
			if (*p1 != c)
				continue;
			if (advance(p1, p2)) {
				loc1 = (char *)p1;
				return (1);
			}
		} while (*p1++);
		return (0);
	}
		/* regular algorithm */
	do {
		if (advance(p1, p2)) {
			loc1 = (char *)p1;
			return (1);
		}
	} while (*p1++);
	return (0);
}

int
advance(const char *lp, const char *ep)
{
	const char *curlp;
	int c;
	char *bbeg;
	register char neg;
	size_t ct;

	for (;;) {
		neg = 0;
		switch (*ep++) {

		case CCHR:
			if (*ep++ == *lp++)
				continue;
			return (0);
			/*FALLTHRU*/

		case CDOT:
			if (*lp++)
				continue;
			return (0);
			/*FALLTHRU*/

		case CDOL:
			if (*lp == 0)
				continue;
			return (0);
			/*FALLTHRU*/

		case CCEOF:
			loc2 = (char *)lp;
			return (1);
			/*FALLTHRU*/

		case CXCL:
			c = (unsigned char)*lp++;
			if (ISTHERE(c)) {
				ep += 32;
				continue;
			}
			return (0);
			/*FALLTHRU*/

		case NCCL:
			neg = 1;
			/*FALLTHRU*/

		case CCL:
			c = *lp++;
			if (((c & 0200) == 0 && ISTHERE(c)) ^ neg) {
				ep += 16;
				continue;
			}
			return (0);
			/*FALLTHRU*/

		case CBRA:
			braslist[*ep++] = (char *)lp;
			continue;
			/*FALLTHRU*/

		case CKET:
			braelist[*ep++] = (char *)lp;
			continue;
			/*FALLTHRU*/

		case CCHR | RNGE:
			c = *ep++;
			getrnge(ep);
			while (low--)
				if (*lp++ != c)
					return (0);
			curlp = lp;
			while (size--)
				if (*lp++ != c)
					break;
			if (size < 0)
				lp++;
			ep += 2;
			goto star;
			/*FALLTHRU*/

		case CDOT | RNGE:
			getrnge(ep);
			while (low--)
				if (*lp++ == '\0')
					return (0);
			curlp = lp;
			while (size--)
				if (*lp++ == '\0')
					break;
			if (size < 0)
				lp++;
			ep += 2;
			goto star;
			/*FALLTHRU*/

		case CXCL | RNGE:
			getrnge(ep + 32);
			while (low--) {
				c = (unsigned char)*lp++;
				if (!ISTHERE(c))
					return (0);
			}
			curlp = lp;
			while (size--) {
				c = (unsigned char)*lp++;
				if (!ISTHERE(c))
					break;
			}
			if (size < 0)
				lp++;
			ep += 34;		/* 32 + 2 */
			goto star;
			/*FALLTHRU*/

		case NCCL | RNGE:
			neg = 1;
			/*FALLTHRU*/

		case CCL | RNGE:
			getrnge(ep + 16);
			while (low--) {
				c = *lp++;
				if (((c & 0200) || !ISTHERE(c)) ^ neg)
					return (0);
			}
			curlp = lp;
			while (size--) {
				c = *lp++;
				if (((c & 0200) || !ISTHERE(c)) ^ neg)
					break;
			}
			if (size < 0)
				lp++;
			ep += 18;		/* 16 + 2 */
			goto star;
			/*FALLTHRU*/

		case CBACK:
			bbeg = braslist[*ep];
			ct = braelist[*ep++] - bbeg;

			if (ecmp(bbeg, lp, ct)) {
				lp += ct;
				continue;
			}
			return (0);
			/*FALLTHRU*/

		case CBACK | STAR:
			bbeg = braslist[*ep];
			ct = braelist[*ep++] - bbeg;
			curlp = lp;
			while (ecmp(bbeg, lp, ct))
				lp += ct;

			while (lp >= curlp) {
				if (advance(lp, ep))
					return (1);
				lp -= ct;
			}
			return (0);
			/*FALLTHRU*/

		case CDOT | STAR:
			curlp = lp;
			while (*lp++)
				;
			goto star;
			/*FALLTHRU*/

		case CCHR | STAR:
			curlp = lp;
			while (*lp++ == *ep)
				;
			ep++;
			goto star;
			/*FALLTHRU*/

		case CXCL | STAR:
			curlp = lp;
			do {
				c = (unsigned char)*lp++;
			} while (ISTHERE(c));
			ep += 32;
			goto star;
			/*FALLTHRU*/

		case NCCL | STAR:
			neg = 1;
			/*FALLTHRU*/

		case CCL | STAR:
			curlp = lp;
			do {
				c = *lp++;
			} while (((c & 0200) == 0 && ISTHERE(c)) ^ neg);
			ep += 16;
			goto star;
			/*FALLTHRU*/

		star:
			do {
				if (--lp == locs)
					break;
				if (advance(lp, ep))
					return (1);
			} while (lp > curlp);
			return (0);

		}
	}
	/*NOTREACHED*/
}

static void
getrnge(const char *str)
{
	low = *str++ & 0377;
	size = ((*str & 0377) == 255)? 20000: (*str &0377) - low;
}

#ifdef	__cplusplus
}
#endif

#endif	/* _REGEXP_H */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
 * All Rights Reserved
 *
 * Portions of this source code were derived from Berkeley
 * 4.3 BSD under license from the regents of the University of
 * California.
 */

/*
 * BIND 4.9.4:
 */

/*
 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies, and that
 * the name of Digital Equipment Corporation not be used in advertising or
 * publicity pertaining to distribution of the document or software without
 * specific, written prior permission.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 * --Copyright--
 *
 * End BIND 4.9.4
 */

/*
 * Copyright (c) 1983, 1987, 1989
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/*
 *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
 *	$Id: resolv.h,v 8.52 2003/04/29 02:27:03 marka Exp $
 */

#ifndef _RESOLV_H_
#define	_RESOLV_H_

#include <sys/param.h>

#include <stdio.h>
#include <arpa/nameser.h>
#include <sys/socket.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Revision information.  This is the release date in YYYYMMDD format.
 * It can change every day so the right thing to do with it is use it
 * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
 * compare for equality; rather, use it to determine whether your resolver
 * is new enough to contain a certain feature.
 */

#define	__RES	20090302

#define	RES_SET_H_ERRNO(r, x)	__h_errno_set(r, x)
struct __res_state;					/* forward */

void __h_errno_set(struct __res_state *res, int err);

/*
 * Resolver configuration file.
 * Normally not present, but may contain the address of the
 * initial name server(s) to query and the domain search list.
 */

#ifndef _PATH_RESCONF
#define	_PATH_RESCONF		"/etc/resolv.conf"
#endif

#ifndef __P
#define	__P(x)	x
#endif

typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
	res_sendhookact;

typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns,
						const uchar_t **query,
						int *querylen,
						uchar_t *ans,
						int anssiz,
						int *resplen));

typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns,
						const uchar_t *query,
						int querylen,
						uchar_t *ans,
						int anssiz,
						int *resplen));

struct res_sym {
	int		number;	   /* Identifying number, like T_MX */
	const char	*name;	   /* Its symbolic name, like "MX" */
	const char	*humanname; /* Its fun name, like "mail exchanger" */
};

/*
 * Global defines and variables for resolver stub.
 */
/* ADDRSORT and MAXADDR retained for compatibility; not used */
#define	ADDRSORT	1	/* enable the address-sorting option */
#define	MAXADDR		10	/* max # addresses to sort by */

#define	MAXNS			3	/* max # name servers we'll track */
#define	MAXDFLSRCH		3	/* # default domain levels to try */
#define	MAXDNSRCH		6	/* max # domains in search path */
#define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */

#define	RES_TIMEOUT		5	/* min. seconds between retries */
#define	MAXRESOLVSORT		10	/* number of net to sort on */
#define	RES_MAXNDOTS		15	/* should reflect bit field size */
#define	RES_MAXRETRANS		30	/* only for resolv.conf/RES_OPTIONS */
#define	RES_MAXRETRY		5	/* only for resolv.conf/RES_OPTIONS */
#define	RES_DFLRETRY		2	/* Default #/tries. */
#define	RES_MAXTIME		65535	/* Infinity, in milliseconds. */

struct __res_state_ext;

struct __res_state {
	int	retrans;		/* retransmission time interval */
	int	retry;			/* number of times to retransmit */
#ifdef __sun
	uint_t	options;		/* option flags - see below. */
#else
	ulong_t	options;		/* option flags - see below. */
#endif
	int	nscount;		/* number of name servers */
	struct sockaddr_in
		nsaddr_list[MAXNS];	/* address of name server */
#define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
	ushort_t id;			/* current packet id */
	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
	char	defdname[256];		/* default domain (deprecated) */
#ifdef __sun
	uint_t	pfcode;			/* RES_PRF_ flags - see below. */
#else
	ulong_t	pfcode;			/* RES_PRF_ flags - see below. */
#endif
	unsigned ndots:4;		/* threshold for initial abs. query */
	unsigned nsort:4;		/* number of elements in sort_list[] */
	char	unused[3];
	struct {
		struct in_addr	addr;
		unsigned int	mask;
	} sort_list[MAXRESOLVSORT];
	res_send_qhook qhook;		/* query hook */
	res_send_rhook rhook;		/* response hook */
	int		res_h_errno;	/* last one set for this context */
	int		_vcsock;	/* PRIVATE: for res_send VC i/o */
	uint_t	_flags;		/* PRIVATE: see below */
	uint_t	_pad;			/* make _u 64 bit aligned */
	union {
		/* On an 32-bit arch this means 512b total. */
		char	pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
		struct {
			uint16_t		nscount;
			uint16_t		nstimes[MAXNS];	/* ms. */
			int			nssocks[MAXNS];
			struct __res_state_ext *ext;	/* extention for IPv6 */
			uchar_t	_rnd[16];	/* PRIVATE: random state */
		} _ext;
	} _u;
};

typedef	struct __res_state	*res_state;

union res_sockaddr_union {
	struct sockaddr_in	sin;
#ifdef IN6ADDR_ANY_INIT
	struct sockaddr_in6	sin6;
#endif
#ifdef ISC_ALIGN64
	int64_t			__align64;	/* 64bit alignment */
#else
	int32_t			__align32;	/* 32bit alignment */
#endif
	char			__space[128];   /* max size */
};

/*
 * Resolver flags (used to be discrete per-module statics ints).
 */
#define	RES_F_VC	0x00000001	/* socket is TCP */
#define	RES_F_CONN	0x00000002	/* socket is connected */
#define	RES_F_EDNS0ERR	0x00000004	/* EDNS0 caused errors */
#define	RES_F__UNUSED	0x00000008	/* (unused) */
#define	RES_F_LASTMASK	0x000000F0	/* ordinal server of last res_nsend */
#define	RES_F_LASTSHIFT	4		/* bit position of LASTMASK "flag" */
#define	RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)

/* res_findzonecut2() options */
#define	RES_EXHAUSTIVE	0x00000001	/* always do all queries */
#define	RES_IPV4ONLY	0x00000002	/* IPv4 only */
#define	RES_IPV6ONLY	0x00000004	/* IPv6 only */

/*
 * Resolver options (keep these in synch with res_debug.c, please)
 */
#define	RES_INIT	0x00000001	/* address initialized */
#define	RES_DEBUG	0x00000002	/* print debug messages */
#define	RES_AAONLY	0x00000004	/* authoritative answers only (!IMPL) */
#define	RES_USEVC	0x00000008	/* use virtual circuit */
#define	RES_PRIMARY	0x00000010	/* query primary server only (!IMPL) */
#define	RES_IGNTC	0x00000020	/* ignore trucation errors */
#define	RES_RECURSE	0x00000040	/* recursion desired */
#define	RES_DEFNAMES	0x00000080	/* use default domain name */
#define	RES_STAYOPEN	0x00000100	/* Keep TCP socket open */
#define	RES_DNSRCH	0x00000200	/* search up local domain tree */
#define	RES_INSECURE1	0x00000400	/* type 1 security disabled */
#define	RES_INSECURE2	0x00000800	/* type 2 security disabled */
#define	RES_NOALIASES	0x00001000	/* shuts off HOSTALIASES feature */
#define	RES_USE_INET6	0x00002000	/* use/map IPv6 in gethostbyname() */
#define	RES_ROTATE	0x00004000	/* rotate ns list after each query */
#define	RES_NOCHECKNAME	0x00008000	/* do not check names for sanity. */
#define	RES_KEEPTSIG	0x00010000	/* do not strip TSIG records */
#define	RES_BLAST	0x00020000	/* blast all recursive servers */
#define	RES_NO_NIBBLE	0x00040000	/* disable IPv6 nibble mode reverse */
#define	RES_NO_BITSTRING 0x00080000	/* disable IPv6 bitstring mode revrse */
#define	RES_NOTLDQUERY	0x00100000	/* don't unqualified name as a tld */
#define	RES_USE_DNSSEC	0x00200000	/* use DNSSEC using OK bit in OPT */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define	RES_USE_DNAME	0x10000000	/* use DNAME */
#define	RES_USE_EDNS0	0x40000000	/* use EDNS0 if configured */
#define	RES_NO_NIBBLE2	0x80000000	/* disable alternate nibble lookup */

#define	RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)

/*
 * Resolver "pfcode" values.  Used by dig.
 */
#define	RES_PRF_STATS	0x00000001
#define	RES_PRF_UPDATE	0x00000002
#define	RES_PRF_CLASS   0x00000004
#define	RES_PRF_CMD		0x00000008
#define	RES_PRF_QUES	0x00000010
#define	RES_PRF_ANS		0x00000020
#define	RES_PRF_AUTH	0x00000040
#define	RES_PRF_ADD		0x00000080
#define	RES_PRF_HEAD1	0x00000100
#define	RES_PRF_HEAD2	0x00000200
#define	RES_PRF_TTLID	0x00000400
#define	RES_PRF_HEADX	0x00000800
#define	RES_PRF_QUERY	0x00001000
#define	RES_PRF_REPLY	0x00002000
#define	RES_PRF_INIT	0x00004000
#define	RES_PRF_TRUNC	0x00008000
/*			0x00010000	*/

/* Things involving an internal (static) resolver context. */
#ifdef _REENTRANT
extern struct __res_state *__res_state(void);
#define	_res (*__res_state())
#else
#ifndef __BIND_NOSTATIC
extern struct __res_state _res;
#endif
#endif

#ifndef __BIND_NOSTATIC
void		fp_nquery __P((const uchar_t *, int, FILE *));
void		fp_query __P((const uchar_t *, FILE *));
const char *hostalias __P((const char *));
void		p_query __P((const uchar_t *));
void		res_close __P((void));
int		res_init __P((void));
int		res_isourserver __P((const struct sockaddr_in *));
int		res_mkquery __P((int, const char *, int, int, const uchar_t *,
				int, const uchar_t *, uchar_t *, int));
int		res_query	__P((const char *, int, int, uchar_t *, int));
int		res_querydomain __P((const char *, const char *, int, int,
				uchar_t *, int));
int		res_search __P((const char *, int, int, uchar_t *, int));
int		res_send __P((const uchar_t *, int, uchar_t *, int));
int		res_sendsigned __P((const uchar_t *, int, ns_tsig_key *,
				    uchar_t *, int));
#endif	/* __BIND_NOSTATIC */

extern const struct res_sym __p_key_syms[];
extern const struct res_sym __p_cert_syms[];
extern const struct res_sym __p_class_syms[];
extern const struct res_sym __p_type_syms[];
extern const struct res_sym __p_rcode_syms[];

int		res_hnok __P((const char *));
int		res_ownok __P((const char *));
int		res_mailok __P((const char *));
int		res_dnok __P((const char *));
int		sym_ston __P((const struct res_sym *, const char *, int *));
const char	*sym_ntos __P((const struct res_sym *, int, int *));
const char	*sym_ntop __P((const struct res_sym *, int, int *));
int		b64_ntop __P((uchar_t const *, size_t, char *, size_t));
int		b64_pton __P((char const *, uchar_t *, size_t));
int		loc_aton __P((const char *ascii, uchar_t *binary));
const char	*loc_ntoa __P((const uchar_t *binary, char *ascii));
int		dn_skipname __P((const uchar_t *, const uchar_t *));
void		putlong __P((unsigned int, uchar_t *));
void		putshort __P((unsigned short, uchar_t *));
const char	*p_class __P((int));
const char	*p_time __P((unsigned int));
const char	*p_type __P((int));
const char	*p_rcode __P((int));
const char	*p_sockun __P((union res_sockaddr_union, char *, size_t));
const uchar_t	*p_cdnname __P((const uchar_t *, const uchar_t *, int,
			FILE *));
const uchar_t	*p_cdname __P((const uchar_t *, const uchar_t *, FILE *));
const uchar_t	*p_fqnname __P((const uchar_t *cp, const uchar_t *msg,
			int, char *, int));
const uchar_t	*p_fqname __P((const uchar_t *, const uchar_t *, FILE *));
const char	*p_option __P((uint_t option));
char		*p_secstodate __P((uint_t));
int		dn_count_labels __P((const char *));
int		dn_comp __P((const char *, uchar_t *, int,
				uchar_t **, uchar_t **));
int		dn_expand __P((const uchar_t *, const uchar_t *,
			const uchar_t *, char *, int));
void		res_rndinit __P((res_state));
uint_t		res_randomid __P((void));
uint_t		res_nrandomid __P((res_state));
int		res_nameinquery __P((const char *, int, int,
				const uchar_t *, const uchar_t *));
int		res_queriesmatch __P((const uchar_t *, const uchar_t *,
				const uchar_t *, const uchar_t *));
const char	*p_section __P((int section, int opcode));


/* Things involving a resolver context. */
int		res_ninit __P((res_state));
int		res_nisourserver __P((const res_state,
				const struct sockaddr_in *));
void	fp_resstat __P((const res_state, FILE *));
void	res_pquery	__P((const res_state, const uchar_t *, int, FILE *));
const char	*res_hostalias __P((const res_state, const char *,
				char *, size_t));
int		res_nquery __P((res_state,
				const char *, int, int, uchar_t *, int));
int		res_nsearch __P((res_state, const char *, int,
				int, uchar_t *, int));
int		res_nquerydomain __P((res_state,
				const char *, const char *, int, int,
				uchar_t *, int));
int		res_nmkquery __P((res_state,
				int, const char *, int, int, const uchar_t *,
				int, const uchar_t *, uchar_t *, int));
int		res_nsend __P((res_state, const uchar_t *, int, uchar_t *,
				int));
int		res_nsendsigned __P((res_state, const uchar_t *, int,
				ns_tsig_key *, uchar_t *, int));
int		res_findzonecut __P((res_state, const char *, ns_class, int,
				char *, size_t, struct in_addr *, int));
int		res_findzonecut2 __P((res_state, const char *, ns_class, int,
				char *, size_t, union res_sockaddr_union *,
				int));
void		res_nclose __P((res_state));
int		res_nopt __P((res_state, int, uchar_t *, int, int));
int		res_nopt_rdata __P((res_state, int, uchar_t *, int, uchar_t *,
				    ushort_t, ushort_t, uchar_t *));
void		res_send_setqhook __P((res_send_qhook hook));
void		res_send_setrhook __P((res_send_rhook hook));
int		__res_vinit __P((res_state, int));
void		res_destroyservicelist __P((void));
const char	*res_servicename __P((uint16_t port, const char *proto));
const char	*res_protocolname __P((int num));
void		res_destroyprotolist __P((void));
void		res_buildprotolist __P((void));
const char	*res_get_nibblesuffix __P((res_state));
const char	*res_get_nibblesuffix2 __P((res_state));
void		res_ndestroy __P((res_state));
uint16_t	res_nametoclass __P((const char *buf, int *success));
uint16_t	res_nametotype __P((const char *buf, int *success));
void		res_setservers __P((res_state,
				    const union res_sockaddr_union *, int));
int		res_getservers __P((res_state,
				    union res_sockaddr_union *, int));


#ifdef	__cplusplus
}
#endif

#endif /* !_RESOLV_H_ */
 * Copyright (c) 2015 IETF Trust and the persons identified
 * as authors of the code.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that the
 * following conditions are met:
 *
 * - Redistributions of source code must retain the above
 *   copyright notice, this list of conditions and the
 *   following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above
 *   copyright notice, this list of conditions and the
 *   following disclaimer in the documentation and/or other
 *   materials provided with the distribution.
 *
 * - Neither the name of Internet Society, IETF or IETF
 *   Trust, nor the names of specific contributors, may be
 *   used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
 *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
 *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
 *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NFS VERSION 4 XDR DESCRIPTION
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1993, by Sun Microsystems, Inc.
 */

#ifndef	_RPCSVC_BOOTPARAM_H
#define	_RPCSVC_BOOTPARAM_H

#include <rpcsvc/bootparam_prot.h>

#endif	/* _RPCSVC_BOOTPARAM_H */
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _BOOTPARAM_PROT_H_RPCGEN
#define	_BOOTPARAM_PROT_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */
/* from bootparam_prot.x */
#define	MAX_MACHINE_NAME 255
#define	MAX_PATH_LEN 1024
#define	MAX_FILEID 32
#define	IP_ADDR_TYPE 1

typedef char *bp_machine_name_t;

typedef char *bp_path_t;

typedef char *bp_fileid_t;

struct ip_addr_t {
	char net;
	char host;
	char lh;
	char impno;
};
typedef struct ip_addr_t ip_addr_t;

struct bp_address {
	int address_type;
	union {
		ip_addr_t ip_addr;
	} bp_address_u;
};
typedef struct bp_address bp_address;

struct bp_whoami_arg {
	bp_address client_address;
};
typedef struct bp_whoami_arg bp_whoami_arg;

struct bp_whoami_res {
	bp_machine_name_t client_name;
	bp_machine_name_t domain_name;
	bp_address router_address;
};
typedef struct bp_whoami_res bp_whoami_res;

struct bp_getfile_arg {
	bp_machine_name_t client_name;
	bp_fileid_t file_id;
};
typedef struct bp_getfile_arg bp_getfile_arg;

struct bp_getfile_res {
	bp_machine_name_t server_name;
	bp_address server_address;
	bp_path_t server_path;
};
typedef struct bp_getfile_res bp_getfile_res;

#define	BOOTPARAMPROG	100026
#define	BOOTPARAMVERS	1

#if defined(__STDC__) || defined(__cplusplus)
#define	BOOTPARAMPROC_WHOAMI	1
extern  bp_whoami_res * bootparamproc_whoami_1(bp_whoami_arg *, CLIENT *);
extern  bp_whoami_res * bootparamproc_whoami_1_svc(bp_whoami_arg *, struct svc_req *);
#define	BOOTPARAMPROC_GETFILE	2
extern  bp_getfile_res * bootparamproc_getfile_1(bp_getfile_arg *, CLIENT *);
extern  bp_getfile_res * bootparamproc_getfile_1_svc(bp_getfile_arg *, struct svc_req *);
extern int bootparamprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	BOOTPARAMPROC_WHOAMI	1
extern  bp_whoami_res * bootparamproc_whoami_1();
extern  bp_whoami_res * bootparamproc_whoami_1_svc();
#define	BOOTPARAMPROC_GETFILE	2
extern  bp_getfile_res * bootparamproc_getfile_1();
extern  bp_getfile_res * bootparamproc_getfile_1_svc();
extern int bootparamprog_1_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_bp_machine_name_t(XDR *, bp_machine_name_t*);
extern  bool_t xdr_bp_path_t(XDR *, bp_path_t*);
extern  bool_t xdr_bp_fileid_t(XDR *, bp_fileid_t*);
extern  bool_t xdr_ip_addr_t(XDR *, ip_addr_t*);
extern  bool_t xdr_bp_address(XDR *, bp_address*);
extern  bool_t xdr_bp_whoami_arg(XDR *, bp_whoami_arg*);
extern  bool_t xdr_bp_whoami_res(XDR *, bp_whoami_res*);
extern  bool_t xdr_bp_getfile_arg(XDR *, bp_getfile_arg*);
extern  bool_t xdr_bp_getfile_res(XDR *, bp_getfile_res*);

#else /* K&R C */
extern bool_t xdr_bp_machine_name_t();
extern bool_t xdr_bp_path_t();
extern bool_t xdr_bp_fileid_t();
extern bool_t xdr_ip_addr_t();
extern bool_t xdr_bp_address();
extern bool_t xdr_bp_whoami_arg();
extern bool_t xdr_bp_whoami_res();
extern bool_t xdr_bp_getfile_arg();
extern bool_t xdr_bp_getfile_res();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_BOOTPARAM_PROT_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
%/*
% * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
% * Use is subject to license terms.
% */

%/* from bootparam_prot.x */

/*
 * RPC for bootparms service.
 * There are two procedures:
 *   WHOAMI takes a net address and returns a client name and also a
 *	likely net address for routing
 *   GETFILE takes a client name and file identifier and returns the
 *	server name, server net address and pathname for the file.
 *   file identifiers typically include root, swap, pub and dump
 */
const MAX_MACHINE_NAME  = 255;
const MAX_PATH_LEN	= 1024;
const MAX_FILEID	= 32;
const IP_ADDR_TYPE	= 1;

typedef	string	bp_machine_name_t<MAX_MACHINE_NAME>;
typedef	string	bp_path_t<MAX_PATH_LEN>;
typedef	string	bp_fileid_t<MAX_FILEID>;

struct	ip_addr_t {
	char	net;
	char	host;
	char	lh;
	char	impno;
};

union bp_address switch (int address_type) {
	case IP_ADDR_TYPE:
		ip_addr_t	ip_addr;
};

struct bp_whoami_arg {
	bp_address		client_address;
};

struct bp_whoami_res {
	bp_machine_name_t	client_name;
	bp_machine_name_t	domain_name;
	bp_address		router_address;
};

struct bp_getfile_arg {
	bp_machine_name_t	client_name;
	bp_fileid_t		file_id;
};

struct bp_getfile_res {
	bp_machine_name_t	server_name;
	bp_address		server_address;
	bp_path_t		server_path;
};

program BOOTPARAMPROG {
	version BOOTPARAMVERS {
		bp_whoami_res	BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1;
		bp_getfile_res	BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2;
	} = 1;
} = 100026;
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_DAEMON_UTILS_H
#define	_DAEMON_UTILS_H

#include <sys/stat.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	AUTOMOUNTD	"svc:/system/filesystem/autofs:default"
#define	LOCKD		"svc:/network/nfs/nlockmgr:default"
#define	STATD		"svc:/network/nfs/status:default"
#define	NFSD		"svc:/network/nfs/server:default"
#define	MOUNTD		"svc:/network/nfs/mountd:default"
#define	NFS4CBD		"svc:/network/nfs/cbd:default"
#define	NFSMAPID	"svc:/network/nfs/mapid:default"
#define	RQUOTAD		"svc:/network/nfs/rquota:default"
#define	REPARSED	"svc:/system/filesystem/reparse:default"

#define	DAEMON_UID	 1
#define	DAEMON_GID	12

#define	DAEMON_DIR	"/var/run/daemon"
#define	DAEMON_DIR_MODE	(S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)

extern void _check_services(char **);
extern int _check_daemon_lock(const char *);
extern int _create_daemon_lock(const char *, uid_t, gid_t);
extern pid_t _enter_daemon_lock(const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _DAEMON_UTILS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014, 2016 PALO, Richard.
 *
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef	_RPCSVC_DBM_H
#define	_RPCSVC_DBM_H

#include <sys/isa_defs.h>
#include <sys/null.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	PBLKSIZ	1024
#define	DBLKSIZ	4096
#define	BYTESIZ	8

long	bitno;
long	maxbno;
long	blkno;
long	hmask;

char	pagbuf[PBLKSIZ];
char	dirbuf[DBLKSIZ];

int	dirf;
int	pagf;
int	dbrdonly;

typedef	struct
{
	char	*dptr;
	int	dsize;
} datum;

datum	fetch(datum);
datum	makdatum(char *, int);
datum	firstkey(void);
datum	nextkey(datum);
datum	firsthash(long);
long	calchash(datum);
long	hashinc(long);

#ifdef	__cplusplus
}
#endif

#endif	/* _RPCSVC_DBM_H */
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _MOUNT_H_RPCGEN
#define	_MOUNT_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

#define	MNTPATHLEN 1024
#define	MNTNAMLEN 255
#define	FHSIZE 32
#define	FHSIZE3 64

typedef char fhandle[FHSIZE];

typedef struct {
	u_int fhandle3_len;
	char *fhandle3_val;
} fhandle3;

struct fhstatus {
	u_int fhs_status;
	union {
		fhandle fhs_fhandle;
	} fhstatus_u;
};
typedef struct fhstatus fhstatus;

#define fhs_fh fhstatus_u.fhs_fhandle

enum mountstat3 {
	MNT_OK = 0,
	MNT3ERR_PERM = 1,
	MNT3ERR_NOENT = 2,
	MNT3ERR_IO = 5,
	MNT3ERR_ACCES = 13,
	MNT3ERR_NOTDIR = 20,
	MNT3ERR_INVAL = 22,
	MNT3ERR_NAMETOOLONG = 63,
	MNT3ERR_NOTSUPP = 10004,
	MNT3ERR_SERVERFAULT = 10006
};
typedef enum mountstat3 mountstat3;

struct mountres3_ok {
	fhandle3 fhandle;
	struct {
		u_int auth_flavors_len;
		int *auth_flavors_val;
	} auth_flavors;
};
typedef struct mountres3_ok mountres3_ok;

struct mountres3 {
	mountstat3 fhs_status;
	union {
		mountres3_ok mountinfo;
	} mountres3_u;
};
typedef struct mountres3 mountres3;

typedef char *dirpath;

typedef char *name;

typedef struct mountbody *mountlist;

struct mountbody {
	name ml_hostname;
	dirpath ml_directory;
	mountlist ml_next;
};
typedef struct mountbody mountbody;

typedef struct groupnode *groups;

struct groupnode {
	name gr_name;
	groups gr_next;
};
typedef struct groupnode groupnode;

typedef struct exportnode *exports;

struct exportnode {
	dirpath ex_dir;
	groups ex_groups;
	exports ex_next;
};
typedef struct exportnode exportnode;

struct ppathcnf {
	int pc_link_max;
	short pc_max_canon;
	short pc_max_input;
	short pc_name_max;
	short pc_path_max;
	short pc_pipe_buf;
	u_char pc_vdisable;
	char pc_xxx;
	short pc_mask[2];
};
typedef struct ppathcnf ppathcnf;

#define	MOUNTPROG	100005
#define	MOUNTVERS	1

#if defined(__STDC__) || defined(__cplusplus)
#define	MOUNTPROC_NULL	0
extern  void * mountproc_null_1(void *, CLIENT *);
extern  void * mountproc_null_1_svc(void *, struct svc_req *);
#define	MOUNTPROC_MNT	1
extern  fhstatus * mountproc_mnt_1(dirpath *, CLIENT *);
extern  fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *);
#define	MOUNTPROC_DUMP	2
extern  mountlist * mountproc_dump_1(void *, CLIENT *);
extern  mountlist * mountproc_dump_1_svc(void *, struct svc_req *);
#define	MOUNTPROC_UMNT	3
extern  void * mountproc_umnt_1(dirpath *, CLIENT *);
extern  void * mountproc_umnt_1_svc(dirpath *, struct svc_req *);
#define	MOUNTPROC_UMNTALL	4
extern  void * mountproc_umntall_1(void *, CLIENT *);
extern  void * mountproc_umntall_1_svc(void *, struct svc_req *);
#define	MOUNTPROC_EXPORT	5
extern  exports * mountproc_export_1(void *, CLIENT *);
extern  exports * mountproc_export_1_svc(void *, struct svc_req *);
#define	MOUNTPROC_EXPORTALL	6
extern  exports * mountproc_exportall_1(void *, CLIENT *);
extern  exports * mountproc_exportall_1_svc(void *, struct svc_req *);
extern int mountprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	MOUNTPROC_NULL	0
extern  void * mountproc_null_1();
extern  void * mountproc_null_1_svc();
#define	MOUNTPROC_MNT	1
extern  fhstatus * mountproc_mnt_1();
extern  fhstatus * mountproc_mnt_1_svc();
#define	MOUNTPROC_DUMP	2
extern  mountlist * mountproc_dump_1();
extern  mountlist * mountproc_dump_1_svc();
#define	MOUNTPROC_UMNT	3
extern  void * mountproc_umnt_1();
extern  void * mountproc_umnt_1_svc();
#define	MOUNTPROC_UMNTALL	4
extern  void * mountproc_umntall_1();
extern  void * mountproc_umntall_1_svc();
#define	MOUNTPROC_EXPORT	5
extern  exports * mountproc_export_1();
extern  exports * mountproc_export_1_svc();
#define	MOUNTPROC_EXPORTALL	6
extern  exports * mountproc_exportall_1();
extern  exports * mountproc_exportall_1_svc();
extern int mountprog_1_freeresult();
#endif /* K&R C */
#define	MOUNTVERS_POSIX	2

#if defined(__STDC__) || defined(__cplusplus)
extern  void * mountproc_null_2(void *, CLIENT *);
extern  void * mountproc_null_2_svc(void *, struct svc_req *);
extern  fhstatus * mountproc_mnt_2(dirpath *, CLIENT *);
extern  fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *);
extern  mountlist * mountproc_dump_2(void *, CLIENT *);
extern  mountlist * mountproc_dump_2_svc(void *, struct svc_req *);
extern  void * mountproc_umnt_2(dirpath *, CLIENT *);
extern  void * mountproc_umnt_2_svc(dirpath *, struct svc_req *);
extern  void * mountproc_umntall_2(void *, CLIENT *);
extern  void * mountproc_umntall_2_svc(void *, struct svc_req *);
extern  exports * mountproc_export_2(void *, CLIENT *);
extern  exports * mountproc_export_2_svc(void *, struct svc_req *);
extern  exports * mountproc_exportall_2(void *, CLIENT *);
extern  exports * mountproc_exportall_2_svc(void *, struct svc_req *);
#define	MOUNTPROC_PATHCONF	7
extern  ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *);
extern  ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *);
extern int mountprog_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
extern  void * mountproc_null_2();
extern  void * mountproc_null_2_svc();
extern  fhstatus * mountproc_mnt_2();
extern  fhstatus * mountproc_mnt_2_svc();
extern  mountlist * mountproc_dump_2();
extern  mountlist * mountproc_dump_2_svc();
extern  void * mountproc_umnt_2();
extern  void * mountproc_umnt_2_svc();
extern  void * mountproc_umntall_2();
extern  void * mountproc_umntall_2_svc();
extern  exports * mountproc_export_2();
extern  exports * mountproc_export_2_svc();
extern  exports * mountproc_exportall_2();
extern  exports * mountproc_exportall_2_svc();
#define	MOUNTPROC_PATHCONF	7
extern  ppathcnf * mountproc_pathconf_2();
extern  ppathcnf * mountproc_pathconf_2_svc();
extern int mountprog_2_freeresult();
#endif /* K&R C */
#define	MOUNTVERS3	3

#if defined(__STDC__) || defined(__cplusplus)
extern  void * mountproc_null_3(void *, CLIENT *);
extern  void * mountproc_null_3_svc(void *, struct svc_req *);
extern  mountres3 * mountproc_mnt_3(dirpath *, CLIENT *);
extern  mountres3 * mountproc_mnt_3_svc(dirpath *, struct svc_req *);
extern  mountlist * mountproc_dump_3(void *, CLIENT *);
extern  mountlist * mountproc_dump_3_svc(void *, struct svc_req *);
extern  void * mountproc_umnt_3(dirpath *, CLIENT *);
extern  void * mountproc_umnt_3_svc(dirpath *, struct svc_req *);
extern  void * mountproc_umntall_3(void *, CLIENT *);
extern  void * mountproc_umntall_3_svc(void *, struct svc_req *);
extern  exports * mountproc_export_3(void *, CLIENT *);
extern  exports * mountproc_export_3_svc(void *, struct svc_req *);
extern int mountprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
extern  void * mountproc_null_3();
extern  void * mountproc_null_3_svc();
extern  mountres3 * mountproc_mnt_3();
extern  mountres3 * mountproc_mnt_3_svc();
extern  mountlist * mountproc_dump_3();
extern  mountlist * mountproc_dump_3_svc();
extern  void * mountproc_umnt_3();
extern  void * mountproc_umnt_3_svc();
extern  void * mountproc_umntall_3();
extern  void * mountproc_umntall_3_svc();
extern  exports * mountproc_export_3();
extern  exports * mountproc_export_3_svc();
extern int mountprog_3_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_fhandle(XDR *, fhandle);
extern  bool_t xdr_fhandle3(XDR *, fhandle3*);
extern  bool_t xdr_fhstatus(XDR *, fhstatus*);
extern  bool_t xdr_mountstat3(XDR *, mountstat3*);
extern  bool_t xdr_mountres3_ok(XDR *, mountres3_ok*);
extern  bool_t xdr_mountres3(XDR *, mountres3*);
extern  bool_t xdr_dirpath(XDR *, dirpath*);
extern  bool_t xdr_name(XDR *, name*);
extern  bool_t xdr_mountlist(XDR *, mountlist*);
extern  bool_t xdr_mountbody(XDR *, mountbody*);
extern  bool_t xdr_groups(XDR *, groups*);
extern  bool_t xdr_groupnode(XDR *, groupnode*);
extern  bool_t xdr_exports(XDR *, exports*);
extern  bool_t xdr_exportnode(XDR *, exportnode*);
extern  bool_t xdr_ppathcnf(XDR *, ppathcnf*);

#else /* K&R C */
extern bool_t xdr_fhandle();
extern bool_t xdr_fhandle3();
extern bool_t xdr_fhstatus();
extern bool_t xdr_mountstat3();
extern bool_t xdr_mountres3_ok();
extern bool_t xdr_mountres3();
extern bool_t xdr_dirpath();
extern bool_t xdr_name();
extern bool_t xdr_mountlist();
extern bool_t xdr_mountbody();
extern bool_t xdr_groups();
extern bool_t xdr_groupnode();
extern bool_t xdr_exports();
extern bool_t xdr_exportnode();
extern bool_t xdr_ppathcnf();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_MOUNT_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright (c) 1988,1990-1992,1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * Protocol description for the mount program
 */

const MNTPATHLEN = 1024;	/* maximum bytes in a pathname argument */
const MNTNAMLEN = 255;		/* maximum bytes in a name argument */
const FHSIZE = 32;		/* size in bytes of a v2 file handle */
const FHSIZE3 = 64;		/*  "   "    "   "  " v3  "     "    */

/*
 * The fhandle is the file handle that the server passes to the client.
 * All file operations are done using the file handles to refer to a file
 * or a directory. The file handle can contain whatever information the
 * server needs to distinguish an individual file.
 *
 * Versions 1 and 2 of the protocol share a filehandle of 32 bytes.
 *
 * Version 3 supports a 64 byte filehandle that can be used only
 * with version 3 of the NFS protocol.
 */

typedef opaque fhandle[FHSIZE];
typedef opaque fhandle3<FHSIZE3>;

/*
 * If a V2 status of zero is returned, the call completed successfully, and
 * a file handle for the directory follows. A non-zero status indicates
 * some sort of error. The status corresponds with UNIX error numbers.
 */
union fhstatus switch (unsigned fhs_status) {
case 0:
	fhandle fhs_fhandle;
default:
	void;
};

/*
 * This #define is added for backwards compatability with applications
 * which reference the old style fhstatus.  The second element of that
 * structure was called fhs_fh, instead of the current fhs_fhandle.
 */
%
%#define	fhs_fh	fhstatus_u.fhs_fhandle

/*
 * The following status codes are defined for the V3 mount service:
 * Note that the precise enum encoding must be followed; the values
 * are derived from existing implementation practice, and there is
 * no good reason to disturb them.
 */
enum mountstat3 {
        MNT_OK= 0,              /* no error */
        MNT3ERR_PERM=1,         /* Not owner */
        MNT3ERR_NOENT=2,        /* No such file or directory */
        MNT3ERR_IO=5,           /* I/O error */
        MNT3ERR_ACCES=13,       /* Permission denied */
        MNT3ERR_NOTDIR=20,      /* Not a directory*/
        MNT3ERR_INVAL=22,       /* Invalid argument.*/
        MNT3ERR_NAMETOOLONG=63, /* File name too long */
        MNT3ERR_NOTSUPP=10004,  /* operation not supported */
        MNT3ERR_SERVERFAULT=10006 /* An i/o or similar failure caused */
                                /* the server to abandon the request */
                                /* No attributes can be returned. The */
                                /* client should translate this into EIO */
};

/*
 * A V3 server returns a file handle and a list of the authentication
 * flavors that the server will accept for this mount.  If the list
 * is empty, AUTH_UNIX is required.  Otherwise, any of the flavors
 * listed in auth_flavors<> may be used (but no others).
 * The values of the authentication flavors are defined in the
 * underlying RPC protocol.
 */
struct mountres3_ok {
	fhandle3 fhandle;
	int auth_flavors<>;
};

/*
 * If a V3 status of MNT_OK is returned, the call completed successfully, and
 * a file handle for the directory follows. Any other status indicates
 * some sort of error.
 */

union mountres3 switch (mountstat3 fhs_status) {
case MNT_OK:
        mountres3_ok mountinfo;
default:
        void;
};

/*
 * The type dirpath is the pathname of a directory
 */
typedef string dirpath<MNTPATHLEN>;

/*
 * The type name is used for arbitrary names (hostnames, groupnames)
 */
typedef string name<MNTNAMLEN>;

/*
 * A list of who has what mounted. This information is
 * strictly advisory, since there is no mechanism to
 * enforce the removal of stale information. The strongest
 * assertion that can be made is that if a hostname:directory
 * pair appears in the list, the server has exported the
 * directory to that client at some point since the server
 * export data base was (re)initialized. Note also that there
 * is no limit on the length of the information returned
 * in this structure, and this may cause problems if the
 * mount service is accessed via a connectionless transport.
 *
 * The ifdef will ensure that these are only carried over to
 * mount.h - no xdr routines will be generated. We want to
 * do these by hand, to avoid the recursive stack-blowing ones
 * that rpcgen will generate.
 */
#ifdef RPC_HDR
typedef struct mountbody *mountlist;
struct mountbody {
	name ml_hostname;
	dirpath ml_directory;
	mountlist ml_next;
};
#endif /* RPC_HDR */

/*
 * A list of netgroups
 */
typedef struct groupnode *groups;
struct groupnode {
	name gr_name;
	groups gr_next;
};

/*
 * A list of what is exported and to whom
 */
typedef struct exportnode *exports;
struct exportnode {
	dirpath ex_dir;
	groups ex_groups;
	exports ex_next;
};

/*
 * POSIX pathconf information
 */
struct ppathcnf {
	int	pc_link_max;	/* max links allowed */
	short	pc_max_canon;	/* max line len for a tty */
	short	pc_max_input;	/* input a tty can eat all at once */
	short	pc_name_max;	/* max file name length (dir entry) */
	short	pc_path_max;	/* max path name length (/x/y/x/.. ) */
	short	pc_pipe_buf;	/* size of a pipe (bytes) */
	u_char	pc_vdisable;	/* safe char to turn off c_cc[i] */
	char	pc_xxx;		/* alignment padding; cc_t == char */
	short	pc_mask[2];	/* validity and boolean bits */
};

program MOUNTPROG {
	/*
	 * Version one of the mount protocol communicates with version two
	 * of the NFS protocol. The only connecting point is the fhandle
	 * structure, which is the same for both protocols.
	 */
	version MOUNTVERS {
		/*
		 * Does no work. It is made available in all RPC services
		 * to allow server reponse testing and timing
		 */
		void
		MOUNTPROC_NULL(void) = 0;

		/*
		 * If fhs_status is 0, then fhs_fhandle contains the
	 	 * file handle for the directory. This file handle may
		 * be used in the NFS protocol. This procedure also adds
		 * a new entry to the mount list for this client mounting
		 * the directory.
		 * Unix authentication required.
		 */
		fhstatus
		MOUNTPROC_MNT(dirpath) = 1;

		/*
		 * Returns the list of remotely mounted filesystems. The
		 * mountlist contains one entry for each hostname and
		 * directory pair.
		 */
		mountlist
		MOUNTPROC_DUMP(void) = 2;

		/*
		 * Removes the mount list entry for the directory
		 * Unix authentication required.
		 */
		void
		MOUNTPROC_UMNT(dirpath) = 3;

		/*
		 * Removes all of the mount list entries for this client
		 * Unix authentication required.
		 */
		void
		MOUNTPROC_UMNTALL(void) = 4;

		/*
		 * Returns a list of all the exported filesystems, and which
		 * machines are allowed to import it.
		 */
		exports
		MOUNTPROC_EXPORT(void)  = 5;

		/*
		 * Identical to MOUNTPROC_EXPORT above
		 */
		exports
		MOUNTPROC_EXPORTALL(void) = 6;
	} = 1;

	/*
	 * Version two of the mount protocol communicates with version two
	 * of the NFS protocol. It is identical to version one except for a
	 * new procedure call for posix.
	 */
	version MOUNTVERS_POSIX {
		/*
		 * Does no work. It is made available in all RPC services
		 * to allow server reponse testing and timing
		 */
		void
		MOUNTPROC_NULL(void) = 0;

		/*
		 * If fhs_status is 0, then fhs_fhandle contains the
	 	 * file handle for the directory. This file handle may
		 * be used in the NFS protocol. This procedure also adds
		 * a new entry to the mount list for this client mounting
		 * the directory.
		 * Unix authentication required.
		 */
		fhstatus
		MOUNTPROC_MNT(dirpath) = 1;

		/*
		 * Returns the list of remotely mounted filesystems. The
		 * mountlist contains one entry for each hostname and
		 * directory pair.
		 */
		mountlist
		MOUNTPROC_DUMP(void) = 2;

		/*
		 * Removes the mount list entry for the directory
		 * Unix authentication required.
		 */
		void
		MOUNTPROC_UMNT(dirpath) = 3;

		/*
		 * Removes all of the mount list entries for this client
		 * Unix authentication required.
		 */
		void
		MOUNTPROC_UMNTALL(void) = 4;

		/*
		 * Returns a list of all the exported filesystems, and which
		 * machines are allowed to import it.
		 */
		exports
		MOUNTPROC_EXPORT(void)  = 5;

		/*
		 * Identical to MOUNTPROC_EXPORT above
		 */
		exports
		MOUNTPROC_EXPORTALL(void) = 6;

		/*
		 * Posix info over the wire isn't supported in NFS version 2
		 * so we get it here at mount time.
		 */
		ppathcnf
		MOUNTPROC_PATHCONF(dirpath) = 7;
	} = 2;

	/*
	 * Version 3 of the mount protocol communicates with version 3
	 * of the NFS protocol. The only connecting point is the nfs_fh3
	 * structure, which is the same for both protocols.
	 *
	 * The only significant change over version 2 is that MOUNTPROC_MNT
	 * returns a longer filehandle (64 bytes instead of 32) as well
	 * as authentication information.  MOUNTPROC_PATHCONF is subsumed
	 * into V3 of the NFS protocol and MOUNTPROC_EXPORTALL is eliminated.
	 */
	version MOUNTVERS3 {
		/*
		 * Does no work. It is made available in all RPC services
		 * to allow server reponse testing and timing
		 */
		void
		MOUNTPROC_NULL(void) = 0;

		/*
		 * Mount a file system.
		 *
		 * If mountres.fhs_status is NFS_OK, then mountres.mountinfo
		 * contains the file handle for the directory and
		 * a list of acceptable authentication flavors. This file
		 * handle may only be used in version 3 of the NFS protocol.
		 * This procedure also results in the server adding a new
		 * entry to its mount list recording that this client has
		 * mounted the directory. Unix authentication or better
		 * is required.
		 */
		mountres3
		MOUNTPROC_MNT(dirpath) = 1;

		/*
		 * Returns the list of remotely mounted filesystems. The
		 * mountlist contains one entry for each hostname and
		 * directory pair.
		 */
		mountlist
		MOUNTPROC_DUMP(void) = 2;

		/*
		 * Removes the mount list entry for the directory
		 * Unix authentication or better is required.
		 */
		void
		MOUNTPROC_UMNT(dirpath) = 3;

		/*
		 * Removes all of the mount list entries for this client
		 * Unix authentication or better is required.
		 */
		void
		MOUNTPROC_UMNTALL(void) = 4;

		/*
		 * Returns a list of all the exported filesystems, and which
		 * machines are allowed to import each one.
		 */
		exports
		MOUNTPROC_EXPORT(void)  = 5;

	} = 3;
} = 100005;
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _NFS4_PROT_H_RPCGEN
#define	_NFS4_PROT_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _AUTH_SYS_DEFINE_FOR_NFSv42
#define _AUTH_SYS_DEFINE_FOR_NFSv42
#include <rpc/auth_sys.h>
typedef struct authsys_parms authsys_parms;
#endif /* _AUTH_SYS_DEFINE_FOR_NFSv42 */
#define	NFS4_FHSIZE 128
#define	NFS4_VERIFIER_SIZE 8
#define	NFS4_OTHER_SIZE 12
#define	NFS4_OPAQUE_LIMIT 1024
#define	NFS4_SESSIONID_SIZE 16
#define	NFS4_INT64_MAX 0x7fffffffffffffff
#define	NFS4_UINT64_MAX 0xffffffffffffffff
#define	NFS4_INT32_MAX 0x7fffffff
#define	NFS4_UINT32_MAX 0xffffffff
#define	NFS4_MAXFILELEN 0xffffffffffffffff
#define	NFS4_MAXFILEOFF 0xfffffffffffffffe

enum nfs_ftype4 {
	NF4REG = 1,
	NF4DIR = 2,
	NF4BLK = 3,
	NF4CHR = 4,
	NF4LNK = 5,
	NF4SOCK = 6,
	NF4FIFO = 7,
	NF4ATTRDIR = 8,
	NF4NAMEDATTR = 9
};
typedef enum nfs_ftype4 nfs_ftype4;

enum nfsstat4 {
	NFS4_OK = 0,
	NFS4ERR_PERM = 1,
	NFS4ERR_NOENT = 2,
	NFS4ERR_IO = 5,
	NFS4ERR_NXIO = 6,
	NFS4ERR_ACCESS = 13,
	NFS4ERR_EXIST = 17,
	NFS4ERR_XDEV = 18,
	NFS4ERR_NOTDIR = 20,
	NFS4ERR_ISDIR = 21,
	NFS4ERR_INVAL = 22,
	NFS4ERR_FBIG = 27,
	NFS4ERR_NOSPC = 28,
	NFS4ERR_ROFS = 30,
	NFS4ERR_MLINK = 31,
	NFS4ERR_NAMETOOLONG = 63,
	NFS4ERR_NOTEMPTY = 66,
	NFS4ERR_DQUOT = 69,
	NFS4ERR_STALE = 70,
	NFS4ERR_BADHANDLE = 10001,
	NFS4ERR_BAD_COOKIE = 10003,
	NFS4ERR_NOTSUPP = 10004,
	NFS4ERR_TOOSMALL = 10005,
	NFS4ERR_SERVERFAULT = 10006,
	NFS4ERR_BADTYPE = 10007,
	NFS4ERR_DELAY = 10008,
	NFS4ERR_SAME = 10009,
	NFS4ERR_DENIED = 10010,
	NFS4ERR_EXPIRED = 10011,
	NFS4ERR_LOCKED = 10012,
	NFS4ERR_GRACE = 10013,
	NFS4ERR_FHEXPIRED = 10014,
	NFS4ERR_SHARE_DENIED = 10015,
	NFS4ERR_WRONGSEC = 10016,
	NFS4ERR_CLID_INUSE = 10017,
	NFS4ERR_RESOURCE = 10018,
	NFS4ERR_MOVED = 10019,
	NFS4ERR_NOFILEHANDLE = 10020,
	NFS4ERR_MINOR_VERS_MISMATCH = 10021,
	NFS4ERR_STALE_CLIENTID = 10022,
	NFS4ERR_STALE_STATEID = 10023,
	NFS4ERR_OLD_STATEID = 10024,
	NFS4ERR_BAD_STATEID = 10025,
	NFS4ERR_BAD_SEQID = 10026,
	NFS4ERR_NOT_SAME = 10027,
	NFS4ERR_LOCK_RANGE = 10028,
	NFS4ERR_SYMLINK = 10029,
	NFS4ERR_RESTOREFH = 10030,
	NFS4ERR_LEASE_MOVED = 10031,
	NFS4ERR_ATTRNOTSUPP = 10032,
	NFS4ERR_NO_GRACE = 10033,
	NFS4ERR_RECLAIM_BAD = 10034,
	NFS4ERR_RECLAIM_CONFLICT = 10035,
	NFS4ERR_BADXDR = 10036,
	NFS4ERR_LOCKS_HELD = 10037,
	NFS4ERR_OPENMODE = 10038,
	NFS4ERR_BADOWNER = 10039,
	NFS4ERR_BADCHAR = 10040,
	NFS4ERR_BADNAME = 10041,
	NFS4ERR_BAD_RANGE = 10042,
	NFS4ERR_LOCK_NOTSUPP = 10043,
	NFS4ERR_OP_ILLEGAL = 10044,
	NFS4ERR_DEADLOCK = 10045,
	NFS4ERR_FILE_OPEN = 10046,
	NFS4ERR_ADMIN_REVOKED = 10047,
	NFS4ERR_CB_PATH_DOWN = 10048,
	NFS4ERR_BADIOMODE = 10049,
	NFS4ERR_BADLAYOUT = 10050,
	NFS4ERR_BAD_SESSION_DIGEST = 10051,
	NFS4ERR_BADSESSION = 10052,
	NFS4ERR_BADSLOT = 10053,
	NFS4ERR_COMPLETE_ALREADY = 10054,
	NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
	NFS4ERR_DELEG_ALREADY_WANTED = 10056,
	NFS4ERR_BACK_CHAN_BUSY = 10057,
	NFS4ERR_LAYOUTTRYLATER = 10058,
	NFS4ERR_LAYOUTUNAVAILABLE = 10059,
	NFS4ERR_NOMATCHING_LAYOUT = 10060,
	NFS4ERR_RECALLCONFLICT = 10061,
	NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
	NFS4ERR_SEQ_MISORDERED = 10063,
	NFS4ERR_SEQUENCE_POS = 10064,
	NFS4ERR_REQ_TOO_BIG = 10065,
	NFS4ERR_REP_TOO_BIG = 10066,
	NFS4ERR_REP_TOO_BIG_TO_CACHE = 10067,
	NFS4ERR_RETRY_UNCACHED_REP = 10068,
	NFS4ERR_UNSAFE_COMPOUND = 10069,
	NFS4ERR_TOO_MANY_OPS = 10070,
	NFS4ERR_OP_NOT_IN_SESSION = 10071,
	NFS4ERR_HASH_ALG_UNSUPP = 10072,
	NFS4ERR_CLIENTID_BUSY = 10074,
	NFS4ERR_PNFS_IO_HOLE = 10075,
	NFS4ERR_SEQ_FALSE_RETRY = 10076,
	NFS4ERR_BAD_HIGH_SLOT = 10077,
	NFS4ERR_DEADSESSION = 10078,
	NFS4ERR_ENCR_ALG_UNSUPP = 10079,
	NFS4ERR_PNFS_NO_LAYOUT = 10080,
	NFS4ERR_NOT_ONLY_OP = 10081,
	NFS4ERR_WRONG_CRED = 10082,
	NFS4ERR_WRONG_TYPE = 10083,
	NFS4ERR_DIRDELEG_UNAVAIL = 10084,
	NFS4ERR_REJECT_DELEG = 10085,
	NFS4ERR_RETURNCONFLICT = 10086,
	NFS4ERR_DELEG_REVOKED = 10087,
	NFS4ERR_PARTNER_NOTSUPP = 10088,
	NFS4ERR_PARTNER_NO_AUTH = 10089,
	NFS4ERR_UNION_NOTSUPP = 10090,
	NFS4ERR_OFFLOAD_DENIED = 10091,
	NFS4ERR_WRONG_LFS = 10092,
	NFS4ERR_BADLABEL = 10093,
	NFS4ERR_OFFLOAD_NO_REQS = 10094
};
typedef enum nfsstat4 nfsstat4;

typedef struct {
	u_int attrlist4_len;
	char *attrlist4_val;
} attrlist4;

typedef struct {
	u_int bitmap4_len;
	uint32_t *bitmap4_val;
} bitmap4;

typedef uint64_t changeid4;

typedef uint64_t clientid4;

typedef uint32_t count4;

typedef uint64_t length4;

typedef uint32_t mode4;

typedef uint64_t nfs_cookie4;

typedef struct {
	u_int nfs_fh4_len;
	char *nfs_fh4_val;
} nfs_fh4;

typedef uint64_t offset4;

typedef uint32_t qop4;

typedef struct {
	u_int sec_oid4_len;
	char *sec_oid4_val;
} sec_oid4;

typedef uint32_t sequenceid4;

typedef uint32_t seqid4;

typedef char sessionid4[NFS4_SESSIONID_SIZE];

typedef uint32_t slotid4;

typedef struct {
	u_int utf8string_len;
	char *utf8string_val;
} utf8string;

typedef utf8string utf8str_cis;

typedef utf8string utf8str_cs;

typedef utf8string utf8str_mixed;

typedef utf8str_cs component4;

typedef struct {
	u_int linktext4_len;
	char *linktext4_val;
} linktext4;

typedef utf8string ascii_REQUIRED4;

typedef struct {
	u_int pathname4_len;
	component4 *pathname4_val;
} pathname4;

typedef char verifier4[NFS4_VERIFIER_SIZE];

typedef char *secret4;

typedef uint32_t policy4;

struct nfstime4 {
	int64_t seconds;
	uint32_t nseconds;
};
typedef struct nfstime4 nfstime4;

enum time_how4 {
	SET_TO_SERVER_TIME4 = 0,
	SET_TO_CLIENT_TIME4 = 1
};
typedef enum time_how4 time_how4;

struct settime4 {
	time_how4 set_it;
	union {
		nfstime4 time;
	} settime4_u;
};
typedef struct settime4 settime4;

typedef uint32_t nfs_lease4;

struct fsid4 {
	uint64_t major;
	uint64_t minor;
};
typedef struct fsid4 fsid4;

struct change_policy4 {
	uint64_t cp_major;
	uint64_t cp_minor;
};
typedef struct change_policy4 change_policy4;

struct fs_location4 {
	struct {
		u_int server_len;
		utf8str_cis *server_val;
	} server;
	pathname4 rootpath;
};
typedef struct fs_location4 fs_location4;

struct fs_locations4 {
	pathname4 fs_root;
	struct {
		u_int locations_len;
		fs_location4 *locations_val;
	} locations;
};
typedef struct fs_locations4 fs_locations4;
#define	ACL4_SUPPORT_ALLOW_ACL 0x00000001
#define	ACL4_SUPPORT_DENY_ACL 0x00000002
#define	ACL4_SUPPORT_AUDIT_ACL 0x00000004
#define	ACL4_SUPPORT_ALARM_ACL 0x00000008

typedef uint32_t acetype4;
#define	ACE4_ACCESS_ALLOWED_ACE_TYPE 0x00000000
#define	ACE4_ACCESS_DENIED_ACE_TYPE 0x00000001
#define	ACE4_SYSTEM_AUDIT_ACE_TYPE 0x00000002
#define	ACE4_SYSTEM_ALARM_ACE_TYPE 0x00000003

typedef uint32_t aceflag4;
#define	ACE4_FILE_INHERIT_ACE 0x00000001
#define	ACE4_DIRECTORY_INHERIT_ACE 0x00000002
#define	ACE4_NO_PROPAGATE_INHERIT_ACE 0x00000004
#define	ACE4_INHERIT_ONLY_ACE 0x00000008
#define	ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
#define	ACE4_FAILED_ACCESS_ACE_FLAG 0x00000020
#define	ACE4_IDENTIFIER_GROUP 0x00000040
#define	ACE4_INHERITED_ACE 0x00000080

typedef uint32_t acemask4;
#define	ACE4_READ_DATA 0x00000001
#define	ACE4_LIST_DIRECTORY 0x00000001
#define	ACE4_WRITE_DATA 0x00000002
#define	ACE4_ADD_FILE 0x00000002
#define	ACE4_APPEND_DATA 0x00000004
#define	ACE4_ADD_SUBDIRECTORY 0x00000004
#define	ACE4_READ_NAMED_ATTRS 0x00000008
#define	ACE4_WRITE_NAMED_ATTRS 0x00000010
#define	ACE4_EXECUTE 0x00000020
#define	ACE4_DELETE_CHILD 0x00000040
#define	ACE4_READ_ATTRIBUTES 0x00000080
#define	ACE4_WRITE_ATTRIBUTES 0x00000100
#define	ACE4_WRITE_RETENTION 0x00000200
#define	ACE4_WRITE_RETENTION_HOLD 0x00000400
#define	ACE4_DELETE 0x00010000
#define	ACE4_READ_ACL 0x00020000
#define	ACE4_WRITE_ACL 0x00040000
#define	ACE4_WRITE_OWNER 0x00080000
#define	ACE4_SYNCHRONIZE 0x00100000
#define	ACE4_GENERIC_READ 0x00120081
#define	ACE4_GENERIC_WRITE 0x00160106
#define	ACE4_GENERIC_EXECUTE 0x001200A0

struct nfsace4 {
	acetype4 type;
	aceflag4 flag;
	acemask4 access_mask;
	utf8str_mixed who;
};
typedef struct nfsace4 nfsace4;

typedef uint32_t aclflag4;
#define	ACL4_AUTO_INHERIT 0x00000001
#define	ACL4_PROTECTED 0x00000002
#define	ACL4_DEFAULTED 0x00000004

struct nfsacl41 {
	aclflag4 na41_flag;
	struct {
		u_int na41_aces_len;
		nfsace4 *na41_aces_val;
	} na41_aces;
};
typedef struct nfsacl41 nfsacl41;
#define	MODE4_SUID 0x800
#define	MODE4_SGID 0x400
#define	MODE4_SVTX 0x200
#define	MODE4_RUSR 0x100
#define	MODE4_WUSR 0x080
#define	MODE4_XUSR 0x040
#define	MODE4_RGRP 0x020
#define	MODE4_WGRP 0x010
#define	MODE4_XGRP 0x008
#define	MODE4_ROTH 0x004
#define	MODE4_WOTH 0x002
#define	MODE4_XOTH 0x001

struct mode_masked4 {
	mode4 mm_value_to_set;
	mode4 mm_mask_bits;
};
typedef struct mode_masked4 mode_masked4;

struct specdata4 {
	uint32_t specdata1;
	uint32_t specdata2;
};
typedef struct specdata4 specdata4;
#define	FH4_PERSISTENT 0x00000000
#define	FH4_NOEXPIRE_WITH_OPEN 0x00000001
#define	FH4_VOLATILE_ANY 0x00000002
#define	FH4_VOL_MIGRATION 0x00000004
#define	FH4_VOL_RENAME 0x00000008

struct netaddr4 {
	char *na_r_netid;
	char *na_r_addr;
};
typedef struct netaddr4 netaddr4;

struct nfs_impl_id4 {
	utf8str_cis nii_domain;
	utf8str_cs nii_name;
	nfstime4 nii_date;
};
typedef struct nfs_impl_id4 nfs_impl_id4;

struct stateid4 {
	uint32_t seqid;
	char other[NFS4_OTHER_SIZE];
};
typedef struct stateid4 stateid4;

enum layouttype4 {
	LAYOUT4_NFSV4_1_FILES = 0x1,
	LAYOUT4_OSD2_OBJECTS = 0x2,
	LAYOUT4_BLOCK_VOLUME = 0x3
};
typedef enum layouttype4 layouttype4;

struct layout_content4 {
	layouttype4 loc_type;
	struct {
		u_int loc_body_len;
		char *loc_body_val;
	} loc_body;
};
typedef struct layout_content4 layout_content4;
/*
 * LAYOUT4_OSD2_OBJECTS loc_body description
 * is in a separate .x file.
 */

/*
 * LAYOUT4_BLOCK_VOLUME loc_body description
 * is in a separate .x file.
 */

struct layouthint4 {
	layouttype4 loh_type;
	struct {
		u_int loh_body_len;
		char *loh_body_val;
	} loh_body;
};
typedef struct layouthint4 layouthint4;

enum layoutiomode4 {
	LAYOUTIOMODE4_READ = 1,
	LAYOUTIOMODE4_RW = 2,
	LAYOUTIOMODE4_ANY = 3
};
typedef enum layoutiomode4 layoutiomode4;

struct layout4 {
	offset4 lo_offset;
	length4 lo_length;
	layoutiomode4 lo_iomode;
	layout_content4 lo_content;
};
typedef struct layout4 layout4;
#define	NFS4_DEVICEID4_SIZE 16

typedef char deviceid4[NFS4_DEVICEID4_SIZE];

struct device_addr4 {
	layouttype4 da_layout_type;
	struct {
		u_int da_addr_body_len;
		char *da_addr_body_val;
	} da_addr_body;
};
typedef struct device_addr4 device_addr4;

struct layoutupdate4 {
	layouttype4 lou_type;
	struct {
		u_int lou_body_len;
		char *lou_body_val;
	} lou_body;
};
typedef struct layoutupdate4 layoutupdate4;

#define	LAYOUT4_RET_REC_FILE 1
#define	LAYOUT4_RET_REC_FSID 2
#define	LAYOUT4_RET_REC_ALL 3


enum layoutreturn_type4 {
	LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE,
	LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID,
	LAYOUTRETURN4_ALL = LAYOUT4_RET_REC_ALL
};
typedef enum layoutreturn_type4 layoutreturn_type4;
 /* layouttype4 specific data */

struct layoutreturn_file4 {
	offset4 lrf_offset;
	length4 lrf_length;
	stateid4 lrf_stateid;
	struct {
		u_int lrf_body_len;
		char *lrf_body_val;
	} lrf_body;
};
typedef struct layoutreturn_file4 layoutreturn_file4;

struct layoutreturn4 {
	layoutreturn_type4 lr_returntype;
	union {
		layoutreturn_file4 lr_layout;
	} layoutreturn4_u;
};
typedef struct layoutreturn4 layoutreturn4;


enum fs4_status_type {
	STATUS4_FIXED = 1,
	STATUS4_UPDATED = 2,
	STATUS4_VERSIONED = 3,
	STATUS4_WRITABLE = 4,
	STATUS4_REFERRAL = 5
};
typedef enum fs4_status_type fs4_status_type;

struct fs4_status {
	bool_t fss_absent;
	fs4_status_type fss_type;
	utf8str_cs fss_source;
	utf8str_cs fss_current;
	int32_t fss_age;
	nfstime4 fss_version;
};
typedef struct fs4_status fs4_status;
#define	TH4_READ_SIZE 0
#define	TH4_WRITE_SIZE 1
#define	TH4_READ_IOSIZE 2
#define	TH4_WRITE_IOSIZE 3

typedef length4 threshold4_read_size;

typedef length4 threshold4_write_size;

typedef length4 threshold4_read_iosize;

typedef length4 threshold4_write_iosize;

struct threshold_item4 {
	layouttype4 thi_layout_type;
	bitmap4 thi_hintset;
	struct {
		u_int thi_hintlist_len;
		char *thi_hintlist_val;
	} thi_hintlist;
};
typedef struct threshold_item4 threshold_item4;

struct mdsthreshold4 {
	struct {
		u_int mth_hints_len;
		threshold_item4 *mth_hints_val;
	} mth_hints;
};
typedef struct mdsthreshold4 mdsthreshold4;
#define	RET4_DURATION_INFINITE 0xffffffffffffffff

struct retention_get4 {
	uint64_t rg_duration;
	struct {
		u_int rg_begin_time_len;
		nfstime4 *rg_begin_time_val;
	} rg_begin_time;
};
typedef struct retention_get4 retention_get4;

struct retention_set4 {
	bool_t rs_enable;
	struct {
		u_int rs_duration_len;
		uint64_t *rs_duration_val;
	} rs_duration;
};
typedef struct retention_set4 retention_set4;
#define	FSCHARSET_CAP4_CONTAINS_NON_UTF8 0x1
#define	FSCHARSET_CAP4_ALLOWS_ONLY_UTF8 0x2

typedef uint32_t fs_charset_cap4;

enum netloc_type4 {
	NL4_NAME = 1,
	NL4_URL = 2,
	NL4_NETADDR = 3
};
typedef enum netloc_type4 netloc_type4;

struct netloc4 {
	netloc_type4 nl_type;
	union {
		utf8str_cis nl_name;
		utf8str_cis nl_url;
		netaddr4 nl_addr;
	} netloc4_u;
};
typedef struct netloc4 netloc4;

enum change_attr_type4 {
	NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR = 0,
	NFS4_CHANGE_TYPE_IS_VERSION_COUNTER = 1,
	NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2,
	NFS4_CHANGE_TYPE_IS_TIME_METADATA = 3,
	NFS4_CHANGE_TYPE_IS_UNDEFINED = 4
};
typedef enum change_attr_type4 change_attr_type4;

struct labelformat_spec4 {
	policy4 lfs_lfs;
	policy4 lfs_pi;
};
typedef struct labelformat_spec4 labelformat_spec4;

struct sec_label4 {
	labelformat_spec4 slai_lfs;
	struct {
		u_int slai_data_len;
		char *slai_data_val;
	} slai_data;
};
typedef struct sec_label4 sec_label4;

struct copy_from_auth_priv {
	secret4 cfap_shared_secret;
	netloc4 cfap_destination;
	utf8str_mixed cfap_username;
};
typedef struct copy_from_auth_priv copy_from_auth_priv;

struct copy_to_auth_priv {
	secret4 ctap_shared_secret;
	struct {
		u_int ctap_source_len;
		netloc4 *ctap_source_val;
	} ctap_source;
	utf8str_mixed ctap_username;
};
typedef struct copy_to_auth_priv copy_to_auth_priv;

struct copy_confirm_auth_priv {
	struct {
		u_int ccap_shared_secret_mic_len;
		char *ccap_shared_secret_mic_val;
	} ccap_shared_secret_mic;
	utf8str_mixed ccap_username;
};
typedef struct copy_confirm_auth_priv copy_confirm_auth_priv;

struct app_data_block4 {
	offset4 adb_offset;
	length4 adb_block_size;
	length4 adb_block_count;
	length4 adb_reloff_blocknum;
	count4 adb_block_num;
	length4 adb_reloff_pattern;
	struct {
		u_int adb_pattern_len;
		char *adb_pattern_val;
	} adb_pattern;
};
typedef struct app_data_block4 app_data_block4;

struct data4 {
	offset4 d_offset;
	struct {
		u_int d_data_len;
		char *d_data_val;
	} d_data;
};
typedef struct data4 data4;

struct data_info4 {
	offset4 di_offset;
	length4 di_length;
};
typedef struct data_info4 data_info4;

enum data_content4 {
	NFS4_CONTENT_DATA = 0,
	NFS4_CONTENT_HOLE = 1
};
typedef enum data_content4 data_content4;

enum stable_how4 {
	UNSTABLE4 = 0,
	DATA_SYNC4 = 1,
	FILE_SYNC4 = 2
};
typedef enum stable_how4 stable_how4;

struct write_response4 {
	struct {
		u_int wr_callback_id_len;
		stateid4 *wr_callback_id_val;
	} wr_callback_id;
	length4 wr_count;
	stable_how4 wr_committed;
	verifier4 wr_writeverf;
};
typedef struct write_response4 write_response4;

typedef bitmap4 fattr4_supported_attrs;

typedef nfs_ftype4 fattr4_type;

typedef uint32_t fattr4_fh_expire_type;

typedef changeid4 fattr4_change;

typedef uint64_t fattr4_size;

typedef bool_t fattr4_link_support;

typedef bool_t fattr4_symlink_support;

typedef bool_t fattr4_named_attr;

typedef fsid4 fattr4_fsid;

typedef bool_t fattr4_unique_handles;

typedef nfs_lease4 fattr4_lease_time;

typedef nfsstat4 fattr4_rdattr_error;

typedef struct {
	u_int fattr4_acl_len;
	nfsace4 *fattr4_acl_val;
} fattr4_acl;

typedef uint32_t fattr4_aclsupport;

typedef bool_t fattr4_archive;

typedef bool_t fattr4_cansettime;

typedef bool_t fattr4_case_insensitive;

typedef bool_t fattr4_case_preserving;

typedef bool_t fattr4_chown_restricted;

typedef uint64_t fattr4_fileid;

typedef uint64_t fattr4_files_avail;

typedef nfs_fh4 fattr4_filehandle;

typedef uint64_t fattr4_files_free;

typedef uint64_t fattr4_files_total;

typedef fs_locations4 fattr4_fs_locations;

typedef bool_t fattr4_hidden;

typedef bool_t fattr4_homogeneous;

typedef uint64_t fattr4_maxfilesize;

typedef uint32_t fattr4_maxlink;

typedef uint32_t fattr4_maxname;

typedef uint64_t fattr4_maxread;

typedef uint64_t fattr4_maxwrite;

typedef ascii_REQUIRED4 fattr4_mimetype;

typedef mode4 fattr4_mode;

typedef mode_masked4 fattr4_mode_set_masked;

typedef uint64_t fattr4_mounted_on_fileid;

typedef bool_t fattr4_no_trunc;

typedef uint32_t fattr4_numlinks;

typedef utf8str_mixed fattr4_owner;

typedef utf8str_mixed fattr4_owner_group;

typedef uint64_t fattr4_quota_avail_hard;

typedef uint64_t fattr4_quota_avail_soft;

typedef uint64_t fattr4_quota_used;

typedef specdata4 fattr4_rawdev;

typedef uint64_t fattr4_space_avail;

typedef length4 fattr4_space_free;

typedef uint64_t fattr4_space_total;

typedef uint64_t fattr4_space_used;

typedef bool_t fattr4_system;

typedef nfstime4 fattr4_time_access;

typedef settime4 fattr4_time_access_set;

typedef nfstime4 fattr4_time_backup;

typedef nfstime4 fattr4_time_create;

typedef nfstime4 fattr4_time_delta;

typedef nfstime4 fattr4_time_metadata;

typedef nfstime4 fattr4_time_modify;

typedef settime4 fattr4_time_modify_set;

typedef bitmap4 fattr4_suppattr_exclcreat;

typedef nfstime4 fattr4_dir_notif_delay;

typedef nfstime4 fattr4_dirent_notif_delay;

typedef struct {
	u_int fattr4_fs_layout_types_len;
	layouttype4 *fattr4_fs_layout_types_val;
} fattr4_fs_layout_types;

typedef fs4_status fattr4_fs_status;

typedef fs_charset_cap4 fattr4_fs_charset_cap;

typedef uint32_t fattr4_layout_alignment;

typedef uint32_t fattr4_layout_blksize;

typedef layouthint4 fattr4_layout_hint;

typedef struct {
	u_int fattr4_layout_types_len;
	layouttype4 *fattr4_layout_types_val;
} fattr4_layout_types;

typedef mdsthreshold4 fattr4_mdsthreshold;

typedef retention_get4 fattr4_retention_get;

typedef retention_set4 fattr4_retention_set;

typedef retention_get4 fattr4_retentevt_get;

typedef retention_set4 fattr4_retentevt_set;

typedef uint64_t fattr4_retention_hold;

typedef nfsacl41 fattr4_dacl;

typedef nfsacl41 fattr4_sacl;

typedef change_policy4 fattr4_change_policy;

typedef uint64_t fattr4_space_freed;

typedef change_attr_type4 fattr4_change_attr_type;

typedef sec_label4 fattr4_sec_label;

typedef uint32_t fattr4_clone_blksize;
/*
 * REQUIRED attributes
 */
#define	FATTR4_SUPPORTED_ATTRS 0
#define	FATTR4_TYPE 1
#define	FATTR4_FH_EXPIRE_TYPE 2
#define	FATTR4_CHANGE 3
#define	FATTR4_SIZE 4
#define	FATTR4_LINK_SUPPORT 5
#define	FATTR4_SYMLINK_SUPPORT 6
#define	FATTR4_NAMED_ATTR 7
#define	FATTR4_FSID 8
#define	FATTR4_UNIQUE_HANDLES 9
#define	FATTR4_LEASE_TIME 10
#define	FATTR4_RDATTR_ERROR 11
#define	FATTR4_FILEHANDLE 19
/*
 * New to NFSv4.1
 */
#define	FATTR4_SUPPATTR_EXCLCREAT 75
/*
 * RECOMMENDED attributes
 */
#define	FATTR4_ACL 12
#define	FATTR4_ACLSUPPORT 13
#define	FATTR4_ARCHIVE 14
#define	FATTR4_CANSETTIME 15
#define	FATTR4_CASE_INSENSITIVE 16
#define	FATTR4_CASE_PRESERVING 17
#define	FATTR4_CHOWN_RESTRICTED 18
#define	FATTR4_FILEID 20
#define	FATTR4_FILES_AVAIL 21
#define	FATTR4_FILES_FREE 22
#define	FATTR4_FILES_TOTAL 23
#define	FATTR4_FS_LOCATIONS 24
#define	FATTR4_HIDDEN 25
#define	FATTR4_HOMOGENEOUS 26
#define	FATTR4_MAXFILESIZE 27
#define	FATTR4_MAXLINK 28
#define	FATTR4_MAXNAME 29
#define	FATTR4_MAXREAD 30
#define	FATTR4_MAXWRITE 31
#define	FATTR4_MIMETYPE 32
#define	FATTR4_MODE 33
#define	FATTR4_NO_TRUNC 34
#define	FATTR4_NUMLINKS 35
#define	FATTR4_OWNER 36
#define	FATTR4_OWNER_GROUP 37
#define	FATTR4_QUOTA_AVAIL_HARD 38
#define	FATTR4_QUOTA_AVAIL_SOFT 39
#define	FATTR4_QUOTA_USED 40
#define	FATTR4_RAWDEV 41
#define	FATTR4_SPACE_AVAIL 42
#define	FATTR4_SPACE_FREE 43
#define	FATTR4_SPACE_TOTAL 44
#define	FATTR4_SPACE_USED 45
#define	FATTR4_SYSTEM 46
#define	FATTR4_TIME_ACCESS 47
#define	FATTR4_TIME_ACCESS_SET 48
#define	FATTR4_TIME_BACKUP 49
#define	FATTR4_TIME_CREATE 50
#define	FATTR4_TIME_DELTA 51
#define	FATTR4_TIME_METADATA 52
#define	FATTR4_TIME_MODIFY 53
#define	FATTR4_TIME_MODIFY_SET 54
#define	FATTR4_MOUNTED_ON_FILEID 55
/*
 * New to NFSv4.1
 */
#define	FATTR4_DIR_NOTIF_DELAY 56
#define	FATTR4_DIRENT_NOTIF_DELAY 57
#define	FATTR4_DACL 58
#define	FATTR4_SACL 59
#define	FATTR4_CHANGE_POLICY 60
#define	FATTR4_FS_STATUS 61
#define	FATTR4_FS_LAYOUT_TYPES 62
#define	FATTR4_LAYOUT_HINT 63
#define	FATTR4_LAYOUT_TYPES 64
#define	FATTR4_LAYOUT_BLKSIZE 65
#define	FATTR4_LAYOUT_ALIGNMENT 66
#define	FATTR4_FS_LOCATIONS_INFO 67
#define	FATTR4_MDSTHRESHOLD 68
#define	FATTR4_RETENTION_GET 69
#define	FATTR4_RETENTION_SET 70
#define	FATTR4_RETENTEVT_GET 71
#define	FATTR4_RETENTEVT_SET 72
#define	FATTR4_RETENTION_HOLD 73
#define	FATTR4_MODE_SET_MASKED 74
#define	FATTR4_FS_CHARSET_CAP 76
/*
 * New to NFSv4.2
 */
#define	FATTR4_CLONE_BLKSIZE 77
#define	FATTR4_SPACE_FREED 78
#define	FATTR4_CHANGE_ATTR_TYPE 79
#define	FATTR4_SEC_LABEL 80

struct fattr4 {
	bitmap4 attrmask;
	attrlist4 attr_vals;
};
typedef struct fattr4 fattr4;

struct change_info4 {
	bool_t atomic;
	changeid4 before;
	changeid4 after;
};
typedef struct change_info4 change_info4;

typedef netaddr4 clientaddr4;

struct cb_client4 {
	uint32_t cb_program;
	netaddr4 cb_location;
};
typedef struct cb_client4 cb_client4;

struct nfs_client_id4 {
	verifier4 verifier;
	struct {
		u_int id_len;
		char *id_val;
	} id;
};
typedef struct nfs_client_id4 nfs_client_id4;

struct client_owner4 {
	verifier4 co_verifier;
	struct {
		u_int co_ownerid_len;
		char *co_ownerid_val;
	} co_ownerid;
};
typedef struct client_owner4 client_owner4;

struct server_owner4 {
	uint64_t so_minor_id;
	struct {
		u_int so_major_id_len;
		char *so_major_id_val;
	} so_major_id;
};
typedef struct server_owner4 server_owner4;

struct state_owner4 {
	clientid4 clientid;
	struct {
		u_int owner_len;
		char *owner_val;
	} owner;
};
typedef struct state_owner4 state_owner4;

typedef state_owner4 open_owner4;

typedef state_owner4 lock_owner4;

enum nfs_lock_type4 {
	READ_LT = 1,
	WRITE_LT = 2,
	READW_LT = 3,
	WRITEW_LT = 4
};
typedef enum nfs_lock_type4 nfs_lock_type4;

/* Input for computing subkeys */

enum ssv_subkey4 {
	SSV4_SUBKEY_MIC_I2T = 1,
	SSV4_SUBKEY_MIC_T2I = 2,
	SSV4_SUBKEY_SEAL_I2T = 3,
	SSV4_SUBKEY_SEAL_T2I = 4
};
typedef enum ssv_subkey4 ssv_subkey4;


/* Input for computing smt_hmac */

struct ssv_mic_plain_tkn4 {
	uint32_t smpt_ssv_seq;
	struct {
		u_int smpt_orig_plain_len;
		char *smpt_orig_plain_val;
	} smpt_orig_plain;
};
typedef struct ssv_mic_plain_tkn4 ssv_mic_plain_tkn4;


/*
 * Secret State Verifier Generic Security Service (SSV GSS)
 * PerMsgToken token
 */

struct ssv_mic_tkn4 {
	uint32_t smt_ssv_seq;
	struct {
		u_int smt_hmac_len;
		char *smt_hmac_val;
	} smt_hmac;
};
typedef struct ssv_mic_tkn4 ssv_mic_tkn4;


/* Input for computing ssct_encr_data and ssct_hmac */

struct ssv_seal_plain_tkn4 {
	struct {
		u_int sspt_confounder_len;
		char *sspt_confounder_val;
	} sspt_confounder;
	uint32_t sspt_ssv_seq;
	struct {
		u_int sspt_orig_plain_len;
		char *sspt_orig_plain_val;
	} sspt_orig_plain;
	struct {
		u_int sspt_pad_len;
		char *sspt_pad_val;
	} sspt_pad;
};
typedef struct ssv_seal_plain_tkn4 ssv_seal_plain_tkn4;


/* SSV GSS SealedMessage token */

struct ssv_seal_cipher_tkn4 {
	uint32_t ssct_ssv_seq;
	struct {
		u_int ssct_iv_len;
		char *ssct_iv_val;
	} ssct_iv;
	struct {
		u_int ssct_encr_data_len;
		char *ssct_encr_data_val;
	} ssct_encr_data;
	struct {
		u_int ssct_hmac_len;
		char *ssct_hmac_val;
	} ssct_hmac;
};
typedef struct ssv_seal_cipher_tkn4 ssv_seal_cipher_tkn4;


struct fs_locations_server4 {
	int32_t fls_currency;
	struct {
		u_int fls_info_len;
		char *fls_info_val;
	} fls_info;
	utf8str_cis fls_server;
};
typedef struct fs_locations_server4 fs_locations_server4;
#define	FSLI4BX_GFLAGS 0
#define	FSLI4BX_TFLAGS 1
#define	FSLI4BX_CLSIMUL 2
#define	FSLI4BX_CLHANDLE 3
#define	FSLI4BX_CLFILEID 4
#define	FSLI4BX_CLWRITEVER 5
#define	FSLI4BX_CLCHANGE 6
#define	FSLI4BX_CLREADDIR 7
#define	FSLI4BX_READRANK 8
#define	FSLI4BX_WRITERANK 9
#define	FSLI4BX_READORDER 10
#define	FSLI4BX_WRITEORDER 11
#define	FSLI4GF_WRITABLE 0x01
#define	FSLI4GF_CUR_REQ 0x02
#define	FSLI4GF_ABSENT 0x04
#define	FSLI4GF_GOING 0x08
#define	FSLI4GF_SPLIT 0x10
#define	FSLI4TF_RDMA 0x01

struct fs_locations_item4 {
	struct {
		u_int fli_entries_len;
		fs_locations_server4 *fli_entries_val;
	} fli_entries;
	pathname4 fli_rootpath;
};
typedef struct fs_locations_item4 fs_locations_item4;

struct fs_locations_info4 {
	uint32_t fli_flags;
	int32_t fli_valid_for;
	pathname4 fli_fs_root;
	struct {
		u_int fli_items_len;
		fs_locations_item4 *fli_items_val;
	} fli_items;
};
typedef struct fs_locations_info4 fs_locations_info4;
#define	FSLI4IF_VAR_SUB 0x00000001

typedef fs_locations_info4 fattr4_fs_locations_info;
#define	NFL4_UFLG_MASK 0x0000003F
#define	NFL4_UFLG_DENSE 0x00000001
#define	NFL4_UFLG_COMMIT_THRU_MDS 0x00000002
#define	NFL42_UFLG_IO_ADVISE_THRU_MDS 0x00000004
#define	NFL4_UFLG_STRIPE_UNIT_SIZE_MASK 0xFFFFFFC0

typedef uint32_t nfl_util4;


enum filelayout_hint_care4 {
	NFLH4_CARE_DENSE = NFL4_UFLG_DENSE,
	NFLH4_CARE_COMMIT_THRU_MDS = NFL4_UFLG_COMMIT_THRU_MDS,
	NFL42_CARE_IO_ADVISE_THRU_MDS = NFL42_UFLG_IO_ADVISE_THRU_MDS,
	NFLH4_CARE_STRIPE_UNIT_SIZE = 0x00000040,
	NFLH4_CARE_STRIPE_COUNT = 0x00000080
};
typedef enum filelayout_hint_care4 filelayout_hint_care4;

/*
 * Encoded in the loh_body field of data type layouthint4:
 */


struct nfsv4_1_file_layouthint4 {
	uint32_t nflh_care;
	nfl_util4 nflh_util;
	count4 nflh_stripe_count;
};
typedef struct nfsv4_1_file_layouthint4 nfsv4_1_file_layouthint4;



typedef struct {
	u_int multipath_list4_len;
	netaddr4 *multipath_list4_val;
} multipath_list4;

/*
 * Encoded in the da_addr_body field of data type device_addr4:
 */

struct nfsv4_1_file_layout_ds_addr4 {
	struct {
		u_int nflda_stripe_indices_len;
		uint32_t *nflda_stripe_indices_val;
	} nflda_stripe_indices;
	struct {
		u_int nflda_multipath_ds_list_len;
		multipath_list4 *nflda_multipath_ds_list_val;
	} nflda_multipath_ds_list;
};
typedef struct nfsv4_1_file_layout_ds_addr4 nfsv4_1_file_layout_ds_addr4;


/*
 * Encoded in the loc_body field of data type layout_content4:
 */

struct nfsv4_1_file_layout4 {
	deviceid4 nfl_deviceid;
	nfl_util4 nfl_util;
	uint32_t nfl_first_stripe_index;
	offset4 nfl_pattern_offset;
	struct {
		u_int nfl_fh_list_len;
		nfs_fh4 *nfl_fh_list_val;
	} nfl_fh_list;
};
typedef struct nfsv4_1_file_layout4 nfsv4_1_file_layout4;


/* New operations for NFSv4.1 */


/* New operations for NFSv4.2 */


enum nfs_opnum4 {
	OP_ACCESS = 3,
	OP_CLOSE = 4,
	OP_COMMIT = 5,
	OP_CREATE = 6,
	OP_DELEGPURGE = 7,
	OP_DELEGRETURN = 8,
	OP_GETATTR = 9,
	OP_GETFH = 10,
	OP_LINK = 11,
	OP_LOCK = 12,
	OP_LOCKT = 13,
	OP_LOCKU = 14,
	OP_LOOKUP = 15,
	OP_LOOKUPP = 16,
	OP_NVERIFY = 17,
	OP_OPEN = 18,
	OP_OPENATTR = 19,
	OP_OPEN_CONFIRM = 20,
	OP_OPEN_DOWNGRADE = 21,
	OP_PUTFH = 22,
	OP_PUTPUBFH = 23,
	OP_PUTROOTFH = 24,
	OP_READ = 25,
	OP_READDIR = 26,
	OP_READLINK = 27,
	OP_REMOVE = 28,
	OP_RENAME = 29,
	OP_RENEW = 30,
	OP_RESTOREFH = 31,
	OP_SAVEFH = 32,
	OP_SECINFO = 33,
	OP_SETATTR = 34,
	OP_SETCLIENTID = 35,
	OP_SETCLIENTID_CONFIRM = 36,
	OP_VERIFY = 37,
	OP_WRITE = 38,
	OP_RELEASE_LOCKOWNER = 39,
	OP_BACKCHANNEL_CTL = 40,
	OP_BIND_CONN_TO_SESSION = 41,
	OP_EXCHANGE_ID = 42,
	OP_CREATE_SESSION = 43,
	OP_DESTROY_SESSION = 44,
	OP_FREE_STATEID = 45,
	OP_GET_DIR_DELEGATION = 46,
	OP_GETDEVICEINFO = 47,
	OP_GETDEVICELIST = 48,
	OP_LAYOUTCOMMIT = 49,
	OP_LAYOUTGET = 50,
	OP_LAYOUTRETURN = 51,
	OP_SECINFO_NO_NAME = 52,
	OP_SEQUENCE = 53,
	OP_SET_SSV = 54,
	OP_TEST_STATEID = 55,
	OP_WANT_DELEGATION = 56,
	OP_DESTROY_CLIENTID = 57,
	OP_RECLAIM_COMPLETE = 58,
	OP_ALLOCATE = 59,
	OP_COPY = 60,
	OP_COPY_NOTIFY = 61,
	OP_DEALLOCATE = 62,
	OP_IO_ADVISE = 63,
	OP_LAYOUTERROR = 64,
	OP_LAYOUTSTATS = 65,
	OP_OFFLOAD_CANCEL = 66,
	OP_OFFLOAD_STATUS = 67,
	OP_READ_PLUS = 68,
	OP_SEEK = 69,
	OP_WRITE_SAME = 70,
	OP_CLONE = 71,
	OP_ILLEGAL = 10044
};
typedef enum nfs_opnum4 nfs_opnum4;
#define	ACCESS4_READ 0x00000001
#define	ACCESS4_LOOKUP 0x00000002
#define	ACCESS4_MODIFY 0x00000004
#define	ACCESS4_EXTEND 0x00000008
#define	ACCESS4_DELETE 0x00000010
#define	ACCESS4_EXECUTE 0x00000020

struct ACCESS4args {
	uint32_t access;
};
typedef struct ACCESS4args ACCESS4args;

struct ACCESS4resok {
	uint32_t supported;
	uint32_t access;
};
typedef struct ACCESS4resok ACCESS4resok;

struct ACCESS4res {
	nfsstat4 status;
	union {
		ACCESS4resok resok4;
	} ACCESS4res_u;
};
typedef struct ACCESS4res ACCESS4res;

struct CLONE4args {
	stateid4 cl_src_stateid;
	stateid4 cl_dst_stateid;
	offset4 cl_src_offset;
	offset4 cl_dst_offset;
	length4 cl_count;
};
typedef struct CLONE4args CLONE4args;

struct CLONE4res {
	nfsstat4 cl_status;
};
typedef struct CLONE4res CLONE4res;

struct CLOSE4args {
	seqid4 seqid;
	stateid4 open_stateid;
};
typedef struct CLOSE4args CLOSE4args;

struct CLOSE4res {
	nfsstat4 status;
	union {
		stateid4 open_stateid;
	} CLOSE4res_u;
};
typedef struct CLOSE4res CLOSE4res;

struct COMMIT4args {
	offset4 offset;
	count4 count;
};
typedef struct COMMIT4args COMMIT4args;

struct COMMIT4resok {
	verifier4 writeverf;
};
typedef struct COMMIT4resok COMMIT4resok;

struct COMMIT4res {
	nfsstat4 status;
	union {
		COMMIT4resok resok4;
	} COMMIT4res_u;
};
typedef struct COMMIT4res COMMIT4res;

struct createtype4 {
	nfs_ftype4 type;
	union {
		linktext4 linkdata;
		specdata4 devdata;
	} createtype4_u;
};
typedef struct createtype4 createtype4;

struct CREATE4args {
	createtype4 objtype;
	component4 objname;
	fattr4 createattrs;
};
typedef struct CREATE4args CREATE4args;

struct CREATE4resok {
	change_info4 cinfo;
	bitmap4 attrset;
};
typedef struct CREATE4resok CREATE4resok;

struct CREATE4res {
	nfsstat4 status;
	union {
		CREATE4resok resok4;
	} CREATE4res_u;
};
typedef struct CREATE4res CREATE4res;

struct DELEGPURGE4args {
	clientid4 clientid;
};
typedef struct DELEGPURGE4args DELEGPURGE4args;

struct DELEGPURGE4res {
	nfsstat4 status;
};
typedef struct DELEGPURGE4res DELEGPURGE4res;

struct DELEGRETURN4args {
	stateid4 deleg_stateid;
};
typedef struct DELEGRETURN4args DELEGRETURN4args;

struct DELEGRETURN4res {
	nfsstat4 status;
};
typedef struct DELEGRETURN4res DELEGRETURN4res;

struct GETATTR4args {
	bitmap4 attr_request;
};
typedef struct GETATTR4args GETATTR4args;

struct GETATTR4resok {
	fattr4 obj_attributes;
};
typedef struct GETATTR4resok GETATTR4resok;

struct GETATTR4res {
	nfsstat4 status;
	union {
		GETATTR4resok resok4;
	} GETATTR4res_u;
};
typedef struct GETATTR4res GETATTR4res;

struct GETFH4resok {
	nfs_fh4 object;
};
typedef struct GETFH4resok GETFH4resok;

struct GETFH4res {
	nfsstat4 status;
	union {
		GETFH4resok resok4;
	} GETFH4res_u;
};
typedef struct GETFH4res GETFH4res;

struct LINK4args {
	component4 newname;
};
typedef struct LINK4args LINK4args;

struct LINK4resok {
	change_info4 cinfo;
};
typedef struct LINK4resok LINK4resok;

struct LINK4res {
	nfsstat4 status;
	union {
		LINK4resok resok4;
	} LINK4res_u;
};
typedef struct LINK4res LINK4res;

struct open_to_lock_owner4 {
	seqid4 open_seqid;
	stateid4 open_stateid;
	seqid4 lock_seqid;
	lock_owner4 lock_owner;
};
typedef struct open_to_lock_owner4 open_to_lock_owner4;

struct exist_lock_owner4 {
	stateid4 lock_stateid;
	seqid4 lock_seqid;
};
typedef struct exist_lock_owner4 exist_lock_owner4;

struct locker4 {
	bool_t new_lock_owner;
	union {
		open_to_lock_owner4 open_owner;
		exist_lock_owner4 lock_owner;
	} locker4_u;
};
typedef struct locker4 locker4;

struct LOCK4args {
	nfs_lock_type4 locktype;
	bool_t reclaim;
	offset4 offset;
	length4 length;
	locker4 locker;
};
typedef struct LOCK4args LOCK4args;

struct LOCK4denied {
	offset4 offset;
	length4 length;
	nfs_lock_type4 locktype;
	lock_owner4 owner;
};
typedef struct LOCK4denied LOCK4denied;

struct LOCK4resok {
	stateid4 lock_stateid;
};
typedef struct LOCK4resok LOCK4resok;

struct LOCK4res {
	nfsstat4 status;
	union {
		LOCK4resok resok4;
		LOCK4denied denied;
	} LOCK4res_u;
};
typedef struct LOCK4res LOCK4res;

struct LOCKT4args {
	nfs_lock_type4 locktype;
	offset4 offset;
	length4 length;
	lock_owner4 owner;
};
typedef struct LOCKT4args LOCKT4args;

struct LOCKT4res {
	nfsstat4 status;
	union {
		LOCK4denied denied;
	} LOCKT4res_u;
};
typedef struct LOCKT4res LOCKT4res;

struct LOCKU4args {
	nfs_lock_type4 locktype;
	seqid4 seqid;
	stateid4 lock_stateid;
	offset4 offset;
	length4 length;
};
typedef struct LOCKU4args LOCKU4args;

struct LOCKU4res {
	nfsstat4 status;
	union {
		stateid4 lock_stateid;
	} LOCKU4res_u;
};
typedef struct LOCKU4res LOCKU4res;

struct LOOKUP4args {
	component4 objname;
};
typedef struct LOOKUP4args LOOKUP4args;

struct LOOKUP4res {
	nfsstat4 status;
};
typedef struct LOOKUP4res LOOKUP4res;

struct LOOKUPP4res {
	nfsstat4 status;
};
typedef struct LOOKUPP4res LOOKUPP4res;

struct NVERIFY4args {
	fattr4 obj_attributes;
};
typedef struct NVERIFY4args NVERIFY4args;

struct NVERIFY4res {
	nfsstat4 status;
};
typedef struct NVERIFY4res NVERIFY4res;

enum createmode4 {
	UNCHECKED4 = 0,
	GUARDED4 = 1,
	EXCLUSIVE4 = 2,
	EXCLUSIVE4_1 = 3
};
typedef enum createmode4 createmode4;

struct creatverfattr {
	verifier4 cva_verf;
	fattr4 cva_attrs;
};
typedef struct creatverfattr creatverfattr;

struct createhow4 {
	createmode4 mode;
	union {
		fattr4 createattrs;
		verifier4 createverf;
		creatverfattr ch_createboth;
	} createhow4_u;
};
typedef struct createhow4 createhow4;

enum opentype4 {
	OPEN4_NOCREATE = 0,
	OPEN4_CREATE = 1
};
typedef enum opentype4 opentype4;

struct openflag4 {
	opentype4 opentype;
	union {
		createhow4 how;
	} openflag4_u;
};
typedef struct openflag4 openflag4;

enum limit_by4 {
	NFS_LIMIT_SIZE = 1,
	NFS_LIMIT_BLOCKS = 2
};
typedef enum limit_by4 limit_by4;

struct nfs_modified_limit4 {
	uint32_t num_blocks;
	uint32_t bytes_per_block;
};
typedef struct nfs_modified_limit4 nfs_modified_limit4;

struct nfs_space_limit4 {
	limit_by4 limitby;
	union {
		uint64_t filesize;
		nfs_modified_limit4 mod_blocks;
	} nfs_space_limit4_u;
};
typedef struct nfs_space_limit4 nfs_space_limit4;
#define	OPEN4_SHARE_ACCESS_READ 0x00000001
#define	OPEN4_SHARE_ACCESS_WRITE 0x00000002
#define	OPEN4_SHARE_ACCESS_BOTH 0x00000003
#define	OPEN4_SHARE_DENY_NONE 0x00000000
#define	OPEN4_SHARE_DENY_READ 0x00000001
#define	OPEN4_SHARE_DENY_WRITE 0x00000002
#define	OPEN4_SHARE_DENY_BOTH 0x00000003
#define	OPEN4_SHARE_ACCESS_WANT_DELEG_MASK 0xFF00
#define	OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE 0x0000
#define	OPEN4_SHARE_ACCESS_WANT_READ_DELEG 0x0100
#define	OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG 0x0200
#define	OPEN4_SHARE_ACCESS_WANT_ANY_DELEG 0x0300
#define	OPEN4_SHARE_ACCESS_WANT_NO_DELEG 0x0400
#define	OPEN4_SHARE_ACCESS_WANT_CANCEL 0x0500
#define	OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL 0x10000
#define	OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED 0x20000

enum open_delegation_type4 {
	OPEN_DELEGATE_NONE = 0,
	OPEN_DELEGATE_READ = 1,
	OPEN_DELEGATE_WRITE = 2,
	OPEN_DELEGATE_NONE_EXT = 3
};
typedef enum open_delegation_type4 open_delegation_type4;

enum open_claim_type4 {
	CLAIM_NULL = 0,
	CLAIM_PREVIOUS = 1,
	CLAIM_DELEGATE_CUR = 2,
	CLAIM_DELEGATE_PREV = 3,
	CLAIM_FH = 4,
	CLAIM_DELEG_CUR_FH = 5,
	CLAIM_DELEG_PREV_FH = 6
};
typedef enum open_claim_type4 open_claim_type4;

struct open_claim_delegate_cur4 {
	stateid4 delegate_stateid;
	component4 file;
};
typedef struct open_claim_delegate_cur4 open_claim_delegate_cur4;

struct open_claim4 {
	open_claim_type4 claim;
	union {
		component4 file;
		open_delegation_type4 delegate_type;
		open_claim_delegate_cur4 delegate_cur_info;
		component4 file_delegate_prev;
		stateid4 oc_delegate_stateid;
	} open_claim4_u;
};
typedef struct open_claim4 open_claim4;

struct OPEN4args {
	seqid4 seqid;
	uint32_t share_access;
	uint32_t share_deny;
	open_owner4 owner;
	openflag4 openhow;
	open_claim4 claim;
};
typedef struct OPEN4args OPEN4args;

struct open_read_delegation4 {
	stateid4 stateid;
	bool_t recall;
	nfsace4 permissions;
};
typedef struct open_read_delegation4 open_read_delegation4;

struct open_write_delegation4 {
	stateid4 stateid;
	bool_t recall;
	nfs_space_limit4 space_limit;
	nfsace4 permissions;
};
typedef struct open_write_delegation4 open_write_delegation4;

enum why_no_delegation4 {
	WND4_NOT_WANTED = 0,
	WND4_CONTENTION = 1,
	WND4_RESOURCE = 2,
	WND4_NOT_SUPP_FTYPE = 3,
	WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
	WND4_NOT_SUPP_UPGRADE = 5,
	WND4_NOT_SUPP_DOWNGRADE = 6,
	WND4_CANCELLED = 7,
	WND4_IS_DIR = 8
};
typedef enum why_no_delegation4 why_no_delegation4;

struct open_none_delegation4 {
	why_no_delegation4 ond_why;
	union {
		bool_t ond_server_will_push_deleg;
		bool_t ond_server_will_signal_avail;
	} open_none_delegation4_u;
};
typedef struct open_none_delegation4 open_none_delegation4;

struct open_delegation4 {
	open_delegation_type4 delegation_type;
	union {
		open_read_delegation4 read;
		open_write_delegation4 write;
		open_none_delegation4 od_whynone;
	} open_delegation4_u;
};
typedef struct open_delegation4 open_delegation4;
#define	OPEN4_RESULT_CONFIRM 0x00000002
#define	OPEN4_RESULT_LOCKTYPE_POSIX 0x00000004
#define	OPEN4_RESULT_PRESERVE_UNLINKED 0x00000008
#define	OPEN4_RESULT_MAY_NOTIFY_LOCK 0x00000020

struct OPEN4resok {
	stateid4 stateid;
	change_info4 cinfo;
	uint32_t rflags;
	bitmap4 attrset;
	open_delegation4 delegation;
};
typedef struct OPEN4resok OPEN4resok;

struct OPEN4res {
	nfsstat4 status;
	union {
		OPEN4resok resok4;
	} OPEN4res_u;
};
typedef struct OPEN4res OPEN4res;

struct OPENATTR4args {
	bool_t createdir;
};
typedef struct OPENATTR4args OPENATTR4args;

struct OPENATTR4res {
	nfsstat4 status;
};
typedef struct OPENATTR4res OPENATTR4res;

struct OPEN_CONFIRM4args {
	stateid4 open_stateid;
	seqid4 seqid;
};
typedef struct OPEN_CONFIRM4args OPEN_CONFIRM4args;

struct OPEN_CONFIRM4resok {
	stateid4 open_stateid;
};
typedef struct OPEN_CONFIRM4resok OPEN_CONFIRM4resok;

struct OPEN_CONFIRM4res {
	nfsstat4 status;
	union {
		OPEN_CONFIRM4resok resok4;
	} OPEN_CONFIRM4res_u;
};
typedef struct OPEN_CONFIRM4res OPEN_CONFIRM4res;

struct OPEN_DOWNGRADE4args {
	stateid4 open_stateid;
	seqid4 seqid;
	uint32_t share_access;
	uint32_t share_deny;
};
typedef struct OPEN_DOWNGRADE4args OPEN_DOWNGRADE4args;

struct OPEN_DOWNGRADE4resok {
	stateid4 open_stateid;
};
typedef struct OPEN_DOWNGRADE4resok OPEN_DOWNGRADE4resok;

struct OPEN_DOWNGRADE4res {
	nfsstat4 status;
	union {
		OPEN_DOWNGRADE4resok resok4;
	} OPEN_DOWNGRADE4res_u;
};
typedef struct OPEN_DOWNGRADE4res OPEN_DOWNGRADE4res;

struct PUTFH4args {
	nfs_fh4 object;
};
typedef struct PUTFH4args PUTFH4args;

struct PUTFH4res {
	nfsstat4 status;
};
typedef struct PUTFH4res PUTFH4res;

struct PUTPUBFH4res {
	nfsstat4 status;
};
typedef struct PUTPUBFH4res PUTPUBFH4res;

struct PUTROOTFH4res {
	nfsstat4 status;
};
typedef struct PUTROOTFH4res PUTROOTFH4res;

struct READ4args {
	stateid4 stateid;
	offset4 offset;
	count4 count;
};
typedef struct READ4args READ4args;

struct READ4resok {
	bool_t eof;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct READ4resok READ4resok;

struct READ4res {
	nfsstat4 status;
	union {
		READ4resok resok4;
	} READ4res_u;
};
typedef struct READ4res READ4res;

struct READDIR4args {
	nfs_cookie4 cookie;
	verifier4 cookieverf;
	count4 dircount;
	count4 maxcount;
	bitmap4 attr_request;
};
typedef struct READDIR4args READDIR4args;

struct entry4 {
	nfs_cookie4 cookie;
	component4 name;
	fattr4 attrs;
	struct entry4 *nextentry;
};
typedef struct entry4 entry4;

struct dirlist4 {
	entry4 *entries;
	bool_t eof;
};
typedef struct dirlist4 dirlist4;

struct READDIR4resok {
	verifier4 cookieverf;
	dirlist4 reply;
};
typedef struct READDIR4resok READDIR4resok;

struct READDIR4res {
	nfsstat4 status;
	union {
		READDIR4resok resok4;
	} READDIR4res_u;
};
typedef struct READDIR4res READDIR4res;

struct READLINK4resok {
	linktext4 link;
};
typedef struct READLINK4resok READLINK4resok;

struct READLINK4res {
	nfsstat4 status;
	union {
		READLINK4resok resok4;
	} READLINK4res_u;
};
typedef struct READLINK4res READLINK4res;

struct REMOVE4args {
	component4 target;
};
typedef struct REMOVE4args REMOVE4args;

struct REMOVE4resok {
	change_info4 cinfo;
};
typedef struct REMOVE4resok REMOVE4resok;

struct REMOVE4res {
	nfsstat4 status;
	union {
		REMOVE4resok resok4;
	} REMOVE4res_u;
};
typedef struct REMOVE4res REMOVE4res;

struct RENAME4args {
	component4 oldname;
	component4 newname;
};
typedef struct RENAME4args RENAME4args;

struct RENAME4resok {
	change_info4 source_cinfo;
	change_info4 target_cinfo;
};
typedef struct RENAME4resok RENAME4resok;

struct RENAME4res {
	nfsstat4 status;
	union {
		RENAME4resok resok4;
	} RENAME4res_u;
};
typedef struct RENAME4res RENAME4res;

struct RENEW4args {
	clientid4 clientid;
};
typedef struct RENEW4args RENEW4args;

struct RENEW4res {
	nfsstat4 status;
};
typedef struct RENEW4res RENEW4res;

struct RESTOREFH4res {
	nfsstat4 status;
};
typedef struct RESTOREFH4res RESTOREFH4res;

struct SAVEFH4res {
	nfsstat4 status;
};
typedef struct SAVEFH4res SAVEFH4res;

struct SECINFO4args {
	component4 name;
};
typedef struct SECINFO4args SECINFO4args;

enum rpc_gss_svc_t {
	RPC_GSS_SVC_NONE = 1,
	RPC_GSS_SVC_INTEGRITY = 2,
	RPC_GSS_SVC_PRIVACY = 3
};
typedef enum rpc_gss_svc_t rpc_gss_svc_t;

struct rpcsec_gss_info {
	sec_oid4 oid;
	qop4 qop;
	rpc_gss_svc_t service;
};
typedef struct rpcsec_gss_info rpcsec_gss_info;

struct secinfo4 {
	uint32_t flavor;
	union {
		rpcsec_gss_info flavor_info;
	} secinfo4_u;
};
typedef struct secinfo4 secinfo4;

typedef struct {
	u_int SECINFO4resok_len;
	secinfo4 *SECINFO4resok_val;
} SECINFO4resok;

struct SECINFO4res {
	nfsstat4 status;
	union {
		SECINFO4resok resok4;
	} SECINFO4res_u;
};
typedef struct SECINFO4res SECINFO4res;

struct SETATTR4args {
	stateid4 stateid;
	fattr4 obj_attributes;
};
typedef struct SETATTR4args SETATTR4args;

struct SETATTR4res {
	nfsstat4 status;
	bitmap4 attrsset;
};
typedef struct SETATTR4res SETATTR4res;

struct SETCLIENTID4args {
	nfs_client_id4 client;
	cb_client4 callback;
	uint32_t callback_ident;
};
typedef struct SETCLIENTID4args SETCLIENTID4args;

struct SETCLIENTID4resok {
	clientid4 clientid;
	verifier4 setclientid_confirm;
};
typedef struct SETCLIENTID4resok SETCLIENTID4resok;

struct SETCLIENTID4res {
	nfsstat4 status;
	union {
		SETCLIENTID4resok resok4;
		clientaddr4 client_using;
	} SETCLIENTID4res_u;
};
typedef struct SETCLIENTID4res SETCLIENTID4res;

struct SETCLIENTID_CONFIRM4args {
	clientid4 clientid;
	verifier4 setclientid_confirm;
};
typedef struct SETCLIENTID_CONFIRM4args SETCLIENTID_CONFIRM4args;

struct SETCLIENTID_CONFIRM4res {
	nfsstat4 status;
};
typedef struct SETCLIENTID_CONFIRM4res SETCLIENTID_CONFIRM4res;

struct VERIFY4args {
	fattr4 obj_attributes;
};
typedef struct VERIFY4args VERIFY4args;

struct VERIFY4res {
	nfsstat4 status;
};
typedef struct VERIFY4res VERIFY4res;

struct WRITE4args {
	stateid4 stateid;
	offset4 offset;
	stable_how4 stable;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct WRITE4args WRITE4args;

struct WRITE4resok {
	count4 count;
	stable_how4 committed;
	verifier4 writeverf;
};
typedef struct WRITE4resok WRITE4resok;

struct WRITE4res {
	nfsstat4 status;
	union {
		WRITE4resok resok4;
	} WRITE4res_u;
};
typedef struct WRITE4res WRITE4res;

struct RELEASE_LOCKOWNER4args {
	lock_owner4 lock_owner;
};
typedef struct RELEASE_LOCKOWNER4args RELEASE_LOCKOWNER4args;

struct RELEASE_LOCKOWNER4res {
	nfsstat4 status;
};
typedef struct RELEASE_LOCKOWNER4res RELEASE_LOCKOWNER4res;

struct ILLEGAL4res {
	nfsstat4 status;
};
typedef struct ILLEGAL4res ILLEGAL4res;

typedef struct {
	u_int gsshandle4_t_len;
	char *gsshandle4_t_val;
} gsshandle4_t;

struct gss_cb_handles4 {
	rpc_gss_svc_t gcbp_service;
	gsshandle4_t gcbp_handle_from_server;
	gsshandle4_t gcbp_handle_from_client;
};
typedef struct gss_cb_handles4 gss_cb_handles4;

struct callback_sec_parms4 {
	uint32_t cb_secflavor;
	union {
		authsys_parms cbsp_sys_cred;
		gss_cb_handles4 cbsp_gss_handles;
	} callback_sec_parms4_u;
};
typedef struct callback_sec_parms4 callback_sec_parms4;

struct BACKCHANNEL_CTL4args {
	uint32_t bca_cb_program;
	struct {
		u_int bca_sec_parms_len;
		callback_sec_parms4 *bca_sec_parms_val;
	} bca_sec_parms;
};
typedef struct BACKCHANNEL_CTL4args BACKCHANNEL_CTL4args;

struct BACKCHANNEL_CTL4res {
	nfsstat4 bcr_status;
};
typedef struct BACKCHANNEL_CTL4res BACKCHANNEL_CTL4res;

enum channel_dir_from_client4 {
	CDFC4_FORE = 0x1,
	CDFC4_BACK = 0x2,
	CDFC4_FORE_OR_BOTH = 0x3,
	CDFC4_BACK_OR_BOTH = 0x7
};
typedef enum channel_dir_from_client4 channel_dir_from_client4;

struct BIND_CONN_TO_SESSION4args {
	sessionid4 bctsa_sessid;
	channel_dir_from_client4 bctsa_dir;
	bool_t bctsa_use_conn_in_rdma_mode;
};
typedef struct BIND_CONN_TO_SESSION4args BIND_CONN_TO_SESSION4args;

enum channel_dir_from_server4 {
	CDFS4_FORE = 0x1,
	CDFS4_BACK = 0x2,
	CDFS4_BOTH = 0x3
};
typedef enum channel_dir_from_server4 channel_dir_from_server4;

struct BIND_CONN_TO_SESSION4resok {
	sessionid4 bctsr_sessid;
	channel_dir_from_server4 bctsr_dir;
	bool_t bctsr_use_conn_in_rdma_mode;
};
typedef struct BIND_CONN_TO_SESSION4resok BIND_CONN_TO_SESSION4resok;

struct BIND_CONN_TO_SESSION4res {
	nfsstat4 bctsr_status;
	union {
		BIND_CONN_TO_SESSION4resok bctsr_resok4;
	} BIND_CONN_TO_SESSION4res_u;
};
typedef struct BIND_CONN_TO_SESSION4res BIND_CONN_TO_SESSION4res;
#define	EXCHGID4_FLAG_SUPP_MOVED_REFER 0x00000001
#define	EXCHGID4_FLAG_SUPP_MOVED_MIGR 0x00000002
#define	EXCHGID4_FLAG_SUPP_FENCE_OPS 0x00000004
#define	EXCHGID4_FLAG_BIND_PRINC_STATEID 0x00000100
#define	EXCHGID4_FLAG_USE_NON_PNFS 0x00010000
#define	EXCHGID4_FLAG_USE_PNFS_MDS 0x00020000
#define	EXCHGID4_FLAG_USE_PNFS_DS 0x00040000
#define	EXCHGID4_FLAG_MASK_PNFS 0x00070000
#define	EXCHGID4_FLAG_UPD_CONFIRMED_REC_A 0x40000000
#define	EXCHGID4_FLAG_CONFIRMED_R 0x80000000

struct state_protect_ops4 {
	bitmap4 spo_must_enforce;
	bitmap4 spo_must_allow;
};
typedef struct state_protect_ops4 state_protect_ops4;

struct ssv_sp_parms4 {
	state_protect_ops4 ssp_ops;
	struct {
		u_int ssp_hash_algs_len;
		sec_oid4 *ssp_hash_algs_val;
	} ssp_hash_algs;
	struct {
		u_int ssp_encr_algs_len;
		sec_oid4 *ssp_encr_algs_val;
	} ssp_encr_algs;
	uint32_t ssp_window;
	uint32_t ssp_num_gss_handles;
};
typedef struct ssv_sp_parms4 ssv_sp_parms4;

enum state_protect_how4 {
	SP4_NONE = 0,
	SP4_MACH_CRED = 1,
	SP4_SSV = 2
};
typedef enum state_protect_how4 state_protect_how4;

struct state_protect4_a {
	state_protect_how4 spa_how;
	union {
		state_protect_ops4 spa_mach_ops;
		ssv_sp_parms4 spa_ssv_parms;
	} state_protect4_a_u;
};
typedef struct state_protect4_a state_protect4_a;

struct EXCHANGE_ID4args {
	client_owner4 eia_clientowner;
	uint32_t eia_flags;
	state_protect4_a eia_state_protect;
	struct {
		u_int eia_client_impl_id_len;
		nfs_impl_id4 *eia_client_impl_id_val;
	} eia_client_impl_id;
};
typedef struct EXCHANGE_ID4args EXCHANGE_ID4args;

struct ssv_prot_info4 {
	state_protect_ops4 spi_ops;
	uint32_t spi_hash_alg;
	uint32_t spi_encr_alg;
	uint32_t spi_ssv_len;
	uint32_t spi_window;
	struct {
		u_int spi_handles_len;
		gsshandle4_t *spi_handles_val;
	} spi_handles;
};
typedef struct ssv_prot_info4 ssv_prot_info4;

struct state_protect4_r {
	state_protect_how4 spr_how;
	union {
		state_protect_ops4 spr_mach_ops;
		ssv_prot_info4 spr_ssv_info;
	} state_protect4_r_u;
};
typedef struct state_protect4_r state_protect4_r;

struct EXCHANGE_ID4resok {
	clientid4 eir_clientid;
	sequenceid4 eir_sequenceid;
	uint32_t eir_flags;
	state_protect4_r eir_state_protect;
	server_owner4 eir_server_owner;
	struct {
		u_int eir_server_scope_len;
		char *eir_server_scope_val;
	} eir_server_scope;
	struct {
		u_int eir_server_impl_id_len;
		nfs_impl_id4 *eir_server_impl_id_val;
	} eir_server_impl_id;
};
typedef struct EXCHANGE_ID4resok EXCHANGE_ID4resok;

struct EXCHANGE_ID4res {
	nfsstat4 eir_status;
	union {
		EXCHANGE_ID4resok eir_resok4;
	} EXCHANGE_ID4res_u;
};
typedef struct EXCHANGE_ID4res EXCHANGE_ID4res;

struct channel_attrs4 {
	count4 ca_headerpadsize;
	count4 ca_maxrequestsize;
	count4 ca_maxresponsesize;
	count4 ca_maxresponsesize_cached;
	count4 ca_maxoperations;
	count4 ca_maxrequests;
	struct {
		u_int ca_rdma_ird_len;
		uint32_t *ca_rdma_ird_val;
	} ca_rdma_ird;
};
typedef struct channel_attrs4 channel_attrs4;
#define	CREATE_SESSION4_FLAG_PERSIST 0x00000001
#define	CREATE_SESSION4_FLAG_CONN_BACK_CHAN 0x00000002
#define	CREATE_SESSION4_FLAG_CONN_RDMA 0x00000004

struct CREATE_SESSION4args {
	clientid4 csa_clientid;
	sequenceid4 csa_sequence;
	uint32_t csa_flags;
	channel_attrs4 csa_fore_chan_attrs;
	channel_attrs4 csa_back_chan_attrs;
	uint32_t csa_cb_program;
	struct {
		u_int csa_sec_parms_len;
		callback_sec_parms4 *csa_sec_parms_val;
	} csa_sec_parms;
};
typedef struct CREATE_SESSION4args CREATE_SESSION4args;

struct CREATE_SESSION4resok {
	sessionid4 csr_sessionid;
	sequenceid4 csr_sequence;
	uint32_t csr_flags;
	channel_attrs4 csr_fore_chan_attrs;
	channel_attrs4 csr_back_chan_attrs;
};
typedef struct CREATE_SESSION4resok CREATE_SESSION4resok;

struct CREATE_SESSION4res {
	nfsstat4 csr_status;
	union {
		CREATE_SESSION4resok csr_resok4;
	} CREATE_SESSION4res_u;
};
typedef struct CREATE_SESSION4res CREATE_SESSION4res;

struct DESTROY_SESSION4args {
	sessionid4 dsa_sessionid;
};
typedef struct DESTROY_SESSION4args DESTROY_SESSION4args;

struct DESTROY_SESSION4res {
	nfsstat4 dsr_status;
};
typedef struct DESTROY_SESSION4res DESTROY_SESSION4res;

struct FREE_STATEID4args {
	stateid4 fsa_stateid;
};
typedef struct FREE_STATEID4args FREE_STATEID4args;

struct FREE_STATEID4res {
	nfsstat4 fsr_status;
};
typedef struct FREE_STATEID4res FREE_STATEID4res;

typedef nfstime4 attr_notice4;

struct GET_DIR_DELEGATION4args {
	bool_t gdda_signal_deleg_avail;
	bitmap4 gdda_notification_types;
	attr_notice4 gdda_child_attr_delay;
	attr_notice4 gdda_dir_attr_delay;
	bitmap4 gdda_child_attributes;
	bitmap4 gdda_dir_attributes;
};
typedef struct GET_DIR_DELEGATION4args GET_DIR_DELEGATION4args;

struct GET_DIR_DELEGATION4resok {
	verifier4 gddr_cookieverf;
	stateid4 gddr_stateid;
	bitmap4 gddr_notification;
	bitmap4 gddr_child_attributes;
	bitmap4 gddr_dir_attributes;
};
typedef struct GET_DIR_DELEGATION4resok GET_DIR_DELEGATION4resok;

enum gddrnf4_status {
	GDD4_OK = 0,
	GDD4_UNAVAIL = 1
};
typedef enum gddrnf4_status gddrnf4_status;

struct GET_DIR_DELEGATION4res_non_fatal {
	gddrnf4_status gddrnf_status;
	union {
		GET_DIR_DELEGATION4resok gddrnf_resok4;
		bool_t gddrnf_will_signal_deleg_avail;
	} GET_DIR_DELEGATION4res_non_fatal_u;
};
typedef struct GET_DIR_DELEGATION4res_non_fatal GET_DIR_DELEGATION4res_non_fatal;

struct GET_DIR_DELEGATION4res {
	nfsstat4 gddr_status;
	union {
		GET_DIR_DELEGATION4res_non_fatal gddr_res_non_fatal4;
	} GET_DIR_DELEGATION4res_u;
};
typedef struct GET_DIR_DELEGATION4res GET_DIR_DELEGATION4res;

struct GETDEVICEINFO4args {
	deviceid4 gdia_device_id;
	layouttype4 gdia_layout_type;
	count4 gdia_maxcount;
	bitmap4 gdia_notify_types;
};
typedef struct GETDEVICEINFO4args GETDEVICEINFO4args;

struct GETDEVICEINFO4resok {
	device_addr4 gdir_device_addr;
	bitmap4 gdir_notification;
};
typedef struct GETDEVICEINFO4resok GETDEVICEINFO4resok;

struct GETDEVICEINFO4res {
	nfsstat4 gdir_status;
	union {
		GETDEVICEINFO4resok gdir_resok4;
		count4 gdir_mincount;
	} GETDEVICEINFO4res_u;
};
typedef struct GETDEVICEINFO4res GETDEVICEINFO4res;

struct GETDEVICELIST4args {
	layouttype4 gdla_layout_type;
	count4 gdla_maxdevices;
	nfs_cookie4 gdla_cookie;
	verifier4 gdla_cookieverf;
};
typedef struct GETDEVICELIST4args GETDEVICELIST4args;

struct GETDEVICELIST4resok {
	nfs_cookie4 gdlr_cookie;
	verifier4 gdlr_cookieverf;
	struct {
		u_int gdlr_deviceid_list_len;
		deviceid4 *gdlr_deviceid_list_val;
	} gdlr_deviceid_list;
	bool_t gdlr_eof;
};
typedef struct GETDEVICELIST4resok GETDEVICELIST4resok;

struct GETDEVICELIST4res {
	nfsstat4 gdlr_status;
	union {
		GETDEVICELIST4resok gdlr_resok4;
	} GETDEVICELIST4res_u;
};
typedef struct GETDEVICELIST4res GETDEVICELIST4res;

struct newtime4 {
	bool_t nt_timechanged;
	union {
		nfstime4 nt_time;
	} newtime4_u;
};
typedef struct newtime4 newtime4;

struct newoffset4 {
	bool_t no_newoffset;
	union {
		offset4 no_offset;
	} newoffset4_u;
};
typedef struct newoffset4 newoffset4;

struct LAYOUTCOMMIT4args {
	offset4 loca_offset;
	length4 loca_length;
	bool_t loca_reclaim;
	stateid4 loca_stateid;
	newoffset4 loca_last_write_offset;
	newtime4 loca_time_modify;
	layoutupdate4 loca_layoutupdate;
};
typedef struct LAYOUTCOMMIT4args LAYOUTCOMMIT4args;

struct newsize4 {
	bool_t ns_sizechanged;
	union {
		length4 ns_size;
	} newsize4_u;
};
typedef struct newsize4 newsize4;

struct LAYOUTCOMMIT4resok {
	newsize4 locr_newsize;
};
typedef struct LAYOUTCOMMIT4resok LAYOUTCOMMIT4resok;

struct LAYOUTCOMMIT4res {
	nfsstat4 locr_status;
	union {
		LAYOUTCOMMIT4resok locr_resok4;
	} LAYOUTCOMMIT4res_u;
};
typedef struct LAYOUTCOMMIT4res LAYOUTCOMMIT4res;

struct LAYOUTGET4args {
	bool_t loga_signal_layout_avail;
	layouttype4 loga_layout_type;
	layoutiomode4 loga_iomode;
	offset4 loga_offset;
	length4 loga_length;
	length4 loga_minlength;
	stateid4 loga_stateid;
	count4 loga_maxcount;
};
typedef struct LAYOUTGET4args LAYOUTGET4args;

struct LAYOUTGET4resok {
	bool_t logr_return_on_close;
	stateid4 logr_stateid;
	struct {
		u_int logr_layout_len;
		layout4 *logr_layout_val;
	} logr_layout;
};
typedef struct LAYOUTGET4resok LAYOUTGET4resok;

struct LAYOUTGET4res {
	nfsstat4 logr_status;
	union {
		LAYOUTGET4resok logr_resok4;
		bool_t logr_will_signal_layout_avail;
	} LAYOUTGET4res_u;
};
typedef struct LAYOUTGET4res LAYOUTGET4res;

struct LAYOUTRETURN4args {
	bool_t lora_reclaim;
	layouttype4 lora_layout_type;
	layoutiomode4 lora_iomode;
	layoutreturn4 lora_layoutreturn;
};
typedef struct LAYOUTRETURN4args LAYOUTRETURN4args;

struct layoutreturn_stateid {
	bool_t lrs_present;
	union {
		stateid4 lrs_stateid;
	} layoutreturn_stateid_u;
};
typedef struct layoutreturn_stateid layoutreturn_stateid;

struct LAYOUTRETURN4res {
	nfsstat4 lorr_status;
	union {
		layoutreturn_stateid lorr_stateid;
	} LAYOUTRETURN4res_u;
};
typedef struct LAYOUTRETURN4res LAYOUTRETURN4res;

enum secinfo_style4 {
	SECINFO_STYLE4_CURRENT_FH = 0,
	SECINFO_STYLE4_PARENT = 1
};
typedef enum secinfo_style4 secinfo_style4;

typedef secinfo_style4 SECINFO_NO_NAME4args;

typedef SECINFO4res SECINFO_NO_NAME4res;

struct SEQUENCE4args {
	sessionid4 sa_sessionid;
	sequenceid4 sa_sequenceid;
	slotid4 sa_slotid;
	slotid4 sa_highest_slotid;
	bool_t sa_cachethis;
};
typedef struct SEQUENCE4args SEQUENCE4args;
#define	SEQ4_STATUS_CB_PATH_DOWN 0x00000001
#define	SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING 0x00000002
#define	SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED 0x00000004
#define	SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED 0x00000008
#define	SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED 0x00000010
#define	SEQ4_STATUS_ADMIN_STATE_REVOKED 0x00000020
#define	SEQ4_STATUS_RECALLABLE_STATE_REVOKED 0x00000040
#define	SEQ4_STATUS_LEASE_MOVED 0x00000080
#define	SEQ4_STATUS_RESTART_RECLAIM_NEEDED 0x00000100
#define	SEQ4_STATUS_CB_PATH_DOWN_SESSION 0x00000200
#define	SEQ4_STATUS_BACKCHANNEL_FAULT 0x00000400
#define	SEQ4_STATUS_DEVID_CHANGED 0x00000800
#define	SEQ4_STATUS_DEVID_DELETED 0x00001000

struct SEQUENCE4resok {
	sessionid4 sr_sessionid;
	sequenceid4 sr_sequenceid;
	slotid4 sr_slotid;
	slotid4 sr_highest_slotid;
	slotid4 sr_target_highest_slotid;
	uint32_t sr_status_flags;
};
typedef struct SEQUENCE4resok SEQUENCE4resok;

struct SEQUENCE4res {
	nfsstat4 sr_status;
	union {
		SEQUENCE4resok sr_resok4;
	} SEQUENCE4res_u;
};
typedef struct SEQUENCE4res SEQUENCE4res;

struct ssa_digest_input4 {
	SEQUENCE4args sdi_seqargs;
};
typedef struct ssa_digest_input4 ssa_digest_input4;

struct SET_SSV4args {
	struct {
		u_int ssa_ssv_len;
		char *ssa_ssv_val;
	} ssa_ssv;
	struct {
		u_int ssa_digest_len;
		char *ssa_digest_val;
	} ssa_digest;
};
typedef struct SET_SSV4args SET_SSV4args;

struct ssr_digest_input4 {
	SEQUENCE4res sdi_seqres;
};
typedef struct ssr_digest_input4 ssr_digest_input4;

struct SET_SSV4resok {
	struct {
		u_int ssr_digest_len;
		char *ssr_digest_val;
	} ssr_digest;
};
typedef struct SET_SSV4resok SET_SSV4resok;

struct SET_SSV4res {
	nfsstat4 ssr_status;
	union {
		SET_SSV4resok ssr_resok4;
	} SET_SSV4res_u;
};
typedef struct SET_SSV4res SET_SSV4res;

struct TEST_STATEID4args {
	struct {
		u_int ts_stateids_len;
		stateid4 *ts_stateids_val;
	} ts_stateids;
};
typedef struct TEST_STATEID4args TEST_STATEID4args;

struct TEST_STATEID4resok {
	struct {
		u_int tsr_status_codes_len;
		nfsstat4 *tsr_status_codes_val;
	} tsr_status_codes;
};
typedef struct TEST_STATEID4resok TEST_STATEID4resok;

struct TEST_STATEID4res {
	nfsstat4 tsr_status;
	union {
		TEST_STATEID4resok tsr_resok4;
	} TEST_STATEID4res_u;
};
typedef struct TEST_STATEID4res TEST_STATEID4res;

struct deleg_claim4 {
	open_claim_type4 dc_claim;
	union {
		open_delegation_type4 dc_delegate_type;
	} deleg_claim4_u;
};
typedef struct deleg_claim4 deleg_claim4;

struct WANT_DELEGATION4args {
	uint32_t wda_want;
	deleg_claim4 wda_claim;
};
typedef struct WANT_DELEGATION4args WANT_DELEGATION4args;

struct WANT_DELEGATION4res {
	nfsstat4 wdr_status;
	union {
		open_delegation4 wdr_resok4;
	} WANT_DELEGATION4res_u;
};
typedef struct WANT_DELEGATION4res WANT_DELEGATION4res;

struct DESTROY_CLIENTID4args {
	clientid4 dca_clientid;
};
typedef struct DESTROY_CLIENTID4args DESTROY_CLIENTID4args;

struct DESTROY_CLIENTID4res {
	nfsstat4 dcr_status;
};
typedef struct DESTROY_CLIENTID4res DESTROY_CLIENTID4res;

struct RECLAIM_COMPLETE4args {
	bool_t rca_one_fs;
};
typedef struct RECLAIM_COMPLETE4args RECLAIM_COMPLETE4args;

struct RECLAIM_COMPLETE4res {
	nfsstat4 rcr_status;
};
typedef struct RECLAIM_COMPLETE4res RECLAIM_COMPLETE4res;

struct COPY4args {
	stateid4 ca_src_stateid;
	stateid4 ca_dst_stateid;
	offset4 ca_src_offset;
	offset4 ca_dst_offset;
	length4 ca_count;
	bool_t ca_consecutive;
	bool_t ca_synchronous;
	struct {
		u_int ca_source_server_len;
		netloc4 *ca_source_server_val;
	} ca_source_server;
};
typedef struct COPY4args COPY4args;

struct copy_requirements4 {
	bool_t cr_consecutive;
	bool_t cr_synchronous;
};
typedef struct copy_requirements4 copy_requirements4;

struct COPY4resok {
	write_response4 cr_response;
	copy_requirements4 cr_requirements;
};
typedef struct COPY4resok COPY4resok;

struct COPY4res {
	nfsstat4 cr_status;
	union {
		COPY4resok cr_resok4;
		copy_requirements4 cr_requirements;
	} COPY4res_u;
};
typedef struct COPY4res COPY4res;

struct COPY_NOTIFY4args {
	stateid4 cna_src_stateid;
	netloc4 cna_destination_server;
};
typedef struct COPY_NOTIFY4args COPY_NOTIFY4args;

struct COPY_NOTIFY4resok {
	nfstime4 cnr_lease_time;
	stateid4 cnr_stateid;
	struct {
		u_int cnr_source_server_len;
		netloc4 *cnr_source_server_val;
	} cnr_source_server;
};
typedef struct COPY_NOTIFY4resok COPY_NOTIFY4resok;

struct COPY_NOTIFY4res {
	nfsstat4 cnr_status;
	union {
		COPY_NOTIFY4resok resok4;
	} COPY_NOTIFY4res_u;
};
typedef struct COPY_NOTIFY4res COPY_NOTIFY4res;

struct OFFLOAD_CANCEL4args {
	stateid4 oca_stateid;
};
typedef struct OFFLOAD_CANCEL4args OFFLOAD_CANCEL4args;

struct OFFLOAD_CANCEL4res {
	nfsstat4 ocr_status;
};
typedef struct OFFLOAD_CANCEL4res OFFLOAD_CANCEL4res;

struct OFFLOAD_STATUS4args {
	stateid4 osa_stateid;
};
typedef struct OFFLOAD_STATUS4args OFFLOAD_STATUS4args;

struct OFFLOAD_STATUS4resok {
	length4 osr_count;
	struct {
		u_int osr_complete_len;
		nfsstat4 *osr_complete_val;
	} osr_complete;
};
typedef struct OFFLOAD_STATUS4resok OFFLOAD_STATUS4resok;

struct OFFLOAD_STATUS4res {
	nfsstat4 osr_status;
	union {
		OFFLOAD_STATUS4resok osr_resok4;
	} OFFLOAD_STATUS4res_u;
};
typedef struct OFFLOAD_STATUS4res OFFLOAD_STATUS4res;

struct ALLOCATE4args {
	stateid4 aa_stateid;
	offset4 aa_offset;
	length4 aa_length;
};
typedef struct ALLOCATE4args ALLOCATE4args;

struct ALLOCATE4res {
	nfsstat4 ar_status;
};
typedef struct ALLOCATE4res ALLOCATE4res;

struct DEALLOCATE4args {
	stateid4 da_stateid;
	offset4 da_offset;
	length4 da_length;
};
typedef struct DEALLOCATE4args DEALLOCATE4args;

struct DEALLOCATE4res {
	nfsstat4 dr_status;
};
typedef struct DEALLOCATE4res DEALLOCATE4res;

enum IO_ADVISE_type4 {
	IO_ADVISE4_NORMAL = 0,
	IO_ADVISE4_SEQUENTIAL = 1,
	IO_ADVISE4_SEQUENTIAL_BACKWARDS = 2,
	IO_ADVISE4_RANDOM = 3,
	IO_ADVISE4_WILLNEED = 4,
	IO_ADVISE4_WILLNEED_OPPORTUNISTIC = 5,
	IO_ADVISE4_DONTNEED = 6,
	IO_ADVISE4_NOREUSE = 7,
	IO_ADVISE4_READ = 8,
	IO_ADVISE4_WRITE = 9,
	IO_ADVISE4_INIT_PROXIMITY = 10
};
typedef enum IO_ADVISE_type4 IO_ADVISE_type4;

struct IO_ADVISE4args {
	stateid4 iaa_stateid;
	offset4 iaa_offset;
	length4 iaa_count;
	bitmap4 iaa_hints;
};
typedef struct IO_ADVISE4args IO_ADVISE4args;

struct IO_ADVISE4resok {
	bitmap4 ior_hints;
};
typedef struct IO_ADVISE4resok IO_ADVISE4resok;

struct IO_ADVISE4res {
	nfsstat4 ior_status;
	union {
		IO_ADVISE4resok resok4;
	} IO_ADVISE4res_u;
};
typedef struct IO_ADVISE4res IO_ADVISE4res;

struct device_error4 {
	deviceid4 de_deviceid;
	nfsstat4 de_status;
	nfs_opnum4 de_opnum;
};
typedef struct device_error4 device_error4;

struct LAYOUTERROR4args {
	offset4 lea_offset;
	length4 lea_length;
	stateid4 lea_stateid;
	struct {
		u_int lea_errors_len;
		device_error4 *lea_errors_val;
	} lea_errors;
};
typedef struct LAYOUTERROR4args LAYOUTERROR4args;

struct LAYOUTERROR4res {
	nfsstat4 ler_status;
};
typedef struct LAYOUTERROR4res LAYOUTERROR4res;

struct io_info4 {
	uint64_t ii_count;
	uint64_t ii_bytes;
};
typedef struct io_info4 io_info4;

struct LAYOUTSTATS4args {
	offset4 lsa_offset;
	length4 lsa_length;
	stateid4 lsa_stateid;
	io_info4 lsa_read;
	io_info4 lsa_write;
	deviceid4 lsa_deviceid;
	layoutupdate4 lsa_layoutupdate;
};
typedef struct LAYOUTSTATS4args LAYOUTSTATS4args;

struct LAYOUTSTATS4res {
	nfsstat4 lsr_status;
};
typedef struct LAYOUTSTATS4res LAYOUTSTATS4res;

struct READ_PLUS4args {
	stateid4 rpa_stateid;
	offset4 rpa_offset;
	count4 rpa_count;
};
typedef struct READ_PLUS4args READ_PLUS4args;

struct read_plus_content {
	data_content4 rpc_content;
	union {
		data4 rpc_data;
		data_info4 rpc_hole;
	} read_plus_content_u;
};
typedef struct read_plus_content read_plus_content;

struct read_plus_res4 {
	bool_t rpr_eof;
	struct {
		u_int rpr_contents_len;
		read_plus_content *rpr_contents_val;
	} rpr_contents;
};
typedef struct read_plus_res4 read_plus_res4;

struct READ_PLUS4res {
	nfsstat4 rp_status;
	union {
		read_plus_res4 rp_resok4;
	} READ_PLUS4res_u;
};
typedef struct READ_PLUS4res READ_PLUS4res;

struct SEEK4args {
	stateid4 sa_stateid;
	offset4 sa_offset;
	data_content4 sa_what;
};
typedef struct SEEK4args SEEK4args;

struct seek_res4 {
	bool_t sr_eof;
	offset4 sr_offset;
};
typedef struct seek_res4 seek_res4;

struct SEEK4res {
	nfsstat4 sa_status;
	union {
		seek_res4 resok4;
	} SEEK4res_u;
};
typedef struct SEEK4res SEEK4res;

struct WRITE_SAME4args {
	stateid4 wsa_stateid;
	stable_how4 wsa_stable;
	app_data_block4 wsa_adb;
};
typedef struct WRITE_SAME4args WRITE_SAME4args;

struct WRITE_SAME4res {
	nfsstat4 wsr_status;
	union {
		write_response4 resok4;
	} WRITE_SAME4res_u;
};
typedef struct WRITE_SAME4res WRITE_SAME4res;

struct nfs_argop4 {
	nfs_opnum4 argop;
	union {
		ACCESS4args opaccess;
		CLOSE4args opclose;
		COMMIT4args opcommit;
		CREATE4args opcreate;
		DELEGPURGE4args opdelegpurge;
		DELEGRETURN4args opdelegreturn;
		GETATTR4args opgetattr;
		LINK4args oplink;
		LOCK4args oplock;
		LOCKT4args oplockt;
		LOCKU4args oplocku;
		LOOKUP4args oplookup;
		NVERIFY4args opnverify;
		OPEN4args opopen;
		OPENATTR4args opopenattr;
		OPEN_CONFIRM4args opopen_confirm;
		OPEN_DOWNGRADE4args opopen_downgrade;
		PUTFH4args opputfh;
		READ4args opread;
		READDIR4args opreaddir;
		REMOVE4args opremove;
		RENAME4args oprename;
		RENEW4args oprenew;
		SECINFO4args opsecinfo;
		SETATTR4args opsetattr;
		SETCLIENTID4args opsetclientid;
		SETCLIENTID_CONFIRM4args opsetclientid_confirm;
		VERIFY4args opverify;
		WRITE4args opwrite;
		RELEASE_LOCKOWNER4args oprelease_lockowner;
		BACKCHANNEL_CTL4args opbackchannel_ctl;
		BIND_CONN_TO_SESSION4args opbind_conn_to_session;
		EXCHANGE_ID4args opexchange_id;
		CREATE_SESSION4args opcreate_session;
		DESTROY_SESSION4args opdestroy_session;
		FREE_STATEID4args opfree_stateid;
		GET_DIR_DELEGATION4args opget_dir_delegation;
		GETDEVICEINFO4args opgetdeviceinfo;
		GETDEVICELIST4args opgetdevicelist;
		LAYOUTCOMMIT4args oplayoutcommit;
		LAYOUTGET4args oplayoutget;
		LAYOUTRETURN4args oplayoutreturn;
		SECINFO_NO_NAME4args opsecinfo_no_name;
		SEQUENCE4args opsequence;
		SET_SSV4args opset_ssv;
		TEST_STATEID4args optest_stateid;
		WANT_DELEGATION4args opwant_delegation;
		DESTROY_CLIENTID4args opdestroy_clientid;
		RECLAIM_COMPLETE4args opreclaim_complete;
		ALLOCATE4args opallocate;
		COPY4args opcopy;
		COPY_NOTIFY4args opoffload_notify;
		DEALLOCATE4args opdeallocate;
		IO_ADVISE4args opio_advise;
		LAYOUTERROR4args oplayouterror;
		LAYOUTSTATS4args oplayoutstats;
		OFFLOAD_CANCEL4args opoffload_cancel;
		OFFLOAD_STATUS4args opoffload_status;
		READ_PLUS4args opread_plus;
		SEEK4args opseek;
		WRITE_SAME4args opwrite_same;
		CLONE4args opclone;
	} nfs_argop4_u;
};
typedef struct nfs_argop4 nfs_argop4;

struct nfs_resop4 {
	nfs_opnum4 resop;
	union {
		ACCESS4res opaccess;
		CLOSE4res opclose;
		COMMIT4res opcommit;
		CREATE4res opcreate;
		DELEGPURGE4res opdelegpurge;
		DELEGRETURN4res opdelegreturn;
		GETATTR4res opgetattr;
		GETFH4res opgetfh;
		LINK4res oplink;
		LOCK4res oplock;
		LOCKT4res oplockt;
		LOCKU4res oplocku;
		LOOKUP4res oplookup;
		LOOKUPP4res oplookupp;
		NVERIFY4res opnverify;
		OPEN4res opopen;
		OPENATTR4res opopenattr;
		OPEN_CONFIRM4res opopen_confirm;
		OPEN_DOWNGRADE4res opopen_downgrade;
		PUTFH4res opputfh;
		PUTPUBFH4res opputpubfh;
		PUTROOTFH4res opputrootfh;
		READ4res opread;
		READDIR4res opreaddir;
		READLINK4res opreadlink;
		REMOVE4res opremove;
		RENAME4res oprename;
		RENEW4res oprenew;
		RESTOREFH4res oprestorefh;
		SAVEFH4res opsavefh;
		SECINFO4res opsecinfo;
		SETATTR4res opsetattr;
		SETCLIENTID4res opsetclientid;
		SETCLIENTID_CONFIRM4res opsetclientid_confirm;
		VERIFY4res opverify;
		WRITE4res opwrite;
		RELEASE_LOCKOWNER4res oprelease_lockowner;
		BACKCHANNEL_CTL4res opbackchannel_ctl;
		BIND_CONN_TO_SESSION4res opbind_conn_to_session;
		EXCHANGE_ID4res opexchange_id;
		CREATE_SESSION4res opcreate_session;
		DESTROY_SESSION4res opdestroy_session;
		FREE_STATEID4res opfree_stateid;
		GET_DIR_DELEGATION4res opget_dir_delegation;
		GETDEVICEINFO4res opgetdeviceinfo;
		GETDEVICELIST4res opgetdevicelist;
		LAYOUTCOMMIT4res oplayoutcommit;
		LAYOUTGET4res oplayoutget;
		LAYOUTRETURN4res oplayoutreturn;
		SECINFO_NO_NAME4res opsecinfo_no_name;
		SEQUENCE4res opsequence;
		SET_SSV4res opset_ssv;
		TEST_STATEID4res optest_stateid;
		WANT_DELEGATION4res opwant_delegation;
		DESTROY_CLIENTID4res opdestroy_clientid;
		RECLAIM_COMPLETE4res opreclaim_complete;
		ALLOCATE4res opallocate;
		COPY4res opcopy;
		COPY_NOTIFY4res opcopy_notify;
		DEALLOCATE4res opdeallocate;
		IO_ADVISE4res opio_advise;
		LAYOUTERROR4res oplayouterror;
		LAYOUTSTATS4res oplayoutstats;
		OFFLOAD_CANCEL4res opoffload_cancel;
		OFFLOAD_STATUS4res opoffload_status;
		READ_PLUS4res opread_plus;
		SEEK4res opseek;
		WRITE_SAME4res opwrite_same;
		CLONE4res opclone;
		ILLEGAL4res opillegal;
	} nfs_resop4_u;
};
typedef struct nfs_resop4 nfs_resop4;

struct COMPOUND4args {
	utf8str_cs tag;
	uint32_t minorversion;
	struct {
		u_int argarray_len;
		nfs_argop4 *argarray_val;
	} argarray;
};
typedef struct COMPOUND4args COMPOUND4args;

struct COMPOUND4res {
	nfsstat4 status;
	utf8str_cs tag;
	struct {
		u_int resarray_len;
		nfs_resop4 *resarray_val;
	} resarray;
};
typedef struct COMPOUND4res COMPOUND4res;

struct CB_GETATTR4args {
	nfs_fh4 fh;
	bitmap4 attr_request;
};
typedef struct CB_GETATTR4args CB_GETATTR4args;

struct CB_GETATTR4resok {
	fattr4 obj_attributes;
};
typedef struct CB_GETATTR4resok CB_GETATTR4resok;

struct CB_GETATTR4res {
	nfsstat4 status;
	union {
		CB_GETATTR4resok resok4;
	} CB_GETATTR4res_u;
};
typedef struct CB_GETATTR4res CB_GETATTR4res;

struct CB_RECALL4args {
	stateid4 stateid;
	bool_t truncate;
	nfs_fh4 fh;
};
typedef struct CB_RECALL4args CB_RECALL4args;

struct CB_RECALL4res {
	nfsstat4 status;
};
typedef struct CB_RECALL4res CB_RECALL4res;

struct CB_ILLEGAL4res {
	nfsstat4 status;
};
typedef struct CB_ILLEGAL4res CB_ILLEGAL4res;

enum layoutrecall_type4 {
	LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE,
	LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID,
	LAYOUTRECALL4_ALL = LAYOUT4_RET_REC_ALL
};
typedef enum layoutrecall_type4 layoutrecall_type4;

struct layoutrecall_file4 {
	nfs_fh4 lor_fh;
	offset4 lor_offset;
	length4 lor_length;
	stateid4 lor_stateid;
};
typedef struct layoutrecall_file4 layoutrecall_file4;

struct layoutrecall4 {
	layoutrecall_type4 lor_recalltype;
	union {
		layoutrecall_file4 lor_layout;
		fsid4 lor_fsid;
	} layoutrecall4_u;
};
typedef struct layoutrecall4 layoutrecall4;

struct CB_LAYOUTRECALL4args {
	layouttype4 clora_type;
	layoutiomode4 clora_iomode;
	bool_t clora_changed;
	layoutrecall4 clora_recall;
};
typedef struct CB_LAYOUTRECALL4args CB_LAYOUTRECALL4args;

struct CB_LAYOUTRECALL4res {
	nfsstat4 clorr_status;
};
typedef struct CB_LAYOUTRECALL4res CB_LAYOUTRECALL4res;

enum notify_type4 {
	NOTIFY4_CHANGE_CHILD_ATTRS = 0,
	NOTIFY4_CHANGE_DIR_ATTRS = 1,
	NOTIFY4_REMOVE_ENTRY = 2,
	NOTIFY4_ADD_ENTRY = 3,
	NOTIFY4_RENAME_ENTRY = 4,
	NOTIFY4_CHANGE_COOKIE_VERIFIER = 5
};
typedef enum notify_type4 notify_type4;

struct notify_entry4 {
	component4 ne_file;
	fattr4 ne_attrs;
};
typedef struct notify_entry4 notify_entry4;

struct prev_entry4 {
	notify_entry4 pe_prev_entry;
	nfs_cookie4 pe_prev_entry_cookie;
};
typedef struct prev_entry4 prev_entry4;

struct notify_remove4 {
	notify_entry4 nrm_old_entry;
	nfs_cookie4 nrm_old_entry_cookie;
};
typedef struct notify_remove4 notify_remove4;

struct notify_add4 {
	struct {
		u_int nad_old_entry_len;
		notify_remove4 *nad_old_entry_val;
	} nad_old_entry;
	notify_entry4 nad_new_entry;
	struct {
		u_int nad_new_entry_cookie_len;
		nfs_cookie4 *nad_new_entry_cookie_val;
	} nad_new_entry_cookie;
	struct {
		u_int nad_prev_entry_len;
		prev_entry4 *nad_prev_entry_val;
	} nad_prev_entry;
	bool_t nad_last_entry;
};
typedef struct notify_add4 notify_add4;

struct notify_attr4 {
	notify_entry4 na_changed_entry;
};
typedef struct notify_attr4 notify_attr4;

struct notify_rename4 {
	notify_remove4 nrn_old_entry;
	notify_add4 nrn_new_entry;
};
typedef struct notify_rename4 notify_rename4;

struct notify_verifier4 {
	verifier4 nv_old_cookieverf;
	verifier4 nv_new_cookieverf;
};
typedef struct notify_verifier4 notify_verifier4;

typedef struct {
	u_int notifylist4_len;
	char *notifylist4_val;
} notifylist4;

struct notify4 {
	bitmap4 notify_mask;
	notifylist4 notify_vals;
};
typedef struct notify4 notify4;

struct CB_NOTIFY4args {
	stateid4 cna_stateid;
	nfs_fh4 cna_fh;
	struct {
		u_int cna_changes_len;
		notify4 *cna_changes_val;
	} cna_changes;
};
typedef struct CB_NOTIFY4args CB_NOTIFY4args;

struct CB_NOTIFY4res {
	nfsstat4 cnr_status;
};
typedef struct CB_NOTIFY4res CB_NOTIFY4res;

struct CB_PUSH_DELEG4args {
	nfs_fh4 cpda_fh;
	open_delegation4 cpda_delegation;
};
typedef struct CB_PUSH_DELEG4args CB_PUSH_DELEG4args;

struct CB_PUSH_DELEG4res {
	nfsstat4 cpdr_status;
};
typedef struct CB_PUSH_DELEG4res CB_PUSH_DELEG4res;
#define	RCA4_TYPE_MASK_RDATA_DLG 0
#define	RCA4_TYPE_MASK_WDATA_DLG 1
#define	RCA4_TYPE_MASK_DIR_DLG 2
#define	RCA4_TYPE_MASK_FILE_LAYOUT 3
#define	RCA4_TYPE_MASK_BLK_LAYOUT 4
#define	RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8
#define	RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9
#define	RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
#define	RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15

struct CB_RECALL_ANY4args {
	uint32_t craa_objects_to_keep;
	bitmap4 craa_type_mask;
};
typedef struct CB_RECALL_ANY4args CB_RECALL_ANY4args;

struct CB_RECALL_ANY4res {
	nfsstat4 crar_status;
};
typedef struct CB_RECALL_ANY4res CB_RECALL_ANY4res;

typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args;

struct CB_RECALLABLE_OBJ_AVAIL4res {
	nfsstat4 croa_status;
};
typedef struct CB_RECALLABLE_OBJ_AVAIL4res CB_RECALLABLE_OBJ_AVAIL4res;

struct CB_RECALL_SLOT4args {
	slotid4 rsa_target_highest_slotid;
};
typedef struct CB_RECALL_SLOT4args CB_RECALL_SLOT4args;

struct CB_RECALL_SLOT4res {
	nfsstat4 rsr_status;
};
typedef struct CB_RECALL_SLOT4res CB_RECALL_SLOT4res;

struct referring_call4 {
	sequenceid4 rc_sequenceid;
	slotid4 rc_slotid;
};
typedef struct referring_call4 referring_call4;

struct referring_call_list4 {
	sessionid4 rcl_sessionid;
	struct {
		u_int rcl_referring_calls_len;
		referring_call4 *rcl_referring_calls_val;
	} rcl_referring_calls;
};
typedef struct referring_call_list4 referring_call_list4;

struct CB_SEQUENCE4args {
	sessionid4 csa_sessionid;
	sequenceid4 csa_sequenceid;
	slotid4 csa_slotid;
	slotid4 csa_highest_slotid;
	bool_t csa_cachethis;
	struct {
		u_int csa_referring_call_lists_len;
		referring_call_list4 *csa_referring_call_lists_val;
	} csa_referring_call_lists;
};
typedef struct CB_SEQUENCE4args CB_SEQUENCE4args;

struct CB_SEQUENCE4resok {
	sessionid4 csr_sessionid;
	sequenceid4 csr_sequenceid;
	slotid4 csr_slotid;
	slotid4 csr_highest_slotid;
	slotid4 csr_target_highest_slotid;
};
typedef struct CB_SEQUENCE4resok CB_SEQUENCE4resok;

struct CB_SEQUENCE4res {
	nfsstat4 csr_status;
	union {
		CB_SEQUENCE4resok csr_resok4;
	} CB_SEQUENCE4res_u;
};
typedef struct CB_SEQUENCE4res CB_SEQUENCE4res;

struct CB_WANTS_CANCELLED4args {
	bool_t cwca_contended_wants_cancelled;
	bool_t cwca_resourced_wants_cancelled;
};
typedef struct CB_WANTS_CANCELLED4args CB_WANTS_CANCELLED4args;

struct CB_WANTS_CANCELLED4res {
	nfsstat4 cwcr_status;
};
typedef struct CB_WANTS_CANCELLED4res CB_WANTS_CANCELLED4res;

struct CB_NOTIFY_LOCK4args {
	nfs_fh4 cnla_fh;
	lock_owner4 cnla_lock_owner;
};
typedef struct CB_NOTIFY_LOCK4args CB_NOTIFY_LOCK4args;

struct CB_NOTIFY_LOCK4res {
	nfsstat4 cnlr_status;
};
typedef struct CB_NOTIFY_LOCK4res CB_NOTIFY_LOCK4res;

enum notify_deviceid_type4 {
	NOTIFY_DEVICEID4_CHANGE = 1,
	NOTIFY_DEVICEID4_DELETE = 2
};
typedef enum notify_deviceid_type4 notify_deviceid_type4;

struct notify_deviceid_delete4 {
	layouttype4 ndd_layouttype;
	deviceid4 ndd_deviceid;
};
typedef struct notify_deviceid_delete4 notify_deviceid_delete4;

struct notify_deviceid_change4 {
	layouttype4 ndc_layouttype;
	deviceid4 ndc_deviceid;
	bool_t ndc_immediate;
};
typedef struct notify_deviceid_change4 notify_deviceid_change4;

struct CB_NOTIFY_DEVICEID4args {
	struct {
		u_int cnda_changes_len;
		notify4 *cnda_changes_val;
	} cnda_changes;
};
typedef struct CB_NOTIFY_DEVICEID4args CB_NOTIFY_DEVICEID4args;

struct CB_NOTIFY_DEVICEID4res {
	nfsstat4 cndr_status;
};
typedef struct CB_NOTIFY_DEVICEID4res CB_NOTIFY_DEVICEID4res;

struct offload_info4 {
	nfsstat4 coa_status;
	union {
		write_response4 coa_resok4;
		length4 coa_bytes_copied;
	} offload_info4_u;
};
typedef struct offload_info4 offload_info4;

struct CB_OFFLOAD4args {
	nfs_fh4 coa_fh;
	stateid4 coa_stateid;
	offload_info4 coa_offload_info;
};
typedef struct CB_OFFLOAD4args CB_OFFLOAD4args;

struct CB_OFFLOAD4res {
	nfsstat4 cor_status;
};
typedef struct CB_OFFLOAD4res CB_OFFLOAD4res;

/* Callback operations new to NFSv4.1 */
/* Callback operations new to NFSv4.2 */

enum nfs_cb_opnum4 {
	OP_CB_GETATTR = 3,
	OP_CB_RECALL = 4,
	OP_CB_LAYOUTRECALL = 5,
	OP_CB_NOTIFY = 6,
	OP_CB_PUSH_DELEG = 7,
	OP_CB_RECALL_ANY = 8,
	OP_CB_RECALLABLE_OBJ_AVAIL = 9,
	OP_CB_RECALL_SLOT = 10,
	OP_CB_SEQUENCE = 11,
	OP_CB_WANTS_CANCELLED = 12,
	OP_CB_NOTIFY_LOCK = 13,
	OP_CB_NOTIFY_DEVICEID = 14,
	OP_CB_OFFLOAD = 15,
	OP_CB_ILLEGAL = 10044
};
typedef enum nfs_cb_opnum4 nfs_cb_opnum4;

struct nfs_cb_argop4 {
	nfs_cb_opnum4 argop;
	union {
		CB_GETATTR4args opcbgetattr;
		CB_RECALL4args opcbrecall;
		CB_LAYOUTRECALL4args opcblayoutrecall;
		CB_NOTIFY4args opcbnotify;
		CB_PUSH_DELEG4args opcbpush_deleg;
		CB_RECALL_ANY4args opcbrecall_any;
		CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail;
		CB_RECALL_SLOT4args opcbrecall_slot;
		CB_SEQUENCE4args opcbsequence;
		CB_WANTS_CANCELLED4args opcbwants_cancelled;
		CB_NOTIFY_LOCK4args opcbnotify_lock;
		CB_NOTIFY_DEVICEID4args opcbnotify_deviceid;
		CB_OFFLOAD4args opcboffload;
	} nfs_cb_argop4_u;
};
typedef struct nfs_cb_argop4 nfs_cb_argop4;

struct nfs_cb_resop4 {
	nfs_cb_opnum4 resop;
	union {
		CB_GETATTR4res opcbgetattr;
		CB_RECALL4res opcbrecall;
		CB_LAYOUTRECALL4res opcblayoutrecall;
		CB_NOTIFY4res opcbnotify;
		CB_PUSH_DELEG4res opcbpush_deleg;
		CB_RECALL_ANY4res opcbrecall_any;
		CB_RECALLABLE_OBJ_AVAIL4res opcbrecallable_obj_avail;
		CB_RECALL_SLOT4res opcbrecall_slot;
		CB_SEQUENCE4res opcbsequence;
		CB_WANTS_CANCELLED4res opcbwants_cancelled;
		CB_NOTIFY_LOCK4res opcbnotify_lock;
		CB_NOTIFY_DEVICEID4res opcbnotify_deviceid;
		CB_OFFLOAD4res opcboffload;
		CB_ILLEGAL4res opcbillegal;
	} nfs_cb_resop4_u;
};
typedef struct nfs_cb_resop4 nfs_cb_resop4;

struct CB_COMPOUND4args {
	utf8str_cs tag;
	uint32_t minorversion;
	uint32_t callback_ident;
	struct {
		u_int argarray_len;
		nfs_cb_argop4 *argarray_val;
	} argarray;
};
typedef struct CB_COMPOUND4args CB_COMPOUND4args;

struct CB_COMPOUND4res {
	nfsstat4 status;
	utf8str_cs tag;
	struct {
		u_int resarray_len;
		nfs_cb_resop4 *resarray_val;
	} resarray;
};
typedef struct CB_COMPOUND4res CB_COMPOUND4res;

#define	NFS4_PROGRAM	100003
#define	NFS_V4	4

#if defined(__STDC__) || defined(__cplusplus)
#define	NFSPROC4_NULL	0
extern  void * nfsproc4_null_4(void *, CLIENT *);
extern  void * nfsproc4_null_4_svc(void *, struct svc_req *);
#define	NFSPROC4_COMPOUND	1
extern  COMPOUND4res * nfsproc4_compound_4(COMPOUND4args *, CLIENT *);
extern  COMPOUND4res * nfsproc4_compound_4_svc(COMPOUND4args *, struct svc_req *);
extern int nfs4_program_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	NFSPROC4_NULL	0
extern  void * nfsproc4_null_4();
extern  void * nfsproc4_null_4_svc();
#define	NFSPROC4_COMPOUND	1
extern  COMPOUND4res * nfsproc4_compound_4();
extern  COMPOUND4res * nfsproc4_compound_4_svc();
extern int nfs4_program_4_freeresult();
#endif /* K&R C */

#define	NFS4_CALLBACK	0x40000000
#define	NFS_CB	1

#if defined(__STDC__) || defined(__cplusplus)
#define	CB_NULL	0
extern  void * cb_null_1(void *, CLIENT *);
extern  void * cb_null_1_svc(void *, struct svc_req *);
#define	CB_COMPOUND	1
extern  CB_COMPOUND4res * cb_compound_1(CB_COMPOUND4args *, CLIENT *);
extern  CB_COMPOUND4res * cb_compound_1_svc(CB_COMPOUND4args *, struct svc_req *);
extern int nfs4_callback_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	CB_NULL	0
extern  void * cb_null_1();
extern  void * cb_null_1_svc();
#define	CB_COMPOUND	1
extern  CB_COMPOUND4res * cb_compound_1();
extern  CB_COMPOUND4res * cb_compound_1_svc();
extern int nfs4_callback_1_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_nfs_ftype4(XDR *, nfs_ftype4*);
extern  bool_t xdr_nfsstat4(XDR *, nfsstat4*);
extern  bool_t xdr_attrlist4(XDR *, attrlist4*);
extern  bool_t xdr_bitmap4(XDR *, bitmap4*);
extern  bool_t xdr_changeid4(XDR *, changeid4*);
extern  bool_t xdr_clientid4(XDR *, clientid4*);
extern  bool_t xdr_count4(XDR *, count4*);
extern  bool_t xdr_length4(XDR *, length4*);
extern  bool_t xdr_mode4(XDR *, mode4*);
extern  bool_t xdr_nfs_cookie4(XDR *, nfs_cookie4*);
extern  bool_t xdr_nfs_fh4(XDR *, nfs_fh4*);
extern  bool_t xdr_offset4(XDR *, offset4*);
extern  bool_t xdr_qop4(XDR *, qop4*);
extern  bool_t xdr_sec_oid4(XDR *, sec_oid4*);
extern  bool_t xdr_sequenceid4(XDR *, sequenceid4*);
extern  bool_t xdr_seqid4(XDR *, seqid4*);
extern  bool_t xdr_sessionid4(XDR *, sessionid4);
extern  bool_t xdr_slotid4(XDR *, slotid4*);
extern  bool_t xdr_utf8string(XDR *, utf8string*);
extern  bool_t xdr_utf8str_cis(XDR *, utf8str_cis*);
extern  bool_t xdr_utf8str_cs(XDR *, utf8str_cs*);
extern  bool_t xdr_utf8str_mixed(XDR *, utf8str_mixed*);
extern  bool_t xdr_component4(XDR *, component4*);
extern  bool_t xdr_linktext4(XDR *, linktext4*);
extern  bool_t xdr_ascii_REQUIRED4(XDR *, ascii_REQUIRED4*);
extern  bool_t xdr_pathname4(XDR *, pathname4*);
extern  bool_t xdr_verifier4(XDR *, verifier4);
extern  bool_t xdr_secret4(XDR *, secret4*);
extern  bool_t xdr_policy4(XDR *, policy4*);
extern  bool_t xdr_nfstime4(XDR *, nfstime4*);
extern  bool_t xdr_time_how4(XDR *, time_how4*);
extern  bool_t xdr_settime4(XDR *, settime4*);
extern  bool_t xdr_nfs_lease4(XDR *, nfs_lease4*);
extern  bool_t xdr_fsid4(XDR *, fsid4*);
extern  bool_t xdr_change_policy4(XDR *, change_policy4*);
extern  bool_t xdr_fs_location4(XDR *, fs_location4*);
extern  bool_t xdr_fs_locations4(XDR *, fs_locations4*);
extern  bool_t xdr_acetype4(XDR *, acetype4*);
extern  bool_t xdr_aceflag4(XDR *, aceflag4*);
extern  bool_t xdr_acemask4(XDR *, acemask4*);
extern  bool_t xdr_nfsace4(XDR *, nfsace4*);
extern  bool_t xdr_aclflag4(XDR *, aclflag4*);
extern  bool_t xdr_nfsacl41(XDR *, nfsacl41*);
extern  bool_t xdr_mode_masked4(XDR *, mode_masked4*);
extern  bool_t xdr_specdata4(XDR *, specdata4*);
extern  bool_t xdr_netaddr4(XDR *, netaddr4*);
extern  bool_t xdr_nfs_impl_id4(XDR *, nfs_impl_id4*);
extern  bool_t xdr_stateid4(XDR *, stateid4*);
extern  bool_t xdr_layouttype4(XDR *, layouttype4*);
extern  bool_t xdr_layout_content4(XDR *, layout_content4*);
extern  bool_t xdr_layouthint4(XDR *, layouthint4*);
extern  bool_t xdr_layoutiomode4(XDR *, layoutiomode4*);
extern  bool_t xdr_layout4(XDR *, layout4*);
extern  bool_t xdr_deviceid4(XDR *, deviceid4);
extern  bool_t xdr_device_addr4(XDR *, device_addr4*);
extern  bool_t xdr_layoutupdate4(XDR *, layoutupdate4*);
extern  bool_t xdr_layoutreturn_type4(XDR *, layoutreturn_type4*);
extern  bool_t xdr_layoutreturn_file4(XDR *, layoutreturn_file4*);
extern  bool_t xdr_layoutreturn4(XDR *, layoutreturn4*);
extern  bool_t xdr_fs4_status_type(XDR *, fs4_status_type*);
extern  bool_t xdr_fs4_status(XDR *, fs4_status*);
extern  bool_t xdr_threshold4_read_size(XDR *, threshold4_read_size*);
extern  bool_t xdr_threshold4_write_size(XDR *, threshold4_write_size*);
extern  bool_t xdr_threshold4_read_iosize(XDR *, threshold4_read_iosize*);
extern  bool_t xdr_threshold4_write_iosize(XDR *, threshold4_write_iosize*);
extern  bool_t xdr_threshold_item4(XDR *, threshold_item4*);
extern  bool_t xdr_mdsthreshold4(XDR *, mdsthreshold4*);
extern  bool_t xdr_retention_get4(XDR *, retention_get4*);
extern  bool_t xdr_retention_set4(XDR *, retention_set4*);
extern  bool_t xdr_fs_charset_cap4(XDR *, fs_charset_cap4*);
extern  bool_t xdr_netloc_type4(XDR *, netloc_type4*);
extern  bool_t xdr_netloc4(XDR *, netloc4*);
extern  bool_t xdr_change_attr_type4(XDR *, change_attr_type4*);
extern  bool_t xdr_labelformat_spec4(XDR *, labelformat_spec4*);
extern  bool_t xdr_sec_label4(XDR *, sec_label4*);
extern  bool_t xdr_copy_from_auth_priv(XDR *, copy_from_auth_priv*);
extern  bool_t xdr_copy_to_auth_priv(XDR *, copy_to_auth_priv*);
extern  bool_t xdr_copy_confirm_auth_priv(XDR *, copy_confirm_auth_priv*);
extern  bool_t xdr_app_data_block4(XDR *, app_data_block4*);
extern  bool_t xdr_data4(XDR *, data4*);
extern  bool_t xdr_data_info4(XDR *, data_info4*);
extern  bool_t xdr_data_content4(XDR *, data_content4*);
extern  bool_t xdr_stable_how4(XDR *, stable_how4*);
extern  bool_t xdr_write_response4(XDR *, write_response4*);
extern  bool_t xdr_fattr4_supported_attrs(XDR *, fattr4_supported_attrs*);
extern  bool_t xdr_fattr4_type(XDR *, fattr4_type*);
extern  bool_t xdr_fattr4_fh_expire_type(XDR *, fattr4_fh_expire_type*);
extern  bool_t xdr_fattr4_change(XDR *, fattr4_change*);
extern  bool_t xdr_fattr4_size(XDR *, fattr4_size*);
extern  bool_t xdr_fattr4_link_support(XDR *, fattr4_link_support*);
extern  bool_t xdr_fattr4_symlink_support(XDR *, fattr4_symlink_support*);
extern  bool_t xdr_fattr4_named_attr(XDR *, fattr4_named_attr*);
extern  bool_t xdr_fattr4_fsid(XDR *, fattr4_fsid*);
extern  bool_t xdr_fattr4_unique_handles(XDR *, fattr4_unique_handles*);
extern  bool_t xdr_fattr4_lease_time(XDR *, fattr4_lease_time*);
extern  bool_t xdr_fattr4_rdattr_error(XDR *, fattr4_rdattr_error*);
extern  bool_t xdr_fattr4_acl(XDR *, fattr4_acl*);
extern  bool_t xdr_fattr4_aclsupport(XDR *, fattr4_aclsupport*);
extern  bool_t xdr_fattr4_archive(XDR *, fattr4_archive*);
extern  bool_t xdr_fattr4_cansettime(XDR *, fattr4_cansettime*);
extern  bool_t xdr_fattr4_case_insensitive(XDR *, fattr4_case_insensitive*);
extern  bool_t xdr_fattr4_case_preserving(XDR *, fattr4_case_preserving*);
extern  bool_t xdr_fattr4_chown_restricted(XDR *, fattr4_chown_restricted*);
extern  bool_t xdr_fattr4_fileid(XDR *, fattr4_fileid*);
extern  bool_t xdr_fattr4_files_avail(XDR *, fattr4_files_avail*);
extern  bool_t xdr_fattr4_filehandle(XDR *, fattr4_filehandle*);
extern  bool_t xdr_fattr4_files_free(XDR *, fattr4_files_free*);
extern  bool_t xdr_fattr4_files_total(XDR *, fattr4_files_total*);
extern  bool_t xdr_fattr4_fs_locations(XDR *, fattr4_fs_locations*);
extern  bool_t xdr_fattr4_hidden(XDR *, fattr4_hidden*);
extern  bool_t xdr_fattr4_homogeneous(XDR *, fattr4_homogeneous*);
extern  bool_t xdr_fattr4_maxfilesize(XDR *, fattr4_maxfilesize*);
extern  bool_t xdr_fattr4_maxlink(XDR *, fattr4_maxlink*);
extern  bool_t xdr_fattr4_maxname(XDR *, fattr4_maxname*);
extern  bool_t xdr_fattr4_maxread(XDR *, fattr4_maxread*);
extern  bool_t xdr_fattr4_maxwrite(XDR *, fattr4_maxwrite*);
extern  bool_t xdr_fattr4_mimetype(XDR *, fattr4_mimetype*);
extern  bool_t xdr_fattr4_mode(XDR *, fattr4_mode*);
extern  bool_t xdr_fattr4_mode_set_masked(XDR *, fattr4_mode_set_masked*);
extern  bool_t xdr_fattr4_mounted_on_fileid(XDR *, fattr4_mounted_on_fileid*);
extern  bool_t xdr_fattr4_no_trunc(XDR *, fattr4_no_trunc*);
extern  bool_t xdr_fattr4_numlinks(XDR *, fattr4_numlinks*);
extern  bool_t xdr_fattr4_owner(XDR *, fattr4_owner*);
extern  bool_t xdr_fattr4_owner_group(XDR *, fattr4_owner_group*);
extern  bool_t xdr_fattr4_quota_avail_hard(XDR *, fattr4_quota_avail_hard*);
extern  bool_t xdr_fattr4_quota_avail_soft(XDR *, fattr4_quota_avail_soft*);
extern  bool_t xdr_fattr4_quota_used(XDR *, fattr4_quota_used*);
extern  bool_t xdr_fattr4_rawdev(XDR *, fattr4_rawdev*);
extern  bool_t xdr_fattr4_space_avail(XDR *, fattr4_space_avail*);
extern  bool_t xdr_fattr4_space_free(XDR *, fattr4_space_free*);
extern  bool_t xdr_fattr4_space_total(XDR *, fattr4_space_total*);
extern  bool_t xdr_fattr4_space_used(XDR *, fattr4_space_used*);
extern  bool_t xdr_fattr4_system(XDR *, fattr4_system*);
extern  bool_t xdr_fattr4_time_access(XDR *, fattr4_time_access*);
extern  bool_t xdr_fattr4_time_access_set(XDR *, fattr4_time_access_set*);
extern  bool_t xdr_fattr4_time_backup(XDR *, fattr4_time_backup*);
extern  bool_t xdr_fattr4_time_create(XDR *, fattr4_time_create*);
extern  bool_t xdr_fattr4_time_delta(XDR *, fattr4_time_delta*);
extern  bool_t xdr_fattr4_time_metadata(XDR *, fattr4_time_metadata*);
extern  bool_t xdr_fattr4_time_modify(XDR *, fattr4_time_modify*);
extern  bool_t xdr_fattr4_time_modify_set(XDR *, fattr4_time_modify_set*);
extern  bool_t xdr_fattr4_suppattr_exclcreat(XDR *, fattr4_suppattr_exclcreat*);
extern  bool_t xdr_fattr4_dir_notif_delay(XDR *, fattr4_dir_notif_delay*);
extern  bool_t xdr_fattr4_dirent_notif_delay(XDR *, fattr4_dirent_notif_delay*);
extern  bool_t xdr_fattr4_fs_layout_types(XDR *, fattr4_fs_layout_types*);
extern  bool_t xdr_fattr4_fs_status(XDR *, fattr4_fs_status*);
extern  bool_t xdr_fattr4_fs_charset_cap(XDR *, fattr4_fs_charset_cap*);
extern  bool_t xdr_fattr4_layout_alignment(XDR *, fattr4_layout_alignment*);
extern  bool_t xdr_fattr4_layout_blksize(XDR *, fattr4_layout_blksize*);
extern  bool_t xdr_fattr4_layout_hint(XDR *, fattr4_layout_hint*);
extern  bool_t xdr_fattr4_layout_types(XDR *, fattr4_layout_types*);
extern  bool_t xdr_fattr4_mdsthreshold(XDR *, fattr4_mdsthreshold*);
extern  bool_t xdr_fattr4_retention_get(XDR *, fattr4_retention_get*);
extern  bool_t xdr_fattr4_retention_set(XDR *, fattr4_retention_set*);
extern  bool_t xdr_fattr4_retentevt_get(XDR *, fattr4_retentevt_get*);
extern  bool_t xdr_fattr4_retentevt_set(XDR *, fattr4_retentevt_set*);
extern  bool_t xdr_fattr4_retention_hold(XDR *, fattr4_retention_hold*);
extern  bool_t xdr_fattr4_dacl(XDR *, fattr4_dacl*);
extern  bool_t xdr_fattr4_sacl(XDR *, fattr4_sacl*);
extern  bool_t xdr_fattr4_change_policy(XDR *, fattr4_change_policy*);
extern  bool_t xdr_fattr4_space_freed(XDR *, fattr4_space_freed*);
extern  bool_t xdr_fattr4_change_attr_type(XDR *, fattr4_change_attr_type*);
extern  bool_t xdr_fattr4_sec_label(XDR *, fattr4_sec_label*);
extern  bool_t xdr_fattr4_clone_blksize(XDR *, fattr4_clone_blksize*);
extern  bool_t xdr_fattr4(XDR *, fattr4*);
extern  bool_t xdr_change_info4(XDR *, change_info4*);
extern  bool_t xdr_clientaddr4(XDR *, clientaddr4*);
extern  bool_t xdr_cb_client4(XDR *, cb_client4*);
extern  bool_t xdr_nfs_client_id4(XDR *, nfs_client_id4*);
extern  bool_t xdr_client_owner4(XDR *, client_owner4*);
extern  bool_t xdr_server_owner4(XDR *, server_owner4*);
extern  bool_t xdr_state_owner4(XDR *, state_owner4*);
extern  bool_t xdr_open_owner4(XDR *, open_owner4*);
extern  bool_t xdr_lock_owner4(XDR *, lock_owner4*);
extern  bool_t xdr_nfs_lock_type4(XDR *, nfs_lock_type4*);
extern  bool_t xdr_ssv_subkey4(XDR *, ssv_subkey4*);
extern  bool_t xdr_ssv_mic_plain_tkn4(XDR *, ssv_mic_plain_tkn4*);
extern  bool_t xdr_ssv_mic_tkn4(XDR *, ssv_mic_tkn4*);
extern  bool_t xdr_ssv_seal_plain_tkn4(XDR *, ssv_seal_plain_tkn4*);
extern  bool_t xdr_ssv_seal_cipher_tkn4(XDR *, ssv_seal_cipher_tkn4*);
extern  bool_t xdr_fs_locations_server4(XDR *, fs_locations_server4*);
extern  bool_t xdr_fs_locations_item4(XDR *, fs_locations_item4*);
extern  bool_t xdr_fs_locations_info4(XDR *, fs_locations_info4*);
extern  bool_t xdr_fattr4_fs_locations_info(XDR *, fattr4_fs_locations_info*);
extern  bool_t xdr_nfl_util4(XDR *, nfl_util4*);
extern  bool_t xdr_filelayout_hint_care4(XDR *, filelayout_hint_care4*);
extern  bool_t xdr_nfsv4_1_file_layouthint4(XDR *, nfsv4_1_file_layouthint4*);
extern  bool_t xdr_multipath_list4(XDR *, multipath_list4*);
extern  bool_t xdr_nfsv4_1_file_layout_ds_addr4(XDR *, nfsv4_1_file_layout_ds_addr4*);
extern  bool_t xdr_nfsv4_1_file_layout4(XDR *, nfsv4_1_file_layout4*);
extern  bool_t xdr_nfs_opnum4(XDR *, nfs_opnum4*);
extern  bool_t xdr_ACCESS4args(XDR *, ACCESS4args*);
extern  bool_t xdr_ACCESS4resok(XDR *, ACCESS4resok*);
extern  bool_t xdr_ACCESS4res(XDR *, ACCESS4res*);
extern  bool_t xdr_CLONE4args(XDR *, CLONE4args*);
extern  bool_t xdr_CLONE4res(XDR *, CLONE4res*);
extern  bool_t xdr_CLOSE4args(XDR *, CLOSE4args*);
extern  bool_t xdr_CLOSE4res(XDR *, CLOSE4res*);
extern  bool_t xdr_COMMIT4args(XDR *, COMMIT4args*);
extern  bool_t xdr_COMMIT4resok(XDR *, COMMIT4resok*);
extern  bool_t xdr_COMMIT4res(XDR *, COMMIT4res*);
extern  bool_t xdr_createtype4(XDR *, createtype4*);
extern  bool_t xdr_CREATE4args(XDR *, CREATE4args*);
extern  bool_t xdr_CREATE4resok(XDR *, CREATE4resok*);
extern  bool_t xdr_CREATE4res(XDR *, CREATE4res*);
extern  bool_t xdr_DELEGPURGE4args(XDR *, DELEGPURGE4args*);
extern  bool_t xdr_DELEGPURGE4res(XDR *, DELEGPURGE4res*);
extern  bool_t xdr_DELEGRETURN4args(XDR *, DELEGRETURN4args*);
extern  bool_t xdr_DELEGRETURN4res(XDR *, DELEGRETURN4res*);
extern  bool_t xdr_GETATTR4args(XDR *, GETATTR4args*);
extern  bool_t xdr_GETATTR4resok(XDR *, GETATTR4resok*);
extern  bool_t xdr_GETATTR4res(XDR *, GETATTR4res*);
extern  bool_t xdr_GETFH4resok(XDR *, GETFH4resok*);
extern  bool_t xdr_GETFH4res(XDR *, GETFH4res*);
extern  bool_t xdr_LINK4args(XDR *, LINK4args*);
extern  bool_t xdr_LINK4resok(XDR *, LINK4resok*);
extern  bool_t xdr_LINK4res(XDR *, LINK4res*);
extern  bool_t xdr_open_to_lock_owner4(XDR *, open_to_lock_owner4*);
extern  bool_t xdr_exist_lock_owner4(XDR *, exist_lock_owner4*);
extern  bool_t xdr_locker4(XDR *, locker4*);
extern  bool_t xdr_LOCK4args(XDR *, LOCK4args*);
extern  bool_t xdr_LOCK4denied(XDR *, LOCK4denied*);
extern  bool_t xdr_LOCK4resok(XDR *, LOCK4resok*);
extern  bool_t xdr_LOCK4res(XDR *, LOCK4res*);
extern  bool_t xdr_LOCKT4args(XDR *, LOCKT4args*);
extern  bool_t xdr_LOCKT4res(XDR *, LOCKT4res*);
extern  bool_t xdr_LOCKU4args(XDR *, LOCKU4args*);
extern  bool_t xdr_LOCKU4res(XDR *, LOCKU4res*);
extern  bool_t xdr_LOOKUP4args(XDR *, LOOKUP4args*);
extern  bool_t xdr_LOOKUP4res(XDR *, LOOKUP4res*);
extern  bool_t xdr_LOOKUPP4res(XDR *, LOOKUPP4res*);
extern  bool_t xdr_NVERIFY4args(XDR *, NVERIFY4args*);
extern  bool_t xdr_NVERIFY4res(XDR *, NVERIFY4res*);
extern  bool_t xdr_createmode4(XDR *, createmode4*);
extern  bool_t xdr_creatverfattr(XDR *, creatverfattr*);
extern  bool_t xdr_createhow4(XDR *, createhow4*);
extern  bool_t xdr_opentype4(XDR *, opentype4*);
extern  bool_t xdr_openflag4(XDR *, openflag4*);
extern  bool_t xdr_limit_by4(XDR *, limit_by4*);
extern  bool_t xdr_nfs_modified_limit4(XDR *, nfs_modified_limit4*);
extern  bool_t xdr_nfs_space_limit4(XDR *, nfs_space_limit4*);
extern  bool_t xdr_open_delegation_type4(XDR *, open_delegation_type4*);
extern  bool_t xdr_open_claim_type4(XDR *, open_claim_type4*);
extern  bool_t xdr_open_claim_delegate_cur4(XDR *, open_claim_delegate_cur4*);
extern  bool_t xdr_open_claim4(XDR *, open_claim4*);
extern  bool_t xdr_OPEN4args(XDR *, OPEN4args*);
extern  bool_t xdr_open_read_delegation4(XDR *, open_read_delegation4*);
extern  bool_t xdr_open_write_delegation4(XDR *, open_write_delegation4*);
extern  bool_t xdr_why_no_delegation4(XDR *, why_no_delegation4*);
extern  bool_t xdr_open_none_delegation4(XDR *, open_none_delegation4*);
extern  bool_t xdr_open_delegation4(XDR *, open_delegation4*);
extern  bool_t xdr_OPEN4resok(XDR *, OPEN4resok*);
extern  bool_t xdr_OPEN4res(XDR *, OPEN4res*);
extern  bool_t xdr_OPENATTR4args(XDR *, OPENATTR4args*);
extern  bool_t xdr_OPENATTR4res(XDR *, OPENATTR4res*);
extern  bool_t xdr_OPEN_CONFIRM4args(XDR *, OPEN_CONFIRM4args*);
extern  bool_t xdr_OPEN_CONFIRM4resok(XDR *, OPEN_CONFIRM4resok*);
extern  bool_t xdr_OPEN_CONFIRM4res(XDR *, OPEN_CONFIRM4res*);
extern  bool_t xdr_OPEN_DOWNGRADE4args(XDR *, OPEN_DOWNGRADE4args*);
extern  bool_t xdr_OPEN_DOWNGRADE4resok(XDR *, OPEN_DOWNGRADE4resok*);
extern  bool_t xdr_OPEN_DOWNGRADE4res(XDR *, OPEN_DOWNGRADE4res*);
extern  bool_t xdr_PUTFH4args(XDR *, PUTFH4args*);
extern  bool_t xdr_PUTFH4res(XDR *, PUTFH4res*);
extern  bool_t xdr_PUTPUBFH4res(XDR *, PUTPUBFH4res*);
extern  bool_t xdr_PUTROOTFH4res(XDR *, PUTROOTFH4res*);
extern  bool_t xdr_READ4args(XDR *, READ4args*);
extern  bool_t xdr_READ4resok(XDR *, READ4resok*);
extern  bool_t xdr_READ4res(XDR *, READ4res*);
extern  bool_t xdr_READDIR4args(XDR *, READDIR4args*);
extern  bool_t xdr_entry4(XDR *, entry4*);
extern  bool_t xdr_dirlist4(XDR *, dirlist4*);
extern  bool_t xdr_READDIR4resok(XDR *, READDIR4resok*);
extern  bool_t xdr_READDIR4res(XDR *, READDIR4res*);
extern  bool_t xdr_READLINK4resok(XDR *, READLINK4resok*);
extern  bool_t xdr_READLINK4res(XDR *, READLINK4res*);
extern  bool_t xdr_REMOVE4args(XDR *, REMOVE4args*);
extern  bool_t xdr_REMOVE4resok(XDR *, REMOVE4resok*);
extern  bool_t xdr_REMOVE4res(XDR *, REMOVE4res*);
extern  bool_t xdr_RENAME4args(XDR *, RENAME4args*);
extern  bool_t xdr_RENAME4resok(XDR *, RENAME4resok*);
extern  bool_t xdr_RENAME4res(XDR *, RENAME4res*);
extern  bool_t xdr_RENEW4args(XDR *, RENEW4args*);
extern  bool_t xdr_RENEW4res(XDR *, RENEW4res*);
extern  bool_t xdr_RESTOREFH4res(XDR *, RESTOREFH4res*);
extern  bool_t xdr_SAVEFH4res(XDR *, SAVEFH4res*);
extern  bool_t xdr_SECINFO4args(XDR *, SECINFO4args*);
extern  bool_t xdr_rpc_gss_svc_t(XDR *, rpc_gss_svc_t*);
extern  bool_t xdr_rpcsec_gss_info(XDR *, rpcsec_gss_info*);
extern  bool_t xdr_secinfo4(XDR *, secinfo4*);
extern  bool_t xdr_SECINFO4resok(XDR *, SECINFO4resok*);
extern  bool_t xdr_SECINFO4res(XDR *, SECINFO4res*);
extern  bool_t xdr_SETATTR4args(XDR *, SETATTR4args*);
extern  bool_t xdr_SETATTR4res(XDR *, SETATTR4res*);
extern  bool_t xdr_SETCLIENTID4args(XDR *, SETCLIENTID4args*);
extern  bool_t xdr_SETCLIENTID4resok(XDR *, SETCLIENTID4resok*);
extern  bool_t xdr_SETCLIENTID4res(XDR *, SETCLIENTID4res*);
extern  bool_t xdr_SETCLIENTID_CONFIRM4args(XDR *, SETCLIENTID_CONFIRM4args*);
extern  bool_t xdr_SETCLIENTID_CONFIRM4res(XDR *, SETCLIENTID_CONFIRM4res*);
extern  bool_t xdr_VERIFY4args(XDR *, VERIFY4args*);
extern  bool_t xdr_VERIFY4res(XDR *, VERIFY4res*);
extern  bool_t xdr_WRITE4args(XDR *, WRITE4args*);
extern  bool_t xdr_WRITE4resok(XDR *, WRITE4resok*);
extern  bool_t xdr_WRITE4res(XDR *, WRITE4res*);
extern  bool_t xdr_RELEASE_LOCKOWNER4args(XDR *, RELEASE_LOCKOWNER4args*);
extern  bool_t xdr_RELEASE_LOCKOWNER4res(XDR *, RELEASE_LOCKOWNER4res*);
extern  bool_t xdr_ILLEGAL4res(XDR *, ILLEGAL4res*);
extern  bool_t xdr_gsshandle4_t(XDR *, gsshandle4_t*);
extern  bool_t xdr_gss_cb_handles4(XDR *, gss_cb_handles4*);
extern  bool_t xdr_callback_sec_parms4(XDR *, callback_sec_parms4*);
extern  bool_t xdr_BACKCHANNEL_CTL4args(XDR *, BACKCHANNEL_CTL4args*);
extern  bool_t xdr_BACKCHANNEL_CTL4res(XDR *, BACKCHANNEL_CTL4res*);
extern  bool_t xdr_channel_dir_from_client4(XDR *, channel_dir_from_client4*);
extern  bool_t xdr_BIND_CONN_TO_SESSION4args(XDR *, BIND_CONN_TO_SESSION4args*);
extern  bool_t xdr_channel_dir_from_server4(XDR *, channel_dir_from_server4*);
extern  bool_t xdr_BIND_CONN_TO_SESSION4resok(XDR *, BIND_CONN_TO_SESSION4resok*);
extern  bool_t xdr_BIND_CONN_TO_SESSION4res(XDR *, BIND_CONN_TO_SESSION4res*);
extern  bool_t xdr_state_protect_ops4(XDR *, state_protect_ops4*);
extern  bool_t xdr_ssv_sp_parms4(XDR *, ssv_sp_parms4*);
extern  bool_t xdr_state_protect_how4(XDR *, state_protect_how4*);
extern  bool_t xdr_state_protect4_a(XDR *, state_protect4_a*);
extern  bool_t xdr_EXCHANGE_ID4args(XDR *, EXCHANGE_ID4args*);
extern  bool_t xdr_ssv_prot_info4(XDR *, ssv_prot_info4*);
extern  bool_t xdr_state_protect4_r(XDR *, state_protect4_r*);
extern  bool_t xdr_EXCHANGE_ID4resok(XDR *, EXCHANGE_ID4resok*);
extern  bool_t xdr_EXCHANGE_ID4res(XDR *, EXCHANGE_ID4res*);
extern  bool_t xdr_channel_attrs4(XDR *, channel_attrs4*);
extern  bool_t xdr_CREATE_SESSION4args(XDR *, CREATE_SESSION4args*);
extern  bool_t xdr_CREATE_SESSION4resok(XDR *, CREATE_SESSION4resok*);
extern  bool_t xdr_CREATE_SESSION4res(XDR *, CREATE_SESSION4res*);
extern  bool_t xdr_DESTROY_SESSION4args(XDR *, DESTROY_SESSION4args*);
extern  bool_t xdr_DESTROY_SESSION4res(XDR *, DESTROY_SESSION4res*);
extern  bool_t xdr_FREE_STATEID4args(XDR *, FREE_STATEID4args*);
extern  bool_t xdr_FREE_STATEID4res(XDR *, FREE_STATEID4res*);
extern  bool_t xdr_attr_notice4(XDR *, attr_notice4*);
extern  bool_t xdr_GET_DIR_DELEGATION4args(XDR *, GET_DIR_DELEGATION4args*);
extern  bool_t xdr_GET_DIR_DELEGATION4resok(XDR *, GET_DIR_DELEGATION4resok*);
extern  bool_t xdr_gddrnf4_status(XDR *, gddrnf4_status*);
extern  bool_t xdr_GET_DIR_DELEGATION4res_non_fatal(XDR *, GET_DIR_DELEGATION4res_non_fatal*);
extern  bool_t xdr_GET_DIR_DELEGATION4res(XDR *, GET_DIR_DELEGATION4res*);
extern  bool_t xdr_GETDEVICEINFO4args(XDR *, GETDEVICEINFO4args*);
extern  bool_t xdr_GETDEVICEINFO4resok(XDR *, GETDEVICEINFO4resok*);
extern  bool_t xdr_GETDEVICEINFO4res(XDR *, GETDEVICEINFO4res*);
extern  bool_t xdr_GETDEVICELIST4args(XDR *, GETDEVICELIST4args*);
extern  bool_t xdr_GETDEVICELIST4resok(XDR *, GETDEVICELIST4resok*);
extern  bool_t xdr_GETDEVICELIST4res(XDR *, GETDEVICELIST4res*);
extern  bool_t xdr_newtime4(XDR *, newtime4*);
extern  bool_t xdr_newoffset4(XDR *, newoffset4*);
extern  bool_t xdr_LAYOUTCOMMIT4args(XDR *, LAYOUTCOMMIT4args*);
extern  bool_t xdr_newsize4(XDR *, newsize4*);
extern  bool_t xdr_LAYOUTCOMMIT4resok(XDR *, LAYOUTCOMMIT4resok*);
extern  bool_t xdr_LAYOUTCOMMIT4res(XDR *, LAYOUTCOMMIT4res*);
extern  bool_t xdr_LAYOUTGET4args(XDR *, LAYOUTGET4args*);
extern  bool_t xdr_LAYOUTGET4resok(XDR *, LAYOUTGET4resok*);
extern  bool_t xdr_LAYOUTGET4res(XDR *, LAYOUTGET4res*);
extern  bool_t xdr_LAYOUTRETURN4args(XDR *, LAYOUTRETURN4args*);
extern  bool_t xdr_layoutreturn_stateid(XDR *, layoutreturn_stateid*);
extern  bool_t xdr_LAYOUTRETURN4res(XDR *, LAYOUTRETURN4res*);
extern  bool_t xdr_secinfo_style4(XDR *, secinfo_style4*);
extern  bool_t xdr_SECINFO_NO_NAME4args(XDR *, SECINFO_NO_NAME4args*);
extern  bool_t xdr_SECINFO_NO_NAME4res(XDR *, SECINFO_NO_NAME4res*);
extern  bool_t xdr_SEQUENCE4args(XDR *, SEQUENCE4args*);
extern  bool_t xdr_SEQUENCE4resok(XDR *, SEQUENCE4resok*);
extern  bool_t xdr_SEQUENCE4res(XDR *, SEQUENCE4res*);
extern  bool_t xdr_ssa_digest_input4(XDR *, ssa_digest_input4*);
extern  bool_t xdr_SET_SSV4args(XDR *, SET_SSV4args*);
extern  bool_t xdr_ssr_digest_input4(XDR *, ssr_digest_input4*);
extern  bool_t xdr_SET_SSV4resok(XDR *, SET_SSV4resok*);
extern  bool_t xdr_SET_SSV4res(XDR *, SET_SSV4res*);
extern  bool_t xdr_TEST_STATEID4args(XDR *, TEST_STATEID4args*);
extern  bool_t xdr_TEST_STATEID4resok(XDR *, TEST_STATEID4resok*);
extern  bool_t xdr_TEST_STATEID4res(XDR *, TEST_STATEID4res*);
extern  bool_t xdr_deleg_claim4(XDR *, deleg_claim4*);
extern  bool_t xdr_WANT_DELEGATION4args(XDR *, WANT_DELEGATION4args*);
extern  bool_t xdr_WANT_DELEGATION4res(XDR *, WANT_DELEGATION4res*);
extern  bool_t xdr_DESTROY_CLIENTID4args(XDR *, DESTROY_CLIENTID4args*);
extern  bool_t xdr_DESTROY_CLIENTID4res(XDR *, DESTROY_CLIENTID4res*);
extern  bool_t xdr_RECLAIM_COMPLETE4args(XDR *, RECLAIM_COMPLETE4args*);
extern  bool_t xdr_RECLAIM_COMPLETE4res(XDR *, RECLAIM_COMPLETE4res*);
extern  bool_t xdr_COPY4args(XDR *, COPY4args*);
extern  bool_t xdr_copy_requirements4(XDR *, copy_requirements4*);
extern  bool_t xdr_COPY4resok(XDR *, COPY4resok*);
extern  bool_t xdr_COPY4res(XDR *, COPY4res*);
extern  bool_t xdr_COPY_NOTIFY4args(XDR *, COPY_NOTIFY4args*);
extern  bool_t xdr_COPY_NOTIFY4resok(XDR *, COPY_NOTIFY4resok*);
extern  bool_t xdr_COPY_NOTIFY4res(XDR *, COPY_NOTIFY4res*);
extern  bool_t xdr_OFFLOAD_CANCEL4args(XDR *, OFFLOAD_CANCEL4args*);
extern  bool_t xdr_OFFLOAD_CANCEL4res(XDR *, OFFLOAD_CANCEL4res*);
extern  bool_t xdr_OFFLOAD_STATUS4args(XDR *, OFFLOAD_STATUS4args*);
extern  bool_t xdr_OFFLOAD_STATUS4resok(XDR *, OFFLOAD_STATUS4resok*);
extern  bool_t xdr_OFFLOAD_STATUS4res(XDR *, OFFLOAD_STATUS4res*);
extern  bool_t xdr_ALLOCATE4args(XDR *, ALLOCATE4args*);
extern  bool_t xdr_ALLOCATE4res(XDR *, ALLOCATE4res*);
extern  bool_t xdr_DEALLOCATE4args(XDR *, DEALLOCATE4args*);
extern  bool_t xdr_DEALLOCATE4res(XDR *, DEALLOCATE4res*);
extern  bool_t xdr_IO_ADVISE_type4(XDR *, IO_ADVISE_type4*);
extern  bool_t xdr_IO_ADVISE4args(XDR *, IO_ADVISE4args*);
extern  bool_t xdr_IO_ADVISE4resok(XDR *, IO_ADVISE4resok*);
extern  bool_t xdr_IO_ADVISE4res(XDR *, IO_ADVISE4res*);
extern  bool_t xdr_device_error4(XDR *, device_error4*);
extern  bool_t xdr_LAYOUTERROR4args(XDR *, LAYOUTERROR4args*);
extern  bool_t xdr_LAYOUTERROR4res(XDR *, LAYOUTERROR4res*);
extern  bool_t xdr_io_info4(XDR *, io_info4*);
extern  bool_t xdr_LAYOUTSTATS4args(XDR *, LAYOUTSTATS4args*);
extern  bool_t xdr_LAYOUTSTATS4res(XDR *, LAYOUTSTATS4res*);
extern  bool_t xdr_READ_PLUS4args(XDR *, READ_PLUS4args*);
extern  bool_t xdr_read_plus_content(XDR *, read_plus_content*);
extern  bool_t xdr_read_plus_res4(XDR *, read_plus_res4*);
extern  bool_t xdr_READ_PLUS4res(XDR *, READ_PLUS4res*);
extern  bool_t xdr_SEEK4args(XDR *, SEEK4args*);
extern  bool_t xdr_seek_res4(XDR *, seek_res4*);
extern  bool_t xdr_SEEK4res(XDR *, SEEK4res*);
extern  bool_t xdr_WRITE_SAME4args(XDR *, WRITE_SAME4args*);
extern  bool_t xdr_WRITE_SAME4res(XDR *, WRITE_SAME4res*);
extern  bool_t xdr_nfs_argop4(XDR *, nfs_argop4*);
extern  bool_t xdr_nfs_resop4(XDR *, nfs_resop4*);
extern  bool_t xdr_COMPOUND4args(XDR *, COMPOUND4args*);
extern  bool_t xdr_COMPOUND4res(XDR *, COMPOUND4res*);
extern  bool_t xdr_CB_GETATTR4args(XDR *, CB_GETATTR4args*);
extern  bool_t xdr_CB_GETATTR4resok(XDR *, CB_GETATTR4resok*);
extern  bool_t xdr_CB_GETATTR4res(XDR *, CB_GETATTR4res*);
extern  bool_t xdr_CB_RECALL4args(XDR *, CB_RECALL4args*);
extern  bool_t xdr_CB_RECALL4res(XDR *, CB_RECALL4res*);
extern  bool_t xdr_CB_ILLEGAL4res(XDR *, CB_ILLEGAL4res*);
extern  bool_t xdr_layoutrecall_type4(XDR *, layoutrecall_type4*);
extern  bool_t xdr_layoutrecall_file4(XDR *, layoutrecall_file4*);
extern  bool_t xdr_layoutrecall4(XDR *, layoutrecall4*);
extern  bool_t xdr_CB_LAYOUTRECALL4args(XDR *, CB_LAYOUTRECALL4args*);
extern  bool_t xdr_CB_LAYOUTRECALL4res(XDR *, CB_LAYOUTRECALL4res*);
extern  bool_t xdr_notify_type4(XDR *, notify_type4*);
extern  bool_t xdr_notify_entry4(XDR *, notify_entry4*);
extern  bool_t xdr_prev_entry4(XDR *, prev_entry4*);
extern  bool_t xdr_notify_remove4(XDR *, notify_remove4*);
extern  bool_t xdr_notify_add4(XDR *, notify_add4*);
extern  bool_t xdr_notify_attr4(XDR *, notify_attr4*);
extern  bool_t xdr_notify_rename4(XDR *, notify_rename4*);
extern  bool_t xdr_notify_verifier4(XDR *, notify_verifier4*);
extern  bool_t xdr_notifylist4(XDR *, notifylist4*);
extern  bool_t xdr_notify4(XDR *, notify4*);
extern  bool_t xdr_CB_NOTIFY4args(XDR *, CB_NOTIFY4args*);
extern  bool_t xdr_CB_NOTIFY4res(XDR *, CB_NOTIFY4res*);
extern  bool_t xdr_CB_PUSH_DELEG4args(XDR *, CB_PUSH_DELEG4args*);
extern  bool_t xdr_CB_PUSH_DELEG4res(XDR *, CB_PUSH_DELEG4res*);
extern  bool_t xdr_CB_RECALL_ANY4args(XDR *, CB_RECALL_ANY4args*);
extern  bool_t xdr_CB_RECALL_ANY4res(XDR *, CB_RECALL_ANY4res*);
extern  bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4args(XDR *, CB_RECALLABLE_OBJ_AVAIL4args*);
extern  bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4res(XDR *, CB_RECALLABLE_OBJ_AVAIL4res*);
extern  bool_t xdr_CB_RECALL_SLOT4args(XDR *, CB_RECALL_SLOT4args*);
extern  bool_t xdr_CB_RECALL_SLOT4res(XDR *, CB_RECALL_SLOT4res*);
extern  bool_t xdr_referring_call4(XDR *, referring_call4*);
extern  bool_t xdr_referring_call_list4(XDR *, referring_call_list4*);
extern  bool_t xdr_CB_SEQUENCE4args(XDR *, CB_SEQUENCE4args*);
extern  bool_t xdr_CB_SEQUENCE4resok(XDR *, CB_SEQUENCE4resok*);
extern  bool_t xdr_CB_SEQUENCE4res(XDR *, CB_SEQUENCE4res*);
extern  bool_t xdr_CB_WANTS_CANCELLED4args(XDR *, CB_WANTS_CANCELLED4args*);
extern  bool_t xdr_CB_WANTS_CANCELLED4res(XDR *, CB_WANTS_CANCELLED4res*);
extern  bool_t xdr_CB_NOTIFY_LOCK4args(XDR *, CB_NOTIFY_LOCK4args*);
extern  bool_t xdr_CB_NOTIFY_LOCK4res(XDR *, CB_NOTIFY_LOCK4res*);
extern  bool_t xdr_notify_deviceid_type4(XDR *, notify_deviceid_type4*);
extern  bool_t xdr_notify_deviceid_delete4(XDR *, notify_deviceid_delete4*);
extern  bool_t xdr_notify_deviceid_change4(XDR *, notify_deviceid_change4*);
extern  bool_t xdr_CB_NOTIFY_DEVICEID4args(XDR *, CB_NOTIFY_DEVICEID4args*);
extern  bool_t xdr_CB_NOTIFY_DEVICEID4res(XDR *, CB_NOTIFY_DEVICEID4res*);
extern  bool_t xdr_offload_info4(XDR *, offload_info4*);
extern  bool_t xdr_CB_OFFLOAD4args(XDR *, CB_OFFLOAD4args*);
extern  bool_t xdr_CB_OFFLOAD4res(XDR *, CB_OFFLOAD4res*);
extern  bool_t xdr_nfs_cb_opnum4(XDR *, nfs_cb_opnum4*);
extern  bool_t xdr_nfs_cb_argop4(XDR *, nfs_cb_argop4*);
extern  bool_t xdr_nfs_cb_resop4(XDR *, nfs_cb_resop4*);
extern  bool_t xdr_CB_COMPOUND4args(XDR *, CB_COMPOUND4args*);
extern  bool_t xdr_CB_COMPOUND4res(XDR *, CB_COMPOUND4res*);

#else /* K&R C */
extern bool_t xdr_nfs_ftype4();
extern bool_t xdr_nfsstat4();
extern bool_t xdr_attrlist4();
extern bool_t xdr_bitmap4();
extern bool_t xdr_changeid4();
extern bool_t xdr_clientid4();
extern bool_t xdr_count4();
extern bool_t xdr_length4();
extern bool_t xdr_mode4();
extern bool_t xdr_nfs_cookie4();
extern bool_t xdr_nfs_fh4();
extern bool_t xdr_offset4();
extern bool_t xdr_qop4();
extern bool_t xdr_sec_oid4();
extern bool_t xdr_sequenceid4();
extern bool_t xdr_seqid4();
extern bool_t xdr_sessionid4();
extern bool_t xdr_slotid4();
extern bool_t xdr_utf8string();
extern bool_t xdr_utf8str_cis();
extern bool_t xdr_utf8str_cs();
extern bool_t xdr_utf8str_mixed();
extern bool_t xdr_component4();
extern bool_t xdr_linktext4();
extern bool_t xdr_ascii_REQUIRED4();
extern bool_t xdr_pathname4();
extern bool_t xdr_verifier4();
extern bool_t xdr_secret4();
extern bool_t xdr_policy4();
extern bool_t xdr_nfstime4();
extern bool_t xdr_time_how4();
extern bool_t xdr_settime4();
extern bool_t xdr_nfs_lease4();
extern bool_t xdr_fsid4();
extern bool_t xdr_change_policy4();
extern bool_t xdr_fs_location4();
extern bool_t xdr_fs_locations4();
extern bool_t xdr_acetype4();
extern bool_t xdr_aceflag4();
extern bool_t xdr_acemask4();
extern bool_t xdr_nfsace4();
extern bool_t xdr_aclflag4();
extern bool_t xdr_nfsacl41();
extern bool_t xdr_mode_masked4();
extern bool_t xdr_specdata4();
extern bool_t xdr_netaddr4();
extern bool_t xdr_nfs_impl_id4();
extern bool_t xdr_stateid4();
extern bool_t xdr_layouttype4();
extern bool_t xdr_layout_content4();
extern bool_t xdr_layouthint4();
extern bool_t xdr_layoutiomode4();
extern bool_t xdr_layout4();
extern bool_t xdr_deviceid4();
extern bool_t xdr_device_addr4();
extern bool_t xdr_layoutupdate4();
extern bool_t xdr_layoutreturn_type4();
extern bool_t xdr_layoutreturn_file4();
extern bool_t xdr_layoutreturn4();
extern bool_t xdr_fs4_status_type();
extern bool_t xdr_fs4_status();
extern bool_t xdr_threshold4_read_size();
extern bool_t xdr_threshold4_write_size();
extern bool_t xdr_threshold4_read_iosize();
extern bool_t xdr_threshold4_write_iosize();
extern bool_t xdr_threshold_item4();
extern bool_t xdr_mdsthreshold4();
extern bool_t xdr_retention_get4();
extern bool_t xdr_retention_set4();
extern bool_t xdr_fs_charset_cap4();
extern bool_t xdr_netloc_type4();
extern bool_t xdr_netloc4();
extern bool_t xdr_change_attr_type4();
extern bool_t xdr_labelformat_spec4();
extern bool_t xdr_sec_label4();
extern bool_t xdr_copy_from_auth_priv();
extern bool_t xdr_copy_to_auth_priv();
extern bool_t xdr_copy_confirm_auth_priv();
extern bool_t xdr_app_data_block4();
extern bool_t xdr_data4();
extern bool_t xdr_data_info4();
extern bool_t xdr_data_content4();
extern bool_t xdr_stable_how4();
extern bool_t xdr_write_response4();
extern bool_t xdr_fattr4_supported_attrs();
extern bool_t xdr_fattr4_type();
extern bool_t xdr_fattr4_fh_expire_type();
extern bool_t xdr_fattr4_change();
extern bool_t xdr_fattr4_size();
extern bool_t xdr_fattr4_link_support();
extern bool_t xdr_fattr4_symlink_support();
extern bool_t xdr_fattr4_named_attr();
extern bool_t xdr_fattr4_fsid();
extern bool_t xdr_fattr4_unique_handles();
extern bool_t xdr_fattr4_lease_time();
extern bool_t xdr_fattr4_rdattr_error();
extern bool_t xdr_fattr4_acl();
extern bool_t xdr_fattr4_aclsupport();
extern bool_t xdr_fattr4_archive();
extern bool_t xdr_fattr4_cansettime();
extern bool_t xdr_fattr4_case_insensitive();
extern bool_t xdr_fattr4_case_preserving();
extern bool_t xdr_fattr4_chown_restricted();
extern bool_t xdr_fattr4_fileid();
extern bool_t xdr_fattr4_files_avail();
extern bool_t xdr_fattr4_filehandle();
extern bool_t xdr_fattr4_files_free();
extern bool_t xdr_fattr4_files_total();
extern bool_t xdr_fattr4_fs_locations();
extern bool_t xdr_fattr4_hidden();
extern bool_t xdr_fattr4_homogeneous();
extern bool_t xdr_fattr4_maxfilesize();
extern bool_t xdr_fattr4_maxlink();
extern bool_t xdr_fattr4_maxname();
extern bool_t xdr_fattr4_maxread();
extern bool_t xdr_fattr4_maxwrite();
extern bool_t xdr_fattr4_mimetype();
extern bool_t xdr_fattr4_mode();
extern bool_t xdr_fattr4_mode_set_masked();
extern bool_t xdr_fattr4_mounted_on_fileid();
extern bool_t xdr_fattr4_no_trunc();
extern bool_t xdr_fattr4_numlinks();
extern bool_t xdr_fattr4_owner();
extern bool_t xdr_fattr4_owner_group();
extern bool_t xdr_fattr4_quota_avail_hard();
extern bool_t xdr_fattr4_quota_avail_soft();
extern bool_t xdr_fattr4_quota_used();
extern bool_t xdr_fattr4_rawdev();
extern bool_t xdr_fattr4_space_avail();
extern bool_t xdr_fattr4_space_free();
extern bool_t xdr_fattr4_space_total();
extern bool_t xdr_fattr4_space_used();
extern bool_t xdr_fattr4_system();
extern bool_t xdr_fattr4_time_access();
extern bool_t xdr_fattr4_time_access_set();
extern bool_t xdr_fattr4_time_backup();
extern bool_t xdr_fattr4_time_create();
extern bool_t xdr_fattr4_time_delta();
extern bool_t xdr_fattr4_time_metadata();
extern bool_t xdr_fattr4_time_modify();
extern bool_t xdr_fattr4_time_modify_set();
extern bool_t xdr_fattr4_suppattr_exclcreat();
extern bool_t xdr_fattr4_dir_notif_delay();
extern bool_t xdr_fattr4_dirent_notif_delay();
extern bool_t xdr_fattr4_fs_layout_types();
extern bool_t xdr_fattr4_fs_status();
extern bool_t xdr_fattr4_fs_charset_cap();
extern bool_t xdr_fattr4_layout_alignment();
extern bool_t xdr_fattr4_layout_blksize();
extern bool_t xdr_fattr4_layout_hint();
extern bool_t xdr_fattr4_layout_types();
extern bool_t xdr_fattr4_mdsthreshold();
extern bool_t xdr_fattr4_retention_get();
extern bool_t xdr_fattr4_retention_set();
extern bool_t xdr_fattr4_retentevt_get();
extern bool_t xdr_fattr4_retentevt_set();
extern bool_t xdr_fattr4_retention_hold();
extern bool_t xdr_fattr4_dacl();
extern bool_t xdr_fattr4_sacl();
extern bool_t xdr_fattr4_change_policy();
extern bool_t xdr_fattr4_space_freed();
extern bool_t xdr_fattr4_change_attr_type();
extern bool_t xdr_fattr4_sec_label();
extern bool_t xdr_fattr4_clone_blksize();
extern bool_t xdr_fattr4();
extern bool_t xdr_change_info4();
extern bool_t xdr_clientaddr4();
extern bool_t xdr_cb_client4();
extern bool_t xdr_nfs_client_id4();
extern bool_t xdr_client_owner4();
extern bool_t xdr_server_owner4();
extern bool_t xdr_state_owner4();
extern bool_t xdr_open_owner4();
extern bool_t xdr_lock_owner4();
extern bool_t xdr_nfs_lock_type4();
extern bool_t xdr_ssv_subkey4();
extern bool_t xdr_ssv_mic_plain_tkn4();
extern bool_t xdr_ssv_mic_tkn4();
extern bool_t xdr_ssv_seal_plain_tkn4();
extern bool_t xdr_ssv_seal_cipher_tkn4();
extern bool_t xdr_fs_locations_server4();
extern bool_t xdr_fs_locations_item4();
extern bool_t xdr_fs_locations_info4();
extern bool_t xdr_fattr4_fs_locations_info();
extern bool_t xdr_nfl_util4();
extern bool_t xdr_filelayout_hint_care4();
extern bool_t xdr_nfsv4_1_file_layouthint4();
extern bool_t xdr_multipath_list4();
extern bool_t xdr_nfsv4_1_file_layout_ds_addr4();
extern bool_t xdr_nfsv4_1_file_layout4();
extern bool_t xdr_nfs_opnum4();
extern bool_t xdr_ACCESS4args();
extern bool_t xdr_ACCESS4resok();
extern bool_t xdr_ACCESS4res();
extern bool_t xdr_CLONE4args();
extern bool_t xdr_CLONE4res();
extern bool_t xdr_CLOSE4args();
extern bool_t xdr_CLOSE4res();
extern bool_t xdr_COMMIT4args();
extern bool_t xdr_COMMIT4resok();
extern bool_t xdr_COMMIT4res();
extern bool_t xdr_createtype4();
extern bool_t xdr_CREATE4args();
extern bool_t xdr_CREATE4resok();
extern bool_t xdr_CREATE4res();
extern bool_t xdr_DELEGPURGE4args();
extern bool_t xdr_DELEGPURGE4res();
extern bool_t xdr_DELEGRETURN4args();
extern bool_t xdr_DELEGRETURN4res();
extern bool_t xdr_GETATTR4args();
extern bool_t xdr_GETATTR4resok();
extern bool_t xdr_GETATTR4res();
extern bool_t xdr_GETFH4resok();
extern bool_t xdr_GETFH4res();
extern bool_t xdr_LINK4args();
extern bool_t xdr_LINK4resok();
extern bool_t xdr_LINK4res();
extern bool_t xdr_open_to_lock_owner4();
extern bool_t xdr_exist_lock_owner4();
extern bool_t xdr_locker4();
extern bool_t xdr_LOCK4args();
extern bool_t xdr_LOCK4denied();
extern bool_t xdr_LOCK4resok();
extern bool_t xdr_LOCK4res();
extern bool_t xdr_LOCKT4args();
extern bool_t xdr_LOCKT4res();
extern bool_t xdr_LOCKU4args();
extern bool_t xdr_LOCKU4res();
extern bool_t xdr_LOOKUP4args();
extern bool_t xdr_LOOKUP4res();
extern bool_t xdr_LOOKUPP4res();
extern bool_t xdr_NVERIFY4args();
extern bool_t xdr_NVERIFY4res();
extern bool_t xdr_createmode4();
extern bool_t xdr_creatverfattr();
extern bool_t xdr_createhow4();
extern bool_t xdr_opentype4();
extern bool_t xdr_openflag4();
extern bool_t xdr_limit_by4();
extern bool_t xdr_nfs_modified_limit4();
extern bool_t xdr_nfs_space_limit4();
extern bool_t xdr_open_delegation_type4();
extern bool_t xdr_open_claim_type4();
extern bool_t xdr_open_claim_delegate_cur4();
extern bool_t xdr_open_claim4();
extern bool_t xdr_OPEN4args();
extern bool_t xdr_open_read_delegation4();
extern bool_t xdr_open_write_delegation4();
extern bool_t xdr_why_no_delegation4();
extern bool_t xdr_open_none_delegation4();
extern bool_t xdr_open_delegation4();
extern bool_t xdr_OPEN4resok();
extern bool_t xdr_OPEN4res();
extern bool_t xdr_OPENATTR4args();
extern bool_t xdr_OPENATTR4res();
extern bool_t xdr_OPEN_CONFIRM4args();
extern bool_t xdr_OPEN_CONFIRM4resok();
extern bool_t xdr_OPEN_CONFIRM4res();
extern bool_t xdr_OPEN_DOWNGRADE4args();
extern bool_t xdr_OPEN_DOWNGRADE4resok();
extern bool_t xdr_OPEN_DOWNGRADE4res();
extern bool_t xdr_PUTFH4args();
extern bool_t xdr_PUTFH4res();
extern bool_t xdr_PUTPUBFH4res();
extern bool_t xdr_PUTROOTFH4res();
extern bool_t xdr_READ4args();
extern bool_t xdr_READ4resok();
extern bool_t xdr_READ4res();
extern bool_t xdr_READDIR4args();
extern bool_t xdr_entry4();
extern bool_t xdr_dirlist4();
extern bool_t xdr_READDIR4resok();
extern bool_t xdr_READDIR4res();
extern bool_t xdr_READLINK4resok();
extern bool_t xdr_READLINK4res();
extern bool_t xdr_REMOVE4args();
extern bool_t xdr_REMOVE4resok();
extern bool_t xdr_REMOVE4res();
extern bool_t xdr_RENAME4args();
extern bool_t xdr_RENAME4resok();
extern bool_t xdr_RENAME4res();
extern bool_t xdr_RENEW4args();
extern bool_t xdr_RENEW4res();
extern bool_t xdr_RESTOREFH4res();
extern bool_t xdr_SAVEFH4res();
extern bool_t xdr_SECINFO4args();
extern bool_t xdr_rpc_gss_svc_t();
extern bool_t xdr_rpcsec_gss_info();
extern bool_t xdr_secinfo4();
extern bool_t xdr_SECINFO4resok();
extern bool_t xdr_SECINFO4res();
extern bool_t xdr_SETATTR4args();
extern bool_t xdr_SETATTR4res();
extern bool_t xdr_SETCLIENTID4args();
extern bool_t xdr_SETCLIENTID4resok();
extern bool_t xdr_SETCLIENTID4res();
extern bool_t xdr_SETCLIENTID_CONFIRM4args();
extern bool_t xdr_SETCLIENTID_CONFIRM4res();
extern bool_t xdr_VERIFY4args();
extern bool_t xdr_VERIFY4res();
extern bool_t xdr_WRITE4args();
extern bool_t xdr_WRITE4resok();
extern bool_t xdr_WRITE4res();
extern bool_t xdr_RELEASE_LOCKOWNER4args();
extern bool_t xdr_RELEASE_LOCKOWNER4res();
extern bool_t xdr_ILLEGAL4res();
extern bool_t xdr_gsshandle4_t();
extern bool_t xdr_gss_cb_handles4();
extern bool_t xdr_callback_sec_parms4();
extern bool_t xdr_BACKCHANNEL_CTL4args();
extern bool_t xdr_BACKCHANNEL_CTL4res();
extern bool_t xdr_channel_dir_from_client4();
extern bool_t xdr_BIND_CONN_TO_SESSION4args();
extern bool_t xdr_channel_dir_from_server4();
extern bool_t xdr_BIND_CONN_TO_SESSION4resok();
extern bool_t xdr_BIND_CONN_TO_SESSION4res();
extern bool_t xdr_state_protect_ops4();
extern bool_t xdr_ssv_sp_parms4();
extern bool_t xdr_state_protect_how4();
extern bool_t xdr_state_protect4_a();
extern bool_t xdr_EXCHANGE_ID4args();
extern bool_t xdr_ssv_prot_info4();
extern bool_t xdr_state_protect4_r();
extern bool_t xdr_EXCHANGE_ID4resok();
extern bool_t xdr_EXCHANGE_ID4res();
extern bool_t xdr_channel_attrs4();
extern bool_t xdr_CREATE_SESSION4args();
extern bool_t xdr_CREATE_SESSION4resok();
extern bool_t xdr_CREATE_SESSION4res();
extern bool_t xdr_DESTROY_SESSION4args();
extern bool_t xdr_DESTROY_SESSION4res();
extern bool_t xdr_FREE_STATEID4args();
extern bool_t xdr_FREE_STATEID4res();
extern bool_t xdr_attr_notice4();
extern bool_t xdr_GET_DIR_DELEGATION4args();
extern bool_t xdr_GET_DIR_DELEGATION4resok();
extern bool_t xdr_gddrnf4_status();
extern bool_t xdr_GET_DIR_DELEGATION4res_non_fatal();
extern bool_t xdr_GET_DIR_DELEGATION4res();
extern bool_t xdr_GETDEVICEINFO4args();
extern bool_t xdr_GETDEVICEINFO4resok();
extern bool_t xdr_GETDEVICEINFO4res();
extern bool_t xdr_GETDEVICELIST4args();
extern bool_t xdr_GETDEVICELIST4resok();
extern bool_t xdr_GETDEVICELIST4res();
extern bool_t xdr_newtime4();
extern bool_t xdr_newoffset4();
extern bool_t xdr_LAYOUTCOMMIT4args();
extern bool_t xdr_newsize4();
extern bool_t xdr_LAYOUTCOMMIT4resok();
extern bool_t xdr_LAYOUTCOMMIT4res();
extern bool_t xdr_LAYOUTGET4args();
extern bool_t xdr_LAYOUTGET4resok();
extern bool_t xdr_LAYOUTGET4res();
extern bool_t xdr_LAYOUTRETURN4args();
extern bool_t xdr_layoutreturn_stateid();
extern bool_t xdr_LAYOUTRETURN4res();
extern bool_t xdr_secinfo_style4();
extern bool_t xdr_SECINFO_NO_NAME4args();
extern bool_t xdr_SECINFO_NO_NAME4res();
extern bool_t xdr_SEQUENCE4args();
extern bool_t xdr_SEQUENCE4resok();
extern bool_t xdr_SEQUENCE4res();
extern bool_t xdr_ssa_digest_input4();
extern bool_t xdr_SET_SSV4args();
extern bool_t xdr_ssr_digest_input4();
extern bool_t xdr_SET_SSV4resok();
extern bool_t xdr_SET_SSV4res();
extern bool_t xdr_TEST_STATEID4args();
extern bool_t xdr_TEST_STATEID4resok();
extern bool_t xdr_TEST_STATEID4res();
extern bool_t xdr_deleg_claim4();
extern bool_t xdr_WANT_DELEGATION4args();
extern bool_t xdr_WANT_DELEGATION4res();
extern bool_t xdr_DESTROY_CLIENTID4args();
extern bool_t xdr_DESTROY_CLIENTID4res();
extern bool_t xdr_RECLAIM_COMPLETE4args();
extern bool_t xdr_RECLAIM_COMPLETE4res();
extern bool_t xdr_COPY4args();
extern bool_t xdr_copy_requirements4();
extern bool_t xdr_COPY4resok();
extern bool_t xdr_COPY4res();
extern bool_t xdr_COPY_NOTIFY4args();
extern bool_t xdr_COPY_NOTIFY4resok();
extern bool_t xdr_COPY_NOTIFY4res();
extern bool_t xdr_OFFLOAD_CANCEL4args();
extern bool_t xdr_OFFLOAD_CANCEL4res();
extern bool_t xdr_OFFLOAD_STATUS4args();
extern bool_t xdr_OFFLOAD_STATUS4resok();
extern bool_t xdr_OFFLOAD_STATUS4res();
extern bool_t xdr_ALLOCATE4args();
extern bool_t xdr_ALLOCATE4res();
extern bool_t xdr_DEALLOCATE4args();
extern bool_t xdr_DEALLOCATE4res();
extern bool_t xdr_IO_ADVISE_type4();
extern bool_t xdr_IO_ADVISE4args();
extern bool_t xdr_IO_ADVISE4resok();
extern bool_t xdr_IO_ADVISE4res();
extern bool_t xdr_device_error4();
extern bool_t xdr_LAYOUTERROR4args();
extern bool_t xdr_LAYOUTERROR4res();
extern bool_t xdr_io_info4();
extern bool_t xdr_LAYOUTSTATS4args();
extern bool_t xdr_LAYOUTSTATS4res();
extern bool_t xdr_READ_PLUS4args();
extern bool_t xdr_read_plus_content();
extern bool_t xdr_read_plus_res4();
extern bool_t xdr_READ_PLUS4res();
extern bool_t xdr_SEEK4args();
extern bool_t xdr_seek_res4();
extern bool_t xdr_SEEK4res();
extern bool_t xdr_WRITE_SAME4args();
extern bool_t xdr_WRITE_SAME4res();
extern bool_t xdr_nfs_argop4();
extern bool_t xdr_nfs_resop4();
extern bool_t xdr_COMPOUND4args();
extern bool_t xdr_COMPOUND4res();
extern bool_t xdr_CB_GETATTR4args();
extern bool_t xdr_CB_GETATTR4resok();
extern bool_t xdr_CB_GETATTR4res();
extern bool_t xdr_CB_RECALL4args();
extern bool_t xdr_CB_RECALL4res();
extern bool_t xdr_CB_ILLEGAL4res();
extern bool_t xdr_layoutrecall_type4();
extern bool_t xdr_layoutrecall_file4();
extern bool_t xdr_layoutrecall4();
extern bool_t xdr_CB_LAYOUTRECALL4args();
extern bool_t xdr_CB_LAYOUTRECALL4res();
extern bool_t xdr_notify_type4();
extern bool_t xdr_notify_entry4();
extern bool_t xdr_prev_entry4();
extern bool_t xdr_notify_remove4();
extern bool_t xdr_notify_add4();
extern bool_t xdr_notify_attr4();
extern bool_t xdr_notify_rename4();
extern bool_t xdr_notify_verifier4();
extern bool_t xdr_notifylist4();
extern bool_t xdr_notify4();
extern bool_t xdr_CB_NOTIFY4args();
extern bool_t xdr_CB_NOTIFY4res();
extern bool_t xdr_CB_PUSH_DELEG4args();
extern bool_t xdr_CB_PUSH_DELEG4res();
extern bool_t xdr_CB_RECALL_ANY4args();
extern bool_t xdr_CB_RECALL_ANY4res();
extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4args();
extern bool_t xdr_CB_RECALLABLE_OBJ_AVAIL4res();
extern bool_t xdr_CB_RECALL_SLOT4args();
extern bool_t xdr_CB_RECALL_SLOT4res();
extern bool_t xdr_referring_call4();
extern bool_t xdr_referring_call_list4();
extern bool_t xdr_CB_SEQUENCE4args();
extern bool_t xdr_CB_SEQUENCE4resok();
extern bool_t xdr_CB_SEQUENCE4res();
extern bool_t xdr_CB_WANTS_CANCELLED4args();
extern bool_t xdr_CB_WANTS_CANCELLED4res();
extern bool_t xdr_CB_NOTIFY_LOCK4args();
extern bool_t xdr_CB_NOTIFY_LOCK4res();
extern bool_t xdr_notify_deviceid_type4();
extern bool_t xdr_notify_deviceid_delete4();
extern bool_t xdr_notify_deviceid_change4();
extern bool_t xdr_CB_NOTIFY_DEVICEID4args();
extern bool_t xdr_CB_NOTIFY_DEVICEID4res();
extern bool_t xdr_offload_info4();
extern bool_t xdr_CB_OFFLOAD4args();
extern bool_t xdr_CB_OFFLOAD4res();
extern bool_t xdr_nfs_cb_opnum4();
extern bool_t xdr_nfs_cb_argop4();
extern bool_t xdr_nfs_cb_resop4();
extern bool_t xdr_CB_COMPOUND4args();
extern bool_t xdr_CB_COMPOUND4res();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_NFS4_PROT_H_RPCGEN */
/*
 * This file was machine generated for [RFC7862].
 *
 * Last updated Sun Mar 13 10:58:40 PDT 2016
 */

/*
 * Copyright (c) 2016 IETF Trust and the persons identified
 * as the authors.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that the
 * following conditions are met:
 *
 * - Redistributions of source code must retain the above
 *   copyright notice, this list of conditions and the
 *   following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above
 *   copyright notice, this list of conditions and the
 *   following disclaimer in the documentation and/or other
 *   materials provided with the distribution.
 *
 * - Neither the name of Internet Society, IETF or IETF
 *   Trust, nor the names of specific contributors, may be
 *   used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
 *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
 *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
 *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

/*
 * This code was derived from RFC 7863.
 */

/*
 *      nfsv42.x
 */

%#ifndef _AUTH_SYS_DEFINE_FOR_NFSv42
%#define _AUTH_SYS_DEFINE_FOR_NFSv42
%#include <rpc/auth_sys.h>
%typedef struct authsys_parms authsys_parms;
%#endif /* _AUTH_SYS_DEFINE_FOR_NFSv42 */

/*
 * Basic typedefs for RFC 1832 data type definitions
 */

/*
 * typedef int                  int32_t;
 * typedef unsigned int         uint32_t;
 * typedef hyper                int64_t;
 * typedef unsigned hyper       uint64_t;
 */

/*
 * Sizes
 */
const NFS4_FHSIZE               = 128;
const NFS4_VERIFIER_SIZE        = 8;
const NFS4_OTHER_SIZE           = 12;
const NFS4_OPAQUE_LIMIT         = 1024;
const NFS4_SESSIONID_SIZE       = 16;

const NFS4_INT64_MAX            = 0x7fffffffffffffff;
const NFS4_UINT64_MAX           = 0xffffffffffffffff;
const NFS4_INT32_MAX            = 0x7fffffff;
const NFS4_UINT32_MAX           = 0xffffffff;

const NFS4_MAXFILELEN           = 0xffffffffffffffff;
const NFS4_MAXFILEOFF           = 0xfffffffffffffffe;


/*
 * File types
 */
enum nfs_ftype4 {
        NF4REG       = 1,  /* Regular File */
        NF4DIR       = 2,  /* Directory */
        NF4BLK       = 3,  /* Special File -- block device */
        NF4CHR       = 4,  /* Special File -- character device */
        NF4LNK       = 5,  /* Symbolic Link */
        NF4SOCK      = 6,  /* Special File -- socket */
        NF4FIFO      = 7,  /* Special File -- fifo */
        NF4ATTRDIR   = 8,  /* Attribute Directory */
        NF4NAMEDATTR = 9   /* Named Attribute */
};

/*
 * Error status
 */
enum nfsstat4 {
 NFS4_OK                = 0,     /* everything is okay        */
 NFS4ERR_PERM           = 1,     /* caller not privileged     */
 NFS4ERR_NOENT          = 2,     /* no such file/directory    */
 NFS4ERR_IO             = 5,     /* hard I/O error            */
 NFS4ERR_NXIO           = 6,     /* no such device            */
 NFS4ERR_ACCESS         = 13,    /* access denied             */
 NFS4ERR_EXIST          = 17,    /* file already exists       */
 NFS4ERR_XDEV           = 18,    /* different file systems    */

/*
 * Please do not allocate value 19; it was used in NFSv3,
 * and we do not want a value in NFSv3 to have a different
 * meaning in NFSv4.x.
 */

 NFS4ERR_NOTDIR         = 20,    /* should be a directory     */
 NFS4ERR_ISDIR          = 21,    /* should not be a directory */
 NFS4ERR_INVAL          = 22,    /* invalid argument          */
 NFS4ERR_FBIG           = 27,    /* file exceeds server max   */
 NFS4ERR_NOSPC          = 28,    /* no space on file system   */
 NFS4ERR_ROFS           = 30,    /* read-only file system     */
 NFS4ERR_MLINK          = 31,    /* too many hard links       */
 NFS4ERR_NAMETOOLONG    = 63,    /* name exceeds server max   */
 NFS4ERR_NOTEMPTY       = 66,    /* directory not empty       */
 NFS4ERR_DQUOT          = 69,    /* hard quota limit reached  */
 NFS4ERR_STALE          = 70,    /* file no longer exists     */
 NFS4ERR_BADHANDLE      = 10001, /* illegal filehandle        */
 NFS4ERR_BAD_COOKIE     = 10003, /* READDIR cookie is stale   */
 NFS4ERR_NOTSUPP        = 10004, /* operation not supported   */
 NFS4ERR_TOOSMALL       = 10005, /* response limit exceeded   */
 NFS4ERR_SERVERFAULT    = 10006, /* undefined server error    */
 NFS4ERR_BADTYPE        = 10007, /* type invalid for CREATE   */
 NFS4ERR_DELAY          = 10008, /* file "busy" -- retry      */
 NFS4ERR_SAME           = 10009, /* nverify says attrs same   */
 NFS4ERR_DENIED         = 10010, /* lock unavailable          */
 NFS4ERR_EXPIRED        = 10011, /* lock lease expired        */
 NFS4ERR_LOCKED         = 10012, /* I/O failed due to lock    */
 NFS4ERR_GRACE          = 10013, /* in grace period           */
 NFS4ERR_FHEXPIRED      = 10014, /* filehandle expired        */
 NFS4ERR_SHARE_DENIED   = 10015, /* share reserve denied      */
 NFS4ERR_WRONGSEC       = 10016, /* wrong security flavor     */
 NFS4ERR_CLID_INUSE     = 10017, /* client ID in use          */

 /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1. */
 NFS4ERR_RESOURCE       = 10018, /* resource exhaustion       */

 NFS4ERR_MOVED          = 10019, /* file system relocated     */
 NFS4ERR_NOFILEHANDLE   = 10020, /* current FH is not set     */
 NFS4ERR_MINOR_VERS_MISMATCH= 10021, /* minor vers not supp   */
 NFS4ERR_STALE_CLIENTID = 10022, /* server has rebooted       */
 NFS4ERR_STALE_STATEID  = 10023, /* server has rebooted       */
 NFS4ERR_OLD_STATEID    = 10024, /* state is out of sync      */
 NFS4ERR_BAD_STATEID    = 10025, /* incorrect stateid         */
 NFS4ERR_BAD_SEQID      = 10026, /* request is out of seq.    */
 NFS4ERR_NOT_SAME       = 10027, /* verify -- attrs not same  */
 NFS4ERR_LOCK_RANGE     = 10028, /* overlapping lock range    */
 NFS4ERR_SYMLINK        = 10029, /* should be file/directory  */
 NFS4ERR_RESTOREFH      = 10030, /* no saved filehandle       */
 NFS4ERR_LEASE_MOVED    = 10031, /* some file system moved    */
 NFS4ERR_ATTRNOTSUPP    = 10032, /* recommended attr not supp */
 NFS4ERR_NO_GRACE       = 10033, /* reclaim outside of grace  */
 NFS4ERR_RECLAIM_BAD    = 10034, /* reclaim error at server   */
 NFS4ERR_RECLAIM_CONFLICT= 10035, /* conflict on reclaim      */
 NFS4ERR_BADXDR         = 10036, /* XDR decode failed         */
 NFS4ERR_LOCKS_HELD     = 10037, /* file locks held at CLOSE  */
 NFS4ERR_OPENMODE       = 10038, /* conflict in OPEN and I/O  */
 NFS4ERR_BADOWNER       = 10039, /* owner translation bad     */
 NFS4ERR_BADCHAR        = 10040, /* UTF-8 char not supported  */
 NFS4ERR_BADNAME        = 10041, /* name not supported        */
 NFS4ERR_BAD_RANGE      = 10042, /* lock range not supported  */
 NFS4ERR_LOCK_NOTSUPP   = 10043, /* no atomic up/downgrade    */
 NFS4ERR_OP_ILLEGAL     = 10044, /* undefined operation       */
 NFS4ERR_DEADLOCK       = 10045, /* file-locking deadlock     */
 NFS4ERR_FILE_OPEN      = 10046, /* open file blocks op       */
 NFS4ERR_ADMIN_REVOKED  = 10047, /* lock-owner state revoked  */
 NFS4ERR_CB_PATH_DOWN   = 10048, /* callback path down        */

 /* NFSv4.1 errors start here. */

 NFS4ERR_BADIOMODE      = 10049,
 NFS4ERR_BADLAYOUT      = 10050,
 NFS4ERR_BAD_SESSION_DIGEST = 10051,
 NFS4ERR_BADSESSION     = 10052,
 NFS4ERR_BADSLOT        = 10053,
 NFS4ERR_COMPLETE_ALREADY = 10054,
 NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
 NFS4ERR_DELEG_ALREADY_WANTED = 10056,
 NFS4ERR_BACK_CHAN_BUSY = 10057, /* backchan reqs outstanding */
 NFS4ERR_LAYOUTTRYLATER = 10058,
 NFS4ERR_LAYOUTUNAVAILABLE = 10059,
 NFS4ERR_NOMATCHING_LAYOUT = 10060,
 NFS4ERR_RECALLCONFLICT = 10061,
 NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
 NFS4ERR_SEQ_MISORDERED = 10063, /* unexpected seq. ID in req */
 NFS4ERR_SEQUENCE_POS   = 10064, /* [CB_]SEQ. op not 1st op   */
 NFS4ERR_REQ_TOO_BIG    = 10065, /* request too big           */
 NFS4ERR_REP_TOO_BIG    = 10066, /* reply too big             */
 NFS4ERR_REP_TOO_BIG_TO_CACHE =10067, /* rep. not all cached  */
 NFS4ERR_RETRY_UNCACHED_REP =10068, /* retry + rep. uncached  */
 NFS4ERR_UNSAFE_COMPOUND =10069, /* retry/recovery too hard   */
 NFS4ERR_TOO_MANY_OPS   = 10070, /* too many ops in [CB_]COMP */
 NFS4ERR_OP_NOT_IN_SESSION =10071, /* op needs [CB_]SEQ. op   */
 NFS4ERR_HASH_ALG_UNSUPP = 10072,  /* hash alg. not supp      */
                                   /* Error 10073 is unused.  */
 NFS4ERR_CLIENTID_BUSY  = 10074, /* client ID has state       */
 NFS4ERR_PNFS_IO_HOLE   = 10075, /* IO to _SPARSE file hole   */
 NFS4ERR_SEQ_FALSE_RETRY= 10076, /* retry != original req     */
 NFS4ERR_BAD_HIGH_SLOT  = 10077, /* req has bad highest_slot  */
 NFS4ERR_DEADSESSION    = 10078, /* new req sent to dead sess */
 NFS4ERR_ENCR_ALG_UNSUPP= 10079, /* encr alg. not supp        */
 NFS4ERR_PNFS_NO_LAYOUT = 10080, /* I/O without a layout      */
 NFS4ERR_NOT_ONLY_OP    = 10081, /* addl ops not allowed      */
 NFS4ERR_WRONG_CRED     = 10082, /* op done by wrong cred     */
 NFS4ERR_WRONG_TYPE     = 10083, /* op on wrong type object   */
 NFS4ERR_DIRDELEG_UNAVAIL=10084, /* delegation not avail.     */
 NFS4ERR_REJECT_DELEG   = 10085, /* cb rejected delegation    */
 NFS4ERR_RETURNCONFLICT = 10086, /* layout get before return  */
 NFS4ERR_DELEG_REVOKED  = 10087, /* deleg./layout revoked     */

 /* NFSv4.2 errors start here. */

 NFS4ERR_PARTNER_NOTSUPP= 10088, /* s2s not supported         */
 NFS4ERR_PARTNER_NO_AUTH= 10089, /* s2s not authorized        */
 NFS4ERR_UNION_NOTSUPP  = 10090, /* arm of union not supp     */
 NFS4ERR_OFFLOAD_DENIED = 10091, /* dest not allowing copy    */
 NFS4ERR_WRONG_LFS      = 10092, /* LFS not supported         */
 NFS4ERR_BADLABEL       = 10093, /* incorrect label           */
 NFS4ERR_OFFLOAD_NO_REQS= 10094  /* dest not meeting reqs     */
};

/*
 * Basic data types
 */
typedef opaque  attrlist4<>;
typedef uint32_t        bitmap4<>;
typedef uint64_t        changeid4;
typedef uint64_t        clientid4;
typedef uint32_t        count4;
typedef uint64_t        length4;
typedef uint32_t        mode4;
typedef uint64_t        nfs_cookie4;
typedef opaque  nfs_fh4<NFS4_FHSIZE>;
typedef uint64_t        offset4;
typedef uint32_t        qop4;
typedef opaque  sec_oid4<>;
typedef uint32_t        sequenceid4;
typedef uint32_t        seqid4;
typedef opaque  sessionid4[NFS4_SESSIONID_SIZE];
typedef uint32_t        slotid4;
typedef opaque  utf8string<>;
typedef utf8string      utf8str_cis;
typedef utf8string      utf8str_cs;
typedef utf8string      utf8str_mixed;
typedef utf8str_cs      component4;
typedef opaque  linktext4<>;
typedef utf8string      ascii_REQUIRED4;
typedef component4      pathname4<>;
typedef opaque  verifier4[NFS4_VERIFIER_SIZE];
typedef string  secret4<>;
typedef uint32_t        policy4;

/*
 * Timeval
 */
struct nfstime4 {
        int64_t         seconds;
        uint32_t        nseconds;
};

enum time_how4 {
        SET_TO_SERVER_TIME4 = 0,
        SET_TO_CLIENT_TIME4 = 1
};

union settime4 switch (time_how4 set_it) {
 case SET_TO_CLIENT_TIME4:
         nfstime4       time;
 default:
         void;
};


typedef uint32_t nfs_lease4;

/*
 * File attribute definitions
 */

/*
 * File System ID (FSID) structure for major/minor
 */
struct fsid4 {
        uint64_t        major;
        uint64_t        minor;
};

/*
 * File system locations attribute
 * for relocation/migration and
 * related attributes
 */
struct change_policy4 {
        uint64_t        cp_major;
        uint64_t        cp_minor;
};

struct fs_location4 {
        utf8str_cis     server<>;
        pathname4       rootpath;
};

struct fs_locations4 {
        pathname4       fs_root;
        fs_location4    locations<>;
};

/*
 * Various Access Control Entry (ACE) definitions
 */

/*
 * Mask that indicates which ACEs are supported.
 * Values for the fattr4_aclsupport attribute.
 */
const ACL4_SUPPORT_ALLOW_ACL    = 0x00000001;
const ACL4_SUPPORT_DENY_ACL     = 0x00000002;
const ACL4_SUPPORT_AUDIT_ACL    = 0x00000004;
const ACL4_SUPPORT_ALARM_ACL    = 0x00000008;


typedef uint32_t        acetype4;


/*
 * acetype4 values.  Others can be added as needed.
 */
const ACE4_ACCESS_ALLOWED_ACE_TYPE      = 0x00000000;
const ACE4_ACCESS_DENIED_ACE_TYPE       = 0x00000001;
const ACE4_SYSTEM_AUDIT_ACE_TYPE        = 0x00000002;
const ACE4_SYSTEM_ALARM_ACE_TYPE        = 0x00000003;



/*
 * ACE flag
 */
typedef uint32_t aceflag4;


/*
 * ACE flag values
 */
const ACE4_FILE_INHERIT_ACE             = 0x00000001;
const ACE4_DIRECTORY_INHERIT_ACE        = 0x00000002;
const ACE4_NO_PROPAGATE_INHERIT_ACE     = 0x00000004;
const ACE4_INHERIT_ONLY_ACE             = 0x00000008;
const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG   = 0x00000010;
const ACE4_FAILED_ACCESS_ACE_FLAG       = 0x00000020;
const ACE4_IDENTIFIER_GROUP             = 0x00000040;
const ACE4_INHERITED_ACE                = 0x00000080;



/*
 * ACE mask
 */
typedef uint32_t        acemask4;


/*
 * ACE mask values
 */
const ACE4_READ_DATA            = 0x00000001;
const ACE4_LIST_DIRECTORY       = 0x00000001;
const ACE4_WRITE_DATA           = 0x00000002;
const ACE4_ADD_FILE             = 0x00000002;
const ACE4_APPEND_DATA          = 0x00000004;
const ACE4_ADD_SUBDIRECTORY     = 0x00000004;
const ACE4_READ_NAMED_ATTRS     = 0x00000008;
const ACE4_WRITE_NAMED_ATTRS    = 0x00000010;
const ACE4_EXECUTE              = 0x00000020;
const ACE4_DELETE_CHILD         = 0x00000040;
const ACE4_READ_ATTRIBUTES      = 0x00000080;
const ACE4_WRITE_ATTRIBUTES     = 0x00000100;
const ACE4_WRITE_RETENTION      = 0x00000200;
const ACE4_WRITE_RETENTION_HOLD = 0x00000400;

const ACE4_DELETE               = 0x00010000;
const ACE4_READ_ACL             = 0x00020000;
const ACE4_WRITE_ACL            = 0x00040000;
const ACE4_WRITE_OWNER          = 0x00080000;
const ACE4_SYNCHRONIZE          = 0x00100000;


/*
 * ACE4_GENERIC_READ -- defined as a combination of
 *      ACE4_READ_ACL |
 *      ACE4_READ_DATA |
 *      ACE4_READ_ATTRIBUTES |
 *      ACE4_SYNCHRONIZE
 */

const ACE4_GENERIC_READ = 0x00120081;

/*
 * ACE4_GENERIC_WRITE -- defined as a combination of
 *      ACE4_READ_ACL |
 *      ACE4_WRITE_DATA |
 *      ACE4_WRITE_ATTRIBUTES |
 *      ACE4_WRITE_ACL |
 *      ACE4_APPEND_DATA |
 *      ACE4_SYNCHRONIZE
 */
const ACE4_GENERIC_WRITE = 0x00160106;


/*
 * ACE4_GENERIC_EXECUTE -- defined as a combination of
 *      ACE4_READ_ACL |
 *      ACE4_READ_ATTRIBUTES |
 *      ACE4_EXECUTE |
 *      ACE4_SYNCHRONIZE
 */
const ACE4_GENERIC_EXECUTE = 0x001200A0;


/*
 * ACE definition
 */
struct nfsace4 {
        acetype4        type;
        aceflag4        flag;
        acemask4        access_mask;
        utf8str_mixed   who;
};


/*
 * Access Control List (ACL) flag
 */

typedef uint32_t aclflag4;

/*
 * ACL flag values
 */
const ACL4_AUTO_INHERIT         = 0x00000001;
const ACL4_PROTECTED            = 0x00000002;
const ACL4_DEFAULTED            = 0x00000004;


/*
 * Version 4.1 ACL definition
 */
struct nfsacl41 {
        aclflag4        na41_flag;
        nfsace4         na41_aces<>;
};


/*
 * Field definitions for the fattr4_mode
 * and fattr4_mode_set_masked attributes
 */
const MODE4_SUID = 0x800;  /* set user id on execution */
const MODE4_SGID = 0x400;  /* set group id on execution */
const MODE4_SVTX = 0x200;  /* save text even after use */
const MODE4_RUSR = 0x100;  /* read permission: owner */
const MODE4_WUSR = 0x080;  /* write permission: owner */
const MODE4_XUSR = 0x040;  /* execute permission: owner */
const MODE4_RGRP = 0x020;  /* read permission: group */
const MODE4_WGRP = 0x010;  /* write permission: group */
const MODE4_XGRP = 0x008;  /* execute permission: group */
const MODE4_ROTH = 0x004;  /* read permission: other */
const MODE4_WOTH = 0x002;  /* write permission: other */
const MODE4_XOTH = 0x001;  /* execute permission: other */


/*
 * Masked mode for the mode_set_masked attribute
 */
struct mode_masked4 {
 mode4  mm_value_to_set; /* Values of bits
                            to set or reset
                            in mode */

 mode4  mm_mask_bits;    /* Mask of bits to
                            set or reset
                            in mode */
};

/*
 * Special data/attribute associated with
 * file types NF4BLK and NF4CHR
 */
struct specdata4 {
 uint32_t specdata1; /* Major device number */
 uint32_t specdata2; /* Minor device number */
};

/*
 * Values for fattr4_fh_expire_type
 */
const FH4_PERSISTENT          = 0x00000000;
const FH4_NOEXPIRE_WITH_OPEN  = 0x00000001;
const FH4_VOLATILE_ANY        = 0x00000002;
const FH4_VOL_MIGRATION       = 0x00000004;
const FH4_VOL_RENAME          = 0x00000008;


struct netaddr4 {
        /* See struct rpcb in RFC 1833. */
        string na_r_netid<>;    /* Network id */
        string na_r_addr<>;     /* Universal address */
};


/*
 * Data structures new to NFSv4.1
 */

struct nfs_impl_id4 {
        utf8str_cis   nii_domain;
        utf8str_cs    nii_name;
        nfstime4      nii_date;
};


/*
 * Stateid
 */
struct stateid4 {
        uint32_t        seqid;
        opaque          other[NFS4_OTHER_SIZE];
};

enum layouttype4 {
        LAYOUT4_NFSV4_1_FILES   = 0x1,
        LAYOUT4_OSD2_OBJECTS    = 0x2,
        LAYOUT4_BLOCK_VOLUME    = 0x3
};

struct layout_content4 {
        layouttype4 loc_type;
        opaque      loc_body<>;
};


%/*
% * LAYOUT4_OSD2_OBJECTS loc_body description
% * is in a separate .x file.
% */
%
%/*
% * LAYOUT4_BLOCK_VOLUME loc_body description
% * is in a separate .x file.
% */

struct layouthint4 {
        layouttype4             loh_type;
        opaque                  loh_body<>;
};

enum layoutiomode4 {
        LAYOUTIOMODE4_READ      = 1,
        LAYOUTIOMODE4_RW        = 2,
        LAYOUTIOMODE4_ANY       = 3
};

struct layout4 {
        offset4                 lo_offset;
        length4                 lo_length;
        layoutiomode4           lo_iomode;
        layout_content4         lo_content;
};

const NFS4_DEVICEID4_SIZE = 16;

typedef opaque  deviceid4[NFS4_DEVICEID4_SIZE];

struct device_addr4 {
        layouttype4             da_layout_type;
        opaque                  da_addr_body<>;
};


struct layoutupdate4 {
        layouttype4             lou_type;
        opaque                  lou_body<>;
};

%
/* Constants used for LAYOUTRETURN and CB_LAYOUTRECALL */
const LAYOUT4_RET_REC_FILE              = 1;
const LAYOUT4_RET_REC_FSID              = 2;
const LAYOUT4_RET_REC_ALL               = 3;
%
enum layoutreturn_type4 {
        LAYOUTRETURN4_FILE = LAYOUT4_RET_REC_FILE,
        LAYOUTRETURN4_FSID = LAYOUT4_RET_REC_FSID,
        LAYOUTRETURN4_ALL  = LAYOUT4_RET_REC_ALL
};

struct layoutreturn_file4 {
        offset4         lrf_offset;
        length4         lrf_length;
        stateid4        lrf_stateid;
%       /* layouttype4 specific data */
        opaque          lrf_body<>;
};

union layoutreturn4 switch (layoutreturn_type4 lr_returntype) {
        case LAYOUTRETURN4_FILE:
                layoutreturn_file4      lr_layout;
        default:
                void;
};
%

enum fs4_status_type {
        STATUS4_FIXED     = 1,
        STATUS4_UPDATED   = 2,
        STATUS4_VERSIONED = 3,
        STATUS4_WRITABLE  = 4,
        STATUS4_REFERRAL  = 5
};

struct fs4_status {
        bool            fss_absent;
        fs4_status_type fss_type;
        utf8str_cs      fss_source;
        utf8str_cs      fss_current;
        int32_t         fss_age;
        nfstime4        fss_version;
};


const TH4_READ_SIZE     = 0;
const TH4_WRITE_SIZE    = 1;
const TH4_READ_IOSIZE   = 2;
const TH4_WRITE_IOSIZE  = 3;

typedef length4 threshold4_read_size;
typedef length4 threshold4_write_size;
typedef length4 threshold4_read_iosize;
typedef length4 threshold4_write_iosize;

struct threshold_item4 {
        layouttype4     thi_layout_type;
        bitmap4         thi_hintset;
        opaque          thi_hintlist<>;
};

struct mdsthreshold4 {
        threshold_item4 mth_hints<>;
};

const RET4_DURATION_INFINITE    = 0xffffffffffffffff;
struct retention_get4 {
        uint64_t        rg_duration;
        nfstime4        rg_begin_time<1>;
};

struct retention_set4 {
        bool            rs_enable;
        uint64_t        rs_duration<1>;
};

const FSCHARSET_CAP4_CONTAINS_NON_UTF8  = 0x1;
const FSCHARSET_CAP4_ALLOWS_ONLY_UTF8   = 0x2;

typedef uint32_t        fs_charset_cap4;


/*
 * Data structures new to NFSv4.2
 */

enum netloc_type4 {
        NL4_NAME        = 1,
        NL4_URL         = 2,
        NL4_NETADDR     = 3
};
union netloc4 switch (netloc_type4 nl_type) {
        case NL4_NAME:          utf8str_cis nl_name;
        case NL4_URL:           utf8str_cis nl_url;
        case NL4_NETADDR:       netaddr4    nl_addr;
};

enum change_attr_type4 {
           NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR         = 0,
           NFS4_CHANGE_TYPE_IS_VERSION_COUNTER        = 1,
           NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2,
           NFS4_CHANGE_TYPE_IS_TIME_METADATA          = 3,
           NFS4_CHANGE_TYPE_IS_UNDEFINED              = 4
};

struct labelformat_spec4 {
        policy4 lfs_lfs;
        policy4 lfs_pi;
};

struct sec_label4 {
        labelformat_spec4       slai_lfs;
        opaque                  slai_data<>;
};


struct copy_from_auth_priv {
        secret4             cfap_shared_secret;
        netloc4             cfap_destination;
        /* The NFSv4 user name that the user principal maps to */
        utf8str_mixed       cfap_username;
};

struct copy_to_auth_priv {
        /* Equal to cfap_shared_secret */
        secret4              ctap_shared_secret;
        netloc4              ctap_source<>;
        /* The NFSv4 user name that the user principal maps to */
        utf8str_mixed        ctap_username;
};

struct copy_confirm_auth_priv {
        /* Equal to GSS_GetMIC() of cfap_shared_secret */
        opaque              ccap_shared_secret_mic<>;
        /* The NFSv4 user name that the user principal maps to */
        utf8str_mixed       ccap_username;
};


struct app_data_block4 {
        offset4         adb_offset;
        length4         adb_block_size;
        length4         adb_block_count;
        length4         adb_reloff_blocknum;
        count4          adb_block_num;
        length4         adb_reloff_pattern;
        opaque          adb_pattern<>;
};


struct data4 {
        offset4         d_offset;
        opaque          d_data<>;
};

struct data_info4 {
        offset4         di_offset;
        length4         di_length;
};


enum data_content4 {
        NFS4_CONTENT_DATA = 0,
        NFS4_CONTENT_HOLE = 1
};



enum stable_how4 {
        UNSTABLE4       = 0,
        DATA_SYNC4      = 1,
        FILE_SYNC4      = 2
};



struct write_response4 {
        stateid4        wr_callback_id<1>;
        length4         wr_count;
        stable_how4     wr_committed;
        verifier4       wr_writeverf;
};


/*
 * NFSv4.1 attributes
 */
typedef bitmap4         fattr4_supported_attrs;
typedef nfs_ftype4      fattr4_type;
typedef uint32_t        fattr4_fh_expire_type;
typedef changeid4       fattr4_change;
typedef uint64_t        fattr4_size;
typedef bool            fattr4_link_support;
typedef bool            fattr4_symlink_support;
typedef bool            fattr4_named_attr;
typedef fsid4           fattr4_fsid;
typedef bool            fattr4_unique_handles;
typedef nfs_lease4      fattr4_lease_time;
typedef nfsstat4        fattr4_rdattr_error;
typedef nfsace4         fattr4_acl<>;
typedef uint32_t        fattr4_aclsupport;
typedef bool            fattr4_archive;
typedef bool            fattr4_cansettime;
typedef bool            fattr4_case_insensitive;
typedef bool            fattr4_case_preserving;
typedef bool            fattr4_chown_restricted;
typedef uint64_t        fattr4_fileid;
typedef uint64_t        fattr4_files_avail;
typedef nfs_fh4         fattr4_filehandle;
typedef uint64_t        fattr4_files_free;
typedef uint64_t        fattr4_files_total;
typedef fs_locations4   fattr4_fs_locations;
typedef bool            fattr4_hidden;
typedef bool            fattr4_homogeneous;
typedef uint64_t        fattr4_maxfilesize;
typedef uint32_t        fattr4_maxlink;
typedef uint32_t        fattr4_maxname;
typedef uint64_t        fattr4_maxread;
typedef uint64_t        fattr4_maxwrite;
typedef ascii_REQUIRED4 fattr4_mimetype;
typedef mode4           fattr4_mode;
typedef mode_masked4    fattr4_mode_set_masked;
typedef uint64_t        fattr4_mounted_on_fileid;
typedef bool            fattr4_no_trunc;
typedef uint32_t        fattr4_numlinks;
typedef utf8str_mixed   fattr4_owner;
typedef utf8str_mixed   fattr4_owner_group;
typedef uint64_t        fattr4_quota_avail_hard;
typedef uint64_t        fattr4_quota_avail_soft;
typedef uint64_t        fattr4_quota_used;
typedef specdata4       fattr4_rawdev;
typedef uint64_t        fattr4_space_avail;
typedef length4         fattr4_space_free;
typedef uint64_t        fattr4_space_total;
typedef uint64_t        fattr4_space_used;
typedef bool            fattr4_system;
typedef nfstime4        fattr4_time_access;
typedef settime4        fattr4_time_access_set;
typedef nfstime4        fattr4_time_backup;
typedef nfstime4        fattr4_time_create;
typedef nfstime4        fattr4_time_delta;
typedef nfstime4        fattr4_time_metadata;
typedef nfstime4        fattr4_time_modify;
typedef settime4        fattr4_time_modify_set;
/*
 * Attributes new to NFSv4.1
 */
typedef bitmap4         fattr4_suppattr_exclcreat;
typedef nfstime4        fattr4_dir_notif_delay;
typedef nfstime4        fattr4_dirent_notif_delay;
typedef layouttype4     fattr4_fs_layout_types<>;
typedef fs4_status      fattr4_fs_status;
typedef fs_charset_cap4 fattr4_fs_charset_cap;
typedef uint32_t        fattr4_layout_alignment;
typedef uint32_t        fattr4_layout_blksize;
typedef layouthint4     fattr4_layout_hint;
typedef layouttype4     fattr4_layout_types<>;
typedef mdsthreshold4   fattr4_mdsthreshold;
typedef retention_get4  fattr4_retention_get;
typedef retention_set4  fattr4_retention_set;
typedef retention_get4  fattr4_retentevt_get;
typedef retention_set4  fattr4_retentevt_set;
typedef uint64_t        fattr4_retention_hold;
typedef nfsacl41        fattr4_dacl;
typedef nfsacl41        fattr4_sacl;
typedef change_policy4  fattr4_change_policy;
/*
 * Attributes new to NFSv4.2
 */
typedef uint64_t        fattr4_space_freed;
typedef change_attr_type4
                fattr4_change_attr_type;
typedef sec_label4      fattr4_sec_label;
typedef uint32_t        fattr4_clone_blksize;

%/*
% * REQUIRED attributes
% */
const FATTR4_SUPPORTED_ATTRS    = 0;
const FATTR4_TYPE               = 1;
const FATTR4_FH_EXPIRE_TYPE     = 2;
const FATTR4_CHANGE             = 3;
const FATTR4_SIZE               = 4;
const FATTR4_LINK_SUPPORT       = 5;
const FATTR4_SYMLINK_SUPPORT    = 6;
const FATTR4_NAMED_ATTR         = 7;
const FATTR4_FSID               = 8;
const FATTR4_UNIQUE_HANDLES     = 9;
const FATTR4_LEASE_TIME         = 10;
const FATTR4_RDATTR_ERROR       = 11;
const FATTR4_FILEHANDLE         = 19;

%/*
% * New to NFSv4.1
% */
const FATTR4_SUPPATTR_EXCLCREAT = 75;

%/*
% * RECOMMENDED attributes
% */
const FATTR4_ACL                = 12;
const FATTR4_ACLSUPPORT         = 13;
const FATTR4_ARCHIVE            = 14;
const FATTR4_CANSETTIME         = 15;
const FATTR4_CASE_INSENSITIVE   = 16;
const FATTR4_CASE_PRESERVING    = 17;
const FATTR4_CHOWN_RESTRICTED   = 18;
const FATTR4_FILEID             = 20;
const FATTR4_FILES_AVAIL        = 21;
const FATTR4_FILES_FREE         = 22;
const FATTR4_FILES_TOTAL        = 23;
const FATTR4_FS_LOCATIONS       = 24;
const FATTR4_HIDDEN             = 25;
const FATTR4_HOMOGENEOUS        = 26;
const FATTR4_MAXFILESIZE        = 27;
const FATTR4_MAXLINK            = 28;
const FATTR4_MAXNAME            = 29;
const FATTR4_MAXREAD            = 30;
const FATTR4_MAXWRITE           = 31;
const FATTR4_MIMETYPE           = 32;
const FATTR4_MODE               = 33;
const FATTR4_NO_TRUNC           = 34;
const FATTR4_NUMLINKS           = 35;
const FATTR4_OWNER              = 36;
const FATTR4_OWNER_GROUP        = 37;
const FATTR4_QUOTA_AVAIL_HARD   = 38;
const FATTR4_QUOTA_AVAIL_SOFT   = 39;
const FATTR4_QUOTA_USED         = 40;
const FATTR4_RAWDEV             = 41;
const FATTR4_SPACE_AVAIL        = 42;
const FATTR4_SPACE_FREE         = 43;
const FATTR4_SPACE_TOTAL        = 44;
const FATTR4_SPACE_USED         = 45;
const FATTR4_SYSTEM             = 46;
const FATTR4_TIME_ACCESS        = 47;
const FATTR4_TIME_ACCESS_SET    = 48;
const FATTR4_TIME_BACKUP        = 49;
const FATTR4_TIME_CREATE        = 50;
const FATTR4_TIME_DELTA         = 51;
const FATTR4_TIME_METADATA      = 52;
const FATTR4_TIME_MODIFY        = 53;
const FATTR4_TIME_MODIFY_SET    = 54;
const FATTR4_MOUNTED_ON_FILEID  = 55;

%/*
% * New to NFSv4.1
% */
const FATTR4_DIR_NOTIF_DELAY    = 56;
const FATTR4_DIRENT_NOTIF_DELAY = 57;
const FATTR4_DACL               = 58;
const FATTR4_SACL               = 59;
const FATTR4_CHANGE_POLICY      = 60;
const FATTR4_FS_STATUS          = 61;
const FATTR4_FS_LAYOUT_TYPES    = 62;
const FATTR4_LAYOUT_HINT        = 63;
const FATTR4_LAYOUT_TYPES       = 64;
const FATTR4_LAYOUT_BLKSIZE     = 65;
const FATTR4_LAYOUT_ALIGNMENT   = 66;
const FATTR4_FS_LOCATIONS_INFO  = 67;
const FATTR4_MDSTHRESHOLD       = 68;
const FATTR4_RETENTION_GET      = 69;
const FATTR4_RETENTION_SET      = 70;
const FATTR4_RETENTEVT_GET      = 71;
const FATTR4_RETENTEVT_SET      = 72;
const FATTR4_RETENTION_HOLD     = 73;
const FATTR4_MODE_SET_MASKED    = 74;
const FATTR4_FS_CHARSET_CAP     = 76;

%/*
% * New to NFSv4.2
% */
const FATTR4_CLONE_BLKSIZE      = 77;
const FATTR4_SPACE_FREED        = 78;
const FATTR4_CHANGE_ATTR_TYPE   = 79;
const FATTR4_SEC_LABEL          = 80;

/*
 * File attribute container
 */
struct fattr4 {
        bitmap4         attrmask;
        attrlist4       attr_vals;
};

/*
 * Change info for the client
 */
struct change_info4 {
        bool            atomic;
        changeid4       before;
        changeid4       after;
};

typedef netaddr4 clientaddr4;

/*
 * Callback program info as provided by the client
 */
struct cb_client4 {
        uint32_t        cb_program;
        netaddr4        cb_location;
};

/*
 * NFSv4.0 long-hand client ID
 */
struct nfs_client_id4 {
        verifier4       verifier;
        opaque          id<NFS4_OPAQUE_LIMIT>;
};

/*
 * NFSv4.1 client owner (aka long-hand client ID)
 */
struct client_owner4 {
        verifier4       co_verifier;
        opaque          co_ownerid<NFS4_OPAQUE_LIMIT>;
};


/*
 * NFSv4.1 server owner
 */
struct server_owner4 {
 uint64_t       so_minor_id;
 opaque         so_major_id<NFS4_OPAQUE_LIMIT>;
};


struct state_owner4 {
        clientid4       clientid;
        opaque          owner<NFS4_OPAQUE_LIMIT>;
};

typedef state_owner4 open_owner4;
typedef state_owner4 lock_owner4;


enum nfs_lock_type4 {
        READ_LT         = 1,
        WRITE_LT        = 2,
        READW_LT        = 3,    /* Blocking read */
        WRITEW_LT       = 4     /* Blocking write */
};


%
%/* Input for computing subkeys */
enum ssv_subkey4 {
        SSV4_SUBKEY_MIC_I2T     = 1,
        SSV4_SUBKEY_MIC_T2I     = 2,
        SSV4_SUBKEY_SEAL_I2T    = 3,
        SSV4_SUBKEY_SEAL_T2I    = 4
};
%

%
%/* Input for computing smt_hmac */
struct ssv_mic_plain_tkn4 {
  uint32_t        smpt_ssv_seq;
  opaque          smpt_orig_plain<>;
};
%

%
%/*
% * Secret State Verifier Generic Security Service (SSV GSS)
% * PerMsgToken token
% */
struct ssv_mic_tkn4 {
  uint32_t        smt_ssv_seq;
  opaque          smt_hmac<>;
};
%

%
%/* Input for computing ssct_encr_data and ssct_hmac */
struct ssv_seal_plain_tkn4 {
  opaque          sspt_confounder<>;
  uint32_t        sspt_ssv_seq;
  opaque          sspt_orig_plain<>;
  opaque          sspt_pad<>;
};
%

%
%/* SSV GSS SealedMessage token */
struct ssv_seal_cipher_tkn4 {
  uint32_t      ssct_ssv_seq;
  opaque        ssct_iv<>;
  opaque        ssct_encr_data<>;
  opaque        ssct_hmac<>;
};
%

/*
 * Defines an individual server replica
 */
struct fs_locations_server4 {
       int32_t          fls_currency;
       opaque           fls_info<>;
       utf8str_cis      fls_server;
};

/*
 * Byte indices of items within
 * fls_info: flag fields, class numbers,
 * bytes indicating ranks and orders
 */
const FSLI4BX_GFLAGS            = 0;
const FSLI4BX_TFLAGS            = 1;

const FSLI4BX_CLSIMUL           = 2;
const FSLI4BX_CLHANDLE          = 3;
const FSLI4BX_CLFILEID          = 4;
const FSLI4BX_CLWRITEVER        = 5;
const FSLI4BX_CLCHANGE          = 6;
const FSLI4BX_CLREADDIR         = 7;

const FSLI4BX_READRANK          = 8;
const FSLI4BX_WRITERANK         = 9;
const FSLI4BX_READORDER         = 10;
const FSLI4BX_WRITEORDER        = 11;

/*
 * Bits defined within the general flag byte
 */
const FSLI4GF_WRITABLE          = 0x01;
const FSLI4GF_CUR_REQ           = 0x02;
const FSLI4GF_ABSENT            = 0x04;
const FSLI4GF_GOING             = 0x08;
const FSLI4GF_SPLIT             = 0x10;

/*
 * Bits defined within the transport flag byte
 */
const FSLI4TF_RDMA              = 0x01;

/*
 * Defines a set of replicas sharing
 * a common value of the root path
 * within the corresponding
 * single-server namespaces
 */
struct fs_locations_item4 {
       fs_locations_server4     fli_entries<>;
       pathname4                fli_rootpath;
};

/*
 * Defines the overall structure of
 * the fs_locations_info attribute
 */
struct fs_locations_info4 {
       uint32_t                 fli_flags;
       int32_t                  fli_valid_for;
       pathname4                fli_fs_root;
       fs_locations_item4       fli_items<>;
};

/*
 * Flag bits in fli_flags
 */
const FSLI4IF_VAR_SUB           = 0x00000001;

typedef fs_locations_info4 fattr4_fs_locations_info;

const NFL4_UFLG_MASK                    = 0x0000003F;
const NFL4_UFLG_DENSE                   = 0x00000001;
const NFL4_UFLG_COMMIT_THRU_MDS         = 0x00000002;
const NFL42_UFLG_IO_ADVISE_THRU_MDS     = 0x00000004;
const NFL4_UFLG_STRIPE_UNIT_SIZE_MASK   = 0xFFFFFFC0;

typedef uint32_t nfl_util4;

%

enum filelayout_hint_care4 {
        NFLH4_CARE_DENSE        = NFL4_UFLG_DENSE,

        NFLH4_CARE_COMMIT_THRU_MDS
                                = NFL4_UFLG_COMMIT_THRU_MDS,

        NFL42_CARE_IO_ADVISE_THRU_MDS
                                = NFL42_UFLG_IO_ADVISE_THRU_MDS,

        NFLH4_CARE_STRIPE_UNIT_SIZE
                                = 0x00000040,

        NFLH4_CARE_STRIPE_COUNT = 0x00000080
};
%
%/*
% * Encoded in the loh_body field of data type layouthint4:
% */
%
struct nfsv4_1_file_layouthint4 {
        uint32_t        nflh_care;
        nfl_util4       nflh_util;
        count4          nflh_stripe_count;
};

%

%
typedef netaddr4 multipath_list4<>;
%
%/*
% * Encoded in the da_addr_body field of data type device_addr4:
% */
struct nfsv4_1_file_layout_ds_addr4 {
        uint32_t        nflda_stripe_indices<>;
        multipath_list4 nflda_multipath_ds_list<>;
};

%

%
%/*
% * Encoded in the loc_body field of data type layout_content4:
% */
struct nfsv4_1_file_layout4 {
         deviceid4      nfl_deviceid;
         nfl_util4      nfl_util;
         uint32_t       nfl_first_stripe_index;
         offset4        nfl_pattern_offset;
         nfs_fh4        nfl_fh_list<>;
};

%


/*
 * Operation arrays (the opnum first)
 */

enum nfs_opnum4 {
 OP_ACCESS               = 3,
 OP_CLOSE                = 4,
 OP_COMMIT               = 5,
 OP_CREATE               = 6,
 OP_DELEGPURGE           = 7,
 OP_DELEGRETURN          = 8,
 OP_GETATTR              = 9,
 OP_GETFH                = 10,
 OP_LINK                 = 11,
 OP_LOCK                 = 12,
 OP_LOCKT                = 13,
 OP_LOCKU                = 14,
 OP_LOOKUP               = 15,
 OP_LOOKUPP              = 16,
 OP_NVERIFY              = 17,
 OP_OPEN                 = 18,
 OP_OPENATTR             = 19,
 OP_OPEN_CONFIRM         = 20, /* Mandatory not-to-implement */
 OP_OPEN_DOWNGRADE       = 21,
 OP_PUTFH                = 22,
 OP_PUTPUBFH             = 23,
 OP_PUTROOTFH            = 24,
 OP_READ                 = 25,
 OP_READDIR              = 26,
 OP_READLINK             = 27,
 OP_REMOVE               = 28,
 OP_RENAME               = 29,
 OP_RENEW                = 30, /* Mandatory not-to-implement */
 OP_RESTOREFH            = 31,
 OP_SAVEFH               = 32,
 OP_SECINFO              = 33,
 OP_SETATTR              = 34,
 OP_SETCLIENTID          = 35, /* Mandatory not-to-implement */
 OP_SETCLIENTID_CONFIRM  = 36, /* Mandatory not-to-implement */
 OP_VERIFY               = 37,
 OP_WRITE                = 38,
 OP_RELEASE_LOCKOWNER    = 39, /* Mandatory not-to-implement */
%
%/* New operations for NFSv4.1 */
%
 OP_BACKCHANNEL_CTL      = 40,
 OP_BIND_CONN_TO_SESSION = 41,
 OP_EXCHANGE_ID          = 42,
 OP_CREATE_SESSION       = 43,
 OP_DESTROY_SESSION      = 44,
 OP_FREE_STATEID         = 45,
 OP_GET_DIR_DELEGATION   = 46,
 OP_GETDEVICEINFO        = 47,
 OP_GETDEVICELIST        = 48,
 OP_LAYOUTCOMMIT         = 49,
 OP_LAYOUTGET            = 50,
 OP_LAYOUTRETURN         = 51,
 OP_SECINFO_NO_NAME      = 52,
 OP_SEQUENCE             = 53,
 OP_SET_SSV              = 54,
 OP_TEST_STATEID         = 55,
 OP_WANT_DELEGATION      = 56,
 OP_DESTROY_CLIENTID     = 57,
 OP_RECLAIM_COMPLETE     = 58,
%
%/* New operations for NFSv4.2 */
%
 OP_ALLOCATE             = 59,
 OP_COPY                 = 60,
 OP_COPY_NOTIFY          = 61,
 OP_DEALLOCATE           = 62,
 OP_IO_ADVISE            = 63,
 OP_LAYOUTERROR          = 64,
 OP_LAYOUTSTATS          = 65,
 OP_OFFLOAD_CANCEL       = 66,
 OP_OFFLOAD_STATUS       = 67,
 OP_READ_PLUS            = 68,
 OP_SEEK                 = 69,
 OP_WRITE_SAME           = 70,
 OP_CLONE                = 71,
 OP_ILLEGAL              = 10044
};



const ACCESS4_READ       = 0x00000001;
const ACCESS4_LOOKUP     = 0x00000002;
const ACCESS4_MODIFY     = 0x00000004;
const ACCESS4_EXTEND     = 0x00000008;
const ACCESS4_DELETE     = 0x00000010;
const ACCESS4_EXECUTE    = 0x00000020;

struct ACCESS4args {
        /* CURRENT_FH: object */
        uint32_t        access;
};

struct ACCESS4resok {
        uint32_t        supported;
        uint32_t        access;
};

union ACCESS4res switch (nfsstat4 status) {
 case NFS4_OK:
         ACCESS4resok    resok4;
 default:
         void;
};

struct CLONE4args {
        /* SAVED_FH: source file */
        /* CURRENT_FH: destination file */
        stateid4        cl_src_stateid;
        stateid4        cl_dst_stateid;
        offset4         cl_src_offset;
        offset4         cl_dst_offset;
        length4         cl_count;
};

struct CLONE4res {
        nfsstat4        cl_status;
};
struct CLOSE4args {
        /* CURRENT_FH: object */
        seqid4          seqid;
        stateid4        open_stateid;
};

union CLOSE4res switch (nfsstat4 status) {
 case NFS4_OK:
         stateid4       open_stateid;
 default:
         void;
};

struct COMMIT4args {
        /* CURRENT_FH: file */
        offset4         offset;
        count4          count;
};

struct COMMIT4resok {
        verifier4       writeverf;
};

union COMMIT4res switch (nfsstat4 status) {
 case NFS4_OK:
         COMMIT4resok   resok4;
 default:
         void;
};

union createtype4 switch (nfs_ftype4 type) {
 case NF4LNK:
         linktext4 linkdata;
 case NF4BLK:
 case NF4CHR:
         specdata4 devdata;
 case NF4SOCK:
 case NF4FIFO:
 case NF4DIR:
         void;
 default:
         void;  /* Server should return NFS4ERR_BADTYPE. */
};

struct CREATE4args {
        /* CURRENT_FH: directory for creation */
        createtype4     objtype;
        component4      objname;
        fattr4          createattrs;
};

struct CREATE4resok {
        change_info4    cinfo;
        bitmap4         attrset;        /* Attributes set */
};

union CREATE4res switch (nfsstat4 status) {
 case NFS4_OK:
         /* New CURRENTFH: created object */
         CREATE4resok resok4;
 default:
         void;
};

struct DELEGPURGE4args {
        clientid4       clientid;
};

struct DELEGPURGE4res {
        nfsstat4        status;
};

struct DELEGRETURN4args {
        /* CURRENT_FH: delegated object */
        stateid4        deleg_stateid;
};

struct DELEGRETURN4res {
        nfsstat4        status;
};

struct GETATTR4args {
        /* CURRENT_FH: object */
        bitmap4         attr_request;
};

struct GETATTR4resok {
        fattr4          obj_attributes;
};

union GETATTR4res switch (nfsstat4 status) {
 case NFS4_OK:
         GETATTR4resok  resok4;
 default:
         void;
};

struct GETFH4resok {
        nfs_fh4         object;
};

union GETFH4res switch (nfsstat4 status) {
 case NFS4_OK:
         GETFH4resok     resok4;
 default:
         void;
};

struct LINK4args {
        /* SAVED_FH: source object */
        /* CURRENT_FH: target directory */
        component4      newname;
};

struct LINK4resok {
        change_info4    cinfo;
};

union LINK4res switch (nfsstat4 status) {
 case NFS4_OK:
         LINK4resok resok4;
 default:
         void;
};

/*
 * For LOCK, transition from open_stateid and lock_owner
 * to a lock stateid.
 */
struct open_to_lock_owner4 {
        seqid4          open_seqid;
        stateid4        open_stateid;
        seqid4          lock_seqid;
        lock_owner4     lock_owner;
};

/*
 * For LOCK, existing lock stateid continues to request new
 * file lock for the same lock_owner and open_stateid.
 */
struct exist_lock_owner4 {
        stateid4        lock_stateid;
        seqid4          lock_seqid;
};

union locker4 switch (bool new_lock_owner) {
 case TRUE:
        open_to_lock_owner4     open_owner;
 case FALSE:
        exist_lock_owner4       lock_owner;
};

/*
 * LOCK/LOCKT/LOCKU: Record lock management
 */
struct LOCK4args {
        /* CURRENT_FH: file */
        nfs_lock_type4  locktype;
        bool            reclaim;
        offset4         offset;
        length4         length;
        locker4         locker;
};

struct LOCK4denied {
        offset4         offset;
        length4         length;
        nfs_lock_type4  locktype;
        lock_owner4     owner;
};

struct LOCK4resok {
        stateid4        lock_stateid;
};

union LOCK4res switch (nfsstat4 status) {
 case NFS4_OK:
         LOCK4resok     resok4;
 case NFS4ERR_DENIED:
         LOCK4denied    denied;
 default:
         void;
};

struct LOCKT4args {
        /* CURRENT_FH: file */
        nfs_lock_type4  locktype;
        offset4         offset;
        length4         length;
        lock_owner4     owner;
};

union LOCKT4res switch (nfsstat4 status) {
 case NFS4ERR_DENIED:
         LOCK4denied    denied;
 case NFS4_OK:
         void;
 default:
         void;
};

struct LOCKU4args {
        /* CURRENT_FH: file */
        nfs_lock_type4  locktype;
        seqid4          seqid;
        stateid4        lock_stateid;
        offset4         offset;
        length4         length;
};

union LOCKU4res switch (nfsstat4 status) {
 case NFS4_OK:
         stateid4       lock_stateid;
 default:
         void;
};

struct LOOKUP4args {
        /* CURRENT_FH: directory */
        component4      objname;
};

struct LOOKUP4res {
        /* New CURRENT_FH: object */
        nfsstat4        status;
};

struct LOOKUPP4res {
        /* New CURRENT_FH: parent directory */
        nfsstat4        status;
};

struct NVERIFY4args {
        /* CURRENT_FH: object */
        fattr4          obj_attributes;
};

struct NVERIFY4res {
        nfsstat4        status;
};

/*
 * Various definitions for OPEN
 */
enum createmode4 {
        UNCHECKED4      = 0,
        GUARDED4        = 1,
        /* Deprecated in NFSv4.1 */
        EXCLUSIVE4      = 2,
        /*
         * New to NFSv4.1.  If session is persistent,
         * GUARDED4 MUST be used.  Otherwise, use
         * EXCLUSIVE4_1 instead of EXCLUSIVE4.
         */
        EXCLUSIVE4_1    = 3
};

struct creatverfattr {
         verifier4      cva_verf;
         fattr4         cva_attrs;
};

union createhow4 switch (createmode4 mode) {
 case UNCHECKED4:
 case GUARDED4:
         fattr4         createattrs;
 case EXCLUSIVE4:
         verifier4      createverf;
 case EXCLUSIVE4_1:
         creatverfattr  ch_createboth;
};

enum opentype4 {
        OPEN4_NOCREATE  = 0,
        OPEN4_CREATE    = 1
};

union openflag4 switch (opentype4 opentype) {
 case OPEN4_CREATE:
         createhow4     how;
 default:
         void;
};

/* Next definitions used for OPEN delegation */
enum limit_by4 {
        NFS_LIMIT_SIZE          = 1,
        NFS_LIMIT_BLOCKS        = 2
        /* Others as needed */
};

struct nfs_modified_limit4 {
        uint32_t        num_blocks;
        uint32_t        bytes_per_block;
};

union nfs_space_limit4 switch (limit_by4 limitby) {
 /* Limit specified as file size */
 case NFS_LIMIT_SIZE:
         uint64_t               filesize;
 /* Limit specified by number of blocks */
 case NFS_LIMIT_BLOCKS:
         nfs_modified_limit4    mod_blocks;
};

/*
 * Share Access and Deny constants for open argument
 */
const OPEN4_SHARE_ACCESS_READ   = 0x00000001;
const OPEN4_SHARE_ACCESS_WRITE  = 0x00000002;
const OPEN4_SHARE_ACCESS_BOTH   = 0x00000003;

const OPEN4_SHARE_DENY_NONE     = 0x00000000;
const OPEN4_SHARE_DENY_READ     = 0x00000001;
const OPEN4_SHARE_DENY_WRITE    = 0x00000002;
const OPEN4_SHARE_DENY_BOTH     = 0x00000003;


/* New flags for share_access field of OPEN4args */
const OPEN4_SHARE_ACCESS_WANT_DELEG_MASK        = 0xFF00;
const OPEN4_SHARE_ACCESS_WANT_NO_PREFERENCE     = 0x0000;
const OPEN4_SHARE_ACCESS_WANT_READ_DELEG        = 0x0100;
const OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG       = 0x0200;
const OPEN4_SHARE_ACCESS_WANT_ANY_DELEG         = 0x0300;
const OPEN4_SHARE_ACCESS_WANT_NO_DELEG          = 0x0400;
const OPEN4_SHARE_ACCESS_WANT_CANCEL            = 0x0500;

const
 OPEN4_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL
 = 0x10000;

const
 OPEN4_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED
 = 0x20000;

enum open_delegation_type4 {
        OPEN_DELEGATE_NONE      = 0,
        OPEN_DELEGATE_READ      = 1,
        OPEN_DELEGATE_WRITE     = 2,
        OPEN_DELEGATE_NONE_EXT  = 3 /* New to NFSv4.1 */
};

enum open_claim_type4 {
        /*
         * Not a reclaim
         */
        CLAIM_NULL              = 0,

        CLAIM_PREVIOUS          = 1,
        CLAIM_DELEGATE_CUR      = 2,
        CLAIM_DELEGATE_PREV     = 3,

        /*
         * Not a reclaim
         *
         * Like CLAIM_NULL, but object identified
         * by the current filehandle
         */
        CLAIM_FH                = 4, /* New to NFSv4.1 */

        /*
         * Like CLAIM_DELEGATE_CUR, but object identified
         * by current filehandle
         */
        CLAIM_DELEG_CUR_FH      = 5, /* New to NFSv4.1 */

        /*
         * Like CLAIM_DELEGATE_PREV, but object identified
         * by current filehandle
         */
        CLAIM_DELEG_PREV_FH     = 6 /* New to NFSv4.1 */
};

struct open_claim_delegate_cur4 {
        stateid4        delegate_stateid;
        component4      file;
};

union open_claim4 switch (open_claim_type4 claim) {
 /*
  * No special rights to file.
  * Ordinary OPEN of the specified file.
  */
 case CLAIM_NULL:
        /* CURRENT_FH: directory */
        component4      file;
 /*
  * Right to the file established by an
  * open previous to server reboot.  File
  * identified by filehandle obtained at
  * that time rather than by name.
  */
 case CLAIM_PREVIOUS:
        /* CURRENT_FH: file being reclaimed */
        open_delegation_type4   delegate_type;

 /*
  * Right to file based on a delegation
  * granted by the server.  File is
  * specified by name.
  */
 case CLAIM_DELEGATE_CUR:
        /* CURRENT_FH: directory */
        open_claim_delegate_cur4        delegate_cur_info;

 /*
  * Right to file based on a delegation
  * granted to a previous boot instance
  * of the client.  File is specified by name.
  */
 case CLAIM_DELEGATE_PREV:
         /* CURRENT_FH: directory */
        component4      file_delegate_prev;

 /*
  * Like CLAIM_NULL.  No special rights
  * to file.  Ordinary OPEN of the
  * specified file by current filehandle.
  */
 case CLAIM_FH: /* New to NFSv4.1 */
        /* CURRENT_FH: regular file to open */
        void;

 /*
  * Like CLAIM_DELEGATE_PREV.  Right to file based on a
  * delegation granted to a previous boot
  * instance of the client.  File is identified
  * by filehandle.
  */
 case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */
        /* CURRENT_FH: file being opened */
        void;

 /*
  * Like CLAIM_DELEGATE_CUR.  Right to file based on
  * a delegation granted by the server.
  * File is identified by filehandle.
  */
 case CLAIM_DELEG_CUR_FH: /* New to NFSv4.1 */
         /* CURRENT_FH: file being opened */
         stateid4       oc_delegate_stateid;

};

/*
 * OPEN: Open a file, potentially receiving an open delegation.
 */
struct OPEN4args {
        seqid4          seqid;
        uint32_t        share_access;
        uint32_t        share_deny;
        open_owner4     owner;
        openflag4       openhow;
        open_claim4     claim;
};

struct open_read_delegation4 {
 stateid4 stateid;    /* Stateid for delegation */
 bool     recall;     /* Pre-recalled flag for
                         delegations obtained
                         by reclaim (CLAIM_PREVIOUS) */

 nfsace4 permissions; /* Defines users who don't
                         need an ACCESS call to
                         open for read */
};

struct open_write_delegation4 {
 stateid4 stateid;      /* Stateid for delegation */
 bool     recall;       /* Pre-recalled flag for
                           delegations obtained
                           by reclaim
                           (CLAIM_PREVIOUS) */

 nfs_space_limit4
           space_limit; /* Defines condition that
                           the client must check to
                           determine whether the
                           file needs to be flushed
                           to the server on close */

 nfsace4   permissions; /* Defines users who don't
                           need an ACCESS call as
                           part of a delegated
                           open */
};


enum why_no_delegation4 { /* New to NFSv4.1 */
        WND4_NOT_WANTED                 = 0,
        WND4_CONTENTION                 = 1,
        WND4_RESOURCE                   = 2,
        WND4_NOT_SUPP_FTYPE             = 3,
        WND4_WRITE_DELEG_NOT_SUPP_FTYPE = 4,
        WND4_NOT_SUPP_UPGRADE           = 5,
        WND4_NOT_SUPP_DOWNGRADE         = 6,
        WND4_CANCELLED                  = 7,
        WND4_IS_DIR                     = 8
};

union open_none_delegation4 /* New to NFSv4.1 */
 switch (why_no_delegation4 ond_why) {
         case WND4_CONTENTION:
                 bool ond_server_will_push_deleg;
         case WND4_RESOURCE:
                 bool ond_server_will_signal_avail;
         default:
                 void;
};

union open_delegation4
 switch (open_delegation_type4 delegation_type) {
         case OPEN_DELEGATE_NONE:
                 void;
         case OPEN_DELEGATE_READ:
                 open_read_delegation4 read;
         case OPEN_DELEGATE_WRITE:
                 open_write_delegation4 write;
         case OPEN_DELEGATE_NONE_EXT: /* New to NFSv4.1 */
                 open_none_delegation4 od_whynone;
};

/*
 * Result flags
 */

/* Client must confirm open. */
const OPEN4_RESULT_CONFIRM      = 0x00000002;
/* Type of file-locking behavior at the server */
const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004;
/* Server will preserve file if removed while open. */
const OPEN4_RESULT_PRESERVE_UNLINKED = 0x00000008;

/*
 * Server may use CB_NOTIFY_LOCK on locks
 * derived from this open.
 */
const OPEN4_RESULT_MAY_NOTIFY_LOCK = 0x00000020;

struct OPEN4resok {
 stateid4         stateid;      /* Stateid for open */
 change_info4     cinfo;        /* Directory change info */
 uint32_t         rflags;       /* Result flags */
 bitmap4          attrset;      /* Attribute set for create */
 open_delegation4 delegation;   /* Info on any open
                                   delegation */
};

union OPEN4res switch (nfsstat4 status) {
 case NFS4_OK:
         /* New CURRENT_FH: opened file */
         OPEN4resok      resok4;
 default:
         void;
};

struct OPENATTR4args {
        /* CURRENT_FH: object */
        bool    createdir;
};

struct OPENATTR4res {
        /*
         * If status is NFS4_OK,
         *   New CURRENT_FH: named attribute
         *                   directory
         */
        nfsstat4        status;
};

/* Obsolete in NFSv4.1 */
struct OPEN_CONFIRM4args {
        /* CURRENT_FH: opened file */
        stateid4        open_stateid;
        seqid4          seqid;
};

struct OPEN_CONFIRM4resok {
        stateid4        open_stateid;
};

union OPEN_CONFIRM4res switch (nfsstat4 status) {
 case NFS4_OK:
         OPEN_CONFIRM4resok     resok4;
 default:
         void;
};

struct OPEN_DOWNGRADE4args {
        /* CURRENT_FH: opened file */
        stateid4        open_stateid;
        seqid4          seqid;
        uint32_t        share_access;
        uint32_t        share_deny;
};

struct OPEN_DOWNGRADE4resok {
        stateid4        open_stateid;
};

union OPEN_DOWNGRADE4res switch (nfsstat4 status) {
 case NFS4_OK:
         OPEN_DOWNGRADE4resok    resok4;
 default:
         void;
};

struct PUTFH4args {
        nfs_fh4         object;
};

struct PUTFH4res {
        /*
         * If status is NFS4_OK,
         *   New CURRENT_FH: argument to PUTFH
         */
        nfsstat4        status;
};

struct PUTPUBFH4res {
        /*
         * If status is NFS4_OK,
         *   New CURRENT_FH: public fh
         */
        nfsstat4        status;
};

struct PUTROOTFH4res {
        /*
         * If status is NFS4_OK,
         *   New CURRENT_FH: root fh
         */
        nfsstat4        status;
};

struct READ4args {
        /* CURRENT_FH: file */
        stateid4        stateid;
        offset4         offset;
        count4          count;
};

struct READ4resok {
        bool            eof;
        opaque          data<>;
};

union READ4res switch (nfsstat4 status) {
 case NFS4_OK:
         READ4resok     resok4;
 default:
         void;
};

struct READDIR4args {
        /* CURRENT_FH: directory */
        nfs_cookie4     cookie;
        verifier4       cookieverf;
        count4          dircount;
        count4          maxcount;
        bitmap4         attr_request;
};

struct entry4 {
        nfs_cookie4     cookie;
        component4      name;
        fattr4          attrs;
        entry4          *nextentry;
};

struct dirlist4 {
        entry4          *entries;
        bool            eof;
};

struct READDIR4resok {
        verifier4       cookieverf;
        dirlist4        reply;
};


union READDIR4res switch (nfsstat4 status) {
 case NFS4_OK:
         READDIR4resok  resok4;
 default:
         void;
};


struct READLINK4resok {
        linktext4       link;
};

union READLINK4res switch (nfsstat4 status) {
 case NFS4_OK:
         READLINK4resok resok4;
 default:
         void;
};

struct REMOVE4args {
        /* CURRENT_FH: directory */
        component4      target;
};

struct REMOVE4resok {
        change_info4    cinfo;
};

union REMOVE4res switch (nfsstat4 status) {
 case NFS4_OK:
         REMOVE4resok   resok4;
 default:
         void;
};

struct RENAME4args {
        /* SAVED_FH: source directory */
        component4      oldname;
        /* CURRENT_FH: target directory */
        component4      newname;
};

struct RENAME4resok {
        change_info4    source_cinfo;
        change_info4    target_cinfo;
};

union RENAME4res switch (nfsstat4 status) {
 case NFS4_OK:
         RENAME4resok    resok4;
 default:
         void;
};

/* Obsolete in NFSv4.1 */
struct RENEW4args {
        clientid4       clientid;
};

struct RENEW4res {
        nfsstat4        status;
};

struct RESTOREFH4res {
        /*
         * If status is NFS4_OK,
         *   New CURRENT_FH: value of saved fh
         */
        nfsstat4        status;
};

struct SAVEFH4res {
        /*
         * If status is NFS4_OK,
         *   New SAVED_FH: value of current fh
         */
        nfsstat4        status;
};

struct SECINFO4args {
        /* CURRENT_FH: directory */
        component4      name;
};

/*
 * From RFC 2203
 */
enum rpc_gss_svc_t {
        RPC_GSS_SVC_NONE        = 1,
        RPC_GSS_SVC_INTEGRITY   = 2,
        RPC_GSS_SVC_PRIVACY     = 3
};

struct rpcsec_gss_info {
        sec_oid4        oid;
        qop4            qop;
        rpc_gss_svc_t   service;
};

/* RPCSEC_GSS has a value of "6".  See RFC 2203. */
union secinfo4 switch (uint32_t flavor) {
 case RPCSEC_GSS:
         rpcsec_gss_info        flavor_info;
 default:
         void;
};

typedef secinfo4 SECINFO4resok<>;

union SECINFO4res switch (nfsstat4 status) {
 case NFS4_OK:
         /* CURRENTFH: consumed */
         SECINFO4resok resok4;
 default:
         void;
};

struct SETATTR4args {
        /* CURRENT_FH: target object */
        stateid4        stateid;
        fattr4          obj_attributes;
};

struct SETATTR4res {
        nfsstat4        status;
        bitmap4         attrsset;
};

/* Obsolete in NFSv4.1 */
struct SETCLIENTID4args {
        nfs_client_id4  client;
        cb_client4      callback;
        uint32_t        callback_ident;
};

struct SETCLIENTID4resok {
        clientid4       clientid;
        verifier4       setclientid_confirm;
};

union SETCLIENTID4res switch (nfsstat4 status) {
 case NFS4_OK:
         SETCLIENTID4resok      resok4;
 case NFS4ERR_CLID_INUSE:
         clientaddr4    client_using;
 default:
         void;
};

/* Obsolete in NFSv4.1 */
struct SETCLIENTID_CONFIRM4args {
        clientid4       clientid;
        verifier4       setclientid_confirm;
};

struct SETCLIENTID_CONFIRM4res {
        nfsstat4        status;
};

struct VERIFY4args {
        /* CURRENT_FH: object */
        fattr4          obj_attributes;
};

struct VERIFY4res {
        nfsstat4        status;
};

struct WRITE4args {
        /* CURRENT_FH: file */
        stateid4        stateid;
        offset4         offset;
        stable_how4     stable;
        opaque          data<>;
};

struct WRITE4resok {
        count4          count;
        stable_how4     committed;
        verifier4       writeverf;
};

union WRITE4res switch (nfsstat4 status) {
 case NFS4_OK:
         WRITE4resok    resok4;
 default:
         void;
};

/* Obsolete in NFSv4.1 */
struct RELEASE_LOCKOWNER4args {
        lock_owner4     lock_owner;
};

struct RELEASE_LOCKOWNER4res {
        nfsstat4        status;
};

struct ILLEGAL4res {
        nfsstat4        status;
};

typedef opaque gsshandle4_t<>;

struct gss_cb_handles4 {
        rpc_gss_svc_t           gcbp_service; /* RFC 2203 */
        gsshandle4_t            gcbp_handle_from_server;
        gsshandle4_t            gcbp_handle_from_client;
};

union callback_sec_parms4 switch (uint32_t cb_secflavor) {
 case AUTH_NONE:
         void;
 case AUTH_SYS:
         authsys_parms   cbsp_sys_cred; /* RFC 5531 */
 case RPCSEC_GSS:
         gss_cb_handles4 cbsp_gss_handles;
};

struct BACKCHANNEL_CTL4args {
        uint32_t                bca_cb_program;
        callback_sec_parms4     bca_sec_parms<>;
};

struct BACKCHANNEL_CTL4res {
        nfsstat4                bcr_status;
};

enum channel_dir_from_client4 {
 CDFC4_FORE             = 0x1,
 CDFC4_BACK             = 0x2,
 CDFC4_FORE_OR_BOTH     = 0x3,
 CDFC4_BACK_OR_BOTH     = 0x7
};

struct BIND_CONN_TO_SESSION4args {
 sessionid4     bctsa_sessid;

 channel_dir_from_client4
                bctsa_dir;

 bool           bctsa_use_conn_in_rdma_mode;
};

enum channel_dir_from_server4 {
 CDFS4_FORE     = 0x1,
 CDFS4_BACK     = 0x2,
 CDFS4_BOTH     = 0x3
};

struct BIND_CONN_TO_SESSION4resok {
 sessionid4     bctsr_sessid;

 channel_dir_from_server4
                bctsr_dir;

 bool           bctsr_use_conn_in_rdma_mode;
};

union BIND_CONN_TO_SESSION4res
 switch (nfsstat4 bctsr_status) {
         case NFS4_OK:
                 BIND_CONN_TO_SESSION4resok  bctsr_resok4;
         default:
                 void;
};

const EXCHGID4_FLAG_SUPP_MOVED_REFER    = 0x00000001;
const EXCHGID4_FLAG_SUPP_MOVED_MIGR     = 0x00000002;
const EXCHGID4_FLAG_SUPP_FENCE_OPS      = 0x00000004;

const EXCHGID4_FLAG_BIND_PRINC_STATEID  = 0x00000100;

const EXCHGID4_FLAG_USE_NON_PNFS        = 0x00010000;
const EXCHGID4_FLAG_USE_PNFS_MDS        = 0x00020000;
const EXCHGID4_FLAG_USE_PNFS_DS         = 0x00040000;

const EXCHGID4_FLAG_MASK_PNFS           = 0x00070000;

const EXCHGID4_FLAG_UPD_CONFIRMED_REC_A = 0x40000000;
const EXCHGID4_FLAG_CONFIRMED_R         = 0x80000000;

struct state_protect_ops4 {
        bitmap4 spo_must_enforce;
        bitmap4 spo_must_allow;
};

struct ssv_sp_parms4 {
        state_protect_ops4      ssp_ops;
        sec_oid4                ssp_hash_algs<>;
        sec_oid4                ssp_encr_algs<>;
        uint32_t                ssp_window;
        uint32_t                ssp_num_gss_handles;
};

enum state_protect_how4 {
        SP4_NONE      = 0,
        SP4_MACH_CRED = 1,
        SP4_SSV       = 2
};

union state_protect4_a switch (state_protect_how4 spa_how) {
        case SP4_NONE:
                void;
        case SP4_MACH_CRED:
                state_protect_ops4      spa_mach_ops;
        case SP4_SSV:
                ssv_sp_parms4           spa_ssv_parms;
};

struct EXCHANGE_ID4args {
        client_owner4           eia_clientowner;
        uint32_t                eia_flags;
        state_protect4_a        eia_state_protect;
        nfs_impl_id4            eia_client_impl_id<1>;
};

struct ssv_prot_info4 {
 state_protect_ops4     spi_ops;
 uint32_t               spi_hash_alg;
 uint32_t               spi_encr_alg;
 uint32_t               spi_ssv_len;
 uint32_t               spi_window;
 gsshandle4_t           spi_handles<>;
};

union state_protect4_r switch (state_protect_how4 spr_how) {
 case SP4_NONE:
         void;
 case SP4_MACH_CRED:
         state_protect_ops4     spr_mach_ops;
 case SP4_SSV:
         ssv_prot_info4         spr_ssv_info;
};

struct EXCHANGE_ID4resok {
 clientid4        eir_clientid;
 sequenceid4      eir_sequenceid;
 uint32_t         eir_flags;
 state_protect4_r eir_state_protect;
 server_owner4    eir_server_owner;
 opaque           eir_server_scope<NFS4_OPAQUE_LIMIT>;
 nfs_impl_id4     eir_server_impl_id<1>;
};

union EXCHANGE_ID4res switch (nfsstat4 eir_status) {
 case NFS4_OK:
         EXCHANGE_ID4resok      eir_resok4;

 default:
         void;
};

struct channel_attrs4 {
        count4                  ca_headerpadsize;
        count4                  ca_maxrequestsize;
        count4                  ca_maxresponsesize;
        count4                  ca_maxresponsesize_cached;
        count4                  ca_maxoperations;
        count4                  ca_maxrequests;
        uint32_t                ca_rdma_ird<1>;
};

const CREATE_SESSION4_FLAG_PERSIST              = 0x00000001;
const CREATE_SESSION4_FLAG_CONN_BACK_CHAN       = 0x00000002;
const CREATE_SESSION4_FLAG_CONN_RDMA            = 0x00000004;

struct CREATE_SESSION4args {
        clientid4               csa_clientid;
        sequenceid4             csa_sequence;

        uint32_t                csa_flags;

        channel_attrs4          csa_fore_chan_attrs;
        channel_attrs4          csa_back_chan_attrs;

        uint32_t                csa_cb_program;
        callback_sec_parms4     csa_sec_parms<>;
};

struct CREATE_SESSION4resok {
        sessionid4              csr_sessionid;
        sequenceid4             csr_sequence;

        uint32_t                csr_flags;

        channel_attrs4          csr_fore_chan_attrs;
        channel_attrs4          csr_back_chan_attrs;
};

union CREATE_SESSION4res switch (nfsstat4 csr_status) {
 case NFS4_OK:
         CREATE_SESSION4resok   csr_resok4;
 default:
         void;
};

struct DESTROY_SESSION4args {
        sessionid4      dsa_sessionid;
};

struct DESTROY_SESSION4res {
        nfsstat4        dsr_status;
};

struct FREE_STATEID4args {
        stateid4        fsa_stateid;
};

struct FREE_STATEID4res {
        nfsstat4        fsr_status;
};


typedef nfstime4 attr_notice4;

struct GET_DIR_DELEGATION4args {
        /* CURRENT_FH: delegated directory */
        bool            gdda_signal_deleg_avail;
        bitmap4         gdda_notification_types;
        attr_notice4    gdda_child_attr_delay;
        attr_notice4    gdda_dir_attr_delay;
        bitmap4         gdda_child_attributes;
        bitmap4         gdda_dir_attributes;
};
struct GET_DIR_DELEGATION4resok {
        verifier4       gddr_cookieverf;
        /* Stateid for get_dir_delegation */
        stateid4        gddr_stateid;
        /* Which notifications can the server support? */
        bitmap4         gddr_notification;
        bitmap4         gddr_child_attributes;
        bitmap4         gddr_dir_attributes;
};

enum gddrnf4_status {
        GDD4_OK         = 0,
        GDD4_UNAVAIL    = 1
};

union GET_DIR_DELEGATION4res_non_fatal
 switch (gddrnf4_status gddrnf_status) {
         case GDD4_OK:
              GET_DIR_DELEGATION4resok      gddrnf_resok4;
         case GDD4_UNAVAIL:
          bool                gddrnf_will_signal_deleg_avail;
};

union GET_DIR_DELEGATION4res
 switch (nfsstat4 gddr_status) {
         case NFS4_OK:
          GET_DIR_DELEGATION4res_non_fatal   gddr_res_non_fatal4;
         default:
                 void;
};

struct GETDEVICEINFO4args {
        deviceid4       gdia_device_id;
        layouttype4     gdia_layout_type;
        count4          gdia_maxcount;
        bitmap4         gdia_notify_types;
};

struct GETDEVICEINFO4resok {
        device_addr4    gdir_device_addr;
        bitmap4         gdir_notification;
};

union GETDEVICEINFO4res switch (nfsstat4 gdir_status) {
 case NFS4_OK:
         GETDEVICEINFO4resok     gdir_resok4;
 case NFS4ERR_TOOSMALL:
         count4                  gdir_mincount;
 default:
         void;
};

struct GETDEVICELIST4args {
        /* CURRENT_FH: object belonging to the file system */
        layouttype4     gdla_layout_type;

        /* Number of device IDs to return */
        count4          gdla_maxdevices;

        nfs_cookie4     gdla_cookie;
        verifier4       gdla_cookieverf;
};

struct GETDEVICELIST4resok {
        nfs_cookie4             gdlr_cookie;
        verifier4               gdlr_cookieverf;
        deviceid4               gdlr_deviceid_list<>;
        bool                    gdlr_eof;
};

union GETDEVICELIST4res switch (nfsstat4 gdlr_status) {
 case NFS4_OK:
         GETDEVICELIST4resok     gdlr_resok4;
 default:
         void;
};

union newtime4 switch (bool nt_timechanged) {
 case TRUE:
         nfstime4           nt_time;
 case FALSE:
         void;
};

union newoffset4 switch (bool no_newoffset) {
 case TRUE:
         offset4           no_offset;
 case FALSE:
         void;
};

struct LAYOUTCOMMIT4args {
        /* CURRENT_FH: file */
        offset4                 loca_offset;
        length4                 loca_length;
        bool                    loca_reclaim;
        stateid4                loca_stateid;
        newoffset4              loca_last_write_offset;
        newtime4                loca_time_modify;
        layoutupdate4           loca_layoutupdate;
};
union newsize4 switch (bool ns_sizechanged) {
 case TRUE:
         length4         ns_size;
 case FALSE:
         void;
};

struct LAYOUTCOMMIT4resok {
        newsize4                locr_newsize;
};

union LAYOUTCOMMIT4res switch (nfsstat4 locr_status) {
 case NFS4_OK:
         LAYOUTCOMMIT4resok      locr_resok4;
 default:
         void;
};

struct LAYOUTGET4args {
        /* CURRENT_FH: file */
        bool                    loga_signal_layout_avail;
        layouttype4             loga_layout_type;
        layoutiomode4           loga_iomode;
        offset4                 loga_offset;
        length4                 loga_length;
        length4                 loga_minlength;
        stateid4                loga_stateid;
        count4                  loga_maxcount;
};
struct LAYOUTGET4resok {
        bool               logr_return_on_close;
        stateid4           logr_stateid;
        layout4            logr_layout<>;
};

union LAYOUTGET4res switch (nfsstat4 logr_status) {
 case NFS4_OK:
         LAYOUTGET4resok     logr_resok4;
 case NFS4ERR_LAYOUTTRYLATER:
         bool                logr_will_signal_layout_avail;
 default:
         void;
};


struct LAYOUTRETURN4args {
        /* CURRENT_FH: file */
        bool                    lora_reclaim;
        layouttype4             lora_layout_type;
        layoutiomode4           lora_iomode;
        layoutreturn4           lora_layoutreturn;
};


union layoutreturn_stateid switch (bool lrs_present) {
 case TRUE:
         stateid4                lrs_stateid;
 case FALSE:
         void;
};

union LAYOUTRETURN4res switch (nfsstat4 lorr_status) {
 case NFS4_OK:
         layoutreturn_stateid    lorr_stateid;
 default:
         void;
};

enum secinfo_style4 {
        SECINFO_STYLE4_CURRENT_FH       = 0,
        SECINFO_STYLE4_PARENT           = 1
};

/* CURRENT_FH: object or child directory */
typedef secinfo_style4 SECINFO_NO_NAME4args;

/* CURRENTFH: consumed if status is NFS4_OK */
typedef SECINFO4res SECINFO_NO_NAME4res;

struct SEQUENCE4args {
        sessionid4     sa_sessionid;
        sequenceid4    sa_sequenceid;
        slotid4        sa_slotid;
        slotid4        sa_highest_slotid;
        bool           sa_cachethis;
};

const SEQ4_STATUS_CB_PATH_DOWN                  = 0x00000001;
const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRING      = 0x00000002;
const SEQ4_STATUS_CB_GSS_CONTEXTS_EXPIRED       = 0x00000004;
const SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED     = 0x00000008;
const SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED    = 0x00000010;
const SEQ4_STATUS_ADMIN_STATE_REVOKED           = 0x00000020;
const SEQ4_STATUS_RECALLABLE_STATE_REVOKED      = 0x00000040;
const SEQ4_STATUS_LEASE_MOVED                   = 0x00000080;
const SEQ4_STATUS_RESTART_RECLAIM_NEEDED        = 0x00000100;
const SEQ4_STATUS_CB_PATH_DOWN_SESSION          = 0x00000200;
const SEQ4_STATUS_BACKCHANNEL_FAULT             = 0x00000400;
const SEQ4_STATUS_DEVID_CHANGED                 = 0x00000800;
const SEQ4_STATUS_DEVID_DELETED                 = 0x00001000;

struct SEQUENCE4resok {
        sessionid4      sr_sessionid;
        sequenceid4     sr_sequenceid;
        slotid4         sr_slotid;
        slotid4         sr_highest_slotid;
        slotid4         sr_target_highest_slotid;
        uint32_t        sr_status_flags;
};

union SEQUENCE4res switch (nfsstat4 sr_status) {
 case NFS4_OK:
         SEQUENCE4resok  sr_resok4;
 default:
         void;
};

struct ssa_digest_input4 {
        SEQUENCE4args sdi_seqargs;
};

struct SET_SSV4args {
        opaque          ssa_ssv<>;
        opaque          ssa_digest<>;
};

struct ssr_digest_input4 {
        SEQUENCE4res sdi_seqres;
};

struct SET_SSV4resok {
        opaque          ssr_digest<>;
};

union SET_SSV4res switch (nfsstat4 ssr_status) {
 case NFS4_OK:
         SET_SSV4resok   ssr_resok4;
 default:
         void;
};

struct TEST_STATEID4args {
        stateid4        ts_stateids<>;
};

struct TEST_STATEID4resok {
        nfsstat4        tsr_status_codes<>;
};

union TEST_STATEID4res switch (nfsstat4 tsr_status) {
 case NFS4_OK:
         TEST_STATEID4resok tsr_resok4;
 default:
         void;
};

union deleg_claim4 switch (open_claim_type4 dc_claim) {
/*
 * No special rights to object.  Ordinary delegation
 * request of the specified object.  Object identified
 * by filehandle.
 */
 case CLAIM_FH: /* New to NFSv4.1 */
         /* CURRENT_FH: object being delegated */
          void;

/*
 * Right to file based on a delegation granted
 * to a previous boot instance of the client.
 * File is specified by filehandle.
 */
 case CLAIM_DELEG_PREV_FH: /* New to NFSv4.1 */
         /* CURRENT_FH: object being delegated */
          void;

/*
 * Right to the file established by an open previous
 * to server reboot.  File identified by filehandle.
 * Used during server reclaim grace period.
 */
 case CLAIM_PREVIOUS:
         /* CURRENT_FH: object being reclaimed */
          open_delegation_type4   dc_delegate_type;
};

struct WANT_DELEGATION4args {
        uint32_t        wda_want;
        deleg_claim4    wda_claim;
};

union WANT_DELEGATION4res switch (nfsstat4 wdr_status) {
 case NFS4_OK:
         open_delegation4 wdr_resok4;
 default:
         void;
};

struct DESTROY_CLIENTID4args {
        clientid4       dca_clientid;
};

struct DESTROY_CLIENTID4res {
        nfsstat4        dcr_status;
};

struct RECLAIM_COMPLETE4args {
        /*
         * If rca_one_fs TRUE,
         *
         *    CURRENT_FH: object in
         *    file system for which the
         *    reclaim is complete.
         */
        bool            rca_one_fs;
};

struct RECLAIM_COMPLETE4res {
        nfsstat4        rcr_status;
};

struct COPY4args {
        /* SAVED_FH: source file */
        /* CURRENT_FH: destination file */
        stateid4        ca_src_stateid;
        stateid4        ca_dst_stateid;
        offset4         ca_src_offset;
        offset4         ca_dst_offset;
        length4         ca_count;
        bool            ca_consecutive;
        bool            ca_synchronous;
        netloc4         ca_source_server<>;
};


struct copy_requirements4 {
        bool            cr_consecutive;
        bool            cr_synchronous;
};

struct COPY4resok {
        write_response4         cr_response;
        copy_requirements4      cr_requirements;
};

union COPY4res switch (nfsstat4 cr_status) {
 case NFS4_OK:
         COPY4resok              cr_resok4;
 case NFS4ERR_OFFLOAD_NO_REQS:
         copy_requirements4      cr_requirements;
 default:
         void;
};

struct COPY_NOTIFY4args {
        /* CURRENT_FH: source file */
        stateid4        cna_src_stateid;
        netloc4         cna_destination_server;
};

struct COPY_NOTIFY4resok {
        nfstime4        cnr_lease_time;
        stateid4        cnr_stateid;
        netloc4         cnr_source_server<>;
};

union COPY_NOTIFY4res switch (nfsstat4 cnr_status) {
 case NFS4_OK:
         COPY_NOTIFY4resok       resok4;
 default:
         void;
};

struct OFFLOAD_CANCEL4args {
        /* CURRENT_FH: file to cancel */
        stateid4        oca_stateid;
};

struct OFFLOAD_CANCEL4res {
        nfsstat4        ocr_status;
};


struct OFFLOAD_STATUS4args {
        /* CURRENT_FH: destination file */
        stateid4        osa_stateid;
};

struct OFFLOAD_STATUS4resok {
        length4         osr_count;
        nfsstat4        osr_complete<1>;
};

union OFFLOAD_STATUS4res switch (nfsstat4 osr_status) {
 case NFS4_OK:
         OFFLOAD_STATUS4resok            osr_resok4;
 default:
         void;
};

struct ALLOCATE4args {
        /* CURRENT_FH: file */
        stateid4        aa_stateid;
        offset4         aa_offset;
        length4         aa_length;
};
struct ALLOCATE4res {
        nfsstat4        ar_status;
};

struct DEALLOCATE4args {
        /* CURRENT_FH: file */
        stateid4        da_stateid;
        offset4         da_offset;
        length4         da_length;
};


struct DEALLOCATE4res {
        nfsstat4        dr_status;
};
enum IO_ADVISE_type4 {
        IO_ADVISE4_NORMAL                       = 0,
        IO_ADVISE4_SEQUENTIAL                   = 1,
        IO_ADVISE4_SEQUENTIAL_BACKWARDS         = 2,
        IO_ADVISE4_RANDOM                       = 3,
        IO_ADVISE4_WILLNEED                     = 4,
        IO_ADVISE4_WILLNEED_OPPORTUNISTIC       = 5,
        IO_ADVISE4_DONTNEED                     = 6,
        IO_ADVISE4_NOREUSE                      = 7,
        IO_ADVISE4_READ                         = 8,
        IO_ADVISE4_WRITE                        = 9,
        IO_ADVISE4_INIT_PROXIMITY               = 10
};

struct IO_ADVISE4args {
        /* CURRENT_FH: file */
        stateid4        iaa_stateid;
        offset4         iaa_offset;
        length4         iaa_count;
        bitmap4         iaa_hints;
};

struct IO_ADVISE4resok {
        bitmap4 ior_hints;
};

union IO_ADVISE4res switch (nfsstat4 ior_status) {
 case NFS4_OK:
         IO_ADVISE4resok resok4;
 default:
         void;
};


struct device_error4 {
        deviceid4       de_deviceid;
        nfsstat4        de_status;
        nfs_opnum4      de_opnum;
};


struct LAYOUTERROR4args {
        /* CURRENT_FH: file */
        offset4                 lea_offset;
        length4                 lea_length;
        stateid4                lea_stateid;
        device_error4           lea_errors<>;
};

struct LAYOUTERROR4res {
        nfsstat4        ler_status;
};

struct io_info4 {
        uint64_t        ii_count;
        uint64_t        ii_bytes;
};

struct LAYOUTSTATS4args {
        /* CURRENT_FH: file */
        offset4                 lsa_offset;
        length4                 lsa_length;
        stateid4                lsa_stateid;
        io_info4                lsa_read;
        io_info4                lsa_write;
        deviceid4               lsa_deviceid;
        layoutupdate4           lsa_layoutupdate;
};

struct LAYOUTSTATS4res {
        nfsstat4        lsr_status;
};

struct READ_PLUS4args {
        /* CURRENT_FH: file */
        stateid4        rpa_stateid;
        offset4         rpa_offset;
        count4          rpa_count;
};
union read_plus_content switch (data_content4 rpc_content) {
 case NFS4_CONTENT_DATA:
         data4           rpc_data;
 case NFS4_CONTENT_HOLE:
         data_info4      rpc_hole;
 default:
         void;
};

/*
 * Allow a return of an array of contents.
 */
struct read_plus_res4 {
        bool                    rpr_eof;
        read_plus_content       rpr_contents<>;
};

union READ_PLUS4res switch (nfsstat4 rp_status) {
 case NFS4_OK:
         read_plus_res4  rp_resok4;
 default:
         void;
};

struct SEEK4args {
        /* CURRENT_FH: file */
        stateid4        sa_stateid;
        offset4         sa_offset;
        data_content4   sa_what;
};
struct seek_res4 {
        bool            sr_eof;
        offset4         sr_offset;
};
union SEEK4res switch (nfsstat4 sa_status) {
 case NFS4_OK:
         seek_res4       resok4;
 default:
         void;
};

struct WRITE_SAME4args {
        /* CURRENT_FH: file */
        stateid4        wsa_stateid;
        stable_how4     wsa_stable;
        app_data_block4 wsa_adb;
};


union WRITE_SAME4res switch (nfsstat4 wsr_status) {
 case NFS4_OK:
         write_response4         resok4;
 default:
         void;
};


/*
 * Operation arrays (the rest)
 */

union nfs_argop4 switch (nfs_opnum4 argop) {
 case OP_ACCESS:         ACCESS4args opaccess;
 case OP_CLOSE:          CLOSE4args opclose;
 case OP_COMMIT:         COMMIT4args opcommit;
 case OP_CREATE:         CREATE4args opcreate;
 case OP_DELEGPURGE:     DELEGPURGE4args opdelegpurge;
 case OP_DELEGRETURN:    DELEGRETURN4args opdelegreturn;
 case OP_GETATTR:        GETATTR4args opgetattr;
 case OP_GETFH:          void;
 case OP_LINK:           LINK4args oplink;
 case OP_LOCK:           LOCK4args oplock;
 case OP_LOCKT:          LOCKT4args oplockt;
 case OP_LOCKU:          LOCKU4args oplocku;
 case OP_LOOKUP:         LOOKUP4args oplookup;
 case OP_LOOKUPP:        void;
 case OP_NVERIFY:        NVERIFY4args opnverify;
 case OP_OPEN:           OPEN4args opopen;
 case OP_OPENATTR:       OPENATTR4args opopenattr;

 /* Not for NFSv4.1 */
 case OP_OPEN_CONFIRM:   OPEN_CONFIRM4args opopen_confirm;

 case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4args opopen_downgrade;

 case OP_PUTFH:          PUTFH4args opputfh;
 case OP_PUTPUBFH:       void;
 case OP_PUTROOTFH:      void;
 case OP_READ:           READ4args opread;
 case OP_READDIR:        READDIR4args opreaddir;
 case OP_READLINK:       void;
 case OP_REMOVE:         REMOVE4args opremove;
 case OP_RENAME:         RENAME4args oprename;

 /* Not for NFSv4.1 */
 case OP_RENEW:          RENEW4args oprenew;

 case OP_RESTOREFH:      void;
 case OP_SAVEFH:         void;
 case OP_SECINFO:        SECINFO4args opsecinfo;
 case OP_SETATTR:        SETATTR4args opsetattr;

 /* Not for NFSv4.1 */
 case OP_SETCLIENTID:    SETCLIENTID4args opsetclientid;

 /* Not for NFSv4.1 */
 case OP_SETCLIENTID_CONFIRM:
                         SETCLIENTID_CONFIRM4args
                                 opsetclientid_confirm;

 case OP_VERIFY:         VERIFY4args opverify;
 case OP_WRITE:          WRITE4args opwrite;

 /* Not for NFSv4.1 */
 case OP_RELEASE_LOCKOWNER:
                         RELEASE_LOCKOWNER4args
                                 oprelease_lockowner;

 /* Operations new to NFSv4.1 */
 case OP_BACKCHANNEL_CTL:
                         BACKCHANNEL_CTL4args opbackchannel_ctl;

 case OP_BIND_CONN_TO_SESSION:
                         BIND_CONN_TO_SESSION4args
                                 opbind_conn_to_session;

 case OP_EXCHANGE_ID:    EXCHANGE_ID4args opexchange_id;

 case OP_CREATE_SESSION: CREATE_SESSION4args opcreate_session;

 case OP_DESTROY_SESSION:
                         DESTROY_SESSION4args opdestroy_session;

 case OP_FREE_STATEID:   FREE_STATEID4args opfree_stateid;

 case OP_GET_DIR_DELEGATION:
                         GET_DIR_DELEGATION4args
                                 opget_dir_delegation;

 case OP_GETDEVICEINFO:  GETDEVICEINFO4args opgetdeviceinfo;
 case OP_GETDEVICELIST:  GETDEVICELIST4args opgetdevicelist;
 case OP_LAYOUTCOMMIT:   LAYOUTCOMMIT4args oplayoutcommit;
 case OP_LAYOUTGET:      LAYOUTGET4args oplayoutget;
 case OP_LAYOUTRETURN:   LAYOUTRETURN4args oplayoutreturn;

 case OP_SECINFO_NO_NAME:
                         SECINFO_NO_NAME4args opsecinfo_no_name;

 case OP_SEQUENCE:       SEQUENCE4args opsequence;
 case OP_SET_SSV:        SET_SSV4args opset_ssv;
 case OP_TEST_STATEID:   TEST_STATEID4args optest_stateid;

 case OP_WANT_DELEGATION:
                         WANT_DELEGATION4args opwant_delegation;

 case OP_DESTROY_CLIENTID:
                         DESTROY_CLIENTID4args
                                 opdestroy_clientid;

 case OP_RECLAIM_COMPLETE:
                         RECLAIM_COMPLETE4args
                                 opreclaim_complete;

 /* Operations new to NFSv4.2 */
 case OP_ALLOCATE:       ALLOCATE4args opallocate;
 case OP_COPY:           COPY4args opcopy;
 case OP_COPY_NOTIFY:    COPY_NOTIFY4args opoffload_notify;
 case OP_DEALLOCATE:     DEALLOCATE4args opdeallocate;
 case OP_IO_ADVISE:      IO_ADVISE4args opio_advise;
 case OP_LAYOUTERROR:    LAYOUTERROR4args oplayouterror;
 case OP_LAYOUTSTATS:    LAYOUTSTATS4args oplayoutstats;
 case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4args opoffload_cancel;
 case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4args opoffload_status;
 case OP_READ_PLUS:      READ_PLUS4args opread_plus;
 case OP_SEEK:           SEEK4args opseek;
 case OP_WRITE_SAME:     WRITE_SAME4args opwrite_same;
 case OP_CLONE:          CLONE4args opclone;

 /* Operations not new to NFSv4.1 */
 case OP_ILLEGAL:        void;
};

union nfs_resop4 switch (nfs_opnum4 resop) {
 case OP_ACCESS:         ACCESS4res opaccess;
 case OP_CLOSE:          CLOSE4res opclose;
 case OP_COMMIT:         COMMIT4res opcommit;
 case OP_CREATE:         CREATE4res opcreate;
 case OP_DELEGPURGE:     DELEGPURGE4res opdelegpurge;
 case OP_DELEGRETURN:    DELEGRETURN4res opdelegreturn;
 case OP_GETATTR:        GETATTR4res opgetattr;
 case OP_GETFH:          GETFH4res opgetfh;
 case OP_LINK:           LINK4res oplink;
 case OP_LOCK:           LOCK4res oplock;
 case OP_LOCKT:          LOCKT4res oplockt;
 case OP_LOCKU:          LOCKU4res oplocku;
 case OP_LOOKUP:         LOOKUP4res oplookup;
 case OP_LOOKUPP:        LOOKUPP4res oplookupp;
 case OP_NVERIFY:        NVERIFY4res opnverify;
 case OP_OPEN:           OPEN4res opopen;
 case OP_OPENATTR:       OPENATTR4res opopenattr;
 /* Not for NFSv4.1 */
 case OP_OPEN_CONFIRM:   OPEN_CONFIRM4res opopen_confirm;

 case OP_OPEN_DOWNGRADE: OPEN_DOWNGRADE4res opopen_downgrade;

 case OP_PUTFH:          PUTFH4res opputfh;
 case OP_PUTPUBFH:       PUTPUBFH4res opputpubfh;
 case OP_PUTROOTFH:      PUTROOTFH4res opputrootfh;
 case OP_READ:           READ4res opread;
 case OP_READDIR:        READDIR4res opreaddir;
 case OP_READLINK:       READLINK4res opreadlink;
 case OP_REMOVE:         REMOVE4res opremove;
 case OP_RENAME:         RENAME4res oprename;
 /* Not for NFSv4.1 */
 case OP_RENEW:          RENEW4res oprenew;
 case OP_RESTOREFH:      RESTOREFH4res oprestorefh;
 case OP_SAVEFH:         SAVEFH4res opsavefh;
 case OP_SECINFO:        SECINFO4res opsecinfo;
 case OP_SETATTR:        SETATTR4res opsetattr;
 /* Not for NFSv4.1 */
 case OP_SETCLIENTID:    SETCLIENTID4res opsetclientid;

 /* Not for NFSv4.1 */
 case OP_SETCLIENTID_CONFIRM:
                         SETCLIENTID_CONFIRM4res
                                 opsetclientid_confirm;
 case OP_VERIFY:         VERIFY4res opverify;
 case OP_WRITE:          WRITE4res opwrite;

 /* Not for NFSv4.1 */
 case OP_RELEASE_LOCKOWNER:
                         RELEASE_LOCKOWNER4res
                                 oprelease_lockowner;

 /* Operations new to NFSv4.1 */
 case OP_BACKCHANNEL_CTL:
                         BACKCHANNEL_CTL4res opbackchannel_ctl;

 case OP_BIND_CONN_TO_SESSION:
                         BIND_CONN_TO_SESSION4res
                                 opbind_conn_to_session;

 case OP_EXCHANGE_ID:    EXCHANGE_ID4res opexchange_id;

 case OP_CREATE_SESSION: CREATE_SESSION4res opcreate_session;

 case OP_DESTROY_SESSION:
                         DESTROY_SESSION4res opdestroy_session;

 case OP_FREE_STATEID:   FREE_STATEID4res opfree_stateid;

 case OP_GET_DIR_DELEGATION:
                         GET_DIR_DELEGATION4res
                                 opget_dir_delegation;

 case OP_GETDEVICEINFO:  GETDEVICEINFO4res opgetdeviceinfo;
 case OP_GETDEVICELIST:  GETDEVICELIST4res opgetdevicelist;
 case OP_LAYOUTCOMMIT:   LAYOUTCOMMIT4res oplayoutcommit;
 case OP_LAYOUTGET:      LAYOUTGET4res oplayoutget;
 case OP_LAYOUTRETURN:   LAYOUTRETURN4res oplayoutreturn;

 case OP_SECINFO_NO_NAME:
                         SECINFO_NO_NAME4res opsecinfo_no_name;

 case OP_SEQUENCE:       SEQUENCE4res opsequence;
 case OP_SET_SSV:        SET_SSV4res opset_ssv;
 case OP_TEST_STATEID:   TEST_STATEID4res optest_stateid;

 case OP_WANT_DELEGATION:
                         WANT_DELEGATION4res opwant_delegation;

 case OP_DESTROY_CLIENTID:
                         DESTROY_CLIENTID4res
                                 opdestroy_clientid;

 case OP_RECLAIM_COMPLETE:
                         RECLAIM_COMPLETE4res
                                 opreclaim_complete;

 /* Operations new to NFSv4.2 */
 case OP_ALLOCATE:       ALLOCATE4res opallocate;
 case OP_COPY:           COPY4res opcopy;
 case OP_COPY_NOTIFY:    COPY_NOTIFY4res opcopy_notify;
 case OP_DEALLOCATE:     DEALLOCATE4res opdeallocate;
 case OP_IO_ADVISE:      IO_ADVISE4res opio_advise;
 case OP_LAYOUTERROR:    LAYOUTERROR4res oplayouterror;
 case OP_LAYOUTSTATS:    LAYOUTSTATS4res oplayoutstats;
 case OP_OFFLOAD_CANCEL: OFFLOAD_CANCEL4res opoffload_cancel;
 case OP_OFFLOAD_STATUS: OFFLOAD_STATUS4res opoffload_status;
 case OP_READ_PLUS:      READ_PLUS4res opread_plus;
 case OP_SEEK:           SEEK4res opseek;
 case OP_WRITE_SAME:     WRITE_SAME4res opwrite_same;
 case OP_CLONE:          CLONE4res opclone;

 /* Operations not new to NFSv4.1 */
 case OP_ILLEGAL:        ILLEGAL4res opillegal;
};

struct COMPOUND4args {
        utf8str_cs       tag;
        uint32_t         minorversion;
        nfs_argop4       argarray<>;
};

struct COMPOUND4res {
        nfsstat4         status;
        utf8str_cs       tag;
        nfs_resop4       resarray<>;
};


/*
 * Remote file service routines
 */
program NFS4_PROGRAM {
        version NFS_V4 {
                void
                         NFSPROC4_NULL(void) = 0;

                COMPOUND4res
                         NFSPROC4_COMPOUND(COMPOUND4args) = 1;

        } = 4;
} = 100003;

/*
 * NFS4 callback procedure definitions and program
 */
struct CB_GETATTR4args {
        nfs_fh4 fh;
        bitmap4 attr_request;
};

struct CB_GETATTR4resok {
        fattr4  obj_attributes;
};

union CB_GETATTR4res switch (nfsstat4 status) {
 case NFS4_OK:
         CB_GETATTR4resok       resok4;
 default:
         void;
};

struct CB_RECALL4args {
        stateid4        stateid;
        bool            truncate;
        nfs_fh4         fh;
};

struct CB_RECALL4res {
        nfsstat4        status;
};

/*
 * CB_ILLEGAL: Response for illegal operation numbers
 */
struct CB_ILLEGAL4res {
        nfsstat4        status;
};

/*
 * NFSv4.1 callback arguments and results
 */

enum layoutrecall_type4 {
        LAYOUTRECALL4_FILE = LAYOUT4_RET_REC_FILE,
        LAYOUTRECALL4_FSID = LAYOUT4_RET_REC_FSID,
        LAYOUTRECALL4_ALL  = LAYOUT4_RET_REC_ALL
};

struct layoutrecall_file4 {
        nfs_fh4         lor_fh;
        offset4         lor_offset;
        length4         lor_length;
        stateid4        lor_stateid;
};

union layoutrecall4 switch (layoutrecall_type4 lor_recalltype) {
 case LAYOUTRECALL4_FILE:
         layoutrecall_file4 lor_layout;
 case LAYOUTRECALL4_FSID:
         fsid4              lor_fsid;
 case LAYOUTRECALL4_ALL:
         void;
};

struct CB_LAYOUTRECALL4args {
        layouttype4             clora_type;
        layoutiomode4           clora_iomode;
        bool                    clora_changed;
        layoutrecall4           clora_recall;
};
struct CB_LAYOUTRECALL4res {
        nfsstat4        clorr_status;
};

/*
 * Directory notification types
 */
enum notify_type4 {
        NOTIFY4_CHANGE_CHILD_ATTRS     = 0,
        NOTIFY4_CHANGE_DIR_ATTRS       = 1,
        NOTIFY4_REMOVE_ENTRY           = 2,
        NOTIFY4_ADD_ENTRY              = 3,
        NOTIFY4_RENAME_ENTRY           = 4,
        NOTIFY4_CHANGE_COOKIE_VERIFIER = 5
};

/* Changed entry information */
struct notify_entry4 {
        component4      ne_file;
        fattr4          ne_attrs;
};

/* Previous entry information */
struct prev_entry4 {
        notify_entry4   pe_prev_entry;
        /* What READDIR returned for this entry */
        nfs_cookie4     pe_prev_entry_cookie;
};

struct notify_remove4 {
        notify_entry4   nrm_old_entry;
        nfs_cookie4     nrm_old_entry_cookie;
};

struct notify_add4 {
        /*
         * During a rename, contains
         * the object that was deleted.
         */
        notify_remove4      nad_old_entry<1>;
        notify_entry4       nad_new_entry;
        /* What READDIR would have returned for this entry */
        nfs_cookie4         nad_new_entry_cookie<1>;
        prev_entry4         nad_prev_entry<1>;
        bool                nad_last_entry;
};

struct notify_attr4 {
        notify_entry4   na_changed_entry;
};

struct notify_rename4 {
        notify_remove4  nrn_old_entry;
        notify_add4     nrn_new_entry;
};

struct notify_verifier4 {
        verifier4       nv_old_cookieverf;
        verifier4       nv_new_cookieverf;
};

/*
 * Objects of type notify_<>4 and
 * notify_device_<>4 are encoded in this.
 */
typedef opaque notifylist4<>;

struct notify4 {
        /* Composed from notify_type4 or notify_deviceid_type4 */
        bitmap4         notify_mask;
        notifylist4     notify_vals;
};

struct CB_NOTIFY4args {
        stateid4    cna_stateid;
        nfs_fh4     cna_fh;
        notify4     cna_changes<>;
};

struct CB_NOTIFY4res {
        nfsstat4    cnr_status;
};

struct CB_PUSH_DELEG4args {
        nfs_fh4          cpda_fh;
        open_delegation4 cpda_delegation;

};

struct CB_PUSH_DELEG4res {
        nfsstat4 cpdr_status;
};

const RCA4_TYPE_MASK_RDATA_DLG          = 0;
const RCA4_TYPE_MASK_WDATA_DLG          = 1;
const RCA4_TYPE_MASK_DIR_DLG            = 2;
const RCA4_TYPE_MASK_FILE_LAYOUT        = 3;
const RCA4_TYPE_MASK_BLK_LAYOUT         = 4;
const RCA4_TYPE_MASK_OBJ_LAYOUT_MIN     = 8;
const RCA4_TYPE_MASK_OBJ_LAYOUT_MAX     = 9;
const RCA4_TYPE_MASK_OTHER_LAYOUT_MIN   = 12;
const RCA4_TYPE_MASK_OTHER_LAYOUT_MAX   = 15;

struct CB_RECALL_ANY4args      {
       uint32_t         craa_objects_to_keep;
       bitmap4          craa_type_mask;
};

struct CB_RECALL_ANY4res {
        nfsstat4        crar_status;
};

typedef CB_RECALL_ANY4args CB_RECALLABLE_OBJ_AVAIL4args;

struct CB_RECALLABLE_OBJ_AVAIL4res {
        nfsstat4        croa_status;
};

struct CB_RECALL_SLOT4args {
        slotid4       rsa_target_highest_slotid;
};

struct CB_RECALL_SLOT4res {
        nfsstat4   rsr_status;
};

struct referring_call4 {
        sequenceid4     rc_sequenceid;
        slotid4         rc_slotid;
};

struct referring_call_list4 {
        sessionid4      rcl_sessionid;
        referring_call4 rcl_referring_calls<>;
};

struct CB_SEQUENCE4args {
        sessionid4           csa_sessionid;
        sequenceid4          csa_sequenceid;
        slotid4              csa_slotid;
        slotid4              csa_highest_slotid;
        bool                 csa_cachethis;
        referring_call_list4 csa_referring_call_lists<>;
};

struct CB_SEQUENCE4resok {
        sessionid4         csr_sessionid;
        sequenceid4        csr_sequenceid;
        slotid4            csr_slotid;
        slotid4            csr_highest_slotid;
        slotid4            csr_target_highest_slotid;
};

union CB_SEQUENCE4res switch (nfsstat4 csr_status) {
 case NFS4_OK:
         CB_SEQUENCE4resok   csr_resok4;
 default:
         void;
};

struct CB_WANTS_CANCELLED4args {
        bool cwca_contended_wants_cancelled;
        bool cwca_resourced_wants_cancelled;
};

struct CB_WANTS_CANCELLED4res {
        nfsstat4        cwcr_status;
};

struct CB_NOTIFY_LOCK4args {
    nfs_fh4     cnla_fh;
    lock_owner4 cnla_lock_owner;
};

struct CB_NOTIFY_LOCK4res {
        nfsstat4        cnlr_status;
};

/*
 * Device notification types
 */
enum notify_deviceid_type4 {
        NOTIFY_DEVICEID4_CHANGE = 1,
        NOTIFY_DEVICEID4_DELETE = 2
};

/* For NOTIFY4_DEVICEID4_DELETE */
struct notify_deviceid_delete4 {
        layouttype4     ndd_layouttype;
        deviceid4       ndd_deviceid;
};

/* For NOTIFY4_DEVICEID4_CHANGE */
struct notify_deviceid_change4 {
        layouttype4     ndc_layouttype;
        deviceid4       ndc_deviceid;
        bool            ndc_immediate;
};

struct CB_NOTIFY_DEVICEID4args {
        notify4 cnda_changes<>;
};

struct CB_NOTIFY_DEVICEID4res {
        nfsstat4        cndr_status;
};

union offload_info4 switch (nfsstat4 coa_status) {
 case NFS4_OK:
         write_response4 coa_resok4;
 default:
         length4         coa_bytes_copied;
};
struct CB_OFFLOAD4args {
        nfs_fh4         coa_fh;
        stateid4        coa_stateid;
        offload_info4   coa_offload_info;
};
struct CB_OFFLOAD4res {
        nfsstat4        cor_status;
};
/*
 * Various definitions for CB_COMPOUND
 */
%
enum nfs_cb_opnum4 {
        OP_CB_GETATTR                   = 3,
        OP_CB_RECALL                    = 4,
%/* Callback operations new to NFSv4.1 */
        OP_CB_LAYOUTRECALL              = 5,
        OP_CB_NOTIFY                    = 6,
        OP_CB_PUSH_DELEG                = 7,
        OP_CB_RECALL_ANY                = 8,
        OP_CB_RECALLABLE_OBJ_AVAIL      = 9,
        OP_CB_RECALL_SLOT               = 10,
        OP_CB_SEQUENCE                  = 11,
        OP_CB_WANTS_CANCELLED           = 12,
        OP_CB_NOTIFY_LOCK               = 13,
        OP_CB_NOTIFY_DEVICEID           = 14,
%/* Callback operations new to NFSv4.2 */
        OP_CB_OFFLOAD                   = 15,

        OP_CB_ILLEGAL                   = 10044
};

union nfs_cb_argop4 switch (nfs_cb_opnum4 argop) {
 case OP_CB_GETATTR:
      CB_GETATTR4args           opcbgetattr;

 /* New NFSv4.1 operations */
 case OP_CB_RECALL:
      CB_RECALL4args            opcbrecall;
 case OP_CB_LAYOUTRECALL:
      CB_LAYOUTRECALL4args      opcblayoutrecall;
 case OP_CB_NOTIFY:
      CB_NOTIFY4args            opcbnotify;
 case OP_CB_PUSH_DELEG:
      CB_PUSH_DELEG4args        opcbpush_deleg;
 case OP_CB_RECALL_ANY:
      CB_RECALL_ANY4args        opcbrecall_any;
 case OP_CB_RECALLABLE_OBJ_AVAIL:
      CB_RECALLABLE_OBJ_AVAIL4args opcbrecallable_obj_avail;
 case OP_CB_RECALL_SLOT:
      CB_RECALL_SLOT4args       opcbrecall_slot;
 case OP_CB_SEQUENCE:
      CB_SEQUENCE4args          opcbsequence;
 case OP_CB_WANTS_CANCELLED:
      CB_WANTS_CANCELLED4args   opcbwants_cancelled;
 case OP_CB_NOTIFY_LOCK:
      CB_NOTIFY_LOCK4args       opcbnotify_lock;
 case OP_CB_NOTIFY_DEVICEID:
      CB_NOTIFY_DEVICEID4args   opcbnotify_deviceid;

 /* New NFSv4.2 operations */
 case OP_CB_OFFLOAD:
      CB_OFFLOAD4args           opcboffload;

 case OP_CB_ILLEGAL:            void;
};

union nfs_cb_resop4 switch (nfs_cb_opnum4 resop) {
 case OP_CB_GETATTR:    CB_GETATTR4res  opcbgetattr;
 case OP_CB_RECALL:     CB_RECALL4res   opcbrecall;

 /* New NFSv4.1 operations */
 case OP_CB_LAYOUTRECALL:
                        CB_LAYOUTRECALL4res
                                        opcblayoutrecall;

 case OP_CB_NOTIFY:     CB_NOTIFY4res   opcbnotify;

 case OP_CB_PUSH_DELEG: CB_PUSH_DELEG4res
                                        opcbpush_deleg;

 case OP_CB_RECALL_ANY: CB_RECALL_ANY4res
                                        opcbrecall_any;

 case OP_CB_RECALLABLE_OBJ_AVAIL:
                        CB_RECALLABLE_OBJ_AVAIL4res
                                opcbrecallable_obj_avail;

 case OP_CB_RECALL_SLOT:
                        CB_RECALL_SLOT4res
                                        opcbrecall_slot;

 case OP_CB_SEQUENCE:   CB_SEQUENCE4res opcbsequence;

 case OP_CB_WANTS_CANCELLED:
                        CB_WANTS_CANCELLED4res
                                opcbwants_cancelled;

 case OP_CB_NOTIFY_LOCK:
                        CB_NOTIFY_LOCK4res
                                        opcbnotify_lock;

 case OP_CB_NOTIFY_DEVICEID:
                        CB_NOTIFY_DEVICEID4res
                                        opcbnotify_deviceid;

 /* New NFSv4.2 operations */
 case OP_CB_OFFLOAD:    CB_OFFLOAD4res  opcboffload;

 /* Not new operation */
 case OP_CB_ILLEGAL:    CB_ILLEGAL4res  opcbillegal;
};


struct CB_COMPOUND4args {
        utf8str_cs      tag;
        uint32_t        minorversion;
        uint32_t        callback_ident;
        nfs_cb_argop4   argarray<>;
};

struct CB_COMPOUND4res {
        nfsstat4 status;
        utf8str_cs      tag;
        nfs_cb_resop4   resarray<>;
};



/*
 * Program number is in the transient range, since the client
 * will assign the exact transient program number and provide
 * that to the server via the CREATE_SESSION or
 * BACKCHANNEL_CTL operations.
 */
program NFS4_CALLBACK {
        version NFS_CB {
                void
                        CB_NULL(void) = 0;
                CB_COMPOUND4res
                        CB_COMPOUND(CB_COMPOUND4args) = 1;
        } = 1;
} = 0x40000000;
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _NFS_ACL_H_RPCGEN
#define	_NFS_ACL_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

#define	NFS_ACL_MAX_ENTRIES 1024

typedef int uid;

typedef u_short o_mode;

struct aclent {
	int type;
	uid id;
	o_mode perm;
};
typedef struct aclent aclent;
#define	NA_USER_OBJ 0x1
#define	NA_USER 0x2
#define	NA_GROUP_OBJ 0x4
#define	NA_GROUP 0x8
#define	NA_CLASS_OBJ 0x10
#define	NA_OTHER_OBJ 0x20
#define	NA_ACL_DEFAULT 0x1000
#define	NA_READ 0x4
#define	NA_WRITE 0x2
#define	NA_EXEC 0x1

struct secattr {
	u_int mask;
	int aclcnt;
	struct {
		u_int aclent_len;
		aclent *aclent_val;
	} aclent;
	int dfaclcnt;
	struct {
		u_int dfaclent_len;
		aclent *dfaclent_val;
	} dfaclent;
};
typedef struct secattr secattr;
#define	NA_ACL 0x1
#define	NA_ACLCNT 0x2
#define	NA_DFACL 0x4
#define	NA_DFACLCNT 0x8

struct GETACL2args {
	fhandle_t fh;
	u_int mask;
};
typedef struct GETACL2args GETACL2args;

struct GETACL2resok {
	struct nfsfattr attr;
	secattr acl;
};
typedef struct GETACL2resok GETACL2resok;

struct GETACL2res {
	nfsstat status;
	union {
		GETACL2resok resok;
	} GETACL2res_u;
};
typedef struct GETACL2res GETACL2res;

struct SETACL2args {
	fhandle_t fh;
	secattr acl;
};
typedef struct SETACL2args SETACL2args;

struct SETACL2resok {
	struct nfsfattr attr;
};
typedef struct SETACL2resok SETACL2resok;

struct SETACL2res {
	nfsstat status;
	union {
		SETACL2resok resok;
	} SETACL2res_u;
};
typedef struct SETACL2res SETACL2res;

struct GETATTR2args {
	fhandle_t fh;
};
typedef struct GETATTR2args GETATTR2args;

struct GETATTR2resok {
	struct nfsfattr attr;
};
typedef struct GETATTR2resok GETATTR2resok;

struct GETATTR2res {
	nfsstat status;
	union {
		GETATTR2resok resok;
	} GETATTR2res_u;
};
typedef struct GETATTR2res GETATTR2res;

struct ACCESS2args {
	fhandle_t fh;
	uint32 access;
};
typedef struct ACCESS2args ACCESS2args;
#define	ACCESS2_READ 0x1
#define	ACCESS2_LOOKUP 0x2
#define	ACCESS2_MODIFY 0x4
#define	ACCESS2_EXTEND 0x8
#define	ACCESS2_DELETE 0x10
#define	ACCESS2_EXECUTE 0x20

struct ACCESS2resok {
	struct nfsfattr attr;
	uint32 access;
};
typedef struct ACCESS2resok ACCESS2resok;

struct ACCESS2res {
	nfsstat status;
	union {
		ACCESS2resok resok;
	} ACCESS2res_u;
};
typedef struct ACCESS2res ACCESS2res;

struct GETXATTRDIR2args {
	fhandle_t fh;
	bool_t create;
};
typedef struct GETXATTRDIR2args GETXATTRDIR2args;

struct GETXATTRDIR2resok {
	fhandle_t fh;
	struct nfsfattr attr;
};
typedef struct GETXATTRDIR2resok GETXATTRDIR2resok;

struct GETXATTRDIR2res {
	nfsstat status;
	union {
		GETXATTRDIR2resok resok;
	} GETXATTRDIR2res_u;
};
typedef struct GETXATTRDIR2res GETXATTRDIR2res;

struct GETACL3args {
	nfs_fh3 fh;
	u_int mask;
};
typedef struct GETACL3args GETACL3args;

struct GETACL3resok {
	post_op_attr attr;
	secattr acl;
};
typedef struct GETACL3resok GETACL3resok;

struct GETACL3resfail {
	post_op_attr attr;
};
typedef struct GETACL3resfail GETACL3resfail;

struct GETACL3res {
	nfsstat3 status;
	union {
		GETACL3resok resok;
		GETACL3resfail resfail;
	} GETACL3res_u;
};
typedef struct GETACL3res GETACL3res;

struct SETACL3args {
	nfs_fh3 fh;
	secattr acl;
};
typedef struct SETACL3args SETACL3args;

struct SETACL3resok {
	post_op_attr attr;
};
typedef struct SETACL3resok SETACL3resok;

struct SETACL3resfail {
	post_op_attr attr;
};
typedef struct SETACL3resfail SETACL3resfail;

struct SETACL3res {
	nfsstat3 status;
	union {
		SETACL3resok resok;
		SETACL3resfail resfail;
	} SETACL3res_u;
};
typedef struct SETACL3res SETACL3res;

struct GETXATTRDIR3args {
	nfs_fh3 fh;
	bool_t create;
};
typedef struct GETXATTRDIR3args GETXATTRDIR3args;

struct GETXATTRDIR3resok {
	nfs_fh3 fh;
	post_op_attr attr;
};
typedef struct GETXATTRDIR3resok GETXATTRDIR3resok;

struct GETXATTRDIR3res {
	nfsstat3 status;
	union {
		GETXATTRDIR3resok resok;
	} GETXATTRDIR3res_u;
};
typedef struct GETXATTRDIR3res GETXATTRDIR3res;

struct GETACL4args {
	nfs_fh4 fh;
	u_int mask;
};
typedef struct GETACL4args GETACL4args;

struct GETACL4resok {
	post_op_attr attr;
	secattr acl;
};
typedef struct GETACL4resok GETACL4resok;

struct GETACL4resfail {
	post_op_attr attr;
};
typedef struct GETACL4resfail GETACL4resfail;

struct GETACL4res {
	nfsstat3 status;
	union {
		GETACL4resok resok;
		GETACL4resfail resfail;
	} GETACL4res_u;
};
typedef struct GETACL4res GETACL4res;

struct SETACL4args {
	nfs_fh4 fh;
	secattr acl;
};
typedef struct SETACL4args SETACL4args;

struct SETACL4resok {
	post_op_attr attr;
};
typedef struct SETACL4resok SETACL4resok;

struct SETACL4resfail {
	post_op_attr attr;
};
typedef struct SETACL4resfail SETACL4resfail;

struct SETACL4res {
	nfsstat3 status;
	union {
		SETACL4resok resok;
		SETACL4resfail resfail;
	} SETACL4res_u;
};
typedef struct SETACL4res SETACL4res;
#define	NFS_ACL_PORT 2049

#define	NFS_ACL_PROGRAM	100227
#define	NFS_ACL_V2	2

#if defined(__STDC__) || defined(__cplusplus)
#define	ACLPROC2_NULL	0
extern  void * aclproc2_null_2(void *, CLIENT *);
extern  void * aclproc2_null_2_svc(void *, struct svc_req *);
#define	ACLPROC2_GETACL	1
extern  GETACL2res * aclproc2_getacl_2(GETACL2args *, CLIENT *);
extern  GETACL2res * aclproc2_getacl_2_svc(GETACL2args *, struct svc_req *);
#define	ACLPROC2_SETACL	2
extern  SETACL2res * aclproc2_setacl_2(SETACL2args *, CLIENT *);
extern  SETACL2res * aclproc2_setacl_2_svc(SETACL2args *, struct svc_req *);
#define	ACLPROC2_GETATTR	3
extern  GETATTR2res * aclproc2_getattr_2(GETATTR2args *, CLIENT *);
extern  GETATTR2res * aclproc2_getattr_2_svc(GETATTR2args *, struct svc_req *);
#define	ACLPROC2_ACCESS	4
extern  ACCESS2res * aclproc2_access_2(ACCESS2args *, CLIENT *);
extern  ACCESS2res * aclproc2_access_2_svc(ACCESS2args *, struct svc_req *);
#define	ACLPROC2_GETXATTRDIR	5
extern  GETXATTRDIR2res * aclproc2_getxattrdir_2(GETXATTRDIR2args *, CLIENT *);
extern  GETXATTRDIR2res * aclproc2_getxattrdir_2_svc(GETXATTRDIR2args *, struct svc_req *);
extern int nfs_acl_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	ACLPROC2_NULL	0
extern  void * aclproc2_null_2();
extern  void * aclproc2_null_2_svc();
#define	ACLPROC2_GETACL	1
extern  GETACL2res * aclproc2_getacl_2();
extern  GETACL2res * aclproc2_getacl_2_svc();
#define	ACLPROC2_SETACL	2
extern  SETACL2res * aclproc2_setacl_2();
extern  SETACL2res * aclproc2_setacl_2_svc();
#define	ACLPROC2_GETATTR	3
extern  GETATTR2res * aclproc2_getattr_2();
extern  GETATTR2res * aclproc2_getattr_2_svc();
#define	ACLPROC2_ACCESS	4
extern  ACCESS2res * aclproc2_access_2();
extern  ACCESS2res * aclproc2_access_2_svc();
#define	ACLPROC2_GETXATTRDIR	5
extern  GETXATTRDIR2res * aclproc2_getxattrdir_2();
extern  GETXATTRDIR2res * aclproc2_getxattrdir_2_svc();
extern int nfs_acl_program_2_freeresult();
#endif /* K&R C */
#define	NFS_ACL_V3	3

#if defined(__STDC__) || defined(__cplusplus)
#define	ACLPROC3_NULL	0
extern  void * aclproc3_null_3(void *, CLIENT *);
extern  void * aclproc3_null_3_svc(void *, struct svc_req *);
#define	ACLPROC3_GETACL	1
extern  GETACL3res * aclproc3_getacl_3(GETACL3args *, CLIENT *);
extern  GETACL3res * aclproc3_getacl_3_svc(GETACL3args *, struct svc_req *);
#define	ACLPROC3_SETACL	2
extern  SETACL3res * aclproc3_setacl_3(SETACL3args *, CLIENT *);
extern  SETACL3res * aclproc3_setacl_3_svc(SETACL3args *, struct svc_req *);
#define	ACLPROC3_GETXATTRDIR	3
extern  GETXATTRDIR3res * aclproc3_getxattrdir_3(GETXATTRDIR3args *, CLIENT *);
extern  GETXATTRDIR3res * aclproc3_getxattrdir_3_svc(GETXATTRDIR3args *, struct svc_req *);
extern int nfs_acl_program_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	ACLPROC3_NULL	0
extern  void * aclproc3_null_3();
extern  void * aclproc3_null_3_svc();
#define	ACLPROC3_GETACL	1
extern  GETACL3res * aclproc3_getacl_3();
extern  GETACL3res * aclproc3_getacl_3_svc();
#define	ACLPROC3_SETACL	2
extern  SETACL3res * aclproc3_setacl_3();
extern  SETACL3res * aclproc3_setacl_3_svc();
#define	ACLPROC3_GETXATTRDIR	3
extern  GETXATTRDIR3res * aclproc3_getxattrdir_3();
extern  GETXATTRDIR3res * aclproc3_getxattrdir_3_svc();
extern int nfs_acl_program_3_freeresult();
#endif /* K&R C */
#define	NFS_ACL_V4	4

#if defined(__STDC__) || defined(__cplusplus)
#define	ACLPROC4_NULL	0
extern  void * aclproc4_null_4(void *, CLIENT *);
extern  void * aclproc4_null_4_svc(void *, struct svc_req *);
#define	ACLPROC4_GETACL	1
extern  GETACL4res * aclproc4_getacl_4(GETACL4args *, CLIENT *);
extern  GETACL4res * aclproc4_getacl_4_svc(GETACL4args *, struct svc_req *);
#define	ACLPROC4_SETACL	2
extern  SETACL4res * aclproc4_setacl_4(SETACL4args *, CLIENT *);
extern  SETACL4res * aclproc4_setacl_4_svc(SETACL4args *, struct svc_req *);
extern int nfs_acl_program_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	ACLPROC4_NULL	0
extern  void * aclproc4_null_4();
extern  void * aclproc4_null_4_svc();
#define	ACLPROC4_GETACL	1
extern  GETACL4res * aclproc4_getacl_4();
extern  GETACL4res * aclproc4_getacl_4_svc();
#define	ACLPROC4_SETACL	2
extern  SETACL4res * aclproc4_setacl_4();
extern  SETACL4res * aclproc4_setacl_4_svc();
extern int nfs_acl_program_4_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_uid(XDR *, uid*);
extern  bool_t xdr_o_mode(XDR *, o_mode*);
extern  bool_t xdr_aclent(XDR *, aclent*);
extern  bool_t xdr_secattr(XDR *, secattr*);
extern  bool_t xdr_GETACL2args(XDR *, GETACL2args*);
extern  bool_t xdr_GETACL2resok(XDR *, GETACL2resok*);
extern  bool_t xdr_GETACL2res(XDR *, GETACL2res*);
extern  bool_t xdr_SETACL2args(XDR *, SETACL2args*);
extern  bool_t xdr_SETACL2resok(XDR *, SETACL2resok*);
extern  bool_t xdr_SETACL2res(XDR *, SETACL2res*);
extern  bool_t xdr_GETATTR2args(XDR *, GETATTR2args*);
extern  bool_t xdr_GETATTR2resok(XDR *, GETATTR2resok*);
extern  bool_t xdr_GETATTR2res(XDR *, GETATTR2res*);
extern  bool_t xdr_ACCESS2args(XDR *, ACCESS2args*);
extern  bool_t xdr_ACCESS2resok(XDR *, ACCESS2resok*);
extern  bool_t xdr_ACCESS2res(XDR *, ACCESS2res*);
extern  bool_t xdr_GETXATTRDIR2args(XDR *, GETXATTRDIR2args*);
extern  bool_t xdr_GETXATTRDIR2resok(XDR *, GETXATTRDIR2resok*);
extern  bool_t xdr_GETXATTRDIR2res(XDR *, GETXATTRDIR2res*);
extern  bool_t xdr_GETACL3args(XDR *, GETACL3args*);
extern  bool_t xdr_GETACL3resok(XDR *, GETACL3resok*);
extern  bool_t xdr_GETACL3resfail(XDR *, GETACL3resfail*);
extern  bool_t xdr_GETACL3res(XDR *, GETACL3res*);
extern  bool_t xdr_SETACL3args(XDR *, SETACL3args*);
extern  bool_t xdr_SETACL3resok(XDR *, SETACL3resok*);
extern  bool_t xdr_SETACL3resfail(XDR *, SETACL3resfail*);
extern  bool_t xdr_SETACL3res(XDR *, SETACL3res*);
extern  bool_t xdr_GETXATTRDIR3args(XDR *, GETXATTRDIR3args*);
extern  bool_t xdr_GETXATTRDIR3resok(XDR *, GETXATTRDIR3resok*);
extern  bool_t xdr_GETXATTRDIR3res(XDR *, GETXATTRDIR3res*);
extern  bool_t xdr_GETACL4args(XDR *, GETACL4args*);
extern  bool_t xdr_GETACL4resok(XDR *, GETACL4resok*);
extern  bool_t xdr_GETACL4resfail(XDR *, GETACL4resfail*);
extern  bool_t xdr_GETACL4res(XDR *, GETACL4res*);
extern  bool_t xdr_SETACL4args(XDR *, SETACL4args*);
extern  bool_t xdr_SETACL4resok(XDR *, SETACL4resok*);
extern  bool_t xdr_SETACL4resfail(XDR *, SETACL4resfail*);
extern  bool_t xdr_SETACL4res(XDR *, SETACL4res*);

#else /* K&R C */
extern bool_t xdr_uid();
extern bool_t xdr_o_mode();
extern bool_t xdr_aclent();
extern bool_t xdr_secattr();
extern bool_t xdr_GETACL2args();
extern bool_t xdr_GETACL2resok();
extern bool_t xdr_GETACL2res();
extern bool_t xdr_SETACL2args();
extern bool_t xdr_SETACL2resok();
extern bool_t xdr_SETACL2res();
extern bool_t xdr_GETATTR2args();
extern bool_t xdr_GETATTR2resok();
extern bool_t xdr_GETATTR2res();
extern bool_t xdr_ACCESS2args();
extern bool_t xdr_ACCESS2resok();
extern bool_t xdr_ACCESS2res();
extern bool_t xdr_GETXATTRDIR2args();
extern bool_t xdr_GETXATTRDIR2resok();
extern bool_t xdr_GETXATTRDIR2res();
extern bool_t xdr_GETACL3args();
extern bool_t xdr_GETACL3resok();
extern bool_t xdr_GETACL3resfail();
extern bool_t xdr_GETACL3res();
extern bool_t xdr_SETACL3args();
extern bool_t xdr_SETACL3resok();
extern bool_t xdr_SETACL3resfail();
extern bool_t xdr_SETACL3res();
extern bool_t xdr_GETXATTRDIR3args();
extern bool_t xdr_GETXATTRDIR3resok();
extern bool_t xdr_GETXATTRDIR3res();
extern bool_t xdr_GETACL4args();
extern bool_t xdr_GETACL4resok();
extern bool_t xdr_GETACL4resfail();
extern bool_t xdr_GETACL4res();
extern bool_t xdr_SETACL4args();
extern bool_t xdr_SETACL4resok();
extern bool_t xdr_SETACL4resfail();
extern bool_t xdr_SETACL4res();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_NFS_ACL_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *	Copyright 1994,2001-2003 Sun Microsystems, Inc.
 *	All rights reserved.
 *	Use is subject to license terms.
 */

const NFS_ACL_MAX_ENTRIES = 1024;

typedef int uid;
typedef unsigned short o_mode;

/*
 * This is the format of an ACL which is passed over the network.
 */
struct aclent {
	int type;
	uid id;
	o_mode perm;
};

/*
 * The values for the type element of the aclent structure.
 */
const NA_USER_OBJ = 0x1;	/* object owner */
const NA_USER = 0x2;		/* additional users */
const NA_GROUP_OBJ = 0x4;	/* owning group of the object */
const NA_GROUP = 0x8;		/* additional groups */
const NA_CLASS_OBJ = 0x10;	/* file group class and mask entry */
const NA_OTHER_OBJ = 0x20;	/* other entry for the object */
const NA_ACL_DEFAULT = 0x1000;	/* default flag */

/*
 * The bit field values for the perm element of the aclent
 * structure.  The three values can be combined to form any
 * of the 8 combinations.
 */
const NA_READ = 0x4;		/* read permission */
const NA_WRITE = 0x2;		/* write permission */
const NA_EXEC = 0x1;		/* exec permission */

/*
 * This is the structure which contains the ACL entries for a
 * particular entity.  It contains the ACL entries which apply
 * to this object plus any default ACL entries which are
 * inherited by its children.
 *
 * The values for the mask field are defined below.
 */
struct secattr {
	u_int mask;
	int aclcnt;
	aclent aclent<NFS_ACL_MAX_ENTRIES>;
	int dfaclcnt;
	aclent dfaclent<NFS_ACL_MAX_ENTRIES>;
};

/*
 * The values for the mask element of the secattr struct as well
 * as for the mask element in the arguments in the GETACL2 and
 * GETACL3 procedures.
 */
const NA_ACL = 0x1;		/* aclent contains a valid list */
const NA_ACLCNT = 0x2;		/* the number of entries in the aclent list */
const NA_DFACL = 0x4;		/* dfaclent contains a valid list */
const NA_DFACLCNT = 0x8;	/* the number of entries in the dfaclent list */

/*
 * This the definition for the GETACL procedure which applies to
 * NFS Version 2.
 */
struct GETACL2args {
	fhandle_t fh;
	u_int mask;
};

struct GETACL2resok {
	struct nfsfattr attr;
	secattr acl;
};

union GETACL2res switch (enum nfsstat status) {
case ACL2_OK:
	GETACL2resok resok;
default:
	void;
};

/*
 * This is the definition for the SETACL procedure which applies
 * NFS Version 2.
 */
struct SETACL2args {
	fhandle_t fh;
	secattr acl;
};

struct SETACL2resok {
	struct nfsfattr attr;
};

union SETACL2res switch (enum nfsstat status) {
case ACL2_OK:
	SETACL2resok resok;
default:
	void;
};

/*
 * This is the definition for the GETATTR procedure which can be
 * used as an alternative to the GETATTR in NFS Version 2.  The
 * main difference between this GETATTR and the NFS GETATTR is
 * that this GETATTR returns the mode of the file without it being
 * changed to match the min/max permissions mapping that the NFS
 * Version 2 server does.
 */
struct GETATTR2args {
	fhandle_t fh;
};

struct GETATTR2resok {
	struct nfsfattr attr;
};

union GETATTR2res switch (enum nfsstat status) {
case ACL2_OK:
	GETATTR2resok resok;
default:
	void;
};

/*
 * This is the definition for the ACCESS procedure which applies
 * to NFS Version 2.
 */
struct ACCESS2args {
	fhandle_t fh;
	uint32 access;
};

/*
 * The following access permissions may be requested:
 */
const ACCESS2_READ = 0x1;	/* read data or readdir a directory */
const ACCESS2_LOOKUP = 0x2;	/* lookup a name in a directory */
const ACCESS2_MODIFY = 0x4;	/* rewrite existing file data or */
				/* modify existing directory entries */
const ACCESS2_EXTEND = 0x8;	/* write new data or add directory entries */
const ACCESS2_DELETE = 0x10;	/* delete existing directory entry */
const ACCESS2_EXECUTE = 0x20;	/* execute file (no meaning for a directory) */

struct ACCESS2resok {
	struct nfsfattr attr;
	uint32 access;
};

union ACCESS2res switch (enum nfsstat status) {
case ACL2_OK:
	ACCESS2resok resok;
default:
	void;
};

/*
 * This is the definition for the GETXATTRDIR procedure which applies
 * to NFS Version 2 files.
 */
struct GETXATTRDIR2args {
	fhandle_t fh;
	bool create;
};

struct GETXATTRDIR2resok {
	fhandle_t fh;
	struct nfsfattr attr;
};

union GETXATTRDIR2res switch (enum nfsstat status) {
case ACL2_OK:
	GETXATTRDIR2resok resok;
default:
	void;
};

/*
 * This is the definition for the GETACL procedure which applies
 * to NFS Version 3 files.
 */
struct GETACL3args {
	nfs_fh3 fh;
	u_int mask;
};

struct GETACL3resok {
	post_op_attr attr;
	secattr acl;
};

struct GETACL3resfail {
	post_op_attr attr;
};

union GETACL3res switch (nfsstat3 status) {
case ACL3_OK:
	GETACL3resok resok;
default:
	GETACL3resfail resfail;
};

/*
 * This is the definition for the SETACL procedure which applies
 * to NFS Version 3 files.
 */
struct SETACL3args {
	nfs_fh3 fh;
	secattr acl;
};

struct SETACL3resok {
	post_op_attr attr;
};

struct SETACL3resfail {
	post_op_attr attr;
};

union SETACL3res switch (nfsstat3 status) {
case ACL3_OK:
	SETACL3resok resok;
default:
	SETACL3resfail resfail;
};

/*
 * This is the definition for the GETXATTRDIR procedure which applies
 * to NFS Version 3 files.
 */
struct GETXATTRDIR3args {
	nfs_fh3 fh;
	bool create;
};

struct GETXATTRDIR3resok {
	nfs_fh3 fh;
	post_op_attr attr;
};

union GETXATTRDIR3res switch (nfsstat3 status) {
case ACL3_OK:
	GETXATTRDIR3resok resok;
default:
	void;
};

/*
 * XXX {
 * This is a transitional interface to enable Solaris NFSv4
 * clients to manipulate ACLs on Solaris servers until the
 * spec is complete enough to implement this inside the
 * NFSv4 protocol itself.  NFSv4 does handle extended
 * attributes in-band.
 */

/*
 * This is the definition for the GETACL procedure which applies
 * to NFS Version 4 files.
 */
struct GETACL4args {
	nfs_fh4 fh;
	u_int mask;
};

struct GETACL4resok {
	post_op_attr attr;
	secattr acl;
};

struct GETACL4resfail {
	post_op_attr attr;
};

union GETACL4res switch (nfsstat3 status) {
case ACL4_OK:
	GETACL4resok resok;
default:
	GETACL4resfail resfail;
};

/*
 * This is the definition for the SETACL procedure which applies
 * to NFS Version 4 files.
 */
struct SETACL4args {
	nfs_fh4 fh;
	secattr acl;
};

struct SETACL4resok {
	post_op_attr attr;
};

struct SETACL4resfail {
	post_op_attr attr;
};

union SETACL4res switch (nfsstat3 status) {
case ACL4_OK:
	SETACL4resok resok;
default:
	SETACL4resfail resfail;
};

/* XXX } */

/*
 * Share the port with the NFS service.  NFS has to be running
 * in order for this service to be useful anyway.
 */
const NFS_ACL_PORT = 2049;

/*
 * This is the definition for the ACL network protocol which is used
 * to provide support for Solaris ACLs for files which are accessed
 * via NFS Version 2 and NFS Version 3.
 */
program NFS_ACL_PROGRAM {
	version NFS_ACL_V2 {
		void
		 ACLPROC2_NULL(void) = 0;
		GETACL2res
		 ACLPROC2_GETACL(GETACL2args) = 1;
		SETACL2res
		 ACLPROC2_SETACL(SETACL2args) = 2;
		GETATTR2res
		 ACLPROC2_GETATTR(GETATTR2args) = 3;
		ACCESS2res
		 ACLPROC2_ACCESS(ACCESS2args) = 4;
		GETXATTRDIR2res
		 ACLPROC2_GETXATTRDIR(GETXATTRDIR2args) = 5;
	} = 2;
	version NFS_ACL_V3 {
		void
		 ACLPROC3_NULL(void) = 0;
		GETACL3res
		 ACLPROC3_GETACL(GETACL3args) = 1;
		SETACL3res
		 ACLPROC3_SETACL(SETACL3args) = 2;
		GETXATTRDIR3res
		 ACLPROC3_GETXATTRDIR(GETXATTRDIR3args) = 3;
	} = 3;
	version NFS_ACL_V4 {
		void
		 ACLPROC4_NULL(void) = 0;
		GETACL4res
		 ACLPROC4_GETACL(GETACL4args) = 1;
		SETACL4res
		 ACLPROC4_SETACL(SETACL4args) = 2;
	} = 4;
} = 100227;
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _NFS_PROT_H_RPCGEN
#define	_NFS_PROT_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Definitions for uint64, int64, uint32, and int32
 */
#include <rpc/rpc_sztypes.h>

#define	NFS_PORT 2049
#define	NFS_MAXDATA 8192
#define	NFS_MAXPATHLEN 1024
#define	NFS_MAXNAMLEN 255
#define	NFS_FHSIZE 32
#define	NFS_COOKIESIZE 4
#define	NFS_FIFO_DEV -1
#define	NFSMODE_FMT 0170000
#define	NFSMODE_DIR 0040000
#define	NFSMODE_CHR 0020000
#define	NFSMODE_BLK 0060000
#define	NFSMODE_REG 0100000
#define	NFSMODE_LNK 0120000
#define	NFSMODE_SOCK 0140000
#define	NFSMODE_FIFO 0010000

enum nfsstat {
	NFS_OK = 0,
	NFSERR_PERM = 1,
	NFSERR_NOENT = 2,
	NFSERR_IO = 5,
	NFSERR_NXIO = 6,
	NFSERR_ACCES = 13,
	NFSERR_EXIST = 17,
	NFSERR_XDEV = 18,
	NFSERR_NODEV = 19,
	NFSERR_NOTDIR = 20,
	NFSERR_ISDIR = 21,
	NFSERR_INVAL = 22,
	NFSERR_FBIG = 27,
	NFSERR_NOSPC = 28,
	NFSERR_ROFS = 30,
	NFSERR_OPNOTSUPP = 45,
	NFSERR_NAMETOOLONG = 63,
	NFSERR_NOTEMPTY = 66,
	NFSERR_DQUOT = 69,
	NFSERR_STALE = 70,
	NFSERR_REMOTE = 71,
	NFSERR_WFLUSH = 72
};
typedef enum nfsstat nfsstat;

enum ftype {
	NFNON = 0,
	NFREG = 1,
	NFDIR = 2,
	NFBLK = 3,
	NFCHR = 4,
	NFLNK = 5,
	NFSOCK = 6,
	NFBAD = 7,
	NFFIFO = 8
};
typedef enum ftype ftype;

struct nfs_fh {
	char data[NFS_FHSIZE];
};
typedef struct nfs_fh nfs_fh;

struct nfstime {
	u_int seconds;
	u_int useconds;
};
typedef struct nfstime nfstime;

struct fattr {
	ftype type;
	u_int mode;
	u_int nlink;
	u_int uid;
	u_int gid;
	u_int size;
	u_int blocksize;
	u_int rdev;
	u_int blocks;
	u_int fsid;
	u_int fileid;
	nfstime atime;
	nfstime mtime;
	nfstime ctime;
};
typedef struct fattr fattr;

struct sattr {
	u_int mode;
	u_int uid;
	u_int gid;
	u_int size;
	nfstime atime;
	nfstime mtime;
};
typedef struct sattr sattr;

typedef char *filename;

typedef char *nfspath;

struct attrstat {
	nfsstat status;
	union {
		fattr attributes;
	} attrstat_u;
};
typedef struct attrstat attrstat;

struct sattrargs {
	nfs_fh file;
	sattr attributes;
};
typedef struct sattrargs sattrargs;

struct diropargs {
	nfs_fh dir;
	filename name;
};
typedef struct diropargs diropargs;

struct diropokres {
	nfs_fh file;
	fattr attributes;
};
typedef struct diropokres diropokres;

struct diropres {
	nfsstat status;
	union {
		diropokres diropres;
	} diropres_u;
};
typedef struct diropres diropres;

struct readlinkres {
	nfsstat status;
	union {
		nfspath data;
	} readlinkres_u;
};
typedef struct readlinkres readlinkres;

struct readargs {
	nfs_fh file;
	u_int offset;
	u_int count;
	u_int totalcount;
};
typedef struct readargs readargs;

struct readokres {
	fattr attributes;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct readokres readokres;

struct readres {
	nfsstat status;
	union {
		readokres reply;
	} readres_u;
};
typedef struct readres readres;

struct writeargs {
	nfs_fh file;
	u_int beginoffset;
	u_int offset;
	u_int totalcount;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct writeargs writeargs;

struct createargs {
	diropargs where;
	sattr attributes;
};
typedef struct createargs createargs;

struct renameargs {
	diropargs from;
	diropargs to;
};
typedef struct renameargs renameargs;

struct linkargs {
	nfs_fh from;
	diropargs to;
};
typedef struct linkargs linkargs;

struct symlinkargs {
	diropargs from;
	nfspath to;
	sattr attributes;
};
typedef struct symlinkargs symlinkargs;

typedef char nfscookie[NFS_COOKIESIZE];

struct readdirargs {
	nfs_fh dir;
	nfscookie cookie;
	u_int count;
};
typedef struct readdirargs readdirargs;

struct entry {
	u_int fileid;
	filename name;
	nfscookie cookie;
	struct entry *nextentry;
};
typedef struct entry entry;

struct dirlist {
	entry *entries;
	bool_t eof;
};
typedef struct dirlist dirlist;

struct readdirres {
	nfsstat status;
	union {
		dirlist reply;
	} readdirres_u;
};
typedef struct readdirres readdirres;

struct statfsokres {
	u_int tsize;
	u_int bsize;
	u_int blocks;
	u_int bfree;
	u_int bavail;
};
typedef struct statfsokres statfsokres;

struct statfsres {
	nfsstat status;
	union {
		statfsokres reply;
	} statfsres_u;
};
typedef struct statfsres statfsres;
#define	NFS3_FHSIZE 64
#define	NFS3_COOKIEVERFSIZE 8
#define	NFS3_CREATEVERFSIZE 8
#define	NFS3_WRITEVERFSIZE 8

typedef char *filename3;

typedef char *nfspath3;

typedef uint64 fileid3;

typedef uint64 cookie3;

typedef char cookieverf3[NFS3_COOKIEVERFSIZE];

typedef char createverf3[NFS3_CREATEVERFSIZE];

typedef char writeverf3[NFS3_WRITEVERFSIZE];

typedef uint32 uid3;

typedef uint32 gid3;

typedef uint64 size3;

typedef uint64 offset3;

typedef uint32 mode3;

typedef uint32 count3;

enum nfsstat3 {
	NFS3_OK = 0,
	NFS3ERR_PERM = 1,
	NFS3ERR_NOENT = 2,
	NFS3ERR_IO = 5,
	NFS3ERR_NXIO = 6,
	NFS3ERR_ACCES = 13,
	NFS3ERR_EXIST = 17,
	NFS3ERR_XDEV = 18,
	NFS3ERR_NODEV = 19,
	NFS3ERR_NOTDIR = 20,
	NFS3ERR_ISDIR = 21,
	NFS3ERR_INVAL = 22,
	NFS3ERR_FBIG = 27,
	NFS3ERR_NOSPC = 28,
	NFS3ERR_ROFS = 30,
	NFS3ERR_MLINK = 31,
	NFS3ERR_NAMETOOLONG = 63,
	NFS3ERR_NOTEMPTY = 66,
	NFS3ERR_DQUOT = 69,
	NFS3ERR_STALE = 70,
	NFS3ERR_REMOTE = 71,
	NFS3ERR_BADHANDLE = 10001,
	NFS3ERR_NOT_SYNC = 10002,
	NFS3ERR_BAD_COOKIE = 10003,
	NFS3ERR_NOTSUPP = 10004,
	NFS3ERR_TOOSMALL = 10005,
	NFS3ERR_SERVERFAULT = 10006,
	NFS3ERR_BADTYPE = 10007,
	NFS3ERR_JUKEBOX = 10008
};
typedef enum nfsstat3 nfsstat3;

enum ftype3 {
	NF3REG = 1,
	NF3DIR = 2,
	NF3BLK = 3,
	NF3CHR = 4,
	NF3LNK = 5,
	NF3SOCK = 6,
	NF3FIFO = 7
};
typedef enum ftype3 ftype3;

struct specdata3 {
	uint32 specdata1;
	uint32 specdata2;
};
typedef struct specdata3 specdata3;

struct nfs_fh3 {
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct nfs_fh3 nfs_fh3;

struct nfstime3 {
	uint32 seconds;
	uint32 nseconds;
};
typedef struct nfstime3 nfstime3;

struct fattr3 {
	ftype3 type;
	mode3 mode;
	uint32 nlink;
	uid3 uid;
	gid3 gid;
	size3 size;
	size3 used;
	specdata3 rdev;
	uint64 fsid;
	fileid3 fileid;
	nfstime3 atime;
	nfstime3 mtime;
	nfstime3 ctime;
};
typedef struct fattr3 fattr3;

struct post_op_attr {
	bool_t attributes_follow;
	union {
		fattr3 attributes;
	} post_op_attr_u;
};
typedef struct post_op_attr post_op_attr;

struct wcc_attr {
	size3 size;
	nfstime3 mtime;
	nfstime3 ctime;
};
typedef struct wcc_attr wcc_attr;

struct pre_op_attr {
	bool_t attributes_follow;
	union {
		wcc_attr attributes;
	} pre_op_attr_u;
};
typedef struct pre_op_attr pre_op_attr;

struct wcc_data {
	pre_op_attr before;
	post_op_attr after;
};
typedef struct wcc_data wcc_data;

struct post_op_fh3 {
	bool_t handle_follows;
	union {
		nfs_fh3 handle;
	} post_op_fh3_u;
};
typedef struct post_op_fh3 post_op_fh3;

enum time_how {
	DONT_CHANGE = 0,
	SET_TO_SERVER_TIME = 1,
	SET_TO_CLIENT_TIME = 2
};
typedef enum time_how time_how;

struct set_mode3 {
	bool_t set_it;
	union {
		mode3 mode;
	} set_mode3_u;
};
typedef struct set_mode3 set_mode3;

struct set_uid3 {
	bool_t set_it;
	union {
		uid3 uid;
	} set_uid3_u;
};
typedef struct set_uid3 set_uid3;

struct set_gid3 {
	bool_t set_it;
	union {
		gid3 gid;
	} set_gid3_u;
};
typedef struct set_gid3 set_gid3;

struct set_size3 {
	bool_t set_it;
	union {
		size3 size;
	} set_size3_u;
};
typedef struct set_size3 set_size3;

struct set_atime {
	time_how set_it;
	union {
		nfstime3 atime;
	} set_atime_u;
};
typedef struct set_atime set_atime;

struct set_mtime {
	time_how set_it;
	union {
		nfstime3 mtime;
	} set_mtime_u;
};
typedef struct set_mtime set_mtime;

struct sattr3 {
	set_mode3 mode;
	set_uid3 uid;
	set_gid3 gid;
	set_size3 size;
	set_atime atime;
	set_mtime mtime;
};
typedef struct sattr3 sattr3;

struct diropargs3 {
	nfs_fh3 dir;
	filename3 name;
};
typedef struct diropargs3 diropargs3;

struct GETATTR3args {
	nfs_fh3 object;
};
typedef struct GETATTR3args GETATTR3args;

struct GETATTR3resok {
	fattr3 obj_attributes;
};
typedef struct GETATTR3resok GETATTR3resok;

struct GETATTR3res {
	nfsstat3 status;
	union {
		GETATTR3resok resok;
	} GETATTR3res_u;
};
typedef struct GETATTR3res GETATTR3res;

struct sattrguard3 {
	bool_t check;
	union {
		nfstime3 obj_ctime;
	} sattrguard3_u;
};
typedef struct sattrguard3 sattrguard3;

struct SETATTR3args {
	nfs_fh3 object;
	sattr3 new_attributes;
	sattrguard3 guard;
};
typedef struct SETATTR3args SETATTR3args;

struct SETATTR3resok {
	wcc_data obj_wcc;
};
typedef struct SETATTR3resok SETATTR3resok;

struct SETATTR3resfail {
	wcc_data obj_wcc;
};
typedef struct SETATTR3resfail SETATTR3resfail;

struct SETATTR3res {
	nfsstat3 status;
	union {
		SETATTR3resok resok;
		SETATTR3resfail resfail;
	} SETATTR3res_u;
};
typedef struct SETATTR3res SETATTR3res;

struct LOOKUP3args {
	diropargs3 what;
};
typedef struct LOOKUP3args LOOKUP3args;

struct LOOKUP3resok {
	nfs_fh3 object;
	post_op_attr obj_attributes;
	post_op_attr dir_attributes;
};
typedef struct LOOKUP3resok LOOKUP3resok;

struct LOOKUP3resfail {
	post_op_attr dir_attributes;
};
typedef struct LOOKUP3resfail LOOKUP3resfail;

struct LOOKUP3res {
	nfsstat3 status;
	union {
		LOOKUP3resok resok;
		LOOKUP3resfail resfail;
	} LOOKUP3res_u;
};
typedef struct LOOKUP3res LOOKUP3res;
#define	ACCESS3_READ 0x0001
#define	ACCESS3_LOOKUP 0x0002
#define	ACCESS3_MODIFY 0x0004
#define	ACCESS3_EXTEND 0x0008
#define	ACCESS3_DELETE 0x0010
#define	ACCESS3_EXECUTE 0x0020

struct ACCESS3args {
	nfs_fh3 object;
	uint32 access;
};
typedef struct ACCESS3args ACCESS3args;

struct ACCESS3resok {
	post_op_attr obj_attributes;
	uint32 access;
};
typedef struct ACCESS3resok ACCESS3resok;

struct ACCESS3resfail {
	post_op_attr obj_attributes;
};
typedef struct ACCESS3resfail ACCESS3resfail;

struct ACCESS3res {
	nfsstat3 status;
	union {
		ACCESS3resok resok;
		ACCESS3resfail resfail;
	} ACCESS3res_u;
};
typedef struct ACCESS3res ACCESS3res;

struct READLINK3args {
	nfs_fh3 symlink;
};
typedef struct READLINK3args READLINK3args;

struct READLINK3resok {
	post_op_attr symlink_attributes;
	nfspath3 data;
};
typedef struct READLINK3resok READLINK3resok;

struct READLINK3resfail {
	post_op_attr symlink_attributes;
};
typedef struct READLINK3resfail READLINK3resfail;

struct READLINK3res {
	nfsstat3 status;
	union {
		READLINK3resok resok;
		READLINK3resfail resfail;
	} READLINK3res_u;
};
typedef struct READLINK3res READLINK3res;

struct READ3args {
	nfs_fh3 file;
	offset3 offset;
	count3 count;
};
typedef struct READ3args READ3args;

struct READ3resok {
	post_op_attr file_attributes;
	count3 count;
	bool_t eof;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct READ3resok READ3resok;

struct READ3resfail {
	post_op_attr file_attributes;
};
typedef struct READ3resfail READ3resfail;

struct READ3res {
	nfsstat3 status;
	union {
		READ3resok resok;
		READ3resfail resfail;
	} READ3res_u;
};
typedef struct READ3res READ3res;

enum stable_how {
	UNSTABLE = 0,
	DATA_SYNC = 1,
	FILE_SYNC = 2
};
typedef enum stable_how stable_how;

struct WRITE3args {
	nfs_fh3 file;
	offset3 offset;
	count3 count;
	stable_how stable;
	struct {
		u_int data_len;
		char *data_val;
	} data;
};
typedef struct WRITE3args WRITE3args;

struct WRITE3resok {
	wcc_data file_wcc;
	count3 count;
	stable_how committed;
	writeverf3 verf;
};
typedef struct WRITE3resok WRITE3resok;

struct WRITE3resfail {
	wcc_data file_wcc;
};
typedef struct WRITE3resfail WRITE3resfail;

struct WRITE3res {
	nfsstat3 status;
	union {
		WRITE3resok resok;
		WRITE3resfail resfail;
	} WRITE3res_u;
};
typedef struct WRITE3res WRITE3res;

enum createmode3 {
	UNCHECKED = 0,
	GUARDED = 1,
	EXCLUSIVE = 2
};
typedef enum createmode3 createmode3;

struct createhow3 {
	createmode3 mode;
	union {
		sattr3 obj_attributes;
		createverf3 verf;
	} createhow3_u;
};
typedef struct createhow3 createhow3;

struct CREATE3args {
	diropargs3 where;
	createhow3 how;
};
typedef struct CREATE3args CREATE3args;

struct CREATE3resok {
	post_op_fh3 obj;
	post_op_attr obj_attributes;
	wcc_data dir_wcc;
};
typedef struct CREATE3resok CREATE3resok;

struct CREATE3resfail {
	wcc_data dir_wcc;
};
typedef struct CREATE3resfail CREATE3resfail;

struct CREATE3res {
	nfsstat3 status;
	union {
		CREATE3resok resok;
		CREATE3resfail resfail;
	} CREATE3res_u;
};
typedef struct CREATE3res CREATE3res;

struct MKDIR3args {
	diropargs3 where;
	sattr3 attributes;
};
typedef struct MKDIR3args MKDIR3args;

struct MKDIR3resok {
	post_op_fh3 obj;
	post_op_attr obj_attributes;
	wcc_data dir_wcc;
};
typedef struct MKDIR3resok MKDIR3resok;

struct MKDIR3resfail {
	wcc_data dir_wcc;
};
typedef struct MKDIR3resfail MKDIR3resfail;

struct MKDIR3res {
	nfsstat3 status;
	union {
		MKDIR3resok resok;
		MKDIR3resfail resfail;
	} MKDIR3res_u;
};
typedef struct MKDIR3res MKDIR3res;

struct symlinkdata3 {
	sattr3 symlink_attributes;
	nfspath3 symlink_data;
};
typedef struct symlinkdata3 symlinkdata3;

struct SYMLINK3args {
	diropargs3 where;
	symlinkdata3 symlink;
};
typedef struct SYMLINK3args SYMLINK3args;

struct SYMLINK3resok {
	post_op_fh3 obj;
	post_op_attr obj_attributes;
	wcc_data dir_wcc;
};
typedef struct SYMLINK3resok SYMLINK3resok;

struct SYMLINK3resfail {
	wcc_data dir_wcc;
};
typedef struct SYMLINK3resfail SYMLINK3resfail;

struct SYMLINK3res {
	nfsstat3 status;
	union {
		SYMLINK3resok resok;
		SYMLINK3resfail resfail;
	} SYMLINK3res_u;
};
typedef struct SYMLINK3res SYMLINK3res;

struct devicedata3 {
	sattr3 dev_attributes;
	specdata3 spec;
};
typedef struct devicedata3 devicedata3;

struct mknoddata3 {
	ftype3 type;
	union {
		devicedata3 device;
		sattr3 pipe_attributes;
	} mknoddata3_u;
};
typedef struct mknoddata3 mknoddata3;

struct MKNOD3args {
	diropargs3 where;
	mknoddata3 what;
};
typedef struct MKNOD3args MKNOD3args;

struct MKNOD3resok {
	post_op_fh3 obj;
	post_op_attr obj_attributes;
	wcc_data dir_wcc;
};
typedef struct MKNOD3resok MKNOD3resok;

struct MKNOD3resfail {
	wcc_data dir_wcc;
};
typedef struct MKNOD3resfail MKNOD3resfail;

struct MKNOD3res {
	nfsstat3 status;
	union {
		MKNOD3resok resok;
		MKNOD3resfail resfail;
	} MKNOD3res_u;
};
typedef struct MKNOD3res MKNOD3res;

struct REMOVE3args {
	diropargs3 object;
};
typedef struct REMOVE3args REMOVE3args;

struct REMOVE3resok {
	wcc_data dir_wcc;
};
typedef struct REMOVE3resok REMOVE3resok;

struct REMOVE3resfail {
	wcc_data dir_wcc;
};
typedef struct REMOVE3resfail REMOVE3resfail;

struct REMOVE3res {
	nfsstat3 status;
	union {
		REMOVE3resok resok;
		REMOVE3resfail resfail;
	} REMOVE3res_u;
};
typedef struct REMOVE3res REMOVE3res;

struct RMDIR3args {
	diropargs3 object;
};
typedef struct RMDIR3args RMDIR3args;

struct RMDIR3resok {
	wcc_data dir_wcc;
};
typedef struct RMDIR3resok RMDIR3resok;

struct RMDIR3resfail {
	wcc_data dir_wcc;
};
typedef struct RMDIR3resfail RMDIR3resfail;

struct RMDIR3res {
	nfsstat3 status;
	union {
		RMDIR3resok resok;
		RMDIR3resfail resfail;
	} RMDIR3res_u;
};
typedef struct RMDIR3res RMDIR3res;

struct RENAME3args {
	diropargs3 from;
	diropargs3 to;
};
typedef struct RENAME3args RENAME3args;

struct RENAME3resok {
	wcc_data fromdir_wcc;
	wcc_data todir_wcc;
};
typedef struct RENAME3resok RENAME3resok;

struct RENAME3resfail {
	wcc_data fromdir_wcc;
	wcc_data todir_wcc;
};
typedef struct RENAME3resfail RENAME3resfail;

struct RENAME3res {
	nfsstat3 status;
	union {
		RENAME3resok resok;
		RENAME3resfail resfail;
	} RENAME3res_u;
};
typedef struct RENAME3res RENAME3res;

struct LINK3args {
	nfs_fh3 file;
	diropargs3 link;
};
typedef struct LINK3args LINK3args;

struct LINK3resok {
	post_op_attr file_attributes;
	wcc_data linkdir_wcc;
};
typedef struct LINK3resok LINK3resok;

struct LINK3resfail {
	post_op_attr file_attributes;
	wcc_data linkdir_wcc;
};
typedef struct LINK3resfail LINK3resfail;

struct LINK3res {
	nfsstat3 status;
	union {
		LINK3resok resok;
		LINK3resfail resfail;
	} LINK3res_u;
};
typedef struct LINK3res LINK3res;

struct READDIR3args {
	nfs_fh3 dir;
	cookie3 cookie;
	cookieverf3 cookieverf;
	count3 count;
};
typedef struct READDIR3args READDIR3args;

struct entry3 {
	fileid3 fileid;
	filename3 name;
	cookie3 cookie;
	struct entry3 *nextentry;
};
typedef struct entry3 entry3;

struct dirlist3 {
	entry3 *entries;
	bool_t eof;
};
typedef struct dirlist3 dirlist3;

struct READDIR3resok {
	post_op_attr dir_attributes;
	cookieverf3 cookieverf;
	dirlist3 reply;
};
typedef struct READDIR3resok READDIR3resok;

struct READDIR3resfail {
	post_op_attr dir_attributes;
};
typedef struct READDIR3resfail READDIR3resfail;

struct READDIR3res {
	nfsstat3 status;
	union {
		READDIR3resok resok;
		READDIR3resfail resfail;
	} READDIR3res_u;
};
typedef struct READDIR3res READDIR3res;

struct READDIRPLUS3args {
	nfs_fh3 dir;
	cookie3 cookie;
	cookieverf3 cookieverf;
	count3 dircount;
	count3 maxcount;
};
typedef struct READDIRPLUS3args READDIRPLUS3args;

struct entryplus3 {
	fileid3 fileid;
	filename3 name;
	cookie3 cookie;
	post_op_attr name_attributes;
	post_op_fh3 name_handle;
	struct entryplus3 *nextentry;
};
typedef struct entryplus3 entryplus3;

struct dirlistplus3 {
	entryplus3 *entries;
	bool_t eof;
};
typedef struct dirlistplus3 dirlistplus3;

struct READDIRPLUS3resok {
	post_op_attr dir_attributes;
	cookieverf3 cookieverf;
	dirlistplus3 reply;
};
typedef struct READDIRPLUS3resok READDIRPLUS3resok;

struct READDIRPLUS3resfail {
	post_op_attr dir_attributes;
};
typedef struct READDIRPLUS3resfail READDIRPLUS3resfail;

struct READDIRPLUS3res {
	nfsstat3 status;
	union {
		READDIRPLUS3resok resok;
		READDIRPLUS3resfail resfail;
	} READDIRPLUS3res_u;
};
typedef struct READDIRPLUS3res READDIRPLUS3res;

struct FSSTAT3args {
	nfs_fh3 fsroot;
};
typedef struct FSSTAT3args FSSTAT3args;

struct FSSTAT3resok {
	post_op_attr obj_attributes;
	size3 tbytes;
	size3 fbytes;
	size3 abytes;
	size3 tfiles;
	size3 ffiles;
	size3 afiles;
	uint32 invarsec;
};
typedef struct FSSTAT3resok FSSTAT3resok;

struct FSSTAT3resfail {
	post_op_attr obj_attributes;
};
typedef struct FSSTAT3resfail FSSTAT3resfail;

struct FSSTAT3res {
	nfsstat3 status;
	union {
		FSSTAT3resok resok;
		FSSTAT3resfail resfail;
	} FSSTAT3res_u;
};
typedef struct FSSTAT3res FSSTAT3res;
#define	FSF3_LINK 0x0001
#define	FSF3_SYMLINK 0x0002
#define	FSF3_HOMOGENEOUS 0x0008
#define	FSF3_CANSETTIME 0x0010

struct FSINFO3args {
	nfs_fh3 fsroot;
};
typedef struct FSINFO3args FSINFO3args;

struct FSINFO3resok {
	post_op_attr obj_attributes;
	uint32 rtmax;
	uint32 rtpref;
	uint32 rtmult;
	uint32 wtmax;
	uint32 wtpref;
	uint32 wtmult;
	uint32 dtpref;
	size3 maxfilesize;
	nfstime3 time_delta;
	uint32 properties;
};
typedef struct FSINFO3resok FSINFO3resok;

struct FSINFO3resfail {
	post_op_attr obj_attributes;
};
typedef struct FSINFO3resfail FSINFO3resfail;

struct FSINFO3res {
	nfsstat3 status;
	union {
		FSINFO3resok resok;
		FSINFO3resfail resfail;
	} FSINFO3res_u;
};
typedef struct FSINFO3res FSINFO3res;

struct PATHCONF3args {
	nfs_fh3 object;
};
typedef struct PATHCONF3args PATHCONF3args;

struct PATHCONF3resok {
	post_op_attr obj_attributes;
	uint32 linkmax;
	uint32 name_max;
	bool_t no_trunc;
	bool_t chown_restricted;
	bool_t case_insensitive;
	bool_t case_preserving;
};
typedef struct PATHCONF3resok PATHCONF3resok;

struct PATHCONF3resfail {
	post_op_attr obj_attributes;
};
typedef struct PATHCONF3resfail PATHCONF3resfail;

struct PATHCONF3res {
	nfsstat3 status;
	union {
		PATHCONF3resok resok;
		PATHCONF3resfail resfail;
	} PATHCONF3res_u;
};
typedef struct PATHCONF3res PATHCONF3res;

struct COMMIT3args {
	nfs_fh3 file;
	offset3 offset;
	count3 count;
};
typedef struct COMMIT3args COMMIT3args;

struct COMMIT3resok {
	wcc_data file_wcc;
	writeverf3 verf;
};
typedef struct COMMIT3resok COMMIT3resok;

struct COMMIT3resfail {
	wcc_data file_wcc;
};
typedef struct COMMIT3resfail COMMIT3resfail;

struct COMMIT3res {
	nfsstat3 status;
	union {
		COMMIT3resok resok;
		COMMIT3resfail resfail;
	} COMMIT3res_u;
};
typedef struct COMMIT3res COMMIT3res;

#define	NFS_PROGRAM	100003
#define	NFS_VERSION	2

#if defined(__STDC__) || defined(__cplusplus)
#define	NFSPROC_NULL	0
extern  void * nfsproc_null_2(void *, CLIENT *);
extern  void * nfsproc_null_2_svc(void *, struct svc_req *);
#define	NFSPROC_GETATTR	1
extern  attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *);
extern  attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
#define	NFSPROC_SETATTR	2
extern  attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *);
extern  attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *);
#define	NFSPROC_ROOT	3
extern  void * nfsproc_root_2(void *, CLIENT *);
extern  void * nfsproc_root_2_svc(void *, struct svc_req *);
#define	NFSPROC_LOOKUP	4
extern  diropres * nfsproc_lookup_2(diropargs *, CLIENT *);
extern  diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *);
#define	NFSPROC_READLINK	5
extern  readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *);
extern  readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
#define	NFSPROC_READ	6
extern  readres * nfsproc_read_2(readargs *, CLIENT *);
extern  readres * nfsproc_read_2_svc(readargs *, struct svc_req *);
#define	NFSPROC_WRITECACHE	7
extern  void * nfsproc_writecache_2(void *, CLIENT *);
extern  void * nfsproc_writecache_2_svc(void *, struct svc_req *);
#define	NFSPROC_WRITE	8
extern  attrstat * nfsproc_write_2(writeargs *, CLIENT *);
extern  attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *);
#define	NFSPROC_CREATE	9
extern  diropres * nfsproc_create_2(createargs *, CLIENT *);
extern  diropres * nfsproc_create_2_svc(createargs *, struct svc_req *);
#define	NFSPROC_REMOVE	10
extern  nfsstat * nfsproc_remove_2(diropargs *, CLIENT *);
extern  nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *);
#define	NFSPROC_RENAME	11
extern  nfsstat * nfsproc_rename_2(renameargs *, CLIENT *);
extern  nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *);
#define	NFSPROC_LINK	12
extern  nfsstat * nfsproc_link_2(linkargs *, CLIENT *);
extern  nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *);
#define	NFSPROC_SYMLINK	13
extern  nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *);
extern  nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *);
#define	NFSPROC_MKDIR	14
extern  diropres * nfsproc_mkdir_2(createargs *, CLIENT *);
extern  diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *);
#define	NFSPROC_RMDIR	15
extern  nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *);
extern  nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *);
#define	NFSPROC_READDIR	16
extern  readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *);
extern  readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *);
#define	NFSPROC_STATFS	17
extern  statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *);
extern  statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	NFSPROC_NULL	0
extern  void * nfsproc_null_2();
extern  void * nfsproc_null_2_svc();
#define	NFSPROC_GETATTR	1
extern  attrstat * nfsproc_getattr_2();
extern  attrstat * nfsproc_getattr_2_svc();
#define	NFSPROC_SETATTR	2
extern  attrstat * nfsproc_setattr_2();
extern  attrstat * nfsproc_setattr_2_svc();
#define	NFSPROC_ROOT	3
extern  void * nfsproc_root_2();
extern  void * nfsproc_root_2_svc();
#define	NFSPROC_LOOKUP	4
extern  diropres * nfsproc_lookup_2();
extern  diropres * nfsproc_lookup_2_svc();
#define	NFSPROC_READLINK	5
extern  readlinkres * nfsproc_readlink_2();
extern  readlinkres * nfsproc_readlink_2_svc();
#define	NFSPROC_READ	6
extern  readres * nfsproc_read_2();
extern  readres * nfsproc_read_2_svc();
#define	NFSPROC_WRITECACHE	7
extern  void * nfsproc_writecache_2();
extern  void * nfsproc_writecache_2_svc();
#define	NFSPROC_WRITE	8
extern  attrstat * nfsproc_write_2();
extern  attrstat * nfsproc_write_2_svc();
#define	NFSPROC_CREATE	9
extern  diropres * nfsproc_create_2();
extern  diropres * nfsproc_create_2_svc();
#define	NFSPROC_REMOVE	10
extern  nfsstat * nfsproc_remove_2();
extern  nfsstat * nfsproc_remove_2_svc();
#define	NFSPROC_RENAME	11
extern  nfsstat * nfsproc_rename_2();
extern  nfsstat * nfsproc_rename_2_svc();
#define	NFSPROC_LINK	12
extern  nfsstat * nfsproc_link_2();
extern  nfsstat * nfsproc_link_2_svc();
#define	NFSPROC_SYMLINK	13
extern  nfsstat * nfsproc_symlink_2();
extern  nfsstat * nfsproc_symlink_2_svc();
#define	NFSPROC_MKDIR	14
extern  diropres * nfsproc_mkdir_2();
extern  diropres * nfsproc_mkdir_2_svc();
#define	NFSPROC_RMDIR	15
extern  nfsstat * nfsproc_rmdir_2();
extern  nfsstat * nfsproc_rmdir_2_svc();
#define	NFSPROC_READDIR	16
extern  readdirres * nfsproc_readdir_2();
extern  readdirres * nfsproc_readdir_2_svc();
#define	NFSPROC_STATFS	17
extern  statfsres * nfsproc_statfs_2();
extern  statfsres * nfsproc_statfs_2_svc();
extern int nfs_program_2_freeresult();
#endif /* K&R C */

#define	NFS3_PROGRAM	100003
#define	NFS_V3	3

#if defined(__STDC__) || defined(__cplusplus)
#define	NFSPROC3_NULL	0
extern  void * nfsproc3_null_3(void *, CLIENT *);
extern  void * nfsproc3_null_3_svc(void *, struct svc_req *);
#define	NFSPROC3_GETATTR	1
extern  GETATTR3res * nfsproc3_getattr_3(GETATTR3args *, CLIENT *);
extern  GETATTR3res * nfsproc3_getattr_3_svc(GETATTR3args *, struct svc_req *);
#define	NFSPROC3_SETATTR	2
extern  SETATTR3res * nfsproc3_setattr_3(SETATTR3args *, CLIENT *);
extern  SETATTR3res * nfsproc3_setattr_3_svc(SETATTR3args *, struct svc_req *);
#define	NFSPROC3_LOOKUP	3
extern  LOOKUP3res * nfsproc3_lookup_3(LOOKUP3args *, CLIENT *);
extern  LOOKUP3res * nfsproc3_lookup_3_svc(LOOKUP3args *, struct svc_req *);
#define	NFSPROC3_ACCESS	4
extern  ACCESS3res * nfsproc3_access_3(ACCESS3args *, CLIENT *);
extern  ACCESS3res * nfsproc3_access_3_svc(ACCESS3args *, struct svc_req *);
#define	NFSPROC3_READLINK	5
extern  READLINK3res * nfsproc3_readlink_3(READLINK3args *, CLIENT *);
extern  READLINK3res * nfsproc3_readlink_3_svc(READLINK3args *, struct svc_req *);
#define	NFSPROC3_READ	6
extern  READ3res * nfsproc3_read_3(READ3args *, CLIENT *);
extern  READ3res * nfsproc3_read_3_svc(READ3args *, struct svc_req *);
#define	NFSPROC3_WRITE	7
extern  WRITE3res * nfsproc3_write_3(WRITE3args *, CLIENT *);
extern  WRITE3res * nfsproc3_write_3_svc(WRITE3args *, struct svc_req *);
#define	NFSPROC3_CREATE	8
extern  CREATE3res * nfsproc3_create_3(CREATE3args *, CLIENT *);
extern  CREATE3res * nfsproc3_create_3_svc(CREATE3args *, struct svc_req *);
#define	NFSPROC3_MKDIR	9
extern  MKDIR3res * nfsproc3_mkdir_3(MKDIR3args *, CLIENT *);
extern  MKDIR3res * nfsproc3_mkdir_3_svc(MKDIR3args *, struct svc_req *);
#define	NFSPROC3_SYMLINK	10
extern  SYMLINK3res * nfsproc3_symlink_3(SYMLINK3args *, CLIENT *);
extern  SYMLINK3res * nfsproc3_symlink_3_svc(SYMLINK3args *, struct svc_req *);
#define	NFSPROC3_MKNOD	11
extern  MKNOD3res * nfsproc3_mknod_3(MKNOD3args *, CLIENT *);
extern  MKNOD3res * nfsproc3_mknod_3_svc(MKNOD3args *, struct svc_req *);
#define	NFSPROC3_REMOVE	12
extern  REMOVE3res * nfsproc3_remove_3(REMOVE3args *, CLIENT *);
extern  REMOVE3res * nfsproc3_remove_3_svc(REMOVE3args *, struct svc_req *);
#define	NFSPROC3_RMDIR	13
extern  RMDIR3res * nfsproc3_rmdir_3(RMDIR3args *, CLIENT *);
extern  RMDIR3res * nfsproc3_rmdir_3_svc(RMDIR3args *, struct svc_req *);
#define	NFSPROC3_RENAME	14
extern  RENAME3res * nfsproc3_rename_3(RENAME3args *, CLIENT *);
extern  RENAME3res * nfsproc3_rename_3_svc(RENAME3args *, struct svc_req *);
#define	NFSPROC3_LINK	15
extern  LINK3res * nfsproc3_link_3(LINK3args *, CLIENT *);
extern  LINK3res * nfsproc3_link_3_svc(LINK3args *, struct svc_req *);
#define	NFSPROC3_READDIR	16
extern  READDIR3res * nfsproc3_readdir_3(READDIR3args *, CLIENT *);
extern  READDIR3res * nfsproc3_readdir_3_svc(READDIR3args *, struct svc_req *);
#define	NFSPROC3_READDIRPLUS	17
extern  READDIRPLUS3res * nfsproc3_readdirplus_3(READDIRPLUS3args *, CLIENT *);
extern  READDIRPLUS3res * nfsproc3_readdirplus_3_svc(READDIRPLUS3args *, struct svc_req *);
#define	NFSPROC3_FSSTAT	18
extern  FSSTAT3res * nfsproc3_fsstat_3(FSSTAT3args *, CLIENT *);
extern  FSSTAT3res * nfsproc3_fsstat_3_svc(FSSTAT3args *, struct svc_req *);
#define	NFSPROC3_FSINFO	19
extern  FSINFO3res * nfsproc3_fsinfo_3(FSINFO3args *, CLIENT *);
extern  FSINFO3res * nfsproc3_fsinfo_3_svc(FSINFO3args *, struct svc_req *);
#define	NFSPROC3_PATHCONF	20
extern  PATHCONF3res * nfsproc3_pathconf_3(PATHCONF3args *, CLIENT *);
extern  PATHCONF3res * nfsproc3_pathconf_3_svc(PATHCONF3args *, struct svc_req *);
#define	NFSPROC3_COMMIT	21
extern  COMMIT3res * nfsproc3_commit_3(COMMIT3args *, CLIENT *);
extern  COMMIT3res * nfsproc3_commit_3_svc(COMMIT3args *, struct svc_req *);
extern int nfs3_program_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	NFSPROC3_NULL	0
extern  void * nfsproc3_null_3();
extern  void * nfsproc3_null_3_svc();
#define	NFSPROC3_GETATTR	1
extern  GETATTR3res * nfsproc3_getattr_3();
extern  GETATTR3res * nfsproc3_getattr_3_svc();
#define	NFSPROC3_SETATTR	2
extern  SETATTR3res * nfsproc3_setattr_3();
extern  SETATTR3res * nfsproc3_setattr_3_svc();
#define	NFSPROC3_LOOKUP	3
extern  LOOKUP3res * nfsproc3_lookup_3();
extern  LOOKUP3res * nfsproc3_lookup_3_svc();
#define	NFSPROC3_ACCESS	4
extern  ACCESS3res * nfsproc3_access_3();
extern  ACCESS3res * nfsproc3_access_3_svc();
#define	NFSPROC3_READLINK	5
extern  READLINK3res * nfsproc3_readlink_3();
extern  READLINK3res * nfsproc3_readlink_3_svc();
#define	NFSPROC3_READ	6
extern  READ3res * nfsproc3_read_3();
extern  READ3res * nfsproc3_read_3_svc();
#define	NFSPROC3_WRITE	7
extern  WRITE3res * nfsproc3_write_3();
extern  WRITE3res * nfsproc3_write_3_svc();
#define	NFSPROC3_CREATE	8
extern  CREATE3res * nfsproc3_create_3();
extern  CREATE3res * nfsproc3_create_3_svc();
#define	NFSPROC3_MKDIR	9
extern  MKDIR3res * nfsproc3_mkdir_3();
extern  MKDIR3res * nfsproc3_mkdir_3_svc();
#define	NFSPROC3_SYMLINK	10
extern  SYMLINK3res * nfsproc3_symlink_3();
extern  SYMLINK3res * nfsproc3_symlink_3_svc();
#define	NFSPROC3_MKNOD	11
extern  MKNOD3res * nfsproc3_mknod_3();
extern  MKNOD3res * nfsproc3_mknod_3_svc();
#define	NFSPROC3_REMOVE	12
extern  REMOVE3res * nfsproc3_remove_3();
extern  REMOVE3res * nfsproc3_remove_3_svc();
#define	NFSPROC3_RMDIR	13
extern  RMDIR3res * nfsproc3_rmdir_3();
extern  RMDIR3res * nfsproc3_rmdir_3_svc();
#define	NFSPROC3_RENAME	14
extern  RENAME3res * nfsproc3_rename_3();
extern  RENAME3res * nfsproc3_rename_3_svc();
#define	NFSPROC3_LINK	15
extern  LINK3res * nfsproc3_link_3();
extern  LINK3res * nfsproc3_link_3_svc();
#define	NFSPROC3_READDIR	16
extern  READDIR3res * nfsproc3_readdir_3();
extern  READDIR3res * nfsproc3_readdir_3_svc();
#define	NFSPROC3_READDIRPLUS	17
extern  READDIRPLUS3res * nfsproc3_readdirplus_3();
extern  READDIRPLUS3res * nfsproc3_readdirplus_3_svc();
#define	NFSPROC3_FSSTAT	18
extern  FSSTAT3res * nfsproc3_fsstat_3();
extern  FSSTAT3res * nfsproc3_fsstat_3_svc();
#define	NFSPROC3_FSINFO	19
extern  FSINFO3res * nfsproc3_fsinfo_3();
extern  FSINFO3res * nfsproc3_fsinfo_3_svc();
#define	NFSPROC3_PATHCONF	20
extern  PATHCONF3res * nfsproc3_pathconf_3();
extern  PATHCONF3res * nfsproc3_pathconf_3_svc();
#define	NFSPROC3_COMMIT	21
extern  COMMIT3res * nfsproc3_commit_3();
extern  COMMIT3res * nfsproc3_commit_3_svc();
extern int nfs3_program_3_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_nfsstat(XDR *, nfsstat*);
extern  bool_t xdr_ftype(XDR *, ftype*);
extern  bool_t xdr_nfs_fh(XDR *, nfs_fh*);
extern  bool_t xdr_nfstime(XDR *, nfstime*);
extern  bool_t xdr_fattr(XDR *, fattr*);
extern  bool_t xdr_sattr(XDR *, sattr*);
extern  bool_t xdr_filename(XDR *, filename*);
extern  bool_t xdr_nfspath(XDR *, nfspath*);
extern  bool_t xdr_attrstat(XDR *, attrstat*);
extern  bool_t xdr_sattrargs(XDR *, sattrargs*);
extern  bool_t xdr_diropargs(XDR *, diropargs*);
extern  bool_t xdr_diropokres(XDR *, diropokres*);
extern  bool_t xdr_diropres(XDR *, diropres*);
extern  bool_t xdr_readlinkres(XDR *, readlinkres*);
extern  bool_t xdr_readargs(XDR *, readargs*);
extern  bool_t xdr_readokres(XDR *, readokres*);
extern  bool_t xdr_readres(XDR *, readres*);
extern  bool_t xdr_writeargs(XDR *, writeargs*);
extern  bool_t xdr_createargs(XDR *, createargs*);
extern  bool_t xdr_renameargs(XDR *, renameargs*);
extern  bool_t xdr_linkargs(XDR *, linkargs*);
extern  bool_t xdr_symlinkargs(XDR *, symlinkargs*);
extern  bool_t xdr_nfscookie(XDR *, nfscookie);
extern  bool_t xdr_readdirargs(XDR *, readdirargs*);
extern  bool_t xdr_entry(XDR *, entry*);
extern  bool_t xdr_dirlist(XDR *, dirlist*);
extern  bool_t xdr_readdirres(XDR *, readdirres*);
extern  bool_t xdr_statfsokres(XDR *, statfsokres*);
extern  bool_t xdr_statfsres(XDR *, statfsres*);
extern  bool_t xdr_filename3(XDR *, filename3*);
extern  bool_t xdr_nfspath3(XDR *, nfspath3*);
extern  bool_t xdr_fileid3(XDR *, fileid3*);
extern  bool_t xdr_cookie3(XDR *, cookie3*);
extern  bool_t xdr_cookieverf3(XDR *, cookieverf3);
extern  bool_t xdr_createverf3(XDR *, createverf3);
extern  bool_t xdr_writeverf3(XDR *, writeverf3);
extern  bool_t xdr_uid3(XDR *, uid3*);
extern  bool_t xdr_gid3(XDR *, gid3*);
extern  bool_t xdr_size3(XDR *, size3*);
extern  bool_t xdr_offset3(XDR *, offset3*);
extern  bool_t xdr_mode3(XDR *, mode3*);
extern  bool_t xdr_count3(XDR *, count3*);
extern  bool_t xdr_nfsstat3(XDR *, nfsstat3*);
extern  bool_t xdr_ftype3(XDR *, ftype3*);
extern  bool_t xdr_specdata3(XDR *, specdata3*);
extern  bool_t xdr_nfs_fh3(XDR *, nfs_fh3*);
extern  bool_t xdr_nfstime3(XDR *, nfstime3*);
extern  bool_t xdr_fattr3(XDR *, fattr3*);
extern  bool_t xdr_post_op_attr(XDR *, post_op_attr*);
extern  bool_t xdr_wcc_attr(XDR *, wcc_attr*);
extern  bool_t xdr_pre_op_attr(XDR *, pre_op_attr*);
extern  bool_t xdr_wcc_data(XDR *, wcc_data*);
extern  bool_t xdr_post_op_fh3(XDR *, post_op_fh3*);
extern  bool_t xdr_time_how(XDR *, time_how*);
extern  bool_t xdr_set_mode3(XDR *, set_mode3*);
extern  bool_t xdr_set_uid3(XDR *, set_uid3*);
extern  bool_t xdr_set_gid3(XDR *, set_gid3*);
extern  bool_t xdr_set_size3(XDR *, set_size3*);
extern  bool_t xdr_set_atime(XDR *, set_atime*);
extern  bool_t xdr_set_mtime(XDR *, set_mtime*);
extern  bool_t xdr_sattr3(XDR *, sattr3*);
extern  bool_t xdr_diropargs3(XDR *, diropargs3*);
extern  bool_t xdr_GETATTR3args(XDR *, GETATTR3args*);
extern  bool_t xdr_GETATTR3resok(XDR *, GETATTR3resok*);
extern  bool_t xdr_GETATTR3res(XDR *, GETATTR3res*);
extern  bool_t xdr_sattrguard3(XDR *, sattrguard3*);
extern  bool_t xdr_SETATTR3args(XDR *, SETATTR3args*);
extern  bool_t xdr_SETATTR3resok(XDR *, SETATTR3resok*);
extern  bool_t xdr_SETATTR3resfail(XDR *, SETATTR3resfail*);
extern  bool_t xdr_SETATTR3res(XDR *, SETATTR3res*);
extern  bool_t xdr_LOOKUP3args(XDR *, LOOKUP3args*);
extern  bool_t xdr_LOOKUP3resok(XDR *, LOOKUP3resok*);
extern  bool_t xdr_LOOKUP3resfail(XDR *, LOOKUP3resfail*);
extern  bool_t xdr_LOOKUP3res(XDR *, LOOKUP3res*);
extern  bool_t xdr_ACCESS3args(XDR *, ACCESS3args*);
extern  bool_t xdr_ACCESS3resok(XDR *, ACCESS3resok*);
extern  bool_t xdr_ACCESS3resfail(XDR *, ACCESS3resfail*);
extern  bool_t xdr_ACCESS3res(XDR *, ACCESS3res*);
extern  bool_t xdr_READLINK3args(XDR *, READLINK3args*);
extern  bool_t xdr_READLINK3resok(XDR *, READLINK3resok*);
extern  bool_t xdr_READLINK3resfail(XDR *, READLINK3resfail*);
extern  bool_t xdr_READLINK3res(XDR *, READLINK3res*);
extern  bool_t xdr_READ3args(XDR *, READ3args*);
extern  bool_t xdr_READ3resok(XDR *, READ3resok*);
extern  bool_t xdr_READ3resfail(XDR *, READ3resfail*);
extern  bool_t xdr_READ3res(XDR *, READ3res*);
extern  bool_t xdr_stable_how(XDR *, stable_how*);
extern  bool_t xdr_WRITE3args(XDR *, WRITE3args*);
extern  bool_t xdr_WRITE3resok(XDR *, WRITE3resok*);
extern  bool_t xdr_WRITE3resfail(XDR *, WRITE3resfail*);
extern  bool_t xdr_WRITE3res(XDR *, WRITE3res*);
extern  bool_t xdr_createmode3(XDR *, createmode3*);
extern  bool_t xdr_createhow3(XDR *, createhow3*);
extern  bool_t xdr_CREATE3args(XDR *, CREATE3args*);
extern  bool_t xdr_CREATE3resok(XDR *, CREATE3resok*);
extern  bool_t xdr_CREATE3resfail(XDR *, CREATE3resfail*);
extern  bool_t xdr_CREATE3res(XDR *, CREATE3res*);
extern  bool_t xdr_MKDIR3args(XDR *, MKDIR3args*);
extern  bool_t xdr_MKDIR3resok(XDR *, MKDIR3resok*);
extern  bool_t xdr_MKDIR3resfail(XDR *, MKDIR3resfail*);
extern  bool_t xdr_MKDIR3res(XDR *, MKDIR3res*);
extern  bool_t xdr_symlinkdata3(XDR *, symlinkdata3*);
extern  bool_t xdr_SYMLINK3args(XDR *, SYMLINK3args*);
extern  bool_t xdr_SYMLINK3resok(XDR *, SYMLINK3resok*);
extern  bool_t xdr_SYMLINK3resfail(XDR *, SYMLINK3resfail*);
extern  bool_t xdr_SYMLINK3res(XDR *, SYMLINK3res*);
extern  bool_t xdr_devicedata3(XDR *, devicedata3*);
extern  bool_t xdr_mknoddata3(XDR *, mknoddata3*);
extern  bool_t xdr_MKNOD3args(XDR *, MKNOD3args*);
extern  bool_t xdr_MKNOD3resok(XDR *, MKNOD3resok*);
extern  bool_t xdr_MKNOD3resfail(XDR *, MKNOD3resfail*);
extern  bool_t xdr_MKNOD3res(XDR *, MKNOD3res*);
extern  bool_t xdr_REMOVE3args(XDR *, REMOVE3args*);
extern  bool_t xdr_REMOVE3resok(XDR *, REMOVE3resok*);
extern  bool_t xdr_REMOVE3resfail(XDR *, REMOVE3resfail*);
extern  bool_t xdr_REMOVE3res(XDR *, REMOVE3res*);
extern  bool_t xdr_RMDIR3args(XDR *, RMDIR3args*);
extern  bool_t xdr_RMDIR3resok(XDR *, RMDIR3resok*);
extern  bool_t xdr_RMDIR3resfail(XDR *, RMDIR3resfail*);
extern  bool_t xdr_RMDIR3res(XDR *, RMDIR3res*);
extern  bool_t xdr_RENAME3args(XDR *, RENAME3args*);
extern  bool_t xdr_RENAME3resok(XDR *, RENAME3resok*);
extern  bool_t xdr_RENAME3resfail(XDR *, RENAME3resfail*);
extern  bool_t xdr_RENAME3res(XDR *, RENAME3res*);
extern  bool_t xdr_LINK3args(XDR *, LINK3args*);
extern  bool_t xdr_LINK3resok(XDR *, LINK3resok*);
extern  bool_t xdr_LINK3resfail(XDR *, LINK3resfail*);
extern  bool_t xdr_LINK3res(XDR *, LINK3res*);
extern  bool_t xdr_READDIR3args(XDR *, READDIR3args*);
extern  bool_t xdr_entry3(XDR *, entry3*);
extern  bool_t xdr_dirlist3(XDR *, dirlist3*);
extern  bool_t xdr_READDIR3resok(XDR *, READDIR3resok*);
extern  bool_t xdr_READDIR3resfail(XDR *, READDIR3resfail*);
extern  bool_t xdr_READDIR3res(XDR *, READDIR3res*);
extern  bool_t xdr_READDIRPLUS3args(XDR *, READDIRPLUS3args*);
extern  bool_t xdr_entryplus3(XDR *, entryplus3*);
extern  bool_t xdr_dirlistplus3(XDR *, dirlistplus3*);
extern  bool_t xdr_READDIRPLUS3resok(XDR *, READDIRPLUS3resok*);
extern  bool_t xdr_READDIRPLUS3resfail(XDR *, READDIRPLUS3resfail*);
extern  bool_t xdr_READDIRPLUS3res(XDR *, READDIRPLUS3res*);
extern  bool_t xdr_FSSTAT3args(XDR *, FSSTAT3args*);
extern  bool_t xdr_FSSTAT3resok(XDR *, FSSTAT3resok*);
extern  bool_t xdr_FSSTAT3resfail(XDR *, FSSTAT3resfail*);
extern  bool_t xdr_FSSTAT3res(XDR *, FSSTAT3res*);
extern  bool_t xdr_FSINFO3args(XDR *, FSINFO3args*);
extern  bool_t xdr_FSINFO3resok(XDR *, FSINFO3resok*);
extern  bool_t xdr_FSINFO3resfail(XDR *, FSINFO3resfail*);
extern  bool_t xdr_FSINFO3res(XDR *, FSINFO3res*);
extern  bool_t xdr_PATHCONF3args(XDR *, PATHCONF3args*);
extern  bool_t xdr_PATHCONF3resok(XDR *, PATHCONF3resok*);
extern  bool_t xdr_PATHCONF3resfail(XDR *, PATHCONF3resfail*);
extern  bool_t xdr_PATHCONF3res(XDR *, PATHCONF3res*);
extern  bool_t xdr_COMMIT3args(XDR *, COMMIT3args*);
extern  bool_t xdr_COMMIT3resok(XDR *, COMMIT3resok*);
extern  bool_t xdr_COMMIT3resfail(XDR *, COMMIT3resfail*);
extern  bool_t xdr_COMMIT3res(XDR *, COMMIT3res*);

#else /* K&R C */
extern bool_t xdr_nfsstat();
extern bool_t xdr_ftype();
extern bool_t xdr_nfs_fh();
extern bool_t xdr_nfstime();
extern bool_t xdr_fattr();
extern bool_t xdr_sattr();
extern bool_t xdr_filename();
extern bool_t xdr_nfspath();
extern bool_t xdr_attrstat();
extern bool_t xdr_sattrargs();
extern bool_t xdr_diropargs();
extern bool_t xdr_diropokres();
extern bool_t xdr_diropres();
extern bool_t xdr_readlinkres();
extern bool_t xdr_readargs();
extern bool_t xdr_readokres();
extern bool_t xdr_readres();
extern bool_t xdr_writeargs();
extern bool_t xdr_createargs();
extern bool_t xdr_renameargs();
extern bool_t xdr_linkargs();
extern bool_t xdr_symlinkargs();
extern bool_t xdr_nfscookie();
extern bool_t xdr_readdirargs();
extern bool_t xdr_entry();
extern bool_t xdr_dirlist();
extern bool_t xdr_readdirres();
extern bool_t xdr_statfsokres();
extern bool_t xdr_statfsres();
extern bool_t xdr_filename3();
extern bool_t xdr_nfspath3();
extern bool_t xdr_fileid3();
extern bool_t xdr_cookie3();
extern bool_t xdr_cookieverf3();
extern bool_t xdr_createverf3();
extern bool_t xdr_writeverf3();
extern bool_t xdr_uid3();
extern bool_t xdr_gid3();
extern bool_t xdr_size3();
extern bool_t xdr_offset3();
extern bool_t xdr_mode3();
extern bool_t xdr_count3();
extern bool_t xdr_nfsstat3();
extern bool_t xdr_ftype3();
extern bool_t xdr_specdata3();
extern bool_t xdr_nfs_fh3();
extern bool_t xdr_nfstime3();
extern bool_t xdr_fattr3();
extern bool_t xdr_post_op_attr();
extern bool_t xdr_wcc_attr();
extern bool_t xdr_pre_op_attr();
extern bool_t xdr_wcc_data();
extern bool_t xdr_post_op_fh3();
extern bool_t xdr_time_how();
extern bool_t xdr_set_mode3();
extern bool_t xdr_set_uid3();
extern bool_t xdr_set_gid3();
extern bool_t xdr_set_size3();
extern bool_t xdr_set_atime();
extern bool_t xdr_set_mtime();
extern bool_t xdr_sattr3();
extern bool_t xdr_diropargs3();
extern bool_t xdr_GETATTR3args();
extern bool_t xdr_GETATTR3resok();
extern bool_t xdr_GETATTR3res();
extern bool_t xdr_sattrguard3();
extern bool_t xdr_SETATTR3args();
extern bool_t xdr_SETATTR3resok();
extern bool_t xdr_SETATTR3resfail();
extern bool_t xdr_SETATTR3res();
extern bool_t xdr_LOOKUP3args();
extern bool_t xdr_LOOKUP3resok();
extern bool_t xdr_LOOKUP3resfail();
extern bool_t xdr_LOOKUP3res();
extern bool_t xdr_ACCESS3args();
extern bool_t xdr_ACCESS3resok();
extern bool_t xdr_ACCESS3resfail();
extern bool_t xdr_ACCESS3res();
extern bool_t xdr_READLINK3args();
extern bool_t xdr_READLINK3resok();
extern bool_t xdr_READLINK3resfail();
extern bool_t xdr_READLINK3res();
extern bool_t xdr_READ3args();
extern bool_t xdr_READ3resok();
extern bool_t xdr_READ3resfail();
extern bool_t xdr_READ3res();
extern bool_t xdr_stable_how();
extern bool_t xdr_WRITE3args();
extern bool_t xdr_WRITE3resok();
extern bool_t xdr_WRITE3resfail();
extern bool_t xdr_WRITE3res();
extern bool_t xdr_createmode3();
extern bool_t xdr_createhow3();
extern bool_t xdr_CREATE3args();
extern bool_t xdr_CREATE3resok();
extern bool_t xdr_CREATE3resfail();
extern bool_t xdr_CREATE3res();
extern bool_t xdr_MKDIR3args();
extern bool_t xdr_MKDIR3resok();
extern bool_t xdr_MKDIR3resfail();
extern bool_t xdr_MKDIR3res();
extern bool_t xdr_symlinkdata3();
extern bool_t xdr_SYMLINK3args();
extern bool_t xdr_SYMLINK3resok();
extern bool_t xdr_SYMLINK3resfail();
extern bool_t xdr_SYMLINK3res();
extern bool_t xdr_devicedata3();
extern bool_t xdr_mknoddata3();
extern bool_t xdr_MKNOD3args();
extern bool_t xdr_MKNOD3resok();
extern bool_t xdr_MKNOD3resfail();
extern bool_t xdr_MKNOD3res();
extern bool_t xdr_REMOVE3args();
extern bool_t xdr_REMOVE3resok();
extern bool_t xdr_REMOVE3resfail();
extern bool_t xdr_REMOVE3res();
extern bool_t xdr_RMDIR3args();
extern bool_t xdr_RMDIR3resok();
extern bool_t xdr_RMDIR3resfail();
extern bool_t xdr_RMDIR3res();
extern bool_t xdr_RENAME3args();
extern bool_t xdr_RENAME3resok();
extern bool_t xdr_RENAME3resfail();
extern bool_t xdr_RENAME3res();
extern bool_t xdr_LINK3args();
extern bool_t xdr_LINK3resok();
extern bool_t xdr_LINK3resfail();
extern bool_t xdr_LINK3res();
extern bool_t xdr_READDIR3args();
extern bool_t xdr_entry3();
extern bool_t xdr_dirlist3();
extern bool_t xdr_READDIR3resok();
extern bool_t xdr_READDIR3resfail();
extern bool_t xdr_READDIR3res();
extern bool_t xdr_READDIRPLUS3args();
extern bool_t xdr_entryplus3();
extern bool_t xdr_dirlistplus3();
extern bool_t xdr_READDIRPLUS3resok();
extern bool_t xdr_READDIRPLUS3resfail();
extern bool_t xdr_READDIRPLUS3res();
extern bool_t xdr_FSSTAT3args();
extern bool_t xdr_FSSTAT3resok();
extern bool_t xdr_FSSTAT3resfail();
extern bool_t xdr_FSSTAT3res();
extern bool_t xdr_FSINFO3args();
extern bool_t xdr_FSINFO3resok();
extern bool_t xdr_FSINFO3resfail();
extern bool_t xdr_FSINFO3res();
extern bool_t xdr_PATHCONF3args();
extern bool_t xdr_PATHCONF3resok();
extern bool_t xdr_PATHCONF3resfail();
extern bool_t xdr_PATHCONF3res();
extern bool_t xdr_COMMIT3args();
extern bool_t xdr_COMMIT3resok();
extern bool_t xdr_COMMIT3resfail();
extern bool_t xdr_COMMIT3res();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_NFS_PROT_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifdef RPC_HDR
%/*
% * Definitions for uint64, int64, uint32, and int32
% */
%#include <rpc/rpc_sztypes.h>
%
#endif

const NFS_PORT          = 2049;
const NFS_MAXDATA       = 8192;
const NFS_MAXPATHLEN    = 1024;
const NFS_MAXNAMLEN	= 255;
const NFS_FHSIZE	= 32;
const NFS_COOKIESIZE	= 4;
const NFS_FIFO_DEV	= -1;	/* size kludge for named pipes */

/*
 * File types
 */
const NFSMODE_FMT  = 0170000;	/* type of file */
const NFSMODE_DIR  = 0040000;	/* directory */
const NFSMODE_CHR  = 0020000;	/* character special */
const NFSMODE_BLK  = 0060000;	/* block special */
const NFSMODE_REG  = 0100000;	/* regular */
const NFSMODE_LNK  = 0120000;	/* symbolic link */
const NFSMODE_SOCK = 0140000;	/* socket */
const NFSMODE_FIFO = 0010000;	/* fifo */

/*
 * Error status
 */
enum nfsstat {
	NFS_OK= 0,		/* no error */
	NFSERR_PERM=1,		/* Not owner */
	NFSERR_NOENT=2,		/* No such file or directory */
	NFSERR_IO=5,		/* I/O error */
	NFSERR_NXIO=6,		/* No such device or address */
	NFSERR_ACCES=13,	/* Permission denied */
	NFSERR_EXIST=17,	/* File exists */
	NFSERR_XDEV=18,		/* Cross-device link */
	NFSERR_NODEV=19,	/* No such device */
	NFSERR_NOTDIR=20,	/* Not a directory*/
	NFSERR_ISDIR=21,	/* Is a directory */
	NFSERR_INVAL=22,	/* Invalid argument */
	NFSERR_FBIG=27,		/* File too large */
	NFSERR_NOSPC=28,	/* No space left on device */
	NFSERR_ROFS=30,		/* Read-only file system */
	NFSERR_OPNOTSUPP=45,	/* Operation not supported */
	NFSERR_NAMETOOLONG=63,	/* File name too long */
	NFSERR_NOTEMPTY=66,	/* Directory not empty */
	NFSERR_DQUOT=69,	/* Disc quota exceeded */
	NFSERR_STALE=70,	/* Stale NFS file handle */
	NFSERR_REMOTE=71,	/* Object is remote */
	NFSERR_WFLUSH=72	/* write cache flushed */
};

/*
 * File types
 */
enum ftype {
	NFNON = 0,	/* non-file */
	NFREG = 1,	/* regular file */
	NFDIR = 2,	/* directory */
	NFBLK = 3,	/* block special */
	NFCHR = 4,	/* character special */
	NFLNK = 5,	/* symbolic link */
	NFSOCK = 6,	/* unix domain sockets */
	NFBAD = 7,	/* unused */
	NFFIFO = 8 	/* named pipe */
};

/*
 * File access handle
 */
struct nfs_fh {
	opaque data[NFS_FHSIZE];
};

/*
 * Timeval
 */
struct nfstime {
	unsigned seconds;
	unsigned useconds;
};


/*
 * File attributes
 */
struct fattr {
	ftype type;		/* file type */
	unsigned mode;		/* protection mode bits */
	unsigned nlink;		/* # hard links */
	unsigned uid;		/* owner user id */
	unsigned gid;		/* owner group id */
	unsigned size;		/* file size in bytes */
	unsigned blocksize;	/* prefered block size */
	unsigned rdev;		/* special device # */
	unsigned blocks;	/* Kb of disk used by file */
	unsigned fsid;		/* device # */
	unsigned fileid;	/* inode # */
	nfstime	atime;		/* time of last access */
	nfstime	mtime;		/* time of last modification */
	nfstime	ctime;		/* time of last change */
};

/*
 * File attributes which can be set
 */
struct sattr {
	unsigned mode;	/* protection mode bits */
	unsigned uid;	/* owner user id */
	unsigned gid;	/* owner group id */
	unsigned size;	/* file size in bytes */
	nfstime	atime;	/* time of last access */
	nfstime	mtime;	/* time of last modification */
};


typedef string filename<NFS_MAXNAMLEN>;
typedef string nfspath<NFS_MAXPATHLEN>;

/*
 * Reply status with file attributes
 */
union attrstat switch (nfsstat status) {
case NFS_OK:
	fattr attributes;
default:
	void;
};

struct sattrargs {
	nfs_fh file;
	sattr attributes;
};

/*
 * Arguments for directory operations
 */
struct diropargs {
	nfs_fh	dir;	/* directory file handle */
	filename name;		/* name (up to NFS_MAXNAMLEN bytes) */
};

struct diropokres {
	nfs_fh file;
	fattr attributes;
};

/*
 * Results from directory operation
 */
union diropres switch (nfsstat status) {
case NFS_OK:
	diropokres diropres;
default:
	void;
};

union readlinkres switch (nfsstat status) {
case NFS_OK:
	nfspath data;
default:
	void;
};

/*
 * Arguments to remote read
 */
struct readargs {
	nfs_fh file;		/* handle for file */
	unsigned offset;	/* byte offset in file */
	unsigned count;		/* immediate read count */
	unsigned totalcount;	/* total read count (from this offset)*/
};

/*
 * Status OK portion of remote read reply
 */
struct readokres {
	fattr	attributes;	/* attributes, need for pagin*/
	opaque data<NFS_MAXDATA>;
};

union readres switch (nfsstat status) {
case NFS_OK:
	readokres reply;
default:
	void;
};

/*
 * Arguments to remote write
 */
struct writeargs {
	nfs_fh	file;		/* handle for file */
	unsigned beginoffset;	/* beginning byte offset in file */
	unsigned offset;	/* current byte offset in file */
	unsigned totalcount;	/* total write count (to this offset)*/
	opaque data<NFS_MAXDATA>;
};

struct createargs {
	diropargs where;
	sattr attributes;
};

struct renameargs {
	diropargs from;
	diropargs to;
};

struct linkargs {
	nfs_fh from;
	diropargs to;
};

struct symlinkargs {
	diropargs from;
	nfspath to;
	sattr attributes;
};


typedef opaque nfscookie[NFS_COOKIESIZE];

/*
 * Arguments to readdir
 */
struct readdirargs {
	nfs_fh dir;		/* directory handle */
	nfscookie cookie;
	unsigned count;		/* number of directory bytes to read */
};

struct entry {
	unsigned fileid;
	filename name;
	nfscookie cookie;
	entry *nextentry;
};

struct dirlist {
	entry *entries;
	bool eof;
};

union readdirres switch (nfsstat status) {
case NFS_OK:
	dirlist reply;
default:
	void;
};

struct statfsokres {
	unsigned tsize;	/* preferred transfer size in bytes */
	unsigned bsize;	/* fundamental file system block size */
	unsigned blocks;	/* total blocks in file system */
	unsigned bfree;	/* free blocks in fs */
	unsigned bavail;	/* free blocks avail to non-superuser */
};

union statfsres switch (nfsstat status) {
case NFS_OK:
	statfsokres reply;
default:
	void;
};

/*
 * Remote file service routines
 */
program NFS_PROGRAM {
	version NFS_VERSION {
		void
		NFSPROC_NULL(void) = 0;

		attrstat
		NFSPROC_GETATTR(nfs_fh) =	1;

		attrstat
		NFSPROC_SETATTR(sattrargs) = 2;

		void
		NFSPROC_ROOT(void) = 3;

		diropres
		NFSPROC_LOOKUP(diropargs) = 4;

		readlinkres
		NFSPROC_READLINK(nfs_fh) = 5;

		readres
		NFSPROC_READ(readargs) = 6;

		void
		NFSPROC_WRITECACHE(void) = 7;

		attrstat
		NFSPROC_WRITE(writeargs) = 8;

		diropres
		NFSPROC_CREATE(createargs) = 9;

		nfsstat
		NFSPROC_REMOVE(diropargs) = 10;

		nfsstat
		NFSPROC_RENAME(renameargs) = 11;

		nfsstat
		NFSPROC_LINK(linkargs) = 12;

		nfsstat
		NFSPROC_SYMLINK(symlinkargs) = 13;

		diropres
		NFSPROC_MKDIR(createargs) = 14;

		nfsstat
		NFSPROC_RMDIR(diropargs) = 15;

		readdirres
		NFSPROC_READDIR(readdirargs) = 16;

		statfsres
		NFSPROC_STATFS(nfs_fh) = 17;
	} = 2;
} = 100003;

/*
 * Version 3 declarations and definitions.
 */

/*
 * Sizes
 */
const NFS3_FHSIZE         = 64;
const NFS3_COOKIEVERFSIZE = 8;
const NFS3_CREATEVERFSIZE = 8;
const NFS3_WRITEVERFSIZE  = 8;

/*
 * Basic data types
 */
typedef string		filename3<>;
typedef string		nfspath3<>;
typedef uint64		fileid3;
typedef uint64		cookie3;
typedef opaque		cookieverf3[NFS3_COOKIEVERFSIZE];
typedef opaque		createverf3[NFS3_CREATEVERFSIZE];
typedef opaque		writeverf3[NFS3_WRITEVERFSIZE];
typedef uint32		uid3;
typedef uint32		gid3;
typedef uint64		size3;
typedef uint64		offset3;
typedef uint32		mode3;
typedef uint32		count3;

/*
 * Error status
 */
enum nfsstat3 {
	NFS3_OK = 0,
	NFS3ERR_PERM = 1,
	NFS3ERR_NOENT = 2,
	NFS3ERR_IO = 5,
	NFS3ERR_NXIO = 6,
	NFS3ERR_ACCES = 13,
	NFS3ERR_EXIST = 17,
	NFS3ERR_XDEV = 18,
	NFS3ERR_NODEV = 19,
	NFS3ERR_NOTDIR = 20,
	NFS3ERR_ISDIR = 21,
	NFS3ERR_INVAL = 22,
	NFS3ERR_FBIG = 27,
	NFS3ERR_NOSPC = 28,
	NFS3ERR_ROFS = 30,
	NFS3ERR_MLINK = 31,
	NFS3ERR_NAMETOOLONG = 63,
	NFS3ERR_NOTEMPTY = 66,
	NFS3ERR_DQUOT = 69,
	NFS3ERR_STALE = 70,
	NFS3ERR_REMOTE = 71,
	NFS3ERR_BADHANDLE = 10001,
	NFS3ERR_NOT_SYNC = 10002,
	NFS3ERR_BAD_COOKIE = 10003,
	NFS3ERR_NOTSUPP = 10004,
	NFS3ERR_TOOSMALL = 10005,
	NFS3ERR_SERVERFAULT = 10006,
	NFS3ERR_BADTYPE = 10007,
	NFS3ERR_JUKEBOX = 10008
};

/*
 * File types
 */
enum ftype3 {
	NF3REG = 1,
	NF3DIR = 2,
	NF3BLK = 3,
	NF3CHR = 4,
	NF3LNK = 5,
	NF3SOCK = 6,
	NF3FIFO = 7
};

struct specdata3 {
	uint32	specdata1;
	uint32	specdata2;
};

/*
 * File access handle
 */
struct nfs_fh3 {
	opaque data<NFS3_FHSIZE>;
};

/*
 * Timeval
 */
struct nfstime3 {
	uint32 seconds;
	uint32 nseconds;
};

/*
 * File attributes
 */
struct fattr3 {
	ftype3	  type;
	mode3	  mode;
	uint32	  nlink;
	uid3	  uid;
	gid3	  gid;
	size3	  size;
	size3	  used;
	specdata3 rdev;
	uint64	  fsid;
	fileid3	  fileid;
	nfstime3  atime;
	nfstime3  mtime;
	nfstime3  ctime;
};

/*
 * File attributes
 */
union post_op_attr switch (bool attributes_follow) {
case TRUE:
	fattr3 attributes;
case FALSE:
	void;
};

struct wcc_attr {
	size3	 size;
	nfstime3 mtime;
	nfstime3 ctime;
};

union pre_op_attr switch (bool attributes_follow) {
case TRUE:
	wcc_attr attributes;
case FALSE:
	void;
};

struct wcc_data {
	pre_op_attr  before;
	post_op_attr after;
};

union post_op_fh3 switch (bool handle_follows) {
case TRUE:
	nfs_fh3 handle;
case FALSE:
	void;
};

enum time_how {
	DONT_CHANGE	   = 0,
	SET_TO_SERVER_TIME = 1,
	SET_TO_CLIENT_TIME = 2
};

union set_mode3 switch (bool set_it) {
case TRUE:
	mode3 mode;
default:
	void;
};

union set_uid3 switch (bool set_it) {
case TRUE:
	uid3 uid;
default:
	void;
};

union set_gid3 switch (bool set_it) {
case TRUE:
	gid3 gid;
default:
	void;
};

union set_size3 switch (bool set_it) {
case TRUE:
	size3	size;
default:
	void;
};

union set_atime switch (time_how set_it) {
case SET_TO_CLIENT_TIME:
	nfstime3 atime;
default:
	void;
};

union set_mtime switch (time_how set_it) {
case SET_TO_CLIENT_TIME:
	nfstime3 mtime;
default:
	void;
};

struct sattr3 {
	set_mode3 mode;
	set_uid3  uid;
	set_gid3  gid;
	set_size3 size;
	set_atime atime;
	set_mtime mtime;
};

struct diropargs3 {
	nfs_fh3   dir;
	filename3 name;
};

/*
 * GETATTR: Get file attributes
 */
struct GETATTR3args {
	nfs_fh3 object;
};

struct GETATTR3resok {
	fattr3 obj_attributes;
};

union GETATTR3res switch (nfsstat3 status) {
case NFS3_OK:
	GETATTR3resok resok;
default:
	void;
};

/*
 * SETATTR: Set file attributes
 */
union sattrguard3 switch (bool check) {
case TRUE:
	nfstime3 obj_ctime;
case FALSE:
	void;
};

struct SETATTR3args {
	nfs_fh3     object;
	sattr3	    new_attributes;
	sattrguard3 guard;
};

struct SETATTR3resok {
	wcc_data obj_wcc;
};

struct SETATTR3resfail {
	wcc_data obj_wcc;
};

union SETATTR3res switch (nfsstat3 status) {
case NFS3_OK:
	SETATTR3resok	resok;
default:
	SETATTR3resfail	resfail;
};

/*
 * LOOKUP: Lookup filename
 */
struct LOOKUP3args {
	diropargs3 what;
};

struct LOOKUP3resok {
	nfs_fh3		object;
	post_op_attr	obj_attributes;
	post_op_attr	dir_attributes;
};

struct LOOKUP3resfail {
	post_op_attr	dir_attributes;
};

union LOOKUP3res switch (nfsstat3 status) {
case NFS3_OK:
	LOOKUP3resok	resok;
default:
	LOOKUP3resfail	resfail;
};

/*
 * ACCESS: Check access permission
 */
const ACCESS3_READ	= 0x0001;
const ACCESS3_LOOKUP	= 0x0002;
const ACCESS3_MODIFY	= 0x0004;
const ACCESS3_EXTEND	= 0x0008;
const ACCESS3_DELETE	= 0x0010;
const ACCESS3_EXECUTE	= 0x0020;

struct ACCESS3args {
	nfs_fh3	object;
	uint32	access;
};

struct ACCESS3resok {
	post_op_attr	obj_attributes;
	uint32		access;
};

struct ACCESS3resfail {
	post_op_attr	obj_attributes;
};

union ACCESS3res switch (nfsstat3 status) {
case NFS3_OK:
	ACCESS3resok	resok;
default:
	ACCESS3resfail	resfail;
};

/*
 * READLINK: Read from symbolic link
 */
struct READLINK3args {
	nfs_fh3	symlink;
};

struct READLINK3resok {
	post_op_attr	symlink_attributes;
	nfspath3	data;
};

struct READLINK3resfail {
	post_op_attr	symlink_attributes;
};

union READLINK3res switch (nfsstat3 status) {
case NFS3_OK:
	READLINK3resok	 resok;
default:
	READLINK3resfail resfail;
};

/*
 * READ: Read from file
 */
struct READ3args {
	nfs_fh3		file;
	offset3		offset;
	count3		count;
};

struct READ3resok {
	post_op_attr	file_attributes;
	count3		count;
	bool		eof;
	opaque		data<>;
};

struct READ3resfail {
	post_op_attr	file_attributes;
};

union READ3res switch (nfsstat3 status) {
case NFS3_OK:
	READ3resok	resok;
default:
	READ3resfail	resfail;
};

/*
 * WRITE: Write to file
 */
enum stable_how {
	UNSTABLE  = 0,
	DATA_SYNC = 1,
	FILE_SYNC = 2
};

struct WRITE3args {
	nfs_fh3		file;
	offset3		offset;
	count3		count;
	stable_how	stable;
	opaque		data<>;
};

struct WRITE3resok {
	wcc_data	file_wcc;
	count3		count;
	stable_how	committed;
	writeverf3	verf;
};

struct WRITE3resfail {
	wcc_data	file_wcc;
};

union WRITE3res switch (nfsstat3 status) {
case NFS3_OK:
	WRITE3resok	resok;
default:
	WRITE3resfail	resfail;
};

/*
 * CREATE: Create a file
 */
enum createmode3 {
	UNCHECKED = 0,
	GUARDED	  = 1,
	EXCLUSIVE = 2
};

union createhow3 switch (createmode3 mode) {
case UNCHECKED:
case GUARDED:
	sattr3		obj_attributes;
case EXCLUSIVE:
	createverf3	verf;
};

struct CREATE3args {
	diropargs3	where;
	createhow3	how;
};

struct CREATE3resok {
	post_op_fh3	obj;
	post_op_attr	obj_attributes;
	wcc_data	dir_wcc;
};

struct CREATE3resfail {
	wcc_data	dir_wcc;
};

union CREATE3res switch (nfsstat3 status) {
case NFS3_OK:
	CREATE3resok	resok;
default:
	CREATE3resfail	resfail;
};

/*
 * MKDIR: Create a directory
 */
struct MKDIR3args {
	diropargs3	where;
	sattr3		attributes;
};

struct MKDIR3resok {
	post_op_fh3	obj;
	post_op_attr	obj_attributes;
	wcc_data	dir_wcc;
};

struct MKDIR3resfail {
	wcc_data	dir_wcc;
};

union MKDIR3res switch (nfsstat3 status) {
case NFS3_OK:
	MKDIR3resok	resok;
default:
	MKDIR3resfail	resfail;
};

/*
 * SYMLINK: Create a symbolic link
 */
struct symlinkdata3 {
	sattr3		symlink_attributes;
	nfspath3	symlink_data;
};

struct SYMLINK3args {
	diropargs3	where;
	symlinkdata3	symlink;
};

struct SYMLINK3resok {
	post_op_fh3	obj;
	post_op_attr	obj_attributes;
	wcc_data	dir_wcc;
};

struct SYMLINK3resfail {
	wcc_data	dir_wcc;
};

union SYMLINK3res switch (nfsstat3 status) {
case NFS3_OK:
	SYMLINK3resok	resok;
default:
	SYMLINK3resfail	resfail;
};

/*
 * MKNOD: Create a special file
 */
struct devicedata3 {
	sattr3		dev_attributes;
	specdata3	spec;
};

union mknoddata3 switch (ftype3 type) {
case NF3CHR:
case NF3BLK:
	devicedata3	device;
case NF3SOCK:
case NF3FIFO:
	sattr3		pipe_attributes;
default:
	void;
};

struct MKNOD3args {
	diropargs3	where;
	mknoddata3	what;
};

struct MKNOD3resok {
	post_op_fh3	obj;
	post_op_attr	obj_attributes;
	wcc_data	dir_wcc;
};

struct MKNOD3resfail {
	wcc_data	dir_wcc;
};

union MKNOD3res switch (nfsstat3 status) {
case NFS3_OK:
	MKNOD3resok	resok;
default:
	MKNOD3resfail	resfail;
};

/*
 * REMOVE: Remove a file
 */
struct REMOVE3args {
	diropargs3	object;
};

struct REMOVE3resok {
	wcc_data	dir_wcc;
};

struct REMOVE3resfail {
	wcc_data	dir_wcc;
};

union REMOVE3res switch (nfsstat3 status) {
case NFS3_OK:
	REMOVE3resok	resok;
default:
	REMOVE3resfail	resfail;
};

/*
 * RMDIR: Remove a directory
 */
struct RMDIR3args {
	diropargs3 object;
};

struct RMDIR3resok {
	wcc_data	dir_wcc;
};

struct RMDIR3resfail {
	wcc_data	dir_wcc;
};

union RMDIR3res switch (nfsstat3 status) {
case NFS3_OK:
	RMDIR3resok	resok;
default:
	RMDIR3resfail	resfail;
};

/*
 * RENAME: Rename a file or directory
 */
struct RENAME3args {
	diropargs3	from;
	diropargs3	to;
};

struct RENAME3resok {
	wcc_data	fromdir_wcc;
	wcc_data	todir_wcc;
};

struct RENAME3resfail {
	wcc_data	fromdir_wcc;
	wcc_data	todir_wcc;
};

union RENAME3res switch (nfsstat3 status) {
case NFS3_OK:
	RENAME3resok	resok;
default:
	RENAME3resfail	resfail;
};

/*
 * LINK: Create link to an object
 */
struct LINK3args {
	nfs_fh3		file;
	diropargs3	link;
};

struct LINK3resok {
	post_op_attr	file_attributes;
	wcc_data	linkdir_wcc;
};

struct LINK3resfail {
	post_op_attr	file_attributes;
	wcc_data	linkdir_wcc;
};

union LINK3res switch (nfsstat3 status) {
case NFS3_OK:
	LINK3resok	resok;
default:
	LINK3resfail	resfail;
};

/*
 * READDIR: Read from directory
 */
struct READDIR3args {
	nfs_fh3		dir;
	cookie3		cookie;
	cookieverf3	cookieverf;
	count3		count;
};

struct entry3 {
	fileid3		fileid;
	filename3	name;
	cookie3		cookie;
	entry3		*nextentry;
};

struct dirlist3 {
	entry3	*entries;
	bool	eof;
};

struct READDIR3resok {
	post_op_attr	dir_attributes;
	cookieverf3	cookieverf;
	dirlist3	reply;
};

struct READDIR3resfail {
	post_op_attr	dir_attributes;
};

union READDIR3res switch (nfsstat3 status) {
case NFS3_OK:
	READDIR3resok	resok;
default:
	READDIR3resfail	resfail;
};

/*
 * READDIRPLUS: Extended read from a directory
 */
struct READDIRPLUS3args {
	nfs_fh3		dir;
	cookie3		cookie;
	cookieverf3	cookieverf;
	count3		dircount;
	count3		maxcount;
};

struct entryplus3 {
	fileid3		fileid;
	filename3	name;
	cookie3		cookie;
	post_op_attr	name_attributes;
	post_op_fh3	name_handle;
	entryplus3	*nextentry;
};

struct dirlistplus3 {
	entryplus3	*entries;
	bool		eof;
};

struct READDIRPLUS3resok {
	post_op_attr	dir_attributes;
	cookieverf3	cookieverf;
	dirlistplus3	reply;
};

struct READDIRPLUS3resfail {
	post_op_attr	dir_attributes;
};

union READDIRPLUS3res switch (nfsstat3 status) {
case NFS3_OK:
	READDIRPLUS3resok	resok;
default:
	READDIRPLUS3resfail	resfail;
};

/*
 * FSSTAT: Get dynamic file system information
 */
struct FSSTAT3args {
	nfs_fh3	fsroot;
};

struct FSSTAT3resok {
	post_op_attr	obj_attributes;
	size3		tbytes;
	size3		fbytes;
	size3		abytes;
	size3		tfiles;
	size3		ffiles;
	size3		afiles;
	uint32		invarsec;
};

struct FSSTAT3resfail {
	post_op_attr	obj_attributes;
};

union FSSTAT3res switch (nfsstat3 status) {
case NFS3_OK:
	FSSTAT3resok	resok;
default:
	FSSTAT3resfail	resfail;
};

/*
 * FSINFO: Get static file system information
 */

const FSF3_LINK		= 0x0001;
const FSF3_SYMLINK	= 0x0002;
const FSF3_HOMOGENEOUS	= 0x0008;
const FSF3_CANSETTIME	= 0x0010;

struct FSINFO3args {
	nfs_fh3	fsroot;
};

struct FSINFO3resok {
	post_op_attr	obj_attributes;
	uint32		rtmax;
	uint32		rtpref;
	uint32		rtmult;
	uint32		wtmax;
	uint32		wtpref;
	uint32		wtmult;
	uint32		dtpref;
	size3		maxfilesize;
	nfstime3	time_delta;
	uint32		properties;
};

struct FSINFO3resfail {
	post_op_attr	obj_attributes;
};

union FSINFO3res switch (nfsstat3 status) {
case NFS3_OK:
	FSINFO3resok	resok;
default:
	FSINFO3resfail	resfail;
};

/*
 * PATHCONF: Retrieve POSIX information
 */
struct PATHCONF3args {
	nfs_fh3	object;
};

struct PATHCONF3resok {
	post_op_attr	obj_attributes;
	uint32		linkmax;
	uint32		name_max;
	bool		no_trunc;
	bool		chown_restricted;
	bool		case_insensitive;
	bool		case_preserving;
};

struct PATHCONF3resfail {
	post_op_attr	obj_attributes;
};

union PATHCONF3res switch (nfsstat3 status) {
case NFS3_OK:
	PATHCONF3resok	 resok;
default:
	PATHCONF3resfail resfail;
};

/*
 * COMMIT: Commit cached data on a server to stable storage
 */
struct COMMIT3args {
	nfs_fh3	file;
	offset3	offset;
	count3	count;
};

struct COMMIT3resok {
	wcc_data	file_wcc;
	writeverf3	verf;
};

struct COMMIT3resfail {
	wcc_data	file_wcc;
};

union COMMIT3res switch (nfsstat3 status) {
case NFS3_OK:
	COMMIT3resok	resok;
default:
	COMMIT3resfail	resfail;
};

/*
 * Remote file service routines
 */
program NFS3_PROGRAM {
	version NFS_V3 {
		void
		NFSPROC3_NULL(void) = 0;

		GETATTR3res
		NFSPROC3_GETATTR(GETATTR3args) = 1;

		SETATTR3res
		NFSPROC3_SETATTR(SETATTR3args) = 2;

		LOOKUP3res
		NFSPROC3_LOOKUP(LOOKUP3args) = 3;

		ACCESS3res
		NFSPROC3_ACCESS(ACCESS3args) = 4;

		READLINK3res
		NFSPROC3_READLINK(READLINK3args) = 5;

		READ3res
		NFSPROC3_READ(READ3args) = 6;

		WRITE3res
		NFSPROC3_WRITE(WRITE3args) = 7;

		CREATE3res
		NFSPROC3_CREATE(CREATE3args) = 8;

		MKDIR3res
		NFSPROC3_MKDIR(MKDIR3args) = 9;

		SYMLINK3res
		NFSPROC3_SYMLINK(SYMLINK3args) = 10;

		MKNOD3res
		NFSPROC3_MKNOD(MKNOD3args) = 11;

		REMOVE3res
		NFSPROC3_REMOVE(REMOVE3args) = 12;

		RMDIR3res
		NFSPROC3_RMDIR(RMDIR3args) = 13;

		RENAME3res
		NFSPROC3_RENAME(RENAME3args) = 14;

		LINK3res
		NFSPROC3_LINK(LINK3args) = 15;

		READDIR3res
		NFSPROC3_READDIR(READDIR3args) = 16;

		READDIRPLUS3res
		NFSPROC3_READDIRPLUS(READDIRPLUS3args) = 17;

		FSSTAT3res
		NFSPROC3_FSSTAT(FSSTAT3args) = 18;

		FSINFO3res
		NFSPROC3_FSINFO(FSINFO3args) = 19;

		PATHCONF3res
		NFSPROC3_PATHCONF(PATHCONF3args) = 20;

		COMMIT3res
		NFSPROC3_COMMIT(COMMIT3args) = 21;
	} = 3;
} = 100003;
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _NIS_H_RPCGEN
#define	_NIS_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <rpc/xdr.h>

#ifndef __nis_object_h
#define __nis_object_h

#define	NIS_MAXSTRINGLEN 255
#define	NIS_MAXNAMELEN 1024
#define	NIS_MAXATTRNAME 32
#define	NIS_MAXATTRVAL 2048
#define	NIS_MAXCOLUMNS 64
#define	NIS_MAXATTR 16
#define	NIS_MAXPATH 1024
#define	NIS_MAXREPLICAS 128
#define	NIS_MAXLINKS 16
#define	NIS_PK_NONE 0
#define	NIS_PK_DH 1
#define	NIS_PK_RSA 2
#define	NIS_PK_KERB 3
#define	NIS_PK_DHEXT 4

struct nis_attr {
	char *zattr_ndx;
	struct {
		u_int zattr_val_len;
		char *zattr_val_val;
	} zattr_val;
};
typedef struct nis_attr nis_attr;

typedef char *nis_name;

enum zotypes {
	BOGUS_OBJ = 0,
	NO_OBJ = 1,
	DIRECTORY_OBJ = 2,
	GROUP_OBJ = 3,
	TABLE_OBJ = 4,
	ENTRY_OBJ = 5,
	LINK_OBJ = 6,
	PRIVATE_OBJ = 7,
	NIS_BOGUS_OBJ = 0,
	NIS_NO_OBJ = 1,
	NIS_DIRECTORY_OBJ = 2,
	NIS_GROUP_OBJ = 3,
	NIS_TABLE_OBJ = 4,
	NIS_ENTRY_OBJ = 5,
	NIS_LINK_OBJ = 6,
	NIS_PRIVATE_OBJ = 7
};
typedef enum zotypes zotypes;

enum nstype {
	UNKNOWN = 0,
	NIS = 1,
	SUNYP = 2,
	IVY = 3,
	DNS = 4,
	X500 = 5,
	DNANS = 6,
	XCHS = 7,
	CDS = 8
};
typedef enum nstype nstype;

struct oar_mask {
	uint_t oa_rights;
	zotypes oa_otype;
};
typedef struct oar_mask oar_mask;

struct endpoint {
	char *uaddr;
	char *family;
	char *proto;
};
typedef struct endpoint endpoint;

struct nis_server {
	nis_name name;
	struct {
		u_int ep_len;
		endpoint *ep_val;
	} ep;
	uint_t key_type;
	netobj pkey;
};
typedef struct nis_server nis_server;

struct directory_obj {
	nis_name do_name;
	nstype do_type;
	struct {
		u_int do_servers_len;
		nis_server *do_servers_val;
	} do_servers;
	uint32_t do_ttl;
	struct {
		u_int do_armask_len;
		oar_mask *do_armask_val;
	} do_armask;
};
typedef struct directory_obj directory_obj;
#define	EN_BINARY 1
#define	EN_CRYPT 2
#define	EN_XDR 4
#define	EN_MODIFIED 8
#define	EN_ASN1 64

struct entry_col {
	uint_t ec_flags;
	struct {
		u_int ec_value_len;
		char *ec_value_val;
	} ec_value;
};
typedef struct entry_col entry_col;

struct entry_obj {
	char *en_type;
	struct {
		u_int en_cols_len;
		entry_col *en_cols_val;
	} en_cols;
};
typedef struct entry_obj entry_obj;

struct group_obj {
	uint_t gr_flags;
	struct {
		u_int gr_members_len;
		nis_name *gr_members_val;
	} gr_members;
};
typedef struct group_obj group_obj;

struct link_obj {
	zotypes li_rtype;
	struct {
		u_int li_attrs_len;
		nis_attr *li_attrs_val;
	} li_attrs;
	nis_name li_name;
};
typedef struct link_obj link_obj;
#define	TA_BINARY 1
#define	TA_CRYPT 2
#define	TA_XDR 4
#define	TA_SEARCHABLE 8
#define	TA_CASE 16
#define	TA_MODIFIED 32
#define	TA_ASN1 64

struct table_col {
	char *tc_name;
	uint_t tc_flags;
	uint_t tc_rights;
};
typedef struct table_col table_col;

struct table_obj {
	char *ta_type;
	int ta_maxcol;
	u_char ta_sep;
	struct {
		u_int ta_cols_len;
		table_col *ta_cols_val;
	} ta_cols;
	char *ta_path;
};
typedef struct table_obj table_obj;

struct objdata {
	zotypes zo_type;
	union {
		struct directory_obj di_data;
		struct group_obj gr_data;
		struct table_obj ta_data;
		struct entry_obj en_data;
		struct link_obj li_data;
		struct {
			u_int po_data_len;
			char *po_data_val;
		} po_data;
	} objdata_u;
};
typedef struct objdata objdata;

struct nis_oid {
	uint32_t ctime;
	uint32_t mtime;
};
typedef struct nis_oid nis_oid;

struct nis_object {
	nis_oid zo_oid;
	nis_name zo_name;
	nis_name zo_owner;
	nis_name zo_group;
	nis_name zo_domain;
	uint_t zo_access;
	uint32_t zo_ttl;
	objdata zo_data;
};
typedef struct nis_object nis_object;

#endif /* if __nis_object_h */


enum log_entry_t {
	LOG_NOP = 0,
	ADD_NAME = 1,
	REM_NAME = 2,
	MOD_NAME_OLD = 3,
	MOD_NAME_NEW = 4,
	ADD_IBASE = 5,
	REM_IBASE = 6,
	MOD_IBASE = 7,
	UPD_STAMP = 8
};
typedef enum log_entry_t log_entry_t;

struct log_entry {
	uint32_t le_time;
	log_entry_t le_type;
	nis_name le_princp;
	nis_name le_name;
	struct {
		u_int le_attrs_len;
		nis_attr *le_attrs_val;
	} le_attrs;
	nis_object le_object;
};
typedef struct log_entry log_entry;

struct nis_tag {
	u_int tag_type;
	char *tag_val;
};
typedef struct nis_tag nis_tag;
/*
 * Structures used for server binding.
 */

struct nis_bound_endpoint {
	endpoint ep;
	int generation;
	int rank;
	u_int flags;
	int hostnum;
	int epnum;
	nis_name uaddr;
	endpoint cbep;
};
typedef struct nis_bound_endpoint nis_bound_endpoint;


struct nis_bound_directory {
	int generation;
	int min_rank;
	int optimal_rank;
	directory_obj dobj;
	struct {
		u_int BEP_len;
		nis_bound_endpoint *BEP_val;
	} BEP;
};
typedef struct nis_bound_directory nis_bound_directory;

#define bep_len BEP.BEP_len
#define bep_val BEP.BEP_val

struct nis_active_endpoint {
	endpoint ep;
	nis_name hostname;
	int rank;
	int uaddr_generation;
	nis_name uaddr;
	int cbep_generation;
	endpoint cbep;
};
typedef struct nis_active_endpoint nis_active_endpoint;

/* defines for nis_bound_endpoint.flags */
#define NIS_BOUND 0x1
#define NIS_TRANSIENT_ERRORS 0x2
/*
 * Generic "hash" datastructures, used by all types of hashed data.
 */
struct nis_hash_data {
	nis_name		name;	   /* NIS name of hashed item      */
	int			keychain;  /* It's hash key (for pop)      */
	struct nis_hash_data	*next;	   /* Hash collision pointer       */
	struct nis_hash_data	*prv_item; /* A serial, doubly linked list */
	struct nis_hash_data	*nxt_item; /* of items in the hash table   */
};
typedef struct nis_hash_data NIS_HASH_ITEM;

struct nis_hash_table {
	NIS_HASH_ITEM	*keys[64];	/* A hash table of items           */
	NIS_HASH_ITEM	*first;		/* The first "item" in serial list */
};
typedef struct nis_hash_table NIS_HASH_TABLE;

/* Structure for storing dynamically allocated static data */
struct nis_sdata {
	void	*buf;	/* Memory allocation pointer 	*/
	u_int	size;	/* Buffer size			*/
};

/* Generic client creating flags */
#define ZMH_VC		1
#define ZMH_DG		2
#define ZMH_AUTH	4
#define ZMH_NOFALLBACK 8

/* Testing Access rights for objects */

#define NIS_READ_ACC		1
#define NIS_MODIFY_ACC		2
#define NIS_CREATE_ACC		4
#define NIS_DESTROY_ACC	8
/* Test macros. a == access rights, m == desired rights. */
#define NIS_WORLD(a, m)	(((a) & (m)) != 0)
#define NIS_GROUP(a, m)	(((a) & ((m) << 8)) != 0)
#define NIS_OWNER(a, m)	(((a) & ((m) << 16)) != 0)
#define NIS_NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
/* 
 * EOL Alert - The following non-prefixed test macros are 
 * here for backward compatability, and will be not be present
 * in future releases - use the NIS_*() macros above.
 */
#define WORLD(a, m)	(((a) & (m)) != 0)
#define GROUP(a, m)	(((a) & ((m) << 8)) != 0)
#define OWNER(a, m)	(((a) & ((m) << 16)) != 0)
#define NOBODY(a, m)	(((a) & ((m) << 24)) != 0)

#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
#define WORLD_DEFAULT (NIS_READ_ACC)
#define GROUP_DEFAULT (NIS_READ_ACC << 8)
#define OWNER_DEFAULT ((NIS_READ_ACC +\
			 NIS_MODIFY_ACC +\
			 NIS_CREATE_ACC +\
			 NIS_DESTROY_ACC) << 16)
#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)

/* Result manipulation defines ... */
#define NIS_RES_NUMOBJ(x)	((x)->objects.objects_len)
#define NIS_RES_OBJECT(x)	((x)->objects.objects_val)
#define NIS_RES_COOKIE(x)	((x)->cookie)
#define NIS_RES_STATUS(x)	((x)->status)

/* These defines make getting at the variant part of the object easier. */
#define TA_data zo_data.objdata_u.ta_data
#define EN_data zo_data.objdata_u.en_data
#define DI_data zo_data.objdata_u.di_data
#define LI_data zo_data.objdata_u.li_data
#define GR_data zo_data.objdata_u.gr_data

#define __type_of(o) ((o)->zo_data.zo_type)

/* Declarations for the internal subroutines in nislib.c */
enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
typedef enum name_pos name_pos;

/*
 * Defines for getting at column data in entry objects. Because RPCGEN
 * generates some rather wordy structures, we create some defines that
 * collapse the needed keystrokes to access a particular value using
 * these definitions they take an nis_object *, and an int and return
 * a u_char * for Value, and an int for length.
 */
#define ENTRY_VAL(obj, col) \
	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
#define ENTRY_LEN(obj, col) \
	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len



/* XDR function declarations (normally rpcgen-generated, pre-generated here
 * because rpcgen cannot handle %#define line continuations in nis.x) */
extern  bool_t xdr_nis_attr(XDR *, nis_attr*);
extern  bool_t xdr_nis_name(XDR *, nis_name*);
extern  bool_t xdr_zotypes(XDR *, zotypes*);
extern  bool_t xdr_nstype(XDR *, nstype*);
extern  bool_t xdr_oar_mask(XDR *, oar_mask*);
extern  bool_t xdr_endpoint(XDR *, endpoint*);
extern  bool_t xdr_nis_server(XDR *, nis_server*);
extern  bool_t xdr_directory_obj(XDR *, directory_obj*);
extern  bool_t xdr_entry_col(XDR *, entry_col*);
extern  bool_t xdr_entry_obj(XDR *, entry_obj*);
extern  bool_t xdr_group_obj(XDR *, group_obj*);
extern  bool_t xdr_link_obj(XDR *, link_obj*);
extern  bool_t xdr_table_col(XDR *, table_col*);
extern  bool_t xdr_table_obj(XDR *, table_obj*);
extern  bool_t xdr_objdata(XDR *, objdata*);
extern  bool_t xdr_nis_oid(XDR *, nis_oid*);
extern  bool_t xdr_nis_object(XDR *, nis_object*);
extern  bool_t xdr_log_entry_t(XDR *, log_entry_t*);
extern  bool_t xdr_log_entry(XDR *, log_entry*);
extern  bool_t xdr_nis_tag(XDR *, nis_tag*);
extern  bool_t xdr_nis_bound_endpoint(XDR *, nis_bound_endpoint*);
extern  bool_t xdr_nis_bound_directory(XDR *, nis_bound_directory*);
extern  bool_t xdr_nis_active_endpoint(XDR *, nis_active_endpoint*);

#ifdef __cplusplus
}
#endif

/* Prototypes, and extern declarations for the NIS library functions. */
#include <rpcsvc/nislib.h>
#endif /* __NIS_RPCGEN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * RPC Language Protocol description file for NIS Plus
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 *
 * From 4.1 : @(#)nis.x	1.61 Copyright 1989 Sun Microsystems
 */

/* This gets stuffed into the source files. */
#if RPC_HDR
%#include <rpc/xdr.h>
#endif
#if defined(RPC_XDR) || defined(RPC_CLNT) || defined(RPC_SVC)
%#ifndef xdr_uint32_t
%#define xdr_uint32_t	xdr_u_int
%#endif
%#ifndef xdr_uint_t
%#define xdr_uint_t	xdr_u_int
%#endif
#endif
#if RPC_SVC
%#include "nis_svc.h"
#endif

/* Include the RPC Language description of NIS objects */
#include "nis_object.x"




/* 
 * These are the type of entries that are stored in the transaction log, 
 * note that modifications will appear as two entries, for names, they have
 * a "OLD" entry followed by a "NEW" entry. For entries in tables, there
 * is a remove followed by an add. It is done this way so that we can read
 * the log backwards to back out transactions and forwards to propogate
 * updated.
 */
enum log_entry_t {
	LOG_NOP = 0,
	ADD_NAME = 1,		/* Name Added to name space 		  */
	REM_NAME = 2,		/* Name removed from name space 	  */
	MOD_NAME_OLD = 3,	/* Name was modified in the name space 	  */
	MOD_NAME_NEW = 4,	/* Name was modified in the name space 	  */
	ADD_IBASE = 5,		/* Entry added to information base 	  */
	REM_IBASE = 6,		/* Entry removed from information base    */
	MOD_IBASE = 7,		/* Entry was modified in information base */
	UPD_STAMP = 8		/* Update timestamp (used as fenceposts)  */
};
	
/*
 * This result is returned from the name service when it is requested to 
 * dump logged entries from its transaction log. Information base updates
 * will have the name of the information base in the le_name field and
 * a canonical set of attribute/value pairs to fully specify the entry's
 * 'name'. 
 */
struct log_entry {
	uint32_t	le_time;	/* Time in seconds 		*/
	log_entry_t	le_type;	/* Type of log entry 		*/
	nis_name	le_princp;	/* Principal making the change	*/
	nis_name	le_name;	/* Name of table/dir involved 	*/
	nis_attr	le_attrs<>;	/* List of AV pairs.		*/
	nis_object	le_object;	/* Actual object value 		*/
};


/*
 * This structure defines a generic NIS tag list. The taglist contains
 * zero or tags, each of which is a type and a value. (u_int). 
 * These are used to report statistics (see tag definitions below)
 * and to set or reset state variables.
 */
struct nis_tag {
	u_int	tag_type;	/* Statistic tag (may vary) 	 */
	string	tag_val<>;	/* Statistic value may also vary */
};


%/*
% * Structures used for server binding.
% */
struct nis_bound_endpoint {
	endpoint ep;
	int generation;
	int rank;
	u_int flags;
	int hostnum;
	int epnum;
	nis_name uaddr;
	endpoint cbep;
};
typedef struct nis_bound_endpoint nis_bound_endpoint;
 
struct nis_bound_directory {
	int generation;
	int min_rank;           /* minimum rank of bound endpoints */
	int optimal_rank;       /* best possible rank of all endpoints */
	directory_obj dobj;
	nis_bound_endpoint BEP<>;
};
typedef struct nis_bound_directory nis_bound_directory;
%#define bep_len BEP.BEP_len
%#define bep_val BEP.BEP_val
 
struct nis_active_endpoint {
	endpoint ep;
	nis_name hostname;
	int rank;
	int uaddr_generation;
	nis_name uaddr;
	int cbep_generation;
	endpoint cbep;
};
typedef struct nis_active_endpoint nis_active_endpoint;
 
%/* defines for nis_bound_endpoint.flags */
%#define NIS_BOUND 0x1
%#define NIS_TRANSIENT_ERRORS 0x2



/* 
 * What's going on here? Well, it's like this. When the service
 * is being compiled it wants to have the service definition specific
 * info included, and when the client is being compiled it wants that
 * info. This includes the appropriate file which was generated by
 * make in the protocols directory (probably /usr/include/rpcsvc). 
 */
#ifdef RPC_SVC
%#include "nis_svc.h"
#endif
#ifdef RPC_CLNT
%#include "nis_clnt.h"
#endif


/*
 * Included below are the defines that become part of nis.h,
 * they are technically not part of the protocol, but do define
 * key aspects of the implementation and are therefore useful
 * in building a conforming server or client.
 */
#if RPC_HDR
%/*
% * Generic "hash" datastructures, used by all types of hashed data.
% */
%struct nis_hash_data {
%	nis_name		name;	   /* NIS name of hashed item      */
%	int			keychain;  /* It's hash key (for pop)      */
%	struct nis_hash_data	*next;	   /* Hash collision pointer       */
%	struct nis_hash_data	*prv_item; /* A serial, doubly linked list */
%	struct nis_hash_data	*nxt_item; /* of items in the hash table   */
%};
%typedef struct nis_hash_data NIS_HASH_ITEM;
%
%struct nis_hash_table {
%	NIS_HASH_ITEM	*keys[64];	/* A hash table of items           */
%	NIS_HASH_ITEM	*first;		/* The first "item" in serial list */
%};
%typedef struct nis_hash_table NIS_HASH_TABLE;
%
%/* Structure for storing dynamically allocated static data */
%struct nis_sdata {
%	void	*buf;	/* Memory allocation pointer 	*/
%	u_int	size;	/* Buffer size			*/
%};
%
%/* Generic client creating flags */
%#define ZMH_VC		1
%#define ZMH_DG		2
%#define ZMH_AUTH	4
%#define ZMH_NOFALLBACK 8
%
%/* Testing Access rights for objects */
%
%#define NIS_READ_ACC		1
%#define NIS_MODIFY_ACC		2
%#define NIS_CREATE_ACC		4
%#define NIS_DESTROY_ACC	8
%/* Test macros. a == access rights, m == desired rights. */
%#define NIS_WORLD(a, m)	(((a) & (m)) != 0)
%#define NIS_GROUP(a, m)	(((a) & ((m) << 8)) != 0)
%#define NIS_OWNER(a, m)	(((a) & ((m) << 16)) != 0)
%#define NIS_NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
%/* 
% * EOL Alert - The following non-prefixed test macros are 
% * here for backward compatability, and will be not be present
% * in future releases - use the NIS_*() macros above.
% */
%#define WORLD(a, m)	(((a) & (m)) != 0)
%#define GROUP(a, m)	(((a) & ((m) << 8)) != 0)
%#define OWNER(a, m)	(((a) & ((m) << 16)) != 0)
%#define NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
%
%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
%#define WORLD_DEFAULT (NIS_READ_ACC)
%#define GROUP_DEFAULT (NIS_READ_ACC << 8)
%#define OWNER_DEFAULT ((NIS_READ_ACC +\
%			 NIS_MODIFY_ACC +\
%			 NIS_CREATE_ACC +\
%			 NIS_DESTROY_ACC) << 16)
%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
%
%/* Result manipulation defines ... */
%#define NIS_RES_NUMOBJ(x)	((x)->objects.objects_len)
%#define NIS_RES_OBJECT(x)	((x)->objects.objects_val)
%#define NIS_RES_COOKIE(x)	((x)->cookie)
%#define NIS_RES_STATUS(x)	((x)->status)
%
%/* These defines make getting at the variant part of the object easier. */
%#define TA_data zo_data.objdata_u.ta_data
%#define EN_data zo_data.objdata_u.en_data
%#define DI_data zo_data.objdata_u.di_data
%#define LI_data zo_data.objdata_u.li_data
%#define GR_data zo_data.objdata_u.gr_data
%
%#define __type_of(o) ((o)->zo_data.zo_type)
%
%/* Declarations for the internal subroutines in nislib.c */
%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
%typedef enum name_pos name_pos;
%
%/*
% * Defines for getting at column data in entry objects. Because RPCGEN
% * generates some rather wordy structures, we create some defines that
% * collapse the needed keystrokes to access a particular value using
% * these definitions they take an nis_object *, and an int and return
% * a u_char * for Value, and an int for length.
% */
%#define ENTRY_VAL(obj, col) \
%	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
%#define ENTRY_LEN(obj, col) \
%	(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
%
%
%
%#ifdef __cplusplus
%}
%#endif
%
%/* Prototypes, and extern declarations for the NIS library functions. */
%#include <rpcsvc/nislib.h>
%#endif /* __NIS_RPCGEN_H */
%/* EDIT_START */
%
%/*
% * nis_3.h
% * 
% * This file contains definitions that are only of interest to the actual
% * service daemon and client stubs. Normal users of NIS will not include
% * this file.
% *
% * NOTE : This include file is automatically created by a combination 
% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
% * and then remake this file.
% */
%#ifndef __nis_3_h
%#define __nis_3_h
%#ifdef __cplusplus
%extern "C" {
%#endif
#endif
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*
 * This header file defines the interface to the NIS database. All
 * implementations of the database must export at least these routines.
 * They must also follow the conventions set herein. See the implementors
 * guide for specific semantics that are required.
 */

#ifndef	_RPCSVC_NIS_DB_H
#define	_RPCSVC_NIS_DB_H

#include <rpc/rpc.h>
#include <rpcsvc/nis.h>

#ifdef	__cplusplus
extern "C" {
#endif

enum db_status {
	DB_SUCCESS = 0,
	DB_NOTFOUND = 1,
	DB_NOTUNIQUE = 2,
	DB_BADTABLE = 3,
	DB_BADQUERY = 4,
	DB_BADOBJECT = 5,
	DB_MEMORY_LIMIT = 6,
	DB_STORAGE_LIMIT = 7,
	DB_INTERNAL_ERROR = 8
};
typedef enum db_status db_status;

enum db_action {
	DB_LOOKUP = 0,
	DB_REMOVE = 1,
	DB_ADD = 2,
	DB_FIRST = 3,
	DB_NEXT = 4,
	DB_ALL = 5,
	DB_RESET_NEXT = 6
};
typedef enum db_action db_action;

typedef entry_obj *entry_object_p;

typedef struct {
	uint_t db_next_desc_len;
	char *db_next_desc_val;
} db_next_desc;

struct db_result {
	db_status status;
	db_next_desc nextinfo;
	struct {
		uint_t objects_len;
		entry_object_p *objects_val;
	} objects;
	long ticks;
};
typedef struct db_result db_result;

/*
 * Prototypes for the database functions.
 */

extern bool_t db_initialize(char *);
extern db_status db_create_table(char *, table_obj *);
extern db_status db_destroy_table(char *);
extern db_result *db_first_entry(char *, int, nis_attr *);
extern db_result *db_next_entry(char *, db_next_desc *);
extern db_result *db_reset_next_entry(char *, db_next_desc *);
extern db_result *db_list_entries(char *, int, nis_attr *);
extern db_result *db_add_entry(char *, int,  nis_attr *, entry_obj *);
extern db_result *db_remove_entry(char *, int, nis_attr *);
extern db_status db_checkpoint(char *);
extern db_status db_standby(char *);
extern db_status db_table_exists(char *);
extern db_status db_unload_table(char *);
extern void db_free_result(db_result *);

#ifdef __cplusplus
}
#endif

#endif	/* _RPCSVC_NIS_DB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *	nis_object.x
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#if RPC_HDR
%
%#ifndef __nis_object_h
%#define __nis_object_h
%
#endif
/* 
 * 	This file defines the format for a NIS object in RPC language.
 * It is included by the main .x file and the database access protocol
 * file. It is common because both of them need to deal with the same
 * type of object. Generating the actual code though is a bit messy because
 * the nis.x file and the nis_dba.x file will generate xdr routines to 
 * encode/decode objects when only one set is needed. Such is life when
 * one is using rpcgen.
 *
 * Note, the protocol doesn't specify any limits on such things as
 * maximum name length, number of attributes, etc. These are enforced
 * by the database backend. When you hit them you will no. Also see
 * the db_getlimits() function for fetching the limit values.
 *
 */

#if defined(RPC_XDR) || defined(RPC_SVC) || defined(RPC_CLNT)
%#ifndef xdr_uint32_t
%#define xdr_uint32_t xdr_u_int
%#endif
%#ifndef xdr_uint_t
%#define xdr_uint_t xdr_u_int
%#endif
#endif

/* Some manifest constants, chosen to maximize flexibility without
 * plugging the wire full of data.
 */
const NIS_MAXSTRINGLEN = 255;
const NIS_MAXNAMELEN   = 1024;
const NIS_MAXATTRNAME  = 32;
const NIS_MAXATTRVAL   = 2048;
const NIS_MAXCOLUMNS   = 64;
const NIS_MAXATTR      = 16;
const NIS_MAXPATH      = 1024;
const NIS_MAXREPLICAS  = 128;
const NIS_MAXLINKS     = 16;

const NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
const NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
const NIS_PK_RSA       = 2;	/* Public key if RSA type */
const NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
const NIS_PK_DHEXT     = 4;	/* Extended Diffie-Hellman for RPC-GSS */

/*
 * The fundamental name type of NIS. The name may consist of two parts,
 * the first being the fully qualified name, and the second being an 
 * optional set of attribute/value pairs.
 */
struct nis_attr {
	string	zattr_ndx<>;	/* name of the index 		*/
	opaque	zattr_val<>;	/* Value for the attribute. 	*/
};

typedef string nis_name<>;	/* The NIS name itself. */

/* NIS object types are defined by the following enumeration. The numbers
 * they use are based on the following scheme :
 *		     0 - 1023 are reserved for Sun,
 * 		1024 - 2047 are defined to be private to a particular tree.
 *		2048 - 4095 are defined to be user defined.
 *		4096 - ...  are reserved for future use.
 *
 * EOL Alert - The non-prefixed names are present for backward
 * compatability only, and will not exist in future releases. Use
 * the NIS_* names for future compatability.
 */

enum zotypes {
	
	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
	LINK_OBJ   	= 6, 	/* A name link.				*/
	PRIVATE_OBJ  	= 7, 	/* Private object (all opaque data) 	*/
	
	NIS_BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
	NIS_NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
	NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain 	*/
	NIS_GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
	NIS_TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
	NIS_ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
	NIS_LINK_OBJ	= 6, 	/* A name link.				*/
	NIS_PRIVATE_OBJ  = 7 /* Private object (all opaque data) */
};

/*
 * The types of Name services NIS knows about. They are enumerated
 * here. The Binder code will use this type to determine if it has
 * a set of library routines that will access the indicated name service.
 */
enum nstype {
	UNKNOWN = 0,
	NIS = 1,	/* Nis Plus Service		*/
	SUNYP = 2,	/* Old NIS Service		*/
	IVY = 3,	/* Nis Plus Plus Service	*/
	DNS = 4,	/* Domain Name Service		*/
	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
	DNANS = 6,	/* Digital DECNet Name Service	*/
	XCHS = 7,	/* Xerox ClearingHouse Service	*/
	CDS= 8
};

/*
 * DIRECTORY - The name service object. These objects identify other name
 * servers that are serving some portion of the name space. Each has a
 * type associated with it. The resolver library will note whether or not
 * is has the needed routines to access that type of service. 
 * The oarmask structure defines an access rights mask on a per object 
 * type basis for the name spaces. The only bits currently used are 
 * create and destroy. By enabling or disabling these access rights for
 * a specific object type for a one of the accessor entities (owner,
 * group, world) the administrator can control what types of objects 
 * may be freely added to the name space and which require the 
 * administrator's approval.
 */
struct oar_mask {
	uint_t	oa_rights;	/* Access rights mask 	*/
	zotypes	oa_otype;	/* Object type 		*/
};

struct endpoint {
	string		uaddr<>;
	string		family<>;   /* Transport family (INET, OSI, etc) */
	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
};

/*
 * Note: pkey is a netobj which is limited to 1024 bytes which limits the
 * keysize to 8192 bits. This is consider to be a reasonable limit for
 * the expected lifetime of this service.
 */
struct nis_server {
	nis_name	name; 	 	/* Principal name of the server  */
	endpoint	ep<>;  		/* Universal addr(s) for server  */
	uint_t		key_type;	/* Public key type		 */
	netobj		pkey;		/* server's public key  	 */
};

struct directory_obj {
	nis_name   do_name;	 /* Name of the directory being served   */
	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
	nis_server do_servers<>; /* <0> == Primary name server     	 */
	uint32_t   do_ttl;	 /* Time To Live (for caches) 		 */
	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
};

/* 
 * ENTRY - This is one row of data from an information base. 
 * The type value is used by the client library to convert the entry to 
 * it's internal structure representation. The Table name is a back pointer
 * to the table where the entry is stored. This allows the client library 
 * to determine where to send a request if the client wishes to change this
 * entry but got to it through a LINK rather than directly.
 * If the entry is a "standalone" entry then this field is void.
 */
const EN_BINARY   = 1;	/* Indicates value is binary data 	*/
const EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
const EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
const EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
const EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */

struct entry_col {
	uint_t	ec_flags;	/* Flags for this value */
	opaque	ec_value<>;	/* It's textual value	*/
};

struct entry_obj {
	string 	en_type<>;	/* Type of entry such as "passwd" */
	entry_col en_cols<>;	/* Value for the entry		  */
};

/*
 * GROUP - The group object contains a list of NIS principal names. Groups
 * are used to authorize principals. Each object has a set of access rights
 * for members of its group. Principal names in groups are in the form 
 * name.directory and recursive groups are expressed as @groupname.directory
 */
struct group_obj {
	uint_t		gr_flags;	/* Flags controlling group	*/
	nis_name	gr_members<>;  	/* List of names in group 	*/
};

/*
 * LINK - This is the LINK object. It is quite similar to a symbolic link
 * in the UNIX filesystem. The attributes in the main object structure are
 * relative to the LINK data and not what it points to (like the file system)
 * "modify" privleges here indicate the right to modify what the link points
 * at and not to modify that actual object pointed to by the link.
 */
struct link_obj {
	zotypes	 li_rtype;	/* Real type of the object	*/
	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
	nis_name li_name; 	/* The object's real NIS name	*/
};

/*
 * TABLE - This is the table object. It implements a simple 
 * data base that applications and use for configuration or 
 * administration purposes. The role of the table is to group together
 * a set of related entries. Tables are the simple database component
 * of NIS. Like many databases, tables are logically divided into columns
 * and rows. The columns are labeled with indexes and each ENTRY makes
 * up a row. Rows may be addressed within the table by selecting one
 * or more indexes, and values for those indexes. Each row which has
 * a value for the given index that matches the desired value is returned.
 * Within the definition of each column there is a flags variable, this
 * variable contains flags which determine whether or not the column is
 * searchable, contains binary data, and access rights for the entry objects
 * column value. 
 */

const TA_BINARY     = 1;	/* Means table data is binary 		*/
const TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
const TA_XDR        = 4;	/* Means value is XDR encoded		*/
const TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
const TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
const TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
const TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */

struct table_col {
	string	tc_name<64>;	/* Column Name 	 	   */
	uint_t	tc_flags;	/* control flags	   */
	uint_t	tc_rights;	/* Access rights mask	   */
};

struct table_obj {
	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
	int	  ta_maxcol;	 /* Total number of columns	*/
	u_char	  ta_sep;	 /* Separator character 	*/
	table_col ta_cols<>; 	 /* The number of table indexes */
	string	  ta_path<>;	 /* A search path for this table */
};

/*
 * This union joins together all of the currently known objects. 
 */
union objdata switch (zotypes zo_type) {
        case NIS_DIRECTORY_OBJ :
                struct directory_obj di_data;
        case NIS_GROUP_OBJ :
                struct group_obj gr_data;
        case NIS_TABLE_OBJ :
                struct table_obj ta_data;
        case NIS_ENTRY_OBJ:
                struct entry_obj en_data;
        case NIS_LINK_OBJ :
                struct link_obj li_data;
        case NIS_PRIVATE_OBJ :
                opaque	po_data<>;
	case NIS_NO_OBJ :
		void;
        case NIS_BOGUS_OBJ :
		void;
        default :
                void;
};

/*
 * This is the basic NIS object data type. It consists of a generic part
 * which all objects contain, and a specialized part which varies depending
 * on the type of the object. All of the specialized sections have been
 * described above. You might have wondered why they all start with an 
 * integer size, followed by the useful data. The answer is, when the 
 * server doesn't recognize the type returned it treats it as opaque data. 
 * And the definition for opaque data is {int size; char *data;}. In this
 * way, servers and utility routines that do not understand a given type
 * may still pass it around. One has to be careful in setting
 * this variable accurately, it must take into account such things as
 * XDR padding of structures etc. The best way to set it is to note one's
 * position in the XDR encoding stream, encode the structure, look at the
 * new position and calculate the size. 
 */
struct nis_oid {
	uint32_t ctime;		/* Time of objects creation 	*/
	uint32_t mtime;		/* Time of objects modification */
};

struct nis_object {
	nis_oid	 zo_oid;	/* object identity verifier.		*/ 
	nis_name zo_name;	/* The NIS name for this object		*/
	nis_name zo_owner;	/* NIS name of object owner.		*/
	nis_name zo_group;	/* NIS name of access group.		*/
	nis_name zo_domain;	/* The administrator for the object	*/
	uint_t	 zo_access;	/* Access rights (owner, group, world)	*/
	uint32_t zo_ttl;	/* Object's time to live in seconds.	*/
	objdata	 zo_data;	/* Data structure for this type 	*/
};
#if RPC_HDR
%
%#endif /* if __nis_object_h */
%
#endif
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * nislib.h
 *
 * This file contains the interfaces that are visible in the SunOS 5.x
 * implementation of NIS Plus.
 */

#ifndef	_RPCSVC_NISLIB_H
#define	_RPCSVC_NISLIB_H


#ifdef __cplusplus
extern "C" {
#endif

extern name_pos nis_dir_cmp(nis_name, nis_name);

extern nis_name nis_domain_of(nis_name);
extern nis_name nis_leaf_of(nis_name);
extern nis_name nis_leaf_of_r(const nis_name, char *, size_t);
extern nis_name nis_name_of(nis_name);
extern nis_name nis_local_group(void);
extern nis_name nis_local_directory(void);
extern nis_name nis_local_host(void);

extern void nis_destroy_object(nis_object *);
extern nis_object *nis_clone_object(nis_object *, nis_object *);
extern nis_object *nis_read_obj(char *);
extern int nis_write_obj(char *, nis_object *);

extern void *nis_get_static_storage(struct nis_sdata *, uint_t, uint_t);
extern nis_name __nis_rpc_domain(void);

CLIENT *__nis_clnt_create(int, struct netconfig *, char *, struct netbuf *,
			int, int, int, int, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _RPCSVC_NISLIB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1994, by Sun Microsystems, Inc.
 */

#ifndef	_RPCSVC_RPC_SZTYPES_H
#define	_RPCSVC_RPC_SZTYPES_H

#include <rpc/rpc_sztypes.h>

#endif	/* _RPCSVC_RPC_SZTYPES_H */
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _RQUOTA_H_RPCGEN
#define	_RQUOTA_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

#define	RQ_PATHLEN 1024

struct getquota_args {
	char *gqa_pathp;
	int32_t gqa_uid;
};
typedef struct getquota_args getquota_args;

struct rquota {
	int32_t rq_bsize;
	bool_t rq_active;
	uint32_t rq_bhardlimit;
	uint32_t rq_bsoftlimit;
	uint32_t rq_curblocks;
	uint32_t rq_fhardlimit;
	uint32_t rq_fsoftlimit;
	uint32_t rq_curfiles;
	uint32_t rq_btimeleft;
	uint32_t rq_ftimeleft;
};
typedef struct rquota rquota;

enum gqr_status {
	Q_OK = 1,
	Q_NOQUOTA = 2,
	Q_EPERM = 3
};
typedef enum gqr_status gqr_status;

struct getquota_rslt {
	gqr_status status;
	union {
		rquota gqr_rquota;
	} getquota_rslt_u;
};
typedef struct getquota_rslt getquota_rslt;

#define	RQUOTAPROG	100011
#define	RQUOTAVERS	1

#if defined(__STDC__) || defined(__cplusplus)
#define	RQUOTAPROC_GETQUOTA	1
extern  getquota_rslt * rquotaproc_getquota_1(getquota_args *, CLIENT *);
extern  getquota_rslt * rquotaproc_getquota_1_svc(getquota_args *, struct svc_req *);
#define	RQUOTAPROC_GETACTIVEQUOTA	2
extern  getquota_rslt * rquotaproc_getactivequota_1(getquota_args *, CLIENT *);
extern  getquota_rslt * rquotaproc_getactivequota_1_svc(getquota_args *, struct svc_req *);
extern int rquotaprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	RQUOTAPROC_GETQUOTA	1
extern  getquota_rslt * rquotaproc_getquota_1();
extern  getquota_rslt * rquotaproc_getquota_1_svc();
#define	RQUOTAPROC_GETACTIVEQUOTA	2
extern  getquota_rslt * rquotaproc_getactivequota_1();
extern  getquota_rslt * rquotaproc_getactivequota_1_svc();
extern int rquotaprog_1_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_getquota_args(XDR *, getquota_args*);
extern  bool_t xdr_rquota(XDR *, rquota*);
extern  bool_t xdr_gqr_status(XDR *, gqr_status*);
extern  bool_t xdr_getquota_rslt(XDR *, getquota_rslt*);

#else /* K&R C */
extern bool_t xdr_getquota_args();
extern bool_t xdr_rquota();
extern bool_t xdr_gqr_status();
extern bool_t xdr_getquota_rslt();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_RQUOTA_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 * Copyright 1987 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Remote quota protocol
 * Requires unix authentication
 */

const RQ_PATHLEN = 1024;

struct getquota_args {
	string gqa_pathp<RQ_PATHLEN>;  	/* path to filesystem of interest */
	int32_t gqa_uid;        	/* inquire about quota for uid */
};

/*
 * remote quota structure
 */
struct rquota {
	int32_t rq_bsize;		/* block size for block counts */
	bool rq_active;  		/* indicates whether quota is active */
	uint32_t rq_bhardlimit;		/* absolute limit on disk blks alloc */
	uint32_t rq_bsoftlimit;		/* preferred limit on disk blks */
	uint32_t rq_curblocks;		/* current block count */
	uint32_t rq_fhardlimit;		/* absolute limit on allocated files */
	uint32_t rq_fsoftlimit;		/* preferred file limit */
	uint32_t rq_curfiles;		/* current # allocated files */
	uint32_t rq_btimeleft;		/* time left for excessive disk use */
	uint32_t rq_ftimeleft;		/* time left for excessive files */
};

enum gqr_status {
	Q_OK = 1,		/* quota returned */
	Q_NOQUOTA = 2,  	/* noquota for uid */
	Q_EPERM = 3		/* no permission to access quota */
};

union getquota_rslt switch (gqr_status status) {
case Q_OK:
	rquota gqr_rquota;	/* valid if status == Q_OK */
case Q_NOQUOTA:
	void;
case Q_EPERM:
	void;
};

program RQUOTAPROG {
	version RQUOTAVERS {
		/*
		 * Get all quotas
		 */
		getquota_rslt
		RQUOTAPROC_GETQUOTA(getquota_args) = 1;

		/*
	 	 * Get active quotas only
		 */
		getquota_rslt
		RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2;
	} = 1;
} = 100011;
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _RSTAT_H_RPCGEN
#define	_RSTAT_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc.
 */
/* from rstat.x */

/*
 * Scale factor for scaled integers used to count load averages.
 */
#ifndef FSCALE
#define FSHIFT 8 /* bits to right of fixed binary point */
#define FSCALE (1<<FSHIFT)
#endif /* ndef FSCALE */

#ifndef DST_NONE
#include <sys/time.h> /* The time struct defined below is	*/
#endif /* meant to match struct timeval.	*/






#define	RSTAT_CPUSTATES 4
#define	RSTAT_DK_NDRIVE 4
#define	RSTAT_CPU_USER 0
#define	RSTAT_CPU_NICE 1
#define	RSTAT_CPU_SYS 2
#define	RSTAT_CPU_IDLE 3

struct rstat_timeval {
	int tv_sec;
	int tv_usec;
};
typedef struct rstat_timeval rstat_timeval;

struct statsvar {
	struct {
		u_int cp_time_len;
		int *cp_time_val;
	} cp_time;
	struct {
		u_int dk_xfer_len;
		int *dk_xfer_val;
	} dk_xfer;
	u_int v_pgpgin;
	u_int v_pgpgout;
	u_int v_pswpin;
	u_int v_pswpout;
	u_int v_intr;
	int if_ipackets;
	int if_ierrors;
	int if_opackets;
	int if_oerrors;
	int if_collisions;
	u_int v_swtch;
	int avenrun[3];
	rstat_timeval boottime;
	rstat_timeval curtime;
};
typedef struct statsvar statsvar;

struct statstime {
	int cp_time[RSTAT_CPUSTATES];
	int dk_xfer[RSTAT_DK_NDRIVE];
	u_int v_pgpgin;
	u_int v_pgpgout;
	u_int v_pswpin;
	u_int v_pswpout;
	u_int v_intr;
	int if_ipackets;
	int if_ierrors;
	int if_oerrors;
	int if_collisions;
	u_int v_swtch;
	int avenrun[3];
	rstat_timeval boottime;
	rstat_timeval curtime;
	int if_opackets;
};
typedef struct statstime statstime;

#if 1 || defined(__cplusplus)
enum clnt_stat rstat(char *, struct statstime *);
int havedisk(char *);
#else
enum clnt_stat rstat();
int havedisk();
#endif


#define	RSTATPROG	100001
#define	RSTATVERS_VAR	4

#if defined(__STDC__) || defined(__cplusplus)
#define	RSTATPROC_STATS	1
extern  statsvar * rstatproc_stats_4(void *, CLIENT *);
extern  statsvar * rstatproc_stats_4_svc(void *, struct svc_req *);
#define	RSTATPROC_HAVEDISK	2
extern  u_int * rstatproc_havedisk_4(void *, CLIENT *);
extern  u_int * rstatproc_havedisk_4_svc(void *, struct svc_req *);
extern int rstatprog_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	RSTATPROC_STATS	1
extern  statsvar * rstatproc_stats_4();
extern  statsvar * rstatproc_stats_4_svc();
#define	RSTATPROC_HAVEDISK	2
extern  u_int * rstatproc_havedisk_4();
extern  u_int * rstatproc_havedisk_4_svc();
extern int rstatprog_4_freeresult();
#endif /* K&R C */
#define	RSTATVERS_TIME	3

#if defined(__STDC__) || defined(__cplusplus)
extern  statstime * rstatproc_stats_3(void *, CLIENT *);
extern  statstime * rstatproc_stats_3_svc(void *, struct svc_req *);
extern  u_int * rstatproc_havedisk_3(void *, CLIENT *);
extern  u_int * rstatproc_havedisk_3_svc(void *, struct svc_req *);
extern int rstatprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
extern  statstime * rstatproc_stats_3();
extern  statstime * rstatproc_stats_3_svc();
extern  u_int * rstatproc_havedisk_3();
extern  u_int * rstatproc_havedisk_3_svc();
extern int rstatprog_3_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_rstat_timeval(XDR *, rstat_timeval*);
extern  bool_t xdr_statsvar(XDR *, statsvar*);
extern  bool_t xdr_statstime(XDR *, statstime*);

#else /* K&R C */
extern bool_t xdr_rstat_timeval();
extern bool_t xdr_statsvar();
extern bool_t xdr_statstime();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_RSTAT_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
%/*
% * Copyright (c) 1985, 1990, 1991 by Sun Microsystems, Inc.
% */

%/* from rstat.x */

/*
 * Gather statistics on remote machines
 */

#ifdef RPC_HDR
%
%/*
% * Scale factor for scaled integers used to count load averages.
% */
%#ifndef	FSCALE
%#define	FSHIFT	8	/* bits to right of fixed binary point */
%#define	FSCALE	(1<<FSHIFT)
%#endif	/* ndef FSCALE */
%
%#ifndef DST_NONE
%#include <sys/time.h>		/* The time struct defined below is	*/
%#endif				/* meant to match struct timeval.	*/
%
%
%
%
%
%
#elif RPC_SVC
%
%/*
% *  Server side stub routines for the rstat daemon
% */
%
#elif RPC_CLNT
%
%/*
% *  Client side stub routines for the rstat daemon
% */
%
#elif RPC_XDR
%/*
% * XDR routines for the rstat daemon, rup and perfmeter.
% */
%
%/*
% * xdr_timeval was used in previous releases.
% */
%
%bool_t
%#ifdef __STDC__
%xdr_timeval(XDR *xdrs, struct timeval *tvp)
%#else /* K&R C */
%xdr_timeval(xdrs, tvp)
%	XDR *xdrs;
%	struct timeval *tvp;
%#endif /* K&R C */
%{
%	return (xdr_rstat_timeval(xdrs, (rstat_timeval *)tvp));
%}

%
#endif

const RSTAT_CPUSTATES = 4;
const RSTAT_DK_NDRIVE = 4;

/*
 * the cpu stat values
 */

const RSTAT_CPU_USER = 0;
const RSTAT_CPU_NICE = 1;
const RSTAT_CPU_SYS = 2;
const RSTAT_CPU_IDLE = 3;

/*
 * GMT since 0:00, January 1, 1970
 */
struct rstat_timeval {
	int tv_sec;	/* seconds */
	int tv_usec;	/* and microseconds */
};

struct statsvar {				/* RSTATVERS_VAR */
	int cp_time<>; 		/* variable number of CPU states */
	int dk_xfer<>;		/* variable number of disks */
	unsigned v_pgpgin;	/* these are cumulative sum */
	unsigned v_pgpgout;
	unsigned v_pswpin;
	unsigned v_pswpout;
	unsigned v_intr;
	int if_ipackets;
	int if_ierrors;
	int if_opackets;
	int if_oerrors;
	int if_collisions;
	unsigned v_swtch;
	int avenrun[3];
	rstat_timeval boottime;
	rstat_timeval curtime;
};

struct statstime {				/* RSTATVERS_TIME */
	int cp_time[RSTAT_CPUSTATES];
	int dk_xfer[RSTAT_DK_NDRIVE];
	unsigned int v_pgpgin;	/* these are cumulative sum */
	unsigned int v_pgpgout;
	unsigned int v_pswpin;
	unsigned int v_pswpout;
	unsigned int v_intr;
	int if_ipackets;
	int if_ierrors;
	int if_oerrors;
	int if_collisions;
	unsigned int v_swtch;
	int avenrun[3];
	rstat_timeval boottime;
	rstat_timeval curtime;
	int if_opackets;
};

program RSTATPROG {
        /*
         * Version 4 allows for variable number of disk and RSTAT_CPU states.
         */
	version RSTATVERS_VAR {
		statsvar
		RSTATPROC_STATS (void) = 1;
		unsigned int
		RSTATPROC_HAVEDISK (void) = 2;
	} = 4;
	/*
	 * Newest version includes current time and context switching info
	 */
	version RSTATVERS_TIME {
		statstime
		RSTATPROC_STATS(void) = 1;
		unsigned int
		RSTATPROC_HAVEDISK(void) = 2;
	} = 3;
} = 100001;

#ifdef RPC_HDR
%
%#if defined(__STDC__) || defined(__cplusplus)
%enum clnt_stat rstat(char *, struct statstime *);
%int havedisk(char *);
%#else
%enum clnt_stat rstat();
%int havedisk();
%#endif
%
#endif
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _RUSERS_H_RPCGEN
#define	_RUSERS_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Find out about remote users
 */
#define	RUSERS_MAXUSERLEN 32
#define	RUSERS_MAXLINELEN 32
#define	RUSERS_MAXHOSTLEN 257

struct rusers_utmp {
	char *ut_user;
	char *ut_line;
	char *ut_host;
	int ut_type;
	int ut_time;
	u_int ut_idle;
};
typedef struct rusers_utmp rusers_utmp;

typedef struct {
	u_int utmp_array_len;
	rusers_utmp *utmp_array_val;
} utmp_array;

/*
 * Values for ut_type field above.
 */
#define	RUSERS_EMPTY 0
#define	RUSERS_RUN_LVL 1
#define	RUSERS_BOOT_TIME 2
#define	RUSERS_OLD_TIME 3
#define	RUSERS_NEW_TIME 4
#define	RUSERS_INIT_PROCESS 5
#define	RUSERS_LOGIN_PROCESS 6
#define	RUSERS_USER_PROCESS 7
#define	RUSERS_DEAD_PROCESS 8
#define	RUSERS_ACCOUNTING 9



/*
 * The following structures are used by version 2 of the rusersd protocol.
 * They were not developed with rpcgen, so they do not appear as RPCL.
 */

#define RUSERSVERS_IDLE 2
#define RUSERSVERS 3 /* current version */
#define MAXUSERS 100

/*
 * This is the structure used in version 2 of the rusersd RPC service.
 * It corresponds to the utmp structure for BSD systems.
 */
struct ru_utmp {
 char ut_line[8]; /* tty name */
 char ut_name[8]; /* user id */
 char ut_host[16]; /* host name, if remote */
 time_t ut_time; /* time on */
};

struct utmpidle {
 struct ru_utmp ui_utmp;
 unsigned ui_idle;
};

struct utmpidlearr {
 struct utmpidle **uia_arr;
 int uia_cnt;
};

int xdr_utmpidlearr();

#if 1 || defined(__cplusplus)
enum clnt_stat rusers(char *host, struct utmpidlearr *up);
int rnusers(char *host);
#else
enum clnt_stat rusers();
int rnusers();
#endif


#define	RUSERSPROG	100002
#define	RUSERSVERS_3	3

#if defined(__STDC__) || defined(__cplusplus)
#define	RUSERSPROC_NUM	1
extern  int * rusersproc_num_3(void *, CLIENT *);
extern  int * rusersproc_num_3_svc(void *, struct svc_req *);
#define	RUSERSPROC_NAMES	2
extern  utmp_array * rusersproc_names_3(void *, CLIENT *);
extern  utmp_array * rusersproc_names_3_svc(void *, struct svc_req *);
#define	RUSERSPROC_ALLNAMES	3
extern  utmp_array * rusersproc_allnames_3(void *, CLIENT *);
extern  utmp_array * rusersproc_allnames_3_svc(void *, struct svc_req *);
extern int rusersprog_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	RUSERSPROC_NUM	1
extern  int * rusersproc_num_3();
extern  int * rusersproc_num_3_svc();
#define	RUSERSPROC_NAMES	2
extern  utmp_array * rusersproc_names_3();
extern  utmp_array * rusersproc_names_3_svc();
#define	RUSERSPROC_ALLNAMES	3
extern  utmp_array * rusersproc_allnames_3();
extern  utmp_array * rusersproc_allnames_3_svc();
extern int rusersprog_3_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_rusers_utmp(XDR *, rusers_utmp*);
extern  bool_t xdr_utmp_array(XDR *, utmp_array*);

#else /* K&R C */
extern bool_t xdr_rusers_utmp();
extern bool_t xdr_utmp_array();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_RUSERS_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1991 Sun Microsystems, Inc.
 */

%/*
% * Find out about remote users
% */

const RUSERS_MAXUSERLEN = 32;
const RUSERS_MAXLINELEN = 32;
const RUSERS_MAXHOSTLEN = 257;

struct rusers_utmp {
	string ut_user<RUSERS_MAXUSERLEN>;	/* aka ut_name */
	string ut_line<RUSERS_MAXLINELEN>;	/* device */
	string ut_host<RUSERS_MAXHOSTLEN>;	/* host user logged on from */
	int ut_type;				/* type of entry */
	int ut_time;				/* time entry was made */
	unsigned int ut_idle;			/* minutes idle */
};

typedef rusers_utmp utmp_array<>;

#ifdef RPC_HDR
%
%/*
% * Values for ut_type field above.
% */
#endif
const	RUSERS_EMPTY = 0;
const	RUSERS_RUN_LVL = 1;
const	RUSERS_BOOT_TIME = 2;
const	RUSERS_OLD_TIME = 3;
const	RUSERS_NEW_TIME = 4;
const	RUSERS_INIT_PROCESS = 5;
const	RUSERS_LOGIN_PROCESS = 6;
const	RUSERS_USER_PROCESS = 7;
const	RUSERS_DEAD_PROCESS = 8;
const	RUSERS_ACCOUNTING = 9;

program RUSERSPROG {

	version RUSERSVERS_3 {
		int
		RUSERSPROC_NUM(void) = 1;

		utmp_array
		RUSERSPROC_NAMES(void) = 2;

		utmp_array
		RUSERSPROC_ALLNAMES(void) = 3;
	} = 3;

} = 100002;

#ifdef RPC_HDR
%
%
%
%/*
% * The following structures are used by version 2 of the rusersd protocol.
% * They were not developed with rpcgen, so they do not appear as RPCL.
% */
%
%#define	RUSERSVERS_IDLE 2
%#define	RUSERSVERS 3		/* current version */
%#define	MAXUSERS 100
%
%/*
% * This is the structure used in version 2 of the rusersd RPC service.
% * It corresponds to the utmp structure for BSD systems.
% */
%struct ru_utmp {
%	char	ut_line[8];		/* tty name */
%	char	ut_name[8];		/* user id */
%	char	ut_host[16];		/* host name, if remote */
%	time_t	ut_time;		/* time on */
%};
%
%struct utmpidle {
%	struct ru_utmp ui_utmp;
%	unsigned ui_idle;
%};
%
%struct utmpidlearr {
%	struct utmpidle **uia_arr;
%	int uia_cnt;
%};
%
%int xdr_utmpidlearr();
%
%#if defined(__STDC__) || defined(__cplusplus)
%enum clnt_stat rusers(char *host, struct utmpidlearr *up);
%int rnusers(char *host);
%#else
%enum clnt_stat rusers();
%int rnusers();
%#endif
%
#endif
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _RWALL_H_RPCGEN
#define	_RWALL_H_RPCGEN

#include <rpc/rpc.h>
#ifndef _KERNEL
#include <synch.h>
#include <thread.h>
#endif /* !_KERNEL */

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/* from rwall.x */

/*
 * Remote write-all ONC service
 */


typedef char *wrapstring;


#if 1 || defined(__cplusplus)
enum clnt_stat rwall(char *, char *);
#else
enum clnt_stat rwall();
#endif


#define	WALLPROG	100008
#define	WALLVERS	1

#if defined(__STDC__) || defined(__cplusplus)
#define	WALLPROC_WALL	2
extern  enum clnt_stat wallproc_wall_1(wrapstring *, void *, CLIENT *);
extern  bool_t wallproc_wall_1_svc(wrapstring *, void *, struct svc_req *);
extern int wallprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	WALLPROC_WALL	2
extern  enum clnt_stat wallproc_wall_1();
extern  bool_t wallproc_wall_1_svc();
extern int wallprog_1_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_wrapstring(XDR *, wrapstring*);

#else /* K&R C */
extern bool_t xdr_wrapstring();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_RWALL_H_RPCGEN */
%/*
% * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
% * Use is subject to license terms.
% *
% * CDDL HEADER START
% *
% * The contents of this file are subject to the terms of the
% * Common Development and Distribution License, Version 1.0 only
% * (the "License").  You may not use this file except in compliance
% * with the License.
% *
% * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
% * or http://www.opensolaris.org/os/licensing.
% * See the License for the specific language governing permissions
% * and limitations under the License.
% *
% * When distributing Covered Code, include this CDDL HEADER in each
% * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
% * If applicable, add the following below this CDDL HEADER, with the
% * fields enclosed by brackets "[]" replaced with your own identifying
% * information: Portions Copyright [yyyy] [name of copyright owner]
% *
% * CDDL HEADER END
% */

%/* from rwall.x */
%
%/*
% * Remote write-all ONC service
% */

#ifdef RPC_HDR
%
#elif RPC_SVC
%
%/*
% *  Server side stub routines for the rpc.rwalld daemon
% */
%
#elif RPC_CLNT
%
%/*
% *  Client side stub routines for the rwall program
% */
%
#endif

typedef string wrapstring<>;	/* Define for RPC library's xdr_wrapstring */

program WALLPROG {
	version WALLVERS {
		/*
		 * There is no procedure 1
		 */
		void
		WALLPROC_WALL (wrapstring) = 2;
	} = 1;
} = 100008;

#ifdef RPC_HDR
%
%
%#if defined(__STDC__) || defined(__cplusplus)
%enum clnt_stat rwall(char *, char *);
%#else
%enum clnt_stat rwall();
%#endif
%
#endif
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _SPRAY_H_RPCGEN
#define	_SPRAY_H_RPCGEN

#include <rpc/rpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Copyright (c) 1987, 1991 by Sun Microsystems, Inc.
 */
/* from spray.x */
#define	SPRAYMAX 8845

struct spraytimeval {
	u_int sec;
	u_int usec;
};
typedef struct spraytimeval spraytimeval;

struct spraycumul {
	u_int counter;
	spraytimeval clock;
};
typedef struct spraycumul spraycumul;

typedef struct {
	u_int sprayarr_len;
	char *sprayarr_val;
} sprayarr;

#define	SPRAYPROG	100012
#define	SPRAYVERS	1

#if defined(__STDC__) || defined(__cplusplus)
#define	SPRAYPROC_SPRAY	1
extern  void * sprayproc_spray_1(sprayarr *, CLIENT *);
extern  void * sprayproc_spray_1_svc(sprayarr *, struct svc_req *);
#define	SPRAYPROC_GET	2
extern  spraycumul * sprayproc_get_1(void *, CLIENT *);
extern  spraycumul * sprayproc_get_1_svc(void *, struct svc_req *);
#define	SPRAYPROC_CLEAR	3
extern  void * sprayproc_clear_1(void *, CLIENT *);
extern  void * sprayproc_clear_1_svc(void *, struct svc_req *);
extern int sprayprog_1_freeresult(SVCXPRT *, xdrproc_t, caddr_t);

#else /* K&R C */
#define	SPRAYPROC_SPRAY	1
extern  void * sprayproc_spray_1();
extern  void * sprayproc_spray_1_svc();
#define	SPRAYPROC_GET	2
extern  spraycumul * sprayproc_get_1();
extern  spraycumul * sprayproc_get_1_svc();
#define	SPRAYPROC_CLEAR	3
extern  void * sprayproc_clear_1();
extern  void * sprayproc_clear_1_svc();
extern int sprayprog_1_freeresult();
#endif /* K&R C */

/* the xdr functions */

#if defined(__STDC__) || defined(__cplusplus)
extern  bool_t xdr_spraytimeval(XDR *, spraytimeval*);
extern  bool_t xdr_spraycumul(XDR *, spraycumul*);
extern  bool_t xdr_sprayarr(XDR *, sprayarr*);

#else /* K&R C */
extern bool_t xdr_spraytimeval();
extern bool_t xdr_spraycumul();
extern bool_t xdr_sprayarr();

#endif /* K&R C */

#ifdef __cplusplus
}
#endif

#endif /* !_SPRAY_H_RPCGEN */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
%/*
% * Copyright (c) 1987, 1991 by Sun Microsystems, Inc.
% */

%/* from spray.x */

/*
 * Spray a server with packets
 * Useful for testing flakiness of network interfaces
 */

const SPRAYMAX = 8845;	/* max amount can spray */

/*
 * GMT since 0:00, 1 January 1970
 */
struct spraytimeval {
	unsigned int sec;
	unsigned int usec;
};

/*
 * spray statistics
 */
struct spraycumul {
	unsigned int counter;
	spraytimeval clock;
};

/*
 * spray data
 */
typedef opaque sprayarr<SPRAYMAX>;

program SPRAYPROG {
	version SPRAYVERS {
		/*
		 * Just throw away the data and increment the counter
		 * This call never returns, so the client should always
		 * time it out.
		 */
		void
		SPRAYPROC_SPRAY(sprayarr) = 1;

		/*
		 * Get the value of the counter and elapsed time  since
		 * last CLEAR.
		 */
		spraycumul
		SPRAYPROC_GET(void) = 2;

		/*
		 * Clear the counter and reset the elapsed time
		 */
		void
		SPRAYPROC_CLEAR(void) = 3;
	} = 1;
} = 100012;
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SVC_DG_PRIV_H
#define	_SVC_DG_PRIV_H

/*
 * The svc_dg_data private datastructure shared by some services
 * for nefarious reasons.  THIS IS NOT AN INTERFACE. DO NOT USE.
 */

#ifdef __cplusplus
extern "C" {
#endif

/*
 * The size of the option header should include sufficient space for
 * a ucred; we reserve 32 words as before we had ucreds and we allocate
 * sizeof (svc_dg_data) + ucred_size().  Of course, opts must be declared
 * last so it can use the additional memory.
 */
#define	MAX_OPT_WORDS	32

/*
 * kept in xprt->xp_p2
 */
struct svc_dg_data {
	/* Note: optbuf must be the first field, used by ti_opts.c code */
	struct	netbuf optbuf;			/* netbuf for options */
	uint_t	 su_iosz;			/* size of send.recv buffer */
	uint32_t	su_xid;			/* transaction id */
	XDR	su_xdrs;			/* XDR handle */
	char	su_verfbody[MAX_AUTH_BYTES];	/* verifier body */
	char	*su_cache;			/* cached data, NULL if none */
	struct t_unitdata   su_tudata;		/* tu_data for recv */
	int	opts[MAX_OPT_WORDS];		/* options: MUST BE LAST */
};

#define	get_svc_dg_data(xprt)	((struct svc_dg_data *)((xprt)->xp_p2))

#ifdef __cplusplus
}
#endif

#endif /* _SVC_DG_PRIV_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 *	yp.x
 *
 *	Copyright (c) 1988-1992 Sun Microsystems Inc
 *	All Rights Reserved.
 */

/*
 * Protocol description file for the Network Information Services
 */

const YPMAXRECORD = 1024;
const YPMAXDOMAIN = 256;
const YPMAXMAP = 64;
const YPMAXPEER = 64;


enum ypstat {
	YP_TRUE		=  1,
	YP_NOMORE	=  2,
	YP_FALSE	=  0,
	YP_NOMAP	= -1,
	YP_NODOM	= -2,
	YP_NOKEY	= -3,
	YP_BADOP	= -4,
	YP_BADDB	= -5,
	YP_YPERR	= -6,
	YP_BADARGS	= -7,
	YP_VERS		= -8
};


enum ypxfrstat {
	YPXFR_SUCC	=  1,
	YPXFR_AGE	=  2,
	YPXFR_NOMAP	= -1,
	YPXFR_NODOM	= -2,
	YPXFR_RSRC	= -3,
	YPXFR_RPC	= -4,
	YPXFR_MADDR	= -5,
	YPXFR_YPERR	= -6,
	YPXFR_BADARGS	= -7,
	YPXFR_DBM	= -8,
	YPXFR_FILE	= -9,
	YPXFR_SKEW	= -10,
	YPXFR_CLEAR	= -11,
	YPXFR_FORCE	= -12,
	YPXFR_XFRERR	= -13,
	YPXFR_REFUSED	= -14
};


typedef string domainname<YPMAXDOMAIN>;
typedef string mapname<YPMAXMAP>;
typedef string peername<YPMAXPEER>;
typedef opaque keydat<YPMAXRECORD>;
typedef opaque valdat<YPMAXRECORD>;


struct ypmap_parms {
	domainname domain;
	mapname map;
	unsigned int ordernum;
	peername peer;
};

struct ypreq_key {
	domainname domain;
	mapname map;
	keydat key;
};

struct ypreq_nokey {
	domainname domain;
	mapname map;
};

struct ypreq_xfr {
	ypmap_parms map_parms;
	unsigned int transid;
	unsigned int prog;
	unsigned int port;
};


struct ypresp_val {
	ypstat stat;
	valdat val;
};

struct ypresp_key_val {
	ypstat stat;
	valdat val;
	keydat key;
};


struct ypresp_master {
	ypstat stat;
	peername peer;
};

struct ypresp_order {
	ypstat stat;
	unsigned int ordernum;
};

union ypresp_all switch (bool more) {
case TRUE:
	ypresp_key_val val;
case FALSE:
	void;
};

struct ypresp_xfr {
	unsigned int transid;
	ypxfrstat xfrstat;
};

struct ypmaplist {
	mapname map;
	ypmaplist *next;
};

struct ypresp_maplist {
	ypstat stat;
	ypmaplist *maps;
};

enum yppush_status {
	YPPUSH_SUCC	=  1,	/* Success */
	YPPUSH_AGE 	=  2,	/* Master's version not newer */
	YPPUSH_NOMAP	= -1,	/* Can't find server for map */
	YPPUSH_NODOM	= -2,	/* Domain not supported */
	YPPUSH_RSRC	= -3,	/* Local resource alloc failure */
	YPPUSH_RPC	= -4,	/* RPC failure talking to server */
	YPPUSH_MADDR 	= -5,	/* Can't get master address */
	YPPUSH_YPERR	= -6,	/* NIS server/map db error */
	YPPUSH_BADARGS	= -7,	/* Request arguments bad */
	YPPUSH_DBM	= -8,	/* Local dbm operation failed */
	YPPUSH_FILE	= -9,	/* Local file I/O operation failed */
	YPPUSH_SKEW	= -10,	/* Map version skew during transfer */
	YPPUSH_CLEAR	= -11,	/* Can't send "Clear" req to local ypserv */
	YPPUSH_FORCE	= -12,	/* No local order number in map  use -f flag. */
	YPPUSH_XFRERR 	= -13,	/* ypxfr error */
	YPPUSH_REFUSED	= -14 	/* Transfer request refused by ypserv */
};

struct yppushresp_xfr {
	unsigned transid;
	yppush_status status;
};

/*
 * Response structure and overall result status codes.  Success and failure
 * represent two separate response message types.
 */

enum ypbind_resptype {
	YPBIND_SUCC_VAL = 1,
	YPBIND_FAIL_VAL = 2
};

struct ypbind_binding {
    opaque ypbind_binding_addr[4]; /* In network order */
    opaque ypbind_binding_port[2]; /* In network order */
};

union ypbind_resp switch (ypbind_resptype ypbind_status) {
case YPBIND_FAIL_VAL:
        unsigned ypbind_error;
case YPBIND_SUCC_VAL:
        ypbind_binding ypbind_bindinfo;
};

/* Detailed failure reason codes for response field ypbind_error*/

const YPBIND_ERR_ERR    = 1;	/* Internal error */
const YPBIND_ERR_NOSERV = 2;	/* No bound server for passed domain */
const YPBIND_ERR_RESC   = 3;	/* System resource allocation failure */


/*
 * Request data structure for ypbind "Set domain" procedure.
 */
struct ypbind_setdom {
	domainname ypsetdom_domain;
	ypbind_binding ypsetdom_binding;
	unsigned ypsetdom_vers;
};


/*
 * NIS access protocol
 */
program YPPROG {
	version YPVERS {
		void
		YPPROC_NULL(void) = 0;

		bool
		YPPROC_DOMAIN(domainname) = 1;

		bool
		YPPROC_DOMAIN_NONACK(domainname) = 2;

		ypresp_val
		YPPROC_MATCH(ypreq_key) = 3;

		ypresp_key_val
		YPPROC_FIRST(ypreq_key) = 4;

		ypresp_key_val
		YPPROC_NEXT(ypreq_key) = 5;

		ypresp_xfr
		YPPROC_XFR(ypreq_xfr) = 6;

		void
		YPPROC_CLEAR(void) = 7;

		ypresp_all
		YPPROC_ALL(ypreq_nokey) = 8;

		ypresp_master
		YPPROC_MASTER(ypreq_nokey) = 9;

		ypresp_order
		YPPROC_ORDER(ypreq_nokey) = 10;

		ypresp_maplist
		YPPROC_MAPLIST(domainname) = 11;
	} = 2;
} = 100004;


/*
 * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
 */
program YPPUSH_XFRRESPPROG {
	version YPPUSH_XFRRESPVERS {
		void
		YPPUSHPROC_NULL(void) = 0;

		yppushresp_xfr
		YPPUSHPROC_XFRRESP(void) = 1;
	} = 1;
} = 0x40000000;	/* transient: could be anything up to 0x5fffffff */


/*
 * NIS binding protocol
 */
program YPBINDPROG {
	version YPBINDVERS {
		void
		YPBINDPROC_NULL(void) = 0;

		ypbind_resp
		YPBINDPROC_DOMAIN(domainname) = 1;

		void
		YPBINDPROC_SETDOM(ypbind_setdom) = 2;
	} = 2;
} = 100007;


/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef	_RPCSVC_YP_PROT_H
#define	_RPCSVC_YP_PROT_H

#include <rpc/rpc.h>
#include <rpcsvc/ypclnt.h>
#include <ndbm.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * This file contains symbols and structures defining the rpc protocol
 * between the YP clients and the YP servers.  The servers are the YP
 * database servers, and the YP.
 */

/*
 * The following procedures are supported by the protocol:
 *
 * YPPROC_NULL() returns () takes nothing, returns nothing.  This indicates
 * that the yp server is alive.
 *
 * YPPROC_DOMAIN (char *) returns (bool_t) TRUE.  Indicates that the
 * responding yp server does serve the named domain; FALSE indicates no
 * support.
 *
 * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the yp server does serve
 * the named domain, otherwise does not return.  Used in the broadcast case.
 *
 * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val).  Returns the
 * right-hand value for a passed left-hand key, within a named map and
 * domain.
 *
 * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val).
 * Returns the first key-value pair from a named domain and map.
 *
 * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val).  Returns
 * the key-value pair following a passed key-value pair within a named
 * domain and map.
 *
 * YPPROC_XFR (struct ypreq_xfr) returns nothing.  Indicates to a server that
 * a map should be updated.
 *
 * YPPROC_NEWXFR (struct ypreq_newxfr) returns nothing.  Indicates to a server
 * that a map should be updated. Uses protocol independent request struct.
 *
 * YPPROC_CLEAR	takes nothing, returns nothing.  Instructs a yp server to
 * close the current map, so that old versions of the disk file don't get
 * held open.
 *
 * YPPROC_ALL (struct ypreq_nokey), returns
 *	union switch (bool more) {
 *		TRUE:	(struct ypresp_key_val);
 *		FALSE:	(struct) {};
 *	}
 *
 * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master)
 *
 * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order)
 *
 * YPPROC_MAPLIST (char *), returns (struct ypmaplist *)
 */

/* 'bool' is a built-in type for g++ */
#if !(defined(__cplusplus) && defined(_BOOL)) && !defined(__GNUG__)
#ifndef BOOL_DEFINED
typedef unsigned int bool;
#define	BOOL_DEFINED
#endif
#endif

/* Program and version symbols, magic numbers */

#define	YPPROG		((rpcprog_t)100004)
#define	YPVERS		((rpcvers_t)2)
#define	YPVERS_ORIG	((rpcvers_t)1)
#define	YPMAXRECORD	((uint_t)1024)
#define	YPMAXDOMAIN	((uint_t)256)
#define	YPMAXMAP	((uint_t)64)
#define	YPMAXPEER	((uint_t)256)

/* byte size of a large yp packet */
#define	YPMSGSZ		1600

struct ypmap_parms {
	char *domain;			/* Null string means not available */
	char *map;			/* Null string means not available */
	unsigned int ordernum;		/* 0 means not available */
	char *owner;			/* Null string means not available */
};

/*
 * Request parameter structures
 */

struct ypreq_key {
	char *domain;
	char *map;
	datum keydat;
};

struct ypreq_nokey {
	char *domain;
	char *map;
};

struct ypreq_xfr {
	struct ypmap_parms map_parms;
	unsigned int transid;
	unsigned int proto;
	unsigned short port;
};

struct ypreq_newxfr {
	struct ypmap_parms map_parms;
	unsigned int transid;
	unsigned int proto;
	char *name;
};

#define	ypxfr_domain map_parms.domain
#define	ypxfr_map map_parms.map
#define	ypxfr_ordernum map_parms.ordernum
#define	ypxfr_owner map_parms.owner

/*
 * Response parameter structures
 */

struct ypresp_val {
	unsigned int status;
	datum valdat;
};

struct ypresp_key_val {
	unsigned int status;
	datum valdat;
	datum keydat;
};

struct ypresp_master {
	unsigned int status;
	char *master;
};

struct ypresp_order {
	unsigned int status;
	unsigned int ordernum;
};

struct ypmaplist {
	char ypml_name[YPMAXMAP + 1];
	struct ypmaplist *ypml_next;
};

struct ypresp_maplist {
	unsigned int status;
	struct ypmaplist *list;
};

/*
 * Procedure symbols.  YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK
 * must keep the same values (0, 1, and 2) that they had in the first version
 * of the protocol.
 */

#define	YPPROC_NULL	((rpcproc_t)0)
#define	YPPROC_DOMAIN	((rpcproc_t)1)
#define	YPPROC_DOMAIN_NONACK ((rpcproc_t)2)
#define	YPPROC_MATCH	((rpcproc_t)3)
#define	YPPROC_FIRST	((rpcproc_t)4)
#define	YPPROC_NEXT	((rpcproc_t)5)
#define	YPPROC_XFR	((rpcproc_t)6)
#define	YPPROC_NEWXFR	((rpcproc_t)12)
#define	YPPROC_CLEAR	((rpcproc_t)7)
#define	YPPROC_ALL	((rpcproc_t)8)
#define	YPPROC_MASTER	((rpcproc_t)9)
#define	YPPROC_ORDER	((rpcproc_t)10)
#define	YPPROC_MAPLIST	((rpcproc_t)11)

/* Return status values */

#define	YP_TRUE		(1)	/* General purpose success code */
#define	YP_NOMORE	(2)	/* No more entries in map */
#define	YP_FALSE	(0)	/* General purpose failure code */
#define	YP_NOMAP	(-1)	/* No such map in domain */
#define	YP_NODOM	(-2)	/* Domain not supported */
#define	YP_NOKEY	(-3)	/* No such key in map */
#define	YP_BADOP	(-4)	/* Invalid operation */
#define	YP_BADDB	(-5)	/* Server data base is bad */
#define	YP_YPERR	(-6)	/* YP server error */
#define	YP_BADARGS	(-7)	/* Request arguments bad */
#define	YP_VERS		(-8)	/* YP server vers. mismatch - server */
				/*   can't supply requested service. */

enum ypreqtype {YPREQ_KEY = 1, YPREQ_NOKEY = 2, YPREQ_MAP_PARMS = 3};
struct yprequest {
	enum ypreqtype yp_reqtype;
	union {
		struct ypreq_key yp_req_keytype;
		struct ypreq_nokey yp_req_nokeytype;
		struct ypmap_parms yp_req_map_parmstype;
	}yp_reqbody;
};

#define	YPMATCH_REQTYPE YPREQ_KEY
#define	ypmatch_req_domain yp_reqbody.yp_req_keytype.domain
#define	ypmatch_req_map yp_reqbody.yp_req_keytype.map
#define	ypmatch_req_keydat yp_reqbody.yp_req_keytype.keydat
#define	ypmatch_req_keyptr yp_reqbody.yp_req_keytype.keydat.dptr
#define	ypmatch_req_keysize yp_reqbody.yp_req_keytype.keydat.dsize

#define	YPFIRST_REQTYPE YPREQ_NOKEY
#define	ypfirst_req_domain yp_reqbody.yp_req_nokeytype.domain
#define	ypfirst_req_map yp_reqbody.yp_req_nokeytype.map

#define	YPNEXT_REQTYPE YPREQ_KEY
#define	ypnext_req_domain yp_reqbody.yp_req_keytype.domain
#define	ypnext_req_map yp_reqbody.yp_req_keytype.map
#define	ypnext_req_keydat yp_reqbody.yp_req_keytype.keydat
#define	ypnext_req_keyptr yp_reqbody.yp_req_keytype.keydat.dptr
#define	ypnext_req_keysize yp_reqbody.yp_req_keytype.keydat.dsize

#define	YPPUSH_REQTYPE YPREQ_NOKEY
#define	yppush_req_domain yp_reqbody.yp_req_nokeytype.domain
#define	yppush_req_map yp_reqbody.yp_req_nokeytype.map

#define	YPPULL_REQTYPE YPREQ_NOKEY
#define	yppull_req_domain yp_reqbody.yp_req_nokeytype.domain
#define	yppull_req_map yp_reqbody.yp_req_nokeytype.map

#define	YPPOLL_REQTYPE YPREQ_NOKEY
#define	yppoll_req_domain yp_reqbody.yp_req_nokeytype.domain
#define	yppoll_req_map yp_reqbody.yp_req_nokeytype.map

#define	YPGET_REQTYPE YPREQ_MAP_PARMS
#define	ypget_req_domain yp_reqbody.yp_req_map_parmstype.domain
#define	ypget_req_map yp_reqbody.yp_req_map_parmstype.map
#define	ypget_req_ordernum yp_reqbody.yp_req_map_parmstype.ordernum
#define	ypget_req_owner yp_reqbody.yp_req_map_parmstype.owner

enum ypresptype {YPRESP_VAL = 1, YPRESP_KEY_VAL = 2, YPRESP_MAP_PARMS = 3};
struct ypresponse {
	enum ypresptype yp_resptype;
	union {
		struct ypresp_val yp_resp_valtype;
		struct ypresp_key_val yp_resp_key_valtype;
		struct ypmap_parms yp_resp_map_parmstype;
	} yp_respbody;
};

#define	YPMATCH_RESPTYPE YPRESP_VAL
#define	ypmatch_resp_status yp_respbody.yp_resp_valtype.status
#define	ypmatch_resp_valdat yp_respbody.yp_resp_valtype.valdat
#define	ypmatch_resp_valptr yp_respbody.yp_resp_valtype.valdat.dptr
#define	ypmatch_resp_valsize yp_respbody.yp_resp_valtype.valdat.dsize

#define	YPFIRST_RESPTYPE YPRESP_KEY_VAL
#define	ypfirst_resp_status yp_respbody.yp_resp_key_valtype.status
#define	ypfirst_resp_keydat yp_respbody.yp_resp_key_valtype.keydat
#define	ypfirst_resp_keyptr yp_respbody.yp_resp_key_valtype.keydat.dptr
#define	ypfirst_resp_keysize yp_respbody.yp_resp_key_valtype.keydat.dsize
#define	ypfirst_resp_valdat yp_respbody.yp_resp_key_valtype.valdat
#define	ypfirst_resp_valptr yp_respbody.yp_resp_key_valtype.valdat.dptr
#define	ypfirst_resp_valsize yp_respbody.yp_resp_key_valtype.valdat.dsize

#define	YPNEXT_RESPTYPE YPRESP_KEY_VAL
#define	ypnext_resp_status yp_respbody.yp_resp_key_valtype.status
#define	ypnext_resp_keydat yp_respbody.yp_resp_key_valtype.keydat
#define	ypnext_resp_keyptr yp_respbody.yp_resp_key_valtype.keydat.dptr
#define	ypnext_resp_keysize yp_respbody.yp_resp_key_valtype.keydat.dsize
#define	ypnext_resp_valdat yp_respbody.yp_resp_key_valtype.valdat
#define	ypnext_resp_valptr yp_respbody.yp_resp_key_valtype.valdat.dptr
#define	ypnext_resp_valsize yp_respbody.yp_resp_key_valtype.valdat.dsize

#define	YPPOLL_RESPTYPE YPRESP_MAP_PARMS
#define	yppoll_resp_domain yp_respbody.yp_resp_map_parmstype.domain
#define	yppoll_resp_map yp_respbody.yp_resp_map_parmstype.map
#define	yppoll_resp_ordernum yp_respbody.yp_resp_map_parmstype.ordernum
#define	yppoll_resp_owner yp_respbody.yp_resp_map_parmstype.owner


extern bool _xdr_yprequest();
extern bool _xdr_ypresponse();
/*
 *		Protocol between clients (ypxfr, only) and yppush
 *		yppush speaks a protocol in the transient range, which
 *		is supplied to ypxfr as a command-line parameter when it
 *		is activated by ypserv.
 */
#define	YPPUSHVERS		((rpcvers_t)1)
#define	YPPUSHVERS_ORIG		((rpcvers_t)1)

/* Procedure symbols */

#define	YPPUSHPROC_NULL		((rpcproc_t)0)
#define	YPPUSHPROC_XFRRESP	((rpcproc_t)1)

struct yppushresp_xfr {
	unsigned int transid;
	unsigned int status;
};

/* Status values for yppushresp_xfr.status */

#define	YPPUSH_SUCC	(1)	/* Success */
#define	YPPUSH_AGE	(2)	/* Master's version not newer */
#define	YPPUSH_NOMAP	(-1)	/* Can't find server for map */
#define	YPPUSH_NODOM	(-2)	/* Domain not supported */
#define	YPPUSH_RSRC	(-3)	/* Local resouce alloc failure */
#define	YPPUSH_RPC	(-4)	/* RPC failure talking to server */
#define	YPPUSH_MADDR	(-5)	/* Can't get master address */
#define	YPPUSH_YPERR	(-6)	/* YP server/map db error */
#define	YPPUSH_BADARGS	(-7)	/* Request arguments bad */
#define	YPPUSH_DBM	(-8)	/* Local dbm operation failed */
#define	YPPUSH_FILE	(-9)	/* Local file I/O operation failed */
#define	YPPUSH_SKEW	(-10)	/* Map version skew during transfer */
#define	YPPUSH_CLEAR	(-11)	/* Can't send "Clear" req to local */
				/*   ypserv */
#define	YPPUSH_FORCE	(-12)	/* No local order number in map - */
				/*   use -f flag. */
#define	YPPUSH_XFRERR	(-13)	/* ypxfr error */
#define	YPPUSH_REFUSED	(-14)	/* Transfer request refused by ypserv */
#define	YPPUSH_NOALIAS	(-15)	/* Alias not found for map or domain */

extern bool xdr_datum(XDR *, datum *);
extern bool xdr_ypdomain_wrap_string(XDR *, char **);
extern bool xdr_ypmap_wrap_string(XDR *, char **);
extern bool xdr_ypreq_key(XDR *, struct ypreq_key *);
extern bool xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
extern bool xdr_ypreq_xfr(XDR *, struct ypreq_xfr *);
extern bool xdr_ypreq_newxfr(XDR *, struct ypreq_newxfr *);
extern bool xdr_ypresp_val(XDR *, struct ypresp_val *);
extern bool xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
extern bool xdr_ypmap_parms(XDR *, struct ypmap_parms *);
extern bool xdr_ypowner_wrap_string(XDR *, char **);
extern bool xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *);
extern bool xdr_ypresp_order(XDR *, struct ypresp_order *);
extern bool xdr_ypresp_master(XDR *, struct ypresp_master *);
extern bool xdr_ypall(XDR *, struct ypall_callback *);
extern bool xdr_ypresp_maplist(XDR *, struct ypresp_maplist *);

#ifdef __cplusplus
}
#endif

#endif	/* _RPCSVC_YP_PROT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef	_RPCSVC_YPCLNT_H
#define	_RPCSVC_YPCLNT_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * ypclnt.h
 * This defines the symbols used in the c language
 * interface to the yp client functions.  A description of this interface
 * can be read in ypclnt(3NSL).
 */

/*
 * Failure reason codes.  The success condition is indicated by a functional
 * value of "0".
 */
#define	YPERR_BADARGS 1			/* Args to function are bad */
#define	YPERR_RPC 2			/* RPC failure */
#define	YPERR_DOMAIN 3			/* Can't bind to a server which */
					/*   serves this domain. */
#define	YPERR_MAP 4			/* No such map in server's domain */
#define	YPERR_KEY 5			/* No such key in map */
#define	YPERR_YPERR 6			/* Internal yp server or client */
					/*   interface error */
#define	YPERR_RESRC 7			/* Local resource allocation failure */
#define	YPERR_NOMORE 8			/* No more records in map database */
#define	YPERR_PMAP 9			/* Can't communicate with portmapper */
#define	YPERR_YPBIND 10			/* Can't communicate with ypbind */
#define	YPERR_YPSERV 11			/* Can't communicate with ypserv */
#define	YPERR_NODOM 12			/* Local domain name not set */
#define	YPERR_BADDB 13			/*  yp data base is bad */
#define	YPERR_VERS 14			/* YP version mismatch */
#define	YPERR_ACCESS 15			/* Access violation */
#define	YPERR_BUSY 16			/* Database is busy */

/*
 * Types of update operations
 */
#define	YPOP_CHANGE 1			/* change, do not add */
#define	YPOP_INSERT 2			/* add, do not change */
#define	YPOP_DELETE 3			/* delete this entry */
#define	YPOP_STORE  4			/* add, or change */



/*
 * Data definitions
 */

/*
 * struct ypall_callback * is the arg which must be passed to yp_all
 */

struct ypall_callback {
	int (*foreach)();		/* Return non-0 to stop getting */
					/*   called */
	char *data;			/* Opaque pointer for use of callback */
					/*   function */
};

/*
 * External yp client function references.
 */

extern int yp_bind(char *);
extern void yp_unbind(char *);
extern int yp_get_default_domain(char **);
extern int yp_match(char *, char *, char *, int, char **, int *);
extern int yp_first(char *, char *, char **, int *, char **, int *);
extern int yp_next(char *, char *, char *, int, char **, int *, char **, int *);
extern int yp_master(char *, char *, char **);
extern int yp_order(char *, char *, unsigned long *);
extern int yp_all(char *, char *, struct ypall_callback *);
extern char *yperr_string(int);
extern int ypprot_err(int);
extern int yp_update(char *, char *, unsigned,  char *, int, char *, int);

/*
 * Global yp data structures
 */

#ifdef	__cplusplus
}
#endif

#endif	/* _RPCSVC_YPCLNT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1985 by Sun Microsystems, Inc.
 *
 */


#ifndef _RPCSVC_YPPASSWD_H
#define	_RPCSVC_YPPASSWD_H

#ifndef _PWD_H
#include <pwd.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#define	YPPASSWDPROG ((rpcprog_t)100009)
#define	YPPASSWDVERS ((rpcvers_t)1)
#define	YPPASSWDPROC_UPDATE ((rpcproc_t)1)

struct yppasswd {
	char *oldpass;		/* old (unencrypted) password */
	struct passwd newpw;	/* new pw structure */
};

int xdr_yppasswd();

#ifdef	__cplusplus
}
#endif

#endif	/* !_RPCSVC_YPPASSWD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef	_RPCSVC_YPUPD_H
#define	_RPCSVC_YPUPD_H

/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Compiled from ypupdate_prot.x using rpcgen
 * This is NOT source code!
 * DO NOT EDIT THIS FILE!
 */
#define	MAXMAPNAMELEN 255
#define	MAXYPDATALEN 1023
#define	MAXERRMSGLEN 255

#define	YPU_PROG ((ulong_t)100028)
#define	YPU_VERS ((ulong_t)1)
#define	YPU_CHANGE ((ulong_t)1)
extern uint_t *ypu_change_1();
#define	YPU_INSERT ((ulong_t)2)
extern uint_t *ypu_insert_1();
#define	YPU_DELETE ((ulong_t)3)
extern uint_t *ypu_delete_1();
#define	YPU_STORE ((ulong_t)4)
extern uint_t *ypu_store_1();

typedef struct {
	uint_t yp_buf_len;
	char *yp_buf_val;
} yp_buf;
bool_t xdr_yp_buf();

struct ypupdate_args {
	char *mapname;
	yp_buf key;
	yp_buf datum;
};
typedef struct ypupdate_args ypupdate_args;
bool_t xdr_ypupdate_args();

struct ypdelete_args {
	char *mapname;
	yp_buf key;
};
typedef struct ypdelete_args ypdelete_args;
bool_t xdr_ypdelete_args();

#ifdef	__cplusplus
}
#endif

#endif	/* _RPCSVC_YPUPD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_RTLD_DB_H
#define	_RTLD_DB_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <sys/lwp.h>
#include <sys/elf.h>
#include <link.h>
#include <proc_service.h>


/*
 * librtld_db interface versions
 */
#define	RD_VERSION1	1
#define	RD_VERSION2	2
#define	RD_VERSION3	3
#define	RD_VERSION4	4
#define	RD_VERSION	RD_VERSION4

typedef enum {
	RD_ERR,		/* generic */
	RD_OK,		/* generic "call" succeeded */
	RD_NOCAPAB,	/* capability not available */
	RD_DBERR,	/* import service failed */
	RD_NOBASE,	/* 5.x: aux tag AT_BASE not found */
	RD_NODYNAM,	/* symbol 'DYNAMIC' not found */
	RD_NOMAPS	/* link-maps are not yet available */
} rd_err_e;


/*
 * ways that the event notification can take place:
 */
typedef enum {
	RD_NOTIFY_BPT,		/* set break-point at address */
	RD_NOTIFY_AUTOBPT,	/* 4.x compat. not used in 5.x */
	RD_NOTIFY_SYSCALL	/* watch for syscall */
} rd_notify_e;

/*
 * information on ways that the event notification can take place:
 */
typedef struct rd_notify {
	rd_notify_e	type;
	union {
		psaddr_t	bptaddr;	/* break point address */
		long		syscallno;	/* system call id */
	} u;
} rd_notify_t;

/*
 * information about event instance:
 */
typedef enum {
	RD_NOSTATE = 0,		/* no state information */
	RD_CONSISTENT,		/* link-maps are stable */
	RD_ADD,			/* currently adding object to link-maps */
	RD_DELETE		/* currently deleteing object from link-maps */
} rd_state_e;

typedef struct rd_event_msg {
	rd_event_e	type;
	union {
		rd_state_e	state;	/* for DLACTIVITY */
	} u;
} rd_event_msg_t;


/*
 * iteration over load objects
 */
typedef struct rd_loadobj {
	psaddr_t	rl_nameaddr;	/* address of the name in user space */
	unsigned	rl_flags;
	psaddr_t	rl_base;	/* base of address of code */
	psaddr_t	rl_data_base;	/* base of address of data */
	Lmid_t		rl_lmident;	/* ident of link map */
	psaddr_t	rl_refnameaddr;	/* reference name of filter in user */
					/* space.  If non null object is a */
					/* filter. */
	psaddr_t	rl_plt_base;	/* These fields are present for 4.x */
	unsigned	rl_plt_size;	/* compatibility and are not */
					/* currently used  in SunOS5.x */
	psaddr_t	rl_bend;	/* end of image (text+data+bss) */
	psaddr_t	rl_padstart;	/* start of padding */
	psaddr_t	rl_padend;	/* end of image after padding */
	psaddr_t	rl_dynamic;	/* points to the DYNAMIC section */
					/* in the target process */
	unsigned long	rl_tlsmodid;	/* module ID for TLS references */
} rd_loadobj_t;

/*
 * Values for rl_flags
 */
#define	RD_FLG_MEM_OBJECT	0x0001	/* Identifies this object as */
					/* originating from a relocatable */
					/* module which was dynamically */
					/* loaded */

/*
 * Commands for rd_ctl()
 */
#define	RD_CTL_SET_HELPPATH	0x01	/* Set the path used to find helpers */

typedef struct rd_agent rd_agent_t;
typedef int rl_iter_f(const rd_loadobj_t *, void *);


/*
 * PLT skipping
 */
typedef enum {
    RD_RESOLVE_NONE,		/* don't do anything special */
    RD_RESOLVE_STEP,		/* step 'pi_nstep' instructions */
    RD_RESOLVE_TARGET,		/* resolved target is in 'pi_target' */
    RD_RESOLVE_TARGET_STEP	/* put a bpt on target, then step nstep times */
} rd_skip_e;


typedef struct rd_plt_info {
	rd_skip_e	pi_skip_method;
	long		pi_nstep;
	psaddr_t	pi_target;
	psaddr_t	pi_baddr;
	unsigned int	pi_flags;
} rd_plt_info_t;


/*
 * Values for pi_flags
 */
#define	RD_FLG_PI_PLTBOUND	0x0001	/* Indicates that the PLT */
					/* has been bound - and that */
					/* pi_baddr will contain its */
					/* destination address */

struct	ps_prochandle;

/*
 * librtld_db.so entry points
 */
extern void		rd_delete(rd_agent_t *);
extern char		*rd_errstr(rd_err_e rderr);
extern rd_err_e		rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *);
extern rd_err_e		rd_event_enable(rd_agent_t *, int);
extern rd_err_e		rd_event_getmsg(rd_agent_t *, rd_event_msg_t *);
extern rd_err_e		rd_init(int);
extern rd_err_e		rd_ctl(int, void *);
extern rd_err_e		rd_loadobj_iter(rd_agent_t *, rl_iter_f *,
				void *);
extern void		rd_log(const int);
extern rd_agent_t	*rd_new(struct ps_prochandle *);
extern rd_err_e		rd_objpad_enable(struct rd_agent *, size_t);
extern rd_err_e		rd_plt_resolution(rd_agent_t *, psaddr_t, lwpid_t,
				psaddr_t, rd_plt_info_t *);
extern rd_err_e		rd_get_dyns(rd_agent_t *, psaddr_t, void **, size_t *);
extern rd_err_e		rd_reset(struct rd_agent *);

#ifdef	__cplusplus
}
#endif

#endif	/* _RTLD_DB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1997-1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _SAC_H
#define	_SAC_H

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	IDLEN		4	/* length in bytes of a utmp id */
#define	SC_WILDC	0xff	/* wild character for utmp ids */
#define	PMTAGSIZE	14	/* maximum length in bytes for */
				/* a port monitor tag */

/*
 * values for rflag in doconfig()
 */

#define	NOASSIGN	0x1	/* don't allow assign operations */
#define	NORUN		0x2	/* don't allow run or runwait operations */


/*
 * message to SAC (header only).  This header is forever fixed.  The
 * size field (pm_size) defines the size of the data portion of the
 * message, which follows the header.  The form of this optional
 * data portion is defined strictly by the message type (pm_type).
 */

struct	pmmsg {
	char	pm_type;		/* type of message */
	uchar_t	pm_state;		/* current state of port monitor */
	char	pm_maxclass;		/* max message class this PM */
					/* understands */
	char	pm_tag[PMTAGSIZE + 1];	/* port monitor's tag */
	int	pm_size;		/* size of optional data portion */
};



/*
 * pm_type values
 */

#define	PM_STATUS	1		/* status response */
#define	PM_UNKNOWN	2		/* an unknown message was received */

/*
 * pm_state values
 */

/*
 * Class 1 responses
 */

#define	PM_STARTING	1		/* port monitor in starting state */
#define	PM_ENABLED	2		/* port monitor in enabled state */
#define	PM_DISABLED	3		/* port monitor in disabled state */
#define	PM_STOPPING	4		/* port monitor in stopping state */

/*
 * message to port monitor
 */

struct	sacmsg {
	int	sc_size;		/* size of optional data portion */
	char	sc_type;		/* type of message */
};



/*
 * sc_type values
 * These represent commands that the SAC sends to a port monitor.  These
 * commands are divided into "classes" for extensibility.  Each subsequent
 * "class" is a superset of the previous "classes" plus the new commands
 * defined within that "class".  The header for all commands is identical;
 * however, a command may be defined such that an optional data portion may
 * be sent in addition to the header.  The format of this optional data piece
 * is self-defining based on the command.  Important note:  the first message
 * sent by the SAC will always be a class 1 message.  The port monitor
 * response will indicate the maximum class that it is able to understand.
 * Another note is that port monitors should only respond to a message with
 * an equivalent class response (i.e. a class 1 command causes a class 1
 * response).
 */

/*
 * Class 1 commands (currently, there are only class 1 commands)
 */

#define	SC_STATUS	1		/* status request */
#define	SC_ENABLE	2		/* enable request */
#define	SC_DISABLE	3		/* disable request */
#define	SC_READDB	4		/* read pmtab request */

/*
 * `errno' values for Saferrno, note that Saferrno is used by
 * both pmadm and sacadm and these values are shared between
 * them
 */

#define	E_BADARGS	1	/* bad args or ill-formed command line */
#define	E_NOPRIV	2	/* user not privileged for operation */
#define	E_SAFERR	3	/* generic SAF error */
#define	E_SYSERR	4	/* system error */
#define	E_NOEXIST	5	/* invalid specification */
#define	E_DUP		6	/* entry already exists */
#define	E_PMRUN	7	/* port monitor is running */
#define	E_PMNOTRUN	8	/* port monitor is not running */
#define	E_RECOVER	9	/* in recovery */
#define	E_SACNOTRUN	10	/* sac daemon is not running */

extern int	doconfig(int, char *, long);

#ifdef	__cplusplus
}
#endif

#endif	/* _SAC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SCHED_H
#define	_SCHED_H

#include <sys/types.h>
#include <time.h>

#ifdef	__cplusplus
extern "C" {
#endif

struct sched_param {
	int	sched_priority;	/* scheduling priority */
	int	sched_pad[8];
};

/*
 * POSIX scheduling policies
 */
#define	SCHED_OTHER	0	/* traditional time-sharing scheduling class */
#define	SCHED_FIFO	1	/* real-time class: run to completion */
#define	SCHED_RR	2	/* real-time class: round-robin */
#define	SCHED_SYS	3	/* system scheduling class */
#define	SCHED_IA	4	/* interactive time-sharing class */
#define	SCHED_FSS	5	/* fair-share scheduling class */
#define	SCHED_FX	6	/* fixed-priority scheduling class */
#define	_SCHED_NEXT	7	/* first unassigned policy number */

/*
 * function prototypes
 */
int	sched_getparam(pid_t, struct sched_param *);
int	sched_setparam(pid_t, const struct sched_param *);
int	sched_getscheduler(pid_t);
int	sched_setscheduler(pid_t, int, const struct sched_param *);
int	sched_yield(void);
int	sched_get_priority_max(int);
int	sched_get_priority_min(int);
int	sched_rr_get_interval(pid_t, struct timespec *);

#ifdef	__cplusplus
}
#endif

#endif	/* _SCHED_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SCHEDCTL_H
#define	_SCHEDCTL_H

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/schedctl.h>

typedef sc_public_t schedctl_t;

extern void yield(void);

#define	schedctl_start(p)					\
		(void) (((p) == NULL)? 0 :			\
		((((schedctl_t *)(p))->sc_nopreempt = 1), 0))

#define	schedctl_stop(p)					\
		(void) (((p) == NULL)? 0 :			\
		((((schedctl_t *)(p))->sc_nopreempt = 0),	\
		(((schedctl_t *)(p))->sc_yield? (yield(), 0) : 0)))

/*
 * libsched API
 */
schedctl_t	*schedctl_init(void);
schedctl_t	*schedctl_lookup(void);
void		schedctl_exit(void);

#ifdef __cplusplus
}
#endif

#endif	/* _SCHEDCTL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SEARCH_H
#define	_SEARCH_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* HSEARCH(3C) */
typedef enum { FIND, ENTER } ACTION;

#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
struct qelem {
	struct qelem	*q_forw;
	struct qelem	*q_back;
};
#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

typedef struct entry { char *key, *data; } ENTRY;

int hcreate(size_t);
void hdestroy(void);
ENTRY *hsearch(ENTRY, ACTION);
#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2)
void insque(void *, void *);
void remque(void *);
#endif


/* TSEARCH(3C) */
typedef enum { preorder, postorder, endorder, leaf } VISIT;

void *tdelete(const void *_RESTRICT_KYWD, void **_RESTRICT_KYWD,
	int (*)(const void *, const void *));
void *tfind(const void *, void *const *, int (*)(const void *, const void *));
void *tsearch(const void *, void **, int (*)(const void *, const void *));
void twalk(const void *, void (*)(const void *, VISIT, int));


#if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE)
/* BSEARCH(3C) */
void *bsearch(const void *, const void *, size_t, size_t,
	    int (*)(const void *, const void *));
#endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) */

/* LSEARCH(3C) */
void *lfind(const void *, const void *, size_t *, size_t,
	    int (*)(const void *, const void *));
void *lsearch(const void *, void *, size_t *, size_t,
	    int (*)(const void *, const void *));

#ifdef	__cplusplus
}
#endif

#endif	/* _SEARCH_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef	_SECDB_H
#define	_SECDB_H

#ifdef	__cplusplus
extern "C" {
#endif


#define	DEFAULT_POLICY		"solaris"
#define	SUSER_POLICY		"suser"		/* fallback: old policy */

#define	KV_ACTION		"act"
#define	KV_COMMAND		"cmd"
#define	KV_JAVA_CLASS		"java_class"
#define	KV_JAVA_METHOD		"java_method"

#define	KV_ASSIGN		"="
#define	KV_DELIMITER		";"
#define	KV_EMPTY		""
#define	KV_ESCAPE		'\\'
#define	KV_ADD_KEYS		16    /* number of key value pairs to realloc */
#define	KV_SPECIAL		"=;:\\"
#define	KV_TOKEN_DELIMIT	":"
#define	KV_WILDCARD		"*"
#define	KV_WILDCHAR		'*'
#define	KV_ACTION_WILDCARD	"*;*;*;*;*"
#define	KV_SEPCHAR		','
#define	KV_SEPSTR		","
#define	KV_OBJECTCHAR		'/'
#define	KV_OBJECT		"/"
#define	KV_AUDIT_DELIMIT	":"

#define	KV_FLAG_NONE		0x0000
#define	KV_FLAG_REQUIRED	0x0001

/*
 * return status macros for all attribute databases
 */
#define	ATTR_FOUND		0	/* Authoritative found */
#define	ATTR_NOT_FOUND		-1	/* Authoritative not found */
#define	ATTR_NO_RECOVERY	-2	/* Non-recoverable errors */


typedef struct kv_s {
	char   *key;
	char   *value;
} kv_t;					/* A key-value pair */

typedef struct kva_s {
	int	length;			/* array length */
	kv_t    *data;			/* array of key value pairs */
} kva_t;				/* Key-value array */


extern char *kva_match(kva_t *, char *);
extern int _auth_match(const char *, const char *);
extern char *_argv_to_csl(char **strings);
extern char **_csl_to_argv(char *csl);
extern char *_do_unescape(char *src);
extern void _free_argv(char **p_argv);
extern int _insert2kva(kva_t *, char *, char *);
extern int _kva2str(kva_t *, char *, int, char *, char *);
extern kva_t *_kva_dup(kva_t *);
extern void _kva_free(kva_t *);
extern void _kva_free_value(kva_t *, char *);
extern kva_t *_new_kva(int size);
extern kva_t *_str2kva(char *, char *, char *);
extern int _enum_auths(const char *, int (*)(const char *, void *, void *),
    void *ctxt, void *pres);
extern int _enum_profs(const char *,
    int (*)(const char *, kva_t *, void *, void *), void *ctxt, void *pres);
extern int _enum_attrs(const char *,
    int (*)(const char *, kva_t *, void *, void *), void *ctxt, void *pres);

#ifdef	__cplusplus
}
#endif

#endif	/* _SECDB_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SEMAPHORE_H
#define	_SEMAPHORE_H

#include <sys/feature_tests.h>

#include <sys/types.h>
#include <sys/fcntl.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Including <time.h> has an unfortunate XPG/POSIX history. In XPG6 and POSIX
 * 1999, sem_timedwait() was added which required making the struct timespec
 * declared in some form. In XPG7, this is permitted to make all of time.h
 * visible. In XPG8, the use of the clockid_t is required from time.h. For
 * better and worse, that is how the ifdef soup is here. We prefer including
 * time.h so that folks can get a full definition for the time struct timespec
 * rather than the forward declaration that most other OSes do here.
 */
#if !defined(_STRICT_POSIX) || defined(_XPG7)
#include <time.h>
#elif defined(_XPG6)
struct timespec;
#endif

typedef struct {
	/* this structure must be the same as sema_t in <synch.h> */
	uint32_t	sem_count;	/* semaphore count */
	uint16_t	sem_type;
	uint16_t	sem_magic;
	upad64_t	sem_pad1[3];	/* reserved for a mutex_t */
	upad64_t	sem_pad2[2];	/* reserved for a cond_t */
} sem_t;

#define	SEM_FAILED	((sem_t *)(-1))

/*
 * function prototypes
 */
int	sem_init(sem_t *, int, unsigned int);
int	sem_destroy(sem_t *);
sem_t	*sem_open(const char *, int, ...);
int	sem_close(sem_t *);
int	sem_unlink(const char *);
int	sem_wait(sem_t *);

#if !defined(_STRICT_POSIX) || defined(_XPG6)
int	sem_timedwait(sem_t *_RESTRICT_KYWD,
		const struct timespec *_RESTRICT_KYWD);
int	sem_reltimedwait_np(sem_t *_RESTRICT_KYWD,
		const struct timespec *_RESTRICT_KYWD);
#endif	/* !_STRICT_POSIX || _XPG6 */

#if !defined(_STRICT_POSIX) || defined(_XPG8)
int	sem_clockwait(sem_t *_RESTRICT_KYWD, clockid_t,
		const struct timespec *_RESTRICT_KYWD);
int	sem_relclockwait_np(sem_t *_RESTRICT_KYWD, clockid_t,
		const struct timespec *_RESTRICT_KYWD);
#endif	/* !_STRICT_POSIX || _XPG8 */
int	sem_trywait(sem_t *);
int	sem_post(sem_t *);
int	sem_getvalue(sem_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);

#ifdef	__cplusplus
}
#endif

#endif	/* _SEMAPHORE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SETJMP_H
#define	_SETJMP_H

#include <iso/setjmp_iso.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/setjmp_iso.h>.
 */
#if __cplusplus >= 199711L
using std::jmp_buf;
using std::longjmp;
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \
	defined(__EXTENSIONS__)
/* non-ANSI standard compilation */

#if defined(_LP64)
typedef long sigjmp_buf[_SIGJBLEN];
#else
typedef int sigjmp_buf[_SIGJBLEN];
#endif

extern int sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
extern void siglongjmp(sigjmp_buf, int) __NORETURN;
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _SETJMP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _SGTTY_H
#define	_SGTTY_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Modes
 */
#define	HUPCL	01
#ifndef _SYS_IOCTL_H
#define	XTABS	02
#define	LCASE	04
#define	ECHO	010
#define	CRMOD	020
#define	RAW	040
#define	ODDP	0100
#define	EVENP	0200
#define	ANYP	0300
#define	NLDELAY	001400
#define	TBDELAY	002000
#define	CRDELAY	030000
#define	VTDELAY	040000
#define	BSDELAY 0100000
#define	ALLDELAY 0177400

/*
 * Delay algorithms
 */
#define	CR0	0
#define	CR1	010000
#define	CR2	020000
#define	CR3	030000
#define	NL0	0
#define	NL1	000400
#define	NL2	001000
#define	NL3	001400
#define	TAB0	0
#define	TAB1	002000
#endif /* _SYS_IOCTL_H */
#define	NOAL	004000
#ifndef _SYS_IOCTL_H
#define	FF0	0
#define	FF1	040000
#define	BS0	0
#define	BS1	0100000
#endif /* _SYS_IOCTL_H */

#ifndef _SYS_TTOLD_H

/*
 * Structure for stty and gtty system calls.
 */
struct sgttyb {
	char	sg_ispeed;		/* input speed */
	char	sg_ospeed;		/* output speed */
	char	sg_erase;		/* erase character */
	char	sg_kill;		/* kill character */
	int	sg_flags;		/* mode flags */
};

/* BSD local special chars. Structure for TIOCSLTC/TIOCGLTC */
struct ltchars {
	char	t_suspc;	/* stop process signal */
	char	t_dsuspc;	/* delayed stop process signal */
	char	t_rprntc;	/* reprint line */
	char	t_flushc;	/* flush output (toggles) */
	char	t_werasc;	/* word erase */
	char	t_lnextc;	/* literal next character */
};

/*
 * Speeds
 */
#define	B0	0
#define	B50	1
#define	B75	2
#define	B110	3
#define	B134	4
#define	B150	5
#define	B200	6
#define	B300	7
#define	B600	8
#define	B1200	9
#define	B1800	10
#define	B2400	11
#define	B4800	12
#define	B9600	13
#define	EXTA	14
#define	EXTB	15

/*
 *	ioctl arguments
 */
#define	FIOCLEX		(('f'<<8)|1)
#define	FIONCLEX	(('f'<<8)|2)
#define	TIOCHPCL	(('t'<<8)|2)
#define	TIOCGETP	(('t'<<8)|8)
#define	TIOCSETP	(('t'<<8)|9)
#define	TIOCEXCL	(('t'<<8)|13)
#define	TIOCNXCL	(('t'<<8)|14)

#endif	/* _SYS_TTOLD_H */

#ifdef	__cplusplus
}
#endif

#endif	/* _SGTTY_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_SHADOW_H
#define	_SHADOW_H


#ifdef	__cplusplus
extern "C" {
#endif

#define	PASSWD		"/etc/passwd"
#define	SHADOW		"/etc/shadow"
#define	OPASSWD		"/etc/opasswd"
#define	OSHADOW		"/etc/oshadow"
#define	PASSTEMP	"/etc/ptmp"
#define	SHADTEMP	"/etc/stmp"

#define	DAY		(24L * 60 * 60) /* 1 day in seconds */
#define	DAY_NOW		(time_t)time((time_t *)0) / DAY
			/* The above timezone variable is set by a call to */
			/* any ctime(3c) routine.  Programs using the DAY_NOW */
			/* macro must call one of the ctime routines, */
			/* e.g. tzset(), BEFORE referencing DAY_NOW */

#define	LOCKSTRING	"*LK*"	/* prefix to/string in sp_pwdp to lock acct */
#define	NOLOGINSTRING	"NP"	/* sp_pwdp for no-login accounts */
#define	NOPWDRTR	"*NP*"	/* password is not retrievable */
/*
 * The spwd structure is used in the retreval of information from
 * /etc/shadow.  It is used by routines in the libos library.
 */
struct spwd {
	char *sp_namp;	/* user name */
	char *sp_pwdp;	/* user password */
	int sp_lstchg;	/* password lastchanged date */
	int sp_min;	/* minimum number of days between password changes */
	int sp_max;	/* number of days password is valid */
	int sp_warn;	/* number of days to warn user to change passwd */
	int sp_inact;	/* number of days the login may be inactive */
	int sp_expire;	/* date when the login is no longer valid */
	unsigned int sp_flag;	/* currently low 4 bits are used */

	/* low 4 bits of sp_flag for counting failed login attempts */
#define	FAILCOUNT_MASK 0xF
};

#ifndef _STDIO_H
#include <stdio.h>
#endif

/* Declare all shadow password functions */

extern struct spwd *getspnam_r(const char *,  struct spwd *, char *, int);
extern struct spwd *getspent_r(struct spwd *, char *, int);
extern struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int);

extern void	setspent(void);
extern void	endspent(void);
extern struct spwd	*getspent(void);			/* MT-unsafe */
extern struct spwd	*fgetspent(FILE *);			/* MT-unsafe */
extern struct spwd	*getspnam(const char *);	/* MT-unsafe */

extern int	putspent(const struct spwd *, FILE *);
extern int	lckpwdf(void);
extern int	ulckpwdf(void);

#ifdef	__cplusplus
}
#endif

#endif	/* _SHADOW_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2015 Circonus, Inc.  All rights reserved.
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef	_SIGINFO_H
#define	_SIGINFO_H

#include <sys/types.h>
#include <sys/siginfo.h>

#ifdef	__cplusplus
extern "C" {
#endif

struct siginfolist {
	int nsiginfo;
	char **vsiginfo;
};

extern const char *_sys_illlist[];
extern const char *_sys_fpelist[];
extern const char *_sys_segvlist[];
extern const char *_sys_buslist[];
extern const char *_sys_traplist[];
extern const char *_sys_cldlist[];
extern const struct siginfolist *_sys_siginfolistp;
#define	_sys_siginfolist	_sys_siginfolistp

extern void psignal(int, const char *);
extern void psiginfo(const siginfo_t *, const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _SIGINFO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SIGNAL_H
#define	_SIGNAL_H

#include <sys/feature_tests.h>

#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(__XOPEN_OR_POSIX)
#include <sys/types.h>	/* need pid_t/uid_t/size_t/clock_t/caddr_t/pthread_t */
#endif

#include <iso/signal_iso.h>
#include <sys/signal.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/signal_iso.h>.
 */
#if __cplusplus >= 199711L
using std::sig_atomic_t;
using std::signal;
using std::raise;
#endif

#ifdef	__cplusplus
extern "C" {
#endif


extern const char	**_sys_siglistp;	/* signal descriptions */
extern const int	_sys_siglistn;		/* # of signal descriptions */

#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
#define	_sys_siglist	_sys_siglistp
#define	_sys_nsig	_sys_siglistn
#endif

#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(__XOPEN_OR_POSIX)
extern int kill(pid_t, int);
extern int sigaction(int, const struct sigaction *_RESTRICT_KYWD,
	struct sigaction *_RESTRICT_KYWD);
#if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
extern int sigaddset(sigset_t *, int);
extern int sigdelset(sigset_t *, int);
extern int sigemptyset(sigset_t *);
extern int sigfillset(sigset_t *);
extern int sigismember(const sigset_t *, int);
#endif
extern int sigpending(sigset_t *);
extern int sigprocmask(int, const sigset_t *_RESTRICT_KYWD,
	sigset_t *_RESTRICT_KYWD);
extern int sigsuspend(const sigset_t *);
#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC)... */

#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
	!defined(__XOPEN_OR_POSIX))
#include <sys/procset.h>
extern int gsignal(int);
extern int (*ssignal(int, int (*)(int)))(int);
extern int sigsend(idtype_t, id_t, int);
extern int sigsendset(const procset_t *, int);
extern int sig2str(int, char *);
extern int str2sig(const char *, int *);
#define	SIG2STR_MAX	32
#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC)... */

#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
	!defined(__XOPEN_OR_POSIX)) || defined(_XPG4_2)
extern void (*bsd_signal(int, void (*)(int)))(int);
extern int killpg(pid_t, int);
extern int siginterrupt(int, int);
extern int sigaltstack(const stack_t *_RESTRICT_KYWD, stack_t *_RESTRICT_KYWD);
extern int sighold(int);
extern int sigignore(int);
extern int sigpause(int);
extern int sigrelse(int);
extern void (*sigset(int, void (*)(int)))(int);
#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... */

/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(defined(_XPG4_2) && !defined(_XPG6))
extern int sigstack(struct sigstack *, struct sigstack *);
#endif

#if defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE > 2)
#include <sys/siginfo.h>
#include <time.h>
extern int pthread_kill(pthread_t, int);
extern int pthread_sigmask(int, const sigset_t *_RESTRICT_KYWD,
	sigset_t *_RESTRICT_KYWD);
extern int sigwaitinfo(const sigset_t *_RESTRICT_KYWD,
	siginfo_t *_RESTRICT_KYWD);
extern int sigtimedwait(const sigset_t *_RESTRICT_KYWD,
	siginfo_t *_RESTRICT_KYWD, const struct timespec *_RESTRICT_KYWD);
extern int sigqueue(pid_t, int, const union sigval);
#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && */

/*
 * sigwait() prototype is defined here.
 */

#if	defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && \
	!defined(__XOPEN_OR_POSIX)) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
	defined(_POSIX_PTHREAD_SEMANTICS)

#if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname sigwait __posix_sigwait
extern int sigwait(const sigset_t *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
#else  /* __PRAGMA_REDEFINE_EXTNAME */

extern int __posix_sigwait(const sigset_t *_RESTRICT_KYWD,
    int *_RESTRICT_KYWD);

#ifdef	__lint
#define	sigwait __posix_sigwait
#else	/* !__lint */

static int
sigwait(const sigset_t *_RESTRICT_KYWD __setp, int *_RESTRICT_KYWD __signo)
{
	return (__posix_sigwait(__setp, __signo));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

extern int sigwait(sigset_t *);

#endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */

#ifdef	__cplusplus
}
#endif

#endif	/* _SIGNAL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright (c) 2011 by Delphix. All rights reserved.
 */

#ifndef _SPAWN_H
#define	_SPAWN_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#include <signal.h>
#include <sched.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * flags for posix_spawnattr_setflags()
 */
#define	POSIX_SPAWN_RESETIDS		0x0001
#define	POSIX_SPAWN_SETPGROUP		0x0002
#define	POSIX_SPAWN_SETSIGDEF		0x0004
#define	POSIX_SPAWN_SETSIGMASK		0x0008
#define	POSIX_SPAWN_SETSCHEDPARAM	0x0010
#define	POSIX_SPAWN_SETSCHEDULER	0x0020
#define	POSIX_SPAWN_SETSID		0x0040
/*
 * non-portable extensions
 */
#if !defined(_STRICT_POSIX)
#define	POSIX_SPAWN_SETSIGIGN_NP	0x0800
#define	POSIX_SPAWN_NOSIGCHLD_NP	0x1000
#define	POSIX_SPAWN_WAITPID_NP		0x2000
#define	POSIX_SPAWN_NOEXECERR_NP	0x4000
#endif	/* !_STRICT_POSIX */

typedef struct {
	void *__spawn_attrp;	/* implementation-private */
} posix_spawnattr_t;

typedef struct {
	void *__file_attrp;	/* implementation-private */
} posix_spawn_file_actions_t;

extern int posix_spawn(
	pid_t *_RESTRICT_KYWD pid,
	const char *_RESTRICT_KYWD path,
	const posix_spawn_file_actions_t *file_actions,
	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
	char *const *_RESTRICT_KYWD argv,
	char *const *_RESTRICT_KYWD envp);

extern int posix_spawnp(
	pid_t *_RESTRICT_KYWD pid,
	const char *_RESTRICT_KYWD file,
	const posix_spawn_file_actions_t *file_actions,
	const posix_spawnattr_t *_RESTRICT_KYWD attrp,
	char *const *_RESTRICT_KYWD argv,
	char *const *_RESTRICT_KYWD envp);

extern int posix_spawn_file_actions_init(
	posix_spawn_file_actions_t *file_actions);

extern int posix_spawn_file_actions_destroy(
	posix_spawn_file_actions_t *file_actions);

extern int posix_spawn_file_actions_addchdir(
	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
	const char *_RESTRICT_KYWD path);

extern int posix_spawn_file_actions_addopen(
	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
	int filedes,
	const char *_RESTRICT_KYWD path,
	int oflag,
	mode_t mode);

extern int posix_spawn_file_actions_addclose(
	posix_spawn_file_actions_t *file_actions,
	int filedes);

extern int posix_spawn_file_actions_adddup2(
	posix_spawn_file_actions_t *file_actions,
	int filedes,
	int newfiledes);

extern int posix_spawn_file_actions_addfchdir(
	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
	int fd);

extern int posix_spawnattr_init(
	posix_spawnattr_t *attr);

extern int posix_spawnattr_destroy(
	posix_spawnattr_t *attr);

extern int posix_spawnattr_setflags(
	posix_spawnattr_t *attr,
	short flags);

extern int posix_spawnattr_getflags(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	short *_RESTRICT_KYWD flags);

extern int posix_spawnattr_setpgroup(
	posix_spawnattr_t *attr,
	pid_t pgroup);

extern int posix_spawnattr_getpgroup(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	pid_t *_RESTRICT_KYWD pgroup);

extern int posix_spawnattr_setschedparam(
	posix_spawnattr_t *_RESTRICT_KYWD attr,
	const struct sched_param *_RESTRICT_KYWD schedparam);

extern int posix_spawnattr_getschedparam(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	struct sched_param *_RESTRICT_KYWD schedparam);

extern int posix_spawnattr_setschedpolicy(
	posix_spawnattr_t *attr,
	int schedpolicy);

extern int posix_spawnattr_getschedpolicy(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	int *_RESTRICT_KYWD schedpolicy);

extern int posix_spawnattr_setsigdefault(
	posix_spawnattr_t *_RESTRICT_KYWD attr,
	const sigset_t *_RESTRICT_KYWD sigdefault);

extern int posix_spawnattr_getsigdefault(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	sigset_t *_RESTRICT_KYWD sigdefault);

/*
 * non-portable extensions
 */
#if !defined(_STRICT_POSIX)

extern int posix_spawn_pipe_np(
	pid_t *_RESTRICT_KYWD pidp,
	int *_RESTRICT_KYWD fdp,
	const char *_RESTRICT_KYWD cmd,
	boolean_t write,
	posix_spawn_file_actions_t *_RESTRICT_KYWD fact,
	posix_spawnattr_t *_RESTRICT_KYWD attr);

extern int posix_spawn_file_actions_addclosefrom_np(
	posix_spawn_file_actions_t *file_actions,
	int lowfiledes);

extern int posix_spawnattr_setsigignore_np(
	posix_spawnattr_t *_RESTRICT_KYWD attr,
	const sigset_t *_RESTRICT_KYWD sigignore);

extern int posix_spawnattr_getsigignore_np(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	sigset_t *_RESTRICT_KYWD sigignore);

/*
 * These _np variants are not documented in the manual, but are provided for
 * compatibility purposes with folks who have implemented this prior to
 * standardization in POSIX 2024.
 */
extern int posix_spawn_file_actions_addchdir_np(
	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
	const char *_RESTRICT_KYWD path);

extern int posix_spawn_file_actions_addfchdir_np(
	posix_spawn_file_actions_t *_RESTRICT_KYWD file_actions,
	int fd);

#endif	/* !_STRICT_POSIX */

extern int posix_spawnattr_setsigmask(
	posix_spawnattr_t *_RESTRICT_KYWD attr,
	const sigset_t *_RESTRICT_KYWD sigmask);

extern int posix_spawnattr_getsigmask(
	const posix_spawnattr_t *_RESTRICT_KYWD attr,
	sigset_t *_RESTRICT_KYWD sigmask);

#ifdef	__cplusplus
}
#endif

#endif	/* _SPAWN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Public interfaces for AMD64 Unwind routines
 */

#ifndef _STACK_UNWIND_H
#define	_STACK_UNWIND_H

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__amd64)	/* none of this is valid except for AMD64 */

typedef enum {
	_URC_NO_REASON = 0,
	_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
	_URC_FATAL_PHASE2_ERROR = 2,
	_URC_FATAL_PHASE1_ERROR = 3,
	_URC_NORMAL_STOP = 4,
	_URC_END_OF_STACK = 5,
	_URC_HANDLER_FOUND = 6,
	_URC_INSTALL_CONTEXT = 7,
	_URC_CONTINUE_UNWIND = 8
} _Unwind_Reason_Code;

typedef int _Unwind_Action;
extern const _Unwind_Action _UA_SEARCH_PHASE;
extern const _Unwind_Action _UA_CLEANUP_PHASE;
extern const _Unwind_Action _UA_HANDLER_FRAME;
extern const _Unwind_Action _UA_FORCE_UNWIND;

struct _Unwind_Exception;
struct _Unwind_Context;


/*
 * Signature of language specific call back for deleting exception object
 */
typedef void (*_Unwind_Exception_Cleanup_Fn)(
	_Unwind_Reason_Code reason,
	struct _Unwind_Exception *exc);

/*
 * Header preceding language specific exception object
 * For Sun C++ these fields are the beginning of the
 * language specific structure.
 */
struct _Unwind_Exception {
	uint64_t exception_class;
	_Unwind_Exception_Cleanup_Fn exception_cleanup;
	uint64_t private_1;
	uint64_t private_2;
};

/*
 * Signature for language specific routine - address is in eh_frame CIE.
 * During phase one it predicts whether exception would be caught at this
 * frame and during phase two selects a handler as predicted.  An action
 * of _UA_FORCE_UNWIND will prevent any catch block from being selected.
 *
 * The personality function is the only call back used when
 * _Unwind_RaiseException() is called.
 */
typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
	int version,
	_Unwind_Action actions,
	uint64_t exceptionClass,
	struct _Unwind_Exception *exceptionObject,
	struct _Unwind_Context *context);

/*
 * Signature of callback function that is used when _Unwind_ForcedUnwind()
 * is called.  It is called at every step of walkback and that can control
 * the execution of the personality routine at each frame.
 */
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(
	int version,
	_Unwind_Action actions,
	uint64_t exceptionClass,
	struct _Unwind_Exception *exceptionObject,
	struct _Unwind_Context *context,
	void *stop_parameter);

/*
 * Here begins the external functional interface
 */

/*
 * Used to implement C++ throw - starts walkback with caller's caller.
 * The routine in the middle must use %rbp as a frame pointer
 */
_Unwind_Reason_Code _Unwind_RaiseException(
	struct _Unwind_Exception *exception_object);

/*
 * Used (with different stop functions) for POSIX thread cancellation
 * and stack walking - starts walkback with caller's caller.
 *
 * Note: must be called by a routine which has a real FP and doesn't use
 * callee saves registers.
 */
_Unwind_Reason_Code _Unwind_ForcedUnwind(
	struct _Unwind_Exception *exception_object,
	_Unwind_Stop_Fn stop,
	void *stop_parameter);

/*
 * Used to resume unwinding at end of cleanup (not catch) code
 * Assumes that caller is language specific cleanup code and
 * pops the stack one level before resuming walk.
 */
void _Unwind_Resume(struct _Unwind_Exception *exception_object);

/*
 * Calls destructor function for exception object
 */
void _Unwind_DeleteException(struct _Unwind_Exception *exception_object);
/*
 * {
 *	(*(exception_object->exception_cleanup))(_URC_NO_REASON,
 *		exception_object);
 * }
 */


#if 0

extern "C" _Unwind_Reason_Code
__example_stop_fn(int version, int actions, uint64_t exclass,
    struct _Unwind_Exception *exception_object,
    struct _Unwind_Context *ctx, void *_Sa)
{
	_Unwind_Reason_Code res;

	uint64_t fp = _Unwind_GetCFA(ctx);

	if (fp == 0 || _Unwind_GetGR(ctx, RET_ADD) == 0) {
		if (no_return)
			die;
		res = _URC_END_OF_STACK;
	} else {
		/*
		 * Your logic here:
		 * res = ........
		 */
	}
	switch (res) {
	case _URC_NO_REASON:
		/*
		 * framework will call personality routine for current context
		 * then then move one frame back the stack and call here with
		 * updated context. POSIX thread cancellation uses this pattern.
		 *
		 * If this path is taken the exception object passed must have
		 * been constructed by the same language system supplying the
		 * personality routines. i.e. foreign exceptions are not
		 * implemented.
		 *
		 * The Sun Microsystems C++ runtime contains the routine
		 *
		 *	_ex_unwind(_Unwind_Stop_fn sfunc, void *sfunc_arg)
		 *
		 * which is a wrapper around _Unwind_ForcedUnwind that
		 * sets up a C++ exception object.
		 *
		 * Once this path is taken, the stack frame from which
		 * _Unwind_ForcedUnwind was called is not guaranteed to
		 * still exist. Thus the return codes listed below which
		 * result in that call returning are rendered bogus.
		 *
		 * A thread reaching the end of the stack during cancellation
		 * must die instead of returning _URC_END_OF_STACK.
		 */
		break;
	case _URC_CONTINUE_UNWIND:
		/*
		 * framework will move one frame back the stack and
		 * call here with updated context
		 *
		 * The exception record supplied to _Unwind_ForcedUnwind
		 * need only contain the header and may be stack allocated
		 * if this function will never allow the personality
		 * function to run (as in a trace generator).
		 */
		break;
	case _URC_INSTALL_CONTEXT:
		/*
		 * framework will resume execution of user code at location
		 * specified by (altered) context
		 */
		_Unwind_Delete_Exception(res, exception_object);
		break;
	case _URC_NORMAL_STOP:
		/*
		 * call to _Unwind_ForcedUnwind will return _URC_NORMAL_STOP
		 */
		_Unwind_Delete_Exception(res, exception_object);
		break;
	case _URC_END_OF_STACK:
		/*
		 * call to _Unwind_ForcedUnwind will return _URC_END_OF_STACK
		 */
		_Unwind_Delete_Exception(res, exception_object);
		break;
	case _URC_FOREIGN_EXCEPTION_CAUGHT:
	case _URC_FATAL_PHASE2_ERROR:
	case _URC_FATAL_PHASE1_ERROR:
	case _URC_HANDLER_FOUND:
		/*
		 * call to _Unwind_ForcedUnwind will return
		 * _URC_FATAL_PHASE2_ERROR
		 */
		_Unwind_Delete_Exception(res, exception_object);
		break;
	}
	return (res);
}

#endif

/*
 * Stack frame context accessors defined in ABI
 * (despite all the dire text in the ABI these are reliable Get/Set routines)
 * Note: RA is handled as a GR value
 */

/*
 * Valid Index values for _Unwind_GetGR
 */
#define	GPR_RBX	3	/* callee saves */
#define	FP_RBP	6	/* callee saves (optional frame pointer) */
#define	SP_RSP	7	/* callee saves */
#define	EIR_R12	12	/* callee saves */
#define	EIR_R13	13	/* callee saves */
#define	EIR_R14	14	/* callee saves */
#define	EIR_R15	15	/* callee saves */
#define	RET_ADD	16	/* virtual register - really caller's PC */

/*
 * Valid Index values for _Unwind_SetGR
 */
#define	GPR_RDX	1	/* landing pad parameter */
#define	GPR_RCX	2	/* landing pad parameter */
#define	GPR_RSI	4	/* landing pad parameter */
#define	GPR_RDI	5	/* landing pad parameter */

uint64_t _Unwind_GetGR(struct _Unwind_Context *context, int index);

void _Unwind_SetGR(struct _Unwind_Context *context, int index,
	uint64_t new_value);

uint64_t _Unwind_GetCFA(struct _Unwind_Context *context);

uint64_t _Unwind_GetIP(struct _Unwind_Context *context);

void _Unwind_SetIP(struct _Unwind_Context *context, uint64_t new_value);

void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context *context);

uint64_t _Unwind_GetRegionStart(struct _Unwind_Context *context);

#endif	/* __amd64 */

#ifdef	__cplusplus
}
#endif

#endif	/* _STACK_UNWIND_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2023 Oxide Computer Company
 */

#ifndef _STDALIGN_H
#define	_STDALIGN_H

#include <sys/stdalign.h>

#endif /* _STDALIGN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDARG_H
#define	_STDARG_H

/*
 * This header defines the ISO C 1989, ISO C++ 1998, and ISO C 1999
 * variable argument definitions.  For legacy support, it also defines
 * the pre-standard variable argument definitions.
 *
 * The varargs definitions within this header are defined in terms of
 * implementation definitions.  These implementation definitions reside
 * in <sys/va_list.h>.  This organization enables protected use of
 * the implementation by other standard headers without introducing
 * names into the users' namespace.
 */

#include <iso/stdarg_iso.h>
#include <iso/stdarg_c99.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/stdarg_iso.h>.
 */
#if __cplusplus >= 199711L
using std::va_list;
#endif

#endif	/* _STDARG_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2024 Oxide Computer Company
 */

#ifndef _STDBIT_H
#define	_STDBIT_H

/*
 * This header was introduced in C23 and is the standard's expected interface
 * for this functionality. We provide these routines to both userland and the
 * kernel and all of the related declarations are in <sys/stdbit.h>.
 */

#include <sys/stdbit.h>

#endif /* _STDBIT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDBOOL_H
#define	_STDBOOL_H

#include <sys/stdbool.h>

#endif	/* _STDBOOL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDDEF_H
#define	_STDDEF_H

#include <sys/isa_defs.h>
#include <iso/stddef_iso.h>
#include <sys/stddef.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/stddef_iso.h>.
 */
#if __cplusplus >= 199711L
using std::ptrdiff_t;
using std::size_t;
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * wchar_t is a built-in type in standard C++ and as such is not
 * defined here when using standard C++. However, the GNU compiler
 * fixincludes utility nonetheless creates its own version of this
 * header for use by gcc and g++. In that version it adds a redundant
 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 * header we need to include the following magic comment:
 *
 * we must use the C++ compiler's type
 *
 * The above comment should not be removed or changed until GNU
 * gcc/fixinc/inclhack.def is updated to bypass this header.
 */
#if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
#ifndef _WCHAR_T
#define	_WCHAR_T
#if defined(_LP64)
typedef int	wchar_t;
#else
typedef long    wchar_t;
#endif
#endif  /* !_WCHAR_T */
#endif	/* !defined(__cplusplus) ... */

#ifdef	__cplusplus
}
#endif

#endif	/* _STDDEF_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDINT_H
#define	_STDINT_H

/*
 * This header was introduced by the ISO C Standard, ISO/IEC
 * 9899:1999 Programming language - C. It is a subset of the
 * <inttypes.h> header.
 */

#include <sys/stdint.h>

#if __EXT1_VISIBLE
/* ISO/IEC 9899:2011 K.3.4.4 */
#ifndef	RSIZE_MAX
#define	RSIZE_MAX (SIZE_MAX >> 1)
#endif
#endif	/* __EXT1_VISIBLE */

#endif	/* _STDINT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2025 Hans Rosenfeld
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * User-visible pieces of the ANSI C standard I/O package.
 */

#ifndef _STDIO_H
#define	_STDIO_H

#include <sys/feature_tests.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Do all of our 'redefine_extname' processing before
 * declarations of the associated functions are seen.
 * This is necessary to keep gcc happy.
 */
#if defined(__PRAGMA_REDEFINE_EXTNAME)

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#pragma redefine_extname	fopen		fopen64
#pragma redefine_extname	freopen		freopen64
#pragma redefine_extname	tmpfile		tmpfile64
#pragma redefine_extname	fgetpos		fgetpos64
#pragma redefine_extname	fsetpos		fsetpos64
#if defined(_LARGEFILE_SOURCE)
#pragma redefine_extname	fseeko		fseeko64
#pragma redefine_extname	ftello		ftello64
#endif	/* _LARGEFILE_SOURCE */
#endif	/* !defined(_LP64) && _FILE_OFFSET_BITS == 64 */

/* In the LP64 compilation environment, all APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#pragma redefine_extname	fopen64		fopen
#pragma redefine_extname	freopen64	freopen
#pragma redefine_extname	tmpfile64	tmpfile
#pragma redefine_extname	fgetpos64	fgetpos
#pragma redefine_extname	fsetpos64	fsetpos
#if defined(_LARGEFILE_SOURCE)
#pragma redefine_extname	fseeko64	fseeko
#pragma redefine_extname	ftello64	ftello
#endif	/* _LARGEFILE_SOURCE */
#endif	/* defined(_LP64) && defined(_LARGEFILE64_SOURCE) */

#endif	/* __PRAGMA_REDEFINE_EXTNAME */

#ifdef	__cplusplus
}
#endif

#include <iso/stdio_iso.h>

/*
 * If feature test macros are set that enable interfaces that use types
 * defined in <sys/types.h>, get those types by doing the include.
 *
 * Note that in asking for the interfaces associated with this feature test
 * macro one also asks for definitions of the POSIX types.
 */

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/stdio_iso.h>.
 */
#if __cplusplus >= 199711L
using std::FILE;
using std::size_t;
using std::fpos_t;
using std::remove;
using std::rename;
using std::tmpfile;
using std::tmpnam;
using std::fclose;
using std::fflush;
using std::fopen;
using std::freopen;
using std::setbuf;
using std::setvbuf;
using std::fprintf;
using std::fscanf;
using std::printf;
using std::scanf;
using std::sprintf;
using std::sscanf;
using std::vfprintf;
using std::vprintf;
using std::vsprintf;
using std::fgetc;
using std::fgets;
using std::fputc;
using std::fputs;
using std::getc;
using std::getchar;
using std::gets;
using std::putc;
using std::putchar;
using std::puts;
using std::ungetc;
using std::fread;
using std::fwrite;
using std::fgetpos;
using std::fseek;
using std::fsetpos;
using std::ftell;
using std::rewind;
using std::clearerr;
using std::feof;
using std::ferror;
using std::perror;
#ifndef	_LP64
using std::__filbuf;
using std::__flsbuf;
#endif	/* _LP64 */
#endif	/*  __cplusplus >= 199711L */

/*
 * This header needs to be included here because it relies on the global
 * visibility of FILE and size_t in the C++ environment.
 */
#include <iso/stdio_c99.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
#ifndef	_OFF_T
#define	_OFF_T
#if defined(_LP64) || _FILE_OFFSET_BITS == 32
typedef long		off_t;
#else
typedef __longlong_t	off_t;
#endif
#ifdef	_LARGEFILE64_SOURCE
#ifdef _LP64
typedef	off_t		off64_t;
#else
typedef __longlong_t	off64_t;
#endif
#endif /* _LARGEFILE64_SOURCE */
#endif /* _OFF_T */
#endif /* _LARGEFILE_SOURCE */

#ifdef _LARGEFILE64_SOURCE
#ifdef _LP64
typedef fpos_t		fpos64_t;
#else
typedef __longlong_t	fpos64_t;
#endif
#endif /* _LARGEFILE64_SOURCE */

/*
 * XPG4 requires that va_list be defined in <stdio.h> "as described in
 * <stdarg.h>".  ANSI-C and POSIX require that the namespace of <stdio.h>
 * not be polluted with this name.
 */
#if defined(_XPG4) && !defined(_VA_LIST)
#define	_VA_LIST
typedef	__va_list va_list;
#endif	/* defined(_XPG4 && !defined(_VA_LIST) */

#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
		defined(__XOPEN_OR_POSIX)

#define	L_ctermid	9

/* Marked LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
#define	L_cuserid	9
#endif

#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XOPEN_SOURCE)

#define	P_tmpdir	"/var/tmp/"
#endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */

#ifndef _STDIO_ALLOCATE
extern unsigned char	 _sibuf[], _sobuf[];
#endif

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#if !defined(__PRAGMA_REDEFINE_EXTNAME)
extern FILE	*fopen64(const char *, const char *);
extern FILE	*freopen64(const char *, const char *, FILE *);
extern FILE	*tmpfile64(void);
extern int	fgetpos64(FILE *, fpos_t *);
extern int	fsetpos64(FILE *, const fpos_t *);
#define	fopen			fopen64
#define	freopen			freopen64
#define	tmpfile			tmpfile64
#define	fgetpos			fgetpos64
#define	fsetpos			fsetpos64
#ifdef	_LARGEFILE_SOURCE
#define	fseeko			fseeko64
#define	ftello			ftello64
#endif
#endif	/* !__PRAGMA_REDEFINE_EXTNAME */
#endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */

#ifndef _LP64
extern unsigned char	*_bufendtab[];
extern FILE		*_lastbuf;
#endif

/* In the LP64 compilation environment, all APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#if !defined(__PRAGMA_REDEFINE_EXTNAME)
#define	fopen64		fopen
#define	freopen64	freopen
#define	tmpfile64	tmpfile
#define	fgetpos64	fgetpos
#define	fsetpos64	fsetpos
#ifdef	_LARGEFILE_SOURCE
#define	fseeko64	fseeko
#define	ftello64	ftello
#endif
#endif	/* !__PRAGMA_REDEFINE_EXTNAME */
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

#ifndef	_SSIZE_T
#define	_SSIZE_T
#if defined(_LP64)
typedef long	ssize_t;	/* size of something in bytes or -1 */
#else
typedef int	ssize_t;	/* (historical version) */
#endif
#endif	/* !_SSIZE_T */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_REENTRANT)
extern char	*tmpnam_r(char *);
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
extern int fdclose(FILE *, int *);
extern int fcloseall(void);
extern void setbuffer(FILE *, char *, size_t);
extern int setlinebuf(FILE *);
/* PRINTFLIKE2 */
extern int asprintf(char **, const char *, ...);
/* PRINTFLIKE2 */
extern int vasprintf(char **, const char *, __va_list);
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
	/* || defined(_XPG7) */
extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
	int, FILE *_RESTRICT_KYWD);
extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
	FILE *_RESTRICT_KYWD);
#endif	/* __EXTENSIONS__ ... */

/*
 * The following are known to POSIX and XOPEN, but not to ANSI-C.
 */
#if defined(__EXTENSIONS__) || \
	!defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)

extern FILE	*fdopen(int, const char *);
extern char	*ctermid(char *);
extern int	fileno(FILE *);

#endif	/* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

/*
 * The following are known to POSIX.1c, but not to ANSI-C or XOPEN.
 */
#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
	(_POSIX_C_SOURCE - 0 >= 199506L)
extern void	flockfile(FILE *);
extern int	ftrylockfile(FILE *);
extern void	funlockfile(FILE *);
extern int	getc_unlocked(FILE *);
extern int	getchar_unlocked(void);
extern int	putc_unlocked(int, FILE *);
extern int	putchar_unlocked(int);

#endif	/* defined(__EXTENSIONS__) || defined(_REENTRANT).. */

/*
 * The following are known to XOPEN, but not to ANSI-C or POSIX.
 */
#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(_XOPEN_SOURCE)
extern FILE	*popen(const char *, const char *);
extern char	*tempnam(const char *, const char *);
extern int	pclose(FILE *);
#if !defined(_XOPEN_SOURCE)
extern int	getsubopt(char **, char *const *, char **);
#endif /* !defined(_XOPEN_SOURCE) */

/* Marked LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern char	*cuserid(char *);
extern int	getopt(int, char *const *, const char *);
extern char	*optarg;
extern int	optind, opterr, optopt;
extern int	getw(FILE *);
extern int	putw(int, FILE *);
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */

#endif	/* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

/*
 * The following are defined as part of the Large File Summit interfaces.
 */
#if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
extern int	fseeko(FILE *, off_t, int);
extern off_t	ftello(FILE *);
#endif

/*
 * The following are defined as part of the transitional Large File Summit
 * interfaces.
 */
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern FILE	*fopen64(const char *, const char *);
extern FILE	*freopen64(const char *, const char *, FILE *);
extern FILE	*tmpfile64(void);
extern int	fgetpos64(FILE *, fpos64_t *);
extern int	fsetpos64(FILE *, const fpos64_t *);
extern int	fseeko64(FILE *, off64_t, int);
extern off64_t	ftello64(FILE *);
#endif

/*
 * XPG7 symbols
 */
#if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
extern FILE	*fmemopen(void *_RESTRICT_KYWD, size_t,
		    const char *_RESTRICT_KYWD);
extern FILE	*open_memstream(char **, size_t *);

extern int	dprintf(int, const char *_RESTRICT_KYWD, ...)
	__PRINTFLIKE(2);
extern int	vdprintf(int, const char *_RESTRICT_KYWD, __va_list)
	__VPRINTFLIKE(2);
#endif	/* !_STRICT_SYMBOLS || _XPG7 */

#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
	    (_POSIX_C_SOURCE - 0 >= 199506L)
#define	getchar_unlocked()	getc_unlocked(stdin)
#define	putchar_unlocked(x)	putc_unlocked((x), stdout)
#endif	/* defined(__EXTENSIONS__) || defined(_REENTRANT).. */

#ifdef	__cplusplus
}
#endif

#endif	/* _STDIO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Extensions to the stdio package
 */

#ifndef _STDIO_EXT_H
#define	_STDIO_EXT_H

#include <stdio.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Even though the contents of the stdio FILE structure have always been
 * private to the stdio implementation, over the years some programs have
 * needed to get information about a stdio stream that was not accessible
 * through a supported interface. These programs have resorted to accessing
 * fields of the FILE structure directly, rendering them possibly non-portable
 * to new implementations of stdio, or more likely, preventing enhancements
 * to stdio because those programs will break.
 *
 * In the 64-bit world, the FILE structure is opaque. The routines here
 * are provided as a way to get the information that used to be retrieved
 * directly from the FILE structure. They are based on the needs of
 * existing programs (such as 'mh' and 'emacs'), so they may be extended
 * as other programs are ported. Though they may still be non-portable to
 * other operating systems, they will work from each Solaris release to
 * the next. More portable interfaces are being developed.
 */

#define	FSETLOCKING_QUERY	0
#define	FSETLOCKING_INTERNAL	1
#define	FSETLOCKING_BYCALLER	2

extern size_t __fbufsize(FILE *stream);
extern int __freading(FILE *stream);
extern int __fwriting(FILE *stream);
extern int __freadable(FILE *stream);
extern int __fwritable(FILE *stream);
extern int __flbf(FILE *stream);
extern void __fpurge(FILE *stream);
extern size_t __fpending(FILE *stream);
extern void _flushlbf(void);
extern int __fsetlocking(FILE *stream, int type);

/*
 * Extended FILE enabling function.
 */
#if defined(_LP64) && !defined(__lint)
#define	enable_extended_FILE_stdio(fd, act)		(0)
#else
extern int enable_extended_FILE_stdio(int, int);
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _STDIO_EXT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDIO_IMPL_H
#define	_STDIO_IMPL_H

#include <sys/isa_defs.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef	_LP64

#ifndef	_FILE64_H

struct __FILE_TAG {
	long	__pad[16];
};

#endif	/* _FILE64_H */

#else

struct __FILE_TAG	/* needs to be binary-compatible with old versions */
{
#ifdef _STDIO_REVERSE
	unsigned char	*_ptr;	/* next character from/to here in buffer */
	int		_cnt;	/* number of available characters in buffer */
#else
	int		_cnt;	/* number of available characters in buffer */
	unsigned char	*_ptr;	/* next character from/to here in buffer */
#endif
	unsigned char	*_base;	/* the buffer */
	unsigned char	_flag;	/* the state of the stream */
	unsigned char	_magic; /* Old home of the file descriptor */
				/* Only fileno(3C) can retrieve the value now */
	unsigned	__orientation:2; /* the orientation of the stream */
	unsigned	__ionolock:1;	/* turn off implicit locking */
	unsigned	__seekable:1;	/* is file seekable? */
	unsigned	__extendedfd:1;	/* enable extended FILE */
	unsigned	__xf_nocheck:1;	/* no extended FILE runtime check */
	unsigned	__filler:10;
};

#endif	/*	_LP64	*/

#ifdef	__cplusplus
}
#endif

#endif	/* _STDIO_IMPL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _STDIO_TAG_H
#define	_STDIO_TAG_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	__FILE_TAG
#if defined(__cplusplus) && !defined(__GNUC__) && (__cplusplus < 54321L)
#define	__FILE_TAG	FILE
#else
#define	__FILE_TAG	__FILE
#endif
typedef struct __FILE_TAG __FILE;
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _STDIO_TAG_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 2013 Gary Mills
 *
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 */

/*
 * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
 * Copyright 2025 Oxide Computer Company
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _STDLIB_H
#define	_STDLIB_H

#include <iso/stdlib_iso.h>
#include <iso/stdlib_c99.h>
#include <iso/stdlib_c11.h>

#if defined(__EXTENSIONS__) || defined(_XPG4)
#include <sys/wait.h>
#endif

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/stdlib_iso.h>.
 */
#if __cplusplus >= 199711L
using std::div_t;
using std::ldiv_t;
using std::size_t;
using std::abort;
using std::abs;
using std::atexit;
using std::atof;
using std::atoi;
using std::atol;
using std::bsearch;
using std::calloc;
using std::div;
using std::exit;
using std::free;
using std::getenv;
using std::labs;
using std::ldiv;
using std::malloc;
using std::mblen;
using std::mbstowcs;
using std::mbtowc;
using std::qsort;
using std::rand;
using std::realloc;
using std::srand;
using std::strtod;
using std::strtol;
using std::strtoul;
using std::system;
using std::wcstombs;
using std::wctomb;
#endif

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/stdlib_c11.h>.
 */
#if __cplusplus >= 201103L
using std::at_quick_exit;
using std::quick_exit;
#endif
#if __cplusplus >= 201703L
using std::aligned_alloc;
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _UID_T
#define	_UID_T
typedef	unsigned int	uid_t;		/* UID type		*/
#endif	/* !_UID_T */

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64

#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	mkstemp		mkstemp64
#pragma redefine_extname	mkstemps	mkstemps64
#pragma	redefine_extname	mkostemp	mkostemp64
#pragma	redefine_extname	mkostemps	mkostemps64
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	mkstemp			mkstemp64
#define	mkstemps		mkstemps64
#define	mkostemp		mkostemp64
#define	mkostemps		mkostemps64
#endif	/* __PRAGMA_REDEFINE_EXTNAME */

#endif	/* _FILE_OFFSET_BITS == 64 */

/* In the LP64 compilation environment, all APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)

#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	mkstemp64	mkstemp
#pragma redefine_extname	mkstemps64	mkstemps
#pragma	redefine_extname	mkostemp64	mkostemp
#pragma	redefine_extname	mkostemps64	mkostemps
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	mkstemp64		mkstemp
#define	mkstemps64		mkstemps
#define	mkostemp64		mkostemp
#define	mkostemps64		mkostemps
#endif	/* __PRAGMA_REDEFINE_EXTNAME */

#endif	/* _LP64 && _LARGEFILE64_SOURCE */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
extern int rand_r(unsigned int *);
#endif

extern void _exithandle(void);

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XPG4)
extern double drand48(void);
extern double erand48(unsigned short *);
extern long jrand48(unsigned short *);
extern void lcong48(unsigned short *);
extern long lrand48(void);
extern long mrand48(void);
extern long nrand48(unsigned short *);
extern unsigned short *seed48(unsigned short *);
extern void srand48(long);
extern int putenv(char *);
extern void setkey(const char *);
#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

/*
 * swab() has historically been in <stdlib.h> as delivered from AT&T
 * and continues to be visible in the default compilation environment.
 * As of Issue 4 of the X/Open Portability Guides, swab() was declared
 * in <unistd.h>. As a result, with respect to X/Open namespace the
 * swab() declaration in this header is only visible for the XPG3
 * environment.
 */
#if (defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
	(!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
#ifndef	_SSIZE_T
#define	_SSIZE_T
#if defined(_LP64)
typedef long	ssize_t;	/* size of something in bytes or -1 */
#else
typedef int	ssize_t;	/* (historical version) */
#endif
#endif	/* !_SSIZE_T */

extern void swab(const char *, char *, ssize_t);
#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

#if defined(__EXTENSIONS__) || \
	!defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
extern int	mkstemp(char *);
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int	mkstemps(char *, int);
#endif
#endif /* defined(__EXTENSIONS__) ... */

#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern int	mkstemp64(char *);
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int	mkstemps64(char *, int);
#endif
#endif	/* _LARGEFILE64_SOURCE... */

#if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
extern char	*mkdtemp(char *);
#endif	/* !_STRICT_SYMBOLS || _XPG7 */

#if !defined(_STRICT_SYMBOLS) || defined(_XPG8)
extern int		mkostemp(char *, int);
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
		!defined(__PRAGMA_REDEFINE_EXTNAME))
extern int		mkostemp64(char *, int);
#endif	/* _LARGEFILE64_SOURCE || !((_FILE_OFFSET_BITS == 64) ... */
#endif	/* !_STRICT_SYMBOLS || _XPG8  */

#if !defined(_STRICT_SYMBOLS)
extern int		mkostemps(char *, int, int);
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
		!defined(__PRAGMA_REDEFINE_EXTNAME))
extern int		mkostemps64(char *, int, int);
#endif	/* _LARGEFILE64_SOURCE || !((_FILE_OFFSET_BITS == 64) ... */
#endif	/* !_STRICT_SYMBOLS */


#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG4_2)
extern long a64l(const char *);
extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern char *gcvt(double, int, char *);
extern int getsubopt(char **, char *const *, char **);
extern int  grantpt(int);
extern char *initstate(unsigned, char *, size_t);
extern char *l64a(long);
extern char *mktemp(char *);
extern char *ptsname(int);
extern long random(void);
extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
extern char *setstate(const char *);
extern void srandom(unsigned);
extern int  unlockpt(int);
/* Marked LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern int ttyslot(void);
extern void *valloc(size_t);
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
#endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG6)
extern int posix_memalign(void **, size_t, size_t);
extern int posix_openpt(int);
extern int setenv(const char *, const char *, int);
extern int unsetenv(const char *);
#endif

/*
 * In strict XPG4v2 mode, slave pseudo terminal devices behave differently.
 * See the block comment in usr/src/lib/libc/port/gen/pt.c
 */
#if defined(_STRICT_SYMBOLS) && defined(_XPG4_2)
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname unlockpt __unlockpt_xpg4
#else
extern int __unlockpt_xpg4(int);
#define	unlockpt __unlockpt_xpg4
#endif
#endif	/* defined(_STRICT_SYMBOLS) && defined(_XPG4_2) */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
extern char *canonicalize_file_name(const char *);
extern int clearenv(void);
extern void closefrom(int);
extern int daemon(int, int);
extern int dup2(int, int);
extern int dup3(int, int, int);
extern int fdwalk(int (*)(void *, int), void *);
extern char *qecvt(long double, int, int *, int *);
extern char *qfcvt(long double, int, int *, int *);
extern char *qgcvt(long double, int, char *);
extern char *getcwd(char *, size_t);
extern const char *getexecname(void);

#ifndef	__GETLOGIN_DEFINED	/* Avoid duplicate in unistd.h */
#define	__GETLOGIN_DEFINED
#ifndef	__USE_LEGACY_LOGNAME__
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname getlogin getloginx
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern char *getloginx(void);
#define	getlogin	getloginx
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* __USE_LEGACY_LOGNAME__ */
extern char *getlogin(void);
#endif	/* __GETLOGIN_DEFINED */

extern int getopt(int, char *const *, const char *);
extern char *optarg;
extern int optind, opterr, optopt;
extern char *getpass(const char *);
extern char *getpassphrase(const char *);
extern int getpw(uid_t, char *);
extern int isatty(int);
extern void *memalign(size_t, size_t);
extern char *ttyname(int);
extern char *mkdtemp(char *);
extern const char *getprogname(void);
extern void setprogname(const char *);

#if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
extern char *lltostr(long long, char *);
extern char *ulltostr(unsigned long long, char *);
#endif	/* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */

#endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */

/* OpenBSD and misc. compatibility functions */
#if !defined(_STRICT_SYMBOLS)

#include <inttypes.h>
extern uint32_t arc4random(void);
extern void arc4random_buf(void *, size_t);
extern uint32_t arc4random_uniform(uint32_t);
extern void freezero(void *, size_t);
extern void *recallocarray(void *, size_t, size_t, size_t);
extern long long strtonum(const char *, long long, long long, const char **);
extern long long strtonumx(const char *, long long, long long, const char **,
    int);
extern void *reallocf(void *, size_t);

/* these three are also in xlocale.h */
#ifndef _LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif
extern float strtof_l(const char *, char **, locale_t);
extern double strtod_l(const char *, char **, locale_t);
extern long double strtold_l(const char *, char **, locale_t);
#endif	/* !_STRICT_SYBMOLS */

/*
 * POSIX 2024 functions.
 */
#if !defined(_STRICT_SYMBOLS) || defined(_XPG8)
extern int ptsname_r(int, char *, size_t);
extern void qsort_r(void *, size_t, size_t,
    int (*)(const void *, const void *, void *), void *);
extern void *reallocarray(void *, size_t, size_t);
extern char *secure_getenv(const char *);
#endif	/* !_STRICT_SYMBOLS || _XPG8 */

#ifdef	__cplusplus
}
#endif

#endif	/* _STDLIB_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2016 Joyent, Inc.
 */

#ifndef _STDNORETURN_H
#define	_STDNORETURN_H

/*
 * ISO/IEC C11 stdnoreturn.h
 */
#include <sys/feature_tests.h>

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)

#define	noreturn	_Noreturn

#endif	/* !_STRICT_SYMBOLS || _STDC_C11 */

#ifdef __cplusplus
}
#endif

#endif /* _STDNORETURN_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright 2020 Joyent, Inc.
 * Copyright 2024 Oxide Computer company
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _STRING_H
#define	_STRING_H

#include <iso/string_iso.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/string_iso.h>.
 */
#if __cplusplus >= 199711L
using std::size_t;
using std::memchr;
using std::memcmp;
using std::memcpy;
using std::memmove;
using std::memset;
using std::strcat;
using std::strchr;
using std::strcmp;
using std::strcoll;
using std::strcpy;
using std::strcspn;
using std::strerror;
using std::strlen;
using std::strncat;
using std::strncmp;
using std::strncpy;
using std::strpbrk;
using std::strrchr;
using std::strspn;
using std::strstr;
using std::strtok;
using std::strxfrm;
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG6) || defined(_REENTRANT)
extern int strerror_r(int, char *, size_t);
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
extern char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
	char **_RESTRICT_KYWD);
#endif

#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
	defined(__XOPEN_OR_POSIX)
extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD,
		int, size_t);
#endif

#if !defined(_STRICT_SYMBOLS) || defined(_XPG7)

extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
extern char *strndup(const char *, size_t);
extern size_t strnlen(const char *, size_t);
extern char *strsignal(int);

#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern int strcoll_l(const char *, const char *, locale_t);
extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, locale_t);
extern int strcasecmp_l(const char *, const char *, locale_t);
extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
extern char *strerror_l(int, locale_t);

#endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */

#if !defined(_STRICT_SYMBOLS)

/* Note that some of these are also declared in strings.h for XPG4_2+ */
extern void explicit_bzero(void *, size_t);
extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
extern int ffs(int);
extern int ffsl(long);
extern int ffsll(long long);
extern int fls(int);
extern int flsl(long);
extern int flsll(long long);
extern void *memmem(const void *, size_t, const void *, size_t);
extern void *memrchr(const void *, int, size_t);
extern char *strcasestr(const char *, const char *);
extern char *strnstr(const char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
extern char *strsep(char **stringp, const char *delim);
extern char *strchrnul(const char *, int);
extern char *strcasestr_l(const char *, const char *, locale_t);
extern int strcasecmp(const char *, const char *);
extern int strncasecmp(const char *, const char *, size_t);
extern const char *strerrorname_np(int);
extern const char *strerrordesc_np(int);
#endif /* !defined(__STRICT_SYMBOLS) */

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG4_2)
extern char *strdup(const char *);
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))

#if defined(__GNUC__)

#define	strdupa(s)							\
	(__extension__(							\
	{								\
	char *__str = (char *)(s);					\
	(__str = strcpy((char *)__builtin_alloca(strlen(__str) + 1),	\
	    __str), __str);						\
	}))

#define	strndupa(s, n)							\
	(__extension__(							\
	{								\
	char *__str = (char *)(s);					\
	size_t __len = strnlen(__str, (n));				\
	(__str = strncpy((char *)__builtin_alloca(__len + 1),		\
	    __str, __len),						\
	__str[__len] = '\0', __str);					\
	}))

#else	/* __GNUC__ */

#if defined(unix)	/* excludes c99 */
/*
 * Studio C currently can't do the gcc-style inlining,
 * so we use thread-local storage instead.
 */
extern void *__builtin_alloca(size_t);
extern __thread char *__strdupa_str;
extern __thread size_t __strdupa_len;

#define	strdupa(s)							\
	(__strdupa_str = (char *)(s),					\
	strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1),	\
	    __strdupa_str))

#define	strndupa(s, n)							\
	(__strdupa_str = (char *)(s),					\
	__strdupa_len = strnlen(__strdupa_str, (n)),			\
	__strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \
	    __strdupa_str, __strdupa_len),				\
	__strdupa_str[__strdupa_len] = '\0', __strdupa_str)
#endif	/* unix */

#endif	/* __GNUC__ */
#endif	/* __EXTENSIONS__ ... */

#ifdef	__cplusplus
}
#endif

#endif	/* _STRING_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright (c) 1995, 1996, by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_STRINGS_H
#define	_STRINGS_H

#include <sys/types.h>
#include <sys/feature_tests.h>

#if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
#include <string.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

extern int bcmp(const void *, const void *, size_t);
extern void bcopy(const void *, void *, size_t);
extern void bzero(void *, size_t);

extern char *index(const char *, int);
extern char *rindex(const char *, int);

/*
 * X/Open System Interfaces and Headers, Issue 4, Version 2, defines
 * both <string.h> and <strings.h>.  The namespace requirements
 * do not permit the visibility of anything other than what is
 * specifically defined for each of these headers.  As a result,
 * inclusion of <string.h> would result in declarations not allowed
 * in <strings.h>, and making the following prototypes visible for
 * anything other than X/Open UNIX Extension would result in
 * conflicts with what is now in <string.h>.
 */
#if defined(_XPG4_2) && !defined(__EXTENSIONS__)
extern int ffs(int);
extern int strcasecmp(const char *, const char *);
extern int strncasecmp(const char *, const char *, size_t);
#if defined(_XPG7)
#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif
extern int strcasecmp_l(const char *, const char *, locale_t);
extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
#endif	/* defined(_XPG7) */
#endif	/* defined(_XPG4_2) && !defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _STRINGS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_STROPTS_H
#define	_STROPTS_H

/*
 * Streams user options definitions.
 */

#include <sys/feature_tests.h>
#include <sys/stropts.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern int isastream(int);

extern int getmsg(int, struct strbuf *_RESTRICT_KYWD,
		struct strbuf *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
extern int putmsg(int, const struct strbuf *, const struct strbuf *, int);

extern int getpmsg(int, struct strbuf *_RESTRICT_KYWD,
		struct strbuf *_RESTRICT_KYWD, int *_RESTRICT_KYWD,
		int *_RESTRICT_KYWD);
extern int putpmsg(int, const struct strbuf *, const struct strbuf *, int, int);

/*
 * These three routines are duplicated in unistd.h; duplication necessitated
 * by XPG4.2 compliance/namespace issues. ioctl() is also duplicated in
 * <sys/ioctl.h> for broader portability aid.
 */
extern int ioctl(int, int, ...);
extern int fattach(int, const char *);
extern int fdetach(const char *);

#ifdef	__cplusplus
}
#endif

#endif	/* _STROPTS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef	_SYNCH_H
#define	_SYNCH_H

/*
 * synch.h:
 * definitions needed to use the thread synchronization interface
 */

#ifndef _ASM
#include <sys/machlock.h>
#include <sys/time_impl.h>
#include <sys/synch.h>
#endif /* _ASM */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASM

/*
 * Semaphores
 */
typedef struct _sema {
	/* this structure must be the same as sem_t in <semaphore.h> */
	uint32_t	count;		/* semaphore count */
	uint16_t	type;
	uint16_t	magic;
	upad64_t	pad1[3];	/* reserved for a mutex_t */
	upad64_t	pad2[2];	/* reserved for a cond_t */
} sema_t;

/*
 * POSIX.1c Note:
 * POSIX.1c requires that <pthread.h> define the structures pthread_mutex_t
 * and pthread_cond_t.  These structures are identical to mutex_t (lwp_mutex_t)
 * and cond_t (lwp_cond_t) which are defined in <synch.h>.  A nested included
 * of <synch.h> (to allow a "#typedef mutex_t  pthread_mutex_t") would pull in
 * non-posix symbols/constants violating the namespace restrictions.  Hence,
 * pthread_mutex_t/pthread_cond_t have been redefined in <pthread.h> (actually
 * in <sys/types.h>).  Any modifications done to mutex_t/lwp_mutex_t or
 * cond_t/lwp_cond_t should also be done to pthread_mutex_t/pthread_cond_t.
 */
typedef lwp_mutex_t mutex_t;
typedef lwp_cond_t cond_t;

/*
 * Readers/writer locks
 *
 * NOTE: The layout of this structure should be kept in sync with the layout
 * of the correponding structure of pthread_rwlock_t in sys/types.h.
 * Also, there is an identical structure for lwp_rwlock_t in <sys/synch.h>.
 * Because we have to deal with C++, we cannot redefine this one as that one.
 */
typedef struct _rwlock {
	int32_t		readers;	/* rwstate word */
	uint16_t	type;
	uint16_t	magic;
	mutex_t		mutex;		/* used with process-shared rwlocks */
	cond_t		readercv;	/* used only to indicate ownership */
	cond_t		writercv;	/* used only to indicate ownership */
} rwlock_t;

int	_lwp_mutex_lock(lwp_mutex_t *);
int	_lwp_mutex_unlock(lwp_mutex_t *);
int	_lwp_mutex_trylock(lwp_mutex_t *);
int	_lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *);
int	_lwp_cond_timedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
int	_lwp_cond_reltimedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
int	_lwp_cond_signal(lwp_cond_t *);
int	_lwp_cond_broadcast(lwp_cond_t *);
int	_lwp_sema_init(lwp_sema_t *, int);
int	_lwp_sema_wait(lwp_sema_t *);
int	_lwp_sema_trywait(lwp_sema_t *);
int	_lwp_sema_post(lwp_sema_t *);
int	cond_init(cond_t *, int, void *);
int	cond_destroy(cond_t *);
int	cond_wait(cond_t *, mutex_t *);
int	cond_timedwait(cond_t *, mutex_t *, const timespec_t *);
int	cond_reltimedwait(cond_t *, mutex_t *, const timespec_t *);
int	cond_signal(cond_t *);
int	cond_broadcast(cond_t *);
int	mutex_init(mutex_t *, int, void *);
int	mutex_destroy(mutex_t *);
int	mutex_consistent(mutex_t *);
int	mutex_lock(mutex_t *);
int	mutex_trylock(mutex_t *);
int	mutex_unlock(mutex_t *);
int	rwlock_init(rwlock_t *, int, void *);
int	rwlock_destroy(rwlock_t *);
int	rw_rdlock(rwlock_t *);
int	rw_wrlock(rwlock_t *);
int	rw_unlock(rwlock_t *);
int	rw_tryrdlock(rwlock_t *);
int	rw_trywrlock(rwlock_t *);
int	sema_init(sema_t *, unsigned int, int, void *);
int	sema_destroy(sema_t *);
int	sema_wait(sema_t *);
int	sema_timedwait(sema_t *, const timespec_t *);
int	sema_reltimedwait(sema_t *, const timespec_t *);
int	sema_post(sema_t *);
int	sema_trywait(sema_t *);

#endif /* _ASM */

/* "Magic numbers" tagging synchronization object types */
#define	MUTEX_MAGIC	_MUTEX_MAGIC
#define	SEMA_MAGIC	_SEMA_MAGIC
#define	COND_MAGIC	_COND_MAGIC
#define	RWL_MAGIC	_RWL_MAGIC

/*
 * POSIX.1c Note:
 * DEFAULTMUTEX is defined same as PTHREAD_MUTEX_INITIALIZER in <pthread.h>.
 * DEFAULTCV is defined same as PTHREAD_COND_INITIALIZER in <pthread.h>.
 * DEFAULTRWLOCK is defined same as PTHREAD_RWLOCK_INITIALIZER in <pthread.h>.
 * Any changes to these macros should be reflected in <pthread.h>
 */
#define	DEFAULTMUTEX	\
	{{0, 0, 0, {USYNC_THREAD}, MUTEX_MAGIC}, \
	{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
#define	SHAREDMUTEX	\
	{{0, 0, 0, {USYNC_PROCESS}, MUTEX_MAGIC}, \
	{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
#define	RECURSIVEMUTEX	\
	{{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE}, MUTEX_MAGIC}, \
	{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
#define	ERRORCHECKMUTEX	\
	{{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, MUTEX_MAGIC}, \
	{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
#define	RECURSIVE_ERRORCHECKMUTEX	\
	{{0, 0, 0, {USYNC_THREAD|LOCK_RECURSIVE|LOCK_ERRORCHECK}, \
	MUTEX_MAGIC}, {{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0}
#define	DEFAULTCV	\
	{{{0, 0, 0, 0}, USYNC_THREAD, COND_MAGIC}, 0}
#define	SHAREDCV	\
	{{{0, 0, 0, 0}, USYNC_PROCESS, COND_MAGIC}, 0}
#define	DEFAULTSEMA	\
	{0, USYNC_THREAD, SEMA_MAGIC, {0, 0, 0}, {0, 0}}
#define	SHAREDSEMA	\
	{0, USYNC_PROCESS, SEMA_MAGIC, {0, 0, 0}, {0, 0}}
#define	DEFAULTRWLOCK	\
	{0, USYNC_THREAD, RWL_MAGIC, DEFAULTMUTEX, DEFAULTCV, DEFAULTCV}
#define	SHAREDRWLOCK	\
	{0, USYNC_PROCESS, RWL_MAGIC, SHAREDMUTEX, SHAREDCV, SHAREDCV}

/*
 * Tests on lock states.
 */
#define	SEMA_HELD(x)		_sema_held(x)
#define	RW_READ_HELD(x)		_rw_read_held(x)
#define	RW_WRITE_HELD(x)	_rw_write_held(x)
#define	RW_LOCK_HELD(x)		(RW_READ_HELD(x) || RW_WRITE_HELD(x))
#define	MUTEX_HELD(x)		_mutex_held(x)

/*
 * The following definitions are for assertions which can be checked
 * statically by tools like lock_lint.  You can also define your own
 * run-time test for each.  If you don't, we define them to 1 so that
 * such assertions simply pass.
 */
#ifndef NO_LOCKS_HELD
#define	NO_LOCKS_HELD	1
#endif
#ifndef NO_COMPETING_THREADS
#define	NO_COMPETING_THREADS	1
#endif

#ifndef _ASM

/*
 * The *_held() functions apply equally well to Solaris threads
 * and to Posix threads synchronization objects, but the formal
 * type declarations are different, so we just declare the argument
 * to each *_held() function to be a void *, expecting that they will
 * be called with the proper type of argument in each case.
 */
int _sema_held(void *);			/* sema_t or sem_t */
int _rw_read_held(void *);		/* rwlock_t or pthread_rwlock_t */
int _rw_write_held(void *);		/* rwlock_t or pthread_rwlock_t */
int _mutex_held(void *);		/* mutex_t or pthread_mutex_t */

/* Pause API */
void smt_pause(void);

#endif /* _ASM */

/*
 * Panicking versions of our favorite friends.
 */
void mutex_enter(mutex_t *);
void mutex_exit(mutex_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _SYNCH_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _SYSEXITS_H
#define	_SYSEXITS_H

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  SYSEXITS.H -- Exit status codes employed by the mail subsystem.
 *
 *	This include file attempts to categorize possible error
 *	exit statuses for mail subsystem.
 *
 *	Error numbers begin at EX__BASE to reduce the possibility of
 *	clashing with other exit statuses that random programs may
 *	already return.  The meaning of the codes is approximately
 *	as follows:
 *
 *	EX_USAGE -- The command was used incorrectly, e.g., with
 *		the wrong number of arguments, a bad flag, a bad
 *		syntax in a parameter, or whatever.
 *	EX_DATAERR -- The input data was incorrect in some way.
 *		This should only be used for user's data & not
 *		system files.
 *	EX_NOINPUT -- An input file (not a system file) did not
 *		exist or was not readable.  This could also include
 *		errors like "No message" to a mailer (if it cared
 *		to catch it).
 *	EX_NOUSER -- The user specified did not exist.  This might
 *		be used for mail addresses or remote logins.
 *	EX_NOHOST -- The host specified did not exist.  This is used
 *		in mail addresses or network requests.
 *	EX_UNAVAILABLE -- A service is unavailable.  This can occur
 *		if a support program or file does not exist.  This
 *		can also be used as a catchall message when something
 *		you wanted to do doesn't work, but you don't know
 *		why.
 *	EX_SOFTWARE -- An internal software error has been detected.
 *		This should be limited to non-operating system related
 *		errors as possible.
 *	EX_OSERR -- An operating system error has been detected.
 *		This is intended to be used for such things as "cannot
 *		fork", "cannot create pipe", or the like.  It includes
 *		things like getuid returning a user that does not
 *		exist in the passwd file.
 *	EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
 *		etc.) does not exist, cannot be opened, or has some
 *		sort of error (e.g., syntax error).
 *	EX_CANTCREAT -- A (user specified) output file cannot be
 *		created.
 *	EX_IOERR -- An error occurred while doing I/O on some file.
 *	EX_TEMPFAIL -- temporary failure, indicating something that
 *		is not really an error.  In sendmail, this means
 *		that a mailer (e.g.) could not create a connection,
 *		and the request should be reattempted later.
 *	EX_PROTOCOL -- the remote system returned something that
 *		was "not possible" during a protocol exchange.
 *	EX_NOPERM -- You did not have sufficient permission to
 *		perform the operation.  This is not intended for
 *		file system problems, which should use NOINPUT or
 *		CANTCREAT, but rather for higher level permissions.
 *		For example, kre uses this to restrict who students
 *		can send mail to.
 */

#define	EX_OK		0	/* successful termination */

#define	EX__BASE	64	/* base value for error messages */

#define	EX_USAGE	64	/* command line usage error */
#define	EX_DATAERR	65	/* data format error */
#define	EX_NOINPUT	66	/* cannot open input */
#define	EX_NOUSER	67	/* addressee unknown */
#define	EX_NOHOST	68	/* host name unknown */
#define	EX_UNAVAILABLE	69	/* service unavailable */
#define	EX_SOFTWARE	70	/* internal software error */
#define	EX_OSERR	71	/* system error (e.g., can't fork) */
#define	EX_OSFILE	72	/* critical OS file missing */
#define	EX_CANTCREAT	73	/* can't create (user) output file */
#define	EX_IOERR	74	/* input/output error */
#define	EX_TEMPFAIL	75	/* temp failure; user is invited to retry */
#define	EX_PROTOCOL	76	/* remote error in protocol */
#define	EX_NOPERM	77	/* permission denied */
#define	EX_CONFIG	78	/* configuration error */

#define	EX_NOTFOUND	79	/* entry not found */
#define	EX__MAX	79	/* maximum listed value */


#ifdef __cplusplus
}
#endif

#endif	/* _SYSEXITS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_SYSLOG_H
#define	_SYSLOG_H

#include <sys/feature_tests.h>
#include <sys/syslog.h>
#include <sys/va_list.h>

#ifdef	__cplusplus
extern "C" {
#endif

void openlog(const char *, int, int);
void syslog(int, const char *, ...);
void closelog(void);
int setlogmask(int);
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
void vsyslog(int, const char *, __va_list);
#endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYSLOG_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _TAR_H
#define	_TAR_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/feature_tests.h>

#define	TMAGIC		"ustar"
#define	TMAGLEN		6
#define	TVERSION	"00"
#define	TVERSLEN	2

/*
 * Typeflag field definitions.
 */

#define	REGTYPE		'0'
#define	AREGTYPE	'\0'
#define	LNKTYPE		'1'
#define	SYMTYPE		'2'
#define	CHRTYPE		'3'
#define	BLKTYPE		'4'
#define	DIRTYPE		'5'
#define	FIFOTYPE	'6'
#define	CONTTYPE	'7'

/*
 * Mode fild bit definitions.
 */

#define	TSUID		04000
#define	TSGID		02000
#define	TSVTX		01000
#define	TUREAD		00400
#define	TUWRITE		00200
#define	TUEXEC		00100
#define	TGREAD		00040
#define	TGWRITE		00020
#define	TGEXEC		00010
#define	TOREAD		00004
#define	TOWRITE		00002
#define	TOEXEC		00001

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/*
 *      Types used in ancillary files
 */
#define	ACL_HDR		'A'	/* Access Control List */
#define	LBL_TYPE	'L'	/* Trusted Extensions file label */
#define	DIR_TYPE	'D'	/* Trusted Extensions directory label */
/*
 * Attribute types used in Trusted Solaris ancillary files
 * that are interpreted for backward compatibility
 */
#define	SLD_TYPE	'S'	/* single-level directory component */
#define	PATH_TYPE	'P'	/* Path component */
#define	MLD_TYPE	'M'	/* multi-level directory component */
#define	FILE_TYPE	'F'	/* Have to handle files differently */
#define	APRIV_TYPE	'P'	/* allowed privileges data type in file */
#define	FPRIV_TYPE	'p'	/* forced privileges data type in file */
#define	COMP_TYPE	'C'	/* path components, use for MLD */
#define	ATTR_FLAG_TYPE	'F'	/* file attribute flag bytes data type */
#define	LK_COMP_TYPE	'K'	/* link data path component */
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _TAR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_TERMIO_H
#define	_TERMIO_H

#include <sys/termio.h>

#endif	/* _TERMIO_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _TERMIOS_H
#define	_TERMIOS_H

#include <sys/termios.h>

#endif	/* _TERMIOS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _TGMATH_H
#define	_TGMATH_H

#if !defined(__cplusplus)

#include <math.h>
#include <complex.h>

/*
 * real-floating and complex
 */
#undef	acos
#define	acos(x)			__tgmath_acos(x)
#undef	asin
#define	asin(x)			__tgmath_asin(x)
#undef	atan
#define	atan(x)			__tgmath_atan(x)
#undef	acosh
#define	acosh(x)		__tgmath_acosh(x)
#undef	asinh
#define	asinh(x)		__tgmath_asinh(x)
#undef	atanh
#define	atanh(x)		__tgmath_atanh(x)
#undef	cos
#define	cos(x)			__tgmath_cos(x)
#undef	sin
#define	sin(x)			__tgmath_sin(x)
#undef	tan
#define	tan(x)			__tgmath_tan(x)
#undef	cosh
#define	cosh(x)			__tgmath_cosh(x)
#undef	sinh
#define	sinh(x)			__tgmath_sinh(x)
#undef	tanh
#define	tanh(x)			__tgmath_tanh(x)
#undef	exp
#define	exp(x)			__tgmath_exp(x)
#undef	log
#define	log(x)			__tgmath_log(x)
#undef	pow
#define	pow(x, y)		__tgmath_pow(x, y)
#undef	sqrt
#define	sqrt(x)			__tgmath_sqrt(x)
#undef	fabs
#define	fabs(x)			__tgmath_fabs(x)

/*
 * real-floating only
 */
#undef	atan2
#define	atan2(y, x)		__tgmath_atan2(y, x)
#undef	cbrt
#define	cbrt(x)			__tgmath_cbrt(x)
#undef	ceil
#define	ceil(x)			__tgmath_ceil(x)
#undef	copysign
#define	copysign(x, y)		__tgmath_copysign(x, y)
#undef	erf
#define	erf(x)			__tgmath_erf(x)
#undef	erfc
#define	erfc(x)			__tgmath_erfc(x)
#undef	exp2
#define	exp2(x)			__tgmath_exp2(x)
#undef	expm1
#define	expm1(x)		__tgmath_expm1(x)
#undef	fdim
#define	fdim(x, y)		__tgmath_fdim(x, y)
#undef	floor
#define	floor(x)		__tgmath_floor(x)
#undef	fma
#define	fma(x, y, z)		__tgmath_fma(x, y, z)
#undef	fmax
#define	fmax(x, y)		__tgmath_fmax(x, y)
#undef	fmin
#define	fmin(x, y)		__tgmath_fmin(x, y)
#undef	fmod
#define	fmod(x, y)		__tgmath_fmod(x, y)
#undef	frexp
#define	frexp(x, ip)		__tgmath_frexp(x, ip)
#undef	hypot
#define	hypot(x, y)		__tgmath_hypot(x, y)
#undef	ilogb
#define	ilogb(x)		__tgmath_ilogb(x)
#undef	ldexp
#define	ldexp(x, i)		__tgmath_ldexp(x, i)
#undef	lgamma
#define	lgamma(x)		__tgmath_lgamma(x)
#undef	llrint
#define	llrint(x)		__tgmath_llrint(x)
#undef	llround
#define	llround(x)		__tgmath_llround(x)
#undef	log10
#define	log10(x)		__tgmath_log10(x)
#undef	log1p
#define	log1p(x)		__tgmath_log1p(x)
#undef	log2
#define	log2(x)			__tgmath_log2(x)
#undef	logb
#define	logb(x)			__tgmath_logb(x)
#undef	lrint
#define	lrint(x)		__tgmath_lrint(x)
#undef	lround
#define	lround(x)		__tgmath_lround(x)
#undef	nearbyint
#define	nearbyint(x)		__tgmath_nearbyint(x)
#undef	nextafter
#define	nextafter(x, y)		__tgmath_nextafter(x, y)
#undef	nexttoward
#define	nexttoward(x, y)	__tgmath_nexttoward(x, y)
#undef	remainder
#define	remainder(x, y)		__tgmath_remainder(x, y)
#undef	remquo
#define	remquo(x, y, ip)	__tgmath_remquo(x, y, ip)
#undef	rint
#define	rint(x)			__tgmath_rint(x)
#undef	round
#define	round(x)		__tgmath_round(x)
#undef	scalbln
#define	scalbln(x, l)		__tgmath_scalbln(x, l)
#undef	scalbn
#define	scalbn(x, i)		__tgmath_scalbn(x, i)
#undef	tgamma
#define	tgamma(x)		__tgmath_tgamma(x)
#undef	trunc
#define	trunc(x)		__tgmath_trunc(x)

/*
 * complex only
 */
#undef	carg
#define	carg(x)			__tgmath_carg(x)
#undef	cimag
#define	cimag(x)		__tgmath_cimag(x)
#undef	conj
#define	conj(x)			__tgmath_conj(x)
#undef	cproj
#define	cproj(x)		__tgmath_cproj(x)
#undef	creal
#define	creal(x)		__tgmath_creal(x)

#endif	/* !defined(__cplusplus) */

#endif	/* _TGMATH_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 *
 * Copyright 2018 Joyent, Inc.
 */

#ifndef	_THREAD_H
#define	_THREAD_H

/*
 * thread.h:
 * definitions needed to use the thread interface except synchronization.
 * use <synch.h> for thread synchronization.
 */

#ifndef _ASM
#include <sys/signal.h>
#include <sys/time.h>
#include <synch.h>
#endif	/* _ASM */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASM
typedef unsigned int thread_t;
typedef unsigned int thread_key_t;

extern int thr_create(void *, size_t, void *(*)(void *), void *, long,
			thread_t *);
extern int thr_join(thread_t, thread_t *, void **);
extern int thr_setconcurrency(int);
extern int thr_getconcurrency(void);
extern void thr_exit(void *) __NORETURN;
extern thread_t thr_self(void);

/*
 * the definition of thr_sigsetmask() is not strict ansi-c since sigset_t is
 * not in the strict ansi-c name space. Hence, include the prototype for
 * thr_sigsetmask() only if strict ansi-c conformance is not turned on.
 */
#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
extern int thr_sigsetmask(int, const sigset_t *, sigset_t *);
#endif

/*
 * the definition of thr_stksegment() is not strict ansi-c since stack_t is
 * not in the strict ansi-c name space. Hence, include the prototype for
 * thr_stksegment() only if strict ansi-c conformance is not turned on.
 */
#if !defined(_STRICT_STDC) || defined(__EXTENSIONS__)
extern int thr_stksegment(stack_t *);
#endif

extern int thr_main(void);
extern int thr_kill(thread_t, int);
extern int thr_suspend(thread_t);
extern int thr_continue(thread_t);
extern void thr_yield(void);
extern int thr_setprio(thread_t, int);
extern int thr_getprio(thread_t, int *);
extern int thr_keycreate(thread_key_t *, void(*)(void *));
extern int thr_keycreate_once(thread_key_t *, void(*)(void *));
extern int thr_setspecific(thread_key_t, void *);
extern int thr_getspecific(thread_key_t, void **);
extern size_t thr_min_stack(void);
extern int thr_getname(thread_t, char *, size_t);
extern int thr_setname(thread_t, const char *);

#endif /* _ASM */

#define	THR_MIN_STACK	thr_min_stack()
/*
 * thread flags (one word bit mask)
 */
/*
 * POSIX.1c Note:
 * THR_BOUND is defined same as PTHREAD_SCOPE_SYSTEM in <pthread.h>
 * THR_DETACHED is defined same as PTHREAD_CREATE_DETACHED in <pthread.h>
 * Any changes in these definitions should be reflected in <pthread.h>
 */
#define	THR_BOUND		0x00000001	/* = PTHREAD_SCOPE_SYSTEM */
#define	THR_NEW_LWP		0x00000002
#define	THR_DETACHED		0x00000040	/* = PTHREAD_CREATE_DETACHED */
#define	THR_SUSPENDED		0x00000080
#define	THR_DAEMON		0x00000100

/*
 * The key to be created by thr_keycreate_once()
 * must be statically initialized with THR_ONCE_KEY.
 * This must be the same as PTHREAD_ONCE_KEY_NP in <pthread.h>
 */
#define	THR_ONCE_KEY	(thread_key_t)(-1)

/*
 * The available register states returned by thr_getstate().
 */
#define	TRS_VALID	0
#define	TRS_NONVOLATILE	1
#define	TRS_LWPID	2
#define	TRS_INVALID	3

#ifdef __cplusplus
}
#endif

#endif	/* _THREAD_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _THREAD_DB_H
#define	_THREAD_DB_H

/*
 *
 *  Description:
 *	Types, global variables, and function definitions for users
 *	of libc_db (formerly libthread_db).
 *
 */


#include <sys/lwp.h>
#include <sys/procfs_isa.h>
#include <thread.h>
#include <proc_service.h>

#ifdef __cplusplus
extern "C" {
#endif

#define		TD_THR_ANY_USER_FLAGS	0xffffffff
#define		TD_THR_LOWEST_PRIORITY	-128
#define		TD_SIGNO_MASK 0
#define		TD_EVENTSIZE 2

/*
 * Opaque handle types.
 */

/* Client's handle for a process */
struct ps_prochandle;

/* libthread's handle for a process */
typedef struct td_thragent td_thragent_t;

/* The thread handle. */
typedef struct td_thrhandle {
	td_thragent_t	*th_ta_p;
	psaddr_t	th_unique;
} td_thrhandle_t;

/* The handle for a synchronization object. */
typedef struct td_synchandle {
	td_thragent_t	*sh_ta_p;
	psaddr_t	sh_unique;
} td_synchandle_t;

/* ------------------------------------------------------------------ */

/*
 * The libc_db event facility.
 */
#define	BT_UISHIFT	5 /* log base 2 of BT_NBIPUI, to extract word index */
#define	BT_NBIPUI	(1 << BT_UISHIFT)	/* n bits per uint */
#define	BT_UIMASK	(BT_NBIPUI - 1)		/* to extract bit index */

/* Bitmask of enabled events. */
typedef struct td_thr_events {
	uint_t	event_bits[TD_EVENTSIZE];
} td_thr_events_t;

/* Event set manipulation macros. */
#define	__td_eventmask(n)	((unsigned int)1 << (((n) - 1)	\
				    & (BT_NBIPUI - 1)))
#define	__td_eventword(n)	(((unsigned int)((n) - 1))>>5)

#define	td_event_emptyset(setp)				\
	{								\
		int _i_;						\
		_i_ = TD_EVENTSIZE;					\
		while (_i_) (setp)->event_bits[--_i_] = 0;	\
	}

#define	td_event_fillset(setp)				\
	{								\
		int _i_;						\
		_i_ = TD_EVENTSIZE;					\
		while (_i_) (setp)->event_bits[--_i_] =	\
			0xffffffff;				\
	}

#define	td_event_addset(setp, n)			\
	(((setp)->event_bits[__td_eventword(n)]) |= __td_eventmask(n))
#define	td_event_delset(setp, n)			\
	(((setp)->event_bits[__td_eventword(n)]) &= ~__td_eventmask(n))
#define	td_eventismember(setp, n)		\
	(__td_eventmask(n) & ((setp)->event_bits[__td_eventword(n)]))
#define	td_eventisempty(setp)			\
	(!((setp)->event_bits[0]) && !((setp)->event_bits[1]))

typedef enum {
	TD_ALL_EVENTS,	/* pseudo-event number */
	TD_EVENT_NONE = TD_ALL_EVENTS,	/* depends on context */
	TD_READY,
	TD_SLEEP,
	TD_SWITCHTO,
	TD_SWITCHFROM,
	TD_LOCK_TRY,
	TD_CATCHSIG,
	TD_IDLE,
	TD_CREATE,
	TD_DEATH,
	TD_PREEMPT,
	TD_PRI_INHERIT,
	TD_REAP,
	TD_CONCURRENCY,
	TD_TIMEOUT,
	TD_MIN_EVENT_NUM = TD_READY,
	TD_MAX_EVENT_NUM = TD_TIMEOUT,
	TD_EVENTS_ENABLE = 31		/* Event reporting enabled */
} td_event_e;

/*
 *   Ways that an event type can be reported.
 */
typedef enum {
	NOTIFY_BPT,
				/*
				 * bpt to be inserted at u.bptaddr by
				 * debugger
				 */
	NOTIFY_AUTOBPT,		/* bpt inserted at u.bptaddr by application */
	NOTIFY_SYSCALL		/* syscall u.syscallno will be invoked */
} td_notify_e;

/*
 * How an event type is reported.
 */
typedef struct td_notify {
	td_notify_e	type;
	union {
		psaddr_t	bptaddr;
		int		syscallno;
	} u;
} td_notify_t;

/*
 * An event message.
 */
typedef struct td_event_msg {
	td_event_e event;		/* Event type being reported */
	const td_thrhandle_t *th_p;	/* Thread reporting the event */
	union {				/* Type-dependent event data */
		td_synchandle_t *sh;	/* historical rubbish; ignore */
		uintptr_t	data;	/* valid, depending on event type */
	} msg;
} td_event_msg_t;

/* --------------------------------------------------------------------- */

/*
 * Thread information structure as returned by td_thr_get_info(), and
 * related types.
 */

/*
 * Possible thread states.  TD_THR_ANY_STATE is a pseudo-state used
 * to select threads regardless of state in td_ta_thr_iter().
 */
typedef enum {
	TD_THR_ANY_STATE,
	TD_THR_UNKNOWN,
	TD_THR_STOPPED,
	TD_THR_RUN,
	TD_THR_ACTIVE,
	TD_THR_ZOMBIE,
	TD_THR_SLEEP,
	TD_THR_STOPPED_ASLEEP
} td_thr_state_e;

/*
 * Thread type: user or system.
 * As of Solaris 9, all threads are type TD_THR_USER.
 */
typedef enum {
	TD_THR_ANY_TYPE,	/* not used */
	TD_THR_USER,
	TD_THR_SYSTEM
} td_thr_type_e;

typedef struct td_thrinfo {
	td_thragent_t	*ti_ta_p;	/* process handle */
	unsigned	ti_user_flags;	/* flags passed to thr_create() */
	thread_t	ti_tid;		/* tid returned by thr_create() */
	void		*ti_exitval;	/* thread exit value (TD_THR_ZOMBIE) */
	psaddr_t	ti_startfunc;	/* startfunc passed to thr_create() */
	psaddr_t	ti_stkbase;	/* base of thread's stack */
	long		ti_stksize;	/* size of thread's stack */
	psaddr_t	ti_ro_area;	/* address of uthread_t struct */
	int		ti_ro_size;	/* size of uthread_t struct */
	td_thr_state_e	ti_state;	/* thread state */
	uchar_t		ti_db_suspended; /* boolean:  suspended by debugger? */
	td_thr_type_e	ti_type;	/* thread type */
	intptr_t	ti_pc;		/* resume PC when sleeping */
	intptr_t	ti_sp;		/* resume SP when sleeping */
	short		ti_flags;	/* flags used by libthread */
	int		ti_pri;		/* thread priority */
	lwpid_t		ti_lid;		/* last LWP assigned to this thread */
	sigset_t	ti_sigmask;	/* signal mask */
	uchar_t		ti_traceme;	/* event reporting enabled? */
	uchar_t		ti_preemptflag;	/* was thread preemppted? */
	uchar_t		ti_pirecflag;	/* priority inheritance happened */
	sigset_t	ti_pending;	/* set of pending signals */
	td_thr_events_t ti_events;	/* set of enabled events */
} td_thrinfo_t;

#define	ti_tls	ti_exitval	/* for source compatibility */

typedef struct td_ta_stats {
	int	nthreads;	/* total number of threads in use */
	int	r_concurrency;	/* requested concurrency level */
	int	nrunnable_num;	/* numerator, avg. runnable threads */
	int	nrunnable_den;	/* denominator, avg. runnable threads */
	int	a_concurrency_num; /* numerator, achieved concurrency level */
	int	a_concurrency_den; /* denominator,  concurrency level */
	int	nlwps_num;	/* numerator, average number of LWP's in use */
	int	nlwps_den;	/* denom., average number of LWP's in use */
	int	nidle_num;	/* numerator, avg. number of idling LWP's */
	int	nidle_den;	/* denom., avg. number of idling LWP's */
} td_ta_stats_t;

/*
 * Iterator callback function declarations.
 */

/* Callback function for td_ta_tsd_iter(). */
typedef int	td_key_iter_f(thread_key_t, void (*destructor)(), void *);

/* Callback function for td_ta_thr_iter(). */
typedef int	td_thr_iter_f(const td_thrhandle_t *, void *);

/* Callback function for td_ta_sync_iter(). */
typedef int	td_sync_iter_f(const td_synchandle_t *, void *);

/* -------------------------------------------------------------------- */

/*
 * Synchronization Objects
 */

/* Enumeration of synchronization object types. */
typedef enum td_sync_type_e {
	TD_SYNC_UNKNOWN,	/* Sync. variable of unknown type  */
	TD_SYNC_COND,		/* Condition variable  */
	TD_SYNC_MUTEX,		/* Mutex lock  */
	TD_SYNC_SEMA,		/* Semaphore  */
	TD_SYNC_RWLOCK		/* Reader/Writer lock  */
} td_sync_type_e;

#define	TD_SV_MAX_FLAGS 4
typedef uint8_t td_sync_flags_t;

/*
 * Synchronization object information structure filled in by td_sync_get_info()
 */
typedef struct td_syncinfo {
	td_thragent_t	*si_ta_p;	/* process handle */
	psaddr_t	si_sv_addr;	/* address of sync. object */
	td_sync_type_e	si_type;	/* object type */
	uint32_t	si_shared_type;	/* process-shared or process-private */
	td_sync_flags_t	si_flags[TD_SV_MAX_FLAGS];	/* flags (?) */
	pid_t		si_ownerpid;	/* owner's process-id (USYNC_PROCESS) */
	union _si_un_state {
		int	sem_count;	/* semaphore count */
		int	nreaders;	/* number of readers, -1 if writer */
		int	mutex_locked;	/* non-zero iff locked */
	} si_state;
	int		si_size;	/* size in bytes of synch variable */
	uint8_t		si_has_waiters;	/* non-zero iff at least one waiter */
	uint8_t		si_is_wlock;	/* non-zero iff rwlock write-locked */
	uint8_t		si_rcount;	/* count for locked recursive mutex */
	uint8_t		si_prioceiling;	/* ceiling pri (PTHREAD_PRIO_PROTECT) */
	td_thrhandle_t	si_owner;	/* mutex holder or write-lock holder */
	psaddr_t	si_data;	/* optional data */
} td_syncinfo_t;

/*
 * Statistics structures for the various synchronization objects, contained
 * within the td_syncstats structure returned by td_sync_get_stats().
 */
typedef struct {
	uint_t		mutex_lock;
	uint_t		mutex_sleep;
	hrtime_t	mutex_sleep_time;
	hrtime_t	mutex_hold_time;
	uint_t		mutex_try;
	uint_t		mutex_try_fail;
	uint_t		mutex_internal;		/* internal to libthread */
} td_mutex_stats_t;

typedef struct {
	uint_t		cond_wait;
	uint_t		cond_timedwait;
	hrtime_t	cond_wait_sleep_time;
	hrtime_t	cond_timedwait_sleep_time;
	uint_t		cond_timedwait_timeout;
	uint_t		cond_signal;
	uint_t		cond_broadcast;
	uint_t		cond_internal;		/* internal to libthread */
} td_cond_stats_t;

typedef struct {
	uint_t		rw_rdlock;
	uint_t		rw_rdlock_sleep;
	hrtime_t	rw_rdlock_sleep_time;
	uint_t		rw_rdlock_try;
	uint_t		rw_rdlock_try_fail;
	uint_t		rw_wrlock;
	uint_t		rw_wrlock_sleep;
	hrtime_t	rw_wrlock_sleep_time;
	hrtime_t	rw_wrlock_hold_time;
	uint_t		rw_wrlock_try;
	uint_t		rw_wrlock_try_fail;
} td_rwlock_stats_t;

typedef struct {
	uint_t		sema_wait;
	uint_t		sema_wait_sleep;
	hrtime_t	sema_wait_sleep_time;
	uint_t		sema_trywait;
	uint_t		sema_trywait_fail;
	uint_t		sema_post;
	uint_t		sema_max_count;
	uint_t		sema_min_count;
} td_sema_stats_t;

/*
 * Synchronization object statistics structure filled in by td_sync_get_stats()
 */
typedef struct td_syncstats {
	td_syncinfo_t	ss_info;	/* as returned by td_sync_get_info() */
	union {
		td_mutex_stats_t	mutex;
		td_cond_stats_t		cond;
		td_rwlock_stats_t	rwlock;
		td_sema_stats_t		sema;
		uint_t			pad[32];	/* for future growth */
	} ss_un;
} td_syncstats_t;

/* The set of error codes. */
typedef enum {
	TD_OK,		/* generic "call succeeded" */
	TD_ERR,		/* generic error. */
	TD_NOTHR,	/* no thread can be found to satisfy query */
	TD_NOSV,	/* no synch. handle can be found to satisfy query */
	TD_NOLWP,	/* no lwp can be found to satisfy query */
	TD_BADPH,	/* invalid process handle */
	TD_BADTH,	/* invalid thread handle */
	TD_BADSH,	/* invalid synchronization handle */
	TD_BADTA,	/* invalid thread agent */
	TD_BADKEY,	/* invalid key */
	TD_NOMSG,	/* no event message for td_thr_event_getmsg() */
	TD_NOFPREGS,	/* FPU register set not available */
	TD_NOLIBTHREAD,	/* application not linked with libthread */
	TD_NOEVENT,	/* requested event is not supported */
	TD_NOCAPAB,	/* capability not available */
	TD_DBERR,	/* Debugger service failed */
	TD_NOAPLIC,	/* Operation not applicable to */
	TD_NOTSD,	/* No thread-specific data for this thread */
	TD_MALLOC,	/* Malloc failed */
	TD_PARTIALREG,	/* Only part of register set was writen/read */
	TD_NOXREGS,	/* X register set not available for given thread */
	TD_NOTLS,	/* There is no TLS in the specified module */
	TD_TLSDEFER	/* module's TLS not yet allocated by the thread */
}	td_err_e;


/* ----------------------------------------------------------------------- */

/*
 * Exported functions.
 */

/*
 * Initialize the threads debug interface.
 */
td_err_e
td_init(void);

/*
 * A no-op, left for historical reasons.
 */
void
td_log(void);

/*
 * Allocate a new process handle ("thread agent").
 */
td_err_e
td_ta_new(struct ps_prochandle *, td_thragent_t **);

/*
 * De-allocate a process handle, releasing all related resources.
 */
td_err_e
td_ta_delete(td_thragent_t *);

/*
 * Map a process handle to a client process handle.
 */
td_err_e
td_ta_get_ph(const td_thragent_t *, struct ps_prochandle **);

/*
 * Set the process's suggested concurrency level.
 */
td_err_e
td_ta_setconcurrency(const td_thragent_t *, int);

/*
 * Get the number of threads in the process, including zombie threads.
 */
td_err_e
td_ta_get_nthreads(const td_thragent_t *, int *);

/*
 * Map a tid, as returned by thr_create(), to a thread handle.
 */
td_err_e
td_ta_map_id2thr(const td_thragent_t *, thread_t,  td_thrhandle_t *);

/*
 * Map the address of a synchronization object to a sync. object handle.
 */
td_err_e
td_ta_map_addr2sync(const td_thragent_t *, psaddr_t, td_synchandle_t *);

/*
 * Iterate over a process's thread-specific data (TSD) keys.
 */
td_err_e
td_ta_tsd_iter(const td_thragent_t *, td_key_iter_f *, void *);

/*
 * Iterate over a process's threads, including zombie threads.
 */
td_err_e
td_ta_thr_iter(const td_thragent_t *, td_thr_iter_f *, void *,
    td_thr_state_e, int, sigset_t *, unsigned);

/*
 * Iterate over a process's known synchronization objects.
 */
td_err_e
td_ta_sync_iter(const td_thragent_t *, td_sync_iter_f *, void *);

/*
 * Enable/disable process statistics collection.
 */
td_err_e
td_ta_enable_stats(const td_thragent_t *, int);

/*
 * Reset process statistics.
 */
td_err_e
td_ta_reset_stats(const td_thragent_t *);

/*
 * Read process statistics.
 */
td_err_e
td_ta_get_stats(const td_thragent_t *, td_ta_stats_t *);

/*
 * Get thread information.
 */
td_err_e
td_thr_get_info(const td_thrhandle_t *, td_thrinfo_t *);

/*
 * Get the "event address" for an event type.
 */
td_err_e
td_ta_event_addr(const td_thragent_t *, td_event_e, td_notify_t *);

/*
 * Enable/disable event reporting for a thread.
 */
td_err_e
td_thr_event_enable(const td_thrhandle_t *, int);

/*
 * Enable a set of events for a thread.
 */
td_err_e
td_thr_set_event(const td_thrhandle_t *, td_thr_events_t *);

/*
 * Disable a set of events for a thread.
 */
td_err_e
td_thr_clear_event(const td_thrhandle_t *, td_thr_events_t *);

/*
 * Retrieve (and consume) an event message for a thread.
 */
td_err_e
td_thr_event_getmsg(const td_thrhandle_t *, td_event_msg_t *);

/*
 * Enable a set of events in the process.
 */
td_err_e
td_ta_set_event(const td_thragent_t *, td_thr_events_t *);

/*
 * Disable a set of events in the process.
 */
td_err_e
td_ta_clear_event(const td_thragent_t *, td_thr_events_t *);

/*
 * Retrieve (and consume) an event message for some thread in the process.
 */
td_err_e
td_ta_event_getmsg(const td_thragent_t *, td_event_msg_t *);

/*
 * Suspend a thread.
 */
td_err_e
td_thr_dbsuspend(const td_thrhandle_t *);

/*
 * Resume a suspended thread.
 */
td_err_e
td_thr_dbresume(const td_thrhandle_t *);

/*
 * Set a thread's signal mask.
 */
td_err_e
td_thr_sigsetmask(const td_thrhandle_t *, const sigset_t);

/*
 * Set a thread's "signals-pending" set.
 */
td_err_e
td_thr_setsigpending(const td_thrhandle_t *, uchar_t, const sigset_t);

/*
 * Get a thread's general register set.
 */
td_err_e
td_thr_getgregs(const td_thrhandle_t *, prgregset_t);

/*
 * Set a thread's general register set.
 */
td_err_e
td_thr_setgregs(const td_thrhandle_t *, const prgregset_t);

/*
 * Get a thread's floating-point register set.
 */
td_err_e
td_thr_getfpregs(const td_thrhandle_t *, prfpregset_t *);

/*
 * Set a thread's floating-point register set.
 */
td_err_e
td_thr_setfpregs(const td_thrhandle_t *, const prfpregset_t *);

/*
 * Get the size of the extra state register set for this architecture.
 */
td_err_e
td_thr_getxregsize(const td_thrhandle_t *th_p, int *xregsize);

/*
 * Get a thread's extra state register set.
 */
td_err_e
td_thr_getxregs(const td_thrhandle_t *th_p, void *xregs);

/*
 * Set a thread's extra state register set.
 */
td_err_e
td_thr_setxregs(const td_thrhandle_t *th_p, const void *xregs);

/*
 * Validate a thread handle.
 */
td_err_e
td_thr_validate(const td_thrhandle_t *);

/*
 * Get a thread-specific data pointer for a thread.
 */
td_err_e
td_thr_tsd(const td_thrhandle_t *, thread_key_t, void **);

/*
 * Get the base address of a thread's thread local storage (TLS) block
 * for the module (executable or shared object) identified by 'moduleid'.
 */
td_err_e
td_thr_tlsbase(const td_thrhandle_t *, ulong_t moduleid, psaddr_t *base);

/*
 * Set a thread's priority.
 */
td_err_e
td_thr_setprio(const td_thrhandle_t *, int);

/*
 * Iterate over the set of locks owned by a thread.
 */
td_err_e
td_thr_lockowner(const td_thrhandle_t *, td_sync_iter_f *, void *);

/*
 * Return the sync. handle of the object this thread is sleeping on.
 */
td_err_e
td_thr_sleepinfo(const td_thrhandle_t *, td_synchandle_t *);

/*
 * Map an lwpid, as returned by _lwp_create(), to a thread handle.
 */
td_err_e
td_ta_map_lwp2thr(const td_thragent_t *, lwpid_t, td_thrhandle_t *th_p);

/*
 * Enable/disable a process's synchronization object tracking.
 */
td_err_e
td_ta_sync_tracking_enable(const td_thragent_t *, int);

/*
 * Get information about a synchronization object.
 */
td_err_e
td_sync_get_info(const td_synchandle_t *, td_syncinfo_t *);

/*
 * Get statistics for a synchronization object.
 */
td_err_e
td_sync_get_stats(const td_synchandle_t *, td_syncstats_t *);

/*
 * Set the state of a synchronization object.
 */
td_err_e
td_sync_setstate(const td_synchandle_t *, int value);

/*
 * Iterate over all threads blocked on a synchronization object.
 */
td_err_e
td_sync_waiters(const td_synchandle_t *, td_thr_iter_f *, void *);

#ifdef __cplusplus
}
#endif

#endif	/* _THREAD_DB_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2016 Joyent, Inc.
 */

#ifndef _THREADS_H
#define	_THREADS_H

/*
 * ISO/IEC C11 threads.h support
 */

#include <sys/feature_tests.h>

#include <sys/types.h>
#include <limits.h>
#include <time.h>
#include <pthread.h>

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)

#if !defined(_NORETURN_KYWD)
#if __STDC_VERSION__ - 0 >= 201112L
#define	_NORETURN_KYWD	_Noreturn
#else
#define	_NORETURN_KYWD
#endif	/* __STDC_VERSION__ - 0 >= 201112L */
#endif	/* !defined(_NORETURN_KYWD) */

#define	thread_local	_Thread_local
#define	ONCE_FLAG_INIT	PTHREAD_ONCE_INIT
#define	TSS_DTOR_ITERATIONS	PTHREAD_DESTRUCTOR_ITERATIONS

typedef	pthread_cond_t cnd_t;
typedef	pthread_t thrd_t;
typedef	pthread_key_t tss_t;
typedef	pthread_mutex_t mtx_t;
typedef	void (*tss_dtor_t)(void *);
typedef int (*thrd_start_t)(void *);
typedef	pthread_once_t once_flag;

enum {
	mtx_plain = 0x1,
	mtx_recursive = 0x2,
	mtx_timed = 0x4
};

enum {
	thrd_success = 0,
	thrd_error = 1,
	thrd_busy = 2,
	thrd_timedout = 3,
	thrd_nomem = 4
};

extern void call_once(once_flag *, void (*)(void));
extern int cnd_broadcast(cnd_t *);
extern void cnd_destroy(cnd_t *);
extern int cnd_init(cnd_t *);
extern int cnd_signal(cnd_t *);
extern int cnd_timedwait(cnd_t *_RESTRICT_KYWD, mtx_t *_RESTRICT_KYWD,
    const struct timespec *_RESTRICT_KYWD);
extern int cnd_wait(cnd_t *, mtx_t *);
extern void mtx_destroy(mtx_t *);
extern int mtx_init(mtx_t *, int);
extern int mtx_lock(mtx_t *);
extern int mtx_timedlock(mtx_t *_RESTRICT_KYWD,
    const struct timespec *_RESTRICT_KYWD);
extern int mtx_trylock(mtx_t *);
extern int mtx_unlock(mtx_t *);
extern int thrd_create(thrd_t *, thrd_start_t, void *);
extern thrd_t thrd_current(void);
extern int thrd_detach(thrd_t);
extern int thrd_equal(thrd_t, thrd_t);
extern _NORETURN_KYWD void thrd_exit(int) __NORETURN;
extern int thrd_join(thrd_t, int *);
extern int thrd_sleep(const struct timespec *, struct timespec *);
extern void thrd_yield(void);
extern int tss_create(tss_t *, tss_dtor_t);
extern void tss_delete(tss_t);
extern void *tss_get(tss_t);
extern int tss_set(tss_t, void *);

#endif /* !_STRICT_SYMBOLS | _STDC_C11 */

#ifdef __cplusplus
}
#endif

#endif /* _THREADS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */
/*
 * Copyright 2010 Nexenta Systems, Inc.  Al rights reserved.
 * Copyright 2016 Joyent, Inc.
 */

#ifndef _TIME_H
#define	_TIME_H

#include <sys/feature_tests.h>
#include <iso/time_iso.h>
/*
 * C11 requires sys/time_impl.h for the definition of the struct timespec.
 */
#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) || defined(_STDC_C11)
#include <sys/types.h>
#include <sys/time_impl.h>
#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) ... */

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/time_iso.h>.
 */
#if __cplusplus >= 199711L
using std::size_t;
using std::clock_t;
using std::time_t;
using std::tm;
using std::asctime;
using std::clock;
using std::ctime;
using std::difftime;
using std::gmtime;
using std::localtime;
using std::mktime;
using std::time;
using std::strftime;
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef _CLOCKID_T
#define	_CLOCKID_T
typedef int	clockid_t;
#endif

#ifndef _TIMER_T
#define	_TIMER_T
typedef int	timer_t;
#endif

#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
extern struct tm *gmtime_r(const time_t *_RESTRICT_KYWD,
			struct tm *_RESTRICT_KYWD);
extern struct tm *localtime_r(const time_t *_RESTRICT_KYWD,
			struct tm *_RESTRICT_KYWD);
#endif

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG4) || defined(__EXTENSIONS__)

#ifdef _STRPTIME_DONTZERO
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname strptime __strptime_dontzero
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern char *__strptime_dontzero(const char *, const char *, struct tm *);
#define	strptime	__strptime_dontzero
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* _STRPTIME_DONTZERO */

extern char *strptime(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
		struct tm *_RESTRICT_KYWD);

#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
/*
 * Neither X/Open nor POSIX allow the inclusion of <signal.h> for the
 * definition of the sigevent structure.  Both require the inclusion
 * of <signal.h> and <time.h> when using the timer_create() function.
 * However, X/Open also specifies that the sigevent structure be defined
 * in <time.h> as described in the header <signal.h>.  This prevents
 * compiler warnings for applications that only include <time.h> and not
 * also <signal.h>.  The sigval union and the sigevent structure is
 * therefore defined both here and in <sys/siginfo.h> which gets included
 * via inclusion of <signal.h>.
 */
#ifndef	_SIGVAL
#define	_SIGVAL
union sigval {
	int	sival_int;	/* integer value */
	void	*sival_ptr;	/* pointer value */
};
#endif	/* _SIGVAL */

#ifndef	_SIGEVENT
#define	_SIGEVENT
struct sigevent {
	int		sigev_notify;	/* notification mode */
	int		sigev_signo;	/* signal number */
	union sigval	sigev_value;	/* signal value */
	void		(*sigev_notify_function)(union sigval);
	pthread_attr_t	*sigev_notify_attributes;
	int		__sigev_pad2;
};
#endif	/* _SIGEVENT */

extern int clock_getres(clockid_t, struct timespec *);
extern int clock_gettime(clockid_t, struct timespec *);
extern int clock_settime(clockid_t, const struct timespec *);
extern int timer_create(clockid_t, struct sigevent *_RESTRICT_KYWD,
		timer_t *_RESTRICT_KYWD);
extern int timer_delete(timer_t);
extern int timer_getoverrun(timer_t);
extern int timer_gettime(timer_t, struct itimerspec *);
extern int timer_settime(timer_t, int, const struct itimerspec *_RESTRICT_KYWD,
		struct itimerspec *_RESTRICT_KYWD);

extern int nanosleep(const struct timespec *, struct timespec *);
extern int clock_nanosleep(clockid_t, int,
	const struct timespec *, struct timespec *);

#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */

#if !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || \
	defined(__EXTENSIONS__)

extern void tzset(void);
extern char *tzname[2];

/* CLK_TCK marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
#ifndef CLK_TCK
extern long _sysconf(int);	/* System Private interface to sysconf() */
#define	CLK_TCK	((clock_t)_sysconf(3))	/* clock ticks per second */
				/* 3 is _SC_CLK_TCK */
#endif
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */

#if (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
	defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
extern long timezone;
extern int daylight;
#endif

#endif /* !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)... */

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(__EXTENSIONS__)
extern time_t timegm(struct tm *);
extern int cftime(char *, char *, const time_t *);
extern int ascftime(char *, const char *, const struct tm *);
extern long altzone;
#endif

#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	defined(_XPG4_2) || defined(__EXTENSIONS__)
extern struct tm *getdate(const char *);
#ifdef	_REENTRANT
#undef getdate_err
#define	getdate_err *(int *)_getdate_err_addr()
extern int *_getdate_err_addr(void);
#else
extern int getdate_err;
#endif /* _REENTRANT */
#endif /* (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))... */

/*
 * ctime_r() & asctime_r() prototypes are defined here.
 */

/*
 * Previous releases of Solaris, starting at 2.3, provided definitions of
 * various functions as specified in POSIX.1c, Draft 6.  For some of these
 * functions, the final POSIX 1003.1c standard had a different number of
 * arguments and return values.
 *
 * The following segment of this header provides support for the standard
 * interfaces while supporting applications written under earlier
 * releases.  The application defines appropriate values of the feature
 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
 * whether it was written to expect the Draft 6 or standard versions of
 * these interfaces, before including this header.  This header then
 * provides a mapping from the source version of the interface to an
 * appropriate binary interface.  Such mappings permit an application
 * to be built from libraries and objects which have mixed expectations
 * of the definitions of these functions.
 *
 * For applications using the Draft 6 definitions, the binary symbol is the
 * same as the source symbol, and no explicit mapping is needed.  For the
 * standard interface, the function func() is mapped to the binary symbol
 * _posix_func().  The preferred mechanism for the remapping is a compiler
 * #pragma.  If the compiler does not provide such a #pragma, the header file
 * defines a static function func() which calls the _posix_func() version;
 * this has to be done instead of #define since POSIX specifies that an
 * application can #undef the symbol and still be bound to the correct
 * implementation.  Unfortunately, the statics confuse lint so we fallback to
 * #define in that case.
 *
 * NOTE: Support for the Draft 6 definitions is provided for compatibility
 * only.  New applications/libraries should use the standard definitions.
 */

#if	defined(__EXTENSIONS__) || defined(_REENTRANT) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname ctime_r __posix_ctime_r
#pragma redefine_extname asctime_r __posix_asctime_r
extern char *asctime_r(const struct tm *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
extern char *ctime_r(const time_t *, char *);
#else  /* __PRAGMA_REDEFINE_EXTNAME */

extern char *__posix_asctime_r(const struct tm *_RESTRICT_KYWD,
    char *_RESTRICT_KYWD);
extern char *__posix_ctime_r(const time_t *, char *);

#ifdef	__lint

#define	ctime_r __posix_ctime_r
#define	asctime_r __posix_asctime_r

#else	/* !__lint */

static char *
asctime_r(const struct tm *_RESTRICT_KYWD __tm, char *_RESTRICT_KYWD __buf)
{
	return (__posix_asctime_r(__tm, __buf));
}

static char *
ctime_r(const time_t *__time, char *__buf)
{
	return (__posix_ctime_r(__time, __buf));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

extern char *asctime_r(const struct tm *, char *, int);
extern char *ctime_r(const time_t *, char *, int);

#endif  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */


#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)

#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern size_t strftime_l(char *_RESTRICT_KYWD, size_t,
	const char *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD, locale_t);

#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)

/*
 * Note, the C11 standard requires that all the various base values that are
 * passed into timespec_get() be non-zero. Hence why TIME_UTC starts at one.
 */
#define	TIME_UTC		0x1		/* CLOCK_REALTIME */
#define	TIME_MONOTONIC		0x2		/* CLOCK_HIGHRES */
#define	TIME_ACTIVE		0x3		/* CLOCK_PROCESS_CPUTIME_ID */
#define	TIME_THREAD_ACTIVE	0x4		/* CLOCK_THREAD_CPUTIME_ID */
#define	TIME_THREAD_ACTIVE_USR	0x5		/* CLOCK_VIRTUAL */

extern int timespec_get(struct timespec *, int);
#endif

#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C23)
extern int timespec_getres(struct timespec *, int);
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _TIME_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_TIUSER_H
#define	_TIUSER_H

/*
 * TLI user interface definitions.
 */

#include <sys/tiuser.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if defined(_REENTRANT) || defined(_TS_ERRNO) || \
	_POSIX_C_SOURCE - 0 >= 199506L
extern int	*__t_errno(void);
#define	t_errno	(*(__t_errno()))
#else
extern int t_errno;
#endif	/* defined(_REENTRANT) || defined(_TS_ERRNO) */

#ifdef	__cplusplus
}
#endif

#endif	/* _TIUSER_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

#ifndef _TZFILE_H
#define	_TZFILE_H

/*
 * A part of this file comes from public domain source, so
 * clarified as of June 5, 1996 by Arthur David Olson
 */

#include <sys/types.h>

/*
 * WARNING:
 * The interfaces defined in this header file are for Sun private use only.
 * The contents of this file are subject to change without notice for the
 * future releases.
 */

/* For further information, see ctime(3C) and zic(8) man pages. */

/*
 * This file is in the public domain, so clarified as of
 * 1996-06-05 by Arthur David Olson.
 */

/*
 * This header is for use ONLY with the time conversion code.
 * There is no guarantee that it will remain unchanged,
 * or that it will remain at all.
 * Do NOT copy it to any system include directory.
 * Thank you!
 */

/*
 * Note: Despite warnings from the authors of this code, Solaris has
 * placed this header file in the system include directory.  This was
 * probably done in order to build both zic and zdump which are in
 * separate source directories, but both use this file.
 */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Information about time zone files.
 */

#ifndef TZDIR
#define	TZDIR	"/usr/share/lib/zoneinfo" /* Time zone object file directory */
#endif /* !defined TZDIR */

#ifndef TZDEFAULT
#define	TZDEFAULT	"localtime"
#endif /* !defined TZDEFAULT */

#ifndef TZDEFRULES
#define	TZDEFRULES	"posixrules"
#endif /* !defined TZDEFRULES */


/* See Internet RFC 9636 for more details about the following format.  */

/*
 * Each file begins with. . .
 */

#define	TZ_MAGIC	"TZif"

struct tzhead {
	char	tzh_magic[4];		/* TZ_MAGIC */
	char	tzh_version[1];		/* '\0' or '2'-'4' as of 2021 */
	char	tzh_reserved[15];	/* reserved; must be zero */
	char	tzh_ttisutcnt[4];	/* coded number of trans. time flags */
	char	tzh_ttisstdcnt[4];	/* coded number of trans. time flags */
	char	tzh_leapcnt[4];		/* coded number of leap seconds */
	char	tzh_timecnt[4];		/* coded number of transition times */
	char	tzh_typecnt[4];		/* coded number of local time types */
	char	tzh_charcnt[4];		/* coded number of abbr. chars */
};

/*
 * . . .followed by. . .
 *
 *	tzh_timecnt (char [4])s		coded transition times a la time(2)
 *	tzh_timecnt (unsigned char)s	types of local time starting at above
 *	tzh_typecnt repetitions of
 *		one (char [4])		coded UT offset in seconds
 *		one (unsigned char)	used to set tm_isdst
 *		one (unsigned char)	that's an abbreviation list index
 *	tzh_charcnt (char)s		'\0'-terminated zone abbreviations
 *	tzh_leapcnt repetitions of
 *		one (char [4])		coded leap second transition times
 *		one (char [4])		total correction after above
 *	tzh_ttisstdcnt (char)s		indexed by type; if 1, transition
 *					time is standard time, if 0,
 *					transition time is local (wall clock)
 *					time; if absent, transition times are
 *					assumed to be local time
 *	tzh_ttisutcnt (char)s		indexed by type; if 1, transition
 *					time is UT, if 0, transition time is
 *					local time; if absent, transition
 *					times are assumed to be local time.
 *					When this is 1, the corresponding
 *					std/wall indicator must also be 1.
 */

/*
 * If tzh_version is '2' or greater, the above is followed by a second instance
 * of tzhead and a second instance of the data in which each coded transition
 * time uses 8 rather than 4 chars,
 * then a POSIX.1-2017 proleptic TZ string for use in handling
 * instants after the last transition time stored in the file
 * (with nothing between the newlines if there is no POSIX.1-2017
 * representation for such instants).
 *
 * If tz_version is '3' or greater, the TZ string can be any POSIX.1-2024
 * proleptic TZ string, which means the above is extended as follows.
 * First, the TZ string's hour offset may range from -167
 * through 167 as compared to the range 0 through 24 required
 * by POSIX.1-2017 and earlier.
 * Second, its DST start time may be January 1 at 00:00 and its stop
 * time December 31 at 24:00 plus the difference between DST and
 * standard time, indicating DST all year.
 */

/*
 * In the current implementation, "tzset()" refuses to deal with files that
 * exceed any of the limits below.
 */

#ifndef TZ_MAX_TIMES
/*
 * The TZ_MAX_TIMES value below is enough to handle a bit more than a
 * year's worth of solar time (corrected daily to the nearest second) or
 * 138 years of Pacific Presidential Election time
 * (where there are three time zone transitions every fourth year).
 */
#define	TZ_MAX_TIMES 370
#endif /* !defined TZ_MAX_TIMES */

#ifndef TZ_MAX_TYPES
/* This must be at least 18 for Europe/Vilnius with 'zic -b fat'.  */
#define	TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#endif /* !defined TZ_MAX_TYPES */

#ifndef TZ_MAX_CHARS
/* This must be at least 40 for America/Anchorage.  */
#define	TZ_MAX_CHARS	50	/* Maximum number of abbreviation characters */
				/* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */

#ifndef TZ_MAX_LEAPS
/* This must be at least 27 for leap seconds from 1972 through mid-2023. */
/* There's a plan to discontinue leap seconds by 2035.  */
#define	TZ_MAX_LEAPS 50	/* Maximum number of leap second corrections */
#endif /* !defined TZ_MAX_LEAPS */

/* Handy macros that are independent of tzfile implementation.  */

enum {
	SECSPERMIN = 60,
	MINSPERHOUR = 60,
	SECSPERHOUR = SECSPERMIN * MINSPERHOUR,
	HOURSPERDAY = 24,
	DAYSPERWEEK = 7,
	DAYSPERNYEAR = 365,
	DAYSPERLYEAR = DAYSPERNYEAR + 1,
	MONSPERYEAR = 12,
	YEARSPERREPEAT = 400	/* years before a Gregorian repeat */
};

#define	SECSPERDAY	((int_fast32_t)SECSPERHOUR * HOURSPERDAY)

#define	DAYSPERREPEAT		((int_fast32_t)400 * 365 + 100 - 4 + 1)
#define	SECSPERREPEAT		((int_fast64_t)DAYSPERREPEAT * SECSPERDAY)
#define	AVGSECSPERYEAR		(SECSPERREPEAT / YEARSPERREPEAT)

/*
 * How many years to generate (in zic.c) or search through (in localtime.c).
 * This is two years larger than the obvious 400, to avoid edge cases.
 * E.g., suppose a rule applies from 2012 on with transitions
 * in March and September, plus one-off transitions in November 2013,
 * and suppose the rule cannot be expressed as a proleptic TZ string.
 * If zic looked only at the last 400 years, it would set max_year=2413,
 * with the intent that the 400 years 2014 through 2413 will be repeated.
 * The last transition listed in the tzfile would be in 2413-09,
 * less than 400 years after the last one-off transition in 2013-11.
 * Two years is not overkill for localtime.c, as a one-year bump
 * would mishandle 2023d's America/Ciudad_Juarez for November 2422.
 */
enum { years_of_observations = YEARSPERREPEAT + 2 };

enum {
	TM_SUNDAY,
	TM_MONDAY,
	TM_TUESDAY,
	TM_WEDNESDAY,
	TM_THURSDAY,
	TM_FRIDAY,
	TM_SATURDAY
};

enum {
	TM_JANUARY,
	TM_FEBRUARY,
	TM_MARCH,
	TM_APRIL,
	TM_MAY,
	TM_JUNE,
	TM_JULY,
	TM_AUGUST,
	TM_SEPTEMBER,
	TM_OCTOBER,
	TM_NOVEMBER,
	TM_DECEMBER
};

enum {
	TM_YEAR_BASE = 1900,
	TM_WDAY_BASE = TM_MONDAY,
	EPOCH_YEAR = 1970,
	EPOCH_WDAY = TM_THURSDAY
};

#define	isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))

/*
 * Since everything in isleap is modulo 400 (or a factor of 400), we know that
 *	isleap(y) == isleap(y % 400)
 * and so
 *	isleap(a + b) == isleap((a + b) % 400)
 * or
 *	isleap(a + b) == isleap(a % 400 + b % 400)
 * This is true even if % means modulo rather than Fortran remainder
 * (which is allowed by C89 but not by C99 or later).
 * We use this to avoid addition overflow problems.
 */

#define	isleap_sum(a, b)	isleap((a) % 400 + (b) % 400)

#ifdef	__cplusplus
}
#endif

#endif	/* _TZFILE_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2020 Robert Mustacchi
 */

#ifndef _UCHAR_H
#define	_UCHAR_H

/*
 * C11 Unicode utilities support.
 *
 * Note, we do not define either __STDC_UTF_16__ or __STDC_UTF_32__. While the
 * functions that are implemented work in that fashion, the ability to represent
 * any UTF-16 or UTF-32 code point depends on the current locale. Though in
 * practice they function that way.
 */

#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
#include <wchar_impl.h>

#ifdef __cplusplus
extern "C" {
#endif

#if !defined(_SIZE_T) || __cplusplus >= 199711L
#define	_SIZE_T
#if defined(_LP64)
typedef	unsigned long size_t;	/* size of something in bytes */
#else
typedef	unsigned int size_t;	/* (historical version) */
#endif
#endif	/* _SIZE_T */

#if !defined(_MBSTATE_T) || __cplusplus >= 199711L
#define	_MBSTATE_T
typedef __mbstate_t	mbstate_t;
#endif	/* _MBSTATE_T */

/*
 * These types must match the uint_least16_t and uint_least32_t. They are
 * defined in terms of the same type so as to minimize the needed includes.
 * C++11 also defines these types and they are considered built in, so we should
 * not define them in that context.
 */
#if __cplusplus < 201103L
typedef unsigned short	char16_t;
typedef unsigned int	char32_t;
#endif

extern size_t mbrtoc16(char16_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD);
extern size_t mbrtoc32(char32_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD);
extern size_t c16rtomb(char *_RESTRICT_KYWD, char16_t,
    mbstate_t *_RESTRICT_KYWD);
extern size_t c32rtomb(char *_RESTRICT_KYWD, char32_t,
    mbstate_t *_RESTRICT_KYWD);

#ifdef __cplusplus
}
#endif

#endif /* _UCHAR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2023 Oxide Computer Company
 *
 * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _UCONTEXT_H
#define	_UCONTEXT_H

#include <sys/ucontext.h>
/*
 * The file sys/regset.h defines indices in the gregset_t array,
 * such as EIP on i386.  Those defines were historically exposed
 * via sys/ucontext.h, sys/signal.h, etc. which caused surprises
 * due to those defines unexpectedly polluting the namespace.
 * On the other hand, several existing applications assume that
 * the regset names are defined after an include <ucontext.h>.
 * To solve both problems at once: <ucontext.h> (this file)
 * DOES include sys/regset.h for you but <sys/ucontext.h>
 * does NOT include sys/regset.h anymore.
 */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#include <sys/regset.h>
#include <sys/siginfo.h>
#include <inttypes.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef __sparc
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname	makecontext	__makecontext_v2
#else
#define	makecontext	__makecontext_v2
#endif
#endif

extern int getcontext(ucontext_t *) __RETURNS_TWICE;
extern int setcontext(const ucontext_t *);
extern int swapcontext(ucontext_t *_RESTRICT_KYWD,
		const ucontext_t *_RESTRICT_KYWD);
extern void makecontext(ucontext_t *, void(*)(), int, ...);

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
extern ucontext_t *ucontext_alloc(uint32_t);
extern void ucontext_free(ucontext_t *);
extern int getcontext_extd(ucontext_t *, uint32_t) __RETURNS_TWICE;
extern int swapcontext_extd(ucontext_t *_RESTRICT_KYWD, uint32_t,
		const ucontext_t *_RESTRICT_KYWD);
extern int walkcontext(const ucontext_t *, int (*)(uintptr_t, int, void *),
    void *);
extern int printstack(int);
extern int addrtosymstr(void *, char *, int);
extern int getustack(stack_t **);
extern int setustack(stack_t *);

extern int stack_getbounds(stack_t *);
extern int stack_setbounds(const stack_t *);
extern int stack_inbounds(void *);
extern int stack_violation(int, const siginfo_t *, const ucontext_t *);

extern void *_stack_grow(void *);
#endif	/* !_XPG4_2 || __EXTENSIONS__ */

#ifdef	__cplusplus
}
#endif

#endif	/* _UCONTEXT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_UCRED_H_
#define	_UCRED_H_

#include <sys/types.h>
#include <sys/priv.h>
#include <sys/tsol/label.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct ucred_s ucred_t;

/*
 * library functions prototype.
 */

extern ucred_t *ucred_get(pid_t pid);

extern void ucred_free(ucred_t *);

extern uid_t ucred_geteuid(const ucred_t *);
extern uid_t ucred_getruid(const ucred_t *);
extern uid_t ucred_getsuid(const ucred_t *);
extern gid_t ucred_getegid(const ucred_t *);
extern gid_t ucred_getrgid(const ucred_t *);
extern gid_t ucred_getsgid(const ucred_t *);
extern int   ucred_getgroups(const ucred_t *, const gid_t **);

extern const priv_set_t *ucred_getprivset(const ucred_t *, priv_ptype_t);
extern uint_t ucred_getpflags(const ucred_t *, uint_t);

extern pid_t ucred_getpid(const ucred_t *); /* for door_cred compatibility */

extern size_t ucred_size(void);

extern int getpeerucred(int, ucred_t **);

extern zoneid_t ucred_getzoneid(const ucred_t *);

extern bslabel_t *ucred_getlabel(const ucred_t *);

extern projid_t ucred_getprojid(const ucred_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _UCRED_H_ */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _ULIMIT_H
#define	_ULIMIT_H

#include <sys/ulimit.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern long ulimit(int, ...);

#ifdef	__cplusplus
}
#endif

#endif	/* _ULIMIT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 PALO, Richard.
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 2013 Gary Mills
 *
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 */

/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/

/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */

#ifndef _UNISTD_H
#define	_UNISTD_H

#include <sys/feature_tests.h>

#include <sys/null.h>
#include <sys/types.h>
#include <sys/unistd.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Symbolic constants for the "access" routine: */
#define	R_OK	4	/* Test for Read permission */
#define	W_OK	2	/* Test for Write permission */
#define	X_OK	1	/* Test for eXecute permission */
#define	F_OK	0	/* Test for existence of File */

#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	F_ULOCK	0	/* Unlock a previously locked region */
#define	F_LOCK	1	/* Lock a region for exclusive use */
#define	F_TLOCK	2	/* Test and lock a region for exclusive use */
#define	F_TEST	3	/* Test a region for other processes locks */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */

/* Symbolic constants for the "lseek" routine: */

#ifndef	SEEK_SET
#define	SEEK_SET	0	/* Set file pointer to "offset" */
#endif

#ifndef	SEEK_CUR
#define	SEEK_CUR	1	/* Set file pointer to current plus "offset" */
#endif

#ifndef	SEEK_END
#define	SEEK_END	2	/* Set file pointer to EOF plus "offset" */
#endif

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#ifndef	SEEK_DATA
#define	SEEK_DATA	3	/* Set file pointer to next data past offset */
#endif

#ifndef	SEEK_HOLE
#define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
#endif
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/* Path names: */
#define	GF_PATH	"/etc/group"	/* Path name of the "group" file */
#define	PF_PATH	"/etc/passwd"	/* Path name of the "passwd" file */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

/*
 * compile-time symbolic constants,
 * Support does not mean the feature is enabled.
 * Use pathconf/sysconf to obtain actual configuration value.
 */

/* Values unchanged in UNIX 03 */
#define	_POSIX_ASYNC_IO			1
#define	_POSIX_JOB_CONTROL		1
#define	_POSIX_SAVED_IDS		1
#define	_POSIX_SYNC_IO			1

/*
 * POSIX.1b compile-time symbolic constants.
 */
#if defined(_XPG6)
#define	_POSIX_ASYNCHRONOUS_IO		200112L
#define	_POSIX_FSYNC			200112L
#define	_POSIX_MAPPED_FILES		200112L
#define	_POSIX_MEMLOCK			200112L
#define	_POSIX_MEMLOCK_RANGE		200112L
#define	_POSIX_MEMORY_PROTECTION	200112L
#define	_POSIX_MESSAGE_PASSING		200112L
#define	_POSIX_PRIORITY_SCHEDULING	200112L
#define	_POSIX_REALTIME_SIGNALS		200112L
#define	_POSIX_SEMAPHORES		200112L
#define	_POSIX_SHARED_MEMORY_OBJECTS	200112L
#define	_POSIX_SYNCHRONIZED_IO		200112L
#else
#define	_POSIX_ASYNCHRONOUS_IO		1
#define	_POSIX_FSYNC			1
#define	_POSIX_MAPPED_FILES		1
#define	_POSIX_MEMLOCK			1
#define	_POSIX_MEMLOCK_RANGE		1
#define	_POSIX_MEMORY_PROTECTION	1
#define	_POSIX_MESSAGE_PASSING		1
#define	_POSIX_PRIORITY_SCHEDULING	1
#define	_POSIX_REALTIME_SIGNALS		1
#define	_POSIX_SEMAPHORES		1
#define	_POSIX_SHARED_MEMORY_OBJECTS	1
#define	_POSIX_SYNCHRONIZED_IO		1
#endif

/*
 * POSIX.1c compile-time symbolic constants.
 */
#if defined(_XPG6)
#define	_POSIX_THREAD_SAFE_FUNCTIONS		200112L
#define	_POSIX_THREADS				200112L
#define	_POSIX_THREAD_ATTR_STACKADDR		200112L
#define	_POSIX_THREAD_ATTR_STACKSIZE		200112L
#define	_POSIX_THREAD_PROCESS_SHARED		200112L
#define	_POSIX_THREAD_PRIORITY_SCHEDULING	200112L
#define	_POSIX_TIMERS				200112L
#else
#define	_POSIX_THREAD_SAFE_FUNCTIONS		1
#define	_POSIX_THREADS				1
#define	_POSIX_THREAD_ATTR_STACKADDR		1
#define	_POSIX_THREAD_ATTR_STACKSIZE		1
#define	_POSIX_THREAD_PROCESS_SHARED		1
#define	_POSIX_THREAD_PRIORITY_SCHEDULING	1
#define	_POSIX_TIMERS				1
#endif

/* New in UNIX 03 */
#define	_POSIX_ADVISORY_INFO			200112L
#define	_POSIX_BARRIERS				200112L
#define	_POSIX_CLOCK_SELECTION			200112L
#define	_POSIX_IPV6				200112L
#define	_POSIX_MONOTONIC_CLOCK			200112L
#define	_POSIX_RAW_SOCKETS			200112L
#define	_POSIX_READER_WRITER_LOCKS		200112L
#define	_POSIX_SPAWN				200112L
#define	_POSIX_SPIN_LOCKS			200112L
#define	_POSIX_TIMEOUTS				200112L

/*
 * Support for the POSIX.1 mutex protocol attribute. For realtime applications
 * which need mutexes to support priority inheritance/ceiling.
 */
#if defined(_XPG6)
#define	_POSIX_THREAD_PRIO_INHERIT		200112L
#define	_POSIX_THREAD_PRIO_PROTECT		200112L
#else
#define	_POSIX_THREAD_PRIO_INHERIT		1
#define	_POSIX_THREAD_PRIO_PROTECT		1
#endif

#ifndef _POSIX_VDISABLE
#define	_POSIX_VDISABLE		0
#endif

#define	STDIN_FILENO	0
#define	STDOUT_FILENO	1
#define	STDERR_FILENO	2

/*
 * Large File Summit-related announcement macros.  The system supports both
 * the additional and transitional Large File Summit interfaces.  (The final
 * two macros provide a finer granularity breakdown of _LFS64_LARGEFILE.)
 */
#define	_LFS_LARGEFILE		1
#define	_LFS64_LARGEFILE	1
#define	_LFS64_STDIO		1
#define	_LFS64_ASYNCHRONOUS_IO	1

/* large file compilation environment setup */
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	ftruncate	ftruncate64
#pragma redefine_extname	lseek		lseek64
#pragma redefine_extname	pread		pread64
#pragma redefine_extname	pwrite		pwrite64
#pragma redefine_extname	truncate	truncate64
#pragma redefine_extname	lockf		lockf64
#pragma	redefine_extname	tell		tell64
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	ftruncate			ftruncate64
#define	lseek				lseek64
#define	pread				pread64
#define	pwrite				pwrite64
#define	truncate			truncate64
#define	lockf				lockf64
#define	tell				tell64
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */

/* In the LP64 compilation environment, the APIs are already large file */
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname	ftruncate64	ftruncate
#pragma redefine_extname	lseek64		lseek
#pragma redefine_extname	pread64		pread
#pragma redefine_extname	pwrite64	pwrite
#pragma redefine_extname	truncate64	truncate
#pragma redefine_extname	lockf64		lockf
#pragma redefine_extname	tell64		tell
#else	/* __PRAGMA_REDEFINE_EXTNAME */
#define	ftruncate64			ftruncate
#define	lseek64				lseek
#define	pread64				pread
#define	pwrite64			pwrite
#define	truncate64			truncate
#define	lockf64				lockf
#define	tell64				tell
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* _LP64 && _LARGEFILE64_SOURCE */

extern int access(const char *, int);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int acct(const char *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
extern unsigned alarm(unsigned);
/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
	defined(__EXTENSIONS__)
extern int brk(void *);
#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
extern int chdir(const char *);
extern int chown(const char *, uid_t, gid_t);
/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && \
	!defined(_XPG6)) || defined(__EXTENSIONS__)
extern int chroot(const char *);
#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE))... */
extern int close(int);
#if defined(_XPG4) || defined(__EXTENSIONS__)
extern size_t confstr(int, char *, size_t);
extern char *crypt(const char *, const char *);
#endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
	defined(__EXTENSIONS__)
extern char *ctermid(char *);
#endif /* (!defined(_POSIX_C_SOURCE) ... */
#if !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) || defined(__EXTENSIONS__)
extern char *ctermid_r(char *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) ... */
/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern char *cuserid(char *);
#endif
extern int dup(int);
extern int dup2(int, int);
extern int dup3(int, int, int);
#if defined(_XPG4) || defined(__EXTENSIONS__)
extern void encrypt(char *, int);
#endif /* defined(XPG4) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void endusershell(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
extern int execl(const char *, const char *, ...);
extern int execle(const char *, const char *, ...);
extern int execlp(const char *, const char *, ...);
extern int execv(const char *, char *const *);
extern int execve(const char *, char *const *, char *const *);
extern int execvp(const char *, char *const *);
#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
extern int fexecve(int, char *const[], char *const[]);
#endif
#if !defined(_STRICT_SYMBOLS)
extern int execvpe(const char *, char *const [], char *const []);
extern int syncfs(int);
#endif	/* !_STRICT_SYMBOLS */
extern void _exit(int)
	__NORETURN;
/*
 * The following fattach prototype is duplicated in <stropts.h>. The
 * duplication is necessitated by XPG4.2 which requires the prototype
 * be defined in <stropts.h>.
 */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int fattach(int, const char *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int fchdir(int);
extern int fchown(int, uid_t, gid_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int fchroot(int);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
	defined(__EXTENSIONS__)
extern int fdatasync(int);
#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
/*
 * The following fdetach prototype is duplicated in <stropts.h>. The
 * duplication is necessitated by XPG4.2 which requires the prototype
 * be defined in <stropts.h>.
 */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int fdetach(const char *);
#endif /* !defined(__XOPEN_OR_POSIX)... */
extern pid_t fork(void);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern pid_t fork1(void);
extern pid_t forkall(void);
#endif /* !defined(__XOPEN_OR_POSIX)... */
extern long fpathconf(int, int);
#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
	defined(__EXTENSIONS__)
extern int fsync(int);
#endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
#if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern int ftruncate(int, off_t);
#endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
extern char *getcwd(char *, size_t);
#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
	defined(__EXTENSIONS__)
extern int getdtablesize(void);
#endif
extern gid_t getegid(void);
extern uid_t geteuid(void);
extern gid_t getgid(void);
extern int getgroups(int, gid_t *);
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern long gethostid(void);
#endif
#if defined(_XPG4_2)
extern int gethostname(char *, size_t);
#elif  !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int gethostname(char *, int);
#endif

#ifndef	__GETLOGIN_DEFINED	/* Avoid duplicate in stdlib.h */
#define	__GETLOGIN_DEFINED
#ifndef	__USE_LEGACY_LOGNAME__
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname getlogin getloginx
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern char *getloginx(void);
#define	getlogin	getloginx
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* __USE_LEGACY_LOGNAME__ */
extern char *getlogin(void);
#endif	/* __GETLOGIN_DEFINED */

#if defined(_XPG4) || defined(__EXTENSIONS__)
extern int  getopt(int, char *const *, const char *);
extern char *optarg;
extern int  opterr, optind, optopt;
/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern char *getpass(const char *);
#endif
#endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
/* Marked as LEGACY in SUSv2 and removed in SUSv3 */
#if !defined(_XPG6) || defined(__EXTENSIONS__)
extern int getpagesize(void);
#endif
extern pid_t getpgid(pid_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
extern pid_t getpid(void);
extern pid_t getppid(void);
extern pid_t getpgrp(void);

#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
char *gettxt(const char *, const char *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern pid_t getsid(pid_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
extern uid_t getuid(void);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern char *getusershell(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
/*
 * The following ioctl prototype is duplicated in <stropts.h>. The
 * duplication is necessitated by XPG4.2 which requires the prototype
 * be defined in <stropts.h>.  ioctl() is also duplicated in <sys/ioctl.h>
 * for broader portability aid.
 */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int ioctl(int, int, ...);
extern int isaexec(const char *, char *const *, char *const *);
extern int issetugid(void);
#endif
extern int isatty(int);
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int lchown(const char *, uid_t, gid_t);
#endif
extern int link(const char *, const char *);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern offset_t llseek(int, offset_t, int);
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern int lockf(int, int, off_t);
#endif
extern off_t lseek(int, off_t, int);
#if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
	defined(__EXTENSIONS__)
extern int nice(int);
#endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int mincore(caddr_t, size_t, char *);
#endif
extern long pathconf(const char *, int);
extern int pause(void);
extern int pipe(int *);
extern int pipe2(int *, int);
#if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern ssize_t pread(int, void *, size_t, off_t);
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void profil(unsigned short *, size_t, unsigned long, unsigned int);
#endif
/*
 * pthread_atfork() is also declared in <pthread.h> as per SUSv3. The
 * declarations are identical. A change to either one may also require
 * appropriate namespace updates in order to avoid redeclaration
 * warnings in the case where both prototypes are exposed via inclusion
 * of both <pthread.h> and <unistd.h>.
 */
#if !defined(__XOPEN_OR_POSIX) || \
	((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \
	defined(__EXTENSIONS__)
extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void));
#endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ... */
#if !defined(_LP64) && \
	(!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__))
extern int ptrace(int, pid_t, int, int);
#endif
#if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern ssize_t pwrite(int, const void *, size_t, off_t);
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/* per RFC 3542; This is also defined in netdb.h */
extern int rcmd_af(char **, unsigned short, const char *, const char *,
	const char *, int *, int);
#endif
extern ssize_t read(int, void *, size_t);
#if !defined(__XOPEN_OR_POSIX) || \
	defined(_XPG4_2) || defined(__EXTENSIONS__)
extern ssize_t readlink(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD,
	size_t);
#endif
#if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \
	defined(__EXTENSIONS__)
#if __cplusplus >= 199711L
namespace std {
#endif
extern int rename(const char *, const char *);
#if __cplusplus >= 199711L
} /* end of namespace std */

using std::rename;
#endif /* __cplusplus >= 199711L */
#endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int resolvepath(const char *, char *, size_t);
/* per RFC 3542; This is also defined in netdb.h */
extern int rexec_af(char **, unsigned short, const char *, const char *,
	const char *, int *, int);
#endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
extern int rmdir(const char *);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/* per RFC 3542; This is also defined in netdb.h */
extern int rresvport_af(int *, int);
#endif

#if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
	defined(__EXTENSIONS__)
extern void *sbrk(intptr_t);
#endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
extern int setegid(gid_t);
extern int seteuid(uid_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
extern int setgid(gid_t);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int setgroups(int, const gid_t *);
extern int sethostname(char *, int);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
extern int setpgid(pid_t, pid_t);
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern pid_t setpgrp(void);
extern int setregid(gid_t, gid_t);
extern int setreuid(uid_t, uid_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
extern pid_t setsid(void);
extern int setuid(uid_t);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void setusershell(void);
#endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
extern unsigned sleep(unsigned);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int stime(const time_t *);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#if defined(_XPG4)
/* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */
extern void swab(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, ssize_t);
#endif /* defined(_XPG4) */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int symlink(const char *, const char *);
extern void sync(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */
#if defined(_XPG5) && !defined(_XPG6)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname sysconf __sysconf_xpg5
#else /* __PRAGMA_REDEFINE_EXTNAME */
#define	sysconf __sysconf_xpg5
#endif  /* __PRAGMA_REDEFINE_EXTNAME */
#endif /* defined(_XPG5) && !defined(_XPG6) */
extern long sysconf(int);
extern pid_t tcgetpgrp(int);
extern int tcsetpgrp(int, pid_t);
#if !defined(__XOPEN_OR_POSIX) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern off_t tell(int);
#endif /* !defined(__XOPEN_OR_POSIX)... */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
	defined(__EXTENSIONS__)
extern int truncate(const char *, off_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
extern char *ttyname(int);
#if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS)
extern useconds_t ualarm(useconds_t, useconds_t);
#endif
extern int unlink(const char *);
#if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS)
extern char *getwd(char *);
extern int usleep(useconds_t);
extern pid_t vfork(void) __RETURNS_TWICE;
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void vhangup(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
extern ssize_t write(int, const void *, size_t);
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void yield(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

#if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \
	defined(__EXTENSIONS__)
	/* || defined(_XPG7) */
extern int faccessat(int, const char *, int, int);
extern int fchownat(int, const char *, uid_t, gid_t, int);
extern int linkat(int, const char *, int, const char *, int);
extern ssize_t readlinkat(int, const char *_RESTRICT_KYWD,
	char *_RESTRICT_KYWD, size_t);
extern int renameat(int, const char *, int, const char *);
extern int symlinkat(const char *, int, const char *);
extern int unlinkat(int, const char *, int);
#endif	/* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern int get_nprocs(void);
extern int get_nprocs_conf(void);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */

/* transitional large file interface versions */
#if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
	    !defined(__PRAGMA_REDEFINE_EXTNAME))
extern int ftruncate64(int, off64_t);
extern off64_t lseek64(int, off64_t, int);
extern ssize_t	pread64(int, void *, size_t, off64_t);
extern ssize_t	pwrite64(int, const void *, size_t, off64_t);
extern off64_t	tell64(int);
extern int	truncate64(const char *, off64_t);
extern int	lockf64(int, int, off64_t);
#endif	/* _LARGEFILE64_SOURCE */

/*
 * getlogin_r() & ttyname_r() prototypes are defined here.
 */

/*
 * Previous releases of Solaris, starting at 2.3, provided definitions of
 * various functions as specified in POSIX.1c, Draft 6.  For some of these
 * functions, the final POSIX 1003.1c standard had a different number of
 * arguments and return values.
 *
 * The following segment of this header provides support for the standard
 * interfaces while supporting applications written under earlier
 * releases.  The application defines appropriate values of the feature
 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
 * whether it was written to expect the Draft 6 or standard versions of
 * these interfaces, before including this header.  This header then
 * provides a mapping from the source version of the interface to an
 * appropriate binary interface.  Such mappings permit an application
 * to be built from libraries and objects which have mixed expectations
 * of the definitions of these functions.
 *
 * For applications using the Draft 6 definitions, the binary symbol is the
 * same as the source symbol, and no explicit mapping is needed.  For the
 * standard interface, the function func() is mapped to the binary symbol
 * _posix_func().  The preferred mechanism for the remapping is a compiler
 * #pragma.  If the compiler does not provide such a #pragma, the header file
 * defines a static function func() which calls the _posix_func() version;
 * this has to be done instead of #define since POSIX specifies that an
 * application can #undef the symbol and still be bound to the correct
 * implementation.  Unfortunately, the statics confuse lint so we fallback to
 * #define in that case.
 *
 * NOTE: Support for the Draft 6 definitions is provided for compatibility
 * only.  New applications/libraries should use the standard definitions.
 */

#if	defined(__EXTENSIONS__) || defined(_REENTRANT) || \
	!defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
	defined(_POSIX_PTHREAD_SEMANTICS)

#if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)

#ifndef	__USE_LEGACY_LOGNAME__
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname getlogin_r __posix_getloginx_r
extern int getlogin_r(char *, int);
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern int __posix_getloginx_r(char *, int);
#define	getlogin_r	__posix_getloginx_r
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#else	/* __USE_LEGACY_LOGNAME__ */
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname getlogin_r __posix_getlogin_r
extern int getlogin_r(char *, int);
#else  /* __PRAGMA_REDEFINE_EXTNAME */
extern int __posix_getlogin_r(char *, int);

#ifdef __lint

#define	getlogin_r	__posix_getlogin_r

#else /* !__lint */

static int
getlogin_r(char *__name, int __len)
{
	return (__posix_getlogin_r(__name, __len));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* __USE_LEGACY_LOGNAME__ */

#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname ttyname_r __posix_ttyname_r
extern int ttyname_r(int, char *, size_t);
#else  /* __PRAGMA_REDEFINE_EXTNAME */
extern int __posix_ttyname_r(int, char *, size_t);

#ifdef __lint

#define	ttyname_r	__posix_ttyname_r

#else /* !__lint */

static int
ttyname_r(int __fildes, char *__buf, size_t __size)
{
	return (__posix_ttyname_r(__fildes, __buf, __size));
}

#endif /* !__lint */
#endif /* __PRAGMA_REDEFINE_EXTNAME */

#else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#ifndef	__USE_LEGACY_LOGNAME__
#ifdef	__PRAGMA_REDEFINE_EXTNAME
#pragma	redefine_extname getlogin_r getloginx_r
#else	/* __PRAGMA_REDEFINE_EXTNAME */
extern char *getloginx_r(char *, int);
#define	getlogin_r	getloginx_r
#endif	/* __PRAGMA_REDEFINE_EXTNAME */
#endif	/* __USE_LEGACY_LOGNAME__ */
extern char *getlogin_r(char *, int);

extern char *ttyname_r(int, char *, int);

#endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */

#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */

#if !defined(_STRICT_SYMBOLS)
extern int getentropy(void *, size_t);
#endif	/* !_STRICT_SYMBOLS */

#ifdef	__cplusplus
}
#endif

#endif /* _UNISTD_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2020 Oxide Computer Company
 */

#ifndef _UPANIC_H
#define	_UPANIC_H

/*
 * Support for guaranteed user process abort-like termination.
 */

#include <sys/feature_tests.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

extern _NORETURN_KYWD void upanic(const char *, size_t) __NORETURN;

#ifdef __cplusplus
}
#endif

#endif /* _UPANIC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
 */

#ifndef	_USER_ATTR_H
#define	_USER_ATTR_H

#ifdef	__cplusplus
extern "C" {
#endif


#include <sys/types.h>
#include <secdb.h>


struct __FILE;		/* structure tag for type FILE defined in stdio.h */

/*
 * Some macros used internally by the nsswitch code
 */
#define	USERATTR_FILENAME		"/etc/user_attr"
#define	USERATTR_DB_NAME		"user_attr.org_dir"
#define	USERATTR_DB_NCOL		5	/* total columns */
#define	USERATTR_DB_NKEYCOL		2	/* total searchable columns */
#define	USERATTR_DB_TBL			"user_attr_tbl"
#define	USERATTR_NAME_DEFAULT_KW	"nobody"

#define	USERATTR_COL0_KW		"name"
#define	USERATTR_COL1_KW		"qualifier"
#define	USERATTR_COL2_KW		"res1"
#define	USERATTR_COL3_KW		"res2"
#define	USERATTR_COL4_KW		"attr"

#define	DEF_LIMITPRIV			"PRIV_LIMIT="
#define	DEF_DFLTPRIV			"PRIV_DEFAULT="

/*
 * indices of searchable columns
 */
#define	USERATTR_KEYCOL0		0	/* name */
#define	USERATTR_KEYCOL1		1	/* qualifier */

/*
 * Key words used in the user_attr database
 */
#define	USERATTR_LOCK_KW		"lock"
#define	USERATTR_LOCK_LOCKED_KW		"locked"
#define	USERATTR_LOCK_OPEN_KW		"open"
#define	USERATTR_LOCK_FIXED_KW		"fixed"
#define	USERATTR_GEN_KW			"gen"
#define	USERATTR_GEN_AUTOMATIC_KW	"automatic"
#define	USERATTR_GEN_MANUAL_KW		"manual"
#define	USERATTR_GEN_SYSDEF_KW		"sysdef"
#define	USERATTR_PROFILES_KW		"profiles"
#define	USERATTR_PROFILES_NONE_KW	"none"
#define	USERATTR_ROLES_KW		"roles"
#define	USERATTR_ROLES_NONE_KW		"none"
#define	USERATTR_DEFAULTPROJ_KW		"project"
#define	USERATTR_TYPE_KW		"type"
#define	USERATTR_TYPE_NORMAL_KW		"normal"
#define	USERATTR_TYPE_ADMIN_KW		"admin"
#define	USERATTR_TYPE_NONADMIN_KW	"role"
#define	USERATTR_AUTHS_KW		"auths"
#define	USERATTR_LIMPRIV_KW		"limitpriv"
#define	USERATTR_DFLTPRIV_KW		"defaultpriv"
#define	USERATTR_LOCK_AFTER_RETRIES_KW	"lock_after_retries"
#define	USERATTR_CLEARANCE		"clearance"
#define	USERATTR_LABELVIEW		"labelview"
#define	USERATTR_LABELVIEW_EXTERNAL	"external"
#define	USERATTR_LABELVIEW_HIDESL	"hidesl"
#define	USERATTR_HIDESL			USERATTR_LABELVIEW_HIDESL
#define	USERATTR_LABELVIEW_INTERNAL	"internal"
#define	USERATTR_LABELVIEW_SHOWSL	"showsl"
#define	USERATTR_LABELTRANS		"labeltrans"
#define	USERATTR_LOCK_NO		"no"
#define	USERATTR_LOCK_YES		"yes"
#define	USERATTR_MINLABEL		"min_label"
#define	USERATTR_PASSWD			"password"
#define	USERATTR_PASSWD_AUTOMATIC	"automatic"
#define	USERATTR_PASSWD_MANUAL		"manual"
#define	USERATTR_TYPE_ROLE		USERATTR_TYPE_NONADMIN_KW
#define	USERATTR_AUDIT_FLAGS_KW		"audit_flags"
#define	USERATTR_ROLEAUTH_KW		"roleauth"
#define	USERATTR_ROLEAUTH_USER		"user"
#define	USERATTR_ROLEAUTH_ROLE		"role"


/*
 * Nsswitch representation of user attributes.
 */
typedef struct userstr_s {
	char   *name;		/* user name */
	char   *qualifier;	/* reserved for future use */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	char   *attr;		/* string of key-value pair attributes */
} userstr_t;

/*
 * API representation of user attributes.
 */
typedef struct userattr_s {
	char   *name;		/* user name */
	char   *qualifier;	/* reserved for future use */
	char   *res1;		/* reserved for future use */
	char   *res2;		/* reserved for future use */
	kva_t  *attr;		/* array of key-value pair attributes */
} userattr_t;

extern userattr_t *getusernam(const char *);
extern userattr_t *getuseruid(uid_t uid);
extern userattr_t *getuserattr(void);
extern userattr_t *fgetuserattr(struct __FILE *);
extern void setuserattr(void);
extern void enduserattr(void);
extern void free_userattr(userattr_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _USER_ATTR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
 */

#ifndef	_USERDEFS_H
#define	_USERDEFS_H

#include <project.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The definitions in this file are local to the OA&M subsystem.  General
 * use is not encouraged.
 */

/* User/group default values */
#define	DEFGID		99	/* max reserved group id */
#define	DEFRID		99
#define	DEFPROJ		3
#define	DEFPROJNAME	"default"
#define	DEFGROUP	1
#define	DEFGNAME	"other"
#define	DEFPARENT	"/home"
#define	DEFSKL		"/etc/skel"
#define	DEFSHL		"/bin/sh"
#define	DEFROLESHL	"/bin/pfsh"
#define	DEFINACT	0
#define	DEFEXPIRE	""
#define	DEFAUTH		""
#define	DEFPROF		""
#define	DEFROLEPROF	"All"
#define	DEFROLE		""
#define	DEFLIMPRIV	""
#define	DEFDFLTPRIV	""
#define	DEFLOCK_AFTER_RETRIES	""
#define	DEFROLEAUTH	""
#define	DEFROLEROLEAUTH	"role"

/* Defaults file keywords */
#define	RIDSTR		"defrid="
#define	GIDSTR		"defgroup="
#define	GNAMSTR		"defgname="
#define	PARSTR		"defparent="
#define	SKLSTR		"defskel="
#define	SHELLSTR	"defshell="
#define	INACTSTR	"definact="
#define	EXPIRESTR	"defexpire="
#define	AUTHSTR		"defauthorization="
#define	PROFSTR		"defprofile="
#define	ROLESTR		"defrole="
#define	PROJSTR		"defproj="
#define	PROJNMSTR	"defprojname="
#define	LIMPRSTR	"deflimitpriv="
#define	DFLTPRSTR	"defdefaultpriv="
#define	FHEADER		"#	Default values for useradd.  Changed "
#define	FHEADER_ROLE	"#	Default values for roleadd.  Changed "
#define	LOCK_AFTER_RETRIESSTR	"deflock_after_retries="
#define	ROLEAUTHSTR	"defroleauth="

/* Defaults file */
#define	DEFFILE		"/usr/sadm/defadduser"
#define	DEFROLEFILE	"/usr/sadm/defaddrole"
#define	GROUP		"/etc/group"

/* various limits */
#define	MAXGLEN		9	/* max length of group name */
#define	MAXDLEN		80	/* max length of a date string */

/* defaults structure */
struct userdefs {
	int defrid;		/* highest reserved uid */
	int defgroup;		/* default group id */
	char *defgname;		/* default group name */
	char *defparent;	/* default base directory for new logins */
	char *defskel;		/* default skel directory */
	char *defshell;		/* default shell */
	int definact;		/* default inactive */
	char *defexpire;		/* default expire date */
	char *defauth;		/* default authorization */
	char *defprof;		/* default profile */
	char *defrole;		/* default role */
	projid_t defproj;	/* default project id */
	char *defprojname;	/* default project name */
	char *deflimpriv;	/* default limitpriv */
	char *defdfltpriv;	/* default defaultpriv */
	char *deflock_after_retries;	/* default lock_after_retries */
	char *defroleauth;		/* default roleauth */

};

/* exit() values for user/group commands */

/* Everything succeeded */
#define	EX_SUCCESS	0

/* No permission */
#define	EX_NO_PERM	1

/* Command syntax error */
#define	EX_SYNTAX	2

/* Invalid argument given */
#define	EX_BADARG	3

/* A gid or uid already exists */
#define	EX_ID_EXISTS	4

/* PASSWD and SHADOW are inconsistent with each other */
#define	EX_INCONSISTENT	5

/* A group or user name  doesn't exist */
#define	EX_NAME_NOT_EXIST	6

/* GROUP, PASSWD, or SHADOW file missing */
#define	EX_MISSING	7

/* GROUP, PASSWD, or SHAWOW file is busy */
#define	EX_BUSY	8

/* A group or user name already exists */
#define	EX_NAME_EXISTS	9

/* Unable to update GROUP, PASSWD, or SHADOW file */
#define	EX_UPDATE	10

/* Not enough space */
#define	EX_NOSPACE	11

/* Unable to create/remove/move home directory */
#define	EX_HOMEDIR	12

/* new login already in use */
#define	EX_NL_USED	13

/* Unexpected failure */
#define	EX_FAILURE	14

/* A user name is in a non-local name service */
#define	EX_NOT_LOCAL	15

#ifdef	__cplusplus
}
#endif

#endif	/* _USERDEFS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _USTAT_H
#define	_USTAT_H

#include <sys/types.h>
#include <sys/ustat.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern int ustat(dev_t, struct ustat *);

#ifdef	__cplusplus
}
#endif

#endif	/* _USTAT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/* utimbuf is used by utime(2) */

#ifndef _UTIME_H
#define	_UTIME_H

#include <sys/utime.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern int utime(const char *, const struct utimbuf *);

#ifdef	__cplusplus
}
#endif

#endif	/* _UTIME_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */


#ifndef _UTMP_H
#define	_UTMP_H

/*
 * Note:  The getutent(3c) family of interfaces are obsolete.
 * The getutxent(3c) family provide a superset of this functionality
 * and should be used in place of getutent(3c).
 */

#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	UTMP_FILE	"/var/adm/utmp"
#define	WTMP_FILE	"/var/adm/wtmp"
#endif

#define	ut_name	ut_user

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
struct exit_status {
	short e_termination;	/* Process termination status */
	short e_exit;		/* Process exit status */
};
#else
struct ut_exit_status {
	short ut_e_termination;	/* Process termination status */
	short ut_e_exit;	/* Process exit status */
};
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)

/*
 * This data structure describes the utmp entries returned by
 * the getutent(3c) family of APIs.  It does not (necessarily)
 * correspond to the contents of the utmp or wtmp files.
 *
 * Applications should only interact with this subsystem via
 * the getutxent(3c) family of APIs, as the getutent(3c) family
 * are obsolete.
 */
struct utmp {
	char ut_user[8];		/* User login name */
	char ut_id[4];			/* /etc/inittab id(usually line #) */
	char ut_line[12];		/* device name (console, lnxx) */
	short ut_pid;			/* short for compat. - process id */
	short ut_type;			/* type of entry */
	struct exit_status ut_exit;	/* The exit status of a process */
					/* marked as DEAD_PROCESS. */
	time_t ut_time;			/* time entry was made */
};

#include <sys/types32.h>
#include <inttypes.h>

/*
 * This data structure describes the utmp *file* contents using
 * fixed-width data types.  It should only be used by the implementation.
 *
 * Applications should use the getutxent(3c) family of routines to interact
 * with this database.
 */

struct futmp {
	char ut_user[8];		/* User login name */
	char ut_id[4];			/* /etc/inittab id */
	char ut_line[12];		/* device name (console, lnxx) */
	int16_t ut_pid;			/* process id */
	int16_t ut_type;		/* type of entry */
	struct {
		int16_t	e_termination;	/* Process termination status */
		int16_t e_exit;		/* Process exit status */
	} ut_exit;			/* The exit status of a process */
	time32_t ut_time;		/* time entry was made */
};

#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

/*	Definitions for ut_type						*/

#define	EMPTY		0
#define	RUN_LVL		1
#define	BOOT_TIME	2
#define	OLD_TIME	3
#define	NEW_TIME	4
#define	INIT_PROCESS	5	/* Process spawned by "init" */
#define	LOGIN_PROCESS	6	/* A "getty" process waiting for login */
#define	USER_PROCESS	7	/* A user process */
#define	DEAD_PROCESS	8

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)

#define	ACCOUNTING	9
#define	DOWN_TIME	10

#define	UTMAXTYPE	DOWN_TIME	/* Largest legal value of ut_type */

/*	Special strings or formats used in the "ut_line" field when	*/
/*	accounting for something other than a process.			*/
/*	No string for the ut_line field can be more than 11 chars +	*/
/*	a NULL in length.						*/

#define	RUNLVL_MSG	"run-level %c"
#define	BOOT_MSG	"system boot"
#define	OTIME_MSG	"old time"
#define	NTIME_MSG	"new time"
#define	PSRADM_MSG	"%03d  %s"	/* processor on or off */
#define	DOWN_MSG	"system down"

/*	Define and macro for determing if a normal user wrote the entry */
/*	 and marking the utmpx entry as a normal user */
#define	NONROOT_USR	2
#define	nonuser(ut)	((ut).ut_exit.e_exit == NONROOT_USR ? 1 : 0)
#define	setuser(ut)	((ut).ut_exit.e_exit = NONROOT_USR)


extern void endutent(void);
extern struct utmp *getutent(void);
extern struct utmp *getutid(const struct utmp *);
extern struct utmp *getutline(const struct utmp *);
extern struct utmp *pututline(const struct utmp *);
extern void setutent(void);
extern int utmpname(const char *);

#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _UTMP_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _UTMPX_H
#define	_UTMPX_H

#include <sys/feature_tests.h>
#include <sys/types.h>
#include <sys/time.h>
#include <utmp.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define	_UTMPX_FILE	"/var/adm/utmpx"
#define	_WTMPX_FILE	"/var/adm/wtmpx"
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
#define	UTMPX_FILE	_UTMPX_FILE
#define	WTMPX_FILE	_WTMPX_FILE
#endif

#define	ut_name	ut_user
#define	ut_xtime ut_tv.tv_sec

/*
 * This data structure describes the utmpx entries returned by
 * the getutxent(3c) family of APIs.  It does not (necessarily)
 * correspond to the contents of the utmpx or wtmpx files.
 *
 * Applications should only interact with this subsystem via
 * the getutxent(3c) family of APIs.
 */
struct utmpx {
	char	ut_user[32];		/* user login name */
	char	ut_id[4];		/* inittab id */
	char	ut_line[32];		/* device name (console, lnxx) */
	pid_t	ut_pid;			/* process id */
	short	ut_type;		/* type of entry */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
	struct exit_status ut_exit;	/* process termination/exit status */
#else
	struct ut_exit_status ut_exit;	/* process termination/exit status */
#endif
	struct timeval ut_tv;		/* time entry was made */
	int	ut_session;		/* session ID, used for windowing */
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
	int	pad[5];			/* reserved for future use */
#else
	int	__pad[5];		/* reserved for future use */
#endif
	short	ut_syslen;		/* significant length of ut_host */
					/*   including terminating null */
	char	ut_host[257];		/* remote host name */
};

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)

#include <sys/types32.h>
#include <inttypes.h>

/*
 * This data structure describes the utmp *file* contents using
 * fixed-width data types.  It should only be used by the implementation.
 *
 * Applications should use the getutxent(3c) family of routines to interact
 * with this database.
 */

struct futmpx {
	char	ut_user[32];		/* user login name */
	char	ut_id[4];		/* inittab id */
	char	ut_line[32];		/* device name (console, lnxx) */
	pid32_t	ut_pid;			/* process id */
	int16_t ut_type;		/* type of entry */
	struct {
		int16_t	e_termination;	/* process termination status */
		int16_t	e_exit;		/* process exit status */
	} ut_exit;			/* exit status of a process */
	struct timeval32 ut_tv;		/* time entry was made */
	int32_t	ut_session;		/* session ID, user for windowing */
	int32_t	pad[5];			/* reserved for future use */
	int16_t ut_syslen;		/* significant length of ut_host */
	char	ut_host[257];		/* remote host name */
};

#define	MOD_WIN		10

/*	Define and macro for determing if a normal user wrote the entry */
/*	and marking the utmpx entry as a normal user */
#define	NONROOT_USRX	2
#define	nonuserx(utx)	((utx).ut_exit.e_exit == NONROOT_USRX ? 1 : 0)
#define	setuserx(utx)	((utx).ut_exit.e_exit = NONROOT_USRX)

#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

extern void endutxent(void);
extern struct utmpx *getutxent(void);
extern struct utmpx *getutxid(const struct utmpx *);
extern struct utmpx *getutxline(const struct utmpx *);
extern struct utmpx *pututxline(const struct utmpx *);
extern void setutxent(void);

#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
extern int utmpxname(const char *);
extern struct utmpx *makeutx(const struct utmpx *);
extern struct utmpx *modutx(const struct utmpx *);
extern void getutmp(const struct utmpx *, struct utmp *);
extern void getutmpx(const struct utmp *, struct utmpx *);
extern void updwtmp(const char *, struct utmp *);
extern void updwtmpx(const char *, struct utmpx *);
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */

#ifdef	__cplusplus
}
#endif

#endif	/* _UTMPX_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 2014 Andrew Stormont.
 */

#ifndef	_UUID_H
#define	_UUID_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The copyright in this file is taken from the original Leach & Salz
 * UUID specification, from which this implementation is derived.
 */

/*
 * Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
 * Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
 * Digital Equipment Corporation, Maynard, Mass.  Copyright (c) 1998
 * Microsoft.  To anyone who acknowledges that this file is provided
 * "AS IS" without any express or implied warranty: permission to use,
 * copy, modify, and distribute this file for any purpose is hereby
 * granted without fee, provided that the above copyright notices and
 * this notice appears in all source code copies, and that none of the
 * names of Open Software Foundation, Inc., Hewlett-Packard Company,
 * or Digital Equipment Corporation be used in advertising or
 * publicity pertaining to distribution of the software without
 * specific, written prior permission.  Neither Open Software
 * Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
 * Equipment Corporation makes any representations about the
 * suitability of this software for any purpose.
 */

#include <sys/types.h>
#include <sys/uuid.h>

extern void uuid_generate(uuid_t);
extern void uuid_generate_random(uuid_t);
extern void uuid_generate_time(uuid_t);
extern void uuid_copy(uuid_t, uuid_t);
extern void uuid_clear(uuid_t);
extern void uuid_unparse(uuid_t, char *);
extern void uuid_unparse_lower(uuid_t, char *);
extern void uuid_unparse_upper(uuid_t, char *);
extern int uuid_compare(uuid_t, uuid_t);
extern int uuid_is_null(uuid_t);
extern int uuid_parse(char *, uuid_t);
extern time_t uuid_time(uuid_t, struct timeval *);

#ifdef __cplusplus
}
#endif

#endif /* _UUID_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef	_VALTOOLS_H
#define	_VALTOOLS_H

#ifdef	__cplusplus
extern "C" {
#endif

struct _choice_ {
	char *token;
	char *text;
	struct _choice_ *next;
};

struct _menu_ {
	char	*label;
	int	attr;
	short	longest;
	short	nchoices;
	struct _choice_
		*choice;
	char	**invis;
};

typedef struct _menu_ CKMENU;

#define	P_ABSOLUTE	0x0001
#define	P_RELATIVE	0x0002
#define	P_EXIST		0x0004
#define	P_NEXIST	0x0008
#define	P_REG		0x0010
#define	P_DIR		0x0020
#define	P_BLK		0x0040
#define	P_CHR		0x0080
#define	P_NONZERO	0x0100
#define	P_READ		0x0200
#define	P_WRITE		0x0400
#define	P_EXEC		0x0800
#define	P_CREAT		0x1000

#define	CKUNNUM		0x01
#define	CKALPHA		0x02
#define	CKONEFLAG	0x04

#ifdef	__cplusplus
}
#endif

#endif	/* _VALTOOLS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_VALUES_H
#define	_VALUES_H

#include <sys/isa_defs.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * These values work with any binary representation of integers
 * where the high-order bit contains the sign.
 */

/* a number used normally for size of a shift */
#define	BITSPERBYTE	8

#define	BITS(type)	(BITSPERBYTE * (long)sizeof (type))

/* short, regular and long ints with only the high-order bit turned on */
#define	HIBITS	((short)(1 << (BITS(short) - 1)))

#define	HIBITI	(1U << (BITS(int) - 1))
#define	HIBITL	(1UL << (BITS(long) - 1))

/* largest short, regular and long int */
#define	MAXSHORT	((short)~HIBITS)
#define	MAXINT		((int)(~HIBITI))
#define	MAXLONG		((long)(~HIBITL))

/*
 * various values that describe the binary floating-point representation
 * _EXPBASE	- the exponent base
 * DMAXEXP	- the maximum exponent of a double (as returned by frexp())
 * FMAXEXP	- the maximum exponent of a float  (as returned by frexp())
 * DMINEXP	- the minimum exponent of a double (as returned by frexp())
 * FMINEXP	- the minimum exponent of a float  (as returned by frexp())
 * MAXDOUBLE	- the largest double
 *			((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
 * MAXFLOAT	- the largest float
 *			((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
 * MINDOUBLE	- the smallest double (_EXPBASE ** (DMINEXP - 1))
 * MINFLOAT	- the smallest float (_EXPBASE ** (FMINEXP - 1))
 * DSIGNIF	- the number of significant bits in a double
 * FSIGNIF	- the number of significant bits in a float
 * DMAXPOWTWO	- the largest power of two exactly representable as a double
 * FMAXPOWTWO	- the largest power of two exactly representable as a float
 * _IEEE	- 1 if IEEE standard representation is used
 * _DEXPLEN	- the number of bits for the exponent of a double
 * _FEXPLEN	- the number of bits for the exponent of a float
 * _HIDDENBIT	- 1 if high-significance bit of mantissa is implicit
 * LN_MAXDOUBLE	- the natural log of the largest double  -- log(MAXDOUBLE)
 * LN_MINDOUBLE	- the natural log of the smallest double -- log(MINDOUBLE)
 * LN_MAXFLOAT	- the natural log of the largest float  -- log(MAXFLOAT)
 * LN_MINFLOAT	- the natural log of the smallest float -- log(MINFLOAT)
 */

/*
 * Currently, only IEEE-754 format is supported.
 */
#if defined(_IEEE_754)
#define	MAXDOUBLE	1.79769313486231570e+308
#define	MAXFLOAT	((float)3.40282346638528860e+38)
#define	MINDOUBLE	4.94065645841246544e-324
#define	MINFLOAT	((float)1.40129846432481707e-45)
#define	_IEEE		1
#define	_DEXPLEN	11
#define	_HIDDENBIT	1
#define	_LENBASE	1
#define	DMINEXP	(-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
#define	FMINEXP	(-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
#else
/* #error is strictly ansi-C, but works as well as anything for K&R systems. */
#error "ISA not supported"
#endif

#define	_EXPBASE	(1 << _LENBASE)
#define	_FEXPLEN	8
#define	DSIGNIF	(BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
#define	FSIGNIF	(BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
#define	DMAXPOWTWO	((double)(1 << (BITS(int) - 2)) * \
				(1 << (DSIGNIF - BITS(int) + 1)))
#define	FMAXPOWTWO	((float)(1 << (FSIGNIF - 1)))
#define	DMAXEXP	((1 << (_DEXPLEN - 1)) - 1 + _IEEE)
#define	FMAXEXP	((1 << (_FEXPLEN - 1)) - 1 + _IEEE)
#define	LN_MAXDOUBLE	(M_LN2 * DMAXEXP)
#define	LN_MAXFLOAT	(float)(M_LN2 * FMAXEXP)
#define	LN_MINDOUBLE	(M_LN2 * (DMINEXP - 1))
#define	LN_MINFLOAT	(float)(M_LN2 * (FMINEXP - 1))
#define	H_PREC	(DSIGNIF % 2 ? (1 << DSIGNIF/2) * M_SQRT2 : 1 << DSIGNIF/2)
#define	FH_PREC \
	(float)(FSIGNIF % 2 ? (1 << FSIGNIF/2) * M_SQRT2 : 1 << FSIGNIF/2)
#define	X_EPS	(1.0/H_PREC)
#define	FX_EPS	(float)((float)1.0/FH_PREC)
#define	X_PLOSS	((double)(int)(M_PI * H_PREC))
#define	FX_PLOSS ((float)(int)(M_PI * FH_PREC))
#define	X_TLOSS	(M_PI * DMAXPOWTWO)
#define	FX_TLOSS (float)(M_PI * FMAXPOWTWO)
#define	M_LN2	0.69314718055994530942
#define	M_PI	3.14159265358979323846
#define	M_SQRT2	1.41421356237309504880
#define	MAXBEXP	DMAXEXP /* for backward compatibility */
#define	MINBEXP	DMINEXP /* for backward compatibility */
#define	MAXPOWTWO	DMAXPOWTWO /* for backward compatibility */

#ifdef	__cplusplus
}
#endif

#endif	/* _VALUES_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _VARARGS_H
#define	_VARARGS_H

/*
 * This header defines the pre-standard variable argument definitions.
 * Programs using this header should migrate to using <stdarg.h>.
 *
 * The varargs definitions within this header are defined in terms of
 * implementation definitions. These implementation definitions reside
 * in <sys/va_impl.h>.  This organization enables protected use of
 * the implementation by other standard headers without introducing
 * names into the users' namespace.
 */

#include <sys/feature_tests.h>
#include <sys/va_impl.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	_VA_LIST
#define	_VA_LIST
typedef __va_list va_list;
#endif

#define	va_alist		__builtin_va_alist
#define	va_dcl			__va_alist_type va_alist;
#define	va_start(list)		__va_start(list, va_alist)
#define	va_arg(list, type)	__va_arg(list, type)
#define	va_end(list)		__va_end(list)

/*
 * va_copy is a Solaris extension to provide a portable way to perform
 * a variable argument list ``bookmarking'' function.
 */
#if defined(__EXTENSIONS__) || \
	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))

#define	va_copy(to, from)	__va_copy(to, from)

#endif	/* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) && ... ) */

#ifdef	__cplusplus
}
#endif

#endif	/* _VARARGS_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1988 AT&T	*/
/*	  All Rights Reserved	*/


#ifndef _WAIT_H
#define	_WAIT_H

#include <sys/types.h>
#include <sys/siginfo.h>
#include <sys/procset.h>
#include <sys/wait.h>

#ifdef	__cplusplus
extern "C" {
#endif

extern pid_t wait(int *);
extern pid_t waitpid(pid_t, int *, int);
extern int waitid(idtype_t, id_t, siginfo_t *, int);

#ifdef	__cplusplus
}
#endif

#endif	/* _WAIT_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef	_WCHAR_H
#define	_WCHAR_H

#include <sys/feature_tests.h>
#include <iso/wchar_iso.h>
#include <iso/wchar_c99.h>

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/wchar_iso.h>.
 */
#if __cplusplus >= 199711L
using std::FILE;
using std::wint_t;
using std::clock_t;
using std::size_t;
using std::time_t;
using std::tm;
using std::mbstate_t;
using std::fgetwc;
using std::fgetws;
using std::fputwc;
using std::fputws;
using std::ungetwc;
using std::getwc;
using std::getwchar;
using std::putwc;
using std::putwchar;
using std::wcstod;
using std::wcstol;
using std::wcstoul;
using std::wcscat;
using std::wcschr;
using std::wcscmp;
using std::wcscoll;
using std::wcscpy;
using std::wcscspn;
using std::wcslen;
using std::wcsncat;
using std::wcsncmp;
using std::wcsncpy;
using std::wcspbrk;
using std::wcsrchr;
using std::wcsspn;
using std::wcsxfrm;
using std::wcstok;
using std::wcsftime;
/* not XPG4 and not XPG4v2 */
#if (!defined(_XPG4) && !defined(_XPG4_2) || defined(_XPG5))
using std::btowc;
using std::fwprintf;
using std::fwscanf;
using std::fwide;
using std::mbsinit;
using std::mbrlen;
using std::mbrtowc;
using std::mbsrtowcs;
using std::swprintf;
using std::swscanf;
using std::vfwprintf;
using std::vwprintf;
using std::vswprintf;
using std::wcrtomb;
using std::wcsrtombs;
using std::wcsstr;
using std::wctob;
using std::wmemchr;
using std::wmemcmp;
using std::wmemcpy;
using std::wmemmove;
using std::wmemset;
using std::wprintf;
using std::wscanf;
#endif /* not XPG4 and not XPG4v2 */
#endif /* __cplusplus >= 199711L */

#ifdef	__cplusplus
extern "C" {
#endif

#if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
#if !defined(_WCTYPE_T) || __cplusplus >= 199711L
#define	_WCTYPE_T
typedef	int	wctype_t;
#endif
#endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */

/*
 * XPG6 requires that va_list be defined as defined in <stdarg.h>,
 * however, inclusion of <stdarg.h> breaks Standard C namespace.
 */
#if defined(_XPG6) && !defined(_VA_LIST)
#define	_VA_LIST
typedef __va_list va_list;
#endif  /* defined(_XPG6) && !defined(_VA_LIST) */

#if !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
#if __cplusplus >= 199711L
namespace std {
#endif
extern int iswalpha(wint_t);
extern int iswupper(wint_t);
extern int iswlower(wint_t);
extern int iswdigit(wint_t);
extern int iswxdigit(wint_t);
extern int iswalnum(wint_t);
extern int iswspace(wint_t);
extern int iswpunct(wint_t);
extern int iswprint(wint_t);
extern int iswgraph(wint_t);
extern int iswcntrl(wint_t);
extern int iswctype(wint_t, wctype_t);
extern wint_t towlower(wint_t);
extern wint_t towupper(wint_t);
extern wchar_t *wcswcs(const wchar_t *, const wchar_t *);
extern int wcswidth(const wchar_t *, size_t);
extern int wcwidth(wchar_t);
extern wctype_t wctype(const char *);
#if __cplusplus >= 199711L
} /* namespace std */

using std::iswalpha;
using std::iswupper;
using std::iswlower;
using std::iswdigit;
using std::iswxdigit;
using std::iswalnum;
using std::iswspace;
using std::iswpunct;
using std::iswprint;
using std::iswgraph;
using std::iswcntrl;
using std::iswctype;
using std::towlower;
using std::towupper;
using std::wcswcs;
using std::wcswidth;
using std::wcwidth;
using std::wctype;
#endif
#endif /* !defined(_STRICT_STDC) || defined(_XOPEN_SOURCE)... */

#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)

#ifndef _LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern size_t wcsnlen(const wchar_t *, size_t);
extern wchar_t *wcpcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD);
extern wchar_t *wcpncpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t);
extern size_t wcsxfrm_l(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t, locale_t);
extern int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
extern wchar_t *wcsdup(const wchar_t *);
extern int wcscasecmp(const wchar_t *, const wchar_t *);
extern int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
extern int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
extern int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
extern size_t mbsnrtowcs(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
    size_t, size_t, mbstate_t *_RESTRICT_KYWD);

extern FILE	*open_wmemstream(wchar_t **, size_t *);

#endif	/* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */

#if defined(_XPG8) || !defined(_STRICT_SYMBOLS)
extern size_t wcslcat(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t);
extern size_t wcslcpy(wchar_t *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t);
#endif	/* defined(_XPG8) || !defined(_STRICT_SYMBOLS) */

#ifdef	__cplusplus
}
#endif

#endif	/* _WCHAR_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 1998 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef	_WCHAR_IMPL_H
#define	_WCHAR_IMPL_H

#include <sys/isa_defs.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef	_MBSTATET_H
#define	_MBSTATET_H
typedef struct __mbstate_t {
#if defined(_LP64)
	long	__filler[4];
#else
	int	__filler[6];
#endif
} __mbstate_t;
#endif	/* _MBSTATET_H */

#ifdef	__cplusplus
}
#endif

#endif	/* _WCHAR_IMPL_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	wctype.h	1.13 89/11/02 SMI; JLE	*/
/*	from AT&T JAE 2.1			*/
/*	definitions for international functions	*/

/*
 * Copyright 2015 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_WCTYPE_H
#define	_WCTYPE_H

#include <sys/feature_tests.h>
#include <iso/wctype_iso.h>
#ifndef _STRICT_SYMBOLS
#include <ctype.h>
#include <wchar.h>
#endif

/*
 * Allow global visibility for symbols defined in
 * C++ "std" namespace in <iso/wctype_iso.h>.
 */
#if __cplusplus >= 199711L
using std::wint_t;
using std::wctrans_t;
using std::iswalnum;
using std::iswalpha;
using std::iswcntrl;
using std::iswdigit;
using std::iswgraph;
using std::iswlower;
using std::iswprint;
using std::iswpunct;
using std::iswspace;
using std::iswupper;
using std::iswxdigit;
using std::towlower;
using std::towupper;
using std::wctrans;
using std::towctrans;
using std::iswctype;
using std::wctype;
#if (__cplusplus >= 201103L) || defined(_STDC_C99) || defined(_XPG6) || \
	!defined(_STRICT_SYMBOLS)
using std::iswblank;
#endif
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/* do not allow any of the following in a strictly conforming application */
#ifndef _STRICT_SYMBOLS

/*
 * data structure for supplementary code set
 * for character class and conversion
 */
struct	_wctype {
	wchar_t	tmin;		/* minimum code for wctype */
	wchar_t	tmax;		/* maximum code for wctype */
	unsigned char  *index;	/* class index */
	unsigned int   *type;	/* class type */
	wchar_t	cmin;		/* minimum code for conversion */
	wchar_t	cmax;		/* maximum code for conversion */
	wchar_t *code;		/* conversion code */
};


#ifdef	_ILLUMOS_PRIVATE
extern	int __iswrune(wint_t);
extern	wint_t __nextwctype(wint_t, wctype_t);
#define	iswrune(c)		__iswrune(c)
#define	nextwctype(c, t)	__nextwctype(c, t)
#endif

/* character classification functions */

/* iswascii is still a macro */
#define	iswascii(c)	isascii(c)

/* isw*, except iswascii(), are not macros any more.  They become functions */

/* is* also become functions */
extern	int isphonogram(wint_t);
extern	int isideogram(wint_t);
extern	int isenglish(wint_t);
extern	int isnumber(wint_t);
extern	int isspecial(wint_t);
/* From BSD/MacOS */
extern	int iswideogram(wint_t);
extern	int iswphonogram(wint_t);
extern	int iswnumber(wint_t);
extern	int iswhexnumber(wint_t);
extern	int iswspecial(wint_t);

#define	iscodeset0(c)	isascii(c)
#define	iscodeset1(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS1)
#define	iscodeset2(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS2)
#define	iscodeset3(c)	(((c) & WCHAR_CSMASK) == WCHAR_CS3)

#endif /* !defined(_STRICT_SYMBOLS)... */


/* XPG7 extended locale support */
#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)

#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern wint_t towlower_l(wint_t, locale_t);
extern wint_t towupper_l(wint_t, locale_t);
extern wint_t towctrans_l(wint_t, wctrans_t, locale_t);
extern int iswctype_l(wint_t, wctype_t, locale_t);
extern int iswalnum_l(wint_t, locale_t);
extern int iswalpha_l(wint_t, locale_t);
extern int iswblank_l(wint_t, locale_t);
extern int iswcntrl_l(wint_t, locale_t);
extern int iswdigit_l(wint_t, locale_t);
extern int iswgraph_l(wint_t, locale_t);
extern int iswlower_l(wint_t, locale_t);
extern int iswprint_l(wint_t, locale_t);
extern int iswpunct_l(wint_t, locale_t);
extern int iswspace_l(wint_t, locale_t);
extern int iswupper_l(wint_t, locale_t);
extern int iswxdigit_l(wint_t, locale_t);
extern wctrans_t wctrans_l(const char *, locale_t);
extern wctype_t wctype_l(const char *, locale_t);
#endif /* defined(_XPG7) || !defined(_STRICT_SYMBOLS) */

#ifdef	__cplusplus
}
#endif

#endif	/* _WCTYPE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1986 AT&T	*/
/*	  All Rights Reserved	*/


/*	This module is created for NLS on Jun.04.86		*/

#ifndef	_WIDEC_H
#define	_WIDEC_H

#include <sys/feature_tests.h>

#include <stdio.h>	/* For definition of FILE */
#include <euc.h>
#include <wchar.h>

#ifdef	__cplusplus
extern "C" {
#endif

/* Character based input and output functions */
extern wchar_t	*getws(wchar_t *);
extern int	putws(const wchar_t *);

#if !defined(__lint)
#define	getwc(p)	fgetwc(p)
#define	putwc(x, p)	fputwc((x), (p))
#define	getwchar()	getwc(stdin)
#define	putwchar(x)	putwc((x), stdout)
#endif

/* wchar_t string operation functions */
extern wchar_t	*strtows(wchar_t *, char *);
extern wchar_t	*wscpy(wchar_t *, const wchar_t *);
extern wchar_t	*wsncpy(wchar_t *, const wchar_t *, size_t);
extern wchar_t	*wscat(wchar_t *, const wchar_t *);
extern wchar_t	*wsncat(wchar_t *, const wchar_t *, size_t);
extern wchar_t	*wschr(const wchar_t *, wchar_t);
extern wchar_t	*wsrchr(const wchar_t *, wchar_t);
extern wchar_t	*wspbrk(const wchar_t *, const wchar_t *);
extern wchar_t	*wstok(wchar_t *, const wchar_t *);
extern char	*wstostr(char *, wchar_t *);

extern int	wscmp(const wchar_t *, const wchar_t *);
extern int	wsncmp(const wchar_t *, const wchar_t *, size_t);
extern size_t	wslen(const wchar_t *);
extern size_t	wsspn(const wchar_t *, const wchar_t *);
extern size_t	wscspn(const wchar_t *, const wchar_t *);
extern int	wscoll(const wchar_t *, const wchar_t *);
extern size_t	wsxfrm(wchar_t *, const wchar_t *, size_t);

#if !defined(_STRICT_SYMBOLS)

extern wchar_t	*wsdup(const wchar_t *);
extern int	wscol(const wchar_t *);
extern double	wstod(const wchar_t *, wchar_t **);
extern long	wstol(const wchar_t *, wchar_t **, int);
extern int	wscasecmp(const wchar_t *, const wchar_t *);
extern int	wsncasecmp(const wchar_t *, const wchar_t *, size_t);
extern int	wsprintf(wchar_t *, const char *, ...);
#if defined(_LONGLONG_TYPE)
extern long long	wstoll(const wchar_t *, wchar_t **, int);
#endif	/* defined(_LONGLONG_TYPE) */

#endif /* !defined(_STRICT_SYMBOLS) */

/* Returns the code set number for the process code c. */
#define	WCHAR_SHIFT	7
#define	WCHAR_S_MASK	0x7f
#define	wcsetno(c) \
	(((c)&0x20000000)?(((c)&0x10000000)?1:3):(((c)&0x10000000)?2:0))

/* Aliases... */
#define	windex		wschr
#define	wrindex		wsrchr

#define	watol(s)	wstol((s), (wchar_t **)0, 10)
#if defined(_LONGLONG_TYPE) && !defined(__lint)
#define	watoll(s)	wstoll((s), (wchar_t **)0, 10)
#endif	/* defined(_LONGLONG_TYPE) && !defined(__lint) */
#define	watoi(s)	((int)wstol((s), (wchar_t **)0, 10))
#define	watof(s)	wstod((s), (wchar_t **)0)

/*
 * other macros.
 */
#define	WCHAR_CSMASK	0x30000000
#define	EUCMASK		0x30000000
#define	WCHAR_CS0	0x00000000
#define	WCHAR_CS1	0x30000000
#define	WCHAR_CS2	0x10000000
#define	WCHAR_CS3	0x20000000
#define	WCHAR_BYTE_OF(wc, i) (((wc&~0x30000000)>>(7*(3-i)))&0x7f)

#ifdef	__cplusplus
}
#endif

#endif	/* _WIDEC_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Copyright 1985, 1992 by Mortice Kern Systems Inc.  All rights reserved.
 */

#ifndef	_WORDEXP_H
#define	_WORDEXP_H

#include <sys/feature_tests.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef	struct	wordexp_t {
	size_t	we_wordc;		/* Count of paths matched by pattern */
	char	**we_wordv;		/* List of matched pathnames */
	size_t	we_offs;		/* # of slots reserved in we_pathv */
	/* following are internal to the implementation */
	char	**we_wordp;		/* we_pathv + we_offs */
	int	we_wordn;		/* # of elements allocated */
} wordexp_t;

/*
 * wordexp flags.
 */
#define	WRDE_APPEND	0x0001		/* append to existing wordexp_t */
#define	WRDE_DOOFFS	0x0002		/* use we_offs */
#define	WRDE_NOCMD	0x0004		/* don't allow $() */
#define	WRDE_REUSE	0x0008
#define	WRDE_SHOWERR	0x0010		/* don't 2>/dev/null */
#define	WRDE_UNDEF	0x0020		/* set -u */

/*
 * wordexp errors.
 */
#define	WRDE_ERRNO	(2)		/* error in "errno" */
#define	WRDE_BADCHAR	(3)		/* shell syntax character */
#define	WRDE_BADVAL	(4)		/* undefined variable expanded */
#define	WRDE_CMDSUB	(5)		/* prohibited $() */
#define	WRDE_NOSPACE	(6)		/* no memory */
#define	WRDE_SYNTAX	(7)		/* bad syntax */
#define	WRDE_NOSYS	(8)		/* function not supported (XPG4) */

extern int wordexp(const char *_RESTRICT_KYWD, wordexp_t *_RESTRICT_KYWD, int);
extern void wordfree(wordexp_t *);

#ifdef	__cplusplus
}
#endif

#endif	/* _WORDEXP_H */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 * Copyright 2025 Bill Sommerfeld <sommerfeld@hamachi.org>
 */

#ifndef _XLOCALE_H
#define	_XLOCALE_H

/*
 * This file supplies declarations for extended locale routines, as
 * originally delivered by MacOS X.  Many of these things are now
 * officially part of XPG7.  (Note that while the interfaces are the
 * same as MacOS X, there is no shared implementation.)
 *
 * Those declarations that are part of XPG7 are provided for the in the
 * XPG7-specified location.  This file lists just the declarations that
 * were not part of the standard.  These will be useful in their own right,
 * and will aid porting programs that don't strictly follow the standard.
 *
 * Note that it is an error to include this file in a program with strict
 * symbol visibilty rules (under strict ANSI or POSIX_C_SOURCE rules.)
 * If this is done, the symbols defined here will indeed be exposed to your
 * program, but those symbols that are part of the related standards might
 * not be.
 */

#include <sys/feature_tests.h>
#include <wchar.h>
#include <locale.h>
#include <stdio.h>
#include <floatingpoint.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef	_LOCALE_T
#define	_LOCALE_T
typedef struct _locale *locale_t;
#endif

extern int mbsinit_l(const mbstate_t *, locale_t);

extern size_t mbsrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD, locale_t);

extern size_t mbsnrtowcs_l(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
    size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t);

extern char *strptime_l(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    struct tm *_RESTRICT_KYWD, locale_t);

extern int wcwidth_l(wchar_t, locale_t);

extern int wcswidth_l(const wchar_t *, size_t, locale_t);

extern int iswspecial_l(wint_t, locale_t);
extern int iswnumber_l(wint_t, locale_t);
extern int iswhexnumber_l(wint_t, locale_t);
extern int iswideogram_l(wint_t, locale_t);
extern int iswphonogram_l(wint_t, locale_t);

extern wint_t btowc_l(int, locale_t);
extern int wctob_l(wint_t, locale_t);
extern size_t mbrtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t mbstowcs_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
    size_t, locale_t);
extern int mblen_l(const char *, size_t, locale_t);
extern size_t mbrlen_l(const char *_RESTRICT_KYWD, size_t,
    mbstate_t *_RESTRICT_KYWD, locale_t);
extern int mbtowc_l(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t,
    locale_t);
extern size_t wcsrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
    size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t wcsnrtombs_l(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
    size_t, size_t, mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t wcrtomb_l(char *_RESTRICT_KYWD, wchar_t,
    mbstate_t *_RESTRICT_KYWD, locale_t);
extern size_t wcstombs_l(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
    size_t, locale_t);
extern int wctomb_l(char *, wchar_t, locale_t);

extern unsigned char __mb_cur_max_l(locale_t);
#ifndef	MB_CUR_MAX_L
#define	MB_CUR_MAX_L(l)	(__mb_cur_max_l(l))
#endif

extern struct lconv *localeconv_l(locale_t);

extern size_t wcsftime_l(wchar_t *_RESTRICT_KYWD,
    size_t, const wchar_t *_RESTRICT_KYWD, const struct tm *_RESTRICT_KYWD,
    locale_t);

/* these three are also in stdlib.h */
extern float strtof_l(const char *, char **, locale_t);
extern double strtod_l(const char *, char **, locale_t);
extern long double strtold_l(const char *, char **, locale_t);

extern void string_to_decimal_l(char **, int, int, decimal_record *,
    enum decimal_string_form *, char **, locale_t);

#if defined(_XPG4) && !defined(_FILEDEFED) || __cplusplus >= 199711L
#define	_FILEDEFED
typedef __FILE FILE;
#endif

extern wint_t fgetwc_l(FILE *, locale_t);
extern wint_t getwc_l(FILE *, locale_t);

#ifndef getwchar_l
#define	getwchar_l(l)	fgetwc_l(stdin, (l))
#endif

#ifdef __cplusplus
}
#endif

#endif /* _XLOCALE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 */
/*	Copyright (c) 1996 Sun Microsystems, Inc.	*/
/*	  All Rights Reserved	*/


#ifndef _XTI_H
#define	_XTI_H

#include <sys/types.h>

/*
 * The following include file has declarations needed by both the kernel
 * level transport providers and the user level library. This file includes
 * it to expose its namespaces to XTI user level interface.
 */
#include <sys/tpicommon.h>

/*
 * Include XTI interface level options management declarations
 */
#include <sys/xti_xtiopt.h>

#if !defined(_XPG5)

/*
 * Include declarations related to OSI transport and management data
 * structures, and the Internet Protocol Suite.
 * Note: The older Unix95/XNS4 XTI spec required these to be
 * exposed through the generic interface header.
 */
#include <sys/xti_osi.h>
#include <sys/xti_inet.h>

#endif /* !defined(_XPG5) */

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * The following t_errno error codes are included in the namespace by
 * inclusion of <sys/tpicommon.h> above. The english language error strings
 * associated with the error values are reproduced here for easy reference.
 *
 * Error		Value	Error message string
 * ----			-----	--------------------
 * TBADADDR		1	Incorrect address format
 * TBADOPT		2	Incorrect options format
 * TACCES		3	Illegal permissions
 * TBADF		4	Illegal file descriptor
 * TNOADDR		5	Couldn't allocate address
 * TOUTSTATE		6	Routine will place interface out of state
 * TBADSEQ		7	Illegal called/calling sequence number
 * TSYSERR		8	System error
 * TLOOK		9	An event requires attention
 * TBADDATA		10	Illegal amount of data
 * TBUFOVFLW		11	Buffer not large enough
 * TFLOW		12	Can't send message - (blocked)
 * TNODATA		13	No message currently available
 * TNODIS		14	Disconnect message not found
 * TNOUDERR		15	Unitdata error message not found
 * TBADFLAG		16	Incorrect flags specified
 * TNOREL		17	Orderly release message not found
 * TNOTSUPPORT		18	Primitive not supported by provider
 * TSTATECHNG		19	State is in process of changing
 * TNOSTRUCTYPE		20	Unsupported structure type requested
 * TBADNAME		21	Invalid transport provider name
 * TBADQLEN		22	Listener queue length limit is zero
 * TADDRBUSY		23	Transport address is in use
 * TINDOUT		24	Outstanding connection indications
 * TPROVMISMATCH	25	Listener-acceptor transport provider mismatch
 * TRESQLEN		26	Connection acceptor has listen queue length
 *				limit greater than zero
 * TRESADDR		27	Connection acceptor-listener addresses not
 *				same but required by transport
 * TQFULL		28	Incoming connection queue is full
 * TPROTO		29	Protocol error on transport primitive
 *
 */

/*
 * The following are the events returned by t_look
 */
#define	T_LISTEN	0x0001	/* connection indication received	*/
#define	T_CONNECT	0x0002	/* connect confirmation received	*/
#define	T_DATA		0x0004	/* normal data received			*/
#define	T_EXDATA	0x0008	/* expedited data received		*/
#define	T_DISCONNECT	0x0010	/* disconnect received			*/
#define	T_UDERR		0x0040	/* data gram error indication		*/
#define	T_ORDREL	0x0080	/* orderly release indication		*/
#define	T_GODATA	0x0100	/* sending normal data is again possible */
#define	T_GOEXDATA	0x0200	/* sending expedited data is again possible */

/*
 * Flags for data primitives
 */
#define	T_MORE		0x001	/* more data		*/
#define	T_EXPEDITED	0x002	/* expedited data	*/
#define	T_PUSH		0x004	/* send data immediately */

/*
 * XTI error return
 */
#if defined(_REENTRANT) || defined(_TS_ERRNO)
extern int	*__t_errno();
#define	t_errno (*(__t_errno()))
#else
extern int t_errno;
#endif	/* defined(_REENTRANT) || defined(_TS_ERRNO) */


/*
 * The following are for t_sysconf()
 */
#ifndef T_IOV_MAX
#define	T_IOV_MAX	16	/* Maximum number of scatter/gather buffers */
#endif				/* Should be <= IOV_MAX */

#ifndef _SC_T_IOV_MAX
#define	_SC_T_IOV_MAX	79	/* Should be same in <unistd.h> for use by */
#endif				/* sysconf() */

struct t_iovec {
	void	*iov_base;
	size_t	iov_len;
};

/*
 * Translate source level interface to binary entry point names.
 *
 * Note: This is done to maintain co-existence of TLI and XTI
 * interfaces which have identical names for most functions but
 * different semantics. The XTI names are moved to the different
 * prefix space in the ABI. The #ifdef is required to make use of
 * of the compiler feature to allow redefinition of external names
 * where available. Otherwise a simple #define is used when this
 * header is used with other compilers.
 * The use of #define also has the effect of renaming all names (not
 * just function names) to the new name. The TLI function names
 * (e.g. t_bind) can have identical names for structure names
 * (e.g struct t_bind). Therefore, this redefinition of names needs
 * to be before all structure and function name declarations in the header.
 */

#ifdef __PRAGMA_REDEFINE_EXTNAME

#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
#pragma redefine_extname t_accept	_xti_accept
#else
#pragma redefine_extname t_accept	_xti_xns5_accept
#endif
#pragma redefine_extname t_alloc	_xti_alloc
#pragma redefine_extname t_bind		_xti_bind
#pragma redefine_extname t_close	_xti_close
#pragma redefine_extname t_connect	_xti_connect
#pragma redefine_extname t_error	_xti_error
#pragma redefine_extname t_free		_xti_free
#pragma redefine_extname t_getinfo	_xti_getinfo
#pragma redefine_extname t_getstate	_xti_getstate
#pragma redefine_extname t_getprotaddr	_xti_getprotaddr
#pragma redefine_extname t_listen	_xti_listen
#pragma redefine_extname t_look		_xti_look
#pragma redefine_extname t_open		_xti_open
#pragma redefine_extname t_optmgmt	_xti_optmgmt
#pragma redefine_extname t_rcv		_xti_rcv
#pragma redefine_extname t_rcvconnect	_xti_rcvconnect
#pragma redefine_extname t_rcvdis	_xti_rcvdis
#pragma redefine_extname t_rcvrel	_xti_rcvrel
#pragma redefine_extname t_rcvreldata	_xti_rcvreldata
#pragma redefine_extname t_rcvudata	_xti_rcvudata
#pragma redefine_extname t_rcvuderr	_xti_rcvuderr
#pragma redefine_extname t_rcvv		_xti_rcvv
#pragma redefine_extname t_rcvvudata	_xti_rcvvudata
#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
#pragma redefine_extname t_snd		_xti_snd
#else
#pragma redefine_extname t_snd		_xti_xns5_snd
#endif
#pragma redefine_extname t_snddis	_xti_snddis
#pragma redefine_extname t_sndrel	_xti_sndrel
#pragma redefine_extname t_sndreldata	_xti_sndreldata
#pragma redefine_extname t_sndudata	_xti_sndudata
#pragma redefine_extname t_sndv		_xti_sndv
#pragma redefine_extname t_sndvudata	_xti_sndvudata
#pragma redefine_extname t_strerror	_xti_strerror
#pragma redefine_extname t_sync		_xti_sync
#pragma redefine_extname t_sysconf	_xti_sysconf
#pragma redefine_extname t_unbind	_xti_unbind

#else /* __PRAGMA_REDEFINE_EXTNAME */

#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
#define	t_accept	_xti_accept
#else
#define	t_accept	_xti_xns5_accept
#endif
#define	t_alloc		_xti_alloc
#define	t_bind		_xti_bind
#define	t_close		_xti_close
#define	t_connect	_xti_connect
#define	t_error		_xti_error
#define	t_free		_xti_free
#define	t_getinfo	_xti_getinfo
#define	t_getstate	_xti_getstate
#define	t_getprotaddr	_xti_getprotaddr
#define	t_listen	_xti_listen
#define	t_look		_xti_look
#define	t_open		_xti_open
#define	t_optmgmt	_xti_optmgmt
#define	t_rcv		_xti_rcv
#define	t_rcvconnect	_xti_rcvconnect
#define	t_rcvdis	_xti_rcvdis
#define	t_rcvrel	_xti_rcvrel
#define	t_rcvreldata	_xti_rcvreldata
#define	t_rcvudata	_xti_rcvudata
#define	t_rcvuderr	_xti_rcvuderr
#define	t_rcvv		_xti_rcvv
#define	t_rcvvudata	_xti_rcvvudata
#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
#define	t_snd		_xti_snd
#else
#define	t_snd		_xti_xns5_snd
#endif
#define	t_snddis	_xti_snddis
#define	t_sndrel	_xti_sndrel
#define	t_sndreldata	_xti_sndreldata
#define	t_sndudata	_xti_sndudata
#define	t_sndv		_xti_sndv
#define	t_sndvudata	_xti_sndvudata
#define	t_strerror	_xti_strerror
#define	t_sync		_xti_sync
#define	t_sysconf	_xti_sysconf
#define	t_unbind	_xti_unbind

#endif /* __PRAGMA_REDEFINE_EXTNAME */

/*
 * protocol specific service limits
 */
struct t_info {
	t_scalar_t addr;	/* max size of protocol address		*/
	t_scalar_t options;	/* max size of protocol options		*/
	t_scalar_t tsdu;	/* max size of max transport service	*/
				/* data unit	*/
	t_scalar_t etsdu;	/* max size of max expedited tsdu	*/
	t_scalar_t connect;	/* max data for connection primitives	*/
	t_scalar_t discon;	/* max data for disconnect primitives	*/
	t_scalar_t servtype;	/* provider service type		*/
	t_scalar_t flags;	/* other info about transport providers	*/
};

/*
 * Flags definitions for the t_info structure
 */
#define	T_SENDZERO	0x001	/* supports 0-length TSDUs */
#define	T_ORDRELDATA	0x002	/* supports orderly release data */

/*
 * netbuf structure
 */
struct netbuf {
	unsigned int maxlen;
	unsigned int len;
#if defined(_XPG5)
	void *buf;
#else
	char *buf;
#endif
};

/*
 * t_opthdr structure
 */
struct t_opthdr {
	t_uscalar_t	len;	/* total length of option */
	t_uscalar_t	level;	/* protocol level */
	t_uscalar_t	name;	/* option name */
	t_uscalar_t	status;	/* status value */
	/* followed by option value */
};

/*
 * t_bind - format of the addres and options arguments of bind
 */

struct t_bind {
	struct netbuf	addr;
	unsigned int	qlen;
};

/*
 * options management
 */
struct t_optmgmt {
	struct netbuf	opt;
	t_scalar_t	flags;
};

/*
 * disconnect structure
 */
struct t_discon {
	struct netbuf	udata;		/* user data		*/
	int		reason;		/* reason code		*/
	int		sequence;	/* sequence number	*/
};

/*
 * call structure
 */
struct t_call {
	struct netbuf	addr;		/*  address		*/
	struct netbuf	opt;		/* options		*/
	struct netbuf	udata;		/* user data		*/
	int		sequence;	/* sequence number	*/
};

/*
 * data gram structure
 */
struct t_unitdata {
	struct netbuf	addr;		/*  address		*/
	struct netbuf	opt;		/* options		*/
	struct netbuf	udata;		/* user data		*/
};

/*
 * unitdata error
 */
struct t_uderr {
	struct netbuf	addr;		/* address		*/
	struct netbuf	opt;		/* options		*/
	t_scalar_t	error;		/* error code		*/
};

/*
 * The following are structure types used when dynamically
 * allocating the above structures via t_structalloc().
 */
#define	T_BIND		1		/* struct t_bind	*/
#define	T_OPTMGMT	2		/* struct t_optmgmt	*/
#define	T_CALL		3		/* struct t_call	*/
#define	T_DIS		4		/* struct t_discon	*/
#define	T_UNITDATA	5		/* struct t_unitdata	*/
#define	T_UDERROR	6		/* struct t_uderr	*/
#define	T_INFO		7		/* struct t_info	*/

/*
 * The following bits specify which fields of the above
 * structures should be allocated by t_alloc().
 */
#define	T_ADDR	0x01			/* address		*/
#define	T_OPT	0x02			/* options		*/
#define	T_UDATA	0x04			/* user data		*/
#define	T_ALL	0xffff			/* all the above fields */


/*
 * the following are the states for the user
 */

#define	T_UNINIT	0		/* uninitialized		*/
#define	T_UNBND		1		/* unbound			*/
#define	T_IDLE		2		/* idle				*/
#define	T_OUTCON	3		/* outgoing connection pending	*/
#define	T_INCON		4		/* incoming connection pending	*/
#define	T_DATAXFER	5		/* data transfer		*/
#define	T_OUTREL	6		/* outgoing release pending	*/
#define	T_INREL		7		/* incoming release pending	*/


#define	T_UNUSED		-1
#define	T_NULL			0


/*
 * Allegedly general purpose constant. Used with (and needs to be bitwise
 * distinct from) T_NOPROTECT, T_PASSIVEPROTECT and T_ACTIVEPROTECT
 * which are OSI specific constants but part of this header (defined
 * in <xti_osi.h> which is included in this header for historical
 * XTI specification reasons)
 */
#define	T_ABSREQ		0x8000

/*
 * General definitions for option management
 *
 * Multiple variable length options may be packed into a single option buffer.
 * Each option consists of a fixed length header followed by variable length
 * data. The header and data will have to be aligned at appropriate
 * boundaries. The following macros are used to manipulate the options.
 *
 * Helper Macros: Macros beginning with a "_T" prefix are helper macros.
 *		  They are private, not meant for public use and may
 *		  change without notice. Users  should use the standard
 *		  XTI macros beginning with "T_" prefix
 */

#define	_T_OPT_HALIGN_SZ	(sizeof (t_scalar_t)) /* Hdr Alignment size  */
#define	_T_OPT_DALIGN_SZ	(sizeof (int32_t))    /* Data Alignment size */
#define	_T_OPTHDR_SZ	(sizeof (struct t_opthdr))

/* Align 'x' to the next 'asize' alignment  boundary */
#define	_T_OPT_ALIGN(x, asize) \
	(((uintptr_t)(x) + ((asize) - 1L)) & ~((asize) - 1L))

/* Align 'x' to the next header alignment  boundary */
#define	_T_OPTHDR_ALIGN(x) \
	(_T_OPT_ALIGN((x), _T_OPT_HALIGN_SZ))

/* Align 'x' to the next data alignment  boundary */
#define	_T_OPTDATA_ALIGN(x) \
	(_T_OPT_ALIGN((x), _T_OPT_DALIGN_SZ))

/*
 * struct t_opthdr *T_OPT_FIRSTHDR(struct netbuf *nbp):
 *     Get aligned start of first option header
 *
 * unsigned char *T_OPT_DATA(struct t_opthdr *tohp):
 *     Get aligned start of data part after option header
 *
 * struct t_opthdr *T_OPT_NEXTHDR(struct netbuf *nbp, struct t_opthdr *tohp):
 *	Skip to next option header
 */

#define	T_OPT_FIRSTHDR(nbp)    \
	((nbp)->len >= _T_OPTHDR_SZ ? (struct t_opthdr *)(nbp)->buf : \
	    (struct t_opthdr *)0)

#define	T_OPT_DATA(tohp)	\
	((unsigned char *)_T_OPTDATA_ALIGN((char *)(tohp) + _T_OPTHDR_SZ))

#define	_T_NEXTHDR(pbuf, buflen, popt) \
	(((char *)_T_OPTHDR_ALIGN((char *)(popt) + (popt)->len) + \
	    _T_OPTHDR_SZ <= ((char *)(pbuf) + (buflen))) ? \
	(struct t_opthdr *)((char *)_T_OPTHDR_ALIGN((char *)(popt) + \
	    (popt)->len)) : (struct t_opthdr *)0)

#define	T_OPT_NEXTHDR(nbp, tohp)   (_T_NEXTHDR((nbp)->buf, (nbp)->len, (tohp)))

#if !defined(_XPG5)
/*
 * The macros below are meant for older applications for compatibility.
 * New applications should use the T_OPT_* macros, obviating the need
 * to explicitly use the T_ALIGN macro
 *
 * struct t_opthdr *OPT_NEXTHDR(char *pbuf, unsigned int buflen,
 *                               struct t_opthdr *popt):
 *         Skip to next option header
 */
#define	T_ALIGN(p)	(((uintptr_t)(p) + (sizeof (t_scalar_t) - 1))\
					& ~(sizeof (t_scalar_t) - 1))
#define	OPT_NEXTHDR(pbuf, buflen, popt)	(_T_NEXTHDR((pbuf), (buflen), (popt)))
#endif

/*
 * XTI LIBRARY FUNCTIONS
 */

#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
extern int t_accept(int, int, struct t_call *);
extern char *t_alloc(int, int, int);
extern int t_bind(int, struct t_bind *, struct t_bind *);
extern int t_connect(int, struct t_call *, struct t_call *);
extern int t_error(char *);
extern int t_free(char *, int);
extern int t_open(char *, int, struct t_info *);
extern int t_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *);
extern int t_rcv(int, char *, unsigned int, int *);
extern int t_snd(int, char *, unsigned int, int);
extern int t_snddis(int, struct t_call *);
extern int t_sndudata(int, struct t_unitdata *);
extern char *t_strerror(int);
#else
extern int t_accept(int, int, const struct t_call *);
extern void *t_alloc(int, int, int);
extern int t_bind(int, const struct t_bind *, struct t_bind *);
extern int t_connect(int, const struct t_call *, struct t_call *);
extern int t_error(const char *);
extern int t_free(void *, int);
extern int t_open(const char *, int, struct t_info *);
extern int t_optmgmt(int, const struct t_optmgmt *, struct t_optmgmt *);
extern int t_rcv(int, void *, unsigned int, int *);
extern int t_snd(int, void *, unsigned int, int);
extern int t_snddis(int, const struct t_call *);
extern int t_sndudata(int, const struct t_unitdata *);
extern const char *t_strerror(int);
#endif
extern int t_close(int);
extern int t_getinfo(int, struct t_info *);
extern int t_getstate(int);
extern int t_getprotaddr(int, struct t_bind *, struct t_bind *);
extern int t_listen(int, struct t_call *);
extern int t_look(int);
extern int t_rcvconnect(int, struct t_call *);
extern int t_rcvdis(int, struct t_discon *);
extern int t_rcvrel(int);
extern int t_rcvreldata(int, struct t_discon *);
extern int t_rcvudata(int, struct t_unitdata *, int *);
extern int t_rcvuderr(int, struct t_uderr *);
extern int t_rcvv(int, struct t_iovec *, unsigned int, int *);
extern int t_rcvvudata(int, struct t_unitdata *, struct t_iovec *,
	unsigned int, int *);
extern int t_sndrel(int);
extern int t_sndreldata(int, struct t_discon *);
extern int t_sndv(int, const struct t_iovec *,  unsigned int, int);
extern int t_sndvudata(int, struct t_unitdata *, struct t_iovec *,
	unsigned int);
extern int t_sync(int);
extern int t_sysconf(int);
extern int t_unbind(int);

#ifdef	__cplusplus
}
#endif

#endif	/* _XTI_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1998 Sun Microsystems, Inc.	*/
/*	  All Rights Reserved	*/


#ifndef _XTI_INET_H
#define	_XTI_INET_H

#include <sys/xti_inet.h>

#endif /* _XTI_INET_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _ZONE_H
#define	_ZONE_H

#include <sys/types.h>
#include <sys/zone.h>
#include <sys/priv.h>
#include <tsol/label.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Functions for mapping between id and name for active zones.
 */
extern zoneid_t		getzoneid(void);
extern zoneid_t		getzoneidbyname(const char *);
extern ssize_t		getzonenamebyid(zoneid_t, char *, size_t);

/*
 * NOTE
 *
 * The remaining contents of this file are private to the implementation
 * of Solaris and are subject to change at any time without notice,
 * Applications using these interfaces may fail to run on future releases.
 */

extern int zonept(int, zoneid_t);
extern int zone_get_id(const char *, zoneid_t *);

/* System call API */
extern zoneid_t	zone_create(const char *, const char *,
    const struct priv_set *, const char *, size_t, const char *, size_t, int *,
    int, int, const bslabel_t *, int);
extern int	zone_boot(zoneid_t);
extern int	zone_destroy(zoneid_t);
extern ssize_t	zone_getattr(zoneid_t, int, void *, size_t);
extern int	zone_setattr(zoneid_t, int, void *, size_t);
extern int	zone_enter(zoneid_t);
extern int	zone_list(zoneid_t *, uint_t *);
extern int	zone_shutdown(zoneid_t);
extern int	zone_version(int *);
extern int	zone_add_datalink(zoneid_t, datalink_id_t);
extern int	zone_remove_datalink(zoneid_t, datalink_id_t);
extern int	zone_check_datalink(zoneid_t *, datalink_id_t);
extern int	zone_list_datalink(zoneid_t, int *, datalink_id_t *);

#ifdef	__cplusplus
}
#endif

#endif /* _ZONE_H */