0003-Add-rpcgen-program-from-nfs-utils-sources.patch 164 KB
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
From 866b651bcb9f93f47582e5e2e4f1eb3155025298 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Sat, 10 Nov 2012 16:21:01 +0100
Subject: [PATCH] Add rpcgen program from nfs-utils sources

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[yann.morin.1998@free.fr: update for 0.3.1]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 Makefile.am          |    2 +-
 configure.ac         |   14 +-
 rpcgen/Makefile.am   |   22 ++
 rpcgen/rpc_clntout.c |  217 ++++++++++
 rpcgen/rpc_cout.c    |  706 +++++++++++++++++++++++++++++++++
 rpcgen/rpc_hout.c    |  490 +++++++++++++++++++++++
 rpcgen/rpc_main.c    | 1067 ++++++++++++++++++++++++++++++++++++++++++++++++++
 rpcgen/rpc_output.h  |   16 +
 rpcgen/rpc_parse.c   |  609 ++++++++++++++++++++++++++++
 rpcgen/rpc_parse.h   |  166 ++++++++
 rpcgen/rpc_sample.c  |  247 ++++++++++++
 rpcgen/rpc_scan.c    |  474 ++++++++++++++++++++++
 rpcgen/rpc_scan.h    |  103 +++++
 rpcgen/rpc_svcout.c  |  882 +++++++++++++++++++++++++++++++++++++++++
 rpcgen/rpc_tblout.c  |  165 ++++++++
 rpcgen/rpc_util.c    |  479 ++++++++++++++++++++++
 rpcgen/rpc_util.h    |  166 ++++++++
 rpcgen/rpcgen.1      |  521 ++++++++++++++++++++++++
 18 files changed, 6344 insertions(+), 2 deletions(-)
 create mode 100644 rpcgen/Makefile.am
 create mode 100644 rpcgen/rpc_clntout.c
 create mode 100644 rpcgen/rpc_cout.c
 create mode 100644 rpcgen/rpc_hout.c
 create mode 100644 rpcgen/rpc_main.c
 create mode 100644 rpcgen/rpc_output.h
 create mode 100644 rpcgen/rpc_parse.c
 create mode 100644 rpcgen/rpc_parse.h
 create mode 100644 rpcgen/rpc_sample.c
 create mode 100644 rpcgen/rpc_scan.c
 create mode 100644 rpcgen/rpc_scan.h
 create mode 100644 rpcgen/rpc_svcout.c
 create mode 100644 rpcgen/rpc_tblout.c
 create mode 100644 rpcgen/rpc_util.c
 create mode 100644 rpcgen/rpc_util.h
 create mode 100644 rpcgen/rpcgen.1

diff --git a/Makefile.am b/Makefile.am
index 466b6dd..8558289 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src man doc
+SUBDIRS = src man doc rpcgen
 ACLOCAL_AMFLAGS = -I m4
 
 noinst_HEADERS	       = tirpc/reentrant.h \
diff --git a/configure.ac b/configure.ac
index e3cb8af..0ea2e6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,18 @@ AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h locale.h netdb.h netine
 AC_CHECK_LIB([pthread], [pthread_create])
 AC_CHECK_FUNCS([getrpcbyname getrpcbynumber setrpcent endrpcent getrpcent])
 
-AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile])
+AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
+
+AC_MSG_CHECKING([for a C compiler for build tools])
+if test $cross_compiling = yes; then
+   AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
+else
+   CC_FOR_BUILD=$CC
+fi
+AC_MSG_RESULT([$CC_FOR_BUILD])
+AC_SUBST(CC_FOR_BUILD)
+
+AC_CONFIG_FILES([Makefile src/Makefile man/Makefile doc/Makefile rpcgen/Makefile])
+
 AC_OUTPUT(libtirpc.pc)
 
diff --git a/rpcgen/Makefile.am b/rpcgen/Makefile.am
new file mode 100644
index 0000000..2277b6f
--- /dev/null
+++ b/rpcgen/Makefile.am
@@ -0,0 +1,22 @@
+COMPILE = $(CC_FOR_BUILD) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS_FOR_BUILD) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD)
+LINK = $(CC_FOR_BUILD) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD) -o $@
+
+noinst_PROGRAMS = rpcgen
+
+rpcgen_SOURCES = \
+	rpc_clntout.c \
+	rpc_cout.c \
+	rpc_hout.c \
+	rpc_main.c \
+	rpc_parse.c \
+	rpc_sample.c \
+	rpc_scan.c \
+	rpc_svcout.c \
+	rpc_tblout.c \
+	rpc_util.c \
+	rpc_parse.h \
+	rpc_scan.h \
+	rpc_util.h
+
+dist_man1_MANS = rpcgen.1
diff --git a/rpcgen/rpc_clntout.c b/rpcgen/rpc_clntout.c
new file mode 100644
index 0000000..e2f4382
--- /dev/null
+++ b/rpcgen/rpc_clntout.c
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_clntout.c 1.11 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_clntout.c, Client-stub outputter for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsytsems, Inc.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <rpc/types.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "rpc_output.h"
+
+/* extern pdeclaration(); */
+/* void printarglist(); */
+
+#define DEFAULT_TIMEOUT 25	/* in seconds */
+static char RESULT[] = "clnt_res";
+
+static void	write_program(definition *def);
+static void	printbody(proc_list *proc);
+
+
+void
+write_stubs(void)
+{
+	list *l;
+	definition *def;
+
+	f_print(fout, 
+		"\n/* Default timeout can be changed using clnt_control() */\n");
+	f_print(fout, "static struct timeval TIMEOUT = { %d, 0 };\n",
+		DEFAULT_TIMEOUT);
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind == DEF_PROGRAM) {
+			write_program(def);
+		}
+	}
+}
+
+static void
+write_program(definition *def)
+{
+	version_list   *vp;
+	proc_list      *proc;
+
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			f_print(fout, "\n");
+			ptype(proc->res_prefix, proc->res_type, 1);
+			f_print(fout, "*\n");
+			pvname(proc->proc_name, vp->vers_num);
+			printarglist(proc, "clnt", "CLIENT *");
+			f_print(fout, "{\n");
+			printbody(proc);
+			f_print(fout, "}\n");
+		}
+	}
+}
+
+/*
+ * Writes out declarations of procedure's argument list.
+ * In either ANSI C style, in one of old rpcgen style (pass by reference),
+ * or new rpcgen style (multiple arguments, pass by value);
+ */
+
+/* sample addargname = "clnt"; sample addargtype = "CLIENT * " */
+
+void
+printarglist(proc_list *proc, char *addargname, char *addargtype)
+{
+
+	decl_list      *l;
+
+	if (!newstyle) {	/* old style: always pass arg by reference */
+		if (Cflag) {	/* C++ style heading */
+			f_print(fout, "(");
+			ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+			f_print(fout, "*argp, %s%s)\n", addargtype, addargname);
+		} else {
+			f_print(fout, "(argp, %s)\n", addargname);
+			f_print(fout, "\t");
+			ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+			f_print(fout, "*argp;\n");
+		}
+	} else if (streq(proc->args.decls->decl.type, "void")) {
+		/* newstyle, 0 argument */
+		if (Cflag)
+			f_print(fout, "(%s%s)\n", addargtype, addargname);
+		else
+			f_print(fout, "(%s)\n", addargname);
+	} else {
+		/* new style, 1 or multiple arguments */
+		if (!Cflag) {
+			f_print(fout, "(");
+			for (l = proc->args.decls; l != NULL; l = l->next)
+				f_print(fout, "%s, ", l->decl.name);
+			f_print(fout, "%s)\n", addargname);
+			for (l = proc->args.decls; l != NULL; l = l->next) {
+				pdeclaration(proc->args.argname, &l->decl, 1, ";\n");
+			}
+		} else {	/* C++ style header */
+			f_print(fout, "(");
+			for (l = proc->args.decls; l != NULL; l = l->next) {
+				pdeclaration(proc->args.argname, &l->decl, 0, ", ");
+			}
+			f_print(fout, " %s%s)\n", addargtype, addargname);
+		}
+	}
+
+	if (!Cflag)
+		f_print(fout, "\t%s%s;\n", addargtype, addargname);
+}
+
+
+
+static char *
+ampr(char *type)
+{
+	if (isvectordef(type, REL_ALIAS)) {
+		return ("");
+	} else {
+		return ("&");
+	}
+}
+
+static void
+printbody(proc_list *proc)
+{
+	decl_list      *l;
+	bool_t          args2 = (proc->arg_num > 1);
+
+	/* For new style with multiple arguments, need a structure in which
+         * to stuff the arguments. */
+	if (newstyle && args2) {
+		f_print(fout, "\t%s", proc->args.argname);
+		f_print(fout, " arg;\n");
+	}
+	f_print(fout, "\tstatic ");
+	if (streq(proc->res_type, "void")) {
+		f_print(fout, "char ");
+	} else {
+		ptype(proc->res_prefix, proc->res_type, 0);
+	}
+	f_print(fout, "%s;\n", RESULT);
+	f_print(fout, "\n");
+	f_print(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
+		ampr(proc->res_type), RESULT, RESULT);
+	if (newstyle && !args2 && (streq(proc->args.decls->decl.type, "void"))) {
+		/* newstyle, 0 arguments */
+		f_print(fout,
+			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_void, (caddr_t) NULL, "
+			"(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+			proc->proc_name,
+			stringfix(proc->res_type), ampr(proc->res_type), RESULT);
+
+	} else if (newstyle && args2) {
+		/* newstyle, multiple arguments:  stuff arguments into structure */
+		for (l = proc->args.decls; l != NULL; l = l->next) {
+			f_print(fout, "\targ.%s = %s;\n",
+				l->decl.name, l->decl.name);
+		}
+		f_print(fout,
+			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_%s, (caddr_t) &arg, "
+			"(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+			proc->proc_name, proc->args.argname,
+			stringfix(proc->res_type), ampr(proc->res_type), RESULT);
+	} else {		/* single argument, new or old style */
+		f_print(fout,
+			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_%s, "
+			"(caddr_t) %s%s, (xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
+			proc->proc_name,
+			stringfix(proc->args.decls->decl.type),
+			(newstyle ? "&" : ""),
+			(newstyle ? proc->args.decls->decl.name : "argp"),
+			stringfix(proc->res_type), ampr(proc->res_type), RESULT);
+	}
+	f_print(fout, "\t\treturn (NULL);\n");
+	f_print(fout, "\t}\n");
+	if (streq(proc->res_type, "void")) {
+		f_print(fout, "\treturn ((void *)%s%s);\n",
+			ampr(proc->res_type), RESULT);
+	} else {
+		f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type), RESULT);
+	}
+}
diff --git a/rpcgen/rpc_cout.c b/rpcgen/rpc_cout.c
new file mode 100644
index 0000000..a61214f
--- /dev/null
+++ b/rpcgen/rpc_cout.c
@@ -0,0 +1,706 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_cout.c, XDR routine outputter for the RPC protocol compiler 
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <ctype.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+
+static int	findtype(definition *def, char *type);
+static int	undefined(char *type);
+static void	print_generic_header(char *procname, int pointerp);
+static void	print_header(definition *def);
+static void	print_prog_header(proc_list *plist);
+static void	print_trailer(void);
+static void	print_ifopen(int indent, char *name);
+static void	print_ifarg(char *arg);
+static void	print_ifsizeof(char *prefix, char *type);
+static void	print_ifclose(int indent);
+static void	print_ifstat(int indent, char *prefix, char *type, relation rel,
+			char *amax, char *objname, char *name);
+static void	emit_enum(definition *def);
+static void	emit_program(definition *def);
+static void	emit_union(definition *def);
+static void	emit_struct(definition *def);
+static void	emit_typedef(definition *def);
+static void	print_stat(int indent, declaration *dec);
+static void	emit_inline(declaration *decl, int flag);
+static void	emit_single_in_line(declaration *decl, int flag, relation rel);
+static char *	upcase(char *str);
+
+/*
+ * Emit the C-routine for the given definition 
+ */
+void
+emit(definition *def)
+{
+	if (def->def_kind == DEF_CONST) {
+		return;
+	}
+	if (def->def_kind == DEF_PROGRAM) {
+		emit_program(def);
+		return;
+	}
+	if (def->def_kind == DEF_TYPEDEF) {
+		/* now we need to handle declarations like
+		 * struct typedef foo foo;
+		 * since we dont want this to be expanded into 2 calls
+		 * to xdr_foo */
+
+		if (strcmp(def->def.ty.old_type, def->def_name) == 0)
+			return;
+	};
+
+	print_header(def);
+	switch (def->def_kind) {
+	case DEF_UNION:
+		emit_union(def);
+		break;
+	case DEF_ENUM:
+		emit_enum(def);
+		break;
+	case DEF_STRUCT:
+		emit_struct(def);
+		break;
+	case DEF_TYPEDEF:
+		emit_typedef(def);
+		break;
+	default:
+		break;
+	}
+	print_trailer();
+}
+
+static int
+findtype(definition *def, char *type)
+{
+
+	if (def->def_kind == DEF_PROGRAM || def->def_kind == DEF_CONST) {
+		return (0);
+	} else {
+		return (streq(def->def_name, type));
+	}
+}
+
+static int
+undefined(char *type)
+{
+	definition     *def;
+
+	def = (definition *) FINDVAL(defined, type, findtype);
+
+	return (def == NULL);
+}
+
+
+static void
+print_generic_header(char *procname, int pointerp)
+{
+	f_print(fout, "\n");
+	f_print(fout, "bool_t\n");
+	if (Cflag) {
+		f_print(fout, "xdr_%s(", procname);
+		f_print(fout, "XDR *xdrs, ");
+		f_print(fout, "%s ", procname);
+		if (pointerp)
+			f_print(fout, "*");
+		f_print(fout, "objp)\n{\n\n");
+	} else {
+		f_print(fout, "xdr_%s(xdrs, objp)\n", procname);
+		f_print(fout, "\tXDR *xdrs;\n");
+		f_print(fout, "\t%s ", procname);
+		if (pointerp)
+			f_print(fout, "*");
+		f_print(fout, "objp;\n{\n\n");
+	}
+}
+
+static void
+print_header(definition *def)
+{
+	print_generic_header(def->def_name,
+		def->def_kind != DEF_TYPEDEF ||
+		!isvectordef(def->def.ty.old_type, def->def.ty.rel));
+
+	/* Now add Inline support */
+
+
+	if (Inline == 0)
+		return;
+}
+
+static void
+print_prog_header(proc_list *plist)
+{
+	print_generic_header(plist->args.argname, 1);
+}
+
+static void
+print_trailer(void)
+{
+	f_print(fout, "\treturn (TRUE);\n");
+	f_print(fout, "}\n");
+}
+
+
+static void
+print_ifopen(int indent, char *name)
+{
+	tabify(fout, indent);
+	f_print(fout, " if (!xdr_%s(xdrs", name);
+}
+
+static void
+print_ifarg(char *arg)
+{
+	f_print(fout, ", %s", arg);
+}
+
+static void
+print_ifsizeof(char *prefix, char *type)
+{
+	if (streq(type, "bool")) {
+		f_print(fout, ", sizeof(bool_t), (xdrproc_t)xdr_bool");
+	} else {
+		f_print(fout, ", sizeof(");
+		if (undefined(type) && prefix) {
+			f_print(fout, "%s ", prefix);
+		}
+		f_print(fout, "%s), (xdrproc_t)xdr_%s", type, type);
+	}
+}
+
+static void
+print_ifclose(int indent)
+{
+	f_print(fout, ")) {\n");
+	tabify(fout, indent);
+	f_print(fout, "\t return (FALSE);\n");
+	tabify(fout, indent);
+	f_print(fout, " }\n");
+}
+
+static void
+print_ifstat(int indent, char *prefix, char *type, relation rel,
+			char *amax, char *objname, char *name)
+{
+	char *alt = NULL;
+
+	switch (rel) {
+	case REL_POINTER:
+		print_ifopen(indent, "pointer");
+		print_ifarg("(char **)");
+		f_print(fout, "%s", objname);
+		print_ifsizeof(prefix, type);
+		break;
+	case REL_VECTOR:
+		if (streq(type, "string")) {
+			alt = "string";
+		} else if (streq(type, "opaque")) {
+			alt = "opaque";
+		}
+		if (alt) {
+			print_ifopen(indent, alt);
+			print_ifarg(objname);
+		} else {
+			print_ifopen(indent, "vector");
+			print_ifarg("(char *)");
+			f_print(fout, "%s", objname);
+		}
+		print_ifarg(amax);
+		if (!alt) {
+			print_ifsizeof(prefix, type);
+		}
+		break;
+	case REL_ARRAY:
+		if (streq(type, "string")) {
+			alt = "string";
+		} else if (streq(type, "opaque")) {
+			alt = "bytes";
+		}
+		if (streq(type, "string")) {
+			print_ifopen(indent, alt);
+			print_ifarg(objname);
+		} else {
+			if (alt) {
+				print_ifopen(indent, alt);
+			} else {
+				print_ifopen(indent, "array");
+			}
+			/* The (void*) avoids a gcc-4.1 warning */
+			print_ifarg("(char **)(void*)");
+			if (*objname == '&') {
+				f_print(fout, "%s.%s_val, (u_int *)%s.%s_len",
+					objname, name, objname, name);
+			} else {
+				f_print(fout, "&%s->%s_val, (u_int *)&%s->%s_len",
+					objname, name, objname, name);
+			}
+		}
+		print_ifarg(amax);
+		if (!alt) {
+			print_ifsizeof(prefix, type);
+		}
+		break;
+	case REL_ALIAS:
+		print_ifopen(indent, type);
+		print_ifarg(objname);
+		break;
+	}
+	print_ifclose(indent);
+}
+
+static void
+emit_enum(definition *def)
+{
+	print_ifopen(1, "enum");
+	print_ifarg("(enum_t *)objp");
+	print_ifclose(1);
+}
+
+static void
+emit_program(definition *def)
+{
+	decl_list      *dl;
+	version_list   *vlist;
+	proc_list      *plist;
+
+	for (vlist = def->def.pr.versions; vlist != NULL; vlist = vlist->next)
+		for (plist = vlist->procs; plist != NULL; plist = plist->next) {
+			if (!newstyle || plist->arg_num < 2)
+				continue;/* old style, or single argument */
+			print_prog_header(plist);
+			for (dl = plist->args.decls; dl != NULL; dl = dl->next)
+				print_stat(1, &dl->decl);
+			print_trailer();
+		}
+}
+
+
+static void
+emit_union(definition *def)
+{
+  declaration *dflt;
+  case_list *cl;
+  declaration *cs;
+  char *object;
+  char *vecformat = "objp->%s_u.%s";
+  char *format = "&objp->%s_u.%s";
+
+  print_stat(1,&def->def.un.enum_decl);
+  f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
+  for (cl = def->def.un.cases; cl != NULL; cl = cl->next) {
+
+    f_print(fout, "\tcase %s:\n", cl->case_name);
+    if(cl->contflag == 1)	/* a continued case statement */
+      continue;
+    cs = &cl->case_decl;
+    if (!streq(cs->type, "void")) {
+      object = alloc(strlen(def->def_name) + strlen(format) +
+		     strlen(cs->name) + 1);
+      if (isvectordef (cs->type, cs->rel)) {
+	s_print(object, vecformat, def->def_name, 
+		cs->name);
+      } else {
+	s_print(object, format, def->def_name, 
+		cs->name);
+      }
+      print_ifstat(2, cs->prefix, cs->type, cs->rel, cs->array_max,
+		   object, cs->name);
+      free(object);
+    }
+    f_print(fout, "\t\tbreak;\n");
+  }
+  dflt = def->def.un.default_decl;
+  if (dflt != NULL) {
+    if (!streq(dflt->type, "void")) {
+      f_print(fout, "\tdefault:\n");
+      object = alloc(strlen(def->def_name) + strlen(format) +
+		     strlen(dflt->name) + 1);
+      if (isvectordef (dflt->type, dflt->rel)) {
+	s_print(object, vecformat, def->def_name, 
+		dflt->name);
+      } else {
+	s_print(object, format, def->def_name, 
+		dflt->name);
+      }
+
+      print_ifstat(2, dflt->prefix, dflt->type, dflt->rel,
+		   dflt->array_max, object, dflt->name);
+      free(object);
+      f_print(fout, "\t\tbreak;\n");
+    } else {
+      /* Avoid gcc warnings about `value not handled in switch' */
+      f_print(fout, "\tdefault:\n");
+      f_print(fout, "\t\tbreak;\n");
+    }
+  } else {
+    f_print(fout, "\tdefault:\n");
+    f_print(fout, "\t\treturn (FALSE);\n");
+  }
+
+  f_print(fout, "\t}\n");
+}
+
+static void
+emit_struct(definition *def)
+{
+	decl_list      *dl;
+	int             i, j, size, flag;
+	decl_list      *cur = NULL, *psav;
+	bas_type       *ptr;
+	char           *sizestr, *plus;
+	char            ptemp[256];
+	int             can_inline;
+	const char	*buf_declaration;
+
+
+	if (Inline == 0) {
+		for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+			print_stat(1, &dl->decl);
+	} else {
+		size = 0;
+		can_inline = 0;
+		for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+			if ((dl->decl.prefix == NULL) && ((ptr = find_type(dl->decl.type)) != NULL) && ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) {
+
+				if (dl->decl.rel == REL_ALIAS)
+					size += ptr->length;
+				else {
+					can_inline = 1;
+					break;	/* can be inlined */
+				};
+			} else {
+				if (size >= Inline) {
+					can_inline = 1;
+					break;	/* can be inlined */
+				}
+				size = 0;
+			}
+		if (size > Inline)
+			can_inline = 1;
+
+		if (can_inline == 0) {	/* can not inline, drop back to old mode */
+			for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+				print_stat(1, &dl->decl);
+			return;
+		};
+
+
+
+
+		flag = PUT;
+		for (j = 0; j < 2; j++) {
+
+			if (flag == PUT)
+				f_print(fout, "\n\t if (xdrs->x_op == XDR_ENCODE) {\n");
+			else
+				f_print(fout, "\n \t return (TRUE);\n\t} else if (xdrs->x_op == XDR_DECODE) {\n");
+
+
+			i = 0;
+			size = 0;
+			sizestr = NULL;
+			buf_declaration = "int32_t *";
+			for (dl = def->def.st.decls; dl != NULL; dl = dl->next) {	/* xxx */
+
+				/* now walk down the list and check for basic types */
+				if ((dl->decl.prefix == NULL) && ((ptr = find_type(dl->decl.type)) != NULL) && ((dl->decl.rel == REL_ALIAS) || (dl->decl.rel == REL_VECTOR))) {
+					if (i == 0)
+						cur = dl;
+					i++;
+
+					if (dl->decl.rel == REL_ALIAS)
+						size += ptr->length;
+					else {
+						/* this is required to handle arrays */
+
+						if (sizestr == NULL)
+							plus = " ";
+						else
+							plus = "+";
+
+						if (ptr->length != 1)
+							s_print(ptemp, " %s %s * %d", plus, dl->decl.array_max, ptr->length);
+						else
+							s_print(ptemp, " %s %s ", plus, dl->decl.array_max);
+
+						/*now concatenate to sizestr !!!! */
+						if (sizestr == NULL)
+							sizestr = strdup(ptemp);
+						else {
+							sizestr = realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
+							if (sizestr == NULL) {
+
+								f_print(stderr, "Fatal error : no memory \n");
+								crash();
+							};
+							sizestr = strcat(sizestr, ptemp);	/*build up length of array */
+
+						}
+					}
+
+				} else {
+					if (i > 0)
+					    {
+						if (sizestr == NULL && size < Inline) {
+							/* don't expand into inline code if size < inline */
+							while (cur != dl) {
+								print_stat(1, &cur->decl);
+								cur = cur->next;
+							}
+						} else {
+
+
+
+							/* were already looking at a xdr_inlineable structure */
+							if (sizestr == NULL)
+								f_print(fout, "\t %sbuf = XDR_INLINE(xdrs,%d * BYTES_PER_XDR_UNIT);",
+									buf_declaration, size);
+							else if (size == 0)
+								f_print(fout,
+									"\t %sbuf = XDR_INLINE(xdrs,%s * BYTES_PER_XDR_UNIT);",
+									buf_declaration, sizestr);
+							else
+								f_print(fout,
+									"\t %sbuf = XDR_INLINE(xdrs,(%d + %s)* BYTES_PER_XDR_UNIT);",
+									buf_declaration, size, sizestr);
+							buf_declaration = "";
+
+							f_print(fout, "\n\t   if (buf == NULL) {\n");
+
+							psav = cur;
+							while (cur != dl) {
+								print_stat(2, &cur->decl);
+								cur = cur->next;
+							}
+
+							f_print(fout, "\n\t  }\n\t  else {\n");
+
+							cur = psav;
+							while (cur != dl) {
+								emit_inline(&cur->decl, flag);
+								cur = cur->next;
+							}
+
+							f_print(fout, "\t  }\n");
+						}
+					    }
+					size = 0;
+					i = 0;
+					sizestr = NULL;
+					print_stat(1, &dl->decl);
+				}
+
+			}
+			if (i > 0)
+			    {
+				if (sizestr == NULL && size < Inline) {
+					/* don't expand into inline code if size < inline */
+					while (cur != dl) {
+						print_stat(1, &cur->decl);
+						cur = cur->next;
+					}
+				} else {
+
+					/* were already looking at a xdr_inlineable structure */
+					if (sizestr == NULL)
+						f_print(fout, "\t\t%sbuf = XDR_INLINE(xdrs,%d * BYTES_PER_XDR_UNIT);",
+							buf_declaration, size);
+					else if (size == 0)
+						f_print(fout,
+							"\t\t%sbuf = XDR_INLINE(xdrs,%s * BYTES_PER_XDR_UNIT);",
+							buf_declaration, sizestr);
+					else
+						f_print(fout,
+							"\t\t%sbuf = XDR_INLINE(xdrs,(%d + %s)* BYTES_PER_XDR_UNIT);",
+							buf_declaration, size, sizestr);
+					buf_declaration = "";
+
+					f_print(fout, "\n\t\tif (buf == NULL) {\n");
+
+					psav = cur;
+					while (cur != NULL) {
+						print_stat(2, &cur->decl);
+						cur = cur->next;
+					}
+					f_print(fout, "\n\t  }\n\t  else {\n");
+
+					cur = psav;
+					while (cur != dl) {
+						emit_inline(&cur->decl, flag);
+						cur = cur->next;
+					}
+
+					f_print(fout, "\t  }\n");
+
+				}
+			    }
+			flag = GET;
+		}
+		f_print(fout, "\t return(TRUE);\n\t}\n\n");
+
+		/* now take care of XDR_FREE case */
+
+		for (dl = def->def.st.decls; dl != NULL; dl = dl->next)
+			print_stat(1, &dl->decl);
+	}
+}
+ 
+
+
+
+static void
+emit_typedef(definition *def)
+{
+	char *prefix = def->def.ty.old_prefix;
+	char *type = def->def.ty.old_type;
+	char *amax = def->def.ty.array_max;
+	relation rel = def->def.ty.rel;
+
+
+	  print_ifstat(1, prefix, type, rel, amax, "objp", def->def_name);
+}
+
+static void
+print_stat(int indent, declaration *dec)
+{
+	char *prefix = dec->prefix;
+	char *type = dec->type;
+	char *amax = dec->array_max;
+	relation rel = dec->rel;
+	char name[256];
+
+	if (isvectordef(type, rel)) {
+		s_print(name, "objp->%s", dec->name);
+	} else {
+		s_print(name, "&objp->%s", dec->name);
+	}
+	print_ifstat(indent, prefix, type, rel, amax, name, dec->name);
+}
+
+
+static void
+emit_inline(declaration *decl, int flag)
+{
+
+	/*check whether an array or not */
+
+	switch (decl->rel) {
+	case REL_ALIAS:
+		emit_single_in_line(decl, flag, REL_ALIAS);
+		break;
+	case REL_VECTOR:
+		f_print(fout, "\t\t{ register %s *genp; \n", decl->type);
+		f_print(fout, "\t\t  int i;\n");
+		f_print(fout, "\t\t  for ( i = 0,genp=objp->%s;\n \t\t\ti < %s; i++){\n\t\t",
+			decl->name, decl->array_max);
+		emit_single_in_line(decl, flag, REL_VECTOR);
+		f_print(fout, "\t\t   }\n\t\t };\n");
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+emit_single_in_line(declaration *decl, int flag, relation rel)
+{
+	char *upp_case;
+	int freed=0;
+
+	if(flag == PUT)
+		f_print(fout,"\t\t (void) IXDR_PUT_");
+	else    
+		if(rel== REL_ALIAS)
+			f_print(fout,"\t\t objp->%s = IXDR_GET_",decl->name);
+		else
+			f_print(fout,"\t\t *genp++ = IXDR_GET_");
+
+	upp_case=upcase(decl->type);
+
+	/* hack  - XX */
+	if(strcmp(upp_case,"INT") == 0)
+	{
+		free(upp_case);
+		freed=1;
+		upp_case="INT32";
+	}
+
+	if(strcmp(upp_case,"U_INT") == 0)
+	{
+		free(upp_case);
+		freed=1;
+		upp_case="U_INT32";
+	}
+
+
+	if(flag == PUT) 
+		if(rel== REL_ALIAS)
+			f_print(fout,"%s(buf,objp->%s);\n",upp_case,decl->name);
+		else
+			f_print(fout,"%s(buf,*genp++);\n",upp_case);
+
+	else
+		f_print(fout,"%s(buf);\n",upp_case);
+	if(!freed)
+		free(upp_case);
+
+}
+
+
+static char *
+upcase(char *str)
+{
+	char           *ptr, *hptr;
+
+
+	ptr = (char *) malloc(strlen(str)+1);
+	if (ptr == (char *) NULL) {
+		f_print(stderr, "malloc failed \n");
+		exit(1);
+	};
+
+	hptr = ptr;
+	while (*str != '\0')
+		*ptr++ = toupper(*str++);
+
+	*ptr = '\0';
+	return (hptr);
+
+}
diff --git a/rpcgen/rpc_hout.c b/rpcgen/rpc_hout.c
new file mode 100644
index 0000000..ea1cb24
--- /dev/null
+++ b/rpcgen/rpc_hout.c
@@ -0,0 +1,490 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_hout.c, Header file outputter for the RPC protocol compiler 
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "rpc_output.h"
+
+
+static int	undefined2(char *type, char *stop);
+static void	pxdrfuncdecl(char *name, int pointerp);
+static void	pconstdef(definition *def);
+static void	pargdef(definition *def);
+static void	pstructdef(definition *def);
+static void	puniondef(definition *def);
+static void	pdefine(char *name, char *num);
+static void	puldefine(char *name, char *num);
+static int	define_printed(proc_list *stop, version_list *start);
+static void	pprogramdef(definition *def);
+static void	pprocdef(proc_list *proc, version_list *vp,
+				char *addargtype, int server_p, int mode);
+static void	parglist(proc_list *proc, char *addargtype);
+static void	penumdef(definition *def);
+static void	ptypedef(definition *def);
+
+/*
+ * Print the C-version of an xdr definition 
+ */
+void
+print_datadef(definition *def)
+{
+
+	if (def->def_kind == DEF_PROGRAM )  /* handle data only */
+	        return;
+
+	if (def->def_kind != DEF_CONST) {
+		f_print(fout, "\n");
+	}
+	switch (def->def_kind) {
+	case DEF_STRUCT:
+		pstructdef(def);
+		break;
+	case DEF_UNION:
+		puniondef(def);
+		break;
+	case DEF_ENUM:
+		penumdef(def);
+		break;
+	case DEF_TYPEDEF:
+		ptypedef(def);
+		break;
+	case DEF_PROGRAM:
+		pprogramdef(def);
+		break;
+	case DEF_CONST:
+		pconstdef(def);
+		break;
+	}
+	if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
+	  pxdrfuncdecl( def->def_name,
+		       def->def_kind != DEF_TYPEDEF ||
+		       !isvectordef(def->def.ty.old_type, def->def.ty.rel));
+
+	}
+}
+
+
+void
+print_funcdef(definition *def)
+{
+	switch (def->def_kind) {
+	case DEF_PROGRAM:
+		f_print(fout, "\n");
+		pprogramdef(def);
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+pxdrfuncdecl(char *name, int pointerp)
+{
+	f_print(fout,
+	"#ifdef __cplusplus \n"
+	"extern \"C\" bool_t xdr_%s(XDR *, %s%s);\n"
+	"#elif __STDC__ \n"
+	"extern  bool_t xdr_%s(XDR *, %s%s);\n"
+	"#else /* Old Style C */ \n"
+	"bool_t xdr_%s();\n"
+	"#endif /* Old Style C */ \n\n",
+	name, name, pointerp ? "*" : "",
+	name, name, pointerp ? "*" : "",
+	name);
+}
+
+
+static void
+pconstdef(definition *def)
+{
+	pdefine(def->def_name, def->def.co);
+}
+
+/* print out the definitions for the arguments of functions in the 
+   header file 
+*/
+static  void
+pargdef(definition *def)
+{
+	decl_list *l;
+	version_list *vers;
+	char *name;
+	proc_list *plist;
+
+	
+	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+			for(plist = vers->procs; plist != NULL; 
+			    plist = plist->next) {
+				
+				if (!newstyle || plist->arg_num < 2) {
+					continue; /* old style or single args */
+				}
+				name = plist->args.argname;
+				f_print(fout, "struct %s {\n", name);
+				for (l = plist->args.decls; 
+				     l != NULL; l = l->next) {
+					pdeclaration(name, &l->decl, 1, ";\n" );
+				}
+				f_print(fout, "};\n");
+				f_print(fout, "typedef struct %s %s;\n", name, name);
+				pxdrfuncdecl(name, 0);
+				f_print( fout, "\n" );
+			}
+		}
+
+}
+
+
+static void
+pstructdef(definition *def)
+{
+	decl_list *l;
+	char *name = def->def_name;
+
+	f_print(fout, "struct %s {\n", name);
+	for (l = def->def.st.decls; l != NULL; l = l->next) {
+		pdeclaration(name, &l->decl, 1, ";\n");
+	}
+	f_print(fout, "};\n");
+	f_print(fout, "typedef struct %s %s;\n", name, name);
+}
+
+static void
+puniondef(definition *def)
+{
+	case_list      *l;
+	char           *name = def->def_name;
+	declaration    *decl;
+
+	f_print(fout, "struct %s {\n", name);
+	decl = &def->def.un.enum_decl;
+	if (streq(decl->type, "bool")) {
+		f_print(fout, "\tbool_t %s;\n", decl->name);
+	} else {
+		f_print(fout, "\t%s %s;\n", decl->type, decl->name);
+	}
+	f_print(fout, "\tunion {\n");
+	for (l = def->def.un.cases; l != NULL; l = l->next) {
+		if (l->contflag == 0)
+			pdeclaration(name, &l->case_decl, 2, ";\n");
+	}
+	decl = def->def.un.default_decl;
+	if (decl && !streq(decl->type, "void")) {
+		pdeclaration(name, decl, 2, ";\n");
+	}
+	f_print(fout, "\t} %s_u;\n", name);
+	f_print(fout, "};\n");
+	f_print(fout, "typedef struct %s %s;\n", name, name);
+}
+
+static void
+pdefine(char *name, char *num)
+{
+	f_print(fout, "#define %s %s\n", name, num);
+}
+
+static void
+puldefine(char *name, char *num)
+{
+	f_print(fout, "#define %s ((u_int32_t)%s)\n", name, num);
+}
+
+static int
+define_printed(proc_list *stop, version_list *start)
+{
+	version_list *vers;
+	proc_list *proc;
+
+	for (vers = start; vers != NULL; vers = vers->next) {
+		for (proc = vers->procs; proc != NULL; proc = proc->next) {
+			if (proc == stop) {
+				return (0);
+			} else if (streq(proc->proc_name, stop->proc_name)) {
+				return (1);
+			}
+		}
+	}
+	abort();
+	/* NOTREACHED */
+}
+
+static void
+pprogramdef(definition *def)
+{
+	version_list   *vers;
+	proc_list      *proc;
+	int             i;
+	char           *ext;
+
+	pargdef(def);
+
+	puldefine(def->def_name, def->def.pr.prog_num);
+	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
+		if (tblflag) {
+			f_print(fout, "extern struct rpcgen_table %s_%s_table[];\n",
+				locase(def->def_name), vers->vers_num);
+			f_print(fout, "extern %s_%s_nproc;\n",
+				locase(def->def_name), vers->vers_num);
+		}
+		puldefine(vers->vers_name, vers->vers_num);
+
+		/*
+		 * Print out 3 definitions, one for ANSI-C, another for C++,
+		 * a third for old style C
+		 */
+
+		for (i = 0; i < 3; i++) {
+			if (i == 0) {
+				f_print(fout, "\n#ifdef __cplusplus\n");
+				ext = "extern \"C\" ";
+			} else if (i == 1) {
+				f_print(fout, "\n#elif __STDC__\n");
+				ext = "extern  ";
+			} else {
+				f_print(fout, "\n#else /* Old Style C */ \n");
+				ext = "extern  ";
+			}
+
+
+			for (proc = vers->procs; proc != NULL; proc = proc->next) {
+				if (!define_printed(proc, def->def.pr.versions)) {
+					puldefine(proc->proc_name, proc->proc_num);
+				}
+				f_print(fout, "%s", ext);
+				pprocdef(proc, vers, "CLIENT *", 0, i);
+				f_print(fout, "%s", ext);
+				pprocdef(proc, vers, "struct svc_req *", 1, i);
+
+			}
+
+		}
+		f_print(fout, "#endif /* Old Style C */ \n");
+	}
+}
+
+static void
+pprocdef(proc_list *proc, version_list *vp, char *addargtype,
+				int server_p, int mode)
+{
+	ptype(proc->res_prefix, proc->res_type, 1);
+	f_print(fout, "* ");
+	if (server_p)
+		pvname_svc(proc->proc_name, vp->vers_num);
+	else
+		pvname(proc->proc_name, vp->vers_num);
+
+	/*
+	 * mode  0 == cplusplus, mode  1 = ANSI-C, mode 2 = old style C
+	 */
+	if (mode == 0 || mode == 1)
+		parglist(proc, addargtype);
+	else
+		f_print(fout, "();\n");
+}
+
+
+
+/* print out argument list of procedure */
+static void
+parglist(proc_list *proc, char *addargtype)
+{
+	decl_list      *dl;
+
+	f_print(fout, "(");
+
+	if (proc->arg_num < 2 && newstyle &&
+		streq(proc->args.decls->decl.type, "void")) {
+		/* 0 argument in new style:  do nothing */
+	} else {
+		for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
+			ptype(dl->decl.prefix, dl->decl.type, 1);
+			if (!newstyle)
+				f_print(fout, "*");	/* old style passes by reference */
+
+			f_print(fout, ", ");
+		}
+	}
+
+	f_print(fout, "%s);\n", addargtype);
+}
+
+static void
+penumdef(definition *def)
+{
+	char *name = def->def_name;
+	enumval_list *l;
+	char *last = NULL;
+	int count = 0;
+
+	f_print(fout, "enum %s {\n", name);
+	for (l = def->def.en.vals; l != NULL; l = l->next) {
+		f_print(fout, "\t%s", l->name);
+		if (l->assignment) {
+			f_print(fout, " = %s", l->assignment);
+			last = l->assignment;
+			count = 1;
+		} else {
+			if (last == NULL) {
+				f_print(fout, " = %d", count++);
+			} else {
+				f_print(fout, " = %s + %d", last, count++);
+			}
+		}
+		f_print(fout, ",\n");
+	}
+	f_print(fout, "};\n");
+	f_print(fout, "typedef enum %s %s;\n", name, name);
+}
+
+static void
+ptypedef(definition *def)
+{
+	char *name = def->def_name;
+	char *old = def->def.ty.old_type;
+	char prefix[8];	/* enough to contain "struct ", including NUL */
+	relation rel = def->def.ty.rel;
+
+
+	if (!streq(name, old)) {
+		if (streq(old, "string")) {
+			old = "char";
+			rel = REL_POINTER;
+		} else if (streq(old, "opaque")) {
+			old = "char";
+		} else if (streq(old, "bool")) {
+			old = "bool_t";
+		}
+		if (undefined2(old, name) && def->def.ty.old_prefix) {
+			s_print(prefix, "%s ", def->def.ty.old_prefix);
+		} else {
+			prefix[0] = 0;
+		}
+		f_print(fout, "typedef ");
+		switch (rel) {
+		case REL_ARRAY:
+			f_print(fout, "struct {\n");
+			f_print(fout, "\tu_int %s_len;\n", name);
+			f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name);
+			f_print(fout, "} %s", name);
+			break;
+		case REL_POINTER:
+			f_print(fout, "%s%s *%s", prefix, old, name);
+			break;
+		case REL_VECTOR:
+			f_print(fout, "%s%s %s[%s]", prefix, old, name,
+				def->def.ty.array_max);
+			break;
+		case REL_ALIAS:
+			f_print(fout, "%s%s %s", prefix, old, name);
+			break;
+		}
+		f_print(fout, ";\n");
+	}
+}
+
+void
+pdeclaration(char *name, declaration *dec, int tab, char *separator)
+{
+	char buf[8];	/* enough to hold "struct ", include NUL */
+	char *prefix;
+	char *type;
+
+	if (streq(dec->type, "void")) {
+		return;
+	}
+	tabify(fout, tab);
+	if (streq(dec->type, name) && !dec->prefix) {
+		f_print(fout, "struct ");
+	}
+	if (streq(dec->type, "string")) {
+		f_print(fout, "char *%s", dec->name);
+	} else {
+		prefix = "";
+		if (streq(dec->type, "bool")) {
+			type = "bool_t";
+		} else if (streq(dec->type, "opaque")) {
+			type = "char";
+		} else {
+			if (dec->prefix) {
+				s_print(buf, "%s ", dec->prefix);
+				prefix = buf;
+			}
+			type = dec->type;
+		}
+		switch (dec->rel) {
+		case REL_ALIAS:
+			f_print(fout, "%s%s %s", prefix, type, dec->name);
+			break;
+		case REL_VECTOR:
+			f_print(fout, "%s%s %s[%s]", prefix, type, dec->name,
+				dec->array_max);
+			break;
+		case REL_POINTER:
+			f_print(fout, "%s%s *%s", prefix, type, dec->name);
+			break;
+		case REL_ARRAY:
+			f_print(fout, "struct {\n");
+			tabify(fout, tab);
+			f_print(fout, "\tu_int %s_len;\n", dec->name);
+			tabify(fout, tab);
+			f_print(fout, "\t%s%s *%s_val;\n", prefix, type, dec->name);
+			tabify(fout, tab);
+			f_print(fout, "} %s", dec->name);
+			break;
+		}
+	}
+	f_print(fout, separator );
+}
+
+static int
+undefined2(char *type, char *stop)
+{
+	list *l;
+	definition *def;
+
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			if (streq(def->def_name, stop)) {
+				return (1);
+			} else if (streq(def->def_name, type)) {
+				return (0);
+			}
+		}
+	}
+	return (1);
+}
diff --git a/rpcgen/rpc_main.c b/rpcgen/rpc_main.c
new file mode 100644
index 0000000..28aa60c
--- /dev/null
+++ b/rpcgen/rpc_main.c
@@ -0,0 +1,1067 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_main.c 1.30 89/03/30 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_main.c, Top level of the RPC protocol compiler. 
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <errno.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "rpc_scan.h"
+
+struct commandline {
+	int cflag;		/* xdr C routines */
+	int hflag;		/* header file */
+	int lflag;		/* client side stubs */
+	int mflag;		/* server side stubs */
+	int nflag;		/* netid flag */
+	int sflag;		/* server stubs for the given transport */
+	int tflag;		/* dispatch Table file */
+	int Ssflag;		/* produce server sample code */
+	int Scflag;		/* produce client sample code */
+	char *infile;		/* input module name */
+	char *outfile;		/* output module name */
+};
+
+static char *	extendfile(char *file, char *ext);
+static void	open_output(char *infile, char *outfile);
+static void	add_warning(void);
+static void	clear_args(void);
+static void	open_input(char *infile, char *define);
+static int	check_nettype(char *name, char **list_to_check);
+static void	c_output(char *infile, char *define, int extend, char *outfile);
+static void	c_initialize(void);
+static char *	generate_guard(char *pathname);
+static void	h_output(char *infile, char *define, int extend, char *outfile);
+static void	s_output(int argc, char **argv, char *infile,
+			char *define, int extend, char *outfile,
+			int nomain, int netflag);
+static void	l_output(char *infile, char *define, int extend, char *outfile);
+static void	t_output(char *infile, char *define, int extend, char *outfile);
+static void	svc_output(char *, char *, int, char *);
+static void	clnt_output(char *, char *, int, char *);
+static int	do_registers(int argc, char **argv);
+static void	addarg(char *cp);
+static void	putarg(int where, char *cp);
+static void	checkfiles(char *infile, char *outfile);
+static int	parseargs(int argc, char **argv, struct commandline *cmd);
+static void	usage(void);
+static void	options_usage(void);
+
+/*
+extern void  write_sample_svc();
+int write_sample_clnt();
+void write_sample_clnt_main();
+
+static svc_output();
+ */
+
+#define EXTEND	1		/* alias for TRUE */
+#define DONT_EXTEND	0		/* alias for FALSE */
+
+#define SVR4_CPP "/usr/ccs/lib/cpp"
+#define SUNOS_CPP "/lib/cpp"
+static int cppDefined = 0;          /* explicit path for C preprocessor */
+
+
+static char *cmdname;
+
+static char *svcclosetime = "120";
+static char *CPP = SVR4_CPP;
+static char CPPFLAGS[] = "-C";
+static char pathbuf[MAXPATHLEN + 1];
+static char *allv[] = {
+	"rpcgen", "-s", "udp", "-s", "tcp",
+};
+static int allc = sizeof(allv)/sizeof(allv[0]);
+static char *allnv[] = {
+	"rpcgen", "-s", "netpath",
+};
+static int allnc = sizeof(allnv)/sizeof(allnv[0]);
+
+/*
+ * machinations for handling expanding argument list
+ */
+#if 0
+static void addarg();		/* add another argument to the list */
+static void putarg();		/* put argument at specified location  */
+static void clear_args();	/* clear argument list */
+static void checkfiles();	/* check if out file already exists */
+#endif
+
+
+
+#define ARGLISTLEN	20
+#define FIXEDARGS         2
+
+static char *arglist[ARGLISTLEN];
+static int argcount = FIXEDARGS;
+
+
+int nonfatalerrors;	/* errors */
+int inetdflag/* = 1*/;	/* Support for inetd */ /* is now the default */
+int pmflag;		/* Support for port monitors */
+int logflag;		/* Use syslog instead of fprintf for errors */
+int tblflag;		/* Support for dispatch table file */
+
+/* length at which to start doing an inline */
+#define INLINE 3
+
+int Inline = INLINE;	/* length at which to start doing an inline. 3 = default
+			 * if 0, no xdr_inline code */
+
+int indefinitewait;	/* If started by port monitors, hang till it wants */
+int exitnow;		/* If started by port monitors, exit after the call */
+int timerflag;		/* TRUE if !indefinite && !exitnow */
+int newstyle;           /* newstyle of passing arguments (by value) */
+int Cflag = 0 ;         /* ANSI C syntax */
+static int allfiles;    /* generate all files */
+#ifdef linux
+int tirpcflag = 0;	/* no tirpc by default */
+#else
+int tirpcflag = 1;      /* generating code for tirpc, by default */
+#endif
+
+int
+main(int argc, char **argv)
+{
+	struct commandline cmd;
+
+	(void) memset((char *) &cmd, 0, sizeof(struct commandline));
+	clear_args();
+	if (!parseargs(argc, argv, &cmd))
+		usage();
+
+	if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
+		cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) {
+		checkfiles(cmd.infile, cmd.outfile);
+	} else
+		checkfiles(cmd.infile, NULL);
+
+	if (cmd.cflag) {
+		c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
+	} else if (cmd.hflag) {
+		h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
+	} else if (cmd.lflag) {
+		l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
+	} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
+		s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
+			cmd.outfile, cmd.mflag, cmd.nflag);
+	} else if (cmd.tflag) {
+		t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
+	} else if (cmd.Ssflag) {
+		svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
+	} else if (cmd.Scflag) {
+		clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
+	} else {
+		/* the rescans are required, since cpp may effect input */
+		c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
+		reinitialize();
+		h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
+		reinitialize();
+		l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
+		reinitialize();
+		if (inetdflag || !tirpcflag)
+			s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
+				"_svc.c", cmd.mflag, cmd.nflag);
+		else
+			s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
+				EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
+		if (tblflag) {
+			reinitialize();
+			t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
+		}
+		if (allfiles) {
+			reinitialize();
+			svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
+		}
+		if (allfiles) {
+			reinitialize();
+			clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
+		}
+	}
+	exit(nonfatalerrors);
+	/* NOTREACHED */
+}
+
+/*
+ * add extension to filename 
+ */
+static char *
+extendfile(char *file, char *ext)
+{
+	char *res;
+	char *p;
+
+	res = alloc(strlen(file) + strlen(ext) + 1);
+	if (res == NULL) {
+		abort();
+	}
+	p = strrchr(file, '.');
+	if (p == NULL) {
+		p = file + strlen(file);
+	}
+	(void) strcpy(res, file);
+	(void) strcpy(res + (p - file), ext);
+	return (res);
+}
+
+/*
+ * Open output file with given extension 
+ */
+static void
+open_output(char *infile, char *outfile)
+{
+
+	if (outfile == NULL) {
+		fout = stdout;
+		return;
+	}
+
+	if (infile != NULL && streq(outfile, infile)) {
+		f_print(stderr, "%s: output would overwrite %s\n", cmdname,
+			infile);
+		crash();
+	}
+	fout = fopen(outfile, "w");
+	if (fout == NULL) {
+		f_print(stderr, "%s: unable to open ", cmdname);
+		perror(outfile);
+		crash();
+	}
+	record_open(outfile);
+
+}
+
+static void
+add_warning(void)
+{
+	f_print(fout, "/*\n");
+	f_print(fout, " * Please do not edit this file.\n");
+	f_print(fout, " * It was generated using rpcgen.\n");
+	f_print(fout, " */\n\n");
+}
+
+/* clear list of arguments */
+static void
+clear_args(void)
+{
+  int i;
+  for( i=FIXEDARGS; i<ARGLISTLEN; i++ )
+    arglist[i] = NULL;
+  argcount = FIXEDARGS;
+}
+
+/*
+ * Open input file with given define for C-preprocessor 
+ */
+static void
+open_input(char *infile, char *define)
+{
+	int pd[2];
+
+	infilename = (infile == NULL) ? "<stdin>" : infile;
+	(void) pipe(pd);
+	switch (fork()) {
+	case 0:
+		putarg(0, "cpp");
+		putarg(1, CPPFLAGS);
+		addarg(define);
+		addarg(infile);
+		addarg((char *)NULL);
+		(void) close(1);
+		(void) dup2(pd[1], 1);
+		(void) close(pd[0]);
+		if (cppDefined)
+			execv(CPP, arglist);
+		else {
+			execvp("cpp", arglist);
+			if (errno == ENOENT)
+				execvp(SVR4_CPP, arglist);
+			if (errno == ENOENT)
+				execvp(SUNOS_CPP, arglist);
+		}
+		perror("execv");
+		exit(1);
+	case -1:
+		perror("fork");
+		exit(1);
+	}
+	(void) close(pd[1]);
+	fin = fdopen(pd[0], "r");
+	if (fin == NULL) {
+		f_print(stderr, "%s: ", cmdname);
+		perror(infilename);
+		crash();
+	}
+}
+
+/* valid tirpc nettypes */
+static char*	valid_ti_nettypes[] =
+{
+	"netpath",
+	"visible",
+	"circuit_v",
+	"datagram_v",
+	"circuit_n",
+	"datagram_n",
+	"udp",
+	"tcp",
+	"raw",
+	NULL
+};
+
+/* valid inetd nettypes */
+static char* valid_i_nettypes[] =
+{
+	"udp",
+	"tcp",
+	NULL
+};
+
+static int
+check_nettype(char *name, char **list_to_check)
+{
+  int i;
+  for( i = 0; list_to_check[i] != NULL; i++ ) {
+	  if( strcmp( name, list_to_check[i] ) == 0 ) {
+	    return 1;
+	  }
+  }
+  f_print( stderr, "illegal nettype :\'%s\'\n", name );
+  return 0;
+}
+
+/*
+ * Compile into an XDR routine output file
+ */
+
+static void
+c_output(char *infile, char *define, int extend, char *outfile)
+{
+	definition *def;
+	char *include;
+	char *outfilename;
+	long tell;
+
+	c_initialize();
+	open_input(infile, define);	
+	outfilename = extend ? extendfile(infile, outfile) : outfile;
+	open_output(infile, outfilename);
+	add_warning();
+	if (infile && (include = extendfile(infile, ".h"))) {
+		f_print(fout, "#include \"%s\"\n", include);
+		free(include);
+		/* .h file already contains rpc/rpc.h */
+	} else
+	  f_print(fout, "#include <rpc/rpc.h>\n");
+	tell = ftell(fout);
+	while ((def = get_definition()) != NULL) {
+		emit(def);
+	}
+	if (extend && tell == ftell(fout)) {
+		(void) unlink(outfilename);
+	}
+}
+
+
+static void
+c_initialize(void)
+{
+
+  /* add all the starting basic types */
+
+  add_type(1,"int");
+  add_type(1,"int32_t");
+  add_type(1,"short");
+  add_type(1,"bool");
+
+  add_type(1,"u_int");
+  add_type(1,"u_int32_t");
+  add_type(1,"u_short");
+
+}
+
+char rpcgen_table_dcl[] = "struct rpcgen_table {\n\
+	char	*(*proc)();\n\
+	xdrproc_t	xdr_arg;\n\
+	unsigned	len_arg;\n\
+	xdrproc_t	xdr_res;\n\
+	unsigned	len_res;\n\
+};\n";
+
+
+static char *
+generate_guard(char *pathname)
+{
+        char* filename, *guard, *tmp;
+
+	filename = strrchr(pathname, '/' );  /* find last component */
+	filename = ((filename == 0) ? pathname : filename+1);
+	guard = strdup(filename);
+	/* convert to upper case */
+	tmp = guard;
+	while (*tmp) {
+		if (islower(*tmp))
+			*tmp = toupper(*tmp);
+		tmp++;
+	}
+		
+	guard = extendfile(guard, "_H_RPCGEN");
+	return( guard );
+}
+
+/*
+ * Compile into an XDR header file
+ */
+static void
+h_output(char *infile, char *define, int extend, char *outfile)
+{
+	definition *def;
+	char *outfilename;
+	long tell;
+	char *guard;
+	list *l;
+
+	open_input(infile, define);
+	outfilename =  extend ? extendfile(infile, outfile) : outfile;
+	open_output(infile, outfilename);
+	add_warning();
+	guard = generate_guard(  outfilename ? outfilename: infile );
+
+	f_print(fout,"#ifndef _%s\n#define _%s\n\n", guard,
+		guard);
+
+	f_print(fout, "#include <rpc/rpc.h>\n\n");
+
+	f_print(fout, "#ifndef IXDR_GET_INT32\n");
+	f_print(fout, "#define IXDR_GET_INT32(buf) IXDR_GET_LONG((buf))\n");
+	f_print(fout, "#endif\n");
+	f_print(fout, "#ifndef IXDR_PUT_INT32\n");
+	f_print(fout, "#define IXDR_PUT_INT32(buf, v) IXDR_PUT_LONG((buf), (v))\n");
+	f_print(fout, "#endif\n");
+	f_print(fout, "#ifndef IXDR_GET_U_INT32\n");
+	f_print(fout, "#define IXDR_GET_U_INT32(buf) IXDR_GET_U_LONG((buf))\n");
+	f_print(fout, "#endif\n");
+	f_print(fout, "#ifndef IXDR_PUT_U_INT32\n");
+	f_print(fout, "#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_U_LONG((buf), (v))\n");
+	f_print(fout, "#endif\n");
+
+	tell = ftell(fout);
+	/* print data definitions */
+	while ((def = get_definition()) != NULL) {
+		print_datadef(def);
+	}
+
+	/* print function declarations.  
+	   Do this after data definitions because they might be used as
+	   arguments for functions */
+	for (l = defined; l != NULL; l = l->next) {
+		print_funcdef(l->val);
+	}
+	if (extend && tell == ftell(fout)) {
+		(void) unlink(outfilename);
+	} else if (tblflag) {
+		f_print(fout, rpcgen_table_dcl);
+	}
+	f_print(fout, "\n#endif /* !_%s */\n", guard);
+}
+
+/*
+ * Compile into an RPC service
+ */
+static void
+s_output(int argc, char **argv, char *infile, char *define, int extend,
+			char *outfile, int nomain, int netflag)
+{
+	char *include;
+	definition *def;
+	int foundprogram = 0;
+	char *outfilename;
+
+	open_input(infile, define);
+	outfilename = extend ? extendfile(infile, outfile) : outfile;
+	open_output(infile, outfilename);
+	add_warning();
+	if (infile && (include = extendfile(infile, ".h"))) {
+		f_print(fout, "#include \"%s\"\n", include);
+		free(include);
+	} else
+	  f_print(fout, "#include <rpc/rpc.h>\n");
+
+	f_print(fout, "#include <stdio.h>\n");
+	f_print(fout, "#include <stdlib.h>/* getenv, exit */\n"); 
+	if (Cflag) {
+		f_print (fout, "#include <rpc/pmap_clnt.h> /* for pmap_unset */\n");
+		f_print (fout, "#include <string.h> /* strcmp */ \n"); 
+	}
+	if (strcmp(svcclosetime, "-1") == 0)
+		indefinitewait = 1;
+	else if (strcmp(svcclosetime, "0") == 0)
+		exitnow = 1;
+	else if (inetdflag || pmflag) {
+		f_print(fout, "#include <signal.h>\n");
+	  timerflag = 1;
+	}
+
+#ifndef linux
+	if( !tirpcflag && inetdflag )
+	  f_print(fout, "#include <sys/ttycom.h>/* TIOCNOTTY */\n");
+#else
+	if( !tirpcflag )
+	  f_print(fout, "#include <sys/ioctl.h>/* TIOCNOTTY */\n");
+#endif
+	if( Cflag && (inetdflag || pmflag ) ) {
+	  f_print(fout, "#ifdef __cplusplus\n");
+	  f_print(fout, "#include <sysent.h> /* getdtablesize, open */\n"); 
+	  f_print(fout, "#endif /* __cplusplus */\n");
+	  
+	  if( tirpcflag )
+	    f_print(fout, "#include <unistd.h> /* setsid */\n");
+	}
+	if( tirpcflag )
+	  f_print(fout, "#include <sys/types.h>\n");
+
+	f_print(fout, "#include <memory.h>\n");
+#ifndef linux
+	f_print(fout, "#include <stropts.h>\n");
+#endif
+	if (inetdflag || !tirpcflag ) {
+		f_print(fout, "#include <sys/socket.h>\n");
+		f_print(fout, "#include <netinet/in.h>\n");
+	} 
+
+	if ( (netflag || pmflag) && tirpcflag ) {
+		f_print(fout, "#include <netconfig.h>\n");
+	}
+	if (/*timerflag &&*/ tirpcflag)
+		f_print(fout, "#include <sys/resource.h> /* rlimit */\n");
+	if (logflag || inetdflag || pmflag) {
+#ifdef linux
+		f_print(fout, "#include <syslog.h>\n");
+#else
+		f_print(fout, "#ifdef SYSLOG\n");
+		f_print(fout, "#include <syslog.h>\n");
+		f_print(fout, "#else\n");
+		f_print(fout, "#define LOG_ERR 1\n");
+		f_print(fout, "#define openlog(a, b, c)\n");
+		f_print(fout, "#endif\n");
+#endif
+	}
+
+	/* for ANSI-C */
+	f_print(fout, "\n#ifdef __STDC__\n#define SIG_PF void(*)(int)\n#endif\n");
+
+	f_print(fout, "\n#ifdef DEBUG\n#define RPC_SVC_FG\n#endif\n");
+	if (timerflag)
+		f_print(fout, "\n#define _RPCSVC_CLOSEDOWN %s\n", svcclosetime);
+	while ((def = get_definition()) != NULL) {
+		foundprogram |= (def->def_kind == DEF_PROGRAM);
+	}
+	if (extend && !foundprogram) {
+		(void) unlink(outfilename);
+		return;
+	}
+	write_most(infile, netflag, nomain);
+	if (!nomain) {
+		if( !do_registers(argc, argv) ) {
+		  if (outfilename)
+		    (void) unlink(outfilename);
+		  usage();
+		}
+		write_rest();
+	}
+}
+
+/*
+ * generate client side stubs
+ */
+static void
+l_output(char *infile, char *define, int extend, char *outfile)
+{
+	char *include;
+	definition *def;
+	int foundprogram = 0;
+	char *outfilename;
+
+	open_input(infile, define);
+	outfilename = extend ? extendfile(infile, outfile) : outfile;
+	open_output(infile, outfilename);
+	add_warning();
+	if (Cflag)
+	  f_print (fout, "#include <memory.h> /* for memset */\n");
+	if (infile && (include = extendfile(infile, ".h"))) {
+		f_print(fout, "#include \"%s\"\n", include);
+		free(include);
+	} else
+	  f_print(fout, "#include <rpc/rpc.h>\n");
+	while ((def = get_definition()) != NULL) {
+		foundprogram |= (def->def_kind == DEF_PROGRAM);
+	}
+	if (extend && !foundprogram) {
+		(void) unlink(outfilename);
+		return;
+	}
+	write_stubs();
+}
+
+/*
+ * generate the dispatch table
+ */
+static void
+t_output(char *infile, char *define, int extend, char *outfile)
+{
+	definition *def;
+	int foundprogram = 0;
+	char *outfilename;
+
+	open_input(infile, define);
+	outfilename = extend ? extendfile(infile, outfile) : outfile;
+	open_output(infile, outfilename);
+	add_warning();
+	while ((def = get_definition()) != NULL) {
+		foundprogram |= (def->def_kind == DEF_PROGRAM);
+	}
+	if (extend && !foundprogram) {
+		(void) unlink(outfilename);
+		return;
+	}
+	write_tables();
+}
+
+/* sample routine for the server template */
+static  void
+svc_output(char *infile, char *define, int extend, char *outfile)
+{
+  definition *def;
+  char *include;
+  char *outfilename;
+  long tell;
+  
+  open_input(infile, define);	
+  outfilename = extend ? extendfile(infile, outfile) : outfile;
+  checkfiles(infile,outfilename); /*check if outfile already exists.
+				  if so, print an error message and exit*/
+  open_output(infile, outfilename);
+  add_sample_msg();
+
+  if (infile && (include = extendfile(infile, ".h"))) {
+    f_print(fout, "#include \"%s\"\n", include);
+    free(include);
+  } else
+    f_print(fout, "#include <rpc/rpc.h>\n");
+
+  tell = ftell(fout);
+  while ((def = get_definition()) != NULL) {
+	  write_sample_svc(def);
+  }
+  if (extend && tell == ftell(fout)) {
+	  (void) unlink(outfilename);
+  }
+}
+
+
+/* sample main routine for client */
+static  void
+clnt_output(char *infile, char *define, int extend, char *outfile)
+{
+	definition     *def;
+	char           *include;
+	char           *outfilename;
+	long            tell;
+	int             has_program = 0;
+
+	open_input(infile, define);
+	outfilename = extend ? extendfile(infile, outfile) : outfile;
+	checkfiles(infile, outfilename);	/*check if outfile already exists.
+				  if so, print an error message and exit*/
+
+	open_output(infile, outfilename);
+	add_sample_msg();
+	if (infile && (include = extendfile(infile, ".h"))) {
+		f_print(fout, "#include \"%s\"\n", include);
+		free(include);
+	} else
+		f_print(fout, "#include <rpc/rpc.h>\n");
+	tell = ftell(fout);
+	while ((def = get_definition()) != NULL) {
+		has_program += write_sample_clnt(def);
+	}
+
+	if (has_program)
+		write_sample_clnt_main();
+
+	if (extend && tell == ftell(fout)) {
+		(void) unlink(outfilename);
+	}
+}
+
+/*
+ * Perform registrations for service output 
+ * Return 0 if failed; 1 otherwise.
+ */
+static int
+do_registers(int argc, char **argv)
+{
+	int             i;
+
+	if (inetdflag || !tirpcflag) {
+		for (i = 1; i < argc; i++) {
+			if (streq(argv[i], "-s")) {
+				if (!check_nettype(argv[i + 1], valid_i_nettypes))
+					return 0;
+				write_inetd_register(argv[i + 1]);
+				i++;
+			}
+		}
+	} else {
+		for (i = 1; i < argc; i++)
+			if (streq(argv[i], "-s")) {
+				if (!check_nettype(argv[i + 1], valid_ti_nettypes))
+					return 0;
+				write_nettype_register(argv[i + 1]);
+				i++;
+			} else if (streq(argv[i], "-n")) {
+				write_netid_register(argv[i + 1]);
+				i++;
+			}
+	}
+	return 1;
+}
+
+/*
+ * Add another argument to the arg list
+ */
+static void
+addarg(char *cp)
+{
+	if (argcount >= ARGLISTLEN) {
+		f_print(stderr, "rpcgen: too many defines\n");
+		crash();
+		/*NOTREACHED*/
+	}
+	arglist[argcount++] = cp;
+
+}
+
+static void
+putarg(int where, char *cp)
+{
+	if (where >= ARGLISTLEN) {
+		f_print(stderr, "rpcgen: arglist coding error\n");
+		crash();
+		/*NOTREACHED*/
+	}
+	arglist[where] = cp;
+	
+}
+
+/*
+ * if input file is stdin and an output file is specified then complain
+ * if the file already exists. Otherwise the file may get overwritten
+ * If input file does not exist, exit with an error 
+ */
+
+static void
+checkfiles(char *infile, char *outfile) 
+{
+
+  struct stat buf;
+
+  if(infile)			/* infile ! = NULL */
+    if(stat(infile,&buf) < 0)
+      {
+	perror(infile);
+	crash();
+      };
+  if (outfile) {
+    if (stat(outfile, &buf) < 0) 
+      return;			/* file does not exist */
+    else {
+      f_print(stderr, 
+	      "file '%s' already exists and may be overwritten\n", outfile);
+      crash();
+    }
+  }
+}
+
+/*
+ * Parse command line arguments 
+ */
+static int
+parseargs(int argc, char **argv, struct commandline *cmd)
+{
+	int i;
+	int j;
+	char c;
+	char flag[(1 << 8 * sizeof(char))];
+	int nflags;
+
+	cmdname = argv[0];
+	cmd->infile = cmd->outfile = NULL;
+	if (argc < 2) {
+		return (0);
+	}
+	allfiles = 0;
+	flag['c'] = 0;
+	flag['h'] = 0;
+	flag['l'] = 0;
+	flag['m'] = 0;
+	flag['o'] = 0;
+	flag['s'] = 0;
+	flag['n'] = 0;
+	flag['t'] = 0;
+	flag['S'] = 0;
+	flag['C'] = 0;
+	for (i = 1; i < argc; i++) {
+		if (argv[i][0] != '-') {
+			if (cmd->infile) {
+			        f_print( stderr, "Cannot specify more than one input file!\n");
+
+				return (0);
+			}
+			cmd->infile = argv[i];
+		} else {
+			for (j = 1; argv[i][j] != 0; j++) {
+				c = argv[i][j];
+				switch (c) {
+				case 'a':
+					allfiles = 1;
+					break;
+				case 'c':
+				case 'h':
+				case 'l':
+				case 'm':
+				case 't':
+					if (flag[(int) c]) {
+						return (0);
+					}
+					flag[(int) c] = 1;
+					break;
+				case 'S':  
+					/* sample flag: Ss or Sc.
+					   Ss means set flag['S'];
+					   Sc means set flag['C']; */
+					c = argv[i][++j];  /* get next char */
+					if( c == 's' )
+					  c = 'S';
+					else if( c == 'c' )
+					  c = 'C';
+					else
+					  return( 0 );
+
+					if (flag[(int) c]) {
+						return (0);
+					}
+					flag[(int) c] = 1;
+					break;
+				case 'C':  /* ANSI C syntax */
+					Cflag = 1;
+					break;
+
+				case 'b':  /* turn TIRPC flag off for
+					    generating backward compatible
+					    */
+					tirpcflag = 0;
+					break;
+
+				case 'I':
+					inetdflag = 1;
+					break;
+				case 'N':
+					newstyle = 1;
+					break;
+				case 'L':
+					logflag = 1;
+					break;
+				case 'K':
+					if (++i == argc) {
+						return (0);
+					}
+					svcclosetime = argv[i];
+					goto nextarg;
+				case 'T':
+					tblflag = 1;
+					break;
+				case 'i' :
+				  	if (++i == argc) {
+						return (0);
+					}
+					Inline = atoi(argv[i]);
+					goto nextarg;
+				case 'n':
+				case 'o':
+				case 's':
+					if (argv[i][j - 1] != '-' || 
+					    argv[i][j + 1] != 0) {
+						return (0);
+					}
+					flag[(int) c] = 1;
+					if (++i == argc) {
+						return (0);
+					}
+					if (c == 's') {
+						if (!streq(argv[i], "udp") &&
+						    !streq(argv[i], "tcp")) {
+							return (0);
+						}
+					} else if (c == 'o') {
+						if (cmd->outfile) {
+							return (0);
+						}
+						cmd->outfile = argv[i];
+					}
+					goto nextarg;
+				case 'D':
+					if (argv[i][j - 1] != '-') {
+						return (0);
+					}
+					(void) addarg(argv[i]);
+					goto nextarg;
+				case 'Y':
+					if (++i == argc) {
+						return (0);
+					}
+					(void) strcpy(pathbuf, argv[i]);
+					(void) strcat(pathbuf, "/cpp");
+					CPP = pathbuf;
+					cppDefined = 1;
+					goto nextarg;
+
+
+
+				default:
+					return (0);
+				}
+			}
+	nextarg:
+			;
+		}
+	}
+
+	cmd->cflag = flag['c'];
+	cmd->hflag = flag['h'];
+	cmd->lflag = flag['l'];
+	cmd->mflag = flag['m'];
+	cmd->nflag = flag['n'];
+	cmd->sflag = flag['s'];
+	cmd->tflag = flag['t'];
+	cmd->Ssflag = flag['S'];
+	cmd->Scflag = flag['C'];
+
+	if( tirpcflag ) {
+	  pmflag = inetdflag ? 0 : 1;	  /* pmflag or inetdflag is always TRUE */
+	  if( (inetdflag && cmd->nflag)) { /* netid not allowed with inetdflag */
+	    f_print(stderr, "Cannot use netid flag with inetd flag!\n");
+	    return (0);
+	  }
+	} else {  /* 4.1 mode */
+	  pmflag = 0;               /* set pmflag only in tirpcmode */
+	  inetdflag = 1;            /* inetdflag is TRUE by default */
+	  if( cmd->nflag ) {          /* netid needs TIRPC */
+	    f_print( stderr, "Cannot use netid flag without TIRPC!\n");
+	    return( 0 );
+	  }
+	}
+
+	if( newstyle && ( tblflag || cmd->tflag) ) {
+	  f_print( stderr, "Cannot use table flags with newstyle!\n");
+	  return( 0 );
+	}
+
+	/* check no conflicts with file generation flags */
+	nflags = cmd->cflag + cmd->hflag + cmd->lflag + cmd->mflag +
+		cmd->sflag + cmd->nflag + cmd->tflag + cmd->Ssflag + cmd->Scflag;
+
+	if (nflags == 0) {
+		if (cmd->outfile != NULL || cmd->infile == NULL) {
+			return (0);
+		}
+	} else if (nflags > 1) {
+	        f_print( stderr, "Cannot have more than one file generation flag!\n");
+		return (0);
+	}
+	return (1);
+}
+
+static void
+usage(void)
+{
+	f_print(stderr, "usage:  %s infile\n", cmdname);
+	f_print(stderr, "\t%s [-a][-b][-C][-Dname[=value]] -i size  [-I [-K seconds]] [-L][-N][-T] infile\n",
+			cmdname);
+	f_print(stderr, "\t%s [-c | -h | -l | -m | -t | -Sc | -Ss] [-o outfile] [infile]\n",
+			cmdname);
+	f_print(stderr, "\t%s [-s nettype]* [-o outfile] [infile]\n", cmdname);
+	f_print(stderr, "\t%s [-n netid]* [-o outfile] [infile]\n", cmdname);
+	options_usage();
+	exit(1);
+}
+
+static void
+options_usage(void)
+{
+	f_print(stderr, "options:\n");
+	f_print(stderr, "-a\t\tgenerate all files, including samples\n");
+	f_print(stderr, "-b\t\tbackward compatibility mode (generates code for SunOS 4.1)\n");
+	f_print(stderr, "-c\t\tgenerate XDR routines\n");
+	f_print(stderr, "-C\t\tANSI C mode\n");
+	f_print(stderr, "-Dname[=value]\tdefine a symbol (same as #define)\n");
+	f_print(stderr, "-h\t\tgenerate header file\n");
+	f_print(stderr, "-i size\t\tsize at which to start generating inline code\n");
+	f_print(stderr, "-I\t\tgenerate code for inetd support in server (for SunOS 4.1)\n");
+	f_print(stderr, "-K seconds\tserver exits after K seconds of inactivity\n");
+	f_print(stderr, "-l\t\tgenerate client side stubs\n");
+	f_print(stderr, "-L\t\tserver errors will be printed to syslog\n");
+	f_print(stderr, "-m\t\tgenerate server side stubs\n");
+	f_print(stderr, "-n netid\tgenerate server code that supports named netid\n");
+	f_print(stderr, "-N\t\tsupports multiple arguments and call-by-value\n");
+	f_print(stderr, "-o outfile\tname of the output file\n");
+	f_print(stderr, "-s nettype\tgenerate server code that supports named nettype\n");
+	f_print(stderr, "-Sc\t\tgenerate sample client code that uses remote procedures\n");
+	f_print(stderr, "-Ss\t\tgenerate sample server code that defines remote procedures\n");
+	f_print(stderr, "-t\t\tgenerate RPC dispatch table\n");
+	f_print(stderr, "-T\t\tgenerate code to support RPC dispatch tables\n");
+	f_print(stderr, "-Y path\t\tdirectory name to find C preprocessor (cpp)\n");
+
+	exit(1);
+}
diff --git a/rpcgen/rpc_output.h b/rpcgen/rpc_output.h
new file mode 100644
index 0000000..eb25a60
--- /dev/null
+++ b/rpcgen/rpc_output.h
@@ -0,0 +1,16 @@
+/*
+ * rpc_output.h
+ *
+ * Declarations for output functions
+ *
+ */
+
+#ifndef RPCGEN_NEW_OUTPUT_H
+#define RPCGEN_NEW_OUTPUT_H
+
+void	write_msg_out(void);
+int	nullproc(proc_list *);
+void	printarglist(proc_list *, char *, char *);
+void	pdeclaration(char *, declaration *, int, char *);
+
+#endif /* RPCGEN_NEW_OUTPUT_H */
diff --git a/rpcgen/rpc_parse.c b/rpcgen/rpc_parse.c
new file mode 100644
index 0000000..b53a553
--- /dev/null
+++ b/rpcgen/rpc_parse.c
@@ -0,0 +1,609 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_parse.c 1.8 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_parse.c, Parser for the RPC protocol compiler 
+ * Copyright (C) 1987 Sun Microsystems, Inc.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "rpc/types.h"
+#include "rpc_scan.h"
+#include "rpc_parse.h"
+#include "rpc_util.h"
+
+#define ARGNAME "arg"
+
+/*
+extern char *make_argname();
+extern char *strdup();
+ */
+
+static void	isdefined(definition *defp);
+static void	def_struct(definition *defp);
+static void	def_program(definition *defp);
+static void	def_enum(definition *defp);
+static void	def_const(definition *defp);
+static void	def_union(definition *defp);
+static void	check_type_name(char *name, int new_type);
+static void	def_typedef(definition *defp);
+static void	get_declaration(declaration *dec, defkind dkind);
+static void	get_prog_declaration(declaration *dec, defkind dkind, int num);
+static void	get_type(char **prefixp, char **typep, defkind dkind);
+static void	unsigned_dec(char **typep);
+
+/*
+ * return the next definition you see
+ */
+definition *
+get_definition(void)
+{
+	definition *defp;
+	token tok;
+
+	defp = ALLOC(definition);
+	get_token(&tok);
+	switch (tok.kind) {
+	case TOK_STRUCT:
+		def_struct(defp);
+		break;
+	case TOK_UNION:
+		def_union(defp);
+		break;
+	case TOK_TYPEDEF:
+		def_typedef(defp);
+		break;
+	case TOK_ENUM:
+		def_enum(defp);
+		break;
+	case TOK_PROGRAM:
+		def_program(defp);
+		break;
+	case TOK_CONST:
+		def_const(defp);
+		break;
+	case TOK_EOF:
+		free(defp);
+		return (NULL);
+	default:
+		error("definition keyword expected");
+	}
+	scan(TOK_SEMICOLON, &tok);
+	isdefined(defp);
+	return (defp);
+}
+
+static void
+isdefined(definition *defp)
+{
+	STOREVAL(&defined, defp);
+}
+
+static void
+def_struct(definition *defp)
+{
+	token tok;
+	declaration dec;
+	decl_list *decls;
+	decl_list **tailp;
+
+	defp->def_kind = DEF_STRUCT;
+
+	scan(TOK_IDENT, &tok);
+	defp->def_name = tok.str;
+	scan(TOK_LBRACE, &tok);
+	tailp = &defp->def.st.decls;
+	do {
+		get_declaration(&dec, DEF_STRUCT);
+		decls = ALLOC(decl_list);
+		decls->decl = dec;
+		*tailp = decls;
+		tailp = &decls->next;
+		scan(TOK_SEMICOLON, &tok);
+		peek(&tok);
+	} while (tok.kind != TOK_RBRACE);
+	get_token(&tok);
+	*tailp = NULL;
+}
+
+static void
+def_program(definition *defp)
+{
+	token tok;
+	declaration dec;
+	decl_list *decls;
+	decl_list **tailp;
+	version_list *vlist;
+	version_list **vtailp;
+	proc_list *plist;
+	proc_list **ptailp;
+	int num_args;
+	bool_t isvoid = FALSE; /* whether first argument is void */
+	defp->def_kind = DEF_PROGRAM;
+	scan(TOK_IDENT, &tok);
+	defp->def_name = tok.str;
+	scan(TOK_LBRACE, &tok);
+	vtailp = &defp->def.pr.versions;
+	tailp = &defp->def.st.decls;
+	scan(TOK_VERSION, &tok);
+	do {
+		scan(TOK_IDENT, &tok);
+		vlist = ALLOC(version_list);
+		vlist->vers_name = tok.str;
+		scan(TOK_LBRACE, &tok);
+		ptailp = &vlist->procs;
+		do {
+			/* get result type */
+			plist = ALLOC(proc_list);
+			get_type(&plist->res_prefix, &plist->res_type, 
+				 DEF_PROGRAM);
+			if (streq(plist->res_type, "opaque")) {
+				error("illegal result type");
+			}
+			scan(TOK_IDENT, &tok);
+			plist->proc_name = tok.str;
+			scan(TOK_LPAREN, &tok);
+			/* get args - first one*/
+			num_args = 1;
+			isvoid = FALSE;
+			/* type of DEF_PROGRAM in the first 
+			 * get_prog_declaration and DEF_STURCT in the next
+			 * allows void as argument if it is the only argument
+			 */
+			get_prog_declaration(&dec, DEF_PROGRAM, num_args);
+			if (streq(dec.type, "void"))
+			  isvoid = TRUE;
+			decls = ALLOC(decl_list);
+			plist->args.decls = decls;
+			decls->decl = dec;
+			tailp = &decls->next;
+			/* get args */
+			while(peekscan(TOK_COMMA, &tok)) {
+			  num_args++;
+			  get_prog_declaration(&dec, DEF_STRUCT, 
+					       num_args);
+			  decls = ALLOC(decl_list);
+			  decls->decl = dec;
+			  *tailp = decls;
+			  if (streq(dec.type, "void"))
+			    isvoid = TRUE;
+			  tailp = &decls->next;
+			}
+			/* multiple arguments are only allowed in newstyle */
+			if( !newstyle && num_args > 1 ) {
+			  error("only one argument is allowed" );
+			}
+			if (isvoid && num_args > 1) { 
+			  error("illegal use of void in program definition");
+			}
+			*tailp = NULL;
+			scan(TOK_RPAREN, &tok);
+			scan(TOK_EQUAL, &tok);
+			scan_num(&tok);
+			scan(TOK_SEMICOLON, &tok);
+			plist->proc_num = tok.str;
+			plist->arg_num = num_args;
+			*ptailp = plist;
+			ptailp = &plist->next;
+			peek(&tok);
+		} while (tok.kind != TOK_RBRACE);
+		*ptailp = NULL;
+		*vtailp = vlist;
+		vtailp = &vlist->next;
+		scan(TOK_RBRACE, &tok);
+		scan(TOK_EQUAL, &tok);
+		scan_num(&tok);
+		vlist->vers_num = tok.str;
+		/* make the argument structure name for each arg*/
+		for(plist = vlist->procs; plist != NULL; 
+		    plist = plist->next) {
+			plist->args.argname = make_argname(plist->proc_name,
+							   vlist->vers_num); 
+			/* free the memory ??*/
+		}
+		scan(TOK_SEMICOLON, &tok);
+		scan2(TOK_VERSION, TOK_RBRACE, &tok);
+	} while (tok.kind == TOK_VERSION);
+	scan(TOK_EQUAL, &tok);
+	scan_num(&tok);
+	defp->def.pr.prog_num = tok.str;
+	*vtailp = NULL;
+}
+
+
+static void
+def_enum(definition *defp)
+{
+	token tok;
+	enumval_list *elist;
+	enumval_list **tailp;
+
+	defp->def_kind = DEF_ENUM;
+	scan(TOK_IDENT, &tok);
+	defp->def_name = tok.str;
+	scan(TOK_LBRACE, &tok);
+	tailp = &defp->def.en.vals;
+	do {
+		scan(TOK_IDENT, &tok);
+		elist = ALLOC(enumval_list);
+		elist->name = tok.str;
+		elist->assignment = NULL;
+		scan3(TOK_COMMA, TOK_RBRACE, TOK_EQUAL, &tok);
+		if (tok.kind == TOK_EQUAL) {
+			scan_num(&tok);
+			elist->assignment = tok.str;
+			scan2(TOK_COMMA, TOK_RBRACE, &tok);
+		}
+		*tailp = elist;
+		tailp = &elist->next;
+	} while (tok.kind != TOK_RBRACE);
+	*tailp = NULL;
+}
+
+static void
+def_const(definition *defp)
+{
+	token tok;
+
+	defp->def_kind = DEF_CONST;
+	scan(TOK_IDENT, &tok);
+	defp->def_name = tok.str;
+	scan(TOK_EQUAL, &tok);
+	scan2(TOK_IDENT, TOK_STRCONST, &tok);
+	defp->def.co = tok.str;
+}
+
+static void
+def_union(definition *defp)
+{
+  token tok;
+  declaration dec;
+  case_list *cases;
+  case_list **tailp;
+
+  defp->def_kind = DEF_UNION;
+  scan(TOK_IDENT, &tok);
+  defp->def_name = tok.str;
+  scan(TOK_SWITCH, &tok);
+  scan(TOK_LPAREN, &tok);
+  get_declaration(&dec, DEF_UNION);
+  defp->def.un.enum_decl = dec;
+  tailp = &defp->def.un.cases;
+  scan(TOK_RPAREN, &tok);
+  scan(TOK_LBRACE, &tok);
+  scan(TOK_CASE, &tok);
+  while (tok.kind == TOK_CASE) {
+    scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+    cases = ALLOC(case_list);
+    cases->case_name = tok.str;
+    scan(TOK_COLON, &tok);
+    /* now peek at next token */
+    if(peekscan(TOK_CASE,&tok))
+      {
+
+	do 
+	  {
+	    scan2(TOK_IDENT, TOK_CHARCONST, &tok);
+	    cases->contflag=1;	/* continued case statement */
+	    *tailp = cases;
+	    tailp = &cases->next;
+	    cases = ALLOC(case_list);
+	    cases->case_name = tok.str;
+	    scan(TOK_COLON, &tok);
+      
+	  }while(peekscan(TOK_CASE,&tok));
+      }
+
+    get_declaration(&dec, DEF_UNION);
+    cases->case_decl = dec;
+    cases->contflag=0;		/* no continued case statement */
+    *tailp = cases;
+    tailp = &cases->next;
+    scan(TOK_SEMICOLON, &tok);
+
+    scan3(TOK_CASE, TOK_DEFAULT, TOK_RBRACE, &tok);
+  }
+  *tailp = NULL;
+  if (tok.kind == TOK_DEFAULT) {
+    scan(TOK_COLON, &tok);
+    get_declaration(&dec, DEF_UNION);
+    defp->def.un.default_decl = ALLOC(declaration);
+    *defp->def.un.default_decl = dec;
+    scan(TOK_SEMICOLON, &tok);
+    scan(TOK_RBRACE, &tok);
+  } else {
+    defp->def.un.default_decl = NULL;
+  }
+}
+
+static char* reserved_words[] =
+{
+  "array",
+  "bytes",
+  "destroy",
+  "free",
+  "getpos",
+  "inline",
+  "pointer",
+  "reference",
+  "setpos",
+  "sizeof",
+  "union",
+  "vector",
+  NULL
+  };
+
+static char* reserved_types[] =
+{
+  "opaque",
+  "string",
+  NULL
+  };
+
+/* check that the given name is not one that would eventually result in
+   xdr routines that would conflict with internal XDR routines. */
+static void
+check_type_name(char *name, int new_type)
+{
+  int i;
+  char tmp[100];
+
+  for( i = 0; reserved_words[i] != NULL; i++ ) {
+    if( strcmp( name, reserved_words[i] ) == 0 ) {
+      sprintf(tmp, 
+	      "illegal (reserved) name :\'%s\' in type definition", name );
+      error(tmp);
+    }
+  }
+  if( new_type ) {
+    for( i = 0; reserved_types[i] != NULL; i++ ) {
+      if( strcmp( name, reserved_types[i] ) == 0 ) {
+	sprintf(tmp, 
+		"illegal (reserved) name :\'%s\' in type definition", name );
+	error(tmp);
+      }
+    }
+  }
+}
+
+static void
+def_typedef(definition *defp)
+{
+	declaration dec;
+
+	defp->def_kind = DEF_TYPEDEF;
+	get_declaration(&dec, DEF_TYPEDEF);
+	defp->def_name = dec.name;
+	check_type_name( dec.name, 1 );
+	defp->def.ty.old_prefix = dec.prefix;
+	defp->def.ty.old_type = dec.type;
+	defp->def.ty.rel = dec.rel;
+	defp->def.ty.array_max = dec.array_max;
+}
+
+static void
+get_declaration(declaration *dec, defkind dkind)
+{
+	token tok;
+
+	get_type(&dec->prefix, &dec->type, dkind);
+	dec->rel = REL_ALIAS;
+	if (streq(dec->type, "void")) {
+		return;
+	}
+
+	check_type_name( dec->type, 0 );
+
+	scan2(TOK_STAR, TOK_IDENT, &tok);
+	if (tok.kind == TOK_STAR) {
+		dec->rel = REL_POINTER;
+		scan(TOK_IDENT, &tok);
+	}
+	dec->name = tok.str;
+	if (peekscan(TOK_LBRACKET, &tok)) {
+		if (dec->rel == REL_POINTER) {
+			error("no array-of-pointer declarations -- use typedef");
+		}
+		dec->rel = REL_VECTOR;
+		scan_num(&tok);
+		dec->array_max = tok.str;
+		scan(TOK_RBRACKET, &tok);
+	} else if (peekscan(TOK_LANGLE, &tok)) {
+		if (dec->rel == REL_POINTER) {
+			error("no array-of-pointer declarations -- use typedef");
+		}
+		dec->rel = REL_ARRAY;
+		if (peekscan(TOK_RANGLE, &tok)) {
+			dec->array_max = "~0";	/* unspecified size, use max */
+		} else {
+			scan_num(&tok);
+			dec->array_max = tok.str;
+			scan(TOK_RANGLE, &tok);
+		}
+	}
+	if (streq(dec->type, "opaque")) {
+		if (dec->rel != REL_ARRAY && dec->rel != REL_VECTOR) {
+			error("array declaration expected");
+		}
+	} else if (streq(dec->type, "string")) {
+		if (dec->rel != REL_ARRAY) {
+			error("variable-length array declaration expected");
+		}
+	}
+}
+
+
+static void
+get_prog_declaration(declaration *dec, defkind dkind, int num)
+{
+	token tok;
+	char name[10]; /* argument name */
+
+	if (dkind == DEF_PROGRAM) { 
+	  peek(&tok);
+	  if (tok.kind == TOK_RPAREN) { /* no arguments */
+	    	dec->rel = REL_ALIAS;
+		dec->type = "void";
+		dec->prefix = NULL;
+		dec->name = NULL;
+		return;
+	      }
+	}
+	get_type(&dec->prefix, &dec->type, dkind);
+	dec->rel = REL_ALIAS;
+	if (peekscan(TOK_IDENT, &tok))  /* optional name of argument */
+		strcpy(name, tok.str);
+	else 
+		sprintf(name, "%s%d", ARGNAME, num); /* default name of argument */
+
+	dec->name = (char *) strdup(name); 
+	
+	if (streq(dec->type, "void")) {
+		return;
+	}
+
+	if (streq(dec->type, "opaque")) {
+		error("opaque -- illegal argument type");
+	}
+	if (peekscan(TOK_STAR, &tok)) { 
+	  if (streq(dec->type, "string")) {
+	    error("pointer to string not allowed in program arguments\n");
+	  }
+		dec->rel = REL_POINTER;
+		if (peekscan(TOK_IDENT, &tok))  /* optional name of argument */
+		  dec->name = strdup(tok.str);
+      }
+	  if (peekscan(TOK_LANGLE, &tok)) {
+	    if (!streq(dec->type, "string")) {
+	      error("arrays cannot be declared as arguments to procedures -- use typedef");
+	    }
+		dec->rel = REL_ARRAY;
+		if (peekscan(TOK_RANGLE, &tok)) {
+			dec->array_max = "~0";/* unspecified size, use max */
+		} else {
+			scan_num(&tok);
+			dec->array_max = tok.str;
+			scan(TOK_RANGLE, &tok);
+		}
+	}
+	if (streq(dec->type, "string")) {
+		if (dec->rel != REL_ARRAY) {  /* .x specifies just string as
+					       * type of argument 
+					       * - make it string<>
+					       */
+			dec->rel = REL_ARRAY;
+			dec->array_max = "~0";/* unspecified size, use max */
+		}
+	}
+}
+
+
+
+static void
+get_type(char **prefixp, char **typep, defkind dkind)
+{
+	token tok;
+
+	*prefixp = NULL;
+	get_token(&tok);
+	switch (tok.kind) {
+	case TOK_IDENT:
+		*typep = tok.str;
+		break;
+	case TOK_STRUCT:
+	case TOK_ENUM:
+	case TOK_UNION:
+		*prefixp = tok.str;
+		scan(TOK_IDENT, &tok);
+		*typep = tok.str;
+		break;
+	case TOK_UNSIGNED:
+		unsigned_dec(typep);
+		break;
+	case TOK_SHORT:
+		*typep = "short";
+		(void) peekscan(TOK_INT, &tok);
+		break;
+	case TOK_INT32:
+		*typep = "int32_t";
+		(void) peekscan(TOK_INT, &tok);
+		break;
+	case TOK_VOID:
+		if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
+			error("voids allowed only inside union and program definitions with one argument");
+		}
+		*typep = tok.str;
+		break;
+	case TOK_STRING:
+	case TOK_OPAQUE:
+	case TOK_CHAR:
+	case TOK_INT:
+	case TOK_FLOAT:
+	case TOK_DOUBLE:
+	case TOK_BOOL:
+		*typep = tok.str;
+		break;
+	default:
+		error("expected type specifier");
+	}
+}
+
+static void
+unsigned_dec(char **typep)
+{
+	token tok;
+
+	peek(&tok);
+	switch (tok.kind) {
+	case TOK_CHAR:
+		get_token(&tok);
+		*typep = "u_char";
+		break;
+	case TOK_SHORT:
+		get_token(&tok);
+		*typep = "u_short";
+		(void) peekscan(TOK_INT, &tok);
+		break;
+	case TOK_INT32:
+		get_token(&tok);
+		*typep = "u_int32_";
+		(void) peekscan(TOK_INT, &tok);
+		break;
+	case TOK_INT:
+		get_token(&tok);
+		*typep = "u_int";
+		break;
+	default:
+		*typep = "u_int";
+		break;
+	}
+}
diff --git a/rpcgen/rpc_parse.h b/rpcgen/rpc_parse.h
new file mode 100644
index 0000000..2afae10
--- /dev/null
+++ b/rpcgen/rpc_parse.h
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+/*      @(#)rpc_parse.h  1.3  90/08/29  (C) 1987 SMI   */
+
+/*
+ * rpc_parse.h, Definitions for the RPCL parser 
+ */
+
+enum defkind {
+	DEF_CONST,
+	DEF_STRUCT,
+	DEF_UNION,
+	DEF_ENUM,
+	DEF_TYPEDEF,
+	DEF_PROGRAM
+};
+typedef enum defkind defkind;
+
+typedef char *const_def;
+
+enum relation {
+	REL_VECTOR,	/* fixed length array */
+	REL_ARRAY,	/* variable length array */
+	REL_POINTER,	/* pointer */
+	REL_ALIAS,	/* simple */
+};
+typedef enum relation relation;
+
+struct typedef_def {
+	char *old_prefix;
+	char *old_type;
+	relation rel;
+	char *array_max;
+};
+typedef struct typedef_def typedef_def;
+
+struct enumval_list {
+	char *name;
+	char *assignment;
+	struct enumval_list *next;
+};
+typedef struct enumval_list enumval_list;
+
+struct enum_def {
+	enumval_list *vals;
+};
+typedef struct enum_def enum_def;
+
+struct declaration {
+	char *prefix;
+	char *type;
+	char *name;
+	relation rel;
+	char *array_max;
+};
+typedef struct declaration declaration;
+
+struct decl_list {
+	declaration decl;
+	struct decl_list *next;
+};
+typedef struct decl_list decl_list;
+
+struct struct_def {
+	decl_list *decls;
+};
+typedef struct struct_def struct_def;
+
+struct case_list {
+	char *case_name;
+	int contflag;
+	declaration case_decl;
+	struct case_list *next;
+};
+typedef struct case_list case_list;
+
+struct union_def {
+	declaration enum_decl;
+	case_list *cases;
+	declaration *default_decl;
+};
+typedef struct union_def union_def;
+
+struct arg_list {
+	char *argname; /* name of struct for arg*/
+	decl_list *decls;
+};
+	
+typedef struct arg_list arg_list;
+
+struct proc_list {
+	char *proc_name;
+	char *proc_num;
+	arg_list args;
+	int arg_num;
+	char *res_type;
+	char *res_prefix;
+	struct proc_list *next;
+};
+typedef struct proc_list proc_list;
+
+struct version_list {
+	char *vers_name;
+	char *vers_num;
+	proc_list *procs;
+	struct version_list *next;
+};
+typedef struct version_list version_list;
+
+struct program_def {
+	char *prog_num;
+	version_list *versions;
+};
+typedef struct program_def program_def;
+
+struct definition {
+	char *def_name;
+	defkind def_kind;
+	union {
+		const_def co;
+		struct_def st;
+		union_def un;
+		enum_def en;
+		typedef_def ty;
+		program_def pr;
+	} def;
+};
+typedef struct definition definition;
+
+definition *get_definition();
+
+
+struct bas_type
+{
+  char *name;
+  int length;
+  struct bas_type *next;
+};
+
+typedef struct bas_type bas_type;
diff --git a/rpcgen/rpc_sample.c b/rpcgen/rpc_sample.c
new file mode 100644
index 0000000..2b5c81b
--- /dev/null
+++ b/rpcgen/rpc_sample.c
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_sample.c  1.1  90/08/30  (C) 1987 SMI";
+
+#endif
+
+/*
+ * rpc_sample.c, Sample client-server code outputter for the RPC protocol compiler
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+
+
+static char RQSTP[] = "rqstp";
+
+static void	write_sample_client(char *program_name, version_list *vp);
+static void	write_sample_server(definition * def);
+static void	return_type(proc_list *plist);
+
+void
+write_sample_svc(definition *def)
+{
+	if (def->def_kind != DEF_PROGRAM)
+		return;
+	write_sample_server(def);
+}
+
+
+int
+write_sample_clnt(definition *def)
+{
+	version_list   *vp;
+	int             count = 0;
+
+	if (def->def_kind != DEF_PROGRAM)
+		return (0);
+	/* generate sample code for each version */
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		write_sample_client(def->def_name, vp);
+		++count;
+	}
+	return (count);
+}
+
+
+static void
+write_sample_client(char *program_name, version_list *vp)
+{
+	proc_list      *proc;
+	int             i;
+	decl_list      *l;
+
+	f_print(fout, "\n\nvoid\n");
+	pvname(program_name, vp->vers_num);
+	if (Cflag)
+		f_print(fout, "( char* host )\n{\n");
+	else
+		f_print(fout, "(host)\nchar *host;\n{\n");
+	f_print(fout, "\tCLIENT *clnt;\n");
+
+	i = 0;
+	for (proc = vp->procs; proc != NULL; proc = proc->next) {
+		f_print(fout, "\t");
+		ptype(proc->res_prefix, proc->res_type, 1);
+		f_print(fout, " *result_%d;\n", ++i);
+		/* print out declarations for arguments */
+		if (proc->arg_num < 2 && !newstyle) {
+			f_print(fout, "\t");
+			if (!streq(proc->args.decls->decl.type, "void"))
+				ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+			else
+				f_print(fout, "char* ");	/* cannot have "void" type */
+			f_print(fout, " ");
+			pvname(proc->proc_name, vp->vers_num);
+			f_print(fout, "_arg;\n");
+		} else if (!streq(proc->args.decls->decl.type, "void")) {
+			for (l = proc->args.decls; l != NULL; l = l->next) {
+				f_print(fout, "\t");
+				ptype(l->decl.prefix, l->decl.type, 1);
+				f_print(fout, " ");
+				pvname(proc->proc_name, vp->vers_num);
+				f_print(fout, "_%s;\n", l->decl.name);
+				/*	  pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );*/
+			}
+		}
+	}
+
+	/* generate creation of client handle */
+	f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
+		program_name, vp->vers_name, tirpcflag ? "netpath" : "udp");
+	f_print(fout, "\tif (clnt == NULL) {\n");
+	f_print(fout, "\t\tclnt_pcreateerror(host);\n");
+	f_print(fout, "\t\texit(1);\n\t}\n");
+
+	/* generate calls to procedures */
+	i = 0;
+	for (proc = vp->procs; proc != NULL; proc = proc->next) {
+		f_print(fout, "\tresult_%d = ", ++i);
+		pvname(proc->proc_name, vp->vers_num);
+		if (proc->arg_num < 2 && !newstyle) {
+			f_print(fout, "(");
+			if (streq(proc->args.decls->decl.type, "void"))	/* cast to void* */
+				f_print(fout, "(void*)");
+			f_print(fout, "&");
+			pvname(proc->proc_name, vp->vers_num);
+			f_print(fout, "_arg, clnt);\n");
+		} else if (streq(proc->args.decls->decl.type, "void")) {
+			f_print(fout, "(clnt);\n");
+		} else {
+			f_print(fout, "(");
+			for (l = proc->args.decls; l != NULL; l = l->next) {
+				pvname(proc->proc_name, vp->vers_num);
+				f_print(fout, "_%s, ", l->decl.name);
+			}
+			f_print(fout, "clnt);\n");
+		}
+		f_print(fout, "\tif (result_%d == NULL) {\n", i);
+		f_print(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
+		f_print(fout, "\t}\n");
+	}
+
+	f_print(fout, "\tclnt_destroy( clnt );\n");
+	f_print(fout, "}\n");
+}
+
+static void
+write_sample_server(definition * def)
+{
+	version_list   *vp;
+	proc_list      *proc;
+
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			f_print(fout, "\n");
+			/*			if( Cflag )
+			  f_print( fout, "extern \"C\"{\n");
+*/
+			return_type(proc);
+			f_print(fout, "* \n");
+			if (Cflag)
+				pvname_svc(proc->proc_name, vp->vers_num);
+			else
+				pvname(proc->proc_name, vp->vers_num);
+			printarglist(proc, RQSTP, "struct svc_req *");
+
+			f_print(fout, "{\n");
+			f_print(fout, "\n\tstatic ");
+			if (!streq(proc->res_type, "void"))
+				return_type(proc);
+			else
+				f_print(fout, "char*");	/* cannot have void type */
+			/* f_print(fout, " result;\n", proc->res_type); */
+			f_print(fout, " result;\n");
+			f_print(fout,
+				"\n\t/*\n\t * insert server code here\n\t */\n\n");
+			if (!streq(proc->res_type, "void"))
+				f_print(fout, "\treturn(&result);\n}\n");
+			else	/* cast back to void * */
+				f_print(fout, "\treturn((void*) &result);\n}\n");
+			/*			if( Cflag)
+			  f_print( fout, "};\n");
+*/
+
+		}
+	}
+}
+
+
+
+static void
+return_type(proc_list *plist)
+{
+	ptype( plist->res_prefix, plist->res_type, 1 );
+}
+
+void
+add_sample_msg(void)
+{
+	f_print(fout, "/*\n");
+	f_print(fout, " * This is sample code generated by rpcgen.\n");
+	f_print(fout, " * These are only templates and you can use them\n");
+	f_print(fout, " * as a guideline for developing your own functions.\n");
+	f_print(fout, " */\n\n");
+}
+
+void
+write_sample_clnt_main(void)
+{
+  list *l;
+  definition *def;
+  version_list *vp;
+
+  f_print(fout, "\n\n" );
+  if( Cflag )
+    f_print(fout,"main( int argc, char* argv[] )\n{\n" );
+  else
+    f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n" );
+
+  f_print(fout, "\tchar *host;");
+  f_print(fout, "\n\n\tif(argc < 2) {");
+  f_print(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n" );
+  f_print(fout, "\t\texit(1);\n\t}");
+  f_print(fout, "\n\thost = argv[1];\n");
+
+  for (l = defined; l != NULL; l = l->next) {
+		def = l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			continue;
+		}
+		for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		        f_print( fout, "\t" );
+			pvname(def->def_name, vp->vers_num);
+			f_print( fout, "( host );\n" );
+		      }
+		}
+  f_print(fout, "}\n");
+}
diff --git a/rpcgen/rpc_scan.c b/rpcgen/rpc_scan.c
new file mode 100644
index 0000000..f58fa9f
--- /dev/null
+++ b/rpcgen/rpc_scan.c
@@ -0,0 +1,474 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_scan.c, Scanner for the RPC protocol compiler 
+ * Copyright (C) 1987, Sun Microsystems, Inc. 
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include "rpc_scan.h"
+#include "rpc_parse.h"
+#include "rpc_util.h"
+
+static void	unget_token(token *tokp);
+static void	findstrconst(char **str, char **val);
+static void	findchrconst(char **str, char **val);
+static void	findconst(char **str, char **val);
+static void	findkind(char **mark, token *tokp);
+static int	cppline(char *line);
+static int	directive(char *line);
+static void	printdirective(char *line);
+static void	docppline(char *line, int *lineno, char **fname);
+
+#define startcomment(where) (where[0] == '/' && where[1] == '*')
+#define endcomment(where) (where[-1] == '*' && where[0] == '/')
+
+static int pushed = 0;	/* is a token pushed */
+static token lasttok;	/* last token, if pushed */
+
+/*
+ * scan expecting 1 given token 
+ */
+void
+scan(tok_kind expect, token *tokp)
+{
+	get_token(tokp);
+	if (tokp->kind != expect) {
+		expected1(expect);
+	}
+}
+
+/*
+ * scan expecting any of the 2 given tokens 
+ */
+void
+scan2(tok_kind expect1, tok_kind expect2, token *tokp)
+{
+	get_token(tokp);
+	if (tokp->kind != expect1 && tokp->kind != expect2) {
+		expected2(expect1, expect2);
+	}
+}
+
+/*
+ * scan expecting any of the 3 given token 
+ */
+void
+scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
+{
+	get_token(tokp);
+	if (tokp->kind != expect1 && tokp->kind != expect2
+	    && tokp->kind != expect3) {
+		expected3(expect1, expect2, expect3);
+	}
+}
+
+/*
+ * scan expecting a constant, possibly symbolic 
+ */
+void
+scan_num(token *tokp)
+{
+	get_token(tokp);
+	switch (tokp->kind) {
+	case TOK_IDENT:
+		break;
+	default:
+		error("constant or identifier expected");
+	}
+}
+
+/*
+ * Peek at the next token 
+ */
+void
+peek(token *tokp)
+{
+	get_token(tokp);
+	unget_token(tokp);
+}
+
+/*
+ * Peek at the next token and scan it if it matches what you expect 
+ */
+int
+peekscan(tok_kind expect, token *tokp)
+{
+	peek(tokp);
+	if (tokp->kind == expect) {
+		get_token(tokp);
+		return (1);
+	}
+	return (0);
+}
+
+/*
+ * Get the next token, printing out any directive that are encountered. 
+ */
+void
+get_token(token *tokp)
+{
+	int commenting;
+
+	if (pushed) {
+		pushed = 0;
+		*tokp = lasttok;
+		return;
+	}
+	commenting = 0;
+	for (;;) {
+		if (*where == 0) {
+			for (;;) {
+				if (!fgets(curline, MAXLINESIZE, fin)) {
+					tokp->kind = TOK_EOF;
+					*where = 0;
+					return;
+				}
+				linenum++;
+				if (commenting) {
+					break;
+				} else if (cppline(curline)) {
+					docppline(curline, &linenum, 
+						  &infilename);
+				} else if (directive(curline)) {
+					printdirective(curline);
+				} else {
+					break;
+				}
+			}
+			where = curline;
+		} else if (isspace(*where)) {
+			while (isspace(*where)) {
+				where++;	/* eat */
+			}
+		} else if (commenting) {
+			for (where++; *where; where++) {
+				if (endcomment(where)) {
+					where++;
+					commenting--;
+					break;
+				}
+			}
+		} else if (startcomment(where)) {
+			where += 2;
+			commenting++;
+		} else {
+			break;
+		}
+	}
+
+	/*
+	 * 'where' is not whitespace, comment or directive Must be a token! 
+	 */
+	switch (*where) {
+	case ':':
+		tokp->kind = TOK_COLON;
+		where++;
+		break;
+	case ';':
+		tokp->kind = TOK_SEMICOLON;
+		where++;
+		break;
+	case ',':
+		tokp->kind = TOK_COMMA;
+		where++;
+		break;
+	case '=':
+		tokp->kind = TOK_EQUAL;
+		where++;
+		break;
+	case '*':
+		tokp->kind = TOK_STAR;
+		where++;
+		break;
+	case '[':
+		tokp->kind = TOK_LBRACKET;
+		where++;
+		break;
+	case ']':
+		tokp->kind = TOK_RBRACKET;
+		where++;
+		break;
+	case '{':
+		tokp->kind = TOK_LBRACE;
+		where++;
+		break;
+	case '}':
+		tokp->kind = TOK_RBRACE;
+		where++;
+		break;
+	case '(':
+		tokp->kind = TOK_LPAREN;
+		where++;
+		break;
+	case ')':
+		tokp->kind = TOK_RPAREN;
+		where++;
+		break;
+	case '<':
+		tokp->kind = TOK_LANGLE;
+		where++;
+		break;
+	case '>':
+		tokp->kind = TOK_RANGLE;
+		where++;
+		break;
+
+	case '"':
+		tokp->kind = TOK_STRCONST;
+		findstrconst(&where, &tokp->str);
+		break;
+	case '\'':
+		tokp->kind = TOK_CHARCONST;
+		findchrconst(&where, &tokp->str);
+		break;
+
+	case '-':
+	case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+		tokp->kind = TOK_IDENT;
+		findconst(&where, &tokp->str);
+		break;
+
+	default:
+		if (!(isalpha(*where) || *where == '_')) {
+			char buf[100];
+			char *p;
+
+			s_print(buf, "illegal character in file: ");
+			p = buf + strlen(buf);
+			if (isprint(*where)) {
+				s_print(p, "%c", *where);
+			} else {
+				s_print(p, "%d", *where);
+			}
+			error(buf);
+		}
+		findkind(&where, tokp);
+		break;
+	}
+}
+
+static void
+unget_token(token *tokp)
+{
+	lasttok = *tokp;
+	pushed = 1;
+}
+
+static void
+findstrconst(char **str, char **val)
+{
+	char *p;
+	int size;
+
+	p = *str;
+	do {
+		*p++;
+	} while (*p && *p != '"');
+	if (*p == 0) {
+		error("unterminated string constant");
+	}
+	p++;
+	size = p - *str;
+	*val = alloc(size + 1);
+	(void) strncpy(*val, *str, size);
+	(*val)[size] = 0;
+	*str = p;
+}
+
+static void
+findchrconst(char **str, char **val)
+{
+	char *p;
+	int size;
+
+	p = *str;
+	do {
+		*p++;
+	} while (*p && *p != '\'');
+	if (*p == 0) {
+		error("unterminated string constant");
+	}
+	p++;
+	size = p - *str;
+	if (size != 3) {
+		error("empty char string");
+	}
+	*val = alloc(size + 1);
+	(void) strncpy(*val, *str, size);
+	(*val)[size] = 0;
+	*str = p;
+}
+
+static void
+findconst(char **str, char **val)
+{
+	char *p;
+	int size;
+
+	p = *str;
+	if (*p == '0' && *(p + 1) == 'x') {
+		p++;
+		do {
+			p++;
+		} while (isxdigit(*p));
+	} else {
+		do {
+			p++;
+		} while (isdigit(*p));
+	}
+	size = p - *str;
+	*val = alloc(size + 1);
+	(void) strncpy(*val, *str, size);
+	(*val)[size] = 0;
+	*str = p;
+}
+
+static token symbols[] = {
+			  {TOK_CONST, "const"},
+			  {TOK_UNION, "union"},
+			  {TOK_SWITCH, "switch"},
+			  {TOK_CASE, "case"},
+			  {TOK_DEFAULT, "default"},
+			  {TOK_STRUCT, "struct"},
+			  {TOK_TYPEDEF, "typedef"},
+			  {TOK_ENUM, "enum"},
+			  {TOK_OPAQUE, "opaque"},
+			  {TOK_BOOL, "bool"},
+			  {TOK_VOID, "void"},
+			  {TOK_CHAR, "char"},
+			  {TOK_INT, "int"},
+			  {TOK_UNSIGNED, "unsigned"},
+			  {TOK_SHORT, "short"},
+			  {TOK_INT32, "int32"},
+			  {TOK_FLOAT, "float"},
+			  {TOK_DOUBLE, "double"},
+			  {TOK_STRING, "string"},
+			  {TOK_PROGRAM, "program"},
+			  {TOK_VERSION, "version"},
+			  {TOK_EOF, "??????"},
+};
+
+static void
+findkind(char **mark, token *tokp)
+{
+	int len;
+	token *s;
+	char *str;
+
+	str = *mark;
+	for (s = symbols; s->kind != TOK_EOF; s++) {
+		len = strlen(s->str);
+		if (strncmp(str, s->str, len) == 0) {
+			if (!isalnum(str[len]) && str[len] != '_') {
+				tokp->kind = s->kind;
+				tokp->str = s->str;
+				*mark = str + len;
+				return;
+			}
+		}
+	}
+	tokp->kind = TOK_IDENT;
+	for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
+	tokp->str = alloc(len + 1);
+	(void) strncpy(tokp->str, str, len);
+	tokp->str[len] = 0;
+	*mark = str + len;
+}
+
+static int
+cppline(char *line)
+{
+	return (line == curline && *line == '#');
+}
+
+static int
+directive(char *line)
+{
+	return (line == curline && *line == '%');
+}
+
+static void
+printdirective(char *line)
+{
+	f_print(fout, "%s", line + 1);
+}
+
+static void
+docppline(char *line, int *lineno, char **fname)
+{
+	char *file;
+	int num;
+	char *p;
+
+	line++;
+	while (isspace(*line)) {
+		line++;
+	}
+	num = atoi(line);
+	while (isdigit(*line)) {
+		line++;
+	}
+	while (isspace(*line)) {
+		line++;
+	}
+	if (*line != '"') {
+		error("preprocessor error");
+	}
+	line++;
+	p = file = alloc(strlen(line) + 1);
+	while (*line && *line != '"') {
+		*p++ = *line++;
+	}
+	if (*line == 0) {
+		error("preprocessor error");
+	}
+	*p = 0;
+	if (*file == 0) {
+		*fname = NULL;
+		free(file);
+	} else {
+		*fname = file;
+	}
+	*lineno = num - 1;
+}
diff --git a/rpcgen/rpc_scan.h b/rpcgen/rpc_scan.h
new file mode 100644
index 0000000..16f688c
--- /dev/null
+++ b/rpcgen/rpc_scan.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+/*      @(#)rpc_scan.h  1.3  90/08/29  (C) 1987 SMI   */
+
+/*
+ * rpc_scan.h, Definitions for the RPCL scanner 
+ */
+
+/*
+ * kinds of tokens 
+ */
+enum tok_kind {
+	TOK_IDENT,
+	TOK_CHARCONST,
+	TOK_STRCONST,
+	TOK_LPAREN,
+	TOK_RPAREN,
+	TOK_LBRACE,
+	TOK_RBRACE,
+	TOK_LBRACKET,
+	TOK_RBRACKET,
+	TOK_LANGLE,
+	TOK_RANGLE,
+	TOK_STAR,
+	TOK_COMMA,
+	TOK_EQUAL,
+	TOK_COLON,
+	TOK_SEMICOLON,
+	TOK_CONST,
+	TOK_STRUCT,
+	TOK_UNION,
+	TOK_SWITCH,
+	TOK_CASE,
+	TOK_DEFAULT,
+	TOK_ENUM,
+	TOK_TYPEDEF,
+	TOK_INT,
+	TOK_SHORT,
+	TOK_INT32,
+	TOK_UNSIGNED,
+	TOK_FLOAT,
+	TOK_DOUBLE,
+	TOK_OPAQUE,
+	TOK_CHAR,
+	TOK_STRING,
+	TOK_BOOL,
+	TOK_VOID,
+	TOK_PROGRAM,
+	TOK_VERSION,
+	TOK_EOF
+};
+typedef enum tok_kind tok_kind;
+
+/*
+ * a token 
+ */
+struct token {
+	tok_kind kind;
+	char *str;
+};
+typedef struct token token;
+
+
+/*
+ * routine interface 
+ */
+void            scan();
+void            scan2();
+void            scan3();
+void            scan_num();
+void            peek();
+int             peekscan();
+void            get_token();
+void            expected1(tok_kind);
+void            expected2(tok_kind, tok_kind);
+void            expected3(tok_kind, tok_kind, tok_kind);
+
diff --git a/rpcgen/rpc_svcout.c b/rpcgen/rpc_svcout.c
new file mode 100644
index 0000000..284a529
--- /dev/null
+++ b/rpcgen/rpc_svcout.c
@@ -0,0 +1,882 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+ static char sccsid[] = "@(#)rpc_svcout.c 1.29 89/03/30 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler
+ */
+#include <stdio.h>
+#include <string.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "rpc_output.h"
+
+static void	write_real_program(definition *def);
+static void	write_program(definition *def, char *storage);
+static void	printerr(char *err, char *transp);
+static void	printif(char *proc, char *transp, char *prefix, char *arg);
+static void	write_inetmost(char *infile);
+static void	print_return(char *space);
+static void	print_pmapunset(char *space);
+static void	print_err_message(char *space);
+static void	write_timeout_func(void);
+static void	write_pm_most(char *infile, int netflag);
+static void	write_rpc_svc_fg(char *infile, char *sp);
+static void	open_log_file(char *infile, char *sp);
+
+static char RQSTP[] = "rqstp";
+static char TRANSP[] = "transp";
+static char ARG[] = "argument";
+static char RESULT[] = "result";
+static char ROUTINE[] = "local";
+
+char _errbuf[256];	/* For all messages */
+
+static void
+p_xdrfunc(char *rname, char *typename)
+{
+	if (Cflag)
+		f_print(fout, "\t\txdr_%s = (xdrproc_t) xdr_%s;\n", rname,
+			stringfix(typename));
+	else
+		f_print(fout, "\t\txdr_%s = xdr_%s;\n", rname, stringfix(typename));
+}
+
+void
+internal_proctype(proc_list *plist)
+{
+	f_print(fout, "static ");
+	ptype( plist->res_prefix, plist->res_type, 1 );
+	f_print( fout, "*" );
+}
+
+
+/*
+ * write most of the service, that is, everything but the registrations. 
+ */
+void
+write_most(char *infile, int netflag, int nomain)
+{
+	if (inetdflag || pmflag) {
+	        char* var_type;
+		var_type = (nomain? "extern" : "static");
+		f_print(fout, "%s int _rpcpmstart;", var_type );
+		f_print(fout, "\t\t/* Started by a port monitor ? */\n"); 
+		f_print(fout, "%s int _rpcfdtype;", var_type );
+		f_print(fout, "\t\t/* Whether Stream or Datagram ? */\n");
+		if (timerflag) {
+			f_print(fout, "%s int _rpcsvcdirty;", var_type );
+			f_print(fout, "\t/* Still serving ? */\n");
+		}
+		write_svc_aux( nomain );
+	}
+	/* write out dispatcher and stubs */
+	write_programs( nomain? (char *)NULL : "static" );
+
+        if( nomain ) 
+	  return;
+
+	f_print(fout, "\nmain()\n");
+	f_print(fout, "{\n");
+	if (inetdflag) {
+		write_inetmost(infile); /* Includes call to write_rpc_svc_fg() */
+	} else {
+	  if( tirpcflag ) {
+		if (netflag) {
+			f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+			f_print(fout, "\tstruct netconfig *nconf = NULL;\n");
+		}
+		f_print(fout, "\tpid_t pid;\n");
+		f_print(fout, "\tint i;\n");
+		f_print(fout, "\tchar mname[FMNAMESZ + 1];\n\n");
+		write_pm_most(infile, netflag);
+		f_print(fout, "\telse {\n");
+		write_rpc_svc_fg(infile, "\t\t");
+		f_print(fout, "\t}\n");
+	      } else {
+		f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+		f_print(fout, "\n");
+		print_pmapunset("\t");
+	      }
+	}
+
+	if (logflag && !inetdflag) {
+		open_log_file(infile, "\t");
+	}
+}
+
+/*
+ * write a registration for the given transport 
+ */
+void
+write_netid_register(char *transp)
+{
+	list *l;
+	definition *def;
+	version_list *vp;
+	char *sp;
+	char tmpbuf[32];
+
+	sp = "";
+	f_print(fout, "\n");
+	f_print(fout, "%s\tnconf = getnetconfigent(\"%s\");\n", sp, transp);
+	f_print(fout, "%s\tif (nconf == NULL) {\n", sp);
+	(void) sprintf(_errbuf, "cannot find %s netid.", transp);
+	sprintf(tmpbuf, "%s\t\t", sp);
+	print_err_message(tmpbuf);
+	f_print(fout, "%s\t\texit(1);\n", sp);
+	f_print(fout, "%s\t}\n", sp);
+	f_print(fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n",
+			sp, TRANSP);
+	f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
+	(void) sprintf(_errbuf, "cannot create %s service.", transp);
+	print_err_message(tmpbuf);
+	f_print(fout, "%s\t\texit(1);\n", sp);
+	f_print(fout, "%s\t}\n", sp);
+
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			continue;
+		}
+		for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+			f_print(fout,
+				"%s\t(void) rpcb_unset(%s, %s, nconf);\n",
+				sp, def->def_name, vp->vers_name);
+			f_print(fout,
+				"%s\tif (!svc_reg(%s, %s, %s, ",
+				sp, TRANSP, def->def_name, vp->vers_name);
+			pvname(def->def_name, vp->vers_num);
+			f_print(fout, ", nconf)) {\n");
+			(void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
+					def->def_name, vp->vers_name, transp);
+			print_err_message(tmpbuf);
+			f_print(fout, "%s\t\texit(1);\n", sp);
+			f_print(fout, "%s\t}\n", sp);
+		}
+	}
+	f_print(fout, "%s\tfreenetconfigent(nconf);\n", sp);
+}
+
+/*
+ * write a registration for the given transport for TLI
+ */
+void
+write_nettype_register(char *transp)
+{
+	list *l;
+	definition *def;
+	version_list *vp;
+
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			continue;
+		}
+		for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+			f_print(fout, "\tif (!svc_create(");
+			pvname(def->def_name, vp->vers_num);
+			f_print(fout, ", %s, %s, \"%s\")) {\n ",
+				def->def_name, vp->vers_name, transp);
+			(void) sprintf(_errbuf,
+				"unable to create (%s, %s) for %s.",
+					def->def_name, vp->vers_name, transp);
+			print_err_message("\t\t");
+			f_print(fout, "\t\texit(1);\n");
+			f_print(fout, "\t}\n");
+		}
+	}
+}
+
+/*
+ * write the rest of the service 
+ */
+void
+write_rest(void)
+{
+	f_print(fout, "\n");
+	if (inetdflag) {
+		f_print(fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP);
+		(void) sprintf(_errbuf, "could not create a handle");
+		print_err_message("\t\t");
+		f_print(fout, "\t\texit(1);\n");
+		f_print(fout, "\t}\n");
+		if (timerflag) {
+			f_print(fout, "\tif (_rpcpmstart) {\n");
+			f_print(fout, 
+				"\t\t(void) signal(SIGALRM, %s closedown);\n",
+				Cflag? "(SIG_PF)" : "(void(*)())" );
+			f_print(fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+			f_print(fout, "\t}\n");
+		}
+	}
+	f_print(fout, "\tsvc_run();\n");
+	(void) sprintf(_errbuf, "svc_run returned");
+	print_err_message("\t");
+	f_print(fout, "\texit(1);\n");
+	f_print(fout, "\t/* NOTREACHED */\n");
+	f_print(fout, "}\n");
+}
+
+void
+write_programs(char *storage)
+{
+	list *l;
+	definition *def;
+
+	/* write out stubs for procedure  definitions */
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind == DEF_PROGRAM) {
+			write_real_program(def);
+		}
+	}
+
+	/* write out dispatcher for each program */
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind == DEF_PROGRAM) {
+			write_program(def, storage);
+		}
+	}
+
+
+}
+
+/* write out definition of internal function (e.g. _printmsg_1(...))
+   which calls server's defintion of actual function (e.g. printmsg_1(...)).
+   Unpacks single user argument of printmsg_1 to call-by-value format
+   expected by printmsg_1. */
+static void
+write_real_program(definition *def)
+{
+	version_list *vp;
+	proc_list *proc;
+	decl_list *l;
+
+	if( !newstyle ) return;  /* not needed for old style */
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			f_print(fout, "\n");
+			internal_proctype(proc);
+			f_print(fout, "\n_");
+			pvname(proc->proc_name, vp->vers_num);
+			if( Cflag ) {
+			  f_print(fout, "(" );
+			  /* arg name */
+			  if (proc->arg_num > 1)
+			    f_print(fout, proc->args.argname);
+			  else
+			    ptype(proc->args.decls->decl.prefix, 
+				  proc->args.decls->decl.type, 0);
+			  f_print(fout, " *argp, struct svc_req *%s)\n", 
+				  RQSTP);
+			} else {
+			  f_print(fout, "(argp, %s)\n", RQSTP );
+			  /* arg name */
+			  if (proc->arg_num > 1)
+			    f_print(fout, "\t%s *argp;\n", proc->args.argname);
+			  else {
+			    f_print(fout, "\t");
+			    ptype(proc->args.decls->decl.prefix, 
+				  proc->args.decls->decl.type, 0);
+			    f_print(fout, " *argp;\n");
+			  }
+			  f_print(fout, "	struct svc_req *%s;\n", RQSTP);
+			}
+
+			f_print(fout, "{\n");
+			f_print(fout, "\treturn(");
+			if( Cflag )
+			  pvname_svc(proc->proc_name, vp->vers_num);
+			else
+			  pvname(proc->proc_name, vp->vers_num);
+			f_print(fout, "(");
+			if (proc->arg_num < 2) { /* single argument */
+			  if (!streq( proc->args.decls->decl.type, "void"))
+			    f_print(fout, "*argp, ");  /* non-void */
+			} else {
+			  for (l = proc->args.decls;  l != NULL; l = l->next) 
+			    f_print(fout, "argp->%s, ", l->decl.name);
+			}
+			f_print(fout, "%s));\n}\n", RQSTP);
+		} 		
+	}
+}
+
+static void
+write_program(definition *def, char *storage)
+{
+	version_list *vp;
+	proc_list *proc;
+	int filled;
+
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		f_print(fout, "\n");
+		if (storage != NULL) {
+			f_print(fout, "%s ", storage);
+		}
+		f_print(fout, "void\n");
+		pvname(def->def_name, vp->vers_num);
+
+		if (Cflag) {
+		   f_print(fout, "(struct svc_req *%s, ", RQSTP);
+		   f_print(fout, "register SVCXPRT *%s)\n", TRANSP);
+		} else {
+		   f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
+		   f_print(fout, "	struct svc_req *%s;\n", RQSTP);
+		   f_print(fout, "	register SVCXPRT *%s;\n", TRANSP);
+		}
+
+		f_print(fout, "{\n");
+
+		filled = 0;
+		f_print(fout, "\tunion {\n");
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			if (proc->arg_num < 2) { /* single argument */
+				if (streq(proc->args.decls->decl.type, 
+					  "void")) {
+					continue;
+				}
+				filled = 1;
+				f_print(fout, "\t\t");
+				ptype(proc->args.decls->decl.prefix, 
+				      proc->args.decls->decl.type, 0);
+				pvname(proc->proc_name, vp->vers_num);
+				f_print(fout, "_arg;\n");
+
+			}
+			else {
+				filled = 1;
+				f_print(fout, "\t\t%s", proc->args.argname);
+				f_print(fout, " ");
+				pvname(proc->proc_name, vp->vers_num);
+				f_print(fout, "_arg;\n");
+			}
+		}
+		if (!filled) {
+			f_print(fout, "\t\tint fill;\n");
+		}
+		f_print(fout, "\t} %s;\n", ARG);
+		f_print(fout, "\tchar *%s;\n", RESULT);
+
+		if (Cflag) {
+		    f_print(fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT);
+		    f_print(fout,
+			    "\tchar *(*%s)(char *, struct svc_req *);\n",
+			    ROUTINE);
+		} else {
+		    f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
+		    f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
+		}
+
+		f_print(fout, "\n");
+
+		if (timerflag)
+			f_print(fout, "\t_rpcsvcdirty = 1;\n");
+		f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);
+		if (!nullproc(vp->procs)) {
+			f_print(fout, "\tcase NULLPROC:\n");
+			f_print(fout,
+			"\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n",
+					TRANSP);
+			print_return("\t\t");
+			f_print(fout, "\n");
+		}
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			f_print(fout, "\tcase %s:\n", proc->proc_name);
+			if (proc->arg_num < 2) { /* single argument */
+			  p_xdrfunc( ARG, proc->args.decls->decl.type);
+			} else {
+			  p_xdrfunc( ARG, proc->args.argname);
+			}
+			p_xdrfunc( RESULT, proc->res_type);
+			if( Cflag )
+			    f_print(fout,
+				    "\t\t%s = (char *(*)(char *, struct svc_req *)) ",
+				    ROUTINE);
+			else
+			    f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
+
+			if (newstyle) { /* new style: calls internal routine */
+				f_print(fout,"_");
+			}
+			/* Not sure about the following...
+			 * rpc_hout always generates foobar_1_svc for
+			 * the service procedure, so why should we use
+			 * foobar_1 here?! --okir */
+#if 0
+			if( Cflag && !newstyle )
+			  pvname_svc(proc->proc_name, vp->vers_num);
+			else
+			  pvname(proc->proc_name, vp->vers_num);
+#else
+			pvname_svc(proc->proc_name, vp->vers_num);
+#endif
+			f_print(fout, ";\n");
+			f_print(fout, "\t\tbreak;\n\n");
+		}
+		f_print(fout, "\tdefault:\n");
+		printerr("noproc", TRANSP);
+		print_return("\t\t");
+		f_print(fout, "\t}\n");
+
+		f_print(fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG);
+		if (Cflag)
+		    printif("getargs", TRANSP, "(caddr_t) &", ARG);
+		else
+		    printif("getargs", TRANSP, "&", ARG);
+		printerr("decode", TRANSP);
+		print_return("\t\t");
+		f_print(fout, "\t}\n");
+
+		if (Cflag)
+		    f_print(fout, "\t%s = (*%s)((char *)&%s, %s);\n",
+			    RESULT, ROUTINE, ARG, RQSTP);
+		else
+		    f_print(fout, "\t%s = (*%s)(&%s, %s);\n",
+			    RESULT, ROUTINE, ARG, RQSTP);
+		f_print(fout, 
+			"\tif (%s != NULL && !svc_sendreply(%s, "
+			"(xdrproc_t) xdr_%s, %s)) {\n",
+			RESULT, TRANSP, RESULT, RESULT);
+		printerr("systemerr", TRANSP);
+		f_print(fout, "\t}\n");
+
+		if (Cflag)
+		    printif("freeargs", TRANSP, "(caddr_t) &", ARG);
+		else
+		    printif("freeargs", TRANSP, "&", ARG);
+		(void) sprintf(_errbuf, "unable to free arguments");
+		print_err_message("\t\t");
+		f_print(fout, "\t\texit(1);\n");
+		f_print(fout, "\t}\n");
+		print_return("\t");
+		f_print(fout, "}\n");
+	}
+}
+
+static void
+printerr(char *err, char *transp)
+{
+	f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp);
+}
+
+static void
+printif(char *proc, char *transp, char *prefix, char *arg)
+{
+	f_print(fout, "\tif (!svc_%s(%s, (xdrproc_t) xdr_%s, (caddr_t) %s%s)) {\n",
+		proc, transp, arg, prefix, arg);
+}
+
+int
+nullproc(proc_list *proc)
+{
+	for (; proc != NULL; proc = proc->next) {
+		if (streq(proc->proc_num, "0")) {
+			return (1);
+		}
+	}
+	return (0);
+}
+
+static void
+write_inetmost(char *infile)
+{
+	f_print(fout, "\tregister SVCXPRT *%s;\n", TRANSP);
+	f_print(fout, "\tint sock;\n");
+	f_print(fout, "\tint proto;\n");
+	f_print(fout, "\tstruct sockaddr_in saddr;\n");
+	f_print(fout, "\tint asize = sizeof (saddr);\n");
+	f_print(fout, "\n");
+	f_print(fout, 
+	"\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n");
+	f_print(fout, "\t\tint ssize = sizeof (int);\n\n");
+	f_print(fout, "\t\tif (saddr.sin_family != AF_INET)\n");
+	f_print(fout, "\t\t\texit(1);\n");
+	f_print(fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n");
+	f_print(fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n");
+	f_print(fout, "\t\t\texit(1);\n");
+	f_print(fout, "\t\tsock = 0;\n");
+	f_print(fout, "\t\t_rpcpmstart = 1;\n");
+	f_print(fout, "\t\tproto = 0;\n");
+	open_log_file(infile, "\t\t");
+	f_print(fout, "\t} else {\n");
+	write_rpc_svc_fg(infile, "\t\t");
+	f_print(fout, "\t\tsock = RPC_ANYSOCK;\n");
+	print_pmapunset("\t\t");
+	f_print(fout, "\t}\n");
+}
+
+static void
+print_return(char *space)
+{
+	if (exitnow)
+		f_print(fout, "%sexit(0);\n", space);
+	else {
+		if (timerflag)
+			f_print(fout, "%s_rpcsvcdirty = 0;\n", space);
+		f_print(fout, "%sreturn;\n", space);
+	}
+}
+
+static void
+print_pmapunset(char *space)
+{
+	list *l;
+	definition *def;
+	version_list *vp;
+
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind == DEF_PROGRAM) {
+			for (vp = def->def.pr.versions; vp != NULL;
+					vp = vp->next) {
+				f_print(fout, "%s(void) pmap_unset(%s, %s);\n",
+					space, def->def_name, vp->vers_name);
+			}
+		}
+	}
+}
+
+static void
+print_err_message(char *space)
+{
+	if (logflag)
+		f_print(fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf);
+	else if (inetdflag || pmflag)
+		f_print(fout, "%s_msgout(\"%s\");\n", space, _errbuf);
+	else
+		f_print(fout, "%sfprintf(stderr, \"%s\");\n", space, _errbuf);
+}
+
+/*
+ * Write the server auxiliary function ( _msgout, timeout)
+ */
+void
+write_svc_aux(int nomain)
+{
+	if (!logflag)
+		write_msg_out();
+	if( !nomain )
+	  write_timeout_func();
+}
+
+/*
+ * Write the _msgout function
+ */
+void
+write_msg_out(void)
+{
+	f_print(fout, "\n");
+	f_print(fout, "static\n");
+	if( !Cflag ) {
+	  f_print(fout, "void _msgout(msg)\n");
+	  f_print(fout, "\tchar *msg;\n");
+	} else {
+	  f_print(fout, "void _msgout(char* msg)\n");
+	}
+	f_print(fout, "{\n");
+	f_print(fout, "#ifdef RPC_SVC_FG\n");
+	if (inetdflag || pmflag)
+		f_print(fout, "\tif (_rpcpmstart)\n");
+	f_print(fout, "\t\tsyslog(LOG_ERR, \"%%s\", msg);\n");
+	f_print(fout, "\telse\n");
+	f_print(fout, "\t\t(void) fprintf(stderr, \"%%s\\n\", msg);\n");
+	f_print(fout, "#else\n");
+	f_print(fout, "\tsyslog(LOG_ERR, \"%%s\", msg);\n");
+	f_print(fout, "#endif\n");
+	f_print(fout, "}\n");
+}
+
+/*
+ * Write the timeout function
+ */
+static void
+write_timeout_func(void)
+{
+	if (!timerflag)
+		return;
+	f_print(fout, "\n");
+	f_print(fout, "static void\n");
+	f_print(fout, "closedown()\n");
+	f_print(fout, "{\n");
+	f_print(fout, "\tif (_rpcsvcdirty == 0) {\n");
+	f_print(fout, "\t\tstatic int size;\n");
+	f_print(fout, "\t\tint i, openfd;\n");
+	if (tirpcflag && pmflag) {
+		f_print(fout, "\t\tstruct t_info tinfo;\n\n");
+		f_print(fout, "\t\tif (!t_getinfo(0, &tinfo) && (tinfo.servtype == T_CLTS))\n");
+	} else {
+		f_print(fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n");
+	}
+	f_print(fout, "\t\t\texit(0);\n");
+	f_print(fout, "\t\tif (size == 0) {\n");
+	if( tirpcflag ) {
+	  f_print(fout, "\t\t\tstruct rlimit rl;\n\n");
+	  f_print(fout, "\t\t\trl.rlim_max = 0;\n");
+	  f_print(fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n");
+	  f_print(fout, "\t\t\tif ((size = rl.rlim_max) == 0)\n");
+	  f_print(fout, "\t\t\t\treturn;\n");
+	} else {
+	  f_print(fout, "\t\t\tsize = getdtablesize();\n");
+	}
+	f_print(fout, "\t\t}\n");
+	f_print(fout, "\t\tfor (i = 0, openfd = 0; i < size && openfd < 2; i++)\n");
+	f_print(fout, "\t\t\tif (FD_ISSET(i, &svc_fdset))\n");
+	f_print(fout, "\t\t\t\topenfd++;\n");
+	f_print(fout, "\t\tif (openfd <= 1)\n");
+	f_print(fout, "\t\t\texit(0);\n");
+	f_print(fout, "\t}\n");
+	f_print(fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+	f_print(fout, "}\n");
+}
+
+/*
+ * Write the most of port monitor support
+ */
+static void
+write_pm_most(char *infile, int netflag)
+{
+	list *l;
+	definition *def;
+	version_list *vp;
+
+	f_print(fout, "\tif (!ioctl(0, I_LOOK, mname) &&\n");
+	f_print(fout, "\t\t(!strcmp(mname, \"sockmod\") ||");
+	f_print(fout, " !strcmp(mname, \"timod\"))) {\n");
+	f_print(fout, "\t\tchar *netid;\n");
+	if (!netflag) {	/* Not included by -n option */
+		f_print(fout, "\t\tstruct netconfig *nconf = NULL;\n");
+		f_print(fout, "\t\tSVCXPRT *%s;\n", TRANSP);
+	}
+	if( timerflag )
+	  f_print(fout, "\t\tint pmclose;\n");
+/* not necessary, defined in /usr/include/stdlib */
+/*	f_print(fout, "\t\textern char *getenv();\n");*/
+	f_print(fout, "\n");
+	f_print(fout, "\t\t_rpcpmstart = 1;\n");
+	if (logflag)
+		open_log_file(infile, "\t\t");
+	f_print(fout, "\t\tif ((netid = getenv(\"NLSPROVIDER\")) == NULL) {\n");
+	sprintf(_errbuf, "cannot get transport name");
+	print_err_message("\t\t\t");
+	f_print(fout, "\t\t} else if ((nconf = getnetconfigent(netid)) == NULL) {\n");
+	sprintf(_errbuf, "cannot get transport info");
+	print_err_message("\t\t\t");
+	f_print(fout, "\t\t}\n");
+	/*
+	 * A kludgy support for inetd services. Inetd only works with
+	 * sockmod, and RPC works only with timod, hence all this jugglery
+	 */
+	f_print(fout, "\t\tif (strcmp(mname, \"sockmod\") == 0) {\n");
+	f_print(fout, "\t\t\tif (ioctl(0, I_POP, 0) || ioctl(0, I_PUSH, \"timod\")) {\n");
+	sprintf(_errbuf, "could not get the right module");
+	print_err_message("\t\t\t\t");
+	f_print(fout, "\t\t\t\texit(1);\n");
+	f_print(fout, "\t\t\t}\n");
+	f_print(fout, "\t\t}\n");
+	if( timerflag )
+	  f_print(fout, "\t\tpmclose = (t_getstate(0) != T_DATAXFER);\n");
+	f_print(fout, "\t\tif ((%s = svc_tli_create(0, nconf, NULL, 0, 0)) == NULL) {\n",
+			TRANSP);
+	sprintf(_errbuf, "cannot create server handle");
+	print_err_message("\t\t\t");
+	f_print(fout, "\t\t\texit(1);\n");
+	f_print(fout, "\t\t}\n");
+	f_print(fout, "\t\tif (nconf)\n");
+	f_print(fout, "\t\t\tfreenetconfigent(nconf);\n");
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			continue;
+		}
+		for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+			f_print(fout,
+				"\t\tif (!svc_reg(%s, %s, %s, ",
+				TRANSP, def->def_name, vp->vers_name);
+			pvname(def->def_name, vp->vers_num);
+			f_print(fout, ", 0)) {\n");
+			(void) sprintf(_errbuf, "unable to register (%s, %s).",
+					def->def_name, vp->vers_name);
+			print_err_message("\t\t\t");
+			f_print(fout, "\t\t\texit(1);\n");
+			f_print(fout, "\t\t}\n");
+		}
+	}
+	if (timerflag) {
+		f_print(fout, "\t\tif (pmclose) {\n");
+		f_print(fout, "\t\t\t(void) signal(SIGALRM, %s closedown);\n",
+				Cflag? "(SIG_PF)" : "(void(*)())" );
+		f_print(fout, "\t\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n");
+		f_print(fout, "\t\t}\n");
+	}
+	f_print(fout, "\t\tsvc_run();\n");
+	f_print(fout, "\t\texit(1);\n");
+	f_print(fout, "\t\t/* NOTREACHED */\n");
+	f_print(fout, "\t}\n");
+}
+
+/*
+ * Support for backgrounding the server if self started.
+ */
+static void
+write_rpc_svc_fg(char *infile, char *sp)
+{
+	f_print(fout, "#ifndef RPC_SVC_FG\n");
+	f_print(fout, "%sint size;\n", sp);
+	if( tirpcflag )
+	        f_print(fout, "%sstruct rlimit rl;\n", sp);
+	if (inetdflag)
+		f_print(fout, "%sint pid, i;\n\n", sp);
+	f_print(fout, "%spid = fork();\n", sp);
+	f_print(fout, "%sif (pid < 0) {\n", sp);
+	f_print(fout, "%s\tperror(\"cannot fork\");\n", sp);
+	f_print(fout, "%s\texit(1);\n", sp);
+	f_print(fout, "%s}\n", sp);
+	f_print(fout, "%sif (pid)\n", sp);
+	f_print(fout, "%s\texit(0);\n", sp);
+	/* get number of file descriptors */
+	if( tirpcflag ) {
+	  f_print(fout, "%srl.rlim_max = 0;\n", sp);
+	  f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
+	  f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
+	  f_print(fout, "%s\texit(1);\n", sp);
+	} else {
+	  f_print(fout, "%ssize = getdtablesize();\n", sp);
+	}
+
+	f_print(fout, "%sfor (i = 0; i < size; i++)\n", sp);
+	f_print(fout, "%s\t(void) close(i);\n", sp);
+	/* Redirect stderr and stdout to console */
+	f_print(fout, "%si = open(\"/dev/console\", 2);\n", sp);
+	f_print(fout, "%s(void) dup2(i, 1);\n", sp);
+	f_print(fout, "%s(void) dup2(i, 2);\n", sp);
+	/* This removes control of the controlling terminal */
+	if( tirpcflag )
+	  f_print(fout, "%ssetsid();\n", sp);
+	else {
+	  f_print(fout, "%si = open(\"/dev/tty\", 2);\n", sp);
+	  f_print(fout, "%sif (i >= 0) {\n", sp);
+	  f_print(fout, "%s\t(void) ioctl(i, TIOCNOTTY, (char *)NULL);\n", sp);;
+	  f_print(fout, "%s\t(void) close(i);\n", sp);
+	  f_print(fout, "%s}\n", sp);
+	}
+	if (!logflag)
+		open_log_file(infile, sp);
+	f_print(fout, "#endif\n");
+	if (logflag)
+		open_log_file(infile, sp);
+}
+
+static void
+open_log_file(char *infile, char *sp)
+{
+	char *s;
+
+	s = strrchr(infile, '.');
+	if (s) 
+		*s = '\0';
+	f_print(fout,"%sopenlog(\"%s\", LOG_PID, LOG_DAEMON);\n", sp, infile);
+	if (s)
+		*s = '.';
+}
+
+
+
+
+/*
+ * write a registration for the given transport for Inetd
+ */
+void
+write_inetd_register(char *transp)
+{
+	list *l;
+	definition *def;
+	version_list *vp;
+	char *sp;
+	int isudp;
+	char tmpbuf[32];
+
+	if (inetdflag)
+		sp = "\t";
+	else
+		sp = "";
+	if (streq(transp, "udp"))
+		isudp = 1;
+	else
+		isudp = 0;
+	f_print(fout, "\n");
+	if (inetdflag) {
+		f_print(fout, "\tif ((_rpcfdtype == 0) || (_rpcfdtype == %s)) {\n",
+				isudp ? "SOCK_DGRAM" : "SOCK_STREAM");
+	}
+	f_print(fout, "%s\t%s = svc%s_create(%s",
+		sp, TRANSP, transp, inetdflag? "sock": "RPC_ANYSOCK");
+	if (!isudp)
+		f_print(fout, ", 0, 0");
+	f_print(fout, ");\n");
+	f_print(fout, "%s\tif (%s == NULL) {\n", sp, TRANSP);
+	(void) sprintf(_errbuf, "cannot create %s service.", transp);
+	(void) sprintf(tmpbuf, "%s\t\t", sp);
+	print_err_message(tmpbuf);
+	f_print(fout, "%s\t\texit(1);\n", sp);
+	f_print(fout, "%s\t}\n", sp);
+
+	if (inetdflag) {
+		f_print(fout, "%s\tif (!_rpcpmstart)\n\t", sp);
+		f_print(fout, "%s\tproto = IPPROTO_%s;\n",
+				sp, isudp ? "UDP": "TCP");
+	}
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind != DEF_PROGRAM) {
+			continue;
+		}
+		for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+			f_print(fout, "%s\tif (!svc_register(%s, %s, %s, ",
+				sp, TRANSP, def->def_name, vp->vers_name);
+			pvname(def->def_name, vp->vers_num);
+			if (inetdflag)
+				f_print(fout, ", proto)) {\n");
+			else 
+				f_print(fout, ", IPPROTO_%s)) {\n",
+					isudp ? "UDP": "TCP");
+			(void) sprintf(_errbuf, "unable to register (%s, %s, %s).",
+					def->def_name, vp->vers_name, transp);
+			print_err_message(tmpbuf);
+			f_print(fout, "%s\t\texit(1);\n", sp);
+			f_print(fout, "%s\t}\n", sp);
+		}
+	}
+	if (inetdflag)
+		f_print(fout, "\t}\n");
+}
diff --git a/rpcgen/rpc_tblout.c b/rpcgen/rpc_tblout.c
new file mode 100644
index 0000000..ae002f7
--- /dev/null
+++ b/rpcgen/rpc_tblout.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_tblout.c 1.4 89/02/22 (C) 1988 SMI";
+#endif
+
+/*
+ * rpc_tblout.c, Dispatch table outputter for the RPC protocol compiler
+ */
+#include <stdio.h>
+#include <string.h>
+#include "rpc_parse.h"
+#include "rpc_util.h"
+#include "rpc_output.h"
+
+static void	write_table(definition *def);
+static void	printit(char *prefix, char *type);
+
+#define TABSIZE		8
+#define TABCOUNT	5
+#define TABSTOP		(TABSIZE*TABCOUNT)
+
+static char tabstr[TABCOUNT+1] = "\t\t\t\t\t";
+
+static char tbl_hdr[] = "struct rpcgen_table %s_table[] = {\n";
+static char tbl_end[] = "};\n";
+
+static char null_entry[] = "\n\t(char *(*)())0,\n\
+ \t(xdrproc_t) xdr_void,\t\t\t0,\n\
+ \t(xdrproc_t) xdr_void,\t\t\t0,\n";
+
+
+static char tbl_nproc[] = "int %s_nproc =\n\tsizeof(%s_table)/sizeof(%s_table[0]);\n\n";
+
+void
+write_tables(void)
+{
+	list *l;
+	definition *def;
+
+	f_print(fout, "\n");
+	for (l = defined; l != NULL; l = l->next) {
+		def = (definition *) l->val;
+		if (def->def_kind == DEF_PROGRAM) {
+			write_table(def);
+		}
+	}
+}
+
+static void
+write_table(definition *def)
+{
+	version_list *vp;
+	proc_list *proc;
+	int current;
+	int expected;
+	char progvers[100];
+	int warning;
+
+	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
+		warning = 0;
+		s_print(progvers, "%s_%s",
+		    locase(def->def_name), vp->vers_num);
+		/* print the table header */
+		f_print(fout, tbl_hdr, progvers);
+
+		if (nullproc(vp->procs)) {
+			expected = 0;
+		} else {
+			expected = 1;
+			f_print(fout, null_entry);
+		}
+		for (proc = vp->procs; proc != NULL; proc = proc->next) {
+			current = atoi(proc->proc_num);
+			if (current != expected++) {
+				f_print(fout,
+			"\n/*\n * WARNING: table out of order\n */\n");
+				if (warning == 0) {
+					f_print(stderr,
+				    "WARNING %s table is out of order\n",
+					    progvers);
+					warning = 1;
+					nonfatalerrors = 1;
+				}
+				expected = current + 1;
+			}
+			f_print(fout, "\n\t(char *(*)())RPCGEN_ACTION(");
+
+			/* routine to invoke */
+			if( Cflag && !newstyle )
+			  pvname_svc(proc->proc_name, vp->vers_num);
+			else {
+			  if( newstyle )
+			    f_print( fout, "_");   /* calls internal func */
+			  pvname(proc->proc_name, vp->vers_num);
+			}
+			f_print(fout, "),\n");
+
+			/* argument info */
+			if( proc->arg_num > 1 )
+			  printit((char*) NULL, proc->args.argname );
+			else  
+			  /* do we have to do something special for newstyle */
+			  printit( proc->args.decls->decl.prefix,
+				  proc->args.decls->decl.type );
+			/* result info */
+			printit(proc->res_prefix, proc->res_type);
+		}
+
+		/* print the table trailer */
+		f_print(fout, tbl_end);
+		f_print(fout, tbl_nproc, progvers, progvers, progvers);
+	}
+}
+
+static void
+printit(char *prefix, char *type)
+{
+	int len;
+	int tabs;
+
+
+ 	len = fprintf(fout, "\txdr_%s,", stringfix(type));
+	/* account for leading tab expansion */
+	len += TABSIZE - 1;
+	/* round up to tabs required */
+	tabs = (TABSTOP - len + TABSIZE - 1)/TABSIZE;
+	f_print(fout, "%s", &tabstr[TABCOUNT-tabs]);
+
+	if (streq(type, "void")) {
+		f_print(fout, "0");
+	} else {
+		f_print(fout, "sizeof ( ");
+		/* XXX: should "follow" be 1 ??? */
+		ptype(prefix, type, 0);
+		f_print(fout, ")");
+	}
+	f_print(fout, ",\n");
+}
diff --git a/rpcgen/rpc_util.c b/rpcgen/rpc_util.c
new file mode 100644
index 0000000..b67be57
--- /dev/null
+++ b/rpcgen/rpc_util.c
@@ -0,0 +1,479 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+#if 0
+static char sccsid[] = "@(#)rpc_util.c 1.11 89/02/22 (C) 1987 SMI";
+#endif
+
+/*
+ * rpc_util.c, Utility routines for the RPC protocol compiler 
+ */
+#include <stdio.h>
+#include <memory.h>
+#include <ctype.h>
+#include <unistd.h>
+#include "rpc_scan.h"
+#include "rpc_parse.h"
+#include "rpc_util.h"
+
+static void	printwhere(void);
+
+
+#define ARGEXT "argument"
+
+char curline[MAXLINESIZE];	/* current read line */
+char *where = curline;		/* current point in line */
+int linenum = 0;		/* current line number */
+
+char *infilename;		/* input filename */
+
+#define NFILES 7
+char *outfiles[NFILES];		/* output file names */
+int nfiles;
+
+FILE *fout;			/* file pointer of current output */
+FILE *fin;			/* file pointer of current input */
+
+list *defined;			/* list of defined things */
+
+/*
+ * Reinitialize the world 
+ */
+void
+reinitialize(void)
+{
+	memset(curline, 0, MAXLINESIZE);
+	where = curline;
+	linenum = 0;
+	defined = NULL;
+}
+
+/*
+ * string equality 
+ */
+int
+streq(char *a, char *b)
+{
+	return (strcmp(a, b) == 0);
+}
+
+/*
+ * find a value in a list 
+ */
+definition *
+findval(list *lst, char *val, int (*cmp)(definition *, char *))
+{
+         
+	for (; lst != NULL; lst = lst->next) {
+		if ((*cmp) (lst->val, val)) {
+			return (lst->val);
+		}
+	}
+	return (NULL);
+}
+
+/*
+ * store a value in a list 
+ */
+void
+storeval(lstp, val)
+	list **lstp;
+	definition *val;
+{
+	list **l;
+	list *lst;
+
+	
+	for (l = lstp; *l != NULL; l = (list **) & (*l)->next);
+	lst = ALLOC(list);
+	lst->val = val;
+	lst->next = NULL;
+	*l = lst;
+}
+
+static int
+findit(definition *def, char *type)
+{
+	return (streq(def->def_name, type));
+}
+
+static char *
+fixit(char *type, char *orig)
+{
+	definition *def;
+
+	def = (definition *) FINDVAL(defined, type, findit);
+	if (def == NULL || def->def_kind != DEF_TYPEDEF) {
+		return (orig);
+	}
+	switch (def->def.ty.rel) {
+	case REL_VECTOR:
+		return (def->def.ty.old_type);
+	case REL_ALIAS:
+		return (fixit(def->def.ty.old_type, orig));
+	default:
+		return (orig);
+	}
+}
+
+char *
+fixtype(char *type)
+{
+	return (fixit(type, type));
+}
+
+char *
+stringfix(char *type)
+{
+	if (streq(type, "string")) {
+		return ("wrapstring");
+	} else {
+		return (type);
+	}
+}
+
+void
+ptype(char *prefix, char *type, int follow)
+{
+	if (prefix != NULL) {
+		if (streq(prefix, "enum")) {
+			f_print(fout, "enum ");
+		} else {
+			f_print(fout, "struct ");
+		}
+	}
+	if (streq(type, "bool")) {
+		f_print(fout, "bool_t ");
+	} else if (streq(type, "string")) {
+		f_print(fout, "char *");
+	} else {
+		f_print(fout, "%s ", follow ? fixtype(type) : type);
+	}
+}
+
+static int
+typedefed(definition *def, char *type)
+{
+	if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) {
+		return (0);
+	} else {
+		return (streq(def->def_name, type));
+	}
+}
+
+int
+isvectordef(char *type, relation rel)
+{
+	definition *def;
+
+	for (;;) {
+		switch (rel) {
+		case REL_VECTOR:
+			return (!streq(type, "string"));
+		case REL_ARRAY:
+			return (0);
+		case REL_POINTER:
+			return (0);
+		case REL_ALIAS:
+			def = (definition *) FINDVAL(defined, type, typedefed);
+			if (def == NULL) {
+				return (0);
+			}
+			type = def->def.ty.old_type;
+			rel = def->def.ty.rel;
+		}
+	}
+}
+
+char *
+locase(char *str)
+{
+	char c;
+	static char buf[100];
+	char *p = buf;
+
+	while ((c = *str++) != '\0') {
+		*p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
+	}
+	*p = 0;
+	return (buf);
+}
+
+void
+pvname_svc(char *pname, char *vnum)
+{
+	f_print(fout, "%s_%s_svc", locase(pname), vnum);
+}
+
+void
+pvname(char *pname, char *vnum)
+{
+	f_print(fout, "%s_%s", locase(pname), vnum);
+}
+
+/*
+ * print a useful (?) error message, and then die 
+ */
+void
+error(char *msg)
+{
+	printwhere();
+	f_print(stderr, "%s, line %d: ", infilename, linenum);
+	f_print(stderr, "%s\n", msg);
+	crash();
+}
+
+/*
+ * Something went wrong, unlink any files that we may have created and then
+ * die. 
+ */
+void
+crash(void)
+{
+	int i;
+
+	for (i = 0; i < nfiles; i++) {
+		(void) unlink(outfiles[i]);
+	}
+	exit(1);
+}
+
+void
+record_open(char *file)
+{
+	if (nfiles < NFILES) {
+		outfiles[nfiles++] = file;
+	} else {
+		f_print(stderr, "too many files!\n");
+		crash();
+	}
+}
+
+static char expectbuf[100];
+static char *toktostr();
+
+/*
+ * error, token encountered was not the expected one 
+ */
+void
+expected1(exp1)
+	tok_kind exp1;
+{
+	s_print(expectbuf, "expected '%s'",
+		toktostr(exp1));
+	error(expectbuf);
+}
+
+/*
+ * error, token encountered was not one of two expected ones 
+ */
+void
+expected2(exp1, exp2)
+	tok_kind exp1, exp2;
+{
+	s_print(expectbuf, "expected '%s' or '%s'",
+		toktostr(exp1),
+		toktostr(exp2));
+	error(expectbuf);
+}
+
+/*
+ * error, token encountered was not one of 3 expected ones 
+ */
+void
+expected3(exp1, exp2, exp3)
+	tok_kind exp1, exp2, exp3;
+{
+	s_print(expectbuf, "expected '%s', '%s' or '%s'",
+		toktostr(exp1),
+		toktostr(exp2),
+		toktostr(exp3));
+	error(expectbuf);
+}
+
+void
+tabify(f, tab)
+	FILE *f;
+	int tab;
+{
+	while (tab--) {
+		(void) fputc('\t', f);
+	}
+}
+
+
+static token tokstrings[] = {
+			     {TOK_IDENT, "identifier"},
+			     {TOK_CONST, "const"},
+			     {TOK_RPAREN, ")"},
+			     {TOK_LPAREN, "("},
+			     {TOK_RBRACE, "}"},
+			     {TOK_LBRACE, "{"},
+			     {TOK_LBRACKET, "["},
+			     {TOK_RBRACKET, "]"},
+			     {TOK_STAR, "*"},
+			     {TOK_COMMA, ","},
+			     {TOK_EQUAL, "="},
+			     {TOK_COLON, ":"},
+			     {TOK_SEMICOLON, ";"},
+			     {TOK_UNION, "union"},
+			     {TOK_STRUCT, "struct"},
+			     {TOK_SWITCH, "switch"},
+			     {TOK_CASE, "case"},
+			     {TOK_DEFAULT, "default"},
+			     {TOK_ENUM, "enum"},
+			     {TOK_TYPEDEF, "typedef"},
+			     {TOK_INT, "int"},
+			     {TOK_SHORT, "short"},
+			     {TOK_INT32, "int32"},
+			     {TOK_UNSIGNED, "unsigned"},
+			     {TOK_DOUBLE, "double"},
+			     {TOK_FLOAT, "float"},
+			     {TOK_CHAR, "char"},
+			     {TOK_STRING, "string"},
+			     {TOK_OPAQUE, "opaque"},
+			     {TOK_BOOL, "bool"},
+			     {TOK_VOID, "void"},
+			     {TOK_PROGRAM, "program"},
+			     {TOK_VERSION, "version"},
+			     {TOK_EOF, "??????"}
+};
+
+static char *
+toktostr(kind)
+	tok_kind kind;
+{
+	token *sp;
+
+	for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++);
+	return (sp->str);
+}
+
+static void
+printbuf(void)
+{
+	char c;
+	int i;
+	int cnt;
+
+#	define TABSIZE 4
+
+	for (i = 0; (c = curline[i]) != '\0'; i++) {
+		if (c == '\t') {
+			cnt = 8 - (i % TABSIZE);
+			c = ' ';
+		} else {
+			cnt = 1;
+		}
+		while (cnt--) {
+			(void) fputc(c, stderr);
+		}
+	}
+}
+
+static void
+printwhere(void)
+{
+	int i;
+	char c;
+	int cnt;
+
+	printbuf();
+	for (i = 0; i < where - curline; i++) {
+		c = curline[i];
+		if (c == '\t') {
+			cnt = 8 - (i % TABSIZE);
+		} else {
+			cnt = 1;
+		}
+		while (cnt--) {
+			(void) fputc('^', stderr);
+		}
+	}
+	(void) fputc('\n', stderr);
+}
+
+char * 
+make_argname(char *pname, char *vname) 
+{
+	char *name;
+	
+	name = malloc(strlen(pname) + strlen(vname) + strlen(ARGEXT) + 3);
+	if (!name) {
+		fprintf(stderr, "failed in malloc");
+		exit(1);
+	}
+	sprintf(name, "%s_%s_%s", locase(pname), vname, ARGEXT);
+	return(name);
+}
+
+bas_type *typ_list_h;
+bas_type *typ_list_t;
+
+void
+add_type(int len, char *type)
+{
+	bas_type       *ptr;
+
+
+	if ((ptr = (bas_type *) malloc(sizeof(bas_type))) == (bas_type *) NULL) {
+		fprintf(stderr, "failed in malloc");
+		exit(1);
+	}
+	ptr->name = type;
+	ptr->length = len;
+	ptr->next = NULL;
+	if (typ_list_t == NULL) {
+
+		typ_list_t = ptr;
+		typ_list_h = ptr;
+	} else {
+
+		typ_list_t->next = ptr;
+		typ_list_t = ptr;
+	}
+}
+
+
+bas_type *
+find_type(char *type)
+{
+	bas_type       *ptr;
+
+	ptr = typ_list_h;
+
+
+	while (ptr != NULL) {
+		if (strcmp(ptr->name, type) == 0)
+			return (ptr);
+		else
+			ptr = ptr->next;
+	};
+	return (NULL);
+}
+
diff --git a/rpcgen/rpc_util.h b/rpcgen/rpc_util.h
new file mode 100644
index 0000000..fa115be
--- /dev/null
+++ b/rpcgen/rpc_util.h
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2009, Sun Microsystems, Inc.
+ * 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 Sun Microsystems, Inc. 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 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 HOLDER 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.
+ */
+
+/*      @(#)rpc_util.h  1.5  90/08/29  (C) 1987 SMI   */
+
+/*
+ * rpc_util.h, Useful definitions for the RPC protocol compiler 
+ */
+
+#include <stdlib.h>
+
+#define alloc(size)		malloc((unsigned)(size))
+#define ALLOC(object)   (object *) malloc(sizeof(object))
+
+#define s_print	(void) sprintf
+#define f_print (void) fprintf
+
+struct list {
+	definition *val;
+	struct list *next;
+};
+typedef struct list list;
+
+#define PUT 1
+#define GET 2
+
+/*
+ * Global variables 
+ */
+#define MAXLINESIZE 1024
+extern char curline[MAXLINESIZE];
+extern char *where;
+extern int linenum;
+
+extern char *infilename;
+extern FILE *fout;
+extern FILE *fin;
+
+extern list *defined;
+
+
+extern bas_type *typ_list_h;
+extern bas_type *typ_list_t;
+
+/*
+ * All the option flags
+ */
+extern int inetdflag;
+extern int pmflag;   
+extern int tblflag;
+extern int logflag;
+extern int newstyle;
+extern int Cflag;	/* C++ flag */
+extern int tirpcflag;	/* flag for generating tirpc code */
+extern int Inline;	/* if this is 0, then do not generate inline code */
+
+/*
+ * Other flags related with inetd jumpstart.
+ */
+extern int indefinitewait;
+extern int exitnow;
+extern int timerflag;
+
+extern int nonfatalerrors;
+
+/*
+ * rpc_util routines 
+ */
+void storeval();
+
+#define STOREVAL(list,item)	\
+	storeval(list,item)
+
+definition *findval();
+
+#define FINDVAL(list,item,finder) \
+	findval(list, item, finder)
+
+
+/*
+ * rpc_cout routines
+ */
+void            cprint(void);
+void            emit(definition *);
+
+/*
+ * rpc_hout routines
+ */
+void            print_datadef(definition *);
+void            print_funcdef(definition *);
+
+/*
+ * rpc_svcout routines
+ */
+void            write_most(char *, int, int);
+void            write_register(void);
+void		write_netid_register(char *);
+void		write_nettype_register(char *);
+void		write_inetd_register(char *);
+void            write_rest(void);
+void            write_programs(char *);
+void            write_svc_aux(int);
+
+/*
+ * rpc_clntout routines
+ */
+void            write_stubs(void);
+void		printarglist(proc_list *, char *, char *);
+
+/*
+ * rpc_tblout routines
+ */
+void            write_tables(void);
+
+/*
+ * rpc_util
+ */
+void            pvname_svc(char *, char *);
+void            pvname(char *, char *);
+void            ptype(char *, char *, int);
+char *		make_argname(char *, char *);
+void		add_type(int, char *);
+void		reinitialize(void);
+void		crash(void);
+void		error(char *);
+char           *fixtype(char *);
+char           *stringfix(char *);
+char           *locase(char *);
+int             isvectordef(char *, relation);
+int             streq(char *, char *);
+void            tabify(FILE *, int);
+void            record_open(char *);
+bas_type       *find_type(char *type);
+
+/*
+ * rpc_sample
+ */
+void		write_sample_svc(definition *);
+int		write_sample_clnt(definition *);
+void		write_sample_clnt_main(void);
+void		add_sample_msg(void);
diff --git a/rpcgen/rpcgen.1 b/rpcgen/rpcgen.1
new file mode 100644
index 0000000..89df7ed
--- /dev/null
+++ b/rpcgen/rpcgen.1
@@ -0,0 +1,521 @@
+.\" @(#)rpcgen.1 1.35 93/06/02 SMI
+.\" $FreeBSD: src/usr.bin/rpcgen/rpcgen.1,v 1.12.2.4 2002/06/21 15:28:50 charnier Exp $
+.\" Copyright 1985-1993 Sun Microsystems, Inc.
+.Dd March 28, 1993
+.Dt RPCGEN 1
+.Os
+.Sh NAME
+.Nm rpcgen
+.Nd an RPC protocol compiler
+.Sh SYNOPSIS
+.Nm
+.Ar infile
+.Nm
+.Op Fl a
+.Op Fl b
+.Op Fl C
+.Oo
+.Fl D Ns Ar name Ns Op Ar =value
+.Oc
+.Op Fl i Ar size
+.Op Fl I Op Fl K Ar seconds
+.Op Fl L
+.Op Fl M
+.Op Fl N
+.Op Fl T
+.Op Fl Y Ar pathname
+.Ar infile
+.Nm
+.Oo
+.Fl c |
+.Fl h |
+.Fl l |
+.Fl m |
+.Fl t |
+.Fl \&Sc |
+.Fl \&Ss |
+.Fl \&Sm
+.Oc
+.Op Fl o Ar outfile
+.Op Ar infile
+.Nm
+.Op Fl s Ar nettype
+.Op Fl o Ar outfile
+.Op Ar infile
+.Nm
+.Op Fl n Ar netid
+.Op Fl o Ar outfile
+.Op Ar infile
+.\" .SH AVAILABILITY
+.\" .LP
+.\" SUNWcsu
+.Sh DESCRIPTION
+The
+.Nm
+utility is a tool that generates C code to implement an
+.Tn RPC
+protocol.
+The input to
+.Nm
+is a language similar to C known as
+.Tn RPC
+Language (Remote Procedure Call Language).
+.Pp
+The
+.Nm
+utility is normally used as in the first synopsis where
+it takes an input file and generates three output files.
+If the
+.Ar infile
+is named
+.Pa proto.x ,
+then
+.Nm
+generates a header in
+.Pa proto.h ,
+XDR routines in
+.Pa proto_xdr.c ,
+server-side stubs in
+.Pa proto_svc.c ,
+and client-side stubs in
+.Pa proto_clnt.c .
+With the
+.Fl T
+option,
+it also generates the
+.Tn RPC
+dispatch table in
+.Pa proto_tbl.i .
+.Pp
+The
+.Nm
+utility can also generate sample client and server files
+that can be customized to suit a particular application.
+The
+.Fl \&Sc ,
+.Fl \&Ss
+and
+.Fl \&Sm
+options generate sample client, server and makefile, respectively.
+The
+.Fl a
+option generates all files, including sample files.
+If the
+.Ar infile
+is
+.Pa proto.x ,
+then the client side sample file is written to
+.Pa proto_client.c ,
+the server side sample file to
+.Pa proto_server.c
+and the sample makefile to
+.Pa makefile.proto .
+.Pp
+The server created can be started both by the port monitors
+(for example,
+.Xr inetd 8 )
+or by itself.
+When it is started by a port monitor,
+it creates servers only for the transport for which
+the file descriptor
+.Em 0
+was passed.
+The name of the transport must be specified
+by setting up the environment variable
+.Ev PM_TRANSPORT .
+When the server generated by
+.Nm
+is executed,
+it creates server handles for all the transports
+specified in
+.Ev NETPATH
+environment variable,
+or if it is unset,
+it creates server handles for all the visible transports from
+.Pa /etc/netconfig
+file.
+Note:
+the transports are chosen at run time and not at compile time.
+When the server is self-started,
+it backgrounds itself by default.
+A special define symbol
+.Em RPC_SVC_FG
+can be used to run the server process in foreground.
+.Pp
+The second synopsis provides special features which allow
+for the creation of more sophisticated
+.Tn RPC
+servers.
+These features include support for user provided
+.Em #defines
+and
+.Tn RPC
+dispatch tables.
+The entries in the
+.Tn RPC
+dispatch table contain:
+.Bl -bullet -offset indent -compact
+.It
+pointers to the service routine corresponding to that procedure,
+.It
+a pointer to the input and output arguments,
+.It
+the size of these routines.
+.El
+A server can use the dispatch table to check authorization
+and then to execute the service routine;
+a client library may use it to deal with the details of storage
+management and XDR data conversion.
+.Pp
+The other three synopses shown above are used when
+one does not want to generate all the output files,
+but only a particular one.
+See the
+.Sx EXAMPLES
+section below for examples of
+.Nm
+usage.
+When
+.Nm
+is executed with the
+.Fl s
+option,
+it creates servers for that particular class of transports.
+When
+executed with the
+.Fl n
+option,
+it creates a server for the transport specified by
+.Ar netid .
+If
+.Ar infile
+is not specified,
+.Nm
+accepts the standard input.
+.Pp
+The C preprocessor,
+.Em cc -E
+is run on the input file before it is actually interpreted by
+.Nm .
+For each type of output file,
+.Nm
+defines a special preprocessor symbol for use by the
+.Nm
+programmer:
+.Bl -tag -width indent
+.It RPC_HDR
+defined when compiling into headers
+.It RPC_XDR
+defined when compiling into XDR routines
+.It RPC_SVC
+defined when compiling into server-side stubs
+.It RPC_CLNT
+defined when compiling into client-side stubs
+.It RPC_TBL
+defined when compiling into RPC dispatch tables
+.El
+.Pp
+Any line beginning with
+.Dq %
+is passed directly into the output file,
+uninterpreted by
+.Nm .
+To specify the path name of the C preprocessor use
+.Fl Y
+flag.
+.Pp
+For every data type referred to in
+.Ar infile ,
+.Nm
+assumes that there exists a
+routine with the string
+.Em xdr_
+prepended to the name of the data type.
+If this routine does not exist in the
+.Tn RPC/XDR
+library, it must be provided.
+Providing an undefined data type
+allows customization of
+.Xr xdr 3
+routines.
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl a
+Generate all files, including sample files.
+.It Fl b
+Backward compatibility mode.
+Generate transport specific
+.Tn RPC
+code for older versions
+of the operating system.
+.Pp
+Note: in
+.Fx ,
+this compatibility flag is turned on by
+default since
+.Fx
+supports only the older
+.Tn ONC RPC
+library.
+.It Fl c
+Compile into
+.Tn XDR
+routines.
+.It Fl C
+Generate header and stub files which can be used with
+.Tn ANSI
+C compilers.  Headers generated with this flag can also be
+used with C++ programs.
+.It Fl D Ns Ar name
+.It Fl D Ns Ar name=value
+.\".It Fl D Ns Ar name Ns Op Ar =value
+Define a symbol
+.Ar name .
+Equivalent to the
+.Em #define
+directive in the source.
+If no
+.Ar value
+is given,
+.Ar value
+is defined as
+.Em 1 .
+This option may be specified more than once.
+.It Fl h
+Compile into C data-definitions (a header).
+.Fl T
+option can be used in conjunction to produce a
+header which supports
+.Tn RPC
+dispatch tables.
+.It Fl i Ar size
+Size at which to start generating inline code.
+This option is useful for optimization.
+The default size is 5.
+.Pp
+Note: in order to provide backwards compatibility with the older
+.Nm
+on the
+.Fx
+platform, the default is actually 0 (which means
+that inline code generation is disabled by default). You must specify
+a non-zero value explicitly to override this default.
+.It Fl I
+Compile support for
+.Xr inetd 8
+in the server side stubs.
+Such servers can be self-started or can be started by
+.Nm inetd .
+When the server is self-started, it backgrounds itself by default.
+A special define symbol
+.Em RPC_SVC_FG
+can be used to run the
+server process in foreground, or the user may simply compile without
+the
+.Fl I
+option.
+.Pp
+If there are no pending client requests, the
+.Nm inetd
+servers exit after 120 seconds (default).
+The default can be changed with the
+.Fl K
+option.
+All the error messages for
+.Nm inetd
+servers
+are always logged with
+.Xr syslog 3 .
+.\" .IP
+.\" Note:
+.\" this option is supported for backward compatibility only.
+.\" By default,
+.\" .B rpcgen
+.\" generates servers that can be invoked through portmonitors.
+.Pp
+.It Fl K Ar seconds
+By default, services created using
+.Nm
+and invoked through
+port monitors wait 120 seconds
+after servicing a request before exiting.
+That interval can be changed using the
+.Fl K
+flag.
+To create a server that exits immediately upon servicing a request,
+use
+.Fl K Ar 0 .
+To create a server that never exits, the appropriate argument is
+.Fl k Ar -1 .
+.Pp
+When monitoring for a server,
+some portmonitors
+.Em always
+spawn a new process in response to a service request.
+If it is known that a server will be used with such a monitor, the
+server should exit immediately on completion.
+For such servers,
+.Nm
+should be used with
+.Fl K Ar 0 .
+.It Fl l
+Compile into client-side stubs.
+.It Fl L
+When the servers are started in foreground, use
+.Xr syslog 3
+to log the server errors instead of printing them on the standard
+error.
+.It Fl m
+Compile into server-side stubs,
+but do not generate a
+.Qq main
+routine.
+This option is useful for doing callback-routines
+and for users who need to write their own
+.Qq main
+routine to do initialization.
+.It Fl M
+Generate multithread-safe stubs for passing arguments and results between
+rpcgen generated code and user written code.
+This option is useful
+for users who want to use threads in their code.
+However, the
+.Xr rpc_svc_calls 3
+functions are not yet MT-safe, which means that rpcgen generated server-side
+code will not be MT-safe.
+.It Fl N
+This option allows procedures to have multiple arguments.
+It also uses the style of parameter passing that closely resembles C.
+So, when passing an argument to a remote procedure, you do not have to
+pass a pointer to the argument, but can pass the argument itself.
+This behavior is different from the old style of
+.Nm
+generated code.
+To maintain backward compatibility,
+this option is not the default.
+.It Fl n Ar netid
+Compile into server-side stubs for the transport
+specified by
+.Ar netid .
+There should be an entry for
+.Ar netid
+in the
+netconfig database.
+This option may be specified more than once,
+so as to compile a server that serves multiple transports.
+.It Fl o Ar outfile
+Specify the name of the output file.
+If none is specified,
+standard output is used
+(
+.Fl c ,
+.Fl h ,
+.Fl l ,
+.Fl m ,
+.Fl n ,
+.Fl s ,
+.Fl \&Sc ,
+.Fl \&Sm ,
+.Fl \&Ss ,
+and
+.Fl t
+modes only).
+.It Fl s Ar nettype
+Compile into server-side stubs for all the
+transports belonging to the class
+.Ar nettype .
+The supported classes are
+.Em netpath ,
+.Em visible ,
+.Em circuit_n ,
+.Em circuit_v ,
+.Em datagram_n ,
+.Em datagram_v ,
+.Em tcp ,
+and
+.Em udp
+(see
+.Xr rpc 3
+for the meanings associated with these classes).
+This option may be specified more than once.
+Note:
+the transports are chosen at run time and not at compile time.
+.It Fl \&Sc
+Generate sample client code that uses remote procedure calls.
+.It Fl \&Sm
+Generate a sample
+.Pa Makefile
+which can be used for compiling the application.
+.It Fl \&Ss
+Generate sample server code that uses remote procedure calls.
+.It Fl t
+Compile into
+.Tn RPC
+dispatch table.
+.It Fl T
+Generate the code to support
+.Tn RPC
+dispatch tables.
+.Pp
+The options
+.Fl c ,
+.Fl h ,
+.Fl l ,
+.Fl m ,
+.Fl s ,
+.Fl \&Sc ,
+.Fl \&Sm ,
+.Fl \&Ss ,
+and
+.Fl t
+are used exclusively to generate a particular type of file,
+while the options
+.Fl D
+and
+.Fl T
+are global and can be used with the other options.
+.It Fl Y Ar pathname
+Give the name of the directory where
+.Nm
+will start looking for the C-preprocessor.
+.El
+.Sh EXAMPLES
+The following example:
+.Dl example% rpcgen -T prot.x
+.Pp
+generates all the five files:
+.Pa prot.h ,
+.Pa prot_clnt.c ,
+.Pa prot_svc.c ,
+.Pa prot_xdr.c
+and
+.Pa prot_tbl.i .
+.Pp
+The following example sends the C data-definitions (header)
+to the standard output.
+.Dl example% rpcgen -h prot.x
+.Pp
+To send the test version of the
+.Fl D Ns Ar TEST ,
+server side stubs for
+all the transport belonging to the class
+.Ar datagram_n
+to standard output, use:
+.Dl example% rpcgen -s datagram_n -DTEST prot.x
+.Pp
+To create the server side stubs for the transport indicated
+by
+.Ar netid
+tcp,
+use:
+.Dl example% rpcgen -n tcp -o prot_svc.c prot.x
+.Sh SEE ALSO
+.Xr cc 1 ,
+.Xr rpc 3 ,
+.Xr syslog 3 ,
+.Xr inetd 8
+.\" .BR rpc_svc_calls (3)
+.Rs
+.%T The rpcgen chapter in the NETP manual
+.Re
-- 
1.9.1